diff --git a/Makefile b/Makefile index 5c4cdd549c..98aa5b1b47 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,12 @@ COMPARE ?= 1 NON_MATCHING ?= 0 # If ORIG_COMPILER is 1, compile with QEMU_IRIX and the original compiler ORIG_COMPILER ?= 0 +# if WERROR is 1, pass -Werror to CC_CHECK, so warnings would be treated as errors +WERROR ?= 0 # Keep .mdebug section in build KEEP_MDEBUG ?= 0 +# Disassembles all asm from the ROM instead of skipping files which are entirely in C +FULL_DISASM ?= 0 ifeq ($(NON_MATCHING),1) CFLAGS := -DNON_MATCHING @@ -17,6 +21,10 @@ ifeq ($(NON_MATCHING),1) COMPARE := 0 endif +ifneq ($(FULL_DISASM), 0) + DISASM_FLAGS += --full +endif + PROJECT_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) MAKE = make @@ -104,6 +112,10 @@ ifneq ($(NON_MATCHING),1) COMPFLAGS += --matching endif +ifneq ($(WERROR), 0) + CC_CHECK += -Werror +endif + #### Files #### # ROM image @@ -246,7 +258,7 @@ setup: ## Assembly generation disasm: $(RM) -rf asm data - python3 tools/disasm/disasm.py -j $(N_THREADS) + python3 tools/disasm/disasm.py -j $(N_THREADS) $(DISASM_FLAGS) diff-init: uncompressed $(RM) -rf expected/ @@ -284,8 +296,8 @@ build/data/%.o: data/%.s $(AS) $(ASFLAGS) $< -o $@ build/src/overlays/%.o: src/overlays/%.c - $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< $(CC_CHECK) $< + $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< @$(OBJDUMP) -d $@ > $(@:.o=.s) # TODO: `() || true` is currently necessary to suppress `Error 1 (ignored)` make warnings caused by `test`, but this will go away if # the following is moved to a separate rule that is only run once when all the required objects have been compiled. @@ -294,21 +306,21 @@ build/src/overlays/%.o: src/overlays/%.c $(RM_MDEBUG) build/src/%.o: src/%.c - $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< $(CC_CHECK) $< + $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< @$(OBJDUMP) -d $@ > $(@:.o=.s) $(RM_MDEBUG) build/src/libultra/libc/ll.o: src/libultra/libc/ll.c - $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< $(CC_CHECK) $< + $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ @$(OBJDUMP) -d $@ > $(@:.o=.s) $(RM_MDEBUG) build/src/libultra/libc/llcvt.o: src/libultra/libc/llcvt.c - $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< $(CC_CHECK) $< + $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ @$(OBJDUMP) -d $@ > $(@:.o=.s) $(RM_MDEBUG) diff --git a/assets/xml/objects/gameplay_dangeon_keep.xml b/assets/xml/objects/gameplay_dangeon_keep.xml index 19fabad2b3..8237f63804 100644 --- a/assets/xml/objects/gameplay_dangeon_keep.xml +++ b/assets/xml/objects/gameplay_dangeon_keep.xml @@ -1,7 +1,7 @@  - - + + diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index f3ed5c8984..5e5b9b4f5c 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -766,59 +766,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -863,7 +866,7 @@ - + @@ -939,36 +942,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1295,13 +1301,13 @@ - + - + - + - + @@ -1316,7 +1322,7 @@ - + diff --git a/assets/xml/objects/object_cs.xml b/assets/xml/objects/object_cs.xml index 7fff51fd8f..65cff1d46c 100644 --- a/assets/xml/objects/object_cs.xml +++ b/assets/xml/objects/object_cs.xml @@ -49,7 +49,7 @@ - + diff --git a/assets/xml/objects/object_fish.xml b/assets/xml/objects/object_fish.xml index 3d02127c6d..c0cbd54c77 100644 --- a/assets/xml/objects/object_fish.xml +++ b/assets/xml/objects/object_fish.xml @@ -1,6 +1,6 @@  - + @@ -35,29 +35,29 @@ - + - + - - + + - - + + - - + + - - - + + + - - + + @@ -73,12 +73,12 @@ - - - + + + - - + + @@ -86,21 +86,23 @@ - + + + - - + + - - + + - + @@ -129,29 +131,32 @@ - - - - + + + + + + + - - + + - - - - + + + + - - - - + + + + - - + + diff --git a/assets/xml/objects/object_giant.xml b/assets/xml/objects/object_giant.xml index 9e1815528e..edaeee0398 100644 --- a/assets/xml/objects/object_giant.xml +++ b/assets/xml/objects/object_giant.xml @@ -1,63 +1,90 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kibako.xml b/assets/xml/objects/object_kibako.xml index 138894b0fb..43276080a0 100644 --- a/assets/xml/objects/object_kibako.xml +++ b/assets/xml/objects/object_kibako.xml @@ -1,8 +1,9 @@  + - - - - + + + + diff --git a/assets/xml/objects/object_kibako2.xml b/assets/xml/objects/object_kibako2.xml index 098a5318d0..4b6ce5ac72 100644 --- a/assets/xml/objects/object_kibako2.xml +++ b/assets/xml/objects/object_kibako2.xml @@ -1,13 +1,14 @@  + - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_oF1d_map.xml b/assets/xml/objects/object_oF1d_map.xml index 78d5fbc9c4..9557dc73e3 100644 --- a/assets/xml/objects/object_oF1d_map.xml +++ b/assets/xml/objects/object_oF1d_map.xml @@ -7,9 +7,9 @@ - + - + diff --git a/assets/xml/objects/object_ssh.xml b/assets/xml/objects/object_ssh.xml index e4072d79e4..a95597ae48 100644 --- a/assets/xml/objects/object_ssh.xml +++ b/assets/xml/objects/object_ssh.xml @@ -11,9 +11,11 @@ - + - + + + diff --git a/assets/xml/objects/object_stream.xml b/assets/xml/objects/object_stream.xml index ac73120799..2e49af9163 100644 --- a/assets/xml/objects/object_stream.xml +++ b/assets/xml/objects/object_stream.xml @@ -1,6 +1,7 @@  + - - + + diff --git a/assets/xml/objects/object_wiz.xml b/assets/xml/objects/object_wiz.xml index 6a27c2ba9e..7f41954cf2 100644 --- a/assets/xml/objects/object_wiz.xml +++ b/assets/xml/objects/object_wiz.xml @@ -3,7 +3,7 @@ - + diff --git a/assets/xml/overlays/ovl_En_Bomjima.xml b/assets/xml/overlays/ovl_En_Bomjima.xml new file mode 100644 index 0000000000..5aada48876 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Bomjima.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/xml/overlays/ovl_En_Mm2.xml b/assets/xml/overlays/ovl_En_Mm2.xml new file mode 100644 index 0000000000..5d0be627f7 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Mm2.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/docs/tutorial/advanced_control_flow.md b/docs/tutorial/advanced_control_flow.md index 953e3e44d7..3420fc5977 100644 --- a/docs/tutorial/advanced_control_flow.md +++ b/docs/tutorial/advanced_control_flow.md @@ -63,7 +63,7 @@ void EnMs_Init(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06003DC0, &D_060005EC, this->jointTable, this->morphTable, 9); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &D_80952BA0); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 35.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); Actor_SetScale(&this->actor, 0.015f); this->actor.colChkInfo.mass = 0xFF; this->actionFunc = func_80952734; @@ -87,7 +87,7 @@ void func_80952734(EnMs* this, GlobalContext* globalCtx) { this->actor.textId = 0x932; } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { this->actionFunc = func_809527F8; return; } @@ -107,12 +107,12 @@ void func_809529AC(EnMs *this, GlobalContext *globalCtx) { func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); this->actionFunc = func_80952A1C; } else { - func_800B8A1C(&this->actor, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } void func_80952A1C(EnMs *this, GlobalContext *globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80151938(globalCtx, 0x936U); this->actionFunc = func_809527F8; } else { @@ -124,7 +124,7 @@ void EnMs_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnMs* this = THIS; - Actor_SetHeight(&this->actor, 20.0f); + Actor_SetFocus(&this->actor, 20.0f); this->actor.targetArrowOffset = 500.0f; Actor_SetScale(&this->actor, 0.015f); SkelAnime_Update(&this->skelAnime); @@ -156,7 +156,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { u8 temp_v0; u8 temp_v0_2; - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 != 4) { if (temp_v0 != 5) { if ((temp_v0 == 6) && (func_80147624(globalCtx) != 0)) { @@ -168,7 +168,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { } if (func_80147624(globalCtx) != 0) { func_801477B4(globalCtx); - func_800B8A1C((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; } @@ -198,7 +198,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { return; } func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; } @@ -208,7 +208,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { which is long, messy, and contains some rather nasty-looking control flow, including horrors like ```C - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 != 4) { if (temp_v0 != 5) { if ((temp_v0 == 6) && (func_80147624(globalCtx) != 0)) { @@ -238,7 +238,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { u8 temp_v0; u8 temp_v0_2; - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 4) { goto block_7; } @@ -258,7 +258,7 @@ block_5: goto block_17; } func_801477B4(globalCtx); - func_800B8A1C((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: @@ -290,7 +290,7 @@ block_13: return; block_15: func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; return; @@ -340,7 +340,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { u8 temp_v0; u8 temp_v0_2; - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 4) { goto block_7; } @@ -360,7 +360,7 @@ block_5: goto block_17; } func_801477B4(globalCtx); - func_800B8A1C((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: @@ -390,7 +390,7 @@ block_11: } func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; return; @@ -410,7 +410,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { u8 temp_v0; u8 temp_v0_2; - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 4) { goto block_7; } @@ -430,7 +430,7 @@ block_5: return; } func_801477B4(globalCtx); - func_800B8A1C((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: @@ -460,7 +460,7 @@ block_11: } func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; return; @@ -509,7 +509,7 @@ So let us rewrite the entire second half as a switch: } func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; return; @@ -540,7 +540,7 @@ There's a couple of other obvious things here: func_80151938(globalCtx, 0x937U); } else { func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; } @@ -568,7 +568,7 @@ can be swapped round and made to wrap the switch. This leaves us with void func_809527F8(EnMs *this, GlobalContext *globalCtx) { u8 temp_v0; - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 4) { goto block_7; } @@ -588,7 +588,7 @@ block_5: return; } func_801477B4(globalCtx); - func_800B8A1C((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: @@ -605,7 +605,7 @@ block_7: func_80151938(globalCtx, 0x937U); } else { func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; } @@ -623,7 +623,7 @@ block_7: Now, the top of the function also looks like a switch: ```C - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 4) { goto block_7; } @@ -641,7 +641,7 @@ Putting all this together, we write down a function with no gotos in it: ```C void func_809527F8(EnMs *this, GlobalContext *globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 6: this->actionFunc = func_80952734; break; @@ -651,7 +651,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { return; } func_801477B4(globalCtx); - func_800B8A1C((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; break; @@ -660,7 +660,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); - + if (gSaveContext.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); @@ -669,7 +669,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { func_80151938(globalCtx, 0x937U); } else { func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; } @@ -694,7 +694,7 @@ Lastly, we can simplify `case 5` to replace the return in the if by the rest of ```C void func_809527F8(EnMs *this, GlobalContext *globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 6: this->actionFunc = func_80952734; break; @@ -702,7 +702,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { case 5: if (func_80147624(globalCtx) != 0) { func_801477B4(globalCtx); - func_800B8A1C((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; } break; @@ -712,7 +712,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); - + if (gSaveContext.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); @@ -721,7 +721,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { func_80151938(globalCtx, 0x937U); } else { func_8019F208(); - func_800B8A1C((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); + Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f); func_801159EC(-0xA); this->actionFunc = func_809529AC; } diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index 9b2c8e177e..de82b54f93 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -148,9 +148,9 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { } } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { func_80C10290(this); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2000)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2000)) { func_800B8614(&this->actor, globalCtx, 60.0f); if (Player_GetMask(globalCtx) == 2) { this->actor.textId = 0x2367; @@ -188,7 +188,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { } } - temp_v0_2 = func_80152498(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&globalCtx->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; func_80C10148(this); @@ -197,7 +197,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { - Actor_SetSwitchFlag(globalCtx, this->actor.params); + Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); if ((gSaveContext.weekEventReg[63] & 0x80)) { this->actor.textId = 0x2ADF; @@ -476,9 +476,9 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { } } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { func_80C10290(this); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2000)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2000)) { func_800B8614(&this->actor, globalCtx, 60.0f); if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { this->actor.textId = 0x2367; // "... doesn't Kafei want to break off his engagement ... ?" @@ -514,13 +514,13 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { } } - temp_v0_2 = func_80152498(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&globalCtx->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; // hear directions again? func_80C10148(this); } else if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." - Actor_SetSwitchFlag(globalCtx, this->actor.params); + Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); if (gSaveContext.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) @@ -546,7 +546,7 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { } } ``` -All this branching is to make the conversation look more diverse and interesting. Notably, though, `func_80C1019C` is set to start with, and is only changed when `func_800B84D0(&this->actor, globalCtx) != 0`. This is something to do with talking. The other function handles the rest of the conversation, and hands back to the first if `func_80152498(&globalCtx->msgCtx) == 2`. This function is *something* to do with the text state, which will require `z_message` to be decomped. However, observation in-game will reveal this is something to do with ending dialogue. So we can conclude that the action functions are `EnRecepgirl_Wait` and `EnRecepgirl_Talk`. The setup functions are thus `EnRecepgirl_SetupWait` and `EnRecepgirl_SetupTalk`. +All this branching is to make the conversation look more diverse and interesting. Notably, though, `func_80C1019C` is set to start with, and is only changed when `Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0`. This is something to do with talking. The other function handles the rest of the conversation, and hands back to the first if `Message_GetState(&globalCtx->msgCtx) == 2`. This function is *something* to do with the text state, which will require `z_message` to be decomped. However, observation in-game will reveal this is something to do with ending dialogue. So we can conclude that the action functions are `EnRecepgirl_Wait` and `EnRecepgirl_Talk`. The setup functions are thus `EnRecepgirl_SetupWait` and `EnRecepgirl_SetupTalk`. For more complex actors, we have a tool called `graphovl.py` that can produce function flow graphs for actors: running ``` diff --git a/docs/tutorial/introduction.md b/docs/tutorial/introduction.md index 4e2d8324d3..6178019c8a 100644 --- a/docs/tutorial/introduction.md +++ b/docs/tutorial/introduction.md @@ -27,7 +27,7 @@ glabel func_809529AC /* 0003D8 809529F8 C484009C */ lwc1 $f4, 0x9c($a0) /* 0003DC 809529FC 8C870098 */ lw $a3, 0x98($a0) /* 0003E0 80952A00 24060035 */ addiu $a2, $zero, 0x35 -/* 0003E4 80952A04 0C02E287 */ jal func_800B8A1C +/* 0003E4 80952A04 0C02E287 */ jal Actor_PickUp /* 0003E8 80952A08 E7A40010 */ swc1 $f4, 0x10($sp) .L80952A0C: /* 0003EC 80952A0C 8FBF001C */ lw $ra, 0x1c($sp) @@ -46,7 +46,7 @@ void func_809529AC(EnMs *this, GlobalContext *globalCtx) { func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); this->actionFunc = func_80952A1C; } else { - func_800B8A1C(&this->actor, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } ``` diff --git a/docs/tutorial/other_functions.md b/docs/tutorial/other_functions.md index bdc49036da..870b490ea6 100644 --- a/docs/tutorial/other_functions.md +++ b/docs/tutorial/other_functions.md @@ -116,11 +116,11 @@ void func_80C1019C(EnRecepgirl *this, GlobalContext *globalCtx) { Animation_ChangeTransitionRepeat(temp_a0, &D_06009890, -4.0f); } } - if (func_800B84D0((Actor *) this, globalCtx) != 0) { + if (Actor_ProcessTalkRequest((Actor *) this, globalCtx) != 0) { func_80C10290(this); return; } - if (Actor_IsActorFacingLink((Actor *) this, 0x2000) != 0) { + if (Actor_IsFacingPlayer((Actor *) this, 0x2000) != 0) { func_800B8614((Actor *) this, globalCtx, 60.0f); if (Player_GetMask(globalCtx) == 2) { this->actor.textId = 0x2367; @@ -168,11 +168,11 @@ void func_80C1019C(EnRecepgirl *this, GlobalContext *globalCtx) { Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, -4.0f); } } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { func_80C10290(this); return; } - if (Actor_IsActorFacingLink(&this->actor, 0x2000) != 0) { + if (Actor_IsFacingPlayer(&this->actor, 0x2000) != 0) { func_800B8614(&this->actor, globalCtx, 60.0f); if (Player_GetMask(globalCtx) == 2) { this->actor.textId = 0x2367; @@ -203,9 +203,9 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { } } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { func_80C10290(this); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2000)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2000)) { func_800B8614(&this->actor, globalCtx, 60.0f); if (Player_GetMask(globalCtx) == 2) { this->actor.textId = 0x2367; @@ -282,7 +282,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { Animation_MorphToPlayOnce(sp20, &D_0600A280, -4.0f); } } - temp_v0_2 = func_80152498(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&globalCtx->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; func_80C10148(this); @@ -291,7 +291,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { temp_v0_3 = this->actor.textId; if (temp_v0_3 == 0x2AD9) { - Actor_SetSwitchFlag(globalCtx, (s32) this->actor.params); + Flags_SetSwitch(globalCtx, (s32) this->actor.params); Animation_MorphToPlayOnce(sp20, &D_0600AD98, 10.0f); if ((*(&gSaveContext + 0xF37) & 0x80) != 0) { this->actor.textId = 0x2ADF; @@ -340,7 +340,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { } } - temp_v0_2 = func_80152498(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&globalCtx->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; func_80C10148(this); @@ -349,7 +349,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { - Actor_SetSwitchFlag(globalCtx, this->actor.params); + Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); if ((*(&gSaveContext + 0xF37) & 0x80) != 0) { this->actor.textId = 0x2ADF; @@ -390,7 +390,7 @@ The yellow shows registers that don't match, the different colours on the regist ``` somehow we skipped over `t0`. Where is this in the code? The `153` in the middle is the line number in the C file (the `3f0`s are the offsets into the assembly file), we have `--source` if you want to see the code explicitly, or you can do it the old-fashioned way, and work it out from nearby function calls. In this case, `func_80C10148` is run straight after, and the only place that is called is ```C - temp_v0_2 = func_80152498(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&globalCtx->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; func_80C10148(this); diff --git a/include/functions.h b/include/functions.h index f1417495ad..30f577b50b 100644 --- a/include/functions.h +++ b/include/functions.h @@ -15,8 +15,7 @@ s32 DmaMgr_FindDmaIndex(u32 vromAddr); const char* func_800809F4(u32 param_1); void DmaMgr_ProcessMsg(DmaRequest* req); void DmaMgr_ThreadEntry(void* arg); -s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, uintptr_t vromStart, size_t size, UNK_TYPE4 unused, - OSMesgQueue* callback, void* callbackMesg); +s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, uintptr_t vromStart, size_t size, UNK_TYPE4 unused, OSMesgQueue* callback, void* callbackMesg); s32 DmaMgr_SendRequest0(void* vramStart, uintptr_t vromStart, size_t size); void DmaMgr_Start(void); void DmaMgr_Stop(void); @@ -305,8 +304,8 @@ void osViBlack(u8 active); s32 __osSiRawReadIo(u32 devAddr, u32* data); OSId osGetThreadId(OSThread* t); void osSpTaskYield(void); -s32 __osPfsGetNextPage(OSPfs* param_1, __OSInode* param_2, u8 param_3, u8 param_4); -s32 osPfsReadWriteFile(OSPfs* pfs, s32 file_no, u8 flag, s32 offset, s32 size_in_bytes, u8* data_buffer); +s32 __osPfsGetNextPage(OSPfs* pfs, u8* bank, __OSInode* inode, __OSInodeUnit* page); +s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8* data); s32 __osPfsGetStatus(OSMesgQueue* queue, s32 channel); // void __osPfsRequestOneChannel(void); // void __osPfsGetOneChannelData(void); @@ -317,8 +316,7 @@ void osViSetMode(OSViMode* modep); void guLookAtF(float mf[4][4], f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp); void guLookAt(Mtx* m, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp); s32 osPfsAllocateFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32 fileSize, s32* fileNo); -s32 __osPfsDeclearPage(OSPfs* pfs, __OSInode* inode, s32 fileSizeInPages, s32* startPage, u8 bank, s32* decleared, - s32* finalPage); +s32 __osPfsDeclearPage(OSPfs* pfs, __OSInode* inode, s32 fileSizeInPages, s32* startPage, u8 bank, s32* decleared, s32* finalPage); s32 osStopTimer(OSTimer* t); u32 __osProbeTLB(void* param_1); void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt); @@ -493,8 +491,8 @@ void* __osMemcpy(void* dst, void* src, size_t size); // void EnItem00_DrawHeartContainer(EnItem00* this, GlobalContext* globalCtx); // void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx); // s16 func_800A7650(s16 dropId); -EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params); -Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params); +Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params); +Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s32 params); void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3f* spawnPos, s16 params); s32 func_800A8150(s32 index); s32 func_800A817C(s32 index); @@ -551,70 +549,51 @@ s16 func_800B09D0(s16 a0, s16 a1, f32 a2); u8 func_800B0A24(u8 a0, u8 a1, f32 a2); void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* texture); void EffectSsDust_Spawn(GlobalContext* globalCtx, u16 drawFlags, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life, u8 updateMode); -void func_800B0DE0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void func_800B0E48(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void func_800B0EB0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); -void func_800B0F18(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); -void func_800B0F80(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); -void func_800B0FE8(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep); -void func_800B1054(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor, s16 scale, s16 scaleStep); +void func_800B0DE0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); +void func_800B0E48(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); +void func_800B0EB0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); +void func_800B0F18(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); +void func_800B0F80(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life); +void func_800B0FE8(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); +void func_800B1054(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep); void func_800B10C0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel); void func_800B1130(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel); void func_800B11A0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); void func_800B1210(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); -void func_800B1280(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, - s16 life); -void func_800B12F0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, - s16 life); -void func_800B1360(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor); -void func_800B139C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, - Color_RGBA8* envColor); +void func_800B1280(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life); +void func_800B12F0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life); +void func_800B1360(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); +void func_800B139C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); void func_800B13D8(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity, Vec3f* accel); void func_800B14D4(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos); void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos); void EffectSsKiraKira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel); -void EffectSsKiraKira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, - Color_RGBA8* primColor, Color_RGBA8* envColor); -void EffectSsGSpk_SpawnSmall(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, - Color_RGBA8* primColor, Color_RGBA8* envColor); +void EffectSsKiraKira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); +void EffectSsGSpk_SpawnSmall(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life); // void EffectSsKiraKira_SpawnFocused(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); // void EffectSsBomb2_SpawnFade(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4); -void EffectSsBomb2_SpawnLayered(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, - s16 scaleStep); +void EffectSsBomb2_SpawnLayered(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); // void EffectSsBlast_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, Color_RGBA8* param_5, Color_RGBA8* param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); -// void EffectSsBlast_SpawnWhiteCustomScale(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); +void EffectSsBlast_SpawnWhiteCustomScale(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, + s16 scaleStep, s16 life); // void EffectSsBlast_SpawnShockwave(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7); -// void EffectSsBlast_SpawnWhiteShockwave(void); +void EffectSsBlast_SpawnWhiteShockwave(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3); // void EffectSsGSpk_SpawnAccel(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, Vec3f* pzParm4, Vec3f* param_5, Color_RGBA8* param_6, Color_RGBA8* param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9); // void EffectSsGSpk_SpawnNoAccel(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9); // void EffectSsGSpk_SpawnFuse(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void EffectSsGSpk_SpawnRandColor(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); // void EffectSsGSpk_SpawnSmall(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, - s16 alpha, s16 fadeDelay, s16 life, s32 arg9); -void EffectSsBubble_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale, - f32 scale); +void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 alpha, s16 fadeDelay, s16 life, s32 arg9); +void EffectSsBubble_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale, f32 scale); void EffectSsGRipple_Spawn(GlobalContext* globalCtx, Vec3f* pos, s16 radius, s16 radiusMax, s16 life); -void EffectSsGSplash_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, - s16 type, s16 scale); +void EffectSsGSplash_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 type, s16 scale); // void EffectSsGFire_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2); // void EffectSsLightning_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Color_RGBA8* pzParm3, Color_RGBA8* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8); // void EffectSsDtBubble_SpawnColorProfile(UNK_TYPE4 param_1, Vec3f* param_2, Vec3f* param_3, Vec3f* param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8); -void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, - Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 life, s16 randXZ); -void EffectSsHahen_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16 scale, - s16 objId, s16 life, Gfx* dList); -void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstScale, s16 unused, s16 scale, - s16 randScaleRange, s16 count, s16 objId, s16 life, Gfx* dList); +void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 life, s16 randXZ); +void EffectSsHahen_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16 scale, s16 objId, s16 life, Gfx* dList); +void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstScale, s16 unused, s16 scale, s16 randScaleRange, s16 count, s16 objId, s16 life, Gfx* dList); // void func_800B2364(void); // void EffectSsStick_Spawn(UNK_TYPE4 uParm1, UNK_PTR puParm2, UNK_TYPE2 uParm3); // void EffectSsSibuki_Spawn(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); @@ -625,28 +604,22 @@ void EffectSsHitMark_SpawnFixedScale(GlobalContext* globalCtx, s32 type, Vec3f* // void EffectSsHitMark_SpawnCustomScale(void); // void EffectSsFhgFlash_SpawnShock(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, UNK_TYPE2 uParm4, UNK_TYPE1 param_5); // void EffectSsKFire_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE1 param_6); -void EffectSsSolderSrchBall_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, - s16* linkDetected, s16 drawFlag); -void EffectSsKakera_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, - s16 arg6, s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, - s16 objId, Gfx* dList); +void EffectSsSolderSrchBall_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16* linkDetected, s16 drawFlag); +void EffectSsKakera_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, s16 arg6, s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, s16 objId, Gfx* dList); // void EffectSsIcePiece_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, UNK_TYPE4 uParm3, Vec3f* pzParm4, Vec3f* param_5, UNK_TYPE4 param_6); // void EffectSsIcePiece_SpawnBurst(void); // void EffectSsEnIce_SpawnFlyingVec3f(UNK_TYPE4 uParm1, Actor* pzParm2, Vec3f* pzParm3, Color_RGBA8* pzParm4, Color_RGBA8* param_5, UNK_TYPE4 param_6); // void func_800B2B44(void); // void func_800B2B7C(void); -void EffectSsEnIce_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, - Color_RGBA8* primColor, Color_RGBA8* envColor, s32 life); +void EffectSsEnIce_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s32 life); // void EffectSsFireTail_Spawn(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, UNK_TYPE4 uParm4, Vec3f* param_5, UNK_TYPE2 param_6, Color_RGBA8* param_7, Color_RGBA8* param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE4 param_11); // void EffectSsFireTail_SpawnFlame(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); // void EffectSsFireTail_SpawnFlameOnPlayer(void); void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s16 scale, s16 arg4, s16 flags, s16 bodyPart); // void EffectSsEnFire_SpawnVec3s(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); // void EffectSsExtra_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); -void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, - s16 scale, s16 scaleStep, s32 unk); -void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, - s32 colorIndex); +void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk); +void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s32 colorIndex); // void EffectSsDeadDd_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE1* param_5, UNK_TYPE1* param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE4 param_10); // void EffectSsDeadDs_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); // void func_800B31BC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); @@ -656,73 +629,60 @@ void FlagSet_Update(GameState* gameState); void FlagSet_Draw(GameState* gameState); void Overlay_LoadGameState(GameStateOverlay* gameState); void Overlay_FreeGameState(GameStateOverlay* gameState); -void Actor_PrintLists(ActorContext* actorCtx); -void ActorShape_Init(ActorShape* actorShape, f32 yOffset, ActorShadowFunc func, f32 scale); -void ActorShadow_Draw(Actor* actor, Lights* mapper, GlobalContext* globalCtx, Gfx* displayList, Color_RGBA8* color); -void func_800B3FC0(Actor* actor, Lights* mapper, GlobalContext* globalCtx); -void func_800B4024(Actor* actor, Lights* mapper, GlobalContext* globalCtx); -void func_800B4088(Actor* actor, Lights* mapper, GlobalContext* globalCtx); -void func_800B40B8(Actor* actor, Lights* mapper, GlobalContext* globalCtx); -void func_800B40E0(GlobalContext* globalCtx, Light* light, MtxF* arg2, s32 arg3, f32 arg4, f32 arg5, f32 arg6); -void func_800B42F8(Actor* actor, Lights* mapper, GlobalContext* globalCtx); -// void func_800B4A98(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -void func_800B4AEC(GlobalContext* globalCtx, Actor* actor, f32 param_3); + +void ActorShape_Init(ActorShape* actorShape, f32 yOffset, ActorShadowFunc shadowDraw, f32 shadowScale); +void ActorShadow_DrawCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx); +void ActorShadow_DrawSquare(Actor* actor, Lights* lights, GlobalContext* globalCtx); +void ActorShadow_DrawWhiteCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx); +void ActorShadow_DrawHorse(Actor* actor, Lights* lights, GlobalContext* globalCtx); + +void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx); +void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* leftFootPos, s32 rightFootIndex, Vec3f* rightFootPos); +void func_800B4AEC(GlobalContext* globalCtx, Actor* actor, f32 y); void func_800B4B50(Actor* actor, Lights* mapper, GlobalContext* globalCtx); -void func_800B4EDC(GlobalContext* globalCtx, Vec3f* pzParm2, Vec3f* pzParm3, f32* pfParm4); -// void func_800B4F40(TargetContext* targetCtx, s32 param_2, UNK_TYPE4 param_3, UNK_TYPE4 param_4, UNK_TYPE4 param_5); -void func_800B4F78(TargetContext* targetCtx, u8 type, GlobalContext* globalCtx); -void func_800B5040(TargetContext* targetCtx, Actor* actor, u8 type, GlobalContext* globalCtx); -void Actor_TargetContextInit(TargetContext* targetCtx, Actor* actor, GlobalContext* globalCtx); -void func_800B5208(TargetContext* targetCtx, GlobalContext* globalCtx); -void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GlobalContext* globalCtx); -u32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag); -void Actor_SetSwitchFlag(GlobalContext* globalCtx, s32 flag); -void Actor_UnsetSwitchFlag(GlobalContext* globalCtx, s32 flag); -u32 Actor_GetChestFlag(GlobalContext* globalCtx, u32 flag); -void Actor_SetChestFlag(GlobalContext* globalCtx, u32 flag); -void Actor_SetAllChestFlag(GlobalContext* globalCtx, u32 flags); -u32 Actor_GetAllChestFlag(GlobalContext* globalCtx); -u32 Actor_GetRoomCleared(GlobalContext* globalCtx, u32 roomNumber); -void Actor_SetRoomCleared(GlobalContext* globalCtx, u32 roomNumber); -void Actor_UnsetRoomCleared(GlobalContext* globalCtx, u32 roomNumber); -u32 Actor_GetRoomClearedTemp(GlobalContext* globalCtx, u32 roomNumber); -void Actor_SetRoomClearedTemp(GlobalContext* globalCtx, u32 roomNumber); -void Actor_UnsetRoomClearedTemp(GlobalContext* globalCtx, u32 roomNumber); -u32 Actor_GetCollectibleFlag(GlobalContext* globalCtx, s32 index); -void Actor_SetCollectibleFlag(GlobalContext* globalCtx, s32 index); -void Actor_TitleCardContextInit(GlobalContext* globalCtx, TitleCardContext* titleCardCtx); -void Actor_TitleCardCreate(GlobalContext* globalCtx, TitleCardContext* titleCardCtx, u32 texture, s16 param_4, s16 param_5, u8 param_6, u8 param_7); -// void Actor_Nop800B5E50(UNK_TYPE4 param_1, UNK_TYPE4 param_2, UNK_TYPE4 param_3, UNK_TYPE4 param_4); -void Actor_TitleCardUpdate(GlobalContext* globalCtx, TitleCardContext* titleCardCtx); -void Actor_TitleCardDraw(GlobalContext* globalCtx, TitleCardContext* titleCardCtx); -// UNK_TYPE4 func_800B6434(GlobalContext* globalCtx, TitleCardContext* titleCardCtx); -// UNK_TYPE4 func_800B645C(void); -void func_800B6468(GlobalContext* globalCtx); -void func_800B6474(GlobalContext* globalCtx); -// UNK_TYPE4 func_800B648C(GlobalContext* globalCtx, UNK_TYPE1 param_2, UNK_TYPE1 param_3, f32 param_4, Vec3f* param_5); -f32 func_800B64FC(GlobalContext* globalCtx, f32 fParm2, Vec3f* pzParm3, u32* puParm4); -void* func_800B6584(GlobalContext* globalCtx, s16 sParm2, void* pvParm3, u32 uParm4); -// UNK_TYPE4 func_800B6608(s32 iParm1, s16 sParm2); -// void func_800B6680(void); +void Actor_GetProjectedPos(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3); + +void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx); + +s32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag); +void Flags_SetSwitch(GlobalContext* globalCtx, s32 flag); +void Flags_UnsetSwitch(GlobalContext* globalCtx, s32 flag); +s32 Flags_GetTreasure(GlobalContext* globalCtx, s32 flag); +void Flags_SetTreasure(GlobalContext* globalCtx, s32 flag); +void Flags_SetAllTreasure(GlobalContext* globalCtx, s32 flag); +s32 Flags_GetAllTreasure(GlobalContext* globalCtx); +s32 Flags_GetClear(GlobalContext* globalCtx, s32 roomNumber); +void Flags_SetClear(GlobalContext* globalCtx, s32 roomNumber); +void Flags_UnsetClear(GlobalContext* globalCtx, s32 roomNumber); +s32 Flags_GetClearTemp(GlobalContext* globalCtx, s32 roomNumber); +void Flags_SetClearTemp(GlobalContext* globalCtx, s32 roomNumber); +void Flags_UnsetClearTemp(GlobalContext* globalCtx, s32 roomNumber); +s32 Flags_GetCollectible(GlobalContext* globalCtx, s32 flag); +void Flags_SetCollectible(GlobalContext* globalCtx, s32 flag); + +void TitleCard_InitBossName(GameState* gameState, TitleCardContext* titleCtx, TexturePtr texture, s16 x, s16 y, u8 width, u8 height); + +s32 func_800B648C(GlobalContext* globalCtx, s32 arg1, s32 arg2, f32 arg3, Vec3f* arg4); +f32 func_800B64FC(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2, u32* arg3); +void* func_800B6584(GlobalContext* globalCtx, s16 id, void* arg2, size_t size); +void* func_800B6608(GlobalContext* globalCtx, s16 id); +void* func_800B6680(GlobalContext* globalCtx, s16 id); void Actor_MarkForDeath(Actor* actor); -void Actor_InitCurrPosition(Actor* actor); -void Actor_SetHeight(Actor* actor, f32 height); -void Actor_SetRotationFromDrawRotation(Actor* actor); -void Actor_InitDrawRotation(Actor* actor); +void Actor_SetWorldToHome(Actor* actor); +void Actor_SetFocus(Actor* actor, f32 height); +void Actor_SetWorldRotToShape(Actor* actor); +void Actor_SetShapeRotToWorld(Actor* actor); void Actor_SetScale(Actor* actor, f32 scale); -void Actor_SetObjectSegment(GlobalContext* globalCtx, Actor* actor); -void Actor_InitToDefaultValues(Actor* actor, GlobalContext* globalCtx); -void Actor_FiniActor(Actor* actor, GlobalContext* globalCtx); +void Actor_SetObjectDependency(GlobalContext* globalCtx, Actor* actor); void Actor_SetMovementScale(s32 scale); -void Actor_ApplyMovement(Actor* actor); -void Actor_SetVelocityYRotationAndGravity(Actor* actor); -void Actor_SetVelocityAndMoveYRotationAndGravity(Actor* actor); -void Actor_SetVelocityXYRotation(Actor* actor); -void Actor_SetVelocityAndMoveXYRotation(Actor* actor); -void Actor_SetVelocityXYRotationReverse(Actor* actor); -void Actor_SetVelocityAndMoveXYRotationReverse(Actor* actor); -void func_800B6C04(Actor* actor, f32 fParm2); -// void func_800B6C58(Actor* actor, UNK_TYPE4 param_2); +void Actor_UpdatePos(Actor* actor); +void Actor_UpdateVelocityWithGravity(Actor* actor); +void Actor_MoveWithGravity(Actor* actor); +void Actor_UpdateVelocityWithoutGravity(Actor* actor); +void Actor_MoveWithoutGravity(Actor* actor); +void Actor_UpdateVelocityWithoutGravityReverse(Actor* actor); +void Actor_MoveWithoutGravityReverse(Actor* actor); +void Actor_SetSpeeds(Actor* actor, f32 speed); s16 Actor_YawBetweenActors(Actor* from, Actor* to); s16 Actor_YawBetweenActorsTop(Actor* from, Actor* to); s16 Actor_YawToPoint(Actor* actor, Vec3f* point); @@ -733,171 +693,142 @@ f32 Actor_DistanceBetweenActors(Actor* actor1, Actor* actor2); f32 Actor_DistanceToPoint(Actor* actor, Vec3f* point); f32 Actor_XZDistanceBetweenActors(Actor* actor1, Actor* actor2); f32 Actor_XZDistanceToPoint(Actor* actor, Vec3f* point); -void Actor_CalcOffsetOrientedToDrawRotation(Actor* actor, Vec3f* offset, Vec3f* point); -f32 Actor_YDistance(Actor* actor1, Actor* actor2); -void func_800B6F20(GlobalContext* globalCtx, s32 param_2, f32 param_3, s16 param_4); -float func_800B6FC8(Player* player); -// void func_800B7090(void); -// void func_800B7118(void); -// void func_800B7128(void); +void Actor_OffsetOfPointInActorCoords(Actor* actor, Vec3f* offset, Vec3f* point); +f32 Actor_HeightDiff(Actor* actor1, Actor* actor2); +void func_800B6F20(GlobalContext* globalCtx, Input* input, f32 arg2, s16 arg3); +f32 Player_GetHeight(Player* player); +f32 Player_GetRunSpeedLimit(Player* player); +s32 func_800B7118(Player* player); +s32 func_800B7128(Player* player); s32 func_800B715C(GlobalContext* globalCtx); -// void func_800B7170(void); -// void func_800B71DC(void); -u32 func_800B7200(s32 param_1); -// void func_800B722C(void); -void func_800B724C(GlobalContext* globalCtx, Actor* actor, u8 arg2); -u32 func_800B7298(GlobalContext* globalCtx, Actor* actor, u8 arg2); -void func_800B72E0(s32 param_1); -void func_800B72F8(DynaPolyActor* dpactor, f32 a1, s16 a2); -s32 Actor_IsLinkFacingActor(Actor* actor, s16 tolerance, GlobalContext* globalCtx); -s32 Actor_IsActorFacedByActor(Actor* actor, Actor* other, s16 tolerance); -s32 Actor_IsActorFacingLink(Actor* actor, s16 angle); -s32 Actor_IsActorFacingActor(Actor* actor, Actor* other, s16 tolerance); -s32 Actor_IsActorFacingLinkAndWithinRange(Actor* actor, f32 range, s16 tolerance); -s32 Actor_IsActorFacingActorAndWithinRange(Actor* actor, Actor* other, f32 range, s16 tolerance); -void func_800B75A0(CollisionPoly* param_1, Vec3f* param_2, s16* param_3); -// UNK_TYPE4 func_800B761C(Actor* param_1, UNK_TYPE4 param_2, u32 param_3); -// UNK_TYPE4 func_800B7678(GlobalContext* globalCtx, Actor* param_2, s32 param_3, u32 param_4); +void Actor_SetCameraHorseSetting(GlobalContext* globalCtx, Player* player); +void Actor_MountHorse(GlobalContext* globalCtx, Player* player, Actor* horse); +s32 func_800B724C(GlobalContext* globalCtx, Actor* actor, u8 csMode); +u32 func_800B7298(GlobalContext* globalCtx, Actor* actor, u8 csMode); +void func_800B72F8(DynaPolyActor* dyna, f32 extraPushForce, s16 yRotation); + +s32 Player_IsFacingActor(Actor* actor, s16 maxAngleDiff, GlobalContext* globalCtx); +s32 Actor_ActorBIsFacingActorA(Actor* actorA, Actor* actorB, s16 maxAngleDiff); +s32 Actor_IsFacingPlayer(Actor* actor, s16 angle); +s32 Actor_ActorAIsFacingActorB(Actor* actorA, Actor* actorB, s16 maxAngleDiff); +s32 Actor_IsFacingAndNearPlayer(Actor* actor, f32 range, s16 maxAngleDiff); +s32 Actor_ActorAIsFacingAndNearActorB(Actor* actorA, Actor* actorB, f32 range, s16 maxAngleDiff); + +void func_800B75A0(CollisionPoly* poly, Vec3f* normal, s16* azimuth); void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallCheckHeight, f32 wallCheckRadius, f32 ceilingCheckHeight, u32 flags); -// void func_800B7E04(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -Hilite* func_800B7FE0(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx); -// void func_800B8018(void); -void func_800B8050(Actor* actor, GlobalContext* globalCtx, s32 iParm3); -void func_800B8118(Actor* actor, GlobalContext* globalCtx, s32 iParm3); -// void func_800B81E0(void); -UNK_PTR func_800B8214(PosRot* param_1, Actor* param_2); -f32* func_800B8248(PosRot* param_1, Player* param_2); -// void func_800B82EC(void); -// void func_800B83BC(void); -// void func_800B83F8(void); -s32 func_800B84D0(Actor* actor, GlobalContext* globalCtx); // Actor_IsTalking -s32 func_800B8500(Actor* actor, GlobalContext* globalCtx, f32 fParm3, f32 fParm4, s32 param_5); -s32 func_800B85E0(Actor* actor, GlobalContext* globalCtx, f32 uParm3, s32 uParm4); -s32 func_800B8614(Actor* actor, GlobalContext* globalCtx, f32 uParm3); +Hilite* Hilite_DrawOpa(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx); +void func_800B8050(Actor* actor, GlobalContext* globalCtx, s32 flag); +void func_800B8118(Actor* actor, GlobalContext* globalCtx, s32 flag); +PosRot* Actor_GetFocus(PosRot* dest, Actor* actor); +PosRot* Actor_GetWorld(PosRot* dest, Actor* actor); +PosRot* Actor_GetWorldPosShapeRot(PosRot* dest, Actor* actor); + +s32 func_800B83F8(Actor* actor, Player* player, s32 flag); +s32 Actor_ProcessTalkRequest(Actor* actor, GameState* gameState); +s32 func_800B8500(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId); +s32 func_800B85E0(Actor* actor, GlobalContext* globalCtx, f32 radius, s32 exchangeItemId); +s32 func_800B8614(Actor* actor, GlobalContext* globalCtx, f32 radius); s32 func_800B863C(Actor* actor, GlobalContext* globalCtx); -u32 func_800B867C(Actor* actor, GlobalContext* globalCtx); -UNK_TYPE4 func_800B86C8(Actor* actor1, GlobalContext* globalCtx, Actor* actor2); -s32 func_800B8708(GlobalContext* globalCtx); -s32 func_800B8718(Actor* actor, GlobalContext* globalCtx); -void func_800B874C(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3); -// void func_800B8804(void); -// void func_800B882C(void); -// void func_800B886C(void); -void func_800B8898(GlobalContext* globalCtx, Actor* actor, s16* arg2, s16* arg3); +s32 Actor_TextboxIsClosing(Actor* actor, GlobalContext* globalCtx); +s32 Actor_ChangeFocus(Actor* actor1, GlobalContext* globalCtx, Actor* actor2); +s32 Player_GetExchangeItemId(GlobalContext* globalCtx); +s32 func_800B8718(Actor* actor, GameState* gameState); +s32 func_800B874C(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange); +s32 func_800B8804(Actor* actor, GlobalContext* globalCtx, f32 xzRange); +s32 func_800B886C(Actor* actor, GlobalContext* globalCtx); +void Actor_GetScreenPos(GlobalContext* globalCtx, Actor* actor, s16* x, s16* y); s32 func_800B8934(GlobalContext* globalCtx, Actor* actor); -u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx); -UNK_TYPE4 func_800B8A1C(Actor* actor, GlobalContext* globalCtx, s32 iParm3, f32 fParm4, f32 param_5); -// void func_800B8B84(void); -void func_800B8BB0(Actor* actor, GlobalContext* globalCtx); -// void func_800B8BD0(void); +s32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx); +s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRange, f32 yRange); +s32 Actor_PickUpNearby(Actor* actor, GlobalContext* globalCtx, s32 getItemId); +s32 Actor_LiftActor(Actor* actor, GlobalContext* globalCtx); +s32 Actor_PickUpFar(Actor* actor, GlobalContext* globalCtx, s32 getItemId); s32 Actor_HasNoParent(Actor* actor, GlobalContext* globalCtx); -// void func_800B8C20(void); +void func_800B8C20(Actor* actorA, Actor* actorB, GlobalContext* globalCtx); void func_800B8C50(Actor* actor, GlobalContext* globalCtx); -// void func_800B8C78(void); -// void func_800B8C9C(void); -// void func_800B8CEC(void); -// void func_800B8D10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); +s32 Actor_HasRider(GlobalContext* globalCtx, Actor* horse); +s32 Actor_SetRideActor(GlobalContext* globalCtx, Actor* horse, s32 mountSide); +s32 Actor_HasNoRider(GlobalContext* globalCtx, Actor* horse); +void func_800B8D10(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5, u32 arg6); void func_800B8D50(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 yaw, f32 arg4, u32 arg5); void func_800B8D98(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4); -// void func_800B8DD4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_800B8E1C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -void func_800B8E58(Actor* actor, u16 sfxId); -void Audio_PlayActorSound2(Actor* actor, u16 sfxId); -// void func_800B8FC0(void); +void func_800B8DD4(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5); +void func_800B8E1C(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4); +void func_800B8E58(Player* player, u16 sfxId); +void Actor_PlaySfxAtPos(Actor* actor, u16 sfxId); +void func_800B8EF4(GlobalContext* globalCtx, Actor* actor); void func_800B8F98(Actor* actor, u16 sfxId); +void func_800B8FC0(Actor* actor, u16 sfxId); void func_800B8FE8(Actor* actor, u16 sfxId); void func_800B9010(Actor* actor, u16 sfxId); -// void func_800B9038(void); -// void func_800B9084(void); +void func_800B9038(Actor* actor, s32 timer); +void func_800B9084(Actor* actor); void func_800B9098(Actor* actor); -s32 func_800B90AC(GlobalContext* globalCtx, Actor* actor, UNK_TYPE arg2, UNK_TYPE arg3, UNK_TYPE arg4); -// void func_800B90F4(void); +s32 func_800B90AC(GlobalContext* globalCtx, Actor* actor, CollisionPoly* polygon, s32 index, s32 arg4); +void func_800B90F4(GlobalContext* globalCtx); void func_800B9120(ActorContext* actorCtx); -// void Actor_Init(GlobalContext* globalCtx, ActorContext* actorCtx, UNK_TYPE4 uParm3); -void func_800B9334(GlobalContext* globalCtx, ActorContext* actorCtx); -Actor* Actor_UpdateActor(s800B948C* params); +void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry* actorEntry); void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx); -void Actor_DrawActor(GlobalContext* globalCtx, Actor* actor); -void func_800B9D1C(Actor* actor); -void Actor_DrawAllSetup(GlobalContext* globalCtx); s32 Actor_RecordUndrawnActor(GlobalContext* globalCtx, Actor* actor); -// void func_800B9E84(void); -void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors); -s32 func_800BA2D8(GlobalContext* globalCtx, Actor* actor); -s32 func_800BA2FC(GlobalContext* globalCtx, Actor* actor, Vec3f* param_3, f32 param_4); void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx); void func_800BA6FC(GlobalContext* globalCtx, ActorContext* actorCtx); void func_800BA798(GlobalContext* globalCtx, ActorContext* actorCtx); -void func_800BA8B8(GlobalContext* globalCtx, ActorContext* actorCtx); -// void func_800BA9B4(void); -void Actor_InsertIntoTypeList(ActorContext* actorCtx, Actor* actor, u8 type); -Actor* Actor_RemoveFromTypeList(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actor); -void Actor_FreeOverlay(ActorOverlay* entry); -Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s16 sParm10); -ActorInit* Actor_LoadOverlay(ActorContext* actorCtx, s16 index); -Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s32 variable, u32 cutscene, s32 param_12, Actor* parent); -Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s32 variable); +void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx); +Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params); +Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s32 params, u32 cutscene, s32 arg11, Actor* parent); +Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params); void Actor_SpawnTransitionActors(GlobalContext* globalCtx, ActorContext* actorCtx); -void func_800BB2D0(ActorContext* actorCtx, u16* param_2, GlobalContext* globalCtx); -Actor* func_800BB498(ActorContext* actorCtx, Actor* actor, GlobalContext* globalCtx); -// void func_800BB59C(void); -// void func_800BB604(void); -// void func_800BB8EC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); void Enemy_StartFinishingBlow(GlobalContext* globalCtx, Actor* actor); -// void func_800BBAC0(void); -void func_800BBB74(s16* arg1, UNK_TYPE1 arg2, UNK_TYPE1 arg3, UNK_TYPE4 arg4); -// void func_800BBC20(void); -void func_800BBCEC(Actor* actor, GlobalContext* globalCtx, s16 arg2, Gfx** dList); -void func_800BBDAC(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, f32 arg3, UNK_TYPE4 arg4, f32 arg5, s16 arg6, s16 arg7, u8 arg8); -void func_800BBFB0(GlobalContext* globalCtx, Vec3f* position, f32 param3, s32 param_4, s16 param_5, s16 param_6, u8 param_7); +s16 func_800BBAC0(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3); +s16 func_800BBB74(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3); +void Actor_SpawnBodyParts(Actor* actor, GlobalContext* globalCtx, s32 arg2, Gfx** dList); +void Actor_SpawnFloorDustRing(GlobalContext* globalCtx, Actor* actor, Vec3f* posXZ, f32 radius, s32 countMinusOne, f32 randAccelWeight, s16 scale, s16 scaleStep, u8 useLighting); +void func_800BBFB0(GlobalContext* globalCtx, Vec3f* position, f32 arg2, s32 arg3, s16 arg4, s16 scaleStep, u8 arg6); void func_800BC154(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actor, u8 actorCategory); -// void func_800BC188(void); -// void func_800BC1B4(void); -Actor* func_800BC270(GlobalContext* globalCtx, Actor* actor, f32 arg2, UNK_TYPE4 arg3); +s32 func_800BC188(s32 index); +Actor* func_800BC270(GlobalContext* globalCtx, Actor* actor, f32 arg2, s32 arg3); Actor* func_800BC444(GlobalContext* globalCtx, Actor* actor, f32 arg2); -s16 func_800BC4EC(Actor* actor, GlobalContext* globalCtx, f32 distance, s16 angle); -s32 func_800BC5B8(GlobalContext* globalCtx, Actor* actor); -s32 func_800BC5EC(GlobalContext* globalCtx, Actor* actor); -void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 arg2, GlobalContext* globalCtx); -// void func_800BC770(void); -// void func_800BC7D8(void); +s16 Actor_TestFloorInDirection(Actor* actor, GlobalContext* globalCtx, f32 distance, s16 angle); +s32 Actor_IsTargeted(GlobalContext* globalCtx, Actor* actor); +s32 Actor_OtherIsTargeted(GlobalContext* globalCtx, Actor* actor); +void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx); +void func_800BC770(GlobalContext* globalCtx, s16 y, s16 countdown); +void func_800BC7D8(GlobalContext* globalCtx, s16 y, s16 countdown, s16 speed); void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 arg2, s16 arg3); -// void func_800BC8B8(void); -// void func_800BCB50(void); -void func_800BCB70(Actor* actor, u16 arg1, u16 arg2, s16 arg3, s16 arg4); -void func_800BCBF4(Vec3f* uParm1, GlobalContext* globalCtx); -void func_800BCC68(Vec3f* param_1, GlobalContext* globalCtx); -UNK_RET func_800BCCDC(Vec3s* points, u8 pathcount, Vec3f* pos1, Vec3f* pos2, UNK_TYPE parm5); -// void func_800BD2B4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_800BD384(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE1 param_9); -// void func_800BD6E4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -void func_800BD888(Actor*, struct_800BD888_arg1*, s16, s16); // This function is very similar to OoT's func_80034A14 -// void func_800BD9A0(void); -// void func_800BD9E0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE2 param_6); -// void func_800BDAA0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE2 param_6); -// void func_800BDB6C(void); -void func_800BDC5C(SkelAnime* skelAnime, ActorAnimationEntry animation[], s32 index); -// void func_800BDCF4(void); +void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type); +void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 xluFlag, u16 duration); +Hilite* func_800BCBF4(Vec3f* arg0, GlobalContext* globalCtx); +Hilite* func_800BCC68(Vec3f* arg0, GlobalContext* globalCtx); +void func_800BCCDC(Vec3s* points, s32 pathCount, Vec3f* pos1, Vec3f* pos2, s32 parm5); +s32 func_800BD2B4(GlobalContext* globalCtx, Actor* actor, s16* arg2, f32 arg3, u16 (*textIdCallback)(GlobalContext*, Actor*), s16 (*arg5)(GlobalContext*, Actor*)); +void func_800BD888(Actor* actor, struct_800BD888_arg1* arg1, s16 arg2, s16 arg3); +void func_800BD9E0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); +void func_800BDAA0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); +void Actor_ChangeAnimation(SkelAnime* skelAnime, ActorAnimationEntry* animation, s32 index); void Actor_Noop(Actor* actor, GlobalContext* globalCtx); -void func_800BDFC0(GlobalContext* globalCtx, Gfx* dl); -void func_800BE03C(GlobalContext* globalCtx, Gfx* dl); -Actor* func_800BE0B8(GlobalContext* globalCtx, Actor* inActor, s16 arg2, u8 arg3, f32 arg4); -s32 func_800BE184(GlobalContext* globalCtx, Actor* actor, f32 arg2, s32 arg3, s32 arg4, s32 arg5); -u8 Actor_ApplyDamage(Actor* actor); // returns current health -void func_800BE258(Actor* actor, UNK_PTR arg1); -void func_800BE2B8(Actor* actor, ColliderJntSph* jntSphere); + +void Gfx_DrawDListOpa(GlobalContext* globalCtx, Gfx* dlist); +void Gfx_DrawDListXlu(GlobalContext* globalCtx, Gfx* dlist); + +Actor* Actor_FindNearby(GlobalContext* globalCtx, Actor* inActor, s16 actorId, u8 actorCategory, f32 distance); +s32 func_800BE184(GlobalContext* globalCtx, Actor* actor, f32 xzDist, s16 arg3, s16 arg4, s16 arg5); +u8 Actor_ApplyDamage(Actor* actor); +void Actor_SetDropFlag(Actor* actor, ColliderInfo* colInfo); +void Actor_SetDropFlagJntSph(Actor* actor, ColliderJntSph* jntSphere); void func_800BE33C(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3); void func_800BE3D0(Actor* actor, s16 angle, Vec3s* arg2); void func_800BE504(Actor* actor, ColliderCylinder* collider); void func_800BE568(Actor* actor, ColliderSphere* collider); -void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 arg2); -// void func_800BE63C(void); -void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 arg3, f32 arg4, f32 arg5, f32 arg6, u8 mode); -void func_800BF7CC(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s32 arg3, s32 arg4, f32 arg5, f32 arg6); -void ActorOverlayTable_FaultPrint(void* arg0, void* arg1); // ActorOverlayTable_FaultPrint -void* ActorOverlayTable_FaultAddrConv(void* arg0, void* arg1); // ActorOverlayTable_FaultAddrConv -void ActorOverlayTable_Init(void); // ActorOverlayTable_Init -void ActorOverlayTable_Cleanup(void); // ActorOverlayTable_Cleanup +void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 colliderIndex); +s32 func_800BE63C(struct EnBox* chest); +void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 arg3, f32 effectScale, f32 steamScale, f32 effectAlpha, u8 mode); +void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s32 limbPosCount, s32 effectsPerLimb, f32 scale, f32 scaleRange); + +void ActorOverlayTable_FaultPrint(void* arg0, void* arg1); +void* ActorOverlayTable_FaultAddrConv(void* arg0, void* arg1); +void ActorOverlayTable_Init(void); +void ActorOverlayTable_Cleanup(void); + void SSNode_SetValue(SSNode* node, s16* polyIndex, u16 next); void SSList_SetNull(SSList* head); void SSNodeList_SetSSListHead(SSNodeList* list, SSList* ssList, s16* polyIndex); @@ -1227,7 +1158,7 @@ void func_800DE0EC(Camera* camera, Actor* actor); Vec3s* Camera_Update(Vec3s* param_1, Camera* camera); // void func_800DF498(void); u32 Camera_SetMode(Camera* camera, s16 mode, s8 param_3); -// void func_800DF840(void); +s32 Camera_ChangeMode(Camera* camera, s16 mode); // void func_800DF86C(void); // void func_800DF8EC(void); s32 func_800DFAC8(Camera* camera, s16 param_2); @@ -1255,7 +1186,7 @@ s16 Camera_ClearFlags(Camera* camera, s16 flags); // void func_800E0238(void); void func_800E02AC(Camera* camera, Actor* actor); void func_800E0308(Camera* camera, Actor* actor); -// void func_800E031C(void); +f32 func_800E031C(Camera* camera); void func_800E0348(Camera* camera); DamageTable* DamageTable_Get(s32 index); void DamageTable_Clear(DamageTable* damageTable); @@ -1533,8 +1464,8 @@ void func_800EDF24(Actor* actor, GlobalContext* globalCtx, u32 arg2); void func_800EDF78(Actor* actor, GlobalContext* globalCtx, s32 iParm3); void func_800EE0CC(Actor* actor, GlobalContext* globalCtx, s32 iParm3); s32 func_800EE1D8(GlobalContext* globalCtx); -u32 func_800EE200(GlobalContext* globalCtx, u32 uParm2); -u32 func_800EE29C(GlobalContext* globalCtx, u32 uParm2); +u32 func_800EE200(GlobalContext* globalCtx, u16 uParm2); +u32 func_800EE29C(GlobalContext* globalCtx, u16 uParm2); u32 func_800EE2F4(GlobalContext* globalCtx); void GetItem_Draw(GlobalContext* globalCtx, s16 index); void func_800EE364(GlobalContext* globalCtx, s16 index); @@ -1618,14 +1549,11 @@ void ActorCutscene_SetReturnCamera(s16 index); // void func_800F23E0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); f32 func_800F2478(f32 target, TransformData* transData, s32 refIdx); void SkelCurve_Clear(SkelAnimeCurve* skelCurve); -s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, - TransformUpdateIndex* transUpdIdx); +s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, TransformUpdateIndex* transUpdIdx); void SkelCurve_Destroy(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve); -void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, - f32 animCurFrame, f32 animSpeed); +void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, f32 animCurFrame, f32 animSpeed); s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve); -void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, - OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx); +void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx); void FireObj_SetPosition(FireObj* fire, Vec3f* pos); void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire); void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init, Actor* actor); @@ -1639,7 +1567,7 @@ void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor); // void func_800F3B68(void); // void func_800F3C44(void); // void func_800F3ED4(void); -void func_800F40A0(GlobalContext* globalCtx, s32 param_2); +void func_800F40A0(GameState* gameState, Player* player); // void func_800F415C(void); UNK_TYPE func_800F41E4(GlobalContext* globalCtx, ActorContext* actorCtx); @@ -1658,7 +1586,7 @@ u32 func_800F5954(u8* param_1, u32 param_2, u32 param_3, u8 param_4, u8 param_5) f32 func_800F5A8C(u16 arg0, u16 arg1, u16 arg2, GlobalContext* globalContext); // void func_800F5B10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); // void func_800F5CD0(void); -// void func_800F6834(void); +void func_800F6834(GlobalContext* globalCtx, s32 waterLightsIndex); // void func_800F694C(void); // void func_800F6A04(void); // void func_800F6A40(void); @@ -2136,7 +2064,7 @@ void func_80122F28(Player* player, GlobalContext* globalCtx, Actor* actor); void func_8012301C(s32 iParm1, GlobalContext* globalCtx); void func_80123140(GlobalContext* globalCtx, Player* param_2); u32 func_80123358(GlobalContext* globalCtx, Player* player); -u32 func_801233E4(GlobalContext* globalCtx); +s32 Player_InCsMode(GameState* gameState); // void func_80123420(void); // void func_80123434(void); // void func_80123448(void); @@ -2160,7 +2088,7 @@ void func_80123F2C(GlobalContext* globalCtx, s32 arg1); // void func_80124020(void); u8 Player_GetMask(GlobalContext* globalCtx); void Player_RemoveMask(GlobalContext* globalCtx); -// void func_8012405C(void); +s32 func_8012405C(GlobalContext* globalCtx); // void func_80124088(void); s32 func_801240C8(Player* player); // void func_801240DC(void); @@ -2172,7 +2100,7 @@ s32 func_801240C8(Player* player); // void func_801241E0(void); // void func_8012420C(void); // void func_8012422C(void); -// void func_80124258(void); +s32 Player_GetExplosiveHeld(Player* player); // void func_80124278(void); s32 func_801242B4(Player* player); // void func_801242DC(void); @@ -2465,35 +2393,20 @@ UNK_TYPE func_80133038(GlobalContext* globalCtx, UNK_TYPE* arg1, struct_80133038 void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, s32 lod, Mtx** mtx); -void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, - OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, - s32 lod); -void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); -void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); -void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, - Mtx** limbMatricies); -void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); -void func_80134148(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor, - Mtx** mtx); -void func_801343C0(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor); +void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, s32 lod); +void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); +void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); +void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, Mtx** limbMatricies); +void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); +void func_80134148(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor, Mtx** mtx); +void func_801343C0(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor); void SkelAnime_GetFrameData(AnimationHeader* animationSeg, s32 currentFrame, s32 limbCount, Vec3s* dst); s16 Animation_GetLength(void* animation); s16 Animation_GetLastFrame(void* animation); -Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); -Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); -Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, - Mtx** mtx, Gfx* gfx); -Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, - OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); +Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); +Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); +Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); +Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); s16 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Vec3s* frameTable); s16 Animation_GetLimbCount2(LegacyAnimationHeader* animation); s16 Animation_GetLength2(LegacyAnimationHeader* animation); @@ -2503,8 +2416,7 @@ void AnimationContext_Reset(AnimationContext* animationCtx); void AnimationContext_SetNextQueue(GlobalContext* globalCtx); void AnimationContext_DisableQueue(GlobalContext* globalCtx); AnimationEntry* AnimationContext_AddEntry(AnimationContext* animationCtx, AnimationType type); -void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader* animation, s32 frame, - s32 limbCount, Vec3s* frameTable); +void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable); void AnimationContext_SetCopyAll(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src); void AnimationContext_SetInterp(GlobalContext* globalCtx, s32 limbCount, Vec3s* arg2, Vec3s* arg3, f32 arg4); void AnimationContext_SetCopyTrue(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); @@ -2517,9 +2429,7 @@ void AnimationContext_CopyTrue(GlobalContext* globalCtx, AnimationEntryData* dat void AnimationContext_CopyFalse(GlobalContext* globalCtx, AnimationEntryData* data); void AnimationContext_MoveActor(GlobalContext* globalCtx, AnimationEntryData* data); void AnimationContext_Update(GlobalContext* globalCtx, AnimationContext* animationCtx); -void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, - LinkAnimationHeader* animation, s32 flags, Vec3s* jointTable, - Vec3s* morphTable, s32 limbBufCount); +void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, LinkAnimationHeader* animation, s32 flags, Vec3s* jointTable, Vec3s* morphTable, s32 limbBufCount); void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime); s32 LinkAnimation_Update(GlobalContext* globalCtx, SkelAnime* skelAnime); s32 LinkAnimation_Morph(GlobalContext* globalCtx, SkelAnime* skelAnime); @@ -2543,8 +2453,7 @@ void LinkAnimation_EndLoop(SkelAnime* skelAnime); s32 Animation_OnFrameImpl(SkelAnime* skelAnime, f32 arg1, f32 updateRate); s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 arg1); void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); -void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, - AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); +void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg); void SkelAnime_SetUpdate(SkelAnime* skelAnime); s32 SkelAnime_Update(SkelAnime* skelAnime); @@ -2617,7 +2526,7 @@ void func_8013A46C(s32 flag); u32 func_8013A4C4(s32 flag); s16 func_8013A504(s16 val); s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleError); -Actor* func_8013A7C0(GlobalContext* globalCtx, s32 arg1); +struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5); Gfx* func_8013A860(GlobalContext* globalCtx, s32 idx, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, UnkActorDraw unkActorDraw, Actor* actor, Mtx** mtx, Gfx* gfx); Gfx* func_8013AB00(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, UnkActorDraw unkActorDraw, Actor* actor, Gfx* gfx); s32 func_8013AD6C(GlobalContext* globalCtx); @@ -2630,7 +2539,7 @@ void func_8013B350(Vec3f* arg0, f32* arg1, f32 arg2, s32 arg3, s32 arg4, Vec3s* s32 func_8013B6B0(Path* path, f32* arg1, s32* arg2, s32 arg3, s32 arg4, s32* arg5, f32* arg6, Vec3f* arg7, s32 arg8); void func_8013B878(GlobalContext* globalCtx, Path* path, s32 arg2, Vec3f* arg3); Path* func_8013BB34(GlobalContext* globalCtx, u8 arg1, s32 arg2); -Actor* func_8013BB7C(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId); +Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId); s32 func_8013BC6C(SkelAnime* skelAnime, ActorAnimationEntryS* arg1, s32 arg2); s32 func_8013BD40(Actor* actor, Path* path, s32 arg2); Path* func_8013BEDC(GlobalContext* globalCtx, u8 arg1, u8 arg2, s32* arg3); @@ -2651,7 +2560,7 @@ s32 func_8013D768(Actor* actor, Vec3f* arg1, s16 arg2); s16 func_8013D83C(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); s8 func_8013D8DC(s8 arg0, GlobalContext* globalCtx); s8 func_8013D924(s16 arg0, GlobalContext* globalCtx); -Actor* func_ActorCategoryIterateById(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); +Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); s32 func_8013D9C8(GlobalContext* globalCtx, s16* arg1, s16* arg2, s32 arg3); s32 func_8013DB90(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2); s32 func_8013DC40(Path* arg0, s32 arg1, s32 arg2, Vec3f* arg3); @@ -2666,17 +2575,17 @@ s32 func_8013E2D4(Actor* actor, s16 arg1, s16 arg2, s32 arg3); s32 func_8013E3B8(Actor* actor, s16 cutscenes[], s16 len); void func_8013E4B0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Plane* plane); s32 func_8013E5CC(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4, Vec3f* arg5); -Actor* func_8013E640(GlobalContext* globalCtx, Actor* arg1, Actor* actorListStart, u8 actorCategory, s16 actorId, void* arg5, func_8013E640_arg6 arg6); +Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, Vec3s* arg5, func_8013E748_arg6 arg6); s32 func_8013E7C0(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2); void func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s16 arg5, s16 arg6); s32 func_8013E950(Vec3f* arg0, Vec3f* arg1, s16 arg2, Vec3f* arg3, Vec3f* arg4, s16* arg5, s16* arg6, s16* arg7, s16* arg8, u16 arg9, u16 arg10, u16 arg11, u16 arg12); // void func_8013EC10(void); -void func_8013EC44(f32 arg0, u8 arg1, u8 arg2, u8 arg3); +void func_8013EC44(f32 a, u8 b, u8 c, u8 d); void func_8013ECE0(f32 xyzDistToPlayerSq, u8 arg1, u8 arg2, u8 arg3); void func_8013ED9C(void); void func_8013EDD0(void); -// void func_8013EE04(void); +u32 func_8013EE04(void); void func_8013EE24(void); // void func_8013EE38(void); // void func_8013EE48(void); @@ -2739,8 +2648,7 @@ void VisMono_Draw(void* arg0, Gfx** gfx, u32 arg2); void func_801420C0(void* arg0); void func_801420F4(void* arg0); void func_80142100(void* arg0, Gfx** gfx, u32 arg2); -s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* vtx, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, - s32 arg8); +s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* vtx, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8); void func_80143148(SkyboxContext* skyboxCtx, s32 arg1); void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType); @@ -2822,7 +2730,7 @@ void func_80151BB4(GlobalContext* globalCtx, u32 uParm2); // void func_80151DA4(void); void func_80152434(GlobalContext* globalCtx, u16 arg2); // void func_80152464(void); -u8 func_80152498(MessageContext* msgCtx); +u8 Message_GetState(MessageContext* msgCtx); // void func_8015268C(void); // void func_80152C64(void); // void func_80152CAC(void); @@ -2924,7 +2832,7 @@ void* TransitionFade_Init(void* param_1); // void TransitionCircle_Update(void); // void TransitionCircle_SetColor(void); // void TransitionCircle_SetType(void); -// void func_80164C14(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); +void func_80164C14(Gfx** arg0, TexturePtr* arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, f32 arg6); // void TransitionCircle_Draw(void); // void TransitionCircle_IsDone(void); // void func_801651B0(void); @@ -2960,7 +2868,7 @@ void Play_Draw(GlobalContext* globalCtx); void func_80168DAC(GlobalContext* globalCtx); void Play_Update(GlobalContext* globalCtx); s32 func_801690CC(GlobalContext* globalCtx); -// void func_80169100(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); +f32 func_80169100(GlobalContext* globalCtx, MtxF* mtx, CollisionPoly** arg2, s32* arg3, Vec3f* feetPosPtr); // void func_801691F0(void); void* Play_LoadScene(GlobalContext* globalCtx, RomFile* entry); void func_8016927C(GlobalContext* globalCtx, s16 sParm2); @@ -2983,7 +2891,7 @@ void func_801699D4(GlobalContext* globalCtx, s16 arg1, s16 arg2); void func_80169AFC(GlobalContext* globalCtx, s16 camId, s16 arg2); // void func_80169C64(void); // void func_80169C84(void); -// void convert_scene_number_among_shared_scenes(void); +s16 convert_scene_number_among_shared_scenes(s16 arg0); void func_80169D40(GlobalContext* globalCtx); void func_80169DCC(GlobalContext* globalCtx, s32 arg1, u16 arg2, s32 arg3, s32 arg4, Vec3f* arg5, s16 arg6); void func_80169E6C(GlobalContext* globalCtx, s32 param_1, s32 param_2); @@ -3038,8 +2946,7 @@ void PreRender_ApplyFiltersSlowlyInit(PreRender* this); void PreRender_ApplyFiltersSlowlyDestroy(PreRender* this); void func_801720C4(PreRender* this); void func_801720FC(PreRenderParams* params, Gfx** gfxp); -void func_80172758(Gfx** gfxp, void* timg, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tt, u16 arg8, f32 x, - f32 y, f32 xScale, f32 yScale, u32 flags); +void func_80172758(Gfx** gfxp, void* timg, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tt, u16 arg8, f32 x, f32 y, f32 xScale, f32 yScale, u32 flags); void THGA_Ct(TwoHeadGfxArena* thga, Gfx* start, size_t size); void THGA_Dt(TwoHeadGfxArena* thga); u32 THGA_IsCrash(TwoHeadGfxArena* thga); @@ -3283,7 +3190,7 @@ s32 Math3D_TriChkLineSegParaZIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, // void func_8017D404(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); void Math3D_TriSetCoords(TriNorm* tri, Vec3f* pointA, Vec3f* pointB, Vec3f* pointC); u32 Math3D_IsPointInSphere(Sphere16* sphere, Vec3f* point); -// void func_8017D668(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); +s32 Math3D_PointDistToLine2D(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32* arg6, f32* arg7, f32* arg8); // returns boolean // void func_8017D7C0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); // void func_8017D814(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8017D91C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); @@ -3786,8 +3693,8 @@ void func_8019F170(Vec3f* pos, u16 sfxId); void func_8019F1C0(Vec3f* pos, u16 sfxId); void play_sound(u16 sfxId); void func_8019F128(u16 sfxId); -void func_8019F208(void); // decide -void func_8019F230(void); // cancel +void func_8019F208(void); // Decide sound +void func_8019F230(void); // Cancel sound // void func_8019F258(void); // void func_8019F300(void); void func_8019F420(Vec3f* pos, u16 sfxId); @@ -3802,7 +3709,7 @@ void func_8019F570(Vec3f* pos, s8 arg1); void func_8019F88C(Vec3f* arg0, u16 sfxId, UNK_TYPE arg2); // void func_8019F900(void); // void func_8019FA18(void); -void func_8019FAD8(Vec3f* param_1, u16 param_2, f32 param_3); +void func_8019FAD8(Vec3f* param_1, u16 sfxId, f32 param_3); // void func_8019FB0C(void); // void func_8019FC20(void); // void func_8019FCB8(void); @@ -3826,7 +3733,7 @@ void func_801A0204(s8 seqId); // void func_801A0554(void); // void func_801A05F0(void); void func_801A0654(Vec3f* arg0, u16 sfxId, s32 arg2); -// void func_801A0810(void); +void func_801A0810(s32* arg0, u16 sfxId, u8 arg2); // void func_801A0868(void); // void func_801A09D4(void); // void func_801A0CB0(void); @@ -3844,7 +3751,7 @@ void func_801A1DB8(Vec3f* vec, u8 seqId, f32 arg2); // void func_801A1E0C(void); void func_801A1F00(u8 arg0, u16 seqId); void func_801A1F88(void); -// void func_801A1FB4(void); +void func_801A1FB4(u8 playerIdx, Vec3f* pos, u16 seqId, f32 maxDist); // void func_801A2090(void); void func_801A246C(u8 param_1, u8 param_2); // void func_801A2544(void); @@ -3936,7 +3843,7 @@ UNK_TYPE func_801A51F0(UNK_TYPE arg0); void func_801A5BD0(s32 param_1); // void func_801A5C28(void); // void func_801A5C8C(void); -void func_801A5CFC(u16 sfxId, Vec3f* param_2, u8 param_3, f32* param_4, f32* param_5, s8* param_6); +void Audio_PlaySfxGeneral(u16 sfxId, Vec3f* param_2, u8 param_3, f32* param_4, f32* param_5, s8* param_6); // void func_801A5DDC(void); // void func_801A5F7C(void); // void func_801A6430(void); diff --git a/include/initvars.h b/include/initvars.h index a1dbe1fa15..797e738764 100644 --- a/include/initvars.h +++ b/include/initvars.h @@ -1,6 +1,39 @@ #ifndef _INITVARS_H_ #define _INITVARS_H_ +extern EffectSsInit Effect_Ss_Dust_InitVars; +extern EffectSsInit Effect_Ss_Kirakira_InitVars; +extern EffectSsInit Effect_Ss_Bomb2_InitVars; +extern EffectSsInit Effect_Ss_Blast_InitVars; +extern EffectSsInit Effect_Ss_G_Spk_InitVars; +extern EffectSsInit Effect_Ss_D_Fire_InitVars; +extern EffectSsInit Effect_Ss_Bubble_InitVars; +extern EffectSsInit Effect_Ss_G_Ripple_InitVars; +extern EffectSsInit Effect_Ss_G_Splash_InitVars; +extern EffectSsInit Effect_Ss_G_Fire_InitVars; +extern EffectSsInit Effect_Ss_Lightning_InitVars; +extern EffectSsInit Effect_Ss_Dt_Bubble_InitVars; +extern EffectSsInit Effect_Ss_Hahen_InitVars; +extern EffectSsInit Effect_Ss_Stick_InitVars; +extern EffectSsInit Effect_Ss_Sibuki_InitVars; +extern EffectSsInit Effect_Ss_Stone1_InitVars; +extern EffectSsInit Effect_Ss_Hitmark_InitVars; +extern EffectSsInit Effect_Ss_Fhg_Flash_InitVars; +extern EffectSsInit Effect_Ss_K_Fire_InitVars; +extern EffectSsInit Effect_Ss_Solder_Srch_Ball_InitVars; +extern EffectSsInit Effect_Ss_Kakera_InitVars; +extern EffectSsInit Effect_Ss_Ice_Piece_InitVars; +extern EffectSsInit Effect_Ss_En_Ice_InitVars; +extern EffectSsInit Effect_Ss_Fire_Tail_InitVars; +extern EffectSsInit Effect_Ss_En_Fire_InitVars; +extern EffectSsInit Effect_Ss_Extra_InitVars; +extern EffectSsInit Effect_Ss_Dead_Db_InitVars; +extern EffectSsInit Effect_Ss_Dead_Dd_InitVars; +extern EffectSsInit Effect_Ss_Dead_Ds_InitVars; +extern EffectSsInit Effect_Ss_Ice_Smoke_InitVars; +extern EffectSsInit Effect_En_Ice_Block_InitVars; +extern EffectSsInit Effect_Ss_Sbn_InitVars; + extern ActorInit Arms_Hook_InitVars; extern ActorInit Arrow_Fire_InitVars; extern ActorInit Arrow_Ice_InitVars; diff --git a/include/io/controller.h b/include/io/controller.h index cbd4963ae8..4321df0966 100644 --- a/include/io/controller.h +++ b/include/io/controller.h @@ -99,8 +99,8 @@ typedef struct { /* 0x00 */ u32 ramarray[15]; - /* 0x3C */ u32 pifstatus; -} OSPifRam; + /* 0x3C */ u32 status; +} OSPifRam; // size = 0x40 typedef struct { @@ -153,4 +153,11 @@ extern u8 __osMaxControllers; // extern OSMesgQueue D_8009CF38; // extern OSMesg D_8009CF50; +typedef struct { + /* 0x00 */ OSContPad cur; + /* 0x06 */ OSContPad prev; + /* 0x0C */ OSContPad press; // X/Y store delta from last frame + /* 0x12 */ OSContPad rel; // X/Y store adjusted +} Input; // size = 0x18 + #endif diff --git a/include/macros.h b/include/macros.h index 1afbde243b..7e6104317a 100644 --- a/include/macros.h +++ b/include/macros.h @@ -39,9 +39,9 @@ } \ (void)0 -#define GET_PLAYER(globalCtx) ((Player*)(globalCtx)->actorCtx.actorList[ACTORCAT_PLAYER].first) +#define GET_PLAYER(globalCtx) ((Player*)(globalCtx)->actorCtx.actorLists[ACTORCAT_PLAYER].first) -#define GET_FIRST_ENEMY(globalCtx) ((Actor*)(globalCtx)->actorCtx.actorList[ACTORCAT_ENEMY].first) +#define GET_FIRST_ENEMY(globalCtx) ((Actor*)(globalCtx)->actorCtx.actorLists[ACTORCAT_ENEMY].first) // linkAge still exists in MM, but is always set to 0 (always adult) // There are remnants of these macros from OOT, but they are essentially useless @@ -86,6 +86,8 @@ #define CHECK_BTN_ALL(state, combo) (~((state) | ~(combo)) == 0) #define CHECK_BTN_ANY(state, combo) (((state) & (combo)) != 0) +#define CHECK_FLAG_ALL(flags, mask) (((flags) & (mask)) == (mask)) + extern GraphicsContext* __gfxCtx; #define WORK_DISP __gfxCtx->work.p @@ -147,6 +149,9 @@ extern GraphicsContext* __gfxCtx; (b) = _temp; \ } +#define OVERLAY_RELOCATION_OFFSET(overlayEntry) ((uintptr_t)((overlayEntry)->vramStart) - (uintptr_t)((overlayEntry)->loadedRamAddr)) +#define VRAM_PTR_SIZE(entry) ((uintptr_t)((entry)->vramEnd) - (uintptr_t)((entry)->vramStart)) + #ifdef __GNUC__ #define ALIGNED8 __attribute__ ((aligned (8))) #else diff --git a/include/ultra64/hardware.h b/include/ultra64/hardware.h index ae6470d51d..57d560ab02 100644 --- a/include/ultra64/hardware.h +++ b/include/ultra64/hardware.h @@ -53,6 +53,8 @@ #define SP_DMEM_START 0x04000000 #define SP_DMEM_SIZE 0x1000 +#define TMEM_SIZE 0x1000 + #define SP_MEM_ADDR_REG 0x04040000 #define SP_DRAM_ADDR_REG 0x04040004 #define SP_RD_LEN_REG 0x04040008 diff --git a/include/variables.h b/include/variables.h index e77dc466d5..6d1fc3ef96 100644 --- a/include/variables.h +++ b/include/variables.h @@ -374,7 +374,6 @@ extern u8 D_801AE214[32]; // extern UNK_TYPE4 D_801AE240; // extern UNK_TYPE4 D_801AE250; extern UNK_PTR D_801AE260[3]; -// extern UNK_TYPE4 D_801AE26C; // extern UNK_TYPE4 D_801AE27C; // extern UNK_TYPE4 D_801AE28C; // extern UNK_TYPE4 D_801AE29C; @@ -382,7 +381,7 @@ extern UNK_PTR D_801AE260[3]; // extern UNK_TYPE4 D_801AE2BC; // extern UNK_TYPE4 D_801AE2CC; // extern UNK_TYPE4 D_801AE2DC; -extern EffectSsInfo EffectSS2Info; +// extern EffectSsInfo sEffectSsInfo; // extern UNK_TYPE1 D_801AE3B0; // extern UNK_TYPE1 D_801AE3B4; // extern UNK_TYPE4 D_801AE3B8; @@ -410,16 +409,13 @@ extern EffectSsInfo EffectSS2Info; // extern UNK_TYPE1 D_801AE48A; // extern UNK_TYPE1 D_801AE48C; // extern UNK_TYPE1 D_801AE490; -extern EffectSsOverlay particleOverlayTable[39]; +extern EffectSsOverlay gParticleOverlayTable[39]; // extern FlagSetEntry sFlagEntries[]; // extern s32 sEntryIndex; // extern u32 sCurrentBit; // extern s32 sTimer; -extern Color_RGBA8 D_801AEC80; -extern s801AEC84 D_801AEC84[13]; extern f32 actorMovementScale; -extern f32 D_801AECF0; -extern f32 D_801AECF4; +extern TargetRangeParams gTargetRanges[]; extern s16 D_801AED48[8]; // extern UNK_TYPE4 D_801AED58; extern Color_RGBA8 actorDefaultHitColor; @@ -2838,7 +2834,7 @@ extern f32 D_801DE860; extern f32 D_801DE864; extern f32 D_801DE868; extern f32 D_801DE884; -// extern UNK_TYPE1 D_801DE890; +extern TexturePtr D_801DE890[]; extern f32 D_801DF090; extern f32 D_801DF094; extern f32 D_801DF0A0; @@ -3102,15 +3098,15 @@ extern u64 gJpegUCodeData[]; // bss // extern UNK_TYPE1 D_801ED890; -// extern UNK_TYPE1 D_801ED8A0; -// extern UNK_TYPE1 D_801ED8B0; -// extern UNK_TYPE1 D_801ED8B4; +// extern UNK_TYPE1 D_801ED894; +extern CollisionPoly* D_801ED8B0; +extern s32 D_801ED8B4; // extern UNK_TYPE1 D_801ED8B8; // extern UNK_TYPE1 D_801ED8BC; // extern UNK_TYPE1 D_801ED8C0; // extern UNK_TYPE1 D_801ED8C4; extern f32 D_801ED8C8; -extern f32 D_801ED8CC; +extern f32 sBgmEnemyDistSq; extern f32 D_801ED8D0; // extern UNK_TYPE1 D_801ED8D4; // extern UNK_TYPE1 D_801ED8D8; @@ -3866,14 +3862,6 @@ extern UNK_TYPE D_0400E3D8; extern UNK_TYPE D_0400E408; extern UNK_TYPE D_0400E410; extern UNK_TYPE D_0400E418; -extern CollisionHeader D_0400E710; // Pink Deku Flower collision -extern AnimationHeader D_0400EB7C; // Deku Flower intense flutter animation -extern Gfx D_0400ED80; // Pink Deku Flower display list -extern SkeletonHeader D_04011518; // Pink Deku Flower skeleton -extern AnimationHeader D_040117A8; // Deku Flower small flutter animation -extern CollisionHeader D_040118D8; // Gold Deku Flower collision -extern Gfx D_04011BD0; // Gold Deku Flower display list -extern SkeletonHeader D_040127E8; // Gold Deku Flower skeleton extern UNK_TYPE D_04012860; extern UNK_TYPE D_040128BC; extern u64 D_04014570[]; @@ -3895,7 +3883,6 @@ extern Gfx D_04023210[]; extern UNK_TYPE D_04023288; extern Gfx D_04023348[]; extern Gfx D_04023428[]; -extern UNK_TYPE D_04025850; extern UNK_TYPE D_04025DD0; extern UNK_TYPE D_040281DC; extern UNK_TYPE D_04028FEC; @@ -3903,16 +3890,9 @@ extern AnimationHeader D_04029140; extern Gfx D_04029CB0[]; extern Gfx D_04029CF0[]; extern UNK_TYPE D_04029D20; -extern AnimationHeader D_0402B494; -extern AnimatedMaterial D_0402C818; -extern AnimatedMaterial D_0402C890; -extern AnimatedMaterial D_0402C908; -extern AnimatedMaterial D_0402C980; -extern AnimatedMaterial D_0402C9F8; -extern FlexSkeletonHeader D_0402CA98; extern Gfx D_0402E510[]; -extern UNK_TYPE D_0402E65C; -extern UNK_TYPE D_0402F0EC; +extern AnimationHeader D_0402E65C; +extern AnimationHeader D_0402F0EC; extern Gfx D_04030100[]; // Floor shockwave ring extern Gfx D_040301B0[]; extern UNK_TYPE D_04032270; @@ -3934,8 +3914,8 @@ extern UNK_TYPE D_0403F230; extern UNK_TYPE D_04044300; extern Gfx D_04048DF0[]; extern UNK_TYPE D_04050D10; -extern UNK_TYPE D_04051180; -extern UNK_TYPE D_04051238; +extern Gfx D_04051180[]; +extern Gfx D_04051238[]; extern AnimationHeader D_0405140C; extern Gfx D_040527F0[]; extern Gfx D_040528B0[]; @@ -3954,7 +3934,8 @@ extern TexturePtr D_0408EFE0[]; // gDust6Tex extern TexturePtr D_0408F3E0[]; // gDust7Tex extern TexturePtr D_0408F7E0[]; // gDust8Tex extern UNK_TYPE D_04050550; -extern UNK_TYPE D_04050648; +extern Gfx D_04050648[]; +extern Gfx D_040506E0[]; extern UNK_TYPE D_040510B0; extern UNK_TYPE D_04054940; extern Gfx D_0405AAB0[]; @@ -3980,17 +3961,14 @@ extern Gfx D_0406AB30[]; extern UNK_TYPE D_0406B730; extern UNK_TYPE D_0406BB0C; extern UNK_TYPE D_0406F380; +extern Gfx D_040706E0[]; extern UNK_TYPE D_04073F00; extern UNK_TYPE D_04075400; -extern Gfx D_04075A40[]; -extern Gfx D_04075B30[]; extern Gfx D_04076BC0[]; -extern Gfx D_04077480[]; extern UNK_TYPE D_04079B10; extern Gfx D_0407AB10[]; // sun (sparkles when small) displaylist extern Gfx D_0407AB58[]; extern UNK_TYPE D_0407AFB0; -extern Gfx gGameplayKeepDrawFlameDL[]; extern UNK_TYPE D_0407D650; extern UNK_TYPE D_0407F218; extern UNK_TYPE D_040815D0; @@ -3998,12 +3976,16 @@ extern UNK_TYPE D_04081628; extern UNK_TYPE D_04083534; extern UNK_TYPE D_04091BE0; extern UNK_TYPE D_04091CE0; +extern TexturePtr D_04091DE0[]; +extern TexturePtr D_04091FE0[]; +extern TexturePtr D_040921E0[]; +extern TexturePtr D_040923E0[]; extern Gfx D_05000C40[]; extern UNK_TYPE D_05001D20; -extern UNK_TYPE D_050061E8; -extern UNK_TYPE D_05006420; -extern UNK_TYPE D_050066B0; +extern Gfx D_050061E8[]; +extern Gfx D_05006420[]; +extern Gfx D_050066B0[]; extern UNK_TYPE D_05007498; extern Gfx D_05007890[]; extern Gfx D_050078A0[]; @@ -4024,7 +4006,7 @@ extern UNK_TYPE D_0502324C; // other segments extern GfxMasterList D_0E000000; - +extern Mtx D_01000000; extern UNK_TYPE D_0F000000; diff --git a/include/z64.h b/include/z64.h index e34af950e1..248c0f7baf 100644 --- a/include/z64.h +++ b/include/z64.h @@ -334,26 +334,6 @@ typedef struct { /* 0x24 */ s16 unk_24; } SramContext; // size = 0x28 -typedef struct { - /* 0x00 */ UNK_TYPE4 unk0; - /* 0x04 */ UNK_TYPE4 unk4; - /* 0x08 */ UNK_TYPE4 unk8; - /* 0x0C */ f32 unkC; - /* 0x10 */ Color_RGBA8 unk10; -} TargetContextEntry; // size = 0x14 - -typedef struct { - /* 0x0 */ u32 texture; - /* 0x4 */ s16 unk4; - /* 0x6 */ s16 unk6; - /* 0x8 */ u8 unk8; - /* 0x9 */ u8 unk9; - /* 0xA */ u8 fadeOutDelay; - /* 0xB */ u8 fadeInDelay; - /* 0xC */ s16 alpha; - /* 0xE */ s16 color; -} TitleCardContext; // size = 0x10 - typedef struct { /* 0x0 */ s32 topY; /* 0x4 */ s32 bottomY; @@ -392,15 +372,27 @@ typedef struct { } s80185D40; // size = 0x2C typedef struct { - /* 0x0 */ u8 unk0; - /* 0x1 */ u8 unk1; - /* 0x2 */ u8 unk2; - /* 0x3 */ u8 unk3; - /* 0x4 */ u8 unk4; - /* 0x5 */ u8 unk5; - /* 0x6 */ u8 unk6; - /* 0x7 */ u8 unk7; -} s801AEC84; // size = 0x8 + /* 0x00 */ u32 unk0; + /* 0x04 */ u8 unk4; + /* 0x05 */ u8 unk5; + /* 0x06 */ u8 unk6; + /* 0x07 */ UNK_TYPE1 pad7[0x2]; + /* 0x09 */ u8 unk9; + /* 0x0A */ UNK_TYPE1 padA[0x2]; + /* 0x0C */ u32 unkC; + /* 0x10 */ u16 unk10; + /* 0x12 */ u16 unk12; + /* 0x14 */ u16 unk14; + /* 0x16 */ UNK_TYPE1 pad16[0x2]; + /* 0x18 */ u32 unk18; + /* 0x1C */ u32 unk1C; + /* 0x20 */ u32 unk20; + /* 0x24 */ u32 unk24; + /* 0x28 */ u32 unk28; + /* 0x2C */ u32 unk2C; + /* 0x30 */ u32 unk30; + /* 0x34 */ u32 unk34; +} s8018CFAC; // size = 0x38 typedef struct { /* 0x00 */ Vec3f unk0; @@ -480,13 +472,6 @@ typedef struct { /* 0x10 */ Vec3f relativePos; } SoundSource; // size = 0x1C -typedef struct { - /* 0x00 */ OSContPad cur; - /* 0x06 */ OSContPad prev; - /* 0x0C */ OSContPad press; // X/Y store delta from last frame - /* 0x12 */ OSContPad rel; // X/Y store adjusted -} Input; // size = 0x18 - typedef struct { /* 0x000 */ u32 magic; /* 0x004 */ GraphicsContext* gfxCtx; @@ -743,7 +728,7 @@ typedef struct { /* 0x22 */ u16 unk_22; /* 0x24 */ u16 unk_24; /* 0x26 */ u8 unk_26; - /* 0x28 */ LightInfo unk_28; // sun 1 + /* 0x28 */ LightInfo dirLight1; // sun 1 /* 0x36 */ LightInfo unk_36; // sun 2 /* 0x44 */ s8 unk_44; /* 0x48 */ DmaRequest unk_48; @@ -877,7 +862,9 @@ typedef struct { /* 0x1202A */ u16 unk1202A; /* 0x1202C */ UNK_TYPE1 pad1202C[0x2]; /* 0x1202E */ u16 unk1202E; - /* 0x12030 */ UNK_TYPE1 pad12030[0x14]; + /* 0x12030 */ s16 unk_12030; + /* 0x12032 */ UNK_TYPE1 unk_12032[0x2]; + /* 0x12034 */ UNK_TYPE1 pad12034[0x10]; /* 0x12044 */ s16 unk12044; /* 0x12046 */ UNK_TYPE1 pad12046[0x2]; /* 0x12048 */ u8 unk12048; // EnKakasi @@ -1197,24 +1184,12 @@ typedef enum { STACK_STATUS_OVERFLOW = 2 } StackStatus; -typedef struct TargetContext TargetContext; - -typedef struct ActorContext ActorContext; - -typedef struct s800B948C s800B948C; - struct FireObjLight { /* 0x00 */ LightNode* light; /* 0x04 */ LightInfoPositional lightInfo; /* 0x12 */ u8 unk12; }; // size = 0x13 -typedef struct ActorListEntry { - /* 0x0 */ s32 length; // number of actors loaded of this type - /* 0x4 */ Actor* first; // pointer to first actor of this type - /* 0x8 */ UNK_TYPE1 pad8[0x4]; -} ActorListEntry; // size = 0xC - #define OS_SC_RETRACE_MSG 1 #define OS_SC_DONE_MSG 2 #define OS_SC_NMI_MSG 3 // name is made up, 3 is OS_SC_RDP_DONE_MSG in the original sched.c @@ -1271,72 +1246,6 @@ struct FireObj { /* 0x78 */ FireObjLight light; }; // size = 0x8B -struct TargetContext { - /* 0x00 */ Vec3f unk0; - /* 0x0C */ Vec3f unkC; - /* 0x18 */ Color_RGBAf unk18; - /* 0x28 */ Color_RGBAf unk28; - /* 0x38 */ Actor* unk38; - /* 0x3C */ Actor* unk3C; - /* 0x40 */ f32 unk40; - /* 0x44 */ f32 unk44; - /* 0x48 */ s16 unk48; - /* 0x4A */ u8 unk4A; - /* 0x4B */ u8 unk4B; - /* 0x4C */ s8 unk4C; - /* 0x4D */ UNK_TYPE1 pad4D[0x3]; - /* 0x50 */ TargetContextEntry unk50[3]; - /* 0x8C */ Actor* unk8C; - /* 0x90 */ Actor* unk90; - /* 0x94 */ Actor* unk_94; -}; // size = 0x98 - -struct s800B948C { - /* 0x00 */ GlobalContext* globalCtx; - /* 0x04 */ Actor* actor; - /* 0x08 */ u32 updateActorIfSet; - /* 0x0C */ u32 unkC; - /* 0x10 */ Actor* unk10; - /* 0x14 */ Player* player; - /* 0x18 */ u32 runMainIfSet; // Bitmask of actor flags. The actor will only have main called if it has at least 1 flag set that matches this bitmask -}; // size = 0x1C - -struct ActorContext { - /* 0x000 */ UNK_TYPE1 pad0[0x2]; - /* 0x002 */ u8 unk2; - /* 0x003 */ u8 unk3; - /* 0x004 */ s8 unk4; - /* 0x005 */ u8 unk5; - /* 0x006 */ UNK_TYPE1 pad6[0x5]; - /* 0x00B */ s8 unkB; - /* 0x00C */ s16 unkC; - /* 0x00E */ u8 totalLoadedActors; - /* 0x00F */ u8 undrawnActorCount; - /* 0x010 */ ActorListEntry actorList[12]; - /* 0x0A0 */ Actor* undrawnActors[32]; // Records the first 32 actors drawn each frame - /* 0x120 */ TargetContext targetContext; - /* 0x1B8 */ u32 switchFlags[4]; // First 0x40 are permanent, second 0x40 are temporary - /* 0x1C8 */ u32 chestFlags; - /* 0x1CC */ u32 clearedRooms; - /* 0x1D0 */ u32 clearedRoomsTemp; - /* 0x1D4 */ u32 collectibleFlags[4]; // bitfield of 128 bits - /* 0x1E4 */ TitleCardContext titleCtxt; - /* 0x1F4 */ u8 unk1F4; - /* 0x1F5 */ u8 unk1F5; - /* 0x1F6 */ UNK_TYPE1 pad1F6[0x2]; - /* 0x1F8 */ f32 unk1F8; - /* 0x1FC */ Vec3f unk1FC; - /* 0x208 */ UNK_TYPE1 pad208[0x48]; - /* 0x250 */ void* unk250; // allocation of 0x20f0 bytes? - /* 0x254 */ u32 unk254[5]; - /* 0x268 */ u8 unk268; - /* 0x269 */ UNK_TYPE1 pad269[0x3]; - /* 0x26C */ UNK_TYPE1 pad26C[0xC]; - /* 0x278 */ u16 unk278; - /* 0x27A */ UNK_TYPE1 pad27A[0x2]; - /* 0x27C */ UNK_TYPE1 pad27C[0x8]; -}; // size = 0x284 - typedef struct { /* 0x00 */ u8 seqIndex; /* 0x01 */ u8 nightSeqIndex; @@ -1448,7 +1357,9 @@ struct GlobalContext { /* 0x18B4C */ PreRender pauseBgPreRender; /* 0x18B9C */ char unk_18B9C[0x2B8]; /* 0x18E54 */ SceneTableEntry* loadedScene; - /* 0x18E58 */ char unk_18E58[0x400]; + /* 0x18E58 */ char unk_18E58[0x10]; + /* 0x18E68 */ s32 unk_18E68; + /* 0x18E6C */ char unk_18E6C[0x3EC]; }; // size = 0x19258 typedef struct { @@ -1504,7 +1415,7 @@ typedef struct { typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, Vec3s*); -typedef s32 (*func_8013E640_arg6)(struct GlobalContext*, Actor*, Actor*, void*); +typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); struct struct_8013DF3C_arg1; typedef void (*struct_8013DF3C_arg1_unk_func1)(struct GlobalContext*, struct struct_8013DF3C_arg1*); @@ -1577,6 +1488,11 @@ typedef struct DebugDispObject { /* 0x2C */ s32 pad; //Padding not in the OOT version } DebugDispObject; // size = 0x30 +typedef struct { + /* 0x0 */ f32 rangeSq; + /* 0x4 */ f32 leashScale; +} TargetRangeParams; // size = 0x8 + typedef struct { /* 0x00 */ u8* value; /* 0x04 */ const char* name; diff --git a/include/z64actor.h b/include/z64actor.h index 2b35bec243..3ed9e2a335 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -1,5 +1,5 @@ -#ifndef _Z64ACTOR_H_ -#define _Z64ACTOR_H_ +#ifndef Z64ACTOR_H +#define Z64ACTOR_H #include "PR/ultratypes.h" #include "z64math.h" @@ -7,6 +7,8 @@ #include "z64collision_check.h" #include "unk.h" +// This value is hardcoded to be the size of ovl_Arrow_Fire which currently is the biggest actor that uses the AM_FIELD. +#define AM_FIELD_SIZE SEGMENT_SIZE(ovl_Arrow_Fire) #define MASS_IMMOVABLE 0xFF // Cannot be pushed by OC collisions #define MASS_HEAVY 0xFE // Can only be pushed by OC collisions with IMMOVABLE and HEAVY objects. @@ -15,6 +17,9 @@ struct GlobalContext; struct Lights; struct CollisionPoly; +struct EnBox; +struct EnDoor; + typedef void(*ActorFunc)(struct Actor* this, struct GlobalContext* globalCtx); typedef struct { @@ -116,6 +121,8 @@ typedef struct { /* 0x10 */ f32 shadowScale; // Changes the size of the shadow /* 0x14 */ u8 shadowAlpha; // Default is 255 /* 0x15 */ u8 feetFloorFlags; // Set if the actor's foot is clipped under the floor. & 1 is right foot, & 2 is left + /* 0x16 */ u8 unk_16; + /* 0x17 */ u8 unk_17; /* 0x18 */ Vec3f feetPos[2]; // Update by using `Actor_SetFeetPos` in PostLimbDrawOpa } ActorShape; // size = 0x30 @@ -131,15 +138,15 @@ typedef struct Actor { /* 0x020 */ s16 unk20; /* 0x024 */ PosRot world; // Position/rotation in the world /* 0x038 */ s8 cutscene; - /* 0x039 */ s8 unk39; + /* 0x039 */ u8 audioFlags; // Another set of flags? Seems related to sfx or bgm /* 0x03C */ PosRot focus; // Target reticle focuses on this position. For player this represents head pos and rot - /* 0x050 */ u16 sfx; // SFX ID to play. Sound plays when value is set, then is cleared the following update cycle + /* 0x050 */ u16 sfxId; // Id of sound effect to play. Plays when value is set, then is cleared the following update cycle /* 0x054 */ f32 targetArrowOffset; // Height offset of the target arrow relative to `focus` position /* 0x058 */ Vec3f scale; // Scale of the actor in each axis /* 0x064 */ Vec3f velocity; // Velocity of the actor in each axis /* 0x070 */ f32 speedXZ; // How fast the actor is traveling along the XZ plane /* 0x074 */ f32 gravity; // Acceleration due to gravity. Value is added to Y velocity every frame - /* 0x078 */ f32 minVelocityY; // Sets the lower bounds cap on velocity along the Y axis + /* 0x078 */ f32 terminalVelocity; // Sets the lower bounds cap on velocity along the Y axis /* 0x07C */ struct CollisionPoly* wallPoly; // Wall polygon the actor is touching /* 0x080 */ struct CollisionPoly* floorPoly; // Floor polygon directly below the actor /* 0x084 */ u8 wallBgId; // Bg ID of the wall polygon the actor is touching @@ -168,12 +175,12 @@ typedef struct Actor { /* 0x11C */ u8 colorFilterTimer; // A non-zero value enables the color filter. Decrements automatically /* 0x11D */ u8 isDrawn; // Set to true if the actor is currently being drawn. Always stays false for lens actors /* 0x11E */ u8 dropFlag; // Configures what item is dropped by the actor from `Item_DropCollectibleRandom` - /* 0x11F */ u8 hintId; // Sets what 0600 dialog to display when talking to navi. Default 0xFF + /* 0x11F */ u8 hintId; // Sets what 0600 dialog to display when talking to Tatl. Default 0xFF /* 0x120 */ struct Actor* parent; // Usage is actor specific. Set if actor is spawned via `Actor_SpawnAsChild` /* 0x124 */ struct Actor* child; // Usage is actor specific. Set if actor is spawned via `Actor_SpawnAsChild` /* 0x128 */ struct Actor* prev; // Previous actor of this category /* 0x12C */ struct Actor* next; // Next actor of this category - /* 0x130 */ ActorFunc init; // Initialization Routine. Called by `Actor_Init` or `Actor_UpdateAll` + /* 0x130 */ ActorFunc init; // Initialization Routine. Called by `Actor_InitContext` or `Actor_UpdateAll` /* 0x134 */ ActorFunc destroy; // Destruction Routine. Called by `Actor_Destroy` /* 0x138 */ ActorFunc update; // Update Routine. Called by `Actor_UpdateAll` /* 0x13C */ ActorFunc draw; // Draw Routine. Called by `Actor_Draw` @@ -287,7 +294,8 @@ typedef enum { /* 0x08 */ ACTORCAT_MISC, /* 0x09 */ ACTORCAT_BOSS, /* 0x0A */ ACTORCAT_DOOR, - /* 0x0B */ ACTORCAT_CHEST + /* 0x0B */ ACTORCAT_CHEST, + /* 0x0C */ ACTORCAT_MAX } ActorType; typedef struct { @@ -308,6 +316,96 @@ typedef struct { /* 0x0E */ s16 transitionRate; } ActorAnimationEntryS; // size = 0x10 +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ f32 unkC; + /* 0x10 */ Color_RGBA8 color; +} TargetContextEntry; // size = 0x14 + +typedef struct TargetContext { + /* 0x00 */ Vec3f unk0; + /* 0x0C */ Vec3f targetCenterPos; + /* 0x18 */ Color_RGBAf fairyInner; + /* 0x28 */ Color_RGBAf fairyOuter; + /* 0x38 */ Actor* arrowPointedActor; + /* 0x3C */ Actor* targetedActor; + /* 0x40 */ f32 unk40; + /* 0x44 */ f32 unk44; + /* 0x48 */ s16 unk48; // alpha + /* 0x4A */ u8 unk4A; + /* 0x4B */ u8 unk4B; + /* 0x4C */ s8 unk4C; + /* 0x4D */ UNK_TYPE1 pad4D[0x3]; + /* 0x50 */ TargetContextEntry unk50[3]; + /* 0x8C */ Actor* unk8C; + /* 0x90 */ Actor* bgmEnemy; + /* 0x94 */ Actor* unk_94; +} TargetContext; // size = 0x98 + +typedef struct { + /* 0x0 */ TexturePtr texture; + /* 0x4 */ s16 x; + /* 0x6 */ s16 y; + /* 0x8 */ u8 width; + /* 0x9 */ u8 height; + /* 0xA */ u8 durationTimer; // how long the title card appears for before fading + /* 0xB */ u8 delayTimer; // how long the title card waits to appear + /* 0xC */ s16 alpha; + /* 0xE */ s16 intensity; +} TitleCardContext; // size = 0x10 + +typedef struct ActorContext_unk_20C { + /* 0x0 */ s16 id; + /* 0x2 */ s8 isDynamicallyInitialised; + /* 0x4 */ void* ptr; +} ActorContext_unk_20C; // size = 0x8 + +typedef struct ActorContextFlags { + /* 0x00 */ u32 switches[4]; // First 0x40 are permanent, second 0x40 are temporary + /* 0x10 */ u32 chest; + /* 0x14 */ u32 clearedRoom; + /* 0x18 */ u32 clearedRoomTemp; + /* 0x1C */ u32 collectible[4]; // bitfield of 128 bits +} ActorContextFlags; // size = 0x2C + +typedef struct ActorListEntry { + /* 0x0 */ s32 length; // number of actors loaded of this type + /* 0x4 */ Actor* first; // pointer to first actor of this type + /* 0x8 */ s32 unk_08; +} ActorListEntry; // size = 0xC + +typedef struct ActorContext { + /* 0x000 */ u8 freezeFlashTimer; + /* 0x001 */ UNK_TYPE1 pad1; + /* 0x002 */ u8 unk2; + /* 0x003 */ u8 unk3; + /* 0x004 */ s8 unk4; + /* 0x005 */ u8 unk5; + /* 0x006 */ UNK_TYPE1 pad6[0x5]; + /* 0x00B */ s8 unkB; + /* 0x00C */ s16 unkC; + /* 0x00E */ u8 totalLoadedActors; + /* 0x00F */ u8 undrawnActorCount; + /* 0x010 */ ActorListEntry actorLists[ACTORCAT_MAX]; + /* 0x0A0 */ Actor* undrawnActors[32]; // Records the first 32 actors drawn each frame + /* 0x120 */ TargetContext targetContext; + /* 0x1B8 */ ActorContextFlags flags; + /* 0x1E4 */ TitleCardContext titleCtxt; + /* 0x1F4 */ u8 unk1F4; + /* 0x1F5 */ u8 unk1F5; + /* 0x1F6 */ UNK_TYPE1 pad1F6[0x2]; + /* 0x1F8 */ f32 unk1F8; + /* 0x1FC */ Vec3f unk1FC; + /* 0x208 */ UNK_TYPE1 unk_208[0x4]; + /* 0x20C */ ActorContext_unk_20C unk_20C[8]; + /* 0x24C */ UNK_TYPE1 unk_24C[0x4]; + /* 0x250 */ void* absoluteSpace; // Space used to allocate actor overlays of alloc type ALLOCTYPE_ABSOLUTE + /* 0x254 */ u32 unk254[5]; + /* 0x268 */ u8 unk268; + /* 0x269 */ UNK_TYPE1 pad269[0x3]; + /* 0x26C */ Input unk_26C; +} ActorContext; // size = 0x284 + typedef enum { /* 0x000 */ ACTOR_PLAYER, /* 0x001 */ ACTOR_EN_TEST, @@ -1002,6 +1100,76 @@ typedef enum { /* 0x2B2 */ ACTOR_ID_MAX // originally "ACTOR_DLF_MAX" } ActorID; +typedef enum { + /* 0 */ DOORLOCK_NORMAL, + /* 1 */ DOORLOCK_BOSS, + /* 2 */ DOORLOCK_2, // DOORLOCK_NORMAL_SPIRIT on OoT + /* 3 */ DOORLOCK_MAX +} DoorLockType; + +// Targetability / ACTOR_FLAG_TARGETABLE? +#define ACTOR_FLAG_1 (1 << 0) +// +#define ACTOR_FLAG_2 (1 << 1) +// +#define ACTOR_FLAG_4 (1 << 2) +// +#define ACTOR_FLAG_8 (1 << 3) +// +#define ACTOR_FLAG_10 (1 << 4) +// +#define ACTOR_FLAG_20 (1 << 5) +// +#define ACTOR_FLAG_40 (1 << 6) +// Invisible +#define ACTOR_FLAG_80 (1 << 7) +// Related to talk +#define ACTOR_FLAG_100 (1 << 8) +// +#define ACTOR_FLAG_200 (1 << 9) +// +#define ACTOR_FLAG_400 (1 << 10) +// +#define ACTOR_FLAG_800 (1 << 11) +// +#define ACTOR_FLAG_1000 (1 << 12) +// +#define ACTOR_FLAG_2000 (1 << 13) +// +#define ACTOR_FLAG_4000 (1 << 14) +// +#define ACTOR_FLAG_8000 (1 << 15) +// +#define ACTOR_FLAG_10000 (1 << 16) +// +#define ACTOR_FLAG_20000 (1 << 17) +// +#define ACTOR_FLAG_40000 (1 << 18) +// +#define ACTOR_FLAG_80000 (1 << 19) +// +#define ACTOR_FLAG_100000 (1 << 20) +// +#define ACTOR_FLAG_200000 (1 << 21) +// +#define ACTOR_FLAG_400000 (1 << 22) +// +#define ACTOR_FLAG_800000 (1 << 23) +// +#define ACTOR_FLAG_1000000 (1 << 24) +// +#define ACTOR_FLAG_2000000 (1 << 25) +// +#define ACTOR_FLAG_4000000 (1 << 26) +// +#define ACTOR_FLAG_8000000 (1 << 27) +// +#define ACTOR_FLAG_10000000 (1 << 28) +// +#define ACTOR_FLAG_20000000 (1 << 29) +// +#define ACTOR_FLAG_40000000 (1 << 30) + typedef enum { /* 0x00 */ CLEAR_TAG_SMALL_EXPLOSION, /* 0x01 */ CLEAR_TAG_LARGE_EXPLOSION, diff --git a/include/z64effect.h b/include/z64effect.h index b095c89e90..d9211ef5e1 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -254,7 +254,7 @@ typedef struct { /* 0x0C */ void* vramEnd; /* 0x10 */ void* loadedRamAddr; /* 0x14 */ EffectSsInit* initInfo; - /* 0x18 */ u32 unk18; // Always 0x01000000? + /* 0x18 */ u8 unk18; // Always 1? } EffectSsOverlay; // size = 0x1C typedef struct EffectSs { @@ -279,27 +279,6 @@ typedef struct { /* 0x8 */ s32 size; } EffectSsInfo; // size = 0xC -typedef struct { - /* 0x0 */ EffectSs* data_table; // Name from debug assert - /* 0x4 */ s32 searchIndex; - /* 0x8 */ s32 size; -} EffectTableInfo; // size = 0xC - -typedef struct { - /* 0x0 */ UNK_TYPE4 unk0; - /* 0x4 */ EffectSsInitFunc init; -} ParticleOverlayInfo; // size = 0x8 - -typedef struct { - /* 0x00 */ u32 vromStart; - /* 0x04 */ u32 vromEnd; - /* 0x08 */ void* vramStart; - /* 0x0C */ void* vramEnd; - /* 0x10 */ void* loadedRamAddr; - /* 0x14 */ ParticleOverlayInfo* overlayInfo; - /* 0x18 */ u32 unk18; // Always 0x01000000? -} ParticleOverlay; // size = 0x1C - typedef enum { /* 0x00 */ EFFECT_SS_DUST, /* 0x01 */ EFFECT_SS_KIRAKIRA, diff --git a/include/z64item.h b/include/z64item.h index d912169f2a..f7ce84a39a 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -275,6 +275,7 @@ typedef enum { /* 0x07 */ GI_RUPEE_HUGE, /* 0x08 */ GI_WALLET_ADULT, /* 0x09 */ GI_WALLET_GIANT, + /* 0x0A */ GI_RECOVERY_HEART, /* 0x0C */ GI_HEART_PIECE = 0x0C, /* 0x0D */ GI_HEART_CONTAINER, /* 0x16 */ GI_BOMBS_10 = 0x16, @@ -298,6 +299,7 @@ typedef enum { /* 0x3C */ GI_KEY_SMALL = 0x3C, /* 0x3E */ GI_MAP = 0x3E, /* 0x3F */ GI_COMPASS, + /* 0x52 */ GI_SCALE_GOLD = 0x52, // Assumed, used in En_Fishing /* 0x59 */ GI_BOTTLE_POTION_RED = 0x59, /* 0x5B */ GI_POTION_RED = 0x5B, /* 0x5C */ GI_POTION_GREEN, @@ -341,6 +343,7 @@ typedef enum { /* 0x9F */ GI_SHIELD_HERO_2, // Code that treats this as hero's shield is unused, so take with a grain of salt /* 0xA1 */ GI_LETTER_TO_MAMA = 0xA1, /* 0xA9 */ GI_BOTTLE = 0xA9, + /* 0xAB */ GI_PENDANT_OF_MEMORIES = 0xAB, /* 0xBA */ GI_MAX = 0xBA } GetItemID; @@ -371,4 +374,12 @@ typedef enum { /* 0x68 */ GID_SWORD_GREAT_FAIRY } GetItemDrawID; +// TODO: fill +typedef enum { + /* -1 */ EXCH_ITEM_MINUS1 = -1, // Unknown usage or function + /* 0x00 */ EXCH_ITEM_NONE, + /* 0x1E */ EXCH_ITEM_1E = 0x1E, // BOTTLE_MUSHROOM + /* 0x2A */ EXCH_ITEM_2A = 0x2A // MOON_TEAR? +} ExchangeItemID; + #endif diff --git a/include/z64player.h b/include/z64player.h index 6b156372eb..4066e2baf3 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -1,5 +1,5 @@ -#ifndef _Z64PLAYER_H_ -#define _Z64PLAYER_H_ +#ifndef Z64PLAYER_H +#define Z64PLAYER_H #include "z64actor.h" #include "os.h" @@ -252,7 +252,7 @@ typedef struct Player { /* 0x32A */ Vec3s morphTable[5]; /* 0x348 */ s16 eyeTexId; /* 0x34A */ s16 eyeAnimTimer; - /* 0x34C */ Actor* leftHandActor; + /* 0x34C */ Actor* heldActor; /* 0x350 */ PosRot leftHandWorld; /* 0x364 */ Actor* rightHandActor; /* 0x368 */ PosRot rightHandWorld; @@ -261,12 +261,12 @@ typedef struct Player { /* 0x37E */ s8 doorTimer; /* 0x37F */ s8 doorNext; // used with spiral staircase /* 0x380 */ Actor* doorActor; - /* 0x384 */ s16 unk_384; - /* 0x386 */ u16 unk_386; - /* 0x388 */ Actor* unk_388; - /* 0x38C */ s16 unk_38C; + /* 0x384 */ s16 getItemId; + /* 0x386 */ u16 getItemDirection; + /* 0x388 */ Actor* interactRangeActor; + /* 0x38C */ s8 mountSide; /* 0x390 */ Actor* rideActor; - /* 0x394 */ u8 unk_394; + /* 0x394 */ u8 csMode; /* 0x395 */ u8 unk_395; /* 0x396 */ u8 unk_396; /* 0x397 */ u8 unk_397; @@ -289,7 +289,8 @@ typedef struct Player { /* 0x664 */ ColliderQuad shieldQuad; /* 0x6E4 */ ColliderCylinder shieldCylinder; /* 0x730 */ Actor* unk_730; - /* 0x734 */ char unk_734[8]; + /* 0x734 */ char unk_734[4]; + /* 0x738 */ s32 unk_738; /* 0x73C */ s32 blureEffectIndex[3]; /* 0x748 */ char unk_748[0x320]; /* 0xA68 */ PlayerAgeProperties* ageProperties; // repurposed as "transformation properties"? @@ -301,7 +302,7 @@ typedef struct Player { /* 0xA80 */ Actor* tatlActor; /* 0xA84 */ s16 tatlTextId; /* 0xA86 */ s8 unk_A86; - /* 0xA87 */ s8 unk_A87; + /* 0xA87 */ s8 exchangeItemId; /* 0xA88 */ Actor* targetActor; /* 0xA8C */ f32 targetActorDistance; /* 0xA90 */ Actor* unk_A90; diff --git a/include/z64save.h b/include/z64save.h index 63d0372dc4..8e08a550a2 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -174,7 +174,7 @@ typedef struct { /* 0x3F5C */ s32 unk_3F5C; // "bet_rupees" /* 0x3F60 */ u8 unk_3F60; // "framescale_flag" /* 0x3F64 */ f32 unk_3F64; // "framescale_scale" - /* 0x3F68 */ u32 unk_3F68[5][120]; + /* 0x3F68 */ u32 cycleSceneFlags[120][5]; /* 0x48C8 */ u16 unk_48C8; // "scene_id_mix" /* 0x48CA */ u8 maskMaskBit[3]; // masks given away on the Moon /* 0x48CD */ char unk_48CD[24]; diff --git a/include/z64scene.h b/include/z64scene.h index 3335699747..8d301d1d17 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -295,7 +295,7 @@ typedef struct { /* 0x04 */ s16 id; /* 0x06 */ Vec3s pos; /* 0x0C */ s16 rotY; - /* 0x0E */ s16 params; + /* 0x0E */ u16 params; } TransitionActorEntry; // size = 0x10 typedef struct { diff --git a/spec b/spec index 6c7ea7702d..20c127ac26 100644 --- a/spec +++ b/spec @@ -120,8 +120,6 @@ beginseg include "build/src/libultra/io/devmgr.o" include "build/src/libultra/io/pirawdma.o" include "build/src/libultra/io/contpfs.o" - include "build/data/boot/contpfs.data.o" - include "build/data/boot/contpfs.bss.o" include "build/asm/boot/getcount.text.o" pad_text include "build/asm/boot/guMtxL2F.text.o" @@ -436,15 +434,13 @@ beginseg include "build/src/code/z_eff_tire_mark.o" include "build/src/code/z_effect.o" include "build/src/code/z_effect_soft_sprite.o" - include "build/data/code/z_effect_soft_sprite.data.o" include "build/src/code/z_effect_soft_sprite_old_init.o" - include "build/data/code/z_effect_soft_sprite_old_init.data.o" + include "build/src/code/z_effect_soft_sprite_dlftbls.o" include "build/src/code/flg_set.o" include "build/data/code/flg_set.bss.o" include "build/src/code/pad_801DC9C0.o" include "build/src/code/z_DLF.o" include "build/src/code/z_actor.o" - include "build/data/code/z_actor.data.o" include "build/data/code/z_actor.bss.o" include "build/src/code/z_actor_dlftbls.o" include "build/src/code/z_bgcheck.o" @@ -879,8 +875,7 @@ beginseg name "ovl_En_Peehat" compress include "build/src/overlays/actors/ovl_En_Peehat/z_en_peehat.o" - include "build/data/ovl_En_Peehat/ovl_En_Peehat.data.o" - include "build/data/ovl_En_Peehat/ovl_En_Peehat.reloc.o" + include "build/src/overlays/actors/ovl_En_Peehat/ovl_En_Peehat_reloc.o" endseg beginseg @@ -963,8 +958,7 @@ beginseg name "ovl_En_St" compress include "build/src/overlays/actors/ovl_En_St/z_en_st.o" - include "build/data/ovl_En_St/ovl_En_St.data.o" - include "build/data/ovl_En_St/ovl_En_St.reloc.o" + include "build/src/overlays/actors/ovl_En_St/ovl_En_St_reloc.o" endseg beginseg @@ -1200,9 +1194,11 @@ beginseg name "ovl_Object_Kankyo" compress include "build/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.o" - include "build/data/ovl_Object_Kankyo/ovl_Object_Kankyo.data.o" - include "build/data/ovl_Object_Kankyo/ovl_Object_Kankyo.bss.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Object_Kankyo/ovl_Object_Kankyo_reloc.o" +#else include "build/data/ovl_Object_Kankyo/ovl_Object_Kankyo.reloc.o" +#endif endseg beginseg @@ -1328,9 +1324,11 @@ beginseg name "ovl_En_Fishing" compress include "build/src/overlays/actors/ovl_En_Fishing/z_en_fishing.o" - include "build/data/ovl_En_Fishing/ovl_En_Fishing.data.o" - include "build/data/ovl_En_Fishing/ovl_En_Fishing.bss.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_En_Fishing/ovl_En_Fishing_reloc.o" +#else include "build/data/ovl_En_Fishing/ovl_En_Fishing.reloc.o" +#endif endseg beginseg @@ -1376,8 +1374,7 @@ beginseg name "ovl_En_Fish" compress include "build/src/overlays/actors/ovl_En_Fish/z_en_fish.o" - include "build/data/ovl_En_Fish/ovl_En_Fish.data.o" - include "build/data/ovl_En_Fish/ovl_En_Fish.reloc.o" + include "build/src/overlays/actors/ovl_En_Fish/ovl_En_Fish_reloc.o" endseg beginseg @@ -1676,8 +1673,7 @@ beginseg name "ovl_En_Ishi" compress include "build/src/overlays/actors/ovl_En_Ishi/z_en_ishi.o" - include "build/data/ovl_En_Ishi/ovl_En_Ishi.data.o" - include "build/data/ovl_En_Ishi/ovl_En_Ishi.reloc.o" + include "build/src/overlays/actors/ovl_En_Ishi/ovl_En_Ishi_reloc.o" endseg beginseg @@ -1819,16 +1815,14 @@ beginseg name "ovl_Obj_Roomtimer" compress include "build/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.o" - include "build/data/ovl_Obj_Roomtimer/ovl_Obj_Roomtimer.data.o" - include "build/data/ovl_Obj_Roomtimer/ovl_Obj_Roomtimer.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Roomtimer/ovl_Obj_Roomtimer_reloc.o" endseg beginseg name "ovl_En_Ssh" compress include "build/src/overlays/actors/ovl_En_Ssh/z_en_ssh.o" - include "build/data/ovl_En_Ssh/ovl_En_Ssh.data.o" - include "build/data/ovl_En_Ssh/ovl_En_Ssh.reloc.o" + include "build/src/overlays/actors/ovl_En_Ssh/ovl_En_Ssh_reloc.o" endseg beginseg @@ -2276,8 +2270,7 @@ beginseg name "ovl_En_Mm2" compress include "build/src/overlays/actors/ovl_En_Mm2/z_en_mm2.o" - include "build/data/ovl_En_Mm2/ovl_En_Mm2.data.o" - include "build/data/ovl_En_Mm2/ovl_En_Mm2.reloc.o" + include "build/src/overlays/actors/ovl_En_Mm2/ovl_En_Mm2_reloc.o" endseg beginseg @@ -2552,9 +2545,7 @@ beginseg name "ovl_Boss_04" compress include "build/src/overlays/actors/ovl_Boss_04/z_boss_04.o" - include "build/data/ovl_Boss_04/ovl_Boss_04.data.o" - include "build/data/ovl_Boss_04/ovl_Boss_04.bss.o" - include "build/data/ovl_Boss_04/ovl_Boss_04.reloc.o" + include "build/src/overlays/actors/ovl_Boss_04/ovl_Boss_04_reloc.o" endseg beginseg @@ -2610,8 +2601,11 @@ beginseg name "ovl_En_Go" compress include "build/src/overlays/actors/ovl_En_Go/z_en_go.o" - include "build/data/ovl_En_Go/ovl_En_Go.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_En_Go/ovl_En_Go_reloc.o" +#else include "build/data/ovl_En_Go/ovl_En_Go.reloc.o" +#endif endseg beginseg @@ -2648,9 +2642,7 @@ beginseg name "ovl_Obj_Flowerpot" compress include "build/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.o" - include "build/data/ovl_Obj_Flowerpot/ovl_Obj_Flowerpot.data.o" - include "build/data/ovl_Obj_Flowerpot/ovl_Obj_Flowerpot.bss.o" - include "build/data/ovl_Obj_Flowerpot/ovl_Obj_Flowerpot.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Flowerpot/ovl_Obj_Flowerpot_reloc.o" endseg beginseg @@ -2930,8 +2922,7 @@ beginseg name "ovl_En_Wiz_Fire" compress include "build/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.o" - include "build/data/ovl_En_Wiz_Fire/ovl_En_Wiz_Fire.data.o" - include "build/data/ovl_En_Wiz_Fire/ovl_En_Wiz_Fire.reloc.o" + include "build/src/overlays/actors/ovl_En_Wiz_Fire/ovl_En_Wiz_Fire_reloc.o" endseg beginseg @@ -3021,8 +3012,7 @@ beginseg name "ovl_Obj_Hugebombiwa" compress include "build/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.o" - include "build/data/ovl_Obj_Hugebombiwa/ovl_Obj_Hugebombiwa.data.o" - include "build/data/ovl_Obj_Hugebombiwa/ovl_Obj_Hugebombiwa.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hugebombiwa/ovl_Obj_Hugebombiwa_reloc.o" endseg beginseg @@ -3044,8 +3034,7 @@ beginseg name "ovl_En_Water_Effect" compress include "build/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.o" - include "build/data/ovl_En_Water_Effect/ovl_En_Water_Effect.data.o" - include "build/data/ovl_En_Water_Effect/ovl_En_Water_Effect.reloc.o" + include "build/src/overlays/actors/ovl_En_Water_Effect/ovl_En_Water_Effect_reloc.o" endseg beginseg @@ -3623,8 +3612,7 @@ beginseg name "ovl_En_Kame" compress include "build/src/overlays/actors/ovl_En_Kame/z_en_kame.o" - include "build/data/ovl_En_Kame/ovl_En_Kame.data.o" - include "build/data/ovl_En_Kame/ovl_En_Kame.reloc.o" + include "build/src/overlays/actors/ovl_En_Kame/ovl_En_Kame_reloc.o" endseg beginseg @@ -3842,8 +3830,7 @@ beginseg name "ovl_En_Col_Man" compress include "build/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.o" - include "build/data/ovl_En_Col_Man/ovl_En_Col_Man.data.o" - include "build/data/ovl_En_Col_Man/ovl_En_Col_Man.reloc.o" + include "build/src/overlays/actors/ovl_En_Col_Man/ovl_En_Col_Man_reloc.o" endseg beginseg @@ -3864,8 +3851,11 @@ beginseg name "ovl_Obj_Snowball" compress include "build/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.o" - include "build/data/ovl_Obj_Snowball/ovl_Obj_Snowball.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Snowball/ovl_obj_Snowball_reloc.o" +#else include "build/data/ovl_Obj_Snowball/ovl_Obj_Snowball.reloc.o" +#endif endseg beginseg @@ -3880,8 +3870,7 @@ beginseg name "ovl_En_Gb2" compress include "build/src/overlays/actors/ovl_En_Gb2/z_en_gb2.o" - include "build/data/ovl_En_Gb2/ovl_En_Gb2.data.o" - include "build/data/ovl_En_Gb2/ovl_En_Gb2.reloc.o" + include "build/src/overlays/actors/ovl_En_Gb2/ovl_En_Gb2_reloc.o" endseg beginseg @@ -3980,8 +3969,7 @@ beginseg name "ovl_Obj_Dowsing" compress include "build/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.o" - include "build/data/ovl_Obj_Dowsing/ovl_Obj_Dowsing.data.o" - include "build/data/ovl_Obj_Dowsing/ovl_Obj_Dowsing.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Dowsing/ovl_Obj_Dowsing_reloc.o" endseg beginseg @@ -4419,8 +4407,7 @@ beginseg name "ovl_Obj_Jg_Gakki" compress include "build/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.o" - include "build/data/ovl_Obj_Jg_Gakki/ovl_Obj_Jg_Gakki.data.o" - include "build/data/ovl_Obj_Jg_Gakki/ovl_Obj_Jg_Gakki.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Jg_Gakki/ovl_Obj_Jg_Gakki_reloc.o" endseg beginseg @@ -4919,8 +4906,7 @@ beginseg name "ovl_En_Ruppecrow" compress include "build/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.o" - include "build/data/ovl_En_Ruppecrow/ovl_En_Ruppecrow.data.o" - include "build/data/ovl_En_Ruppecrow/ovl_En_Ruppecrow.reloc.o" + include "build/src/overlays/actors/ovl_En_Ruppecrow/ovl_En_Ruppecrow_reloc.o" endseg beginseg @@ -5105,7 +5091,6 @@ beginseg name "ovl_En_Bomjima" compress include "build/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.o" - include "build/data/ovl_En_Bomjima/ovl_En_Bomjima.data.o" include "build/data/ovl_En_Bomjima/ovl_En_Bomjima.reloc.o" endseg diff --git a/src/boot_O2/__osMalloc.c b/src/boot_O2/__osMalloc.c index 503c7c25ac..c74c34866b 100644 --- a/src/boot_O2/__osMalloc.c +++ b/src/boot_O2/__osMalloc.c @@ -182,7 +182,7 @@ void __osFree(Arena* arena, void* ptr) { ArenaNode* newNext; ArenaImpl_Lock(arena); - node = (ArenaNode*)((u32)ptr - sizeof(ArenaNode)); + node = (ArenaNode*)((uintptr_t)ptr - sizeof(ArenaNode)); if (ptr == NULL || (node->magic != NODE_MAGIC) || node->isFree) { goto end; @@ -190,10 +190,10 @@ void __osFree(Arena* arena, void* ptr) { next = node->next; prev = node->prev; - node->isFree = 1; + node->isFree = true; newNext = next; - if ((u32)next == (u32)node + sizeof(ArenaNode) + node->size && next->isFree) { + if ((uintptr_t)next == (uintptr_t)node + sizeof(ArenaNode) + node->size && next->isFree) { newNext = next->next; if (newNext != NULL) { newNext->prev = node; @@ -205,7 +205,7 @@ void __osFree(Arena* arena, void* ptr) { next = newNext; } - if (prev != NULL && prev->isFree && (u32)node == (u32)prev + sizeof(ArenaNode) + prev->size) { + if (prev != NULL && prev->isFree && (uintptr_t)node == (uintptr_t)prev + sizeof(ArenaNode) + prev->size) { if (next) { next->prev = prev; } diff --git a/src/boot_O2_g3/yaz0.c b/src/boot_O2_g3/yaz0.c index 094c0bb381..5fb32b8eaa 100644 --- a/src/boot_O2_g3/yaz0.c +++ b/src/boot_O2_g3/yaz0.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u8 sYaz0DataBuffer[0x400]; diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index ebf3909249..190536b21e 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u32 sDmaMgrDmaBuffSize = 0x2000; diff --git a/src/buffers/gfxyield.c b/src/buffers/gfxyield.c index 73810d4acd..94a5f55c97 100644 --- a/src/buffers/gfxyield.c +++ b/src/buffers/gfxyield.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; diff --git a/src/code/audio/code_801A5BD0.c b/src/code/audio/code_801A5BD0.c index 32889dcb83..0a13b00ecf 100644 --- a/src/code/audio/code_801A5BD0.c +++ b/src/code/audio/code_801A5BD0.c @@ -6,7 +6,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5C8C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5CFC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/Audio_PlaySfxGeneral.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5DDC.s") diff --git a/src/code/graph.c b/src/code/graph.c index 7ef1715fd9..e09cfedc4b 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -88,33 +88,27 @@ GameStateOverlay* Graph_GetNextGameState(GameState* gameState) { return NULL; } -#ifdef NON_MATCHING -// Regalloc differences void* Graph_FaultAddrConvFunc(void* address, void* param) { - u32 addr = address; - GameStateOverlay* gamestateOvl; - u32 ramConv; - u32 ramStart; - u32 diff; + uintptr_t addr = address; + GameStateOverlay* gamestateOvl = &gGameStateOverlayTable[0]; + uintptr_t ramConv; + void* ramStart; + uintptr_t diff; s32 i; - for (i = 0; i < graphNumGameStates; i++) { - gamestateOvl = &gGameStateOverlayTable[i]; + for (i = 0; i < graphNumGameStates; i++, gamestateOvl++) { + diff = VRAM_PTR_SIZE(gamestateOvl); ramStart = gamestateOvl->loadedRamAddr; - diff = (u32)gamestateOvl->vramEnd - (u32)gamestateOvl->vramStart; - ramConv = (u32)gamestateOvl->vramStart - ramStart; + ramConv = (uintptr_t)gamestateOvl->vramStart - (uintptr_t)ramStart; - if (gamestateOvl->loadedRamAddr != NULL) { - if (addr >= ramStart && addr < ramStart + diff) { + if (ramStart != NULL) { + if (addr >= (uintptr_t)ramStart && addr < (uintptr_t)ramStart + diff) { return addr + ramConv; } } } return NULL; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/graph/Graph_FaultAddrConvFunc.s") -#endif void Graph_Init(GraphicsContext* gfxCtx) { bzero(gfxCtx, sizeof(GraphicsContext)); diff --git a/src/code/sched.c b/src/code/sched.c index 927a48f66b..5f9cdf236a 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #define RSP_DONE_MSG 667 diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index 50fd1211ec..d676a437cf 100644 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -138,7 +138,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_IsPointInSphere.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017D668.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_PointDistToLine2D.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017D7C0.s") diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 42f67987a1..49eee72358 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1,7 +1,44 @@ +/* + * File: z_actor.c + * Description: + */ + #include "global.h" +#include "overlays/actors/ovl_En_Horse/z_en_horse.h" +#include "overlays/actors/ovl_En_Part/z_en_part.h" +#include "overlays/actors/ovl_En_Box/z_en_box.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "objects/object_bdoor/object_bdoor.h" + +// bss +extern FaultClient sActorFaultClient; // 2 funcs +extern CollisionPoly* D_801ED8B0; // 1 func +extern s32 D_801ED8B4; // 2 funcs +extern Actor* D_801ED8B8; // 2 funcs +extern Actor* D_801ED8BC; // 2 funcs +extern Actor* D_801ED8C0; // 2 funcs +extern Actor* D_801ED8C4; // 2 funcs +extern f32 D_801ED8C8; // 2 funcs +extern f32 sBgmEnemyDistSq; // 2 funcs +extern f32 D_801ED8D0; // 2 funcs +extern s32 D_801ED8D4; // 2 funcs +extern s32 D_801ED8D8; // 2 funcs +extern s16 D_801ED8DC; // 2 funcs +extern Mtx D_801ED8E0; // 1 func +extern Actor* D_801ED920; // 2 funcs. 1 out of z_actor + +// Internal forward declarations +void func_800BA8B8(GlobalContext* globalCtx, ActorContext* actorCtx); +Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, GlobalContext* globalCtx); +Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalCtx); +void func_800BB8EC(GameState* gameState, ActorContext* actorCtx, Actor** arg2, Actor** arg3, Player* player); +s32 func_800BA2FC(GlobalContext* globalCtx, Actor* actor, Vec3f* projectedPos, f32 projectedW); +void Actor_AddToCategory(ActorContext* actorCtx, Actor* actor, u8 actorCategory); +Actor* Actor_RemoveFromCategory(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actorToRemove); void Actor_PrintLists(ActorContext* actorCtx) { - ActorListEntry* actorList = &actorCtx->actorList[0]; + ActorListEntry* actorList = &actorCtx->actorLists[0]; Actor* actor; s32 i; @@ -9,7 +46,7 @@ void Actor_PrintLists(ActorContext* actorCtx) { FaultDrawer_Printf("actor\n", gMaxActorId); FaultDrawer_Printf("No. Actor Name Part SegName\n"); - for (i = 0; i < ARRAY_COUNT(actorCtx->actorList); i++) { + for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) { actor = actorList[i].first; while (actor != NULL) { @@ -26,7 +63,6 @@ void ActorShape_Init(ActorShape* actorShape, f32 yOffset, ActorShadowFunc shadow actorShape->shadowAlpha = 255; } -#ifdef NON_MATCHING void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gfx* dlist, Color_RGBA8* color) { if (actor->floorPoly != NULL) { f32 dy = actor->world.pos.y - actor->floorHeight; @@ -43,7 +79,10 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf COMBINED); dy = CLAMP(dy, 0.0f, 150.0f); - shadowScale = 1.0f - (dy * 0.0028571428f); + shadowScale = 1.0f - (dy * (1.0f / 350.0f)); + if ((dy * (1.0f / 350.0f)) > 1.0f) { + shadowScale = 0.0f; + } if (color != NULL) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, color->r, color->g, color->b, @@ -55,13 +94,12 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf func_800C0094(actor->floorPoly, actor->world.pos.x, actor->floorHeight, actor->world.pos.z, &mtx); Matrix_SetCurrentState(&mtx); - if (dlist != D_04076BC0) { - Matrix_RotateY((f32)actor->shape.rot.y * (M_PI / 32768), MTXMODE_APPLY); + if ((dlist != gCircleShadowDL) || (actor->scale.x != actor->scale.z)) { + Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); } - shadowScale = 1.0f - (dy * 0.0028571428f); shadowScale *= actor->shape.shadowScale; - Matrix_Scale(shadowScale * actor->scale.x, 1.0f, shadowScale * actor->scale.z, MTXMODE_APPLY); + Matrix_Scale(actor->scale.x * shadowScale, 1.0f, actor->scale.z * shadowScale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, dlist); @@ -70,244 +108,949 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/ActorShadow_Draw.s") -#endif -/* ActorShadow_DrawCircle */ -void func_800B3FC0(Actor* actor, Lights* lights, GlobalContext* globalCtx) { +void ActorShadow_DrawCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx) { if (actor->bgCheckFlags & 0x400) { func_800B4AEC(globalCtx, actor, 50.0f); } - ActorShadow_Draw(actor, lights, globalCtx, D_04076BC0, NULL); + ActorShadow_Draw(actor, lights, globalCtx, gCircleShadowDL, NULL); } -/* ActorShadow_DrawSquare */ -void func_800B4024(Actor* actor, Lights* lights, GlobalContext* globalCtx) { +void ActorShadow_DrawSquare(Actor* actor, Lights* lights, GlobalContext* globalCtx) { if (actor->bgCheckFlags & 0x400) { func_800B4AEC(globalCtx, actor, 50.0f); } - ActorShadow_Draw(actor, lights, globalCtx, D_04075A40, NULL); + ActorShadow_Draw(actor, lights, globalCtx, gSquareShadowDL, NULL); } -/* ActorShadow_DrawWhiteCircle */ -void func_800B4088(Actor* actor, Lights* lights, GlobalContext* globalCtx) { - ActorShadow_Draw(actor, lights, globalCtx, D_04076BC0, &D_801AEC80); +void ActorShadow_DrawWhiteCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx) { + static Color_RGBA8 color = { 255, 255, 255, 255 }; + + ActorShadow_Draw(actor, lights, globalCtx, gCircleShadowDL, &color); } -/* ActorShadow_DrawHorse */ -void func_800B40B8(Actor* actor, Lights* lights, GlobalContext* globalCtx) { - ActorShadow_Draw(actor, lights, globalCtx, D_04077480, NULL); +void ActorShadow_DrawHorse(Actor* actor, Lights* lights, GlobalContext* globalCtx) { + ActorShadow_Draw(actor, lights, globalCtx, gHorseShadowDL, NULL); } -/* ActorShadow_DrawFoot */ -#ifdef NON_MATCHING -void func_800B40E0(GlobalContext* globalCtx, Light* light, MtxF* arg2, s32 arg3, f32 arg4, f32 arg5, f32 arg6) { - s32 pad1; +void ActorShadow_DrawFoot(GlobalContext* globalCtx, Light* light, MtxF* arg2, s32 lightNum, f32 shadowAlpha, + f32 shadowScaleX, f32 shadowScaleZ) { + s32 pad; s16 sp58; - s32 pad2[2]; + f32 dir2; + f32 dir0; OPEN_DISPS(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, - (u32)(((arg3 * 1.3e-05f) > 1.0f ? 1.0f : (arg3 * 1.3e-05f)) * arg4) & 0xFF); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u8)(CLAMP_MAX(lightNum * 1.3e-05f, 1.0f) * shadowAlpha)); - sp58 = Math_FAtan2F(light->l.dir[0], light->l.dir[2]); - arg6 *= (4.5f - (light->l.dir[1] * 0.035f)); - arg6 = (arg6 < 1.0f) ? 1.0f : arg6; + dir0 = light->l.dir[0]; + dir2 = light->l.dir[2]; + sp58 = Math_FAtan2F(dir2, dir0); + shadowScaleZ *= (4.5f - (light->l.dir[1] * 0.035f)); + shadowScaleZ = CLAMP_MIN(shadowScaleZ, 1.0f); Matrix_SetCurrentState(arg2); Matrix_RotateY(sp58, MTXMODE_APPLY); - Matrix_Scale(arg5, 1.0f, arg5 * arg6, MTXMODE_APPLY); + Matrix_Scale(shadowScaleX, 1.0f, shadowScaleX * shadowScaleZ, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); - gSPDisplayList(POLY_OPA_DISP++, D_04075B30); + gSPDisplayList(POLY_OPA_DISP++, gFootShadowDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B40E0.s") -#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B42F8.s") +void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx) { + f32 distToFloor = actor->world.pos.y - actor->floorHeight; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B4A98.s") + if (distToFloor > 0.0f) { + f32 shadowScale = actor->shape.shadowScale; + u8 shadowAlpha = actor->shape.shadowAlpha; + f32 alphaRatio; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B4AEC.s") + if ((actor->id == ACTOR_PLAYER) && (((Player*)actor)->stateFlags3 & 0x8000)) { + f32 tmpScaleZ = actor->scale.z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B4B50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B4EDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B4F40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B4F78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B5040.s") - -void Actor_TargetContextInit(TargetContext* targetCtx, Actor* actor, GlobalContext* globalCtx) { - targetCtx->unk90 = NULL; - targetCtx->unk8C = NULL; - targetCtx->unk3C = NULL; - targetCtx->unk38 = NULL; - targetCtx->unk4B = 0; - targetCtx->unk4C = 0; - targetCtx->unk40 = 0; - func_800B5040(targetCtx, actor, actor->category, globalCtx); - func_800B4F78(targetCtx, actor->category, globalCtx); -} - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B5208.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B5814.s") - -u32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag) { - if (flag >= 0 && flag < 0x80) { - return globalCtx->actorCtx.switchFlags[(flag & -0x20) >> 5] & (1 << (flag & 0x1F)); - } - return 0; -} - -void Actor_SetSwitchFlag(GlobalContext* globalCtx, s32 flag) { - if (flag >= 0 && flag < 0x80) { - globalCtx->actorCtx.switchFlags[(flag & -0x20) >> 5] |= 1 << (flag & 0x1F); - } -} - -void Actor_UnsetSwitchFlag(GlobalContext* globalCtx, s32 flag) { - if (flag >= 0 && flag < 0x80) { - globalCtx->actorCtx.switchFlags[(flag & -0x20) >> 5] &= ~(1 << (flag & 0x1F)); - } -} - -u32 Actor_GetChestFlag(GlobalContext* globalCtx, u32 flag) { - return globalCtx->actorCtx.chestFlags & (1 << flag); -} - -void Actor_SetChestFlag(GlobalContext* globalCtx, u32 flag) { - globalCtx->actorCtx.chestFlags |= (1 << flag); -} - -void Actor_SetAllChestFlag(GlobalContext* globalCtx, u32 flag) { - globalCtx->actorCtx.chestFlags = flag; -} - -u32 Actor_GetAllChestFlag(GlobalContext* globalCtx) { - return globalCtx->actorCtx.chestFlags; -} - -u32 Actor_GetRoomCleared(GlobalContext* globalCtx, u32 roomNumber) { - return globalCtx->actorCtx.clearedRooms & (1 << roomNumber); -} - -void Actor_SetRoomCleared(GlobalContext* globalCtx, u32 roomNumber) { - globalCtx->actorCtx.clearedRooms |= (1 << roomNumber); -} - -void Actor_UnsetRoomCleared(GlobalContext* globalCtx, u32 roomNumber) { - globalCtx->actorCtx.clearedRooms &= ~(1 << roomNumber); -} - -u32 Actor_GetRoomClearedTemp(GlobalContext* globalCtx, u32 roomNumber) { - return globalCtx->actorCtx.clearedRoomsTemp & (1 << roomNumber); -} - -void Actor_SetRoomClearedTemp(GlobalContext* globalCtx, u32 roomNumber) { - globalCtx->actorCtx.clearedRoomsTemp |= (1 << roomNumber); -} - -void Actor_UnsetRoomClearedTemp(GlobalContext* globalCtx, u32 roomNumber) { - globalCtx->actorCtx.clearedRoomsTemp &= ~(1 << roomNumber); -} - -u32 Actor_GetCollectibleFlag(GlobalContext* globalCtx, s32 index) { - if (index > 0 && index < 0x80) { - return globalCtx->actorCtx.collectibleFlags[(index & -0x20) >> 5] & (1 << (index & 0x1F)); - } - return 0; -} - -void Actor_SetCollectibleFlag(GlobalContext* globalCtx, s32 index) { - if (index > 0 && index < 0x80) { - globalCtx->actorCtx.collectibleFlags[(index & -0x20) >> 5] |= 1 << (index & 0x1F); - } -} - -void Actor_TitleCardContextInit(GlobalContext* globalCtx, TitleCardContext* titleCardCtx) { - titleCardCtx->fadeOutDelay = 0; - titleCardCtx->fadeInDelay = 0; - titleCardCtx->color = 0; - titleCardCtx->alpha = 0; -} - -void Actor_TitleCardCreate(GlobalContext* globalCtx, TitleCardContext* titleCardCtx, u32 texture, s16 param_4, - s16 param_5, u8 param_6, u8 param_7) { - titleCardCtx->texture = texture; - titleCardCtx->unk4 = param_4; - titleCardCtx->unk6 = param_5; - titleCardCtx->unk8 = param_6; - titleCardCtx->unk9 = param_7; - titleCardCtx->fadeOutDelay = 80; - titleCardCtx->fadeInDelay = 0; -} - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_Nop800B5E50.s") - -void Actor_TitleCardUpdate(GlobalContext* globalCtx, TitleCardContext* titleCardCtx) { - if (DECR(titleCardCtx->fadeInDelay) == 0) { - if (DECR(titleCardCtx->fadeOutDelay) == 0) { - Math_StepToS(&titleCardCtx->alpha, 0, 30); - Math_StepToS(&titleCardCtx->color, 0, 70); + actor->scale.z += 0.03f * fabsf(Math_CosS(((Player*)actor)->unk_AAA)); + actor->shape.shadowScale *= 0.2f; + alphaRatio = distToFloor * 0.03f; + actor->shape.shadowAlpha = actor->shape.shadowAlpha * CLAMP_MAX(alphaRatio, 1.0f); + ActorShadow_Draw(actor, mapper, globalCtx, gCircleShadowDL, NULL); + actor->scale.z = tmpScaleZ; } else { - Math_StepToS(&titleCardCtx->alpha, 255, 10); - Math_StepToS(&titleCardCtx->color, 255, 20); + actor->shape.shadowScale *= 0.3f; + alphaRatio = (distToFloor - 20.0f) * 0.02f; + actor->shape.shadowAlpha = actor->shape.shadowAlpha * CLAMP_MAX(alphaRatio, 1.0f); + ActorShadow_DrawCircle(actor, mapper, globalCtx); + } + + actor->shape.shadowScale = shadowScale; + actor->shape.shadowAlpha = shadowAlpha; + } + + if (distToFloor < 200.0f) { + MtxF sp13C; + MtxF spFC; + CollisionPoly* spF8; + s32 bgId; + f32 floorHeight[2]; + f32 pad; + f32 shadowAlpha; + f32 shadowScaleX; + f32 shadowScaleZ; + Light* lightPtr; + s32 lightNumMax; + s32 i; + s32 j; + s32 lightNum; + Vec3f* feetPosPtr; + s32 numLights; + f32* floorHeightPtr; + s32 spB8; + + numLights = mapper->numLights - 2; + feetPosPtr = actor->shape.feetPos; + floorHeightPtr = floorHeight; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); + actor->shape.feetFloorFlags = 0; + spB8 = 2; + + for (i = 0; i < ARRAY_COUNT(floorHeight); i++, spB8 >>= 1) { + feetPosPtr->y += 50.0f; + *floorHeightPtr = func_80169100(globalCtx, &sp13C, &spF8, &bgId, feetPosPtr); + feetPosPtr->y -= 50.0f; + + distToFloor = feetPosPtr->y - *floorHeightPtr; + if ((distToFloor >= -1.0f) && (distToFloor < 500.0f)) { + lightNumMax = 0; + + if (distToFloor <= 10.0f) { + actor->shape.feetFloorFlags |= spB8; + + if ((actor->depthInWater < 0.0f) && (bgId == 0x32) && ((actor->shape.unk_17 & spB8) != 0)) { + if (func_800C9C24(&globalCtx->colCtx, spF8, bgId, 1) != 0) { + SkinMatrix_MtxFCopy(&sp13C, &spFC); + SkinMatrix_MulYRotation(&spFC, actor->shape.rot.y); + EffFootmark_Add(globalCtx, &spFC, actor, i, feetPosPtr, (actor->shape.shadowScale * 0.3f), + IREG(88) + 80, IREG(89) + 60, IREG(90) + 40, 30000, 200, 60); + } + actor->shape.unk_17 &= ~spB8; + + if (!mapper->l.l) {} // POSSIBLE FAKE MATCH + } + } + + if (distToFloor > 30.0f) { + distToFloor = 30.0f; + } + + shadowAlpha = actor->shape.shadowAlpha * (1.0f - (distToFloor * (1 / 30.0f))); + shadowScaleZ = 1.0f - (distToFloor * (1.0f / 70.0f)); + shadowScaleX = actor->shape.shadowScale * shadowScaleZ * actor->scale.x; + + for (lightPtr = mapper->l.l, j = 0; j < numLights; lightPtr++, j++) { + if (lightPtr->l.dir[1] > 0) { + lightNum = (lightPtr->l.col[0] + lightPtr->l.col[1] + lightPtr->l.col[2]) * + ABS_ALT(lightPtr->l.dir[1]); + + if (lightNum > 0) { + lightNumMax += lightNum; + ActorShadow_DrawFoot(globalCtx, lightPtr, &sp13C, lightNum, shadowAlpha, shadowScaleX, + shadowScaleZ); + } + } + } + + for (j = 0; j < 2; lightPtr++, j++) { + if (lightPtr->l.dir[1] > 0) { + lightNum = ((lightPtr->l.col[0] + lightPtr->l.col[1] + lightPtr->l.col[2]) * + ABS_ALT(lightPtr->l.dir[1])) - + (lightNumMax * 8); + if (lightNum > 0) { + ActorShadow_DrawFoot(globalCtx, lightPtr, &sp13C, lightNum, shadowAlpha, shadowScaleX, + shadowScaleZ); + } + } + } + } + feetPosPtr++; + floorHeightPtr++; + } + + if (!(actor->bgCheckFlags & 1)) { + actor->shape.feetFloorFlags = 0; + } else if (actor->shape.feetFloorFlags == 3) { + f32 footDistY = actor->shape.feetPos[FOOT_LEFT].y - actor->shape.feetPos[FOOT_RIGHT].y; + + if ((floorHeight[0] + footDistY) < (floorHeight[1] - footDistY)) { + actor->shape.feetFloorFlags = 2; + } else { + actor->shape.feetFloorFlags = 1; + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* leftFootPos, s32 rightFootIndex, + Vec3f* rightFootPos) { + if (limbIndex == leftFootIndex) { + Matrix_MultiplyVector3fByState(leftFootPos, &actor->shape.feetPos[FOOT_LEFT]); + } else if (limbIndex == rightFootIndex) { + Matrix_MultiplyVector3fByState(rightFootPos, &actor->shape.feetPos[FOOT_RIGHT]); + } +} + +void func_800B4AEC(GlobalContext* globalCtx, Actor* actor, f32 y) { + s32 floorBgId; + f32 yPos = actor->world.pos.y; + + actor->world.pos.y += y; + actor->floorHeight = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &actor->floorPoly, &floorBgId, + actor, &actor->world.pos); + actor->floorBgId = floorBgId; + actor->world.pos.y = yPos; +} + +void func_800B4B50(Actor* actor, Lights* mapper, GlobalContext* globalCtx) { + f32 spEC; + f32 temp_f12; + f32 temp_f20; + f32 shadowScaleZ; + f32 temp_f22; + f32 temp_f24; + f32 temp_f8; + MtxF sp94; + s32 lightNum; + s32 numLights; + s8 phi_v1; + u8 temp_v0; + Light* phi_s0; + s32 lightNumMax; + + if (actor->bgCheckFlags & 0x400) { + func_800B4AEC(globalCtx, actor, 50.0f); + } + + if (actor->floorPoly != NULL) { + s32 j; + + spEC = actor->world.pos.y - actor->floorHeight; + if (spEC > 20.0f) { + temp_f20 = actor->shape.shadowScale; + temp_v0 = actor->shape.shadowAlpha; + actor->shape.shadowScale *= 0.3f; + temp_f12 = (spEC - 20.0f) * 0.02f; + actor->shape.shadowAlpha = CLAMP_MAX(temp_f12, 1.0f) * actor->shape.shadowAlpha; + ActorShadow_DrawCircle(actor, mapper, globalCtx); + actor->shape.shadowScale = temp_f20; + actor->shape.shadowAlpha = temp_v0; + dummy_label_111649:; + } else if (spEC >= -1.0f) { + numLights = mapper->numLights - 2; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); + + func_800C0094(actor->floorPoly, actor->world.pos.x, actor->floorHeight, actor->world.pos.z, &sp94); + temp_f22 = (f32)actor->shape.shadowAlpha * (1.0f - (spEC * (1.0f / 30.0f))); + phi_s0 = mapper->l.l; + shadowScaleZ = 1.0f - (spEC * (1.0f / 70.0f)); + temp_f24 = actor->shape.shadowScale * shadowScaleZ * actor->scale.x; + + lightNumMax = 0; + for (j = 0; j < numLights; j++, phi_s0++) { + if (phi_s0->l.dir[1] > 0) { + lightNum = (phi_s0->l.col[0] + phi_s0->l.col[1] + phi_s0->l.col[2]) * ABS_ALT(phi_s0->l.dir[1]); + if (lightNum > 0) { + lightNumMax += lightNum; + ActorShadow_DrawFoot(globalCtx, phi_s0, &sp94, lightNum, temp_f22, temp_f24, shadowScaleZ); + } + } + } + + for (j = 0; j < 2; j++, phi_s0++) { + if (phi_s0->l.dir[1] > 0) { + lightNum = (ABS_ALT(phi_s0->l.dir[1]) * (phi_s0->l.col[0] + phi_s0->l.col[1] + phi_s0->l.col[2])) - + (lightNumMax * ((void)0, 8)); + if (lightNum > 0) { + ActorShadow_DrawFoot(globalCtx, phi_s0, &sp94, lightNum, temp_f22, temp_f24, shadowScaleZ); + } + } + } + CLOSE_DISPS(globalCtx->state.gfxCtx); } } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_TitleCardDraw.s") +void Actor_GetProjectedPos(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, arg2, arg3); + if (*arg3 < 1.0f) { + *arg3 = 1.0f; + } else { + *arg3 = 1.0f / *arg3; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6434.s") +void Target_SetPos(TargetContext* targetCtx, s32 index, f32 x, f32 y, f32 z) { + targetCtx->unk50[index].pos.x = x; + targetCtx->unk50[index].pos.y = y; + targetCtx->unk50[index].pos.z = z; + targetCtx->unk50[index].unkC = targetCtx->unk44; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6468.s") +typedef struct { + /* 0x0 */ Color_RGBA8 inner; + /* 0x4 */ Color_RGBA8 outer; +} TatlColor; // size = 0x8 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6474.s") +TatlColor sTatlColorList[] = { + { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, + { { 255, 255, 230, 255 }, { 220, 160, 80, 0 } }, { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, + { { 150, 150, 255, 255 }, { 150, 150, 255, 0 } }, { { 255, 255, 0, 255 }, { 200, 155, 0, 0 } }, + { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, + { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, { { 255, 255, 0, 255 }, { 200, 155, 0, 0 } }, + { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, + { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } } +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B648C.s") +void func_800B4F78(TargetContext* targetCtx, s32 type, GlobalContext* globalCtx) { + TatlColor* tatlColorEntry; + s32 i; + TargetContextEntry* targetEntry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B64FC.s") + Math_Vec3f_Copy(&targetCtx->targetCenterPos, &globalCtx->view.eye); + targetCtx->unk48 = 0x100; + tatlColorEntry = &sTatlColorList[type]; + targetCtx->unk44 = 500.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6584.s") + targetEntry = targetCtx->unk50; + for (i = 0; i < ARRAY_COUNT(targetCtx->unk50); i++, targetEntry++) { + Target_SetPos(targetCtx, i, 0.0f, 0.0f, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6608.s") + targetEntry->color.r = tatlColorEntry->inner.r; + targetEntry->color.g = tatlColorEntry->inner.g; + targetEntry->color.b = tatlColorEntry->inner.b; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6680.s") +void Target_SetColors(TargetContext* targetCtx, Actor* actor, s32 type, GlobalContext* globalCtx) { + targetCtx->unk0.x = actor->focus.pos.x; + targetCtx->unk0.y = actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y); + targetCtx->unk0.z = actor->focus.pos.z; + + targetCtx->fairyInner.r = sTatlColorList[type].inner.r; + targetCtx->fairyInner.g = sTatlColorList[type].inner.g; + targetCtx->fairyInner.b = sTatlColorList[type].inner.b; + targetCtx->fairyInner.a = sTatlColorList[type].inner.a; + targetCtx->fairyOuter.r = sTatlColorList[type].outer.r; + targetCtx->fairyOuter.g = sTatlColorList[type].outer.g; + targetCtx->fairyOuter.b = sTatlColorList[type].outer.b; + targetCtx->fairyOuter.a = sTatlColorList[type].outer.a; +} + +void Actor_TargetContextInit(TargetContext* targetCtx, Actor* actor, GlobalContext* globalCtx) { + targetCtx->bgmEnemy = NULL; + targetCtx->unk8C = NULL; + targetCtx->targetedActor = NULL; + targetCtx->arrowPointedActor = NULL; + targetCtx->unk4B = 0; + targetCtx->unk4C = 0; + targetCtx->unk40 = 0.0f; + Target_SetColors(targetCtx, actor, actor->category, globalCtx); + func_800B4F78(targetCtx, actor->category, globalCtx); +} + +void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (!(player->stateFlags1 & 0x300006C2)) { + Actor* actor = targetCtx->targetedActor; + + OPEN_DISPS(globalCtx->state.gfxCtx); + if (targetCtx->unk48 != 0) { + TargetContextEntry* entry; + s16 alpha = 255; + f32 var1 = 1.0f; + Vec3f spBC; + s32 spB8; + f32 spB4; + s32 spB0; + s32 spAC; + f32 var2; + s32 i; + + if (targetCtx->unk4B != 0) { + spB8 = 1; + } else { + spB8 = 3; + } + + if (actor != NULL) { + Math_Vec3f_Copy(&targetCtx->targetCenterPos, &actor->focus.pos); + var1 = (500.0f - targetCtx->unk44) / 420.0f; + } else { + targetCtx->unk48 -= 120; + if (targetCtx->unk48 < 0) { + targetCtx->unk48 = 0; + } + alpha = targetCtx->unk48; + } + + Actor_GetProjectedPos(globalCtx, &targetCtx->targetCenterPos, &spBC, &spB4); + + spBC.x = (160 * (spBC.x * spB4)) * var1; + spBC.x = CLAMP(spBC.x, -320.0f, 320.0f); + + spBC.y = (120 * (spBC.y * spB4)) * var1; + spBC.y = CLAMP(spBC.y, -240.0f, 240.0f); + + spBC.z = spBC.z * var1; + + targetCtx->unk4C--; + if (targetCtx->unk4C < 0) { + targetCtx->unk4C = 2; + } + + Target_SetPos(targetCtx, targetCtx->unk4C, spBC.x, spBC.y, spBC.z); + + if ((!(player->stateFlags1 & 0x40)) || (actor != player->unk_730)) { + OVERLAY_DISP = Gfx_CallSetupDL(OVERLAY_DISP, 0x39); + + for (spB0 = 0, spAC = targetCtx->unk4C; spB0 < spB8; spB0++, spAC = (spAC + 1) % 3) { + entry = &targetCtx->unk50[spAC]; + + if (entry->unkC < 500.0f) { + if (entry->unkC <= 120.0f) { + var2 = 0.15f; + } else { + var2 = ((entry->unkC - 120.0f) * 0.001f) + 0.15f; + } + + Matrix_InsertTranslation(entry->pos.x, entry->pos.y, 0.0f, MTXMODE_NEW); + Matrix_Scale(var2, 0.15f, 1.0f, MTXMODE_APPLY); + + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, entry->color.r, entry->color.g, entry->color.b, + (u8)alpha); + + Matrix_InsertZRotation_s((targetCtx->unk4B * 512), MTXMODE_APPLY); + + for (i = 0; i < 4; i++) { + Matrix_InsertZRotation_s(0x4000, MTXMODE_APPLY); + Matrix_StatePush(); + Matrix_InsertTranslation(entry->unkC, entry->unkC, 0.0f, MTXMODE_APPLY); + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(OVERLAY_DISP++, gZTargetLockOnTriangleDL); + Matrix_StatePop(); + } + } + + alpha -= 255 / 3; + if (alpha < 0) { + alpha = 0; + } + } + } + } + + actor = targetCtx->unk_94; + if ((actor != NULL) && !(actor->flags & ACTOR_FLAG_8000000)) { + TatlColor* color = &sTatlColorList[actor->category]; + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x07); + + Matrix_InsertTranslation(actor->focus.pos.x, + actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y) + 17.0f, + actor->focus.pos.z, MTXMODE_NEW); + Matrix_RotateY((globalCtx->gameplayFrames * 3000), MTXMODE_APPLY); + Matrix_Scale((iREG(27) + 35) / 1000.0f, (iREG(28) + 60) / 1000.0f, (iREG(29) + 50) / 1000.0f, + MTXMODE_APPLY); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, color->inner.r, color->inner.g, color->inner.b, 255); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(POLY_XLU_DISP++, gZTargetArrowDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +// OoT: func_8002C7BC +void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + Actor* sp68 = NULL; + s32 category; + Vec3f sp58; + f32 sp54; + + if ((player->unk_730 != 0) && (player->unk_AE3[player->unk_ADE] == 2)) { + targetCtx->unk_94 = NULL; + } else { + func_800BB8EC(gameState, &globalCtx->actorCtx, &sp68, &D_801ED920, player); + targetCtx->unk_94 = sp68; + } + + if (targetCtx->unk8C != 0) { + sp68 = targetCtx->unk8C; + targetCtx->unk8C = NULL; + } else if (actor != 0) { + sp68 = actor; + } + + if (sp68 != NULL) { + category = sp68->category; + } else { + category = player->actor.category; + } + + if ((sp68 != targetCtx->arrowPointedActor) || (category != targetCtx->unk4A)) { + targetCtx->arrowPointedActor = sp68; + targetCtx->unk4A = category; + targetCtx->unk40 = 1.0f; + } + + if (sp68 == NULL) { + sp68 = &player->actor; + } + + if (!Math_StepToF(&targetCtx->unk40, 0.0f, 0.25f)) { + f32 temp_f0; + f32 x; + f32 y; + f32 z; + + temp_f0 = 0.25f / targetCtx->unk40; + + x = sp68->focus.pos.x - targetCtx->unk0.x; + y = (sp68->focus.pos.y + (sp68->targetArrowOffset * sp68->scale.y)) - targetCtx->unk0.y; + z = sp68->focus.pos.z - targetCtx->unk0.z; + + targetCtx->unk0.x += x * temp_f0; + targetCtx->unk0.y += y * temp_f0; + targetCtx->unk0.z += z * temp_f0; + } else { + Target_SetColors(targetCtx, sp68, category, globalCtx); + } + + if (actor != NULL && targetCtx->unk4B == 0) { + Actor_GetProjectedPos(globalCtx, &actor->focus.pos, &sp58, &sp54); + if ((sp58.z <= 0.0f) || (fabsf(sp58.x * sp54) >= 1.0f) || (fabsf(sp58.y * sp54) >= 1.0f)) { + actor = NULL; + } + } + + if (actor != NULL) { + if (actor != targetCtx->targetedActor) { + s32 sfxId; + + func_800B4F78(targetCtx, actor->category, globalCtx); + + targetCtx->targetedActor = actor; + + if (actor->id == ACTOR_EN_BOOM) { + targetCtx->unk48 = 0; + } + + sfxId = + CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_4 | ACTOR_FLAG_1) ? NA_SE_SY_LOCK_ON : NA_SE_SY_LOCK_ON_HUMAN; + play_sound(sfxId); + } + + targetCtx->targetCenterPos.x = actor->world.pos.x; + targetCtx->targetCenterPos.y = actor->world.pos.y - (actor->shape.yOffset * actor->scale.y); + targetCtx->targetCenterPos.z = actor->world.pos.z; + + if (targetCtx->unk4B == 0) { + f32 temp_f0_2; + f32 clampedFloat; + + temp_f0_2 = (500.0f - targetCtx->unk44) * 3.0f; + clampedFloat = CLAMP(temp_f0_2, 30.0f, 100.0f); + + if (Math_StepToF(&targetCtx->unk44, 80.0f, clampedFloat)) { + targetCtx->unk4B++; + } + } else { + targetCtx->unk4B = (targetCtx->unk4B + 3) | 0x80; + targetCtx->unk44 = 120.0f; + } + } else { + targetCtx->targetedActor = NULL; + Math_StepToF(&targetCtx->unk44, 500.0f, 80.0f); + } +} + +/* Start of Flags section */ + +/** + * Tests if current scene switch flag is set. + */ +s32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag) { + if (flag >= 0 && flag < 0x80) { + return globalCtx->actorCtx.flags.switches[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F)); + } + return 0; +} + +/** + * Sets current scene switch flag. + */ +void Flags_SetSwitch(GlobalContext* globalCtx, s32 flag) { + if (flag >= 0 && flag < 0x80) { + globalCtx->actorCtx.flags.switches[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F); + } +} + +/** + * Unsets current scene switch flag. + */ +void Flags_UnsetSwitch(GlobalContext* globalCtx, s32 flag) { + if (flag >= 0 && flag < 0x80) { + globalCtx->actorCtx.flags.switches[(flag & ~0x1F) >> 5] &= ~(1 << (flag & 0x1F)); + } +} + +/** + * Tests if current scene chest flag is set. + */ +s32 Flags_GetTreasure(GlobalContext* globalCtx, s32 flag) { + return globalCtx->actorCtx.flags.chest & (1 << flag); +} + +/** + * Sets current scene chest flag. + */ +void Flags_SetTreasure(GlobalContext* globalCtx, s32 flag) { + globalCtx->actorCtx.flags.chest |= (1 << flag); +} + +/** + * Overrides the all the chest flags. + */ +void Flags_SetAllTreasure(GlobalContext* globalCtx, s32 flag) { + globalCtx->actorCtx.flags.chest = flag; +} + +/** + * Returns all the chest flags. + */ +s32 Flags_GetAllTreasure(GlobalContext* globalCtx) { + return globalCtx->actorCtx.flags.chest; +} + +/** + * Tests if current scene clear flag is set. + */ +s32 Flags_GetClear(GlobalContext* globalCtx, s32 roomNumber) { + return globalCtx->actorCtx.flags.clearedRoom & (1 << roomNumber); +} + +/** + * Sets current scene clear flag. + */ +void Flags_SetClear(GlobalContext* globalCtx, s32 roomNumber) { + globalCtx->actorCtx.flags.clearedRoom |= (1 << roomNumber); +} + +/** + * Unsets current scene clear flag. + */ +void Flags_UnsetClear(GlobalContext* globalCtx, s32 roomNumber) { + globalCtx->actorCtx.flags.clearedRoom &= ~(1 << roomNumber); +} + +/** + * Tests if current scene temp clear flag is set. + */ +s32 Flags_GetClearTemp(GlobalContext* globalCtx, s32 roomNumber) { + return globalCtx->actorCtx.flags.clearedRoomTemp & (1 << roomNumber); +} + +/** + * Sets current scene temp clear flag. + */ +void Flags_SetClearTemp(GlobalContext* globalCtx, s32 roomNumber) { + globalCtx->actorCtx.flags.clearedRoomTemp |= (1 << roomNumber); +} + +/** + * Unsets current scene temp clear flag. + */ +void Flags_UnsetClearTemp(GlobalContext* globalCtx, s32 roomNumber) { + globalCtx->actorCtx.flags.clearedRoomTemp &= ~(1 << roomNumber); +} + +/** + * Tests if current scene collectible flag is set. + */ +s32 Flags_GetCollectible(GlobalContext* globalCtx, s32 flag) { + if (flag > 0 && flag < 0x80) { + return globalCtx->actorCtx.flags.collectible[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F)); + } + return 0; +} + +/** + * Sets current scene collectible flag. + */ +void Flags_SetCollectible(GlobalContext* globalCtx, s32 flag) { + if (flag > 0 && flag < 0x80) { + globalCtx->actorCtx.flags.collectible[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F); + } +} + +/* End of Flags section */ + +/* Start of TitleCard section */ + +void TitleCard_ContextInit(GameState* gameState, TitleCardContext* titleCtx) { + titleCtx->durationTimer = 0; + titleCtx->delayTimer = 0; + titleCtx->intensity = 0; + titleCtx->alpha = 0; +} + +void TitleCard_InitBossName(GameState* gameState, TitleCardContext* titleCtx, TexturePtr texture, s16 x, s16 y, + u8 width, u8 height) { + titleCtx->texture = texture; + titleCtx->x = x; + titleCtx->y = y; + titleCtx->width = width; + titleCtx->height = height; + titleCtx->durationTimer = 80; + titleCtx->delayTimer = 0; +} + +void TitleCard_InitPlaceName(GameState* gameState, TitleCardContext* titleCtx, TexturePtr texture, s32 x, s32 y, + s32 width, s32 height, s32 delay) { +} + +void TitleCard_Update(GameState* gameState, TitleCardContext* titleCtx) { + if (DECR(titleCtx->delayTimer) == 0) { + if (DECR(titleCtx->durationTimer) == 0) { + Math_StepToS(&titleCtx->alpha, 0, 30); + Math_StepToS(&titleCtx->intensity, 0, 70); + } else { + Math_StepToS(&titleCtx->alpha, 255, 10); + Math_StepToS(&titleCtx->intensity, 255, 20); + } + } +} + +void TitleCard_Draw(GameState* gameState, TitleCardContext* titleCtx) { + if (titleCtx->alpha != 0) { + s32 width = titleCtx->width; + s32 height = titleCtx->height; + s32 unk1; + s32 spC0; + s32 sp38; + s32 spB8; + s32 spB4; + s32 temp; + + temp = width * 2; + spC0 = (titleCtx->x * 4) - temp; + spB8 = (titleCtx->y * 4) - (height * 2); + sp38 = width * 2; + + OPEN_DISPS(gameState->gfxCtx); + + height = (width * height > TMEM_SIZE) ? TMEM_SIZE / width : height; + spB4 = spB8 + (height * 4); + + if (1) {} + + OVERLAY_DISP = func_8012C014(OVERLAY_DISP); + + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, (u8)titleCtx->intensity, (u8)titleCtx->intensity, (u8)titleCtx->intensity, + (u8)titleCtx->alpha); + + gDPLoadTextureBlock(OVERLAY_DISP++, (s32*)titleCtx->texture, G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gSPTextureRectangle(OVERLAY_DISP++, spC0, spB8, ((sp38 * 2) + spC0) - 4, spB8 + (height * 4) - 1, + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + + height = titleCtx->height - height; + + if (height > 0) { + gDPLoadTextureBlock(OVERLAY_DISP++, (s32)titleCtx->texture + 0x1000, G_IM_FMT_IA, G_IM_SIZ_8b, width, + height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, + G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + gSPTextureRectangle(OVERLAY_DISP++, spC0, spB4, ((sp38 * 2) + spC0) - 4, spB4 + (height * 4) - 1, + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + } + + CLOSE_DISPS(gameState->gfxCtx); + } +} + +/* End of TitleCard section */ + +// unused +s32 func_800B6434(GlobalContext* globalCtx, TitleCardContext* titleCtx) { + if ((globalCtx->actorCtx.titleCtxt.delayTimer != 0) || (globalCtx->actorCtx.titleCtxt.alpha != 0)) { + titleCtx->durationTimer = 0; + titleCtx->delayTimer = 0; + return false; + } + return true; +} + +void func_800B6468(GlobalContext* globalCtx) { + globalCtx->actorCtx.unk1F5 = 0; +} + +void func_800B6474(GlobalContext* globalCtx) { + if (globalCtx->actorCtx.unk1F5 != 0) { + globalCtx->actorCtx.unk1F5--; + } +} + +s32 func_800B648C(GlobalContext* globalCtx, s32 arg1, s32 arg2, f32 arg3, Vec3f* arg4) { + if ((globalCtx->actorCtx.unk1F5 != 0) && (arg3 < globalCtx->actorCtx.unk1F8)) { + return false; + } + + globalCtx->actorCtx.unk1F4 = arg1; + globalCtx->actorCtx.unk1F5 = arg2; + globalCtx->actorCtx.unk1F8 = arg3; + Math_Vec3f_Copy(&globalCtx->actorCtx.unk1FC, arg4); + + return true; +} + +f32 func_800B64FC(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2, u32* arg3) { + f32 temp_f8; + + if ((globalCtx->actorCtx.unk1F5 == 0) || (arg1 == 0.0f)) { + return -1.0f; + } + + temp_f8 = Math_Vec3f_DistXYZ(&globalCtx->actorCtx.unk1FC, arg2) / arg1; + *arg3 = globalCtx->actorCtx.unk1F4; + return globalCtx->actorCtx.unk1F8 - temp_f8; +} + +/** + * Initializes an element of the `globalCtx->actorCtx.unk_20C` array to the `arg2` pointer, or allocates one using the + * `size` argument in case `arg2` is NULL. This element is associated to an `id` + * + * In success returns the allocated pointer if `arg2` was NULL or the `arg2` pointer otherwise + * In failure (There's no space left in `globalCtx->actorCtx.unk_20C` or an allocation error happened) returns NULL + * + * Note there are no duplicated id checks. + * + * Used only by EnLiftNuts. + */ +void* func_800B6584(GlobalContext* globalCtx, s16 id, void* arg2, size_t size) { + ActorContext_unk_20C* entry = globalCtx->actorCtx.unk_20C; + s32 i; + + for (i = 0; i < ARRAY_COUNT(globalCtx->actorCtx.unk_20C); i++) { + if (entry->id == 0) { + if (arg2 == NULL) { + arg2 = ZeldaArena_Malloc(size); + if (arg2 == NULL) { + return NULL; + } + entry->isDynamicallyInitialised = true; + } + + entry->id = id; + entry->ptr = arg2; + return arg2; + } + + entry++; + } + + return NULL; +} + +/** + * Frees the first element of `globalCtx->actorCtx.unk_20C` with id `id`. + * + * If success, the free'd pointer is returned. + * If failure, NULL is returned. + * + * Used only by EnLiftNuts. + */ +void* func_800B6608(GlobalContext* globalCtx, s16 id) { + ActorContext_unk_20C* entry = globalCtx->actorCtx.unk_20C; + s32 i; + + for (i = 0; i < ARRAY_COUNT(globalCtx->actorCtx.unk_20C); i++) { + if (id == entry->id) { + entry->id = 0; + if (entry->isDynamicallyInitialised) { + ZeldaArena_Free(entry->ptr); + entry->isDynamicallyInitialised = false; + } + return entry->ptr; + } + + entry++; + } + + return NULL; +} + +/** + * Retrieves the first pointer stored with the id `id`. + * If there's no pointer stored with that id, NULL is returned. + * + * Used only by EnLiftNuts. + */ +void* func_800B6680(GlobalContext* globalCtx, s16 id) { + ActorContext_unk_20C* entry = globalCtx->actorCtx.unk_20C; + s32 i; + + for (i = 0; i < ARRAY_COUNT(globalCtx->actorCtx.unk_20C); i++) { + if (id == entry->id) { + return entry->ptr; + } + + entry++; + } + + return NULL; +} void Actor_MarkForDeath(Actor* actor) { actor->draw = NULL; actor->update = NULL; - actor->flags &= ~0x1; + actor->flags &= ~ACTOR_FLAG_1; } -void Actor_InitCurrPosition(Actor* actor) { +void Actor_SetWorldToHome(Actor* actor) { actor->world = actor->home; } -void Actor_SetHeight(Actor* actor, f32 height) { +void Actor_SetFocus(Actor* actor, f32 height) { actor->focus.pos.x = actor->world.pos.x; actor->focus.pos.y = actor->world.pos.y + height; actor->focus.pos.z = actor->world.pos.z; + actor->focus.rot.x = actor->world.rot.x; actor->focus.rot.y = actor->world.rot.y; actor->focus.rot.z = actor->world.rot.z; } -void Actor_SetRotationFromDrawRotation(Actor* actor) { +void Actor_SetWorldRotToShape(Actor* actor) { actor->world.rot = actor->shape.rot; } -void Actor_InitDrawRotation(Actor* actor) { +void Actor_SetShapeRotToWorld(Actor* actor) { actor->shape.rot = actor->world.rot; } @@ -317,43 +1060,38 @@ void Actor_SetScale(Actor* actor, f32 scale) { actor->scale.x = scale; } -void Actor_SetObjectSegment(GlobalContext* globalCtx, Actor* actor) { - // TODO: Segment number enum +void Actor_SetObjectDependency(GlobalContext* globalCtx, Actor* actor) { gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[actor->objBankIndex].segment); } -#if 0 -void Actor_InitToDefaultValues(Actor* actor, GlobalContext* globalCtx) { - Actor_InitCurrPosition(actor); - Actor_InitDrawRotation(actor); - Actor_SetHeight(actor, 0); +void Actor_Init(Actor* actor, GlobalContext* globalCtx) { + Actor_SetWorldToHome(actor); + Actor_SetShapeRotToWorld(actor); + Actor_SetFocus(actor, 0.0f); Math_Vec3f_Copy(&actor->prevPos, &actor->world.pos); - Actor_SetScale(actor, 0.01); + Actor_SetScale(actor, 0.01f); actor->targetMode = 3; - actor->minYVelocity = -20.0f; + actor->terminalVelocity = -20.0f; - actor->meshAttachedTo = 0x32; - - actor->sqrdDistToLink = D_801DCA54; - CollisionCheck_InitInfo(&actor->colChkInfo); + actor->xyzDistToPlayerSq = FLT_MAX; actor->uncullZoneForward = 1000.0f; actor->uncullZoneScale = 350.0f; actor->uncullZoneDownward = 700.0f; - actor->naviMsgId = 255; + actor->hintId = 255; - Actor_Setshape(&actor->shape, 0, 0, 0); - if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex) != 0) { - Actor_SetObjectSegment(globalCtx, actor); + CollisionCheck_InitInfo(&actor->colChkInfo); + actor->floorBgId = BGCHECK_SCENE; + + ActorShape_Init(&actor->shape, 0.0f, NULL, 0.0f); + if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { + Actor_SetObjectDependency(globalCtx, actor); actor->init(actor, globalCtx); actor->init = NULL; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_InitToDefaultValues.s") -#endif -void Actor_FiniActor(Actor* actor, GlobalContext* globalCtx) { +void Actor_Destroy(Actor* actor, GlobalContext* globalCtx) { if (actor->init == NULL) { if (actor->destroy != NULL) { actor->destroy(actor, globalCtx); @@ -362,60 +1100,111 @@ void Actor_FiniActor(Actor* actor, GlobalContext* globalCtx) { } } +f32 actorMovementScale = 1.0f; + void Actor_SetMovementScale(s32 scale) { actorMovementScale = scale * 0.5f; } -void Actor_ApplyMovement(Actor* actor) { +/** + * Update actor position using velocity and any push from z_collision_check. + */ +void Actor_UpdatePos(Actor* actor) { f32 speedRate = actorMovementScale; - actor->world.pos.x += ((actor->velocity.x * speedRate) + actor->colChkInfo.displacement.x); - actor->world.pos.y += ((actor->velocity.y * speedRate) + actor->colChkInfo.displacement.y); - actor->world.pos.z += ((actor->velocity.z * speedRate) + actor->colChkInfo.displacement.z); + actor->world.pos.x += (actor->velocity.x * speedRate) + actor->colChkInfo.displacement.x; + actor->world.pos.y += (actor->velocity.y * speedRate) + actor->colChkInfo.displacement.y; + actor->world.pos.z += (actor->velocity.z * speedRate) + actor->colChkInfo.displacement.z; } -void Actor_SetVelocityYRotationAndGravity(Actor* actor) { +/** + * Updates actor's velocity accounting for gravity (without exceeding terminal velocity) + * The operation is performed in cylindrical coordinates + * + * It is recommended to not call this function directly and use `Actor_MoveWithGravity` instead + */ +void Actor_UpdateVelocityWithGravity(Actor* actor) { actor->velocity.x = actor->speedXZ * Math_SinS(actor->world.rot.y); actor->velocity.z = actor->speedXZ * Math_CosS(actor->world.rot.y); - actor->velocity.y += actor->gravity; - if (actor->velocity.y < actor->minVelocityY) { - actor->velocity.y = actor->minVelocityY; + actor->velocity.y += actor->gravity; + if (actor->velocity.y < actor->terminalVelocity) { + actor->velocity.y = actor->terminalVelocity; } } -void Actor_SetVelocityAndMoveYRotationAndGravity(Actor* actor) { - Actor_SetVelocityYRotationAndGravity(actor); - Actor_ApplyMovement(actor); +/** + * Moves actor accounting for its current velocity and applying gravity + * The operation is performed in cylindrical coordinates + */ +void Actor_MoveWithGravity(Actor* actor) { + Actor_UpdateVelocityWithGravity(actor); + Actor_UpdatePos(actor); } -void Actor_SetVelocityXYRotation(Actor* actor) { - f32 velX = Math_CosS(actor->world.rot.x) * actor->speedXZ; - actor->velocity.x = Math_SinS(actor->world.rot.y) * velX; +/** + * Updates actor's velocity, ignoring gravity + * The operation is performed in spherical coordinates + * + * It is recommended to not call this function directly and use `Actor_MoveWithoutGravity` instead + */ +void Actor_UpdateVelocityWithoutGravity(Actor* actor) { + f32 horizontalSpeed = Math_CosS(actor->world.rot.x) * actor->speedXZ; + + actor->velocity.x = Math_SinS(actor->world.rot.y) * horizontalSpeed; actor->velocity.y = Math_SinS(actor->world.rot.x) * actor->speedXZ; - actor->velocity.z = Math_CosS(actor->world.rot.y) * velX; + actor->velocity.z = Math_CosS(actor->world.rot.y) * horizontalSpeed; } -void Actor_SetVelocityAndMoveXYRotation(Actor* actor) { - Actor_SetVelocityXYRotation(actor); - Actor_ApplyMovement(actor); +/** + * Moves actor accounting for its current velocity, without applying gravity + * The operation is performed in spherical coordinates + * + * Useful for flying or swimming actors + */ +void Actor_MoveWithoutGravity(Actor* actor) { + Actor_UpdateVelocityWithoutGravity(actor); + Actor_UpdatePos(actor); } -void Actor_SetVelocityXYRotationReverse(Actor* actor) { - f32 velX = Math_CosS(-actor->world.rot.x) * actor->speedXZ; - actor->velocity.x = Math_SinS(actor->world.rot.y) * velX; +/** + * Like `Actor_UpdateVelocityWithoutGravity`, but the actor is moved backwards instead of forwards + * + * It is recommended to not call this function directly and use `Actor_MoveWithoutGravityReverse` instead + */ +void Actor_UpdateVelocityWithoutGravityReverse(Actor* actor) { + f32 horizontalSpeed = Math_CosS(-actor->world.rot.x) * actor->speedXZ; + + actor->velocity.x = Math_SinS(actor->world.rot.y) * horizontalSpeed; actor->velocity.y = Math_SinS(-actor->world.rot.x) * actor->speedXZ; - actor->velocity.z = Math_CosS(actor->world.rot.y) * velX; + actor->velocity.z = Math_CosS(actor->world.rot.y) * horizontalSpeed; } -void Actor_SetVelocityAndMoveXYRotationReverse(Actor* actor) { - Actor_SetVelocityXYRotationReverse(actor); - Actor_ApplyMovement(actor); +/** + * Like `Actor_MoveWithoutGravity`, but the actor is moved backwards instead of forwards + */ +void Actor_MoveWithoutGravityReverse(Actor* actor) { + Actor_UpdateVelocityWithoutGravityReverse(actor); + Actor_UpdatePos(actor); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6C04.s") +/** + * Sets horizontal speed and Y velocity using the `speed` argument and current pitch + */ +void Actor_SetSpeeds(Actor* actor, f32 speed) { + actor->speedXZ = Math_CosS(actor->world.rot.x) * speed; + actor->velocity.y = -Math_SinS(actor->world.rot.x) * speed; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6C58.s") +// unused +void Actor_UpdatePosFromSkelAnime(Actor* actor, SkelAnime* skelAnime) { + Vec3f pos; + + SkelAnime_UpdateTranslation(skelAnime, &pos, actor->shape.rot.y); + actor->world.pos.x += pos.x * actor->scale.x; + actor->world.pos.y += pos.y * actor->scale.y; + actor->world.pos.z += pos.z * actor->scale.z; +} s16 Actor_YawBetweenActors(Actor* from, Actor* to) { return Math_Vec3f_Yaw(&from->world.pos, &to->world.pos); @@ -457,171 +1246,744 @@ f32 Actor_XZDistanceToPoint(Actor* actor, Vec3f* point) { return Math_Vec3f_DistXZ(&actor->world.pos, point); } -/** Performs the affine (linear) transformation from world coordinates to actor coordinates +/** + * Find the offset of a point from an actor in that actor's own coordinates (origin at the actor's + * world.pos, z-axis is facing angle, i.e. shape.rot.y) * * @param[in] actor The actor whose coordinate system to transform to. * @param[out] offset The transformed coordinates. * @param[in] point The point to transform to actor coordinates. */ -void Actor_CalcOffsetOrientedToDrawRotation(Actor* actor, Vec3f* offset, Vec3f* point) { - f32 cos_rot_y; - f32 sin_rot_y; - f32 imm_x; - f32 imm_z; +void Actor_OffsetOfPointInActorCoords(Actor* actor, Vec3f* offset, Vec3f* point) { + f32 cos = Math_CosS(actor->shape.rot.y); + f32 sin = Math_SinS(actor->shape.rot.y); + f32 diffX; + f32 diffZ; - cos_rot_y = Math_CosS(actor->shape.rot.y); - sin_rot_y = Math_SinS(actor->shape.rot.y); - imm_x = point->x - actor->world.pos.x; - imm_z = point->z - actor->world.pos.z; - offset->x = ((imm_x * cos_rot_y) - (imm_z * sin_rot_y)); - offset->z = ((imm_z * cos_rot_y) + (imm_x * sin_rot_y)); + // Shift X,Z to actor coordinates origin + diffX = point->x - actor->world.pos.x; + diffZ = point->z - actor->world.pos.z; + + // Rotate X and Z offsets to align Z to actor's shape.rot.y + offset->x = ((diffX * cos) - (diffZ * sin)); + offset->z = ((diffZ * cos) + (diffX * sin)); + + // Shift Y to origin offset->y = point->y - actor->world.pos.y; } -f32 Actor_YDistance(Actor* actor1, Actor* actor2) { +f32 Actor_HeightDiff(Actor* actor1, Actor* actor2) { return actor2->world.pos.y - actor1->world.pos.y; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6F20.s") +/** + * Sets the current and new inputs. + */ +void func_800B6F20(GlobalContext* globalCtx, Input* input, f32 magnitude, s16 baseYaw) { + s16 relativeYaw = baseYaw - func_800DFC68(GET_ACTIVE_CAM(globalCtx)); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B6FC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7090.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7118.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7128.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B715C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7170.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B71DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7200.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B722C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B724C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7298.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B72E0.s") - -void func_800B72F8(DynaPolyActor* dpactor, f32 a1, s16 a2) { - dpactor->yRotation = a2; - dpactor->pushForce += a1; + input->cur.stick_x = -Math_SinS(relativeYaw) * magnitude; + input->rel.stick_x = input->cur.stick_x; + input->cur.stick_y = Math_CosS(relativeYaw) * magnitude; + input->rel.stick_y = input->cur.stick_y; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_IsLinkFacingActor.s") +f32 Player_GetHeight(Player* player) { + f32 extraHeight; -s32 Actor_IsActorFacedByActor(Actor* actor, Actor* other, s16 tolerance) { - s16 angle; - s16 dist; - - angle = BINANG_ROT180(Actor_YawBetweenActors(actor, other)); - dist = angle - other->shape.rot.y; - if (ABS_ALT(dist) < tolerance) { - return 1; + if (player->stateFlags1 & 0x800000) { + extraHeight = 32.0f; + } else { + extraHeight = 0.0f; } - return 0; -} -s32 Actor_IsActorFacingLink(Actor* actor, s16 angle) { - s16 dist; - - dist = actor->yawTowardsPlayer - actor->shape.rot.y; - if (ABS_ALT(dist) < angle) { - return 1; + switch (player->transformation) { + default: + case PLAYER_FORM_FIERCE_DEITY: + return extraHeight + 124.0f; + case PLAYER_FORM_GORON: + // (player->stateFlags3 & 0x1000): being curled? + return extraHeight + ((player->stateFlags3 & 0x1000) ? 34.0f : 80.0f); + case PLAYER_FORM_ZORA: + return extraHeight + 68.0f; + case PLAYER_FORM_DEKU: + return extraHeight + 36.0f; + case PLAYER_FORM_HUMAN: + return extraHeight + 44.0f; } - return 0; } -s32 Actor_IsActorFacingActor(Actor* actor, Actor* other, s16 tolerance) { - s16 dist; - - dist = Actor_YawBetweenActors(actor, other) - actor->shape.rot.y; - if (ABS_ALT(dist) < tolerance) { - return 1; +f32 Player_GetRunSpeedLimit(Player* player) { + if (player->stateFlags1 & 0x800000) { + return 15.0f; + } else if (player->stateFlags1 & 0x8000000) { + return (R_RUN_SPEED_LIMIT / 100.0f) * 0.6f; + } else { + return R_RUN_SPEED_LIMIT / 100.0f; } - return 0; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_IsActorFacingLinkAndWithinRange.s") +s32 func_800B7118(Player* player) { + return player->stateFlags1 & 0x8; +} -s32 Actor_IsActorFacingActorAndWithinRange(Actor* actor, Actor* other, f32 range, s16 tolerance) { - s16 dist; +s32 func_800B7128(Player* player) { + return func_800B7118(player) && player->unk_ACC; +} - if (Actor_DistanceBetweenActors(actor, other) < range) { - dist = Actor_YawBetweenActors(actor, other) - actor->shape.rot.y; - if (ABS_ALT(dist) < tolerance) { - return 1; +s32 func_800B715C(GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + return player->stateFlags2 & 0x8; +} + +void Actor_SetCameraHorseSetting(GlobalContext* globalCtx, Player* player) { + if ((globalCtx->roomCtx.currRoom.unk3 != 4) && (player->actor.id == ACTOR_PLAYER)) { + EnHorse* rideActor = (EnHorse*)player->rideActor; + + if ((rideActor != NULL) && !(rideActor->unk_1EC & 0x10)) { + func_800DFAC8(Play_GetCamera(globalCtx, MAIN_CAM), 4); } } - return 0; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B75A0.s") +void Actor_MountHorse(GlobalContext* globalCtx, Player* player, Actor* horse) { + player->rideActor = horse; + player->stateFlags1 |= 0x800000; + horse->child = &player->actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B761C.s") +s32 func_800B7200(Player* player) { + return (player->stateFlags1 & 0x20000080) || (player->csMode != 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7678.s") +void func_800B722C(GameState* gameState, Player* player) { + func_800F40A0(gameState, player); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_UpdateBgCheckInfo.s") +s32 func_800B724C(GlobalContext* globalCtx, Actor* actor, u8 csMode) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7E04.s") + if ((player->csMode == 5) || ((csMode == 6) && (player->csMode == 0))) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B7FE0.s") + player->csMode = csMode; + player->unk_398 = actor; + player->unk_3BA = 0; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8018.s") +u32 func_800B7298(GlobalContext* globalCtx, Actor* actor, u8 csMode) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8050.s") + if (func_800B724C(globalCtx, actor, csMode)) { + player->unk_3BA = 1; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8118.s") +// Unused +void func_800B72E0(DynaPolyActor* dyna) { + dyna->unk14C = 0.0f; + dyna->pushForce = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B81E0.s") +void func_800B72F8(DynaPolyActor* dyna, f32 extraPushForce, s16 yRotation) { + dyna->yRotation = yRotation; + dyna->pushForce += extraPushForce; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8214.s") +/** + * Check if the player is facing the specified actor. + * The maximum angle difference that qualifies as "facing" is specified by `maxAngleDiff`. + */ +s32 Player_IsFacingActor(Actor* actor, s16 maxAngleDiff, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 yawDiff = BINANG_ADD(actor->yawTowardsPlayer, 0x8000) - player->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8248.s") + if (ABS_ALT(yawDiff) < maxAngleDiff) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B82EC.s") +/** + * Check if `actorB` is facing `actorA`. + * The maximum angle difference that qualifies as "facing" is specified by `maxAngle`. + * + * This function is unused in the original game. + */ +s32 Actor_ActorBIsFacingActorA(Actor* actorA, Actor* actorB, s16 maxAngleDiff) { + s16 angle = BINANG_ROT180(Actor_YawBetweenActors(actorA, actorB)); + s16 dist = angle - actorB->shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B83BC.s") + if (ABS_ALT(dist) < maxAngleDiff) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B83F8.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B84D0.s") +/** + * Check if the specified actor is facing the player. + * The maximum angle difference that qualifies as "facing" is specified by `maxAngleDiff`. + */ +s32 Actor_IsFacingPlayer(Actor* actor, s16 angle) { + s16 dist = actor->yawTowardsPlayer - actor->shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8500.s") + if (ABS_ALT(dist) < angle) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B85E0.s") +/** + * Check if `actorA` is facing `actorB`. + * The maximum angle difference that qualifies as "facing" is specified by `maxAngleDiff`. + */ +s32 Actor_ActorAIsFacingActorB(Actor* actorA, Actor* actorB, s16 maxAngleDiff) { + s16 dist = Actor_YawBetweenActors(actorA, actorB) - actorA->shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8614.s") + if (ABS_ALT(dist) < maxAngleDiff) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B863C.s") +/** + * Check if the specified actor is facing the player and is nearby. + * The maximum angle difference that qualifies as "facing" is specified by `maxAngleDiff`. + * The maximum distance that qualifies as "nearby" is specified by `range`. + */ +s32 Actor_IsFacingAndNearPlayer(Actor* actor, f32 range, s16 maxAngleDiff) { + s16 yaw = actor->yawTowardsPlayer - actor->shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B867C.s") + if (ABS_ALT(yaw) < maxAngleDiff) { + s16 pad; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B86C8.s") + if (sqrtf(SQ(actor->xzDistToPlayer) + SQ(actor->playerHeightRel)) < range) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8708.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8718.s") +/** + * Check if `actorA` is facing `actorB` and is nearby. + * The maximum angle difference that qualifies as "facing" is specified by `maxAngleDiff`. + * The maximum distance that qualifies as "nearby" is specified by `range`. + */ +s32 Actor_ActorAIsFacingAndNearActorB(Actor* actorA, Actor* actorB, f32 range, s16 maxAngleDiff) { + if (Actor_DistanceBetweenActors(actorA, actorB) < range) { + s16 dist = Actor_YawBetweenActors(actorA, actorB) - actorA->shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B874C.s") + if (ABS_ALT(dist) < maxAngleDiff) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8804.s") +/* Start of BgCheck related section */ -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B882C.s") +void func_800B75A0(CollisionPoly* poly, Vec3f* normal, s16* azimuth) { + normal->x = COLPOLY_GET_NORMAL(poly->normal.x); + normal->y = COLPOLY_GET_NORMAL(poly->normal.y); + normal->z = COLPOLY_GET_NORMAL(poly->normal.z); + *azimuth = Math_FAtan2F(normal->z, normal->x); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B886C.s") +s32 func_800B761C(Actor* actor, f32 arg1, s32 arg2) { + if (actor->bgCheckFlags & 1) { + actor->bgCheckFlags &= ~1; + actor->bgCheckFlags |= 4; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8898.s") + if ((actor->velocity.y < 0.0f) && (arg2 & 0x10)) { + actor->velocity.y = 0.0f; + } + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8934.s") + return true; +} -u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { +s32 func_800B7678(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s32 flags) { + f32 distToFloor; + s32 bgId; + + pos->y += (flags & 0x800) ? 10.0f : 50.0f; + + actor->floorHeight = + BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &actor->floorPoly, &bgId, actor, pos); + actor->bgCheckFlags &= ~(0x80 | 0x04 | 0x02); + if (actor->floorHeight <= BGCHECK_Y_MIN) { + return func_800B761C(actor, BGCHECK_Y_MIN, flags); + } + + distToFloor = actor->floorHeight - actor->world.pos.y; + actor->floorBgId = bgId; + if ((distToFloor >= 0.0f) || (((actor->bgCheckFlags & 1)) && !(actor->bgCheckFlags & 0x800) && + (distToFloor >= -11.0f) && (actor->velocity.y < 0.0f))) { + actor->bgCheckFlags |= 0x80; + + if (actor->bgCheckFlags & 0x10) { + if (bgId != D_801ED8B4) { + if (distToFloor > 15.0f) { + actor->bgCheckFlags |= 0x100; + } + } else { + actor->world.pos.x = actor->prevPos.x; + actor->world.pos.z = actor->prevPos.z; + } + } + + actor->world.pos.y = actor->floorHeight; + + if (actor->velocity.y <= 0.0f) { + if (!(actor->bgCheckFlags & 1)) { + actor->bgCheckFlags |= 2; + } else if ((flags & 8) && (actor->gravity < 0.0f)) { + actor->velocity.y = -4.0f; + } else if (!(flags & 0x100)) { + actor->velocity.y = 0.0f; + } + + actor->bgCheckFlags |= 1; + BgCheck2_AttachToMesh(&globalCtx->colCtx, actor, (s32)actor->floorBgId); + } + } else { + return func_800B761C(actor, distToFloor, flags); + } + + return true; +} + +void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallCheckHeight, f32 wallCheckRadius, + f32 ceilingCheckHeight, u32 flags) { + f32 sp94 = actor->world.pos.y - actor->prevPos.y; + s32 pad; + Vec3f pos; + + if ((actor->floorBgId != BGCHECK_SCENE) && (actor->bgCheckFlags & 1)) { + BgCheck2_UpdateActorAttachedToMesh(&globalCtx->colCtx, actor->floorBgId, actor); + } + + if (flags & 1) { + s32 bgId; + + actor->bgCheckFlags &= ~0x1000; + if ((!(flags & 0x80) && + (BgCheck_EntitySphVsWall3(&globalCtx->colCtx, &pos, &actor->world.pos, &actor->prevPos, wallCheckRadius, + &actor->wallPoly, &bgId, actor, wallCheckHeight))) || + ((flags & 0x80) && + (BgCheck_EntitySphVsWall4(&globalCtx->colCtx, &pos, &actor->world.pos, &actor->prevPos, wallCheckRadius, + &actor->wallPoly, &bgId, actor, wallCheckHeight)))) { + CollisionPoly* sp7C = actor->wallPoly; + + actor->bgCheckFlags |= 8; + if ((flags & 0x200) && (actor->bgCheckFlags & 0x1000) && ((s32)sp7C->normal.y > 0) && + (sqrtf(SQXYZ(actor->colChkInfo.displacement)) < 10.0f)) { + actor->bgCheckFlags &= ~8; + } else if (actor->bgCheckFlags & 8) { + Math_Vec3f_Copy(&actor->world.pos, &pos); + } + + actor->wallYaw = Math_FAtan2F(sp7C->normal.z, sp7C->normal.x); + actor->wallBgId = bgId; + } else { + actor->bgCheckFlags &= ~8; + } + } + + pos.x = actor->world.pos.x; + pos.z = actor->world.pos.z; + if (flags & 2) { + f32 y; + + pos.y = actor->prevPos.y + 4.0f; + if (BgCheck_EntityCheckCeiling(&globalCtx->colCtx, &y, &pos, (ceilingCheckHeight + sp94) - 4.0f, &D_801ED8B0, + &D_801ED8B4, actor)) { + actor->bgCheckFlags |= 0x10; + actor->world.pos.y = (y + sp94) - 4.0f; + } else { + actor->bgCheckFlags &= ~0x10; + } + } + if (flags & 4) { + WaterBox* waterbox; + f32 y; + + pos.y = actor->prevPos.y; + func_800B7678(globalCtx, actor, &pos, flags); + y = actor->world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, actor->world.pos.x, actor->world.pos.z, &y, + &waterbox)) { + actor->depthInWater = y - actor->world.pos.y; + if (actor->depthInWater <= 0.0f) { + actor->bgCheckFlags &= ~(0x40 | 0x20); + } else if (!(actor->bgCheckFlags & 0x20)) { + actor->bgCheckFlags |= (0x40 | 0x20); + if (!(flags & 0x40)) { + Vec3f sp64; + + sp64.x = actor->world.pos.x; + sp64.y = y; + sp64.z = actor->world.pos.z; + + EffectSsGRipple_Spawn(globalCtx, &sp64, 100, 500, 0); + EffectSsGRipple_Spawn(globalCtx, &sp64, 100, 500, 4); + EffectSsGRipple_Spawn(globalCtx, &sp64, 100, 500, 8); + } + } else { + actor->bgCheckFlags &= ~0x40; + } + } else { + actor->bgCheckFlags &= ~(0x40 | 0x20); + actor->depthInWater = BGCHECK_Y_MIN; + } + } + + if (flags & 0x400) { + WaterBox* waterbox; + f32 y = actor->world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, actor->world.pos.x, actor->world.pos.z, &y, + &waterbox)) { + actor->depthInWater = y - actor->world.pos.y; + + if (actor->depthInWater < 0.0f) { + actor->bgCheckFlags &= ~(0x40 | 0x20); + } else if (!(actor->bgCheckFlags & 0x20)) { + actor->bgCheckFlags |= (0x40 | 0x20); + if (!(flags & 0x40)) { + Vec3f sp50; + + sp50.x = actor->world.pos.x; + sp50.y = y; + sp50.z = actor->world.pos.z; + + EffectSsGRipple_Spawn(globalCtx, &sp50, 100, 500, 0); + EffectSsGRipple_Spawn(globalCtx, &sp50, 100, 500, 4); + EffectSsGRipple_Spawn(globalCtx, &sp50, 100, 500, 8); + } + } else { + actor->bgCheckFlags &= ~0x40; + } + } else { + actor->bgCheckFlags &= ~(0x40 | 0x20); + actor->depthInWater = BGCHECK_Y_MIN; + } + } +} + +Gfx* Hilite_Draw(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx, Gfx* dl, Hilite** hilite) { + LookAt* lookAt = GRAPH_ALLOC(gfxCtx, sizeof(LookAt)); + f32 correctedEyeX = (eye->x == object->x) && (eye->z == object->z) ? eye->x + 0.001f : eye->x; + + *hilite = GRAPH_ALLOC(gfxCtx, sizeof(Hilite)); + + guLookAtHilite(&D_801ED8E0, lookAt, *hilite, correctedEyeX, eye->y, eye->z, object->x, object->y, object->z, 0.0f, + 1.0f, 0.0f, lightDir->x, lightDir->y, lightDir->z, lightDir->x, lightDir->y, lightDir->z, 0x10, + 0x10); + + gSPLookAt(dl++, lookAt); + gDPSetHilite1Tile(dl++, 1, *hilite, 0x10, 0x10); + + return dl; +} + +Hilite* Hilite_DrawOpa(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx) { + Hilite* hilite; + + OPEN_DISPS(gfxCtx); + + POLY_OPA_DISP = Hilite_Draw(object, eye, lightDir, gfxCtx, POLY_OPA_DISP, &hilite); + + CLOSE_DISPS(gfxCtx); + + return hilite; +} + +Hilite* Hilite_DrawXlu(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* gfxCtx) { + Hilite* hilite; + + OPEN_DISPS(gfxCtx); + + POLY_XLU_DISP = Hilite_Draw(object, eye, lightDir, gfxCtx, POLY_XLU_DISP, &hilite); + + CLOSE_DISPS(gfxCtx); + + return hilite; +} + +void func_800B8050(Actor* actor, GlobalContext* globalCtx, s32 flag) { + Hilite* hilite = func_800BCBF4(&actor->world.pos, globalCtx); + + if (flag != 0) { + Gfx* displayListHead; + Gfx* displayList = GRAPH_ALLOC(globalCtx->state.gfxCtx, 2 * sizeof(Gfx)); + + displayListHead = displayList; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gDPSetHilite1Tile(displayListHead++, 1, hilite, 0x10, 0x10); + gSPEndDisplayList(displayListHead); + gSPSegment(POLY_OPA_DISP++, 0x07, displayList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_800B8118(Actor* actor, GlobalContext* globalCtx, s32 flag) { + Hilite* hilite = func_800BCC68(&actor->world.pos, globalCtx); + + if (flag != 0) { + Gfx* displayListHead; + Gfx* displayList = GRAPH_ALLOC(globalCtx->state.gfxCtx, 2 * sizeof(Gfx)); + + displayListHead = displayList; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gDPSetHilite1Tile(displayListHead++, 1, hilite, 0x10, 0x10); + gSPEndDisplayList(displayListHead); + gSPSegment(POLY_XLU_DISP++, 0x07, displayList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +PosRot* Actor_GetFocus(PosRot* dest, Actor* actor) { + *dest = actor->focus; + + return dest; +} + +PosRot* Actor_GetWorld(PosRot* dest, Actor* actor) { + *dest = actor->world; + + return dest; +} + +PosRot* Actor_GetWorldPosShapeRot(PosRot* dest, Actor* actor) { + PosRot sp1C; + + Math_Vec3f_Copy(&sp1C.pos, &actor->world.pos); + if (actor->id == ACTOR_PLAYER) { + Player* player = (Player*)actor; + + sp1C.pos.y += player->unk_AC0 * actor->scale.y; + } + sp1C.rot = actor->shape.rot; + *dest = sp1C; + + return dest; +} + +f32 func_800B82EC(Actor* actor, Player* player, s16 angle) { + f32 temp_f12; + s16 temp_v0 = BINANG_SUB(BINANG_SUB(actor->yawTowardsPlayer, 0x8000), angle); + s16 yaw = ABS_ALT(temp_v0); + + if (player->unk_730 != NULL) { + if ((yaw > 0x4000) || ((actor->flags & ACTOR_FLAG_8000000))) { + return FLT_MAX; + } + + temp_f12 = actor->xyzDistToPlayerSq - ((actor->xyzDistToPlayerSq * 0.8f) * ((0x4000 - yaw) * (1.0f / 0x8000))); + return temp_f12; + } + + if (yaw >= 0x2AAB) { + return FLT_MAX; + } + return actor->xyzDistToPlayerSq; +} + +#define TARGET_RANGE(range, leash) \ + { SQ(range), (f32)range / leash } + +TargetRangeParams gTargetRanges[] = { + TARGET_RANGE(70, 140), TARGET_RANGE(170, 255), TARGET_RANGE(280, 5600), TARGET_RANGE(350, 525), + TARGET_RANGE(700, 1050), TARGET_RANGE(1000, 1500), TARGET_RANGE(100, 105.36842), TARGET_RANGE(140, 163.33333), + TARGET_RANGE(240, 576), TARGET_RANGE(280, 280000), TARGET_RANGE(2500, 3750), +}; + +s32 func_800B83BC(Actor* actor, f32 arg1) { + return arg1 < gTargetRanges[actor->targetMode].rangeSq; +} + +s32 func_800B83F8(Actor* actor, Player* player, s32 flag) { + if ((actor->update == NULL) || !(actor->flags & ACTOR_FLAG_1) || (actor->flags & ACTOR_FLAG_8000000)) { + return true; + } + + if (!flag) { + s16 yaw = BINANG_SUB(actor->yawTowardsPlayer, 0x8000) - player->actor.shape.rot.y; + s16 phi_v1 = ABS_ALT(yaw); + f32 dist; + + if ((player->unk_730 == NULL) && (phi_v1 >= 0x2AAB)) { + dist = FLT_MAX; + } else { + dist = actor->xyzDistToPlayerSq; + } + + return !func_800B83BC(actor, gTargetRanges[actor->targetMode].leashScale * dist); + } + + return false; +} + +s16 D_801AED48[] = { + 0x101, 0x141, 0x111, 0x151, 0x105, 0x145, 0x115, 0x155, +}; + +s32 Actor_ProcessTalkRequest(Actor* actor, GameState* gameState) { + if (actor->flags & ACTOR_FLAG_100) { + actor->flags &= ~ACTOR_FLAG_100; + return true; + } + + return false; +} + +// Actor_PickUpExchange? Seems to be called with exchangeItemId -1 if the same actor used Actor_PickUp +// This function is also used to toggle the "Speak" action on the A button +s32 func_800B8500(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->actor.flags & ACTOR_FLAG_100) || + ((exchangeItemId > EXCH_ITEM_NONE) && Player_InCsMode(&globalCtx->state)) || + (!actor->isTargeted && + ((fabsf(actor->playerHeightRel) > fabsf(yRange)) || ((actor->xzDistToPlayer > player->targetActorDistance)) || + (xzRange < actor->xzDistToPlayer)))) { + return false; + } + + player->targetActor = actor; + player->targetActorDistance = actor->xzDistToPlayer; + player->exchangeItemId = exchangeItemId; + + ActorCutscene_SetIntentToPlay(0x7C); + return true; +} + +s32 func_800B85E0(Actor* actor, GlobalContext* globalCtx, f32 radius, s32 exchangeItemId) { + return func_800B8500(actor, globalCtx, radius, radius, exchangeItemId); +} + +s32 func_800B8614(Actor* actor, GlobalContext* globalCtx, f32 radius) { + return func_800B85E0(actor, globalCtx, radius, EXCH_ITEM_NONE); +} + +s32 func_800B863C(Actor* actor, GlobalContext* globalCtx) { + f32 cylRadius = actor->colChkInfo.cylRadius + 50.0f; + + return func_800B8614(actor, globalCtx, cylRadius); +} + +s32 Actor_TextboxIsClosing(Actor* actor, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 2) { + actor->flags &= ~ACTOR_FLAG_100; + return true; + } + + return false; +} + +/** + * Changes the actor the Player is focussing on + * Fails if Player is not already focussing on an actor or in a talking state + */ +s32 Actor_ChangeFocus(Actor* actor1, GlobalContext* globalCtx, Actor* actor2) { + Actor* targetActor; + Player* player = GET_PLAYER(globalCtx); + + targetActor = player->targetActor; + + if ((player->actor.flags & ACTOR_FLAG_100) && (targetActor != NULL)) { + player->targetActor = actor2; + player->unk_730 = actor2; + return true; + } + + return false; +} + +s32 Player_GetExchangeItemId(GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + return player->exchangeItemId; +} + +s32 func_800B8718(Actor* actor, GameState* gameState) { + if (actor->flags & ACTOR_FLAG_20000000) { + actor->flags &= ~ACTOR_FLAG_20000000; + return true; + } + + return false; +} + +// Similar to func_800B8500 +s32 func_800B874C(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->actor.flags & ACTOR_FLAG_20000000) || Player_InCsMode(&globalCtx->state) || + (yRange < fabsf(actor->playerHeightRel)) || ((player->unk_A94 < actor->xzDistToPlayer)) || + (xzRange < actor->xzDistToPlayer)) { + return false; + } + + player->unk_A90 = actor; + player->unk_A94 = actor->xzDistToPlayer; + return true; +} + +s32 func_800B8804(Actor* actor, GlobalContext* globalCtx, f32 xzRange) { + return func_800B874C(actor, globalCtx, xzRange, 20.0f); +} + +s32 func_800B882C(Actor* actor, GlobalContext* globalCtx) { + f32 cylRadius = actor->colChkInfo.cylRadius + 50.0f; + + return func_800B8804(actor, globalCtx, cylRadius); +} + +s32 func_800B886C(Actor* actor, GlobalContext* globalCtx) { + if (!(GET_PLAYER(globalCtx)->actor.flags & ACTOR_FLAG_20000000)) { + return true; + } + + return false; +} + +void Actor_GetScreenPos(GlobalContext* globalCtx, Actor* actor, s16* x, s16* y) { + Vec3f projectedPos; + f32 w; + + Actor_GetProjectedPos(globalCtx, &actor->focus.pos, &projectedPos, &w); + *x = (projectedPos.x * w * (SCREEN_WIDTH / 2)) + (SCREEN_WIDTH / 2); + *y = (projectedPos.y * w * -(SCREEN_HEIGHT / 2)) + (SCREEN_HEIGHT / 2); +} + +s32 func_800B8934(GlobalContext* globalCtx, Actor* actor) { + Vec3f sp2C; + f32 sp28; + s32 pad[2]; + + Actor_GetProjectedPos(globalCtx, &actor->focus.pos, &sp2C, &sp28); + + return (sp2C.x * sp28 >= -1.0f) && (sp2C.x * sp28 <= 1.0f) && (sp2C.y * sp28 >= -1.0f) && (sp2C.y * sp28 <= 1.0f); +} + +s32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { if (actor->parent != NULL) { return true; } else { @@ -629,119 +1991,1126 @@ u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8A1C.s") +/** + * Allows to pick up an item (GetItem or GI), lift an actor or catch various actors in bottles + * within the specified range. + * + * GI_NONE is usually used as a special case to lift an actor + * GI_MAX is usually used to catch an actor in a bottle + */ +s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRange, f32 yRange) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8B84.s") + if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) { + if ((actor->xzDistToPlayer <= xzRange) && (fabsf(actor->playerHeightRel) <= fabsf(yRange))) { + if (((getItemId == GI_MASK_CIRCUS_LEADER) || (getItemId == GI_PENDANT_OF_MEMORIES) || + (getItemId == GI_DEED_LAND) || + (((player->heldActor != NULL) || (actor == player->targetActor)) && + (getItemId > GI_NONE && getItemId < GI_MAX))) || + (!(player->stateFlags1 & 0x20000800))) { + s16 yawDiff = actor->yawTowardsPlayer - player->actor.shape.rot.y; + s32 absYawDiff = ABS_ALT(yawDiff); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8BB0.s") + if ((getItemId != GI_NONE) || (player->getItemDirection < absYawDiff)) { + player->getItemId = getItemId; + player->interactRangeActor = actor; + player->getItemDirection = absYawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8BD0.s") + if ((getItemId > GI_NONE) && (getItemId < GI_MAX)) { + ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[1]); + } + + return true; + } + } + } + } + + return false; +} + +s32 Actor_PickUpNearby(Actor* actor, GlobalContext* globalCtx, s32 getItemId) { + return Actor_PickUp(actor, globalCtx, getItemId, 50.0f, 10.0f); +} + +s32 Actor_LiftActor(Actor* actor, GlobalContext* globalCtx) { + return Actor_PickUpNearby(actor, globalCtx, GI_NONE); +} + +s32 Actor_PickUpFar(Actor* actor, GlobalContext* globalCtx, s32 getItemId) { + return Actor_PickUp(actor, globalCtx, getItemId, 9999.9f, 9999.9f); +} s32 Actor_HasNoParent(Actor* actor, GlobalContext* globalCtx) { - if (!actor->parent) { + if (actor->parent == NULL) { return true; - } else { - return false; + } + + return false; +} + +void func_800B8C20(Actor* actorA, Actor* actorB, GlobalContext* globalCtx) { + Actor* parent = actorA->parent; + + if (parent->id == ACTOR_PLAYER) { + Player* player = (Player*)parent; + + player->heldActor = actorB; + player->interactRangeActor = actorB; + } + + parent->child = actorB; + actorB->parent = parent; + actorA->parent = NULL; +} + +void func_800B8C50(Actor* actor, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (actor->xyzDistToPlayerSq < player->unk_AA0) { + player->unk_AA0 = actor->xyzDistToPlayerSq; } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8C20.s") +s32 Actor_HasRider(GlobalContext* globalCtx, Actor* horse) { + if (horse->child != NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8C50.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8C78.s") +s32 Actor_SetRideActor(GlobalContext* globalCtx, Actor* horse, s32 mountSide) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8C9C.s") + if (!(player->stateFlags1 & 0x003C7880)) { + player->rideActor = horse; + player->mountSide = mountSide; + ActorCutscene_SetIntentToPlay(0x7C); + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8CEC.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8D10.s") +s32 Actor_HasNoRider(GlobalContext* globalCtx, Actor* horse) { + if (horse->child == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8D50.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8D98.s") +void func_800B8D10(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5, u32 arg6) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8DD4.s") + player->unk_B74 = arg6; + player->unk_B75 = arg5; + player->unk_B78 = arg2; + player->unk_B76 = arg3; + player->unk_B7C = arg4; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8E1C.s") +void func_800B8D50(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 yaw, f32 arg4, u32 arg5) { + func_800B8D10(globalCtx, actor, arg2, yaw, arg4, 3, arg5); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8E58.s") +void func_800B8D98(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4) { + func_800B8D50(globalCtx, actor, arg2, arg3, arg4, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Audio_PlayActorSound2.s") +void func_800B8DD4(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5) { + func_800B8D10(globalCtx, actor, arg2, arg3, arg4, 2, arg5); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8EF4.s") +void func_800B8E1C(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4) { + func_800B8DD4(globalCtx, actor, arg2, arg3, arg4, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8F98.s") +void func_800B8E58(Player* player, u16 sfxId) { + if (player->currentMask == PLAYER_MASK_GIANT) { + func_8019F170(&player->actor.projectedPos, sfxId); + } else { + Audio_PlaySfxGeneral(sfxId, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8FC0.s") +/** + * Plays the sound effect at the actor's position + */ +void Actor_PlaySfxAtPos(Actor* actor, u16 sfxId) { + func_8019F1C0(&actor->projectedPos, sfxId); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B8FE8.s") +void func_800B8EF4(GlobalContext* globalCtx, Actor* actor) { + u32 sfxId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9010.s") + if (actor->bgCheckFlags & 0x20) { + if (actor->depthInWater < 20.0f) { + sfxId = NA_SE_PL_WALK_WATER0 - SFX_FLAG; + } else { + sfxId = NA_SE_PL_WALK_WATER1 - SFX_FLAG; + } + } else { + sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, actor->floorPoly, actor->floorBgId); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9038.s") + func_8019F1C0(&actor->projectedPos, NA_SE_EV_BOMB_BOUND); + func_8019F1C0(&actor->projectedPos, sfxId + SFX_FLAG); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9084.s") +void func_800B8F98(Actor* actor, u16 sfxId) { + actor->sfxId = sfxId; + actor->audioFlags &= ~(0x10 | 0x08 | 0x04 | 0x02 | 0x01); + actor->audioFlags |= 0x02; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9098.s") +void func_800B8FC0(Actor* actor, u16 sfxId) { + actor->sfxId = sfxId; + actor->audioFlags &= ~(0x10 | 0x08 | 0x04 | 0x02 | 0x01); + actor->audioFlags |= 4; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B90AC.s") +void func_800B8FE8(Actor* actor, u16 sfxId) { + actor->sfxId = sfxId; + actor->audioFlags &= ~(0x10 | 0x08 | 0x04 | 0x02 | 0x01); + actor->audioFlags |= 0x08; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B90F4.s") +void func_800B9010(Actor* actor, u16 sfxId) { + actor->sfxId = sfxId; + actor->audioFlags &= ~(0x10 | 0x08 | 0x04 | 0x02 | 0x01); + actor->audioFlags |= 0x01; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9120.s") +void func_800B9038(Actor* actor, s32 timer) { + actor->audioFlags &= ~(0x10 | 0x08 | 0x04 | 0x02 | 0x01); + actor->audioFlags |= 0x10; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_Init.s") + // The sfxId here are not actually sound effects, but instead this is data that gets sent into + // the io ports of the music macro language (func_801A0810 / Audio_PlaySfxAtPosWithSoundScriptIO is + // the function that it's used for) + if (timer < 40) { + actor->sfxId = 3; + } else if (timer < 100) { + actor->sfxId = 2; + } else { + actor->sfxId = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9334.s") +void func_800B9084(Actor* actor) { + actor->audioFlags |= 0x20; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_UpdateActor.s") +void func_800B9098(Actor* actor) { + actor->audioFlags |= 0x40; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_UpdateAll.s") +s32 func_800B90AC(GlobalContext* globalCtx, Actor* actor, CollisionPoly* polygon, s32 index, s32 arg4) { + if (func_800C99D4(&globalCtx->colCtx, polygon, index) == 8) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_DrawActor.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9D1C.s") +void func_800B90F4(GlobalContext* globalCtx) { + if (globalCtx->actorCtx.unk3 != 0) { + globalCtx->actorCtx.unk3 = 0; + func_80115D5C(&globalCtx->state); + } +} + +void func_800B9120(ActorContext* actorCtx) { + s32 phi_v0 = CURRENT_DAY * 2; + + if (gSaveContext.time < CLOCK_TIME(6, 0) || gSaveContext.time > CLOCK_TIME(18, 0)) { + phi_v0++; + } + + actorCtx->unkC = 0x200 >> phi_v0; +} + +void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry* actorEntry) { + ActorOverlay* overlayEntry; + u32* cycleFlags; + s32 i; + + gSaveContext.weekEventReg[92] |= 0x80; + cycleFlags = gSaveContext.cycleSceneFlags[convert_scene_number_among_shared_scenes(globalCtx->sceneNum)]; + + bzero(actorCtx, sizeof(ActorContext)); + ActorOverlayTable_Init(); + Matrix_MtxFCopy(&globalCtx->billboardMtxF, &gIdentityMtxF); + Matrix_MtxFCopy(&globalCtx->viewProjectionMtxF, &gIdentityMtxF); + + overlayEntry = gActorOverlayTable; + for (i = 0; i < ARRAY_COUNT(gActorOverlayTable); i++) { + overlayEntry->loadedRamAddr = NULL; + overlayEntry->numLoaded = 0; + overlayEntry++; + } + + actorCtx->flags.chest = cycleFlags[0]; + actorCtx->flags.switches[0] = cycleFlags[1]; + actorCtx->flags.switches[1] = cycleFlags[2]; + if (globalCtx->sceneNum == SCENE_INISIE_R) { + cycleFlags = gSaveContext.cycleSceneFlags[globalCtx->sceneNum]; + } + actorCtx->flags.collectible[0] = cycleFlags[4]; + actorCtx->flags.clearedRoom = cycleFlags[3]; + + TitleCard_ContextInit(&globalCtx->state, &actorCtx->titleCtxt); + func_800B6468(globalCtx); + + actorCtx->absoluteSpace = NULL; + + Actor_SpawnEntry(actorCtx, actorEntry, globalCtx); + Actor_TargetContextInit(&actorCtx->targetContext, actorCtx->actorLists[ACTORCAT_PLAYER].first, globalCtx); + func_800B9120(actorCtx); + Fault_AddClient(&sActorFaultClient, (void*)Actor_PrintLists, actorCtx, NULL); + func_800B722C(&globalCtx->state, (Player*)actorCtx->actorLists[ACTORCAT_PLAYER].first); +} + +/** + * Spawns the actors in the current setup (of the current scene/setup/room triple) + * Only spawns actors based on the time flags embedded in their rotation parameters + */ +void Actor_SpawnSetupActors(GlobalContext* globalCtx, ActorContext* actorCtx) { + if (globalCtx->numSetupActors > 0) { + ActorEntry* actorEntry = globalCtx->setupActorList; + s32 temp_fp = actorCtx->unkC; + s32 temp_s1; + s32 phi_v0; + s32 i; + + func_800B9120(actorCtx); + func_800BA8B8(globalCtx, &globalCtx->actorCtx); + + temp_s1 = (actorCtx->unkC * 2) & 0x2FF; + + for (i = 0; i < globalCtx->numSetupActors; i++) { + phi_v0 = ((actorEntry->rot.x & 7) << 7) | (actorEntry->rot.z & 0x7F); + if (phi_v0 == 0) { + phi_v0 = 0x3FF; + } + + if (!(phi_v0 & temp_fp) && (phi_v0 & actorCtx->unkC) && + (!(gSaveContext.eventInf[1] & 0x80) || !(phi_v0 & temp_s1) || !(actorEntry->id & 0x800))) { + Actor_SpawnEntry(&globalCtx->actorCtx, actorEntry, globalCtx); + } + actorEntry++; + } + + // Prevents re-spawning the setup actors + globalCtx->numSetupActors = -globalCtx->numSetupActors; + } +} + +typedef struct { + /* 0x00 */ GlobalContext* globalCtx; + /* 0x04 */ Actor* actor; + /* 0x08 */ u32 unk_08; + /* 0x0C */ u32 unkC; + /* 0x10 */ Actor* unk10; + /* 0x14 */ Player* player; + /* 0x18 */ u32 unk_18; // Bitmask of actor flags. The actor will only have main called if it has at least 1 + // flag set that matches this bitmask +} UpdateActor_Params; // size = 0x1C + +Actor* Actor_UpdateActor(UpdateActor_Params* params) { + GlobalContext* globalCtx = params->globalCtx; + Actor* actor = params->actor; + Actor* nextActor; + + if (actor->world.pos.y < -25000.0f) { + actor->world.pos.y = -25000.0f; + } + + actor->sfxId = 0; + actor->audioFlags &= ~0x7F; + + if (actor->init != NULL) { + if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { + Actor_SetObjectDependency(globalCtx, actor); + actor->init(actor, globalCtx); + actor->init = NULL; + } + nextActor = actor->next; + } else if (actor->update == NULL) { + if (!actor->isDrawn) { + nextActor = Actor_Delete(&globalCtx->actorCtx, actor, globalCtx); + } else { + Actor_Destroy(actor, globalCtx); + nextActor = actor->next; + } + } else { + if (!Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { + Actor_MarkForDeath(actor); + } else { + s32 tmp = (params->unk_08 == 0); + + if (((params->unk_08) && !(actor->flags & params->unk_08)) || + ((tmp = (params->unk_08 == 0)) && + (!(actor->flags & ACTOR_FLAG_100000) || + ((actor->category == ACTORCAT_EXPLOSIVES) && (params->player->stateFlags1 & 0x200))) && + (params->unkC != 0) && (actor != params->unk10) && ((actor != params->player->heldActor)) && + (actor->parent != ¶ms->player->actor))) { + CollisionCheck_ResetDamage(&actor->colChkInfo); + } else { + Math_Vec3f_Copy(&actor->prevPos, &actor->world.pos); + actor->xzDistToPlayer = Actor_XZDistanceBetweenActors(actor, ¶ms->player->actor); + actor->playerHeightRel = Actor_HeightDiff(actor, ¶ms->player->actor); + actor->xyzDistToPlayerSq = SQ(actor->xzDistToPlayer) + SQ(actor->playerHeightRel); + + actor->yawTowardsPlayer = Actor_YawBetweenActors(actor, ¶ms->player->actor); + actor->flags &= ~ACTOR_FLAG_1000000; + + if ((DECR(actor->freezeTimer) == 0) && (actor->flags & params->unk_18)) { + if (actor == params->player->unk_730) { + actor->isTargeted = true; + } else { + actor->isTargeted = false; + } + + if ((actor->targetPriority != 0) && (params->player->unk_730 == 0)) { + actor->targetPriority = 0; + } + + Actor_SetObjectDependency(globalCtx, actor); + + if (actor->colorFilterTimer != 0) { + actor->colorFilterTimer--; + } + + actor->update(actor, globalCtx); + BgCheck_ResetFlagsIfLoadedActor(globalCtx, &globalCtx->colCtx.dyna, actor); + } + + CollisionCheck_ResetDamage(&actor->colChkInfo); + } + } + nextActor = actor->next; + } + return nextActor; +} + +u32 D_801AED58[] = { + 0x100002C2, 0x100002C2, 0x00000200, 0x100006C2, 0x00000282, 0x300002C2, + 0x10000282, 0x00000002, 0x300002C2, 0x100006C2, 0x00000002, 0x100002C2, +}; + +void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { + s32 i; + Actor* actor; + Player* player = GET_PLAYER(globalCtx); + u32* tmp; + s32 cat; + Actor* next; + ActorListEntry* entry; + UpdateActor_Params params; + + params.player = player; + params.globalCtx = globalCtx; + + if (globalCtx->unk_18844 != 0) { + params.unk_18 = ACTOR_FLAG_200000; + } else { + params.unk_18 = ACTOR_FLAG_200000 | ACTOR_FLAG_40 | ACTOR_FLAG_10; + } + + Actor_SpawnSetupActors(globalCtx, actorCtx); + + if (actorCtx->unk2 != 0) { + actorCtx->unk2--; + } + + tmp = D_801AED58; + + if (player->stateFlags2 & 0x8000000) { + params.unk_08 = 0x2000000; + } else { + params.unk_08 = 0; + } + + if ((player->stateFlags1 & 0x40) && ((player->actor.textId & 0xFF00) != 0x1900)) { + params.unk10 = player->targetActor; + } else { + params.unk10 = NULL; + } + + for (i = 0, entry = actorCtx->actorLists; i < ARRAY_COUNT(actorCtx->actorLists); entry++, tmp++, i++) { + params.unkC = *tmp & player->stateFlags1; + params.actor = entry->first; + + while (params.actor != NULL) { + params.actor = Actor_UpdateActor(¶ms); + } + + if (i == ACTORCAT_BG) { + DynaPoly_Setup(globalCtx, &globalCtx->colCtx.dyna); + } + } + + for (i = 0, entry = actorCtx->actorLists; i < ARRAY_COUNT(actorCtx->actorLists); entry++, i++) { + if (entry->unk_08 != 0) { + actor = entry->first; + + while (actor != NULL) { + if (i == actor->category) { + actor = actor->next; + } else { + next = actor->next; + cat = actor->category; + actor->category = i; + Actor_RemoveFromCategory(globalCtx, actorCtx, actor); + Actor_AddToCategory(actorCtx, actor, cat); + actor = next; + } + } + entry->unk_08 = 0; + } + } + + actor = player->unk_730; + if ((actor != NULL) && (actor->update == NULL)) { + actor = NULL; + func_80123DA4(player); + } + + if ((actor == NULL) || (player->unk_738 < 5)) { + actor = NULL; + if (actorCtx->targetContext.unk4B != 0) { + actorCtx->targetContext.unk4B = 0; + play_sound(NA_SE_SY_LOCK_OFF); + } + } + + if (!(player->stateFlags1 & 2)) { + func_800B5814(&actorCtx->targetContext, player, actor, &globalCtx->state); + } + + TitleCard_Update(&globalCtx->state, &actorCtx->titleCtxt); + func_800B6474(globalCtx); + DynaPoly_UpdateBgActorTransforms(globalCtx, &globalCtx->colCtx.dyna); +} + +void Actor_Draw(GlobalContext* globalCtx, Actor* actor) { + Lights* light; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + light = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx); + if ((actor->flags & ACTOR_FLAG_10000000) && (globalCtx->roomCtx.currRoom.enablePosLights || (MREG(93) != 0))) { + light->enablePosLights = true; + } + + Lights_BindAll(light, globalCtx->lightCtx.listHead, + (actor->flags & (ACTOR_FLAG_10000000 | ACTOR_FLAG_400000)) ? NULL : &actor->world.pos, globalCtx); + Lights_Draw(light, globalCtx->state.gfxCtx); + + if (actor->flags & ACTOR_FLAG_1000) { + Matrix_SetStateRotationAndTranslation( + actor->world.pos.x + globalCtx->mainCamera.skyboxOffset.x, + actor->world.pos.y + ((actor->shape.yOffset * actor->scale.y) + globalCtx->mainCamera.skyboxOffset.y), + actor->world.pos.z + globalCtx->mainCamera.skyboxOffset.z, &actor->shape.rot); + } else { + Matrix_SetStateRotationAndTranslation(actor->world.pos.x, + actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), + actor->world.pos.z, &actor->shape.rot); + } + + Matrix_Scale(actor->scale.x, actor->scale.y, actor->scale.z, MTXMODE_APPLY); + Actor_SetObjectDependency(globalCtx, actor); + + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[actor->objBankIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[actor->objBankIndex].segment); + + if (actor->colorFilterTimer != 0) { + s32 temp_v0_2 = actor->colorFilterParams & 0xC000; + Color_RGBA8 actorDefaultHitColor = { 0, 0, 0, 255 }; + + if (temp_v0_2 == 0x8000) { + actorDefaultHitColor.r = actorDefaultHitColor.g = actorDefaultHitColor.b = + ((actor->colorFilterParams & 0x1F00) >> 5) | 7; + } else if (temp_v0_2 == 0x4000) { + actorDefaultHitColor.r = ((actor->colorFilterParams & 0x1F00) >> 5) | 7; + } else if (temp_v0_2 == 0xC000) { + actorDefaultHitColor.b = actorDefaultHitColor.g = actorDefaultHitColor.r = 0; + } else { + actorDefaultHitColor.b = ((actor->colorFilterParams & 0x1F00) >> 5) | 7; + } + + if (actor->colorFilterParams & 0x2000) { + func_800AE778(globalCtx, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); + } else { + func_800AE434(globalCtx, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); + } + } + + actor->draw(actor, globalCtx); + + if (actor->colorFilterTimer != 0) { + if (actor->colorFilterParams & 0x2000) { + func_800AE8EC(globalCtx); + } else { + func_800AE5A0(globalCtx); + } + } + + if (actor->shape.shadowDraw != NULL) { + actor->shape.shadowDraw(actor, light, globalCtx); + } + actor->isDrawn = true; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_800B9D1C(Actor* actor) { + s32 sfxId = actor->sfxId; + + if (sfxId != 0) { + if (actor->audioFlags & 2) { + Audio_PlaySfxGeneral(sfxId, &actor->projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); + } else if (actor->audioFlags & 4) { + play_sound(sfxId); + } else if (actor->audioFlags & 8) { + func_8019F128(sfxId); + } else if (actor->audioFlags & 0x10) { + func_801A0810(&D_801DB4A4, NA_SE_SY_TIMER - SFX_FLAG, (sfxId - 1)); + } else if (actor->audioFlags & 1) { + func_8019F1C0(&actor->projectedPos, sfxId); + } + } + + if (sfxId) {} + + if (actor->audioFlags & 0x40) { + func_801A1FB4(3, &actor->projectedPos, NA_BGM_MUSIC_BOX_HOUSE, 1500.0f); + } + + if (actor->audioFlags & 0x20) { + func_801A1FB4(0, &actor->projectedPos, NA_BGM_KAMARO_DANCE, 900.0f); + } +} void Actor_DrawAllSetup(GlobalContext* globalCtx) { globalCtx->actorCtx.undrawnActorCount = 0; globalCtx->actorCtx.unkB = 0; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_RecordUndrawnActor.s") +s32 Actor_RecordUndrawnActor(GlobalContext* globalCtx, Actor* actor) { + if (globalCtx->actorCtx.undrawnActorCount >= 32) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9E84.s") + globalCtx->actorCtx.undrawnActors[globalCtx->actorCtx.undrawnActorCount] = actor; + globalCtx->actorCtx.undrawnActorCount++; + return true; +} +void func_800B9E84(Gfx** arg0, s32 arg1) { + func_80164C14(arg0, D_801DE890, 4, 0, 6, 6, ((100 - arg1) * 0.003f) + 1.0f); +} + +#ifdef NON_EQUIVALENT +// Related to draw actors with lens +void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) { + s32 spB4; + Gfx* spAC; + void* spA8; // pad + s32 spA4; + // void* sp34; + // Gfx* temp_s1_11; + // Gfx** temp_a0_2; + // Gfx** temp_a1; + // GraphicsContext* temp_s2; + // void* temp_s1_10; + // void* temp_s1_7; + // void* temp_s1_8; + // void* temp_s1_9; + // Gfx* phi_s1; + Gfx* phi_s1_2; + // void* phi_s1_4; + + OPEN_DISPS(globalCtx->state.gfxCtx); + // temp_s2 = globalCtx->state.gfxCtx; + + if (numActors > 0) { + spAC = POLY_XLU_DISP; + // sp34 = globalCtx + 0x18000; + spA4 = globalCtx->unk_18E68; + + PreRender_SetValues(&globalCtx->pauseBgPreRender, D_801FBBCC, D_801FBBCE, __gfxCtx->curFrameBuffer, + __gfxCtx->zbuffer); + + func_80170200(&globalCtx->pauseBgPreRender, &spAC, __gfxCtx->zbuffer, (void*)spA4); + + // spAC->words.w0 = 0xE7000000; + // spAC->words.w1 = 0; + // temp_s1_2 = spAC + 8; + gDPPipeSync(spAC++); + + // temp_s1_2->words.w0 = 0xEE000000; + // temp_s1_2->words.w1 = 0; + // temp_s1_3 = temp_s1_2 + 8; + gDPSetPrimDepth(spAC++, 0, 0); + + // temp_s1_3->words.w0 = 0xEF002C30; + // temp_s1_3->words.w1 = 0xAF504365; + // temp_s1_4 = temp_s1_3 + 8; + gDPSetOtherMode(spAC++, + G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_THRESHOLD | G_ZS_PRIM | Z_UPD | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | + GBL_c1(G_BL_CLR_BL, G_BL_0, G_BL_CLR_MEM, G_BL_1MA) | + GBL_c2(G_BL_CLR_BL, G_BL_0, G_BL_CLR_MEM, G_BL_1MA)); + + // temp_s1_4->words.w1 = 0xFF; + // temp_s1_4->words.w0 = 0xFA000000; + // temp_s1_5 = temp_s1_4 + 8; + gDPSetPrimColor(spAC++, 0, 0, 0, 0, 0, 255); + // temp_s1_5 = spAC; + + if (globalCtx->roomCtx.currRoom.unk5 == 0) { + // temp_s1_5->words.w0 = 0xFC61E6C3; + // temp_s1_5->words.w1 = 0x11CF9FCF; + // phi_s1 = temp_s1_5 + 8; + gDPSetCombineLERP(spAC++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, + TEXEL0, PRIMITIVE, 0); + } else { + // temp_s1_5->words.w0 = 0xFC119623; + // temp_s1_5->words.w1 = 0xFF2FFFFF; + // phi_s1 = temp_s1_5 + 8; + gDPSetCombineMode(spAC++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + } + + // spAC = phi_s1; + func_800B9E84(&spAC, globalCtx->actorCtx.unk4); + phi_s1_2 = func_801660B8(globalCtx, spAC); + + for (spB4 = 0; spB4 < numActors; spB4++, actors++) { + Actor_Draw(globalCtx, *actors); + } + + // temp_s0_2 = &globalCtx->pauseBgPreRender; + + // phi_s1_2->words.w0 = 0xE7000000; + // phi_s1_2->words.w1 = 0; + // temp_s1_7 = phi_s1_2 + 8; + gDPPipeSync(phi_s1_2++); + + // temp_s1_7->unk_0 = 0xEF002CF0; + // temp_s1_7->unk_4 = 0xF5A714D; + // temp_s1_8 = temp_s1_7 + 8; + gDPSetOtherMode(phi_s1_2++, + G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_THRESHOLD | G_ZS_PRIM | AA_EN | IM_RD | CVG_DST_WRAP | ZMODE_OPA | CVG_X_ALPHA | + ALPHA_CVG_SEL | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_1) | + GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_1)); + + // temp_s1_8->unk_4 = -0x100; + // temp_s1_8->unk_0 = 0xF9000000; + // temp_s1_9 = temp_s1_8 + 8; + gDPSetBlendColor(phi_s1_2++, 255, 255, 255, 0); + + // temp_s1_9->unk_4 = 0x20; + // temp_s1_9->unk_0 = 0xFA0000FF; + // temp_s1_10 = temp_s1_9 + 8; + gDPSetPrimColor(phi_s1_2++, 0, 0xFF, 0, 0, 0, 32); + + // temp_a0_2 = &spAC; + // if (sp34->unk_6E5 == 0) { + if (globalCtx->roomCtx.currRoom.unk5 == 0) { + // temp_s1_10->unk_0 = 0xFC119623; + // temp_s1_10->unk_4 = 0xFF2FFFFF; + // phi_s1_4 = temp_s1_10 + 8; + gDPSetCombineMode(phi_s1_2++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + //} else { + } else { + // temp_s1_10->unk_4 = 0x11CF9FCF; + // temp_s1_10->unk_0 = 0xFC61E6C3; + // phi_s1_4 = temp_s1_10 + 8; + gDPSetCombineLERP(phi_s1_2++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, + TEXEL0, PRIMITIVE, 0); + + //} + } + // phi_s1_4->unk_0 = (s32) (((sp34->unk_B4C - 1) & 0xFFF) | 0xFF100000); + // temp_s1_11 = phi_s1_4 + 8; + // phi_s1_4->unk_4 = spA4; + gDPSetColorImage(phi_s1_2++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((globalCtx->pauseBgPreRender.width - 1) & 0xFFF), + spA4); + // temp_s1_11 = phi_s1_2; + + spAC = phi_s1_2; + + // spAC = temp_s1_11; + func_800B9E84(&spAC, (s32)globalCtx->actorCtx.unk4); + // temp_s1_11->words.w0 = 0xE7000000; + // temp_s1_11->words.w1 = 0; + // temp_s1_12 = temp_s1_11 + 8; + gDPPipeSync(spAC++); + + // temp_s1_12->words.w1 = -0xF8; + // temp_s1_12->words.w0 = 0xF9000000; + // temp_s1_13 = temp_s1_12 + 8; + gDPSetBlendColor(spAC++, 255, 255, 255, 8); + + // temp_s1_14 = temp_s1_13 + 8; + // temp_s1_13->words.w0 = ((sp34->unk_B4C - 1) & 0xFFF) | 0xFF100000; + // temp_s1_13->words.w1 = sp34->unk_B5C; + gDPSetColorImage(spAC++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((globalCtx->pauseBgPreRender.width - 1) & 0xFFF), + globalCtx->pauseBgPreRender.fbuf); + + // temp_a1 = &spAC; + // spAC = temp_s1_14; + // func_8016FDB8(&globalCtx->pauseBgPreRender, temp_a1, (void* ) spA4, spA8, 1U); + func_8016FDB8(&globalCtx->pauseBgPreRender, &spAC, (void*)spA4, __gfxCtx->zbuffer, 1U); + // + // POLY_OPA_DISP = temp_s1_14; + POLY_OPA_DISP = spAC; + } + + // temp_s1_15 = OVERLAY_DISP; + // temp_s1_15->words.w0 = 0xE7000000; + // temp_s1_15->words.w1 = 0; + // temp_s1_16 = temp_s1_15 + 8; + spAC = OVERLAY_DISP; + gDPPipeSync(spAC++); + + // temp_s1_16->words.w0 = 0xEF002C30; + // temp_s1_16->words.w1 = 0x00504345; + // temp_s1_17 = temp_s1_16 + 8; + gDPSetOtherMode(spAC++, + G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_THRESHOLD | G_ZS_PRIM | G_RM_CLD_SURF | G_RM_CLD_SURF2); + + // temp_s1_17->words.w0 = 0xFC61E6C3; + // temp_s1_17->words.w1 = 0x11CF9FCF; + // temp_s1_18 = temp_s1_17 + 8; + gDPSetCombineLERP(spAC++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, + PRIMITIVE, 0); + + // temp_s1_18->words.w0 = 0xFA000000; + // temp_s1_18->words.w1 = 0x4A00004A; + // spAC = temp_s1_18 + 8; + gDPSetPrimColor(spAC++, 0, 0, 74, 0, 0, 74); + + func_800B9E84(&spAC, (s32)globalCtx->actorCtx.unk4); + + OVERLAY_DISP = spAC; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} +#else +void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors); #pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9EF4.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BA2D8.s") +s32 func_800BA2D8(GlobalContext* globalCtx, Actor* actor) { + return func_800BA2FC(globalCtx, actor, &actor->projectedPos, actor->projectedW); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BA2FC.s") +s32 func_800BA2FC(GlobalContext* globalCtx, Actor* actor, Vec3f* projectedPos, f32 projectedW) { + if ((-actor->uncullZoneScale < projectedPos->z) && + (projectedPos->z < (actor->uncullZoneForward + actor->uncullZoneScale))) { + f32 phi_f12; + f32 phi_f2 = CLAMP_MIN(projectedW, 1.0f); + f32 phi_f14; + f32 phi_f16; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_DrawAll.s") + if (globalCtx->view.fovy != 60.0f) { + phi_f12 = actor->uncullZoneScale * globalCtx->unk_187F0.x * 0.76980036f; // sqrt(16/27) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BA6FC.s") + phi_f14 = globalCtx->unk_187F0.y * 0.57735026f; // 1 / sqrt(3) + phi_f16 = actor->uncullZoneScale * phi_f14; + phi_f14 *= actor->uncullZoneDownward; + } else { + phi_f16 = phi_f12 = actor->uncullZoneScale; + phi_f14 = actor->uncullZoneDownward; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BA798.s") + if (((fabsf(projectedPos->x) - phi_f12) < phi_f2) && ((-phi_f2 < (projectedPos->y + phi_f14))) && + ((projectedPos->y - phi_f16) < phi_f2)) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BA8B8.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BA9B4.s") +void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx) { + s32 pad[2]; + Gfx* ref2; + Gfx* tmp2; + s32 pad2; + Gfx* sp58; + ActorListEntry* actorEntry; + Actor* actor; + s32 actorFlags; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_InsertIntoTypeList.s") + if (globalCtx->unk_18844 != 0) { + actorFlags = ACTOR_FLAG_200000; + } else { + actorFlags = ACTOR_FLAG_200000 | ACTOR_FLAG_40 | ACTOR_FLAG_20; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_RemoveFromTypeList.s") + OPEN_DISPS(globalCtx->state.gfxCtx); + + Actor_DrawAllSetup(globalCtx); + + sp58 = POLY_XLU_DISP; + POLY_XLU_DISP = &sp58[1]; + + for (i = 0, actorEntry = actorCtx->actorLists; i < ARRAY_COUNT(actorCtx->actorLists); i++, actorEntry++) { + actor = actorEntry->first; + + while (actor != NULL) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &actor->world.pos, &actor->projectedPos, + &actor->projectedW); + + if (actor->audioFlags & 0x7F) { + func_800B9D1C(actor); + } + + if (func_800BA2D8(globalCtx, actor)) { + actor->flags |= ACTOR_FLAG_40; + } else { + actor->flags &= ~ACTOR_FLAG_40; + } + + actor->isDrawn = false; + if ((actor->init == NULL) && (actor->draw != NULL) && (actor->flags & actorFlags)) { + if ((actor->flags & ACTOR_FLAG_80) && + ((globalCtx->roomCtx.currRoom.unk5 == 0) || (globalCtx->actorCtx.unk4 == 0x64) || + (actor->room != globalCtx->roomCtx.currRoom.num))) { + if (Actor_RecordUndrawnActor(globalCtx, actor)) {} + } else { + Actor_Draw(globalCtx, actor); + } + } + + actor = actor->next; + } + } + + Effect_DrawAll(globalCtx->state.gfxCtx); + EffectSS_DrawAllParticles(globalCtx); + EffFootmark_Draw(globalCtx); + + ref2 = POLY_XLU_DISP; + gSPDisplayList(sp58, &ref2[1]); + POLY_XLU_DISP = &ref2[1]; + + if (globalCtx->actorCtx.unk3 != 0) { + Math_StepToC(&globalCtx->actorCtx.unk4, 100, 20); + if (GET_PLAYER(globalCtx)->stateFlags2 & 0x8000000) { + func_800B90F4(globalCtx); + } + } else { + Math_StepToC(&globalCtx->actorCtx.unk4, 0, 10); + } + if (globalCtx->actorCtx.unk4 != 0) { + globalCtx->actorCtx.unkB = 1; + func_800B9EF4(globalCtx, globalCtx->actorCtx.undrawnActorCount, globalCtx->actorCtx.undrawnActors); + } + + tmp2 = POLY_XLU_DISP; + gSPEndDisplayList(&tmp2[0]); + gSPBranchList(ref2, &tmp2[1]); + POLY_XLU_DISP = &tmp2[1]; + + if (globalCtx->unk_18844 == 0) { + Lights_DrawGlow(globalCtx); + } + + TitleCard_Draw(&globalCtx->state, &actorCtx->titleCtxt); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +/** + * Kills every actor which its object is not loaded + */ +void func_800BA6FC(GlobalContext* globalCtx, ActorContext* actorCtx) { + Actor* actor; + s32 i; + + for (i = 0; i != ARRAY_COUNT(actorCtx->actorLists); i++) { + actor = actorCtx->actorLists[i].first; + + while (actor != NULL) { + if (!Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { + Actor_MarkForDeath(actor); + } + + actor = actor->next; + } + } +} + +/** + * Kill actors on room change and update flags accordingly + */ +void func_800BA798(GlobalContext* globalCtx, ActorContext* actorCtx) { + Actor* actor; + s32 i; + + for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) { + actor = actorCtx->actorLists[i].first; + + while (actor != NULL) { + if ((actor->room >= 0) && (actor->room != globalCtx->roomCtx.currRoom.num) && + (actor->room != globalCtx->roomCtx.prevRoom.num)) { + if (!actor->isDrawn) { + actor = Actor_Delete(actorCtx, actor, globalCtx); + } else { + Actor_MarkForDeath(actor); + Actor_Destroy(actor, globalCtx); + actor = actor->next; + } + } else { + actor = actor->next; + } + } + } + + CollisionCheck_ClearContext(globalCtx, &globalCtx->colChkCtx); + actorCtx->flags.clearedRoomTemp = 0; + actorCtx->flags.switches[3] = 0; + actorCtx->flags.collectible[3] = 0; + globalCtx->msgCtx.unk_12030 = 0; +} + +void func_800BA8B8(GlobalContext* globalCtx, ActorContext* actorCtx) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) { + Actor* actor = actorCtx->actorLists[i].first; + + while (actor != NULL) { + if (!(actor->unk20 & actorCtx->unkC)) { + func_80123590(globalCtx, actor); + if (!actor->isDrawn) { + actor = Actor_Delete(actorCtx, actor, globalCtx); + } else { + Actor_MarkForDeath(actor); + Actor_Destroy(actor, globalCtx); + actor = actor->next; + } + } else { + actor = actor->next; + } + } + } + + CollisionCheck_ClearContext(globalCtx, &globalCtx->colChkCtx); + globalCtx->msgCtx.unk_12030 = 0; +} + +void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx) { + s32 i; + + Fault_RemoveClient(&sActorFaultClient); + + for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) { + if (i != ACTORCAT_PLAYER) { + Actor* actor = actorCtx->actorLists[i].first; + + while (actor != NULL) { + Actor_Delete(actorCtx, actor, globalCtx); + actor = actorCtx->actorLists[i].first; + } + } + } + + while (actorCtx->actorLists[ACTORCAT_PLAYER].first != NULL) { + Actor_Delete(actorCtx, actorCtx->actorLists[ACTORCAT_PLAYER].first, globalCtx); + } + + if (actorCtx->absoluteSpace != NULL) { + ZeldaArena_Free(actorCtx->absoluteSpace); + actorCtx->absoluteSpace = NULL; + } + + func_80169D40(globalCtx); + ActorOverlayTable_Cleanup(); +} + +/** + * Adds a given actor instance at the front of the actor list of the specified category. + * Also sets the actor instance as being of that category. + */ +void Actor_AddToCategory(ActorContext* actorCtx, Actor* actor, u8 actorCategory) { + Actor* actorAux; + Actor* lastActor; + + actor->category = actorCategory; + + actorCtx->totalLoadedActors++; + actorCtx->actorLists[actorCategory].length++; + lastActor = actorCtx->actorLists[actorCategory].first; + + if (lastActor == NULL) { + actorCtx->actorLists[actorCategory].first = actor; + return; + } + + actorAux = lastActor->next; + while (actorAux != NULL) { + lastActor = actorAux; + actorAux = actorAux->next; + } + + lastActor->next = actor; + actor->prev = lastActor; +} + +/** + * Removes a given actor instance from its actor list. + * Also sets the temp clear flag of the current room if the actor removed was the last enemy loaded. + */ +Actor* Actor_RemoveFromCategory(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actorToRemove) { + Actor* newHead; + + actorCtx->totalLoadedActors--; + actorCtx->actorLists[actorToRemove->category].length--; + + if (actorToRemove->prev != NULL) { + actorToRemove->prev->next = actorToRemove->next; + } else { + actorCtx->actorLists[actorToRemove->category].first = actorToRemove->next; + } + + newHead = actorToRemove->next; + + if (newHead != NULL) { + newHead->prev = actorToRemove->prev; + } + + actorToRemove->next = NULL; + actorToRemove->prev = NULL; + + if ((actorToRemove->room == globalCtx->roomCtx.currRoom.num) && (actorToRemove->category == ACTORCAT_ENEMY) && + (actorCtx->actorLists[ACTORCAT_ENEMY].length == 0)) { + Flags_SetClearTemp(globalCtx, globalCtx->roomCtx.currRoom.num); + } + + return newHead; +} void Actor_FreeOverlay(ActorOverlay* entry) { - void* ramAddr; - if (entry->numLoaded == 0) { - ramAddr = entry->loadedRamAddr; + void* ramAddr = entry->loadedRamAddr; + if (ramAddr != NULL) { - // Bit 1 - always loaded - if ((entry->allocType & 2) == 0) { - // Bit 0 - don't alloc memory - if ((entry->allocType & 1) != 0) { + if (!(entry->allocType & ALLOCTYPE_PERMANENT)) { + if (entry->allocType & ALLOCTYPE_ABSOLUTE) { entry->loadedRamAddr = NULL; } else { ZeldaArena_Free(ramAddr); @@ -752,115 +3121,1183 @@ void Actor_FreeOverlay(ActorOverlay* entry) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_Spawn.s") +Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ, + s16 rotX, s16 rotY, s16 rotZ, s32 params) { + return Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1, + 0x3FF, NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_LoadOverlay.s") +ActorInit* Actor_LoadOverlay(ActorContext* actorCtx, s16 index) { + size_t overlaySize; + ActorOverlay* overlayEntry = &gActorOverlayTable[index]; + ActorInit* actorInit; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_SpawnAsChildAndCutscene.s") + overlaySize = VRAM_PTR_SIZE(overlayEntry); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_SpawnAsChild.s") + if (overlayEntry->vramStart == NULL) { + actorInit = overlayEntry->initInfo; + } else { + if (overlayEntry->loadedRamAddr == NULL) { + if (overlayEntry->allocType & ALLOCTYPE_ABSOLUTE) { + if (actorCtx->absoluteSpace == NULL) { + actorCtx->absoluteSpace = ZeldaArena_MallocR(AM_FIELD_SIZE); + } + gActorOverlayTable[index].loadedRamAddr = actorCtx->absoluteSpace; + } else if (overlayEntry->allocType & ALLOCTYPE_PERMANENT) { + gActorOverlayTable[index].loadedRamAddr = ZeldaArena_MallocR(overlaySize); + } else { + gActorOverlayTable[index].loadedRamAddr = ZeldaArena_Malloc(overlaySize); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_SpawnTransitionActors.s") + if (overlayEntry->loadedRamAddr == NULL) { + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BB2D0.s") + Load2_LoadOverlay(overlayEntry->vromStart, overlayEntry->vromEnd, overlayEntry->vramStart, + overlayEntry->vramEnd, overlayEntry->loadedRamAddr); + overlayEntry->numLoaded = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BB498.s") + actorInit = + (uintptr_t)((overlayEntry->initInfo != NULL) + ? (void*)(-OVERLAY_RELOCATION_OFFSET(overlayEntry) + (uintptr_t)overlayEntry->initInfo) + : NULL); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BB59C.s") + return actorInit; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BB604.s") +Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, + s16 rotX, s16 rotY, s16 rotZ, s32 params, u32 cutscene, s32 arg11, Actor* parent) { + s32 pad; + Actor* actor; + ActorInit* actorInit; + s32 objBankIndex; + ActorOverlay* overlayEntry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BB8EC.s") + if (actorCtx->totalLoadedActors >= 0xFF) { + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Enemy_StartFinishingBlow.s") + actorInit = Actor_LoadOverlay(actorCtx, index); + if (actorInit == NULL) { + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BBAC0.s") + objBankIndex = Object_GetIndex(&globalCtx->objectCtx, actorInit->objectId); + if ((objBankIndex < 0) || + ((actorInit->type == ACTORCAT_ENEMY) && Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num) && + (actorInit->id != ACTOR_BOSS_05))) { + Actor_FreeOverlay(&gActorOverlayTable[index]); + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BBB74.s") + actor = ZeldaArena_Malloc(actorInit->instanceSize); + if (actor == NULL) { + Actor_FreeOverlay(&gActorOverlayTable[index]); + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BBC20.s") + overlayEntry = &gActorOverlayTable[index]; + if (overlayEntry->vramStart != 0) { + overlayEntry->numLoaded++; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BBCEC.s") + bzero(actor, actorInit->instanceSize); + actor->overlayEntry = overlayEntry; + actor->id = actorInit->id; + actor->flags = actorInit->flags; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BBDAC.s") + if (actorInit->id == ACTOR_EN_PART) { + actor->objBankIndex = rotZ; + rotZ = 0; + } else { + actor->objBankIndex = objBankIndex; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BBFB0.s") + actor->init = actorInit->init; + actor->destroy = actorInit->destroy; + actor->update = actorInit->update; + actor->draw = actorInit->draw; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC154.s") + if (parent != NULL) { + actor->room = parent->room; + actor->parent = parent; + parent->child = actor; + } else { + actor->room = globalCtx->roomCtx.currRoom.num; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC188.s") + actor->home.pos.x = x; + actor->home.pos.y = y; + actor->home.pos.z = z; + actor->home.rot.x = rotX; + actor->home.rot.y = rotY; + actor->home.rot.z = rotZ; + actor->params = params & 0xFFFF; + actor->cutscene = (cutscene & 0x7F); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC1B4.s") + if (actor->cutscene == 0x7F) { + actor->cutscene = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC270.s") + if (arg11 != 0) { + actor->unk20 = arg11; + } else { + actor->unk20 = 0x3FF; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC444.s") + Actor_AddToCategory(actorCtx, actor, actorInit->type); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC4EC.s") + { + u32 sp20 = gSegments[6]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC5B8.s") + Actor_Init(actor, globalCtx); + gSegments[6] = sp20; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC5EC.s") + return actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC620.s") +Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, GlobalContext* globalCtx, s16 actorId, f32 posX, + f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params) { + return Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1, + parent->unk20, parent); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC770.s") +void Actor_SpawnTransitionActors(GlobalContext* globalCtx, ActorContext* actorCtx) { + TransitionActorEntry* transitionActorList = globalCtx->doorCtx.transitionActorList; + s32 i; + s16 numTransitionActors = globalCtx->doorCtx.numTransitionActors; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC7D8.s") + for (i = 0; i < numTransitionActors; transitionActorList++, i++) { + if (transitionActorList->id >= 0) { + if ((transitionActorList->sides[0].room >= 0 && + (globalCtx->roomCtx.currRoom.num == transitionActorList->sides[0].room || + globalCtx->roomCtx.prevRoom.num == transitionActorList->sides[0].room)) || + (transitionActorList->sides[1].room >= 0 && + (globalCtx->roomCtx.currRoom.num == transitionActorList->sides[1].room || + globalCtx->roomCtx.prevRoom.num == transitionActorList->sides[1].room))) { + s16 rotY = ((transitionActorList->rotY >> 7) & 0x1FF) * (0x10000 / 360.0f); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC848.s") + if (Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, transitionActorList->id & 0x1FFF, + transitionActorList->pos.x, transitionActorList->pos.y, + transitionActorList->pos.z, 0, rotY, 0, + (i << 0xA) + (transitionActorList->params & 0x3FF), + transitionActorList->rotY & 0x7F, 0x3FF, 0) != NULL) { + transitionActorList->id = -transitionActorList->id; + } + numTransitionActors = globalCtx->doorCtx.numTransitionActors; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BC8B8.s") +Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, GlobalContext* globalCtx) { + s16 rotX = (actorEntry->rot.x >> 7) & 0x1FF; + s16 rotY = (actorEntry->rot.y >> 7) & 0x1FF; + s16 rotZ = (actorEntry->rot.z >> 7) & 0x1FF; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BCB50.s") + if (!(actorEntry->id & 0x8000)) { + rotY *= 0x10000 / 360.0f; + } else if (rotY > 180) { + rotY -= 360; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BCB70.s") + if (!(actorEntry->id & 0x4000)) { + rotX *= 0x10000 / 360.0f; + } else if (rotX > 180) { + rotX -= 360; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BCBF4.s") + if (!(actorEntry->id & 0x2000)) { + rotZ *= 0x10000 / 360.0f; + } else if (rotZ > 180) { + rotZ -= 360; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BCC68.s") + return Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, actorEntry->id & 0x1FFF, actorEntry->pos.x, + actorEntry->pos.y, actorEntry->pos.z, rotX, rotY, rotZ, + actorEntry->params & 0xFFFF, actorEntry->rot.y & 0x7F, + ((actorEntry->rot.x & 7) << 7) | (actorEntry->rot.z & 0x7F), NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BCCDC.s") +Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Actor* newHead; + ActorOverlay* overlayEntry = actor->overlayEntry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BD2B4.s") + if ((player != NULL) && (actor == player->unk_730)) { + func_80123DA4(player); + Camera_ChangeMode(Play_GetCamera(globalCtx, Play_GetActiveCameraIndex(globalCtx)), 0); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BD384.s") + if (actor == actorCtx->targetContext.arrowPointedActor) { + actorCtx->targetContext.arrowPointedActor = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BD6B8.s") + if (actor == actorCtx->targetContext.unk8C) { + actorCtx->targetContext.unk8C = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BD6E4.s") + if (actor == actorCtx->targetContext.bgmEnemy) { + actorCtx->targetContext.bgmEnemy = NULL; + } + + func_801A72CC(&actor->projectedPos); + Actor_Destroy(actor, globalCtx); + + newHead = Actor_RemoveFromCategory(globalCtx, actorCtx, actor); + ZeldaArena_Free(actor); + + if (overlayEntry->vramStart != NULL) { + overlayEntry->numLoaded--; + Actor_FreeOverlay(overlayEntry); + } + + return newHead; +} + +s32 func_800BB59C(GlobalContext* globalCtx, Actor* actor) { + s16 x; + s16 y; + + Actor_GetScreenPos(globalCtx, actor, &x, &y); + + return (x > -20) && (x < gScreenWidth + 20) && (y > -160) && (y < gScreenHeight + 160); +} + +void func_800BB604(GameState* gameState, ActorContext* actorCtx, Player* player, s32 actorCategory) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + f32 temp_f0_2; + Actor* sp8C; + Actor* actor; + s32 phi_s2; + CollisionPoly* sp80; + s32 sp7C; + Vec3f sp70; + s32 phi_s2_2; + + actor = actorCtx->actorLists[actorCategory].first; + sp8C = player->unk_730; + while (actor != NULL) { + if ((actor->update != NULL) && ((Player*)actor != player)) { + if (actor->flags & (ACTOR_FLAG_40000000 | ACTOR_FLAG_1)) { + if ((actorCategory == ACTORCAT_ENEMY) && CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_4 | ACTOR_FLAG_1)) { + if ((actor->xyzDistToPlayerSq < SQ(500.0f)) && (actor->xyzDistToPlayerSq < sBgmEnemyDistSq)) { + actorCtx->targetContext.bgmEnemy = actor; + sBgmEnemyDistSq = actor->xyzDistToPlayerSq; + } + } + + if ((actor != sp8C) || (actor->flags & ACTOR_FLAG_80000)) { + temp_f0_2 = func_800B82EC(actor, player, D_801ED8DC); + phi_s2_2 = (actor->flags & 1) != 0; + if (phi_s2_2) { + phi_s2_2 = temp_f0_2 < D_801ED8C8; + } + phi_s2 = phi_s2_2; + phi_s2_2 = (actor->flags & ACTOR_FLAG_40000000) != 0; + if (phi_s2_2) { + phi_s2_2 = temp_f0_2 < D_801ED8D0; + } + + if (((phi_s2) || (phi_s2_2)) && (func_800B83BC(actor, temp_f0_2))) { + if (func_800BB59C(globalCtx, actor)) { + if (((!BgCheck_CameraLineTest1(&globalCtx->colCtx, &player->actor.focus.pos, + &actor->focus.pos, &sp70, &sp80, 1, 1, 1, 1, &sp7C)) || + (SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, sp80, sp7C)))) { + if (actor->targetPriority != 0) { + if ((phi_s2 != 0) && (actor->targetPriority < D_801ED8D4)) { + D_801ED8BC = actor; + D_801ED8D4 = actor->targetPriority; + } + if ((phi_s2_2 != 0) && (actor->targetPriority < D_801ED8D8)) { + D_801ED8C4 = actor; + D_801ED8D8 = actor->targetPriority; + } + } else { + if (phi_s2 != 0) { + D_801ED8B8 = actor; + D_801ED8C8 = temp_f0_2; + } + if (phi_s2_2 != 0) { + D_801ED8C0 = actor; + D_801ED8D0 = temp_f0_2; + } + } + } + } + } + } + } + } + + actor = actor->next; + } +} + +u8 D_801AED8C[] = { + ACTORCAT_BOSS, ACTORCAT_ENEMY, ACTORCAT_BG, ACTORCAT_EXPLOSIVES, ACTORCAT_NPC, ACTORCAT_ITEMACTION, + ACTORCAT_CHEST, ACTORCAT_SWITCH, ACTORCAT_PROP, ACTORCAT_MISC, ACTORCAT_DOOR, ACTORCAT_SWITCH, +}; + +void func_800BB8EC(GameState* gameState, ActorContext* actorCtx, Actor** arg2, Actor** arg3, Player* player) { + u8* actorCategories; + s32 i; + + D_801ED8B8 = D_801ED8BC = D_801ED8C0 = D_801ED8C4 = NULL; + D_801ED8C8 = D_801ED8D0 = sBgmEnemyDistSq = FLT_MAX; + D_801ED8D4 = D_801ED8D8 = INT32_MAX; + + actorCtx->targetContext.bgmEnemy = NULL; + D_801ED8DC = player->actor.shape.rot.y; + + actorCategories = D_801AED8C; + + for (i = 0; i < 3; i++) { + func_800BB604(gameState, actorCtx, player, *actorCategories); + actorCategories++; + } + + if (D_801ED8B8 == NULL) { + for (; i < ARRAY_COUNT(D_801AED8C); i++) { + func_800BB604(gameState, actorCtx, player, *actorCategories); + actorCategories++; + } + } + + if (D_801ED8B8 == NULL) { + *arg2 = D_801ED8BC; + } else { + *arg2 = D_801ED8B8; + } + + if (D_801ED8C0 == NULL) { + *arg3 = D_801ED8C4; + } else { + *arg3 = D_801ED8C0; + } +} + +/** + * Play the death sound effect and flash the screen white for 4 frames. + * While the screen flashes, the game freezes. + */ +void Enemy_StartFinishingBlow(GlobalContext* globalCtx, Actor* actor) { + globalCtx->actorCtx.freezeFlashTimer = 5; + Audio_PlaySoundAtPosition(globalCtx, &actor->world.pos, 20, NA_SE_EN_LAST_DAMAGE); +} + +// blinking routine +s16 func_800BBAC0(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3) { + if (DECR(arg0[1]) == 0) { + arg0[1] = Rand_S16Offset(arg1, arg2); + } + + if (arg0[1] - arg3 > 0) { + arg0[0] = 0; + } else if ((arg0[1] - arg3 >= -1) || (arg0[1] < 2)) { + arg0[0] = 1; + } else { + arg0[0] = 2; + } + + return arg0[0]; +} + +// blinking routine +s16 func_800BBB74(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3) { + if (DECR(arg0[1]) == 0) { + arg0[1] = Rand_S16Offset(arg1, arg2); + } + + if (arg0[1] - arg3 > 0) { + arg0[0] = 0; + } else if (arg0[1] - arg3 == 0) { + arg0[0] = 1; + } else { + arg0[0] = 2; + } + + return arg0[0]; +} + +// unused blinking routine +s16 func_800BBC20(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3) { + if (DECR(arg0[1]) == 0) { + arg0[1] = Rand_S16Offset(arg1, arg2); + arg0[0]++; + if ((arg0[0] % 3) == 0) { + arg0[0] = (s32)(Rand_ZeroOne() * arg3) * 3; + } + } + return arg0[0]; +} + +void Actor_SpawnBodyParts(Actor* actor, GlobalContext* globalCtx, s32 arg2, Gfx** dList) { + EnPart* part; + Actor* spawnedPart; + MtxF* currentMatrix; + + if (*dList != NULL) { + currentMatrix = Matrix_GetCurrentState(); + spawnedPart = + Actor_SpawnAsChild(&globalCtx->actorCtx, actor, globalCtx, ACTOR_EN_PART, currentMatrix->mf[3][0], + currentMatrix->mf[3][1], currentMatrix->mf[3][2], 0, 0, actor->objBankIndex, arg2); + if (spawnedPart != NULL) { + part = (EnPart*)spawnedPart; + + func_8018219C(currentMatrix, &part->actor.shape.rot, 0); + part->unk_150 = *dList; + Math_Vec3f_Copy(&part->actor.scale, &actor->scale); + } + } +} + +void Actor_SpawnFloorDustRing(GlobalContext* globalCtx, Actor* actor, Vec3f* posXZ, f32 radius, s32 countMinusOne, + f32 randAccelWeight, s16 scale, s16 scaleStep, u8 useLighting) { + Vec3f pos; + Vec3f accel = { 0.0f, 0.3f, 0.0f }; + s32 pad[2]; + f32 angle; + s32 i; + + angle = (Rand_ZeroOne() - 0.5f) * (2.0f * 3.14f); + pos.y = actor->floorHeight; + accel.y += (Rand_ZeroOne() - 0.5f) * 0.2f; + + for (i = countMinusOne; i >= 0; i--) { + pos.x = (sin_rad(angle) * radius) + posXZ->x; + pos.z = (cos_rad(angle) * radius) + posXZ->z; + accel.x = (Rand_ZeroOne() - 0.5f) * randAccelWeight; + accel.z = (Rand_ZeroOne() - 0.5f) * randAccelWeight; + + if (scale == 0) { + func_800B10C0(globalCtx, &pos, &gZeroVec3f, &accel); + } else if (useLighting) { + func_800B1210(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep); + } else { + func_800B11A0(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep); + } + angle += (2.0f * 3.14f) / (countMinusOne + 1.0f); + } +} + +void func_800BBFB0(GlobalContext* globalCtx, Vec3f* position, f32 arg2, s32 arg3, s16 arg4, s16 scaleStep, u8 arg6) { + Vec3f pos; + Vec3f accel = { 0.0f, 0.3f, 0.0f }; + s32 i; + + for (i = arg3; i >= 0; i--) { + s16 scale; + + pos.x = ((Rand_ZeroOne() - 0.5f) * arg2) + position->x; + pos.y = ((Rand_ZeroOne() - 0.5f) * arg2) + position->y; + pos.z = ((Rand_ZeroOne() - 0.5f) * arg2) + position->z; + + scale = (s32)(Rand_ZeroOne() * arg4 * 0.2f); + scale += arg4; + + if (arg6) { + func_800B1210(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep); + } else { + func_800B11A0(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep); + } + } +} + +void func_800BC154(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actor, u8 actorCategory) { + actorCtx->actorLists[actor->category].unk_08 = 1; + actor->category = actorCategory; +} + +// Damage flags for EnArrow +s32 D_801AEDB0[] = { + 0x800, 0x20, 0x20, 0x800, 0x1000, 0x2000, 0x1, 0x10000, 0x1, +}; + +s32 func_800BC188(s32 index) { + if ((index < 0) || (index >= ARRAY_COUNT(D_801AEDB0))) { + return 0; + } + + return D_801AEDB0[index]; +} + +s32 func_800BC1B4(Actor* actor, Actor* arg1, f32 arg2, f32 arg3) { + if ((arg3 > 0.0f) && (Actor_DistanceBetweenActors(arg1, actor) < ((arg3 * 2.5f) + arg2))) { + s16 temp_v1 = BINANG_SUB(Actor_YawBetweenActors(arg1, actor), arg1->world.rot.y); + + if (ABS_ALT(temp_v1) < 0x1400) { + return true; + } + } + + return false; +} + +Actor* func_800BC270(GlobalContext* globalCtx, Actor* actor, f32 arg2, s32 arg3) { + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + + while (itemAction != NULL) { + if (((itemAction->id == ACTOR_ARMS_HOOK) && (arg3 & 0x80)) || + ((itemAction->id == ACTOR_EN_BOOM) && (arg3 & 0x10)) || + ((itemAction->id == ACTOR_EN_ARROW) && (func_800BC188(itemAction->params) & arg3))) { + f32 speedXZ; + + if ((itemAction->speedXZ <= 0.0f) && (GET_PLAYER(globalCtx)->unk_D57 != 0)) { + if (itemAction->id == ACTOR_ARMS_HOOK) { + speedXZ = 20.0f; + } else if (itemAction->id == ACTOR_EN_BOOM) { + speedXZ = 12.0f; + } else { + s32 temp_v0_3 = func_800BC188(itemAction->params); + + if (temp_v0_3 == 1) { + speedXZ = 80.0f; + } else if (temp_v0_3 == 0x10000) { + speedXZ = 60.0f; + } else { + speedXZ = 150.0f; + } + } + } else { + speedXZ = itemAction->speedXZ; + } + + if (func_800BC1B4(actor, itemAction, arg2, speedXZ)) { + break; + } + } + + itemAction = itemAction->next; + } + + return itemAction; +} + +Actor* func_800BC444(GlobalContext* globalCtx, Actor* actor, f32 arg2) { + Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + + while (explosive != NULL) { + if (((explosive->id == ACTOR_EN_BOM) || (explosive->id == ACTOR_EN_BOM_CHU) || + (explosive->id == ACTOR_EN_BOMBF))) { + if (func_800BC1B4(actor, explosive, arg2, explosive->speedXZ)) { + break; + } + } + explosive = explosive->next; + } + + return explosive; +} + +/** + * Checks if a given actor will be standing on the ground after being translated + * by the provided distance and angle. + * + * Returns true if the actor will be standing on ground. + */ +s16 Actor_TestFloorInDirection(Actor* actor, GlobalContext* globalCtx, f32 distance, s16 angle) { + s16 ret; + u16 bgCheckFlags; + f32 dx; + f32 dz; + Vec3f actorPos; + + Math_Vec3f_Copy(&actorPos, &actor->world.pos); + + bgCheckFlags = actor->bgCheckFlags; + + dx = Math_SinS(angle) * distance; + dz = Math_CosS(angle) * distance; + + actor->world.pos.x += dx; + actor->world.pos.z += dz; + + Actor_UpdateBgCheckInfo(globalCtx, actor, 0.0f, 0.0f, 0.0f, 4); + Math_Vec3f_Copy(&actor->world.pos, &actorPos); + + ret = actor->bgCheckFlags & 1; + + actor->bgCheckFlags = bgCheckFlags; + + return ret; +} + +/** + * Returns true if the player is targeting the provided actor + */ +s32 Actor_IsTargeted(GlobalContext* globalCtx, Actor* actor) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags3 & 0x80000000) && actor->isTargeted) { + return true; + } + + return false; +} + +/** + * Returns true if the player is targeting an actor other than the provided actor + */ +s32 Actor_OtherIsTargeted(GlobalContext* globalCtx, Actor* actor) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags3 & 0x80000000) && !actor->isTargeted) { + return true; + } + + return false; +} + +void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx) { + MtxF sp58; + f32 sp54; + Vec3f sp48; + CollisionPoly* sp44; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, alpha); + + sp48.x = arg0->x; + sp48.y = arg0->y + 1.0f; + sp48.z = arg0->z; + + sp54 = BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &sp44, &sp48); + if (sp44 != NULL) { + func_800C0094(sp44, arg0->x, sp54, arg0->z, &sp58); + Matrix_SetCurrentState(&sp58); + } else { + Matrix_InsertTranslation(arg0->x, arg0->y, arg0->z, MTXMODE_NEW); + } + Matrix_Scale(arg1->x, 1.0f, arg1->z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gCircleShadowDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_800BC770(GlobalContext* globalCtx, s16 y, s16 countdown) { + s16 idx = Quake_Add(&globalCtx->mainCamera, 3); + + Quake_SetSpeed(idx, 20000); + Quake_SetQuakeValues(idx, y, 0, 0, 0); + Quake_SetCountdown(idx, countdown); +} + +void func_800BC7D8(GlobalContext* globalCtx, s16 y, s16 countdown, s16 speed) { + s16 idx = Quake_Add(&globalCtx->mainCamera, 3); + + Quake_SetSpeed(idx, speed); + Quake_SetQuakeValues(idx, y, 0, 0, 0); + Quake_SetCountdown(idx, countdown); +} + +void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 arg2, s16 arg3) { + if (arg2 >= 5) { + func_8013ECE0(actor->xyzDistToPlayerSq, 255, 20, 150); + } else { + func_8013ECE0(actor->xyzDistToPlayerSq, 180, 20, 100); + } + func_800BC770(globalCtx, arg2, arg3); +} + +typedef struct { + /* 0x00 */ f32 chainAngle; + /* 0x04 */ f32 chainLength; + /* 0x08 */ f32 yShift; + /* 0x0C */ f32 chainsScale; + /* 0x10 */ f32 chainsRotZInit; + /* 0x14 */ Gfx* chainDL; + /* 0x18 */ Gfx* lockDL; +} DoorLockInfo; // size = 0x1C + +DoorLockInfo sDoorLocksInfo[DOORLOCK_MAX] = { + /* DOORLOCK_NORMAL */ { 0.54f, 6000.0f, 5000.0, 1.0f, 0.0f, gDoorChainsDL, gDoorLockDL }, + /* DOORLOCK_BOSS */ { 0.644f, 12000.0f, 8000.0f, 1.0f, 0.0f, object_bdoor_DL_000530, object_bdoor_DL_000400 }, + /* DOORLOCK_2 */ { 0.6400000453f, 8500.0f, 8000.0f, 1.75f, 0.1f, gDoorChainsDL, gDoorLockDL }, +}; + +/** + * Draws chains and lock of a locked door, of the specified `type` (see `DoorLockType`). + * `frame` can be 0 to 10, where 0 is "open" and 10 is "closed", the chains slide accordingly. + */ +void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { + s32 pad[2]; + MtxF baseMtxF; + s32 i; + f32 chainsTranslateX; + f32 chainsTranslateY; + DoorLockInfo* entry = &sDoorLocksInfo[type]; + f32 chainRotZ = entry->chainsRotZInit; + f32 rotZStep; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY); + Matrix_CopyCurrentState(&baseMtxF); + + chainsTranslateX = __sinf(entry->chainAngle - chainRotZ) * -(10 - frame) * 0.1f * entry->chainLength; + chainsTranslateY = __cosf(entry->chainAngle - chainRotZ) * (10 - frame) * 0.1f * entry->chainLength; + + for (i = 0; i < 4; i++) { + Matrix_SetCurrentState(&baseMtxF); + Matrix_InsertZRotation_f(chainRotZ, MTXMODE_APPLY); + Matrix_InsertTranslation(chainsTranslateX, chainsTranslateY, 0.0f, MTXMODE_APPLY); + if (entry->chainsScale != 1.0f) { + Matrix_Scale(entry->chainsScale, entry->chainsScale, entry->chainsScale, MTXMODE_APPLY); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, entry->chainDL); + + if ((i % 2) != 0) { + rotZStep = 2.0f * entry->chainAngle; + } else { + rotZStep = M_PI - (2.0f * entry->chainAngle); + } + + chainRotZ += rotZStep; + } + + Matrix_SetCurrentState(&baseMtxF); + Matrix_Scale(frame * 0.1f, frame * 0.1f, frame * 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, entry->lockDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void Actor_SpawnShieldParticlesMetal(GlobalContext* globalCtx, Vec3f* pos) { + CollisionCheck_SpawnShieldParticlesMetal(globalCtx, pos); +} + +void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 xluFlag, u16 duration) { + if ((colorFlag == 0x8000) && !(colorIntensityMax & 0x8000)) { + Actor_PlaySfxAtPos(actor, NA_SE_EN_LIGHT_ARROW_HIT); + } + + actor->colorFilterParams = colorFlag | xluFlag | ((colorIntensityMax & 0xF8) << 5) | duration; + actor->colorFilterTimer = duration; +} + +Hilite* func_800BCBF4(Vec3f* arg0, GlobalContext* globalCtx) { + Vec3f lightDir; + + lightDir.x = globalCtx->envCtx.dirLight1.params.dir.x; + lightDir.y = globalCtx->envCtx.dirLight1.params.dir.y; + lightDir.z = globalCtx->envCtx.dirLight1.params.dir.z; + + return Hilite_DrawOpa(arg0, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); +} + +Hilite* func_800BCC68(Vec3f* arg0, GlobalContext* globalCtx) { + Vec3f lightDir; + + lightDir.x = globalCtx->envCtx.dirLight1.params.dir.x; + lightDir.y = globalCtx->envCtx.dirLight1.params.dir.y; + lightDir.z = globalCtx->envCtx.dirLight1.params.dir.z; + + return Hilite_DrawXlu(arg0, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); +} + +void func_800BCCDC(Vec3s* points, s32 pathCount, Vec3f* pos1, Vec3f* pos2, s32 arg4) { + s32 spB4; + s32 spB0; + s32 spA8[2] = { 0, 0 }; + s32 spA0[2] = { 0, 0 }; + Vec3f sp94; + Vec3f sp7C[2]; + Vec3f sp70; + Vec3f sp64; + f32 sp60; + f32 sp5C; + f32 sp54[2]; + + spB0 = 0; + sp5C = SQ(40000.0f); + + for (spB4 = 0; spB4 < pathCount; spB4++) { + sp60 = Math3D_XZDistanceSquared(pos1->x, pos1->z, points[spB4].x, points[spB4].z); + if (sp60 < sp5C) { + sp5C = sp60; + spB0 = spB4; + } + } + + sp94.x = (points + spB0)->x; + sp94.z = (points + spB0)->z; + pos2->y = (points + spB0)->y; + if (spB0 != 0) { + sp64.x = (points + spB0 - 1)->x; + sp64.z = (points + spB0 - 1)->z; + } else if (arg4) { + sp64.x = (points + pathCount - 1)->x; + sp64.z = (points + pathCount - 1)->z; + } + + if ((spB0 != 0) || arg4) { + spA8[0] = + Math3D_PointDistToLine2D(pos1->x, pos1->z, sp64.x, sp64.z, sp94.x, sp94.z, &sp7C[0].x, &sp7C[0].z, &sp60); + } + + if (spB0 + 1 != pathCount) { + sp70.x = (points + spB0 + 1)->x; + sp70.z = (points + spB0 + 1)->z; + } else if (arg4) { + sp70.x = points->x; + sp70.z = points->z; + } + + if ((spB0 + 1 != pathCount) || arg4) { + spA8[1] = + Math3D_PointDistToLine2D(pos1->x, pos1->z, sp94.x, sp94.z, sp70.x, sp70.z, &sp7C[1].x, &sp7C[1].z, &sp60); + } + + if (arg4) { + s32 phi_s0_2; + + spA0[0] = ((sp64.x - pos1->x) * (sp94.z - pos1->z)) < ((sp64.z - pos1->z) * (sp94.x - pos1->x)); + spA0[1] = ((sp70.z - pos1->z) * (sp94.x - pos1->x)) < ((sp94.z - pos1->z) * (sp70.x - pos1->x)); + + for (phi_s0_2 = 0; phi_s0_2 < ARRAY_COUNT(sp54); phi_s0_2++) { + if (spA8[phi_s0_2] != 0) { + sp54[phi_s0_2] = Math3D_XZDistanceSquared(pos1->x, pos1->z, sp7C[phi_s0_2].x, sp7C[phi_s0_2].z); + } else { + sp54[phi_s0_2] = SQ(40000.0f); + } + } + } + + if (arg4 && (((spA0[0] != 0) && (spA0[1] != 0)) || ((spA0[0] != 0) && (spA8[0] != 0) && (sp54[0] < sp54[1])) || + ((spA0[1] != 0) && (spA8[1] != 0) && (sp54[1] < sp54[0])))) { + pos2->x = pos1->x; + pos2->z = pos1->z; + } else if ((spA8[0] != 0) && (spA8[1] != 0)) { + if ((spA0[0] == 0) && (spA0[1] == 0)) { + if (Math3D_PointDistToLine2D(pos1->x, pos1->z, sp7C[0].x, sp7C[0].z, sp7C[1].x, sp7C[1].z, &pos2->x, + &pos2->z, &sp60) == 0) { + pos2->x = (sp7C[1].x + sp7C[0].x) * 0.5f; + pos2->z = (sp7C[1].z + sp7C[0].z) * 0.5f; + } + } else if (sp54[1] < sp54[0]) { + pos2->x = sp7C[1].x; + pos2->z = sp7C[1].z; + } else { + pos2->x = sp7C[0].x; + pos2->z = sp7C[0].z; + } + } else if (spA8[0] != 0) { + pos2->x = sp7C[0].x; + pos2->z = sp7C[0].z; + } else if (spA8[1] != 0) { + pos2->x = sp7C[1].x; + pos2->z = sp7C[1].z; + } else if (arg4 && ((((sp64.x - pos1->x) * (sp70.z - pos1->z)) < ((sp64.z - pos1->z) * (sp70.x - pos1->x))))) { + pos2->x = pos1->x; + pos2->z = pos1->z; + } else { + pos2->x = sp94.x; + pos2->z = sp94.z; + } +} + +// unused +s32 func_800BD2B4(GlobalContext* globalCtx, Actor* actor, s16* arg2, f32 arg3, + u16 (*textIdCallback)(GlobalContext*, Actor*), s16 (*arg5)(GlobalContext*, Actor*)) { + if (Actor_ProcessTalkRequest(actor, &globalCtx->state)) { + *arg2 = true; + return true; + } else if (*arg2) { + *arg2 = arg5(globalCtx, actor); + return false; + } else if (!func_800B8934(globalCtx, actor)) { + return false; + } else if (!func_800B8614(actor, globalCtx, arg3)) { + return false; + } else { + actor->textId = textIdCallback(globalCtx, actor); + return false; + } +} + +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ s16 unk_04; + /* 0x06 */ s16 unk_06; + /* 0x08 */ s16 unk_08; + /* 0x0A */ s16 unk_0A; + /* 0x0C */ u8 unk_0C; +} struct_801AEE38_0; // size = 0x10 + +typedef struct { + /* 0x00 */ struct_801AEE38_0 sub_00; + /* 0x10 */ f32 unk_10; + /* 0x14 */ s16 unk_14; +} struct_801AEE38; // size = 0x18 + +struct_801AEE38 D_801AEE38[] = { + { { 0x1C20, 0xE390, 0x1C70, 0x1554, 0x0000, 0x0000, 0x0000 }, 170.0f, 0x3FFC }, + { { 0x2AA8, 0xEAAC, 0x1554, 0x1554, 0xF8E4, 0x0E38, 0x0001 }, 170.0f, 0x3FFC }, + { { 0x31C4, 0xE390, 0x0E38, 0x0E38, 0xF1C8, 0x071C, 0x0001 }, 170.0f, 0x3FFC }, + { { 0x1554, 0xF1C8, 0x0000, 0x071C, 0xF8E4, 0x0000, 0x0001 }, 170.0f, 0x3FFC }, + { { 0x2AA8, 0xF8E4, 0x071C, 0x0E38, 0xD558, 0x2AA8, 0x0001 }, 170.0f, 0x3FFC }, + { { 0x0000, 0xE390, 0x2AA8, 0x3FFC, 0xF1C8, 0x0E38, 0x0001 }, 170.0f, 0x3FFC }, + { { 0x2AA8, 0xF1C8, 0x0E38, 0x0E38, 0x0000, 0x0000, 0x0001 }, 0.0f, 0x0000 }, + { { 0x2AA8, 0xF1C8, 0x0000, 0x0E38, 0x0000, 0x1C70, 0x0001 }, 0.0f, 0x0000 }, + { { 0x2AA8, 0xF1C8, 0xF1C8, 0x0000, 0x0000, 0x0000, 0x0001 }, 0.0f, 0x0000 }, + { { 0x071C, 0xF1C8, 0x0E38, 0x1C70, 0x0000, 0x0000, 0x0001 }, 0.0f, 0x0000 }, + { { 0x0E38, 0xF1C8, 0x0000, 0x1C70, 0x0000, 0x0E38, 0x0001 }, 0.0f, 0x0000 }, + { { 0x2AA8, 0xE390, 0x1C70, 0x0E38, 0xF1C8, 0x0E38, 0x0001 }, 0.0f, 0x0000 }, + { { 0x18E2, 0xF1C8, 0x0E38, 0x0E38, 0x0000, 0x0000, 0x0001 }, 0.0f, 0x0000 }, + { { 0x2A6C, 0xE390, 0x1C70, 0x1554, 0x0000, 0x0000, 0x0000 }, 170.0f, 0x3FFC }, +}; + +void func_800BD384(Actor* actor, struct_800BD888_arg1* arg1, s16 arg2, s16 arg3, s16 arg4, s16 arg5, s16 arg6, s16 arg7, + u8 arg8) { + s16 sp46; + s16 sp44; + s16 temp2; + s16 sp40; + s16 temp1; + Vec3f sp30; + + sp30.x = actor->world.pos.x; + sp30.y = actor->world.pos.y + arg1->unk_14; + sp30.z = actor->world.pos.z; + + sp46 = Math_Vec3f_Pitch(&sp30, &arg1->unk_18); + sp44 = Math_Vec3f_Yaw(&sp30, &arg1->unk_18); + sp40 = Math_Vec3f_Yaw(&actor->world.pos, &arg1->unk_18) - actor->shape.rot.y; + + temp1 = CLAMP(sp40, -arg2, arg2); + Math_SmoothStepToS(&arg1->unk_08.y, temp1, 6, 2000, 1); + + temp1 = (ABS_ALT(sp40) >= 0x8000) ? 0 : ABS_ALT(sp40); + arg1->unk_08.y = CLAMP(arg1->unk_08.y, -temp1, temp1); + + sp40 -= arg1->unk_08.y; + + temp1 = CLAMP(sp40, -arg5, arg5); + Math_SmoothStepToS(&arg1->unk_0E.y, temp1, 6, 2000, 1); + + temp1 = (ABS_ALT(sp40) >= 0x8000) ? 0 : ABS_ALT(sp40); + arg1->unk_0E.y = CLAMP(arg1->unk_0E.y, -temp1, temp1); + + if (arg8) { + Math_SmoothStepToS(&actor->shape.rot.y, sp44, 6, 2000, 1); + } + + temp1 = CLAMP(sp46, arg4, (s16)(u16)arg3); + Math_SmoothStepToS(&arg1->unk_08.x, temp1, 6, 2000, 1); + + temp2 = sp46 - arg1->unk_08.x; + + temp1 = CLAMP(temp2, arg7, arg6); + Math_SmoothStepToS(&arg1->unk_0E.x, temp1, 6, 2000, 1); +} + +// unused +s16 func_800BD6B8(s16 arg0) { + return D_801AEE38[arg0].unk_14; +} + +s16 func_800BD6E4(Actor* actor, struct_800BD888_arg1* arg1, f32 arg2, s16 arg3, s16 flag) { + s32 pad; + + if (flag) { + return flag; + } else if (arg1->unk_00 != 0) { + return 4; + } else if (arg2 < Math_Vec3f_DistXYZ(&actor->world.pos, &arg1->unk_18)) { + arg1->unk_04 = 0; + arg1->unk_06 = 0; + return 1; + } else { + s16 yaw = Math_Vec3f_Yaw(&actor->world.pos, &arg1->unk_18); + s16 phi_a0 = ABS_ALT(BINANG_SUB(yaw, actor->shape.rot.y)); + + if (arg3 >= phi_a0) { + arg1->unk_04 = 0; + arg1->unk_06 = 0; + return 2; + } else if (DECR(arg1->unk_04) != 0) { + return arg1->unk_02; + } else { + switch (arg1->unk_06) { + case 0: + case 2: + arg1->unk_04 = Rand_S16Offset(30, 30); + arg1->unk_06++; + return 1; + + case 1: + arg1->unk_04 = Rand_S16Offset(10, 10); + arg1->unk_06++; + return 3; + + default: + return 4; + } + } + } +} // This function is very similar to OoT's func_80034A14 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BD888.s") +void func_800BD888(Actor* actor, struct_800BD888_arg1* arg1, s16 arg2, s16 arg3) { + struct_801AEE38_0 sp38; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BD9A0.s") + arg1->unk_02 = func_800BD6E4(actor, arg1, D_801AEE38[arg2].unk_10, D_801AEE38[arg2].unk_14, arg3); + sp38 = D_801AEE38[arg2].sub_00; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BD9E0.s") + switch (arg1->unk_02) { + case 1: + sp38.unk_00 = 0; + sp38.unk_04 = 0; + sp38.unk_02 = 0; + case 3: + sp38.unk_06 = 0; + sp38.unk_0A = 0; + sp38.unk_08 = 0; + case 2: + sp38.unk_0C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BDAA0.s") + func_800BD384(actor, arg1, sp38.unk_00, sp38.unk_04, sp38.unk_02, sp38.unk_06, sp38.unk_0A, sp38.unk_08, + sp38.unk_0C); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BDB6C.s") +Gfx D_801AEF88[] = { + gsDPSetRenderMode(AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + G_RM_FOG_SHADE_A, + AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)), + gsDPSetAlphaCompare(G_AC_THRESHOLD), + gsSPEndDisplayList(), +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BDC5C.s") +Gfx D_801AEFA0[] = { + gsSPEndDisplayList(), +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BDCF4.s") +void* func_800BD9A0(GraphicsContext* gfxCtx) { + Gfx* displayListHead; + Gfx* displayList; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_Noop.s") + displayListHead = displayList = GRAPH_ALLOC(gfxCtx, 0x10); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BDFC0.s") + gDPSetRenderMode(displayListHead++, + AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + G_RM_FOG_SHADE_A, + AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); + gSPEndDisplayList(displayListHead++); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE03C.s") + return displayList; +} -Actor* func_800BE0B8(GlobalContext* globalCtx, Actor* inActor, s16 arg2, u8 arg3, f32 arg4) { - Actor* actor = globalCtx->actorCtx.actorList[arg3].first; +// unused +void func_800BD9E0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, + PostLimbDraw postLimbDraw, Actor* actor, s16 alpha) { + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, alpha); + gSPSegment(POLY_OPA_DISP++, 0x0C, gEmptyDL); + + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + overrideLimbDraw, postLimbDraw, actor, POLY_OPA_DISP); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_800BDAA0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, + PostLimbDraw postLimbDraw, Actor* actor, s16 alpha) { + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, alpha); + gSPSegment(POLY_XLU_DISP++, 0x0C, func_800BD9A0(globalCtx->state.gfxCtx)); + + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + overrideLimbDraw, postLimbDraw, actor, POLY_XLU_DISP); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +// Unused +s16 func_800BDB6C(Actor* actor, GlobalContext* globalCtx, s16 arg2, f32 arg3) { + Player* player = GET_PLAYER(globalCtx); + f32 phi_f2; + + if ((globalCtx->csCtx.state != 0) || (D_801D0D50 != 0)) { + phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &globalCtx->view.eye) * 0.25f; + } else { + phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &player->actor.world.pos); + } + + if (arg3 < phi_f2) { + actor->flags &= ~ACTOR_FLAG_1; + Math_SmoothStepToS(&arg2, 0, 6, 0x14, 1); + } else { + actor->flags |= ACTOR_FLAG_1; + Math_SmoothStepToS(&arg2, 0xFF, 6, 0x14, 1); + } + + return arg2; +} + +void Actor_ChangeAnimation(SkelAnime* skelAnime, ActorAnimationEntry* animation, s32 index) { + f32 frameCount; + + animation += index; + if (animation->frameCount > 0.0f) { + frameCount = animation->frameCount; + } else { + frameCount = Animation_GetLastFrame(&animation->animation->common); + } + + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, frameCount, + animation->mode, animation->morphFrames); +} + +// Unused +void func_800BDCF4(GlobalContext* globalCtx, s16* arg1, s16* arg2, s32 size) { + s32 frames = globalCtx->gameplayFrames; + s32 i; + + for (i = 0; i < size; i++) { + arg1[i] = (0x814 + 50 * i) * frames; + arg2[i] = (0x940 + 50 * i) * frames; + } +} + +void Actor_Noop(Actor* actor, GlobalContext* globalCtx) { +} + +#include "z_cheap_proc.c" + +/** + * Finds the first actor instance of a specified Id and category within a given range from + * an actor if there is one. If the Id provided is -1, this will look for any actor of the + * specified category rather than a specific Id. + */ +Actor* Actor_FindNearby(GlobalContext* globalCtx, Actor* inActor, s16 actorId, u8 actorCategory, f32 distance) { + Actor* actor = globalCtx->actorCtx.actorLists[actorCategory].first; while (actor != NULL) { - if (actor == inActor || ((arg2 != -1) && (arg2 != actor->id))) { + if (actor == inActor || ((actorId != -1) && (actorId != actor->id))) { actor = actor->next; continue; } - if (Actor_DistanceBetweenActors(inActor, actor) <= arg4) { + if (Actor_DistanceBetweenActors(inActor, actor) <= distance) { return actor; } @@ -870,26 +4307,434 @@ Actor* func_800BE0B8(GlobalContext* globalCtx, Actor* inActor, s16 arg2, u8 arg3 return NULL; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE184.s") +s32 func_800BE184(GlobalContext* globalCtx, Actor* actor, f32 xzDist, s16 arg3, s16 arg4, s16 arg5) { + Player* player = GET_PLAYER(globalCtx); + s16 phi_v0 = BINANG_SUB(BINANG_ROT180(actor->yawTowardsPlayer), player->actor.shape.rot.y); + s16 temp_t0 = actor->yawTowardsPlayer - arg5; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_ApplyDamage.s") + if ((actor->xzDistToPlayer <= xzDist) && (player->swordState != 0)) { + if ((arg4 >= ABS_ALT(phi_v0)) && (arg3 >= ABS_ALT(temp_t0))) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE258.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE2B8.s") +u8 Actor_ApplyDamage(Actor* actor) { + if (actor->colChkInfo.damage >= actor->colChkInfo.health) { + actor->colChkInfo.health = 0; + } else { + actor->colChkInfo.health -= actor->colChkInfo.damage; + } + return actor->colChkInfo.health; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE33C.s") +void Actor_SetDropFlag(Actor* actor, ColliderInfo* colInfo) { + ColliderInfo* acHitInfo = colInfo->acHitInfo; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE3D0.s") + if (acHitInfo == NULL) { + actor->dropFlag = 0; + } else if (acHitInfo->toucher.dmgFlags & 0x800) { // DMG_FIRE_ARROW + actor->dropFlag = 1; + } else if (acHitInfo->toucher.dmgFlags & 0x1000) { // DMG_ICE_ARROW + actor->dropFlag = 2; + } else if (acHitInfo->toucher.dmgFlags & 0x2000) { // DMG_LIGHT_ARROW + actor->dropFlag = 0x20; + } else { + actor->dropFlag = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE504.s") +void Actor_SetDropFlagJntSph(Actor* actor, ColliderJntSph* jntSphere) { + s32 i; + ColliderJntSphElement* jntElement; + ColliderInfo* acHitInfo; + s32 flag; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE568.s") + actor->dropFlag = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE5CC.s") + for (i = jntSphere->count - 1; i >= 0; i--) { + jntElement = &jntSphere->elements[i]; + acHitInfo = jntElement->info.acHitInfo; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE63C.s") + if (acHitInfo == NULL) { + flag = 0; + } else { + s32 dmgFlags = acHitInfo->toucher.dmgFlags; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BE680.s") + if (dmgFlags & 0x800) { + flag = 1; + } else if (dmgFlags & 0x1000) { + flag = 2; + } else { + flag = (dmgFlags & 0x2000) ? 0x20 : 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800BF7CC.s") + actor->dropFlag |= flag; + } +} + +void func_800BE33C(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3) { + f32 xDiff = arg1->x - arg0->x; + f32 zDiff = arg1->z - arg0->z; + f32 yDiff = arg3 ? (arg1->y - arg0->y) : (arg0->y - arg1->y); + + arg2->y = Math_FAtan2F(zDiff, xDiff); + arg2->x = Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), yDiff); +} + +void func_800BE3D0(Actor* actor, s16 angle, Vec3s* arg2) { + f32 sp44; + f32 sp40; + f32 sp3C; + f32 sp38; + f32 sp34; + f32 sp30; + f32 sp2C; + s32 pad[3]; + + if (actor->floorPoly != NULL) { + CollisionPoly* floorPoly = actor->floorPoly; + + sp44 = COLPOLY_GET_NORMAL(floorPoly->normal.x); + sp40 = COLPOLY_GET_NORMAL(floorPoly->normal.y); + sp3C = COLPOLY_GET_NORMAL(floorPoly->normal.z); + + sp38 = Math_SinS(angle); + sp34 = Math_CosS(angle); + arg2->x = (s16)-Math_Atan2S((-(sp44 * sp38) - (sp3C * sp34)) * sp40, 1.0f); + + sp2C = Math_SinS(angle - 0x3FF7); + sp30 = Math_CosS(angle - 0x3FF7); + arg2->z = (s16)-Math_Atan2S((-(sp44 * sp2C) - (sp3C * sp30)) * sp40, 1.0f); + } +} + +void func_800BE504(Actor* actor, ColliderCylinder* collider) { + // Checks if was hit by either DMG_NORMAL_ARROW, DMG_FIRE_ARROW, DMG_ICE_ARROW, DMG_LIGHT_ARROW or DMG_DEKU_BUBBLE + if ((collider->info.acHitInfo->toucher.dmgFlags & (0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20))) { + actor->world.rot.y = collider->base.ac->shape.rot.y; + } else { + actor->world.rot.y = Actor_YawBetweenActors(collider->base.ac, actor); + } +} + +void func_800BE568(Actor* actor, ColliderSphere* collider) { + if (collider->info.acHitInfo->toucher.dmgFlags & (0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20)) { + actor->world.rot.y = collider->base.ac->shape.rot.y; + } else { + actor->world.rot.y = Actor_YawBetweenActors(collider->base.ac, actor); + } +} + +void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 colliderIndex) { + if (collider->elements[colliderIndex].info.acHitInfo->toucher.dmgFlags & + (0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20)) { + actor->world.rot.y = collider->base.ac->shape.rot.y; + } else { + actor->world.rot.y = Actor_YawBetweenActors(collider->base.ac, actor); + } +} + +s32 func_800BE63C(struct EnBox* chest) { + if ((chest->unk_1F1 == 5) || (chest->unk_1F1 == 6) || (chest->unk_1F1 == 7) || (chest->unk_1F1 == 8) || + (chest->unk_1F1 == 0xC)) { + return true; + } + return false; +} + +TexturePtr D_801AEFA8[] = { + gameplay_keep_Tex_091DE0, + gameplay_keep_Tex_091FE0, + gameplay_keep_Tex_0921E0, + gameplay_keep_Tex_0923E0, +}; + +// Draw common damageEffects +void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 arg3, f32 effectScale, f32 steamScale, + f32 effectAlpha, u8 mode) { + if (effectAlpha > 0.001f) { + s32 temp_v1_3; + s16 i; + MtxF* temp_s3; + f32 alpha; + f32 sp124; + f32 sp120; + f32 sp11C; + f32 sp118; + Vec3f* limbAux = limbPos; + u32 sp110 = globalCtx->gameplayFrames; + f32 sp74; + + temp_s3 = Matrix_GetCurrentState(); + + if ((actor != NULL) && (effectAlpha > 0.05f) && (globalCtx->gameOverCtx.state == 0)) { + if (mode == 0) { + Actor_PlaySfxAtPos(actor, NA_SE_EV_BURN_OUT - SFX_FLAG); + } else if (mode == 1) { + Actor_PlaySfxAtPos(actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } else if (mode == 0xB) { + Actor_PlaySfxAtPos(actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } else if ((mode == 0x14) || (mode == 0x15)) { + Actor_PlaySfxAtPos(actor, NA_SE_EN_COMMON_DEADLIGHT - SFX_FLAG); + } + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + switch (mode) { + case 0xA: + case 0xB: + sp124 = ((KREG(19) * 0.01f) + 2.3f) * effectScale; + sp118 = ((KREG(28) * 0.0001f) + 0.035f) * steamScale; + func_800BCC68(limbPos, globalCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp110 & 0xFF, 0x20, 0x10, 1, 0, + (sp110 * 2) & 0xFF, 0x40, 0x20)); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, 255); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_050648); + + sp74 = effectAlpha * 255.0f; + for (i = 0; i < arg3; i++) { + alpha = i & 3; + alpha = sp74 - (30.0f * alpha); + if (sp74 < (30.0f * (i & 3))) { + alpha = 0.0f; + } + if (alpha > 255.0f) { + alpha = 255.0f; + } + + gDPSetEnvColor(POLY_XLU_DISP++, KREG(20) + 0xC8, KREG(21) + 0xC8, KREG(22) + 0xFF, (u8)alpha); + + Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); + Matrix_Scale(sp124, sp124, sp124, MTXMODE_APPLY); + if (i & 1) { + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + } + if (i & 2) { + Matrix_InsertZRotation_f(M_PI, MTXMODE_APPLY); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0506E0); + + limbPos++; + } + + limbPos = limbAux; + + gDPSetColorDither(POLY_XLU_DISP++, G_CD_BAYER); + + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_PATTERN); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051180); + + alpha = effectAlpha * 100.0f; + if (alpha > 100.0f) { + alpha = 100.0f; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (u8)alpha); + + for (i = 0; i < arg3; i++) { + temp_v1_3 = ((i * 3) + sp110); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, temp_v1_3 * 3, temp_v1_3 * -0xC, 0x20, 0x40, + 1, 0, 0, 0x20, 0x20)); + + Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(sp118, sp118, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051238); + + limbPos++; + } + break; + + case 0x0: + case 0x1: + if (mode == 0) { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 0); + mode = 0xFF; + } + + Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f, 1); + + sp74 = effectAlpha * 255.0f; + + for (i = 0; i < arg3; i++) { + alpha = i & 3; + alpha = sp74 - 30.0f * alpha; + if (sp74 < 30.0f * (i & 3)) { + alpha = 0.0f; + } + if (alpha > 255.0f) { + alpha = 255.0f; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, mode, (u8)alpha); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, + ((i * 10 + sp110) * -0x14) & 0x1FF, 0x20, 0x80)); + + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + temp_s3->mf[3][0] = limbPos->x; + temp_s3->mf[3][1] = limbPos->y; + temp_s3->mf[3][2] = limbPos->z; + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + + limbPos++; + } + break; + + case 0x14: + case 0x15: + sp120 = ((KREG(19) * 0.01f) + 4.0f) * effectScale; + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023348); + + alpha = effectAlpha * 255.0f; + if (alpha > 255.0f) { + alpha = 255.0f; + } + + if (mode == 0x15) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 0xFF), (u8)(sREG(17) + 0xFF), + (u8)(sREG(18) + 0xFF), (u8)alpha); + + gDPSetEnvColor(POLY_XLU_DISP++, (u8)sREG(19), (u8)(sREG(20) + 0xFF), (u8)(sREG(21) + 0xFF), 0x80); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)alpha); + + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 100, 128); + } + Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Scale(sp120, sp120, 1.0f, MTXMODE_APPLY); + + for (i = 0; i < arg3; i++) { + Matrix_InsertZRotation_f(randPlusMinusPoint5Scaled(2 * M_PI), MTXMODE_APPLY); + temp_s3->mf[3][0] = limbPos->x; + temp_s3->mf[3][1] = limbPos->y; + temp_s3->mf[3][2] = limbPos->z; + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); + + limbPos++; + } + break; + + case 0x1E: + case 0x1F: + case 0x20: + if (mode == 0x1E) { + sp11C = (KREG(19) * 0.01f + 1.0f) * effectScale; + } else if (mode == 0x1F) { + sp11C = (KREG(19) * 0.01f + 1.5f) * effectScale; + } else { + sp11C = (KREG(19) * 0.01f + 2.0f) * effectScale; + } + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_801AEFA8[globalCtx->gameplayFrames & 3])); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023480); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 0xFF), (u8)(sREG(17) + 0xFF), + (u8)(sREG(18) + 0x96), (u8)(sREG(19) + 0xFF)); + + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 0xFF), (u8)(sREG(21) + 0xFF), (u8)sREG(22), + (u8)sREG(23)); + + Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Scale(sp11C, sp11C, sp11C, MTXMODE_APPLY); + + for (i = 0; i < arg3; i++) { + Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); + Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), 1); + temp_s3->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; + temp_s3->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; + temp_s3->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0234F0); + + Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); + Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), 1); + temp_s3->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; + temp_s3->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; + temp_s3->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0234F0); + + limbPos++; + } + break; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s32 limbPosCount, + s32 effectsPerLimb, f32 scale, f32 scaleRange) { + static Color_RGBA8 primColor = { 170, 255, 255, 255 }; + static Color_RGBA8 envColor = { 200, 200, 255, 255 }; + static Vec3f accel = { 0.0f, -1.0f, 0.0f }; + s32 i; + s32 pad; + Vec3f velocity; + s16 randomYaw; + s16 yaw; + s32 j; + + Audio_PlaySoundAtPosition(globalCtx, &actor->world.pos, 30, NA_SE_EV_ICE_BROKEN); + + for (i = 0; i < limbPosCount; i++) { + yaw = Actor_YawToPoint(actor, limbPos); + + for (j = 0; j < effectsPerLimb; j++) { + randomYaw = (Rand_Next() >> 0x13) + yaw; + + velocity.z = Rand_ZeroFloat(5.0f); + + velocity.x = Math_SinS(randomYaw) * velocity.z; + velocity.y = Rand_ZeroFloat(4.0f) + 8.0f; + velocity.z *= Math_CosS(randomYaw); + + EffectSsEnIce_Spawn(globalCtx, limbPos, Rand_ZeroFloat(scaleRange) + scale, &velocity, &accel, &primColor, + &envColor, 30); + } + + limbPos++; + } +} diff --git a/src/code/z_actor_dlftbls.c b/src/code/z_actor_dlftbls.c index f33fcd5388..77b6546ffd 100644 --- a/src/code/z_actor_dlftbls.c +++ b/src/code/z_actor_dlftbls.c @@ -722,7 +722,7 @@ void ActorOverlayTable_FaultPrint(void* arg0, void* arg1) { FaultDrawer_Printf("No. RamStart- RamEnd cn Name\n"); for (i = 0, overlayEntry = &gActorOverlayTable[0]; i < gMaxActorId; i++, overlayEntry++) { - overlaySize = (u32)overlayEntry->vramEnd - (u32)overlayEntry->vramStart; + overlaySize = VRAM_PTR_SIZE(overlayEntry); if (overlayEntry->loadedRamAddr != NULL) { FaultDrawer_Printf("%3d %08x-%08x %3d %s\n", i, overlayEntry->loadedRamAddr, (u32)overlayEntry->loadedRamAddr + overlaySize, overlayEntry->numLoaded, ""); @@ -740,7 +740,7 @@ void* ActorOverlayTable_FaultAddrConv(void* arg0, void* arg1) { u32 offset; for (i = 0; i < gMaxActorId; i++, overlayEntry++) { - size = (u8*)overlayEntry->vramEnd - (u8*)overlayEntry->vramStart; + size = VRAM_PTR_SIZE(overlayEntry); ramStart = overlayEntry->loadedRamAddr; ramEnd = ramStart + size; offset = (u8*)overlayEntry->vramStart - ramStart; diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index d7a94da5ba..850d5234b7 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -3991,7 +3991,7 @@ void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, GlobalContext* globa for (i = 0; i < BG_ACTOR_MAX; i++) { flag = dyna->bgActorFlags[i]; if ((flag & 1) && !(flag & 2)) { - Actor_SetObjectSegment(globalCtx, dyna->bgActors[i].actor); + Actor_SetObjectDependency(globalCtx, dyna->bgActors[i].actor); CollisionHeader_SegmentedToVirtual(dyna->bgActors[i].colHeader); } } diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 4c25024706..1e983c9541 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -312,7 +312,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_SetMode.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DF840.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ChangeMode.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DF86C.s") diff --git a/src/code/z_cheap_proc.c b/src/code/z_cheap_proc.c new file mode 100644 index 0000000000..d0709fde96 --- /dev/null +++ b/src/code/z_cheap_proc.c @@ -0,0 +1,39 @@ +#include "global.h" + +/** + * Draws a display list to the opaque display buffer + */ +void Gfx_DrawDListOpa(GlobalContext* globalCtx, Gfx* dlist) { + Gfx* dl; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + dl = POLY_OPA_DISP; + + gSPDisplayList(&dl[0], &sSetupDL[6 * 0x19]); + gSPMatrix(&dl[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&dl[2], dlist); + + POLY_OPA_DISP = &dl[3]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +/** + * Draws a display list to the translucent display buffer + */ +void Gfx_DrawDListXlu(GlobalContext* globalCtx, Gfx* dlist) { + Gfx* dl; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + dl = POLY_XLU_DISP; + + gSPDisplayList(&dl[0], &sSetupDL[6 * 0x19]); + gSPMatrix(&dl[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&dl[2], dlist); + + POLY_XLU_DISP = &dl[3]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index 47c2202f16..fddcf7f954 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -1,20 +1,22 @@ #include "global.h" +EffectSsInfo sEffectSsInfo = { NULL, 0, 0 }; + void EffectSS_Init(GlobalContext* globalCtx, s32 numEntries) { u32 i; EffectSs* effectsSs; EffectSsOverlay* overlay; - EffectSS2Info.data_table = (EffectSs*)THA_AllocEndAlign16(&globalCtx->state.heap, numEntries * sizeof(EffectSs)); - EffectSS2Info.searchIndex = 0; - EffectSS2Info.size = numEntries; + sEffectSsInfo.data_table = (EffectSs*)THA_AllocEndAlign16(&globalCtx->state.heap, numEntries * sizeof(EffectSs)); + sEffectSsInfo.searchIndex = 0; + sEffectSsInfo.size = numEntries; - for (effectsSs = &EffectSS2Info.data_table[0]; effectsSs < &EffectSS2Info.data_table[EffectSS2Info.size]; + for (effectsSs = &sEffectSsInfo.data_table[0]; effectsSs < &sEffectSsInfo.data_table[sEffectSsInfo.size]; effectsSs++) { EffectSS_ResetEntry(effectsSs); } - overlay = &particleOverlayTable[0]; + overlay = &gParticleOverlayTable[0]; for (i = 0; i < EFFECT_SS_MAX; i++) { overlay->loadedRamAddr = NULL; overlay++; @@ -27,30 +29,31 @@ void EffectSS_Clear(GlobalContext* globalCtx) { EffectSsOverlay* overlay; void* addr; - EffectSS2Info.data_table = NULL; - EffectSS2Info.searchIndex = 0; - EffectSS2Info.size = 0; + sEffectSsInfo.data_table = NULL; + sEffectSsInfo.searchIndex = 0; + sEffectSsInfo.size = 0; - // This code is completely useless, as data_table was just set to NULL and size to 0 - for (effectsSs = EffectSS2Info.data_table; effectsSs < EffectSS2Info.data_table + EffectSS2Info.size; effectsSs++) { + //! @bug: Effects left in the table are not properly deleted, as data_table was just set to NULL and size to 0 + for (effectsSs = &sEffectSsInfo.data_table[0]; effectsSs < &sEffectSsInfo.data_table[sEffectSsInfo.size]; + effectsSs++) { EffectSS_Delete(effectsSs); } // Free memory from loaded particle overlays - overlay = &particleOverlayTable[0]; + overlay = &gParticleOverlayTable[0]; for (i = 0; i < EFFECT_SS_MAX; i++) { addr = overlay->loadedRamAddr; if (addr != NULL) { ZeldaArena_Free(addr); } - overlay->loadedRamAddr = 0; + overlay->loadedRamAddr = NULL; overlay++; } } EffectSs* EffectSS_GetTable() { - return EffectSS2Info.data_table; + return sEffectSsInfo.data_table; } void EffectSS_Delete(EffectSs* effectSs) { @@ -90,27 +93,27 @@ s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry) { s32 foundFree; s32 i; - if (EffectSS2Info.searchIndex >= EffectSS2Info.size) { - EffectSS2Info.searchIndex = 0; + if (sEffectSsInfo.searchIndex >= sEffectSsInfo.size) { + sEffectSsInfo.searchIndex = 0; } // Search for a unused entry - i = EffectSS2Info.searchIndex; + i = sEffectSsInfo.searchIndex; foundFree = false; while (true) { - if (EffectSS2Info.data_table[i].life == -1) { + if (sEffectSsInfo.data_table[i].life == -1) { foundFree = true; break; } i++; - if (i >= EffectSS2Info.size) { + if (i >= sEffectSsInfo.size) { i = 0; // Loop around the whole table } // After a full loop, break out - if (i == EffectSS2Info.searchIndex) { + if (i == sEffectSsInfo.searchIndex) { break; } } @@ -122,22 +125,22 @@ s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry) { // If all slots are in use, search for a slot with a lower priority // Note that a lower priority is representend by a higher value - i = EffectSS2Info.searchIndex; + i = sEffectSsInfo.searchIndex; while (true) { // Equal priority should only be considered "lower" if flag 0 is set - if ((priority <= EffectSS2Info.data_table[i].priority) && - !((priority == EffectSS2Info.data_table[i].priority) && (EffectSS2Info.data_table[i].flags & 1))) { + if ((priority <= sEffectSsInfo.data_table[i].priority) && + !((priority == sEffectSsInfo.data_table[i].priority) && (sEffectSsInfo.data_table[i].flags & 1))) { break; } i++; - if (i >= EffectSS2Info.size) { + if (i >= sEffectSsInfo.size) { i = 0; // Loop around the whole table } // After a full loop, return 1 to indicate that we failed to find a suitable slot - if (i == EffectSS2Info.searchIndex) { + if (i == sEffectSsInfo.searchIndex) { return true; } } @@ -151,8 +154,8 @@ void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) { if (FrameAdvance_IsEnabled(globalCtx) != true) { if (EffectSS_FindFreeSpace(effectsSs->priority, &index) == 0) { - EffectSS2Info.searchIndex = index + 1; - EffectSS2Info.data_table[index] = *effectsSs; + sEffectSsInfo.searchIndex = index + 1; + sEffectSsInfo.data_table[index] = *effectsSs; } } } @@ -160,7 +163,7 @@ void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) { void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* initData) { s32 index; u32 overlaySize; - EffectSsOverlay* entry = &particleOverlayTable[type]; + EffectSsOverlay* entry = &gParticleOverlayTable[type]; EffectSsInit* initInfo; if (EffectSS_FindFreeSpace(priority, &index) != 0) { @@ -168,8 +171,8 @@ void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* init return; } - EffectSS2Info.searchIndex = index + 1; - overlaySize = (u32)entry->vramEnd - (u32)entry->vramStart; + sEffectSsInfo.searchIndex = index + 1; + overlaySize = VRAM_PTR_SIZE(entry); if (entry->vramStart == NULL) { initInfo = entry->initInfo; @@ -184,27 +187,25 @@ void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* init Load2_LoadOverlay(entry->vromStart, entry->vromEnd, entry->vramStart, entry->vramEnd, entry->loadedRamAddr); } - initInfo = (void*)(u32)( - entry->initInfo != NULL - ? (EffectSsInit*)(-((u32)entry->vramStart - (u32)entry->loadedRamAddr) + (u32)entry->initInfo) - : NULL); + initInfo = (uintptr_t)( + (entry->initInfo != NULL) ? (void*)(-OVERLAY_RELOCATION_OFFSET(entry) + (uintptr_t)entry->initInfo) : NULL); } if (initInfo->init != NULL) { // Delete the previous effect in the slot, in case the slot wasn't free - EffectSS_Delete(&EffectSS2Info.data_table[index]); + EffectSS_Delete(&sEffectSsInfo.data_table[index]); - EffectSS2Info.data_table[index].type = type; - EffectSS2Info.data_table[index].priority = priority; + sEffectSsInfo.data_table[index].type = type; + sEffectSsInfo.data_table[index].priority = priority; - if (initInfo->init(globalCtx, index, &EffectSS2Info.data_table[index], initData) == 0) { - EffectSS_ResetEntry(&EffectSS2Info.data_table[index]); + if (initInfo->init(globalCtx, index, &sEffectSsInfo.data_table[index], initData) == 0) { + EffectSS_ResetEntry(&sEffectSsInfo.data_table[index]); } } } void EffectSS_UpdateParticle(GlobalContext* globalCtx, s32 index) { - EffectSs* particle = &EffectSS2Info.data_table[index]; + EffectSs* particle = &sEffectSsInfo.data_table[index]; if (particle->update != NULL) { particle->velocity.x += particle->accel.x; @@ -222,23 +223,23 @@ void EffectSS_UpdateParticle(GlobalContext* globalCtx, s32 index) { void EffectSS_UpdateAllParticles(GlobalContext* globalCtx) { s32 i; - for (i = 0; i < EffectSS2Info.size; i++) { - if (EffectSS2Info.data_table[i].life > -1) { - EffectSS2Info.data_table[i].life--; + for (i = 0; i < sEffectSsInfo.size; i++) { + if (sEffectSsInfo.data_table[i].life > -1) { + sEffectSsInfo.data_table[i].life--; - if (EffectSS2Info.data_table[i].life < 0) { - EffectSS_Delete(&EffectSS2Info.data_table[i]); + if (sEffectSsInfo.data_table[i].life < 0) { + EffectSS_Delete(&sEffectSsInfo.data_table[i]); } } - if (EffectSS2Info.data_table[i].life > -1) { + if (sEffectSsInfo.data_table[i].life > -1) { EffectSS_UpdateParticle(globalCtx, i); } } } void EffectSS_DrawParticle(GlobalContext* globalCtx, s32 index) { - EffectSs* entry = &EffectSS2Info.data_table[index]; + EffectSs* entry = &sEffectSsInfo.data_table[index]; if (entry->draw != NULL) { entry->draw(globalCtx, index, entry); @@ -252,12 +253,12 @@ void EffectSS_DrawAllParticles(GlobalContext* globalCtx) { Lights_BindAll(lights, globalCtx->lightCtx.listHead, NULL, globalCtx); Lights_Draw(lights, globalCtx->state.gfxCtx); - for (i = 0; i < EffectSS2Info.size; i++) { - if (EffectSS2Info.data_table[i].life > -1) { - if ((EffectSS2Info.data_table[i].pos.x > 32000.0f) || (EffectSS2Info.data_table[i].pos.x < -32000.0f) || - (EffectSS2Info.data_table[i].pos.y > 32000.0f) || (EffectSS2Info.data_table[i].pos.y < -32000.0f) || - (EffectSS2Info.data_table[i].pos.z > 32000.0f) || (EffectSS2Info.data_table[i].pos.z < -32000.0f)) { - EffectSS_Delete(&EffectSS2Info.data_table[i]); + for (i = 0; i < sEffectSsInfo.size; i++) { + if (sEffectSsInfo.data_table[i].life > -1) { + if ((sEffectSsInfo.data_table[i].pos.x > 32000.0f) || (sEffectSsInfo.data_table[i].pos.x < -32000.0f) || + (sEffectSsInfo.data_table[i].pos.y > 32000.0f) || (sEffectSsInfo.data_table[i].pos.y < -32000.0f) || + (sEffectSsInfo.data_table[i].pos.z > 32000.0f) || (sEffectSsInfo.data_table[i].pos.z < -32000.0f)) { + EffectSS_Delete(&sEffectSsInfo.data_table[i]); } else { EffectSS_DrawParticle(globalCtx, i); } diff --git a/src/code/z_effect_soft_sprite_dlftbls.c b/src/code/z_effect_soft_sprite_dlftbls.c new file mode 100644 index 0000000000..e215cdee96 --- /dev/null +++ b/src/code/z_effect_soft_sprite_dlftbls.c @@ -0,0 +1,56 @@ +#include "global.h" +#include "initvars.h" + +#define EFFECT_SS_OVERLAY(name) \ + { \ + SEGMENT_ROM_START(ovl_##name), SEGMENT_ROM_END(ovl_##name), SEGMENT_START(ovl_##name), \ + SEGMENT_END(ovl_##name), NULL, &name##_InitVars, 1, \ + } + +#define EFFECT_SS_OVERLAY_INTERNAL(name) \ + { 0, 0, NULL, NULL, NULL, &name##_InitVars, 1 } + +#define EFFECT_SS_OVERLAY_UNSET \ + { 0 } + +EffectSsOverlay gParticleOverlayTable[] = { + EFFECT_SS_OVERLAY(Effect_Ss_Dust), + EFFECT_SS_OVERLAY(Effect_Ss_Kirakira), + EFFECT_SS_OVERLAY_UNSET, + EFFECT_SS_OVERLAY(Effect_Ss_Bomb2), + EFFECT_SS_OVERLAY(Effect_Ss_Blast), + EFFECT_SS_OVERLAY(Effect_Ss_G_Spk), + EFFECT_SS_OVERLAY(Effect_Ss_D_Fire), + EFFECT_SS_OVERLAY(Effect_Ss_Bubble), + EFFECT_SS_OVERLAY_UNSET, + EFFECT_SS_OVERLAY(Effect_Ss_G_Ripple), + EFFECT_SS_OVERLAY(Effect_Ss_G_Splash), + EFFECT_SS_OVERLAY_UNSET, + EFFECT_SS_OVERLAY(Effect_Ss_G_Fire), + EFFECT_SS_OVERLAY(Effect_Ss_Lightning), + EFFECT_SS_OVERLAY(Effect_Ss_Dt_Bubble), + EFFECT_SS_OVERLAY(Effect_Ss_Hahen), + EFFECT_SS_OVERLAY(Effect_Ss_Stick), + EFFECT_SS_OVERLAY(Effect_Ss_Sibuki), + EFFECT_SS_OVERLAY_UNSET, + EFFECT_SS_OVERLAY_UNSET, + EFFECT_SS_OVERLAY(Effect_Ss_Stone1), + EFFECT_SS_OVERLAY(Effect_Ss_Hitmark), + EFFECT_SS_OVERLAY(Effect_Ss_Fhg_Flash), + EFFECT_SS_OVERLAY(Effect_Ss_K_Fire), + EFFECT_SS_OVERLAY(Effect_Ss_Solder_Srch_Ball), + EFFECT_SS_OVERLAY(Effect_Ss_Kakera), + EFFECT_SS_OVERLAY(Effect_Ss_Ice_Piece), + EFFECT_SS_OVERLAY(Effect_Ss_En_Ice), + EFFECT_SS_OVERLAY(Effect_Ss_Fire_Tail), + EFFECT_SS_OVERLAY(Effect_Ss_En_Fire), + EFFECT_SS_OVERLAY(Effect_Ss_Extra), + EFFECT_SS_OVERLAY_UNSET, + EFFECT_SS_OVERLAY(Effect_Ss_Dead_Db), + EFFECT_SS_OVERLAY(Effect_Ss_Dead_Dd), + EFFECT_SS_OVERLAY(Effect_Ss_Dead_Ds), + EFFECT_SS_OVERLAY_UNSET, + EFFECT_SS_OVERLAY(Effect_Ss_Ice_Smoke), + EFFECT_SS_OVERLAY(Effect_En_Ice_Block), + EFFECT_SS_OVERLAY(Effect_Ss_Sbn), +}; diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index 4303d3db2d..3f868ecc36 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -124,32 +124,32 @@ void func_800B1054(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* EffectSsDust_Spawn(globalCtx, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1); } -extern Color_RGBA8 D_801AE3B0; -extern Color_RGBA8 D_801AE3B4; +static Color_RGBA8 sDustBrownPrim = { 170, 130, 90, 255 }; +static Color_RGBA8 sDustBrownEnv = { 100, 60, 20, 255 }; void func_800B10C0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, 100, 5, 10, 0); + EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0); } void func_800B1130(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, 100, 5, 10, 0); + EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0); } void func_800B11A0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, scale, scaleStep, 10, 0); + EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0); } void func_800B1210(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, scale, scaleStep, 10, 0); + EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0); } void func_800B1280(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, scale, scaleStep, life, 0); + EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); } void func_800B12F0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &D_801AE3B0, &D_801AE3B4, scale, scaleStep, life, 0); + EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); } void func_800B1360(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, @@ -206,12 +206,9 @@ void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) { } } -extern Color_RGBA8 D_801AE3B8; -extern Color_RGBA8 D_801AE3BC; - void EffectSsKiraKira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - Color_RGBA8 primColor = D_801AE3B8; - Color_RGBA8 envColor = D_801AE3BC; + Color_RGBA8 primColor = { 255, 255, 200, 255 }; + Color_RGBA8 envColor = { 255, 200, 0, 0 }; EffectSsKiraKira_SpawnDispersed(globalCtx, pos, velocity, accel, &primColor, &envColor, 1000, 16); } @@ -307,12 +304,12 @@ void EffectSsBlast_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, EffectSs_Spawn(globalCtx, EFFECT_SS_BLAST, 128, &initParams); } -extern Color_RGBA8 D_801AE3C0; -extern Color_RGBA8 D_801AE3C4; - void EffectSsBlast_SpawnWhiteCustomScale(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { - EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, &D_801AE3C0, &D_801AE3C4, scale, scaleStep, 35, life); + static Color_RGBA8 primColor = { 255, 255, 255, 255 }; + static Color_RGBA8 envColor = { 200, 200, 200, 0 }; + + EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, &primColor, &envColor, scale, scaleStep, 35, life); } void EffectSsBlast_SpawnShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, @@ -320,11 +317,11 @@ void EffectSsBlast_SpawnShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* v EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, primColor, envColor, 100, 375, 35, life); } -extern Color_RGBA8 D_801AE3C8; -extern Color_RGBA8 D_801AE3CC; - void EffectSsBlast_SpawnWhiteShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - EffectSsBlast_SpawnShockwave(globalCtx, pos, velocity, accel, &D_801AE3C8, &D_801AE3CC, 10); + static Color_RGBA8 primColor = { 255, 255, 255, 255 }; + static Color_RGBA8 envColor = { 200, 200, 200, 0 }; + + EffectSsBlast_SpawnShockwave(globalCtx, pos, velocity, accel, &primColor, &envColor, 10); } // EffectSsGSpk Spawn Functions @@ -364,24 +361,18 @@ void EffectSsGSpk_SpawnNoAccel(GlobalContext* globalCtx, Actor* actor, Vec3f* po EffectSs_Spawn(globalCtx, EFFECT_SS_G_SPK, 128, &initParams); } -extern Color_RGBA8 D_801AE3D0; -extern Color_RGBA8 D_801AE3D4; - void EffectSsGSpk_SpawnFuse(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - Color_RGBA8 primColor = D_801AE3D0; - Color_RGBA8 envColor = D_801AE3D4; + Color_RGBA8 primColor = { 255, 255, 150, 255 }; + Color_RGBA8 envColor = { 255, 0, 0, 0 }; EffectSsGSpk_SpawnSmall(globalCtx, actor, pos, velocity, accel, &primColor, &envColor); } -extern Color_RGBA8 D_801AE3D8; -extern Color_RGBA8 D_801AE3DC; - // unused void EffectSsGSpk_SpawnRandColor(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { - Color_RGBA8 primColor = D_801AE3D8; - Color_RGBA8 envColor = D_801AE3DC; + Color_RGBA8 primColor = { 255, 255, 150, 255 }; + Color_RGBA8 envColor = { 255, 0, 0, 0 }; s32 randOffset = (Rand_ZeroOne() * 20.0f) - 10.0f; primColor.r += randOffset; @@ -585,12 +576,10 @@ void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstSca } } -extern Vec3f D_801AE3E0; - void func_800B2364(GlobalContext* globalCtx, Vec3f* pos, Gfx* dList) { - Vec3f posVec = D_801AE3E0; + Vec3f accel = { 0.0f, -2.0f, 0.0f }; - EffectSsHahen_Spawn(globalCtx, pos, &gZeroVec3f, &posVec, 1, 5, 1, 10, dList); + EffectSsHahen_Spawn(globalCtx, pos, &gZeroVec3f, &accel, 1, 5, 1, 10, dList); } // EffectSsStick Spawn Functions @@ -624,12 +613,9 @@ void EffectSsSibuki_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, EffectSs_Spawn(globalCtx, EFFECT_SS_SIBUKI, 128, &initParams); } -extern Vec3f D_801AE3EC; -extern Vec3f D_801AE3F8; - void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos) { s16 i; - Vec3f zeroVec = D_801AE3EC; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; s16 randDirection = Rand_ZeroOne() * 1.99f; for (i = 0; i < KREG(19) + 30; i++) { @@ -759,11 +745,6 @@ void EffectSsIcePiece_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec EffectSs_Spawn(globalCtx, EFFECT_SS_ICE_PIECE, 128, &initParams); } -extern Vec3f D_801AE3F8; -extern Vec3f D_801AE404[10]; - -#ifdef NON_MATCHING -/* needs data migration to match */ void EffectSsIcePiece_SpawnBurst(GlobalContext* globalCtx, Vec3f* refPos, f32 scale) { static Vec3f accel = { 0.0f, 0.0f, 0.0f }; static Vec3f vecScales[] = { @@ -799,15 +780,11 @@ void EffectSsIcePiece_SpawnBurst(GlobalContext* globalCtx, Vec3f* refPos, f32 sc &accel, 25); } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsIcePiece_SpawnBurst.s") -#endif // EffectSsEnIce Spawn Functions void EffectSsEnIce_SpawnFlyingVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Color_RGBA8* prim, Color_RGBA8* env, f32 scale) { - EffectSsEnIceInitParams initParams; initParams.actor = actor; @@ -818,17 +795,17 @@ void EffectSsEnIce_SpawnFlyingVec3f(GlobalContext* globalCtx, Actor* actor, Vec3 initParams.scale = scale; if (actor != NULL) { - Audio_PlayActorSound2(actor, NA_SE_PL_FREEZE_S); + Actor_PlaySfxAtPos(actor, NA_SE_PL_FREEZE_S); } EffectSs_Spawn(globalCtx, EFFECT_SS_EN_ICE, 80, &initParams); } -extern Color_RGBA8 D_801AE47C; -extern Color_RGBA8 D_801AE480; - void func_800B2B44(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 scale) { - EffectSsEnIce_SpawnFlyingVec3f(globalCtx, actor, pos, &D_801AE47C, &D_801AE480, scale); + static Color_RGBA8 primColor = { 150, 150, 150, 250 }; + static Color_RGBA8 envColor = { 235, 245, 255, 255 }; + + EffectSsEnIce_SpawnFlyingVec3f(globalCtx, actor, pos, &primColor, &envColor, scale); } void func_800B2B7C(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, f32 scale) { @@ -874,29 +851,21 @@ void EffectSsFireTail_Spawn(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, EffectSs_Spawn(globalCtx, EFFECT_SS_FIRE_TAIL, 128, &initParams); } -extern Color_RGBA8 D_801AE484; -extern Color_RGBA8 D_801AE488; - -#ifdef NON_MATCHING -// needs data migration to match void EffectSsFireTail_SpawnFlame(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 arg3, s16 bodyPart, f32 colorIntensity) { + static Color_RGBA8 primColor = { 255, 255, 0, 255 }; + static Color_RGBA8 envColor = { 255, 0, 0, 255 }; - D_801AE484.g = (s32)(255.0f * colorIntensity); - D_801AE484.b = 0; + primColor.g = (s32)(255.0f * colorIntensity); + primColor.b = 0; - D_801AE488.g = 0; - D_801AE488.b = 0; - D_801AE484.r = D_801AE488.r = (s32)(255.0f * colorIntensity); + envColor.g = 0; + envColor.b = 0; + primColor.r = envColor.r = (s32)(255.0f * colorIntensity); - EffectSsFireTail_Spawn(globalCtx, actor, pos, arg3, &actor->velocity, 15, &D_801AE484, &D_801AE488, + EffectSsFireTail_Spawn(globalCtx, actor, pos, arg3, &actor->velocity, 15, &primColor, &envColor, (colorIntensity == 1.0f) ? 0 : 1, bodyPart, 1); } -#else -void EffectSsFireTail_SpawnFlame(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 arg3, s16 bodyPart, - f32 colorIntensity); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsFireTail_SpawnFlame.s") -#endif void EffectSsFireTail_SpawnFlameOnPlayer(GlobalContext* globalCtx, f32 scale, s16 bodyPart, f32 colorIntensity) { Player* player = GET_PLAYER(globalCtx); @@ -919,7 +888,7 @@ void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* po initParams.bodyPart = bodyPart; if (actor != NULL) { - Audio_PlayActorSound2(actor, NA_SE_EV_FLAME_IGNITION); + Actor_PlaySfxAtPos(actor, NA_SE_EV_FLAME_IGNITION); } EffectSs_Spawn(globalCtx, EFFECT_SS_EN_FIRE, 128, &initParams); @@ -939,7 +908,7 @@ void EffectSsEnFire_SpawnVec3s(GlobalContext* globalCtx, Actor* actor, Vec3s* po initParams.bodyPart = bodyPart; if (actor != NULL) { - Audio_PlayActorSound2(actor, NA_SE_EV_FLAME_IGNITION); + Actor_PlaySfxAtPos(actor, NA_SE_EV_FLAME_IGNITION); } EffectSs_Spawn(globalCtx, EFFECT_SS_EN_FIRE, 128, &initParams); @@ -982,12 +951,17 @@ void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_DB, 120, &initParams); } -extern Color_RGBA8 D_801AE48C; -extern Color_RGBA8 D_801AE490[4]; - void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s32 colorIndex) { - EffectSsDeadDb_Spawn(globalCtx, pos, velocity, accel, &D_801AE48C, &D_801AE490[colorIndex], scale, scaleStep, 9); + static Color_RGBA8 primColor = { 255, 255, 255, 255 }; + static Color_RGBA8 envColors[] = { + { 255, 0, 0, 255 }, + { 0, 255, 0, 255 }, + { 0, 0, 255, 255 }, + { 150, 150, 150, 255 }, + }; + + EffectSsDeadDb_Spawn(globalCtx, pos, velocity, accel, &primColor, &envColors[colorIndex], scale, scaleStep, 9); } // EffectSsDeadDd Spawn Functions diff --git a/src/code/z_en_a_keep.c b/src/code/z_en_a_keep.c index d5125d2497..1d083b2c7a 100644 --- a/src/code/z_en_a_keep.c +++ b/src/code/z_en_a_keep.c @@ -11,10 +11,10 @@ void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.textId = ((this->actor.params >> 8) & 0xFF) | 0x300; this->actor.params = (this->actor.params & 0xFF) - 9; Actor_ProcessInitChain(&this->actor, &enAObjInitVar); - ActorShape_Init(&this->actor.shape, 0, func_800B3FC0, 12); + ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 12); Collider_InitAndSetCylinder(globalCtx, &this->collision, &this->actor, &enAObjCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collision); - this->actor.colChkInfo.mass = 255; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actionFunc = EnAObj_Update1; } @@ -27,7 +27,7 @@ void EnAObj_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnAObj_Update1(EnAObj* this, GlobalContext* globalCtx) { s32 yawDiff; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnAObj_Update2; } else { yawDiff = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)); @@ -39,7 +39,7 @@ void EnAObj_Update1(EnAObj* this, GlobalContext* globalCtx) { } void EnAObj_Update2(EnAObj* this, GlobalContext* globalCtx) { - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->actionFunc = EnAObj_Update1; } } @@ -48,10 +48,10 @@ void EnAObj_Update(Actor* thisx, GlobalContext* globalCtx) { EnAObj* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, 45.0f); + Actor_SetFocus(&this->actor, 45.0f); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collision.base); } void EnAObj_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, enAObjDisplayLists[thisx->params]); + Gfx_DrawDListOpa(globalCtx, enAObjDisplayLists[thisx->params]); } diff --git a/src/code/z_en_hy.c b/src/code/z_en_hy.c index 73adc5fa58..e0c4872628 100644 --- a/src/code/z_en_hy.c +++ b/src/code/z_en_hy.c @@ -66,7 +66,7 @@ Actor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) { f32 minDist = 0.0f; do { - doorIter = func_ActorCategoryIterateById(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); + doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); door = doorIter; dist = Actor_DistanceBetweenActors(actor, door); if (!isSetup || (dist < minDist)) { @@ -131,7 +131,7 @@ void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, Actor* door, s16 arg3, Vec3f offset; f32 phi_f0; - Actor_CalcOffsetOrientedToDrawRotation(door, &offset, &enHy->actor.world.pos); + Actor_OffsetOfPointInActorCoords(door, &offset, &enHy->actor.world.pos); phi_f0 = (offset.z >= 0.0f) ? 1.0f : -1.0f; sp3B = ((s8)phi_f0 < 0) ? 0 : 2; EnHy_ChangeObjectAndAnim(enHy, globalCtx, (sp3B == 0) ? arg3 : arg4); @@ -260,12 +260,12 @@ s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThr enHy->isLeftFootOnGround = isFootOnGround = func_8013DB90(globalCtx, &enHy->leftFootPos, distAboveThreshold); if (enHy->isLeftFootOnGround && !wasLeftFootOnGround && isFootOnGround) { - Audio_PlayActorSound2(&enHy->actor, sfxId); + Actor_PlaySfxAtPos(&enHy->actor, sfxId); } enHy->isRightFootOnGround = isFootOnGround = func_8013DB90(globalCtx, &enHy->rightFootPos, distAboveThreshold); if (enHy->isRightFootOnGround && !wasRightFootOnGround && isFootOnGround) { - Audio_PlayActorSound2(&enHy->actor, sfxId); + Actor_PlaySfxAtPos(&enHy->actor, sfxId); } return 0; } diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index acd827f8e9..ec32550f87 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -43,7 +43,7 @@ static InitChainEntry sInitChain[] = { }; void EnItem00_SetObject(EnItem00* this, GlobalContext* globalCtx, f32* shadowOffset, f32* shadowScale) { - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); Actor_SetScale(&this->actor, 0.5f); this->unk154 = 0.5f; *shadowOffset = 0.0f; @@ -63,7 +63,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->params &= 0xFF; // Has to be thisx to match - if (Actor_GetCollectibleFlag(globalCtx, this->collectibleFlag)) { + if (Flags_GetCollectible(globalCtx, this->collectibleFlag)) { if (this->actor.params == ITEM00_HEART_PIECE) { sp30 = 0; this->collectibleFlag = 0; @@ -169,7 +169,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { } this->unk14E = 0; - ActorShape_Init(&this->actor.shape, shadowOffset, func_800B3FC0, shadowScale); + ActorShape_Init(&this->actor.shape, shadowOffset, ActorShadow_DrawCircle, shadowScale); this->actor.shape.shadowAlpha = 180; this->actor.focus.pos = this->actor.world.pos; this->unk14A = GI_NONE; @@ -251,7 +251,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { } if ((getItemId != GI_NONE) && (Actor_HasParent(&this->actor, globalCtx) == 0)) { - func_800B8A1C(&this->actor, globalCtx, getItemId, 50.0f, 20.0f); + Actor_PickUp(&this->actor, globalCtx, getItemId, 50.0f, 20.0f); } this->actionFunc = func_800A6A40; @@ -407,7 +407,7 @@ void func_800A6A40(EnItem00* this, GlobalContext* globalCtx) { if (this->unk14A != GI_NONE) { if (Actor_HasParent(&this->actor, globalCtx) == 0) { - func_800B8A1C(&this->actor, globalCtx, this->unk14A, 50.0f, 80.0f); + Actor_PickUp(&this->actor, globalCtx, this->unk14A, 50.0f, 80.0f); this->unk152++; } else { this->unk14A = GI_NONE; @@ -457,7 +457,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.scale.y = this->actor.scale.x; if (this->actor.gravity != 0.0f) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 15.0f, 15.0f, 0x1D); if (this->actor.floorHeight <= BGCHECK_Y_MIN) { @@ -574,7 +574,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { if (getItemId != GI_NONE) { if (!Actor_HasParent(&this->actor, globalCtx)) { - func_800B8A1C(&this->actor, globalCtx, getItemId, 50.0f, 20.0f); + Actor_PickUp(&this->actor, globalCtx, getItemId, 50.0f, 20.0f); } } @@ -586,7 +586,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { case ITEM00_MAP: case ITEM00_COMPASS: if (Actor_HasParent(&this->actor, globalCtx)) { - Actor_SetCollectibleFlag(globalCtx, this->collectibleFlag); + Flags_SetCollectible(globalCtx, this->collectibleFlag); Actor_MarkForDeath(&this->actor); } return; @@ -598,7 +598,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { play_sound(NA_SE_SY_GET_RUPY); } else if (getItemId != GI_NONE) { if (Actor_HasParent(&this->actor, globalCtx)) { - Actor_SetCollectibleFlag(globalCtx, this->collectibleFlag); + Flags_SetCollectible(globalCtx, this->collectibleFlag); Actor_MarkForDeath(&this->actor); } return; @@ -606,7 +606,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { play_sound(NA_SE_SY_GET_ITEM); } - Actor_SetCollectibleFlag(globalCtx, this->collectibleFlag); + Flags_SetCollectible(globalCtx, this->collectibleFlag); this->unk152 = 15; this->unk14C = 35; @@ -651,7 +651,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { s8 bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEART); if (Object_IsLoaded(&globalCtx->objectCtx, bankIndex)) { this->actor.objBankIndex = bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); this->unk152 = -2; } } else { @@ -828,112 +828,94 @@ s16 func_800A7650(s16 dropId) { return dropId; } -#ifdef NON_MATCHING -// Reordering issues -EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params) { +Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params) { s32 pad; - EnItem00* spawnedActor = NULL; - s32 pad2; - s32 param10000; - s16 param8000; - s16 param7F00; - s32 param20000; - s32 paramFF; + Actor* spawnedActor = NULL; + s32 newParamFF; + s32 param10000 = params & 0x10000; + s16 param8000 = params & 0x8000; + s16 param7F00 = params & 0x7F00; + s32 param20000 = params & 0x20000; + s32 paramFF = params & 0xFF; s32 i; - param10000 = params & 0x10000; - param8000 = params & 0x8000; - param7F00 = params & 0x7F00; - param20000 = params & 0x20000; - paramFF = params & 0xFF; - params &= 0x7FFF; + newParamFF = params & 0xFF; if (paramFF == ITEM00_3_HEARTS) { - for (i = 0; i != 3; i++) { + for (i = 0; i < 3; i++) { spawnedActor = Item_DropCollectible(globalCtx, spawnPos, param7F00 | ITEM00_HEART | param8000); } } else if (paramFF == ITEM00_MUSHROOM_CLOUD) { param7F00 >>= 8; - if (!Actor_GetCollectibleFlag(globalCtx, param7F00)) { + if (!Flags_GetCollectible(globalCtx, param7F00)) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_KINOKO, spawnPos->x, spawnPos->y, spawnPos->z, 0, 0, 0, param7F00); } - } else if (((paramFF == ITEM00_FLEXIBLE) || ((params & 0xFF) == ITEM00_BIG_FAIRY)) && (param10000 == 0)) { - if ((params & 0xFF) == ITEM00_FLEXIBLE) { - // TODO: fix cast, this actor is not an EnItem00 - spawnedActor = - (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, + } else if (((paramFF == ITEM00_FLEXIBLE) || (newParamFF == ITEM00_BIG_FAIRY)) && (param10000 == 0)) { + newParamFF = params & 0xFF; + if (newParamFF == ITEM00_FLEXIBLE) { + spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) << 9) & 0xFE00) | 0x102); - if (!Actor_GetCollectibleFlag(globalCtx, (param7F00 >> 8) & 0x7F)) { + if (!Flags_GetCollectible(globalCtx, (param7F00 >> 8) & 0x7F)) { Audio_PlaySoundAtPosition(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); } } else { - // TODO: fix cast, this actor is not an EnItem00 - spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, spawnPos->x, - spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, - ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7); + spawnedActor = + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f, + spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7); if (param20000 == 0) { - if (!Actor_GetCollectibleFlag(globalCtx, (param7F00 >> 8) & 0x7F)) { + if (!Flags_GetCollectible(globalCtx, (param7F00 >> 8) & 0x7F)) { Audio_PlaySoundAtPosition(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); } } } } else { if (param8000 == 0) { - params = func_800A7650(params & 0xFF); + params = func_800A7650(newParamFF); } - if (params != (u32)ITEM00_NO_DROP) { - spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, - spawnPos->y, spawnPos->z, 0, 0, 0, params | param8000 | param7F00); + if ((s32)params != ITEM00_NO_DROP) { + spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y, + spawnPos->z, 0, 0, 0, (s32)params | param8000 | param7F00); if ((spawnedActor != NULL) && (param8000 == 0)) { if (param10000 == 0) { - spawnedActor->actor.velocity.y = 8.0f; + spawnedActor->velocity.y = 8.0f; } else { - spawnedActor->actor.velocity.y = -2.0f; + spawnedActor->velocity.y = -2.0f; } - spawnedActor->actor.speedXZ = 2.0f; - spawnedActor->actor.gravity = -0.9f; - spawnedActor->actor.world.rot.y = randPlusMinusPoint5Scaled(65536.0f); - Actor_SetScale(&spawnedActor->actor, 0.0f); - spawnedActor->actionFunc = func_800A6780; - spawnedActor->unk152 = 0xDC; - if ((spawnedActor->actor.params != ITEM00_SMALL_KEY) && - (spawnedActor->actor.params != ITEM00_HEART_PIECE) && - (spawnedActor->actor.params != ITEM00_HEART_CONTAINER)) { - spawnedActor->actor.room = -1; + spawnedActor->speedXZ = 2.0f; + spawnedActor->gravity = -0.9f; + spawnedActor->world.rot.y = randPlusMinusPoint5Scaled(65536.0f); + Actor_SetScale(spawnedActor, 0.0f); + ((EnItem00*)spawnedActor)->actionFunc = func_800A6780; + ((EnItem00*)spawnedActor)->unk152 = 0xDC; + if ((spawnedActor->params != ITEM00_SMALL_KEY) && (spawnedActor->params != ITEM00_HEART_PIECE) && + (spawnedActor->params != ITEM00_HEART_CONTAINER)) { + spawnedActor->room = -1; } - spawnedActor->actor.flags |= 0x0010; + spawnedActor->flags |= 0x0010; } } } return spawnedActor; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_en_item00/Item_DropCollectible.s") -#endif -#ifdef NON_MATCHING -// Regalloc, minor reordering -Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params) { +Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s32 params) { Actor* spawnedActor = NULL; - u32 pad; - u32 param10000; - s16 param8000; - s16 param7F00; + s32 pad; + s32 param10000 = params & 0x10000; + s16 param8000 = params & 0x8000; + s16 param7F00 = params & 0x7F00; - param10000 = params & 0x10000; - param8000 = params & 0x8000; - param7F00 = params & 0x7F00; params &= 0xFF; - if (params == ITEM00_3_HEARTS) { + if ((params & 0xFF) == ITEM00_3_HEARTS) { return NULL; } - if (((params == ITEM00_FLEXIBLE) || (params == ITEM00_BIG_FAIRY)) && (param10000 == 0)) { - if (params == ITEM00_FLEXIBLE) { + if ((((params & 0xFF) == ITEM00_FLEXIBLE) || ((params & 0xFF) == ITEM00_BIG_FAIRY)) && (param10000 == 0)) { + if ((params & 0xFF) == ITEM00_FLEXIBLE) { spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) << 9) & 0xFE00) | 0x102); } else { @@ -941,14 +923,14 @@ Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, u32 para Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7); } - if (Actor_GetCollectibleFlag(globalCtx, (param7F00 >> 8) & 0x7F) == 0) { + if (Flags_GetCollectible(globalCtx, (param7F00 >> 8) & 0x7F) == 0) { Audio_PlaySoundAtPosition(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); } } else { - params = func_800A7650(params); - if (params != (u32)ITEM00_NO_DROP) { + params = func_800A7650(params & 0xFF); + if (params != ITEM00_NO_DROP) { spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y, - spawnPos->z, 0, 0, 0, params | param8000 | param7F00); + spawnPos->z, 0, 0, 0, (s32)params | param8000 | param7F00); if (spawnedActor != NULL) { if (param8000 == 0) { spawnedActor->velocity.y = 0.0f; @@ -967,9 +949,6 @@ Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, u32 para return spawnedActor; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_en_item00/Item_DropCollectible2.s") -#endif u8 sDropTable[DROP_TABLE_SIZE * DROP_TABLE_NUMBER] = { ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_NO_DROP, ITEM00_NO_DROP, @@ -1047,17 +1026,14 @@ u8 sDropTableAmounts[DROP_TABLE_SIZE * DROP_TABLE_NUMBER] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, }; -#ifdef NON_MATCHING -// Many regalloc and reordering issues void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3f* spawnPos, s16 params) { EnItem00* spawnedActor; u8 dropId; s32 dropQuantity; - s16 dropTableIndex; - s16 param8000; + s16 dropTableIndex = Rand_ZeroOne() * 16.0f; + s16 param8000 = params & 0x8000; + u8 dropFlag; - dropTableIndex = Rand_ZeroOne() * 16.0f; - param8000 = params & 0x8000; params &= 0x1F0; if (params < 0x101) { @@ -1065,50 +1041,54 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 dropQuantity = sDropTableAmounts[params + dropTableIndex]; if (dropId == ITEM00_MASK) { - dropQuantity = 1; - if (gSaveContext.playerForm != PLAYER_FORM_GORON) { - if (gSaveContext.playerForm != PLAYER_FORM_ZORA) { - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - dropId = ITEM00_RUPEE_GREEN; - } else { - dropId = ITEM00_ARROWS_10; - } - } else { + switch (gSaveContext.playerForm) { + case PLAYER_FORM_HUMAN: + dropId = ITEM00_ARROWS_10; + break; + case PLAYER_FORM_ZORA: dropId = ITEM00_HEART; - } - } else { - dropId = ITEM00_MAGIC_SMALL; + break; + case PLAYER_FORM_GORON: + dropId = ITEM00_MAGIC_SMALL; + break; + default: + dropId = ITEM00_RUPEE_GREEN; + break; } + dropQuantity = 1; } if (fromActor != NULL) { - if (fromActor->dropFlag != 0) { - if ((fromActor->dropFlag & 1) != 0) { + dropFlag = fromActor->dropFlag; + if (dropFlag != 0) { + if (fromActor->dropFlag & 1) { + params = 0x10; dropId = ITEM00_ARROWS_30; + dropQuantity = 1; + } else if (fromActor->dropFlag & 2) { params = 0x10; - } else if ((fromActor->dropFlag & 2) != 0) { dropId = ITEM00_HEART; - params = 0x10; - } else if ((fromActor->dropFlag & 0x20) != 0) { + dropQuantity = 1; + } else if (fromActor->dropFlag & 0x20) { dropId = ITEM00_RUPEE_PURPLE; + dropQuantity = 1; } - dropQuantity = 1; } } if (dropId == ITEM00_FLEXIBLE) { - if (gSaveContext.health < 0x11) { + if (gSaveContext.health <= 0x10) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, 2); Audio_PlaySoundAtPosition(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); return; } - if (gSaveContext.health < 0x31) { + if (gSaveContext.health <= 0x30) { params = 0x10; dropId = ITEM00_HEART; dropQuantity = 3; - } else if (gSaveContext.health < 0x51) { + } else if (gSaveContext.health <= 0x50) { params = 0x10; dropId = ITEM00_HEART; dropQuantity = 1; @@ -1132,6 +1112,8 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 params = 0xA0; dropId = ITEM00_RUPEE_RED; dropQuantity = 1; + } else { + return; } } @@ -1167,18 +1149,16 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_en_item00/Item_DropCollectibleRandom.s") -#endif -s32 D_801AE194[32] = { ITEM00_NO_DROP, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_NO_DROP, - ITEM00_RUPEE_RED, ITEM00_RUPEE_PURPLE, ITEM00_NO_DROP, ITEM00_RUPEE_HUGE, - ITEM00_COMPASS, ITEM00_MUSHROOM_CLOUD, ITEM00_HEART, ITEM00_3_HEARTS, - ITEM00_HEART_PIECE, ITEM00_HEART_CONTAINER, ITEM00_MAGIC_SMALL, ITEM00_MAGIC_LARGE, - ITEM00_FLEXIBLE, ITEM00_BIG_FAIRY, ITEM00_NO_DROP, ITEM00_NUTS_10, - ITEM00_NO_DROP, ITEM00_BOMBS_A, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_STICK, ITEM00_NO_DROP, ITEM00_NO_DROP, - ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_ARROWS_10, ITEM00_ARROWS_30 }; +s32 D_801AE194[32] = { + ITEM00_NO_DROP, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_NO_DROP, ITEM00_RUPEE_RED, + ITEM00_RUPEE_PURPLE, ITEM00_NO_DROP, ITEM00_RUPEE_HUGE, ITEM00_COMPASS, ITEM00_MUSHROOM_CLOUD, + ITEM00_HEART, ITEM00_3_HEARTS, ITEM00_HEART_PIECE, ITEM00_HEART_CONTAINER, ITEM00_MAGIC_SMALL, + ITEM00_MAGIC_LARGE, ITEM00_FLEXIBLE, ITEM00_BIG_FAIRY, ITEM00_NO_DROP, ITEM00_NUTS_10, + ITEM00_NO_DROP, ITEM00_BOMBS_A, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_STICK, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, ITEM00_NO_DROP, + ITEM00_ARROWS_10, ITEM00_ARROWS_30, +}; s32 func_800A8150(s32 index) { if ((index < 0) || (index >= ARRAY_COUNT(D_801AE194))) { @@ -1188,9 +1168,7 @@ s32 func_800A8150(s32 index) { return D_801AE194[index]; } -u8 D_801AE214[32] = { - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; +u8 D_801AE214[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; s32 func_800A817C(s32 index) { if ((index < 0) || (index >= ARRAY_COUNT(D_801AE214))) { @@ -1201,5 +1179,5 @@ s32 func_800A817C(s32 index) { } s32 func_800A81A4(GlobalContext* globalCtx, s32 a1, s32 a2) { - return (func_800A8150(a1) == ITEM00_BIG_FAIRY) && (!Actor_GetCollectibleFlag(globalCtx, a2)); + return (func_800A8150(a1) == ITEM00_BIG_FAIRY) && (!Flags_GetCollectible(globalCtx, a2)); } diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.c index 318b033f64..5e89f49e97 100644 --- a/src/code/z_kaleido_manager.c +++ b/src/code/z_kaleido_manager.c @@ -24,7 +24,7 @@ void* KaleidoManager_FaultAddrConvFunc(void* address, void* param) { uintptr_t offset; if (ovl != NULL) { - size = (u8*)ovl->vramEnd - (u8*)ovl->vramStart; + size = VRAM_PTR_SIZE(ovl); ramStart = ovl->loadedRamAddr; ramEnd = ramStart + size; offset = (u8*)ovl->vramStart - ramStart; @@ -47,7 +47,7 @@ void KaleidoManager_LoadOvl(KaleidoMgrOverlay* ovl) { void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl) { if (ovl->loadedRamAddr != NULL) { ovl->offset = 0; - bzero(ovl->loadedRamAddr, (uintptr_t)ovl->vramEnd - (uintptr_t)ovl->vramStart); + bzero(ovl->loadedRamAddr, VRAM_PTR_SIZE(ovl)); ovl->loadedRamAddr = NULL; gKaleidoMgrCurOvl = NULL; } @@ -59,7 +59,7 @@ void KaleidoManager_Init(GlobalContext* globalCtx) { u32 i; for (i = 0; i < ARRAY_COUNT(gKaleidoMgrOverlayTable); i++) { - size = (uintptr_t)gKaleidoMgrOverlayTable[i].vramEnd - (uintptr_t)gKaleidoMgrOverlayTable[i].vramStart; + size = VRAM_PTR_SIZE(&gKaleidoMgrOverlayTable[i]); if (size > largestSize) { largestSize = size; } diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index bbfad829f3..738f9373e2 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -399,9 +399,9 @@ void LifeMeter_UpdateSizeAndBeep(GlobalContext* globalCtx) { if (interfaceCtx->lifeSizeChange <= 0) { interfaceCtx->lifeSizeChange = 0; interfaceCtx->lifeSizeChangeDirection = 0; - if (func_801233E4(globalCtx) == 0 && (globalCtx->pauseCtx.state == 0) && + if (Player_InCsMode(&globalCtx->state) == 0 && (globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && LifeMeter_IsCritical() && func_801690CC(globalCtx) == 0) { - // func_801233E4 and func_801690CC : Check if in Cutscene + // Player_InCsMode and func_801690CC : Check if in Cutscene play_sound(NA_SE_SY_HITPOINT_ALARM); } } diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 4d649da2d7..fae6af51e1 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -382,7 +382,7 @@ void Lights_GlowCheck(GlobalContext* globalCtx) { pos.x = params->x; pos.y = params->y; pos.z = params->z; - func_800B4EDC(globalCtx, &pos, &multDest, &wDest); + Actor_GetProjectedPos(globalCtx, &pos, &multDest, &wDest); params->drawGlow = 0; diff --git a/src/code/z_message.c b/src/code/z_message.c index 0bfbdc53d2..84f2ab951c 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -80,7 +80,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152464.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152498.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_GetState.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015268C.s") diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index c03c0dfc7c..99253188cb 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -38,7 +38,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123358.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801233E4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_InCsMode.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123420.s") @@ -114,7 +114,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012422C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124258.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_GetExplosiveHeld.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124278.s") diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 9c5288139d..e699ff0862 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -608,7 +608,7 @@ void Quake2_Update(void) { player = GET_PLAYER(globalCtx); if (&player->actor != NULL) { - func_800B8248(&playerPosRot, player); + Actor_GetWorldPosShapeRot(&playerPosRot, &player->actor); } angle1Speed = 359.2f; diff --git a/src/code/z_snap.c b/src/code/z_snap.c index 1c0ab3a27d..6d206eea55 100644 --- a/src/code/z_snap.c +++ b/src/code/z_snap.c @@ -20,7 +20,7 @@ s32 func_8013A240(GlobalContext* globalCtx) { } for (; type < 12; type++) { - for (actor = globalCtx->actorCtx.actorList[type].first; actor != NULL; actor = actor->next) { + for (actor = globalCtx->actorCtx.actorLists[type].first; actor != NULL; actor = actor->next) { seen = 0; switch (globalCtx->sceneNum) { @@ -134,7 +134,7 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, ret |= 0x3e; } - func_800B4EDC(globalCtx, pos, &screenSpace, &distance); + Actor_GetProjectedPos(globalCtx, pos, &screenSpace, &distance); x = (s16)(screenSpace.x * distance * 160.0f + 160.0f) - 85; y = (s16)(screenSpace.y * distance * -120.0f + 120.0f) - 67; if ((x < 0) || (0x96 < x) || (y < 0) || (0x69 < y)) { diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 1ab44acc10..8f0599b553 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -1,6 +1,40 @@ -#include "global.h" +/* + * File: z_sub_s.c + * Description: Various miscellaneous helpers + */ -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013A7C0.s") +#include "global.h" +#include "overlays/actors/ovl_En_Door/z_en_door.h" + +/** + * Finds the first EnDoor instance with unk_1A4 == 5 and the specified unk_1A5. + */ +EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5) { + Actor* actor = NULL; + EnDoor* door; + + while (true) { + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_DOOR, ACTOR_EN_DOOR); + door = (EnDoor*)actor; + + if (actor == NULL) { + break; + } + + if ((door->unk_1A4 == 5) && (door->unk_1A5 == (u8)unk_1A5)) { + break; + } + + if (actor->next == NULL) { + door = NULL; + break; + } + + actor = actor->next; + } + + return door; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013A860.s") @@ -26,7 +60,40 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BB34.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BB7C.s") +/** + * Finds the nearest actor instance of a specified Id and category to an actor. + */ +Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId) { + Actor* actorIter = NULL; + Actor* actorTmp; + f32 dist; + Actor* closestActor = NULL; + f32 minDist = 99999.0f; + s32 isSetup = false; + + do { + actorIter = SubS_FindActor(globalCtx, actorIter, actorCategory, actorId); + + actorTmp = actorIter; + if (actorTmp == NULL) { + break; + } + actorIter = actorTmp; + + if (actorIter != actor) { + dist = Actor_DistanceBetweenActors(actor, actorIter); + if (!isSetup || dist < minDist) { + closestActor = actorIter; + minDist = dist; + isSetup = true; + } + } + + actorIter = actorIter->next; + } while (actorIter != NULL); + + return closestActor; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BC6C.s") @@ -68,7 +135,22 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D924.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_ActorCategoryIterateById.s") +/** + * Finds the first actor instance of a specified Id and category. + */ +Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId) { + Actor* actor = actorListStart; + + if (actor == NULL) { + actor = globalCtx->actorCtx.actorLists[actorCategory].first; + } + + while (actor != NULL && actorId != actor->id) { + actor = actor->next; + } + + return actor; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D9C8.s") @@ -100,7 +182,27 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E5CC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E640.s") +/** + * Finds the first actor instance of a specified Id and category verified with a custom callback. + * The callback should return `true` when the actor is succesfully verified. + */ +Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, + s16 actorId, void* verifyData, VerifyActor verifyActor) { + Actor* actorIter = actorListStart; + + if (actorListStart == NULL) { + actorIter = globalCtx->actorCtx.actorLists[actorCategory].first; + } + + while (actorIter != NULL && (actorId != actorIter->id || + (actorId == actorIter->id && + (verifyActor == NULL || + (verifyActor != NULL && !verifyActor(globalCtx, actor, actorIter, verifyData)))))) { + actorIter = actorIter->next; + } + + return actorIter; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E748.s") diff --git a/src/libultra/io/contchannelreset.c b/src/libultra/io/contchannelreset.c index 5a66274a96..d0f1fbd9bc 100644 --- a/src/libultra/io/contchannelreset.c +++ b/src/libultra/io/contchannelreset.c @@ -7,7 +7,7 @@ s32 __osContChannelReset(OSMesgQueue* mq, s32 channel) { __osSiGetAccess(); - __osPfsPifRam.pifstatus = 1; + __osPfsPifRam.status = 1; for (i = 0; i < channel; i++) { *bufptr++ = 0; diff --git a/src/libultra/io/contpfs.c b/src/libultra/io/contpfs.c index 3dd0c96ca8..fd4c4e459f 100644 --- a/src/libultra/io/contpfs.c +++ b/src/libultra/io/contpfs.c @@ -1,6 +1,42 @@ #include "ultra64.h" #include "global.h" +__OSInode __osPfsInodeCache; +OSViMode osViModeNtscHpn1 = { + 8, // type + { + // comRegs + 0x324E, // ctrl + 0x500, // width + 0x3E52239, // burst + 0x20C, // vSync + 0xC15, // hSync + 0xC150C15, // leap + 0x6C02EC, // hStart + 0x400, // xScale + 0, // vCurrent + }, + { // fldRegs + { + // [0] + 0x500, // origin + 0x400, // yScale + 0x2301FD, // vStart + 0xE0204, // vBurst + 2, // vIntr + }, + { + // [1] + 0xA00, // origin + 0x400, // yScale + 0x2501FF, // vStart + 0xE0204, // vBurst + 2, // vIntr + } }, +}; +s32 __osPfsInodeCacheChannel = -1; +u8 __osPfsInodeCacheBank = 250; + u16 __osSumcalc(u8* ptr, s32 length) { s32 i; u32 sum = 0; diff --git a/src/libultra/io/contreaddata.c b/src/libultra/io/contreaddata.c index 47b7968d38..b54d894f30 100644 --- a/src/libultra/io/contreaddata.c +++ b/src/libultra/io/contreaddata.c @@ -47,7 +47,7 @@ void __osPackReadData() { __osContPifRam.ramarray[i] = 0; } - __osContPifRam.pifstatus = 1; + __osContPifRam.status = 1; readformat.dummy = 255; readformat.txsize = 1; readformat.rxsize = 4; diff --git a/src/libultra/io/controller.c b/src/libultra/io/controller.c index d84ba2d711..bd82709931 100644 --- a/src/libultra/io/controller.c +++ b/src/libultra/io/controller.c @@ -78,7 +78,7 @@ void __osPackRequestData(u8 poll) { __osContPifRam.ramarray[i] = 0; } - __osContPifRam.pifstatus = 1; + __osContPifRam.status = 1; ptr = (u8*)__osContPifRam.ramarray; requestHeader.align = 255; requestHeader.txsize = 1; diff --git a/src/libultra/io/motor.c b/src/libultra/io/motor.c index b8216dfc78..649a8b368f 100644 --- a/src/libultra/io/motor.c +++ b/src/libultra/io/motor.c @@ -20,7 +20,7 @@ s32 __osMotorAccess(OSPfs* pfs, u32 vibrate) { } __osSiGetAccess(); - osPifBuffers[pfs->channel].pifstatus = 1; + osPifBuffers[pfs->channel].status = 1; buf += pfs->channel; for (i = 0; i < BLOCKSIZE; i++) { ((__OSContRamReadFormat*)buf)->data[i] = vibrate; diff --git a/src/libultra/io/pfsgetstatus.c b/src/libultra/io/pfsgetstatus.c index 8127dde217..1d8e6dcf5f 100644 --- a/src/libultra/io/pfsgetstatus.c +++ b/src/libultra/io/pfsgetstatus.c @@ -1,7 +1,75 @@ +#include "ultra64.h" #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsgetstatus/__osPfsGetStatus.s") +void __osPfsRequestOneChannel(s32 channel, u8 poll); +void __osPfsGetOneChannelData(s32 channel, OSContStatus* contData); -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsgetstatus/__osPfsRequestOneChannel.s") +s32 __osPfsGetStatus(OSMesgQueue* queue, s32 channel) { + s32 ret = 0; + OSMesg msg; + OSContStatus data; -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsgetstatus/__osPfsGetOneChannelData.s") + __osPfsInodeCacheBank = 250; + + __osPfsRequestOneChannel(channel, CONT_CMD_REQUEST_STATUS); + ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + osRecvMesg(queue, &msg, OS_MESG_BLOCK); + + ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); + osRecvMesg(queue, &msg, OS_MESG_BLOCK); + + __osPfsGetOneChannelData(channel, &data); + if (((data.status & CONT_CARD_ON) != 0) && ((data.status & CONT_CARD_PULL) != 0)) { + return PFS_ERR_NEW_PACK; + } else if (data.errno || ((data.status & CONT_CARD_ON) == 0)) { + return PFS_ERR_NOPACK; + } else if ((data.status & CONT_ADDR_CRC_ER) != 0) { + return PFS_ERR_CONTRFAIL; + } + return ret; +} + +void __osPfsRequestOneChannel(s32 channel, u8 poll) { + u8* bufptr; + __OSContRequestHeaderAligned req; + s32 idx; + + __osContLastPoll = CONT_CMD_END; + __osPfsPifRam.status = CONT_CMD_READ_BUTTON; + + bufptr = (u8*)&__osPfsPifRam; + + req.txsize = 1; + req.rxsize = 3; + req.poll = poll; + req.typeh = 0xFF; + req.typel = 0xFF; + req.status = 0xFF; + + for (idx = 0; idx < channel; idx++) { + *bufptr++ = 0; + } + + *((__OSContRequestHeaderAligned*)bufptr) = req; + bufptr += sizeof(req); + *((u8*)bufptr) = CONT_CMD_END; +} + +void __osPfsGetOneChannelData(s32 channel, OSContStatus* contData) { + u8* bufptr = (u8*)&__osPfsPifRam; + __OSContRequestHeaderAligned req; + s32 idx; + + for (idx = 0; idx < channel; idx++) { + bufptr++; + } + + req = *((__OSContRequestHeaderAligned*)bufptr); + contData->errno = (req.rxsize & 0xC0) >> 4; + if (contData->errno) { + return; + } + + contData->type = (req.typel << 8) | req.typeh; + contData->status = req.status; +} diff --git a/src/libultra/io/pfsisplug.c b/src/libultra/io/pfsisplug.c index 358af0c985..474c7f914b 100644 --- a/src/libultra/io/pfsisplug.c +++ b/src/libultra/io/pfsisplug.c @@ -55,7 +55,7 @@ void __osPfsRequestData(u8 poll) { __osContLastPoll = poll; - __osPfsPifRam.pifstatus = 1; + __osPfsPifRam.status = 1; req.align = 0xFF; req.txsize = 1; diff --git a/src/libultra/io/pfsreadwritefile.c b/src/libultra/io/pfsreadwritefile.c index bc2b9741ce..b5ab6e4b4c 100644 --- a/src/libultra/io/pfsreadwritefile.c +++ b/src/libultra/io/pfsreadwritefile.c @@ -1,5 +1,124 @@ +#include "ultra64.h" #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsreadwritefile/__osPfsGetNextPage.s") +#define CHECK_IPAGE(p, pfs) \ + (((p).ipage >= (pfs).inodeStartPage) && ((p).inode_t.bank < (pfs).banks) && ((p).inode_t.page >= 0x01) && \ + ((p).inode_t.page < 0x80)) -#pragma GLOBAL_ASM("asm/non_matchings/boot/pfsreadwritefile/osPfsReadWriteFile.s") +s32 __osPfsGetNextPage(OSPfs* pfs, u8* bank, __OSInode* inode, __OSInodeUnit* page) { + s32 ret; + + if (page->inode_t.bank != *bank) { + *bank = page->inode_t.bank; + if ((ret = __osPfsRWInode(pfs, inode, PFS_READ, *bank)) != 0) { + return ret; + } + } + *page = inode->inodePage[page->inode_t.page]; + + if (!CHECK_IPAGE(*page, *pfs)) { + if (page->ipage == PFS_EOF) { + return PFS_ERR_INVALID; + } + return PFS_ERR_INCONSISTENT; + } + return 0; +} + +s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8* data) { + s32 ret; + __OSDir dir; + __OSInode inode; + __OSInodeUnit curPage; + s32 curBlock; + s32 blockSize; + u8* buffer; + u8 bank; + u16 blockno; + + if ((fileNo >= pfs->dir_size) || (fileNo < 0)) { + return PFS_ERR_INVALID; + } + if ((size <= 0) || ((size % BLOCKSIZE) != 0)) { + return PFS_ERR_INVALID; + } + if ((offset < 0) || ((offset % BLOCKSIZE) != 0)) { + return PFS_ERR_INVALID; + } + if (!(pfs->status & PFS_INITIALIZED)) { + return PFS_ERR_INVALID; + } + if (__osCheckId(pfs) == PFS_ERR_NEW_PACK) { + return PFS_ERR_NEW_PACK; + } + if (pfs->activebank != PFS_ID_BANK_256K && (ret = __osPfsSelectBank(pfs, PFS_ID_BANK_256K)) != 0) { + return ret; + } + if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + fileNo, (u8*)&dir)) != 0) { + return ret; + } + if ((dir.company_code == 0) || (dir.game_code == 0)) { + return PFS_ERR_INVALID; + } + if (!CHECK_IPAGE(dir.start_page, *pfs)) { + if (dir.start_page.ipage == PFS_EOF) { + return PFS_ERR_INVALID; + } + return PFS_ERR_INCONSISTENT; + } + if ((flag == PFS_READ) && ((dir.status & PFS_WRITTEN) == 0)) { + return PFS_ERR_BAD_DATA; + } + + bank = 255; + curBlock = offset / BLOCKSIZE; + curPage = dir.start_page; + + while (curBlock >= 8) { + if ((ret = __osPfsGetNextPage(pfs, &bank, &inode, &curPage)) != 0) { + return ret; + } + curBlock -= 8; + } + + blockSize = size / BLOCKSIZE; + buffer = data; + + while (blockSize > 0) { + if (curBlock == 8) { + if ((ret = __osPfsGetNextPage(pfs, &bank, &inode, &curPage)) != 0) { + return ret; + } + curBlock = 0; + } + if (pfs->activebank != curPage.inode_t.bank && (ret = __osPfsSelectBank(pfs, curPage.inode_t.bank)) != 0) { + return ret; + } + + blockno = curPage.inode_t.page * PFS_ONE_PAGE + curBlock; + if (flag == PFS_READ) { + ret = __osContRamRead(pfs->queue, pfs->channel, blockno, buffer); + } else { + ret = __osContRamWrite(pfs->queue, pfs->channel, blockno, buffer, 0); + } + if (ret != 0) { + return ret; + } + + buffer += BLOCKSIZE; + curBlock++; + blockSize--; + } + + if (flag == PFS_WRITE && !(dir.status & PFS_WRITTEN)) { + dir.status |= PFS_WRITTEN; + if (pfs->activebank != PFS_ID_BANK_256K && (ret = __osPfsSelectBank(pfs, PFS_ID_BANK_256K)) != 0) { + return ret; + } + if ((ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + fileNo, (u8*)&dir, 0)) != 0) { + return ret; + } + } + + return __osPfsGetStatus(pfs->queue, pfs->channel); +} diff --git a/src/libultra/voice/voicegetstatus.c b/src/libultra/voice/voicegetstatus.c index 833f5ad272..d8e7edb671 100644 --- a/src/libultra/voice/voicegetstatus.c +++ b/src/libultra/voice/voicegetstatus.c @@ -12,7 +12,7 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { do { if (ret != CONT_ERR_CONTRFAIL) { - __osContPifRam.pifstatus = CONT_CMD_READ_BUTTON; + __osContPifRam.status = CONT_CMD_READ_BUTTON; for (i = 0; i < port; i++, *ptr++ = 0) { ; diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 42834bb57e..6e4841bcef 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -77,7 +77,7 @@ void ArmsHook_Destroy(Actor* thisx, GlobalContext* globalCtx) { void ArmsHook_Wait(ArmsHook* this, GlobalContext* globalCtx) { if (this->actor.parent == NULL) { ArmsHook_SetupAction(this, ArmsHook_Shoot); - func_800B6C04(&this->actor, 20.0f); + Actor_SetSpeeds(&this->actor, 20.0f); this->actor.parent = &GET_PLAYER(globalCtx)->actor; this->timer = 26; } @@ -90,7 +90,7 @@ void func_808C1154(ArmsHook* this) { s32 ArmsHook_AttachToPlayer(ArmsHook* this, Player* player) { player->actor.child = &this->actor; - player->leftHandActor = &this->actor; + player->heldActor = &this->actor; if (this->actor.child != NULL) { player->actor.parent = this->actor.child = NULL; return 1; @@ -237,7 +237,7 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { Vec3f prevFrameDiff; Vec3f sp60; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Math_Vec3f_Diff(&this->actor.world.pos, &this->actor.prevPos, &prevFrameDiff); Math_Vec3f_Sum(&this->unk1E0, &prevFrameDiff, &this->unk1E0); this->actor.shape.rot.x = Math_FAtan2F(this->actor.speedXZ, -this->actor.velocity.y); diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index 14bfdce02e..2bea2f0ff5 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -162,7 +162,7 @@ void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx) { ArrowIce_LerpFiredPosition(&this->firedPos, &this->actor.world.pos, 0.05f); if (arrow->unk_261 & 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_EXPLOSION_ICE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_EXPLOSION_ICE); ArrowIce_SetupAction(this, ArrowIce_Hit); this->timer = 32; this->alpha = 255; diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c index 5b47f8e4ed..5ce8f18e96 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c @@ -123,7 +123,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { } } } - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WATERWHEEL_LEVEL); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WATERWHEEL_LEVEL); } } @@ -200,7 +200,7 @@ void BgCtowerGear_UpdateOrgan(Actor* thisx, GlobalContext* globalCtx) { // Using BgCtowerGear *this = THIS causes regalloc issues void BgCtowerGear_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_80AD32E8[BGCTOWERGEAR_GET_TYPE(thisx)]); + Gfx_DrawDListOpa(globalCtx, D_80AD32E8[BGCTOWERGEAR_GET_TYPE(thisx)]); } void BgCtowerGear_DrawOrgan(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c index 94868e0cd6..1686906238 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c @@ -67,7 +67,7 @@ void BgCtowerRot_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06017650); this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y - 0x4000; } - Actor_CalcOffsetOrientedToDrawRotation(&this->dyna.actor, &offset, &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); if (offset.z < 0.0f) { this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + (Math_SinS(this->dyna.actor.world.rot.y) * 80.0f); this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + (Math_CosS(this->dyna.actor.world.rot.y) * 80.0f); @@ -91,7 +91,7 @@ void BgCtowerRot_CorridorRotate(BgCtowerRot* this, GlobalContext* globalCtx) { f32 offsetDiffZ; f32 rotZtmp; - Actor_CalcOffsetOrientedToDrawRotation(&this->dyna.actor, &offset, &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); if (offset.z > 1100.0f) { rotZ = 0.0f; } else { @@ -114,7 +114,7 @@ void BgCtowerRot_DoorDoNothing(BgCtowerRot* this, GlobalContext* globalCtx) { void BgCtowerRot_DoorClose(BgCtowerRot* this, GlobalContext* globalCtx) { if (!Math_SmoothStepToF(&this->timer, 0.0f, 0.1f, 15.0f, 0.1f)) { if (this->dyna.actor.params == MAIN_DOOR) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); ActorCutscene_Stop(this->dyna.actor.cutscene); } this->actionFunc = BgCtowerRot_DoorDoNothing; @@ -131,7 +131,7 @@ void BgCtowerRot_DoorIdle(BgCtowerRot* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3f offset; - Actor_CalcOffsetOrientedToDrawRotation(&this->dyna.actor, &offset, &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); if (offset.z > 30.0f) { this->unk160 = 0.0f; ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); @@ -159,8 +159,8 @@ void BgCtowerRot_Update(Actor* thisx, GlobalContext* globalCtx) { void BgCtowerRot_Draw(Actor* thisx, GlobalContext* globalCtx) { BgCtowerRot* this = THIS; - func_800BDFC0(globalCtx, bgCtowerRotDlists[this->dyna.actor.params]); + Gfx_DrawDListOpa(globalCtx, bgCtowerRotDlists[this->dyna.actor.params]); if (this->dyna.actor.params == CORRIDOR) { - func_800BE03C(globalCtx, D_060129D0); + Gfx_DrawDListXlu(globalCtx, D_060129D0); } } diff --git a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c index 3d0f5c204b..389f80809a 100644 --- a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c +++ b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c @@ -95,8 +95,8 @@ void func_80B401F8(BgGoronOyu* this, GlobalContext* globalCtx) { if (dist.x >= 0.0f && dist.x <= this->waterBoxXLength && dist.z >= 0.0f && dist.z <= this->waterBoxZLength && fabsf(dist.y) < 100.0f && player->actor.depthInWater > 12.0f) { - func_800B8A1C(&this->dyna.actor, globalCtx, 0xBA, this->dyna.actor.xzDistToPlayer, - fabsf(this->dyna.actor.playerHeightRel)); + Actor_PickUp(&this->dyna.actor, globalCtx, 0xBA, this->dyna.actor.xzDistToPlayer, + fabsf(this->dyna.actor.playerHeightRel)); } } diff --git a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c index fceb27755e..87686f4c8e 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c +++ b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c @@ -53,7 +53,7 @@ void BgHakaCurtain_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 1); DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06001588); - if (Actor_GetRoomCleared(globalCtx, this->dyna.actor.room)) { + if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { func_80B6DE80(this); return; } @@ -71,7 +71,7 @@ void func_80B6DC98(BgHakaCurtain* this) { } void func_80B6DCAC(BgHakaCurtain* this, GlobalContext* globalCtx) { - if (Actor_GetRoomCleared(globalCtx, this->dyna.actor.room)) { + if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { func_80B6DCEC(this); } } @@ -137,5 +137,5 @@ void BgHakaCurtain_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgHakaCurtain_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06001410); + Gfx_DrawDListOpa(globalCtx, D_06001410); } diff --git a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c index 58ccf1cd91..a36055a3dc 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c +++ b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c @@ -84,11 +84,10 @@ s32 func_80BD6638(s16* arg0, s16* arg1, s32 arg2) { void func_80BD66AC(BgHakaTomb* this, GlobalContext* globalCtx) { s16 temp; - if (Actor_GetRoomCleared(globalCtx, this->dyna.actor.room)) { + if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { this->dyna.actor.flags |= 9; } - if (!func_80BD6638(&temp, this->cutscenes, 1) && (temp < 0) && - Actor_GetRoomCleared(globalCtx, this->dyna.actor.room)) { + if (!func_80BD6638(&temp, this->cutscenes, 1) && (temp < 0) && Flags_GetClear(globalCtx, this->dyna.actor.room)) { this->dyna.actor.flags |= 1; if (this->dyna.actor.isTargeted) { func_80BD6754(this); @@ -129,5 +128,5 @@ void BgHakaTomb_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgHakaTomb_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_060007B0); + Gfx_DrawDListOpa(globalCtx, D_060007B0); } 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 cf628cc952..0a3ef22ebc 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 @@ -187,7 +187,7 @@ void func_80A9B160(BgHakuginPostUnkStruct* unkStruct, GlobalContext* globalCtx) unkStruct->unk_0000[i].unk_24 = 0.0f; unkStruct->unk_0000[i].unk_34 = 1; if (D_80A9D880[unkStruct->unk_0000[i].unk_00].unk_04 != 0) { - Actor_UnsetSwitchFlag(globalCtx, unkStruct->unk_0000[i].unk_2E); + Flags_UnsetSwitch(globalCtx, unkStruct->unk_0000[i].unk_2E); } } } @@ -261,7 +261,7 @@ void func_80A9B3BC(BgHakuginPost* this, GlobalContext* globalCtx) { } if (!(sp20 | sp1C)) { - Actor_SetSwitchFlag(globalCtx, sp28); + Flags_SetSwitch(globalCtx, sp28); this->unk_170 = true; } else { this->unk_170 = sp20; @@ -290,9 +290,9 @@ void func_80A9B46C(BgHakuginPost* this, GlobalContext* globalCtx) { } if (!this->unk_170 && (sp28 == 1)) { - Actor_UnsetSwitchFlag(globalCtx, sp2C); + Flags_UnsetSwitch(globalCtx, sp2C); } else if (!this->unk_174 && (sp24 == 1)) { - Actor_UnsetSwitchFlag(globalCtx, sp30); + Flags_UnsetSwitch(globalCtx, sp30); } this->unk_170 = sp28; @@ -682,9 +682,9 @@ void func_80A9C854(BgHakuginPost* this, GlobalContext* globalCtx) { } if (sp38) { - Actor_SetSwitchFlag(globalCtx, this->dyna.actor.home.rot.x & 0x7F); + Flags_SetSwitch(globalCtx, this->dyna.actor.home.rot.x & 0x7F); } else { - Actor_UnsetSwitchFlag(globalCtx, this->dyna.actor.home.rot.x & 0x7F); + Flags_UnsetSwitch(globalCtx, this->dyna.actor.home.rot.x & 0x7F); } } @@ -840,9 +840,9 @@ void func_80A9CE1C(BgHakuginPost* this, GlobalContext* globalCtx) { temp = (s16)(this->dyna.actor.yawTowardsPlayer + 0x58F0); D_80A9E028.unk_0000[i].unk_28 = ((s16)(player->actor.shape.rot.y - temp) / 3) + temp; D_80A9E028.unk_0000[i].unk_34 = 2; - func_800B8E58(&player->actor, NA_SE_IT_HAMMER_HIT); + func_800B8E58(player, NA_SE_IT_HAMMER_HIT); func_8019F128(NA_SE_EV_SLIDE_DOOR_OPEN); - Actor_SetSwitchFlag(globalCtx, D_80A9E028.unk_0000[i].unk_2E); + Flags_SetSwitch(globalCtx, D_80A9E028.unk_0000[i].unk_2E); this->unk_178 = 20; func_80A9D2C4(this, func_80A9CE00, D_80A9E028.unk_0000[i].unk_14.y + 50.0f, D_80A9E028.unk_0000[i].unk_2A, D_80A9E028.unk_0000[i].unk_2C); diff --git a/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c b/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c index 653e125044..44f67c5bda 100644 --- a/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c +++ b/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c @@ -56,7 +56,7 @@ const ActorInit Bg_Icicle_InitVars = { static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), ICHAIN_F32(gravity, -3, ICHAIN_CONTINUE), - ICHAIN_F32(minVelocityY, -30, ICHAIN_CONTINUE), + ICHAIN_F32(terminalVelocity, -30, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; @@ -144,7 +144,7 @@ void BgIcicle_Shiver(BgIcicle* this, GlobalContext* globalCtx) { } if (!(this->shiverTimer % 4)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_ICE_SWING); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_ICE_SWING); } if (this->shiverTimer == 0) { @@ -184,7 +184,7 @@ void BgIcicle_Fall(BgIcicle* this, GlobalContext* globalCtx) { return; } } else { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->dyna.actor); + Actor_MoveWithGravity(&this->dyna.actor); this->dyna.actor.world.pos.y += 40.0f; Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); this->dyna.actor.world.pos.y -= 40.0f; @@ -245,5 +245,5 @@ void BgIcicle_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgIcicle_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_060000D0); + Gfx_DrawDListOpa(globalCtx, D_060000D0); } diff --git a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c index bc3ee78805..e96c20accb 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c @@ -119,5 +119,5 @@ void BgIkanaRay_Draw(Actor* thisx, GlobalContext* globalCtx) { BgIkanaRay* this = THIS; AnimatedMat_Draw(globalCtx, this->animatedTextures); - func_800BE03C(globalCtx, D_06001100); + Gfx_DrawDListXlu(globalCtx, D_06001100); } diff --git a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c index 503c09048a..70b58b4828 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c @@ -77,7 +77,7 @@ void BgIkanaShutter_Init(Actor* thisx, GlobalContext* globalCtx) { func_80BD5828(this); return; } - if (Actor_GetRoomCleared(globalCtx, this->dyna.actor.room)) { + if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { BgIkanaShutter_SetupDoNothing(this); return; } @@ -166,7 +166,7 @@ void func_80BD5AE8(BgIkanaShutter* this) { } void func_80BD5B04(BgIkanaShutter* this, GlobalContext* globalCtx) { - if (Actor_GetRoomClearedTemp(globalCtx, this->dyna.actor.room)) { + if (Flags_GetClearTemp(globalCtx, this->dyna.actor.room)) { func_80BD5B44(this); } } @@ -179,7 +179,7 @@ void func_80BD5B44(BgIkanaShutter* this) { void func_80BD5B60(BgIkanaShutter* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - Actor_SetRoomCleared(globalCtx, this->dyna.actor.room); + Flags_SetClear(globalCtx, this->dyna.actor.room); func_80BD5BC4(this); return; } @@ -213,5 +213,5 @@ void BgIkanaShutter_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgIkanaShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000CE8); + Gfx_DrawDListOpa(globalCtx, D_06000CE8); } diff --git a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c index 10454f2cb1..f4dca549b3 100644 --- a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c +++ b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c @@ -57,7 +57,7 @@ s32 func_80C0A740(BgIkninSusceil* this, GlobalContext* globalCtx) { Vec3f offset; Player* player = GET_PLAYER(globalCtx); - Actor_CalcOffsetOrientedToDrawRotation(&this->dyna.actor, &offset, &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); return (D_80C0B0E8.x < offset.z) && (offset.z < D_80C0B0E8.y) && (offset.x > -240.0f) && (offset.x < D_80C0B0E4); } @@ -94,7 +94,7 @@ s32 func_80C0A95C(BgIkninSusceil* this, GlobalContext* globalCtx) { Vec3f offset; f32 temp1, temp2, temp3, temp4; - Actor_CalcOffsetOrientedToDrawRotation(&this->dyna.actor, &offset, &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); for (i = 0; i < 7; i++) { temp3 = (D_80C0B0F0[i] * 80.0f) + 0.5f; temp4 = (D_80C0B0F0[i] * 80.0f) + 79.5f; @@ -155,8 +155,8 @@ void func_80C0ABA8(BgIkninSusceil* this, GlobalContext* globalCtx) { this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; if (this->dyna.actor.world.pos.y <= this->dyna.actor.home.pos.y) { func_80C0A86C(this, globalCtx, 4, 14, 1); - Actor_UnsetSwitchFlag(globalCtx, GET_SUSCEIL_SWITCHFLAG(this)); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND); + Flags_UnsetSwitch(globalCtx, GET_SUSCEIL_SWITCHFLAG(this)); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND); func_80C0AC74(this); } else { func_800B9010(&this->dyna.actor, NA_SE_EV_ICE_PILLAR_FALL - SFX_FLAG); @@ -229,7 +229,7 @@ void BgIkninSusceil_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->unk168 == 0) && (this->unk166 > 0) && (player->stateFlags3 & 0x100) && (player->unk_B48 > 1000.0f)) { this->unk168 = 2; if ((func_80C0A95C(this, globalCtx) != 0) && (this->actionFunc != func_80C0AE5C)) { - func_800B8E58(&player->actor, NA_SE_PL_BODY_HIT); + func_800B8E58(player, NA_SE_PL_BODY_HIT); func_80C0AE3C(this); } } @@ -260,5 +260,5 @@ void BgIkninSusceil_Draw(Actor* thisx, GlobalContext* globalCtx) { BgIkninSusceil* this = THIS; AnimatedMat_Draw(globalCtx, this->animatedTexture); - func_800BDFC0(globalCtx, D_0600C308); + Gfx_DrawDListOpa(globalCtx, D_0600C308); } diff --git a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c index 3bf7bf9889..53a0b5ea29 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c @@ -90,7 +90,7 @@ void BgIknvObj_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->dyna.actor, &this->collider); this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; gSaveContext.weekEventReg[51] &= (u8)~0x10; - Actor_SetHeight(&this->dyna.actor, IREG(88)); + Actor_SetFocus(&this->dyna.actor, IREG(88)); break; default: Actor_MarkForDeath(&this->dyna.actor); @@ -154,7 +154,7 @@ s32 func_80BD7E0C(BgIknvObj* this, s16 targetRotation, GlobalContext* globalCtx) func_800B9010(&this->dyna.actor, NA_SE_EV_STONEDOOR_OPEN_S - SFX_FLAG); return false; } - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); return true; } diff --git a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c index c75db53063..61e6845631 100644 --- a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c +++ b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c @@ -71,11 +71,11 @@ void BgInibsMovebg_Draw(Actor* thisx, GlobalContext* globalCtx) { dl1 = this->unk_15C; if (dl1 != NULL) { - func_800BDFC0(globalCtx, this->unk_15C); + Gfx_DrawDListOpa(globalCtx, this->unk_15C); } dl2 = this->unk_160; if (dl2 != NULL) { - func_800BE03C(globalCtx, this->unk_160); + Gfx_DrawDListXlu(globalCtx, this->unk_160); } } diff --git a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c index ac56722384..d526c458ba 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c @@ -228,7 +228,7 @@ void BgKin2Fence_SetupPlayOpenCutscene(BgKin2Fence* this) { void BgKin2Fence_PlayOpenCutscene(BgKin2Fence* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - Actor_SetSwitchFlag(globalCtx, this->dyna.actor.params & 0x7F); + Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x7F); BgKin2Fence_SetupWaitBeforeOpen(this); return; } @@ -272,5 +272,5 @@ void BgKin2Fence_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgKin2Fence_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000828); + Gfx_DrawDListOpa(globalCtx, D_06000828); } diff --git a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c index c646c3e6cb..e9326d8cd7 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c @@ -55,7 +55,7 @@ static ColliderTrisInit D_80B6FA08 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_80B6FA24[] = { ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), diff --git a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c index 0acccbc56a..070d8776b2 100644 --- a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c +++ b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c @@ -110,7 +110,7 @@ void BgLadder_ActionStartCutscene(BgLadder* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); this->dyna.actor.draw = BgLadder_Draw; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_SECRET_LADDER_APPEAR); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SECRET_LADDER_APPEAR); this->action = BgLadder_ActionFadeIn; } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); diff --git a/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c b/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c index c07f419f9e..11132cf64e 100644 --- a/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c +++ b/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c @@ -47,5 +47,5 @@ void BgLbfshot_Destroy(Actor* thisx, GlobalContext* globalCtx) { DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void BgLbfshot_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000228); + Gfx_DrawDListOpa(globalCtx, D_06000228); } diff --git a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c index 7499e35cde..e8a2d0b4cc 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -173,5 +173,5 @@ void BgLotus_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgLotus_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000040); + Gfx_DrawDListOpa(globalCtx, D_06000040); } diff --git a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c index b5f8e9c49c..e9a365c91d 100644 --- a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c +++ b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c @@ -41,6 +41,6 @@ void BgMarketStep_Init(Actor* thisx, GlobalContext* globalCtx) { void BgMarketStep_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 index = thisx->params & 1; - func_800BDFC0(globalCtx, D_80AF0120[index]); - func_800BDFC0(globalCtx, D_80AF0128[index]); + Gfx_DrawDListOpa(globalCtx, D_80AF0120[index]); + Gfx_DrawDListOpa(globalCtx, D_80AF0128[index]); } diff --git a/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c b/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c index c805de05c9..8a31c536bc 100644 --- a/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c +++ b/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.c @@ -55,5 +55,5 @@ void BgMbarChair_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgMbarChair_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000288); + Gfx_DrawDListOpa(globalCtx, D_06000288); } diff --git a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c index 69ba3e6529..38ce543ccf 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c @@ -65,7 +65,7 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { if (this->timer != prevTimer) { if (1) {} - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_STONEDOOR_OPEN_S - SFX_FLAG); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_OPEN_S - SFX_FLAG); this->dyna.actor.world.pos.y = (this->yOffset = (this->timer * (5.0f / 3.0f)) + this->dyna.actor.home.pos.y); this->timer2 = 180; } diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index f0455bb05f..2d404126de 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -740,8 +740,8 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->actor.speedXZ = this->unk_01A8 * D_809DF5B0; } - Actor_SetVelocityXYRotation(&this->actor); - Actor_ApplyMovement(&this->actor); + Actor_UpdateVelocityWithoutGravity(&this->actor); + Actor_UpdatePos(&this->actor); spD0 = this->actor.world.pos; if (D_809E0422 != 0) { @@ -756,7 +756,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->unk_0170 = this->unk_017C; this->unk_0170.y = temp_f0; this->unk_016C = 120; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); } this->actor.flags &= ~1; @@ -965,7 +965,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { D_809E042C->unk_1D5C = 0.0f; play_sound(NA_SE_EN_INBOSS_DEAD_PRE2_OLD); } else if (!(this->unk_0146[1] & 0xF) && (Rand_ZeroOne() < 0.5f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); } return; @@ -987,7 +987,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->unk_0144 = 22; this->actor.gravity = -1.0f * D_809DF5B0; this->actor.velocity.y = 0.0f; - this->actor.minVelocityY = -1000.0f * D_809DF5B0; + this->actor.terminalVelocity = -1000.0f * D_809DF5B0; this->unk_0164 = randPlusMinusPoint5Scaled(0.05f); spCC = player->actor.world.pos.x - this->actor.world.pos.x; @@ -1006,7 +1006,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DEAD_OLD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_DEAD_OLD); } } return; @@ -1017,7 +1017,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&this->unk_01BC[i], &this->actor.world.pos); this->unk_0B1C[i].y += this->unk_0164; Math_ApproachF(&this->unk_0B1C[i].x, -(M_PI / 2), 0.1f, 0.07f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 4); if (this->actor.bgCheckFlags & 1) { @@ -1100,7 +1100,7 @@ void func_809DBFB4(Boss02* this, GlobalContext* globalCtx) { this->unk_0156 = 15; if (i == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); this->unk_015C = 1; } else { func_8019F1C0(&this->unk_167C, NA_SE_EN_INBOSS_DAMAGE_OLD); @@ -1227,9 +1227,9 @@ void Boss02_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_016C != 0) { if ((this->unk_016C == 60) && (this->unk_0144 < 20)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_SAND_OLD - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_SAND_OLD - SFX_FLAG); if (this->unk_0144 > 20) { sp3C.x = randPlusMinusPoint5Scaled(100.0f * D_809DF5B0) + this->unk_0170.x; @@ -1959,7 +1959,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { player->actor.home.pos = player->actor.world.pos; player->actor.prevPos = player->actor.world.pos; - temp_a0_5 = globalCtx->actorCtx.actorList[ACTORCAT_BG].first; + temp_a0_5 = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; while (temp_a0_5 != NULL) { if (temp_a0_5->id == ACTOR_BG_INIBS_MOVEBG) { Actor_MarkForDeath(temp_a0_5); @@ -1971,7 +1971,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_INIBS_MOVEBG, 0, D_809E0422 ? 3150.0f : 0.0f, 0, 0, 0, 0, D_809E0422); - temp_a0_5 = globalCtx->actorCtx.actorList[ACTORCAT_BOSS].first; + temp_a0_5 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; while (temp_a0_5 != NULL) { if ((temp_a0_5->id == ACTOR_EN_TANRON5) || (temp_a0_5->id == ACTOR_ITEM_B_HEART)) { if (D_809E0422 == 0) { @@ -2002,7 +2002,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { temp_a0_5->velocity.z *= phi_f0_2; temp_a0_5->gravity *= phi_f0_2; - temp_a0_5->minVelocityY *= phi_f0_2; + temp_a0_5->terminalVelocity *= phi_f0_2; temp_a0_5->scale.x *= phi_f0_2; temp_a0_5->scale.y *= phi_f0_2; @@ -2109,11 +2109,11 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { player->actor.shape.rot.y = -0x8000; player->actor.world.rot.y = player->actor.shape.rot.y; this->unk_1D24.x = player->actor.world.pos.x - 20.0f; - this->unk_1D24.y = (func_800B6FC8(player) + player->actor.world.pos.y) - 29.0f; + this->unk_1D24.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 29.0f; this->unk_1D24.z = player->actor.world.pos.z - 50; this->unk_1D30.x = player->actor.world.pos.x; - this->unk_1D30.y = (func_800B6FC8(player) + player->actor.world.pos.y) - 17.0f; + this->unk_1D30.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 17.0f; this->unk_1D30.z = player->actor.world.pos.z; if (this->unk_1D1C >= 30) { if (this->unk_1D1C == 30) { @@ -2177,8 +2177,8 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { } if (this->unk_1D1C == (u32)(KREG(92) + 125)) { - Actor_TitleCardCreate(globalCtx, &globalCtx->actorCtx.titleCtxt, Lib_SegmentedToVirtual(&D_06008650), - 160, 180, 128, 40); + TitleCard_InitBossName(&globalCtx->state, &globalCtx->actorCtx.titleCtxt, + Lib_SegmentedToVirtual(&D_06008650), 160, 180, 128, 40); } if (this->unk_1D1C == (u32)(BREG(27) + 335)) { diff --git a/src/overlays/actors/ovl_Boss_04/z_boss_04.c b/src/overlays/actors/ovl_Boss_04/z_boss_04.c index 3e3ca12c17..6e3fa14e3c 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -5,6 +5,7 @@ */ #include "z_boss_04.h" +#include "objects/object_boss04/object_boss04.h" #define FLAGS 0x00000035 @@ -15,14 +16,18 @@ void Boss04_Destroy(Actor* thisx, GlobalContext* globalCtx); void Boss04_Update(Actor* thisx, GlobalContext* globalCtx); void Boss04_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_809EC544(Boss04* this); void func_809EC568(Boss04* this, GlobalContext* globalCtx); +void func_809ECD00(Boss04* this, GlobalContext* globalCtx); void func_809ECD18(Boss04* this, GlobalContext* globalCtx); +void func_809ECEF4(Boss04* this); void func_809ECF58(Boss04* this, GlobalContext* globalCtx); +void func_809ED224(Boss04* this); void func_809ED2A0(Boss04* this, GlobalContext* globalCtx); -#if 0 -// static DamageTable sDamageTable = { -static DamageTable D_809EE150 = { +static u8 D_809EE4D0; + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0xF), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -69,75 +74,777 @@ const ActorInit Boss_04_InitVars = { (ActorFunc)Boss04_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_809EE190[1] = { +static ColliderJntSphElementInit sJntSphElementsInit1[1] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809EE1B4 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809EE190, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit1 = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit1, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_809EE1C4[1] = { +static ColliderJntSphElementInit sJntSphElementsInit2[1] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 70 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809EE1E8 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809EE1C4, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit2 = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit2, }; -#endif +void func_809EC040(s32 index, ColliderJntSph* collider, Vec3f* arg2) { + collider->elements[index].dim.worldSphere.center.x = arg2->x; + collider->elements[index].dim.worldSphere.center.y = arg2->y; + collider->elements[index].dim.worldSphere.center.z = arg2->z; + collider->elements[index].dim.worldSphere.radius = + collider->elements[index].dim.modelSphere.radius * collider->elements[index].dim.scale; +} -extern DamageTable D_809EE150; -extern ColliderJntSphElementInit D_809EE190[1]; -extern ColliderJntSphInit D_809EE1B4; -extern ColliderJntSphElementInit D_809EE1C4[1]; -extern ColliderJntSphInit D_809EE1E8; +void Boss04_Init(Actor* thisx, GlobalContext* globalCtx2) { + static Vec3f D_809EE1F8[] = { + { -1000.0f, 0.0f, 0.0f }, + { 1000.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, -1000.0f }, + { 0.0f, 0.0f, 1000.0f }, + }; + GlobalContext* globalCtx = globalCtx2; + Boss04* this = THIS; + s32 i; + CollisionPoly* spC0; + Vec3f spB4; + Vec3f spA8; + s32 spA4; + f32 phi_f20; + f32 phi_f24; + Vec3f sp90; + s16 phi_s0_2; + s32 pad; -extern UNK_TYPE D_0600004C; -extern UNK_TYPE D_06004510; + if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809EC040.s") + this->actor.params = 0x64; + Actor_SetScale(&this->actor, 0.1f); + this->actor.targetMode = 5; + this->actor.hintId = 0x19; + this->actor.colChkInfo.health = 20; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->unk_700 = 1.0f; + this->unk_6FC = 1.0f; + this->unk_6F8 = 1.0f; + Collider_InitAndSetJntSph(globalCtx, &this->collider1, &this->actor, &sJntSphInit1, this->collider1Elements); + Collider_InitAndSetJntSph(globalCtx, &this->collider2, &this->actor, &sJntSphInit2, this->collider2Elements); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_boss04_Skel_0045E8, &object_boss04_Anim_00004C, + this->jointTable, this->morphtable, 9); + spA8.y = this->actor.world.pos.y + 200.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/Boss04_Init.s") + for (i = 0; i < ARRAY_COUNT(D_809EE1F8); i++) { + spA8.x = D_809EE1F8[i].x + this->actor.world.pos.x; + spA8.z = D_809EE1F8[i].z + this->actor.world.pos.z; + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &spA8, &spB4, &spC0, 1, 0, 0, 1, + &spA4)) { + if (i == 0) { + this->unk_6D8 = spB4.x; + } else if (i == 1) { + this->unk_6DC = spB4.x; + } else if (i == 2) { + this->unk_6E0 = spB4.z; + } else if (i == 3) { + this->unk_6E4 = spB4.z; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/Boss04_Destroy.s") + this->unk_6E8 = this->unk_6D8 + ((this->unk_6DC - this->unk_6D8) * 0.5f); + this->unk_6F0 = this->unk_6E0 + ((this->unk_6E4 - this->unk_6E0) * 0.5f); + this->actor.world.pos.x = this->unk_6E8; + this->actor.world.pos.z = this->unk_6F0; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 35.0f, 60.0f, 60.0f, 4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809EC544.s") + if ((KREG(64) != 0) || (gSaveContext.eventInf[6] & 1)) { + func_809ECD00(this, globalCtx); + this->actor.world.pos.y = this->actor.floorHeight + 160.0f; + phi_f24 = this->actor.floorHeight; + D_809EE4D0 = KREG(41) + 50; + } else { + func_809EC544(this); + this->actor.world.pos.y = KREG(70) + (this->actor.floorHeight + 590.0f); + phi_f24 = KREG(71) + (this->actor.floorHeight + 550.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809EC568.s") + phi_f20 = 110.0f; + this->unk_6F6 = 82; + phi_s0_2 = 0; + for (i = 0; i < 82; i++) { + Matrix_RotateY(phi_s0_2, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(phi_f20, &sp90); + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON2, this->unk_6E8 + sp90.x, + phi_f24, this->unk_6F0 + sp90.z, 0, 0, 0, i); + phi_f20 += 2.5f; + phi_s0_2 += 0x1300; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ECD00.s") + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON2, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 100); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ECD18.s") +void Boss04_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ECEF4.s") +void func_809EC544(Boss04* this) { + this->actionFunc = func_809EC568; + this->actor.flags &= ~1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ECF58.s") +void func_809EC568(Boss04* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 x; + f32 y; + f32 z; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ED224.s") + this->unk_704++; + this->unk_1FE = 15; + if ((this->unk_708 != 0) && (this->unk_708 < 10)) { + this->actor.world.pos.y = (Math_SinS(this->unk_1F4 * 512) * 10.0f) + (this->actor.floorHeight + 160.0f); + Matrix_RotateY(this->actor.yawTowardsPlayer, MTXMODE_NEW); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ED2A0.s") + switch (this->unk_708) { + case 0: + this->unk_2C8 = 50; + this->unk_2D0 = 2000.0f; + if ((player->stateFlags1 & 0x100000) && (this->actor.projectedPos.z > 0.0f) && + (fabsf(this->actor.projectedPos.x) < 300.0f) && (fabsf(this->actor.projectedPos.y) < 300.0f)) { + if ((this->unk_704 >= 15) && (ActorCutscene_GetCurrentIndex() == -1)) { + Actor* boss; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ED45C.s") + this->unk_708 = 10; + this->unk_704 = 0; + func_800EA0D4(globalCtx, &globalCtx->csCtx); + this->unk_70A = func_801694DC(globalCtx); + func_80169590(globalCtx, 0, 1); + func_80169590(globalCtx, this->unk_70A, 7); + func_800B7298(globalCtx, &this->actor, 7); + player->actor.world.pos.x = this->unk_6E8; + player->actor.world.pos.z = this->unk_6F0 + 410.0f; + player->actor.shape.rot.y = 0x7FFF; + player->actor.world.rot.y = player->actor.shape.rot.y; + Math_Vec3f_Copy(&this->unk_70C, &player->actor.world.pos); + this->unk_70C.y += 100.0f; + Math_Vec3f_Copy(&this->unk_718, &this->actor.world.pos); + func_8016566C(150); + this->unk_744 = 60.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809ED50C.s") + boss = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + while (boss != NULL) { + if (boss->id == ACTOR_EN_WATER_EFFECT) { + Actor_MarkForDeath(boss); + } + boss = boss->next; + } + } + } else { + this->unk_704 = 0; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/Boss04_Update.s") + case 10: + if (this->unk_704 == 3) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEMO_EYE); + this->unk_74A = 1; + } + this->unk_2D0 = 10000.0f; + this->unk_2C8 = 300; + Math_ApproachF(&this->unk_744, 20.0f, 0.3f, 11.0f); + if (this->unk_704 == 40) { + this->unk_708 = 11; + this->unk_704 = 0; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809EDCCC.s") + case 11: + if (this->unk_704 > 50) { + this->unk_708 = 12; + this->unk_704 = 0; + this->actor.gravity = -3.0f; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/func_809EDECC.s") + case 13: + if (this->unk_704 == 45) { + this->unk_708 = 1; + this->unk_704 = 0; + func_800B7298(globalCtx, &this->actor, 0x15); + this->actor.gravity = 0.0f; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_04/Boss04_Draw.s") + case 12: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_ATTACK - SFX_FLAG); + Math_ApproachF(&this->unk_718.x, this->actor.world.pos.x, 0.5f, 1000.0f); + Math_ApproachF(&this->unk_718.y, this->actor.world.pos.y, 0.5f, 1000.0f); + Math_ApproachF(&this->unk_718.z, this->actor.world.pos.z, 0.5f, 1000.0f); + if (this->actor.bgCheckFlags & 2) { + play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); + this->unk_6F4 = 15; + this->unk_708 = 13; + this->unk_704 = 0; + this->unk_2DA = 10; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_SPLASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); + this->unk_748 = 20; + } + break; + + case 1: + player->actor.shape.rot.y = 0x7FFF; + player->actor.world.rot.y = player->actor.shape.rot.y; + Matrix_GetStateTranslationAndScaledZ(-100.0f, &this->unk_70C); + + this->unk_70C.x += player->actor.world.pos.x; + this->unk_70C.y = Player_GetHeight(player) + player->actor.world.pos.y + 36.0f; + this->unk_70C.z += player->actor.world.pos.z; + + this->unk_718.x = player->actor.world.pos.x; + this->unk_718.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 4.0f; + this->unk_718.z = player->actor.world.pos.z; + + if (this->unk_704 >= 35) { + this->unk_704 = 0; + this->unk_708 = 2; + this->unk_728 = -200.0f; + } + break; + + case 2: + case 3: + Matrix_GetStateTranslationAndScaledZ(500.0f, &this->unk_70C); + this->unk_70C.x += this->actor.world.pos.x; + this->unk_70C.y += this->actor.world.pos.y - 50.0f; + this->unk_70C.z += this->actor.world.pos.z; + this->unk_718.x = this->actor.world.pos.x; + this->unk_718.z = this->actor.world.pos.z; + this->unk_718.y = (this->actor.world.pos.y - 70.0f) + this->unk_728; + Math_ApproachZeroF(&this->unk_728, 0.05f, this->unk_73C); + Math_ApproachF(&this->unk_73C, 3.0f, 1.0f, 0.05f); + if (this->unk_704 == 20) { + this->unk_708 = 3; + } + + if (this->unk_704 == 70) { + this->unk_2C8 = 300; + this->unk_2D0 = 0.0f; + D_809EE4D0 = 1; + this->unk_2E2 = 60; + this->unk_2E0 = 93; + } + + if (this->unk_704 > 140) { + Camera* sp5C = Play_GetCamera(globalCtx, MAIN_CAM); + + this->unk_708 = 0; + func_809ECD00(this, globalCtx); + sp5C->eye = this->unk_70C; + sp5C->eyeNext = this->unk_70C; + sp5C->at = this->unk_718; + func_80169AFC(globalCtx, this->unk_70A, 0); + this->unk_70A = 0; + func_800EA0EC(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + func_80165690(); + gSaveContext.eventInf[6] |= 1; + } + break; + } + + if (this->unk_70A != 0) { + Vec3f sp50; + + ShrinkWindow_SetLetterboxTarget(0x1B); + if (this->unk_748 != 0) { + this->unk_748--; + } + Math_Vec3f_Copy(&sp50, &this->unk_718); + sp50.y += Math_SinS(this->unk_748 * 0x4000) * this->unk_748 * 1.5f; + Play_CameraSetAtEye(globalCtx, this->unk_70A, &sp50, &this->unk_70C); + func_80169940(globalCtx, this->unk_70A, this->unk_744); + Math_ApproachF(&this->unk_744, 60.0f, 0.1f, 1.0f); + } + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + x = player->actor.world.pos.x - this->actor.world.pos.x; + y = player->actor.world.pos.y - this->actor.world.pos.y; + z = player->actor.world.pos.z - this->actor.world.pos.z; + this->actor.shape.rot.x = Math_Atan2S(-y, sqrtf(SQ(x) + SQ(z))); +} + +void func_809ECD00(Boss04* this, GlobalContext* globalCtx) { + this->actionFunc = func_809ECD18; +} + +void func_809ECD18(Boss04* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_1F4 >= 0x500) { + this->unk_1F4 -= 0x300; + this->unk_1F7 += 1; + } + + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 10, 0x200); + this->actor.world.pos.y = (this->actor.floorHeight + KREG(17) + 160.0f) + (Math_SinS(this->unk_1F4 * 512) * 10.0f); + Math_ApproachF(&this->actor.speedXZ, this->unk_6D4, 1.0f, 0.5f); + + if (this->unk_1F8 == 0) { + this->unk_1F8 = Rand_ZeroFloat(100.0f) + 50.0f; + this->unk_6D4 = Rand_ZeroFloat(3.0f); + if (Rand_ZeroOne() < 0.1f) { + Math_Vec3f_Copy(&this->unk_6C8, &player->actor.world.pos); + } else { + this->unk_6C8.x = randPlusMinusPoint5Scaled(600.0f) + this->unk_6E8; + this->unk_6C8.z = randPlusMinusPoint5Scaled(600.0f) + this->unk_6F0; + } + } + + Math_ApproachS(&this->actor.world.rot.y, + Math_Atan2S(this->unk_6C8.x - this->actor.world.pos.x, this->unk_6C8.z - this->actor.world.pos.z), 5, + 0x200); + + if (((s8)this->actor.colChkInfo.health <= 10) || (KREG(88) != 0)) { + KREG(88) = 0; + func_809ECEF4(this); + } +} + +void func_809ECEF4(Boss04* this) { + this->actionFunc = func_809ECF58; + Math_Vec3s_Copy(&this->actor.world.rot, &this->actor.shape.rot); + this->unk_1F8 = 0; + this->unk_1F6 = 1; + this->unk_1FA = 60; + this->actor.speedXZ = 0.0f; + this->actor.gravity = -3.0f; +} + +void func_809ECF58(Boss04* this, GlobalContext* globalCtx) { + Vec3f sp3C; + + if ((this->unk_1FE == 14) || ((this->actor.bgCheckFlags & 8) && (this->unk_1F8 == 0))) { + this->unk_1F8 = 20; + if ((Rand_ZeroOne() < 0.2f) && (this->unk_1FE == 0)) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->unk_2D0 = 10000.0f; + this->unk_2C8 = 100; + } else { + this->actor.world.rot.y = BINANG_ROT180((s16)Rand_ZeroFloat(8000.0f) + this->actor.world.rot.y); + } + + this->actor.speedXZ = 0.0f; + + if (this->actor.bgCheckFlags & 8) { + play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); + func_800BC848(&this->actor, globalCtx, 15, 10); + this->unk_6F4 = 15; + sp3C.x = this->actor.focus.pos.x; + sp3C.y = this->actor.focus.pos.y; + sp3C.z = this->actor.focus.pos.z; + func_800BBFB0(globalCtx, &sp3C, 100.0f, 40, 500, 10, 0); + } + } + + Math_ApproachS(&this->actor.shape.rot.x, Math_SinS(this->unk_1F4 * 0xFB8) * 5000.0f, 5, 0x800); + Math_ApproachS(&this->actor.shape.rot.z, Math_SinS(this->unk_1F4 * 0xCD0) * 3000.0f, 5, 0x800); + + if (this->unk_6F4 == 0) { + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 5, 0x1000); + if (this->unk_1FA == 0) { + Math_ApproachF(&this->actor.speedXZ, 20.0f, 1.0f, 1.0f); + sp3C.x = this->actor.world.pos.x; + sp3C.y = this->actor.floorHeight + 2.0f; + sp3C.z = this->actor.world.pos.z; + EffectSsGRipple_Spawn(globalCtx, &sp3C, 1400, 500, 0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_ATTACK - SFX_FLAG); + } + } + + if (KREG(88) != 0) { + KREG(88) = 0; + func_809ED224(this); + this->unk_1FE = 100; + this->unk_200 = 100; + } +} + +void func_809ED224(Boss04* this) { + this->actionFunc = func_809ED2A0; + this->unk_1F8 = 60; + this->unk_1FA = 100; + this->actor.speedXZ = 0.0f; + this->unk_2D0 = 10000.0f; + this->unk_2C8 = 200; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_DEAD); + this->actor.flags &= ~1; + func_801A2ED8(); + this->unk_1F6 = 10; +} + +void func_809ED2A0(Boss04* this, GlobalContext* globalCtx) { + this->unk_2DA = 10; + + if (this->unk_1F8 >= 5) { + this->unk_6FC = (Math_SinS(this->unk_1F8 * 0x3000) * 10.0f * 0.01f) + 1.0f; + this->unk_700 = (Math_CosS(this->unk_1F8 * 0x3000) * 10.0f * 0.01f) + 1.0f; + this->unk_6F8 = this->unk_700; + } + + if (this->unk_1F8 == 5) { + this->unk_6F8 *= 1.3f; + this->unk_6FC *= 1.3f; + this->unk_700 *= 1.3f; + } + + if (this->unk_1F8 == 3) { + this->actor.flags &= ~1; + this->unk_700 = 0.0f; + this->unk_6FC = 0.0f; + this->unk_6F8 = 0.0f; + } + + if ((this->unk_1F8 == 2) || (this->unk_1F8 == 5)) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_EXPLOSION); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_IT_BIG_BOMB_EXPLOSION); + } + + if (this->unk_1FA == 3) { + this->unk_1F6 = 11; + } + + if (this->unk_1FA == 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_809ED45C(Boss04* this, GlobalContext* globalCtx) { + ColliderJntSphElement* temp_v0; + u8 damage; + + if ((this->unk_1FE == 0) && (this->collider1.elements[0].info.bumperFlags & BUMP_HIT)) { + this->collider1.elements[0].info.bumperFlags &= ~BUMP_HIT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_DAMAGE); + damage = this->actor.colChkInfo.damage; + this->actor.colChkInfo.health = this->actor.colChkInfo.health - damage; + if ((s8)this->actor.colChkInfo.health <= 0) { + func_809ED224(this); + this->unk_1FE = 100; + this->unk_200 = 100; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } else { + this->unk_2DA = 15; + this->unk_1FE = 15; + this->unk_200 = 15; + } + } +} + +void func_809ED50C(Boss04* this) { + s32 i; + + this->unk_2DE += this->unk_2E2; + this->unk_2DC += this->unk_2E0; + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 10.0f, MTXMODE_APPLY); + Matrix_GetStateTranslation(&this->unk_6BC); + Matrix_Scale(this->actor.scale.x * 13.0f, this->actor.scale.y * 13.0f, this->actor.scale.z * 16.0f, MTXMODE_APPLY); + Matrix_RotateY(this->unk_2DC, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_2DE, MTXMODE_APPLY); + Matrix_StatePush(); + + for (i = 0; i < ARRAY_COUNT(this->unk_2E4); i++) { + Matrix_RotateStateAroundXAxis(0.3926991f); + Matrix_GetStateTranslationAndScaledZ(100.0f, &this->unk_2E4[i]); + } + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(38.0f, 0.0f, 0.0f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(this->unk_3A4); i++) { + Matrix_RotateStateAroundXAxis(0.41887903f); + Matrix_GetStateTranslationAndScaledZ(92.0f, &this->unk_3A4[i]); + } + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(-38.0f, 0.0f, 0.0f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(this->unk_458); i++) { + Matrix_RotateStateAroundXAxis(0.41887903f); + Matrix_GetStateTranslationAndScaledZ(92.0f, &this->unk_458[i]); + } + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(71.0f, 0.0f, 0.0f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(this->unk_50C); i++) { + Matrix_RotateStateAroundXAxis(0.5711987f); + Matrix_GetStateTranslationAndScaledZ(71.0f, &this->unk_50C[i]); + } + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(-71.0f, 0.0f, 0.0f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(this->unk_590); i++) { + Matrix_RotateStateAroundXAxis(0.5711987f); + Matrix_GetStateTranslationAndScaledZ(71.0f, &this->unk_590[i]); + } + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(92.0f, 0.0f, 0.0f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(this->unk_614); i++) { + Matrix_RotateStateAroundXAxis(1.0471976f); + Matrix_GetStateTranslationAndScaledZ(38.0f, &this->unk_614[i]); + } + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(-92.0f, 0.0f, 0.0f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(this->unk_65C); i++) { + Matrix_RotateStateAroundXAxis(1.0471976f); + Matrix_GetStateTranslationAndScaledZ(38.0f, &this->unk_65C[i]); + } + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(100.0f, 0.0f, 0.0f, MTXMODE_APPLY); + + Matrix_GetStateTranslation(&this->unk_6A4); + Matrix_StatePop(); + Matrix_InsertTranslation(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_GetStateTranslation(&this->unk_6B0); +} + +void Boss04_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + Boss04* this = THIS; + s16 temp_v0_8; + s32 pad; + + this->unk_1F4++; + if (KREG(63) == 0) { + if (this->unk_1F8 != 0) { + this->unk_1F8--; + } + + if (this->unk_1FA != 0) { + this->unk_1FA--; + } + + if (this->unk_2C8 != 0) { + this->unk_2C8--; + } + if (this->unk_1FE != 0) { + this->unk_1FE--; + } + + if (this->unk_200 != 0) { + this->unk_200--; + } + + if (this->unk_2DA != 0) { + this->unk_2DA--; + } + + if (this->unk_6F4 != 0) { + this->unk_6F4--; + } + + this->actionFunc(this, globalCtx); + + Actor_MoveWithGravity(&this->actor); + this->actor.world.pos.y -= 100.0f; + this->actor.prevPos.y -= 100.0f; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 100.0f, 120.0f, 200.0f, 5); + this->actor.world.pos.y += 100.0f; + this->actor.prevPos.y += 100.0f; + } + + if (this->unk_200 == 10) { + this->unk_2D0 = 0.0f; + this->unk_2C8 = Rand_ZeroFloat(100.0f) + 60.0f; + } + + if (this->unk_2C8 == 0) { + this->unk_2C8 = Rand_ZeroFloat(100.0f) + 60.0f; + this->unk_2D0 = 10000.0f - this->unk_2D0; + } + + Math_ApproachF(&this->unk_2CC, this->unk_2D0, 0.2f, 1000.0f); + if (this->actionFunc != func_809ED2A0) { + temp_v0_8 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if (ABS_ALT(temp_v0_8) < 0x6000) { + if (temp_v0_8 > 0x2500) { + this->unk_2D6 = 0x2500; + } else if (temp_v0_8 < -0x2500) { + this->unk_2D6 = -0x2500; + } else { + this->unk_2D6 = temp_v0_8; + } + } else { + this->unk_2D6 = 0; + } + Math_ApproachS(&this->unk_2D4, this->unk_2D6, 5, 0x800); + this->unk_2D8 = 2000; + this->unk_700 = (Math_SinS(this->unk_6F4 * 0x3000) * this->unk_6F4 * 0.02f) + 1.0f; + this->unk_6FC = (Math_CosS(this->unk_6F4 * 0x3000) * this->unk_6F4 * 0.02f) + 1.0f; + this->unk_6F8 = this->unk_6FC; + this->actor.shape.yOffset = (this->unk_6FC - 1.0f) * 1000.0f; + func_809ED45C(this, globalCtx); + if (this->unk_2CC > 3000.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + this->actor.flags |= 1; + } else { + this->actor.flags &= ~1; + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + func_809ED50C(this); + } + + if (D_809EE4D0 != 0) { + D_809EE4D0--; + if (D_809EE4D0 == 0) { + func_801A2E54(0x38); + } + } + + if (this->unk_74A != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_EXIST - SFX_FLAG); + } +} + +s32 Boss04_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + Boss04* this = THIS; + + if (limbIndex == KREG(32)) { + if (!(this->unk_1F4 & 3)) { + *dList = NULL; + } + rot->x += KREG(33) * 256; + rot->y += KREG(34) * 256; + rot->z += KREG(35) * 256; + } + + if ((limbIndex == 5) || (limbIndex == 7)) { + rot->y = (rot->y + (s16)this->unk_2CC) - 0x500; + } + + if (limbIndex == 4) { + rot->y += this->unk_2D8; + rot->z += this->unk_2D4; + if (this->unk_2DA != 0) { + rot->y = (s16)(Math_SinS(this->unk_1F4 * 0x3000) * (this->unk_2DA * 500)) + rot->y; + rot->z = (s16)(Math_SinS(this->unk_1F4 * 0x3500) * (this->unk_2DA * 300)) + rot->z; + } + } + + return false; +} + +void Boss04_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_809EE228 = { 0.0f, -200.0f, 0.0f }; + static Vec3f D_809EE234 = { 0.0f, 720.0f, 0.0f }; + Boss04* this = THIS; + Vec3f sp18; + + if (limbIndex == 1) { + Matrix_GetStateTranslationAndScaledY(-500.0f, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&D_809EE228, &sp18); + func_809EC040(0, &this->collider1, &sp18); + Matrix_MultiplyVector3fByState(&D_809EE234, &sp18); + func_809EC040(0, &this->collider2, &sp18); + } +} + +void Boss04_Draw(Actor* thisx, GlobalContext* globalCtx) { + Boss04* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_200 & 1) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 900, 1099); + } + + Matrix_InsertTranslation(0.0f, 0.0f, 800.0f, MTXMODE_APPLY); + Matrix_Scale(this->unk_6F8, this->unk_6FC, this->unk_700, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + Boss04_OverrideLimbDraw, Boss04_PostLimbDraw, &this->actor); + + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + + if (this->actionFunc != func_809EC568) { + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 150); + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004510); + + Matrix_InsertTranslation(this->unk_6BC.x, this->actor.floorHeight, this->unk_6BC.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, -20.0f, MTXMODE_APPLY); + Matrix_Scale(this->unk_6F8 * 1.8f, 0.0f, this->unk_700 * 2.8f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004550); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Boss_04/z_boss_04.h b/src/overlays/actors/ovl_Boss_04/z_boss_04.h index 7dec60d9ca..f4542cf3a0 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.h +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.h @@ -9,9 +9,70 @@ typedef void (*Boss04ActionFunc)(struct Boss04*, GlobalContext*); typedef struct Boss04 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC0]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[9]; + /* 0x01BE */ Vec3s morphtable[9]; + /* 0x01F4 */ s16 unk_1F4; + /* 0x01F6 */ s8 unk_1F6; + /* 0x01F7 */ u8 unk_1F7; + /* 0x01F8 */ s16 unk_1F8; + /* 0x01FA */ s16 unk_1FA; + /* 0x01FC */ UNK_TYPE1 unk_1FC[2]; + /* 0x01FE */ s16 unk_1FE; + /* 0x0200 */ s16 unk_200; /* 0x0204 */ Boss04ActionFunc actionFunc; - /* 0x0208 */ char unk_208[0x544]; + /* 0x0208 */ ColliderJntSph collider1; + /* 0x0228 */ ColliderJntSphElement collider1Elements[1]; + /* 0x0268 */ ColliderJntSph collider2; + /* 0x0288 */ ColliderJntSphElement collider2Elements[1]; + /* 0x02C8 */ s16 unk_2C8; + /* 0x02CC */ f32 unk_2CC; + /* 0x02D0 */ f32 unk_2D0; + /* 0x02D4 */ s16 unk_2D4; + /* 0x02D6 */ s16 unk_2D6; + /* 0x02D8 */ s16 unk_2D8; + /* 0x02DA */ s16 unk_2DA; + /* 0x02DC */ s16 unk_2DC; + /* 0x02DE */ s16 unk_2DE; + /* 0x02E0 */ s16 unk_2E0; + /* 0x02E2 */ s16 unk_2E2; + /* 0x02E4 */ Vec3f unk_2E4[16]; + /* 0x02E4 */ Vec3f unk_3A4[15]; + /* 0x02E4 */ Vec3f unk_458[15]; + /* 0x02E4 */ Vec3f unk_50C[11]; + /* 0x02E4 */ Vec3f unk_590[11]; + /* 0x02E4 */ Vec3f unk_614[6]; + /* 0x02E4 */ Vec3f unk_65C[6]; + /* 0x02E4 */ Vec3f unk_6A4; + /* 0x02E4 */ Vec3f unk_6B0; + /* 0x06BC */ Vec3f unk_6BC; + /* 0x06C8 */ Vec3f unk_6C8; + /* 0x06D4 */ f32 unk_6D4; + /* 0x06D8 */ f32 unk_6D8; + /* 0x06DC */ f32 unk_6DC; + /* 0x06E0 */ f32 unk_6E0; + /* 0x06E4 */ f32 unk_6E4; + /* 0x06E8 */ f32 unk_6E8; + /* 0x06EC */ UNK_TYPE1 unk_6EC[4]; + /* 0x06F0 */ f32 unk_6F0; + /* 0x06F4 */ s16 unk_6F4; + /* 0x06F6 */ s16 unk_6F6; + /* 0x06F8 */ f32 unk_6F8; + /* 0x06FC */ f32 unk_6FC; + /* 0x0700 */ f32 unk_700; + /* 0x0704 */ u32 unk_704; + /* 0x0708 */ s16 unk_708; + /* 0x070A */ s16 unk_70A; + /* 0x070C */ Vec3f unk_70C; + /* 0x0718 */ Vec3f unk_718; + /* 0x0724 */ UNK_TYPE1 unk_724[4]; + /* 0x0728 */ f32 unk_728; + /* 0x072C */ UNK_TYPE1 unk_72C[0x10]; + /* 0x073C */ f32 unk_73C; + /* 0x0740 */ UNK_TYPE1 unk_740[4]; + /* 0x0744 */ f32 unk_744; + /* 0x0748 */ s16 unk_748; + /* 0x074A */ u8 unk_74A; } Boss04; // size = 0x74C extern const ActorInit Boss_04_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c index ccda78a8ea..586b231ae4 100644 --- a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c +++ b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c @@ -53,8 +53,8 @@ void DmSa_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk2E0 = 0; this->alpha = 0xFF; this->actor.targetArrowOffset = 3000.0f; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013328, NULL, 0, 0, 0); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013328, NULL, NULL, NULL, 0); func_80A2E960(&this->skelAnime, D_80A2ED00, 0); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = DmSa_DoNothing; diff --git a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c index 8234deec66..edfa0567da 100644 --- a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c +++ b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c @@ -44,5 +44,5 @@ void DmStatue_Update(Actor* thisx, GlobalContext* globalCtx) { void DmStatue_Draw(Actor* thisx, GlobalContext* globalCtx) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_06001788)); - func_800BE03C(globalCtx, D_06000520); + Gfx_DrawDListXlu(globalCtx, D_06000520); } diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index bf934be08d..ef6f258a71 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -260,7 +260,7 @@ void func_80A9FE3C(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, void func_80A9FED8(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames + 20) { case 1195: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); break; case 1232: @@ -268,48 +268,48 @@ void func_80A9FED8(DmStk* this, GlobalContext* globalCtx) { case 1252: case 1255: case 1257: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); break; case 1285: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); break; case 1343: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 1410: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); break; case 1603: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_WALK); break; case 1610: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_REVERSE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_REVERSE); break; case 2095: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_SURPRISED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_SURPRISED); break; case 2190: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_JUMP); break; case 2212: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_ONGND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_ONGND); break; case 2214: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL02_LAUGH_SHORT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL02_LAUGH_SHORT); break; case 2250: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL06_SURPRISED); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL06_SURPRISED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); break; case 2255: @@ -338,7 +338,7 @@ void func_80A9FED8(DmStk* this, GlobalContext* globalCtx) { case 2508: case 2519: case 2530: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; } } @@ -368,11 +368,11 @@ void func_80AA0100(DmStk* this, GlobalContext* globalCtx) { case 232: case 243: case 254: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; case 173: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); break; } } @@ -380,15 +380,15 @@ void func_80AA0100(DmStk* this, GlobalContext* globalCtx) { void func_80AA0158(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 18: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_GASAGOSO); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_GASAGOSO); break; case 90: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); break; case 142: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EVIL_POWER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); break; } } @@ -405,11 +405,11 @@ void func_80AA01C0(DmStk* this, GlobalContext* globalCtx) { break; case 560: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL02_LAUGH_SHORT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL02_LAUGH_SHORT); break; case 890: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL21_PSYCHO_VOICE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL21_PSYCHO_VOICE); break; } } @@ -423,7 +423,7 @@ void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { break; case 71: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_BODY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_BODY); break; case 365: @@ -435,30 +435,30 @@ void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { break; case 265: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); break; case 126: - Audio_PlayActorSound2(&player->actor, NA_SE_VO_DUMMY_150); + Actor_PlaySfxAtPos(&player->actor, NA_SE_VO_DUMMY_150); break; case 197: - Audio_PlayActorSound2(&player->actor, NA_SE_VO_DUMMY_134); + Actor_PlaySfxAtPos(&player->actor, NA_SE_VO_DUMMY_134); break; case 207: - Audio_PlayActorSound2(&player->actor, NA_SE_VO_DUMMY_135); + Actor_PlaySfxAtPos(&player->actor, NA_SE_VO_DUMMY_135); break; case 217: - Audio_PlayActorSound2(&player->actor, NA_SE_VO_DUMMY_136); + Actor_PlaySfxAtPos(&player->actor, NA_SE_VO_DUMMY_136); break; } if (player) {} if ((globalCtx->csCtx.frames >= 263) && (globalCtx->csCtx.frames < 698)) { - Audio_PlayActorSound2(&player->actor, NA_SE_EN_STALKIDS_BODY_LEV - SFX_FLAG); + Actor_PlaySfxAtPos(&player->actor, NA_SE_EN_STALKIDS_BODY_LEV - SFX_FLAG); } } @@ -471,37 +471,37 @@ void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { break; case 258: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_TURN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_TURN); break; case 524: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_TURN); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL04_ANGER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_TURN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL04_ANGER); break; case 534: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); break; case 678: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_STRETCH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_STRETCH); break; } if ((this->unk_2E0 == 31) && (globalCtx->csCtx.frames < 700)) { if (Animation_OnFrame(&this->skelAnime, 5.0f) || Animation_OnFrame(&this->skelAnime, 25.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA1); } else if (Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 40.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA2); } } if (globalCtx->csCtx.frames >= 700) { if (D_80AA3CB8 < 128) { if ((D_80AA3CB8 & 0x1F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL20_CALL_MOON); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON); } else if ((D_80AA3CB8 & 0x1F) == 16) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); } D_80AA3CB8++; } @@ -512,14 +512,14 @@ void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { void func_80AA05F0(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.frames == 3) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL06_SURPRISED); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL06_SURPRISED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); } } void func_80AA0634(DmStk* this, GlobalContext* globalCtx) { if ((globalCtx->csCtx.frames >= 642) && (globalCtx->csCtx.frames < 845)) { - Audio_PlayActorSound2(&this->actor, NA_SE_NE_STAL23_COLD - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_NE_STAL23_COLD - SFX_FLAG); } } @@ -531,16 +531,16 @@ void func_80AA066C(DmStk* this, GlobalContext* globalCtx) { case 72: case 77: case 79: - Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_WATER2); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_WATER2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_WALK); break; case 186: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); break; case 230: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL22_LAUGH_KID_L); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL22_LAUGH_KID_L); break; } } @@ -552,7 +552,7 @@ void func_80AA071C(DmStk* this, GlobalContext* globalCtx) { break; case 660: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); break; } } @@ -566,27 +566,27 @@ void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { break; case 45: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; case 93: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 245: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; case 269: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL11_LAUGH_SHY2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL11_LAUGH_SHY2); break; case 327: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); break; case 455: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; case 1730: @@ -594,7 +594,7 @@ void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { break; case 1395: - func_800B8E58(&player->actor, NA_SE_VO_DUMMY_34); + func_800B8E58(player, NA_SE_VO_DUMMY_34); break; case 1850: @@ -608,20 +608,20 @@ void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { if (this->unk_2E0 == 0) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } if (Animation_OnFrame(&this->skelAnime, 28.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); } } else if (this->unk_2E0 == 71) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } } else if ((this->unk_2E0 == 70) && (Animation_OnFrame(&this->skelAnime, 16.0f) || Animation_OnFrame(&this->skelAnime, 23.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_NOSE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_NOSE); } } @@ -634,25 +634,25 @@ void func_80AA09DC(DmStk* this, GlobalContext* globalCtx) { break; case 234: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_TURN); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL04_ANGER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_TURN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL04_ANGER); break; case 244: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); break; case 388: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_STRETCH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_STRETCH); break; } if (globalCtx->csCtx.frames >= 408) { if (D_80AA3CBC < 128) { if ((D_80AA3CBC & 0x1F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL20_CALL_MOON); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON); } else if ((D_80AA3CBC & 0x1F) == 16) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); } D_80AA3CBC++; } @@ -675,19 +675,19 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { case 332: case 335: case 344: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 367: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_BODY_LEV); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_BODY_LEV); break; case 470: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_HEADACHE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_HEADACHE); break; case 486: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); func_8019F1C0(&this->unk_310, NA_SE_EN_STAL08_CRY_BIG); break; @@ -696,11 +696,11 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { break; case 590: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 592: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; case 594: @@ -712,16 +712,16 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { if ((globalCtx->csCtx.frames >= 62) && (globalCtx->csCtx.frames < 273)) { if ((Rand_ZeroOne() < 0.75f) && ((globalCtx->state.frames % 2) != 0)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_EARTHQUAKE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_EARTHQUAKE); } } if ((globalCtx->csCtx.frames >= 498) && (globalCtx->csCtx.frames < 577)) { if ((globalCtx->state.frames % 4) == 0) { if ((globalCtx->state.frames & 4) != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_BODY_LEV); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_BODY_LEV); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } } } @@ -734,16 +734,16 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { void func_80AA0DA8(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 551: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_PULLED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_PULLED); break; case 711: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 716: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_ONGND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_ONGND); break; } } @@ -751,16 +751,16 @@ void func_80AA0DA8(DmStk* this, GlobalContext* globalCtx) { void func_80AA0E1C(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 311: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_PULLED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_PULLED); break; case 365: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 372: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_ONGND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_ONGND); break; } } @@ -834,24 +834,24 @@ void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { if (this->unk_2E0 == 1) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_WALK); } } else if (this->unk_2E0 == 19) { if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f) || Animation_OnFrame(&this->skelAnime, 20.0f) || Animation_OnFrame(&this->skelAnime, 27.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_CALM_HIT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_CALM_HIT); } } else if (this->unk_2E0 == 14) { if (Animation_OnFrame(&this->skelAnime, 3.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_PUT_OUT_ITEM); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PUT_OUT_ITEM); } } else if (this->unk_2E0 == 15) { if (Animation_OnFrame(&this->skelAnime, 14.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_UNSKILLFUL_OCARINA); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_UNSKILLFUL_OCARINA); } if (Animation_OnFrame(&this->skelAnime, 45.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STAL01_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL01_LAUGH); } } } @@ -964,7 +964,7 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2E4 = this->unk_2E4; this->actor.targetArrowOffset = 1100.0f; this->unk_334 = 99; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013328, NULL, NULL, NULL, 0); func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); } @@ -1062,7 +1062,7 @@ void func_80AA19EC(DmStk* this, GlobalContext* globalCtx) { void func_80AA1A50(DmStk* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(0xA)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DAMAGE); ActorCutscene_Start(0xA, &this->actor); this->actor.shape.rot.x = 0; this->actor.world.rot.x = this->actor.shape.rot.x; @@ -1109,7 +1109,7 @@ void func_80AA1B9C(DmStk* this, GlobalContext* globalCtx) { this->unk_2E0 = 39; func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); this->actionFunc = func_80AA1C64; } @@ -1568,9 +1568,9 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params != 1) { if (this->unk_2E0 == 33) { - Actor_SetHeight(&this->actor, 40.0f); + Actor_SetFocus(&this->actor, 40.0f); } else { - Actor_SetHeight(&this->actor, 6.0f); + Actor_SetFocus(&this->actor, 6.0f); } func_80A9FDB0(this, globalCtx); @@ -1592,7 +1592,7 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { switch (this->unk_33A) { case 1: - if (func_800B8718(&this->actor, globalCtx)) { + if (func_800B8718(&this->actor, &globalCtx->state)) { this->unk_33A = 2; } else { func_800B874C(&this->actor, globalCtx, this->actor.xzDistToPlayer, @@ -1719,7 +1719,7 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_337].segment); AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_06008658)); - func_800BDFC0(globalCtx, D_06007840); + Gfx_DrawDListOpa(globalCtx, D_06007840); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_336].segment); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_336].segment); @@ -1829,7 +1829,7 @@ void DmStk_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_33B != 0) { if (this->actor.params == 1) { - func_800BDFC0(globalCtx, D_06006BB0); + Gfx_DrawDListOpa(globalCtx, D_06006BB0); return; } diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index fb983aa6fe..167dbfe69d 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -208,5 +208,5 @@ void DoorAna_Update(Actor* thisx, GlobalContext* globalCtx) { } void DoorAna_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BE03C(globalCtx, D_05000C40); + Gfx_DrawDListXlu(globalCtx, D_05000C40); } diff --git a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c index 1716721dea..3e9754ccfc 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c @@ -205,7 +205,7 @@ void DoorSpiral_Init(Actor* thisx, GlobalContext* globalCtx) { } DoorSpiral_SetupAction(this, DoorSpiral_WaitForObject); - Actor_SetHeight(&this->actor, 60.0f); + Actor_SetFocus(&this->actor, 60.0f); } void DoorSpiral_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -237,7 +237,7 @@ f32 DoorSpiral_GetDistFromPlayer(GlobalContext* globalCtx, DoorSpiral* this, f32 target.y = player->actor.world.pos.y + yOffset; target.z = player->actor.world.pos.z; - Actor_CalcOffsetOrientedToDrawRotation(&this->actor, &offset, &target); + Actor_OffsetOfPointInActorCoords(&this->actor, &offset, &target); if ((spiralWidth < fabsf(offset.x)) || (spiralHeight < fabsf(offset.y))) { return FLT_MAX; @@ -252,7 +252,7 @@ f32 DoorSpiral_GetDistFromPlayer(GlobalContext* globalCtx, DoorSpiral* this, f32 s32 DoorSpiral_PlayerShouldClimb(DoorSpiral* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (!(func_801233E4(globalCtx))) { + if (!Player_InCsMode(&globalCtx->state)) { SpiralInfo* spiralInfo = &sSpiralInfo[this->spiralType]; f32 dist = DoorSpiral_GetDistFromPlayer(globalCtx, this, 0.0f, spiralInfo->spiralWidth, spiralInfo->spiralHeight); diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index b37a3df2f9..6d933ecd95 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -327,7 +327,7 @@ void func_808B90CC(DoorWarp1* this, GlobalContext* globalCtx) { DoorWarp1_SetupAction(this, func_808B921C); } - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WARP_HOLE_ENERGY - SFX_FLAG); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE_ENERGY - SFX_FLAG); } void func_808B921C(DoorWarp1* this, GlobalContext* globalCtx) { @@ -348,14 +348,14 @@ void func_808B921C(DoorWarp1* this, GlobalContext* globalCtx) { DoorWarp1_SetupAction(this, func_808B93A0); } - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); } void func_808B93A0(DoorWarp1* this, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); - if ((func_80152498(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 4 && func_80147624(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); @@ -371,7 +371,7 @@ void func_808B93A0(DoorWarp1* this, GlobalContext* globalCtx) { } } func_808BB8D4(this, globalCtx, 1); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); } void func_808B94A4(DoorWarp1* this, GlobalContext* globalCtx) { @@ -379,7 +379,7 @@ void func_808B94A4(DoorWarp1* this, GlobalContext* globalCtx) { DoorWarp1_SetupAction(this, func_808B921C); } func_808BB8D4(this, globalCtx, 1); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); } void func_808B9524(DoorWarp1* this, GlobalContext* globalCtx) { @@ -414,14 +414,14 @@ void func_808B958C(DoorWarp1* this, GlobalContext* globalCtx) { } Math_SmoothStepToF(&this->unk_1A8, 6.0f, 0.2f, 0.02f, 0.01f); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_LINK_WARP - SFX_FLAG); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_LINK_WARP - SFX_FLAG); } void func_808B96A0(DoorWarp1* this, GlobalContext* globalCtx) { } void func_808B96B0(DoorWarp1* this, GlobalContext* globalCtx) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); Math_SmoothStepToF(&this->unk_1B0, 255.0f, 0.4f, 10.0f, 0.01f); Math_SmoothStepToF(&this->unk_1B4, 255.0f, 0.4f, 10.0f, 0.01f); @@ -441,11 +441,11 @@ void func_808B96B0(DoorWarp1* this, GlobalContext* globalCtx) { } void func_808B977C(DoorWarp1* this, GlobalContext* globalCtx) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); if (func_808B866C(this, globalCtx) && !func_801690CC(globalCtx)) { Player* player = GET_PLAYER(globalCtx); - func_801A5CFC(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); + Audio_PlaySfxGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); func_800B7298(globalCtx, &this->dyna.actor, 9); player->unk_3A0.x = this->dyna.actor.world.pos.x; player->unk_3A0.z = this->dyna.actor.world.pos.z; @@ -514,7 +514,7 @@ void func_808B9B30(DoorWarp1* this, GlobalContext* globalCtx) { } void func_808B9BE8(DoorWarp1* this, GlobalContext* globalCtx) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); Math_SmoothStepToF(&this->unk_1B0, 255.0f, 0.2f, 2.0f, 0.1f); Math_SmoothStepToF(&this->unk_1B4, 255.0f, 0.2f, 2.0f, 0.1f); if (this->unk_1C4 < 10) { @@ -546,7 +546,7 @@ void func_808B9CE8(DoorWarp1* this, GlobalContext* globalCtx) { } if (!Actor_HasParent(&this->dyna.actor, globalCtx)) { - func_800B8A1C(&this->dyna.actor, globalCtx, func_808B849C(this, globalCtx) + 84, 30.0f, 80.0f); + Actor_PickUp(&this->dyna.actor, globalCtx, func_808B849C(this, globalCtx) + 84, 30.0f, 80.0f); return; } @@ -579,7 +579,7 @@ void func_808B9CE8(DoorWarp1* this, GlobalContext* globalCtx) { } void func_808B9E94(DoorWarp1* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 2) { + if (Message_GetState(&globalCtx->msgCtx) == 2) { this->unk_1CE = 110; DoorWarp1_SetupAction(this, func_808B9ED8); } @@ -593,7 +593,7 @@ void func_808B9ED8(DoorWarp1* this, GlobalContext* globalCtx) { } void func_808B9F10(DoorWarp1* this, GlobalContext* globalCtx) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); if ((this->unk_203 == 0) && func_808B866C(this, globalCtx) && !func_801690CC(globalCtx) && (this->unk_203 == 0)) { Player* player = GET_PLAYER(globalCtx); @@ -619,7 +619,7 @@ void func_808B9FD0(DoorWarp1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]); } else { ActorCutscene_Start(globalCtx->unk_1879C[9], NULL); - func_801A5CFC(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); + Audio_PlaySfxGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); Animation_ChangeImpl(&this->skelAnime, &object_warp1_Anim_001374, 1.0f, Animation_GetLastFrame(&object_warp1_Anim_001374.common), Animation_GetLastFrame(&object_warp1_Anim_001374.common), 2, 40.0f, 1); @@ -1015,7 +1015,7 @@ void func_808BAE9C(DoorWarp1* this, GlobalContext* globalCtx) { } void func_808BB4C4(DoorWarp1* this, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, object_warp1_DL_0076C0); + Gfx_DrawDListOpa(globalCtx, object_warp1_DL_0076C0); } #ifdef NON_MATCHING @@ -1036,7 +1036,7 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { this->dyna.actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(4.0f, this->unk_1AC, 4.0f, MTXMODE_APPLY); AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_warp1_Matanimheader_0044D8)); - func_800BE03C(globalCtx, object_warp1_DL_003230); + Gfx_DrawDListXlu(globalCtx, object_warp1_DL_003230); return; } diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index 4010b1e124..a638422bff 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -129,7 +129,7 @@ void func_80BECBE0(EnAkindonuts* this, s16 arg1) { this->actor.velocity.z = 0.0f; } - Actor_ApplyMovement(&this->actor); + Actor_UpdatePos(&this->actor); } void func_80BECC7C(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -1036,7 +1036,7 @@ void func_80BEE73C(EnAkindonuts* this, GlobalContext* globalCtx) { player->actor.textId = D_80BF048C[params]; this->unk_33C = player->actor.textId; if (this->unk_33C == 0x15E4) { - player->unk_A87 = itemActionParam; + player->exchangeItemId = itemActionParam; this->actionFunc = func_80BEF20C; } else { this->actionFunc = func_80BEF18C; @@ -1045,7 +1045,7 @@ void func_80BEE73C(EnAkindonuts* this, GlobalContext* globalCtx) { player->actor.textId = D_80BF0494[params]; this->unk_33C = player->actor.textId; if (this->unk_33C == 0x15F9) { - player->unk_A87 = itemActionParam; + player->exchangeItemId = itemActionParam; this->actionFunc = func_80BEF20C; } else { this->actionFunc = func_80BEF18C; @@ -1054,7 +1054,7 @@ void func_80BEE73C(EnAkindonuts* this, GlobalContext* globalCtx) { player->actor.textId = D_80BF049C[params]; this->unk_33C = player->actor.textId; if (this->unk_33C == 0x160C) { - player->unk_A87 = itemActionParam; + player->exchangeItemId = itemActionParam; this->actionFunc = func_80BEF20C; } else { this->actionFunc = func_80BEF18C; @@ -1063,7 +1063,7 @@ void func_80BEE73C(EnAkindonuts* this, GlobalContext* globalCtx) { player->actor.textId = D_80BF04A4[params]; this->unk_33C = player->actor.textId; if (this->unk_33C == 0x1621) { - player->unk_A87 = itemActionParam; + player->exchangeItemId = itemActionParam; this->actionFunc = func_80BEF20C; } else { this->actionFunc = func_80BEF18C; @@ -1162,7 +1162,7 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { } if (phi_v0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80BEEDC0; this->unk_338 = 3; this->collider.dim.height = 64; @@ -1175,12 +1175,12 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { if ((this->unk_338 == 4) || (this->unk_338 == 18)) { this->unk_338 = 17; this->collider.dim.height = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); func_8013BC6C(&this->skelAnime, sAnimations, 17); } else if (this->unk_338 == 2) { this->unk_338 = 16; this->collider.dim.height = 32; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); func_8013BC6C(&this->skelAnime, sAnimations, 16); } else if (this->unk_338 == 17) { phi_v0 = DECR(this->unk_33A); @@ -1213,7 +1213,7 @@ void func_80BEEE10(EnAkindonuts* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 2000, 0); this->actor.world.rot.y = this->actor.shape.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_2DC(this, globalCtx); this->actionFunc = func_80BEEFA8; } else if (((this->actor.xzDistToPlayer < 100.0f) && @@ -1229,7 +1229,7 @@ void func_80BEEE10(EnAkindonuts* this, GlobalContext* globalCtx) { } void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { - u8 temp_v0 = func_80152498(&globalCtx->msgCtx); + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { if (func_80147624(globalCtx)) { @@ -1274,7 +1274,7 @@ void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { } void func_80BEF18C(EnAkindonuts* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_33C = 0; @@ -1283,7 +1283,7 @@ void func_80BEF18C(EnAkindonuts* this, GlobalContext* globalCtx) { } void func_80BEF20C(EnAkindonuts* this, GlobalContext* globalCtx) { - u8 sp27 = func_80152498(&globalCtx->msgCtx); + u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 sp24 = this->skelAnime.curFrame; s16 sp22 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); @@ -1319,25 +1319,25 @@ void func_80BEF360(EnAkindonuts* this, GlobalContext* globalCtx) { this->unk_32C &= ~0x40; this->actionFunc = func_80BEF450; } else { - func_800B8A1C(&this->actor, globalCtx, func_80BED034(this), 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, func_80BED034(this), 300.0f, 300.0f); } } else if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actionFunc = func_80BEF450; } else { - func_800B8A1C(&this->actor, globalCtx, func_80BECFBC(this), 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, func_80BECFBC(this), 300.0f, 300.0f); } } void func_80BEF450(EnAkindonuts* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); this->actionFunc = func_80BEF4B8; } } void func_80BEF4B8(EnAkindonuts* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_2DC(this, globalCtx); this->actionFunc = func_80BEEFA8; } else { @@ -1422,7 +1422,7 @@ void func_80BEF518(EnAkindonuts* this, GlobalContext* globalCtx) { this->unk_33E = 3; this->unk_338 = 19; func_8013BC6C(&this->skelAnime, sAnimations, this->unk_338); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_32C &= ~2; this->unk_32C |= 0x80; this->unk_358 = this->actor.world.pos.y; @@ -1481,7 +1481,7 @@ void func_80BEF83C(EnAkindonuts* this, GlobalContext* globalCtx) { this->unk_34C = 0.3f; this->unk_338 = 9; func_8013BC6C(&this->skelAnime, sAnimations, this->unk_338); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80BEF9F0; } } @@ -1587,7 +1587,7 @@ void EnAkindonuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->morphTable, 28); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 35.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); Actor_SetScale(&this->actor, 0.01f); this->actor.colChkInfo.cylRadius = 0; @@ -1620,9 +1620,9 @@ void EnAkindonuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnAkindonuts_Update(Actor* thisx, GlobalContext* globalCtx) { EnAkindonuts* this = THIS; - Actor_SetHeight(&this->actor, 60.0f); + Actor_SetFocus(&this->actor, 60.0f); SkelAnime_Update(&this->skelAnime); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); this->actionFunc(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index c26081e0de..4c7b1d6cb2 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -150,7 +150,7 @@ s32 func_809C1424(EnAob01* this) { if (this->unk_43C == 1) { if (curFrame == lastFrame) { this->unk_43C = 2; - func_800BDC5C(&this->skelAnime, D_809C3790, 2); + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 2); return true; } } else if (this->unk_43C == 2) { @@ -166,13 +166,13 @@ s32 func_809C14D0(EnAob01* this) { if ((this->unk_43C == 0) || (this->unk_43C == 5)) { if (curFrame == lastFrame) { this->unk_43C = 3; - func_800BDC5C(&this->skelAnime, D_809C3790, 3); + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 3); return true; } } else if (this->unk_43C == 3) { if (curFrame == lastFrame) { this->unk_43C = 4; - func_800BDC5C(&this->skelAnime, D_809C3790, 4); + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 4); return true; } } else if (this->unk_43C == 4) { @@ -188,7 +188,7 @@ s32 func_809C15BC(EnAob01* this) { if ((this->unk_43C != 0) && (this->unk_43C != 5)) { if (curFrame == lastFrame) { this->unk_43C = 5; - func_800BDC5C(&this->skelAnime, D_809C3790, 5); + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 5); return true; } } else { @@ -330,7 +330,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x40; this->unk_2D2 |= 0x10; this->unk_43C = 1; - func_800BDC5C(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); break; case 0x3525: @@ -345,7 +345,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x40; this->unk_2D2 |= 0x10; this->unk_43C = 1; - func_800BDC5C(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); break; } @@ -360,7 +360,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 4; this->unk_2D2 |= 0x10; this->unk_43C = 1; - func_800BDC5C(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); break; case 0x3527: @@ -372,7 +372,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_210 = 0x3536; this->unk_2D2 |= 0x40; this->unk_43C = 1; - func_800BDC5C(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); break; } @@ -380,7 +380,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_210 = 0x3537; this->unk_2D2 |= 0x40; this->unk_43C = 1; - func_800BDC5C(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); break; } @@ -427,7 +427,7 @@ void func_809C1C9C(EnAob01* this, GlobalContext* globalCtx) { } void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { - u8 temp_v0 = func_80152498(&globalCtx->msgCtx); + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 4) { if (func_80147624(globalCtx)) { @@ -499,7 +499,7 @@ void func_809C2060(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 8; this->actionFunc = func_809C21E0; } - } else if (func_800B84D0(&this->actor, globalCtx) && (this->unk_2D2 & 0x100)) { + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_2D2 & 0x100)) { this->unk_2D2 &= ~0x100; this->unk_2E6 = this->unk_2D4; this->unk_2EC = this->unk_2DA; @@ -517,7 +517,7 @@ void func_809C2060(EnAob01* this, GlobalContext* globalCtx) { } void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { - u8 sp2F = func_80152498(&globalCtx->msgCtx); + u8 sp2F = Message_GetState(&globalCtx->msgCtx); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 4000, 1); @@ -542,7 +542,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { } if (this->unk_2D2 & 8) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; func_80123E90(globalCtx, &this->actor); if (this->unk_2D2 & 4) { @@ -552,7 +552,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x10; this->unk_2D2 |= 0x40; this->unk_43C = 1; - func_800BDC5C(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); func_801518B0(globalCtx, 0x354B, &this->actor); } this->unk_2D2 &= ~8; @@ -593,7 +593,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { } s32 func_809C2504(EnAob01* this, GlobalContext* globalCtx) { - Actor* npc = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (npc != NULL) { if ((npc->id == ACTOR_EN_RACEDOG) && (func_800F2178(this->unk_430) == ((EnRacedog*)npc)->unk_1E8)) { @@ -609,7 +609,7 @@ s32 func_809C2504(EnAob01* this, GlobalContext* globalCtx) { } s32 func_809C2594(EnAob01* this, GlobalContext* globalCtx) { - Actor* npc = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (npc != NULL) { if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->unk_290 == ((EnRacedog*)npc)->unk_292)) { @@ -623,7 +623,7 @@ s32 func_809C2594(EnAob01* this, GlobalContext* globalCtx) { } s32 func_809C25E4(EnAob01* this, GlobalContext* globalCtx) { - Actor* npc = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; s16 count = 0; while (npc != NULL) { @@ -699,7 +699,7 @@ void func_809C2824(EnAob01* this, GlobalContext* globalCtx) { } void func_809C28B8(EnAob01* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; func_80123E90(globalCtx, &this->actor); this->unk_434 = gSaveContext.unk_3F5C; @@ -731,7 +731,7 @@ void func_809C28B8(EnAob01* this, GlobalContext* globalCtx) { this->unk_210 = 0x352D; this->unk_2D2 |= 0x40; this->unk_43C = 1; - func_800BDC5C(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); break; } @@ -743,7 +743,7 @@ void func_809C28B8(EnAob01* this, GlobalContext* globalCtx) { } void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { - u8 sp2F = func_80152498(&globalCtx->msgCtx); + u8 sp2F = Message_GetState(&globalCtx->msgCtx); if (func_809C15BC(this)) { if ((sp2F == 5) && func_80147624(globalCtx)) { @@ -765,15 +765,15 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { this->actionFunc = func_809C2BE4; } } else if (gSaveContext.weekEventReg[8] & 0x20) { - func_800B8A1C(&this->actor, globalCtx, 4, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, 4, 300.0f, 300.0f); } else { - func_800B8A1C(&this->actor, globalCtx, 12, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, 12, 300.0f, 300.0f); } } } void func_809C2BE4(EnAob01* this, GlobalContext* globalCtx) { - u8 temp_v0 = func_80152498(&globalCtx->msgCtx); + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (((temp_v0 == 5) || (temp_v0 == 6)) && func_80147624(globalCtx)) { if (gSaveContext.weekEventReg[63] & 2) { @@ -792,7 +792,7 @@ void func_809C2BE4(EnAob01* this, GlobalContext* globalCtx) { } void func_809C2C9C(EnAob01* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_210 = 0x354C; func_80151938(globalCtx, this->unk_210); this->actionFunc = func_809C1D64; @@ -802,7 +802,7 @@ void func_809C2C9C(EnAob01* this, GlobalContext* globalCtx) { } void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { - u8 sp2F = func_80152498(&globalCtx->msgCtx); + u8 sp2F = Message_GetState(&globalCtx->msgCtx); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 4000, 1); @@ -847,7 +847,7 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { } s32 func_809C2EC4(EnAob01* this, GlobalContext* globalCtx) { - Actor* dog = globalCtx->actorCtx.actorList[ACTORCAT_ENEMY].first; + Actor* dog = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; while (dog != NULL) { if (dog->id == ACTOR_EN_DG) { @@ -927,7 +927,7 @@ void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->unk_43C = 0; - func_800BDC5C(&this->skelAnime, D_809C3790, 0); + Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 0); Actor_SetScale(&this->actor, 0.01f); switch (gSaveContext.eventInf[0] & 7) { diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index bacb293950..097c90fe08 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -42,7 +42,7 @@ static ColliderQuadInit D_8088C1E0 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_8088C230[] = { - ICHAIN_F32(minVelocityY, -150, ICHAIN_STOP), + ICHAIN_F32(terminalVelocity, -150, ICHAIN_STOP), }; #endif diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c index c776dc6963..2668c1d680 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c @@ -111,7 +111,7 @@ static DamageTable sDamageTable = { void EnBaguo_Init(Actor* thisx, GlobalContext* globalCtx) { EnBaguo* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 0.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &gNejironSkel, NULL, this->jointTable, this->morphTable, 3); this->actor.hintId = 0xB; this->maxDistanceFromHome = 240.0f; @@ -145,7 +145,7 @@ void EnBaguo_UndergroundIdle(EnBaguo* this, GlobalContext* globalCtx) { this->action = NEJIRON_ACTION_INACTIVE; if (this->actor.xzDistToPlayer < 200.0f && Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { this->actor.draw = EnBaguo_DrawBody; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BAKUO_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_APPEAR); this->actor.world.rot.z = 0; this->actor.world.rot.x = this->actor.world.rot.z; this->actor.flags &= ~0x8000000; @@ -159,8 +159,8 @@ void EnBaguo_EmergeFromUnderground(EnBaguo* this, GlobalContext* globalCtx) { this->actor.world.rot.y += 0x1518; this->actor.shape.rot.y = this->actor.world.rot.y; if ((globalCtx->gameplayFrames % 8) == 0) { - func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 10, 8.0f, - 500, 10, 1); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, + 10, 8.0f, 500, 10, 1); } Math_ApproachF(&this->actor.shape.shadowScale, 50.0f, 0.3f, 5.0f); Math_ApproachF(&this->actor.shape.yOffset, 2700.0f, 100.0f, 500.0f); @@ -188,9 +188,9 @@ void EnBaguo_Idle(EnBaguo* this, GlobalContext* globalCtx) { if (fabsf(this->actor.world.rot.y - this->actor.yawTowardsPlayer) > 200.0f) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 30, 300, 1000); if ((globalCtx->gameplayFrames % 8) == 0) { - func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, - this->actor.shape.shadowScale - 20.0f, 10, 8.0f, 500, 10, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BAKUO_VOICE); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, + this->actor.shape.shadowScale - 20.0f, 10, 8.0f, 500, 10, 1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_VOICE); } } } @@ -252,7 +252,7 @@ void EnBaguo_Roll(EnBaguo* this, GlobalContext* globalCtx) { this->actor.world.rot.z -= (s16)this->currentRotation.z; } } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BAKUO_ROLL - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_ROLL - SFX_FLAG); } void EnBaguo_SetupRetreatUnderground(EnBaguo* this) { @@ -265,8 +265,8 @@ void EnBaguo_RetreatUnderground(EnBaguo* this, GlobalContext* globalCtx) { this->actor.world.rot.y -= 0x1518; this->actor.shape.rot.y = this->actor.world.rot.y; if ((globalCtx->gameplayFrames % 8) == 0) { - func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 10, 8.0f, - 500, 10, 1); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, + 10, 8.0f, 500, 10, 1); } Math_ApproachF(&this->actor.shape.yOffset, -3000.0f, 100.0f, 500.0f); Math_ApproachZeroF(&this->actor.shape.shadowScale, 0.3f, 5.0f); @@ -274,7 +274,7 @@ void EnBaguo_RetreatUnderground(EnBaguo* this, GlobalContext* globalCtx) { this->actor.shape.yOffset = -3000.0f; this->actor.draw = EnBaguo_DrawBody; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BAKUO_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_APPEAR); this->actor.flags |= 0x8000000; this->actor.flags &= ~1; this->actionFunc = EnBaguo_UndergroundIdle; @@ -311,7 +311,7 @@ void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { if ((this->collider.base.acFlags & AC_HIT || i)) { this->collider.base.acFlags &= ~AC_HIT; if (i || this->actor.colChkInfo.damageEffect == NEJIRON_DMGEFF_KILL) { - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); this->action = NEJIRON_ACTION_EXPLODING; this->actor.speedXZ = 0.0f; this->actor.shape.shadowScale = 0.0f; @@ -329,8 +329,8 @@ void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_POP); - Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BAKUO_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_DEAD); this->timer = 30; this->actor.flags |= 0x8000000; this->actor.flags &= ~1; @@ -347,7 +347,7 @@ void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { void EnBaguo_Update(Actor* thisx, GlobalContext* globalCtx) { EnBaguo* this = THIS; - Actor_SetHeight(&this->actor, 30.0f); + Actor_SetFocus(&this->actor, 30.0f); EnBaguo_UpdateParticles(this, globalCtx); EnBaguo_CheckForDetonation(this, globalCtx); this->actionFunc(this, globalCtx); @@ -369,7 +369,7 @@ void EnBaguo_Update(Actor* thisx, GlobalContext* globalCtx) { this->blinkTimer = Rand_ZeroFloat(60.0f) + 20.0f; } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); if (this->action != NEJIRON_ACTION_INACTIVE) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); diff --git a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c index 7323c95b35..fcbd60ed0a 100644 --- a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c +++ b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c @@ -68,7 +68,7 @@ static u8 animModes[] = { 0, 0 }; void EnBaisen_Init(Actor* thisx, GlobalContext* globalCtx) { EnBaisen* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06007908, &D_060011C0, this->jointTable, this->morphTable, 20); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->paramCopy = this->actor.params; @@ -124,7 +124,7 @@ void func_80BE871C(EnBaisen* this) { } void func_80BE87B0(EnBaisen* this, GlobalContext* globalCtx) { - Actor* actorIterator = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + Actor* actorIterator = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (actorIterator != NULL) { if (actorIterator->id == ACTOR_EN_HEISHI) { @@ -151,7 +151,7 @@ void func_80BE87FC(EnBaisen* this) { } void func_80BE887C(EnBaisen* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80BE895C(this, globalCtx); } else { if (this->paramCopy != 0) { @@ -176,7 +176,7 @@ void func_80BE895C(EnBaisen* this, GlobalContext* globalCtx) { if (this->unk2A4 != NULL) { this->unk290 = true; this->unk2AC = 1; - func_800B86C8(this->unk2A4, globalCtx, this->unk2A4); + Actor_ChangeFocus(this->unk2A4, globalCtx, this->unk2A4); } this->unk29C = 1; if (this->paramCopy == 0) { @@ -223,7 +223,7 @@ void func_80BE8AAC(EnBaisen* this, GlobalContext* globalCtx) { EnBaisen_ChangeAnimation(this, 0); } } - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); this->textIdIndex++; if (this->textIdIndex < 6) { @@ -233,7 +233,7 @@ void func_80BE8AAC(EnBaisen* this, GlobalContext* globalCtx) { } else { this->unk2A4 = &this->actor; } - func_800B86C8(this->unk2A4, globalCtx, this->unk2A4); + Actor_ChangeFocus(this->unk2A4, globalCtx, this->unk2A4); } else { func_80BE87FC(this); } @@ -254,13 +254,13 @@ void EnBaisen_Update(Actor* thisx, GlobalContext* globalCtx) { return; } this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); Actor_SetScale(&this->actor, 0.01f); if (this->unk290) { func_80BE871C(this); } - Actor_SetHeight(&this->actor, 60.0f); + Actor_SetFocus(&this->actor, 60.0f); Math_SmoothStepToS(&this->headRotX, this->headRotXTarget, 1, 0xBB8, 0); Math_SmoothStepToS(&this->headRotY, this->headRotYTarget, 1, 0x3E8, 0); Collider_UpdateCylinder(&this->actor, &this->collider); 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 7ea98689ec..5b31f76013 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -207,7 +207,7 @@ void EnBigpo_Init(Actor* thisx, GlobalContext* globalCtx2) { 255, 0); } - ActorShape_Init(&thisx->shape, 0.0f, func_800B3FC0, 45.0f); + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 45.0f); thisx->bgCheckFlags |= 0x400; this->savedHeight = thisx->home.pos.y + 100.0f; this->mainColor.r = 255; @@ -262,7 +262,7 @@ void EnBigpo_UpdateSpin(EnBigpo* this) { this->actor.shape.rot.y += this->rotVelocity; if ((oldYaw < 0) && (this->actor.shape.rot.y > 0)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); // spinning sfx during spin attack + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); // spinning sfx during spin attack } } @@ -398,7 +398,7 @@ void EnBigpo_SpawnCutsceneStage5(EnBigpo* this) { Animation_PlayLoop(&this->skelAnime, &gBigpoAwakenStretchAnim); this->actor.draw = EnBigpo_DrawMainBigpo; Actor_SetScale(&this->actor, 0.014f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); this->actionFunc = EnBigpo_SpawnCutsceneStage6; } @@ -464,7 +464,7 @@ void EnBigpo_SpawnCutsceneStage8(EnBigpo* this, GlobalContext* globalCtx) { Play_CameraSetAtEye(globalCtx, MAIN_CAM, &subCam->at, &subCam->eye); this->cutsceneSubCamId = SUBCAM_FREE; if (this->actor.params == ENBIGPO_SUMMONED) { - dampe = func_ActorCategoryIterateById(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_TK); + dampe = SubS_FindActor(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_TK); if (dampe != NULL) { // if dampe exists, switch to viewing his running away cutscene dampe->params = this->actor.cutscene; @@ -486,7 +486,7 @@ void EnBigpo_SetupWarpOut(EnBigpo* this) { this->idleTimer = 32; this->actor.flags &= ~0x1; // targetable OFF this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DISAPPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DISAPPEAR); this->actionFunc = EnBigpo_WarpingOut; } @@ -508,7 +508,7 @@ void EnBigpo_SetupWarpIn(EnBigpo* this, GlobalContext* globalCtx) { f32 distance = CLAMP_MIN(this->actor.xzDistToPlayer, 200.0f); s16 randomYaw = (Rand_Next() >> 0x14) + this->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); Animation_PlayLoop(&this->skelAnime, &gBigpoAwakenStretchAnim); this->rotVelocity = 0x2000; this->actor.world.pos.x = (Math_SinS(randomYaw) * distance) + player->actor.world.pos.x; @@ -648,7 +648,7 @@ void EnBigpo_SpinningDown(EnBigpo* this, GlobalContext* globalCtx) { */ void EnBigpo_HitStun(EnBigpo* this) { Animation_MorphToPlayOnce(&this->skelAnime, &gBigpoShockAnim, -6.0f); - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 0x10); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0x10); this->collider.base.acFlags &= ~AC_ON; func_800BE504(&this->actor, &this->collider); this->actionFunc = EnBigpo_CheckHealth; @@ -728,7 +728,7 @@ void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx) { func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); // burning sfx } if (this->idleTimer == 18) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); } } @@ -754,7 +754,7 @@ void EnBigpo_SetupLanternDrop(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_LanternFalling(EnBigpo* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1 || this->actor.floorHeight == BGCHECK_Y_MIN) { if (this->switchFlags != 0xFF) { - Actor_SetSwitchFlag(globalCtx, this->switchFlags); + Flags_SetSwitch(globalCtx, this->switchFlags); } EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 6.0f, 0, 1, 1, 15, OBJECT_BIGPO, 10, @@ -799,7 +799,7 @@ void EnBigpo_SpawnScoopSoul(EnBigpo* this) { this->actor.scale.x = 0.0f; this->actor.scale.y = 0.0f; this->savedHeight = this->actor.world.pos.y; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_METAL_BOX_BOUND); // misnamed? + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_METAL_BOX_BOUND); // misnamed? this->actionFunc = EnBigpo_ScoopSoulAppearing; } @@ -813,7 +813,7 @@ void EnBigpo_ScoopSoulAppearing(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SetupScoopSoulIdle(EnBigpo* this) { this->savedHeight = this->actor.world.pos.y; - Actor_SetHeight(&this->actor, -10.0f); + Actor_SetFocus(&this->actor, -10.0f); this->idleTimer = 400; // 20 seconds this->actor.flags |= 0x1; // targetable ON this->actionFunc = EnBigpo_ScoopSoulIdle; @@ -825,10 +825,10 @@ void EnBigpo_ScoopSoulIdle(EnBigpo* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } else if (this->idleTimer == 0) { // took too long, soul is leaving - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); EnBigpo_SetupScoopSoulLeaving(this); } else { - func_800B8A1C(&this->actor, globalCtx, GI_MAX, 35.0f, 60.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 35.0f, 60.0f); this->actor.world.pos.y = (sin_rad(this->idleTimer * (M_PI / 20)) * 5.0f) + this->savedHeight; } } @@ -1048,7 +1048,7 @@ void EnBigpo_FlameCircleCutscene(EnBigpo* this, GlobalContext* globalCtx) { this->idleTimer--; if (this->idleTimer == 0) { EnBigpo* parentPoh = (EnBigpo*)this->actor.parent; - Actor_SetSwitchFlag(globalCtx, this->switchFlags); + Flags_SetSwitch(globalCtx, this->switchFlags); Math_Vec3f_Copy(&parentPoh->fires[this->unk20C].pos, &this->actor.world.pos); Actor_MarkForDeath(&this->actor); if (this->unk20C == 0) { @@ -1126,13 +1126,13 @@ s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx) { if (Actor_ApplyDamage(&this->actor) == 0) { this->actor.flags &= ~0x1; // targetable OFF - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DEAD); Enemy_StartFinishingBlow(globalCtx, &this->actor); if (this->actor.params == ENBIGPO_SUMMONED) { // dampe type func_801A2ED8(); } } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DAMAGE); } // light arrows @@ -1167,23 +1167,23 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk20C = 0; } if (this->unk20C == 40) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); EnBigpo_SetupWarpOut(this); } } this->actionFunc(this, globalCtx); if ((this->actionFunc != EnBigpo_SpawnCutsceneStage6) && (this->actionFunc != EnBigpo_SpawnCutsceneStage4)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } if (this->actionFunc == EnBigpo_LanternFalling) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 27.0f, 60.0f, 4); } if (this->actor.draw == EnBigpo_DrawScoopSoul) { - Actor_SetHeight(&this->actor, -10.0f); + Actor_SetFocus(&this->actor, -10.0f); } else { - Actor_SetHeight(&this->actor, 42.0f); + Actor_SetFocus(&this->actor, 42.0f); } EnBigpo_UpdateColor(this); diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index 42395579eb..9f55e3e0b0 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -337,7 +337,7 @@ void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx) { this->gekkoCollider.base.ocFlags1 &= ~OC1_NO_PUSH; this->actor.params = CLAMP(this->actor.params, 1, 4); - if (Actor_GetRoomCleared(globalCtx, globalCtx->roomCtx.currRoom.num)) { + if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { Actor_MarkForDeath(&this->actor); if (!(gSaveContext.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & (u8)isFrogReturnedFlags[this->actor.params - 1])) { @@ -770,7 +770,7 @@ void EnBigslime_BreakIntoMinislime(EnBigslime* this, GlobalContext* globalCtx) { this->actor.bgCheckFlags &= ~1; this->formBigslimeTimer = 2; EnBigslime_AddIceShardEffect(this, globalCtx); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_B_SLIME_BREAK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_BREAK); EnBigslime_SetupJumpGekko(this); } @@ -921,7 +921,7 @@ void EnBigslime_GekkoThaw(EnBigslime* this, GlobalContext* globalCtx) { this->gekkoCollider.base.colType = COLTYPE_HIT6; this->gekkoCollider.info.elemType = ELEMTYPE_UNK1; this->unk_388 = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); this->actor.flags |= 0x200; } } @@ -1212,7 +1212,7 @@ void EnBigslime_SetTargetVtxToWideCone(EnBigslime* this) { } void EnBigslime_SetupSquishFlat(EnBigslime* this) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_B_SLIME_JUMP2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_JUMP2); this->squishFlatTimer = 20; this->actor.scale.x = 0.2f; this->actor.scale.z = 0.2f; @@ -1411,7 +1411,7 @@ void EnBigslime_SetupRise(EnBigslime* this) { Animation_PlayLoop(&this->skelAnime, &gGekkoSwimForwardAnim); EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_JUMP_ABOVE); EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_UTSUBO_APPEAR_TRG); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_B_SLIME_JUMP1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_JUMP1); this->riseCounter = 0; this->bigslimeCollider[0].base.atFlags &= ~AT_ON; this->actor.gravity = 0.0f; @@ -1514,7 +1514,7 @@ void EnBigslime_SetupCutsceneGrabPlayer(EnBigslime* this, GlobalContext* globalC this->subCamYawGrabPlayer += this->actor.world.rot.y; Animation_PlayLoop(&this->skelAnime, &gGekkoBoxingStanceAnim); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_B_SLIME_EAT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_EAT); this->actionFunc = EnBigslime_CutsceneGrabPlayer; } @@ -1623,7 +1623,7 @@ void EnBigslime_AttackPlayerInBigslime(EnBigslime* this, GlobalContext* globalCt } globalCtx->damagePlayer(globalCtx, -4); - func_800B8E58(&player->actor, player->ageProperties->unk_92 + 0x6805); + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); this->gekkoRot.y += (s16)(Rand_S16Offset(0x4000, 0x4000) * (Rand_ZeroOne() < 0.5f ? -1 : 1)); this->gekkoPosOffset.x = Math_SinS(this->gekkoRot.y) * -50.0f; this->gekkoPosOffset.z = Math_CosS(this->gekkoRot.y) * -50.0f; @@ -1700,7 +1700,7 @@ void EnBigslime_WindupThrowPlayer(EnBigslime* this, GlobalContext* globalCtx) { this->gekkoPosOffset.z = Math_CosS(this->gekkoRot.y) * -50.0f; } else { if (this->windupPunchTimer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_B_SLIME_REVERSE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_REVERSE); EnBigslime_GekkoSfxInsideBigslime(this, NA_SE_EN_FROG_PUNCH1); } @@ -2283,7 +2283,7 @@ void EnBigslime_FormBigslime(EnBigslime* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; Animation_PlayLoop(&this->skelAnime, &gGekkoSwimForwardAnim); this->formBigslimeCutsceneTimer--; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_B_SLIME_COMBINE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_COMBINE); } else if (this->isAnimUpdate) { this->formBigslimeCutsceneTimer--; if (this->formBigslimeCutsceneTimer == 0) { @@ -2497,7 +2497,7 @@ void EnBigslime_Despawn(EnBigslime* this, GlobalContext* globalCtx) { } if (!this->isDespawned) { - Actor_SetRoomClearedTemp(globalCtx, globalCtx->roomCtx.currRoom.num); + Flags_SetClearTemp(globalCtx, globalCtx->roomCtx.currRoom.num); this->isDespawned = true; } @@ -2585,8 +2585,7 @@ void EnBigslime_ApplyDamageEffectBigslime(EnBigslime* this, GlobalContext* globa EnBigslime_SetPlayerParams(this, globalCtx); this->rotation = 0; EnBigslime_SetupFreeze(this); - minislime = (EnMinislime*)func_ActorCategoryIterateById(globalCtx, NULL, ACTORCAT_ITEMACTION, - ACTOR_ARROW_ICE); + minislime = (EnMinislime*)SubS_FindActor(globalCtx, NULL, ACTORCAT_ITEMACTION, ACTOR_ARROW_ICE); if (minislime != NULL) { minislime->shakeRefPos.z = -100.0f; } @@ -2644,7 +2643,7 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt EnBigslime_SetupCutscene(this); } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ELECTRIC_STUN) { this->stunTimer = 40; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_ELECTRIC_STUN; this->unk_38C = 0.75f; this->unk_388 = 2.0f; @@ -2652,7 +2651,7 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_STUN || this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_DEKU_STUN) { this->stunTimer = 40; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); EnBigslime_SetupStunGekko(this); } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ICE) { EnBigslime_GekkoFreeze(this); @@ -2722,7 +2721,7 @@ void EnBigslime_AddIceShardEffect(EnBigslime* this, GlobalContext* globalCtx) { } } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ICE_BROKEN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); EnBigslime_InitShockwave(this, globalCtx); } @@ -2791,9 +2790,9 @@ void EnBigslime_UpdateBigslime(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (this->actionFunc != EnBigslime_FormBigslime) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } else { - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); } if (this->actionFunc != EnBigslime_JumpGekko) { @@ -2831,9 +2830,9 @@ void EnBigslime_UpdateGekko(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (this->actionFunc != EnBigslime_FormBigslime) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } else { - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 40.0f, 80.0f, 0x1F); diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index ee51c74444..d1c876b6cc 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -105,7 +105,7 @@ void func_809CCEE8(EnBji01* this, GlobalContext* globalCtx) { this->actor.flags &= ~0x10000; } } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.unk11F22 = 0; globalCtx->msgCtx.unk11F10 = 0; func_809CD028(this, globalCtx); @@ -116,10 +116,9 @@ void func_809CCEE8(EnBji01* this, GlobalContext* globalCtx) { return; } } else { - this->moonsTear = - (ObjMoonStone*)func_ActorCategoryIterateById(globalCtx, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); + this->moonsTear = (ObjMoonStone*)SubS_FindActor(globalCtx, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); } - func_800B8500(&this->actor, globalCtx, 60.0f, 10.0f, 0); + func_800B8500(&this->actor, globalCtx, 60.0f, 10.0f, EXCH_ITEM_NONE); } } @@ -172,7 +171,8 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { } else { this->textId = 0x5F1; } - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, + EXCH_ITEM_NONE); break; case PLAYER_FORM_HUMAN: this->textId = 0x5F7; @@ -205,7 +205,7 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { } void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x444); func_809CCDE0(this, globalCtx); @@ -323,7 +323,7 @@ void func_809CD70C(EnBji01* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x444); func_809CCDE0(this, globalCtx); if (this->actor.shape.rot.y == this->actor.yawTowardsPlayer) { - func_800B86C8(&this->moonsTear->actor, globalCtx, &this->actor); /* Z-Target the Moon's Tear? */ + Actor_ChangeFocus(&this->moonsTear->actor, globalCtx, &this->actor); /* Z-Target the Moon's Tear? */ this->actionFunc = func_809CD77C; } } @@ -337,7 +337,7 @@ void func_809CD77C(EnBji01* this, GlobalContext* globalCtx) { void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx) { EnBji01* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 30.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600578C, &D_06000FDC, this->jointTable, this->morphTable, BJI_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -350,8 +350,7 @@ void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); /* initializes all elements of cutscenes to -1 */ - this->moonsTear = - (ObjMoonStone*)func_ActorCategoryIterateById(globalCtx, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); + this->moonsTear = (ObjMoonStone*)SubS_FindActor(globalCtx, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); switch (gSaveContext.entranceIndex) { case 0x4C00: /* Observatory from ECT */ @@ -396,7 +395,7 @@ void EnBji01_Update(Actor* thisx, GlobalContext* globalCtx) { } } - Actor_SetHeight(&this->actor, 40.0f); + Actor_SetFocus(&this->actor, 40.0f); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } diff --git a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h index ce6fd67244..9ac9fafa08 100644 --- a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h +++ b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h @@ -10,7 +10,12 @@ typedef void (*EnBombalActionFunc)(struct EnBombal*, GlobalContext*); typedef struct EnBombal { /* 0x0000 */ Actor actor; /* 0x0144 */ EnBombalActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x28FC]; + /* 0x0148 */ char unk148[0x4]; + /* 0x014C */ s16 unk_14C; + /* 0x0150 */ f32 unk_150; + /* 0x0154 */ char unk154[0x150]; + /* 0x02A4 */ Vec3f unk_2A4; + /* 0x02B0 */ char unk2B0[0x2794]; } EnBombal; // size = 0x2A44 extern const ActorInit En_Bombal_InitVars; 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 5a003ef85d..084439a4b5 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -4,7 +4,9 @@ * Description: Bombers - Jim */ +#include "overlays/actors/ovl_En_Bombal/z_en_bombal.h" #include "z_en_bomjima.h" +#include "objects/object_cs/object_cs.h" #define FLAGS 0x00000019 @@ -16,8 +18,11 @@ void EnBomjima_Update(Actor* thisx, GlobalContext* globalCtx); void EnBomjima_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BFEA94(EnBomjima* this, GlobalContext* globalCtx); +void func_80BFEB1C(EnBomjima* this); void func_80BFEB64(EnBomjima* this, GlobalContext* globalCtx); +void func_80BFEFF0(EnBomjima* this); void func_80BFF03C(EnBomjima* this, GlobalContext* globalCtx); +void func_80BFF120(EnBomjima* this); void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx); void func_80BFF430(EnBomjima* this, GlobalContext* globalCtx); void func_80BFF52C(EnBomjima* this, GlobalContext* globalCtx); @@ -26,13 +31,17 @@ void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx); void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx); void func_80BFFB40(EnBomjima* this, GlobalContext* globalCtx); void func_80BFFBC4(EnBomjima* this, GlobalContext* globalCtx); +void func_80BFFCFC(EnBomjima* this); void func_80BFFD48(EnBomjima* this, GlobalContext* globalCtx); void func_80BFFE48(EnBomjima* this, GlobalContext* globalCtx); void func_80BFFF54(EnBomjima* this, GlobalContext* globalCtx); void func_80C00168(EnBomjima* this, GlobalContext* globalCtx); +void func_80C00234(EnBomjima* this); void func_80C00284(EnBomjima* this, GlobalContext* globalCtx); -#if 0 +static s32 D_80C009F0 = 0; +static s32 D_80C009F4 = 0; + const ActorInit En_Bomjima_InitVars = { ACTOR_EN_BOMJIMA, ACTORCAT_NPC, @@ -45,83 +54,1075 @@ const ActorInit En_Bomjima_InitVars = { (ActorFunc)EnBomjima_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C00A18 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 30, 0, { 0, 0, 0 } }, }; +static u16 D_80C00A44[] = { + 0x0719, + 0x071A, + 0x071B, + 0x0708, +}; + +static u16 D_80C00A4C[] = { + 0x0739, + 0x073A, + 0x073B, + 0x0000, +}; + +static u16 D_80C00A54[] = { 0x0739, 0x073A, 0x073B, 0x0714, 0x0709, 0x070A, 0x070B, + 0x070C, 0x070D, 0x070E, 0x070F, 0x0712, 0x0713 }; + +static u16 D_80C00A70[] = { 0x0739, 0x073A, 0x073B, 0x0759, 0x0753, 0x0754, 0x0755, + 0x0756, 0x070D, 0x0757, 0x0758, 0x0712, 0x0713 }; + +static u16 D_80C00A8C[] = { + 0x0736, + 0x0737, + 0x0738, + 0x074E, +}; + +static AnimationHeader* sAnimations[] = { + &object_cs_Anim_0064B8, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, + &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, + &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, &object_cs_Anim_001708, + &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, &object_cs_Anim_0031C4, +}; + +static u8 D_80C00AE4[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, +}; + +void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBomjima* this = THIS; + s32 cs; + s32 i; + + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + this->actor.gravity = -3.0f; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, + this->morphTable, 21); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + gSaveContext.weekEventReg[83] &= (u8)~0x4; + this->actor.targetMode = 0; + this->unk_2E6 = ENBOMJIMA_GET_F0(&this->actor); + this->unk_2E4 = ENBOMJIMA_GET_F(&this->actor); + Actor_SetScale(&this->actor, 0.01f); + + if (this->unk_2E6 == 0) { + cs = this->actor.cutscene; + i = 0; + + while (cs != -1) { + // clang-format off + this->unk_2D4[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); + // clang-format on + i++; + } + + this->actionFunc = func_80BFEA94; + } else if (this->unk_2E6 == 2) { + func_80BFFCFC(this); + } + + if ((gSaveContext.weekEventReg[75] & 0x40) || (gSaveContext.weekEventReg[73] & 0x10) || + (gSaveContext.weekEventReg[85] & 2)) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnBomjima_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBomjima* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void func_80BFE32C(EnBomjima* this, GlobalContext* globalCtx, s32 arg2) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_2CA = arg2; + if (player->transformation == PLAYER_FORM_GORON) { + this->unk_2C8 = 1; + } + if (player->transformation == PLAYER_FORM_ZORA) { + this->unk_2C8 = 2; + } + + switch (this->unk_2CA) { + case 0: + if (player->transformation == PLAYER_FORM_DEKU) { + this->actor.textId = 0x759; + if (!(gSaveContext.weekEventReg[73] & 0x20)) { + this->actor.textId = 0x708; + } + } else if (player->transformation == PLAYER_FORM_HUMAN) { + this->actor.textId = 0x75A; + if (!(gSaveContext.weekEventReg[84] & 0x80)) { + this->actor.textId = 0x719; + } + } else if ((this->unk_2C8 == 1) || (this->unk_2C8 == 2)) { + this->actor.textId = D_80C00A44[this->unk_2C8]; + } + break; + + case 1: + this->actor.textId = D_80C00A4C[this->unk_2C8]; + break; + + case 2: + if (player->transformation == PLAYER_FORM_DEKU) { + this->actor.textId = D_80C00A54[this->unk_2C8]; + return; + } + this->actor.textId = D_80C00A70[this->unk_2C8]; + break; + + case 3: + this->actor.textId = D_80C00A8C[this->unk_2C8]; + break; + } +} + +void func_80BFE494(EnBomjima* this, s32 arg1, f32 arg2) { + this->unk_2EC = arg1; + this->unk_2CC = Animation_GetLastFrame(sAnimations[arg1]); + Animation_Change(&this->skelAnime, sAnimations[this->unk_2EC], arg2, 0.0f, this->unk_2CC, D_80C00AE4[this->unk_2EC], + -4.0f); +} + +void func_80BFE524(EnBomjima* this) { + if ((this->unk_2EC == 5) && + (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || + Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 18.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } + + if ((this->unk_2EC == 18) && + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 2.0f) || + Animation_OnFrame(&this->skelAnime, 4.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } + + if ((this->unk_2EC == 15) && Animation_OnFrame(&this->skelAnime, 15.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + } + + if ((this->unk_2EC == 6) && Animation_OnFrame(&this->skelAnime, 8.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + } +} + +void func_80BFE65C(EnBomjima* this) { + this->unk_2BC = 0; + this->unk_2C0 = 0; + this->unk_2BE = 0; + this->unk_2A2 = 0; + this->unk_290 = 0; + this->unk_29A = 0; +} + +void func_80BFE67C(EnBomjima* this, GlobalContext* globalCtx) { + f32 sp84 = this->skelAnime.curFrame; + f32 x; + f32 z; + s16 abs; + s16 abs2; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + CollisionPoly* sp50; + s32 sp4C; + + this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2A4); + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); + + switch (this->unk_2A2) { + case 0: + if (this->unk_2C0 == 0) { + Math_Vec3f_Copy(&sp54, &this->actor.home.pos); + + sp54.x += randPlusMinusPoint5Scaled(150.0f); + sp54.z += randPlusMinusPoint5Scaled(150.0f); + + abs = ABS_ALT(BINANG_SUB(this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp54))); + if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp6C, + &sp50, 1, 0, 0, 1, &sp4C)) { + func_80BFE494(this, 5, 1.0f); + Math_Vec3f_Copy(&this->unk_2A4, &sp54); + this->unk_2BE = Rand_S16Offset(30, 50); + this->unk_2A2++; + } + } + break; + + case 1: + if (sp84 >= 0.0f) { + this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2A4); + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 10, 2000, 20); + } + + abs2 = BINANG_SUB(this->actor.world.rot.y, this->unk_2DC); + if ((s16)ABS_ALT(abs2) < 0x100) { + Math_Vec3f_Copy(&sp60, &this->actor.world.pos); + + sp60.x += Math_SinS(this->actor.world.rot.y) * 60.0f; + sp60.z += Math_CosS(this->actor.world.rot.y) * 60.0f; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp60, &sp6C, &sp50, 1, 0, 0, 1, + &sp4C)) { + this->unk_2C0 = 0; + if (Rand_ZeroOne() < 0.5f) { + func_80BFE494(this, 19, 1.0f); + } else { + func_80BFE494(this, 0, 1.0f); + } + this->unk_2A2 = 0; + this->unk_2D0 = 0.0f; + break; + } + } + + x = this->unk_2A4.x - this->actor.world.pos.x; + z = this->unk_2A4.z - this->actor.world.pos.z; + + if ((this->unk_2BE == 0) || (sqrtf(SQ(x) + SQ(z)) < 4.0f)) { + this->unk_2C0 = Rand_S16Offset(20, 20); + if (!(this->unk_2C0 & 1)) { + func_80BFE494(this, 19, 1.0f); + } else { + func_80BFE494(this, 0, 1.0f); + } + this->unk_2A2 = 0; + this->unk_2D0 = 0.0f; + } else if (sp84 >= 0.0f) { + Math_ApproachF(&this->actor.world.pos.x, this->unk_2A4.x, 0.3f, this->unk_2D0); + Math_ApproachF(&this->actor.world.pos.z, this->unk_2A4.z, 0.3f, this->unk_2D0); + Math_ApproachF(&this->unk_2D0, 1.0f, 0.3f, 0.5f); + } + break; + } +} + +void func_80BFEA94(EnBomjima* this, GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; + + while (actor != NULL) { + if (actor->id != ACTOR_EN_BOMBAL) { + actor = actor->next; + continue; + } + + this->unk_2F0 = (EnBombal*)actor; + Math_Vec3f_Copy(&this->unk_2B0, &actor->world.pos); + if (this->unk_2F4 == 0) { + this->unk_2F4 = this->unk_2F0->actor.cutscene; + } + func_80BFEB1C(this); + break; + } +} + +void func_80BFEB1C(EnBomjima* this) { + func_80BFE494(this, 1, 1.0f); + func_80BFE65C(this); + this->unk_2A0 = 0; + this->actionFunc = func_80BFEB64; +} + +void func_80BFEB64(EnBomjima* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad[2]; + Vec3f sp40; + + func_80BFE32C(this, globalCtx, 0); + if (player->transformation == PLAYER_FORM_DEKU) { + if (gSaveContext.weekEventReg[73] & 0x20) { + this->unk_2C8 = 3; + func_80BFE32C(this, globalCtx, 3); + } else if (gSaveContext.weekEventReg[77] & 2) { + this->unk_2C8 = 11; + func_80BFE32C(this, globalCtx, 2); + } + } else if (player->transformation == PLAYER_FORM_HUMAN) { + if (gSaveContext.weekEventReg[84] & 0x80) { + this->unk_2C8 = 0; + func_80BFE32C(this, globalCtx, 3); + } else if (gSaveContext.weekEventReg[85] & 1) { + this->unk_2C8 = 11; + func_80BFE32C(this, globalCtx, 2); + } + } + + if (Text_GetFaceReaction(globalCtx, 0x11) != 0) { + this->actor.textId = Text_GetFaceReaction(globalCtx, 0x11); + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2DC = this->actor.yawTowardsPlayer; + func_80C00234(this); + return; + } + + if (ActorCutscene_GetCurrentIndex() == -1) { + func_800B8614(&this->actor, globalCtx, 70.0f); + } + + if ((this->unk_2F0->actor.update == NULL) || (this->unk_2F0->actor.colChkInfo.health == 0)) { + func_80BFEFF0(this); + return; + } + + switch (this->unk_2A2) { + case 0: + func_80BFE494(this, 4, 1.0f); + this->unk_29A = -7000; + this->unk_2A2++; + break; + + case 1: + this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2F0->actor.world.pos); + if (Animation_OnFrame(&this->skelAnime, 19.0f)) { + this->unk_2C0 = 5; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_SHOT_BREATH); + } + + if (this->unk_2C0 == 1) { + s16 sp3E = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2F0->actor.world.pos); + + if (Rand_ZeroOne() < 0.5f) { + sp3E += 0x4000; + } else { + sp3E += 0xC000; + } + + sp40.x = (Math_SinS(sp3E) * (Rand_ZeroFloat(20.0f) + 40.0f)) + this->unk_2F0->actor.world.pos.x; + sp40.y = this->unk_2F0->actor.world.pos.y - randPlusMinusPoint5Scaled(40.0f); + sp40.z = (Math_CosS(sp3E) * (Rand_ZeroFloat(20.0f) + 40.0f)) + this->unk_2F0->actor.world.pos.z; + + Audio_PlaySoundAtPosition(globalCtx, &sp40, 50, NA_SE_EV_BOMBERS_SHOT_EXPLOSUIN); + EffectSsHitMark_SpawnFixedScale(globalCtx, 0, &sp40); + this->unk_2BC++; + + if (((s16)Rand_ZeroFloat(2.0f) + 3) < this->unk_2BC) { + func_80BFE494(this, 5, 1.0f); + this->unk_29A = 0; + Math_Vec3f_Copy(&this->unk_2A4, &this->actor.home.pos); + this->unk_2A4.x += randPlusMinusPoint5Scaled(150.0f); + this->unk_2A4.z += randPlusMinusPoint5Scaled(150.0f); + this->unk_2A2++; + } + } + break; + + case 2: + this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2A4); + Math_ApproachF(&this->actor.world.pos.x, this->unk_2A4.x, 0.3f, 2.0f); + Math_ApproachF(&this->actor.world.pos.z, this->unk_2A4.z, 0.3f, 2.0f); + if (sqrtf(SQ(this->actor.world.pos.x - this->unk_2A4.x) + SQ(this->actor.world.pos.z - this->unk_2A4.z)) < + 4.0f) { + func_80BFE65C(this); + } + break; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); +} + +void func_80BFEFF0(EnBomjima* this) { + this->unk_2F0 = NULL; + func_80BFE494(this, 19, 1.0f); + func_80BFE65C(this); + this->unk_2A0 = 1; + this->actionFunc = func_80BFF03C; +} + +void func_80BFF03C(EnBomjima* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D4[0]); + } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D4[0])) { + ActorCutscene_SetIntentToPlay(this->unk_2D4[0]); + } else { + player->stateFlags1 &= ~0x20; + gSaveContext.weekEventReg[83] &= (u8)~4; + this->actor.world.rot.y = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)); + this->unk_2DC = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)); + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[0], &this->actor); + func_80BFF120(this); + } +} + +void func_80BFF120(EnBomjima* this) { + func_80BFE65C(this); + this->unk_2C4 = 30; + func_80BFE494(this, 6, 1.0f); + this->unk_2DE = 0; + this->unk_2A0 = 2; + this->actionFunc = func_80BFF174; +} + +void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx) { + f32 sp2C = this->skelAnime.curFrame; + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_2C4 == 1) { + ActorCutscene_Stop(this->unk_2D4[0]); + this->unk_2DE = 1; + } + + if (Text_GetFaceReaction(globalCtx, 0x11) != 0) { + this->actor.textId = Text_GetFaceReaction(globalCtx, 0x11); + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2DC = this->actor.yawTowardsPlayer; + func_80C00234(this); + return; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); + + if ((this->unk_2CC <= sp2C) && (this->unk_2BC < 5)) { + this->unk_2BC++; + if (this->unk_2EC != 19) { + func_80BFE494(this, 19, 1.0f); + } + } + + if (player->transformation == PLAYER_FORM_DEKU) { + if (gSaveContext.weekEventReg[73] & 0x20) { + this->unk_2C8 = 3; + func_80BFE32C(this, globalCtx, 3); + } else { + if (!(gSaveContext.weekEventReg[77] & 2)) { + if (this->unk_2E8 == 0) { + this->unk_2C8 = 4; + } else { + this->unk_2C8 = 3; + } + } else { + this->unk_2C8 = 11; + } + func_80BFE32C(this, globalCtx, 2); + } + } else if (player->transformation == PLAYER_FORM_HUMAN) { + if (gSaveContext.weekEventReg[84] & 0x80) { + this->unk_2C8 = 0; + func_80BFE32C(this, globalCtx, 3); + } else { + if (!(gSaveContext.weekEventReg[85] & 1)) { + if (this->unk_2EA == 0) { + this->unk_2C8 = 4; + } else { + this->unk_2C8 = 3; + } + } else { + this->unk_2C8 = 11; + } + func_80BFE32C(this, globalCtx, 2); + } + } else if (this->unk_2CA != 1) { + func_80BFE32C(this, globalCtx, 1); + } + + if (this->unk_2DE != 0) { + if (this->unk_2BC >= 5) { + func_80BFE67C(this, globalCtx); + } + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void func_80BFF3F0(EnBomjima* this) { + func_80BFE494(this, 15, 1.0f); + this->unk_2A0 = 3; + this->actionFunc = func_80BFF430; +} + +void func_80BFF430(EnBomjima* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->unk_2CC <= curFrame) { + EnBombal* bombal = (EnBombal*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBAL, this->unk_2B0.x, + this->unk_2B0.y, this->unk_2B0.z, 0, 0, 0, 0); + + if (bombal != NULL) { + bombal->unk_150 = 0.0f; + bombal->unk_14C = this->unk_2F4; + Actor_ChangeFocus(&this->actor, globalCtx, &bombal->actor); + gSaveContext.weekEventReg[83] &= (u8)~4; + func_80BFE65C(this); + func_801477B4(globalCtx); + this->actionFunc = func_80BFEA94; + } + } +} + +void func_80BFF4F4(EnBomjima* this) { + func_80BFE65C(this); + this->unk_2A0 = 4; + this->actionFunc = func_80BFF52C; +} + +void func_80BFF52C(EnBomjima* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + if (globalCtx->msgCtx.choiceIndex == 0) { + Player* player = GET_PLAYER(globalCtx); + + func_8019F208(); + func_80BFE65C(this); + this->unk_28E = 0; + this->unk_29A = 0; + this->unk_2C8 = 8; + if (player->transformation == PLAYER_FORM_DEKU) { + this->actor.textId = D_80C00A54[this->unk_2C8]; + } else { + this->actor.textId = D_80C00A70[this->unk_2C8]; + } + func_80151938(globalCtx, this->actor.textId); + play_sound(NA_SE_SY_FOUND); + func_80BFE494(this, 15, 1.0f); + this->unk_2A0 = 5; + this->actionFunc = func_80BFF6CC; + } else { + Player* player = GET_PLAYER(globalCtx); + + func_8019F230(); + func_80BFE65C(this); + this->unk_2C8 = 10; + if (player->transformation == PLAYER_FORM_DEKU) { + this->actor.textId = D_80C00A54[this->unk_2C8]; + this->unk_2E8 = 1; + } else { + this->actor.textId = D_80C00A70[this->unk_2C8]; + this->unk_2EA = 1; + } + func_80151938(globalCtx, this->actor.textId); + func_80C00234(this); + } + } +} + +void func_80BFF6CC(EnBomjima* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->unk_2CC <= curFrame) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + func_80BFE494(this, 1, 1.0f); + this->actionFunc = func_80BFF754; + } + } +} + +#ifdef NON_EQUIVALENT +// Data indexing is wrong + +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; +} EnBombjimaStruct; + +void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { + static EnBombjimaStruct D_80C00AF8[] = { + { 0x4000, 0x003C }, + { 0x4000, 0x001E }, + { 0xC000, 0x001E }, + { 0xC000, 0x003C }, + }; + Player* player = GET_PLAYER(globalCtx); + Vec3f spA0; + EnBombal* temp_s3; + s32 i; + f32 x; + f32 y; + f32 z; + + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D4[1]); + return; + } + + if (!ActorCutscene_GetCanPlayNext(this->unk_2D4[1])) { + ActorCutscene_SetIntentToPlay(this->unk_2D4[1]); + return; + } + + for (i = 1; i < 5; i++) { + Math_Vec3f_Copy(&spA0, &player->actor.world.pos); + + x = spA0.x - this->actor.world.pos.x; + y = spA0.y - this->actor.world.pos.y; + z = spA0.z - this->actor.world.pos.z; + + spA0.x += x * (2.0f + (i * 0.2f)); + spA0.y += y * (2.0f + (i * 0.2f)); + spA0.z += z * (2.0f + (i * 0.2f)); + + temp_s3 = (EnBombal*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_BOMJIMA, spA0.x, + spA0.y, spA0.z, 0, 0, 0, i + 32); + if (temp_s3 != NULL) { + s32 idx1 = (i * 2) - 1; + s32 idx2 = i * 2; + + Math_Vec3f_Copy(&spA0, &this->actor.world.pos); + + spA0.x += Math_SinS(D_80C00AF8[idx1 - 1].unk_00 + this->actor.world.rot.y) * D_80C00AF8[idx2].unk_02; + spA0.z += Math_CosS(D_80C00AF8[idx2].unk_00 + this->actor.world.rot.y) * D_80C00AF8[idx2].unk_02; + + Math_Vec3f_Copy(&temp_s3->unk_2A4, &spA0); + } + } + + D_80C009F0 = 0; + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[1], &this->actor); + this->actionFunc = func_80BFF9B0; +} +#else +static s16 D_80C00AF8[][2] = { + { 0x4000, 0x003C }, + { 0x4000, 0x001E }, + { 0xC000, 0x001E }, + { 0xC000, 0x003C }, +}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF754.s") #endif -extern ColliderCylinderInit D_80C00A18; +void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx) { + if (D_80C009F0 >= 4) { + Player* player = GET_PLAYER(globalCtx); -extern UNK_TYPE D_060064B8; + D_80C009F0 = 0; + this->unk_2C8 = 9; + if (player->transformation == PLAYER_FORM_DEKU) { + gSaveContext.weekEventReg[73] |= 0x10; + gSaveContext.weekEventReg[77] |= 2; + } else { + gSaveContext.weekEventReg[85] |= 2; + gSaveContext.weekEventReg[85] |= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/EnBomjima_Init.s") + gSaveContext.weekEventReg[11] &= (u8)~1; + gSaveContext.weekEventReg[11] &= (u8)~2; + gSaveContext.weekEventReg[11] &= (u8)~4; + gSaveContext.weekEventReg[11] &= (u8)~8; + gSaveContext.weekEventReg[11] &= (u8)~0x10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/EnBomjima_Destroy.s") + gSaveContext.weekEventReg[76] &= (u8)~1; + gSaveContext.weekEventReg[76] &= (u8)~2; + gSaveContext.weekEventReg[76] &= (u8)~4; + gSaveContext.weekEventReg[76] &= (u8)~8; + gSaveContext.weekEventReg[76] &= (u8)~0x10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFE32C.s") + gSaveContext.unk_FE6 = 0; + gSaveContext.unk_FE7[0] = 0; + gSaveContext.unk_FE7[1] = 0; + gSaveContext.unk_FE7[2] = 0; + gSaveContext.unk_FE7[3] = 0; + gSaveContext.unk_FE7[4] = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFE494.s") + func_80BFE494(this, 3, 1.0f); + this->unk_2C8 = 9; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFE524.s") + if (player->transformation == PLAYER_FORM_DEKU) { + this->actor.textId = D_80C00A54[this->unk_2C8]; + } else { + this->actor.textId = D_80C00A70[this->unk_2C8]; + } + func_80151938(globalCtx, this->actor.textId); + this->actionFunc = func_80BFFB40; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFE65C.s") +void func_80BFFB40(EnBomjima* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + func_80BFE494(this, 15, 1.0f); + D_80C009F0 = 100; + this->unk_2DC = 0; + this->actionFunc = func_80BFFBC4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFE67C.s") +void func_80BFFBC4(EnBomjima* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFEA94.s") + if ((this->unk_2EC != 1) && (this->unk_2CC <= curFrame)) { + func_80BFE494(this, 1, 1.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFEB1C.s") + if ((D_80C009F4 != 0) && (this->unk_2C2 == 0)) { + this->unk_2C2 = Rand_S16Offset(5, 5); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFEB64.s") + if (this->unk_2C2 == 1) { + this->unk_2DC = -10000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFEFF0.s") + Math_SmoothStepToS(&this->unk_290, this->unk_2DC, 1, 5000, 0); + if (D_80C009F0 >= 104) { + D_80C009F0 = 0; + func_801477B4(globalCtx); + globalCtx->nextEntranceIndex = Entrance_CreateIndexFromSpawn(6); + gSaveContext.nextCutsceneIndex = 0; + globalCtx->sceneLoadFlag = 20; + globalCtx->unk_1887F = 0x56; + gSaveContext.nextTransition = 3; + ActorCutscene_Stop(this->unk_2D4[1]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF03C.s") +void func_80BFFCFC(EnBomjima* this) { + func_80BFE65C(this); + func_80BFE494(this, 18, 1.0f); + this->unk_2A0 = 6; + this->actionFunc = func_80BFFD48; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF120.s") +void func_80BFFD48(EnBomjima* this, GlobalContext* globalCtx) { + s32 pad[2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF174.s") + this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2A4); + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); + Math_ApproachF(&this->actor.world.pos.x, this->unk_2A4.x, 0.3f, 4.0f); + Math_ApproachF(&this->actor.world.pos.z, this->unk_2A4.z, 0.3f, 4.0f); + if (sqrtf(SQ(this->actor.world.pos.x - this->unk_2A4.x) + SQ(this->actor.world.pos.z - this->unk_2A4.z)) < 4.0f) { + D_80C009F0++; + this->unk_2DC = this->actor.parent->world.rot.y; + func_80BFE494(this, 0, 1.0f); + this->actionFunc = func_80BFFE48; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF3F0.s") +void func_80BFFE48(EnBomjima* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); + Math_ApproachF(&this->actor.world.pos.x, this->unk_2A4.x, 0.3f, 4.0f); + Math_ApproachF(&this->actor.world.pos.z, this->unk_2A4.z, 0.3f, 4.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF430.s") + if (D_80C009F0 >= 100) { + if (this->unk_2E4 != 4) { + func_80BFE494(this, 15, 1.0f); + this->unk_2DC = 0; + func_80BFE65C(this); + this->actionFunc = func_80BFFF54; + } else { + Math_SmoothStepToS(&this->unk_290, 10000, 1, 5000, 0); + if (D_80C009F0 >= 103) { + this->unk_2DC = 0; + func_80BFE494(this, 15, 1.0f); + func_80BFE65C(this); + this->actionFunc = func_80BFFF54; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF4F4.s") +void func_80BFFF54(EnBomjima* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF52C.s") + Math_SmoothStepToS(&this->unk_290, this->unk_2DC, 1, 5000, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF6CC.s") + if ((D_80C009F4 != 0) && (this->unk_2C2 == 0)) { + this->unk_2C2 = Rand_S16Offset(5, 5); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF754.s") + if (this->unk_2C2 == 1) { + this->unk_2DC = -10000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF9B0.s") + if (this->unk_2E4 != 4) { + if ((this->unk_2EC != 0) && (this->unk_2CC <= curFrame)) { + D_80C009F0++; + func_80BFE494(this, 0, 1.0f); + } + } else if ((this->unk_2EC != 8) && (this->unk_2CC <= curFrame)) { + func_80BFE494(this, 8, 1.0f); + D_80C009F4 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFFB40.s") + if (this->unk_2EC == 8) { + if ((D_80C009F4 == 1) && Animation_OnFrame(&this->skelAnime, 7.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); + D_80C009F4 = 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFFBC4.s") + if ((this->unk_2CC <= curFrame) && (this->unk_2C0 == 0)) { + this->unk_2C0 = 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFFCFC.s") + if (this->unk_2C0 == 1) { + D_80C009F0++; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFFD48.s") +void func_80C0011C(EnBomjima* this) { + func_80BFE65C(this); + func_80BFE494(this, 0, 1.0f); + this->unk_2A0 = 7; + this->actionFunc = func_80C00168; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFFE48.s") +void func_80C00168(EnBomjima* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFFF54.s") + if (player->transformation == PLAYER_FORM_HUMAN) { + this->unk_2C8 = 4; + } else if (player->transformation == PLAYER_FORM_DEKU) { + this->unk_2C8 = 7; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80C0011C.s") + func_80BFE32C(this, globalCtx, 0); + func_80BFE67C(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80C00168.s") + if (Text_GetFaceReaction(globalCtx, 0x11) != 0) { + this->actor.textId = Text_GetFaceReaction(globalCtx, 0x11); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80C00234.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2DC = this->actor.yawTowardsPlayer; + func_80C00234(this); + } else { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80C00284.s") +void func_80C00234(EnBomjima* this) { + func_80BFE494(this, 3, 1.0f); + this->collider.dim.radius = 15; + this->collider.dim.height = 40; + func_80BFE65C(this); + this->actionFunc = func_80C00284; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/EnBomjima_Update.s") +void func_80C00284(EnBomjima* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 sp28 = this->skelAnime.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80C007F4.s") + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); + if (((this->unk_2A0 == 0) || (this->unk_2C8 == 10) || (this->unk_2C8 == 11) || (this->unk_2CA == 1)) && + (this->unk_2CC <= sp28)) { + if (!(this->unk_2BC & 1)) { + func_80BFE494(this, 3, 1.0f); + } else { + func_80BFE494(this, 16, 1.0f); + } + this->unk_2BC++; + this->unk_2BC &= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/EnBomjima_Draw.s") + if ((player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_ZORA)) { + if (player->transformation == PLAYER_FORM_HUMAN) { + this->unk_28E = -4000; + } + } else { + this->unk_28E = -6000; + } + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + this->collider.dim.radius = 10; + this->collider.dim.height = 30; + if ((this->unk_2A0 == 4) || (this->unk_2CA == 1) || ((this->unk_2CA == 3) && (this->unk_2C8 >= 2))) { + this->unk_28E = 0; + if (player->stateFlags1 & 0x20) { + player->stateFlags1 &= ~0x20; + } + + if ((this->unk_2F0 == 0) || (this->unk_2F0->actor.update == NULL) || + (this->unk_2F0->actor.colChkInfo.health <= 0)) { + func_80BFF3F0(this); + } else { + func_80BFE65C(this); + func_801477B4(globalCtx); + this->actionFunc = func_80BFEA94; + } + return; + } + + func_801477B4(globalCtx); + + switch (this->unk_2CA) { + case 0: + this->unk_28E = 0; + if (this->unk_2A0 == 7) { + func_80C0011C(this); + } else { + func_80BFEB1C(this); + } + break; + + case 2: + if (this->unk_2C8 == 10) { + func_80BFE65C(this); + this->unk_28E = 0; + func_80BFE494(this, 1, 1.0f); + this->unk_2A0 = 2; + this->actionFunc = func_80BFF174; + return; + } + + this->unk_2C8++; + if (player->transformation == PLAYER_FORM_DEKU) { + if ((this->unk_2E8 != 0) && (this->unk_2C8 == 4)) { + this->unk_2C8 = 6; + } + this->actor.textId = D_80C00A54[this->unk_2C8]; + } else { + if ((this->unk_2EA != 0) && (this->unk_2C8 == 4)) { + this->unk_2C8 = 6; + } + this->actor.textId = D_80C00A70[this->unk_2C8]; + } + func_80151938(globalCtx, this->actor.textId); + if ((this->unk_2C8 == 7) || (this->unk_2C8 == 12)) { + func_80BFF4F4(this); + } + break; + + case 3: + this->unk_2C8++; + this->actor.textId = D_80C00A8C[this->unk_2C8]; + func_80151938(globalCtx, this->actor.textId); + if (this->unk_2C8 >= 2) { + func_80BFE494(this, 17, 1.0f); + } + break; + } + } +} + +void EnBomjima_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBomjima* this = THIS; + + if (this->unk_2BE != 0) { + this->unk_2BE--; + } + + if (this->unk_2C2 != 0) { + this->unk_2C2--; + } + + if (this->unk_2C0 != 0) { + this->unk_2C0--; + } + + if (this->unk_2C6 != 0) { + this->unk_2C6--; + } + + if (this->unk_2C4 != 0) { + this->unk_2C4--; + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y = this->actor.world.rot.y; + func_80BFE524(this); + Actor_SetFocus(&this->actor, 20.0f); + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 5000, 0); + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 1000, 0); + Math_SmoothStepToS(&this->unk_294, this->unk_29A, 1, 1000, 0); + + if (this->unk_2E2 == 0) { + this->unk_2E0++; + if (this->unk_2E0 >= 3) { + this->unk_2E0 = 0; + this->unk_2E2 = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + this->actor.uncullZoneForward = 500.0f; + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 EnBomjima_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBomjima* this = THIS; + + if (limbIndex == 8) { + rot->z += this->unk_294; + } + + if ((limbIndex == 15) && (this->unk_2E6 == 2)) { + *dList = NULL; + } + + if (limbIndex == 17) { + rot->x += this->unk_28A; + rot->z += this->unk_288; + } + + if ((limbIndex == 19) && (this->unk_2E6 == 2)) { + *dList = NULL; + } + + if ((limbIndex == 20) && (this->unk_2E6 == 0)) { + *dList = NULL; + } + + return false; +} + +#include "overlays/ovl_En_Bomjima/ovl_En_Bomjima.c" + +void EnBomjima_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Gfx* D_80C00B28[] = { + gEnBomjima_D_80C00B08, gEnBomjima_D_80C00B18, gEnBomjima_D_80C00B18, + gEnBomjima_D_80C00B18, gEnBomjima_D_80C00B18, + }; + static TexturePtr D_80C00B3C[] = { + &object_cs_Tex_00C520, + &object_cs_Tex_00CD20, + &object_cs_Tex_00D520, + }; + static TexturePtr D_80C00B48[] = { + &object_cs_Tex_00E620, &object_cs_Tex_00EA20, &object_cs_Tex_00EE20, + &object_cs_Tex_00DD20, &object_cs_Tex_00F220, + }; + EnBomjima* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C00B3C[this->unk_2E0])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C00B48[this->unk_2E4])); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(D_80C00B28[this->unk_2E4])); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnBomjima_OverrideLimbDraw, NULL, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h index b24725d217..c01e70bd51 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h @@ -7,11 +7,53 @@ struct EnBomjima; typedef void (*EnBomjimaActionFunc)(struct EnBomjima*, GlobalContext*); +#define ENBOMJIMA_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) +#define ENBOMJIMA_GET_F(thisx) ((thisx)->params & 0xF) + typedef struct EnBomjima { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x140]; - /* 0x0284 */ EnBomjimaActionFunc actionFunc; - /* 0x0288 */ char unk_288[0xBC]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[21]; + /* 0x206 */ Vec3s morphTable[21]; + /* 0x284 */ EnBomjimaActionFunc actionFunc; + /* 0x288 */ s16 unk_288; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ UNK_TYPE1 unk28C[2]; + /* 0x28E */ s16 unk_28E; + /* 0x290 */ s16 unk_290; + /* 0x292 */ UNK_TYPE1 unk292[2]; + /* 0x294 */ s16 unk_294; + /* 0x296 */ UNK_TYPE1 unk296[4]; + /* 0x29A */ s16 unk_29A; + /* 0x29C */ UNK_TYPE1 unk29C[4]; + /* 0x2A0 */ s16 unk_2A0; + /* 0x2A2 */ s16 unk_2A2; + /* 0x2A4 */ Vec3f unk_2A4; + /* 0x2B0 */ Vec3f unk_2B0; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C2 */ s16 unk_2C2; + /* 0x2C4 */ s16 unk_2C4; + /* 0x2C6 */ s16 unk_2C6; + /* 0x2C8 */ s16 unk_2C8; + /* 0x2CA */ s16 unk_2CA; + /* 0x2CC */ f32 unk_2CC; + /* 0x2D0 */ f32 unk_2D0; + /* 0x2D4 */ s16 unk_2D4[2]; + /* 0x2D8 */ UNK_TYPE1 unk2D8[4]; // maybe a part of the above? + /* 0x2DC */ s16 unk_2DC; + /* 0x2DE */ s16 unk_2DE; + /* 0x2E0 */ s16 unk_2E0; + /* 0x2E2 */ s16 unk_2E2; + /* 0x2E4 */ s16 unk_2E4; + /* 0x2E6 */ s16 unk_2E6; + /* 0x2E8 */ s16 unk_2E8; + /* 0x2EA */ s16 unk_2EA; + /* 0x2EC */ s32 unk_2EC; + /* 0x2F0 */ EnBombal* unk_2F0; + /* 0x2F4 */ s16 unk_2F4; + /* 0x2F8 */ ColliderCylinder collider; } EnBomjima; // size = 0x344 extern const ActorInit En_Bomjima_InitVars; diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index 229803174b..dc776fa59a 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -76,7 +76,7 @@ void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx) { EnBomjimb* this = THIS; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 19.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); this->actor.gravity = -2.0f; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, this->morphTable, 21); @@ -181,20 +181,20 @@ void func_80C011CC(EnBomjimb* this) { if ((this->unk_2DC == 5) && (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 18.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOMBERS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); } if ((this->unk_2DC == 19) && (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOMBERS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); } if ((this->unk_2DC == 18) && Animation_OnFrame(&this->skelAnime, 15.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOMBERS_LAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); } if ((this->unk_2DC == 7) && Animation_OnFrame(&this->skelAnime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOMBERS_LAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); } } @@ -447,7 +447,7 @@ void func_80C01CD0(EnBomjimb* this, GlobalContext* globalCtx) { } if ((this->unk_2C0 == 0) && (this->unk_2E4->bgCheckFlags & 1)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PUT_DOWN_WOODBOX); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PUT_DOWN_WOODBOX); this->unk_2C0 = 1; } @@ -501,7 +501,7 @@ void func_80C0201C(EnBomjimb* this, GlobalContext* globalCtx) { } } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_2CA = 10; this->actionFunc = func_80C02A14; } else { @@ -691,7 +691,7 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { if (gSaveContext.unk_FE6 > 4) { func_801A3098(0x922); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_SY_PIECE_OF_HEART); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); } switch (this->unk_2C8) { @@ -747,7 +747,7 @@ void func_80C02A14(EnBomjimb* this, GlobalContext* globalCtx) { player->actor.freezeTimer = 3; if (this->unk_2E0 == 0) { if (Animation_OnFrame(&this->skelAnime, 7.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HUMAN_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); this->unk_2E0 = 1; } } @@ -757,7 +757,7 @@ void func_80C02A14(EnBomjimb* this, GlobalContext* globalCtx) { player->actor.freezeTimer = 3; } - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); if ((this->unk_2CA == 8) && (gSaveContext.unk_FE6 >= 5)) { func_80C02CA4(this, globalCtx); @@ -776,7 +776,7 @@ void func_80C02BCC(EnBomjimb* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 5000, 0); if (this->unk_2C0 == 0) { player->actor.freezeTimer = 3; - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); this->unk_2C0 = 1; player->stateFlags1 &= ~0x10000000; @@ -829,11 +829,11 @@ void EnBomjimb_Update(Actor* thisx, GlobalContext* globalCtx2) { SkelAnime_Update(&this->skelAnime); this->actor.shape.rot.y = this->actor.world.rot.y; func_80C011CC(this); - Actor_SetHeight(&this->actor, 20.0f); + Actor_SetFocus(&this->actor, 20.0f); this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (this->unk_2CA == 0) { if ((this->unk_2E4 != NULL) && (this->unk_2E4->update != NULL)) { diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.h b/src/overlays/actors/ovl_En_Box/z_en_box.h index ad688b9a02..aa7c425d2d 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.h +++ b/src/overlays/actors/ovl_En_Box/z_en_box.h @@ -9,7 +9,11 @@ typedef void (*EnBoxActionFunc)(struct EnBox*, GlobalContext*); typedef struct EnBox { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xBC]; + /* 0x0144 */ char unk_144[0xAC]; + /* 0x01F0 */ char unk_1F0[0x01]; + /* 0x01F1 */ u8 unk_1F1; + /* 0x01F2 */ char unk_1F2[0x02]; + /* 0x01F4 */ char unk_1F4[0x0C]; /* 0x0200 */ EnBoxActionFunc actionFunc; /* 0x0204 */ char unk_204[0x20]; } EnBox; // size = 0x224 diff --git a/src/overlays/actors/ovl_En_Bu/z_en_bu.c b/src/overlays/actors/ovl_En_Bu/z_en_bu.c index 3c56535256..6dab7f307d 100644 --- a/src/overlays/actors/ovl_En_Bu/z_en_bu.c +++ b/src/overlays/actors/ovl_En_Bu/z_en_bu.c @@ -44,7 +44,7 @@ void EnBu_DoNothing(EnBu* this, GlobalContext* globalCtx) { void EnBu_Update(Actor* thisx, GlobalContext* globalCtx) { EnBu* this = THIS; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); this->actionFunc(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Cha/z_en_cha.c b/src/overlays/actors/ovl_En_Cha/z_en_cha.c index d8f32613f4..d5a2f0be06 100644 --- a/src/overlays/actors/ovl_En_Cha/z_en_cha.c +++ b/src/overlays/actors/ovl_En_Cha/z_en_cha.c @@ -86,12 +86,12 @@ void EnCha_Ring(EnCha* this, GlobalContext* globalCtx) { void EnCha_Idle(EnCha* this, GlobalContext* globalCtx) { if (gSaveContext.weekEventReg[60] & 4) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_DOOR_BELL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); gSaveContext.weekEventReg[60] &= 0xFB; this->actor.home.rot.z = 0x7D0; } if (this->collider.base.acFlags & AC_HIT) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_DOOR_BELL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); this->actor.home.rot.z = 0x7D0; if (!(gSaveContext.weekEventReg[51] & 4)) { gSaveContext.weekEventReg[51] |= 4; @@ -117,8 +117,8 @@ void EnCha_Update(Actor* thisx, GlobalContext* globalCtx) { void EnCha_Draw(Actor* thisx, GlobalContext* globalCtx) { EnCha* this = THIS; - func_800BDFC0(globalCtx, D_06000710); + Gfx_DrawDListOpa(globalCtx, D_06000710); Matrix_InsertTranslation(-1094.0f, 4950.0f, 9.0f, MTXMODE_APPLY); Matrix_InsertXRotation_s(this->actor.home.rot.x, MTXMODE_APPLY); - func_800BDFC0(globalCtx, D_06000958); + Gfx_DrawDListOpa(globalCtx, D_06000958); } diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index f76b22296c..d323c98d27 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -538,7 +538,7 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { func_80169590(globalCtx, 0, 1); func_80169590(globalCtx, this->camId, 7); func_800B7298(globalCtx, &this->actor, 4); - camera = Play_GetCamera(globalCtx, 0); + camera = Play_GetCamera(globalCtx, MAIN_CAM); this->eye.x = camera->eye.x; this->eye.y = camera->eye.y; this->eye.z = camera->eye.z; @@ -556,8 +556,8 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { } player->actor.speedXZ = 0.0f; - if (func_80152498(&globalCtx->msgCtx) == 0) { - camera = Play_GetCamera(globalCtx, 0); + if (Message_GetState(&globalCtx->msgCtx) == 0) { + camera = Play_GetCamera(globalCtx, MAIN_CAM); camera->eye = this->eye; camera->eyeNext = this->eye; camera->at = this->at; diff --git a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c index d65232214b..531e0b1229 100644 --- a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c +++ b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c @@ -1,10 +1,12 @@ /* * File: z_en_col_man.c * Overlay: ovl_En_Col_Man - * Description: Piece of Heart spawned by Fish2 + * Description: Lab HP, Garo Master falling rocks, Garo Master bomb */ #include "z_en_col_man.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00100000 @@ -13,17 +15,35 @@ void EnColMan_Init(Actor* thisx, GlobalContext* globalCtx); void EnColMan_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnColMan_Update(Actor* thisx, GlobalContext* globalCtx); - +void func_80AFDD60(EnColMan* this); void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx); -void func_80AFDF00(EnColMan* this, GlobalContext* globalCtx); +void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, GlobalContext* globalCtx); +void func_80AFDF60(EnColMan* this); void func_80AFDFB4(EnColMan* this, GlobalContext* globalCtx); +void func_80AFE234(EnColMan* this); void func_80AFE25C(EnColMan* this, GlobalContext* globalCtx); +void func_80AFE414(Actor* thisx, GlobalContext* globalCtx); +void func_80AFE4AC(Actor* thisx, GlobalContext* globalCtx); +void func_80AFE584(Actor* thisx, GlobalContext* globalCtx); +void func_80AFE650(Actor* thisx, GlobalContext* globalCtx); -#if 0 -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AFE730 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 11, 1, { 0, 0, 0 } }, }; @@ -39,34 +59,217 @@ const ActorInit En_Col_Man_InitVars = { (ActorFunc)NULL, }; -#endif +static Color_RGBA8 primColor = { 60, 50, 20, 255 }; +static Color_RGBA8 envColor = { 40, 30, 30, 255 }; -extern ColliderCylinderInit D_80AFE730; +void EnColMan_Init(Actor* thisx, GlobalContext* globalCtx) { + EnColMan* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/EnColMan_Init.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.targetMode = 1; + this->scale = (BREG(55) / 1000.0f) + 0.01f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/EnColMan_Destroy.s") + switch (this->actor.params) { + case EN_COL_MAN_HEART_PIECE: + case EN_COL_MAN_RECOVERY_HEART: + default: + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); + func_80AFDD60(this); + break; + case EN_COL_MAN_FALLING_ROCK: + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); + func_80AFDF60(this); + break; + case EN_COL_MAN_CUTSCENE_BOMB: + case EN_COL_MAN_GAMEPLAY_BOMB: + func_80AFE234(this); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFDD60.s") +void EnColMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnColMan* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFDE00.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFDF00.s") +void func_80AFDD60(EnColMan* this) { + if (!(gSaveContext.weekEventReg[56] & 2)) { + this->actor.draw = func_80AFE414; + this->actor.shape.yOffset = 700.0f; + if (this->actor.params == EN_COL_MAN_HEART_PIECE) { + this->actor.gravity = -2.0f; + } + this->type = EN_COL_MAN_HEART_PIECE; + } else { + this->actor.draw = func_80AFE4AC; + this->actor.shape.yOffset = 300.0f; + this->actor.shape.shadowScale = 5.0f; + if (this->actor.params == EN_COL_MAN_HEART_PIECE) { + this->actor.gravity = -2.0f; + } + this->type = EN_COL_MAN_RECOVERY_HEART; + } + this->actionFunc = func_80AFDE00; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFDF60.s") +void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx) { + if (this->actor.bgCheckFlags & 1) { + if (this->actor.params == EN_COL_MAN_HEART_PIECE) { + this->actor.params = EN_COL_MAN_RECOVERY_HEART; + this->actor.speedXZ = 2.0f; + this->actor.velocity.y = 8.0f; + } else { + this->actor.speedXZ = 0.0f; + } + } + if (!(gSaveContext.weekEventReg[56] & 2)) { + this->actor.shape.rot.y += 0x3E8; + } + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actor.draw = NULL; + this->actionFunc = EnColMan_SetHeartPieceCollectedAndKill; + } else if (!(gSaveContext.weekEventReg[56] & 2)) { + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 40.0f, 40.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_RECOVERY_HEART, 40.0f, 40.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFDFB4.s") +void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + gSaveContext.weekEventReg[56] |= 2; + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFE234.s") +void func_80AFDF60(EnColMan* this) { + this->actor.draw = func_80AFE584; + this->actor.flags |= 0x10; + this->actor.flags |= 0x20; + this->type = EN_COL_MAN_FALLING_ROCK; + this->actionFunc = func_80AFDFB4; + this->actor.shape.shadowScale = 5.0f; + this->actor.gravity = -3.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFE25C.s") +void func_80AFDFB4(EnColMan* this, GlobalContext* globalCtx) { + s32 i; + Vec3f velocity; + Vec3f accel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/EnColMan_Update.s") + this->scale = (BREG(55) / 10000.0f) + 0.0015f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFE414.s") + if ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f)) { + if (!this->hasSetRandomValues) { + this->actor.world.rot.y = randPlusMinusPoint5Scaled(30000.0f); + this->actor.speedXZ = 2.0f + BREG(56) + Rand_ZeroFloat(2.0f); + this->actor.velocity.y = 12.0f + BREG(57) + Rand_ZeroFloat(5.0f); + this->hasSetRandomValues = true; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ANSATSUSYA_ROCK); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFE4AC.s") + for (i = 0; i < 2; i++) { + velocity.x = randPlusMinusPoint5Scaled(2.0f); + velocity.y = Rand_ZeroFloat(2.0f) + 1.0f; + velocity.z = randPlusMinusPoint5Scaled(2.0f); + accel.y = -0.1f; + accel.z = 0.0f; + accel.x = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFE584.s") + func_800B0EB0(globalCtx, &this->actor.world.pos, &velocity, &accel, &primColor, &envColor, + Rand_ZeroFloat(50.0f) + 60.0f, 30, Rand_ZeroFloat(5.0f) + 20.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Col_Man/func_80AFE650.s") + Actor_MarkForDeath(&this->actor); + } +} + +void func_80AFE234(EnColMan* this) { + this->actor.draw = func_80AFE650; + this->type = EN_COL_MAN_CUTSCENE_BOMB; + this->actionFunc = func_80AFE25C; +} + +void func_80AFE25C(EnColMan* this, GlobalContext* globalCtx) { + this->scale = BREG(55) * 0.01f + 0.05f; + + if (BREG(60) || (this->actor.world.rot.z != 0)) { + if (this->actor.params == EN_COL_MAN_CUTSCENE_BOMB) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.parent->world.pos.x, + this->actor.parent->world.pos.y, this->actor.parent->world.pos.z, 0, 0, 0, + CLEAR_TAG_SMALL_EXPLOSION); + } else { + EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + + if (bomb != NULL) { + bomb->timer = 0; + } + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_MarkForDeath(&this->actor); + } +} + +void EnColMan_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnColMan* this = THIS; + + Actor_SetScale(&this->actor, this->scale); + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 30.0f, 30.0f, 0x1F); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80AFE414(Actor* thisx, GlobalContext* globalCtx) { + EnColMan* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + func_800B8118(&this->actor, globalCtx, 0); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_05AAB0); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80AFE4AC(Actor* thisx, GlobalContext* globalCtx) { + EnColMan* this = THIS; + + func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(globalCtx->state.gfxCtx); + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&gameplay_keep_Tex_05E6F0)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80AFE584(Actor* thisx, GlobalContext* globalCtx) { + func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06AB30); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80AFE650(Actor* thisx, GlobalContext* globalCtx) { + func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(globalCtx->state.gfxCtx); + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&gameplay_keep_Tex_05CEF0)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.h b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.h index 6bab3c11a6..ab1ac285dd 100644 --- a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.h +++ b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.h @@ -8,10 +8,21 @@ struct EnColMan; typedef void (*EnColManActionFunc)(struct EnColMan*, GlobalContext*); typedef struct EnColMan { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnColManActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x58]; -} EnColMan; // size = 0x1A0 + /* 0x000 */ Actor actor; + /* 0x144 */ EnColManActionFunc actionFunc; + /* 0x148 */ s16 type; // never used, only set + /* 0x14C */ s32 hasSetRandomValues; + /* 0x150 */ f32 scale; + /* 0x154 */ ColliderCylinder collider; +} EnColMan; /* size = 0x1A0 */ + +typedef enum { + /* 0 */ EN_COL_MAN_HEART_PIECE, + /* 1 */ EN_COL_MAN_RECOVERY_HEART, + /* 2 */ EN_COL_MAN_FALLING_ROCK, + /* 3 */ EN_COL_MAN_CUTSCENE_BOMB, + /* 4 */ EN_COL_MAN_GAMEPLAY_BOMB, +} EnColManType; extern const ActorInit En_Col_Man_InitVars; diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index 54eb091b76..9f997cc1eb 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -108,7 +108,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnCow* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 72.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 72.0f); switch (EN_COW_TYPE(thisx)) { case EN_COW_TYPE_DEFAULT: @@ -207,7 +207,7 @@ void EnCow_UpdateAnimation(EnCow* this, GlobalContext* globalCtx) { } void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { this->actor.flags &= ~0x10000; func_801477B4(globalCtx); this->actionFunc = EnCow_Idle; @@ -215,7 +215,7 @@ void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { } void EnCow_GiveMilkEnd(EnCow* this, GlobalContext* globalCtx) { - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->actor.flags &= ~0x10000; this->actionFunc = EnCow_Idle; } @@ -226,21 +226,21 @@ void EnCow_GiveMilkWait(EnCow* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = EnCow_GiveMilkEnd; } else { - func_800B8A1C(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); } } void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { this->actor.flags &= ~0x10000; func_801477B4(globalCtx); this->actionFunc = EnCow_GiveMilkWait; - func_800B8A1C(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); } } void EnCow_CheckForEmptyBottle(EnCow* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { if (func_80114E90()) { func_80151938(globalCtx, 0x32C9); // Text to give milk. this->actionFunc = EnCow_GiveMilk; @@ -252,7 +252,7 @@ void EnCow_CheckForEmptyBottle(EnCow* this, GlobalContext* globalCtx) { } void EnCow_Talk(EnCow* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->actor.textId == 0x32C8) { // Text to give milk after playing Epona's Song. this->actionFunc = EnCow_CheckForEmptyBottle; } else if (this->actor.textId == 0x32C9) { // Text to give milk. @@ -345,13 +345,13 @@ void EnCow_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliders[0].base); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliders[1].base); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (SkelAnime_Update(&this->skelAnime)) { if (this->skelAnime.animation == &D_060001CC) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_COW_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_COW_CRY); Animation_Change(&this->skelAnime, &D_06004264, 1.0f, 0.0f, Animation_GetLastFrame(&D_06004264), ANIMMODE_ONCE, 1.0f); } else { diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index b84feb51a2..0e83d1091f 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -192,7 +192,7 @@ s32 func_80B3E69C(EnDai* this, GlobalContext* globalCtx) { if ((globalCtx->csCtx.state != 0) && (globalCtx->sceneNum == SCENE_12HAKUGINMAE) && (globalCtx->csCtx.unk_12 == 0) && !(gSaveContext.weekEventReg[30] & 1)) { if (!(this->unk_1CE & 0x10)) { - Actor_SetSwitchFlag(globalCtx, 20); + Flags_SetSwitch(globalCtx, 20); this->unk_1CE |= (0x80 | 0x10); this->unk_1CE &= ~(0x100 | 0x20); this->unk_1CC = 0xFF; @@ -216,7 +216,7 @@ s32 func_80B3E7C8(EnDai* this, GlobalContext* globalCtx) { s32 ret = false; if (this->unk_1CE & 7) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_8013AED4(&this->unk_1CE, 0, 7); this->actionFunc = func_80B3EF90; ret = true; @@ -304,7 +304,7 @@ s32 func_80B3E96C(EnDai* this, GlobalContext* globalCtx) { break; case 1: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SNOWSTORM_HARD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SNOWSTORM_HARD); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WEATHER_TAG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0x1388, 0x708, 0x3E8, 0); func_80B3E5DC(this, 3); @@ -470,7 +470,7 @@ void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { break; case 2: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROLL_AND_FALL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROLL_AND_FALL); break; case 3: @@ -493,27 +493,27 @@ void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { case 2: if (globalCtx->csCtx.frames == 360) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIGOLON_SLEEP3 - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIGOLON_SLEEP3 - SFX_FLAG); } if (Animation_OnFrame(&this->skelAnime, 43.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GORON_BOUND_1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_BOUND_1); } this->unk_1D6 = func_80B3E8BC(this, this->unk_1CC); break; case 3: if (Animation_OnFrame(&this->skelAnime, 6.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIGOLON_SLEEP1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIGOLON_SLEEP1); } this->unk_1D6 = func_80B3E8BC(this, this->unk_1CC); break; case 4: if (Animation_OnFrame(&this->skelAnime, 30.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIGOLON_SLEEP2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIGOLON_SLEEP2); } if (Animation_OnFrame(&this->skelAnime, 35.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GORON_BOUND_0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_BOUND_0); } this->unk_1D6 = func_80B3E8BC(this, this->unk_1CC); break; @@ -525,7 +525,7 @@ void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { EnDai* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 0.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060130D0, NULL, this->jointTable, this->morphTable, 19); this->unk_A70 = -1; func_80B3E5DC(this, 0); diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c index 40eac8099a..4971193a32 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -76,7 +76,7 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { EnDaiku* this = THIS; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 40.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); this->actor.targetMode = 0; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->unk_278 = ENDAIKU_GET_FF(&this->actor); @@ -195,7 +195,7 @@ void func_809438F8(EnDaiku* this, GlobalContext* globalCtx) { this->actor.textId = sTextIds[this->unk_28C]; } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80943BC0(this); return; } @@ -255,7 +255,7 @@ void func_80943BDC(EnDaiku* this, GlobalContext* globalCtx) { } } - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); func_80943820(this); } @@ -286,8 +286,8 @@ void EnDaiku_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->actor.shape.rot.y = this->actor.world.rot.y; - Actor_SetHeight(&this->actor, 65.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_SetFocus(&this->actor, 65.0f); + Actor_MoveWithGravity(&this->actor); Math_SmoothStepToS(&this->unk_260, this->unk_266, 1, 0xBB8, 0); Math_SmoothStepToS(&this->unk_25E, this->unk_264, 1, 0xBB8, 0); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c index daa1597884..6776086cc6 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -95,7 +95,7 @@ void EnDaiku2_Init(Actor* thisx, GlobalContext* globalCtx) { s32 day = gSaveContext.day; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 40.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600A850, &D_06002FA0, this->jointTable, this->morphTable, 17); this->actor.targetMode = 0; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -158,7 +158,7 @@ s32 func_80BE64C0(EnDaiku2* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp30, &this->actor.world.pos); Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); - bomb = (EnBom*)func_800BE0B8(globalCtx, &this->actor, -1, ACTORCAT_EXPLOSIVES, BREG(7) + 240.0f); + bomb = (EnBom*)Actor_FindNearby(globalCtx, &this->actor, -1, ACTORCAT_EXPLOSIVES, BREG(7) + 240.0f); Math_Vec3f_Copy(&this->actor.world.pos, &sp30); if ((this->unk_278 >= ENDAIKU2_GET_7F_0) && !Flags_GetSwitch(globalCtx, this->unk_278) && (bomb != NULL) && (bomb->actor.id == ACTOR_EN_BOM)) { @@ -233,7 +233,7 @@ void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { this->actor.textId = sTextIds[this->unk_28A]; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80BE6B40(this, globalCtx); return; } @@ -245,7 +245,7 @@ void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { func_800B8614(&this->actor, globalCtx, 80.0f); if ((this->unk_276 == 8) && Animation_OnFrame(&this->skelAnime, 6.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROCK_BROKEN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROCK_BROKEN); for (i = 0; i < 10; i++) { Math_Vec3f_Copy(&sp70, &this->actor.world.pos); @@ -304,7 +304,7 @@ void func_80BE6B40(EnDaiku2* this, GlobalContext* globalCtx) { void func_80BE6BC0(EnDaiku2* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0x0); - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { s32 day = gSaveContext.day - 1; func_801477B4(globalCtx); @@ -342,7 +342,7 @@ void func_80BE6D40(EnDaiku2* this, GlobalContext* globalCtx) { s32 pad[3]; s16 sp3A = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_268); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80BE6BC0; return; } @@ -376,7 +376,7 @@ void func_80BE6EF0(EnDaiku2* this, GlobalContext* globalCtx) { Vec3f sp40; s16 var; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80BE6BC0; return; } @@ -460,8 +460,8 @@ void EnDaiku2_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actionFunc(this, globalCtx); this->actor.shape.rot.y = this->actor.world.rot.y; - Actor_SetHeight(&this->actor, 65.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_SetFocus(&this->actor, 65.0f); + Actor_MoveWithGravity(&this->actor); Math_ApproachF(&this->unk_260, this->unk_264, 0.3f, 2.0f); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c index 69d2fc9d63..30b749c0dc 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -131,7 +131,7 @@ void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx) { EnDekunuts* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 35.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &D_06002468, &D_0600326C, this->jointTable, this->morphTable, 10); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -165,7 +165,7 @@ void func_808BD348(EnDekunuts* this) { this->unk_210 = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_190 = 80; - func_800BCB70(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808BD3B4(EnDekunuts* this, GlobalContext* globalCtx) { @@ -173,7 +173,7 @@ void func_808BD3B4(EnDekunuts* this, GlobalContext* globalCtx) { this->unk_18E = 0; this->collider.base.colType = COLTYPE_HIT6; this->unk_210 = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->unk_21C, 8, 2, 0.2f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_21C, 8, 2, 0.2f, 0.2f); } } @@ -200,7 +200,7 @@ void func_808BD49C(EnDekunuts* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 9.0f)) { this->collider.base.acFlags |= AC_ON; } else if (Animation_OnFrame(&this->skelAnime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); } this->collider.dim.height = (s32)((CLAMP(this->skelAnime.curFrame, 9.0f, 12.0f) - 9.0f) * 9.0f) + 5; @@ -333,7 +333,7 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NUTSBALL, pos.x, pos.y, pos.z, this->actor.world.rot.x, this->actor.shape.rot.y, 0, params) != NULL) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_THROW); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_THROW); } } else if ((this->unk_190 >= 2) && Animation_OnFrame(&this->skelAnime, 12.0f)) { Animation_MorphToPlayOnce(&this->skelAnime, &D_06000168, -3.0f); @@ -346,7 +346,7 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { void func_808BDC9C(EnDekunuts* this) { Animation_MorphToPlayOnce(&this->skelAnime, &D_06002A5C, -5.0f); this->unk_190 = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->actionFunc = func_808BDD54; } @@ -354,7 +354,7 @@ void func_808BDCF0(EnDekunuts* this) { Animation_MorphToPlayOnce(&this->skelAnime, &D_06002A5C, -5.0f); this->collider.base.acFlags &= ~AC_ON; this->unk_190 = 80; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->actionFunc = func_808BDD54; } @@ -382,7 +382,7 @@ void func_808BDE7C(EnDekunuts* this) { Animation_MorphToPlayOnce(&this->skelAnime, &D_06002DD4, -3.0f); this->collider.dim.height = 37; this->actor.colChkInfo.mass = 50; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); this->actor.world.rot.x = 0; this->actor.flags |= 0x20; this->collider.base.acFlags &= ~AC_ON; @@ -418,7 +418,7 @@ void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx) { } if (this->unk_18C != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); this->unk_18C = 0; } else { this->unk_18C = 1; @@ -490,9 +490,9 @@ void func_808BE294(EnDekunuts* this, s32 arg1) { this->actor.world.rot.x = 0; this->collider.base.acFlags &= ~AC_ON; this->actionFunc = func_808BE358; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DAMAGE); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_CUTBODY); - func_800BCB70(&this->actor, 0x4000, 255, 0, Animation_GetLastFrame(&D_0600259C)); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CUTBODY); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, Animation_GetLastFrame(&D_0600259C)); } void func_808BE358(EnDekunuts* this, GlobalContext* globalCtx) { @@ -534,7 +534,7 @@ void func_808BE484(EnDekunuts* this) { Animation_PlayOnce(&this->skelAnime, &D_06002BD4); this->actionFunc = func_808BE4D4; this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); } void func_808BE4D4(EnDekunuts* this, GlobalContext* globalCtx) { @@ -578,7 +578,7 @@ void func_808BE6C4(EnDekunuts* this, GlobalContext* globalCtx) { void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - func_800BE258(&this->actor, &this->collider.info); + Actor_SetDropFlag(&this->actor, &this->collider.info); if ((this->unk_18E != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { func_808BD3B4(this, globalCtx); if ((this->actor.colChkInfo.mass == 50) || (this->actor.params != ENDEKUNUTS_GET_FF00_0)) { @@ -603,8 +603,8 @@ void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 1) { this->unk_190 = 40; - func_800BCB70(&this->actor, 0, 255, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_808BE3A8(this); return; } @@ -651,7 +651,7 @@ void EnDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { func_808BE73C(this, globalCtx); this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, this->collider.dim.radius, this->collider.dim.height, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); @@ -747,7 +747,7 @@ void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.colorFilterTimer != 0) { func_800AE5A0(globalCtx); } - func_800BDFC0(globalCtx, D_06001E50); + Gfx_DrawDListOpa(globalCtx, D_06001E50); func_800BE680(globalCtx, &this->actor, this->unk_21C, 8, this->unk_214, this->unk_218, this->unk_210, this->unk_18E); } diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index 2c5a330ab7..907344cf5a 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -302,37 +302,37 @@ void func_80989864(EnDg* this, GlobalContext* globalCtx) { sp38.x = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.x; sp38.y = this->actor.world.pos.y; sp38.z = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.z; - func_800BBDAC(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 300, 0, 1); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 300, 0, 1); } } void func_80989974(EnDg* this) { if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 7.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_MONKEY_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); } } void func_809899C8(EnDg* this, f32 arg1) { if (Animation_OnFrame(&this->skelAnime, arg1)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_BARK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); } } void func_80989A08(EnDg* this, f32 arg1) { if (Animation_OnFrame(&this->skelAnime, arg1)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); } } void func_80989A48(EnDg* this) { if (Animation_OnFrame(&this->skelAnime, 23.0f) || Animation_OnFrame(&this->skelAnime, 28.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_WHINE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_WHINE); } } void func_80989A9C(EnDg* this, f32 arg1) { if (Animation_OnFrame(&this->skelAnime, arg1)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); } } @@ -402,7 +402,7 @@ void func_80989E18(EnDg* this, GlobalContext* globalCtx) { } if (Actor_HasParent(&this->actor, globalCtx)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_BARK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); this->unk_290 = 1; D_8098C2FC = D_8098C2A8[this->unk_286]; if (D_8098C2A0 == 0) { @@ -422,12 +422,12 @@ void func_80989E18(EnDg* this, GlobalContext* globalCtx) { this->actionFunc = func_8098BA64; } } else { - func_800B8BB0(&this->actor, globalCtx); + Actor_LiftActor(&this->actor, globalCtx); } } s32 func_80989FC8(GlobalContext* globalCtx) { - EnDg* enemy = (EnDg*)globalCtx->actorCtx.actorList[ACTORCAT_ENEMY].first; + EnDg* enemy = (EnDg*)globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; f32 minDist = 9999.0f; f32 dist; @@ -470,7 +470,7 @@ void func_8098A064(EnDg* this, GlobalContext* globalCtx) { } else if ((this->actionFunc == func_8098B004) || (this->actionFunc == func_8098AB48)) { if (DECR(this->unk_292) == 0) { this->unk_292 = 10; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_BARK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); } } } @@ -567,7 +567,7 @@ void func_8098A468(EnDg* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; this->actor.gravity = -3.0f; func_80989674(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (player->transformation == PLAYER_FORM_HUMAN) { func_80989E18(this, globalCtx); } @@ -619,7 +619,7 @@ void func_8098A618(EnDg* this, GlobalContext* globalCtx) { } this->actor.world.rot.y = this->actor.shape.rot.y; Math_ApproachF(&this->actor.speedXZ, -1.5f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } func_80989974(this); @@ -655,12 +655,12 @@ void func_8098A70C(EnDg* this, GlobalContext* globalCtx) { this->actor.speedXZ = 7.0f; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80989974(this); if (Animation_OnFrame(&this->skelAnime, 3.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_CRY); } else if (Animation_OnFrame(&this->skelAnime, 6.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_MONKEY_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); } } @@ -707,7 +707,7 @@ void func_8098A938(EnDg* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 1.0f); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80989974(this); func_80989A08(this, 5.0f); } @@ -715,7 +715,7 @@ void func_8098A938(EnDg* this, GlobalContext* globalCtx) { void func_8098AAAC(EnDg* this, GlobalContext* globalCtx) { this->unk_280 &= ~8; Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.1f, 0.5f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (DECR(this->unk_28E) == 0) { this->unk_28E = 20; this->actionFunc = func_8098A938; @@ -790,7 +790,7 @@ void func_8098AC34(EnDg* this, GlobalContext* globalCtx) { if (sp26 >= 0x18) { func_80989864(this, globalCtx); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } func_80989A9C(this, 10.0f); @@ -808,7 +808,7 @@ void func_8098AE58(EnDg* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xC00); this->actor.world.rot.y = this->actor.shape.rot.y; Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } func_80989974(this); @@ -818,7 +818,7 @@ void func_8098AE58(EnDg* this, GlobalContext* globalCtx) { void func_8098AF44(EnDg* this, GlobalContext* globalCtx) { if (func_801A46F8() == 1) { this->unk_292 = 10; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_BARK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); this->actionFunc = func_8098B004; } } @@ -829,7 +829,7 @@ void func_8098AF98(EnDg* this, GlobalContext* globalCtx) { this->actionFunc = func_8098A468; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_809899C8(this, 3.0f); } @@ -859,7 +859,7 @@ void func_8098B004(EnDg* this, GlobalContext* globalCtx) { } func_8098A064(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80989974(this); if (!(this->unk_280 & 0x20)) { func_809899C8(this, 3.0f); @@ -881,7 +881,7 @@ void func_8098B198(EnDg* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; Math_ApproachF(&this->actor.speedXZ, -1.0f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80989974(this); func_80989A9C(this, 4.0f); } @@ -901,11 +901,11 @@ void func_8098B28C(EnDg* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; Math_ApproachF(&this->actor.speedXZ, -2.0f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } func_80989974(this); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); } void func_8098B390(EnDg* this, GlobalContext* globalCtx) { @@ -936,12 +936,12 @@ void func_8098B464(EnDg* this, GlobalContext* globalCtx) { this->actor.gravity = 0.0f; this->actor.velocity.y = -3.0f; this->unk_284 = 10; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOMB_DROP_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); this->actionFunc = func_8098B560; } Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_8098B560(EnDg* this, GlobalContext* globalCtx) { @@ -963,7 +963,7 @@ void func_8098B560(EnDg* this, GlobalContext* globalCtx) { if (DECR(this->unk_284) == 0) { if (!(this->unk_280 & 4)) { this->unk_280 |= 4; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_OUT_OF_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); } this->unk_284 = 5; EffectSsGRipple_Spawn(globalCtx, &sp54, 100, 500, 30); @@ -999,7 +999,7 @@ void func_8098B560(EnDg* this, GlobalContext* globalCtx) { this->unk_280 &= ~4; this->unk_28C = 8; this->unk_282 = Rand_S16Offset(60, 60); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_OUT_OF_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); func_80989140(&this->skelAnime, sAnimations, 2); Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); this->actionFunc = func_8098A468; @@ -1008,7 +1008,7 @@ void func_8098B560(EnDg* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, sp46, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_8098B88C(EnDg* this, GlobalContext* globalCtx) { @@ -1040,7 +1040,7 @@ void func_8098B88C(EnDg* this, GlobalContext* globalCtx) { this->actor.velocity.y = 10.0f; this->actor.gravity = -3.0f; this->unk_282 = Rand_S16Offset(60, 60); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_OUT_OF_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); func_80989140(&this->skelAnime, sAnimations, 2); this->actionFunc = func_8098A468; Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); @@ -1048,7 +1048,7 @@ void func_8098B88C(EnDg* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_8098BA64(EnDg* this, GlobalContext* globalCtx) { @@ -1063,7 +1063,7 @@ void func_8098BA64(EnDg* this, GlobalContext* globalCtx) { this->unk_288 = -1; D_8098C2FC.unk_02 = this->unk_288; this->unk_28A = 100; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); this->unk_280 |= 0x10; this->actionFunc = func_8098BB10; } @@ -1075,7 +1075,7 @@ void func_8098BB10(EnDg* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { if (this->unk_280 & 0x10) { this->unk_280 &= ~0x10; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_MONKEY_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); } this->actor.speedXZ = 0.0f; @@ -1091,11 +1091,11 @@ void func_8098BB10(EnDg* this, GlobalContext* globalCtx) { this->actionFunc = func_8098A468; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_8098BBEC(EnDg* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; func_80989D38(this, globalCtx); this->actionFunc = func_8098BC54; @@ -1105,7 +1105,7 @@ void func_8098BBEC(EnDg* this, GlobalContext* globalCtx) { } void func_8098BC54(EnDg* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 2) { + if (Message_GetState(&globalCtx->msgCtx) == 2) { func_80989140(&this->skelAnime, sAnimations, 0); this->actionFunc = func_8098BA64; } @@ -1115,7 +1115,7 @@ void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { EnDg* this = THIS; s32 pad; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060080F0, NULL, this->jointTable, this->morphTable, 13); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index f82295874b..7c7b2811cb 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -287,7 +287,7 @@ void EnDinofos_Init(Actor* thisx, GlobalContext* globalCtx) { ColliderJntSphElementDim* dim; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B42F8, 90.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFeet, 90.0f); Effect_Add(globalCtx, &this->unk_2A0, EFFECT_BLURE2, 0, 0, &D_8089E368); Collider_InitAndSetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderJntSphElement); @@ -353,7 +353,7 @@ s32 func_8089A968(EnDinofos* this) { void func_8089A9B0(EnDinofos* this, GlobalContext* globalCtx) { if (func_8089A968(this)) { if (this->actor.xzDistToPlayer < 100.0f) { - if (!func_800BC5EC(globalCtx, &this->actor) && + if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && (((this->actionFunc != func_8089C56C) && (Rand_ZeroOne() > 0.35f)) || ((this->actionFunc == func_8089C56C) && (Rand_ZeroOne() > 0.8f)))) { func_8089C4F8(this); @@ -400,7 +400,7 @@ void func_8089AC70(EnDinofos* this) { this->unk_2B0 = 1.0f; this->unk_290 = 80; this->actor.flags &= ~0x400; - func_800BCB70(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_8089ACEC(EnDinofos* this, GlobalContext* globalCtx) { @@ -408,7 +408,7 @@ void func_8089ACEC(EnDinofos* this, GlobalContext* globalCtx) { this->unk_28A = 0; this->colliderJntSph.base.colType = COLTYPE_HIT0; this->unk_2B0 = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->unk_2D4, 12, 2, 0.3f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D4, 12, 2, 0.3f, 0.2f); this->actor.flags |= 0x400; } } @@ -436,7 +436,7 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { temp_v1 = (Actor_YawBetweenActors(&this->actor, temp_v0) - this->actor.shape.rot.y) - this->unk_28E; if (ABS_ALT(temp_v1) < 0x3000) { func_8089D11C(this, temp_v1 + this->unk_28E); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WARAU); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WARAU); return true; } } @@ -446,7 +446,7 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { temp_v1_2 = (Actor_YawBetweenActors(&this->actor, temp_v0) - this->actor.shape.rot.y) - this->unk_28E; if (ABS_ALT(temp_v1_2) < 0x3000) { func_8089C024(this, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WARAU); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WARAU); return true; } } @@ -457,13 +457,13 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { } if ((this->actor.xzDistToPlayer < 100.0f) && (player->swordState != 0) && this->actor.isTargeted && - (Rand_ZeroOne() < 0.5f) && func_8089A968(this) && Actor_IsLinkFacingActor(&this->actor, 0x2000, globalCtx)) { + (Rand_ZeroOne() < 0.5f) && func_8089A968(this) && Player_IsFacingActor(&this->actor, 0x2000, globalCtx)) { if (Rand_ZeroOne() < 0.5f) { func_8089C024(this, 2); } else { func_8089C024(this, 3); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WARAU); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WARAU); return true; } @@ -485,7 +485,7 @@ void func_8089B100(EnDinofos* this, GlobalContext* globalCtx) { Animation_Change(&this->skelAnime, &D_06001CCC, 1.0f, Animation_GetLastFrame(&D_06001CCC), Animation_GetLastFrame(&D_06001CCC), 2, 0.0f); - func_800BE33C(&camera->eye, &camera->at, &this->unk_29A, 1); + func_800BE33C(&camera->eye, &camera->at, &this->unk_29A, true); Math_Vec3f_Diff(&this->actor.world.pos, &player->actor.world.pos, &sp3C); this->unk_2BC.x = player->actor.world.pos.x + (0.4f * sp3C.x); this->unk_2BC.y = player->actor.world.pos.y + 5.0f; @@ -513,7 +513,7 @@ void func_8089B288(EnDinofos* this, GlobalContext* globalCtx) { void func_8089B320(EnDinofos* this) { this->actor.gravity = -2.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_CRY); this->unk_2BC.x = (Math_SinS(this->actor.shape.rot.y - 0x0E00) * 86.0f) + this->actor.world.pos.x; this->unk_2BC.y = this->actor.floorHeight + 6.0f; this->unk_2BC.z = (Math_CosS(this->actor.shape.rot.y - 0x0E00) * 86.0f) + this->actor.world.pos.z; @@ -553,7 +553,7 @@ void func_8089B4A4(EnDinofos* this) { this->unk_2BC.x = (Math_SinS(this->actor.shape.rot.y + 0x200) * 123.0f) + this->actor.world.pos.x; this->unk_2BC.y = this->actor.floorHeight + 11.0f; this->unk_2BC.z = (Math_CosS(this->actor.shape.rot.y + 0x200) * 123.0f) + this->actor.world.pos.z; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BOMCHU_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_WALK); this->unk_290 = 0; this->unk_292 = -1; this->actionFunc = func_8089B580; @@ -595,7 +595,7 @@ void func_8089B6E8(EnDinofos* this) { void func_8089B72C(EnDinofos* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 2.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_ATTACK); } if (SkelAnime_Update(&this->skelAnime)) { @@ -636,7 +636,7 @@ void func_8089B8B0(EnDinofos* this, GlobalContext* globalCtx) { if (this->actionFunc != func_8089B98C) { Animation_MorphToLoop(&this->skelAnime, &D_06000580, -4.0f); - if (func_800BC5EC(globalCtx, &this->actor)) { + if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { phi_f0 = 170.0f; } else { phi_f0 = 70.0f; @@ -658,7 +658,7 @@ void func_8089B98C(EnDinofos* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (!func_8089AE00(this, globalCtx)) { - if (func_800BC5EC(globalCtx, &this->actor)) { + if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { phi_f0 = 170.0f; } else { phi_f0 = 70.0f; @@ -683,7 +683,7 @@ void func_8089B98C(EnDinofos* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); } } } @@ -782,7 +782,7 @@ void func_8089BD28(EnDinofos* this, GlobalContext* globalCtx) { } this->actor.world.rot.y = BINANG_ADD(this->actor.shape.rot.y, 0x4000); - if (func_800BC5EC(globalCtx, &this->actor)) { + if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { sp2C = 100.0f; } @@ -804,7 +804,7 @@ void func_8089BD28(EnDinofos* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); } } } @@ -853,7 +853,7 @@ void func_8089C164(EnDinofos* this) { } this->actor.bgCheckFlags &= ~1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_JUMP); this->actionFunc = func_8089C1F8; } @@ -868,7 +868,7 @@ void func_8089C244(EnDinofos* this) { this->actor.bgCheckFlags &= ~1; this->actor.speedXZ = 8.0f; this->actor.velocity.y = 16.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_JUMP); this->unk_290 = 0; this->unk_292 = -1; this->actionFunc = func_8089C2A8; @@ -905,7 +905,7 @@ void func_8089C398(EnDinofos* this) { this->actor.speedXZ = 0.0f; func_8089AD70(this); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BOMCHU_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_WALK); this->actionFunc = func_8089C44C; } @@ -923,7 +923,7 @@ void func_8089C44C(EnDinofos* this, GlobalContext* globalCtx) { void func_8089C4F8(EnDinofos* this) { Animation_PlayOnce(&this->skelAnime, &D_060025B4); this->colliderQuad.base.atFlags &= ~AT_BOUNCED; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_CRY); this->unk_290 = 0; this->unk_292 = -1; this->actor.speedXZ = 0.0f; @@ -945,7 +945,7 @@ void func_8089C56C(EnDinofos* this, GlobalContext* globalCtx) { } else if (Animation_OnFrame(&this->skelAnime, 13.0f)) { this->colliderQuad.base.atFlags &= ~AT_ON; } else if (Animation_OnFrame(&this->skelAnime, 11.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_ATTACK); } else if (this->skelAnime.curFrame < 7.0f) { func_8089AE00(this, globalCtx); } @@ -1010,9 +1010,9 @@ void func_8089C87C(EnDinofos* this, s32 arg1) { this->actor.velocity.y = 0.0f; } this->unk_28E = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_DAMAGE); this->colliderJntSph.base.acFlags &= ~AC_ON; - func_800BCB70(&this->actor, 0x4000, 255, 0, 18); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 18); this->actionFunc = func_8089C938; } @@ -1145,7 +1145,7 @@ void func_8089CF70(EnDinofos* this, GlobalContext* globalCtx) { void func_8089CFAC(EnDinofos* this) { Animation_PlayOnce(&this->skelAnime, &D_0600ABD0); this->actor.flags &= ~1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_DEAD); this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_8089D018; @@ -1173,7 +1173,7 @@ void func_8089D018(EnDinofos* this, GlobalContext* globalCtx) { this->actor.shape.shadowAlpha = this->unk_288; } else if (Animation_OnFrame(&this->skelAnime, 26.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } } @@ -1206,7 +1206,7 @@ void func_8089D1E0(EnDinofos* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); } } @@ -1263,7 +1263,7 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { if (this->colliderJntSph.base.acFlags & AC_HIT) { this->colliderJntSph.base.acFlags &= ~AC_HIT; - func_800BE2B8(&this->actor, &this->colliderJntSph); + Actor_SetDropFlagJntSph(&this->actor, &this->colliderJntSph); for (i = 0; i < ARRAY_COUNT(this->colliderJntSphElement); i++) { if (this->colliderJntSph.elements[i].info.bumperFlags & BUMP_HIT) { @@ -1317,19 +1317,19 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 1) { this->unk_290 = 40; - func_800BCB70(&this->actor, 0, 255, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_8089C784(this); return true; } if (this->actor.colChkInfo.damageEffect == 5) { this->unk_290 = 40; - func_800BCB70(&this->actor, 0, 255, 0, 40); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); this->unk_2B4 = 0.55f; this->unk_2B0 = 2.0f; this->unk_28A = 31; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_8089C784(this); return true; } @@ -1369,7 +1369,7 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { } this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 30.0f, 60.0f, 0x5D); if (this->actionFunc != func_8089C7B8) { if ((this->actor.depthInWater > 0.0f) && (this->actor.depthInWater < 10.0f)) { diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index 8a6c3a5833..2dcf85e3d0 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -265,7 +265,7 @@ void EnDnk_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); SkelAnime_Update(&this->skelAnime); func_80A515C4(this); - Actor_SetHeight(&this->actor, 34.0f); + Actor_SetFocus(&this->actor, 34.0f); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); @@ -436,11 +436,11 @@ void func_80A52074(EnDnk* this, GlobalContext* globalCtx) { break; case 438: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKNUTS_DANCE_BIG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKNUTS_DANCE_BIG); break; case 493: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); break; } diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index 2e82973da5..2a352380cf 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -135,10 +135,10 @@ void func_80A714B4(EnDno* this, GlobalContext* globalCtx) { Actor* actor = NULL; do { - actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (actor != NULL) { - if ((s32)ENDNO_GET_F(actor) == ENDNO_GET_F_1) { - Actor_SetSwitchFlag(globalCtx, ENDNO_GET_7F0(actor)); + if (ENDNO_GET_F(actor) == ENDNO_GET_F_1) { + Flags_SetSwitch(globalCtx, ENDNO_GET_7F0(actor)); } actor = actor->next; } @@ -165,8 +165,7 @@ void func_80A715DC(EnDno* this, GlobalContext* globalCtx) { Vec3f sp70; do { - crace = - (BgCraceMovebg*)func_ActorCategoryIterateById(globalCtx, &crace->actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); + crace = (BgCraceMovebg*)SubS_FindActor(globalCtx, &crace->actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (crace != NULL) { if (ENDNO_GET_F(&crace->actor) == ENDNO_GET_F_0 && !(crace->unk_170 & 1)) { if (func_8013E5CC(&crace->actor.home.pos, &crace->actor.home.rot, &D_80A73B2C, &this->actor.prevPos, @@ -188,9 +187,9 @@ void func_80A71788(EnDno* this, GlobalContext* globalCtx) { Actor* actor = NULL; do { - actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (actor != NULL) { - Actor_UnsetSwitchFlag(globalCtx, ENDNO_GET_7F0(actor)); + Flags_UnsetSwitch(globalCtx, ENDNO_GET_7F0(actor)); actor = actor->next; } } while (actor != NULL); @@ -202,7 +201,7 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { Actor* actor = NULL; while (true) { - actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_DNO); + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_DNO); if (actor != NULL) { if (actor != thisx) { Actor_MarkForDeath(thisx); @@ -213,7 +212,7 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { if (actor == NULL) { Actor_ProcessInitChain(thisx, sInitChain); - ActorShape_Init(&thisx->shape, 0.0f, func_800B3FC0, 21.0f); + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 21.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600E1F8, &D_06007CA4, this->jointTable, this->morphTable, 28); Collider_InitCylinder(globalCtx, &this->collider); @@ -249,7 +248,7 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(thisx); } else { func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); - this->unk_460 = func_ActorCategoryIterateById(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_DNQ); + this->unk_460 = SubS_FindActor(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_DNQ); if (this->unk_460 == NULL) { Actor_MarkForDeath(thisx); } else { @@ -340,7 +339,7 @@ void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x222); } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.unk11F22 = 0; globalCtx->msgCtx.unk11F10 = 0; func_80A71E54(this, globalCtx); @@ -375,7 +374,7 @@ void func_80A71E54(EnDno* this, GlobalContext* globalCtx) { void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->unk_466, 0, 0x16C); - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: if (!(this->unk_3B0 & 0x10) || Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xE38)) { @@ -529,7 +528,7 @@ void func_80A724B8(EnDno* this, GlobalContext* globalCtx) { func_80A71424(&this->unk_466, 0, this->actor.yawTowardsPlayer, this->actor.home.rot.y, 0x2000, 0x2D8); } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80A725E0(this, globalCtx); } else if (this->actor.xzDistToPlayer < 60.0f) { func_800B8614(&this->actor, globalCtx, 60.0f); @@ -537,11 +536,11 @@ void func_80A724B8(EnDno* this, GlobalContext* globalCtx) { } void func_80A7256C(EnDno* this, GlobalContext* globalCtx) { - func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, -1); + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, EXCH_ITEM_MINUS1); } void func_80A72598(EnDno* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80A725E0(this, globalCtx); } else { func_80A7256C(this, globalCtx); @@ -556,7 +555,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { s32 pad[2]; func_80A71424(&this->unk_466, 0, 0, 0, 0x2000, 0x16C); - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: switch (this->unk_328) { case 0: @@ -598,7 +597,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame <= 23.0f) { this->unk_452 = 3; if (Animation_OnFrame(&this->skelAnime, 23.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_OPEN_AMBRELLA); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OPEN_AMBRELLA); } } else if (this->skelAnime.curFrame <= 24.0f) { this->unk_452 = 4; @@ -634,7 +633,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { } else { this->unk_458 = GI_MASK_SCENTS; } - func_800B8A1C(&this->actor, globalCtx, this->unk_458, 60.0f, 60.0f); + Actor_PickUp(&this->actor, globalCtx, this->unk_458, 60.0f, 60.0f); func_801477B4(globalCtx); func_80A72B84(this, globalCtx); } @@ -698,7 +697,7 @@ void func_80A72BA4(EnDno* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = func_80A72598; } else { - func_800B8A1C(&this->actor, globalCtx, this->unk_458, 60.0f, 60.0f); + Actor_PickUp(&this->actor, globalCtx, this->unk_458, 60.0f, 60.0f); } } @@ -710,9 +709,11 @@ void func_80A72C04(EnDno* this, GlobalContext* globalCtx) { func_8013DCE0(globalCtx, &this->unk_334, &this->actor, &this->unk_340, globalCtx->setupPathList, ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); func_8013DF3C(globalCtx, &this->unk_340); + this->actor.world.rot.y = this->unk_340.unk_54.y; this->actor.world.rot.x = this->unk_340.unk_54.x; - Actor_SetSwitchFlag(globalCtx, ENDNO_GET_3F80(&this->actor)); + + Flags_SetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor)); this->actionFunc = func_80A730A0; } @@ -832,7 +833,7 @@ void func_80A73244(EnDno* this, GlobalContext* globalCtx) { this->actor.flags |= (8 | 1); this->unk_328 = 2; this->actor.speedXZ = 0.0f; - Actor_UnsetSwitchFlag(globalCtx, ENDNO_GET_3F80(&this->actor)); + Flags_UnsetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor)); gSaveContext.unk_3DD0[1] = 5; this->unk_44E = 0; this->actionFunc = func_80A732C8; @@ -857,14 +858,14 @@ void func_80A732C8(EnDno* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 4.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CLOSE_AMBRELLA); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOSE_AMBRELLA); this->unk_452 = 4; } else if (Animation_OnFrame(&this->skelAnime, 5.0f)) { this->unk_452 = 3; } } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80A73408(EnDno* this, GlobalContext* globalCtx) { @@ -915,7 +916,7 @@ void EnDno_Update(Actor* thisx, GlobalContext* globalCtx) { } Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_SetHeight(&this->actor, 51.0f); + Actor_SetFocus(&this->actor, 51.0f); } void EnDno_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c index f3753c978a..98884c1149 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -104,37 +104,37 @@ s32 func_80B3CA20(EnDnp* this) { if ((this->unk_340 == 2) || (this->unk_340 == 9)) { if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_TURN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_TURN); } } else if ((this->unk_340 == 24) || (this->unk_340 == 7)) { if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_TURN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_TURN); } } else if (this->unk_340 == 14) { if (Animation_OnFrame(&this->skelAnime, 7.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_GREET); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET); } if (Animation_OnFrame(&this->skelAnime, 22.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_GREET2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET2); } } else if (this->unk_340 == 8) { if (Animation_OnFrame(&this->skelAnime, 9.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_GREET); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET); } if (Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_GREET2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET2); } } else if ((this->unk_340 == 17) && (this->unk_340 == 18)) { if (Animation_OnFrame(&this->skelAnime, 7.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_WALK); } } else if (this->unk_340 == 21) { if (Animation_OnFrame(&this->skelAnime, 17.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_WALK); } } else if (this->unk_340 == 23) { if (Animation_OnFrame(&this->skelAnime, 3.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DEKUHIME_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_WALK); } } @@ -212,7 +212,7 @@ s32 func_80B3CEC0(EnDnp* this, GlobalContext* globalCtx) { s32 func_80B3CF60(EnDnp* this, GlobalContext* globalCtx) { s32 ret = false; - if ((this->unk_322 & 7) && func_800B84D0(&this->actor, globalCtx)) { + if ((this->unk_322 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_8013AED4(&this->unk_322, 0, 7); this->unk_322 |= 8; this->actionFunc = func_80B3D3F8; @@ -276,7 +276,7 @@ void func_80B3D11C(EnDnp* this, GlobalContext* globalCtx) { } if (this->unk_340 == 19) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_DHVO04); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_DHVO04); } if (this->unk_340 == 24) { @@ -307,15 +307,15 @@ void func_80B3D2D4(EnDnp* this, GlobalContext* globalCtx) { void func_80B3D338(EnDnp* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((this->unk_32E != 0) && (func_80152498(&globalCtx->msgCtx) == 2)) { + if ((this->unk_32E != 0) && (Message_GetState(&globalCtx->msgCtx) == 2)) { Actor_MarkForDeath(&this->actor); } else if (this->unk_32E == 0) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_32E = 1; } else { this->actor.textId = 0x971; player->actor.textId = this->actor.textId; - func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, -1); + func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, EXCH_ITEM_MINUS1); } } } @@ -357,7 +357,7 @@ void func_80B3D558(EnDnp* this, GlobalContext* globalCtx) { void EnDnp_Init(Actor* thisx, GlobalContext* globalCtx) { EnDnp* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 16.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 16.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06010D60, NULL, this->jointTable, this->morphTable, 26); this->unk_340 = -1; func_80B3CC38(this, 15); @@ -413,15 +413,15 @@ void EnDnp_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); func_80B3CD1C(this); func_80B3CEC0(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); sp2C = this->collider.dim.radius + 50; sp28 = this->collider.dim.height + 30; if ((this->unk_322 & 0x400) && !(gSaveContext.weekEventReg[23] & 0x20)) { - func_800B8A1C(&this->actor, globalCtx, GI_MAX, sp2C, sp28); + Actor_PickUp(&this->actor, globalCtx, GI_MAX, sp2C, sp28); } func_8013C964(&this->actor, globalCtx, sp2C, sp28, 0, this->unk_322 & 7); - Actor_SetHeight(&this->actor, 30.0f); + Actor_SetFocus(&this->actor, 30.0f); func_80B3CC80(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c index a52d7fa110..f1e500e0fb 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -324,7 +324,7 @@ s32* func_80A52CF8(EnDnq* this, GlobalContext* globalCtx) { s32 func_80A52D44(EnDnq* this, GlobalContext* globalCtx) { s32 ret = false; - if ((this->unk_37C & 7) && func_800B84D0(&this->actor, globalCtx)) { + if ((this->unk_37C & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_8013AED4(&this->unk_37C, 0, 7); this->unk_380 = func_80A52CF8(this, globalCtx); this->actionFunc = func_80A52FB8; @@ -347,7 +347,7 @@ void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { if (!(gSaveContext.weekEventReg[23] & 0x20)) { this->unk_390 = 70.0f; if (func_80114F2C(ITEM_DEKU_PRINCESS) && !func_801690CC(globalCtx) && - (func_80152498(&globalCtx->msgCtx) == 0) && (ActorCutscene_GetCurrentIndex() == -1)) { + (Message_GetState(&globalCtx->msgCtx) == 0) && (ActorCutscene_GetCurrentIndex() == -1)) { if ((DECR(this->unk_384) == 0) && (gSaveContext.weekEventReg[29] & 0x40)) { func_801518B0(globalCtx, 0x969, NULL); this->unk_384 = 200; @@ -404,7 +404,7 @@ void func_80A53038(EnDnq* this, GlobalContext* globalCtx) { } if ((this->unk_398 == 4) && Animation_OnFrame(&this->skelAnime, 2.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KINGNUTS_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KINGNUTS_DAMAGE); } if (((this->unk_398 == 3) || (this->unk_398 == 6)) && @@ -461,7 +461,7 @@ void EnDnq_Update(Actor* thisx, GlobalContext* globalCtx) { func_8013C964(&this->actor, globalCtx, this->unk_390, fabsf(this->actor.playerHeightRel) + 1.0f, 0, this->unk_37C & 7); this->actor.xzDistToPlayer = this->unk_394; - Actor_SetHeight(&this->actor, 46.0f); + Actor_SetFocus(&this->actor, 46.0f); func_80A52604(this, globalCtx); } } diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index 97db5bcb68..b6e75ef3ce 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -85,7 +85,7 @@ void func_8092C5C0(EnDns* this) { if (((this->unk_2F8 == 2) || (this->unk_2F8 == 3) || (this->unk_2F8 == 6) || (this->unk_2F8 == 7)) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 3.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); } } @@ -220,7 +220,7 @@ s32 func_8092CAD0(EnDns* this, GlobalContext* globalCtx) { s32 ret = false; if (this->unk_2C6 & 7) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_8013AED4(&this->unk_2C6, 0, 7); this->unk_2C6 &= ~0x10; if (ENDNS_GET_4000(&this->actor)) { @@ -292,7 +292,7 @@ s32 func_8092CCEC(EnDns* this, GlobalContext* globalCtx) { this->unk_2D8 = (Rand_ZeroOne() * 182.0f) + 182.0f; this->unk_2D8 = (sp2E > 0) ? this->unk_2D8 : -this->unk_2D8; this->unk_2D0 = 0x28; - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; return 1; } @@ -308,7 +308,7 @@ s32 func_8092CE38(EnDns* this) { this->unk_2C6 &= ~0x200; this->skelAnime.curFrame = 0.0f; if (this->unk_2D2 == 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_JUMP); } this->unk_2D2++; if (this->unk_2D2 >= 3) { @@ -321,7 +321,7 @@ s32 func_8092CE38(EnDns* this) { this->actor.world.rot.y = BINANG_ROT180(this->actor.world.rot.y); this->unk_2E4 = 0.0f; this->actor.shape.rot.y = this->actor.world.rot.y; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_JUMP); } else if (this->skelAnime.curFrame < 13.0f) { frame = this->skelAnime.curFrame; this->actor.shape.rot.y = this->actor.world.rot.y; @@ -332,7 +332,7 @@ s32 func_8092CE38(EnDns* this) { } else { if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); } if (this->skelAnime.curFrame > 7.0f) { @@ -426,7 +426,7 @@ void func_8092D330(EnDns* this, GlobalContext* globalCtx) { sp30.x = Math_SinS(this->unk_2D4) * this->unk_2EC; sp30.z = Math_CosS(this->unk_2D4) * this->unk_2EC; Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp30), 3, 0x2AA8); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } if ((this->unk_2C6 & 0x100) && (DECR(this->unk_2D0) == 0)) { this->unk_2C6 &= ~0x100; @@ -538,7 +538,7 @@ void EnDns_Update(Actor* thisx, GlobalContext* globalCtx) { func_8092C86C(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); func_8013C964(&this->actor, globalCtx, 80.0f, 40.0f, 0, this->unk_2C6 & 7); - Actor_SetHeight(&this->actor, 34.0f); + Actor_SetFocus(&this->actor, 34.0f); func_8092C6FC(this, globalCtx); func_8092C5C0(this); } diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index fe92a5b1f9..bf7955ec7b 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -303,7 +303,7 @@ void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_330.g = 10; this->unk_330.a = 200; Math_Vec3f_Copy(&this->unk_314, &D_801C5DB0); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 48.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 48.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &D_06008318, &D_06004C20, this->jointTable, this->morphTable, 31); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Collider_InitAndSetJntSph(globalCtx, &this->collider2, &this->actor, &sJntSphInit2, this->collider2Elements); @@ -429,7 +429,7 @@ void func_80876CAC(EnDodongo* this) { this->unk_33C = 1.0f; this->timer = 80; this->actor.flags &= ~0x400; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); } void func_80876D28(EnDodongo* this, GlobalContext* globalCtx) { @@ -439,7 +439,8 @@ void func_80876D28(EnDodongo* this, GlobalContext* globalCtx) { this->unk_300 = 0; this->collider1.base.colType = COLTYPE_HIT0; this->unk_33C = 0.0f; - func_800BF7CC(globalCtx, &this->actor, &this->unk_348[0], 9, 2, this->unk_334 * 0.3f, this->unk_334 * 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, &this->unk_348[0], 9, 2, this->unk_334 * 0.3f, + this->unk_334 * 0.2f); this->actor.flags |= 0x400; } } @@ -522,13 +523,13 @@ s32 func_8087721C(EnDodongo* this) { s32 func_80877278(EnDodongo* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Actor* explosive = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; + Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; Vec3f sp44; // Bugfix from OoT while (explosive != NULL) { if (!explosive->params && (explosive->parent == NULL) && (explosive->update != NULL) && - (explosive != player->unk_388) && + (explosive != player->interactRangeActor) && (((explosive->id == ACTOR_EN_BOM) && (((EnBom*)explosive)->timer > 0)) || ((explosive->id == ACTOR_EN_BOMBF) && (((EnBombf*)explosive)->timer > 0)))) { Math_Vec3f_Diff(&explosive->world.pos, &this->unk_308, &sp44); @@ -577,13 +578,13 @@ void func_80877500(EnDodongo* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 19.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_WALK); sp30.x = this->collider1Elements[2].dim.worldSphere.center.x; sp30.y = this->collider1Elements[2].dim.worldSphere.center.y; sp30.z = this->collider1Elements[2].dim.worldSphere.center.z; func_80876930(this, globalCtx, &sp30); } else if (Animation_OnFrame(&this->skelAnime, 39.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_WALK); sp30.x = this->collider1Elements[1].dim.worldSphere.center.x; sp30.y = this->collider1Elements[1].dim.worldSphere.center.y; sp30.z = this->collider1Elements[1].dim.worldSphere.center.z; @@ -649,7 +650,7 @@ void func_8087784C(EnDodongo* this, GlobalContext* globalCtx) { f32 temp_f12; if (Animation_OnFrame(&this->skelAnime, 24.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_CRY); } if (func_8087721C(this)) { @@ -713,7 +714,7 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { Vec3f sp84; Vec3f sp78; s16 i; - Actor* explosive = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; + Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; Vec3f sp64; s32 pad; s16 sp5E; @@ -736,7 +737,7 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 28.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_EAT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_EAT); if (this->actor.child != NULL) { Actor_MarkForDeath(this->actor.child); this->actor.child = NULL; @@ -759,14 +760,14 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { this->unk_334 * 10.0f, 10); } - Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); if (this->actor.colChkInfo.health <= 4) { this->actor.colChkInfo.health = 0; Enemy_StartFinishingBlow(globalCtx, &this->actor); } else { this->actor.colChkInfo.health -= 4; } - func_800BCB70(&this->actor, 0x4000, 0x78, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 0x78, 0, 8); } } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { this->timer--; @@ -818,7 +819,7 @@ void func_80878354(EnDodongo* this) { sp18 = &D_06003B14; } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_TAIL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_TAIL); Animation_PlayOnceSetSpeed(&this->skelAnime, sp18, 2.0f); this->timer = 0; this->collider1.base.atFlags |= AT_ON; @@ -879,11 +880,11 @@ void func_808785B0(EnDodongo* this, GlobalContext* globalCtx) { void func_8087864C(EnDodongo* this) { Animation_MorphToPlayOnce(&this->skelAnime, &D_06001A44, -4.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_DAMAGE); this->timer = 0; this->unk_304 = 0; this->actor.speedXZ = 0.0f; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); this->actionFunc = func_808786C8; } @@ -901,10 +902,10 @@ void func_80878724(EnDodongo* this) { Animation_MorphToPlayOnce(&this->skelAnime, &D_060013C4, -8.0f); this->timer = 0; this->unk_304 = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_DEAD); this->actor.flags &= ~1; this->actor.speedXZ = 0.0f; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); this->actionFunc = func_808787B0; } @@ -916,7 +917,7 @@ void func_808787B0(EnDodongo* this, GlobalContext* globalCtx) { func_80876DC4(this, globalCtx); } } else if (this->actor.colorFilterTimer == 0) { - func_800BCB70(&this->actor, 0x4000, 0x78, 0, 4); + Actor_SetColorFilter(&this->actor, 0x4000, 0x78, 0, 4); } if (SkelAnime_Update(&this->skelAnime)) { @@ -929,7 +930,7 @@ void func_808787B0(EnDodongo* this, GlobalContext* globalCtx) { this->timer = 8; } } else if (Animation_OnFrame(&this->skelAnime, 52.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } if (this->timer != 0) { @@ -974,7 +975,7 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { } else if (this->collider1.base.acFlags & AC_HIT) { this->collider2.base.acFlags &= ~AC_HIT; this->collider1.base.acFlags &= ~AC_HIT; - func_800BE2B8(&this->actor, &this->collider1); + Actor_SetDropFlagJntSph(&this->actor, &this->collider1); for (i = 0; i < ARRAY_COUNT(this->collider1Elements); i++) { if (this->collider1.elements[i].info.bumperFlags & BUMP_HIT) { @@ -1000,13 +1001,13 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { } } else if (this->actor.colChkInfo.damageEffect == 1) { this->timer = 40; - func_800BCB70(&this->actor, 0, 0xFF, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_80878594(this); } else if (this->actor.colChkInfo.damageEffect == 5) { this->timer = 40; - func_800BCB70(&this->actor, 0, 0xFF, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->unk_300 = 30; this->unk_340 = 0.75f; this->unk_33C = 2.0f; @@ -1029,10 +1030,10 @@ void EnDodongo_Update(Actor* thisx, GlobalContext* globalCtx2) { EnDodongo_UpdateDamage(this, globalCtx); this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 60.0f, 70.0f, 0x1D); if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.h b/src/overlays/actors/ovl_En_Door/z_en_door.h index 7331339fcf..6ed5aac156 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.h +++ b/src/overlays/actors/ovl_En_Door/z_en_door.h @@ -12,7 +12,10 @@ typedef struct EnDoor { /* 0x144 */ char unk_144[0x5C]; /* 0x1A0 */ s8 unk_1A0; /* 0x1A1 */ s8 unk_1A1; - /* 0x1A2 */ char unk_1A2[0x5]; + /* 0x1A2 */ char unk_1A2[0x2]; + /* 0x1A4 */ u8 unk_1A4; + /* 0x1A5 */ u8 unk_1A5; + /* 0x1A6 */ s8 unk_1A6; /* 0x1A7 */ s8 unk_1A7; /* 0x1A8 */ char unk_1A8[0x20]; /* 0x1C8 */ EnDoorActionFunc actionFunc; diff --git a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c index a67805e574..564b52fcb1 100644 --- a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c +++ b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c @@ -82,9 +82,9 @@ void EnDyExtra_Update(Actor* thisx, GlobalContext* globalCtx) { EnDyExtra* this = THIS; DECR(this->unk14C); - Audio_PlayActorSound2(&this->actor, NA_SE_PL_SPIRAL_HEAL_BEAM - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_SPIRAL_HEAL_BEAM - SFX_FLAG); this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void EnDyExtra_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 112892a38e..d614223e76 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -297,7 +297,7 @@ void func_8088CC48(EnElf* this, GlobalContext* globalCtx) { func_8088CBAC(this, globalCtx); this->unk_25C = 0; this->disappearTimer = 240; - if ((this->fairyFlags & 0x400) && Actor_GetCollectibleFlag(globalCtx, this->unk_260)) { + if ((this->fairyFlags & 0x400) && Flags_GetCollectible(globalCtx, this->unk_260)) { Actor_MarkForDeath(&this->actor); } } @@ -386,7 +386,7 @@ void EnElf_Init(Actor* thisx, GlobalContext* globalCtx2) { case 7: this->fairyFlags |= 0x200; - thisx->shape.shadowDraw = func_800B4088; + thisx->shape.shadowDraw = ActorShadow_DrawWhiteCircle; this->fairyFlags |= 0x100; colorConfig = -1; this->fairyFlags |= 0x800; @@ -519,14 +519,14 @@ void func_8088D660(EnElf* this, Vec3f* targetPos, f32 arg2) { func_8088D5A0(this, targetPos, arg2); Math_StepToF(&this->actor.velocity.x, xVelTarget, 1.5f); Math_StepToF(&this->actor.velocity.z, zVelTarget, 1.5f); - Actor_ApplyMovement(&this->actor); + Actor_UpdatePos(&this->actor); } void func_8088D7F8(EnElf* this, Vec3f* targetPos) { func_8088D5A0(this, targetPos, 0.2f); this->actor.velocity.x = 0.0f; this->actor.velocity.z = 0.0f; - Actor_ApplyMovement(&this->actor); + Actor_UpdatePos(&this->actor); this->actor.world.pos.x = targetPos->x + this->unk_224.x; this->actor.world.pos.z = targetPos->z + this->unk_224.z; } @@ -535,7 +535,7 @@ void func_8088D864(EnElf* this, Vec3f* targetPos) { func_8088D5A0(this, targetPos, 0.2f); this->actor.velocity.z = 0.0f; this->actor.velocity.x = 0.0f; - Actor_ApplyMovement(&this->actor); + Actor_UpdatePos(&this->actor); this->actor.world.pos.x = targetPos->x + this->unk_224.x; this->actor.world.pos.z = targetPos->z + this->unk_224.z; } @@ -590,7 +590,7 @@ void func_8088D9BC(EnElf* this, GlobalContext* globalCtx) { } this->actor.world.rot.y = this->unk_258; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_8088DB4C(EnElf* this, Vec3f* arg1, f32 arg2, f32 arg3, f32 arg4) { @@ -616,7 +616,7 @@ void func_8088DB4C(EnElf* this, Vec3f* arg1, f32 arg2, f32 arg3, f32 arg4) { Math_StepToF(&this->actor.velocity.x, xVelTarget, 5.0f); Math_StepToF(&this->actor.velocity.z, zVelTarget, 5.0f); - Actor_ApplyMovement(&this->actor); + Actor_UpdatePos(&this->actor); } s32 func_8088DCA4(EnElf* this) { @@ -656,13 +656,13 @@ void func_8088DD34(EnElf* this, GlobalContext* globalCtx) { func_8088D9BC(this, globalCtx); if (Actor_HasParent(&this->actor, globalCtx)) { if (this->fairyFlags & 0x400) { - Actor_SetCollectibleFlag(globalCtx, this->unk_260); + Flags_SetCollectible(globalCtx, this->unk_260); } Actor_MarkForDeath(&this->actor); return; } - if (func_801233E4(globalCtx)) { + if (Player_InCsMode(&globalCtx->state)) { if ((this->fairyFlags & 0x4000) && (this->fairyFlags & 0x100) && func_8088DCA4(this)) { return; } @@ -686,7 +686,7 @@ void func_8088DD34(EnElf* this, GlobalContext* globalCtx) { this->unk_246 = 0; EnElf_SetupAction(this, func_8088E0F0); if (this->fairyFlags & 0x400) { - Actor_SetCollectibleFlag(globalCtx, this->unk_260); + Flags_SetCollectible(globalCtx, this->unk_260); } return; } @@ -700,7 +700,7 @@ void func_8088DD34(EnElf* this, GlobalContext* globalCtx) { } if (this->fairyFlags & 0x2000) { - func_800B8A1C(&this->actor, globalCtx, 0xBA, 80.0f, 60.0f); + Actor_PickUp(&this->actor, globalCtx, 0xBA, 80.0f, 60.0f); } } @@ -768,7 +768,7 @@ void func_8088E0F0(EnElf* this, GlobalContext* globalCtx) { this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); func_8088F5F4(this, globalCtx, 32); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); } void func_8088E304(EnElf* this, GlobalContext* globalCtx) { @@ -802,7 +802,7 @@ void func_8088E304(EnElf* this, GlobalContext* globalCtx) { func_8088D7F8(this, &player->bodyPartsPos[0]); this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); func_8088F5F4(this, globalCtx, 0x20); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); } void func_8088E484(EnElf* this, GlobalContext* globalCtx) { @@ -827,7 +827,7 @@ void func_8088E484(EnElf* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, (1.0f - (SQ(this->unk_250) * SQ(1.0f / 9.0f))) * 0.008f); this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); func_8088F5F4(this, globalCtx, 32); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); } void func_8088E5A8(EnElf* this, GlobalContext* globalCtx) { @@ -907,12 +907,12 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { (globalCtx->csCtx.unk_12 == 0) && ((globalCtx->csCtx.frames == 0x95) || (globalCtx->csCtx.frames == 0x17D) || (globalCtx->csCtx.frames == 0x24F))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } if ((globalCtx->sceneNum == SCENE_SECOM) && (gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.unk_12 == 4) && (globalCtx->csCtx.frames == 0x5F)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } } else { this->actor.shape.rot.x = 0; @@ -967,7 +967,7 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { break; default: - arrowPointedActor = globalCtx->actorCtx.targetContext.unk38; + arrowPointedActor = globalCtx->actorCtx.targetContext.arrowPointedActor; if ((player->stateFlags1 & 0x40) && (player->targetActor != NULL)) { Math_Vec3f_Copy(&nextPos, &player->targetActor->focus.pos); } else { @@ -995,7 +995,7 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { if (distFromLinksHead > 100.0f) { this->fairyFlags |= 2; if (this->unk_269 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); } this->unk_25C = 100; } @@ -1036,7 +1036,7 @@ void func_8088EF18(Color_RGBAf* dest, Color_RGBAf* newColor, Color_RGBAf* curCol } void func_8088EFA4(EnElf* this, GlobalContext* globalCtx) { - Actor* arrayPointerActor = globalCtx->actorCtx.targetContext.unk38; + Actor* arrayPointerActor = globalCtx->actorCtx.targetContext.arrowPointedActor; Player* player = GET_PLAYER(globalCtx); f32 transitionRate; @@ -1065,7 +1065,7 @@ void func_8088EFA4(EnElf* this, GlobalContext* globalCtx) { this->unk_268 = 0; this->unk_238 = 1.0f; if (!this->unk_269) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); } } else if (this->unk_268 == 0) { if ((arrayPointerActor == NULL) || @@ -1074,13 +1074,13 @@ void func_8088EFA4(EnElf* this, GlobalContext* globalCtx) { } } else if (this->unk_238 != 0.0f) { if (Math_StepToF(&this->unk_238, 0.0f, 0.25f)) { - this->innerColor = globalCtx->actorCtx.targetContext.unk18; - this->outerColor = globalCtx->actorCtx.targetContext.unk28; + this->innerColor = globalCtx->actorCtx.targetContext.fairyInner; + this->outerColor = globalCtx->actorCtx.targetContext.fairyOuter; } else { transitionRate = 0.25f / this->unk_238; - func_8088EF18(&this->innerColor, &globalCtx->actorCtx.targetContext.unk18, &this->innerColor, + func_8088EF18(&this->innerColor, &globalCtx->actorCtx.targetContext.fairyInner, &this->innerColor, transitionRate); - func_8088EF18(&this->outerColor, &globalCtx->actorCtx.targetContext.unk28, &this->outerColor, + func_8088EF18(&this->outerColor, &globalCtx->actorCtx.targetContext.fairyOuter, &this->outerColor, transitionRate); } } @@ -1094,7 +1094,7 @@ void func_8088EFA4(EnElf* this, GlobalContext* globalCtx) { u16 targetSfxId = this->unk_269 == 0 ? NA_SE_PL_WALK_GROUND - SFX_FLAG : NA_SE_PL_WALK_GROUND - SFX_FLAG; if (!temp) { - Audio_PlayActorSound2(&this->actor, targetSfxId); + Actor_PlaySfxAtPos(&this->actor, targetSfxId); } this->fairyFlags |= 1; } @@ -1133,7 +1133,7 @@ void func_8088F214(EnElf* this, GlobalContext* globalCtx) { sp34 = 1; func_800B9010(&this->actor, NA_SE_EV_BELL_ANGER - SFX_FLAG); } else { - arrowPointedActor = globalCtx->actorCtx.targetContext.unk38; + arrowPointedActor = globalCtx->actorCtx.targetContext.arrowPointedActor; if (player->stateFlags1 & 0x400) { sp34 = 10; this->unk_25C = 100; @@ -1150,7 +1150,7 @@ void func_8088F214(EnElf* this, GlobalContext* globalCtx) { sp34 = 0; } else if (!(player->stateFlags1 & 0x40)) { if (this->unk_269 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_NAVY_VANISH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); } sp34 = 5; } else { @@ -1199,7 +1199,7 @@ void func_8088F214(EnElf* this, GlobalContext* globalCtx) { if (!(player->stateFlags2 & 0x100000)) { sp34 = 5; if (this->unk_269 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_NAVY_VANISH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); } } break; @@ -1209,7 +1209,7 @@ void func_8088F214(EnElf* this, GlobalContext* globalCtx) { sp34 = 9; this->unk_25C = 0x2A; if (this->unk_269 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); } } else if (player->stateFlags1 & 0x40) { player->stateFlags2 |= 0x100000; @@ -1358,7 +1358,7 @@ void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { func_8088FA38(this, globalCtx); - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 4: if (func_80147624(globalCtx)) { if (globalCtx->msgCtx.unk11F04 == 0x202) { @@ -1467,7 +1467,7 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { thisx->flags |= 0x10000; } - if (func_800B84D0(thisx, globalCtx)) { + if (Actor_ProcessTalkRequest(thisx, &globalCtx->state)) { func_8019FDC8(&D_801DB4A4, NA_SE_VO_NA_LISTEN, 0x20); thisx->focus.pos = thisx->world.pos; @@ -1488,7 +1488,7 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { } if (this->elfMsg->home.rot.x == -0x961) { this->unk_234 = this->elfMsg; - func_800B86C8(thisx, globalCtx, this->elfMsg); + Actor_ChangeFocus(thisx, globalCtx, this->elfMsg); } } else { thisx->cutscene = -1; diff --git a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c index cd574fb318..0bf4b18ede 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -62,7 +62,7 @@ void EnElfbub_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - ActorShape_Init(&this->actor.shape, 16.0f, func_800B3FC0, 0.2f); + ActorShape_Init(&this->actor.shape, 16.0f, ActorShadow_DrawCircle, 0.2f); this->actor.hintId = 0x16; Actor_SetScale(&this->actor, 1.25f); @@ -143,7 +143,7 @@ void EnElfbub_Update(Actor* thisx, GlobalContext* globalCtx) { EnElfbub* this = THIS; Collider_UpdateCylinder(&this->actor, &this->collider); this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, this->actor.shape.yOffset); + Actor_SetFocus(&this->actor, this->actor.shape.yOffset); } void EnElfbub_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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 6ca10601cd..65863f546d 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -5,6 +5,7 @@ */ #include "z_en_elforg.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000010 @@ -72,7 +73,8 @@ void EnElforg_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->flags = 0; this->direction = 0; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0402CA98, &D_0402B494, this->jointTable, this->jointTable, 10); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gStrayFairySkel, &gStrayFairyFlyingAnim, this->jointTable, + this->jointTable, STRAY_FAIRY_LIMB_MAX); this->skelAnime.playSpeed = 1.0f; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); this->actor.shape.shadowAlpha = 255; @@ -85,7 +87,7 @@ void EnElforg_Init(Actor* thisx, GlobalContext* globalCtx) { } break; case STRAY_FAIRY_TYPE_COLLECTIBLE: - if (Actor_GetCollectibleFlag(globalCtx, STRAY_FAIRY_FLAG(&this->actor))) { + if (Flags_GetCollectible(globalCtx, STRAY_FAIRY_FLAG(&this->actor))) { Actor_MarkForDeath(&this->actor); return; } @@ -224,7 +226,7 @@ void EnElforg_MoveToTargetFairyFountain(EnElforg* this, Vec3f* homePos) { targetAngle += angleAdjustment; Math_SmoothStepToS(&this->actor.world.rot.y, targetAngle, 2, 4000, 1000); EnElforg_ApproachTargetSpeedXZ(this); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } /** @@ -247,7 +249,7 @@ void EnElforg_MoveToTarget(EnElforg* this, Vec3f* targetPos) { Math_SmoothStepToS(&this->actor.world.rot.y, targetAngle, 10, 0x200, 0x80); } EnElforg_ApproachTargetSpeedXZ(this); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80ACCBB8(EnElforg* this, GlobalContext* globalCtx) { @@ -401,7 +403,7 @@ void EnElforg_ClockTownFairyCollected(EnElforg* this, GlobalContext* globalCtx) EnElforg_CirclePlayer(this, globalCtx); player->actor.freezeTimer = 100; player->stateFlags1 |= 0x20000000; - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { player->actor.freezeTimer = 0; player->stateFlags1 &= ~0x20000000; Actor_MarkForDeath(&this->actor); @@ -435,19 +437,19 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { } scaledYDistance = this->actor.playerHeightRel - (this->actor.shape.yOffset * this->actor.scale.y); - if (!func_801233E4(globalCtx)) { + if (!Player_InCsMode(&globalCtx->state)) { if ((this->actor.xzDistToPlayer < 30.0f) && (scaledYDistance < 12.0f) && (scaledYDistance > -68.0f)) { EnElforg_SetupFairyCollected(this, globalCtx); func_80115908(globalCtx, 48); switch (STRAY_FAIRY_TYPE(&this->actor)) { case STRAY_FAIRY_TYPE_COLLECTIBLE: - Actor_SetCollectibleFlag(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); + Flags_SetCollectible(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); break; case STRAY_FAIRY_TYPE_CHEST: - Actor_SetChestFlag(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); + Flags_SetTreasure(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); break; default: - Actor_SetSwitchFlag(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); + Flags_SetSwitch(globalCtx, STRAY_FAIRY_FLAG(&this->actor)); break; } @@ -491,7 +493,7 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { Actor* EnElforg_GetHoldingEnemy(EnElforg* this, GlobalContext* globalCtx) { Actor* enemy; - for (enemy = globalCtx->actorCtx.actorList[ACTORCAT_ENEMY].first; enemy != NULL; enemy = enemy->next) { + for (enemy = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; enemy != NULL; enemy = enemy->next) { if ((enemy->home.pos.x == this->actor.home.pos.x) && (enemy->home.pos.y == this->actor.home.pos.y) && (enemy->home.pos.z == this->actor.home.pos.z)) { return enemy; @@ -507,7 +509,7 @@ void EnElforg_TrappedByEnemy(EnElforg* this, GlobalContext* globalCtx) { EnElforg_InitializeParams(this); this->actionFunc = EnElforg_FreeFloating; this->actor.draw = EnElforg_Draw; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHIBI_FAIRY_SAVED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHIBI_FAIRY_SAVED); } else { // The enemy is still alive, so have the Stray Fairy // track the enemy in case it's moving around. @@ -540,7 +542,7 @@ void EnElforg_HiddenByCollider(EnElforg* this, GlobalContext* globalCtx) { this->actor.draw = EnElforg_Draw; this->actor.world.pos.y += 40.0f; this->actor.home.pos.y += 40.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHIBI_FAIRY_SAVED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHIBI_FAIRY_SAVED); } else { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } @@ -575,13 +577,14 @@ s32 EnElforg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi EnElforg* this = THIS; if (this->direction < 0) { - if (limbIndex == 9) { + if (limbIndex == STRAY_FAIRY_LIMB_LEFT_FACING_HEAD) { *dList = NULL; } - } else if (limbIndex == 1) { + } else if (limbIndex == STRAY_FAIRY_LIMB_RIGHT_FACING_HEAD) { *dList = NULL; } - return 0; + + return false; } void EnElforg_Draw(Actor* thisx, GlobalContext* globalCtx) { @@ -589,22 +592,23 @@ void EnElforg_Draw(Actor* thisx, GlobalContext* globalCtx) { EnElforg* this = THIS; OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); switch (this->area) { case STRAY_FAIRY_AREA_WOODFALL: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_0402C908)); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairyWoodfallTexAnim)); break; case STRAY_FAIRY_AREA_SNOWHEAD: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_0402C890)); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairySnowheadTexAnim)); break; case STRAY_FAIRY_AREA_GREAT_BAY: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_0402C980)); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairyGreatBayTexAnim)); break; case STRAY_FAIRY_AREA_STONE_TOWER: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_0402C9F8)); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairyStoneTowerTexAnim)); break; default: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_0402C818)); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairyClockTownTexAnim)); break; } Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h index 5195235a31..fbf982beb4 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.h @@ -33,6 +33,20 @@ typedef enum { STRAY_FAIRY_AREA_MAX } StrayFairyArea; +typedef enum { + /* 0 */ STRAY_FAIRY_LIMB_NONE, + /* 1 */ STRAY_FAIRY_LIMB_RIGHT_FACING_HEAD, + /* 2 */ STRAY_FAIRY_LIMB_LEFT_WING, + /* 3 */ STRAY_FAIRY_LIMB_RIGHT_WING, + /* 4 */ STRAY_FAIRY_LIMB_GLOW, + /* 5 */ STRAY_FAIRY_LIMB_TORSO, + /* 6 */ STRAY_FAIRY_LIMB_RIGHT_ARM, + /* 7 */ STRAY_FAIRY_LIMB_PELVIS_AND_LEGS, + /* 8 */ STRAY_FAIRY_LIMB_LEFT_ARM, + /* 9 */ STRAY_FAIRY_LIMB_LEFT_FACING_HEAD, + /* 10 */ STRAY_FAIRY_LIMB_MAX, +} StrayFairyLimbs; + struct EnElforg; typedef void (*EnElforgActionFunc)(struct EnElforg*, GlobalContext*); @@ -40,11 +54,11 @@ typedef void (*EnElforgActionFunc)(struct EnElforg*, GlobalContext*); typedef struct EnElforg { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[10]; + /* 0x188 */ Vec3s jointTable[STRAY_FAIRY_LIMB_MAX]; /* 0x1C4 */ ColliderCylinder collider; /* 0x210 */ Actor* enemy; /* 0x214 */ u16 flags; - /* 0x216 */ s16 direction; // negative when facing left, positive when facing right + /* 0x216 */ s16 direction; // negative when facing right, positive when facing left /* 0x218 */ s16 area; /* 0x21C */ s32 timer; /* 0x220 */ s32 secondaryTimer; diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index f196fa54bb..58bf7e1fe7 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -109,7 +109,7 @@ void EnEncount2_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&D_06002420, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - ActorShape_Init(&this->dyna.actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->dyna.actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, &this->colElement); @@ -172,7 +172,7 @@ void EnEncount2_Popped(EnEncount2* this, GlobalContext* globalCtx) { EnEncount2_InitParticles(this, &curPos, 10); } - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_MUJURA_BALLOON_BROKEN); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_MUJURA_BALLOON_BROKEN); this->deathTimer = 30; this->actionFunc = EnEncount2_Die; } @@ -180,7 +180,7 @@ void EnEncount2_Popped(EnEncount2* this, GlobalContext* globalCtx) { void EnEncount2_Die(EnEncount2* this, GlobalContext* globalCtx) { if (this->deathTimer == 0) { if (this->switchFlag >= 0) { - Actor_SetSwitchFlag(globalCtx, this->switchFlag); + Flags_SetSwitch(globalCtx, this->switchFlag); } Actor_MarkForDeath(&this->dyna.actor); } @@ -193,10 +193,10 @@ void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx) { DECR(this->deathTimer); this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; - Actor_SetHeight(&this->dyna.actor, 30.0f); + Actor_SetFocus(&this->dyna.actor, 30.0f); Actor_SetScale(&this->dyna.actor, this->scale); this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->dyna.actor); + Actor_MoveWithGravity(&this->dyna.actor); EnEncount2_UpdateParticles(this, globalCtx); if (!this->isPopped) { @@ -209,8 +209,8 @@ void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx) { void EnEncount2_Draw(Actor* thisx, GlobalContext* globalCtx) { EnEncount2* this = THIS; if (this->isPopped != true) { - func_800BDFC0(globalCtx, D_06000A00); - func_800BDFC0(globalCtx, D_06000D78); + Gfx_DrawDListOpa(globalCtx, D_06000A00); + Gfx_DrawDListOpa(globalCtx, D_06000D78); } EnEncount2_DrawParticles(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c index e94c19f258..f483b3289d 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c +++ b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c @@ -49,7 +49,7 @@ void EnEndingHero_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 6; this->actor.gravity = -3.0f; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B0CC, &D_06000BE0, this->jointTable, this->morphTable, 15); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C1E748(this); } @@ -76,7 +76,7 @@ void EnEndingHero_Update(Actor* thisx, GlobalContext* globalCtx) { } } this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c index 045bf8deb2..8df6a328dd 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c +++ b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c @@ -41,7 +41,7 @@ void EnEndingHero2_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 6; this->actor.gravity = -3.0f; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06007908, &D_060011C0, this->jointTable, this->morphTable, 20); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C232E8(this); } @@ -61,7 +61,7 @@ void EnEndingHero2_Update(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero2* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c index 2f9c8391f3..b89196d58d 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c +++ b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c @@ -41,7 +41,7 @@ void EnEndingHero3_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 6; this->actor.gravity = -3.0f; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06007150, &D_06000E50, this->jointTable, this->morphTable, 17); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C23518(this); } @@ -61,7 +61,7 @@ void EnEndingHero3_Update(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero3* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c index fd5eae6249..5f2ad62224 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c +++ b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c @@ -41,7 +41,7 @@ void EnEndingHero4_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 6; this->actor.gravity = -3.0f; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600D640, &D_06002A84, this->jointTable, this->morphTable, 17); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C23748(this); } @@ -61,7 +61,7 @@ void EnEndingHero4_Update(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero4* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c index 77fc673085..3a8f317f55 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c +++ b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c @@ -47,7 +47,7 @@ void EnEndingHero5_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 6; this->actor.gravity = -3.0f; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600A850, &D_06002FA0, this->jointTable, this->morphTable, 17); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); this->unk25C = this->actor.params; func_80C23980(this); } @@ -68,7 +68,7 @@ void EnEndingHero5_Update(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero5* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } diff --git a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c index d692d4f112..7af0874336 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c +++ b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c @@ -78,7 +78,7 @@ void EnEndingHero6_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -3.0f; SkelAnime_InitFlex(globalCtx, &this->skelAnime, sSkeletons[this->npcIndex], sAnimations[this->npcIndex], this->jointTable, this->morphTable, sLimbCounts[this->npcIndex]); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); EnEndingHero6_SetupIdle(this); } @@ -119,7 +119,7 @@ void EnEndingHero6_Update(Actor* thisx, GlobalContext* globalCtx) { } this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.c b/src/overlays/actors/ovl_En_Fall/z_en_fall.c index 155493dbd2..0474bc1323 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -176,7 +176,7 @@ void EnFall_Destroy(Actor* thisx, GlobalContext* globalCtx) { * Finds the Termina Field moon so the Moon's Tear can spawn in the correct place. */ Actor* EnFall_MoonsTear_GetTerminaFieldMoon(GlobalContext* globalCtx) { - Actor* itemAction = globalCtx->actorCtx.actorList[ACTORCAT_ITEMACTION].first; + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (itemAction != NULL) { if (itemAction->id == ACTOR_EN_FALL && EN_FALL_TYPE(itemAction) == EN_FALL_TYPE_TERMINA_FIELD_MOON) { @@ -349,7 +349,7 @@ void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, GlobalCont switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0) { case 3: if (this->eyeGlowIntensity == 0.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_MOON_EYE_FLASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MOON_EYE_FLASH); } this->eyeGlowIntensity += 0.033333335f; if (this->eyeGlowIntensity > 1.0f) { @@ -380,13 +380,13 @@ void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalCo case 0: switch (globalCtx->csCtx.frames) { case 1060: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MOON_SCREAM1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MOON_SCREAM1); break; case 1089: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_MOON_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MOON_CRY); break; case 1303: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SLIP_MOON); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIP_MOON); break; } if (globalCtx->csCtx.frames >= 1145) { @@ -396,13 +396,13 @@ void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalCo case 1: switch (globalCtx->csCtx.frames) { case 561: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MOON_SCREAM1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MOON_SCREAM1); break; case 590: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_MOON_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MOON_CRY); break; case 737: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SLIP_MOON); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIP_MOON); break; } if (globalCtx->csCtx.frames >= 650) { @@ -480,7 +480,7 @@ void EnFall_MoonsTear_Fall(EnFall* this, GlobalContext* globalCtx) { if (this->actor.draw != NULL) { if (Math_Vec3f_StepTo(&this->actor.world.pos, &this->actor.home.pos, this->actor.speedXZ) <= 0.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_GORON_BOUND_1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_BOUND_1); gSaveContext.weekEventReg[0x4A] |= 0x80; gSaveContext.weekEventReg[0x4A] |= 0x20; Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TEST, this->actor.world.pos.x, @@ -659,7 +659,7 @@ void EnFall_FireRing_Update(Actor* thisx, GlobalContext* globalCtx) { if (func_800EE29C(globalCtx, 0x1C2) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1C2)]->unk0 == 5) { if (!(this->flags & EN_FALL_FLAG_FIRE_RING_APPEARS)) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_DM_RING_EXPLOSION); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_DM_RING_EXPLOSION); } this->flags |= EN_FALL_FLAG_FIRE_RING_APPEARS; } diff --git a/src/overlays/actors/ovl_En_Fg/z_en_fg.c b/src/overlays/actors/ovl_En_Fg/z_en_fg.c index f91ee7a312..6123310541 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.c +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.c @@ -184,7 +184,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { switch (EnFg_GetDamageEffect(this)) { case FG_DMGEFFECT_DEKUSTICK: this->actor.flags &= ~1; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_CRY_1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_1); this->skelAnime.playSpeed = 0.0f; this->actor.shape.shadowDraw = NULL; this->actor.scale.x *= 1.5f; @@ -210,7 +210,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { break; case FG_DMGEFFECT_EXPLOSION: this->actor.flags &= ~1; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_CRY_0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_0); if (1) {} this->actor.params = FG_BLACK; this->skelAnime.playSpeed = 0.0f; @@ -226,14 +226,14 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { break; default: if (DECR(this->timer) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_JUMP); EnFg_UpdateAnimation(&this->skelAnime, 3); this->actor.velocity.y = 10.0f; this->timer = Rand_S16Offset(30, 30); this->actionFunc = EnFg_Jump; } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { @@ -261,7 +261,7 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { break; case FG_DMGEFFECT_EXPLOSION: this->actor.flags &= ~1; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_CRY_0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_0); EnFg_UpdateAnimation(&this->skelAnime, 0); this->actor.params = FG_BLACK; this->skelAnime.playSpeed = 0.0f; @@ -286,7 +286,7 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { this->actionFunc = EnFg_Idle; this->actor.velocity.y = 0.0f; } else { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } } } @@ -313,14 +313,14 @@ void EnFg_Knockback(EnFg* this, GlobalContext* globalCtx) { EnFg_AddDust(&this->dustEffect[0], &this->actor.world.pos); } this->actor.shape.rot.x += 0x1000; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } } void EnFg_Init(Actor* thisx, GlobalContext* globalCtx) { EnFg* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 10.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B538, NULL, this->jointTable, this->morphTable, 24); EnFg_UpdateAnimation(&this->skelAnime, 0); Collider_InitCylinder(globalCtx, &this->collider); 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 32d5d5e819..5c5952cc6b 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -127,7 +127,7 @@ void EnFirefly_Init(Actor* thisx, GlobalContext* globalCtx) { EnFirefly* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &D_060018B8, &D_0600017C, this->jointTable, this->morphTable, 28); Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -173,7 +173,7 @@ void EnFirefly_SpawnIceEffects(EnFirefly* this, GlobalContext* globalCtx) { if (this->unk_18F == 0xA) { this->unk_18F = 0; this->unk_2E8.x = 0.0f; - func_800BF7CC(globalCtx, &this->actor, &this->unk_2F8, 3, 2, 0.2f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, &this->unk_2F8, 3, 2, 0.2f, 0.2f); } } @@ -223,7 +223,7 @@ s32 EnFirefly_ReturnToPerch(EnFirefly* this, GlobalContext* globalCtx) { } s32 EnFirefly_SeekTorch(EnFirefly* this, GlobalContext* globalCtx) { - ObjSyokudai* findTorch = (ObjSyokudai*)globalCtx->actorCtx.actorList[ACTORCAT_PROP].first; + ObjSyokudai* findTorch = (ObjSyokudai*)globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; ObjSyokudai* closestTorch = NULL; f32 currentMinDist = 35000.0f; f32 currentDist; @@ -332,13 +332,13 @@ void EnFirefly_SetupFall(EnFirefly* this, GlobalContext* globalCtx) { this->timer = 40; this->actor.velocity.y = 0.0f; Animation_Change(&this->skelAnime, &D_0600017C, 0.0f, 6.0f, 6.0f, 2, 0.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FFLY_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_DEAD); this->actor.flags |= 0x10; if (this->isInvisible) { - func_800BCB70(&this->actor, 0x4000, 255, 0x2000, 40); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0x2000, 40); } else { - func_800BCB70(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); } if (this->actor.colChkInfo.damageEffect == 3) { @@ -431,7 +431,7 @@ void EnFirefly_DiveAttack(EnFirefly* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 8) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 2, 0xC00, 0x300); Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2800)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2800)) { if (Animation_OnFrame(&this->skelAnime, 4.0f)) { this->skelAnime.playSpeed = 0.0f; this->skelAnime.curFrame = 4.0f; @@ -534,9 +534,9 @@ void EnFirefly_FlyAway(EnFirefly* this, GlobalContext* globalCtx) { void EnFirefly_SetupStunned(EnFirefly* this) { if (this->isInvisible) { - func_800BCB70(&this->actor, 0, 255, 0x2000, this->timer); + Actor_SetColorFilter(&this->actor, 0, 255, 0x2000, this->timer); } else { - func_800BCB70(&this->actor, 0, 255, 0, this->timer); + Actor_SetColorFilter(&this->actor, 0, 255, 0, this->timer); } if (this->actionFunc != EnFirefly_Stunned) { @@ -545,7 +545,7 @@ void EnFirefly_SetupStunned(EnFirefly* this) { } this->auraType = KEESE_AURA_NONE; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = EnFirefly_Stunned; } @@ -633,7 +633,7 @@ void EnFirefly_DisturbDiveAttack(EnFirefly* this, GlobalContext* globalCtx) { void EnFirefly_UpdateDamage(EnFirefly* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - func_800BE258(&this->actor, &this->collider.info); + Actor_SetDropFlag(&this->actor, &this->collider.info); if (this->actor.colChkInfo.damageEffect == 1) { this->timer = 40; @@ -666,7 +666,7 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FFLY_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_ATTACK); if (this->currentType != KEESE_NORMAL) { EnFirefly_Extinguish(this); @@ -682,13 +682,13 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { if (!(this->actor.flags & 0x8000)) { if ((this->actor.colChkInfo.health == 0) || (this->actionFunc == EnFirefly_Stunned)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } else { if (this->actionFunc != EnFirefly_Rebound) { this->actor.world.rot.x = 0x1554 - this->actor.shape.rot.x; } - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); } } @@ -706,7 +706,7 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { this->actor.world.rot.y = this->actor.shape.rot.y; if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FFLY_FLY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_FLY); } } diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.c b/src/overlays/actors/ovl_En_Fish/z_en_fish.c index 61f08534b7..24d8efb58a 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -5,6 +5,7 @@ */ #include "z_en_fish.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000000 @@ -15,19 +16,56 @@ void EnFish_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFish_Update(Actor* thisx, GlobalContext* globalCtx); void EnFish_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8091FA60[1] = { +void func_8091DF68(Actor* thisx, GlobalContext* globalCtx); +void func_8091E070(EnFish* this); +void func_8091E128(Actor* thisx, GlobalContext* globalCtx); +void func_8091E2E0(EnFish* this); +void func_8091E34C(Actor* thisx, GlobalContext* globalCtx2); +void func_8091E5EC(EnFish* this); +void func_8091E658(Actor* thisx, GlobalContext* globalCtx); +void func_8091E810(EnFish* this); +void func_8091E880(Actor* thisx, GlobalContext* globalCtx); +void func_8091E9A4(EnFish* this); +void func_8091EAF0(Actor* thisx, GlobalContext* globalCtx); +void func_8091ECF4(EnFish* this); +void func_8091ED70(Actor* thisx, GlobalContext* globalCtx); +void func_8091EF30(EnFish* this); +void func_8091EFE8(Actor* thisx, GlobalContext* globalCtx); +void func_8091F344(EnFish* this); +void func_8091F3BC(Actor* thisx, GlobalContext* globalCtx); +void func_8091F994(Actor* thisx, GlobalContext* globalCtx); + +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 5 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8091FA84 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_8091FA60, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static Color_RGB8 D_8091FA94[] = { + { 255, 155, 55 }, + { 255, 47, 157 }, + { 215, 97, 7 }, }; const ActorInit En_Fish_InitVars = { @@ -42,87 +80,874 @@ const ActorInit En_Fish_InitVars = { (ActorFunc)EnFish_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8091FAC0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 720, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 40, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 40, ICHAIN_STOP), }; -#endif +f32 func_8091D630(Vec3f* arg0, Vec3f* arg1) { + return SQ(arg0->x - arg1->x) + SQ(arg0->z - arg1->z); +} -extern ColliderJntSphElementInit D_8091FA60[1]; -extern ColliderJntSphInit D_8091FA84; -extern InitChainEntry D_8091FAC0[]; +void func_8091D660(EnFish* this) { + Animation_Change(&this->skelAnime, &gameplay_keep_Anim_02F0EC, 1.0f, 0.0f, + Animation_GetLastFrame(&gameplay_keep_Anim_02F0EC), 1, 2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D630.s") +void func_8091D6C4(EnFish* this) { + Animation_Change(&this->skelAnime, &gameplay_keep_Anim_02E65C, 1.0f, 0.0f, + Animation_GetLastFrame(&gameplay_keep_Anim_02E65C), 1, 2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D660.s") +void func_8091D728(EnFish* this) { + f32 phi_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D6C4.s") + this->actor.scale.x = this->unk_250 * this->unk_25C; + this->actor.scale.y = this->unk_254 * this->unk_25C; + this->actor.scale.z = this->unk_258 * this->unk_25C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D728.s") + if (this->actor.scale.z > 0.00001f) { + phi_f0 = 1.0f / this->actor.scale.z; + } else { + phi_f0 = 0.0f; + } + this->unk_264 = 16.0f * phi_f0; + this->unk_266 = 12.0f * phi_f0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D7C4.s") +void func_8091D7C4(EnFish* this) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D840.s") + Math_ScaledStepToS(&this->actor.world.rot.x, this->unk_268, this->unk_26E); + Math_ScaledStepToS(&this->actor.world.rot.y, this->unk_26A, this->unk_270); + if (this->actor.world.rot.z != this->unk_26C) { + Math_ScaledStepToS(&this->actor.world.rot.z, this->unk_26C, this->unk_272); + } + this->actor.shape.rot = this->actor.world.rot; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D904.s") +void func_8091D840(Actor* thisx, GlobalContext* globalCtx, s32 arg2, f32 arg3) { + EnFish* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091D944.s") + for (i = 0; i < arg2; i++) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, arg3, arg3, (Rand_ZeroOne() * 0.09f) + 0.06f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091DA14.s") +void func_8091D904(EnFish* this) { + this->unk_242 = 400; + this->unk_25C = this->unk_260 * 0.1f; + func_8091D728(this); + this->actor.draw = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/EnFish_Init.s") +Actor* func_8091D944(EnFish* this, GlobalContext* globalCtx) { + f32 distSq; + Actor* retActor = NULL; + f32 minDistSq = FLT_MAX; + Actor* foundActor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/EnFish_Destroy.s") + while (foundActor != NULL) { + if ((foundActor->id == ACTOR_EN_FISH) && (foundActor->params == ENFISH_2) && + (foundActor->room == this->actor.room)) { + distSq = Math3D_Vec3fDistSq(&foundActor->world.pos, &this->actor.world.pos); + if (retActor == NULL) { + retActor = foundActor; + minDistSq = distSq; + } else if (distSq < minDistSq) { + minDistSq = distSq; + } + } + foundActor = foundActor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091DD48.s") + return retActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091DDF4.s") +s32 func_8091DA14(EnFish* this, GlobalContext* globalCtx) { + return globalCtx->sceneNum == SCENE_LABO && func_8091D944(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091DEE4.s") +void EnFish_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFish* this = THIS; + s16 sp36 = this->actor.params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091DF68.s") + Collider_InitJntSph(globalCtx, &this->collider); + if (sp36 == ENFISH_2) { + this->actor.draw = NULL; + this->actor.update = func_8091F994; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E070.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->unk_250 = 1.0f; + this->unk_254 = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E128.s") + if (sp36 == ENFISH_MINUS1) { + this->unk_258 = (Rand_ZeroOne() * 0.9f) + 0.6f; + this->unk_25C = ((Rand_ZeroOne() * 1.2f) + 0.6f) * 0.01f; + } else { + this->unk_258 = 1.0f; + this->unk_25C = 0.01f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E2E0.s") + this->unk_260 = this->unk_25C; + func_8091D728(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E34C.s") + if ((this->unk_258 * this->unk_25C * 100.0f) < 1.02f) { + this->unk_278 = 2; + } else if ((this->unk_258 * this->unk_25C * 100.0f) < 2.0f) { + this->unk_278 = 1; + } else { + this->unk_278 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E5EC.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gameplay_keep_Skel_02F028, &gameplay_keep_Anim_02F0EC, + this->jointTable, this->morphTable, 7); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E658.s") + this->actor.colChkInfo.mass = this->unk_25C * 30.0f; + this->unk_244 = (u32)Rand_Next() >> 0x10; + this->unk_246 = (u32)Rand_Next() >> 0x10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E810.s") + if (sp36 == ENFISH_0) { + this->actor.flags |= 0x10; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 8.0f); + func_8091E810(this); + } else if (sp36 == ENFISH_1) { + func_8091F344(this); + } else { + func_8091E070(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E880.s") +void EnFish_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnFish* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091E9A4.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091EAF0.s") +void func_8091DD48(EnFish* this) { + this->actor.shape.yOffset += (Math_SinS(this->unk_246) * 5.0f) + (Math_SinS(this->unk_244) * 10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091ECF4.s") + if (this->actor.shape.yOffset < -200.0f) { + this->actor.shape.yOffset = -200.0f; + } else if (this->actor.shape.yOffset > 200.0f) { + this->actor.shape.yOffset = 200.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091ED70.s") +s32 func_8091DDF4(EnFish* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Vec3f sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091EF30.s") + if (this->actor.xzDistToPlayer < 50.0f) { + sp1C.x = (Math_SinS(BINANG_ROT180(this->actor.yawTowardsPlayer)) * 30.0f) + player->actor.world.pos.x; + sp1C.y = player->actor.world.pos.y; + sp1C.z = (Math_CosS(BINANG_ROT180(this->actor.yawTowardsPlayer)) * 30.0f) + player->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091EFE8.s") + if (func_8091D630(&sp1C, &this->actor.world.pos) <= SQ(30.0f)) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091F344.s") +void func_8091DEE4(EnFish* this) { + static s16 D_8091FACC[] = { 85, 60, 45 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091F3BC.s") + this->actor.gravity = 0.0f; + this->actor.terminalVelocity = 0.0f; + this->unk_240 = Rand_S16Offset(5, D_8091FACC[this->unk_278]); + this->unk_248 = 0; + this->unk_26E = 400; + this->unk_272 = 400; + this->unk_268 = 0; + this->unk_26C = 0; + func_8091D660(this); + this->unk_24C = 0.0f; + this->unkFunc = func_8091DF68; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091F5A4.s") +void func_8091DF68(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091F830.s") + func_8091DD48(this); + Math_SmoothStepToF(&thisx->speedXZ, 0.0f, 0.05f, 0.3f, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/EnFish_Update.s") + if ((thisx->speedXZ * 1.4f) + 0.8f > 2.0f) { + this->skelAnime.playSpeed = 2.0f; + } else { + this->skelAnime.playSpeed = (thisx->speedXZ * 1.4f) + 0.8f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/func_8091F994.s") + this->unk_270 >>= 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fish/EnFish_Draw.s") + if (this->unk_240 <= 0) { + func_8091E070(this); + } else if (thisx == thisx->child) { + func_8091E5EC(this); + } else if ((thisx->xzDistToPlayer < 60.0f) || (this->unk_276 > 0)) { + func_8091E2E0(this); + } +} + +void func_8091E070(EnFish* this) { + static s16 D_8091FAD4[] = { 20, 30, 40 }; + s16 phi_a1; + + this->actor.gravity = 0.0f; + this->actor.terminalVelocity = 0.0f; + + if ((Rand_Next() & 3) == 0) { + if (((Rand_Next() & 7) == 0) && (this->unk_278 != 0)) { + phi_a1 = 80; + } else { + phi_a1 = 45; + } + } else { + phi_a1 = D_8091FAD4[this->unk_278]; + } + this->unk_240 = Rand_S16Offset(15, phi_a1); + this->unk_248 = 0; + this->unk_26E = 400; + this->unk_272 = 400; + this->unk_26C = 0; + func_8091D660(this); + this->unkFunc = func_8091E128; +} + +void func_8091E128(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFish* this = THIS; + + func_8091DD48(this); + Math_SmoothStepToF(&thisx->speedXZ, 1.8f, 0.08f, 0.4f, 0.0f); + + if ((func_8091D630(&thisx->world.pos, &thisx->home.pos) > SQ(80.0f)) || (this->unk_240 < 4)) { + this->unk_270 = this->unk_264; + this->unk_26A = Math_Vec3f_Yaw(&thisx->world.pos, &thisx->home.pos); + this->unk_24C = 1.0f; + } else if ((thisx->child != NULL) && (thisx != thisx->child)) { + this->unk_270 = this->unk_264; + this->unk_26A = Math_Vec3f_Yaw(&thisx->world.pos, &thisx->child->world.pos); + this->unk_24C = 1.2f; + } else { + this->unk_270 >>= 2; + this->unk_24C = 0.0f; + } + + if ((thisx->speedXZ * 1.5f) + 0.8f > 4.0f) { + this->skelAnime.playSpeed = 4.0f; + } else { + this->skelAnime.playSpeed = (thisx->speedXZ * 1.5f) + 0.8f; + } + + if (this->unk_240 <= 0) { + func_8091DEE4(this); + } else if (thisx == thisx->child) { + func_8091E5EC(this); + } else if ((thisx->xzDistToPlayer < 60.0f) || (this->unk_276 > 0)) { + func_8091E2E0(this); + } +} + +void func_8091E2E0(EnFish* this) { + this->actor.gravity = 0.0f; + this->actor.terminalVelocity = 0.0f; + this->unk_240 = Rand_S16Offset(10, 40); + this->unk_248 = 0; + this->unk_26E = 400; + this->unk_272 = 400; + this->unk_268 = 0; + this->unk_26C = 0; + func_8091D660(this); + this->unkFunc = func_8091E34C; +} + +void func_8091E34C(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnFish* this = THIS; + s32 sp3C = thisx->xzDistToPlayer < 60.0f; + s32 sp38 = this->unk_276 > 0; + s32 pad; + + func_8091DD48(this); + Math_SmoothStepToF(&thisx->speedXZ, 4.2f, 0.08f, 1.4f, 0.0f); + + if (func_8091D630(&thisx->world.pos, &thisx->home.pos) > SQ(160.0f)) { + this->unk_270 = this->unk_264; + this->unk_26A = Math_Vec3f_Yaw(&thisx->world.pos, &thisx->home.pos); + this->unk_24C = 0.8f; + } else if ((thisx->child != NULL) && (thisx != thisx->child)) { + this->unk_270 = this->unk_266; + this->unk_26A = Math_Vec3f_Yaw(&thisx->world.pos, &thisx->child->world.pos); + this->unk_24C = 1.0f; + } else if (sp3C) { + this->unk_26A = BINANG_ROT180(thisx->yawTowardsPlayer); + if ((globalCtx->state.frames & 0x10) == 0) { + if ((globalCtx->state.frames & 0x20) == 0) { + this->unk_26A += 0x2000; + } + } else if ((globalCtx->state.frames & 0x20) == 0) { + this->unk_26A -= 0x2000; + } + this->unk_270 = this->unk_266; + this->unk_24C = 1.2f; + } else if (sp38 != 0) { + if ((globalCtx->state.frames & 0x10) == 0) { + s16 temp = BINANG_SUB(thisx->shape.rot.y, this->unk_274); + + if (temp < 0) { + this->unk_26A = BINANG_SUB(this->unk_274, 0x4000); + } else { + this->unk_26A = BINANG_ADD(this->unk_274, 0x4000); + } + } else { + this->unk_26A = BINANG_ROT180(this->unk_274); + } + this->unk_24C = 1.2f; + this->unk_270 = this->unk_266; + } else { + this->unk_270 >>= 2; + this->unk_24C = 0.0f; + } + + if ((thisx->speedXZ * 1.5f) + 0.8f > 4.0f) { + this->skelAnime.playSpeed = 4.0f; + } else { + this->skelAnime.playSpeed = (thisx->speedXZ * 1.5f) + 0.8f; + } + + if ((this->unk_240 <= 0) || (!sp3C && (sp38 == 0))) { + func_8091DEE4(this); + } else if (thisx == thisx->child) { + func_8091E5EC(this); + } +} + +void func_8091E5EC(EnFish* this) { + this->actor.gravity = 0.0f; + this->actor.terminalVelocity = 0.0f; + this->unk_26E = 400; + this->unk_272 = 400; + this->unk_268 = 0; + this->unk_26C = 0; + func_8091D660(this); + this->unk_240 = Rand_S16Offset(10, 30); + this->unk_248 = 0; + this->unkFunc = func_8091E658; +} + +void func_8091E658(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + Player* player = GET_PLAYER(globalCtx); + s32 pad; + Vec3f sp38; + s32 pad2; + s16 sp32; + + func_8091DD48(this); + Math_SmoothStepToF(&thisx->speedXZ, 1.8f, 0.1f, 0.5f, 0.0f); + + if (func_8091D630(&thisx->world.pos, &thisx->home.pos) > SQ(80.0f)) { + this->unk_270 = this->unk_264; + this->unk_26A = Math_Vec3f_Yaw(&thisx->world.pos, &thisx->home.pos); + this->unk_24C = 1.0f; + } else { + if ((globalCtx->state.frames & 0x40) == 0) { + sp32 = BINANG_ADD(thisx->yawTowardsPlayer, 0x9000); + } else { + sp32 = BINANG_ADD(thisx->yawTowardsPlayer, 0x7000); + } + + sp38.x = (Math_SinS(sp32) * 20.0f) + player->actor.world.pos.x; + sp38.y = player->actor.world.pos.y; + sp38.z = (Math_CosS(sp32) * 20.0f) + player->actor.world.pos.z; + + this->unk_270 = this->unk_264; + this->unk_26A = Math_Vec3f_Yaw(&thisx->world.pos, &sp38); + this->unk_24C = 1.2f; + } + + if ((thisx->speedXZ * 1.5f) + 0.8f > 4.0f) { + this->skelAnime.playSpeed = 4.0f; + } else { + this->skelAnime.playSpeed = (thisx->speedXZ * 1.5f) + 0.8f; + } + + if (this->unk_240 <= 0) { + func_8091DEE4(this); + } +} + +void func_8091E810(EnFish* this) { + this->unk_270 = 0; + this->unk_26A = 0; + this->actor.gravity = -1.0f; + this->actor.terminalVelocity = -10.0f; + this->actor.shape.yOffset = 0.0f; + func_8091D6C4(this); + this->unk_248 = 5; + this->unkFunc = func_8091E880; + this->unk_24C = 0.0f; + this->unk_240 = 300; +} + +void func_8091E880(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.1f, 0.0f); + this->unk_26E = 0x43; + this->unk_272 = 0x43; + this->unk_268 = 0x4000; + this->unk_26C = -0x4000; + if (this->actor.bgCheckFlags & 1) { + this->unk_240 = 400; + func_8091E9A4(this); + } else if (this->actor.bgCheckFlags & 0x20) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); + func_8091D840(thisx, globalCtx, 10, 15.0f); + if (func_8091DA14(this, globalCtx)) { + func_8091EF30(this); + } else { + func_8091ECF4(this); + } + } else if ((this->unk_240 <= 0) && (this->actor.params == ENFISH_0) && + (this->actor.floorHeight < BGCHECK_Y_MIN + 10)) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_8091E9A4(EnFish* this) { + s32 pad[2]; + s32 sp24; + f32 temp_f0; + + this->actor.gravity = -1.0f; + this->actor.terminalVelocity = -10.0f; + + temp_f0 = Rand_ZeroOne(); + if (temp_f0 < 0.1f) { + this->actor.velocity.y = (Rand_ZeroOne() * 3.0f) + 2.5f; + sp24 = true; + } else if (temp_f0 < 0.2f) { + this->actor.velocity.y = (Rand_ZeroOne() * 1.2f) + 0.2f; + sp24 = true; + } else { + this->actor.velocity.y = 0.0f; + if (Rand_ZeroOne() < 0.2f) { + sp24 = true; + } else { + sp24 = false; + } + } + + this->actor.shape.yOffset = 300.0f; + func_8091D6C4(this); + this->unkFunc = func_8091EAF0; + this->unk_248 = 5; + this->unk_24C = 0.0f; + if (sp24 && (this->actor.draw != NULL)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FISH_LEAP); + } +} + +void func_8091EAF0(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + s32 sp40 = globalCtx->state.frames; + s16 phi_v1; + + Math_SmoothStepToF(&this->actor.speedXZ, Rand_ZeroOne() * 0.2f, 0.1f, 0.1f, 0.0f); + phi_v1 = (s16)((((sp40 >> 5) & 2) | ((sp40 >> 2) & 1)) << 0xB) * 0.3f; + if (sp40 & 4) { + phi_v1 *= -1; + } + this->unk_268 = phi_v1; + this->unk_26E = 0xA6B; + this->unk_26C = 0x4000; + this->unk_272 = 0x29B; + this->unk_270 = ((Math_SinS(this->unk_244) * 1333.0f) + (Math_SinS(this->unk_246) * 667.0f)) * Rand_ZeroOne(); + + if (this->unk_270 >= 0) { + this->unk_26A = BINANG_ADD(this->actor.world.rot.y, 0x4000); + } else { + this->unk_26A = BINANG_SUB(this->actor.world.rot.y, 0x4000); + this->unk_270 = -this->unk_270; + } + + if (this->unk_240 <= 0) { + Actor_MarkForDeath(&this->actor); + } else if (this->unk_240 <= 60) { + if (sp40 & 4) { + this->actor.draw = EnFish_Draw; + } else { + this->actor.draw = NULL; + } + } else if (this->actor.bgCheckFlags & 0x20) { + if (func_8091DA14(this, globalCtx)) { + func_8091EF30(this); + } else { + func_8091ECF4(this); + } + } else if (this->actor.bgCheckFlags & 1) { + func_8091E9A4(this); + } +} + +void func_8091ECF4(EnFish* this) { + this->actor.home.pos = this->actor.world.pos; + this->actor.gravity = 0.0f; + this->actor.terminalVelocity = 0.0f; + this->actor.shape.yOffset = 0.0f; + this->actor.flags |= 0x10; + this->unk_240 = 200; + func_8091D660(this); + this->unkFunc = func_8091ED70; + this->unk_248 = 5; + this->unk_24C = 0.0f; +} + +void func_8091ED70(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + s32 pad; + s16 sp2E; + + if (this->unk_240 >= 0xBF) { + func_8091D840(thisx, globalCtx, 2, 25.0f); + } + + Math_SmoothStepToF(&thisx->speedXZ, 2.8f, 0.1f, 0.4f, 0.0f); + + if ((thisx->bgCheckFlags & 8) || !(thisx->bgCheckFlags & 0x20)) { + sp2E = Math_Vec3f_Yaw(&thisx->world.pos, &thisx->home.pos); + thisx->home.rot.y = Rand_S16Offset(-100, 100) + sp2E; + thisx->speedXZ *= 0.5f; + } + + this->unk_268 = 0; + this->unk_26A = thisx->home.rot.y; + this->unk_26C = 0; + this->unk_26E = 1000; + this->unk_270 = 2000; + this->unk_272 = 0x29B; + + if (thisx->bgCheckFlags & 1) { + Math_StepToF(&thisx->world.pos.y, thisx->home.pos.y - 4.0f, 2.0f); + } else { + Math_StepToF(&thisx->world.pos.y, thisx->home.pos.y - 10.0f, 2.0f); + } + + if (this->unk_240 < 100) { + this->unk_25C *= 0.982f; + func_8091D728(this); + } + + if ((thisx->speedXZ * 1.5f) + 1.0f > 4.8f) { + this->skelAnime.playSpeed = 4.8f; + } else { + this->skelAnime.playSpeed = (thisx->speedXZ * 1.5f) + 1.0f; + } + + if (this->unk_240 <= 0) { + Actor_MarkForDeath(thisx); + } +} + +void func_8091EF30(EnFish* this) { + this->actor.gravity = -2.0f; + this->actor.terminalVelocity = -10.0f; + this->actor.shape.yOffset = 0.0f; + if (this->actor.velocity.y < -1.0f) { + this->actor.velocity.y = -1.0f; + } + this->actor.flags |= 0x10; + this->actor.home.pos.x = this->actor.world.pos.x; + this->actor.home.pos.y = this->actor.world.pos.y - 20.0f; + this->actor.home.pos.z = this->actor.world.pos.z; + func_8091D660(this); + this->unk_240 = 15; + this->unk_279 = 10; + this->unkFunc = func_8091EFE8; + this->unk_248 = 5; + this->unk_24C = 0.0f; +} + +void func_8091EFE8(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + s32 temp_v0_2; + Actor* sp3C = func_8091D944(this, globalCtx); + f32 temp_f0; + f32 sp34; + f32 sp30; + s16 sp2E; + + if (sp3C == 0) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->unk_240 <= 0) { + this->unk_240 = Rand_S16Offset(5, 35); + } + + if (this->unk_277 == 0) { + Math_SmoothStepToF(&this->actor.speedXZ, 2.8f, 0.1f, 0.4f, 0.0f); + if (this->unk_240 < 6) { + this->actor.speedXZ *= 0.75f; + } + } + + if ((this->actor.bgCheckFlags & 8) && !(this->actor.bgCheckFlags & 0x20)) { + this->actor.speedXZ *= 0.5f; + } + + if (!((u32)Rand_Next() >> 0x1B) || ((this->actor.bgCheckFlags & 8) && !((u32)Rand_Next() >> 0x1E)) || + !(this->actor.bgCheckFlags & 0x20)) { + temp_f0 = Rand_ZeroOne(); + sp34 = (1.0f - SQ(temp_f0)) * sp3C->home.rot.x; + sp30 = Rand_ZeroOne() * sp3C->home.rot.z; + sp2E = (u32)Rand_Next() >> 0x10; + this->actor.home.pos.x = (Math_SinS(sp2E) * sp34) + sp3C->world.pos.x; + this->actor.home.pos.y = sp3C->world.pos.y + sp30; + this->actor.home.pos.z = (Math_CosS(sp2E) * sp34) + sp3C->world.pos.z; + this->actor.home.rot.y = + Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos) + Rand_S16Offset(-100, 100); + } + + this->unk_268 = Math_Vec3f_Pitch(&this->actor.world.pos, &this->actor.home.pos); + this->unk_26C = 0; + this->unk_26A = this->actor.home.rot.y; + + temp_v0_2 = BINANG_SUB(this->unk_268, this->actor.shape.rot.x); + temp_v0_2 = ABS_ALT(temp_v0_2); + + temp_v0_2 = temp_v0_2 / 11; + if (temp_v0_2 > 800) { + temp_v0_2 = 800; + } else if (temp_v0_2 < 100) { + temp_v0_2 = 100; + } + + if (this->unk_279 > 0) { + this->unk_279--; + this->unk_26E = 1000; + } else { + this->unk_26E = temp_v0_2; + } + + if (this->unk_240 < 10) { + this->unk_270 = 400; + } else { + this->unk_270 = 2000; + } + + this->unk_272 = 0x29B; + if (fabsf(this->actor.world.pos.y - this->actor.home.pos.y) < 2.0f) { + this->actor.gravity = 0.0f; + } else if (this->actor.home.pos.y < this->actor.world.pos.y) { + this->actor.gravity = -0.15f; + } else { + this->actor.gravity = 0.15f; + } + + this->actor.velocity.y *= 0.8f; + if ((this->actor.speedXZ * 1.5f) + 1.0f > 4.8f) { + this->skelAnime.playSpeed = 4.8f; + } else { + this->skelAnime.playSpeed = (this->actor.speedXZ * 1.5f) + 1.0f; + } +} + +void func_8091F344(EnFish* this) { + this->actor.gravity = 0.0f; + this->actor.terminalVelocity = 0.0f; + this->unk_240 = Rand_S16Offset(5, 35); + this->unk_248 = 1; + this->unk_268 = 0; + this->unk_26C = 0; + this->unk_26E = 1500; + this->unk_272 = 0; + func_8091D660(this); + this->unkFunc = func_8091F3BC; + this->unk_24C = 0.0f; +} + +void func_8091F3BC(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f D_8091FADC = { 0.0f, 0.04f, 0.09f }; + static Vec3f D_8091FAE8 = { 0.5f, 0.1f, 0.15f }; + EnFish* this = THIS; + s32 sp40 = globalCtx->gameplayFrames; + Vec3f* sp3C; + f32 phi_f0; + f32 temp_f2; + + if ((this->actor.xzDistToPlayer < 60.0f) || ((sp40 & 0x1FF) < 20)) { + if (this->unk_240 < 12) { + sp3C = &D_8091FAE8; + } else { + sp3C = &D_8091FADC; + } + } else if (this->unk_240 < 4) { + sp3C = &D_8091FAE8; + } else { + sp3C = &D_8091FADC; + } + + func_8091DD48(this); + Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 2.0f); + Math_SmoothStepToF(&this->actor.speedXZ, sp3C->x, sp3C->y, sp3C->z, 0.0f); + this->unk_24C = 0.0f; + + if (func_8091D630(&this->actor.world.pos, &this->actor.home.pos) > SQ(15.0f)) { + this->unk_26A = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); + this->unk_270 = 0x85; + phi_f0 = 0.4f; + } else if (this->unk_240 < 4) { + this->unk_26A = sp40 << 7; + this->unk_270 = 0x43; + phi_f0 = 0.4f; + } else { + this->unk_270 = 0; + phi_f0 = 0.0f; + } + + temp_f2 = this->actor.speedXZ + 0.4f + phi_f0; + this->skelAnime.playSpeed = CLAMP(temp_f2, 0.5f, 1.6f); + + if (this->unk_240 <= 0) { + this->unk_240 = Rand_S16Offset(5, 80); + } +} + +void func_8091F5A4(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + Actor* temp_v0_2; + s16 temp_v0; + s16 temp_v0_4; + s32 temp_v1; + s32 phi_v1; + f32 phi_f0; + + if (this->unk_240 > 0) { + this->unk_240--; + } + + this->unk_244 += 0x111; + this->unk_246 += 0x500; + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL) && (thisx != this->actor.child)) { + this->actor.child = NULL; + } + + if ((this->unkFunc == NULL) || (this->unkFunc(&this->actor, globalCtx), (this->actor.update != NULL))) { + if ((ABS_ALT(BINANG_SUB(this->unk_26A, this->actor.shape.rot.y)) > 0x3000) && (this->unk_270 > 1000)) { + this->skelAnime.playSpeed += this->unk_24C; + } + SkelAnime_Update(&this->skelAnime); + func_8091D7C4(this); + Actor_MoveWithGravity(&this->actor); + if (this->unk_248 != 0) { + u32 temp = (globalCtx->sceneNum ^ SCENE_LABO) != 0; + phi_f0 = BREG(1) + 10.0f; + + if (temp) { + phi_f0 = 6.0f; + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 17.5f, phi_f0, 0.0f, this->unk_248); + } + + if ((this->actor.xzDistToPlayer < 70.0f) && (this->unkFunc != func_8091EFE8)) { + ColliderJntSphElement* element = &this->collider.elements[0]; + + element->dim.worldSphere.center.x = this->actor.world.pos.x; + element->dim.worldSphere.center.y = this->actor.world.pos.y; + element->dim.worldSphere.center.z = this->actor.world.pos.z; + element->dim.worldSphere.radius = this->unk_25C * 500.0f; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + Actor_SetFocus(&this->actor, this->actor.shape.yOffset * 0.01f); + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + if (this->actor.params == ENFISH_0) { + Actor_MarkForDeath(&this->actor); + } else { + func_8091D904(this); + } + } else if (func_8091DDF4(this, globalCtx)) { + Actor_PickUp(&this->actor, globalCtx, 0xBA, 80.0f, 25.0f); + } + } +} + +void func_8091F830(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + + if (this->actor.params == ENFISH_1) { + Actor_MarkForDeath(&this->actor); + return; + } + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL) && (thisx != this->actor.child)) { + this->actor.child = NULL; + } + + if ((this->unkFunc == NULL) || (this->unkFunc(&this->actor, globalCtx), (this->actor.update != NULL))) { + func_8091D7C4(this); + Actor_MoveWithGravity(&this->actor); + + if (this->unk_242 == 20) { + this->actor.draw = EnFish_Draw; + } else if (this->unk_242 == 0) { + this->unk_25C = this->unk_260; + func_8091D728(this); + } else if (this->unk_242 < 20) { + this->unk_25C += 0.1f * this->unk_260; + if (this->unk_260 < this->unk_25C) { + this->unk_25C = this->unk_260; + } + func_8091D728(this); + } + } +} + +void EnFish_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + + if (this->unk_242 > 0) { + this->unk_242--; + func_8091F830(thisx, globalCtx); + } else { + func_8091F5A4(thisx, globalCtx); + } + + if (this->unk_276 > 0) { + this->unk_276--; + } +} + +void func_8091F994(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnFish_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnFish* this = THIS; + Color_RGB8* colour = &D_8091FA94[this->unk_278]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, colour->r, colour->g, colour->b, 255); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, NULL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.h b/src/overlays/actors/ovl_En_Fish/z_en_fish.h index 7d4a9f0cf2..fd35ef6262 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.h +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.h @@ -5,11 +5,47 @@ struct EnFish; +typedef void (*EnFishUnkFunc)(Actor*, GlobalContext*); + +enum { + /* -1 */ ENFISH_MINUS1 = -1, + /* 0 */ ENFISH_0, + /* 1 */ ENFISH_1, + /* 2 */ ENFISH_2, +}; + typedef struct EnFish { /* 0x000 */ Actor actor; - /* 0x144 */ char unk144[0x133]; - /* 0x277 */ s8 unk_277; - /* 0x278 */ char unk278[0x4]; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colliderElements[1]; + /* 0x1A4 */ SkelAnime skelAnime; + /* 0x1E8 */ Vec3s jointTable[7]; + /* 0x212 */ Vec3s morphTable[7]; + /* 0x23C */ EnFishUnkFunc unkFunc; + /* 0x240 */ s16 unk_240; + /* 0x242 */ s16 unk_242; + /* 0x244 */ s16 unk_244; + /* 0x246 */ s16 unk_246; + /* 0x248 */ s32 unk_248; + /* 0x24C */ f32 unk_24C; + /* 0x250 */ f32 unk_250; + /* 0x254 */ f32 unk_254; + /* 0x258 */ f32 unk_258; + /* 0x25C */ f32 unk_25C; + /* 0x260 */ f32 unk_260; + /* 0x264 */ s16 unk_264; + /* 0x266 */ s16 unk_266; + /* 0x268 */ s16 unk_268; + /* 0x26A */ s16 unk_26A; + /* 0x26C */ s16 unk_26C; + /* 0x26E */ s16 unk_26E; + /* 0x270 */ s16 unk_270; + /* 0x272 */ s16 unk_272; + /* 0x274 */ s16 unk_274; + /* 0x276 */ s8 unk_276; + /* 0x277 */ u8 unk_277; + /* 0x278 */ s8 unk_278; + /* 0x279 */ s8 unk_279; } EnFish; // size = 0x27C extern const ActorInit En_Fish_InitVars; diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c index cd553b537f..dcb634f42f 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -160,7 +160,7 @@ void EnFish2_Init(Actor* thisx, GlobalContext* globalCtx) { D_80B2B2F0++; if (this->actor.params == 0) { - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06006190, &D_060013AC, this->jointTable, this->morphTable, 24); this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -328,10 +328,10 @@ void func_80B28B5C(EnFish2* this) { } void func_80B28C14(EnFish2* this, GlobalContext* globalCtx) { - Actor* itemAction = globalCtx->actorCtx.actorList[ACTORCAT_ITEMACTION].first; + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; WaterBox* waterbox; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80B29128(this); return; } @@ -438,7 +438,7 @@ void func_80B29128(EnFish2* this) { } void func_80B2913C(EnFish2* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); func_80B28B5C(this); } @@ -533,7 +533,7 @@ void func_80B2951C(EnFish2* this) { Actor_MarkForDeath(this->unk_350); this->unk_350 = NULL; D_80B2B2F4 = &this->actor; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_M_EAT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_M_EAT); this->actionFunc = func_80B295A4; } @@ -642,7 +642,7 @@ void func_80B297FC(EnFish2* this, GlobalContext* globalCtx) { } this->unk_2B6 = 4; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FISH_GROW_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FISH_GROW_UP); this->unk_2C4++; } break; @@ -747,7 +747,7 @@ void func_80B297FC(EnFish2* this, GlobalContext* globalCtx) { } void func_80B29E5C(EnFish2* this, GlobalContext* globalCtx) { - Actor* prop = globalCtx->actorCtx.actorList[ACTORCAT_PROP].first; + Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; while (prop != NULL) { if (prop->id != ACTOR_EN_FISH2) { @@ -893,7 +893,7 @@ void func_80B2A498(EnFish2* this, GlobalContext* globalCtx) { if (temp_v0 != NULL) { temp_v0->speedXZ = 4.0f; temp_v0->velocity.y = 15.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_SY_PIECE_OF_HEART); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); gSaveContext.weekEventReg[81] &= (u8)~0x10; gSaveContext.weekEventReg[81] &= (u8)~0x20; gSaveContext.weekEventReg[81] &= (u8)~0x40; @@ -958,7 +958,7 @@ void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx2) { } this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, 0); + Actor_SetFocus(&this->actor, 0); if (this->actor.params != 1) { WaterBox* sp6C; @@ -990,7 +990,7 @@ void EnFish2_Update(Actor* thisx, GlobalContext* globalCtx2) { this->unk_2F4.z += (Math_CosS(this->actor.world.rot.y) * 25.0f) - this->unk_330; this->unk_33C = 25.0f - ((this->unk_330 - 0.01f) * 1000.0f); Actor_SetScale(&this->actor, this->unk_330); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0, 15.0f, 10.0f, 7); if (this->actor.params != 2) { diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c index d1f93bdbc8..a1fedd7a97 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -1,21 +1,204 @@ /* * File: z_en_fishing.c * Overlay: ovl_En_Fishing - * Description: Fishing + * Description: Fishing Pond Elements (Owner, Fish, Props, Effects...) */ #include "z_en_fishing.h" +#include "objects/object_fish/object_fish.h" +#include "overlays/actors/ovl_En_Kanban/z_en_kanban.h" #define FLAGS 0x00000010 #define THIS ((EnFishing*)thisx) +#define WATER_SURFACE_Y(globalCtx) globalCtx->colCtx.colHeader->waterBoxes->minPos.y + void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx); void EnFishing_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnFishing_Update(Actor* thisx, GlobalContext* globalCtx); -void EnFishing_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx); +void EnFishing_DrawFish(Actor* thisx, GlobalContext* globalCtx); + +void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx); +void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx); + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x02 */ Vec3s pos; + /* 0x08 */ u8 unk_08; + /* 0x0C */ f32 unk_0C; +} FishingFishInit; // size = 0x10 + +#define EFFECT_COUNT 130 + +typedef enum { + /* 0x00 */ FS_EFF_NONE, + /* 0x01 */ FS_EFF_RIPPLE, + /* 0x02 */ FS_EFF_DUST_SPLASH, + /* 0x03 */ FS_EFF_WATER_DUST, + /* 0x04 */ FS_EFF_BUBBLE, + /* 0x05 */ FS_EFF_RAIN_DROP, + /* 0x06 */ FS_EFF_OWNER_HAT, + /* 0x07 */ FS_EFF_RAIN_RIPPLE, + /* 0x08 */ FS_EFF_RAIN_SPLASH +} FishingEffectType; + +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ Vec3f vel; + /* 0x18 */ Vec3f accel; + /* 0x24 */ u8 type; + /* 0x25 */ u8 timer; + /* 0x26 */ UNK_TYPE1 unk_26[0x04]; + /* 0x2A */ s16 alpha; + /* 0x2C */ s16 unk_2C; + /* 0x2E */ s16 unk_2E; + /* 0x30 */ f32 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; + /* 0x3C */ f32 unk_3C; +} FishingEffect; // size = 0x40 + +#define POND_PROP_COUNT 140 + +typedef enum { + /* 0x00 */ FS_PROP_NONE, + /* 0x01 */ FS_PROP_REED, + /* 0x02 */ FS_PROP_LILY_PAD, + /* 0x03 */ FS_PROP_ROCK, + /* 0x04 */ FS_PROP_WOOD_POST, + /* 0x23 */ FS_PROP_INIT_STOP = 0x23 +} FishingPropType; + +typedef struct { + /* 0x00 */ u8 type; + /* 0x02 */ Vec3s pos; +} FishingPropInit; // size = 0x08 + +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ f32 rotX; + /* 0x10 */ f32 rotY; + /* 0x14 */ f32 reedAngle; + /* 0x18 */ Vec3f projectedPos; + /* 0x24 */ f32 scale; + /* 0x28 */ s16 lilyPadAngle; + /* 0x2C */ f32 lilyPadOffset; + /* 0x30 */ u8 type; + /* 0x32 */ s16 timer; + /* 0x34 */ u8 shouldDraw; + /* 0x38 */ f32 drawDistance; +} FishingProp; // size = 0x3C + +typedef enum { + /* 0x00 */ FS_GROUP_FISH_NONE, + /* 0x01 */ FS_GROUP_FISH_NORMAL +} FishingGroupFishType; + +#define GROUP_FISH_COUNT 60 + +typedef struct { + /* 0x00 */ u8 type; + /* 0x02 */ s16 timer; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f unk_10; + /* 0x1C */ Vec3f projectedPos; + /* 0x28 */ f32 unk_28; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ f32 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; + /* 0x3C */ s16 unk_3C; + /* 0x3E */ s16 unk_3E; + /* 0x40 */ s16 unk_40; + /* 0x42 */ s16 unk_42; + /* 0x44 */ u8 shouldDraw; +} FishingGroupFish; // size = 0x48 + +#define LINE_SEG_COUNT 200 +#define SINKING_LURE_SEG_COUNT 20 + +static f32 D_809101B0; +static f32 D_809101B4; +static s16 D_809101B8; +static f32 D_809101BC; +static f32 D_809101C0; +static f32 D_809101C4; +static f32 D_809101C8; +static s16 D_809101CC; +static f32 D_809101D0; +static Vec3f sRodTipPos; +static Vec3f sReelLinePos[LINE_SEG_COUNT]; +static Vec3f sReelLineRot[LINE_SEG_COUNT]; +static Vec3f sReelLineUnk[LINE_SEG_COUNT]; +static Vec3f sLureHookRefPos[2]; +static f32 sLureHookRotY[2]; +static u8 D_80911E28; +static Vec3f sSinkingLurePos[SINKING_LURE_SEG_COUNT]; +static s16 D_80911F20; +static f32 sProjectedW; +static Vec3f sCameraEye; +static Vec3f sCameraAt; +static s16 sCameraId; +static f32 D_80911F48; +static f32 D_80911F4C; +static f32 D_80911F50; +static Vec3f sSinkingLureBasePos; +static f32 D_80911F64; +static s32 sRandSeed0; +static s32 sRandSeed1; +static s32 sRandSeed2; +static FishingProp sPondProps[POND_PROP_COUNT]; +static FishingGroupFish sGroupFishes[GROUP_FISH_COUNT]; +static f32 sFishGroupAngle1; +static f32 sFishGroupAngle2; +static f32 sFishGroupAngle3; +static FishingEffect sFishingEffects[EFFECT_COUNT]; +static Vec3f sStreamSoundProjectedPos; +static EnFishing* sFishingMain; +static u8 D_809171C8; +static u8 sLinkAge; +static u8 D_809171CA; +static u8 D_809171CB; +static f32 D_809171CC; +static u8 D_809171D0; +static u8 D_809171D1; +static u8 D_809171D2; +static s16 D_809171D4; +static u8 D_809171D6; +static u16 D_809171D8; +static u16 D_809171DA; +static s8 D_809171DC; +static Vec3f sOwnerHeadPos; +static Vec3s sEffOwnerHatRot; +static u8 D_809171F2; +static s16 D_809171F4; +static s16 D_809171F6; +static EnFishing* sFishingHookedFish; +static s16 D_809171FC; +static s16 D_809171FE; +static s16 D_80917200; +static s16 D_80917202; +static s16 D_80917204; +static u8 D_80917206; +static Vec3f sLurePos; +static Vec3f D_80917218; +static Vec3f sLureRot; +static Vec3f D_80917238; +static Vec3f D_80917248; +static f32 D_80917254; +static f32 D_80917258; +static f32 D_8091725C; +static f32 D_80917260; +static s8 D_80917264; +static s16 D_80917266; +static u8 D_80917268; +static f32 D_8091726C; +static u8 D_80917270; +static s16 D_80917272; +static u8 D_80917274; +static Vec3f D_80917278; -#if 0 const ActorInit En_Fishing_InitVars = { ACTOR_EN_FISHING, ACTORCAT_NPC, @@ -24,181 +207,5503 @@ const ActorInit En_Fishing_InitVars = { sizeof(EnFishing), (ActorFunc)EnFishing_Init, (ActorFunc)EnFishing_Destroy, - (ActorFunc)EnFishing_Update, - (ActorFunc)EnFishing_Draw, + (ActorFunc)EnFishing_UpdateFish, + (ActorFunc)EnFishing_DrawFish, }; -// static ColliderJntSphElementInit sJntSphElementsInit[12] = { -static ColliderJntSphElementInit D_8090CD58[12] = { +static f32 D_8090CCD0 = 0.0f; +static u8 D_8090CCD4 = 0; +static f32 D_8090CCD8 = 0.0f; +static Vec3f D_8090CCDC = { 0.0f, 0.0f, 0.0f }; +static f32 D_8090CCE8 = 0.0f; +static u8 sSinkingLureLocation = 0; +static f32 D_8090CCF0 = 0.0f; +static u8 D_8090CCF4 = true; +static u16 D_8090CCF8 = 0; +static u8 D_8090CCFC = 0; +static s32 D_8090CD00 = 0; +static s16 D_8090CD04 = 0; +static u8 D_8090CD08 = 0; +static u8 D_8090CD0C = 0; +static u8 D_8090CD10 = 0; +static s16 D_8090CD14 = 0; +static Vec3f sFishMouthOffset = { 500.0f, 500.0f, 0.0f }; +static u8 D_8090CD24 = 0; +static f32 D_8090CD28 = 0; +static f32 D_8090CD2C = 0; +static f32 D_8090CD30 = 0.0f; +static f32 D_8090CD34 = 0.0f; +static f32 D_8090CD38 = 0.0f; +static f32 D_8090CD3C = 0.0f; +static f32 D_8090CD40 = 0.0f; +static s16 D_8090CD44 = 0; +static s16 D_8090CD48 = 0; +static u8 D_8090CD4C = 0; +static u8 D_8090CD50 = 0; +static u8 D_8090CD54 = 0; + +static ColliderJntSphElementInit sJntSphElementsInit[12] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8090CF08 = { - { COLTYPE_NONE, AT_NONE | AT_TYPE_ENEMY, AC_NONE | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 12, D_8090CD58, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE | AT_TYPE_ENEMY, + AC_NONE | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 12, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8090D4D0[] = { +static u8 D_8090CF18 = 0; +static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; +static Vec3f D_8090CF28 = { 0.0f, 0.0f, 2000.0f }; // Unused + +void EnFishing_SetColliderElement(s32 index, ColliderJntSph* collider, Vec3f* pos, f32 scale) { + collider->elements[index].dim.worldSphere.center.x = pos->x; + collider->elements[index].dim.worldSphere.center.y = pos->y; + collider->elements[index].dim.worldSphere.center.z = pos->z; + collider->elements[index].dim.worldSphere.radius = + collider->elements[index].dim.modelSphere.radius * collider->elements[index].dim.scale * scale * 1.6f; +} + +void EnFishing_SeedRand(s32 seed0, s32 seed1, s32 seed2) { + sRandSeed0 = seed0; + sRandSeed1 = seed1; + sRandSeed2 = seed2; +} + +f32 EnFishing_RandZeroOne(void) { + f32 rand; + + // Wichmann-Hill algorithm + sRandSeed0 = (sRandSeed0 * 171) % 30269; + sRandSeed1 = (sRandSeed1 * 172) % 30307; + sRandSeed2 = (sRandSeed2 * 170) % 30323; + + rand = (sRandSeed0 / 30269.0f) + (sRandSeed1 / 30307.0f) + (sRandSeed2 / 30323.0f); + while (rand >= 1.0f) { + rand -= 1.0f; + } + + return fabsf(rand); +} + +s16 EnFishing_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step) { + s16 stepSize; + s16 diff; + + diff = target - *pValue; + stepSize = diff / scale; + + if (stepSize > step) { + stepSize = step; + } + + if (stepSize < -step) { + stepSize = -step; + } + + *pValue += stepSize; + + return stepSize; +} + +void EnFishing_SpawnRipple(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, f32 arg3, f32 arg4, s16 arg5, + s16 countLimit) { + s16 i; + + if ((projectedPos != NULL) && ((projectedPos->z > 500.0f) || (projectedPos->z < 0.0f))) { + return; + } + + for (i = 0; i < countLimit; i++) { + if (effect->type == FS_EFF_NONE) { + effect->type = FS_EFF_RIPPLE; + effect->pos = *pos; + effect->vel = sZeroVec; + effect->accel = sZeroVec; + effect->unk_30 = arg3 * 0.0025f; + effect->unk_34 = arg4 * 0.0025f; + + if (arg3 > 300.0f) { + effect->alpha = 0; + effect->unk_2E = arg5; + effect->unk_2C = 0; + effect->unk_38 = (effect->unk_34 - effect->unk_30) * 0.05f; + } else { + effect->alpha = arg5; + effect->unk_2C = 1; + effect->unk_38 = (effect->unk_34 - effect->unk_30) * 0.1f; + } + break; + } + + effect++; + } +} + +void EnFishing_SpawnDustSplash(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, Vec3f* vel, f32 scale) { + s16 i; + Vec3f accel = { 0.0f, -1.0f, 0.0f }; + + if ((projectedPos != NULL) && ((projectedPos->z > 500.0f) || (projectedPos->z < 0.0f))) { + return; + } + + for (i = 0; i < 100; i++) { + if ((effect->type == FS_EFF_NONE) || (effect->type == FS_EFF_RAIN_DROP) || + (effect->type == FS_EFF_RAIN_RIPPLE) || (effect->type == FS_EFF_RAIN_SPLASH)) { + effect->type = FS_EFF_DUST_SPLASH; + effect->pos = *pos; + effect->vel = *vel; + effect->accel = accel; + effect->alpha = 100 + Rand_ZeroFloat(100.0f); + effect->unk_30 = scale; + break; + } + + effect++; + } +} + +void EnFishing_SpawnWaterDust(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, f32 scale) { + s16 i; + Vec3f accel = { 0.0f, 0.05f, 0.0f }; + + if ((projectedPos != NULL) && ((projectedPos->z > 500.0f) || (projectedPos->z < 0.0f))) { + return; + } + + for (i = 0; i < 90; i++) { + if (effect->type == FS_EFF_NONE) { + effect->type = FS_EFF_WATER_DUST; + effect->pos = *pos; + effect->vel = sZeroVec; + effect->accel = accel; + effect->alpha = 255; + effect->timer = Rand_ZeroFloat(100.0f); + effect->unk_30 = scale; + effect->unk_34 = 2.0f * scale; + break; + } + + effect++; + } +} + +void EnFishing_SpawnBubble(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, f32 scale, u8 arg4) { + s16 i; + Vec3f vel = { 0.0f, 1.0f, 0.0f }; + + if ((projectedPos != NULL) && ((projectedPos->z > 500.0f) || (projectedPos->z < 0.0f))) { + return; + } + + for (i = 0; i < 90; i++) { + if (effect->type == FS_EFF_NONE) { + effect->type = FS_EFF_BUBBLE; + effect->pos = *pos; + effect->vel = vel; + effect->accel = sZeroVec; + effect->timer = Rand_ZeroFloat(100.0f); + effect->unk_30 = scale; + effect->unk_2C = arg4; + break; + } + + effect++; + } +} + +void EnFishing_SpawnRainDrop(FishingEffect* effect, Vec3f* pos, Vec3f* rot) { + s16 i; + Vec3f velSrc; + + velSrc.x = 0.0f; + velSrc.y = 0.0f; + velSrc.z = 300.0f; + + effect += 30; + + for (i = 30; i < EFFECT_COUNT; i++) { + if (effect->type == FS_EFF_NONE) { + effect->type = FS_EFF_RAIN_DROP; + effect->pos = *pos; + effect->accel = sZeroVec; + effect->unk_34 = rot->x; + effect->unk_38 = rot->y; + effect->unk_3C = rot->z; + Matrix_InsertYRotation_f(rot->y, MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(rot->x); + Matrix_MultiplyVector3fByState(&velSrc, &effect->vel); + break; + } + + effect++; + } +} + +static FishingPropInit sPondPropInits[POND_PROP_COUNT + 1] = { + { FS_PROP_ROCK, { 529, -53, -498 } }, + { FS_PROP_ROCK, { 461, -66, -480 } }, + { FS_PROP_ROCK, { 398, -73, -474 } }, + { FS_PROP_ROCK, { -226, -52, -691 } }, + { FS_PROP_ROCK, { -300, -41, -710 } }, + { FS_PROP_ROCK, { -333, -50, -643 } }, + { FS_PROP_ROCK, { -387, -46, -632 } }, + { FS_PROP_ROCK, { -484, -43, -596 } }, + { FS_PROP_ROCK, { -409, -57, -560 } }, + { FS_PROP_WOOD_POST, { 444, -87, -322 } }, + { FS_PROP_WOOD_POST, { 447, -91, -274 } }, + { FS_PROP_WOOD_POST, { 395, -109, -189 } }, + { FS_PROP_REED, { 617, -29, 646 } }, + { FS_PROP_REED, { 698, -26, 584 } }, + { FS_PROP_REED, { 711, -29, 501 } }, + { FS_PROP_REED, { 757, -28, 457 } }, + { FS_PROP_REED, { 812, -29, 341 } }, + { FS_PROP_REED, { 856, -30, 235 } }, + { FS_PROP_REED, { 847, -31, 83 } }, + { FS_PROP_REED, { 900, -26, 119 } }, + { FS_PROP_LILY_PAD, { 861, -22, 137 } }, + { FS_PROP_LILY_PAD, { 836, -22, 150 } }, + { FS_PROP_LILY_PAD, { 829, -22, 200 } }, + { FS_PROP_LILY_PAD, { 788, -22, 232 } }, + { FS_PROP_LILY_PAD, { 803, -22, 319 } }, + { FS_PROP_LILY_PAD, { 756, -22, 348 } }, + { FS_PROP_LILY_PAD, { 731, -22, 377 } }, + { FS_PROP_LILY_PAD, { 700, -22, 392 } }, + { FS_PROP_LILY_PAD, { 706, -22, 351 } }, + { FS_PROP_LILY_PAD, { 677, -22, 286 } }, + { FS_PROP_LILY_PAD, { 691, -22, 250 } }, + { FS_PROP_LILY_PAD, { 744, -22, 290 } }, + { FS_PROP_LILY_PAD, { 766, -22, 201 } }, + { FS_PROP_LILY_PAD, { 781, -22, 128 } }, + { FS_PROP_LILY_PAD, { 817, -22, 46 } }, + { FS_PROP_LILY_PAD, { 857, -22, -50 } }, + { FS_PROP_LILY_PAD, { 724, -22, 110 } }, + { FS_PROP_LILY_PAD, { 723, -22, 145 } }, + { FS_PROP_LILY_PAD, { 728, -22, 202 } }, + { FS_PROP_LILY_PAD, { 721, -22, 237 } }, + { FS_PROP_LILY_PAD, { 698, -22, 312 } }, + { FS_PROP_LILY_PAD, { 660, -22, 349 } }, + { FS_PROP_LILY_PAD, { 662, -22, 388 } }, + { FS_PROP_LILY_PAD, { 667, -22, 432 } }, + { FS_PROP_LILY_PAD, { 732, -22, 429 } }, + { FS_PROP_LILY_PAD, { 606, -22, 366 } }, + { FS_PROP_LILY_PAD, { 604, -22, 286 } }, + { FS_PROP_LILY_PAD, { 620, -22, 217 } }, + { FS_PROP_LILY_PAD, { 663, -22, 159 } }, + { FS_PROP_LILY_PAD, { 682, -22, 73 } }, + { FS_PROP_LILY_PAD, { 777, -22, 83 } }, + { FS_PROP_LILY_PAD, { 766, -22, 158 } }, + { FS_PROP_REED, { 1073, 0, -876 } }, + { FS_PROP_REED, { 970, 0, -853 } }, + { FS_PROP_REED, { 896, 0, -886 } }, + { FS_PROP_REED, { 646, -27, -651 } }, + { FS_PROP_REED, { 597, -29, -657 } }, + { FS_PROP_REED, { 547, -32, -651 } }, + { FS_PROP_REED, { 690, -29, -546 } }, + { FS_PROP_REED, { 720, -29, -490 } }, + { FS_PROP_REED, { -756, -30, -409 } }, + { FS_PROP_REED, { -688, -34, -458 } }, + { FS_PROP_REED, { -613, -34, -581 } }, + { FS_PROP_LILY_PAD, { -593, -22, -479 } }, + { FS_PROP_LILY_PAD, { -602, -22, -421 } }, + { FS_PROP_LILY_PAD, { -664, -22, -371 } }, + { FS_PROP_LILY_PAD, { -708, -22, -316 } }, + { FS_PROP_LILY_PAD, { -718, -22, -237 } }, + { FS_PROP_REED, { -807, -36, -183 } }, + { FS_PROP_REED, { -856, -29, -259 } }, + { FS_PROP_LILY_PAD, { -814, -22, -317 } }, + { FS_PROP_LILY_PAD, { -759, -22, -384 } }, + { FS_PROP_LILY_PAD, { -718, -22, -441 } }, + { FS_PROP_LILY_PAD, { -474, -22, -567 } }, + { FS_PROP_LILY_PAD, { -519, -22, -517 } }, + { FS_PROP_LILY_PAD, { -539, -22, -487 } }, + { FS_PROP_LILY_PAD, { -575, -22, -442 } }, + { FS_PROP_LILY_PAD, { -594, -22, -525 } }, + { FS_PROP_LILY_PAD, { -669, -22, -514 } }, + { FS_PROP_LILY_PAD, { -653, -22, -456 } }, + { FS_PROP_REED, { -663, -28, -606 } }, + { FS_PROP_REED, { -708, -26, -567 } }, + { FS_PROP_REED, { -739, -27, -506 } }, + { FS_PROP_REED, { -752, -28, -464 } }, + { FS_PROP_REED, { -709, -29, -513 } }, + { FS_PROP_LILY_PAD, { -544, -22, -436 } }, + { FS_PROP_LILY_PAD, { -559, -22, -397 } }, + { FS_PROP_LILY_PAD, { -616, -22, -353 } }, + { FS_PROP_LILY_PAD, { -712, -22, -368 } }, + { FS_PROP_LILY_PAD, { -678, -22, -403 } }, + { FS_PROP_LILY_PAD, { -664, -22, -273 } }, + { FS_PROP_LILY_PAD, { -630, -22, -276 } }, + { FS_PROP_LILY_PAD, { -579, -22, -311 } }, + { FS_PROP_LILY_PAD, { -588, -22, -351 } }, + { FS_PROP_LILY_PAD, { -555, -22, -534 } }, + { FS_PROP_LILY_PAD, { -547, -22, -567 } }, + { FS_PROP_LILY_PAD, { -592, -22, -571 } }, + { FS_PROP_LILY_PAD, { -541, -22, -610 } }, + { FS_PROP_LILY_PAD, { -476, -22, -629 } }, + { FS_PROP_LILY_PAD, { -439, -22, -598 } }, + { FS_PROP_LILY_PAD, { -412, -22, -550 } }, + { FS_PROP_LILY_PAD, { -411, -22, -606 } }, + { FS_PROP_LILY_PAD, { -370, -22, -634 } }, + { FS_PROP_LILY_PAD, { -352, -22, -662 } }, + { FS_PROP_LILY_PAD, { -413, -22, -641 } }, + { FS_PROP_LILY_PAD, { -488, -22, -666 } }, + { FS_PROP_LILY_PAD, { -578, -22, -656 } }, + { FS_PROP_LILY_PAD, { -560, -22, -640 } }, + { FS_PROP_LILY_PAD, { -531, -22, -654 } }, + { FS_PROP_LILY_PAD, { -451, -22, -669 } }, + { FS_PROP_LILY_PAD, { -439, -22, -699 } }, + { FS_PROP_LILY_PAD, { -482, -22, -719 } }, + { FS_PROP_LILY_PAD, { -524, -22, -720 } }, + { FS_PROP_LILY_PAD, { -569, -22, -714 } }, + { FS_PROP_REED, { -520, -27, -727 } }, + { FS_PROP_REED, { -572, -28, -686 } }, + { FS_PROP_REED, { -588, -32, -631 } }, + { FS_PROP_REED, { -622, -34, -571 } }, + { FS_PROP_REED, { -628, -36, -510 } }, + { FS_PROP_REED, { -655, -36, -466 } }, + { FS_PROP_REED, { -655, -41, -393 } }, + { FS_PROP_REED, { -661, -47, -328 } }, + { FS_PROP_REED, { -723, -40, -287 } }, + { FS_PROP_REED, { -756, -33, -349 } }, + { FS_PROP_REED, { -755, -43, -210 } }, + { FS_PROP_LILY_PAD, { -770, -22, -281 } }, + { FS_PROP_LILY_PAD, { -750, -22, -313 } }, + { FS_PROP_LILY_PAD, { -736, -22, -341 } }, + { FS_PROP_LILY_PAD, { -620, -22, -418 } }, + { FS_PROP_LILY_PAD, { -601, -22, -371 } }, + { FS_PROP_LILY_PAD, { -635, -22, -383 } }, + { FS_PROP_LILY_PAD, { -627, -22, -311 } }, + { FS_PROP_LILY_PAD, { -665, -22, -327 } }, + { FS_PROP_LILY_PAD, { -524, -22, -537 } }, + { FS_PROP_LILY_PAD, { -514, -22, -579 } }, + { FS_PROP_LILY_PAD, { -512, -22, -623 } }, + { FS_PROP_LILY_PAD, { -576, -22, -582 } }, + { FS_PROP_LILY_PAD, { -600, -22, -608 } }, + { FS_PROP_LILY_PAD, { -657, -22, -531 } }, + { FS_PROP_LILY_PAD, { -641, -22, -547 } }, + { FS_PROP_INIT_STOP, { 0 } }, +}; + +void EnFishing_InitPondProps(EnFishing* this, GlobalContext* globalCtx) { + FishingProp* prop = &sPondProps[0]; + Vec3f colliderPos; + s16 i; + + EnFishing_SeedRand(1, 29100, 9786); + + for (i = 0; i < POND_PROP_COUNT; i++) { + if (sPondPropInits[i].type == FS_PROP_INIT_STOP) { + break; + } + + prop->type = sPondPropInits[i].type; + prop->pos.x = sPondPropInits[i].pos.x; + prop->pos.y = sPondPropInits[i].pos.y; + prop->pos.z = sPondPropInits[i].pos.z; + prop->rotX = 0.0f; + prop->reedAngle = 0.0f; + + prop->timer = Rand_ZeroFloat(100.0f); + prop->drawDistance = 800.0f; + + if (prop->type == FS_PROP_REED) { + prop->scale = (EnFishing_RandZeroOne() * 0.25f) + 0.75f; + prop->reedAngle = Rand_ZeroFloat(2 * M_PI); + if (sLinkAge == 1) { + prop->scale *= 0.6f; + } + prop->drawDistance = 1200.0f; + } else if (prop->type == FS_PROP_WOOD_POST) { + prop->scale = 0.08f; + prop->drawDistance = 1200.0f; + colliderPos = prop->pos; + colliderPos.y += 50.0f; + EnFishing_SetColliderElement(i, &sFishingMain->collider, &colliderPos, prop->scale * 3.5f); + } else if (prop->type == FS_PROP_LILY_PAD) { + prop->scale = (EnFishing_RandZeroOne() * 0.3f) + 0.5f; + prop->rotY = Rand_ZeroFloat(2 * M_PI); + if (sLinkAge == 1) { + if ((i % 4) != 0) { + prop->scale *= 0.6f; + } else { + prop->type = FS_PROP_NONE; + } + } + } else { + prop->scale = (EnFishing_RandZeroOne() * 0.1f) + 0.3f; + prop->rotY = Rand_ZeroFloat(2 * M_PI); + prop->drawDistance = 1000.0f; + EnFishing_SetColliderElement(i, &sFishingMain->collider, &prop->pos, prop->scale); + } + + prop++; + } +} + +static FishingFishInit sFishInits[] = { + { 0, { 666, -45, 354 }, 38, 0.1f }, { 0, { 681, -45, 240 }, 36, 0.1f }, { 0, { 670, -45, 90 }, 41, 0.05f }, + { 0, { 615, -45, -450 }, 35, 0.2f }, { 0, { 500, -45, -420 }, 39, 0.1f }, { 0, { 420, -45, -550 }, 44, 0.05f }, + { 0, { -264, -45, -640 }, 40, 0.1f }, { 0, { -470, -45, -540 }, 34, 0.2f }, { 0, { -557, -45, -430 }, 54, 0.01f }, + { 0, { -260, -60, -330 }, 47, 0.05f }, { 0, { -500, -60, 330 }, 42, 0.06f }, { 0, { 428, -40, -283 }, 33, 0.2f }, + { 0, { 409, -70, -230 }, 57, 0.0f }, { 0, { 450, -67, -300 }, 63, 0.0f }, { 0, { -136, -65, -196 }, 71, 0.0f }, + { 1, { -561, -35, -547 }, 45, 0.0f }, { 1, { 667, -35, 317 }, 43, 0.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 5, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), }; +void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnFishing* this = THIS; + u16 fishCount; + + Actor_ProcessInitChain(thisx, sInitChain); + ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); + + sLinkAge = gSaveContext.linkAge; + + if (thisx->params < 100) { + s16 i; + FishingGroupFish* fish; + + D_809171C8 = 0; + sFishingMain = this; + Collider_InitJntSph(globalCtx, &sFishingMain->collider); + Collider_SetJntSph(globalCtx, &sFishingMain->collider, thisx, &sJntSphInit, sFishingMain->colliderElements); + + thisx->params = 1; + + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingOwnerSkel, &gFishingOwnerAnim, NULL, NULL, 0); + Animation_MorphToLoop(&this->skelAnime, &gFishingOwnerAnim, 0.0f); + + thisx->update = EnFishing_UpdateOwner; + thisx->draw = EnFishing_DrawOwner; + + thisx->shape.rot.y = -0x6000; + thisx->world.pos.x = 160.0f; + thisx->world.pos.y = -2.0f; + thisx->world.pos.z = 1208.0f; + + Actor_SetScale(thisx, 0.011f); + + thisx->focus.pos = thisx->world.pos; + thisx->focus.pos.y += 75.0f; + thisx->flags |= 9; + + if (sLinkAge != 1) { + // HIGH_SCORE(HS_FISHING) from OoT + if (gSaveContext.roomInf[127][2] & 0x1000) { + D_8090CD08 = 0; + } else { + D_8090CD08 = 1; + } + } else { + D_8090CD08 = 2; + } + + D_8090CD04 = 20; + globalCtx->specialEffects = sFishingEffects; + REG(15) = 1; // gTimeIncrement in OoT + D_809171FC = 0; + D_809171F6 = 10; + + Audio_QueueSeqCmd(0x100100FF); + + if (sLinkAge == 1) { + if (gSaveContext.roomInf[127][2] & 0x7F) { + D_809171CC = gSaveContext.roomInf[127][2] & 0x7F; + } else { + D_809171CC = 40.0f; + } + } else if (gSaveContext.roomInf[127][2] & 0x7F000000) { + D_809171CC = (gSaveContext.roomInf[127][2] & 0x7F000000) >> 0x18; + } else { + D_809171CC = 45.0f; + } + + D_809171D1 = (gSaveContext.roomInf[127][2] & 0xFF0000) >> 0x10; + if ((D_809171D1 & 7) == 7) { + globalCtx->roomCtx.unk7A[0] = 90; + D_809171CA = 1; + } else { + globalCtx->roomCtx.unk7A[0] = 40; + D_809171CA = 0; + } + + if ((D_809171D1 & 7) == 6) { + D_809171CB = 100; + } else { + D_809171CB = 0; + } + + for (i = 0; i < EFFECT_COUNT; i++) { + sFishingEffects[i].type = FS_EFF_NONE; + } + + for (i = 0; i < POND_PROP_COUNT; i++) { + sPondProps[i].type = FS_PROP_NONE; + } + + sFishGroupAngle1 = 0.7f; + sFishGroupAngle2 = 2.3f; + sFishGroupAngle3 = 4.6f; + + for (i = 0; i < GROUP_FISH_COUNT; i++) { + fish = &sGroupFishes[i]; + + fish->type = FS_GROUP_FISH_NORMAL; + + if (i <= 20) { + fish->unk_10.x = fish->pos.x = __sinf(sFishGroupAngle1) * 720.0f; + fish->unk_10.z = fish->pos.z = __cosf(sFishGroupAngle1) * 720.0f; + } else if (i <= 40) { + fish->unk_10.x = fish->pos.x = __sinf(sFishGroupAngle2) * 720.0f; + fish->unk_10.z = fish->pos.z = __cosf(sFishGroupAngle2) * 720.0f; + } else { + fish->unk_10.x = fish->pos.x = __sinf(sFishGroupAngle3) * 720.0f; + fish->unk_10.z = fish->pos.z = __cosf(sFishGroupAngle3) * 720.0f; + } + + fish->unk_10.y = fish->pos.y = -35.0f; + + fish->timer = Rand_ZeroFloat(100.0f); + + fish->unk_3C = 0; + fish->unk_3E = 0; + fish->unk_40 = 0; + + if (sLinkAge != 1) { + if (((i >= 15) && (i < 20)) || ((i >= 35) && (i < 40)) || ((i >= 55) && (i < 60))) { + fish->type = FS_GROUP_FISH_NONE; + } + } + } + + EnFishing_InitPondProps(this, globalCtx); + Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_KANBAN, 53.0f, -17.0f, 982.0f, 0, 0, 0, + ENKANBAN_FISHING); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FISHING, 0.0f, 0.0f, 0.0f, 0, 0, 0, 200); + + if ((D_809171D1 & 3) == 3) { + if (sLinkAge != 1) { + fishCount = 16; + } else { + fishCount = 17; + } + } else { + fishCount = 15; + } + + for (i = 0; i < fishCount; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_FISHING, sFishInits[i].pos.x, sFishInits[i].pos.y, + sFishInits[i].pos.z, 0, Rand_ZeroFloat(0x10000), 0, 100 + i); + } + + return; + } + + thisx->bgCheckFlags |= 0x800; // Added in MM + + if ((thisx->params < 115) || (thisx->params == 200)) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingFishSkel, &gFishingFishAnim, NULL, NULL, 0); + Animation_MorphToLoop(&this->skelAnime, &gFishingFishAnim, 0.0f); + } else { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingLoachSkel, &gFishingLoachAnim, NULL, NULL, 0); + Animation_MorphToLoop(&this->skelAnime, &gFishingLoachAnim, 0.0f); + } + + SkelAnime_Update(&this->skelAnime); + + if (thisx->params == 200) { + this->unk_150 = 100; + func_800BC154(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_PROP); + thisx->targetMode = 0; + thisx->flags |= 9; + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + } else { + this->unk_150 = 10; + this->unk_152 = 10; + + this->unk_148 = sFishInits[thisx->params - 100].unk_00; + this->unk_1A0 = sFishInits[thisx->params - 100].unk_0C; + this->unk_1A4 = sFishInits[thisx->params - 100].unk_08; + + this->unk_1A4 += Rand_ZeroFloat(4.99999f); + + if ((this->unk_1A4 >= 65.0f) && (Rand_ZeroOne() < 0.05f)) { + this->unk_1A4 += Rand_ZeroFloat(7.99999f); + } + + if (sLinkAge == 1) { + this->unk_1A4 *= 0.73f; + } + } +} + +void EnFishing_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnFishing* this = THIS; + + SkelAnime_Free(&this->skelAnime, globalCtx); + + if (thisx->params == 200) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + } else if (thisx->params == 1) { + Collider_DestroyJntSph(globalCtx, &this->collider); + } +} + +void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { + f32 rippleY; + s16 i; + + for (i = 0; i < EFFECT_COUNT; i++) { + if (effect->type) { + effect->timer++; + effect->pos.x += effect->vel.x; + effect->pos.y += effect->vel.y; + effect->pos.z += effect->vel.z; + effect->vel.y += effect->accel.y; + + if (effect->type == FS_EFF_RIPPLE) { + Math_ApproachF(&effect->unk_30, effect->unk_34, 0.2f, effect->unk_38); + + if (effect->unk_2C == 0) { + effect->alpha += 20; + + if (effect->alpha >= effect->unk_2E) { + effect->alpha = effect->unk_2E; + effect->unk_2C++; + } + } else { + effect->alpha -= 8; + + if (effect->alpha <= 0) { + effect->type = FS_EFF_NONE; + } + } + } else if (effect->type == FS_EFF_WATER_DUST) { + Math_ApproachF(&effect->unk_30, effect->unk_34, 0.1f, 0.1f); + effect->alpha -= 10; + + if (effect->pos.y > (WATER_SURFACE_Y(globalCtx) - 5.0f)) { + effect->accel.y = 0.0f; + effect->vel.y = 0.0f; + effect->alpha -= 5; + } + + if (effect->alpha <= 0) { + effect->type = FS_EFF_NONE; + } + } else if (effect->type == FS_EFF_BUBBLE) { + if (effect->unk_2C == 0) { + rippleY = WATER_SURFACE_Y(globalCtx); + } else { + rippleY = 69.0f; + } + + if (effect->pos.y >= rippleY) { + effect->type = FS_EFF_NONE; + + if (Rand_ZeroOne() < 0.3f) { + Vec3f pos = effect->pos; + pos.y = rippleY; + EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &pos, 20.0f, 60.0f, 150, 90); + } + } + } else if (effect->type == FS_EFF_DUST_SPLASH) { + if (effect->vel.y < -20.0f) { + effect->vel.y = -20.0f; + effect->accel.y = 0.0f; + } + + if (effect->pos.y <= WATER_SURFACE_Y(globalCtx)) { + effect->type = FS_EFF_NONE; + if (Rand_ZeroOne() < 0.5f) { + Vec3f pos = effect->pos; + pos.y = WATER_SURFACE_Y(globalCtx); + EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &pos, 40.0f, 110.0f, 150, 90); + } + } + } else if (effect->type == FS_EFF_RAIN_DROP) { + if (effect->pos.y < WATER_SURFACE_Y(globalCtx)) { + f32 sqDistXZ = SQ(effect->pos.x) + SQ(effect->pos.z); + + if (sqDistXZ > SQ(920.0f)) { + effect->pos.y = WATER_SURFACE_Y(globalCtx) + ((sqrtf(sqDistXZ) - 920.0f) * 0.11f); + effect->timer = 2; + effect->type = FS_EFF_RAIN_SPLASH; + effect->unk_30 = (KREG(18) + 30) * 0.001f; + } else { + effect->pos.y = WATER_SURFACE_Y(globalCtx) + 3.0f; + effect->timer = 0; + if (Rand_ZeroOne() < 0.75f) { + effect->type = FS_EFF_RAIN_RIPPLE; + effect->vel = sZeroVec; + effect->unk_30 = 30 * 0.001f; + } else { + effect->type = FS_EFF_NONE; + } + } + + effect->vel = sZeroVec; + } + } else if (effect->type >= FS_EFF_RAIN_RIPPLE) { + effect->unk_30 += (KREG(18) + 30) * 0.001f; + + if (effect->timer >= 6) { + effect->type = FS_EFF_NONE; + } + } else if (effect->type == FS_EFF_OWNER_HAT) { + f32 sqDistXZ; + f32 bottomY; + + effect->unk_30 = 0.010000001f; + + Math_ApproachS(&sEffOwnerHatRot.y, 0, 20, 100); + Math_ApproachS(&sEffOwnerHatRot.x, 0, 20, 100); + Math_ApproachS(&sEffOwnerHatRot.z, -0x4000, 20, 100); + + sqDistXZ = SQ(effect->pos.x) + SQ(effect->pos.z); + bottomY = WATER_SURFACE_Y(globalCtx) + ((sqrtf(sqDistXZ) - 920.0f) * 0.147f); + + if (effect->pos.y > (bottomY - 10.0f)) { + effect->pos.y -= 0.1f; + } + + if ((effect->timer % 16) == 0) { + Vec3f pos = effect->pos; + pos.y = WATER_SURFACE_Y(globalCtx); + EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &pos, 30.0f, 300.0f, 150, 90); + } + + if (effect->unk_2C >= 0) { + effect->unk_2C++; + } + + if (effect->unk_2C == 30) { + func_801518B0(globalCtx, 0x40B3, NULL); + } + + if ((effect->unk_2C >= 100) && (Message_GetState(&globalCtx->msgCtx) == 5)) { + if (func_80147624(globalCtx) || !Message_GetState(&globalCtx->msgCtx)) { + func_801477B4(globalCtx); + func_801159EC(-50); + effect->unk_2C = -1; + } + } + } + } + + effect++; + } +} + +void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { + u8 flag = 0; + f32 rotY; + s16 i; + s32 pad; + FishingEffect* firstEffect = effect; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + gDPPipeSync(POLY_XLU_DISP++); + + for (i = 0; i < 100; i++) { + if (effect->type == FS_EFF_RIPPLE) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gFishingRippleSetupDL); + gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, effect->alpha); + + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Scale(effect->unk_30, 1.0f, effect->unk_30, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gFishingRippleVtxDL); + } + effect++; + } + + effect = firstEffect; + flag = 0; + for (i = 0; i < 100; i++) { + if (effect->type == FS_EFF_DUST_SPLASH) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gFishingDustSplashSetupDL); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 0); + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, effect->alpha); + + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gFishingDustSplashVtxDL); + } + effect++; + } + + effect = firstEffect; + flag = 0; + for (i = 0; i < 100; i++) { + if (effect->type == FS_EFF_WATER_DUST) { + if (flag == 0) { + gSPDisplayList(POLY_OPA_DISP++, gFishingWaterDustSetupDL); + gDPSetEnvColor(POLY_OPA_DISP++, 40, 90, 80, 128); + flag++; + } + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 40, 90, 80, effect->alpha); + + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->timer + (i * 3), + (effect->timer + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); + + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gFishingWaterDustVtxDL); + } + effect++; + } + + effect = firstEffect; + flag = 0; + for (i = 0; i < 100; i++) { + if (effect->type == FS_EFF_BUBBLE) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gFishingBubbleSetupDL); + gDPSetEnvColor(POLY_XLU_DISP++, 150, 150, 150, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + flag++; + } + + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gFishingBubbleVtxDL); + } + effect++; + } + + effect = firstEffect + 30; + flag = 0; + for (i = 30; i < EFFECT_COUNT; i++) { + if (effect->type == FS_EFF_RAIN_DROP) { + if (flag == 0) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); + gDPSetCombineMode(POLY_XLU_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 150, 255, 255, 30); + flag++; + } + + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f(effect->unk_38, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(effect->unk_34); + Matrix_InsertZRotation_f(effect->unk_3C, MTXMODE_APPLY); + Matrix_Scale(0.002f, 1.0f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gFishingRainDropVtxDL); + } + effect++; + } + + func_8012C2DC(globalCtx->state.gfxCtx); + + effect = firstEffect + 30; + flag = 0; + for (i = 30; i < EFFECT_COUNT; i++) { + if (effect->type == FS_EFF_RAIN_RIPPLE) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gFishingRippleSetupDL); + gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 130); + flag++; + } + + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Scale(effect->unk_30, 1.0f, effect->unk_30, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gFishingRippleVtxDL); + } + effect++; + } + + effect = firstEffect + 30; + flag = 0; + for (i = 30; i < EFFECT_COUNT; i++) { + if (effect->type == FS_EFF_RAIN_SPLASH) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gFishingRainSplashSetupDL); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, KREG(19) + 80); + flag++; + } + + if (Rand_ZeroOne() < 0.5f) { + rotY = 0.0f; + } else { + rotY = M_PI; + } + + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_InsertYRotation_f(rotY, MTXMODE_APPLY); + Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gFishingRainSplashVtxDL); + } + effect++; + } + + effect = firstEffect; + if (effect->type == FS_EFF_OWNER_HAT) { + Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f((sEffOwnerHatRot.y * M_PI) / 32768, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis((sEffOwnerHatRot.x * M_PI) / 32768); + Matrix_InsertZRotation_f((sEffOwnerHatRot.z * M_PI) / 32768, MTXMODE_APPLY); + Matrix_Scale(effect->unk_30, effect->unk_30, effect->unk_30, MTXMODE_APPLY); + Matrix_InsertTranslation(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(M_PI / 2); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); + } + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFishing_DrawStreamSplash(GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->gameplayFrames * 1, + globalCtx->gameplayFrames * 8, 32, 64, 1, -globalCtx->gameplayFrames * 2, 0, 16, 16)); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, 50); + + Matrix_InsertTranslation(670.0f, -24.0f, -600.0f, MTXMODE_NEW); + Matrix_Scale(0.02f, 1.0f, 0.02f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingStreamSplashDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 func_808FEF70(Vec3f* vec) { + if (((vec->x >= 110.0f) && (vec->x <= 150.0f) && (vec->z <= 1400.0f) && (vec->z >= 1160.0f)) || + ((vec->x >= 110.0f) && (vec->x <= 210.0f) && (vec->z <= 1200.0f) && (vec->z >= 1160.0f))) { + if (vec->y <= 42.0f) { + return true; + } + } + + return false; +} + +void EnFishing_UpdateLine(GlobalContext* globalCtx, Vec3f* basePos, Vec3f* pos, Vec3f* rot, Vec3f* unk) { + s32 i; + s32 k; + f32 dx; + f32 dy; + f32 dz; + f32 rx; + f32 ry; + f32 dist; + f32 spD8; + s32 temp_s2; + s32 pad; + f32 temp_f20; + Vec3f posSrc = { 0.0f, 0.0f, 0.0f }; + Vec3f posStep; + f32 phi_f12; + Vec3f spA4; + Vec3f sp98; + f32 sp94; + f32 sp90; + f32 sp8C; + f32 sqDistXZ; + f32 temp_f18; + + if (D_8090CD24 != 0) { + spA4 = *basePos; + sp98 = pos[LINE_SEG_COUNT - 1]; + + sp94 = sp98.x - spA4.x; + sp90 = sp98.y - spA4.y; + sp8C = sp98.z - spA4.z; + + temp_f20 = sqrtf(SQ(sp94) + SQ(sp90) + SQ(sp8C)) * 0.97f; + if (temp_f20 > 1000.0f) { + temp_f20 = 1000.0f; + } + + D_809101C0 = 200.0f - (temp_f20 * 200.0f * 0.001f); + } + + temp_s2 = D_809101C0; + posSrc.z = 5.0f; + + for (i = 0; i < LINE_SEG_COUNT; i++) { + if (i <= temp_s2) { + pos[i] = *basePos; + } else if (D_8090CD24 != 0) { + temp_f20 = (f32)(i - temp_s2) / (f32)(LINE_SEG_COUNT - temp_s2 + 1); + Math_ApproachF(&pos[i].x, (sp94 * temp_f20) + spA4.x, 1.0f, 20.0f); + Math_ApproachF(&pos[i].y, (sp90 * temp_f20) + spA4.y, 1.0f, 20.0f); + Math_ApproachF(&pos[i].z, (sp8C * temp_f20) + spA4.z, 1.0f, 20.0f); + } + } + + for (i = temp_s2 + 1, k = 0; i < LINE_SEG_COUNT; i++, k++) { + temp_f18 = 2.0f * D_809101C4; + + dx = (pos + i)->x - (pos + i - 1)->x; + spD8 = (pos + i)->y; + + sqDistXZ = SQ((pos + i)->x) + SQ((pos + i)->z); + + if (sqDistXZ > SQ(920.0f)) { + phi_f12 = ((sqrtf(sqDistXZ) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); + } else { + phi_f12 = WATER_SURFACE_Y(globalCtx); + } + + if (D_80917206 == 2) { + f32 phi_f2; + + if (spD8 < phi_f12) { + phi_f12 = ((sqrtf(sqDistXZ) - 920.0f) * 0.147f) + WATER_SURFACE_Y(globalCtx); + if (spD8 > phi_f12) { + u8 temp; + + phi_f2 = (spD8 - phi_f12) * 0.05f; + + if (phi_f2 > 0.29999998f) { + phi_f2 = 0.29999998f; + } + if (i >= 100) { + phi_f2 *= (i - 100) * 0.02f; + spD8 -= phi_f2; + } + } + } else { + spD8 -= temp_f18; + } + } else if (i > LINE_SEG_COUNT - 10) { + if (spD8 > phi_f12) { + f32 phi_f2 = (spD8 - phi_f12) * 0.2f; + + phi_f2 = CLAMP_MAX(phi_f2, temp_f18); + spD8 -= phi_f2; + } + } else { + if (spD8 > phi_f12) { + spD8 -= temp_f18; + } + } + + if (func_808FEF70(&pos[i])) { + spD8 = 42.0f; + } + + dy = spD8 - (pos + i - 1)->y; + dz = (pos + i)->z - (pos + i - 1)->z; + + ry = Math_Acot2F(dz, dx); + dist = sqrtf(SQ(dx) + SQ(dz)); + rx = -Math_Acot2F(dist, dy); + + (rot + i - 1)->y = ry; + (rot + i - 1)->x = rx; + + Matrix_InsertYRotation_f(ry, MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(rx); + Matrix_MultiplyVector3fByState(&posSrc, &posStep); + + (pos + i)->x = (pos + i - 1)->x + posStep.x; + (pos + i)->y = (pos + i - 1)->y + posStep.y; + (pos + i)->z = (pos + i - 1)->z + posStep.z; + } +} + +void EnFishing_UpdateLinePos(Vec3f* pos) { + s32 i; + f32 dx; + f32 dy; + f32 dz; + f32 rx; + f32 ry; + f32 dist; + Vec3f posSrc = { 0.0f, 0.0f, 0.0f }; + Vec3f posStep; + s32 min = D_809101C0; + + posSrc.z = 5.0f; + + for (i = LINE_SEG_COUNT - 2; i > min; i--) { + dx = (pos + i)->x - (pos + i + 1)->x; + dy = (pos + i)->y - (pos + i + 1)->y; + dz = (pos + i)->z - (pos + i + 1)->z; + + ry = Math_Acot2F(dz, dx); + dist = sqrtf(SQ(dx) + SQ(dz)); + rx = -Math_Acot2F(dist, dy); + + Matrix_InsertYRotation_f(ry, MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(rx); + Matrix_MultiplyVector3fByState(&posSrc, &posStep); + + (pos + i)->x = (pos + i + 1)->x + posStep.x; + (pos + i)->y = (pos + i + 1)->y + posStep.y; + (pos + i)->z = (pos + i + 1)->z + posStep.z; + } +} + +void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, u8 hookIndex) { + f32 dx; + f32 dy; + f32 dz; + f32 rx; + f32 ry; + f32 dist; + f32 offsetY; + Vec3f posSrc = { 0.0f, 0.0f, 1.0f }; + Vec3f posStep; + Player* player = GET_PLAYER(globalCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + if ((D_8090CD14 == 3) && ((pos->y > WATER_SURFACE_Y(globalCtx)) || ((D_8090CD0C != 0) && hookIndex))) { + offsetY = 0.0f; + } else if (pos->y < WATER_SURFACE_Y(globalCtx)) { + offsetY = -1.0f; + } else { + offsetY = -3.0f; + } + + dx = refPos->x - pos->x; + dy = refPos->y - pos->y + offsetY; + dz = refPos->z - pos->z; + + ry = Math_Acot2F(dz, dx); + dist = sqrtf(SQ(dx) + SQ(dz)); + rx = -Math_Acot2F(dist, dy); + + Matrix_InsertYRotation_f(ry, MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(rx); + Matrix_MultiplyVector3fByState(&posSrc, &posStep); + + refPos->x = pos->x + posStep.x; + refPos->y = pos->y + posStep.y; + refPos->z = pos->z + posStep.z; + + Matrix_InsertTranslation(pos->x, pos->y, pos->z, MTXMODE_NEW); + + if ((player->actor.speedXZ == 0.0f) && (D_809101B4 == 0.0f)) { + Math_ApproachF(&sLureHookRotY[hookIndex], ry, 0.1f, 0.3f); + } else { + sLureHookRotY[hookIndex] = ry; + } + + Matrix_InsertYRotation_f(sLureHookRotY[hookIndex], MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(rx); + Matrix_Scale(0.0039999997f, 0.0039999997f, 0.005f, MTXMODE_APPLY); + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingLureHookDL); + + Matrix_InsertZRotation_f(M_PI / 2, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingLureHookDL); + + if ((hookIndex == 1) && (D_8090CD0C != 0)) { + Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(250.0f, 0.0f, -1400.0f, MTXMODE_APPLY); + Matrix_StatePush(); + + if (D_8090CD10 != 0) { + FishingEffect* effect = globalCtx->specialEffects; + MtxF mf; + + Matrix_MultiplyVector3fByState(&sZeroVec, &effect->pos); + Matrix_CopyCurrentState(&mf); + func_8018219C(&mf, &sEffOwnerHatRot, 0); + + D_8090CD10 = 0; + D_8090CD0C = 0; + + effect->type = FS_EFF_OWNER_HAT; + effect->unk_2C = 0; + effect->vel = sZeroVec; + effect->accel = sZeroVec; + } + + Matrix_StatePop(); + Matrix_InsertTranslation(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(M_PI / 2); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); + } + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { + s32 i; + f32 dx; + f32 dy; + f32 dz; + f32 rx; + f32 ry; + f32 dist; + f32 offsetY; + Vec3f posSrc = { 0.0f, 0.0f, 0.0f }; + Vec3f posStep; + Vec3f sp94; + Vec3f sp88; + f32 offsetX; + f32 offsetZ; + Player* player = GET_PLAYER(globalCtx); + Vec3f* pos; + s32 pad; + + posSrc.z = 0.85f; + + sSinkingLurePos[0] = sLurePos; + + if (D_8090CD54 != 0) { + offsetY = -1.0f; + } else if (sLurePos.y < WATER_SURFACE_Y(globalCtx)) { + offsetY = 0.5f; + } else { + offsetY = -5.0f; + } + + if (D_8090CD14 == 5) { + Matrix_InsertYRotation_f(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); + sp94.x = 5.0f; + sp94.y = 0.0f; + sp94.z = 3.0f; + Matrix_MultiplyVector3fByState(&sp94, &sp88); + } + + for (i = 1; i < SINKING_LURE_SEG_COUNT; i++) { + pos = sSinkingLurePos; + + if ((i < 10) && (D_8090CD14 == 5)) { + offsetX = (10 - i) * sp88.x * 0.1f; + offsetZ = (10 - i) * sp88.z * 0.1f; + } else { + offsetX = offsetZ = 0.0f; + } + + dx = (pos + i)->x - (pos + i - 1)->x + offsetX; + dy = (pos + i)->y - (pos + i - 1)->y + offsetY; + dz = (pos + i)->z - (pos + i - 1)->z + offsetZ; + + ry = Math_Acot2F(dz, dx); + dist = sqrtf(SQ(dx) + SQ(dz)); + rx = -Math_Acot2F(dist, dy); + + Matrix_InsertYRotation_f(ry, MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(rx); + Matrix_MultiplyVector3fByState(&posSrc, &posStep); + + (pos + i)->x = (pos + i - 1)->x + posStep.x; + (pos + i)->y = (pos + i - 1)->y + posStep.y; + (pos + i)->z = (pos + i - 1)->z + posStep.z; + } +} + +static f32 sSinkingLureSizes[] = { + 1.0f, 1.5f, 1.8f, 2.0f, 1.8f, 1.6f, 1.4f, 1.2f, 1.0f, 1.0f, + 0.9f, 0.85f, 0.8f, 0.7f, 0.8f, 1.0f, 1.2f, 1.1f, 1.0f, 0.8f, +}; + +void EnFishing_DrawSinkingLure(GlobalContext* globalCtx) { + s16 i; + f32 scale; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + EnFishing_UpdateSinkingLure(globalCtx); + + if (sLurePos.y < WATER_SURFACE_Y(globalCtx)) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, gFishingSinkingLureSegmentSetupDL); + + for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { + if ((i + D_80911F20) < SINKING_LURE_SEG_COUNT) { + Matrix_InsertTranslation(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); + scale = sSinkingLureSizes[i + D_80911F20] * 0.04f; + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingSinkingLureSegmentVtxDL); + } + } + } else { + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_XLU_DISP++, gFishingSinkingLureSegmentSetupDL); + + for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { + if ((i + D_80911F20) < SINKING_LURE_SEG_COUNT) { + Matrix_InsertTranslation(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); + scale = sSinkingLureSizes[i + D_80911F20] * 0.04f; + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingSinkingLureSegmentVtxDL); + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* lineRot) { + Vec3f posSrc; + Vec3f posStep; + Vec3f hookPos[2]; + s32 i; + s32 spB4 = D_809101C0; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_StatePush(); + + if (D_8090CD54 != 0) { + Vec3f posTemp = sLurePos; + + sLurePos = sSinkingLureBasePos; + EnFishing_DrawSinkingLure(globalCtx); + sLurePos = posTemp; + } + + if ((D_8090CD14 == 4) || (D_8090CD14 == 5)) { + sLurePos = sFishingHookedFish->fishMouthPos; + + if ((D_8090CD14 == 5) && (D_80917206 == 2)) { + Matrix_InsertYRotation_f(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); + posSrc.x = 2.0f; + posSrc.y = 0.0f; + posSrc.z = 0.0f; + Matrix_MultiplyVector3fByState(&posSrc, &posStep); + sLurePos.x += posStep.x; + sLurePos.z += posStep.z; + } + } else if (D_8090CD14 == 0) { + sLurePos = sReelLinePos[LINE_SEG_COUNT - 1]; + sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; + + if ((player->actor.speedXZ == 0.0f) && (D_80917200 == 0)) { + Math_ApproachF(&sLureRot.y, sReelLineRot[LINE_SEG_COUNT - 2].y, 0.1f, 0.2f); + } else { + sLureRot.y = sReelLineRot[LINE_SEG_COUNT - 2].y; + } + } + + if (D_80917206 != 2) { + Matrix_InsertTranslation(sLurePos.x, sLurePos.y, sLurePos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f(sLureRot.y + D_80917254, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(sLureRot.x); + Matrix_Scale(0.0039999997f, 0.0039999997f, 0.0039999997f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, D_80917258, MTXMODE_APPLY); + Matrix_InsertZRotation_f(M_PI / 2, MTXMODE_APPLY); + Matrix_InsertYRotation_f(M_PI / 2, MTXMODE_APPLY); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingLureFloatDL); + + posSrc.x = -850.0f; + posSrc.y = 0.0f; + posSrc.z = 0.0f; + Matrix_MultiplyVector3fByState(&posSrc, &D_80917218); + + posSrc.x = 500.0f; + posSrc.z = -300.0f; + Matrix_MultiplyVector3fByState(&posSrc, &hookPos[0]); + EnFishing_DrawLureHook(globalCtx, &hookPos[0], &sLureHookRefPos[0], 0); + + posSrc.x = 2100.0f; + posSrc.z = -50.0f; + Matrix_MultiplyVector3fByState(&posSrc, &hookPos[1]); + EnFishing_DrawLureHook(globalCtx, &hookPos[1], &sLureHookRefPos[1], 1); + } + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); + + gDPSetCombineMode(POLY_XLU_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 55); + + if ((D_8090CD14 == 4) && ((D_80917274 != 0) || (D_80917206 != 2))) { + f32 rx; + f32 ry; + f32 dist; + f32 dx; + f32 dy; + f32 dz; + + dx = sLurePos.x - sRodTipPos.x; + dy = sLurePos.y - sRodTipPos.y; + dz = sLurePos.z - sRodTipPos.z; + + ry = func_80086B30(dx, dz); + dist = sqrtf(SQ(dx) + SQ(dz)); + rx = -func_80086B30(dy, dist); + + dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) * 0.001f; + + Matrix_InsertTranslation(sRodTipPos.x, sRodTipPos.y, sRodTipPos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f(ry, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(rx); + Matrix_Scale(D_809101C8, 1.0f, dist, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingLineVtxDL); + } else { + for (i = spB4; i < LINE_SEG_COUNT - 1; i++) { + if ((i == LINE_SEG_COUNT - 3) && (D_80917206 == 0) && (D_8090CD14 == 3)) { + f32 rx; + f32 ry; + f32 dist; + f32 dx; + f32 dy; + f32 dz; + + dx = D_80917218.x - (linePos + i)->x; + dy = D_80917218.y - (linePos + i)->y; + dz = D_80917218.z - (linePos + i)->z; + + ry = func_80086B30(dx, dz); + dist = sqrtf(SQ(dx) + SQ(dz)); + rx = -func_80086B30(dy, dist); + + dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) * 0.001f; + + Matrix_InsertTranslation((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); + Matrix_InsertYRotation_f(ry, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(rx); + Matrix_Scale(D_809101C8, 1.0f, dist, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingLineVtxDL); + break; + } + + Matrix_InsertTranslation((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); + Matrix_InsertYRotation_f((lineRot + i)->y, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis((lineRot + i)->x); + Matrix_Scale(D_809101C8, 1.0f, 0.005f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingLineVtxDL); + } + } + + Matrix_StatePop(); + func_8012C2DC(globalCtx->state.gfxCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +static f32 sRodScales[22] = { + 1.0f, 1.0f, 1.0f, 0.9625f, 0.925f, 0.8875f, 0.85f, 0.8125f, + 0.775f, 0.73749995f, 0.7f, 0.6625f, 0.625f, 0.5875f, 0.54999995f, 0.5125f, + 0.47499996f, 0.4375f, 0.39999998f, 0.36249995f, 0.325f, 0.28749996f, +}; + +static f32 sRodBendRatios[22] = { + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.06f, 0.12f, 0.18f, 0.24f, 0.30f, 0.36f, + 0.42f, 0.48f, 0.54f, 0.60f, 0.60f, 0.5142f, 0.4285f, 0.3428f, 0.2571f, 0.1714f, 0.0857f, +}; + +static Vec3f sRodTipOffset = { 0.0f, 0.0f, 0.0f }; + +void EnFishing_DrawRod(GlobalContext* globalCtx) { + s16 i; + f32 spC8; + f32 spC4; + f32 spC0; + Input* input = CONTROLLER1(globalCtx); + Player* player = GET_PLAYER(globalCtx); + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (D_80911E28 != 0) { + D_80911E28--; + + Math_ApproachF(&D_8090CD40, 35.0f, 1.0f, 100.0f); + Math_ApproachF(&D_8090CD3C, -0.8f, 1.0f, 0.4f); + Math_ApproachS(&player->actor.shape.rot.x, -4000, 2, 15000); + } else { + s16 target = 0; + + if ((D_8090CD14 == 4) && (D_80917274 != 0)) { + target = Math_SinS(D_809171FE * 25600) * 1500.0f; + } else { + Math_ApproachZeroF(&D_8090CD40, 0.1f, 10.0f); + Math_ApproachZeroF(&D_8090CD3C, 1.0f, 0.05f); + } + + Math_ApproachS(&player->actor.shape.rot.x, target, 5, 1000); + } + + if ((D_8090CD14 == 3) || (D_8090CD14 == 4)) { + if ((input->rel.stick_x == 0) && (D_8090CD44 != 0)) { + D_8090CD30 = 0.0f; + } + if ((input->rel.stick_y == 0) && (D_8090CD48 != 0)) { + D_8090CD34 = 0.0f; + } + + spC8 = player->unk_B08[1]; + Math_SmoothStepToF(&player->unk_B08[1], input->rel.stick_y * 0.02f, 0.3f, 5.0f, 0.0f); + spC8 = player->unk_B08[1] - spC8; + + spC4 = player->unk_B08[0]; + Math_SmoothStepToF(&player->unk_B08[0], input->rel.stick_x * 0.02f, 0.3f, 5.0f, 0.0f); + spC4 = player->unk_B08[0] - spC4; + + if (player->unk_B08[0] > 1.0f) { + player->unk_B08[0] = 1.0f; + } + if (player->unk_B08[1] > 1.0f) { + player->unk_B08[1] = 1.0f; + } + if (player->unk_B08[0] < -1.0f) { + player->unk_B08[0] = -1.0f; + } + if (player->unk_B08[1] < -1.0f) { + player->unk_B08[1] = -1.0f; + } + + Math_ApproachF(&D_8090CD28, spC4 * 70.0f * -0.01f, 1.0f, D_8090CD30); + Math_ApproachF(&D_8090CD30, 1.0f, 1.0f, 0.1f); + Math_ApproachF(&D_8090CD2C, spC8 * 70.0f * 0.01f, 1.0f, D_8090CD34); + Math_ApproachF(&D_8090CD34, 1.0f, 1.0f, 0.1f); + Math_ApproachZeroF(&D_8090CD38, 1.0f, 0.05f); + } else { + Math_ApproachZeroF(&player->unk_B08[1], 1.0f, 0.1f); + Math_ApproachZeroF(&player->unk_B08[0], 1.0f, 0.1f); + Math_ApproachF(&D_8090CD2C, (Math_SinS(D_809171FE * 3000) * 0.025f) + -0.03f, 1.0f, 0.05f); + Math_ApproachZeroF(&D_8090CD28, 1.0f, 0.05f); + + if ((D_80917204 >= 19) && (D_80917204 <= 24)) { + Math_ApproachF(&D_8090CD38, 0.8f, 1.0f, 0.2f); + } else { + Math_ApproachF(&D_8090CD38, 0.0f, 1.0f, 0.4f); + } + } + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, gFishingRodSetupDL); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 155, 0, 255); + + Matrix_InsertMatrix(&player->mf_CC4, MTXMODE_NEW); + + if (sLinkAge != 1) { + Matrix_InsertTranslation(0.0f, 400.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_InsertTranslation(0.0f, 230.0f, 0.0f, MTXMODE_APPLY); + } + + if (D_8090CD14 == 5) { + Matrix_InsertYRotation_f(1.7592919f, MTXMODE_APPLY); + } else { + Matrix_InsertYRotation_f(1.288053f, MTXMODE_APPLY); + } + + Matrix_RotateStateAroundXAxis(-0.6283185f); + Matrix_InsertZRotation_f((player->unk_B08[0] * 0.5f) + 0.4712389f, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis((D_8090CD40 + 20.0f) * 0.01f * M_PI); + Matrix_Scale(0.70000005f, 0.70000005f, 0.70000005f, MTXMODE_APPLY); + + spC0 = (D_8090CD3C * (((player->unk_B08[1] - 1.0f) * -0.25f) + 0.5f)) + (D_8090CD2C + D_8090CD38); + + Matrix_InsertTranslation(0.0f, 0.0f, -1300.0f, MTXMODE_APPLY); + + for (i = 0; i < 22; i++) { + Matrix_InsertYRotation_f(sRodBendRatios[i] * D_8090CD28 * 0.5f, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(sRodBendRatios[i] * spC0 * 0.5f); + + Matrix_StatePush(); + Matrix_Scale(sRodScales[i], sRodScales[i], 0.52f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (i < 5) { + gDPLoadTextureBlock(POLY_OPA_DISP++, &gFishingRodSegmentBlackTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 8, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, 3, G_TX_NOLOD, G_TX_NOLOD); + } else if ((i < 8) || ((i % 2) == 0)) { + gDPLoadTextureBlock(POLY_OPA_DISP++, &gFishingRodSegmentWhiteTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 8, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, 3, G_TX_NOLOD, G_TX_NOLOD); + } else { + gDPLoadTextureBlock(POLY_OPA_DISP++, &gFishingRodSegmentStripTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 8, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, 3, G_TX_NOLOD, G_TX_NOLOD); + } + + gSPDisplayList(POLY_OPA_DISP++, gFishingRodSegmentDL); + + Matrix_StatePop(); + Matrix_InsertTranslation(0.0f, 0.0f, 500.0f, MTXMODE_APPLY); + + if (i == 21) { + Matrix_MultiplyVector3fByState(&sRodTipOffset, &sRodTipPos); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +static Vec3f D_8090D614 = { 0.0f, 0.0f, 0.0f }; + +#ifdef NON_MATCHING +// Stack memes, the pad on line ~2410 makes stack too big, but needed for ordering +void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { + f32 spE4; + f32 spE0; + s16 phi_v0; + s16 spDC; + f32 spD8; + f32 spD4; + f32 spD0; + f32 phi_f16; + f32 spC8; + s16 i; + Player* player = GET_PLAYER(globalCtx); + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + Vec3f spA8; + Vec3f sp9C; + Vec3f sp90; + Input* input = CONTROLLER1(globalCtx); + // Vec3f sp80; + + f32 phi_f0; + // f32 sp70; + // Vec3f sp64; + // Vec3f sp58; + // s32 pad; + + D_809171FE++; + + if (D_80917200 != 0) { + D_80917200--; + } + + if (D_80917202 != 0) { + D_80917202--; + } + + if (D_80917204 != 0) { + D_80917204--; + } + + if (D_80917272 != 0) { + D_80917272--; + } + + if (D_809101CC != 0) { + D_809101CC--; + } + + if (D_8090CD24 != 0) { + D_8090CD24--; + } + + if (D_809171F4 != 0) { + D_809171F4--; + } + + if (D_80917264 != 0) { + D_80917264--; + } + + if (D_809171FC == 1) { + D_809171FC = 2; + D_809171D8 = 0; + D_809171D6 = 0; + D_80917206 = 0; + + // Age and high score check removed in MM + sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; + + D_809101C4 = 520.0f; + D_809101C0 = 195.0f; + + D_8090CD14 = 0; + D_80917206 = 0; + D_809171FE = 0; + D_80917200 = 0; + D_80917202 = 0; + D_80917204 = 0; + D_80917270 = 0; + D_80917264 = 0; + D_809101CC = 0; + + D_80917254 = D_809101D0 = D_80917258 = 0.0f; + + D_80917278 = zeroVec; + + for (i = 0; i < LINE_SEG_COUNT; i++) { + sReelLinePos[i] = zeroVec; + sReelLineRot[i] = zeroVec; + sReelLineUnk[i] = zeroVec; + } + } + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sLurePos, &D_8090D614, &sProjectedW); + + if (D_8090CD14 == 0) { + Math_ApproachF(&D_80917258, -800.0f, 1.0f, 20.0f); + } else { + Math_ApproachF(&D_80917258, 300.0f, 1.0f, 20.0f); + } + + switch (D_8090CD14) { + case 0: + D_80911F20 = 0; + + Math_ApproachF(&D_809101C0, 195.0f, 1.0f, 1.0f); + + if (player->stateFlags1 & 0x8000000) { + D_80917204 = 0; + player->unk_B28 = 0; + } + + if (D_80917204 == 0) { + if ((D_80917200 == 0) && (player->unk_B28 == 1)) { + D_80917204 = 37; + func_801477B4(globalCtx); + } + } else { + sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; + sLureRot.y = sReelLineRot[LINE_SEG_COUNT - 2].y; + + if (D_80917204 == 18) { + D_8090CD14 = 1; + sLurePos = sRodTipPos; + Matrix_InsertYRotation_f(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); + sp90.x = 0.0f; + sp90.y = 0.0f; + sp90.z = 25.0f; + Matrix_MultiplyVector3fByState(&sp90, &D_80917238); + D_80917238.y = 15.0f; + D_80917248.x = D_80917248.z = 0.0f; + D_80917248.y = -1.0f; + D_809101C4 = 0.0f; + D_80917202 = 5; + D_8091726C = 0.5f; + D_80917268 = Rand_ZeroFloat(1.9f); + sFishMouthOffset.y = 500.0f; + func_8019F1C0(&D_8090D614, NA_SE_IT_SWORD_SWING_HARD); + } + } + break; + + case 1: + spE0 = sLurePos.y; + + sLurePos.x += D_80917238.x; + sLurePos.y += D_80917238.y; + sLurePos.z += D_80917238.z; + + D_80917238.x += D_80917248.x; + D_80917238.y += D_80917248.y; + D_80917238.z += D_80917248.z; + + if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_8090CD0C != 0)) { + D_80917238.x *= 0.9f; + D_80917238.z *= 0.9f; + if (D_8090CD0C == 0) { + play_sound(NA_SE_IT_FISHING_REEL_HIGH - SFX_FLAG); + } + } + + spD8 = sLurePos.x - sRodTipPos.x; + spD4 = sLurePos.y - sRodTipPos.y; + spD0 = sLurePos.z - sRodTipPos.z; + + if (D_80917202 != 0) { + sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; + sLureRot.y = sReelLineRot[LINE_SEG_COUNT - 2].y; + } else { + sLureRot.x = 0.0f; + sLureRot.y = Math_Acot2F(spD0, spD8) + M_PI; + } + + phi_f16 = sqrtf(SQ(spD8) + SQ(spD4) + SQ(spD0)); + if (phi_f16 > 1000.0f) { + phi_f16 = 1000.0f; + } + D_809101C0 = 200.0f - (phi_f16 * 200.0f * 0.001f); + + spC8 = SQ(sLurePos.x) + SQ(sLurePos.z); + if (spC8 > SQ(920.0f)) { + f32 temp; + + if ((sLurePos.y > 160.0f) || (sLurePos.x < 80.0f) || (sLurePos.x > 180.0f) || (sLurePos.z > 1350.0f) || + (sLurePos.z < 1100.0f) || (sLurePos.y < 45.0f)) { + Vec3f sp80 = this->actor.world.pos; + + this->actor.prevPos = this->actor.world.pos = sLurePos; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 30.0f, 0x43); + this->actor.world.pos = sp80; + + if (this->actor.bgCheckFlags & 0x10) { + D_80917238.y = -0.5f; + } + if (this->actor.bgCheckFlags & 8) { + if (D_80917238.y > 0.0f) { + D_80917238.y = 0.0f; + } + D_80917238.x = D_80917238.z = 0.0f; + } + } else { + if (func_808FEF70(&sLurePos)) { + D_8090CD14 = 3; + D_809101D0 = 0.0f; + } + } + + temp = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); + // spE4 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); + if (sLurePos.y <= temp) { + sLurePos.y = temp; + D_80917238.x = D_80917238.y = D_80917238.z = 0.0f; + D_8090CD14 = 3; + D_809101D0 = 0.0; + } else { + Math_ApproachF(&D_809101C4, 0.0f, 1.0f, 0.05f); + func_8019F1C0(&D_8090D614, + NA_SE_EN_WIZ_UNARI - SFX_FLAG); // changed from NA_SE_EN_FANTOM_FLOAT in OoT + } + } else { + f32 sp7C = WATER_SURFACE_Y(globalCtx); + f32 sp78; + // spE4 = WATER_SURFACE_Y(globalCtx); + + if (sLurePos.y <= sp7C) { + D_8090CD14 = 2; + D_809101D0 = 0.0f; + D_80917238.x = D_80917238.z = 0.0f; + + if (D_80917206 == 2) { + D_809171F2 = 0; + } else { + D_809171F2 = 10; + } + + if ((sLurePos.y <= sp7C) && (sp7C < spE0) && (sp7C == WATER_SURFACE_Y(globalCtx))) { + D_80917264 = 10; + func_8019F1C0(&D_8090D614, NA_SE_EV_BOMB_DROP_WATER); + D_80917248.y = 0.0f; + D_80917238.y *= 0.2f; + + for (i = 0; i < 50; i++) { + sp7C = Rand_ZeroFloat(1.5f) + 0.5f; + sp78 = Rand_ZeroFloat(6.28f); + + sp9C.x = __sinf(sp78) * sp7C; + sp9C.z = __cosf(sp78) * sp7C; + sp9C.y = Rand_ZeroFloat(3.0f) + 3.0f; + + spA8 = sLurePos; + spA8.x += (sp9C.x * 3.0f); + spA8.y = WATER_SURFACE_Y(globalCtx); + spA8.z += (sp9C.z * 3.0f); + EnFishing_SpawnDustSplash(NULL, globalCtx->specialEffects, &spA8, &sp9C, + Rand_ZeroFloat(0.02f) + 0.025f); + } + + spA8 = sLurePos; + spA8.y = WATER_SURFACE_Y(globalCtx); + EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &spA8, 100.0f, 800.0f, 150, 90); + } + } else { + Math_ApproachZeroF(&D_809101C4, 1.0f, 0.05f); + func_8019F1C0(&D_8090D614, + NA_SE_EN_WIZ_UNARI - SFX_FLAG); // changed from NA_SE_EN_FANTOM_FLOAT in OoT + } + } + + sReelLinePos[LINE_SEG_COUNT - 1].x = sLurePos.x; + sReelLinePos[LINE_SEG_COUNT - 1].y = sLurePos.y; + sReelLinePos[LINE_SEG_COUNT - 1].z = sLurePos.z; + + D_809101BC = 1.0f; + D_8091725C = 0.5f; + break; + + case 2: + if (sLurePos.y <= WATER_SURFACE_Y(globalCtx)) { + sLurePos.y += D_80917238.y; + + Math_ApproachZeroF(&D_80917238.y, 1.0f, 1.0f); + + if (D_80917206 != 2) { + Math_ApproachF(&sLurePos.y, WATER_SURFACE_Y(globalCtx), 0.5f, 1.0f); + } + } + + Math_ApproachF(&D_809101C4, 2.0f, 1.0f, 0.1f); + + if (D_809171F2 == 0) { + D_8090CD14 = 3; + } else { + D_809171F2--; + } + break; + + case 3: { + f32 sp70; + + D_80911F20 = 0; + + if ((D_8090CD0C != 0) && ((SQ(sLurePos.x) + SQ(sLurePos.z)) < SQ(500.0f))) { + D_8090CD10 = 1; + } + + player->unk_B28 = 2; + + if (D_809101B4 < 3.0f) { + spD0 = D_8091725C * Math_SinS(D_809171FE * 0x1060); + Math_ApproachF(&sLureRot.x, -0.5235988f + spD0, 0.3f, D_80917260); + Math_ApproachF(&D_80917260, 0.5f, 1.0f, 0.02f); + Math_ApproachZeroF(&D_8091725C, 1.0f, 0.02f); + } else { + D_80917260 = 0.0f; + } + + spDC = 0x4000; + spE4 = WATER_SURFACE_Y(globalCtx); + + spC8 = SQ(sLurePos.x) + SQ(sLurePos.z); + if (spC8 < SQ(920.0f)) { + if (sLurePos.y <= (spE4 + 4.0f)) { + sp70 = 0.0f; + + if (D_809101CC == 0) { + if (fabsf(input->rel.stick_x) > 30.0f) { + sp70 = fabsf((input->rel.stick_x - D_8090CD44) * (1.0f / 60.0f)); + } else if (fabsf(input->rel.stick_y) > 30.0f) { + sp70 = fabsf((input->rel.stick_y - D_8090CD48) * (1.0f / 60.0f)); + } + } + + if (sp70 > 1.0f) { + sp70 = 1.0f; + } + if (CHECK_BTN_ALL(input->press.button, BTN_B)) { + sp70 = 0.5f; + } + + if (D_8090CD0C != 0) { + if (sp70 > 0.3f) { + sp70 = 0.3f; + } + } + + if ((sp70 > 0.2f) && (D_809101B4 < 4.0f)) { + D_809101CC = 5; + + if (sp70 > 0.8f) { + D_80917270 = 2; + } else { + D_80917270 = 1; + } + + sp90.x = player->actor.world.pos.x - sLurePos.x; + sp90.z = player->actor.world.pos.z - sLurePos.z; + sp90.y = Math_Acot2F(sp90.z, sp90.x); + + D_809101B0 = (sp70 * D_809101BC) + sp90.y; + D_809101BC *= -1.0f; + D_809101B4 = fabsf(sp70) * 6.0f; + sLureRot.x = 0.0f; + D_8091725C = 0.5f; + D_809101C0 += (fabsf(sp70) * 7.5f); + + func_8019FAD8(&D_8090D614, NA_SE_EV_LURE_MOVE_W, (sp70 * 1.999f * 0.25f) + 0.75f); + + if (D_80917206 == 2) { + D_80917278.y = 5.0f * sp70; + sReelLinePos[LINE_SEG_COUNT - 1].y += D_80917278.y; + sLurePos.y += D_80917278.y; + } + } else if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { + s32 pad; + + spDC = 0x500; + D_809101B0 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + sLureRot.x = 0.0f; + D_8091725C = 0.5f; + if (D_80917206 == 2) { + D_80917278.y = 0.2f; + sReelLinePos[LINE_SEG_COUNT - 1].y += D_80917278.y; + sLurePos.y += D_80917278.y; + } + } + } else { + if (D_809101C0 > 150.0f) { + sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; + D_809101B0 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + D_809101C0 += 2.0f; + } + } + } else { + spE4 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); + if (sLurePos.y <= spE4) { + sLurePos.y = spE4; + spDC = 0x500; + D_809101B0 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + sLureRot.x = 0.0f; + if (CHECK_BTN_ALL(input->press.button, BTN_B)) { + D_809101C0 += 6.0f; + func_8019F1C0(&D_8090D614, NA_SE_PL_WALK_SAND); + } + } else { + if (D_809101C0 > 150.0f) { + sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; + D_809101B0 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; + D_809101C0 += 2.0f; + } + } + } + + Math_ApproachZeroF(&D_809101B4, 1.0f, 0.3f); + Math_ApproachS(&D_809101B8, (D_809101B0 * 32768.0f) / M_PI, 3, spDC); + + sLureRot.y = (D_809101B8 / 32768.0f) * M_PI; + + sp90.x = 0.0f; + sp90.y = 0.0f; + sp90.z = D_809101B4; + + Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); + + if (D_80917206 == 2) { + Vec3f sp64; + + Matrix_MultiplyVector3fByState(&sp90, &sp64); + D_80917278.x = sp64.x; + D_80917278.z = sp64.z; + phi_f0 = 10.0f; + } else { + Matrix_MultiplyVector3fByState(&sp90, &D_80917278); + phi_f0 = 0.0f; + } + + D_80917254 = 0.0f; + + if ((D_80917206 == 1) && CHECK_BTN_ALL(input->cur.button, BTN_A)) { + D_80917278.y = -2.0f; + + if (D_809171FE & 1) { + D_80917254 = 0.5f; + } else { + D_80917254 = -0.5f; + } + } else if (sReelLinePos[LINE_SEG_COUNT - 1].y < (WATER_SURFACE_Y(globalCtx) + phi_f0)) { + if (D_80917206 == 2) { + Vec3f sp58 = this->actor.world.pos; + this->actor.prevPos = this->actor.world.pos = sLurePos; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 30.0f, 0x44); + this->actor.world.pos = sp58; + + D_80917278.y += -0.5f; + if (D_80917278.y < -1.0f) { + D_80917278.y = -1.0f; + } + + if (sLurePos.y < (this->actor.floorHeight + 5.0f)) { + sReelLinePos[LINE_SEG_COUNT - 1].y = sLurePos.y = this->actor.floorHeight + 5.0f; + D_80917278.y = 0.0f; + } else { + D_80917270 = 1; + } + } else { + D_80917278.y = fabsf(sReelLinePos[LINE_SEG_COUNT - 1].y - WATER_SURFACE_Y(globalCtx)) * 0.2f; + if (D_80917278.y > 1.5f) { + D_80917278.y = 1.5f; + } + } + } + + sReelLinePos[LINE_SEG_COUNT - 1].x += D_80917278.x; + sReelLinePos[LINE_SEG_COUNT - 1].y += D_80917278.y; + sReelLinePos[LINE_SEG_COUNT - 1].z += D_80917278.z; + + if (sReelLinePos[LINE_SEG_COUNT - 1].y > (spE4 + 6.0f)) { + sReelLinePos[LINE_SEG_COUNT - 1].y -= 5.0f; + } + + D_80917238.x = D_80917238.y = D_80917238.z = D_80917248.y = 0.0f; + + if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { + if (CHECK_BTN_ALL(input->cur.button, BTN_R)) { + D_809101C0 += 1.5f; + play_sound(NA_SE_IT_FISHING_REEL_HIGH - SFX_FLAG); + Math_ApproachF(&D_809101D0, 1000.0f, 1.0f, 2.0f); + } else { + D_809101C0 += D_8091726C; + play_sound(NA_SE_IT_FISHING_REEL_SLOW - SFX_FLAG); + Math_ApproachF(&D_809101D0, 1000.0f, 1.0f, 0.2f); + } + + if (sReelLinePos[LINE_SEG_COUNT - 1].y > (WATER_SURFACE_Y(globalCtx) + 4.0f)) { + Math_ApproachF(&D_809101C4, 3.0f, 1.0f, 0.2f); + } else { + Math_ApproachF(&D_809101C4, 1.0f, 1.0f, 0.2f); + } + } else { + Math_ApproachF(&D_809101C4, 2.0f, 1.0f, 0.2f); + } + + Math_ApproachF(&sLurePos.x, sReelLinePos[LINE_SEG_COUNT - 1].x, 1.0f, D_809101D0); + Math_ApproachF(&sLurePos.y, sReelLinePos[LINE_SEG_COUNT - 1].y, 1.0f, D_809101D0); + Math_ApproachF(&sLurePos.z, sReelLinePos[LINE_SEG_COUNT - 1].z, 1.0f, D_809101D0); + + if (D_809101B4 > 1.0f) { + Math_ApproachF(&D_809101D0, 1000.0f, 1.0f, 1.0f); + } + + Math_ApproachF(&D_809101D0, 1000.0f, 1.0f, 0.1f); + + if (D_809101C0 >= 195.0f) { + D_809101C0 = 195.0f; + D_8090CD14 = 0; + D_809101C4 = 520.0f; + D_8090CD4C = 3; + } + + if ((sLurePos.y <= (WATER_SURFACE_Y(globalCtx) + 4.0f)) && + (sLurePos.y >= (WATER_SURFACE_Y(globalCtx) - 4.0f))) { + phi_v0 = 63; + if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_809101B4 > 1.0f)) { + phi_v0 = 1; + } + + if ((D_809171FE & phi_v0) == 0) { + spA8 = sLurePos; + spA8.y = WATER_SURFACE_Y(globalCtx); + EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &spA8, 30.0f, 300.0f, 150, 90); + } + } + break; + } + + case 4: + if (this->unk_14F != 0) { + this->unk_14F--; + D_809101C0 += D_8091726C; + } + + if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { + if ((SQ(sLurePos.x) + SQ(sLurePos.z)) > SQ(920.0f)) { + D_809101C0 += 1.0f; + } else { + D_809101C0 += D_8091726C; + } + play_sound(NA_SE_IT_FISHING_REEL_SLOW - SFX_FLAG); + } + + if ((D_809171FE & 0x1F) == 0) { + if ((D_80917274 != 0) || (D_80917206 != 2)) { + D_8090CD24 = 5; + } + } + + Math_ApproachF(&D_809101C4, 0.0f, 1.0f, 0.2f); + break; + + case 5: + D_809101C8 = 0.0005000001f; + sReelLinePos[LINE_SEG_COUNT - 1].x = sLurePos.x; + sReelLinePos[LINE_SEG_COUNT - 1].y = sLurePos.y; + sReelLinePos[LINE_SEG_COUNT - 1].z = sLurePos.z; + D_809101C4 = 2.0f; + break; + } +} +#else +static Vec3f D_8090D620 = { 0.0f, 0.0f, 0.0f }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateLure.s") #endif -extern ColliderJntSphElementInit D_8090CD58[12]; -extern ColliderJntSphInit D_8090CF08; -extern InitChainEntry D_8090D4D0[]; +s32 func_809033F0(EnFishing* this, GlobalContext* globalCtx, u8 ignorePosCheck) { + s16 i; + s16 count; + f32 scale; + Vec3f pos; + Vec3f vel; + f32 speedXZ; + f32 angle; -extern UNK_TYPE D_0600007C; -extern UNK_TYPE D_06003230; -extern UNK_TYPE D_0600453C; -extern UNK_TYPE D_060074C8; -extern UNK_TYPE D_06008678; -extern UNK_TYPE D_0600B950; -extern UNK_TYPE D_0600C220; -extern UNK_TYPE D_060113D0; -extern UNK_TYPE D_06012160; -extern UNK_TYPE D_060121F0; -extern UNK_TYPE D_06014030; -extern UNK_TYPE D_060153D0; + if ((this->actor.world.pos.y < (WATER_SURFACE_Y(globalCtx) - 10.0f)) && !ignorePosCheck) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FC6C0.s") + // Necessary to match + if (this->unk_1A4) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FC770.s") + if (this->unk_1A4 >= 40.0f) { + count = 40; + scale = 1.2f; + } else { + count = 30; + scale = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FC790.s") + for (i = 0; i < count; i++) { + speedXZ = (Rand_ZeroFloat(1.5f) + 0.5f) * scale; + angle = Rand_ZeroFloat(6.28f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FC8B8.s") + vel.x = __sinf(angle) * speedXZ; + vel.z = __cosf(angle) * speedXZ; + vel.y = (Rand_ZeroFloat(3.0f) + 3.0f) * scale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FC964.s") + pos = this->actor.world.pos; + pos.x += vel.x * 3.0f; + pos.y = WATER_SURFACE_Y(globalCtx); + pos.z += vel.z * 3.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FCABC.s") + EnFishing_SpawnDustSplash(&this->actor.projectedPos, globalCtx->specialEffects, &pos, &vel, + (Rand_ZeroFloat(0.02f) + 0.025f) * scale); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FCC0C.s") + pos = this->actor.world.pos; + pos.y = WATER_SURFACE_Y(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FCDBC.s") + EnFishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &pos, 100.0f, 800.0f, 150, 90); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FCF60.s") + this->unk_149 = 30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FD054.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_Init.s") +void func_809036BC(EnFishing* this, GlobalContext* globalCtx) { + s16 count; + s16 i; + f32 scale; + Vec3f pos; + Vec3f vel; + f32 speedXZ; + f32 angle; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_Destroy.s") + // Necessary to match + if (this->unk_1A4) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FDCDC.s") + if (this->unk_1A4 >= 45.0f) { + count = 30; + scale = 0.5f; + } else { + count = 20; + scale = 0.3f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FE3F8.s") + for (i = 0; i < count; i++) { + speedXZ = (Rand_ZeroFloat(1.5f) + 0.5f) * scale; + angle = Rand_ZeroFloat(6.28f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FEE1C.s") + vel.x = __sinf(angle) * speedXZ; + vel.z = __cosf(angle) * speedXZ; + vel.y = Rand_ZeroFloat(2.0f) + 2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FEF70.s") + pos = this->actor.world.pos; + pos.x += (vel.x * 3.0f); + pos.y += (vel.y * 3.0f); + pos.z += (vel.z * 3.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FF064.s") + EnFishing_SpawnDustSplash(&this->actor.projectedPos, globalCtx->specialEffects, &pos, &vel, + (Rand_ZeroFloat(0.02f) + 0.025f) * scale); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FF5E0.s") +void func_809038A4(EnFishing* this, Input* input) { + Vec3f sp34; + Vec3f sp28; + f32 sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FF750.s") + sp34.x = sLurePos.x - this->actor.world.pos.x; + sp34.y = sLurePos.y - this->actor.world.pos.y; + sp34.z = sLurePos.z - this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FFC44.s") + sp24 = SQ(sp34.x) + SQ(sp34.y) + SQ(sp34.z); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_808FFF3C.s") + if ((D_8090CD14 == 3) && (this->unk_19A == 0) && (D_8090CD0C == 0)) { + Matrix_InsertYRotation_f((-this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp34, &sp28); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80900228.s") + if ((sp28.z > 0.0f) || (this->unk_1A4 < 40.0f)) { + if ((this->unk_150 == 7) && (sp24 < SQ(200.0f))) { + this->unk_150 = 4; + this->unk_1AC = sLurePos; + this->unk_1A8 = 28672.0f; + this->unk_180 = 5.0f; + } else { + if ((CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_809101B4 > 1.0f)) && (sp24 < SQ(120.0f))) { + this->unk_150 = 2; + this->unk_156 = 0; + this->unk_172[0] = 0; + this->unk_172[2] = Rand_ZeroFloat(100.0f) + 100.0f; + this->unk_1A0 = sFishInits[this->actor.params - 100].unk_0C; + this->unk_1A8 = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80900A04.s") + if ((this->unk_172[1] == 0) && (sp24 < SQ(70.0f))) { + this->unk_150 = 2; + this->unk_156 = 0; + this->unk_172[0] = 0; + this->unk_172[2] = Rand_ZeroFloat(100.0f) + 100.0f; + this->unk_1A0 = sFishInits[this->actor.params - 100].unk_0C; + this->unk_1A8 = 0.0f; + } + } + } + } else if ((D_8090CD14 == 4) && (D_80917274 != 0) && (sp24 < SQ(100.0f)) && (this->unk_150 >= 10)) { + this->unk_152 = 0; + this->unk_150 = 1; + this->unk_19C = 1000; + this->unk_19A = 100; + this->unk_172[1] = 50; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80901480.s") + if ((D_80917206 != 2) && (D_80917264 != 0) && (this->unk_1A4 > 60.0f) && (sp24 < SQ(30.0f)) && + (this->unk_150 >= 10)) { + this->unk_152 = 0; + this->unk_150 = 1; + this->unk_19C = 1000; + this->unk_19A = 100; + this->unk_172[1] = 50; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_809033F0.s") +void func_80903C60(EnFishing* this, u8 arg1) { + u16 sfxId; + u8 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_809036BC.s") + if (this->unk_148 == 0) { + temp = this->unk_1A4; + } else { + temp = 2.0f * this->unk_1A4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_809038A4.s") + if (arg1 == 0) { + if (temp >= 50) { + sfxId = NA_SE_EV_DIVE_INTO_WATER; + } else if (temp >= 40) { + sfxId = NA_SE_EV_BOMB_DROP_WATER; + } else { + sfxId = NA_SE_EV_BOMB_DROP_WATER; + } + } else { + if (temp >= 50) { + sfxId = NA_SE_EV_JUMP_OUT_WATER; + } else if (temp >= 40) { + sfxId = NA_SE_EV_OUT_OF_WATER; + } else { + sfxId = NA_SE_EV_OUT_OF_WATER; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80903C60.s") + Actor_PlaySfxAtPos(&this->actor, sfxId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80903E20.s") +void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { + if (sLinkAge == 1) { + if (gSaveContext.roomInf[127][2] & 0x7F) { + if (gSaveContext.roomInf[127][2] & 0x80) { + this->actor.textId = 0x40B1; + } else { + this->actor.textId = 0x4089; + } + } else { + this->actor.textId = 0x40AE; + } + } else if (gSaveContext.roomInf[127][2] & 0x7F000000) { + if (gSaveContext.roomInf[127][2] & 0x80000000) { + this->actor.textId = 0x40B1; + } else { + this->actor.textId = 0x4089; + } + } else { + this->actor.textId = 0x40AE; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_Update.s") + if (this->unk_1CB == 0) { + if (this->unk_1CC == 0) { + this->actor.flags |= 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80908554.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + D_8090CCF8 = D_809171CC; + this->unk_1CB = 1; + } else { + func_800B863C(&this->actor, globalCtx); + } + } else { + this->unk_1CC--; + this->actor.flags &= ~1; + } + } else if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + this->unk_1CB = 0; + this->unk_1CC = 20; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80908674.s") +#ifdef NON_MATCHING +// D_80917266 in case 5 around the large branching +void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { + s16 i; + s16 sp134 = 10; + f32 sp130; + f32 sp12C; + f32 sp128; + f32 sp124; + f32 multiplier; + f32 sp11C; + f32 sp118; + Vec3f sp10C; + Vec3f sp100; + s16 spFE; + s16 spFC; + s16 spFA; + s16 phi_v0; + s16 spF6; + s16 spF4; + s16 spF2; + s16 spF0; + s16 spEE; + EnFishing* this = THIS; + GlobalContext* globalCtx = globalCtx2; + Player* player = GET_PLAYER(globalCtx); + Input* input = CONTROLLER1(globalCtx); + f32 spD8; + f32 phi_f0; + f32 phi_f2; + Vec3f spC4; + Vec3f spB8; + u8 phi_v0_2; + f32 temp_f0; + f32 temp; + s32 pad; + f32 spA4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_809086B4.s") + this->actor.uncullZoneForward = 700.0f; + this->actor.uncullZoneScale = 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80908734.s") + if (this->unk_148 == 0) { + sp118 = (player->actor.speedXZ * 0.15f) + 0.25f; + } else { + sp118 = (player->actor.speedXZ * 0.3f) + 0.25f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_Draw.s") + if ((D_80917200 != 0) || (sCameraId != MAIN_CAM) || + ((player->actor.world.pos.z > 1150.0f) && (this->unk_150 != 100))) { + this->actor.flags &= ~1; + } else { + this->actor.flags |= 1; + if (D_8090CD14 != 0) { + if (D_80917202 == 0) { + this->actor.focus.pos = sLurePos; + } else if (D_80917202 == 1) { + D_8090CD4C = 1; + D_80911F50 = 0.0f; + D_809171DC = 2; + } + } + this->actor.focus.pos = this->actor.world.pos; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_809089B8.s") + this->unk_154++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80908A64.s") + for (i = 0; i < ARRAY_COUNT(this->unk_172); i++) { + if (this->unk_172[i] != 0) { + this->unk_172[i]--; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80908B4C.s") + if (this->unk_19C != 0) { + this->unk_19C--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80908E08.s") + if (this->unk_19A != 0) { + this->unk_19A--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80909234.s") + if (this->unk_198 != 0) { + this->unk_198--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80909AD0.s") + if (this->unk_149 != 0) { + this->unk_149--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_80909CC0.s") + Math_ApproachF(&this->unk_190, this->unk_188, 1.0f, 0.2f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_8090AB6C.s") + if (this->unk_150 == 6) { + Math_ApproachF(&this->unk_194, this->unk_18C, 0.2f, 200.0f); + } else { + phi_f0 = 1.0f; + phi_f2 = 1.0f; + if (this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) { + phi_f0 = 1.5f; + phi_f2 = 3.0f; + } + Math_ApproachF(&this->unk_194, this->unk_18C * phi_f0, 1.0f, 500.0f * phi_f2); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_8090C884.s") + Math_ApproachS(&this->unk_168, 0, 5, 500); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_8090C8BC.s") + if (this->unk_148 == 0) { + Actor_SetScale(&this->actor, this->unk_1A4 * 15.0f * 0.00001f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/func_8090C96C.s") + this->unk_184 += this->unk_190; + + temp = __cosf(this->unk_184); + this->unk_164 = this->unk_166 + (temp * this->unk_194); + + temp = __cosf(this->unk_184 + -1.2f); + this->unk_16E = this->unk_166 + (temp * this->unk_194 * 1.6f); + } else { + Actor_SetScale(&this->actor, this->unk_1A4 * 65.0f * 0.000001f); + + this->actor.scale.x = this->actor.scale.z * 1.1f; + this->actor.scale.y = this->actor.scale.z * 1.1f; + + this->unk_184 += this->unk_190 * 0.8f; + + for (i = 0; i < 3; i++) { + temp = __cosf(this->unk_184 + (i * 2.1f)); + this->unk_1C4[i] = this->unk_166 + (temp * this->unk_194 * 2.0f); + } + + temp = __cosf(this->unk_184 + 0.4f); + this->unk_164 = (this->unk_194 * temp * 2.0f) * 0.6f; + } + + sp130 = this->unk_1AC.x - this->actor.world.pos.x; + sp12C = this->unk_1AC.y - this->actor.world.pos.y; + sp128 = this->unk_1AC.z - this->actor.world.pos.z; + + spFC = Math_FAtan2F(sp128, sp130); + sp124 = sqrtf(SQ(sp130) + SQ(sp128)); + + spFE = Math_FAtan2F(sp124, sp12C); + sp124 = sqrtf(SQ(sp130) + SQ(sp128) + SQ(sp12C)); + + if ((this->unk_198 != 0) && (this->unk_150 != 2) && (this->unk_150 != 3) && (this->unk_150 != 4)) { + if (this->unk_154 & 0x40) { + spFC += 0x4000; + } else { + spFC -= 0x4000; + } + if ((this->unk_154 + 0x20) & 0x40) { + spFE += 0x2000; + } else { + spFE -= 0x2000; + } + } + + switch (this->unk_150) { + case 100: + EnFishing_HandleAquariumDialog(this, globalCtx); + + this->actor.uncullZoneForward = 500.0f; + this->actor.uncullZoneScale = 300.0f; + + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y + 20.0f, + this->actor.world.pos.z - 50.0f, 255, 255, 255, 255); + + this->unk_1A4 = D_809171CC; + sp100.y = Math_SinS(globalCtx->gameplayFrames * 300); + sp100.z = Math_SinS(globalCtx->gameplayFrames * 230) * 2.0f; + this->actor.world.pos.x = 130.0f; + this->actor.world.pos.y = 55.0f + sp100.y; + this->actor.world.pos.z = 1300.0f + sp100.z; + this->actor.shape.rot.y = -0x8000; + + if ((this->actor.projectedPos.z < 200.0f) && (this->actor.projectedPos.z > 0.0f)) { + spC4.x = randPlusMinusPoint5Scaled(5.0f) + 130.0f; + spC4.y = 40.0f; + spC4.z = randPlusMinusPoint5Scaled(5.0f) + 1280.0f; + EnFishing_SpawnBubble(NULL, globalCtx->specialEffects, &spC4, Rand_ZeroFloat(0.02f) + 0.03f, 1); + } + + Math_ApproachS(&this->unk_16A, (Math_SinS(this->unk_154 * 0x800) * 2500.0f) + 2500.0f, 2, 0x7D0); + Math_ApproachS(&this->unk_16C, Math_SinS(this->unk_154 * 0xA00) * 1500.0f, 2, 0x7D0); + + this->unk_188 = 0.3f; + this->unk_18C = 333.33334f; + return; + + case 10: + this->unk_1AC = this->actor.home.pos; + + Math_ApproachF(&this->actor.speedXZ, 2.0f, 1.0f, 0.5f); + Math_ApproachF(&this->unk_1A8, 4096.0f, 1.0f, 256.0f); + + if (sp124 < 40.0f) { + this->unk_150 = 11; + this->unk_188 = 0.4f; + this->unk_18C = 500.0f; + } + + func_809038A4(this, input); + + if (this->actor.xzDistToPlayer < (250.0f * sp118)) { + this->unk_152 = this->unk_150 = 0; + this->unk_19C = 1000; + this->unk_19A = 200; + this->unk_172[1] = 50; + } + break; + + case 11: + this->unk_1AC = this->actor.home.pos; + + Math_ApproachF(&this->actor.speedXZ, 0.0f, 1.0f, 0.05f); + Math_ApproachF(&this->unk_1A8, 0.0f, 1.0f, 256.0f); + + if (sp124 >= 40.0f) { + this->unk_150 = 10; + this->unk_188 = 1.0f; + this->unk_18C = 2000.0f; + } + func_809038A4(this, input); + + if (this->actor.xzDistToPlayer < (250.0f * sp118)) { + this->unk_152 = this->unk_150 = 0; + this->unk_19C = 1000; + this->unk_19A = 200; + this->unk_172[1] = 50; + } + + if (!Message_GetState(&globalCtx->msgCtx)) { + if ((gSaveContext.time >= 0xC000) && (gSaveContext.time <= 0xC01B)) { + this->unk_150 = 7; + this->unk_172[3] = Rand_ZeroFloat(150.0f) + 200.0f; + } + if ((gSaveContext.time >= 0x3AAA) && (gSaveContext.time <= 0x3AC5)) { + this->unk_150 = 7; + this->unk_172[3] = Rand_ZeroFloat(150.0f) + 200.0f; + } + } + break; + + case 0: + Math_ApproachF(&this->actor.speedXZ, 1.0f, 1.0f, 0.05f); + Math_ApproachF(&this->unk_1A8, 0.0f, 1.0f, 256.0f); + + if (this->unk_172[0] == 0) { + if (this->unk_19C == 0) { + this->unk_150 = this->unk_152 = 10; + } else { + this->unk_150 = 1; + this->unk_172[0] = Rand_ZeroFloat(30.0f) + 10.0f; + this->unk_1AC.x = randPlusMinusPoint5Scaled(300.0f); + this->unk_1AC.y = (WATER_SURFACE_Y(globalCtx) - 50.0f) - Rand_ZeroFloat(50.0f); + this->unk_1AC.z = randPlusMinusPoint5Scaled(300.0f); + this->unk_188 = 1.0f; + this->unk_18C = 2000.0f; + } + } + + if (D_80917206 == 2) { + func_809038A4(this, input); + } else { + this->actor.flags &= ~1; + } + break; + + case 1: + if (this->unk_148 == 1) { + this->unk_150 = -1; + this->unk_19C = 20000; + this->unk_19A = 20000; + this->unk_1AC.x = 0.0f; + this->unk_1AC.y = -140.0f; + this->unk_1AC.z = 0.0f; + } else { + Math_ApproachF(&this->unk_1A8, 4096.0f, 1.0f, 256.0f); + + if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_172[1] != 0)) { + Math_ApproachF(&this->unk_1A8, 8192.0f, 1.0f, 768.0f); + Math_ApproachF(&this->actor.speedXZ, 4.2f, 1.0f, 0.75); + this->unk_188 = 1.2f; + this->unk_18C = 4000.0f; + this->unk_172[0] = 20; + } else { + this->unk_188 = 1.0f; + this->unk_18C = 2000.0f; + Math_ApproachF(&this->actor.speedXZ, 1.5f, 1.0f, 0.1f); + } + + if ((this->unk_172[0] == 0) || (sp124 < 50.0f)) { + this->unk_150 = 0; + this->unk_172[0] = Rand_ZeroFloat(30.0f) + 3.0f; + this->unk_188 = 1.0f; + this->unk_18C = 500.0f; + } + + if (D_80917206 == 2) { + func_809038A4(this, input); + } else { + this->actor.flags &= ~1; + } + } + break; + + case -1: + Math_ApproachS(&this->unk_15E, 0, 0x14, 0x20); + + if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_172[1] != 0)) { + Math_ApproachF(&this->actor.speedXZ, 3.0f, 1.0f, 0.75); + this->unk_188 = 1.0f; + this->unk_172[0] = 20; + this->unk_18C = 4000.0f; + Math_ApproachF(&this->unk_1A8, 4096.0f, 1.0f, 256.0f); + + if ((globalCtx->gameplayFrames % 32) == 0) { + this->unk_1AC.x = randPlusMinusPoint5Scaled(600.0f); + this->unk_1AC.z = randPlusMinusPoint5Scaled(600.0f); + this->unk_1AC.y = -120.0f; + } + } else if (sp124 > 50.0f) { + this->unk_188 = 0.8f; + this->unk_18C = 1500.0f; + Math_ApproachF(&this->actor.speedXZ, 1.0f, 1.0f, 0.1f); + Math_ApproachF(&this->unk_1A8, 2048.0f, 1.0f, 128.0f); + } else { + this->unk_188 = 0.4f; + this->unk_18C = 500.0f; + Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.02f); + Math_ApproachF(&this->unk_1A8, 0.0f, 1.0f, 256.0f); + } + + if (this->unk_19C == 0) { + this->unk_150 = 10; + this->unk_152 = 10; + } else if (((this->unk_19C & 0x7FF) == 0) && (this->unk_19C < 15000)) { + this->unk_150 = -2; + this->actor.world.rot.x = this->actor.shape.rot.x = 0; + this->unk_1AC.y = WATER_SURFACE_Y(globalCtx) + 10.0f; + this->unk_1AC.x = Rand_ZeroFloat(50.0f); + this->unk_1AC.z = Rand_ZeroFloat(50.0f); + } + + this->actor.flags &= ~1; + break; + + case -2: + if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_172[1] != 0)) { + this->unk_150 = -1; + this->unk_1AC.y = -120.0f; + } else { + this->unk_188 = 0.6f; + this->unk_18C = 1000.0f; + + Math_ApproachS(&this->unk_15E, -0x1000, 0x14, 0x100); + + if (this->actor.world.pos.y < (WATER_SURFACE_Y(globalCtx) - 20.0f)) { + Math_ApproachF(&this->actor.speedXZ, 0.5f, 1.0f, 0.1f); + } else { + Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.01f); + + if ((this->actor.speedXZ == 0.0f) || + (this->actor.world.pos.y > (WATER_SURFACE_Y(globalCtx) - 5.0f))) { + this->unk_1AC.x = Rand_ZeroFloat(300.0f); + this->unk_1AC.z = Rand_ZeroFloat(300.0f); + this->unk_1AC.y = this->actor.floorHeight + 10.0f; + this->unk_150 = -25; + this->unk_1A8 = 0.0f; + + spB8 = this->fishMouthPos; + spB8.y = WATER_SURFACE_Y(globalCtx); + EnFishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &spB8, 10.0f, + 300.0f, 150, 90); + EnFishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &spB8, 30.0f, + 400.0f, 150, 90); + + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_CATCH_BOOMERANG); + break; + } + } + + Math_ApproachF(&this->unk_1A8, 2048.0f, 1.0f, 128.0f); + this->actor.flags &= ~1; + } + break; + + case -25: + if ((this->actor.xzDistToPlayer < (250.0f * sp118)) || (this->unk_172[1] != 0)) { + this->unk_150 = -1; + this->unk_1AC.y = -120.0f; + } else { + Math_ApproachS(&this->unk_15E, 0x1000, 0x14, 0x6A); + + if (sp124 > 40.0f) { + this->unk_188 = 0.7f; + this->unk_18C = 1200.0f; + Math_ApproachF(&this->actor.speedXZ, 0.5f, 1.0f, 0.01f); + Math_ApproachF(&this->unk_1A8, 2048.0f, 1.0f, 128.0f); + } else { + this->unk_150 = -1; + } + } + break; + + case 2: + if ((this->actor.params + D_80917268) & 1) { + sp10C.x = 10.0f; + } else { + sp10C.x = -10.0f; + } + sp10C.y = 0.0f; + sp10C.z = 0.0f; + Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp10C, &sp100); + + this->unk_1AC.x = sLurePos.x + sp100.x; + this->unk_1AC.z = sLurePos.z + sp100.z; + + if (D_80917206 == 2) { + this->unk_1AC.y = sLurePos.y; + } else if (this->unk_148 == 0) { + this->unk_1AC.y = sLurePos.y - 15.0f; + } else { + this->unk_1AC.y = sLurePos.y - 5.0f; + } + + if (this->unk_1AC.y <= this->actor.floorHeight) { + this->unk_1AC.y = this->actor.floorHeight + 3.0f; + } + + if ((D_80917206 != 2) && (this->unk_1AC.y < this->actor.world.pos.y)) { + Math_ApproachF(&this->actor.world.pos.y, this->unk_1AC.y, 0.1f, + (this->actor.world.pos.y - this->unk_1AC.y) * 0.1f); + } + + Math_ApproachF(&this->unk_1A8, 8192.0f, 1.0f, 384.0f); + if (CHECK_BTN_ALL(input->press.button, BTN_A)) { + this->unk_1A0 += 0.005f; + } + + if (D_80917270 != 0) { + if (D_80917270 == 1) { + this->unk_1A0 += 0.01f; + } else { + this->unk_1A0 += 0.05f; + } + D_80917270 = 0; + } + + if (CHECK_BTN_ALL(input->press.button, BTN_B)) { + this->unk_1A0 += 0.008f; + } + + if (sp124 < ((this->unk_1A4 * 0.5f) + 20.0f)) { + if (this->unk_156 == 0) { + this->unk_188 = 1.0f; + this->unk_18C = 500.0f; + this->unk_172[0] = Rand_ZeroFloat(10.0f) + 2.0f; + } + Math_ApproachF(&this->actor.speedXZ, -0.2f, 1.0f, 0.1f); + this->unk_156 = 1; + } else { + if (this->unk_156 != 0) { + this->unk_188 = 1.0f; + this->unk_1A8 = 0.0f; + this->unk_18C = 3000.0f; + } + Math_ApproachF(&this->actor.speedXZ, 3.0f, 1.0f, 0.15f); + this->unk_156 = 0; + } + + if (this->unk_1A4 >= 60.0f) { + multiplier = 0.3f; + } else if (this->unk_1A4 >= 45.0f) { + multiplier = 0.6f; + } else { + multiplier = 1.0f; + } + + if ((gSaveContext.time >= 0xB555) && (gSaveContext.time <= 0xCAAA)) { + multiplier *= 1.75f; + } else if ((gSaveContext.time >= 0x3555) && (gSaveContext.time <= 0x4AAA)) { + multiplier *= 1.5f; + } else if (D_809171CA != 0) { + multiplier *= 1.5f; + } else if ((u8)D_8090CCD0 != 0) { + multiplier *= 3.0f; + } + + sp11C = 0.03f * multiplier; + if (D_80917206 == 2) { + sp11C *= 5.0f; + } + + if (((this->unk_172[0] == 1) || (Rand_ZeroOne() < sp11C)) && + (Rand_ZeroOne() < (this->unk_1A0 * multiplier))) { + if (this->unk_148 == 0) { + this->unk_150 = 3; + this->unk_188 = 1.2f; + this->unk_18C = 5000.0f; + this->unk_172[0] = Rand_ZeroFloat(10.0f); + } else { + this->unk_150 = -3; + this->unk_188 = 1.0f; + this->unk_18C = 3000.0f; + this->unk_172[0] = 40; + } + if (D_80917206 == 2) { + this->unk_180 = Rand_ZeroFloat(1.5f) + 3.0f; + } else { + this->unk_180 = Rand_ZeroFloat(1.5f) + 4.5f; + } + } + + if ((D_8090CD14 != 3) || (this->unk_172[2] == 0) || + (sqrtf(SQ(this->actor.world.pos.x) + SQ(this->actor.world.pos.z)) > 800.0f)) { + this->unk_150 = this->unk_152; + this->unk_172[1] = Rand_ZeroFloat(30.0f) + 50.0f; + this->unk_172[0] = Rand_ZeroFloat(10.0f) + 5.0f; + this->unk_188 = 1.0f; + this->unk_1A8 = 0.0f; + this->unk_18C = 2000.0f; + } + + if (this->actor.xzDistToPlayer < (100.0f * sp118)) { + this->unk_152 = this->unk_150 = 0; + this->unk_19C = 1000; + this->unk_19A = 200; + this->unk_172[1] = 50; + } + break; + + case 3: + this->unk_149 = 6; + sp134 = 2; + + if (((s16)player->actor.world.pos.x + D_80917268) & 1) { + sp10C.x = 30.0f; + } else { + sp10C.x = -30.0f; + } + sp10C.y = 0.0f; + sp10C.z = 30.0f; + + Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp10C, &sp100); + + this->unk_1AC.x = sLurePos.x + sp100.x; + this->unk_1AC.z = sLurePos.z + sp100.z; + this->unk_1AC.y = sLurePos.y - 10.0f; + this->unk_1A8 = 4096.0f; + Math_ApproachF(&this->actor.speedXZ, this->unk_180 * 0.8f, 1.0f, 1.0f); + + if ((D_8090CD14 != 3) || (sLurePos.y > (WATER_SURFACE_Y(globalCtx) + 5.0f)) || + (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { + this->unk_150 = this->unk_152; + this->unk_172[0] = 0; + this->unk_188 = 1.0f; + this->unk_18C = 2000.0f; + } else if ((this->unk_172[0] == 0) || (sp124 < 30.0f)) { + this->unk_150 = 4; + this->unk_1AC = sLurePos; + this->unk_1A8 = 16384.0f; + this->unk_188 = 1.2f; + this->unk_18C = 5000.0f; + this->unk_172[0] = 20; + } + break; + + case 4: + Math_ApproachF(&this->unk_1A8, 16384.0f, 1.0f, 4096.0f); + Math_ApproachS(&this->unk_168, 0x4E20, 4, 0x1388); + + this->unk_149 = 50; + sp134 = 2; + this->unk_1AC = sLurePos; + Math_ApproachF(&this->actor.speedXZ, this->unk_180, 1.0f, 1.0f); + + if ((D_8090CD14 != 3) || (this->unk_172[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(globalCtx) + 5.0f)) || + (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { + + this->unk_172[0] = 0; + this->unk_150 = this->unk_152; + this->unk_188 = 1.0f; + this->unk_18C = 2000.0f; + } else if (sp124 < 10.0f) { + if (func_809033F0(this, globalCtx, false)) { + func_80903C60(this, 0); + } + + this->unk_150 = 5; + this->unk_188 = 1.2f; + this->unk_18C = 5000.0f; + this->unk_172[1] = 150; + this->unk_172[0] = 0; + this->unk_172[2] = 0; + this->unk_172[3] = 120; + + D_8090CD14 = 4; + sFishingHookedFish = this; + sFishMouthOffset.y = 500.0f - Rand_ZeroFloat(400.0f); + + if (D_80917206 == 2) { + if (this->unk_1A4 > 70.0f) { + phi_v0 = Rand_ZeroFloat(20.0f) + 10.0f; + } else if (this->unk_1A4 > 60.0f) { + phi_v0 = Rand_ZeroFloat(30.0f) + 20.0f; + } else if (this->unk_1A4 > 50.0f) { + phi_v0 = Rand_ZeroFloat(30.0f) + 30.0f; + } else { + phi_v0 = Rand_ZeroFloat(40.0f) + 40.0f; + } + D_80917272 = phi_v0; + D_809171F4 = phi_v0; + func_8013EC44(0.0f, 60, phi_v0 * 3, 10); + } else { + if (this->unk_1A4 > 70.0f) { + phi_v0 = Rand_ZeroFloat(5.0f) + 10.0f; + } else if (this->unk_1A4 > 60.0f) { + phi_v0 = Rand_ZeroFloat(5.0f) + 15.0f; + } else if (this->unk_1A4 > 50.0f) { + phi_v0 = Rand_ZeroFloat(5.0f) + 17.0f; + } else { + phi_v0 = Rand_ZeroFloat(5.0f) + 25.0f; + } + D_80917272 = phi_v0; + D_809171F4 = phi_v0; + func_8013EC44(0.0f, 180, phi_v0 * 3, 10); + } + + D_80917274 = 0; + D_80917266 = 100; + D_809171D4 = 0; + } + break; + + case -3: + this->unk_149 = 50; + this->unk_1AC = sLurePos; + Math_ApproachF(&this->actor.speedXZ, 2.0f, 1.0f, 1.0f); + + if ((D_8090CD14 != 3) || (this->unk_172[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(globalCtx) + 5.0f)) || + (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { + + this->unk_172[0] = 0; + this->unk_188 = 1.0f; + this->unk_150 = this->unk_152; + this->unk_18C = 2000.0f; + } else if (sp124 < 10.0f) { + if (sLurePos.y > (WATER_SURFACE_Y(globalCtx) - 10.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_JUMP_OUT_WATER); + play_sound(NA_SE_PL_CATCH_BOOMERANG); + } + + func_809033F0(this, globalCtx, false); + this->unk_150 = 5; + this->unk_188 = 1.2f; + this->unk_18C = 5000.0f; + this->unk_172[1] = 150; + this->unk_172[0] = 0; + this->unk_172[2] = 0; + this->unk_172[3] = 120; + + D_8090CD14 = 4; + sFishingHookedFish = this; + + if (D_80917206 == 2) { + D_80917272 = 30; + D_809171F4 = 100; + func_8013EC44(0.0f, 60, 90, 10); + } else { + D_80917272 = 30; + D_809171F4 = 40; + func_8013EC44(0.0f, 180, 90, 10); + } + + D_80917274 = 0; + D_80917266 = 100; + D_809171D4 = 0; + } + break; + + case 5: + this->actor.uncullZoneForward = 1200.0f; + this->actor.uncullZoneScale = 200.0f; + + D_809171D4++; + + Math_ApproachS(&this->unk_168, 0x2AF8, 4, 0xBB8); + sFishingHookedFish = this; + Math_ApproachS(&player->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 5, 0x500); + + if (D_80917274 == 0) { + if ((D_80911F20 < 20) && ((D_809171FE & 3) == 0)) { + D_80911F20++; + } + } + + if ((D_80917272 != 0) && (D_80917274 == 0)) { + if (((input->rel.stick_y < -50) && (D_8090CD48 > -40)) || CHECK_BTN_ALL(input->press.button, BTN_A)) { + if (input->rel.stick_y < -50) { + temp_f0 = 40.0f - ((this->unk_1A4 - 30.0f) * 1.333333f); + if (temp_f0 > 0.0f) { + this->unk_14A = temp_f0; + this->unk_14C = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + this->unk_14E = 1; + } + } + + this->unk_190 = 1.7f; + this->unk_194 = 7000.0f; + D_80917274 = 1; + Audio_QueueSeqCmd(0x881A); // Changed from 0x81A in OoT + D_809171F6 = 0; + + if (this->unk_148 == 1) { + spA4 = (this->unk_1A4 * 3.0f) + 120.0f; + } else { + spA4 = (2.0f * this->unk_1A4) + 120.0f; + } + if (spA4 > 255.0f) { + spA4 = 255.0f; + } + + func_8013EC44(0.0f, spA4, 120, 5); + D_809171F4 = 40; + D_80911E28 = 10; + play_sound(NA_SE_IT_FISHING_HIT); + } + } + + if (this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) { + if (this->unk_172[1] > 30) { + phi_v0_2 = 7; + } else { + phi_v0_2 = 0xF; + } + + if (((this->unk_154 & phi_v0_2) == 0) && (Rand_ZeroOne() < 0.75f) && (D_809171F4 == 0)) { + if (this->unk_1A4 >= 70.0f) { + spA4 = 255.0f; + } else if (this->unk_1A4 >= 60.0f) { + spA4 = 230.0f; + } else if (this->unk_1A4 >= 50.0f) { + spA4 = 200.0f; + } else if (this->unk_1A4 >= 40.0f) { + spA4 = 170.0f; + } else { + spA4 = 140.0f; + } + + if (phi_v0_2 == 0xF) { + spA4 *= 3.0f / 4.0f; + } + + func_8013EC44(0.0f, spA4, Rand_ZeroFloat(5.0f) + 10.0f, 5); + } + + if (this->unk_172[1] > 30) { + if (this->unk_172[0] == 0) { + u16 spA2; + + sp10C.x = 0.0f; + sp10C.y = 0.0f; + sp10C.z = 200.0f; + + for (spA2 = 0; spA2 < 100; spA2++) { + + Matrix_InsertYRotation_f(randPlusMinusPoint5Scaled(2.3561945f) + + (((this->actor.yawTowardsPlayer + 0x8000) / 32768.0f) * M_PI), + MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp10C, &sp100); + + this->unk_1AC.x = this->actor.world.pos.x + sp100.x; + this->unk_1AC.z = this->actor.world.pos.z + sp100.z; + + if ((SQ(this->unk_1AC.x) + SQ(this->unk_1AC.z)) < SQ(750.0f)) { + break; + } + } + + if ((Rand_ZeroOne() < 0.1f) && (this->unk_172[3] == 0)) { + u8 phi_a1; + + if (this->unk_1A4 >= 60.0f) { + phi_a1 = 255; + } else if (this->unk_1A4 >= 50.0f) { + phi_a1 = 200; + } else { + phi_a1 = 180; + } + func_8013EC44(0.0f, phi_a1, 90, 2); + this->unk_172[0] = 20; + this->unk_172[1] = 100; + this->unk_172[2] = 20; + this->unk_172[3] = 100; + this->unk_1AC.y = 300.0f; + D_809171F4 = 0x28; + D_80917266 = Rand_ZeroFloat(30.0f) + 20.0f; + } else { + this->unk_172[0] = Rand_ZeroFloat(10.0f) + 3.0f; + this->unk_172[2] = 0; + this->unk_1AC.y = -70.0f - Rand_ZeroFloat(150.0f); + } + } + + if (this->unk_172[2] != 0) { + D_8091726C = 0.0f; + this->unk_188 = 1.6f; + this->unk_18C = 6000.0f; + Math_ApproachF(&this->actor.speedXZ, 7.5f, 1.0f, 1.0f); + Math_ApproachS(&this->unk_168, 0x4E20, 2, 0xFA0); + } else { + if ((D_80917274 == 0) && (D_80917206 == 2)) { + this->unk_188 = 1.0f; + this->unk_18C = 2000.0f; + Math_ApproachF(&this->actor.speedXZ, 3.0f, 1.0f, 0.2f); + } else { + this->unk_188 = 1.4f; + this->unk_18C = 5000.0f; + Math_ApproachF(&this->actor.speedXZ, 5.0f, 1.0f, 0.5f); + } + + if (this->unk_148 == 0) { + D_8091726C = 1.0f - (this->unk_1A4 * 0.00899f); + } else { + D_8091726C = 1.0f - (this->unk_1A4 * 0.00899f * 1.4f); + } + } + } else { + if (((this->unk_172[1] & 0xF) == 0) && CHECK_BTN_ALL(input->cur.button, BTN_A) && + (!(this->unk_1A4 >= 60.0f) || (D_809171D4 >= 2000))) { + this->unk_14A = Rand_ZeroFloat(30.0f) + 15.0f; + this->unk_14C = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + } + + this->unk_188 = 1.0f; + this->unk_18C = 4500.0f; + + if (this->unk_148 == 0) { + D_8091726C = 1.3f - (this->unk_1A4 * 0.00899f); + } else { + D_8091726C = 1.3f - (this->unk_1A4 * 0.00899f * 1.4f); + } + + Math_ApproachF(&this->actor.speedXZ, 2.0f, 1.0f, 0.5f); + + if (this->unk_172[1] == 0) { + this->unk_14A = 0; + + if (D_809171D4 < 2000) { + this->unk_172[1] = Rand_ZeroFloat(50.0f) + 50.0f; + } else if (D_809171D4 < 3000) { + this->unk_172[1] = Rand_ZeroFloat(20.0f) + 30.0f; + } else { + this->unk_172[1] = Rand_ZeroFloat(10.0f) + 25.0f; + } + } + } + } + + if (D_809171C8 != 0) { + D_8091726C = 0.0f; + } + + if (D_80917274 || (D_80917206 != 2)) { + if (this->actor.speedXZ < 3.0f) { + if (D_809171FE & 8) { + sp100.x = -0.8f; + } else { + sp100.x = -0.75f; + } + } else if (D_809171FE & 4) { + sp100.x = -0.9f; + } else { + sp100.x = -0.85f; + } + + Math_ApproachF(&D_8090CD40, 35.0f, 0.1f, 3.5f); + Math_ApproachF(&D_8090CD3C, sp100.x, 0.3f, 0.1f); + } + + sReelLinePos[LINE_SEG_COUNT - 1] = this->fishMouthPos; + sp10C.x = sReelLinePos[LINE_SEG_COUNT - 1].x - sReelLinePos[LINE_SEG_COUNT - 2].x; + sp10C.y = sReelLinePos[LINE_SEG_COUNT - 1].y - sReelLinePos[LINE_SEG_COUNT - 2].y; + sp10C.z = sReelLinePos[LINE_SEG_COUNT - 1].z - sReelLinePos[LINE_SEG_COUNT - 2].z; + + if ((SQ(sp10C.x) + SQ(sp10C.y) + SQ(sp10C.z)) > SQ(20.0f)) { + Math_ApproachF(&this->actor.world.pos.x, sReelLinePos[LINE_SEG_COUNT - 2].x, 0.2f, + 2.0f * (this->actor.speedXZ * 1.5f)); + Math_ApproachF(&this->actor.world.pos.y, sReelLinePos[LINE_SEG_COUNT - 2].y, 0.2f, + 2.0f * (this->actor.speedXZ * 1.5f) * 5.0f * 0.1f); + Math_ApproachF(&this->actor.world.pos.z, sReelLinePos[LINE_SEG_COUNT - 2].z, 0.2f, + 2.0f * (this->actor.speedXZ * 1.5f)); + } + + if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (input->rel.stick_y < -30)) { + if (D_80917266 < 100) { + D_80917266++; + } + } else { + if (D_80917266 != 0) { + D_80917266--; + } + } + + if ((D_8090CD14 < 3) || ((D_809171C8 != 0) && (D_809171D4 > 50)) || (D_809171D4 >= 6000) || + ((D_80917272 == 0) && (D_80917274 == 0)) || (D_80917266 == 0) || + (((D_809171FE & 0x7F) == 0) && (Rand_ZeroOne() < 0.05f) && (D_80917206 != 2))) { + // Assignment of OoT's D_80B7A67C here removed in MM + + if ((D_80917272 == 0) && (D_80917274 == 0)) { + // Assignment of OoT's D_80B7E086 here removed in MM + if (((sLinkAge == 1) && (gSaveContext.roomInf[127][2] & 0x400)) || + ((sLinkAge != 1) && (gSaveContext.roomInf[127][2] & 0x800))) { + // Assignment of OoT's D_80B7A67C here removed in MM, this is now an empty branch + } + } else { + // Assignment of OoT's D_80B7E086 here removed in MM + func_8013EC44(0.0f, 1, 3, 1); + Audio_QueueSeqCmd(0x100A00FF); + } + + this->unk_150 = this->unk_152 = 0; + this->unk_19C = 10000; + this->unk_19A = 500; + this->unk_172[1] = 50; + this->unk_172[0] = 0; + this->unk_188 = 1.0f; + this->unk_18C = 3000.0f; + + if (D_8090CD14 == 4) { + D_8090CD14 = 3; + } + + D_809171F6 = 50; + D_8091726C = 0.5f; + this->unk_14A = 0; + } else if (this->actor.xzDistToPlayer < 50.0f) { + this->unk_150 = 6; + this->unk_172[0] = 100; + player->unk_B28 = 3; + func_8013EC44(0.0f, 1, 3, 1); + D_809171D8++; + func_800EA0D4(globalCtx, &globalCtx->csCtx); + D_8090CD4C = 100; + D_80911F48 = 45.0f; + D_8090CD14 = 5; + this->unk_188 = 1.0f; + this->unk_18C = 500.0f; + this->unk_194 = 5000.0f; + + if (this->actor.world.pos.y <= WATER_SURFACE_Y(globalCtx)) { + func_80903C60(this, 1); + func_809033F0(this, globalCtx, true); + } + goto case_6; + } + break; + + case_6: + case 6: + Math_ApproachS(&this->unk_168, 0x2AF8, 2, 0xFA0); + Math_ApproachF(&D_80911F48, 15.0f, 0.05f, 0.75f); + + sp10C.x = D_80911F48; + if (sLinkAge != 1) { + sp10C.y = 30.0f; + sp10C.z = 55.0f; + } else { + sp10C.y = 10.0f; + sp10C.z = 50.0f; + } + Matrix_InsertYRotation_f((player->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp10C, &sCameraEye); + + sCameraEye.x += player->actor.world.pos.x; + sCameraEye.y += player->actor.world.pos.y; + sCameraEye.z += player->actor.world.pos.z; + + sCameraAt = player->actor.world.pos; + if (sLinkAge != 1) { + sCameraAt.y += 40.0f; + } else { + sCameraAt.y += 25.0f; + } + + if (this->unk_172[0] == 90) { + Audio_QueueSeqCmd(0x8924); // changed from 0x924 in OoT + D_8090CCFC = 40; + + if (this->unk_148 == 0) { + D_8090CCF8 = this->unk_1A4; + + if (D_8090CCF8 >= 75) { + D_809171DA = 0x409F; + } else if (D_8090CCF8 >= 50) { + D_809171DA = 0x4091; + } else { + D_809171DA = 0x4083; + } + } else { + D_8090CCF8 = 2.0f * this->unk_1A4; + D_809171DA = 0x4099; + } + + this->unk_1CD = 0; + } + + this->unk_158 = -0x4000; + this->actor.shape.rot.y = player->actor.shape.rot.y + 0x5000; + this->actor.shape.rot.x = this->actor.shape.rot.z = this->unk_15A = this->unk_15C = this->unk_166 = 0; + + sp10C.x = 4.0f; + sp10C.y = -10.0f; + sp10C.z = 5.0f; + Matrix_MultiplyVector3fByState(&sp10C, &sp100); + Math_ApproachF(&this->actor.world.pos.x, player->bodyPartsPos[15].x + sp100.x, 1.0f, 6.0f); + Math_ApproachF(&this->actor.world.pos.y, player->bodyPartsPos[15].y + sp100.y, 1.0f, 6.0f); + Math_ApproachF(&this->actor.world.pos.z, player->bodyPartsPos[15].z + sp100.z, 1.0f, 6.0f); + + D_809101C0 = 188.0f; + + if (this->unk_172[0] <= 50) { + switch (this->unk_1CD) { + case 0: + if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { + if (func_80147624(globalCtx)) { + func_801477B4(globalCtx); + if (globalCtx->msgCtx.choiceIndex == 0) { + if (D_8090CCF0 == 0.0f) { + D_8090CCF0 = this->unk_1A4; + D_809171D0 = this->unk_148; + D_809171D2 = D_80917206; + Actor_MarkForDeath(&this->actor); + } else if ((this->unk_148 == 0) && (D_809171D0 == 0) && + ((s16)this->unk_1A4 < (s16)D_8090CCF0)) { + this->unk_1CD = 1; + this->unk_172[0] = 0x3C; + func_801518B0(globalCtx, 0x4098, NULL); + } else { + f32 temp1 = D_8090CCF0; + s16 temp2 = D_809171D0; + D_8090CCF0 = this->unk_1A4; + D_809171D0 = this->unk_148; + D_809171D2 = D_80917206; + this->unk_1A4 = temp1; + this->unk_148 = temp2; + } + } + if (this->unk_1CD == 0) { + D_8090CD14 = 0; + } + } + } + break; + case 1: + if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { + if (func_80147624(globalCtx)) { + func_801477B4(globalCtx); + if (globalCtx->msgCtx.choiceIndex != 0) { + f32 temp1 = D_8090CCF0; + s16 temp2 = D_809171D0; + D_8090CCF0 = this->unk_1A4; + D_809171D2 = D_80917206; + this->unk_1A4 = temp1; + this->unk_148 = temp2; + } + D_8090CD14 = 0; + } + } + break; + } + } + + if (D_8090CD14 == 0) { + if (this->actor.update != NULL) { + this->unk_150 = this->unk_152 = 0; + this->unk_19C = 10000; + this->unk_19A = 500; + this->unk_172[1] = 50; + this->unk_172[0] = 0; + this->unk_188 = 1.0f; + this->unk_18C = 2000.0f; + SkelAnime_Free(&this->skelAnime, globalCtx); + + if (this->unk_148 == 0) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingFishSkel, &gFishingFishAnim, 0, 0, 0); + Animation_MorphToLoop(&this->skelAnime, &gFishingFishAnim, 0.0f); + } else { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFishingLoachSkel, &gFishingLoachAnim, 0, 0, + 0); + Animation_MorphToLoop(&this->skelAnime, &gFishingLoachAnim, 0.0f); + } + } + + D_809101C4 = 520.0f; + D_809101C0 = 195.0f; + Audio_QueueSeqCmd(0x100A00FF); + D_809171F6 = 20; + D_8090CD4C = 3; + } + break; + + case 7: + this->unk_149 = 50; + sp134 = 5; + this->unk_1A8 = 12288.0f; + + if (this->actor.params < 104) { + this->unk_1AC = sGroupFishes[this->actor.params - 100].pos; + D_8090CF18 = 1; + } else if (this->actor.params < 108) { + this->unk_1AC = sGroupFishes[this->actor.params - 100 + 16].pos; + D_8090CF18 = 2; + } else { + this->unk_1AC = sGroupFishes[this->actor.params - 100 + 32].pos; + D_8090CF18 = 3; + } + + Math_ApproachF(&this->actor.speedXZ, 5.0f, 1.0f, 1.0f); + + if (sp124 < 20.0f) { + Math_ApproachS(&this->unk_168, 0x4E20, 2, 0xFA0); + + if ((this->unk_172[2] == 0) && func_809033F0(this, globalCtx, false)) { + func_80903C60(this, Rand_ZeroFloat(1.99f)); + this->unk_172[2] = Rand_ZeroFloat(20.0f) + 20.0f; + } + } + + if (this->unk_172[3] == 0) { + this->unk_150 = 10; + this->unk_152 = 10; + } else { + func_809038A4(this, input); + if (this->actor.xzDistToPlayer < (100.0f * sp118)) { + this->unk_152 = this->unk_150 = 0; + this->unk_19C = 500; + this->unk_19A = 200; + this->unk_172[1] = 50; + } + } + break; + } + + Math_ApproachS(&this->unk_16A, (Math_SinS(this->unk_154 * 0x1000) * 5000.0f) + 5000.0f, 2, 0x7D0); + + if (this->unk_150 != 6) { + if (this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) { + this->unk_188 = 1.5f; + this->unk_18C = 5000.0f; + + Math_ApproachS(&this->unk_166, 0, 5, 0x7D0); + + spF4 = spF0 = spFA = 3; + spF2 = spEE = 0x2000; + + this->unk_172[2] = 0; + this->unk_17C -= 1.0f; + } else { + Math_ApproachZeroF(&this->unk_17C, 1.0f, 2.0f); + if ((this->unk_150 != -1) && (this->unk_150 != -2) && (this->unk_150 != -25)) { + this->unk_15E = 0; + } + + this->unk_160 = this->unk_162 = 0; + spF4 = spF0 = spFA = 4; + spF2 = spEE = 0x2000; + + spF6 = EnFishing_SmoothStepToS(&this->actor.world.rot.y, spFC, sp134, this->unk_1A8) * 3.0f; + Math_ApproachS(&this->actor.world.rot.x, spFE, sp134, this->unk_1A8 * 0.5f); + + if (spF6 > 0x1F40) { + spF6 = 0x1F40; + } else if (spF6 < -0x1F40) { + spF6 = -0x1F40; + } + + if (this->actor.speedXZ >= 3.2f) { + Math_ApproachS(&this->unk_166, spF6, 2, 0x4E20); + } else { + Math_ApproachS(&this->unk_166, spF6, 3, 0xBB8); + } + + Actor_UpdateVelocityWithoutGravity(&this->actor); + } + + Actor_UpdatePos(&this->actor); + + this->actor.world.pos.y += (this->unk_17C * 1.5f); + + if (1) {} + + if (this->unk_14A != 0) { + this->unk_160 = this->unk_14C; + this->unk_14A--; + if (this->unk_14E != 0) { + spF0 = 5; + spEE = 0x4000; + } else { + spF0 = 10; + spEE = 0x800; + } + this->unk_15E = -0x500 - this->actor.shape.rot.x; + spF4 = 5; + spF2 = 0x4000; + } else { + this->unk_14E = 0; + } + + Math_ApproachS(&this->unk_158, this->unk_15E, spF4, spF2); + Math_ApproachS(&this->unk_15A, this->unk_160, spF0, spEE); + Math_ApproachS(&this->unk_15C, this->unk_162, spFA, 0x2000); + + if (this->actor.speedXZ <= 0.5f) { + Math_ApproachS(&this->actor.shape.rot.x, 0, 10, this->unk_170); + Math_ApproachS(&this->unk_170, 0x500, 1, 0x20); + } else { + Math_ApproachS(&this->actor.shape.rot.x, -this->actor.world.rot.x, 10, 0x1000); + this->unk_170 = 0; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + + if ((this->unk_150 != -1) && (this->unk_150 != -2) && (this->unk_150 != -25)) { + if ((this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) && + (this->actor.prevPos.y <= WATER_SURFACE_Y(globalCtx))) { + func_809033F0(this, globalCtx, true); + func_80903C60(this, 1); + this->unk_17C = this->actor.velocity.y; + this->actor.velocity.y = 0.0f; + this->unk_162 = randPlusMinusPoint5Scaled(32768.0f); + } else if ((this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) && + (this->actor.prevPos.y >= WATER_SURFACE_Y(globalCtx))) { + if (this->unk_17C < -5.0f) { + this->unk_17C = -5.0f; + } + this->actor.world.rot.x = -0xFA0; + func_809033F0(this, globalCtx, true); + this->unk_1CA = 20; + func_80903C60(this, 0); + } + } + + if ((this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) && + (this->actor.world.pos.y > (WATER_SURFACE_Y(globalCtx) - 10.0f)) && !(this->unk_154 & 1) && + (this->actor.speedXZ > 0.0f)) { + Vec3f pos = this->actor.world.pos; + + pos.y = WATER_SURFACE_Y(globalCtx); + EnFishing_SpawnRipple(&this->actor.projectedPos, globalCtx->specialEffects, &pos, 80.0f, 500.0f, 150, 90); + } + + if ((this->actor.speedXZ > 0.0f) || (this->unk_150 == 5)) { + f32 velocityY = this->actor.velocity.y; + + spD8 = this->unk_1A4 * 0.1f; + + this->actor.world.pos.y -= spD8; + this->actor.prevPos.y -= spD8; + this->actor.velocity.y = -1.0f; + if (KREG(90) == 0) { // Check added in MM + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 30.0f, 100.0f, 0x45); + } + this->actor.world.pos.y += spD8; + this->actor.prevPos.y += spD8; + + this->actor.velocity.y = velocityY; + + if (this->actor.bgCheckFlags & 8) { + this->unk_198 = 20; + } + + if (this->actor.bgCheckFlags & 1) { + if (this->actor.world.pos.y > WATER_SURFACE_Y(globalCtx)) { + this->unk_17C = Rand_ZeroFloat(3.0f) + 3.0f; + this->actor.velocity.x = this->actor.world.pos.x * -0.003f; + this->actor.velocity.z = this->actor.world.pos.z * -0.003f; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FISH_LEAP); + func_809036BC(this, globalCtx); + + if (Rand_ZeroOne() < 0.5f) { + this->unk_162 = 0x4000; + } else { + this->unk_162 = -0x4000; + } + + if (Rand_ZeroOne() < 0.5f) { + this->unk_15E = 0; + } else { + this->unk_15E = (s16)randPlusMinusPoint5Scaled(32.0f) + 0x8000; + } + + this->unk_160 = (s16)randPlusMinusPoint5Scaled(16384.0f); + this->unk_188 = 1.0f; + this->unk_18C = 5000.0f; + this->unk_194 = 5000.0f; + } else { + this->unk_17C = 0.0f; + + if ((this->unk_150 == 5) && !(this->unk_154 & 1)) { + Vec3f pos; + + pos.x = randPlusMinusPoint5Scaled(10.0f) + this->actor.world.pos.x; + pos.z = randPlusMinusPoint5Scaled(10.0f) + this->actor.world.pos.z; + pos.y = this->actor.floorHeight + 5.0f; + EnFishing_SpawnWaterDust(&this->actor.projectedPos, globalCtx->specialEffects, &pos, + (this->unk_1A4 * 0.005f) + 0.15f); + } + } + } + } + } + + if (this->unk_1CA != 0) { + s16 i; + Vec3f pos; + f32 range = (this->unk_1A4 * 0.075f) + 10.0f; + + this->unk_1CA--; + + for (i = 0; i < 2; i++) { + pos.x = randPlusMinusPoint5Scaled(range) + this->actor.world.pos.x; + pos.y = randPlusMinusPoint5Scaled(range) + this->actor.world.pos.y; + pos.z = randPlusMinusPoint5Scaled(range) + this->actor.world.pos.z; + EnFishing_SpawnBubble(&this->actor.projectedPos, globalCtx->specialEffects, &pos, + Rand_ZeroFloat(0.035f) + 0.04f, 0); + } + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateFish.s") +#endif + +s32 EnFishing_FishOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnFishing* this = THIS; + + if (limbIndex == 13) { + rot->z -= this->unk_168 - 11000; + } else if ((limbIndex == 2) || (limbIndex == 3)) { + rot->y += this->unk_164; + } else if (limbIndex == 4) { + rot->y += this->unk_16E; + } else if (limbIndex == 0xE) { + rot->y -= this->unk_16A; + } else if (limbIndex == 0xF) { + rot->y += this->unk_16A; + } else if (limbIndex == 8) { + rot->y += this->unk_16C; + } else if (limbIndex == 9) { + rot->y -= this->unk_16C; + } + + return false; +} + +void EnFishing_FishPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnFishing* this = THIS; + + if (limbIndex == 13) { + Matrix_MultiplyVector3fByState(&sFishMouthOffset, &this->fishMouthPos); + } +} + +s32 EnFishing_LoachOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnFishing* this = THIS; + + if (limbIndex == 3) { + rot->y += this->unk_1C4[0]; + } else if (limbIndex == 4) { + rot->y += this->unk_1C4[1]; + } else if (limbIndex == 5) { + rot->y += this->unk_1C4[2]; + } + + return 0; +} + +void EnFishing_LoachPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f sLoachMouthOffset = { 500.0f, 500.0f, 0.0f }; + EnFishing* this = THIS; + + if (limbIndex == 11) { + Matrix_MultiplyVector3fByState(&sLoachMouthOffset, &this->fishMouthPos); + } +} + +void EnFishing_DrawFish(Actor* thisx, GlobalContext* globalCtx) { + EnFishing* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f(((this->unk_15A + this->actor.shape.rot.y) / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(((this->unk_158 + this->actor.shape.rot.x) / 32768.0f) * M_PI); + Matrix_InsertZRotation_f(((this->unk_15C + this->actor.shape.rot.z) / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + + if (this->unk_148 == 0) { + Matrix_InsertYRotation_f((this->unk_164 * (M_PI / 32768)) - (M_PI / 2), MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, this->unk_164 * 10.0f * 0.01f, MTXMODE_APPLY); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnFishing_FishOverrideLimbDraw, EnFishing_FishPostLimbDraw, + &this->actor); + } else { + Matrix_InsertTranslation(0.0f, 0.0f, 3000.0f, MTXMODE_APPLY); + Matrix_InsertYRotation_f(this->unk_164 * (M_PI / 32768), MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, -3000.0f, MTXMODE_APPLY); + Matrix_InsertYRotation_f(-(M_PI / 2), MTXMODE_APPLY); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnFishing_LoachOverrideLimbDraw, EnFishing_LoachPostLimbDraw, + &this->actor); + } +} + +void EnFishing_HandleReedContact(FishingProp* prop, Vec3f* entityPos) { + f32 dx = prop->pos.x - entityPos->x; + f32 dz = prop->pos.z - entityPos->z; + f32 distXZ = sqrtf(SQ(dx) + SQ(dz)); + + if (distXZ <= 20.0f) { + prop->rotY = Math_Acot2F(dz, dx); + + Math_ApproachF(&prop->rotX, (20.0f - distXZ) * 0.03f, 0.2f, 0.2f); + } +} + +void EnFishing_HandleLilyPadContact(FishingProp* prop, Vec3f* entityPos, u8 fishTimer) { + f32 dx = prop->pos.x - entityPos->x; + f32 dz = prop->pos.z - entityPos->z; + f32 distXZ = sqrtf(SQ(dx) + SQ(dz)); + + if (distXZ <= 40.0f) { + Math_ApproachS(&prop->lilyPadAngle, Math_FAtan2F(dz, dx), 10, 0x300); + } + + if (fishTimer && (distXZ <= 60.0f)) { + f32 heightTarget = 1.0f; + + if (fishTimer >= 21) { + heightTarget = 1.5f; + } + + Math_ApproachF(&prop->lilyPadOffset, heightTarget, 0.1f, 0.2f); + } +} + +void EnFishing_UpdatePondProps(GlobalContext* globalCtx) { + FishingProp* prop = &sPondProps[0]; + Player* player = GET_PLAYER(globalCtx); + Actor* actor; + s16 i; + + for (i = 0; i < POND_PROP_COUNT; i++) { + if (prop->type != FS_PROP_NONE) { + prop->shouldDraw = false; + prop->timer++; + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &prop->pos, &prop->projectedPos, &sProjectedW); + + if ((prop->projectedPos.z < prop->drawDistance) && + (fabsf(prop->projectedPos.x) < (100.0f + prop->projectedPos.z))) { + prop->shouldDraw = true; + } + + if ((prop->projectedPos.z < 500.0f) && (fabsf(prop->projectedPos.x) < (100.0f + prop->projectedPos.z))) { + if (prop->type == FS_PROP_REED) { + EnFishing_HandleReedContact(prop, &player->actor.world.pos); + + actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + while (actor != NULL) { + if (!((actor->id == ACTOR_EN_FISHING) && (actor->params >= 100))) { + actor = actor->next; + } else { + EnFishing_HandleReedContact(prop, &actor->world.pos); + actor = actor->next; + } + } + + Math_ApproachZeroF(&prop->rotX, 0.05f, 0.05f); + } else if (prop->type == FS_PROP_LILY_PAD) { + EnFishing_HandleLilyPadContact(prop, &player->actor.world.pos, 0); + + actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + while (actor != NULL) { + if (!((actor->id == ACTOR_EN_FISHING) && (actor->params >= 100))) { + actor = actor->next; + } else { + EnFishing_HandleLilyPadContact(prop, &actor->world.pos, ((EnFishing*)actor)->unk_149); + actor = actor->next; + } + } + + Math_ApproachS(&prop->lilyPadAngle, 0, 20, 80); + prop->pos.y = + (Math_SinS(prop->timer * 0x1000) * prop->lilyPadOffset) + (WATER_SURFACE_Y(globalCtx) + 2.0f); + Math_ApproachZeroF(&prop->lilyPadOffset, 0.1f, 0.02f); + } + } + } + + prop++; + } + + if (sCameraId == MAIN_CAM) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &sFishingMain->collider.base); + } +} + +void EnFishing_DrawPondProps(GlobalContext* globalCtx) { + u8 flag = 0; + FishingProp* prop = &sPondProps[0]; + s16 i; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + for (i = 0; i < POND_PROP_COUNT; i++) { + if (prop->type == FS_PROP_REED) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gFishingReedSetupDL); + flag++; + } + + if (prop->shouldDraw) { + Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); + Matrix_InsertYRotation_f(prop->rotY, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(prop->rotX); + Matrix_InsertYRotation_f(prop->reedAngle, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingReedVtxDL); + } + } + + prop++; + } + + prop = &sPondProps[0]; + flag = 0; + for (i = 0; i < POND_PROP_COUNT; i++) { + if (prop->type == FS_PROP_WOOD_POST) { + if (flag == 0) { + gSPDisplayList(POLY_OPA_DISP++, gFishingWoodPostSetupDL); + flag++; + } + + if (prop->shouldDraw) { + Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingWoodPostVtxDL); + } + } + + prop++; + } + + prop = &sPondProps[0]; + flag = 0; + for (i = 0; i < POND_PROP_COUNT; i++) { + if (prop->type == FS_PROP_LILY_PAD) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, gFishingLilyPadSetupDL); + flag++; + } + + if (prop->shouldDraw) { + Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Scale(prop->scale, 1.0f, prop->scale, MTXMODE_APPLY); + Matrix_InsertYRotation_f(prop->lilyPadAngle * (M_PI / 32768), MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 20.0f, MTXMODE_APPLY); + Matrix_InsertYRotation_f(prop->rotY, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingLilyPadVtxDL); + } + } + + prop++; + } + + prop = &sPondProps[0]; + flag = 0; + for (i = 0; i < POND_PROP_COUNT; i++) { + if (prop->type == FS_PROP_ROCK) { + if (flag == 0) { + gSPDisplayList(POLY_OPA_DISP++, gFishingRockSetupDL); + flag++; + } + + if (prop->shouldDraw) { + Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); + Matrix_InsertYRotation_f(prop->rotY, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingRockVtxDL); + } + } + + prop++; + } + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { + s16 groupContactFlags = 0; + Player* player = GET_PLAYER(globalCtx); + FishingGroupFish* fish = &sGroupFishes[0]; + f32 dy; + f32 dx; + f32 dist; + f32 dz; + f32 offset; + s16 groupIndex; + s16 groupFlag; + f32 spD8; + s16 spD6; + s16 spD4; + s16 target; + s16 i; + Vec3f basePos[3]; + Vec3f ripplePos; + Vec3f* refPos; + f32 temp1; + f32 temp2; + + if ((D_80917264 != 0) || (D_8090CD14 == 4)) { + refPos = &sLurePos; + } else { + refPos = &player->actor.world.pos; + } + + basePos[0].x = __sinf(sFishGroupAngle1) * 720.0f; + basePos[0].y = -35.0f; + basePos[0].z = __cosf(sFishGroupAngle1) * 720.0f; + + temp1 = refPos->x - basePos[0].x; + temp2 = refPos->z - basePos[0].z; + + if ((SQ(temp1) + SQ(temp2)) < SQ(50.0f)) { + sFishGroupAngle1 += 0.3f; + groupContactFlags |= 1; + } else if (D_8090CF18 != 0) { + sFishGroupAngle1 += 0.05f; + basePos[0].y = WATER_SURFACE_Y(globalCtx) - 5.0f; + } else { + Math_ApproachF(&sFishGroupAngle1, 0.7f, 1.0f, 0.001f); + } + + basePos[1].x = __sinf(sFishGroupAngle2) * 720.0f; + basePos[1].y = -35.0f; + basePos[1].z = __cosf(sFishGroupAngle2) * 720.0f; + + temp1 = refPos->x - basePos[1].x; + temp2 = refPos->z - basePos[1].z; + + if ((SQ(temp1) + SQ(temp2)) < SQ(50.0f)) { + sFishGroupAngle2 -= 0.3f; + groupContactFlags |= 2; + } else if (D_8090CF18 != 0) { + sFishGroupAngle2 -= 0.05f; + basePos[1].y = WATER_SURFACE_Y(globalCtx) - 5.0f; + } else { + Math_ApproachF(&sFishGroupAngle2, 2.3f, 1.0f, 0.001f); + } + + basePos[2].x = __sinf(sFishGroupAngle3) * 720.0f; + basePos[2].y = -35.0f; + basePos[2].z = __cosf(sFishGroupAngle3) * 720.0f; + + temp1 = refPos->x - basePos[2].x; + temp2 = refPos->z - basePos[2].z; + + if ((SQ(temp1) + SQ(temp2)) < SQ(50.0f)) { + sFishGroupAngle3 -= 0.3f; + groupContactFlags |= 4; + } else if (D_8090CF18 != 0) { + sFishGroupAngle3 -= 0.05f; + basePos[2].y = WATER_SURFACE_Y(globalCtx) - 5.0f; + } else { + Math_ApproachF(&sFishGroupAngle3, 4.6f, 1.0f, 0.001f); + } + + if (sLinkAge == 1) { + spD8 = 0.8f; + } else { + spD8 = 1.0f; + } + + for (i = 0; i < GROUP_FISH_COUNT; i++) { + if (fish->type != FS_GROUP_FISH_NONE) { + fish->timer++; + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &fish->pos, &fish->projectedPos, &sProjectedW); + + if ((fish->projectedPos.z < 400.0f) && (fabsf(fish->projectedPos.x) < (100.0f + fish->projectedPos.z))) { + fish->shouldDraw = true; + } else { + fish->shouldDraw = false; + } + + if (i <= 20) { + groupIndex = 0; + groupFlag = 1; + } else if (i <= 40) { + groupIndex = 1; + groupFlag = 2; + } else { + groupIndex = 2; + groupFlag = 4; + } + + dx = fish->unk_10.x - fish->pos.x; + dy = fish->unk_10.y - fish->pos.y; + dz = fish->unk_10.z - fish->pos.z; + spD4 = Math_FAtan2F(dz, dx); + dist = sqrtf(SQ(dx) + SQ(dz)); + spD6 = Math_FAtan2F(dist, dy); + + if ((dist < 10.0f) || (((fish->timer % 32) == 0) && (Rand_ZeroOne() > 0.5f))) { + fish->unk_10.y = basePos[groupIndex].y + randPlusMinusPoint5Scaled(10.0f); + + if (D_8090CF18 != 0) { + fish->unk_10.x = basePos[groupIndex].x + randPlusMinusPoint5Scaled(200.0f); + fish->unk_10.z = basePos[groupIndex].z + randPlusMinusPoint5Scaled(200.0f); + } else { + fish->unk_10.x = basePos[groupIndex].x + randPlusMinusPoint5Scaled(100.0f); + fish->unk_10.z = basePos[groupIndex].z + randPlusMinusPoint5Scaled(100.0f); + } + + ripplePos = fish->pos; + ripplePos.y = WATER_SURFACE_Y(globalCtx); + EnFishing_SpawnRipple(&fish->projectedPos, globalCtx->specialEffects, &ripplePos, 20.0f, + Rand_ZeroFloat(50.0f) + 100.0f, 150, 90); + + if (fish->unk_28 < 1.5f) { + fish->unk_28 = 1.5f; + } + + fish->unk_34 = 1.5f; + fish->unk_38 = 1.0f; + } + + target = EnFishing_SmoothStepToS(&fish->unk_3E, spD4, 5, 0x4000) * 3.0f; + if (target > 0x1F40) { + target = 0x1F40; + } else if (target < -0x1F40) { + target = -0x1F40; + } + + Math_ApproachS(&fish->unk_42, target, 3, 0x1388); + + offset = fish->unk_42 * -0.0001f; + Math_ApproachS(&fish->unk_3C, spD6, 5, 0x4000); + + if (groupContactFlags & groupFlag) { + fish->unk_38 = 1.0f; + fish->unk_28 = 6.0f; + fish->unk_34 = 2.0f; + } + + if (D_8090CF18 != 0) { + fish->unk_38 = 1.0f; + fish->unk_28 = 4.0f; + fish->unk_34 = 2.0f; + } + + Math_ApproachF(&fish->unk_28, 0.75f, 1.0f, 0.05f); + + temp1 = fish->unk_28 * spD8; + temp2 = Math_CosS(fish->unk_3C) * temp1; + + fish->pos.x += temp2 * Math_SinS(fish->unk_3E); + fish->pos.y += temp1 * Math_SinS(fish->unk_3C); + fish->pos.z += temp2 * Math_CosS(fish->unk_3E); + + if (fish->shouldDraw) { + Math_ApproachF(&fish->unk_34, 1.0f, 1.0f, 0.1f); + Math_ApproachF(&fish->unk_38, 0.4f, 1.0f, 0.04f); + fish->unk_30 += fish->unk_34; + fish->unk_2C = (__cosf(fish->unk_30) * fish->unk_38) + offset; + } + } + + fish++; + } + + D_8090CF18 = 0; +} + +void EnFishing_DrawGroupFishes(GlobalContext* globalCtx) { + u8 flag = 0; + FishingGroupFish* fish = &sGroupFishes[0]; + f32 scale; + s16 i; + s32 pad; + + if (sLinkAge == 1) { + scale = 0.003325f; + } else { + scale = 0.00475f; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + for (i = 0; i < GROUP_FISH_COUNT; i++) { + if (fish->type != FS_GROUP_FISH_NONE) { + if (flag == 0) { + gSPDisplayList(POLY_OPA_DISP++, gFishingGroupFishSetupDL); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 155, 155, 155, 255); + flag++; + } + + if (fish->shouldDraw) { + Matrix_InsertTranslation(fish->pos.x, fish->pos.y, fish->pos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f(((f32)fish->unk_3E * M_PI) / 32768.0f, MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis((-(f32)fish->unk_3C * M_PI) / 32768.0f); + Matrix_Scale(fish->unk_2C * scale, scale, scale, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gFishingGroupFishVtxDL); + } + } + fish++; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +static u16 D_8090D638[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; + +void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { + switch (this->unk_154) { + case 0: + if (D_809171FC == 0) { + if (sLinkAge != 1) { + if ((gSaveContext.roomInf[127][2] & 0x100) && !(gSaveContext.roomInf[127][2] & 0x200)) { + this->actor.textId = 0x4093; + } else { + this->actor.textId = 0x407B; + } + } else { + this->actor.textId = 0x407B; + } + } else if (D_8090CD0C == 0) { + this->actor.textId = 0x4084; + } else { + this->actor.textId = 0x4097; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (D_809171FC == 0) { + this->unk_154 = 1; + if (sLinkAge != 1) { + gSaveContext.roomInf[127][2] |= 0x200; + } else { + gSaveContext.roomInf[127][2] |= 0x100; + } + } else { + this->unk_154 = 10; + } + } else { + func_800B8614(&this->actor, globalCtx, 100.0f); + } + break; + + case 1: + if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (gSaveContext.rupees >= 20) { + func_801159EC(-20); + if (func_8013EE04() == 0) { + this->actor.textId = 0x407C; + } else { + this->actor.textId = 0x407D; + } + func_80151938(globalCtx, this->actor.textId); + this->unk_154 = 2; + } else { + func_80151938(globalCtx, 0x407E); + this->unk_154 = 3; + } + break; + case 1: + func_80151938(globalCtx, 0x2D); + this->unk_154 = 3; + break; + } + } + break; + + case 2: + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + func_80151938(globalCtx, 0x407F); + this->unk_154 = 4; + } + break; + + case 3: + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + this->unk_154 = 0; + } + if (Message_GetState(&globalCtx->msgCtx) == 6) { + this->unk_154 = 0; + } + break; + + case 4: + if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + D_8090CCF8 = D_809171CC; + func_80151938(globalCtx, 0x4080); + this->unk_154 = 5; + break; + case 1: + func_80151938(globalCtx, 0x407F); + break; + } + } + break; + + case 5: + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + + globalCtx->interfaceCtx.unk_27E = 1; + globalCtx->startPlayerFishing(globalCtx); + D_809171FC = 1; + D_8090CD04 = 20; + this->unk_154 = 0; + + if ((gSaveContext.roomInf[127][2] & 0xFF0000) < 0xFF0000) { + gSaveContext.roomInf[127][2] += 0x10000; + } + } + break; + + case 10: + if (D_8090CD0C != 0) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_80151938(globalCtx, 0x40B2); + D_8090CD08 = 1; + D_8090CD0C = 0; + this->unk_154 = 20; + break; + case 1: + this->unk_154 = 0; + break; + } + } + } else { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (D_8090CCF0 == 0.0f) { + this->actor.textId = 0x408C; + this->unk_154 = 20; + } else if (D_809171D0 == 0) { + D_8090CCF8 = D_8090CCF0; + if ((s16)D_809171CC < (s16)D_8090CCF0) { + if (D_809171D2 == 2) { + this->actor.textId = 0x40B0; + } else { + this->actor.textId = 0x4086; + } + this->unk_154 = 11; + } else { + this->actor.textId = 0x408B; + this->unk_154 = 20; + } + } else { + this->actor.textId = 0x409B; + this->unk_154 = 11; + } + func_80151938(globalCtx, this->actor.textId); + break; + case 1: + if (D_8090CD00 > 36000) { + D_8090CD00 = 30000; + func_80151938(globalCtx, 0x4088); + } else { + if (D_809171CA == 0) { + if (D_809171D6 == 0) { + D_809171D6++; + } + } + + if ((D_80917206 == 2) && (D_8090D638[D_809171D6] == 0x408D)) { + func_80151938(globalCtx, 0x40AF); + } else { + func_80151938(globalCtx, D_8090D638[D_809171D6]); + } + + D_809171D6++; + + if (sLinkAge != 1) { + if (D_809171D6 >= 6) { + D_809171D6 = 0; + } + } else { + if (D_809171D6 >= 4) { + D_809171D6 = 0; + } + } + } + this->unk_154 = 0; + break; + case 2: + if (D_809171D8 == 0) { + func_80151938(globalCtx, 0x4085); + } else if (sLinkAge == 1) { + func_80151938(globalCtx, 0x4092); + } + this->unk_154 = 22; + break; + } + } + } + break; + + case 11: + if (((Message_GetState(&globalCtx->msgCtx) == 5) || !Message_GetState(&globalCtx->msgCtx)) && + func_80147624(globalCtx)) { + s32 getItemId; + + func_801477B4(globalCtx); + + if (D_809171D0 == 0) { + D_809171CC = D_8090CCF0; + D_8090CCF0 = 0.0f; + + if (sLinkAge == 1) { + f32 temp; + + gSaveContext.roomInf[127][2] &= 0xFFFFFF00; + gSaveContext.roomInf[127][2] |= ((s16)D_809171CC & 0x7F); + + temp = (gSaveContext.roomInf[127][2] & 0x7F000000) >> 0x18; + if (temp < D_809171CC) { + gSaveContext.roomInf[127][2] &= 0xFFFFFF; + gSaveContext.roomInf[127][2] |= ((s16)D_809171CC & 0x7F) << 0x18; + + if (D_809171D2 == 2) { + gSaveContext.roomInf[127][2] |= 0x80000000; + } + } + + if (D_809171D2 == 2) { + gSaveContext.roomInf[127][2] |= 0x80; + this->unk_154 = 0; + break; + } + } else { + gSaveContext.roomInf[127][2] &= 0xFFFFFF; + gSaveContext.roomInf[127][2] |= ((s16)D_809171CC & 0x7F) << 0x18; + + if (D_809171D2 == 2) { + gSaveContext.roomInf[127][2] |= 0x80000000; + this->unk_154 = 0; + break; + } + } + + if (D_809171CC >= 60.0f) { + getItemId = GI_RUPEE_PURPLE; + } else if (D_809171CC >= 50.0f) { + getItemId = GI_RUPEE_10; + } else if (D_809171CC >= 40.0f) { + getItemId = GI_RUPEE_BLUE; + } else { + getItemId = GI_RUPEE_GREEN; + } + + if (sLinkAge == 1) { + if ((D_809171CC >= 50.0f) && !(gSaveContext.roomInf[127][2] & 0x400)) { + gSaveContext.roomInf[127][2] |= 0x400; + getItemId = GI_HEART_PIECE; + sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; + } + } else { + if ((D_809171CC >= 60.0f) && !(gSaveContext.roomInf[127][2] & 0x800)) { + gSaveContext.roomInf[127][2] |= 0x800; + getItemId = GI_SCALE_GOLD; + sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; + } + } + } else { + getItemId = GI_RUPEE_PURPLE; + D_8090CCF0 = 0.0f; + } + + this->actor.parent = NULL; + Actor_PickUp(&this->actor, globalCtx, getItemId, 2000.0f, 1000.0f); + this->unk_154 = 23; + } + break; + + case 20: + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + this->unk_154 = 0; + } + break; + + case 21: + if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + this->unk_154 = 0; + break; + case 1: + if (D_809171D8 == 0) { + func_80151938(globalCtx, 0x4085); + } else if (sLinkAge == 1) { + func_80151938(globalCtx, 0x4092); + } + this->unk_154 = 22; + break; + } + } + break; + + case 22: + if (!Message_GetState(&globalCtx->msgCtx)) { + this->unk_154 = 0; + if (D_8090CD0C != 0) { + D_8090CD08 = 1; + D_8090CD0C = 0; + } + D_809171FC = 0; + globalCtx->interfaceCtx.unk_27E = 0; + } + break; + + case 23: + D_8090CCF4 = false; + if (Actor_HasParent(&this->actor, globalCtx)) { + this->unk_154 = 24; + } else { + Actor_PickUp(&this->actor, globalCtx, GI_SCALE_GOLD, 2000.0f, 1000.0f); + } + break; + + case 24: + D_8090CCF4 = false; + if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if (D_809171D0 == 0) { + this->unk_154 = 0; + } else { + func_801518B0(globalCtx, 0x409C, NULL); + this->unk_154 = 20; + } + } + break; + } +} + +static s16 D_8090D644[] = { 0, 1, 2, 2, 1 }; + +static Vec3f sStreamSoundPos = { 670.0f, 0.0f, -600.0f }; + +static Vec3s sSinkingLureLocationPos[] = { + { -364, -30, -269 }, + { 1129, 3, -855 }, + { -480, 0, -1055 }, + { 553, -48, -508 }, +}; + +#ifdef NON_MATCHING +// Register flip around target near the end of the function +void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnFishing* this = THIS; + Vec3f sp114; + Vec3f sp108; + Vec3f spFC; + s16 headRotTarget; + s16 playerShadowAlpha; + f32 target; + f32 camAtFraction; + f32 lureDistXZ; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Input* input = CONTROLLER1(globalCtx); + Camera* camera; + + playerShadowAlpha = player->actor.shape.shadowAlpha; + + if ((SQ(player->actor.world.pos.x) + SQ(player->actor.world.pos.z)) < SQ(920.0f)) { + Math_ApproachS(&playerShadowAlpha, 0, 1, 40); + } else { + Math_ApproachS(&playerShadowAlpha, 200, 1, 40); + } + + player->actor.shape.shadowAlpha = playerShadowAlpha; + + SkelAnime_Update(&this->skelAnime); + + if ((D_8090CD04 != 0) || Message_GetState(&globalCtx->msgCtx)) { + this->actor.flags &= ~1; + } else { + this->actor.flags |= 0x21; + } + + if ((this->actor.xzDistToPlayer < 120.0f) || Message_GetState(&globalCtx->msgCtx)) { + headRotTarget = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; + } else { + headRotTarget = 0; + } + + if (headRotTarget > 0x2710) { + headRotTarget = 0x2710; + } else if (headRotTarget < -0x2710) { + headRotTarget = -0x2710; + } + + Math_ApproachS(&this->unk_15C, headRotTarget, 3, 0x1388); + + if (((globalCtx->gameplayFrames % 32) == 0) && (Rand_ZeroOne() < 0.3f)) { + this->unk_15A = 4; + } + + this->unk_158 = D_8090D644[this->unk_15A]; + + if (this->unk_15A != 0) { + this->unk_15A--; + } + + if (D_8090CD04 != 0) { + D_8090CD04--; + } + + if ((D_8090CD0C == 0) && (D_80917206 != 2) && (D_8090CD14 > 0) && (D_8090CD08 == 1) && (D_8090CD04 == 0)) { + f32 dx = sOwnerHeadPos.x - sLurePos.x; + f32 dy = sOwnerHeadPos.y - sLurePos.y; + f32 dz = sOwnerHeadPos.z - sLurePos.z; + + if ((sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 25.0f)) { + D_8090CD08 = 0; + D_8090CD0C = 1; + func_801518B0(globalCtx, 0x4087, NULL); + } + } + + if (D_8090CD08 == 0) { + gSaveContext.roomInf[127][2] |= 0x1000; + } else if (D_8090CD08 == 1) { + gSaveContext.roomInf[127][2] &= ~0x1000; + } + + if (D_8090CCFC != 0) { + D_8090CCFC--; + if (D_8090CCFC == 0) { + func_801518B0(globalCtx, D_809171DA, NULL); + } + } + + EnFishing_HandleOwnerDialog(this, globalCtx); + + D_809101C8 = 0.0015f; + D_8090CD00++; + + if ((D_809171FC != 0) && D_8090CCF4) { + EnFishing_UpdateLure(this, globalCtx); + } + + EnFishing_UpdateEffects(globalCtx->specialEffects, globalCtx); + EnFishing_UpdatePondProps(globalCtx); + EnFishing_UpdateGroupFishes(globalCtx); + + if ((D_809171FC != 0) && (D_8090CD4C == 0) && (player->actor.world.pos.z > 1360.0f) && + (fabsf(player->actor.world.pos.x) < 25.0f)) { + player->actor.world.pos.z = 1360.0f; + player->actor.speedXZ = 0.0f; + + if (D_8090CD50 == 0) { + D_8090CD4C = 10; + } + } + + if ((sSinkingLureLocation != 0) && + (fabsf(player->actor.world.pos.x - sSinkingLureLocationPos[sSinkingLureLocation - 1].x) < 25.0f) && + (fabsf(player->actor.world.pos.y - sSinkingLureLocationPos[sSinkingLureLocation - 1].y) < 10.0f) && + (fabsf(player->actor.world.pos.z - sSinkingLureLocationPos[sSinkingLureLocation - 1].z) < 25.0f)) { + sSinkingLureLocation = 0; + D_8090CD4C = 20; + func_8013EC44(0.0f, 150, 10, 10); + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + Audio_QueueSeqCmd(0x101400FF); + } + + if (D_8090CD50 != 0) { + D_8090CD50--; + } + + switch (D_8090CD4C) { + case 0: + break; + + case 1: + sCameraId = func_801694DC(globalCtx); + func_80169590(globalCtx, MAIN_CAM, 1); + func_80169590(globalCtx, sCameraId, 7); + camera = Play_GetCamera(globalCtx, MAIN_CAM); + sCameraEye.x = camera->eye.x; + sCameraEye.y = camera->eye.y; + sCameraEye.z = camera->eye.z; + sCameraAt.x = camera->at.x; + sCameraAt.y = camera->at.y; + sCameraAt.z = camera->at.z; + D_8090CD4C = 2; + Interface_ChangeAlpha(12); + D_80911F4C = 0.0f; + // fallthrough + + case 2: + ShrinkWindow_SetLetterboxTarget(0x1B); + + spFC.x = sLurePos.x - player->actor.world.pos.x; + spFC.z = sLurePos.z - player->actor.world.pos.z; + lureDistXZ = sqrtf(SQ(spFC.x) + SQ(spFC.z)); + Matrix_InsertYRotation_f(Math_Acot2F(spFC.z, spFC.x), MTXMODE_NEW); + + sp114.x = 0.0f; + sp114.y = 0.0f; + sp114.z = 100.0f; + Matrix_MultiplyVector3fByState(&sp114, &spFC); + + if (D_8090CD14 == 1) { + camAtFraction = 0.2f; + } else { + camAtFraction = 0.1f; + } + + Math_ApproachF(&sCameraAt.x, sLurePos.x, camAtFraction, fabsf(spFC.x) * D_80911F4C); + Math_ApproachF(&sCameraAt.y, sLurePos.y, camAtFraction, 50.0f * D_80911F4C); + Math_ApproachF(&sCameraAt.z, sLurePos.z, camAtFraction, fabsf(spFC.z) * D_80911F4C); + + sp114.x = 0.0f - D_80911F50; + if (sLinkAge != 1) { + sp114.y = 80.0f; + } else { + sp114.y = 55.0f; + } + sp114.z = -80.0f; + + Matrix_MultiplyVector3fByState(&sp114, &sp108); + sp108.x += player->actor.world.pos.x; + sp108.y += player->actor.world.pos.y; + sp108.z += player->actor.world.pos.z; + + Math_ApproachF(&D_80911F50, 30.0f, 0.1f, 0.4f); + + if (CHECK_BTN_ALL(input->press.button, BTN_Z)) { + if ((D_809171DC >= 0) && (D_80917272 == 0)) { + D_809171DC++; + + if (D_809171DC >= 4) { + D_809171DC = 0; + } + + if ((D_809171DC == 0) || (D_809171DC == 3)) { + play_sound(NA_SE_SY_CAMERA_ZOOM_DOWN); + } else { + play_sound(NA_SE_SY_CAMERA_ZOOM_UP); + } + } + } + + if (D_8090CD14 >= 3) { + if (lureDistXZ < 110.0f) { + D_809171DC = -1; + } else if ((lureDistXZ > 300.0f) && (D_809171DC < 0)) { + D_809171DC = 0; + } + } + + if (D_809171DC > 0) { + f32 dist; + f32 offset; + f32 factor; + + dist = sqrtf(SQ(spFC.x) + SQ(spFC.z)) * 0.001f; + if (dist > 1.0f) { + dist = 1.0f; + } + if (D_809171DC == 2) { + offset = 0.3f; + } else { + offset = 0.1f; + } + factor = 0.4f + offset + (dist * 0.4f); + + sp108.x += (sLurePos.x - sp108.x) * factor; + sp108.y += ((sLurePos.y - sp108.y) * factor) + 20.0f; + sp108.z += (sLurePos.z - sp108.z) * factor; + D_809101C8 = 0.0005000001f; + } + + sp114.x = 0.0f; + sp114.y = 0.0f; + sp114.z = 100.0f; + Matrix_MultiplyVector3fByState(&sp114, &spFC); + + Math_ApproachF(&sCameraEye.x, sp108.x, 0.3f, fabsf(spFC.x) * D_80911F4C); + Math_ApproachF(&sCameraEye.y, sp108.y, 0.3f, 20.0f * D_80911F4C); + Math_ApproachF(&sCameraEye.z, sp108.z, 0.3f, fabsf(spFC.z) * D_80911F4C); + break; + + case 3: { + Camera* camera = Play_GetCamera(globalCtx, MAIN_CAM); + + camera->eye = sCameraEye; + camera->eyeNext = sCameraEye; + camera->at = sCameraAt; + } + func_80169AFC(globalCtx, sCameraId, 0); + func_800EA0EC(globalCtx, &globalCtx->csCtx); + D_8090CD4C = 0; + sCameraId = MAIN_CAM; + func_800F6834(globalCtx, 0); + globalCtx->envCtx.unk_8C.fogNear = 0; + player->unk_B28 = -5; + D_80917200 = 5; + break; + + case 10: + func_800EA0D4(globalCtx, &globalCtx->csCtx); + sCameraId = func_801694DC(globalCtx); + func_80169590(globalCtx, MAIN_CAM, 1); + func_80169590(globalCtx, sCameraId, 7); + func_800B7298(globalCtx, &this->actor, 4); + camera = Play_GetCamera(globalCtx, MAIN_CAM); + sCameraEye.x = camera->eye.x; + sCameraEye.y = camera->eye.y; + sCameraEye.z = camera->eye.z; + sCameraAt.x = camera->at.x; + sCameraAt.y = camera->at.y; + sCameraAt.z = camera->at.z; + func_801518B0(globalCtx, 0x409E, NULL); + D_8090CD4C = 11; + func_8013EC44(0.0f, 150, 10, 10); + // fallthrough + + case 11: + player->actor.world.pos.z = 1360.0f; + player->actor.speedXZ = 0.0f; + + if (!Message_GetState(&globalCtx->msgCtx)) { + camera = Play_GetCamera(globalCtx, MAIN_CAM); + + camera->eye = sCameraEye; + camera->eyeNext = sCameraEye; + camera->at = sCameraAt; + func_80169AFC(globalCtx, sCameraId, 0); + func_800EA0EC(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + D_8090CD4C = 0; + sCameraId = MAIN_CAM; + D_8090CD50 = 30; + func_800F6834(globalCtx, 0); + globalCtx->envCtx.unk_8C.fogNear = 0; + } + break; + + case 20: + func_800EA0D4(globalCtx, &globalCtx->csCtx); + sCameraId = func_801694DC(globalCtx); + func_80169590(globalCtx, MAIN_CAM, 1); + func_80169590(globalCtx, sCameraId, 7); + func_800B7298(globalCtx, &this->actor, 4); + camera = Play_GetCamera(globalCtx, MAIN_CAM); + sCameraEye.x = camera->eye.x; + sCameraEye.y = camera->eye.y; + sCameraEye.z = camera->eye.z; + sCameraAt.x = camera->at.x; + sCameraAt.y = camera->at.y; + sCameraAt.z = camera->at.z; + func_801518B0(globalCtx, 0x409A, NULL); + D_8090CD4C = 21; + D_80911F48 = 45.0f; + D_8090CD50 = 10; + // fallthrough + + case 21: + if ((D_8090CD50 == 0) && func_80147624(globalCtx)) { + D_8090CD4C = 22; + D_8090CD50 = 40; + // func_800B7298 call removed in MM + D_80911F64 = 0.0f; + } + break; + + case 22: + if (D_8090CD50 == 30) { + Audio_QueueSeqCmd(0x8922); // changed from 0x922 to 0x8922 in MM + } + + D_8090CD54 = 1; + + Math_ApproachF(&D_80911F64, 71.0f, 0.5f, 3.0f); + Matrix_InsertYRotation_f(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); + + sp114.x = Math_SinS(globalCtx->gameplayFrames * 0x1000); + sp114.y = D_80911F64; + sp114.z = -5.0f; + if (sLinkAge == 1) { + sp114.y -= 20.0f; + } + + Matrix_MultiplyVector3fByState(&sp114, &sp108); + + sSinkingLureBasePos.x = player->actor.world.pos.x + sp108.x; + sSinkingLureBasePos.y = player->actor.world.pos.y + sp108.y; + sSinkingLureBasePos.z = player->actor.world.pos.z + sp108.z; + + Math_ApproachF(&D_80911F48, 15.0f, 0.1f, 0.75f); + + sp114.x = D_80911F48 - 15.0f; + + if (sLinkAge != 1) { + sp114.y = 60.0f; + sp114.z = -30.0f; + } else { + sp114.y = 40.0f; + sp114.z = -35.0f; + } + + Matrix_MultiplyVector3fByState(&sp114, &sCameraEye); + sCameraEye.x += player->actor.world.pos.x; + sCameraEye.y += player->actor.world.pos.y; + sCameraEye.z += player->actor.world.pos.z; + + sCameraAt = player->actor.world.pos; + if (sLinkAge != 1) { + sCameraAt.y += 62.0f; + } else { + sCameraAt.y += 40.0f; + } + + if (D_8090CD50 == 0) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { + if (func_80147624(globalCtx)) { + Camera* camera = Play_GetCamera(globalCtx, MAIN_CAM); + + func_801477B4(globalCtx); + if (globalCtx->msgCtx.choiceIndex == 0) { + D_80917206 = 2; + D_809171D6 = 0; + } + + camera->eye = sCameraEye; + camera->eyeNext = sCameraEye; + camera->at = sCameraAt; + func_80169AFC(globalCtx, sCameraId, 0); + func_800EA0EC(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); // arg2 changed from 7 to 6 in MM + D_8090CD4C = 0; + sCameraId = MAIN_CAM; + player->unk_B28 = -5; + D_80917200 = 5; + D_8090CD54 = 0; + D_809171F6 = 20; + func_800F6834(globalCtx, 0); + globalCtx->envCtx.unk_8C.fogNear = 0; + } + } + } + break; + + case 100: + break; + } + + if (sCameraId != MAIN_CAM) { + Play_CameraSetAtEye(globalCtx, sCameraId, &sCameraAt, &sCameraEye); + Math_ApproachF(&D_80911F4C, 1.0f, 1.0f, 0.02f); + + if (sCameraEye.y <= (WATER_SURFACE_Y(globalCtx) + 1.0f)) { + func_800F6834(globalCtx, 1); + if (D_809171CA != 0) { + globalCtx->envCtx.unk_8C.fogNear = -0xB2; + } else { + globalCtx->envCtx.unk_8C.fogNear = -0x2E; + } + } else { + func_800F6834(globalCtx, 0); + globalCtx->envCtx.unk_8C.fogNear = 0; + } + } + + if ((player->actor.floorHeight < (WATER_SURFACE_Y(globalCtx) - 3.0f)) && + (player->actor.world.pos.y < (player->actor.floorHeight + 3.0f)) && (player->actor.speedXZ > 1.0f) && + ((globalCtx->gameplayFrames % 2) == 0)) { + Vec3f pos; + + pos.x = randPlusMinusPoint5Scaled(20.0f) + player->actor.world.pos.x; + pos.z = randPlusMinusPoint5Scaled(20.0f) + player->actor.world.pos.z; + pos.y = player->actor.floorHeight + 5.0f; + EnFishing_SpawnWaterDust(NULL, globalCtx->specialEffects, &pos, 0.5f); + } + + if ((player->actor.floorHeight < WATER_SURFACE_Y(globalCtx)) && + (player->actor.floorHeight > (WATER_SURFACE_Y(globalCtx) - 10.0f)) && (player->actor.speedXZ >= 4.0f) && + ((globalCtx->gameplayFrames % 4) == 0)) { + s16 i; + + for (i = 0; i < 10; i++) { + Vec3f pos; + Vec3f vel; + f32 speedXZ; + f32 angle; + + speedXZ = Rand_ZeroFloat(1.5f) + 1.5f; + angle = Rand_ZeroFloat(6.28f); + + vel.x = __sinf(angle) * speedXZ; + vel.z = __cosf(angle) * speedXZ; + vel.y = Rand_ZeroFloat(3.0f) + 2.0f; + + pos = player->actor.world.pos; + pos.x += 2.0f * vel.x; + pos.y = WATER_SURFACE_Y(globalCtx); + pos.z += 2.0f * vel.z; + EnFishing_SpawnDustSplash(NULL, globalCtx->specialEffects, &pos, &vel, + Rand_ZeroFloat(0.01f) + 0.020000001f); + } + } + + if (D_809171CB >= 2) { + D_809171CB--; + } + + if ((D_809171CB == 1) && !Message_GetState(&globalCtx->msgCtx) && ((D_8090CD00 & 0xFFF) == 0xFFF)) { + D_809171CB = 200; + + if (Rand_ZeroOne() < 0.5f) { + D_8090CCD4 = Rand_ZeroFloat(10.0f) + 5.0f; + globalCtx->envCtx.unk_E1 = 1; + } else { + D_8090CCD4 = 0; + globalCtx->envCtx.unk_E1 = 2; + } + } + + Math_ApproachF(&D_8090CCD0, D_8090CCD4, 1.0f, 0.05f); + + if (D_8090CCD0 > 0.0f) { + target = (D_8090CCD0 * 0.03f) + 0.8f; + if (target > 1.2f) { + target = 1.2f; + } + Math_ApproachF(&D_8090CCE8, target, 1.0f, 0.01f); + } + + target = (10.0f - D_8090CCD0) * 150.1f; + if (target < 0.0f) { + target = 0.0f; + } + Math_ApproachF(&D_8090CCDC.z, target, 1.0f, 5.0f); + + if (D_8090CCDC.z < 1500.0f) { + func_8019FAD8(&D_8090CCDC, NA_SE_EV_RAIN - SFX_FLAG, D_8090CCE8); + } + + if (D_8090CCD4 != 0) { + Math_ApproachF(&D_8090CCD8, -200.0f, 1.0f, 2.0f); + } else { + Math_ApproachZeroF(&D_8090CCD8, 1.0f, 2.0f); + } + + globalCtx->envCtx.unk_8C.diffuseColor1[0] = globalCtx->envCtx.unk_8C.diffuseColor1[1] = + globalCtx->envCtx.unk_8C.diffuseColor1[2] = D_8090CCD8; + + if ((u8)D_8090CCD0 > 0) { + s32 pad; + Camera* camera = Play_GetCamera(globalCtx, MAIN_CAM); + s16 i; + s32 pad1; + Vec3f pos; + Vec3f rot; + Vec3f projectedPos; + s32 pad2; + + rot.x = 1.6707964f; + rot.y = 1.0f; + rot.z = (func_800DFC68(camera) * -(M_PI / 32768)) + rot.y; + + for (i = 0; i < (u8)D_8090CCD0; i++) { + pos.x = randPlusMinusPoint5Scaled(700.0f) + globalCtx->view.eye.x; + pos.y = (Rand_ZeroFloat(100.0f) + 150.0f) - 170.0f; + pos.z = randPlusMinusPoint5Scaled(700.0f) + globalCtx->view.eye.z; + + if (pos.z < 1160.0f) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &pos, &projectedPos, &sProjectedW); + + if (projectedPos.z < 0.0f) { + i--; + } else { + EnFishing_SpawnRainDrop(globalCtx->specialEffects, &pos, &rot); + } + } + } + } + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sStreamSoundPos, &sStreamSoundProjectedPos, + &sProjectedW); + + func_8019F1C0(&sStreamSoundProjectedPos, NA_SE_EV_WATER_WALL - SFX_FLAG); + + if (gSaveContext.language == 0) { // Added in MM + gSaveContext.minigameScore = D_8090CCF8; + } else { + gSaveContext.minigameScore = (SQ((f32)D_8090CCF8) * 0.0036f) + 0.5f; + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateOwner.s") +#endif + +s32 EnFishing_OwnerOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnFishing* this = THIS; + + if (limbIndex == 8) { // Head + rot->x -= this->unk_15C; + } + + return false; +} + +void EnFishing_OwnerPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == 8) { // Head + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_MultiplyVector3fByState(&sZeroVec, &sOwnerHeadPos); + + if (D_8090CD08 == 1) { + gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); + } else if (D_8090CD08 == 2) { + gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHairDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +static UNK_TYPE sFishingOwnerEyeTexs[] = { + &gFishingOwnerEyeOpenTex, + &gFishingOwnerEyeHalfTex, + &gFishingOwnerEyeClosedTex, +}; + +void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFishing* this = THIS; + Input* input = CONTROLLER1(globalCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + if ((this->actor.projectedPos.z < 1500.0f) && + (fabsf(this->actor.projectedPos.x) < (100.0f + this->actor.projectedPos.z))) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sFishingOwnerEyeTexs[this->unk_158])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnFishing_OwnerOverrideLimbDraw, EnFishing_OwnerPostLimbDraw, + &this->actor); + } + + EnFishing_DrawPondProps(globalCtx); + EnFishing_DrawEffects(globalCtx->specialEffects, globalCtx); + EnFishing_DrawGroupFishes(globalCtx); + EnFishing_DrawStreamSplash(globalCtx); + + if (D_809171F6 != 0) { + D_809171F6--; + + if (D_809171F6 == 0) { + if (sLinkAge != 1) { + Audio_QueueSeqCmd(0x8019); // Changed from 0x19 in OoT + } else { + Audio_QueueSeqCmd(0x8027); // Changed from 0x27 in OoT + } + + if (sLinkAge != 1) { + Audio_QueueSeqCmd(0x8019); // Changed from 0x19 in OoT + } else { + Audio_QueueSeqCmd(0x8027); // Changed from 0x27 in OoT + } + } + } + + if ((D_809171FC != 0) && D_8090CCF4) { + EnFishing_DrawRod(globalCtx); + EnFishing_UpdateLinePos(sReelLinePos); + EnFishing_UpdateLine(globalCtx, &sRodTipPos, sReelLinePos, sReelLineRot, sReelLineUnk); + EnFishing_DrawLureAndLine(globalCtx, sReelLinePos, sReelLineRot); + + D_8090CD44 = input->rel.stick_x; + D_8090CD48 = input->rel.stick_y; + } + + D_8090CCF4 = true; + + Matrix_InsertTranslation(130.0f, 40.0f, 1300.0f, MTXMODE_NEW); + Matrix_Scale(0.08f, 0.12f, 0.14f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gFishingAquariumBottomDL); + gSPDisplayList(POLY_XLU_DISP++, gFishingAquariumContainerDL); + + if ((D_809171FC != 0) && (D_80917206 == 2)) { + EnFishing_DrawSinkingLure(globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h index d954b4cf88..3cd594b384 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h @@ -9,7 +9,56 @@ typedef void (*EnFishingActionFunc)(struct EnFishing*, GlobalContext*); typedef struct EnFishing { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x404]; + /* 0x0144 */ UNK_TYPE1 unk_144[0x004]; + /* 0x0148 */ u8 unk_148; + /* 0x0149 */ u8 unk_149; + /* 0x014A */ u8 unk_14A; + /* 0x014C */ s16 unk_14C; + /* 0x014E */ u8 unk_14E; + /* 0x014F */ u8 unk_14F; + /* 0x0150 */ s16 unk_150; + /* 0x0152 */ s16 unk_152; + /* 0x0154 */ s16 unk_154; + /* 0x0156 */ s16 unk_156; + /* 0x0158 */ s16 unk_158; + /* 0x015A */ s16 unk_15A; + /* 0x015C */ s16 unk_15C; + /* 0x015E */ s16 unk_15E; + /* 0x0160 */ s16 unk_160; + /* 0x0162 */ s16 unk_162; + /* 0x0164 */ s16 unk_164; + /* 0x0166 */ s16 unk_166; + /* 0x0168 */ s16 unk_168; + /* 0x016A */ s16 unk_16A; + /* 0x016C */ s16 unk_16C; + /* 0x016E */ s16 unk_16E; + /* 0x0170 */ s16 unk_170; + /* 0x0172 */ s16 unk_172[4]; + /* 0x017C */ f32 unk_17C; + /* 0x0180 */ f32 unk_180; + /* 0x0184 */ f32 unk_184; + /* 0x0188 */ f32 unk_188; + /* 0x018C */ f32 unk_18C; + /* 0x0190 */ f32 unk_190; + /* 0x0194 */ f32 unk_194; + /* 0x0198 */ s16 unk_198; + /* 0x019A */ s16 unk_19A; + /* 0x019C */ s16 unk_19C; + /* 0x01A0 */ f32 unk_1A0; + /* 0x01A4 */ f32 unk_1A4; + /* 0x01A8 */ f32 unk_1A8; + /* 0x01AC */ Vec3f unk_1AC; + /* 0x01B8 */ Vec3f fishMouthPos; + /* 0x01C4 */ s16 unk_1C4[3]; + /* 0x01CA */ u8 unk_1CA; + /* 0x01CB */ u8 unk_1CB; + /* 0x01CC */ u8 unk_1CC; + /* 0x01CD */ u8 unk_1CD; + /* 0x01D0 */ SkelAnime skelAnime; + /* 0x0214 */ LightNode* lightNode; + /* 0x0218 */ LightInfo lightInfo; + /* 0x0228 */ ColliderJntSph collider; + /* 0x0248 */ ColliderJntSphElement colliderElements[12]; } EnFishing; // size = 0x548 extern const ActorInit En_Fishing_InitVars; diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index f8b88f50a7..d7ccc8b158 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -165,7 +165,7 @@ void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { s32 params; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 50.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06008FB0, &D_06009DB0, this->jointTable, this->morphTable, 25); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -236,7 +236,7 @@ void func_808D0930(EnFloormas* this, GlobalContext* globalCtx) { func_808D19D4((EnFloormas*)this->actor.child); func_808D19D4((EnFloormas*)this->actor.parent); func_808D19D4(this); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KUSAMUSHI_HIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_HIDE); } else { Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); func_808D1ED4(this, globalCtx); @@ -251,7 +251,7 @@ void func_808D09CC(EnFloormas* this) { this->collider.base.colType = COLTYPE_HIT3; this->unk_18E = 80; this->actor.flags &= ~(0x400 | 0x200); - func_800BCB70(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808D0A48(EnFloormas* this, GlobalContext* globalCtx) { @@ -259,8 +259,8 @@ void func_808D0A48(EnFloormas* this, GlobalContext* globalCtx) { this->unk_18C = 0; this->collider.base.colType = COLTYPE_HIT0; this->unk_2C4 = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), 2, - this->actor.scale.x * 30.000002f, this->actor.scale.x * 20.0f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), 2, + this->actor.scale.x * 30.000002f, this->actor.scale.x * 20.0f); if (this->actor.scale.x > 0.009f) { this->actor.flags |= 0x400; } else { @@ -277,10 +277,10 @@ void func_808D0B08(EnFloormas* this) { void func_808D0B50(EnFloormas* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { - if ((this->actor.xzDistToPlayer < 400.0f) && !Actor_IsActorFacingLink(&this->actor, 0x4000)) { + if ((this->actor.xzDistToPlayer < 400.0f) && !Actor_IsFacingPlayer(&this->actor, 0x4000)) { this->unk_190 = this->actor.yawTowardsPlayer; func_808D108C(this); - } else if ((this->actor.xzDistToPlayer < 280.0f) && Actor_IsActorFacingLink(&this->actor, 0x2000)) { + } else if ((this->actor.xzDistToPlayer < 280.0f) && Actor_IsFacingPlayer(&this->actor, 0x2000)) { func_808D1380(this, globalCtx); } else { func_808D0C14(this); @@ -328,15 +328,15 @@ void func_808D0D70(EnFloormas* this, GlobalContext* globalCtx) { if ((temp_v0 != 0) || Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 24.0f) || Animation_OnFrame(&this->skelAnime, 36.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_WALK); } - if ((this->actor.xzDistToPlayer < 320.0f) && Actor_IsActorFacingLink(&this->actor, 0x4000)) { + if ((this->actor.xzDistToPlayer < 320.0f) && Actor_IsFacingPlayer(&this->actor, 0x4000)) { func_808D0F50(this); } else if (this->actor.bgCheckFlags & 8) { this->unk_190 = this->actor.wallYaw; func_808D108C(this); - } else if ((this->actor.xzDistToPlayer < 400.0f) && !Actor_IsActorFacingLink(&this->actor, 0x4000)) { + } else if ((this->actor.xzDistToPlayer < 400.0f) && !Actor_IsFacingPlayer(&this->actor, 0x4000)) { this->unk_190 = this->actor.yawTowardsPlayer; func_808D108C(this); } else if (this->unk_18E == 0) { @@ -367,11 +367,11 @@ void func_808D0F80(EnFloormas* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 24.0f) || Animation_OnFrame(&this->skelAnime, 36.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_WALK); } Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x71C); - if ((this->actor.xzDistToPlayer < 280.0f) && Actor_IsActorFacingLink(&this->actor, 0x2000) && + if ((this->actor.xzDistToPlayer < 280.0f) && Actor_IsFacingPlayer(&this->actor, 0x2000) && !(this->actor.bgCheckFlags & 8)) { func_808D1380(this, globalCtx); } else if (this->actor.xzDistToPlayer > 400.0f) { @@ -412,9 +412,9 @@ void func_808D11BC(EnFloormas* this, GlobalContext* globalCtx) { if (((this->skelAnime.playSpeed > 0.0f) && Animation_OnFrame(&this->skelAnime, 21.0f)) || ((this->skelAnime.playSpeed < 0.0f) && Animation_OnFrame(&this->skelAnime, 6.0f))) { if (this->actor.scale.x > 0.009f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_WALK); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); } } @@ -433,8 +433,8 @@ void func_808D1380(EnFloormas* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; this->actor.gravity = 0.0f; func_808D08D0(this); - func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_ATTACK); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, 1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_ATTACK); this->actionFunc = func_808D1458; } @@ -522,9 +522,9 @@ void func_808D17EC(EnFloormas* this, GlobalContext* globalCtx) { if (this->actor.velocity.y < -4.0f) { if (this->actor.scale.x > 0.009f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_LAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_LAND); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); } } } @@ -600,7 +600,7 @@ void func_808D1B44(EnFloormas* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); } if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); } } @@ -617,7 +617,7 @@ void func_808D1C1C(EnFloormas* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); } if (this->unk_194 == 0) { @@ -644,7 +644,7 @@ void func_808D1D6C(EnFloormas* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); } flags = this->actor.bgCheckFlags & 8; @@ -712,7 +712,7 @@ void func_808D2040(EnFloormas* this, GlobalContext* globalCtx) { } else if (this->actor.bgCheckFlags & 2) { this->unk_18E = 50; this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); func_808D1740(this); } else if ((this->actor.playerHeightRel < -10.0f) && (this->collider.base.ocFlags1 & OC1_HIT) && (&player->actor == this->collider.base.oc)) { @@ -774,10 +774,10 @@ void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx) { this->actor.speedXZ = -3.0f; func_808D1740(this); } else if ((this->unk_190 % 20) == 0) { - func_800B8E58(&player->actor, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92); + func_800B8E58(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92); globalCtx->damagePlayer(globalCtx, -4); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_STICK - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_STICK - SFX_FLAG); } void func_808D2484(EnFloormas* this) { @@ -814,7 +814,7 @@ void func_808D24F0(EnFloormas* this, GlobalContext* globalCtx) { this->collider.base.ocFlags1 |= OC1_ON; } else if (this->actor.bgCheckFlags & 2) { this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); func_808D1740(this); } @@ -874,7 +874,7 @@ void func_808D2764(EnFloormas* this, GlobalContext* globalCtx) { this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; if (((temp_f2 == 0.007f) || (temp_f2 == 0.004f)) && (temp_f2 != this->actor.scale.x)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_EXPAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_EXPAND); } this->collider.dim.radius = sCylinderInit.dim.radius * 100.0f * this->actor.scale.x; @@ -935,7 +935,7 @@ void func_808D2AF4(EnFloormas* this, GlobalContext* globalCtx) { void func_808D2B18(EnFloormas* this) { Animation_MorphToPlayOnce(&this->skelAnime, &D_06000590, -3.0f); func_800BE504(&this->actor, &this->collider); - func_800BCB70(&this->actor, 0x4000, 255, 0, 20); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); this->actor.speedXZ = 5.0f; this->actor.velocity.y = 5.5f; if (this->actor.params == ENFLOORMAS_GET_7FFF_40) { @@ -966,9 +966,9 @@ void func_808D2C08(EnFloormas* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 13.0f)) { if (this->actor.scale.x > 0.009f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } } @@ -1017,7 +1017,7 @@ void func_808D2DC0(EnFloormas* this, GlobalContext* globalCtx) { void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - func_800BE258(&this->actor, &this->collider.info); + Actor_SetDropFlag(&this->actor, &this->collider.info); if ((this->unk_18C != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (this->actor.colChkInfo.damageEffect == 0xE) { func_808D0908(this); @@ -1033,14 +1033,14 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { if (this->collider.base.colType != COLTYPE_HARD) { if (!Actor_ApplyDamage(&this->actor)) { if (this->actor.scale.x > 0.009f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_DAIOCTA_REVERSE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_REVERSE); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FLOORMASTER_SM_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_DEAD); } Enemy_StartFinishingBlow(globalCtx, &this->actor); this->actor.flags &= ~1; } else if (this->actor.colChkInfo.damage != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FALL_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_DAMAGE); } func_808D0A48(this, globalCtx); @@ -1055,13 +1055,13 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { func_808D2D6C(this); } else if (this->actor.colChkInfo.damageEffect == 1) { this->unk_18E = 40; - func_800BCB70(&this->actor, 0, 255, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_808D2D6C(this); } else if (this->actor.colChkInfo.damageEffect == 5) { this->unk_18E = 40; - func_800BCB70(&this->actor, 0, 255, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->unk_2C8 = 0.55f; this->unk_2C4 = 2.0f; this->unk_18C = 31; @@ -1110,7 +1110,7 @@ void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->actionFunc != func_808D22C8) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, this->actor.scale.x * 3000.0f, 0.0f, 0x1D); @@ -1131,7 +1131,7 @@ void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { } } - Actor_SetHeight(&this->actor, this->actor.scale.x * 2500.0f); + Actor_SetFocus(&this->actor, this->actor.scale.x * 2500.0f); if (this->collider.base.colType == COLTYPE_HARD) { if (this->unk_190 != 0) { this->unk_190--; diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index bf159f7de6..7e43657c09 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -196,9 +196,9 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_HandleSetupResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx) && this->cutsceneState == 0) { - func_800B84D0(&this->actor, globalCtx); - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx) && this->cutsceneState == 0) { + Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); if (ENFSN_IS_SHOP(&this->actor)) { this->actor.textId = 0; } @@ -376,7 +376,7 @@ void EnFsn_EndInteraction(EnFsn* this, GlobalContext* globalCtx) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = 0; } - func_800B84D0(&this->actor, globalCtx); + Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; Interface_ChangeAlpha(50); @@ -415,7 +415,7 @@ void EnFsn_UpdateCursorPos(EnFsn* this, GlobalContext* globalCtx) { f32 xOffset = 0.0f; f32 yOffset = 17.0f; - func_800B8898(globalCtx, &this->items[this->cursorIdx]->actor, &sp2E, &sp2C); + Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &sp2E, &sp2C); this->cursorPos.x = sp2E + xOffset; this->cursorPos.y = sp2C + yOffset; this->cursorPos.z = 1.2f; @@ -722,7 +722,7 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { this->actionFunc = EnFsn_Haggle; } else { dummy2:; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->cutsceneState == 0) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -754,7 +754,7 @@ void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); } else { if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HANKO); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } if (this->flags & ENFSN_CALM_DOWN) { this->flags &= ~ENFSN_CALM_DOWN; @@ -771,7 +771,7 @@ void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); } else { if (Animation_OnFrame(&this->skelAnime, 28.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HANKO); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } return; } @@ -806,7 +806,7 @@ void EnFsn_BeginInteraction(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_StartBuying(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); EnFsn_HandleLookToShopkeeperBuyingCutscene(this); @@ -827,7 +827,7 @@ void EnFsn_StartBuying(EnFsn* this, GlobalContext* globalCtx) { this->actionFunc = EnFsn_DeterminePrice; break; case 0x29CF: - player->unk_A87 = PLAYER_AP_NONE; + player->exchangeItemId = EXCH_ITEM_NONE; this->actionFunc = EnFsn_SetupDeterminePrice; break; } @@ -835,7 +835,7 @@ void EnFsn_StartBuying(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { if (func_80147624(globalCtx)) { @@ -895,7 +895,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_SetupDeterminePrice(EnFsn* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.textId = 0xFF; func_801518B0(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_DeterminePrice; @@ -907,7 +907,7 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { s32 itemActionParam; u8 buttonItem; - if (func_80152498(&globalCtx->msgCtx) == 16) { + if (Message_GetState(&globalCtx->msgCtx) == 16) { itemActionParam = func_80123810(globalCtx); if (itemActionParam > PLAYER_AP_NONE) { if (player->heldItemButton == 0) { @@ -918,8 +918,7 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { this->price = (buttonItem < ITEM_MOON_TEAR) ? gItemPrices[buttonItem] : 0; if (this->price > 0) { player->actor.textId = 0x29EF; - // player->unk_A87 should be set to itemActionParam? - player->unk_A87 = buttonItem; + player->exchangeItemId = buttonItem; this->actionFunc = EnFsn_MakeOffer; } else { player->actor.textId = 0x29CF; @@ -941,7 +940,7 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); if (talkState == 4 && func_80147624(globalCtx)) { @@ -975,7 +974,7 @@ void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { break; case 1: func_8019F230(); - player->unk_A87 = PLAYER_AP_NONE; + player->exchangeItemId = EXCH_ITEM_NONE; this->actionFunc = EnFsn_SetupDeterminePrice; break; } @@ -994,9 +993,9 @@ void EnFsn_GiveItem(EnFsn* this, GlobalContext* globalCtx) { } this->actionFunc = EnFsn_SetupResumeInteraction; } else if (this->isSelling == true) { - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); } else { - func_800B8A1C(&this->actor, globalCtx, this->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->getItemId, 300.0f, 300.0f); } } @@ -1011,7 +1010,7 @@ void EnFsn_SetupResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_ResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (ENFSN_IS_SHOP(&this->actor)) { if (!this->isSelling) { this->cutscene = this->lookToShopkeeperBuyingCutscene; @@ -1031,7 +1030,7 @@ void EnFsn_ResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { this->actionFunc = EnFsn_ConverseBackroom; } } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); } } @@ -1083,7 +1082,7 @@ void EnFsn_LookToShelf(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_BrowseShelf(EnFsn* this, GlobalContext* globalCtx) { - u8 talkstate = func_80152498(&globalCtx->msgCtx); + u8 talkstate = Message_GetState(&globalCtx->msgCtx); s32 pad; u8 prevCursorIdx = this->cursorIdx; @@ -1147,7 +1146,7 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { func_8019F208(); item = this->items[this->cursorIdx]; item->buyFanfareFunc(globalCtx, item); - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; Interface_ChangeAlpha(50); @@ -1178,7 +1177,7 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_SetupEndInteraction(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { @@ -1195,7 +1194,7 @@ void EnFsn_SetupEndInteraction(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (EnFsn_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); @@ -1214,14 +1213,14 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); } } void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (this->cutsceneState == 0) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -1267,7 +1266,7 @@ void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (this->cutsceneState == 0) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -1314,7 +1313,7 @@ void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) } void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); u8 cursorIdx; if (talkState == 4) { @@ -1339,13 +1338,13 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_SetupEndInteractionImmediately(EnFsn* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { EnFsn_EndInteraction(this, globalCtx); } } void EnFsn_IdleBackroom(EnFsn* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->textId = 0; EnFsn_HandleConversationBackroom(this, globalCtx); this->actionFunc = EnFsn_ConverseBackroom; @@ -1355,7 +1354,7 @@ void EnFsn_IdleBackroom(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_ConverseBackroom(EnFsn* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { if (this->flags & ENFSN_END_CONVERSATION) { this->flags &= ~ENFSN_END_CONVERSATION; globalCtx->msgCtx.unk11F22 = 0x43; @@ -1398,7 +1397,7 @@ void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { EnFsn* this = THIS; s32 pad; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013320, &D_06012C34, this->jointTable, this->morphTable, 19); if (ENFSN_IS_SHOP(&this->actor)) { this->actor.shape.rot.y = BINANG_ROT180(this->actor.shape.rot.y); @@ -1432,7 +1431,7 @@ void EnFsn_Update(Actor* thisx, GlobalContext* globalCtx) { EnFsn* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unk27A, this->actor.focus.pos); func_8013D9C8(globalCtx, this->limbRotYTable, this->limbRotZTable, 19); EnFsn_Blink(this); diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 7dcf097d79..c7eebb281b 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -188,7 +188,7 @@ void func_809619D0(EnFu* this, GlobalContext* globalCtx) { void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnFu* this = THIS; - Actor* fuKaiten = globalCtx->actorCtx.actorList[ACTORCAT_BG].first; + Actor* fuKaiten = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; while (fuKaiten != NULL) { if (fuKaiten->id == ACTOR_BG_FU_KAITEN) { @@ -199,7 +199,7 @@ void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { } if (fuKaiten != NULL) { - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 36.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B2B0, &D_06001F74, this->jointTable, this->morphTable, 21); Collider_InitCylinder(globalCtx, &this->collider); @@ -257,7 +257,7 @@ s32 func_80961D10(EnFu* this) { } void func_80961D7C(GlobalContext* globalCtx) { - Actor* explosive = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; + Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (explosive != NULL) { if ((explosive->id == ACTOR_EN_BOM) && (explosive->bgCheckFlags & 1)) { @@ -277,7 +277,7 @@ void func_80961D7C(GlobalContext* globalCtx) { } void func_80961E88(GlobalContext* globalCtx) { - Actor* explosive = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; + Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (explosive != NULL) { Actor_MarkForDeath(explosive); @@ -286,7 +286,7 @@ void func_80961E88(GlobalContext* globalCtx) { } void func_80961EC8(GlobalContext* globalCtx) { - Actor* fuMato = globalCtx->actorCtx.actorList[ACTORCAT_BG].first; + Actor* fuMato = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; while (fuMato != NULL) { if (fuMato->id == ACTOR_EN_FU_MATO) { @@ -297,7 +297,7 @@ void func_80961EC8(GlobalContext* globalCtx) { } void func_80961F00(GlobalContext* globalCtx) { - Actor* fuKago = globalCtx->actorCtx.actorList[ACTORCAT_BG].first; + Actor* fuKago = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; while (fuKago != NULL) { if (fuKago->id == ACTOR_EN_FU_KAGO) { @@ -377,7 +377,7 @@ void func_8096209C(EnFu* this, GlobalContext* globalCtx) { } void func_809622FC(EnFu* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80962340; } @@ -388,7 +388,7 @@ void func_80962340(EnFu* this, GlobalContext* globalCtx) { this->actor.flags |= 0x10000; } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->unk_54A == 2) { if (this->unk_552 == 0x287D) { if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { @@ -542,7 +542,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { func_801477B4(globalCtx); player->stateFlags1 |= 0x20; this->unk_53C = 0; - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); func_801A2BB8(NA_BGM_MINI_GAME_2); if (this->unk_542 == 0) { if (this->unk_546 == 1) { @@ -583,7 +583,7 @@ void func_809628BC(EnFu* this) { } void func_809628D0(EnFu* this, GlobalContext* globalCtx) { - u8 sp27 = func_80152498(&globalCtx->msgCtx); + u8 sp27 = Message_GetState(&globalCtx->msgCtx); switch (sp27) { case 0: @@ -846,8 +846,8 @@ void func_80963350(EnFu* this, GlobalContext* globalCtx) { static s32 D_80964C24 = 0; BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; - if ((this->unk_54A == 0) && (((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) || - ((func_80152498(&globalCtx->msgCtx) == 2) && (globalCtx->msgCtx.unk12023 == 1)))) { + if ((this->unk_54A == 0) && (((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) || + ((Message_GetState(&globalCtx->msgCtx) == 2) && (globalCtx->msgCtx.unk12023 == 1)))) { func_801477B4(globalCtx); this->unk_54A = 2; D_80964C24 = 1; @@ -884,9 +884,9 @@ void func_80963560(EnFu* this, GlobalContext* globalCtx) { this->actor.parent = NULL; func_80963610(this); } else if ((this->unk_552 == 0x2880) && !(gSaveContext.weekEventReg[22] & 0x80)) { - func_800B8A1C(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); } this->actor.child->freezeTimer = 10; } @@ -899,7 +899,7 @@ void func_80963610(EnFu* this) { void func_80963630(EnFu* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20) && (CURRENT_DAY == 3) && (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { if (gSaveContext.weekEventReg[22] & 0x40) { @@ -940,7 +940,7 @@ void func_80963630(EnFu* this, GlobalContext* globalCtx) { player->stateFlags1 &= ~0x20; } else { this->actor.child->freezeTimer = 10; - func_800B85E0(&this->actor, globalCtx, 500.0f, -1); + func_800B85E0(&this->actor, globalCtx, 500.0f, EXCH_ITEM_MINUS1); } } @@ -962,7 +962,7 @@ s32 func_80963810(GlobalContext* globalCtx, Vec3f pos) { } globalCtx->actorCtx.unk268 = 1; - func_800B6F20(globalCtx, globalCtx->actorCtx.pad26C, phi_f0, sp22); + func_800B6F20(globalCtx, &globalCtx->actorCtx.unk_26C, phi_f0, sp22); if (sp28 < 80.0f) { return true; @@ -1181,7 +1181,7 @@ void func_80963FF8(EnFu* this, GlobalContext* globalCtx) { if (player->stateFlags1 & 0x100000) { globalCtx->actorCtx.unk268 = 1; - globalCtx->actorCtx.unk278 = 0x8000; + globalCtx->actorCtx.unk_26C.press.button = 0x8000; } else { globalCtx->actorCtx.unk268 = 1; } @@ -1219,7 +1219,7 @@ void func_80964190(EnFu* this, GlobalContext* globalCtx) { case 0x2842: case 0x2844: case 0x2848: - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); break; case 0x2840: @@ -1245,21 +1245,21 @@ void func_80964190(EnFu* this, GlobalContext* globalCtx) { case 0x286B: case 0x286D: case 0x2871: - func_800BDC5C(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); break; case 0x2860: - func_800BDC5C(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); break; case 0x285F: - func_800BDC5C(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); break; case 0x287E: case 0x2880: case 0x2883: - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); break; } } @@ -1340,7 +1340,7 @@ void EnFu_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); func_809642E0(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_8096209C(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); SkelAnime_Update(&this->skelAnime); 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 e07abfbe9b..1efcd42e7e 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -359,7 +359,8 @@ void func_80932C98(EnFz* this, GlobalContext* globalCtx) { Vec3f sp3C; if (this->unk_BCD != 0) { - if ((this->actor.bgCheckFlags & 8) || !func_800BC4EC(&this->actor, globalCtx, 60.0f, this->actor.world.rot.y)) { + if ((this->actor.bgCheckFlags & 8) || + !Actor_TestFloorInDirection(&this->actor, globalCtx, 60.0f, this->actor.world.rot.y)) { this->actor.bgCheckFlags &= ~0x8; this->unk_BCD = 0; this->unk_BBC = 0.0f; @@ -374,8 +375,8 @@ void func_80932C98(EnFz* this, GlobalContext* globalCtx) { if ((parent->update == NULL) || (parent->colChkInfo.health <= 0)) { this->actor.colChkInfo.health = 0; this->unk_BC4 = 5; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FREEZAD_DEAD); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ICE_BROKEN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FREEZAD_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); sp3C.x = this->actor.world.pos.x; sp3C.y = this->actor.world.pos.y; sp3C.z = this->actor.world.pos.z; @@ -387,8 +388,8 @@ void func_80932C98(EnFz* this, GlobalContext* globalCtx) { if ((this->actor.colChkInfo.health != 0) && (this->unk_BC4 == 1)) { this->actor.colChkInfo.health = 0; this->unk_BC4 = 5; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FREEZAD_DEAD); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ICE_BROKEN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FREEZAD_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); sp3C.x = this->actor.world.pos.x; sp3C.y = this->actor.world.pos.y; sp3C.z = this->actor.world.pos.z; @@ -419,9 +420,9 @@ void func_80932C98(EnFz* this, GlobalContext* globalCtx) { case 15: Actor_ApplyDamage(&this->actor); - func_800BCB70(&this->actor, 0x4000, 0xFF, 0x2000, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 8); if (this->actor.colChkInfo.health != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FREEZAD_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FREEZAD_DAMAGE); sp3C.x = this->actor.world.pos.x; sp3C.y = this->actor.world.pos.y; sp3C.z = this->actor.world.pos.z; @@ -429,8 +430,8 @@ void func_80932C98(EnFz* this, GlobalContext* globalCtx) { this->unk_BCF++; break; } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FREEZAD_DEAD); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ICE_BROKEN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FREEZAD_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); sp3C.x = this->actor.world.pos.x; sp3C.y = this->actor.world.pos.y; sp3C.z = this->actor.world.pos.z; @@ -439,7 +440,7 @@ void func_80932C98(EnFz* this, GlobalContext* globalCtx) { break; case 2: - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FREEZAD_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FREEZAD_DEAD); func_80933790(this); break; } @@ -803,7 +804,7 @@ void EnFz_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_BD9--; } - Actor_SetHeight(&this->actor, 50.0f); + Actor_SetFocus(&this->actor, 50.0f); func_80932C98(this, globalCtx); this->actionFunc(this, globalCtx); @@ -821,7 +822,7 @@ void EnFz_Update(Actor* thisx, GlobalContext* globalCtx) { } Math_StepToF(&this->actor.speedXZ, this->unk_BBC, 0.2f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (this->unk_BCC != 0) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 20.0f, 5); } diff --git a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c index 6d78480e77..90880e2618 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -5,6 +5,7 @@ */ #include "z_en_gb2.h" +#include "objects/object_ps/object_ps.h" #define FLAGS 0x00000039 @@ -15,6 +16,7 @@ void EnGb2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGb2_Update(Actor* thisx, GlobalContext* globalCtx); void EnGb2_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B0FBF0(EnGb2* this, GlobalContext* globalCtx); void func_80B0FEBC(EnGb2* this, GlobalContext* globalCtx); void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx); void func_80B10240(EnGb2* this, GlobalContext* globalCtx); @@ -29,11 +31,11 @@ void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx); void func_80B10DAC(EnGb2* this, GlobalContext* globalCtx); void func_80B10E98(EnGb2* this, GlobalContext* globalCtx); void func_80B11048(EnGb2* this, GlobalContext* globalCtx); +void func_80B110F8(EnGb2* this, GlobalContext* globalCtx); void func_80B111AC(EnGb2* this, GlobalContext* globalCtx); void func_80B11268(EnGb2* this, GlobalContext* globalCtx); void func_80B11344(EnGb2* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Gb2_InitVars = { ACTOR_EN_GB2, ACTORCAT_NPC, @@ -46,98 +48,984 @@ const ActorInit En_Gb2_InitVars = { (ActorFunc)EnGb2_Draw, }; -// static ColliderCylinderInitType1 sCylinderInit = { -static ColliderCylinderInitType1 D_80B11A40 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x04 */ Vec3f unk_04; + /* 0x10 */ s16 unk_10; +} EnGbStruct; // size = 0x14 + +static EnGbStruct D_80B119B0[] = { + { ACTOR_EN_PO_SISTERS, { 0.0f, 0.0f, 0.0f }, 0x300 }, + { ACTOR_EN_PO_SISTERS, { 100.0f, 0.0f, 0.0f }, 0x200 }, + { ACTOR_EN_PO_SISTERS, { -100.0f, 0.0f, 0.0f }, 0x100 }, + { ACTOR_EN_PO_SISTERS, { 0.0f, 0.0f, 0.0f }, 0 }, +}; + +static f32 D_80B11A00[][4] = { + { 0.0f, -13.0f, 549.0f, 0.0f }, + { -242.0f, -13.0f, 390.0f, -90.0f }, + { 0.0f, -13.0f, 148.0f, 180.0f }, + { 244.0f, -13.0f, 390.0f, 90.0f }, +}; + +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 40, 75, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B11AC4[] = { +void func_80B0F5E0(EnGb2* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 func_80B0F660(EnGb2* this, GlobalContext* globalCtx) { + Actor* temp_v0; + Actor* phi_s0 = NULL; + + while (true) { + temp_v0 = SubS_FindActor(globalCtx, phi_s0, ACTORCAT_NPC, ACTOR_EN_GB2); + if (temp_v0 == NULL) { + break; + } + + if ((EnGb2*)temp_v0 != this) { + return true; + } + + temp_v0 = temp_v0->next; + if (temp_v0 == NULL) { + break; + } + phi_s0 = temp_v0; + }; + + return false; +} + +void func_80B0F6DC(EnGb2* this) { + if (!(gSaveContext.weekEventReg[54] & 0x20)) { + gSaveContext.weekEventReg[54] |= 0x20; + this->unk_26E = 0x14D0; + } else { + this->unk_26E = 0x14D1; + } + this->unk_288 = 30; + this->actionFunc = func_80B0FEBC; +} + +void func_80B0F728(EnGb2* this, GlobalContext* globalCtx) { + if (gSaveContext.eventInf[4] & 0x10) { + func_80B0FBF0(this, globalCtx); + this->unk_26E = 0x14E1; + if (gSaveContext.eventInf[4] & 0x80) { + this->unk_288 = 10; + } else { + this->unk_288 = 30; + } + } else if (gSaveContext.eventInf[4] & 0x20) { + func_80B0FBF0(this, globalCtx); + this->unk_26E = 0x14E0; + this->unk_26C |= 2; + } else { + this->unk_26E = 0x14DC; + } + + gSaveContext.eventInf[4] &= (u8)~0x10; + gSaveContext.eventInf[4] &= (u8)~0x20; + gSaveContext.eventInf[4] &= (u8)~0x40; + this->actionFunc = func_80B10584; +} + +u16 func_80B0F7FC(EnGb2* this) { + switch (this->unk_26E) { + case 0x14D0: + return 0x14D1; + + case 0x14D1: + if (gSaveContext.eventInf[4] & 0x80) { + return 0x14E4; + } + + if (gSaveContext.health > 48) { + return 0x14D2; + } + + this->unk_26C |= 2; + return 0x14D3; + + case 0x14E4: + if (gSaveContext.health > 48) { + return 0x14D2; + } + + this->unk_26C |= 2; + return 0x14D3; + + case 0x14D2: + if (gSaveContext.eventInf[4] & 0x80) { + return 0x14E5; + } + return 0x14D4; + + case 0x14D4: + case 0x14E5: + return 0x14D5; + + case 0x14D8: + return 0x14D9; + + case 0x14D9: + return 0x14DA; + } + return 0; +} + +u16 func_80B0F8F8(EnGb2* this) { + switch (this->unk_26E) { + case 0x14DC: + this->unk_26C |= 2; + return 0x14DD; + + case 0x14DD: + return 0x14DE; + + case 0x14DE: + this->unk_26C |= 2; + gSaveContext.weekEventReg[54] |= 0x80; + return 0x14DF; + + case 0x14E1: + return 0x14E2; + } + return 0; +} + +u16 func_80B0F97C(EnGb2* this) { + switch (this->unk_26E) { + case 0x14F5: + return 0x14F6; + + case 0x14F6: + return 0x14F7; + + case 0x14F7: + gSaveContext.weekEventReg[76] |= 0x80; + this->unk_26C |= 2; + return 0x14F8; + + case 0x14F9: + return 0x14FA; + + case 0x14FA: + this->unk_26C |= 2; + return 0x14FB; + } + return 0; +} + +void func_80B0FA04(EnGb2* this) { + this->unk_282[0] = this->actor.cutscene; + this->unk_282[1] = ActorCutscene_GetAdditionalCutscene(this->unk_282[0]); + this->unk_282[2] = ActorCutscene_GetAdditionalCutscene(this->unk_282[1]); +} + +s32 func_80B0FA48(EnGb2* this, GlobalContext* globalCtx) { + switch (Player_GetMask(globalCtx)) { + case PLAYER_MASK_GIBDO: + this->unk_26C |= 4; + this->unk_26E = 0x14E6; + return false; + + case PLAYER_MASK_GARO: + this->unk_26C |= 8; + this->unk_26E = 0x14E6; + return false; + + case PLAYER_MASK_CAPTAIN: + if (!(gSaveContext.weekEventReg[80] & 0x40)) { + this->unk_26E = 0x14EB; + return false; + } + this->unk_26E = 0x14EE; + return true; + } + + if (!(gSaveContext.weekEventReg[80] & 0x20)) { + this->unk_26E = 0x14EF; + return false; + } else { + this->unk_26E = 0x14F4; + return true; + } +} + +u16 func_80B0FB24(EnGb2* this) { + switch (this->unk_26E) { + case 0x14E6: + if (this->unk_26C & 4) { + return 0x14E7; + } + + if (this->unk_26C & 8) { + return 0x14E9; + } + + case 0x14E7: + this->unk_26C |= 2; + return 0x14E8; + + case 0x14E9: + this->unk_26C |= 2; + return 0x14EA; + + case 0x14EB: + return 0x14EC; + + case 0x14EC: + this->unk_26C |= 2; + return 0x14ED; + + case 0x14EF: + return 0x14F0; + + case 0x14F0: + return 0x14F1; + + case 0x14F1: + return 0x14F2; + + case 0x14F2: + this->unk_26C |= 2; + return 0x14F3; + } + return 0; +} + +void func_80B0FBF0(EnGb2* this, GlobalContext* globalCtx) { + Vec3f sp90[4] = { + { 120.0f, 0.0f, 800.0f }, + { -120.0f, 0.0f, 750.0f }, + { 60.0f, 0.0f, 750.0f }, + { -60.0f, 0.0f, 800.0f }, + }; + Vec3s sp78[] = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + }; + s32 sp68[] = { + 0x1000, + 0x1100, + 0x1200, + 0x1300, + }; + s16 i; + s16 end = ARRAY_COUNT(sp90); + + for (i = 0; i < end; i++) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PO_SISTERS, sp90[i].x, sp90[i].y, + sp90[i].z, sp78[i].x, sp78[i].y, sp78[i].z, sp68[i]); + } +} + +void func_80B0FD8C(EnGb2* this, GlobalContext* globalCtx) { + this->unk_280++; + this->unk_268 = this->actor.child; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PO_SISTERS, + D_80B119B0[this->unk_280].unk_04.x, D_80B119B0[this->unk_280].unk_04.y, + D_80B119B0[this->unk_280].unk_04.z, 0, 0, 0, D_80B119B0[this->unk_280].unk_10); +} + +void func_80B0FE18(GlobalContext* globalCtx) { + func_800FD750(0x38); + globalCtx->nextEntranceIndex = 0x9C10; + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 0x40; + globalCtx->sceneLoadFlag = 0x14; +} + +void func_80B0FE7C(GlobalContext* globalCtx) { + globalCtx->nextEntranceIndex = 0x9C20; + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 0x40; + globalCtx->sceneLoadFlag = 0x14; +} + +void func_80B0FEBC(EnGb2* this, GlobalContext* globalCtx) { + if ((globalCtx->msgCtx.unk1202A == 3) && (globalCtx->msgCtx.unk1202E == 7)) { + globalCtx->msgCtx.unk1202A = 4; + gSaveContext.eventInf[4] |= 0x80; + this->unk_26E = 0x14D1; + this->unk_288 = 10; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_801518B0(globalCtx, this->unk_26E, &this->actor); + this->actionFunc = func_80B0FFA8; + } else if ((this->actor.xzDistToPlayer < 300.0f) || this->actor.isTargeted) { + func_800B863C(&this->actor, globalCtx); + } +} + +void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (temp_v0 == 5) { + if (func_80147624(globalCtx)) { + if (this->unk_26C & 2) { + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_26E = 0x14D1; + this->unk_288 = 30; + gSaveContext.eventInf[4] &= (u8)~0x80; + this->unk_26C &= ~2; + this->actionFunc = func_80B0FEBC; + } else { + this->unk_26E = func_80B0F7FC(this); + func_801518B0(globalCtx, this->unk_26E, &this->actor); + } + } + } else if ((temp_v0 == 4) && func_80147624(globalCtx)) { + if (this->unk_26E == 0x14D5) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (gSaveContext.rupees < this->unk_288) { + play_sound(NA_SE_SY_ERROR); + this->unk_26E = 0x14D7; + this->unk_26C |= 2; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + } else { + func_8019F208(); + this->unk_26E = 0x14D8; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + } + break; + + case 1: + func_8019F230(); + this->unk_26E = 0x14D6; + this->unk_26C |= 2; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + break; + } + } else if (this->unk_26E == 0x14DA) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + func_801159EC(-this->unk_288); + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + func_800B7298(globalCtx, NULL, 7); + this->actionFunc = func_80B11344; + break; + + case 1: + func_8019F230(); + this->unk_26E = 0x14DB; + this->unk_26C |= 2; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + break; + } + } + } +} + +void func_80B10240(EnGb2* this, GlobalContext* globalCtx) { + this->unk_27C = D_80B119B0[this->unk_280].unk_00; + this->unk_27E = D_80B119B0[this->unk_280].unk_10; + this->unk_282[0] = this->actor.cutscene; + this->unk_268 = NULL; + if (ActorCutscene_GetCanPlayNext(this->unk_282[0])) { + ActorCutscene_Start(this->unk_282[0], &this->actor); + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, this->unk_27C, + D_80B119B0[this->unk_280].unk_04.x, D_80B119B0[this->unk_280].unk_04.y, + D_80B119B0[this->unk_280].unk_04.z, 0, 0, 0, this->unk_27E); + if (this->unk_280 == 0) { + func_8010E9F0(1, 180); + } + this->actionFunc = func_80B10344; + } else { + ActorCutscene_SetIntentToPlay(this->unk_282[0]); + } +} + +void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { + if (this->unk_280 == 1) { + func_80B0FD8C(this, globalCtx); + } + + if (this->unk_280 == 2) { + if ((this->unk_268 != NULL) && (this->unk_268->update == NULL)) { + this->unk_268 = NULL; + this->unk_26C |= 0x400; + } + } + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL)) { + this->actor.child = NULL; + this->unk_26C |= 0x200; + } + + if (this->unk_26C & 0x200) { + if (this->unk_280 == 3) { + this->unk_26C &= ~0x200; + gSaveContext.unk_3DD0[1] = 5; + func_800FE498(); + gSaveContext.eventInf[4] |= 0x40; + func_80B0FE7C(globalCtx); + } else if (this->unk_280 == 2) { + if (this->unk_26C & 0x400) { + this->unk_280++; + this->unk_26C &= ~0x200; + this->unk_26C &= ~0x400; + this->actionFunc = func_80B10240; + } + } else { + this->unk_280++; + this->unk_26C &= ~0x200; + this->actionFunc = func_80B10240; + } + } + + if (gSaveContext.health < 49) { + gSaveContext.unk_3DD0[1] = 5; + gSaveContext.eventInf[4] |= 0x40; + gSaveContext.eventInf[4] |= 0x20; + + if ((this->unk_268 != NULL) && (this->unk_268->update == NULL)) { + this->unk_268 = NULL; + } + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL)) { + this->actor.child = NULL; + } + + func_80B0FE7C(globalCtx); + } else if (gSaveContext.unk_3DE0[1] == 0) { + gSaveContext.unk_3DD0[1] = 5; + gSaveContext.eventInf[4] |= 0x40; + gSaveContext.eventInf[4] |= 0x10; + + if ((this->unk_268 != NULL) && (this->unk_268->update == NULL)) { + this->unk_268 = NULL; + } + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL)) { + this->actor.child = NULL; + } + + func_80B0FE7C(globalCtx); + } +} + +void func_80B10584(EnGb2* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_801518B0(globalCtx, this->unk_26E, &this->actor); + this->actor.flags &= ~0x10000; + this->actionFunc = func_80B10634; + } else if (this->actor.xzDistToPlayer < 300.0f) { + this->actor.flags |= 0x10000; + func_800B8614(&this->actor, globalCtx, 300.0f); + } +} + +void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (temp_v0 == 5) { + if (func_80147624(globalCtx)) { + if (this->unk_26C & 2) { + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_26C &= ~2; + if (this->unk_26E == 0x14DD) { + this->unk_26E = 0x14DE; + this->actionFunc = func_80B10924; + } else if (this->unk_26E == 0x14DF) { + this->actionFunc = func_80B10A48; + } else { + this->unk_26E = 0x14D1; + this->unk_288 = 30; + gSaveContext.eventInf[4] &= (u8)~0x80; + this->actionFunc = func_80B0FEBC; + } + } else { + this->unk_26E = func_80B0F8F8(this); + func_801518B0(globalCtx, this->unk_26E, &this->actor); + } + } + } else if ((temp_v0 == 4) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (gSaveContext.rupees < this->unk_288) { + play_sound(NA_SE_SY_ERROR); + this->unk_26E = 0x14D7; + this->unk_26C |= 2; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + } else { + func_8019F208(); + func_801159EC(-this->unk_288); + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + func_800B7298(globalCtx, NULL, 7); + this->actionFunc = func_80B11344; + } + break; + + case 1: + func_8019F230(); + this->unk_26E = 0x14E3; + this->unk_26C |= 2; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + break; + } + } +} + +void func_80B10868(EnGb2* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->unk_282[2]) { + if (ActorCutscene_GetCanPlayNext(this->unk_282[this->unk_290])) { + this->actionFunc = func_80B10A48; + ActorCutscene_StartAndSetFlag(this->unk_282[this->unk_290], &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->unk_282[this->unk_290]); + } + } else { + this->unk_290 = 1; + ActorCutscene_SetIntentToPlay(this->unk_282[this->unk_290]); + } +} + +void func_80B10924(EnGb2* this, GlobalContext* globalCtx) { + s32 sp24; + + if (gSaveContext.weekEventReg[54] & 0x40) { + sp24 = 5; + } else { + sp24 = 12; + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + if (sp24 == 12) { + gSaveContext.weekEventReg[54] |= 0x40; + } else { + func_801159EC(50); + } + this->actionFunc = func_80B109DC; + } else { + Actor_PickUp(&this->actor, globalCtx, sp24, 300.0f, 300.0f); + } +} + +void func_80B109DC(EnGb2* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_801518B0(globalCtx, this->unk_26E, &this->actor); + this->actionFunc = func_80B10634; + } else { + func_800B85E0(&this->actor, globalCtx, 300.0f, -1); + } +} + +void func_80B10A48(EnGb2* this, GlobalContext* globalCtx) { + this->unk_28A -= 5; + if (this->unk_28A < 5) { + this->unk_28A = 0; + + switch (ENGB2_GET_7(&this->actor)) { + case ENGB2_7_0: + Actor_MarkForDeath(&this->actor); + break; + + case ENGB2_7_1: + ActorCutscene_Stop(this->unk_282[this->unk_290]); + Actor_MarkForDeath(&this->actor); + break; + + case ENGB2_7_2: + ActorCutscene_Stop(this->unk_282[this->unk_290]); + if (this->unk_26E == 0x14FB) { + Flags_SetSwitch(globalCtx, ENGB2_GET_7F8(&this->actor)); + Actor_MarkForDeath(&this->actor); + } else { + this->actor.draw = NULL; + this->unk_26C |= 0x100; + this->actor.flags &= ~1; + this->actionFunc = func_80B111AC; + } + break; + } + } +} + +void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { + s32 mask = Player_GetMask(globalCtx); + + if (this->unk_28C != mask) { + this->unk_28C = Player_GetMask(globalCtx); + this->unk_26C &= ~0x80; + this->unk_26C &= ~0x20; + this->unk_26C &= ~0x40; + } + + if (func_80B0FA48(this, globalCtx)) { + this->unk_26C &= ~0x20; + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_26C & 0x40)) { + if ((this->unk_26E == 0x14EE) || (this->unk_26E == 0x14F4)) { + this->unk_26C |= 2; + } + func_801518B0(globalCtx, this->unk_26E, &this->actor); + this->unk_290 = 1; + this->unk_26C &= ~0x40; + this->actionFunc = func_80B10DAC; + } else if ((this->actor.xzDistToPlayer < 300.0f) && this->actor.isTargeted) { + this->unk_26C |= 0x40; + func_800B8614(&this->actor, globalCtx, 300.0f); + } + } else { + this->unk_26C &= ~0x40; + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_26C & 0x20)) { + this->actor.flags &= ~0x10000; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + if (this->unk_26E == 0x14EB) { + gSaveContext.weekEventReg[80] |= 0x40; + } else if (this->unk_26E == 0x14EF) { + gSaveContext.weekEventReg[80] |= 0x20; + } + this->unk_26C &= ~0x20; + this->unk_290 = 0; + this->unk_26C |= 0x80; + this->actionFunc = func_80B10DAC; + } else if (this->actor.xzDistToPlayer < 300.0f) { + if (!(this->unk_26C & 0x80)) { + this->actor.flags |= 0x10000; + this->unk_26C |= 0x20; + func_800B8614(&this->actor, globalCtx, 300.0f); + } + } + } +} + +void func_80B10DAC(EnGb2* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->unk_282[this->unk_290])) { + if (ENGB2_GET_7(&this->actor) == ENGB2_7_1) { + if (this->unk_290 != 2) { + this->actionFunc = func_80B10E98; + } else { + Flags_SetSwitch(globalCtx, ENGB2_GET_7F8(&this->actor)); + this->actionFunc = func_80B10868; + } + } else { + this->actionFunc = func_80B110F8; + } + ActorCutscene_StartAndSetFlag(this->unk_282[this->unk_290], &this->actor); + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->unk_282[this->unk_290]); + } +} + +void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if (this->unk_26C & 2) { + this->unk_26C &= ~2; + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + if ((this->unk_26E != 0x14E8) && (this->unk_26E != 0x14EA)) { + ActorCutscene_Stop(this->unk_282[this->unk_290]); + this->actionFunc = func_80B10B5C; + } else if (Flags_GetSwitch(globalCtx, ENGB2_GET_7F8(&this->actor))) { + this->actionFunc = func_80B10A48; + } else { + ActorCutscene_Stop(this->unk_282[this->unk_290]); + this->unk_290 = 2; + ActorCutscene_SetIntentToPlay(this->unk_282[this->unk_290]); + this->actionFunc = func_80B10DAC; + } + } else { + s32 temp; + + this->unk_26E = func_80B0FB24(this); + func_801518B0(globalCtx, this->unk_26E, &this->actor); + temp = this->unk_26E; + if ((temp == 0x14E7) || (temp == 0x14E9) || (temp == 0x14EC) || (temp == 0x14F0)) { + ActorCutscene_Stop(this->unk_282[this->unk_290]); + this->unk_290 = 1; + ActorCutscene_SetIntentToPlay(this->unk_282[this->unk_290]); + this->actionFunc = func_80B10DAC; + } + } + } +} + +void func_80B11048(EnGb2* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~0x10000; + func_801518B0(globalCtx, this->unk_26E, &this->actor); + this->actionFunc = func_80B10DAC; + } else if (this->actor.xzDistToPlayer < 300.0f) { + this->actor.flags |= 0x10000; + func_800B8614(&this->actor, globalCtx, 200.0f); + } +} + +void func_80B110F8(EnGb2* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if (this->unk_26C & 2) { + globalCtx->msgCtx.unk11F22 = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_26C &= ~2; + this->actionFunc = func_80B10A48; + } else { + this->unk_26E = func_80B0F97C(this); + func_801518B0(globalCtx, this->unk_26E, &this->actor); + } + } +} + +void func_80B111AC(EnGb2* this, GlobalContext* globalCtx) { + s32 index; + + if (globalCtx->roomCtx.currRoom.num == 1) { + return; + } + + switch (globalCtx->roomCtx.currRoom.num) { + case 2: + index = 1; + break; + + case 3: + case 4: + index = 2; + break; + + case 5: + index = 3; + break; + + default: + index = 0; + } + + this->actor.world.pos.x = D_80B11A00[index][0]; + this->actor.world.pos.y = D_80B11A00[index][1]; + this->actor.world.pos.z = D_80B11A00[index][2]; + this->actor.world.rot.y = D_80B11A00[index][3] * 182.04445f; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = func_80B11268; +} + +void func_80B11268(EnGb2* this, GlobalContext* globalCtx) { + if (globalCtx->roomCtx.currRoom.num == 1) { + this->unk_290 = 0; + this->unk_282[0] = this->actor.cutscene; + if (Flags_GetClear(globalCtx, 2) && Flags_GetClear(globalCtx, 3) && Flags_GetClear(globalCtx, 4) && + Flags_GetClear(globalCtx, 5)) { + this->unk_28A = 0xFF; + this->unk_26C &= ~0x100; + this->actor.flags |= 1; + this->actor.draw = EnGb2_Draw; + this->unk_26E = 0x14F9; + this->actionFunc = func_80B11048; + } else { + this->actionFunc = func_80B111AC; + } + } +} + +void func_80B11344(EnGb2* this, GlobalContext* globalCtx) { + if (gSaveContext.rupeeAccumulator == 0) { + func_80B0FE18(globalCtx); + } +} + +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 4, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2200, ICHAIN_STOP), }; -#endif +void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGb2* this = THIS; -extern ColliderCylinderInit D_80B11A40; -extern InitChainEntry D_80B11AC4[]; + if (func_80B0F660(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } -extern UNK_TYPE D_0600049C; + this->actor.room = -1; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ps_Skel_007230, &object_ps_Anim_00049C, this->jointTable, + this->morphTable, 12); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0F5E0.s") + switch (ENGB2_GET_7(&this->actor)) { + case ENGB2_7_0: + if (gSaveContext.weekEventReg[54] & 0x80) { + Actor_MarkForDeath(&this->actor); + } else if (gSaveContext.weekEventReg[52] & 0x20) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0F660.s") + if (gSaveContext.entranceIndex == 0x9C10) { + func_800FE484(); + this->actionFunc = func_80B10240; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0F6DC.s") + this->unk_28A = 255; + this->actor.flags |= 0x10; + this->actor.flags |= 0x2000000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0F728.s") + if (gSaveContext.eventInf[4] & 0x40) { + func_80B0F728(this, globalCtx); + } else { + func_80B0FBF0(this, globalCtx); + func_80B0F6DC(this); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0F7FC.s") + case ENGB2_7_1: + if ((globalCtx->curSpawn == 1) || (gSaveContext.weekEventReg[80] & 0x80)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0F8F8.s") + if (Flags_GetSwitch(globalCtx, ENGB2_GET_7F8(thisx))) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0F97C.s") + this->unk_28A = 255; + func_80B0FA04(this); + this->unk_28C = Player_GetMask(globalCtx); + this->actionFunc = func_80B10B5C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FA04.s") + case ENGB2_7_2: + this->unk_290 = 0; + this->unk_282[0] = this->actor.cutscene; + if (Flags_GetSwitch(globalCtx, ENGB2_GET_7F8(thisx))) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FA48.s") + if (Flags_GetClear(globalCtx, 2) && Flags_GetClear(globalCtx, 3) && Flags_GetClear(globalCtx, 4) && + Flags_GetClear(globalCtx, 5)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FB24.s") + if (gSaveContext.weekEventReg[76] & 0x80) { + this->actor.draw = NULL; + this->unk_26C |= 0x100; + this->actor.flags &= ~1; + this->actionFunc = func_80B111AC; + } else { + this->unk_28A = 255; + this->unk_26E = 0x14F5; + this->actionFunc = func_80B11048; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FBF0.s") + default: + Actor_MarkForDeath(&this->actor); + return; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FD8C.s") +void EnGb2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGb2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FE18.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FE7C.s") +void EnGb2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGb2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FEBC.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B0FFA8.s") + this->actionFunc(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10240.s") + if (!(this->unk_26C & 0x100)) { + func_80B0F5E0(this, globalCtx); + } + func_800E9250(globalCtx, &this->actor, &this->unk_270, &this->unk_276, this->actor.focus.pos); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10344.s") +s32 EnGb2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnGb2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10584.s") + if (limbIndex == 7) { + limbIndex = limbIndex; + Matrix_RotateY(this->unk_270.y, MTXMODE_APPLY); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10634.s") + if (limbIndex == 1) { + *dList = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10868.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10924.s") +void EnGb2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnGb2* this = THIS; + Vec3f sp18 = { 2400.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B109DC.s") + if (limbIndex == 7) { + Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10A48.s") +void EnGb2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnGb2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10B5C.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10DAC.s") + if (this->unk_28A == 255) { + func_8012C28C(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B10E98.s") + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B11048.s") + Scene_SetRenderModeXlu(globalCtx, 0, 1); + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnGb2_OverrideLimbDraw, EnGb2_PostLimbDraw, + &this->actor, POLY_OPA_DISP); + } else { + func_8012C2DC(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B110F8.s") + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, this->unk_28A); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B111AC.s") + Scene_SetRenderModeXlu(globalCtx, 1, 2); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnGb2_OverrideLimbDraw, EnGb2_PostLimbDraw, + &this->actor, POLY_XLU_DISP); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B11268.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B11344.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/EnGb2_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/EnGb2_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/EnGb2_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B1179C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/func_80B117FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gb2/EnGb2_Draw.s") + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h index 17274b82f1..c054c4ed24 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h @@ -7,11 +7,35 @@ struct EnGb2; typedef void (*EnGb2ActionFunc)(struct EnGb2*, GlobalContext*); +#define ENGB2_GET_7(thisx) ((thisx)->params & 7) +#define ENGB2_GET_7F8(thisx) (((thisx)->params & 0x7F8) >> 3) + +enum { + /* 0 */ ENGB2_7_0, + /* 1 */ ENGB2_7_1, + /* 2 */ ENGB2_7_2, +}; + typedef struct EnGb2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xD4]; - /* 0x0218 */ EnGb2ActionFunc actionFunc; - /* 0x021C */ char unk_21C[0x78]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[12]; + /* 0x1D0 */ Vec3s morphTable[12]; + /* 0x218 */ EnGb2ActionFunc actionFunc; + /* 0x21C */ ColliderCylinder collider; + /* 0x268 */ Actor* unk_268; + /* 0x26C */ u16 unk_26C; + /* 0x26E */ u16 unk_26E; + /* 0x270 */ Vec3s unk_270; + /* 0x276 */ Vec3s unk_276; + /* 0x27C */ s16 unk_27C; + /* 0x27E */ s16 unk_27E; + /* 0x280 */ s16 unk_280; + /* 0x282 */ s16 unk_282[3]; + /* 0x288 */ s16 unk_288; + /* 0x28A */ u8 unk_28A; + /* 0x28C */ s32 unk_28C; + /* 0x290 */ s16 unk_290; } EnGb2; // size = 0x294 extern const ActorInit En_Gb2_InitVars; diff --git a/src/overlays/actors/ovl_En_Geg/z_en_geg.c b/src/overlays/actors/ovl_En_Geg/z_en_geg.c index b915aef0d3..4209efe3fe 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -259,7 +259,7 @@ Vec3f* func_80BB19C0(Vec3f* arg0, EnGeg* this, GlobalContext* globalCtx) { u8 func_80BB1B14(EnGeg* this, GlobalContext* globalCtx) { Actor* explosive; - Actor* mm = func_ActorCategoryIterateById(globalCtx, NULL, ACTORCAT_ITEMACTION, ACTOR_EN_MM); + Actor* mm = SubS_FindActor(globalCtx, NULL, ACTORCAT_ITEMACTION, ACTOR_EN_MM); if (mm != NULL) { this->unk_4B0 = Math_Vec3f_Yaw(&this->actor.world.pos, &mm->world.pos); @@ -268,7 +268,7 @@ u8 func_80BB1B14(EnGeg* this, GlobalContext* globalCtx) { } } - explosive = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; + explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (explosive != NULL) { if ((explosive->id == ACTOR_EN_BOM) && func_80BB18FC(this, explosive)) { @@ -381,7 +381,7 @@ s32 func_80BB2088(EnGeg* this, GlobalContext* globalCtx) { return true; } - if (Actor_IsActorFacingLinkAndWithinRange(&this->actor, 300.0f, 0x7FF8) && + if (Actor_IsFacingAndNearPlayer(&this->actor, 300.0f, 0x7FF8) && ((this->unk_4AC == 5) || ((this->unk_4AC == 13) && (this->unk_496 == 0xD69)))) { this->unk_230 |= 2; func_80BB1D64(this, globalCtx); @@ -418,7 +418,7 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { if (sp27 != 0) { this->unk_230 &= ~8; - if (func_800B84D0(&this->actor, globalCtx) && (this->unk_230 & 4)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 4)) { if (sp27 == 1) { this->unk_496 = 0xD66; this->unk_49A = this->unk_49C[3]; @@ -443,7 +443,7 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { } else { this->unk_230 &= ~4; if (gSaveContext.weekEventReg[35] & 0x40) { - if (func_800B84D0(&this->actor, globalCtx) && (this->unk_230 & 8)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 8)) { this->unk_496 = 0xD62; func_801518B0(globalCtx, this->unk_496, &this->actor); this->unk_230 &= ~8; @@ -452,7 +452,7 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { func_800B8614(&this->actor, globalCtx, 300.0f); this->unk_230 |= 8; } - } else if (func_800B84D0(&this->actor, globalCtx) && (this->unk_230 & 8)) { + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 8)) { gSaveContext.weekEventReg[35] |= 0x40; this->unk_496 = 0xD5E; this->unk_49A = this->unk_49C[0]; @@ -532,7 +532,7 @@ void func_80BB2520(EnGeg* this, GlobalContext* globalCtx) { } void func_80BB26EC(EnGeg* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { switch (this->unk_496) { case 0xD5E: this->unk_49A = this->unk_49C[1]; @@ -554,7 +554,7 @@ void func_80BB26EC(EnGeg* this, GlobalContext* globalCtx) { } void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { switch (this->unk_496) { case 0xD63: globalCtx->msgCtx.unk11F22 = 0x43; @@ -596,7 +596,7 @@ void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx) { } void func_80BB2944(EnGeg* this, GlobalContext* globalCtx) { - u8 sp27 = func_80152498(&globalCtx->msgCtx); + u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 curFrame = this->skelAnime.curFrame; s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_4AC].animationSeg); @@ -619,7 +619,7 @@ void func_80BB2944(EnGeg* this, GlobalContext* globalCtx) { } void func_80BB2A54(EnGeg* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { if (this->unk_496 == 0xD65) { ActorCutscene_Stop(this->unk_498); this->unk_230 &= ~0x10; @@ -705,7 +705,7 @@ void func_80BB2E00(EnGeg* this, GlobalContext* globalCtx) { func_80BB2020(this, globalCtx); this->actionFunc = func_80BB30B4; } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_STAND_IMT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_STAND_IMT); } } else if (this->unk_4AC == 4) { if (Animation_OnFrame(&this->skelAnime, 0.0f)) { @@ -718,7 +718,7 @@ void func_80BB2E00(EnGeg* this, GlobalContext* globalCtx) { this->actionFunc = func_80BB3318; } } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_SIT_IMT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SIT_IMT); } } } @@ -737,7 +737,7 @@ void func_80BB2F7C(EnGeg* this, GlobalContext* globalCtx) { this->actionFunc = func_80BB2E00; } else { this->actor.speedXZ = 5.0f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } if (this->actor.bgCheckFlags & 1) { @@ -745,7 +745,7 @@ void func_80BB2F7C(EnGeg* this, GlobalContext* globalCtx) { func_800B9010(&this->actor, NA_SE_EN_GOLON_SIRLOIN_ROLL - SFX_FLAG); } else { this->unk_230 |= 0x80; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } } } @@ -753,7 +753,7 @@ void func_80BB2F7C(EnGeg* this, GlobalContext* globalCtx) { void func_80BB30B4(EnGeg* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (player->transformation == PLAYER_FORM_GORON) { this->unk_496 = 0xD6A; } else if (Player_GetMask(globalCtx) == PLAYER_MASK_DON_GERO) { @@ -793,12 +793,12 @@ void func_80BB31B8(EnGeg* this, GlobalContext* globalCtx) { } this->actionFunc = func_80BB32AC; } else { - func_800B8A1C(&this->actor, globalCtx, getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, getItemId, 300.0f, 300.0f); } } void func_80BB32AC(EnGeg* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB27D4; } else { @@ -831,7 +831,7 @@ void func_80BB3318(EnGeg* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } else { Math_ApproachF(&this->actor.speedXZ, 10.0f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } func_800B9010(&this->actor, NA_SE_EN_GOLON_SIRLOIN_ROLL - SFX_FLAG); @@ -855,7 +855,7 @@ void EnGeg_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 0.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, &object_oF1d_map_Anim_012DE0, this->jointTable, this->morphTable, 18); diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.c b/src/overlays/actors/ovl_En_Giant/z_en_giant.c index 547bfd8c63..85f1798e3e 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -5,6 +5,7 @@ */ #include "z_en_giant.h" +#include "objects/object_giant/object_giant.h" #define FLAGS 0x00000030 @@ -31,41 +32,21 @@ const ActorInit En_Giant_InitVars = { (ActorFunc)EnGiant_Draw, }; -extern AnimationHeader D_06002168; -extern Gfx D_06005A80[]; -extern Gfx D_06006280[]; -extern Gfx D_06007610[]; -extern Gfx D_06006A80[]; -extern FlexSkeletonHeader D_060079B0; -extern AnimationHeader D_06008394; -extern AnimationHeader D_060096E4; -extern AnimationHeader D_0600A1C4; -extern AnimationHeader D_0600ACA4; -extern AnimationHeader D_0600B784; -extern AnimationHeader D_0600C5D4; -extern AnimationHeader D_0600D040; -extern AnimationHeader D_0600DE84; -extern AnimationHeader D_060102A4; -extern AnimationHeader D_060116E4; -extern AnimationHeader D_06012A38; -extern AnimationHeader D_06013004; -extern AnimationHeader D_06013FE8; -extern AnimationHeader D_06015334; -extern AnimationHeader D_06017944; - -static AnimationHeader* sAnimationTable[] = { - &D_06008394, &D_060096E4, &D_060102A4, &D_060116E4, &D_06012A38, &D_06013004, &D_06013FE8, &D_06015334, - &D_06017944, &D_0600A1C4, &D_0600D040, &D_0600DE84, &D_0600ACA4, &D_0600B784, &D_0600C5D4, +static AnimationHeader* sAnimations[] = { + &gGiantLookUpStartAnim, &gGiantLookUpLoopAnim, &gGiantFallingOverAnim, &gGiantRaisedArmsStartAnim, + &gGiantRaisedArmsLoopAnim, &gGiantStruggleStartAnim, &gGiantStruggleLoopAnim, &gGiantIdleAnim, + &gGiantWalkingAnim, &gGiantBigCallStartAnim, &gGiantBigCallLoopAnim, &gGiantBigCallEndAnim, + &gGiantSmallCallStartAnim, &gGiantSmallCallLoopAnim, &gGiantSmallCallEndAnim, }; void EnGiant_ChangeAnimation(EnGiant* this, s16 newAnimationId) { if (newAnimationId >= GIANT_ANIMATION_LOOK_UP_START && newAnimationId < GIANT_ANIMATION_MAX) { if ((this->animationId == GIANT_ANIMATION_WALKING_LOOP && newAnimationId != GIANT_ANIMATION_WALKING_LOOP) || (newAnimationId == GIANT_ANIMATION_WALKING_LOOP && this->animationId != GIANT_ANIMATION_WALKING_LOOP)) { - Animation_Change(&this->skelAnime, sAnimationTable[newAnimationId], 1.0f, 0.0f, - Animation_GetLastFrame(&sAnimationTable[newAnimationId]->common), 2, 10.0f); + Animation_Change(&this->skelAnime, sAnimations[newAnimationId], 1.0f, 0.0f, + Animation_GetLastFrame(&sAnimations[newAnimationId]->common), 2, 10.0f); } else { - Animation_PlayOnce(&this->skelAnime, sAnimationTable[newAnimationId]); + Animation_PlayOnce(&this->skelAnime, sAnimations[newAnimationId]); } this->animationId = newAnimationId; } @@ -118,33 +99,34 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.uncullZoneScale = 2000.0f; this->actor.uncullZoneDownward = 2400.0f; Actor_SetScale(&this->actor, 0.32f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060079B0, &D_06002168, this->jointTable, this->morphTable, 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGiantSkel, &gGiantLargeStrideAnim, this->jointTable, + this->morphTable, GIANT_LIMB_MAX); EnGiant_ChangeAnimation(this, GIANT_ANIMATION_IDLE_LOOP); this->csAction = GIANT_CS_ACTION_NONE; this->actionFunc = EnGiant_PerformCutsceneActions; this->actor.draw = NULL; this->alpha = 0; this->actor.velocity.y = -10.0f; - this->actor.minVelocityY = -10.0f; + this->actor.terminalVelocity = -10.0f; this->actor.gravity = -5.0f; switch (type) { case GIANT_TYPE_CANYON_TERMINA_FIELD: case GIANT_TYPE_CANYON_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_CANYON_GIANTS_CHAMBER_AND_ENDING: - this->unk_24A = 0x1C6; + this->actorActionCommand = 0x1C6; break; case GIANT_TYPE_SWAMP_TERMINA_FIELD: case GIANT_TYPE_SWAMP_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_SWAMP_GIANTS_CHAMBER_AND_ENDING: - this->unk_24A = 0x1C7; + this->actorActionCommand = 0x1C7; break; case GIANT_TYPE_OCEAN_TERMINA_FIELD: case GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING: - this->unk_24A = 0x1C8; + this->actorActionCommand = 0x1C8; break; default: - this->unk_24A = 0x1C5; + this->actorActionCommand = 0x1C5; break; } @@ -153,24 +135,26 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - this->unk_24A = 0x1C5; + this->actorActionCommand = 0x1C5; Actor_SetScale(&this->actor, 0.32f); this->actionFunc = EnGiant_PerformClockTowerSuccessActions; - Animation_Change(&this->skelAnime, &D_060116E4, 0.0f, Animation_GetLastFrame(&D_060116E4) - 1.0f, - Animation_GetLastFrame(&D_060116E4), 2, 0.0f); + Animation_Change(&this->skelAnime, &gGiantRaisedArmsStartAnim, 0.0f, + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim) - 1.0f, + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), 2, 0.0f); this->actor.draw = EnGiant_Draw; this->actor.velocity.y = 0.0f; - this->actor.minVelocityY = 0.0f; + this->actor.terminalVelocity = 0.0f; this->actor.gravity = 0.0f; } if (GIANT_TYPE_IS_CLOCK_TOWER_FAILURE(type)) { Actor_SetScale(&this->actor, 0.32f); this->actionFunc = EnGiant_PlayClockTowerFailureAnimation; - Animation_Change(&this->skelAnime, &D_06013FE8, 1.0f, 0.0f, Animation_GetLastFrame(&D_06013004), 0, 0.0f); + Animation_Change(&this->skelAnime, &gGiantStruggleLoopAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGiantStruggleStartAnim), 0, 0.0f); this->actor.draw = EnGiant_Draw; this->actor.velocity.y = 0.0f; - this->actor.minVelocityY = 0.0f; + this->actor.terminalVelocity = 0.0f; this->actor.gravity = 0.0f; if (EnGiant_IsImprisoned(this)) { Actor_MarkForDeath(&this->actor); @@ -204,7 +188,7 @@ void EnGiant_Destroy(Actor* thisx, GlobalContext* globalCtx) { } /** - * The animations in sAnimationTable are organized such that looping animations + * The animations in sAnimations are organized such that looping animations * appear immediately after their respective starting animations. The point of * this function is to play the requested start animation if it has not been * played yet and play the respetive looping animation otherwise. @@ -266,8 +250,9 @@ void EnGiant_ChangeAnimationBasedOnCsAction(EnGiant* this) { } break; case GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER: - Animation_Change(&this->skelAnime, &D_060116E4, 0.0f, Animation_GetLastFrame(&D_060116E4) - 1.0f, - Animation_GetLastFrame(&D_060116E4), 2, 0.0f); + Animation_Change(&this->skelAnime, &gGiantRaisedArmsStartAnim, 0.0f, + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim) - 1.0f, + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), 2, 0.0f); break; } } @@ -333,10 +318,10 @@ void EnGiant_PlaySound(EnGiant* this) { if (this->actor.draw != NULL && this->alpha > 0) { if (this->animationId == GIANT_ANIMATION_WALKING_LOOP && (Animation_OnFrame(&this->skelAnime, 40.0f) || Animation_OnFrame(&this->skelAnime, 100.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KYOJIN_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_WALK); } if (this->animationId == GIANT_ANIMATION_FALLING_OVER && Animation_OnFrame(&this->skelAnime, 40.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KYOJIN_VOICE_FAIL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_VOICE_FAIL); } if (this->sfxId != 0xFFFF && ((this->animationId == GIANT_ANIMATION_BIG_CALL_START && this->skelAnime.curFrame >= 18.0f) || @@ -352,20 +337,19 @@ void EnGiant_PlaySound(EnGiant* this) { void EnGiant_UpdatePosition(EnGiant* this, GlobalContext* globalCtx, u32 actionIndex) { CsCmdActorAction* actorAction = globalCtx->csCtx.npcActions[actionIndex]; - f32 floatUnk10 = actorAction->unk0C.y; + f32 startPosY = actorAction->unk0C.y; s32 pad[2]; - f32 floatUnk1C = actorAction->unk18.y; - f32 functionTemp; + f32 endPosY = actorAction->unk18.y; + f32 scale = func_800F5A8C(actorAction->endFrame, actorAction->startFrame, globalCtx->csCtx.frames, globalCtx); - functionTemp = func_800F5A8C(actorAction->endFrame, actorAction->startFrame, globalCtx->csCtx.frames, globalCtx); - this->actor.world.pos.y = ((floatUnk1C - floatUnk10) * functionTemp) + floatUnk10; + this->actor.world.pos.y = ((endPosY - startPosY) * scale) + startPosY; } void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, this->unk_24A)) { - EnGiant_UpdatePosition(this, globalCtx, func_800EE200(globalCtx, this->unk_24A)); - if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0) { - this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0; + if (func_800EE29C(globalCtx, this->actorActionCommand)) { + EnGiant_UpdatePosition(this, globalCtx, func_800EE200(globalCtx, this->actorActionCommand)); + if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0) { + this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0; EnGiant_ChangeAnimationBasedOnCsAction(this); } EnGiant_UpdateAlpha(this); @@ -385,10 +369,10 @@ void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, GlobalContext* global void EnGiant_PerformCutsceneActions(EnGiant* this, GlobalContext* globalCtx) { this->actor.draw = EnGiant_Draw; - if (func_800EE29C(globalCtx, this->unk_24A)) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->unk_24A)); - if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0) { - this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0; + if (func_800EE29C(globalCtx, this->actorActionCommand)) { + func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->actorActionCommand)); + if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0) { + this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0; EnGiant_ChangeAnimationBasedOnCsAction(this); } EnGiant_UpdateAlpha(this); @@ -407,7 +391,7 @@ void EnGiant_Update(Actor* thisx, GlobalContext* globalCtx) { s32 blinkTimerTemp; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (this->blinkTimer == 0) { @@ -427,10 +411,10 @@ void EnGiant_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnGiant_PostLimbDrawOpa(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - if (limbIndex == 1) { + if (limbIndex == GIANT_LIMB_HEAD) { OPEN_DISPS(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, D_06007610); + gSPDisplayList(POLY_OPA_DISP++, gGiantBeardDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -440,21 +424,15 @@ void EnGiant_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis Gfx** gfx) { EnGiant* this = THIS; - if (limbIndex == 1) { - Matrix_CopyCurrentState(&this->unk_254); + if (limbIndex == GIANT_LIMB_HEAD) { + Matrix_CopyCurrentState(&this->headDrawMtxF); } } void EnGiant_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnGiant* this = THIS; - - /** - * 0 = eyes fully open face - * 1 = eyes half-closed face - * 2 = eyes fully closed face - */ - static TexturePtr sFaceTextures[] = { D_06005A80, D_06006280, D_06006A80 }; + static TexturePtr sFaceTextures[] = { gGiantFaceEyeOpenTex, gGiantFaceEyeHalfTex, gGiantFaceEyeClosedTex }; if (this->alpha > 0) { OPEN_DISPS(globalCtx->state.gfxCtx); @@ -479,10 +457,10 @@ void EnGiant_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnGiant_PostLimbDrawXlu, thisx, POLY_XLU_DISP); - Matrix_InsertMatrix(&this->unk_254, MTXMODE_NEW); + Matrix_InsertMatrix(&this->headDrawMtxF, MTXMODE_NEW); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, D_06007610); + gSPDisplayList(POLY_XLU_DISP++, gGiantBeardDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.h b/src/overlays/actors/ovl_En_Giant/z_en_giant.h index 6f50370f7b..e28aa2a32a 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.h +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.h @@ -86,6 +86,26 @@ typedef enum { /* 15 */ GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER } GiantCsActionIndex; +typedef enum { + /* 0 */ GIANT_LIMB_NONE, + /* 1 */ GIANT_LIMB_HEAD, + /* 2 */ GIANT_LIMB_LEFT_THIGH, + /* 3 */ GIANT_LIMB_LEFT_LOWER_LEG, + /* 4 */ GIANT_LIMB_LEFT_FOOT, + /* 5 */ GIANT_LIMB_RIGHT_THIGH, + /* 6 */ GIANT_LIMB_RIGHT_LOWER_LEG, + /* 7 */ GIANT_LIMB_RIGHT_FOOT, + /* 8 */ GIANT_LIMB_LEFT_SHOULDER, + /* 9 */ GIANT_LIMB_LEFT_UPPER_ARM, + /* 10 */ GIANT_LIMB_LEFT_FOREARM, + /* 11 */ GIANT_LIMB_LEFT_HAND, + /* 12 */ GIANT_LIMB_RIGHT_SHOULDER, + /* 13 */ GIANT_LIMB_RIGHT_UPPER_ARM, + /* 14 */ GIANT_LIMB_RIGHT_FOREARM, + /* 15 */ GIANT_LIMB_RIGHT_HAND, + /* 16 */ GIANT_LIMB_MAX, +} EnGiantLimbs; + struct EnGiant; typedef void (*EnGiantActionFunc)(struct EnGiant*, GlobalContext*); @@ -93,14 +113,14 @@ typedef void (*EnGiantActionFunc)(struct EnGiant*, GlobalContext*); typedef struct EnGiant { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[16]; - /* 0x1E8 */ Vec3s morphTable[16]; + /* 0x188 */ Vec3s jointTable[GIANT_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[GIANT_LIMB_MAX]; /* 0x248 */ s16 animationId; - /* 0x24A */ u16 unk_24A; + /* 0x24A */ u16 actorActionCommand; /* 0x24C */ u16 csAction; /* 0x24E */ s16 alpha; /* 0x250 */ u16 sfxId; - /* 0x254 */ MtxF unk_254; + /* 0x254 */ MtxF headDrawMtxF; /* 0x294 */ s16 faceIndex; /* 0x296 */ s16 blinkTimer; /* 0x298 */ EnGiantActionFunc actionFunc; diff --git a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c index 6946f58ec6..a58710030b 100644 --- a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c +++ b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c @@ -78,7 +78,7 @@ void EnGinkoMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnGinkoMan_SetupIdle(EnGinkoMan* this) { this->actor.flags |= 1; // targetable - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); this->actionFunc = EnGinkoMan_Idle; } @@ -86,13 +86,13 @@ void EnGinkoMan_Idle(EnGinkoMan* this, GlobalContext* globalCtx) { s32 yaw = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; EnGinkoMan_SwitchAnimation(this, globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { // Listen for dialogue start? + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if ((gSaveContext.roomInf[127][0] & 0xFFFF) == 0) { - func_800BDC5C(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x44C, &this->actor); this->curTextId = 0x44C; // would you like to make an account } else { - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { func_801518B0(globalCtx, 0x467, &this->actor); this->curTextId = 0x467; // "What's this? You need somethin' on a day like this? @@ -115,7 +115,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { switch (this->curTextId) { case 0x44C: // "Hey there, little guy! Won't you deposit some Rupees? (first dialogue) - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); if (gSaveContext.weekEventReg[10] & 8) { func_801518B0(globalCtx, 0x44E, &this->actor); this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" @@ -130,7 +130,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" break; case 0x44F: // "...So, what'll it be? Deposit Rupees Don't deposit Rupees" - func_800BDC5C(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x450, &this->actor); this->curTextId = 0x450; // "How much? How much? [rupee prompt] break; @@ -141,14 +141,14 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { if (this->isNewAccount == true) { this->isNewAccount = false; if (this->curTextId != 0x453) { // "That's it? That ain't nothing at all, big spender! - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); } func_801518B0(globalCtx, 0x461, &this->actor); this->curTextId = 0x461; // So, little guy, what's your name? } else { if (this->curTextId == 0x453) { // "That's it? That ain't nothing at all, big spender! - func_800BDC5C(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); } globalCtx->msgCtx.bankRupees = gSaveContext.roomInf[127][0] & 0xFFFF; @@ -178,17 +178,17 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, 0x45D, &this->actor); this->curTextId = 0x45D; // "What's this? You've already saved up 5000 Rupees?! } else if (this->previousBankValue < (s16)(gSaveContext.roomInf[127][0] & 0xFFFF)) { - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); func_801518B0(globalCtx, 0x45E, &this->actor); this->curTextId = 0x45E; // "...Hang on there, little guy. I can't take any more deposits. Sorry..." } else { - func_800BDC5C(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x460, &this->actor); this->curTextId = 0x460; // "Come back and deposit some after you save up a bunch!" } } else { - func_800BDC5C(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x460, &this->actor); this->curTextId = 0x460; // "Come back and deposit some after you save up a bunch!" } @@ -218,7 +218,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_SetupStamp(this); // stamp player break; case 0x465: // "There! Now I'll know you when I see you!" - func_800BDC5C(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); globalCtx->msgCtx.bankRupees = gSaveContext.roomInf[127][0] & 0xFFFF; func_801518B0(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" @@ -275,7 +275,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { break; case 0x476: // "...You haven't deposited that many Rupees, so that much isn't available for withdrawal. Do the // math! - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); case 0x475: // "What's this? Look, little guy, you can't hold this many rupees! You got that?" case 0x47C: // "Is that so? Think it over, little guy! So what are you gonna do?" case 0x47D: // duplicate of 48 @@ -342,7 +342,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { if (gSaveContext.rupees < globalCtx->msgCtx.bankRupeesSelected) { play_sound(NA_SE_SY_ERROR); - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); func_801518B0(globalCtx, 0x459, &this->actor); this->curTextId = 0x459; // HEY you dont have that much } else { @@ -354,7 +354,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) func_801518B0(globalCtx, 0x454, &this->actor); this->curTextId = 0x454; // Seriously? that's a lot. A lot! } else { - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); func_801518B0(globalCtx, 0x453, &this->actor); this->curTextId = 0x453; // That's it? That aint nothing at all } @@ -372,7 +372,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) } } else { // GINKOMAN_CHOICE_NO func_8019F230(); - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); if ((gSaveContext.roomInf[127][0] & 0xFFFF) == 0) { func_801518B0(globalCtx, 0x456, &this->actor); this->curTextId = 0x456; // Is that so? think about it @@ -405,7 +405,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) if ((s32)((gSaveContext.roomInf[127][0] & 0xFFFF)) < ((s32)(globalCtx->msgCtx.bankRupeesSelected + this->serviceFee))) { play_sound(NA_SE_SY_ERROR); - func_800BDC5C(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x476, &this->actor); this->curTextId = 0x476; // you dont have enough deposited to withdrawl } else if (CUR_CAPACITY(UPG_WALLET) < (globalCtx->msgCtx.bankRupeesSelected + gSaveContext.rupees)) { @@ -447,7 +447,7 @@ void EnGinkoMan_WaitForRupeeCount(EnGinkoMan* this, GlobalContext* globalCtx) { switch (this->curTextId) { case 0x450: // "How much? How much?" [rupee prompt] Set the amount with [Control Stick] and if (globalCtx->msgCtx.bankRupeesSelected == 0) { - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); func_801518B0(globalCtx, 0x457, &this->actor); this->curTextId = 0x457; // Zero Rupees? Cruel joke! } else { @@ -477,7 +477,7 @@ void EnGinkoMan_SetupDialogue(EnGinkoMan* this) { } void EnGinkoMan_Dialogue(EnGinkoMan* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { // get dialogue state? + switch (Message_GetState(&globalCtx->msgCtx)) { case 2: EnGinkoMan_SetupIdle(this); break; @@ -502,7 +502,7 @@ void EnGinkoMan_Dialogue(EnGinkoMan* this, GlobalContext* globalCtx) { } if ((this->skelAnime.animation == &D_060008C0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BANK_MAN_HAND_HIT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BANK_MAN_HAND_HIT); } } @@ -517,16 +517,16 @@ void EnGinkoMan_BankAward(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_SetupBankAward2(this); } else if (this->curTextId == 0x45B) { // "Whats this, you already saved up 200?" if (!(gSaveContext.weekEventReg[10] & 8)) { - func_800B8A1C(&this->actor, globalCtx, GI_WALLET_ADULT + CUR_UPG_VALUE(UPG_WALLET), 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_WALLET_ADULT + CUR_UPG_VALUE(UPG_WALLET), 500.0f, 100.0f); } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); } } else if (this->curTextId == 0x45C) { // "Whats this, you already saved up 5000?" - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); } else if (!(gSaveContext.weekEventReg[59] & 8)) { - func_800B8A1C(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); } } @@ -537,7 +537,7 @@ void EnGinkoMan_SetupBankAward2(EnGinkoMan* this) { // separate function to handle bank rewards... if the bank has a parent actor? might be unused void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (!(gSaveContext.weekEventReg[10] & 8) && (this->curTextId == 0x45B)) { // "What's this? You've already saved up 200 Rupees!?! Well, little guy, here's your special gift. Take // it!" @@ -545,44 +545,44 @@ void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, 0x47A, &this->actor); this->curTextId = 0x47A; // "See! Doesn't it hold more than your old one? } else { - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); func_801518B0(globalCtx, 0x47B, &this->actor); this->curTextId = 0x47B; // "Is that so? Think it over, little guy! So what are you gonna do?" } EnGinkoMan_SetupDialogue(this); } else if (this->curTextId == 0x45D) { // saved up 5000 rupees for HP - if ((func_80152498(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { if (!(gSaveContext.weekEventReg[59] & 8)) { gSaveContext.weekEventReg[59] |= 8; } EnGinkoMan_SetupIdle(this); } } else { - func_800B85E0(&this->actor, globalCtx, 500.0f, -1); + func_800B85E0(&this->actor, globalCtx, 500.0f, EXCH_ITEM_MINUS1); } } void EnGinkoMan_SetupStamp(EnGinkoMan* this) { - func_800BDC5C(&this->skelAnime, animations, GINKO_REACHING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_REACHING); this->actionFunc = EnGinkoMan_Stamp; } void EnGinkoMan_Stamp(EnGinkoMan* this, GlobalContext* globalCtx) { if ((this->curTextId == 0x464) // "Hey, relax! It doesn't leave any marks, and it's not gonna hurt." && (Animation_OnFrame(&this->skelAnime, 10.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HANKO); // "stamp" + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); // "stamp" } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { switch (this->curTextId) { case 0x464: // "Hey, relax! It doesn't leave any marks, and it's not gonna hurt." - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); func_801518B0(globalCtx, 0x465, &this->actor); this->curTextId = 0x465; // "There! Now I'll know you when I see you!" break; case 0x469: // "Excuse me, but let me take a look at you..." - func_800BDC5C(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); globalCtx->msgCtx.bankRupees = (gSaveContext.roomInf[127][0] & 0xFFFF); if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { func_801518B0(globalCtx, 0x46C, &this->actor); @@ -603,12 +603,12 @@ void EnGinkoMan_SwitchAnimation(EnGinkoMan* this, GlobalContext* globalCtx) { if (this->animTimer == 0) { if (this->skelAnime.animation != &D_06004A7C) { this->animTimer = 40; - func_800BDC5C(&this->skelAnime, animations, GINKO_ADVERTISING); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_ADVERTISING); } } } else if ((this->animTimer == 0) && (this->skelAnime.animation != &D_06000AC4)) { this->animTimer = 40; - func_800BDC5C(&this->skelAnime, animations, GINKO_AMAZED); + Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_AMAZED); } DECR(this->animTimer); diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c index ad39a682a2..91ae3270fa 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -579,7 +579,7 @@ void EnGirlA_Update2(EnGirlA* this, GlobalContext* globalCtx) { this->actor.shape.shadowScale = 4.0f; EnGirlA_TrySetMaskItemDescription(this, globalCtx); this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, 5.0f); + Actor_SetFocus(&this->actor, 5.0f); this->actor.shape.rot.x = 0; if (this->isSelected) { this->rotY += 0x1F4; diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index 5f3854a138..aee390e8dc 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -159,7 +159,7 @@ Actor* func_8094DEE0(EnGm* this, GlobalContext* globalCtx, u8 arg2, s16 arg3) { Actor* actor; while (true) { - actor = func_ActorCategoryIterateById(globalCtx, foundActor, arg2, arg3); + actor = SubS_FindActor(globalCtx, foundActor, arg2, arg3); foundActor = actor; if (actor == NULL) { break; @@ -212,7 +212,7 @@ EnDoor* func_8094DF90(GlobalContext* globalCtx, s32 arg1) { phi_a1 = -1; } - return (EnDoor*)func_8013A7C0(globalCtx, phi_a1); + return SubS_FindDoor(globalCtx, phi_a1); } s32 func_8094DFF8(EnGm* this, GlobalContext* globalCtx) { @@ -429,7 +429,7 @@ s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { switch (this->unk_3E0) { case 0: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIR_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); func_8094E054(this, globalCtx, 2); this->unk_3E2 = 0; this->unk_3E0++; @@ -481,7 +481,7 @@ s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { break; case 8: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIR_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); ActorCutscene_Stop(sp4A); this->unk_3E2 = 0; this->unk_3E0++; @@ -566,7 +566,7 @@ s32 func_8094EB1C(EnGm* this, GlobalContext* globalCtx) { ret = true; break; } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIR_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); func_8094E054(this, globalCtx, 2); this->unk_3E2 = 0; this->unk_3E0++; @@ -586,7 +586,7 @@ s32 func_8094EB1C(EnGm* this, GlobalContext* globalCtx) { break; case 2: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIR_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); this->unk_3E2 = 0; this->unk_3E0++; @@ -661,7 +661,7 @@ s32 func_8094EE84(EnGm* this, GlobalContext* globalCtx) { s32 ret = false; if (this->unk_3A4 & 7) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_8013AED4(&this->unk_3A4, 0, 7); this->unk_3E0 = 0; this->unk_3E4 = NULL; @@ -786,7 +786,7 @@ void func_8094F2E8(EnGm* this) { void func_8094F3D0(EnGm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s32 sp28 = func_80152498(&globalCtx->msgCtx); + s32 sp28 = Message_GetState(&globalCtx->msgCtx); s32 var = globalCtx->msgCtx.unk11F04; if ((&this->actor == player->targetActor) && ((var < 0xFF) || (var > 0x200)) && (sp28 == 3) && @@ -892,7 +892,7 @@ s32 func_8094F53C(EnGm* this, GlobalContext* globalCtx) { } if ((this->unk_3E8 == 6) && !(globalCtx->actorCtx.unk5 & 0x20) && Animation_OnFrame(&this->skelAnime, 20.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HANKO); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } return false; @@ -1260,7 +1260,7 @@ s32 func_809503F8(EnGm* this, GlobalContext* globalCtx) { if (this->unk_3E8 == 9) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; func_8013AED4(&this->unk_3A4, 3, 7); func_8094E054(this, globalCtx, 0); } else { @@ -1292,7 +1292,7 @@ s32 func_80950490(EnGm* this, GlobalContext* globalCtx) { switch (this->unk_3E8) { case 9: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; func_8013AED4(&this->unk_3A4, 3, 7); this->unk_3C8 = 4; this->unk_3CA = 4; @@ -1351,7 +1351,7 @@ s32 func_80950690(EnGm* this, GlobalContext* globalCtx) { case 7: this->unk_3D0 += 992; if (DECR(this->unk_3B8) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_GO_SLEEP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_GO_SLEEP); this->unk_3B8 = 30; } break; @@ -1389,7 +1389,7 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { Lib_Vec3f_TranslateAndRotateY(&this->unk_278, this->actor.world.rot.y, &sp38, &this->actor.world.pos); this->unk_3BA += this->unk_3C4; if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PIRATE_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } } @@ -1443,7 +1443,7 @@ s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { this->unk_250 = sp50; this->unk_238 = sp58; } else if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PIRATE_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } return false; } @@ -1513,7 +1513,7 @@ void func_80950CDC(EnGm* this, GlobalContext* globalCtx) { this->actor.flags &= ~1; sp20.unk0 = 0; } else { - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= 1; } this->unk_258 = sp20.unk0; @@ -1569,7 +1569,7 @@ void func_80950F2C(EnGm* this, GlobalContext* globalCtx) { sp2C = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x20E)]->unk0; if (this->unk_259 != (sp2C & 0xFF)) { if (sp2C == 3) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHAIR_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); } this->unk_259 = sp2C; func_8094E054(this, globalCtx, sp50[sp2C]); @@ -1597,7 +1597,7 @@ void EnGm_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 22.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 22.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060078B0, NULL, this->jointTable, this->morphTable, 20); this->unk_3E8 = -1; func_8094E054(this, globalCtx, 0); @@ -1641,7 +1641,7 @@ void EnGm_Update(Actor* thisx, GlobalContext* globalCtx) { func_8094F2E8(this); func_8013C964(&this->actor, globalCtx, this->unk_3B4, 30.0f, 0, this->unk_3A4 & 7); if ((this->unk_258 != 3) && (this->unk_258 != 5) && (this->unk_258 != 8)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); } func_8094E1DC(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index a79aef7ea5..15e0b7622a 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -5,6 +5,10 @@ */ #include "z_en_go.h" +#include "objects/object_oF1d_map/object_oF1d_map.h" +#include "objects/object_hakugin_demo/object_hakugin_demo.h" +#include "objects/object_taisou/object_taisou.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x02000019 @@ -23,8 +27,56 @@ void func_80A14EB0(EnGo* this, GlobalContext* globalCtx); void func_80A14FC8(EnGo* this, GlobalContext* globalCtx); void func_80A153FC(EnGo* this, GlobalContext* globalCtx); void func_80A157C4(EnGo* this, GlobalContext* globalCtx); +void func_80A15FEC(Actor* thisx, GlobalContext* globalCtx); + +static s32 D_80A16100[] = { + 0x00150800, 0x40010022, 0x00150200, 0x180E0E10, 0x0C0F0E11, 0x0C0F0E12, 0x0C0F0E13, 0x0C0F0E14, 0x0C111502, + 0x100E0E15, 0x0C100015, 0x0400110E, 0x0E160C0F, 0x0E170C0F, 0x0E180C11, 0x15041610, 0x0E0E190C, 0x10001504, + 0x000D0100, 0x050E0E31, 0x0C100E0E, 0x2F0C1001, 0x00050E0E, 0x2D0C100E, 0x0E2B0C10, +}; + +static s32 D_80A16164[] = { + 0x00150800, 0x7E01004D, 0x00150400, 0x180E0E1A, 0x0C170F0E, 0x230C180F, 0x0E240C0F, 0x0E250C12, 0x16111508, + 0x100E0E1A, 0x0C170F0E, 0x230C180F, 0x0E240C0F, 0x0E250C17, 0x0F0E260C, 0x180F0E27, 0x0C170F0E, 0x280C180F, + 0x0E290C17, 0x0F0E2A0C, 0x16111508, 0x100E0E1A, 0x0C170F0E, 0x1B0C180F, 0x0E1C0C0F, 0x0E1D0C0F, 0x0E1E0C17, + 0x0F0E1F0C, 0x180F0E20, 0x0C170F0E, 0x210C0F0E, 0x220C1611, 0x15081000, 0x1504000D, 0x0100050E, 0x0E320C10, + 0x0E0E300C, 0x10010005, 0x0E0E2E0C, 0x100E0E2C, 0x0C100000, +}; + +static s32 D_80A16208[2] = { 0xE0E520C, 0x10000000 }; + +static s32 D_80A16210[17] = { + 0x160400, 0x38010010, 0xE0E430C, 0xF0E440C, 0xF0E450C, 0x11188010, 0x160800, 0x1B0E0E46, 0xC0F0E47, + 0xC0F0E48, 0xC0F0E49, 0xC0F0E4A, 0xC111608, 0x11188010, 0xE0E4B0C, 0x100E0E42, 0xC100000, +}; + +static s32 D_80A16254[11] = { + 0x160400, 0x22010009, 0xE0E4D0C, 0xF0E4E0C, 0x10001701, 0xC0E0E, + 0x4F0C0F0E, 0x500C1117, 0x1100E0E, 0x510C100E, 0xE4C0C10, +}; + +static s32 D_80A16280[52] = { + 0x1001200, 0x12200008, 0xE0C8E0C, 0x11122010, 0xE0C8F0C, 0x10001240, 0x1D0E0C, 0x800C1112, 0x40001280, + 0x742500, 0xC006F00, 0x13010045, 0xF0C810C, 0x19001300, 0x1280005E, 0x25000C00, 0x59001301, 0x2F0E0C, + 0x810C0F0C, 0x820C0500, 0x1A00, 0x1A300E0C, 0x830C1209, 0x700, 0xE0C84, 0x160C1113, 0x1100E0C, + 0x840C1031, 0xE0C850C, 0x1029FFF2, 0x130200, 0xF0E0C88, 0xC0F0C89, 0xC05000A, 0xFFE3FFE3, 0xE0C860C, + 0x11128019, 0x213019, 0xFFC02900, 0x2C0E0C8C, 0xC050000, 0x50000, 0x8006400, 0x6320E0C, 0x8D0C1030, + 0x14FF9C12, 0x6003400, 0x130034, 0x700000E, 0xC870C16, 0x100E0C8B, 0xC100000, +}; + +static s32 D_80A16350[27] = { + 0x584000, 0x2903000E, 0x2001301, 0x180058, 0x80005119, 0x1E0059, 0x1004919, 0x160059, 0x2004119, + 0xE0059, 0x4003919, 0x2F0E0D, 0x4D0C1210, 0xE0D480C, 0xF0D490C, 0xF0D4A0C, 0x5000000, 0xF000F30, + 0xE0D4B0C, 0x15090000, 0xE0D4D0C, 0x1210310E, 0xD4C0C12, 0x100E0D4E, 0xC19FFD8, 0xE0D4F0C, 0x19FFD500, +}; + +static s32 D_80A163BC[4] = { 0x100060E, 0xDFE0C12, 0x100E0DFF, 0xC121000 }; +static s32 D_80A163CC[4] = { 0x100060E, 0xE000C12, 0x100E0E01, 0xC121000 }; +static s32 D_80A163DC[4] = { 0x100060E, 0xE020C12, 0x100E0E03, 0xC121000 }; +static s32 D_80A163EC[4] = { 0x100060E, 0xE040C12, 0x100E0E05, 0xC121000 }; +static s32 D_80A163FC[4] = { 0x100060E, 0xE060C12, 0x100E0E07, 0xC121000 }; +static s32 D_80A1640C[2] = { 0xE023A0C, 0x12100000 }; -#if 0 const ActorInit En_Go_InitVars = { ACTOR_EN_GO, ACTORCAT_NPC, @@ -37,32 +89,69 @@ const ActorInit En_Go_InitVars = { (ActorFunc)NULL, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80A16434 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 0 }, 100 }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A16460 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x02, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x02, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, 0, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A1648C = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, 0, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80A164B8 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80A164C4 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -97,156 +186,1887 @@ static DamageTable D_80A164C4 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; +static ActorAnimationEntryS sAnimations[] = { + { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, 0 }, { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, -4 }, + { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, 0 }, { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, -4 }, + { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, 2, 0 }, { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, 0 }, + { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, -4 }, { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, 2, -4 }, + { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, 0, 0 }, { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, 2, -4 }, + + { &object_taisou_Anim_004DD4, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_0016C8, 1.0f, 0, -1, 0, 0 }, + { &object_taisou_Anim_00283C, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_007764, 1.0f, 0, -1, 0, 0 }, + { &object_taisou_Anim_005EE0, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_002C48, 1.0f, 0, -1, 0, 0 }, + { &object_taisou_Anim_0031D8, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_005790, 1.0f, 0, -1, 0, 0 }, + + { &object_hakugin_demo_Anim_001420, 1.0f, 0, -1, 2, 0 }, { &object_hakugin_demo_Anim_001A4C, 1.0f, 0, -1, 0, -4 }, + { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, 2, 0 }, { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, 0, -4 }, +}; + +EnGoStruct* func_80A10FD0(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6) { + s32 i; + + for (i = 16; i < 32; i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = 7; + ptr->unk_01 = (Rand_ZeroOne() * (2.0f * (arg6 / 3.0f))) + (arg6 / 3.0f); + ptr->unk_02 = ptr->unk_01; + ptr->unk_10 = arg1; + ptr->unk_1C = arg2; + ptr->unk_28 = arg3; + ptr->unk_34 = arg4; + ptr->unk_38 = arg5; + break; + } + } + + return ptr; +} + +void func_80A11144(EnGoStruct ptr[], GlobalContext* globalCtx) { + s32 pad; + s32 i; + s32 flag = false; + f32 temp; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < 32; i++, ptr++) { + + if (ptr->unk_00 == 7) { + gDPPipeSync(POLY_XLU_DISP++); + + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_0031A0); + flag = true; + } + + Matrix_StatePush(); + + temp = ((f32)ptr->unk_02 / ptr->unk_01); + temp *= 255; + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (u8)temp); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_02 + (i * 3)) * 3, + (ptr->unk_02 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + + Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(ptr->unk_34, ptr->unk_34, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_003258); + + Matrix_StatePop(); + if (globalCtx->state.gfxCtx) {} + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A1143C(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6, s32 arg7) { + s32 i; + + for (i = 16; i < 32; i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = arg7 + 4; + + ptr->unk_01 = (Rand_ZeroOne() * (2.0f * (arg6 / 3.0f))) + (arg6 / 3.0f); + ptr->unk_02 = ptr->unk_01; + + ptr->unk_10 = arg1; + ptr->unk_1C = arg2; + ptr->unk_28 = arg3; + ptr->unk_34 = arg4; + ptr->unk_38 = arg5; + break; + } + } +} + +void func_80A115B4(EnGoStruct ptr[], GlobalContext* globalCtx) { + static TexturePtr D_80A16644[] = { + &gameplay_keep_Tex_08F7E0, &gameplay_keep_Tex_08F3E0, &gameplay_keep_Tex_08EFE0, &gameplay_keep_Tex_08EBE0, + &gameplay_keep_Tex_08E7E0, &gameplay_keep_Tex_08E3E0, &gameplay_keep_Tex_08DFE0, &gameplay_keep_Tex_08DBE0, + }; + static Color_RGBA8 D_80A16664[] = { + { 255, 255, 255, 0 }, + { 170, 130, 90, 0 }, + { 0, 0, 0, 0 }, + }; + static Color_RGBA8 D_80A16670[] = { + { 255, 255, 255, 0 }, + { 100, 60, 20, 0 }, + { 0, 0, 0, 0 }, + }; + s32 i; + u8 flag = false; + f32 temp; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < 32; i++, ptr++) { + if ((ptr->unk_00 >= 4) && (ptr->unk_00 < 7)) { + if (!flag) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014CF0); + flag = true; + } + Matrix_StatePush(); + + temp = (f32)ptr->unk_02 / ptr->unk_01; + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80A16664[(s32)ptr->unk_00 - 4].r, + D_80A16664[(s32)ptr->unk_00 - 4].g, D_80A16664[(s32)ptr->unk_00 - 4].b, (u8)(temp * 255)); + gDPSetEnvColor(POLY_XLU_DISP++, D_80A16670[(s32)ptr->unk_00 - 4].r, D_80A16670[(s32)ptr->unk_00 - 4].g, + D_80A16670[(s32)ptr->unk_00 - 4].b, 0); + + Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_Scale(ptr->unk_34, ptr->unk_34, 1.0f, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A16644[(s32)(temp * 7.0f)])); + gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014D00); + + Matrix_StatePop(); + } + if (globalCtx->state.gfxCtx) {} + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +#ifdef NON_MATCHING +void func_80A118F8(EnGoStruct ptr[32], Vec3f arg1) { + static u8 D_80A1667C[] = { + 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, + }; + EnGoStruct* ptr2 = &ptr[16]; + s32 i; + Vec3f spB4; + Vec3f spA8; + f32 temp_f20; + + for (i = 0; i < 16; i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_10 = arg1; + ptr->unk_10.y += 56.0f; + + ptr->unk_04.x = (Rand_ZeroOne() - 0.5f) * 5460.0f; + ptr->unk_04.y = (Rand_ZeroOne() - 0.5f) * 5460.0f; + ptr->unk_04.z = (Rand_ZeroOne() - 0.5f) * 5460.0f; + + temp_f20 = (Rand_ZeroOne() * 4.0f) + 6.0f; + ptr->unk_28.x = Math_SinS(i * 0x1000) * temp_f20; + ptr->unk_28.z = Math_CosS(i * 0x1000) * temp_f20; + ptr->unk_28.y = (Rand_ZeroOne() * 3.0f) + 6.0f; + + ptr->unk_1C = gZeroVec3f; + ptr->unk_1C.y = -0.8f; + + ptr->unk_01 = ptr->unk_02 = 1; + ptr->unk_00 = D_80A1667C[i]; + + spB4.x = ((Rand_ZeroOne() - 0.5f) * 80.0f) + ptr->unk_10.x; + spB4.y = ((Rand_ZeroOne() - 0.5f) * 40.0f) + ptr->unk_10.y; + spB4.z = ((Rand_ZeroOne() - 0.5f) * 80.0f) + ptr->unk_10.z; + + spA8 = gZeroVec3f; + spA8.y = (Rand_ZeroOne() * 3.0f) + 1.0f; + + func_80A1143C(ptr2, spB4, gZeroVec3f, spA8, 0.6f, 0.2f, 16, 0); + } + } +} +#else +static u8 D_80A1667C[] = { + 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, +}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A118F8.s") #endif -extern ColliderSphereInit D_80A16434; -extern ColliderCylinderInit D_80A16460; -extern ColliderCylinderInit D_80A1648C; -extern CollisionCheckInfoInit2 D_80A164B8; -extern DamageTable D_80A164C4; +void func_80A11BF8(EnGoStruct ptr[], f32 arg1) { + f32 test; + f32 test2; + f32 x; + f32 z; -extern UNK_TYPE D_06000458; -extern UNK_TYPE D_06003258; -extern UNK_TYPE D_060091A8; -extern UNK_TYPE D_06011AC8; -extern UNK_TYPE D_06014D00; + ptr->unk_10.x += ptr->unk_28.x; + ptr->unk_10.y += ptr->unk_28.y; + ptr->unk_10.z += ptr->unk_28.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A10FD0.s") + ptr->unk_28.y += ptr->unk_1C.y; + ptr->unk_34 += ptr->unk_38; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A11144.s") + if (ptr->unk_10.y < arg1) { + ptr->unk_10.y = arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A1143C.s") + ptr->unk_00 = 4; + ptr->unk_01 = (Rand_ZeroOne() * 8.0f) + 4.0f; + ptr->unk_02 = ptr->unk_01; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A115B4.s") + ptr->unk_28 = gZeroVec3f; + ptr->unk_28.y = (Rand_ZeroOne() * 3.0f) + 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A118F8.s") + ptr->unk_34 = 0.4f; + ptr->unk_38 = 0.1f; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A11BF8.s") + if (ptr->unk_28.x != 0.0f) { + x = ptr->unk_28.x / fabsf(ptr->unk_28.x); + x *= ((sREG(13) + 140) * 0.01f); + Math_StepToF(&ptr->unk_28.x, x, (sREG(14) + 40) * 0.01f); + } + if (ptr->unk_28.z != 0.0f) { + z = ptr->unk_28.z / fabsf(ptr->unk_28.z); + z *= ((sREG(13) + 140) * 0.01f); + Math_StepToF(&ptr->unk_28.z, z, (sREG(14) + 40) * 0.01f); + } + + ptr->unk_0A.x += ptr->unk_04.x; + ptr->unk_0A.y += ptr->unk_04.y; + ptr->unk_0A.z += ptr->unk_04.z; +} + +#ifdef NON_MATCHING +void func_80A11EC0(EnGoStruct ptr[], GlobalContext* globalCtx, Gfx arg2[], Gfx arg3[], u8 arg4) { + s32 i; + u8 flag = false; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < 16; i++, ptr++) { + if (ptr->unk_00 == arg4) { + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, arg2); + flag = true; + } + + Matrix_StatePush(); + Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_Scale(0.08f, 0.08f, 0.08f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(ptr->unk_0A.z, MTXMODE_APPLY); + Matrix_InsertXRotation_s(ptr->unk_0A.x, MTXMODE_APPLY); + Matrix_RotateY(ptr->unk_0A.y, MTXMODE_APPLY); + + if (1) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, arg3); + } + + Matrix_StatePop(); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A11EC0.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A1203C.s") +void func_80A1203C(EnGo* this) { + EnGoStruct* ptr = this->unk_3F8; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A1213C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_3F8); i++, ptr++) { + if (ptr->unk_00 != 0) { + if (ptr->unk_02 == 0) { + ptr->unk_00 = 0; + } else if ((ptr->unk_00 > 0) && (ptr->unk_00 < 4)) { + func_80A11BF8(ptr, this->actor.world.pos.y); + } else { + ptr->unk_10.x += ptr->unk_28.x; + ptr->unk_10.y += ptr->unk_28.y; + ptr->unk_10.z += ptr->unk_28.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A121F4.s") + ptr->unk_28.x += ptr->unk_1C.x; + ptr->unk_28.y += ptr->unk_1C.y; + ptr->unk_28.z += ptr->unk_1C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A1222C.s") + ptr->unk_34 += ptr->unk_38; + ptr->unk_02--; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A122EC.s") +void func_80A1213C(EnGo* this, GlobalContext* globalCtx) { + func_80A11EC0(this->unk_3F8, globalCtx, object_oF1d_map_DL_0003D0, object_oF1d_map_DL_000458, 1); + func_80A11EC0(this->unk_3F8, globalCtx, object_oF1d_map_DL_0008C0, object_oF1d_map_DL_000948, 2); + func_80A11EC0(this->unk_3F8, globalCtx, object_oF1d_map_DL_000D50, object_oF1d_map_DL_000DD8, 3); + func_80A11144(this->unk_3F8, globalCtx); + func_80A115B4(this->unk_3F8, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A123A0.s") +s32 func_80A121F4(GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A124A0.s") + if ((player->transformation == PLAYER_FORM_GORON) && (player->stateFlags3 & 0x2000000)) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A124FC.s") +s32 func_80A1222C(EnGo* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A125BC.s") + if (((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.unk1202A == 3) && + (globalCtx->msgCtx.unk1202E == 1) && (this->unk_3EC == 0) && (this->actor.xzDistToPlayer < 400.0f)) || + (!(gSaveContext.weekEventReg[22] & 4) && (globalCtx->sceneNum == SCENE_16GORON_HOUSE) && + (gSaveContext.sceneSetupIndex == 0) && (this->unk_3EC == 0) && (globalCtx->csCtx.unk_12 == 1))) { + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12660.s") +s32 func_80A122EC(EnGo* this) { + static Vec3f D_80A1668C = { 0.0f, 100.0f, 160.0f }; + s32 pad; + f32 sp20 = 58.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A126BC.s") + if (ENGO_GET_F(&this->actor) == ENGO_F_8) { + Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80A1668C, + &this->actor.focus.pos); + } else { + if ((this->unk_390 & 0x200) || (this->unk_390 & 0x100)) { + sp20 = this->actor.shape.yOffset; + } + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); + this->actor.focus.pos.y += sp20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12774.s") + this->actor.focus.rot.x = this->actor.world.rot.x; + this->actor.focus.rot.y = this->actor.world.rot.y; + this->actor.focus.rot.z = this->actor.world.rot.z; + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12868.s") +void func_80A123A0(EnGo* this, GlobalContext* globalCtx) { + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12954.s") + Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12A64.s") + this->colliderSphere.dim.worldSphere.center.x = sp2C.x; + this->colliderSphere.dim.worldSphere.center.y = sp2C.y; + this->colliderSphere.dim.worldSphere.center.y += (s16)this->actor.shape.yOffset; + this->colliderSphere.dim.worldSphere.center.z = sp2C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12B78.s") + this->colliderSphere.dim.modelSphere.radius = 48; + this->colliderSphere.dim.worldSphere.radius = + this->colliderSphere.dim.modelSphere.radius * this->colliderSphere.dim.scale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12C48.s") + if (func_80A121F4(globalCtx)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12D6C.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12DF4.s") +void func_80A124A0(EnGo* this, GlobalContext* globalCtx) { + this->colliderSphere.dim.worldSphere.radius = + this->colliderSphere.dim.modelSphere.radius * this->colliderSphere.dim.scale; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12E80.s") +void func_80A124FC(EnGo* this, GlobalContext* globalCtx) { + Vec3f sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A12FE8.s") + Math_Vec3f_Copy(&sp1C, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A131F8.s") + this->colliderSphere.dim.worldSphere.center.x = sp1C.x; + this->colliderSphere.dim.worldSphere.center.y = sp1C.y; + this->colliderSphere.dim.worldSphere.center.y += (s16)this->actor.shape.yOffset; + this->colliderSphere.dim.worldSphere.center.z = sp1C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A132C8.s") + this->colliderSphere.dim.modelSphere.radius = 20; + this->colliderSphere.dim.worldSphere.radius = + this->colliderSphere.dim.modelSphere.radius * this->colliderSphere.dim.scale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A133A8.s") + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A13400.s") +void func_80A125BC(EnGo* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A134B0.s") + Math_Vec3f_ToVec3s(&this->colliderCylinder.dim.pos, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A134F4.s") + this->colliderCylinder.dim.radius = 46; + this->colliderCylinder.dim.height = 78; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A13564.s") + if (this->unk_3C6 == 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A136B8.s") +void func_80A12660(EnGo* this, GlobalContext* globalCtx) { + Math_Vec3f_ToVec3s(&this->colliderCylinder.dim.pos, &this->actor.world.pos); + this->colliderCylinder.dim.radius = 24; + this->colliderCylinder.dim.height = 62; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A13728.s") +void func_80A126BC(EnGo* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A137C0.s") + if (!(player->stateFlags2 & 0x4000)) { + if (this->unk_3C6 != 0) { + this->unk_3C6--; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A139E4.s") + if (ENGO_GET_F(&this->actor) == ENGO_F_8) { + func_80A124A0(this, globalCtx); + } else if (this->unk_390 & 0x100) { + func_80A123A0(this, globalCtx); + } else if (this->unk_390 & 0x200) { + func_80A124FC(this, globalCtx); + } else if (this->unk_390 & 0x400) { + func_80A125BC(this, globalCtx); + } else { + func_80A12660(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A13B1C.s") +s32 func_80A12774(EnGo* this, GlobalContext* globalCtx) { + if (!(this->unk_390 & 7) || !Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A13E80.s") + if ((ENGO_GET_F(&this->actor) != ENGO_F_8) && (ENGO_GET_F(&this->actor) != ENGO_F_1)) { + if (!(this->unk_390 & 0x200)) { + this->unk_390 |= 8; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14018.s") + if ((ENGO_GET_F(&this->actor) == ENGO_F_5) || (ENGO_GET_F(&this->actor) == ENGO_F_6) || + (ENGO_GET_F(&this->actor) == ENGO_F_7)) { + this->unk_3BC = 0; + this->unk_3BE = 0; + this->unk_390 |= 0x20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14104.s") + func_8013AED4(&this->unk_390, 0, 7); + this->unk_3C0 = 0; + this->unk_3C4 = 0; + this->unk_18C = this->actionFunc; + this->actionFunc = func_80A157C4; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A141D4.s") +s32 func_80A12868(EnGo* this, GlobalContext* globalCtx) { + this->unk_390 &= ~0x800; + this->unk_390 &= ~0x1000; + this->unk_390 &= ~0x2000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A1428C.s") + if ((this->colliderCylinder.base.atFlags & AT_HIT) || (this->colliderSphere.base.atFlags & AT_HIT)) { + this->colliderCylinder.base.atFlags &= ~AT_HIT; + this->colliderSphere.base.atFlags &= ~AT_HIT; + this->unk_390 |= 0x800; + this->unk_3C6 = 0x28; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14324.s") + if ((this->colliderCylinder.base.acFlags & AC_HIT) || (this->colliderSphere.base.acFlags & AC_HIT)) { + this->colliderCylinder.base.acFlags &= ~AC_HIT; + this->colliderSphere.base.acFlags &= ~AC_HIT; + this->unk_390 |= 0x1000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A143A8.s") + if ((this->colliderCylinder.base.ocFlags1 & OC1_HIT) || (this->colliderSphere.base.ocFlags1 & OC1_HIT)) { + this->colliderCylinder.base.ocFlags1 &= ~OC1_HIT; + this->colliderSphere.base.ocFlags1 &= ~OC1_HIT; + this->unk_390 |= 0x2000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14430.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A1449C.s") +s32 func_80A12954(EnGo* this, GlobalContext* globalCtx) { + if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (globalCtx->csCtx.state != 0) && (this->actor.draw != NULL) && + (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && + (globalCtx->csCtx.unk_12 == 0)) { + if (this->unk_3F0 == 0) { + this->actor.flags &= ~1; + this->unk_394 = 255; + this->unk_3F0 = 1; + this->unk_18C = this->actionFunc; + } + func_8013AED4(&this->unk_390, 0, 7); + this->actionFunc = func_80A14FC8; + } else if (this->unk_3F0 != 0) { + this->actor.flags |= 1; + this->unk_394 = 255; + this->unk_3F0 = 0; + func_8013AED4(&this->unk_390, 3, 7); + this->actionFunc = this->unk_18C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A144F4.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A145AC.s") +s32 func_80A12A64(EnGo* this, GlobalContext* globalCtx) { + s8 objIdx = this->actor.objBankIndex; + s8 objIdx2 = -1; + s32 ret = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14668.s") + if ((this->unk_3DC >= 18) && (this->unk_289 >= 0)) { + objIdx2 = this->unk_289; + } else if ((this->unk_3DC >= 10) && (this->unk_288 >= 0)) { + objIdx2 = this->unk_288; + } else if (this->unk_3DC < 10) { + objIdx2 = this->actor.objBankIndex; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A146CC.s") + if (objIdx2 >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx2].segment); + this->skelAnime.playSpeed = this->unk_398; + ret = SkelAnime_Update(&this->skelAnime); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx].segment); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14798.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A149B0.s") +s32 func_80A12B78(EnGo* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state == 0) { + if (this->unk_3DC == 4) { + if (Animation_OnFrame(&this->skelAnime, 2.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_CIRCLE); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14B30.s") + if (Animation_OnFrame(&this->skelAnime, 22.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SIT_IMT); + } + } else if ((this->unk_3DC == 2) || (this->unk_3DC == 3)) { + if (Animation_OnFrame(&this->skelAnime, 2.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_CIRCLE_OFF); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14E14.s") + if (Animation_OnFrame(&this->skelAnime, 24.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_STAND_IMT); + } + } + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14E74.s") +s32 func_80A12C48(EnGo* this, GlobalContext* globalCtx, s32 arg2) { + s8 objIdx = this->actor.objBankIndex; + s8 objIdx2 = -1; + s32 ret = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14EB0.s") + if ((arg2 >= 18) && (this->unk_289 >= 0)) { + objIdx2 = this->unk_289; + } else if ((arg2 >= 10) && (this->unk_288 >= 0)) { + objIdx2 = this->unk_288; + } else if (arg2 < 10) { + objIdx2 = this->actor.objBankIndex; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A14FC8.s") + if (objIdx2 >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx2].segment); + this->unk_3DC = arg2; + ret = func_8013BC6C(&this->skelAnime, sAnimations, arg2); + this->unk_398 = this->skelAnime.playSpeed; + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx].segment); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A153FC.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A15684.s") +void func_80A12D6C(EnGo* this) { + if ((this->unk_390 & 0x20) && (DECR(this->unk_3BC) == 0)) { + this->unk_3BE++; + if (this->unk_3BE >= 4) { + this->unk_3BC = Rand_S16Offset(30, 30); + this->unk_3BE = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A157C4.s") +void func_80A12DF4(EnGo* this, GlobalContext* globalCtx) { + if (this->unk_3D4 == 0) { + func_80A12C48(this, globalCtx, 9); + this->unk_3D4++; + } else if ((this->unk_3D4 == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A12C48(this, globalCtx, 6); + this->unk_3D4++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/EnGo_Init.s") +s32 func_80A12E80(EnGo* this, GlobalContext* globalCtx) { + u16 temp = globalCtx->msgCtx.unk11F04; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/EnGo_Destroy.s") + if (ENGO_GET_F(&this->actor) != ENGO_F_4) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/EnGo_Update.s") + if (player->stateFlags1 & 0x40) { + if (this->unk_392 != temp) { + switch (temp) { + case 0xE1A: + this->unk_390 |= 8; + this->unk_38C = this->actor.child; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A15B80.s") + case 0xE1D: + case 0xE25: + if (ENGO_GET_70(&this->actor) == ENGO_70_1) { + this->unk_38C = &GET_PLAYER(globalCtx)->actor; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A15D04.s") + case 0xE27: + if (ENGO_GET_70(&this->actor) == ENGO_70_1) { + this->unk_38C = this->actor.child; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A15E38.s") + case 0xE16: + case 0xE1E: + this->unk_190 = func_80A12DF4; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A15FEC.s") + case 0xE1F: + if (ENGO_GET_70(&this->actor) == ENGO_70_0) { + this->unk_38C = &GET_PLAYER(globalCtx)->actor; + } + break; + } + } + this->unk_3F4 = 1; + this->unk_392 = temp; + } else if (this->unk_3F4 != 0) { + this->unk_3F4 = 0; + this->unk_190 = NULL; + this->unk_392 = 0; + func_80A12C48(this, globalCtx, 5); + this->unk_390 &= ~8; + } + + if (this->unk_190 != NULL) { + this->unk_190(this, globalCtx); + } + + return false; +} + +s32 func_80A12FE8(EnGo* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; + + Math_Vec3f_Copy(&sp40, &this->unk_38C->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); + + Math_ApproachS(&this->unk_3B2, (sp32 - this->unk_3B6) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_3B2 = CLAMP(this->unk_3B2, -0x1FFE, 0x1FFE); + + Math_ApproachS(&this->unk_3B6, (sp32 - this->unk_3B2) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_3B6 = CLAMP(this->unk_3B6, -0x1C70, 0x1C70); + + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + + if (this->unk_38C->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_38C)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_38C->focus.pos); + } + + Math_ApproachS(&this->unk_3B0, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_3B4, 4, 0x2AA8); + this->unk_3B0 = CLAMP(this->unk_3B0, -0x1554, 0x1554); + + Math_ApproachS(&this->unk_3B4, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_3B0, 4, 0x2AA8); + this->unk_3B4 = CLAMP(this->unk_3B4, -0xE38, 0xE38); + + return false; +} + +s32 func_80A131F8(EnGo* this, GlobalContext* globalCtx) { + if (this->unk_3F4 == 0) { + this->unk_38C = &GET_PLAYER(globalCtx)->actor; + } + + func_80A12E80(this, globalCtx); + + if (this->unk_390 & 8) { + this->unk_390 &= ~0x40; + this->unk_390 |= 0x10; + func_80A12FE8(this, globalCtx); + } else if (this->unk_390 & 0x10) { + this->unk_390 &= ~0x10; + this->unk_3B0 = 0; + this->unk_3B2 = 0; + this->unk_3B4 = 0; + this->unk_3B6 = 0; + this->unk_3BA = 0x14; + } else if (DECR(this->unk_3BA) == 0) { + this->unk_390 |= 0x40; + this->unk_3BA = 0x14; + } + + return true; +} + +void func_80A132C8(EnGo* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 temp_v1 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); + + if ((fabsf(this->actor.playerHeightRel) > 20.0f) || (this->actor.xzDistToPlayer > 300.0f)) { + func_8013AED4(&this->unk_390, 3, 7); + } else if ((player->transformation != PLAYER_FORM_GORON) || (ABS_ALT(temp_v1) >= 0x1C70) || + (gSaveContext.weekEventReg[21] & 4) || (gSaveContext.weekEventReg[21] & 8)) { + func_8013AED4(&this->unk_390, 3, 7); + } else { + func_8013AED4(&this->unk_390, 4, 7); + } +} + +void func_80A133A8(EnGo* this, GlobalContext* globalCtx) { + if (gSaveContext.weekEventReg[21] & 8) { + func_8013AED4(&this->unk_390, 3, 7); + } else { + func_8013AED4(&this->unk_390, 4, 7); + } +} + +Actor* func_80A13400(EnGo* this, GlobalContext* globalCtx) { + Actor* actor; + Actor* retActor = NULL; + + while (true) { + actor = SubS_FindActor(globalCtx, retActor, ACTORCAT_NPC, ACTOR_EN_GO); + retActor = actor; + + if ((actor != NULL) && ((EnGo*)actor != this) && (ENGO_GET_F(actor) == ENGO_F_4) && + (ENGO_GET_70(actor) == ENGO_70_0)) { + return retActor; + } + + if (actor == NULL) { + break; + } + + actor = actor->next; + if (actor == NULL) { + break; + } + retActor = actor; + } + + return NULL; +} + +void func_80A134B0(EnGo* this, GlobalContext* globalCtx, s32 arg2) { + if ((gSaveContext.weekEventReg[18] & 0x80) || (globalCtx->actorCtx.unk5 & 1) || arg2) { + this->colliderSphere.dim.modelSphere.radius = 300; + } else { + this->colliderSphere.dim.modelSphere.radius = 380; + } +} + +s32 func_80A134F4(EnGo* this, s16 arg1) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } else if (ActorCutscene_GetCanPlayNext(arg1)) { + ActorCutscene_StartAndSetUnkLinkFields(arg1, &this->actor); + return true; + } + ActorCutscene_SetIntentToPlay(arg1); + return false; +} + +s32 func_80A13564(EnGo* this, f32 arg1, f32 arg2, s32 arg3) { + s32 pad; + f32 temp_f0 = 1.0f; + f32 temp_f14 = this->actor.velocity.y + this->actor.gravity; + s32 ret; + + if (this->actor.bgCheckFlags & 2) { + ret = true; + } else { + if (temp_f14 > 0.0f) { + temp_f0 = temp_f14 / arg1; + this->actor.shape.rot.x += (s16)(9100.0f * temp_f0); + this->unk_3AE = 0; + } else if ((s32)this->actor.velocity.y == 0) { + if (arg3 >= this->unk_3AE) { + temp_f0 = (f32)this->unk_3AE / arg3; + } else { + this->actor.gravity = -6.0f; + } + this->unk_3AE++; + } else if (this->unk_3AE == 0) { + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + temp_f0 = temp_f14 / arg1; + } + ret = false; + } + + this->unk_3A8 = (1.0f - temp_f0) * arg2; + this->actor.scale.x = this->unk_3A4 - this->unk_3A8; + this->actor.scale.y = this->unk_3A4 + this->unk_3A8; + + if (this->actor.scale.y < this->actor.scale.x) { + this->actor.scale.z = this->actor.scale.x; + } else { + this->actor.scale.z = this->actor.scale.y; + } + return ret; +} + +void func_80A136B8(GlobalContext* globalCtx, s16 arg1, s16 arg2, s16 arg3) { + s16 sp26 = Quake_Add(Play_GetCamera(globalCtx, MAIN_CAM), 3); + + Quake_SetCountdown(sp26, arg3); + Quake_SetSpeed(sp26, arg1); + Quake_SetQuakeValues(sp26, arg2, 0, 0, 0); +} + +void func_80A13728(EnGo* this, GlobalContext* globalCtx) { + func_80A136B8(globalCtx, 0x6C77, 7, 20); + globalCtx->actorCtx.unk2 = 4; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TEST, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 0); + EffectSsBlast_SpawnWhiteShockwave(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f); +} + +void func_80A137C0(EnGo* this, GlobalContext* globalCtx, f32 arg2, f32 arg3) { + u32 frames1; + u32 frames2; + + if (this->unk_390 & 0x400) { + Matrix_StatePush(); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_Scale(arg2 * 0.7f, arg2 * 0.8f, arg2, MTXMODE_APPLY); + func_800B8118(&this->actor, globalCtx, 0); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + frames1 = globalCtx->gameplayFrames % 256; + frames2 = (globalCtx->gameplayFrames * 2) % 256; + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, frames1, 0x20, 0x10, 1, 0, frames2, 0x40, 0x20)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, (u8)arg3); + gSPDisplayList(POLY_XLU_DISP++, &gameplay_keep_DL_050D10); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePop(); + } +} + +void func_80A139E4(EnGo* this) { + static Vec3f D_80A16698 = { 0.0f, 0.06f, 0.0f }; + Vec3f sp54; + Vec3f sp48; + s16 sp46 = Rand_ZeroOne() * 360.0f * 182.0f; + + Math_Vec3f_Copy(&sp54, &gZeroVec3f); + sp54.z = 28.0f; + Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, sp46, &sp54, &sp48); + sp48.y = (Rand_ZeroOne() * 10.0f) + 4.0f; + sp48.y += this->actor.floorHeight; + func_80A10FD0(&this->unk_3F8[16], sp48, D_80A16698, gZeroVec3f, 0.01f, 0.002f, 16); +} + +s32 func_80A13B1C(EnGo* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s32 ret = false; + + switch (this->unk_3C0) { + case 0: + this->unk_3B8 = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + if (func_80A134F4(this, this->unk_3B8)) { + this->unk_3C4 = 1; + this->unk_3C0 = 1; + } else { + break; + } + + case 1: + if (ActorCutscene_GetCurrentIndex() != this->unk_3B8) { + this->unk_3B8 = ActorCutscene_GetAdditionalCutscene(this->unk_3B8); + this->unk_3C0 = 2; + } else { + break; + } + + case 2: + if (func_80A134F4(this, this->unk_3B8)) { + this->unk_3C0 = 3; + } else { + break; + } + + case 3: + if (ActorCutscene_GetCanPlayNext(0x7C)) { + ActorCutscene_StartAndSetUnkLinkFields(0x7C, NULL); + this->unk_3C0 = 4; + } else if (ActorCutscene_GetCurrentIndex() == this->unk_3B8) { + ActorCutscene_SetIntentToPlay(0x7C); + } + } + + switch (this->unk_3C4) { + case 1: + func_80A12C48(this, globalCtx, 4); + this->unk_390 |= 0x4000; + this->unk_3C4++; + break; + + case 2: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_390 &= ~0x4000; + this->unk_390 &= ~0x80; + this->unk_390 |= 0x200; + this->unk_3C4++; + this->unk_3C2 = 0; + this->actor.shape.yOffset = 14.0f; + } + break; + + case 3: + this->unk_3C2++; + if (this->unk_3C2 >= 10) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_JUMP); + this->actor.velocity.y = 10.0f; + this->actor.gravity = -1.0f; + this->unk_3C4++; + } + break; + + case 4: + if (func_80A13564(this, 10.0f, 0.004f, 6)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_LAND_BIG); + func_80A13728(this, globalCtx); + this->unk_3C4++; + this->unk_3C2 = 0; + gSaveContext.weekEventReg[88] |= 0x40; + } + break; + + case 5: + this->unk_3C2++; + if (this->unk_3C2 >= 10) { + func_80A12C48(this, globalCtx, 5); + this->actor.shape.rot.x = 0; + this->unk_390 &= ~0x200; + this->unk_390 |= 0x80; + this->unk_3C4++; + } + break; + + case 6: + this->unk_3C0++; + if (this->unk_3C0 >= 65) { + switch (player->transformation) { + case 4: + gSaveContext.weekEventReg[88] |= 0x80; + break; + + case 1: + gSaveContext.weekEventReg[89] |= 4; + break; + + case 2: + gSaveContext.weekEventReg[89] |= 2; + break; + + case 3: + gSaveContext.weekEventReg[89] |= 1; + break; + } + ret = true; + } + break; + } + + Actor_MoveWithGravity(&this->actor); + return ret; +} + +s32 func_80A13E80(EnGo* this, GlobalContext* globalCtx) { + static Vec3f D_80A166A4 = { 0.0f, 200.0f, 280.0f }; + s32 pad; + Vec3f sp48; + s32 ret = false; + + switch (this->unk_3C0) { + case 0: + this->unk_3B8 = this->actor.cutscene; + if (func_80A134F4(this, this->unk_3B8)) { + this->unk_3C0++; + } + break; + + case 1: + func_80A12C48(this, globalCtx, 7); + this->unk_3C0++; + + case 2: + if (Animation_OnFrame(&this->skelAnime, 16.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_HAND_HIT); + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A12C48(this, globalCtx, 1); + Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80A166A4, &sp48); + gSaveContext.powderKegTimer = 2400; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, sp48.x, sp48.y, sp48.z, 1, 0, 0, 0); + func_80A134B0(this, globalCtx, 1); + this->unk_3C2 = 0; + this->unk_3C0++; + } + break; + + case 3: + if (this->unk_3C2 >= 60) { + ActorCutscene_Stop(this->unk_3B8); + this->unk_3C2 = 0; + this->unk_3C0 = 0; + ret = true; + } else { + this->unk_3C2++; + } + break; + } + + return ret; +} + +void func_80A14018(EnGo* this, GlobalContext* globalCtx) { + static Vec3f D_80A166B0 = { 0.0f, 0.0f, 40.0f }; + static s32 D_80A166BC[] = { 11, 10, 12, 13, 14, 17 }; + Vec3f sp2C; + s32 phi_v0 = ENGO_GET_70(&this->actor) % 6; + + if (phi_v0 < 4) { + phi_v0 = ((gSaveContext.eventInf[2] & 0xF) + phi_v0) % 4; + } + + func_80A12C48(this, globalCtx, D_80A166BC[phi_v0]); + + if (this->unk_3DC == 14) { + Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80A166B0, &sp2C); + Math_Vec3f_Copy(&this->actor.world.pos, &sp2C); + } + this->actor.flags &= ~1; + Actor_SetScale(&this->actor, this->unk_3A4); + this->unk_3EC = 0; + this->unk_390 = 0; + this->unk_390 |= (0x40 | 0x20); + this->actor.gravity = 0.0f; +} + +void func_80A14104(EnGo* this, GlobalContext* globalCtx) { + static s32 D_80A166D4[] = { 15, 16 }; + s16 temp; + + func_80A12C48(this, globalCtx, D_80A166D4[ENGO_GET_70(&this->actor) % 2]); + temp = Rand_ZeroOne() * this->skelAnime.endFrame; + this->skelAnime.curFrame = temp; + this->actor.flags &= ~1; + Actor_SetScale(&this->actor, this->unk_3A4); + this->unk_3EC = 0; + this->unk_390 = 0; + this->unk_390 |= 0x40; + this->unk_390 |= 0x20; + this->actor.gravity = 0.0f; +} + +void func_80A141D4(EnGo* this, GlobalContext* globalCtx) { + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit1); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->unk_3DC = -1; + func_80A12C48(this, globalCtx, 5); + this->unk_3EC = 0; + this->unk_39C = (this->unk_3A4 / 0.01f) * 0.9f; + this->unk_3BE = 2; + this->unk_390 = 0; + this->unk_390 |= 0x40; + this->unk_390 |= 0x400; + this->unk_3A0 = 100.0f; +} + +void func_80A1428C(EnGo* this, GlobalContext* globalCtx) { + s16 temp; + Vec3f sp30; + Vec3f sp24; + + Math_Vec3f_Copy(&sp30, &this->actor.world.pos); + if (this->unk_284 != NULL) { + this->actor.flags &= ~0x2000000; + func_8013C8B8(this->unk_284, 0, &sp24); + temp = Math_Vec3f_Yaw(&sp30, &sp24); + this->actor.shape.rot.y = temp; + this->actor.world.rot.y = temp; + } + this->unk_390 = 0; + this->unk_390 |= 0x100; + this->actor.shape.yOffset = 46.0f; + this->actor.gravity = -1.0f; +} + +void func_80A14324(EnGo* this, GlobalContext* globalCtx) { + func_80A12C48(this, globalCtx, 8); + Actor_SetScale(&this->actor, this->unk_3A4); + this->unk_390 = 0; + this->actor.gravity = -1.0f; + func_8013AED4(&this->unk_390, 3, 7); + this->unk_3EC = 0; + this->unk_390 |= 0x40; + this->unk_3BC = 0; + this->unk_3BE = 4; + this->unk_39C = 0.0f; + this->unk_3A0 = 0.0f; +} + +void func_80A143A8(EnGo* this, GlobalContext* globalCtx) { + func_80A12C48(this, globalCtx, 5); + Actor_SetScale(&this->actor, this->unk_3A4); + this->unk_390 = 0; + this->actor.gravity = -1.0f; + func_8013AED4(&this->unk_390, 3, 7); + this->unk_3EC = 0; + this->unk_390 |= 0x40; + this->unk_390 |= 0x20; + this->unk_3BC = 0; + this->unk_3BE = 0; + this->unk_39C = 0.0f; + this->unk_3A0 = 0.0f; +} + +void func_80A14430(EnGo* this, GlobalContext* globalCtx) { + if (((gSaveContext.entranceIndex == 0xD000) || (gSaveContext.entranceIndex == 0xD020)) && + (gSaveContext.weekEventReg[33] & 0x80)) { + func_80A14018(this, globalCtx); + this->actionFunc = func_80A149B0; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80A1449C(EnGo* this, GlobalContext* globalCtx) { + if ((gSaveContext.entranceIndex == 0xD010) || (gSaveContext.entranceIndex == 0x1C00)) { + func_80A14104(this, globalCtx); + this->actionFunc = func_80A149B0; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80A144F4(EnGo* this, GlobalContext* globalCtx) { + if (gSaveContext.day >= 2) { + this->unk_284 = func_8013BEDC(globalCtx, ENGO_GET_7F80(&this->actor), 0xFF, &this->unk_3E4); + if (this->unk_284 != NULL) { + this->unk_3E4 = 1; + } + func_80A1428C(this, globalCtx); + this->actionFunc = func_80A153FC; + this->unk_3D8 = func_80A13B1C; + } else { + func_80A143A8(this, globalCtx); + this->actionFunc = func_80A149B0; + this->unk_3D8 = func_80A13B1C; + } +} + +void func_80A145AC(EnGo* this, GlobalContext* globalCtx) { + if ((ENGO_GET_70(&this->actor) == ENGO_70_1) && + (((globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && + (globalCtx->csCtx.unk_12 == 0)) || + !(gSaveContext.weekEventReg[21] & 8))) { + this->actor.child = func_80A13400(this, globalCtx); + this->actor.child->child = &this->actor; + func_80A141D4(this, globalCtx); + this->actionFunc = func_80A14E14; + } else { + func_80A143A8(this, globalCtx); + this->actionFunc = func_80A149B0; + } +} + +void func_80A14668(EnGo* this, GlobalContext* globalCtx) { + if (!(gSaveContext.weekEventReg[22] & 4)) { + func_80A14324(this, globalCtx); + this->actionFunc = func_80A149B0; + } else { + func_80A143A8(this, globalCtx); + this->actionFunc = func_80A149B0; + } +} + +void func_80A146CC(EnGo* this, GlobalContext* globalCtx) { + func_80A134B0(this, globalCtx, 0); + func_80A12C48(this, globalCtx, 0); + this->unk_3A4 *= 5.0f; + Actor_SetScale(&this->actor, this->unk_3A4); + this->actor.flags &= ~1; + this->actor.targetMode = 3; + this->unk_390 = 0; + this->actor.gravity = -1.0f; + func_8013AED4(&this->unk_390, 3, 7); + this->unk_390 |= 0x40; + this->unk_390 |= 0x20; + this->unk_3D8 = func_80A13E80; + this->actionFunc = func_80A149B0; +} + +void func_80A14798(EnGo* this, GlobalContext* globalCtx) { + s32 sp38[2] = { 0x0000003E, 0x00000F64 }; + + if ((this->unk_288 < 0) || func_8013D8DC(this->unk_288, globalCtx) || (this->unk_289 < 0) || + func_8013D8DC(this->unk_289, globalCtx)) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, + this->morphTable, 18); + + this->unk_3DC = -1; + func_80A12C48(this, globalCtx, 2); + this->actor.draw = func_80A15FEC; + + Collider_InitAndSetSphere(globalCtx, &this->colliderSphere, &this->actor, &sSphereInit); + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit2); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Effect_Add(globalCtx, &this->unk_3E8, 4, 0, 0, &sp38); + + this->actor.targetMode = 1; + this->unk_3A4 = 0.01f; + this->unk_3D8 = NULL; + + switch (ENGO_GET_F(&this->actor)) { + case ENGO_F_1: + func_80A14430(this, globalCtx); + break; + + case ENGO_F_2: + func_80A1449C(this, globalCtx); + break; + + case ENGO_F_3: + func_80A144F4(this, globalCtx); + break; + + case ENGO_F_4: + func_80A145AC(this, globalCtx); + break; + + case ENGO_F_5: + case ENGO_F_6: + case ENGO_F_7: + func_80A14668(this, globalCtx); + break; + + case ENGO_F_8: + func_80A146CC(this, globalCtx); + break; + + default: + Actor_MarkForDeath(&this->actor); + break; + } + } +} + +void func_80A149B0(EnGo* this, GlobalContext* globalCtx) { + s16 sp26 = this->actor.world.rot.y; + + if ((ENGO_GET_F(&this->actor) == ENGO_F_2) && (gSaveContext.entranceIndex == 0xD010)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_CHEER - SFX_FLAG); + } else if (ENGO_GET_F(&this->actor) != ENGO_F_8) { + if (func_80A1222C(this, globalCtx)) { + func_8013AED4(&this->unk_390, 0, 7); + this->unk_3EC = 1; + this->actionFunc = func_80A14B30; + } else if (ENGO_GET_F(&this->actor) == ENGO_F_4) { + switch (ENGO_GET_70(&this->actor)) { + case ENGO_70_0: + func_80A132C8(this, globalCtx); + break; + + case ENGO_70_1: + func_80A133A8(this, globalCtx); + break; + } + } else if (ENGO_GET_F(&this->actor) == ENGO_F_1) { + if (ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)) < 0x3FFC) { + func_8013AED4(&this->unk_390, 3, 7); + } else { + func_8013AED4(&this->unk_390, 0, 7); + } + } + } + Math_ApproachS(&this->actor.shape.rot.y, sp26, 4, 0x2AA8); +} + +void func_80A14B30(EnGo* this, GlobalContext* globalCtx) { + s16 sp26 = this->actor.world.rot.y; + u16 sfxId; + + if (func_80A1222C(this, globalCtx)) { + this->unk_3EC = 1; + } + + if (this->unk_390 & 0x4000) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_390 &= ~0x4000; + this->unk_390 |= 0x200; + if (this->unk_3EC != 0) { + this->unk_3AE = 0; + } + this->actor.shape.yOffset = 14.0f; + } + } else if (this->unk_390 & 0x8000) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_390 |= 0x80; + this->unk_390 &= ~0x8000; + } + } else if (this->unk_390 & 0x200) { + if ((this->actor.xzDistToPlayer < 160.0f) && (this->actor.playerHeightRel < 20.0f) && (this->unk_3EC == 0)) { + func_80A12C48(this, globalCtx, 3); + this->unk_390 &= ~0x80; + this->unk_390 &= ~0x200; + this->unk_390 |= 0x8000; + this->actor.shape.yOffset = 0.0f; + } else if ((this->unk_3EC != 0) && (gSaveContext.weekEventReg[22] & 4)) { + this->actor.scale.x = this->unk_3A4 - (Math_SinS(this->unk_3AE) * 0.001f); + this->actor.scale.y = (Math_SinS(this->unk_3AE) * 0.001f) + this->unk_3A4; + this->actor.scale.z = (Math_SinS(this->unk_3AE) * 0.001f) + this->unk_3A4; + if (this->unk_3AE == 0) { + this->unk_3EC = -this->unk_3EC; + if (this->unk_3EC > 0) { + sfxId = NA_SE_EN_GOLON_SNORE1; + } else { + sfxId = NA_SE_EN_GOLON_SNORE2; + } + Actor_PlaySfxAtPos(&this->actor, sfxId); + } + this->unk_3AE += 0x400; + this->actor.shape.yOffset = (this->actor.scale.y / this->unk_3A4) * 14.0f; + func_8013AED4(&this->unk_390, 3, 7); + } + } else if ((this->actor.xzDistToPlayer >= 240.0f) || (this->actor.playerHeightRel >= 20.0f) || + (this->unk_3EC != 0)) { + func_80A12C48(this, globalCtx, 4); + this->unk_390 &= ~0x80; + this->unk_390 &= ~0x200; + this->unk_390 |= 0x4000; + this->actor.shape.yOffset = 0.0f; + } + + func_8013D9C8(globalCtx, &this->unk_3CE[0], &this->unk_3C8[0], 3); + Math_ApproachS(&this->actor.shape.rot.y, sp26, 4, 0x2AA8); +} + +void func_80A14E14(EnGo* this, GlobalContext* globalCtx) { + Actor* actor = this->colliderCylinder.base.ac; + + if ((this->unk_390 & 0x1000) && (((actor != NULL) && (actor->id == ACTOR_OBJ_AQUA) && (actor->params & 1)) || + (this->actor.colChkInfo.damageEffect == 2))) { + this->actionFunc = func_80A14E74; + } +} + +void func_80A14E74(EnGo* this, GlobalContext* globalCtx) { + if (func_80A134F4(this, this->actor.cutscene)) { + this->actionFunc = func_80A14EB0; + } +} + +void func_80A14EB0(EnGo* this, GlobalContext* globalCtx) { + EnGo* sp24 = (EnGo*)this->actor.child; + + if ((s32)(this->unk_39C * 3.0f) != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); + Math_ApproachF(&this->unk_39C, 0.0f, 0.02f, 1.0f); + this->unk_3A0 = (this->unk_39C / 0.9f) * 100.0f; + func_80A139E4(this); + } else { + ActorCutscene_Stop(this->actor.cutscene); + func_80A143A8(this, globalCtx); + if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (ENGO_GET_70(&this->actor) == ENGO_70_1)) { + func_8013AED4(&this->unk_390, 4, 7); + func_80A143A8(sp24, globalCtx); + sp24->actionFunc = func_80A149B0; + } + this->actionFunc = func_80A149B0; + } +} + +void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { + s32 sp38[] = { + 0, 2, 6, 20, 18, 5, 5, 15, + }; + u16 sp36 = 0; + s32 sp30; + u32 sp2C; + + switch (ENGO_GET_70(&this->actor)) { + case ENGO_70_0: + sp36 = 0x80; + break; + + case ENGO_70_1: + sp36 = 0x81; + break; + } + + if ((sp36 == 0x80) || (sp36 == 0x81)) { + if (func_800EE29C(globalCtx, sp36)) { + sp2C = func_800EE200(globalCtx, sp36); + sp30 = globalCtx->csCtx.npcActions[sp2C]->unk0; + + if (this->unk_394 != (u8)sp30) { + this->unk_394 = sp30; + func_80A12C48(this, globalCtx, sp38[sp30]); + this->unk_390 = 0; + this->unk_390 |= 0x20; + this->unk_3BE = 0; + this->unk_39C = 0.0f; + this->unk_3A0 = 0.0f; + + switch (sp30) { + case 1: + this->unk_390 |= 0x80; + this->skelAnime.curFrame = this->skelAnime.endFrame; + break; + + case 5: + case 6: + func_80A141D4(this, globalCtx); + break; + } + } + + switch (this->unk_394) { + case 3: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (this->unk_3DC == 20)) { + func_80A12C48(this, globalCtx, 21); + } + break; + + case 4: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (this->unk_3DC == 18)) { + func_80A12C48(this, globalCtx, 19); + } + break; + + case 6: + if ((s32)(this->unk_39C * 3.0f) != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); + Math_ApproachF(&this->unk_39C, 0.0f, 0.02f, 1.0f); + this->unk_3A0 = (this->unk_39C / 0.9f) * 100.0f; + func_80A139E4(this); + } else if (this->unk_390 & 0x400) { + func_80A143A8(this, globalCtx); + } + break; + } + + if (sp36 == 0x80) { + switch (globalCtx->csCtx.frames) { + case 55: + case 100: + case 130: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_COLD); + break; + + case 185: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_WAKE_UP); + break; + + case 250: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_EYE_BIG); + break; + + case 465: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IWAIGORON_SOLO); + break; + + case 490: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_VOICE_EATFULL); + break; + } + } else if (sp36 == 0x81) { + switch (globalCtx->csCtx.frames) { + case 360: + case 390: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_COLD); + break; + + case 430: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_WAKE_UP); + break; + + case 450: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_EYE_BIG); + break; + + case 480: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_VOICE_EATFULL); + break; + } + } + + func_8013D9C8(globalCtx, this->unk_3CE, this->unk_3C8, 3); + func_800EDF24(&this->actor, globalCtx, sp2C); + } + } +} + +void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { + Vec3s* sp5C; + Vec3f sp50; + Vec3f sp44; + + if ((this->unk_390 & 0x1000) && (this->actor.colChkInfo.damageEffect == 0xF)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SNOWBALL_BROKEN); + + this->actor.flags &= ~0x10; + this->actor.flags |= 0x2000000; + + func_80A118F8(this->unk_3F8, this->actor.world.pos); + this->actor.shape.rot.x = 0; + this->actor.speedXZ = 0.0f; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_COLD); + + if (gSaveContext.day == 3) { + func_80A141D4(this, globalCtx); + this->actionFunc = func_80A14E14; + } else { + func_80A143A8(this, globalCtx); + this->actionFunc = func_80A149B0; + } + } else if (this->unk_284 != NULL) { + if (this->unk_390 & 0x800) { + func_800B8E58(GET_PLAYER(globalCtx), NA_SE_PL_BODY_HIT); + func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); + } + + sp5C = Lib_SegmentedToVirtual(this->unk_284->points); + if (func_8013BD40(&this->actor, this->unk_284, this->unk_3E4)) { + if (this->unk_3E4 >= (this->unk_284->count - 1)) { + this->unk_3E4 = 0; + } else { + this->unk_3E4++; + } + } + + Math_Vec3s_ToVec3f(&sp44, &sp5C[this->unk_3E4]); + Math_Vec3f_Copy(&sp50, &this->actor.world.pos); + Math_ApproachS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&sp50, &sp44), 4, 0x38E); + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (this->actor.bgCheckFlags & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BIGBALL_ROLL - SFX_FLAG); + func_800AE930(&globalCtx->colCtx, Effect_GetByIndex(this->unk_3E8), &this->actor.world.pos, 18.0f, + this->actor.shape.rot.y, this->actor.floorPoly, this->actor.floorBgId); + } else { + func_800AEF44(Effect_GetByIndex(this->unk_3E8)); + } + + this->actor.speedXZ = 4.0f; + this->actor.shape.rot.x += (s16)(this->actor.speedXZ * 546.0f); + Actor_MoveWithGravity(&this->actor); + } +} + +s32* func_80A15684(EnGo* this, GlobalContext* globalCtx) { + static s32 D_80A16704[] = { + D_80A16100, + D_80A16164, + }; + + if (this->unk_3EC != 0) { + return D_80A1640C; + } + + if (ENGO_GET_F(&this->actor) == ENGO_F_1) { + switch (ENGO_GET_70(&this->actor) % 6) { + case ENGO_70_0: + return D_80A163BC; + case ENGO_70_1: + return D_80A163CC; + case ENGO_70_2: + return D_80A163DC; + case ENGO_70_3: + return D_80A163EC; + case ENGO_70_4: + return D_80A163FC; + case ENGO_70_5: + return D_80A163FC; + } + } + + switch (ENGO_GET_F(&this->actor)) { + case ENGO_F_3: + return D_80A16350; + case ENGO_F_4: + return D_80A16704[ENGO_GET_70(&this->actor)]; + case ENGO_F_5: + return D_80A16208; + case ENGO_F_6: + return D_80A16254; + case ENGO_F_7: + return D_80A16210; + case ENGO_F_8: + return D_80A16280; + default: + return D_80A16208; + } +} + +void func_80A157C4(EnGo* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + + if (!func_8010BF58(&this->actor, globalCtx, func_80A15684(this, globalCtx), this->unk_3D8, &this->unk_28C)) { + if ((ENGO_GET_F(&this->actor) != ENGO_F_1) && !(this->unk_390 & 0x200)) { + Math_Vec3f_Copy(&sp40, &this->unk_38C->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); + } + func_8013D9C8(globalCtx, this->unk_3CE, this->unk_3C8, 3); + return; + } + + if ((ENGO_GET_F(&this->actor) == ENGO_F_5) || (ENGO_GET_F(&this->actor) == ENGO_F_6) || + (ENGO_GET_F(&this->actor) == ENGO_F_7)) { + this->unk_3BC = 0; + this->unk_390 &= ~0x20; + this->unk_3BE = 4; + } + + this->unk_390 &= ~0x8; + func_8013AED4(&this->unk_390, 3, 7); + this->unk_28C = 0; + this->unk_390 |= 0x40; + this->actionFunc = this->unk_18C; +} + +void EnGo_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGo* this = THIS; + + this->unk_288 = func_8013D924(OBJECT_TAISOU, globalCtx); + this->unk_289 = func_8013D924(OBJECT_HAKUGIN_DEMO, globalCtx); + this->actionFunc = func_80A14798; +} + +void EnGo_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGo* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroySphere(globalCtx, &this->colliderSphere); + Effect_Destroy(globalCtx, this->unk_3E8); +} + +void EnGo_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGo* this = THIS; + f32 phi_f0; + + func_80A12868(this, globalCtx); + if (!func_80A12774(this, globalCtx)) { + func_80A12954(this, globalCtx); + } + + this->actionFunc(this, globalCtx); + + if (!(this->unk_390 & 0x400)) { + func_80A12D6C(this); + func_80A12A64(this, globalCtx); + func_80A131F8(this, globalCtx); + func_80A12B78(this, globalCtx); + } + + if (!(this->unk_390 & 0x100) && !(this->unk_390 & 0x200) && !(this->unk_390 & 0x400)) { + if (ENGO_GET_F(&this->actor) == ENGO_F_8) { + phi_f0 = this->colliderSphere.dim.worldSphere.radius + 60; + } else { + phi_f0 = this->colliderCylinder.dim.radius + 40; + } + func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, 0, this->unk_390 & 7); + } else if ((this->unk_390 & 0x200) && (this->unk_3EC != 0)) { + phi_f0 = this->colliderCylinder.dim.radius + 40; + func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, 0, this->unk_390 & 7); + } + + if ((ENGO_GET_F(&this->actor) != ENGO_F_8) && (ENGO_GET_F(&this->actor) != ENGO_F_2) && + (ENGO_GET_F(&this->actor) != ENGO_F_1)) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + } + + func_80A122EC(this); + func_80A126BC(this, globalCtx); + func_80A1203C(this); +} + +void func_80A15B80(EnGo* this, GlobalContext* globalCtx) { + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + + if (this->unk_390 & 0x100) { + Matrix_Scale(this->actor.scale.x * 8.0f, this->actor.scale.y * 8.0f, this->actor.scale.z * 8.0f, MTXMODE_APPLY); + } else { + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + } + + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, (this->unk_390 & 0x100) ? object_oF1d_map_DL_001560 : object_oF1d_map_DL_0091A8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnGo* this = THIS; + Vec3f sp30; + s32 idx; + + if ((ENGO_GET_F(&this->actor) == ENGO_F_8) && (limbIndex == 10)) { + limbIndex = limbIndex; + Matrix_GetStateTranslation(&sp30); + sp30.y = this->actor.world.pos.y; + Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp30); + } + + switch (limbIndex) { + case 10: + idx = 0; + break; + + case 11: + idx = 1; + break; + + case 14: + idx = 2; + break; + + default: + idx = 9; + break; + } + + if ((this->unk_390 & 0x80) && (idx < 9)) { + rot->y += (s16)(Math_SinS(this->unk_3CE[idx]) * 200.0f); + rot->z += (s16)(Math_CosS(this->unk_3C8[idx]) * 200.0f); + } + return false; +} + +void EnGo_UnkDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnGo* this = THIS; + u16 temp_v0; + s32 phi_v1; + s32 phi_v0; + + if (this->unk_390 & 0x40) { + phi_v1 = false; + } else { + phi_v1 = true; + } + + if (this->unk_390 & 0x10) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (!phi_v1) { + phi_v0 = false; + } + + switch (limbIndex) { + case 17: + func_8013AD9C(this->unk_3B0 + this->unk_3B4 + 0x4000, + this->unk_3B2 + this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_290, + &this->unk_2A8, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_2A8.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_2A8.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_2A8.z, MTXMODE_APPLY); + Matrix_StatePush(); + break; + + case 10: + func_8013AD9C(this->unk_3B4 + 0x4000, this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_29C, + &this->unk_2AE, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_2AE.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_2AE.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_2AE.z, MTXMODE_APPLY); + Matrix_StatePush(); + break; + } +} + +void func_80A15FEC(Actor* thisx, GlobalContext* globalCtx) { + static UNK_TYPE D_80A1670C[] = { + &object_oF1d_map_Tex_010438, &object_oF1d_map_Tex_010C38, &object_oF1d_map_Tex_011038, + &object_oF1d_map_Tex_010C38, &object_oF1d_map_Tex_010838, + }; + EnGo* this = THIS; + + if (!(this->unk_390 & 0x300)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A1670C[this->unk_3BE])); + + if (this->unk_3DC == 14) { + Matrix_InsertTranslation(0.0f, 0.0f, -4000.0f, MTXMODE_APPLY); + } + func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnGo_OverrideLimbDraw, NULL, EnGo_UnkDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + func_80A15B80(this, globalCtx); + } + func_80A137C0(this, globalCtx, this->unk_39C, this->unk_3A0); + func_80A1213C(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.h b/src/overlays/actors/ovl_En_Go/z_en_go.h index 08363e8221..ab7f068e15 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.h +++ b/src/overlays/actors/ovl_En_Go/z_en_go.h @@ -7,11 +7,98 @@ struct EnGo; typedef void (*EnGoActionFunc)(struct EnGo*, GlobalContext*); +#define ENGO_GET_F(thisx) (((thisx)->params & 0xF) & 0xFF) +#define ENGO_GET_70(thisx) ((((thisx)->params & 0x70) >> 4) & 0xFF) +#define ENGO_GET_7F80(thisx) ((((thisx)->params & 0x7F80) >> 7) & 0xFF) + +enum { + /* 0 */ ENGO_F_0, + /* 1 */ ENGO_F_1, + /* 2 */ ENGO_F_2, + /* 3 */ ENGO_F_3, + /* 4 */ ENGO_F_4, + /* 5 */ ENGO_F_5, + /* 6 */ ENGO_F_6, + /* 7 */ ENGO_F_7, + /* 8 */ ENGO_F_8, +}; + +enum { + /* 0 */ ENGO_70_0, + /* 1 */ ENGO_70_1, + /* 2 */ ENGO_70_2, + /* 3 */ ENGO_70_3, + /* 4 */ ENGO_70_4, + /* 5 */ ENGO_70_5, +}; + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; + /* 0x02 */ u8 unk_02; + /* 0x04 */ Vec3s unk_04; + /* 0x0A */ Vec3s unk_0A; + /* 0x10 */ Vec3f unk_10; + /* 0x1C */ Vec3f unk_1C; + /* 0x28 */ Vec3f unk_28; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; +} EnGoStruct; // size = 0x3C; + typedef struct EnGo { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnGoActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x9EC]; + /* 0x018C */ EnGoActionFunc unk_18C; + /* 0x0190 */ EnGoActionFunc unk_190; + /* 0x0194 */ ColliderCylinder colliderCylinder; + /* 0x01E0 */ UNK_TYPE1 unk1E0[0x4C]; + /* 0x022C */ ColliderSphere colliderSphere; + /* 0x0284 */ Path* unk_284; + /* 0x0288 */ s8 unk_288; + /* 0x0289 */ s8 unk_289; + /* 0x028C */ s32 unk_28C; + /* 0x0290 */ Vec3f unk_290; + /* 0x029C */ Vec3f unk_29C; + /* 0x02A8 */ Vec3s unk_2A8; + /* 0x02AE */ Vec3s unk_2AE; + /* 0x02B4 */ Vec3s jointTable[18]; + /* 0x0320 */ Vec3s morphTable[18]; + /* 0x038C */ Actor* unk_38C; + /* 0x0390 */ u16 unk_390; + /* 0x0392 */ u16 unk_392; + /* 0x0394 */ u8 unk_394; + /* 0x0398 */ f32 unk_398; + /* 0x039C */ f32 unk_39C; + /* 0x03A0 */ f32 unk_3A0; + /* 0x03A4 */ f32 unk_3A4; + /* 0x03A8 */ f32 unk_3A8; + /* 0x03AC */ UNK_TYPE1 unk3AC[0x2]; + /* 0x03AE */ s16 unk_3AE; + /* 0x03B0 */ s16 unk_3B0; + /* 0x03B2 */ s16 unk_3B2; + /* 0x03B4 */ s16 unk_3B4; + /* 0x03B6 */ s16 unk_3B6; + /* 0x03B8 */ s16 unk_3B8; + /* 0x03BA */ s16 unk_3BA; + /* 0x03BC */ s16 unk_3BC; + /* 0x03BE */ s16 unk_3BE; + /* 0x03C0 */ s16 unk_3C0; + /* 0x03C2 */ s16 unk_3C2; + /* 0x03C4 */ s16 unk_3C4; + /* 0x03C6 */ s16 unk_3C6; + /* 0x03C8 */ s16 unk_3C8[3]; + /* 0x03CE */ s16 unk_3CE[3]; + /* 0x03D4 */ s16 unk_3D4; + /* 0x03D8 */ void* unk_3D8; + /* 0x03DC */ s32 unk_3DC; + /* 0x03E0 */ UNK_TYPE1 unk3E0[0x4]; + /* 0x03E4 */ s32 unk_3E4; + /* 0x03E8 */ s32 unk_3E8; + /* 0x03EC */ s32 unk_3EC; + /* 0x03F0 */ s32 unk_3F0; + /* 0x03F4 */ s32 unk_3F4; + /* 0x03F8 */ EnGoStruct unk_3F8[32]; } EnGo; // size = 0xB78 extern const ActorInit En_Go_InitVars; diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index 3a74a8a5f5..dc8e0bfa5f 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -119,7 +119,7 @@ static Vec3f D_80942E60 = { 0.0f, 1.0f, 0.0f }; static Vec3f D_80942E6C = { 0.0f, 0.0f, 1.0f }; static InitChainEntry sInitChain[] = { - ICHAIN_F32_DIV1000(gravity, -900, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(minVelocityY, -26000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -900, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -26000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 160, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 350, ICHAIN_STOP), }; @@ -371,7 +371,7 @@ s32 func_8093F34C(EnGoroiwa* this) { f32 z; Math_StepToF(&this->actor.speedXZ, D_80942DFC[this->unk_1E4], 0.3f); - Actor_SetVelocityYRotationAndGravity(&this->actor); + Actor_UpdateVelocityWithGravity(&this->actor); temp_v0 = &this->unk_1D0[this->unk_1D8]; this->actor.velocity.y *= 0.97f; x = temp_v0->x; @@ -495,7 +495,7 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { func_8093EF54(globalCtx, &sp48, &D_80942E30[ENGOROIWA_GET_C000(&this->actor)], &D_80942E3C[ENGOROIWA_GET_C000(&this->actor)], this->actor.scale.x); } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BIGBALL_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BIGBALL_BOUND); } } } @@ -1001,7 +1001,7 @@ void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx) { } CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - ActorShape_Init(&this->actor.shape, 595.0f, func_800B3FC0, 9.4f); + ActorShape_Init(&this->actor.shape, 595.0f, ActorShadow_DrawCircle, 9.4f); this->actor.shape.shadowAlpha = 200; func_8093EB58(this, globalCtx); @@ -1190,7 +1190,7 @@ void func_80941A10(EnGoroiwa* this, GlobalContext* globalCtx) { func_80941DB4(this); } - func_800B8E58(&player->actor, NA_SE_PL_BODY_HIT); + func_800B8E58(player, NA_SE_PL_BODY_HIT); if ((sp34 == 1) || (sp34 == 2)) { this->unk_1CC = 50; @@ -1230,7 +1230,7 @@ void func_80941A10(EnGoroiwa* this, GlobalContext* globalCtx) { } if (this->actor.bgCheckFlags & 1) { - Audio_PlayActorSound2(&this->actor, D_80942E9C[this->unk_1E4][this->actor.home.rot.x & 1]); + Actor_PlaySfxAtPos(&this->actor, D_80942E9C[this->unk_1E4][this->actor.home.rot.x & 1]); } } } @@ -1239,7 +1239,7 @@ void func_80941DB4(EnGoroiwa* this) { this->actionFunc = func_80941E28; func_8093EAB0(this, 6); this->actor.gravity = -0.86f; - this->actor.minVelocityY = -15.0f; + this->actor.terminalVelocity = -15.0f; this->actor.speedXZ *= 0.15f; this->actor.velocity.y = 5.0f; this->unk_1C4 = 1.0f; @@ -1288,7 +1288,7 @@ void func_80941FA4(EnGoroiwa* this, GlobalContext* globalCtx) { if (func_8094156C(this, globalCtx) == 0) { if ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & 0x80000)) { func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); - func_800B8E58(&player->actor, NA_SE_PL_BODY_HIT); + func_800B8E58(player, NA_SE_PL_BODY_HIT); if (((this->actor.home.rot.z & 3) == 1) || ((this->actor.home.rot.z & 3) == 2)) { this->unk_1CC = 50; } @@ -1316,7 +1316,7 @@ void func_809420F0(EnGoroiwa* this, GlobalContext* globalCtx) { if (func_8094156C(this, globalCtx) == 0) { if ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & 0x80000)) { func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); - func_800B8E58(&player->actor, NA_SE_PL_BODY_HIT); + func_800B8E58(player, NA_SE_PL_BODY_HIT); if (((this->actor.home.rot.z & 3) == 1) || ((this->actor.home.rot.z & 3) == 2)) { this->unk_1CC = 50; } @@ -1592,7 +1592,7 @@ void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - func_800BDFC0(globalCtx, phi_fp); + Gfx_DrawDListOpa(globalCtx, phi_fp); if ((ptr->unk_28 != 0) && (ptr->unk_2C > 0)) { OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1629,6 +1629,6 @@ void EnGoroiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->actionFunc == func_8094220C) { func_80942B1C(this, globalCtx); } else if (this->actionFunc != func_80942604) { - func_800BDFC0(globalCtx, D_80942EB4[params]); + Gfx_DrawDListOpa(globalCtx, D_80942EB4[params]); } } diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.c b/src/overlays/actors/ovl_En_Gs/z_en_gs.c index 8e50b07947..615d228599 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -5,6 +5,7 @@ */ #include "z_en_gs.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x02000019 @@ -35,7 +36,6 @@ s32 func_809995A4(EnGs* this, GlobalContext* globalCtx); void func_80999A8C(EnGs* this, GlobalContext* globalCtx); void func_80999AC0(EnGs* this); -extern Gfx D_0407D590[]; extern Gfx D_06000950[]; extern Gfx D_060009D0[]; extern Gfx D_06000A60[]; @@ -184,7 +184,7 @@ void func_80997D14(EnGs* this, GlobalContext* globalCtx) { void func_80997D38(EnGs* this, GlobalContext* globalCtx) { static f32 D_8099A408[] = { 40.0f, 60.0f, 40.0f, 40.0f }; - if (!func_80152498(&globalCtx->msgCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 0) { if (this->actor.xzDistToPlayer <= D_8099A408[this->actor.params]) { func_8013E8F8(&this->actor, globalCtx, D_8099A408[this->actor.params], D_8099A408[this->actor.params], 0, 0x2000, 0x2000); @@ -207,7 +207,7 @@ void func_80997DEC(EnGs* this, GlobalContext* globalCtx) { } void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: func_801518B0(globalCtx, this->unk_210, &this->actor); break; @@ -284,8 +284,8 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { if (!Flags_GetSwitch(globalCtx, this->unk_196)) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, 2); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); - Actor_SetSwitchFlag(globalCtx, this->unk_196); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); + Flags_SetSwitch(globalCtx, this->unk_196); } break; @@ -293,8 +293,8 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { if (!Flags_GetSwitch(globalCtx, this->unk_196)) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, 7); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); - Actor_SetSwitchFlag(globalCtx, this->unk_196); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); + Flags_SetSwitch(globalCtx, this->unk_196); } break; @@ -363,7 +363,7 @@ void func_809984F4(EnGs* this, GlobalContext* globalCtx) { EnGs* gossipStone = NULL; do { - gossipStone = (EnGs*)func_ActorCategoryIterateById(globalCtx, &gossipStone->actor, ACTORCAT_PROP, ACTOR_EN_GS); + gossipStone = (EnGs*)SubS_FindActor(globalCtx, &gossipStone->actor, ACTORCAT_PROP, ACTOR_EN_GS); if (gossipStone != NULL) { if ((this != gossipStone) && (this->unk_194 == gossipStone->unk_194)) { gossipStone->unk_19A |= 1; @@ -396,8 +396,7 @@ void func_809985B8(EnGs* this, GlobalContext* globalCtx) { gossipStone = NULL; do { - gossipStone = - (EnGs*)func_ActorCategoryIterateById(globalCtx, &gossipStone->actor, ACTORCAT_PROP, ACTOR_EN_GS); + gossipStone = (EnGs*)SubS_FindActor(globalCtx, &gossipStone->actor, ACTORCAT_PROP, ACTOR_EN_GS); if (gossipStone != NULL) { if ((gossipStone != this) && (gossipStone->actor.params == ENGS_2) && (gossipStone->unk_198 == this->unk_198)) { @@ -415,7 +414,7 @@ void func_809985B8(EnGs* this, GlobalContext* globalCtx) { void func_80998704(EnGs* this, GlobalContext* globalCtx) { this->unk_19D = 0; this->unk_19A &= ~(0x100 | 0x4); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_G_STONE_CHANGE_COLOR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_G_STONE_CHANGE_COLOR); this->actionFunc = func_8099874C; } @@ -504,7 +503,7 @@ void func_8099874C(EnGs* this, GlobalContext* globalCtx) { } void func_809989B4(EnGs* this, GlobalContext* globalCtx) { - func_800B8A1C(&this->actor, globalCtx, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809989F4; } @@ -513,7 +512,7 @@ void func_809989F4(EnGs* this, GlobalContext* globalCtx) { this->actor.parent = NULL; func_80997D14(this, globalCtx); } else { - func_800B8A1C(&this->actor, globalCtx, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } @@ -522,7 +521,7 @@ s32 func_80998A48(EnGs* this, GlobalContext* globalCtx) { if (this->unk_19D == 0) { this->unk_216 = 200; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_1D4 = 0; this->unk_19A |= 1; @@ -537,9 +536,9 @@ s32 func_80998A48(EnGs* this, GlobalContext* globalCtx) { } else if (this->unk_19D == 1) { if (func_80998334(this, globalCtx, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, 0.8f, 0.007f, 0.001f, 7, 0) == 0.0f) { - if ((this->actor.params != ENGS_0) && !func_801690CC(globalCtx) && !func_80152498(&globalCtx->msgCtx)) { + if ((this->actor.params != ENGS_0) && !func_801690CC(globalCtx) && !Message_GetState(&globalCtx->msgCtx)) { this->unk_216 = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FAIVE_LUPY_COUNT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIVE_LUPY_COUNT); func_801518B0(globalCtx, 0x20D2, NULL); } this->unk_19A &= ~1; @@ -554,7 +553,7 @@ s32 func_80998BBC(EnGs* this, GlobalContext* globalCtx) { if (this->unk_19D == 0) { this->unk_216 = 200; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_1DC = 0.3f; this->unk_1E0 = 0.0f; @@ -585,7 +584,7 @@ s32 func_80998D44(EnGs* this, GlobalContext* globalCtx) { this->unk_216 = 200; this->unk_1DC = this->unk_1B0[0].y - 1.0f; this->unk_1E0 = -0.8f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_G_STONE_CRUSH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_G_STONE_CRUSH); this->unk_19A |= 1; this->unk_21C = 40; this->unk_21E = 11; @@ -616,7 +615,7 @@ s32 func_80998D44(EnGs* this, GlobalContext* globalCtx) { this->unk_21C = 10; this->unk_21E = 10; this->unk_1DC = 0.5f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_19D += 1; } } else if ((this->unk_19D == 4) && (func_80998334(this, globalCtx, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, @@ -665,7 +664,7 @@ s32 func_80998F9C(EnGs* this, GlobalContext* globalCtx) { this->unk_1E0 = 1.5f; this->unk_1E4 = this->unk_1B0[1].y - 1.0f; this->unk_1E8 = -0.3f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_STONE_GROW_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_STONE_GROW_UP); this->unk_19D = 3; } } @@ -715,7 +714,7 @@ s32 func_80998F9C(EnGs* this, GlobalContext* globalCtx) { this->unk_1E8 = 0.0f; this->unk_1F0 = 0.0f; this->unk_1EC = 0.5f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_21C = 20; this->unk_21E = 2; this->unk_19D = 6; @@ -738,7 +737,7 @@ s32 func_80998F9C(EnGs* this, GlobalContext* globalCtx) { } if ((u16)this->unk_19E[0].y < sp3A) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_STONE_ROLLING); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_STONE_ROLLING); } return sp4C; @@ -853,7 +852,7 @@ s32 func_809995A4(EnGs* this, GlobalContext* globalCtx) { sp54.x = this->actor.world.pos.x; sp54.y = this->actor.world.pos.y; sp54.z = this->actor.world.pos.z; - Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); EffectSsBomb2_SpawnLayered(globalCtx, &sp54, &bomb2Velocity, &bomb2Accel, 100, 20); this->unk_1D4 = 10; this->unk_19A |= 8; @@ -863,7 +862,7 @@ s32 func_809995A4(EnGs* this, GlobalContext* globalCtx) { func_800B9010(&this->actor, NA_SE_EV_STONE_LAUNCH - SFX_FLAG); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Math_SmoothStepToF(&this->unk_1DC, this->unk_1E0, 0.5f, 364.0f, 0.0f); this->unk_19E[1].y += (s16)this->unk_1DC; @@ -935,9 +934,9 @@ void func_80999BC8(Actor* thisx, GlobalContext* globalCtx2) { } if (this->actor.params == ENGS_1) { - Actor_SetHeight(&this->actor, 34.5f); + Actor_SetFocus(&this->actor, 34.5f); } else { - Actor_SetHeight(&this->actor, 23.0f); + Actor_SetFocus(&this->actor, 23.0f); } if (this->unk_21A > 0) { @@ -1008,12 +1007,12 @@ void EnGs_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnGs* this = THIS; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.unk11F22 = 0; globalCtx->msgCtx.unk11F10 = 0; this->collider.base.acFlags &= ~AC_HIT; func_80997DEC(this, globalCtx); - } else if (func_800B8718(&this->actor, globalCtx)) { + } else if (func_800B8718(&this->actor, &globalCtx->state)) { this->unk_19A |= 0x200; this->collider.base.acFlags &= ~AC_HIT; if (this->actor.cutscene != -1) { @@ -1027,7 +1026,7 @@ void EnGs_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.flags & 0x40) || (this->unk_19A & 0x100) || (this->unk_19A & 0x200)) { func_80999BC8(&this->actor, globalCtx); - func_800B8898(globalCtx, &this->actor, &sp2E, &sp2C); + Actor_GetScreenPos(globalCtx, &this->actor, &sp2E, &sp2C); if ((this->actor.xyzDistToPlayerSq > SQ(400.0f)) || (sp2E < 0) || (sp2E > 320) || (sp2C < 0) || (sp2C > 240)) { this->unk_216 = 0; @@ -1103,7 +1102,7 @@ void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, -frames * 20, 0x20, 0x80)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - gSPDisplayList(POLY_XLU_DISP++, D_0407D590); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index 14a2ac839e..b93a1befee 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -79,7 +79,7 @@ void EnGuruguru_Init(Actor* thisx, GlobalContext* globalCtx) { EnGuruguru* this = THIS; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 19.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06006C90, &D_06000B04, this->jointTable, this->morphTable, 16); this->actor.targetMode = 0; if (this->actor.params != 2) { @@ -170,7 +170,7 @@ void func_80BC6F14(EnGuruguru* this, GlobalContext* globalCtx) { yawTemp = this->actor.yawTowardsPlayer - this->actor.world.rot.y; yaw = ABS_ALT(yawTemp); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80BC701C(this, globalCtx); } else if (yaw <= 0x2890) { func_800B8614(&this->actor, globalCtx, 60.0f); @@ -197,7 +197,7 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); } else if (this->unusedTimer == 0) { this->unusedTimer = 6; - if (func_80152498(&globalCtx->msgCtx) != 5) { + if (Message_GetState(&globalCtx->msgCtx) != 5) { if (this->unk266 == 0) { if (this->headZRotTarget != 0) { this->headZRotTarget = 0; @@ -213,7 +213,7 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { } } } - if ((func_80152498(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { func_801477B4(globalCtx); this->headZRotTarget = 0; if ((this->textIdIndex == 13) || (this->textIdIndex == 14)) { @@ -301,21 +301,21 @@ void func_80BC7440(EnGuruguru* this, GlobalContext* globalCtx) { this->textIdIndex++; this->actor.textId = textIDs[this->textIdIndex]; func_801A3B48(1); - func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, -1); + func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, EXCH_ITEM_MINUS1); this->unk268 = 0; gSaveContext.weekEventReg[38] |= 0x40; this->actionFunc = func_80BC7520; } else { - func_800B8A1C(&this->actor, globalCtx, GI_MASK_BREMEN, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MASK_BREMEN, 300.0f, 300.0f); } } void func_80BC7520(EnGuruguru* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80BC7068; } else { - func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, -1); + func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, EXCH_ITEM_MINUS1); } } @@ -365,8 +365,8 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { } } Actor_SetScale(&this->actor, 0.01f); - Actor_SetHeight(&this->actor, 50.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_SetFocus(&this->actor, 50.0f); + Actor_MoveWithGravity(&this->actor); Math_SmoothStepToS(&this->headXRot, this->headXRotTarget, 1, 3000, 0); Math_SmoothStepToS(&this->headZRot, this->headZRotTarget, 1, 1000, 0); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index 0a0dccef71..416ab1140a 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -72,14 +72,14 @@ extern Gfx D_06011178[]; void EnHakurock_Init(Actor* thisx, GlobalContext* globalCtx) { EnHakurock* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 52.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 52.0f); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); if (this->actor.params == EN_HAKUROCK_TYPE_BOULDER) { this->actor.gravity = -1.5f; } else { this->collider.base.ocFlags1 &= ~OC1_NO_PUSH; - this->actor.minVelocityY = -100.0f; + this->actor.terminalVelocity = -100.0f; this->actor.gravity = -7.0f; } func_80B21FFC(this); @@ -212,7 +212,7 @@ void func_80B221E8(EnHakurock* this, GlobalContext* globalCtx) { if (this->collider.base.atFlags & AT_HIT || ((this->counter == 0) && (this->collider.base.ocFlags1 & OC1_HIT)) || ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROCK_BROKEN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROCK_BROKEN); func_80B21EA4(this, 0); func_80B21FFC(this); } @@ -247,7 +247,7 @@ void func_80B2242C(EnHakurock* this, GlobalContext* globalCtx) { func_80B21FFC(this); } else if ((this->actor.bgCheckFlags & 1)) { func_80B21EA4(this, 2); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_OBJECT_STICK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OBJECT_STICK); func_80B224C0(this); } } @@ -322,7 +322,7 @@ void EnHakurock_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); rockParams = this->actor.params; if ((rockParams == EN_HAKUROCK_TYPE_BOULDER) || (rockParams == EN_HAKUROCK_TYPE_UNK_2)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, this->collider.dim.radius, 0.0f, 0x85); if (this->actor.floorHeight == BGCHECK_Y_MIN) { func_80B21FFC(this); diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.c b/src/overlays/actors/ovl_En_Hg/z_en_hg.c index d7eec060d9..c02ab0eaf2 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -155,7 +155,7 @@ void EnHg_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80BCF354(EnHg* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BCF398; } @@ -167,13 +167,13 @@ void func_80BCF398(EnHg* this, GlobalContext* globalCtx) { } if ((gSaveContext.sceneSetupIndex == 0 && globalCtx->csCtx.unk_12 == 0) && (globalCtx->csCtx.frames == 20 || globalCtx->csCtx.frames == 60)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_HALF_REDEAD_SURPRISE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HALF_REDEAD_SURPRISE); } } } void func_80BCF468(EnHg* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BCF4AC; } @@ -182,10 +182,10 @@ void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { s32 pad; this->actor.speedXZ = 1.6f; - if (!(player->stateFlags2 & 0x08000000) && !func_80152498(&globalCtx->msgCtx)) { + if (!(player->stateFlags2 & 0x08000000) && !Message_GetState(&globalCtx->msgCtx)) { if (((this->skelAnime.curFrame > 9.0f) && (this->skelAnime.curFrame < 16.0f)) || ((this->skelAnime.curFrame > 44.0f) && (this->skelAnime.curFrame < 51.0f))) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x3E8, 0x14); this->actor.world.rot.y = this->actor.shape.rot.y; } @@ -197,7 +197,7 @@ void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF5F0(EnHg* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BCF634; } @@ -210,7 +210,7 @@ void func_80BCF634(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF68C(EnHg* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80BCF6D0; } @@ -221,8 +221,8 @@ void func_80BCF6D0(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF710(EnHg* this, GlobalContext* globalCtx) { - if (!func_80152498(&globalCtx->msgCtx)) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, 0x24F, &this->actor); } else { func_800B8614(&this->actor, globalCtx, 80.0f); @@ -284,17 +284,17 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { case 1: this->currentAnimation = 0; - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); break; case 2: this->cutscenes[2] = 0; this->currentAnimation = 3; - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); break; case 3: this->cutscenes[2] = 0; this->currentAnimation = 5; - func_800BDC5C(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); break; case 4: this->cutscenes[2] = 0; @@ -302,11 +302,11 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { if ((this->unk218 == 1) || (this->unk218 == 3)) { func_8019F128(NA_SE_EN_HALF_REDEAD_TRANS); } - func_800BDC5C(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); break; case 5: this->currentAnimation = 1; - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); break; case 6: gSaveContext.weekEventReg[0x4B] |= 0x20; @@ -318,11 +318,11 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { switch (this->currentAnimation) { case 3: this->currentAnimation = 4; - func_800BDC5C(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); break; case 5: this->currentAnimation = 6; - func_800BDC5C(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); break; } } diff --git a/src/overlays/actors/ovl_En_Holl/z_en_holl.c b/src/overlays/actors/ovl_En_Holl/z_en_holl.c index 65f5e4d555..ff418b5797 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -108,7 +108,7 @@ void EnHoll_SetupAction(EnHoll* this) { void EnHoll_SetPlayerSide(GlobalContext* globalCtx, EnHoll* this, Vec3f* transformedPlayerPos) { Player* player = GET_PLAYER(globalCtx); - Actor_CalcOffsetOrientedToDrawRotation(&this->actor, transformedPlayerPos, &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->actor, transformedPlayerPos, &player->actor.world.pos); this->playerSide = (transformedPlayerPos->z < 0.0f) ? EN_HOLL_BEHIND : EN_HOLL_BEFORE; } @@ -223,8 +223,8 @@ void EnHoll_TransparentIdle(EnHoll* this, GlobalContext* globalCtx) { f32 enHollTop; f32 playerDistFromCentralPlane; - Actor_CalcOffsetOrientedToDrawRotation(&this->actor, &transformedPlayerPos, - useViewEye ? &globalCtx->view.eye : &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->actor, &transformedPlayerPos, + useViewEye ? &globalCtx->view.eye : &player->actor.world.pos); enHollTop = (globalCtx->sceneNum == SCENE_PIRATE) ? EN_HOLL_TOP_PIRATE : EN_HOLL_TOP_DEFAULT; if ((transformedPlayerPos.y > EN_HOLL_BOTTOM_DEFAULT) && (transformedPlayerPos.y < enHollTop) && diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.h b/src/overlays/actors/ovl_En_Horse/z_en_horse.h index 7efae12fc7..787fd8b579 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.h +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.h @@ -7,9 +7,11 @@ struct EnHorse; typedef struct EnHorse { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x00C]; + /* 0x144 */ char unk_144[0xC]; /* 0x150 */ s32 unk_150; - /* 0x154 */ char unk_154[0x440]; + /* 0x154 */ char unk_154[0x98]; + /* 0x1EC */ UNK_TYPE4 unk_1EC; + /* 0x1F0 */ char unk_1F0[0x3A4]; } EnHorse; // size = 0x594 extern const ActorInit En_Horse_InitVars; diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index 800e44c6fb..627aec919c 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -215,12 +215,13 @@ s32 func_808F3178(EnIn* this, GlobalContext* globalCtx) { this->unk260 = tmp = func_8013DB90(globalCtx, &this->unk248, -6.0f); if (this->unk260 != 0 && prevUnk260 == 0 && tmp) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_CONCRETE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } this->unk261 = tmp = func_8013DB90(globalCtx, &this->unk254, -6.0f); if (this->unk261 != 0 && prevUnk261 == 0 && tmp) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_CONCRETE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } + return 0; } @@ -258,7 +259,7 @@ s32 func_808F3334(EnIn* this, GlobalContext* globalCtx) { if (this->colliderJntSph.base.atFlags & AT_BOUNCED) { return 0; } - Audio_PlayActorSound2(&player->actor, 0x83E); + Actor_PlaySfxAtPos(&player->actor, 0x83E); func_800B8D98(globalCtx, &this->actor, 3.0f, this->actor.yawTowardsPlayer, 6.0f); } return 1; @@ -356,7 +357,7 @@ void func_808F374C(EnIn* this, GlobalContext* globalCtx) { } } if (this->skelAnime.animation == &D_060198A8 && Animation_OnFrame(&this->skelAnime, 20.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_IN_CRY_0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_CRY_0); } if (SkelAnime_Update(&this->skelAnime)) { this->unk486 = this->unk488 %= 8; @@ -369,7 +370,7 @@ void func_808F38F8(EnIn* this, GlobalContext* globalCtx) { this->unk4A4 = NULL; while (true) { //! @bug: Infinite loop if there is only one ACTOR_EN_IN - this->unk4A4 = (EnIn*)func_ActorCategoryIterateById(globalCtx, &this->unk4A4->actor, ACTORCAT_NPC, ACTOR_EN_IN); + this->unk4A4 = (EnIn*)SubS_FindActor(globalCtx, &this->unk4A4->actor, ACTORCAT_NPC, ACTOR_EN_IN); if (this->unk4A4 != NULL && this->unk4A4 != this) { break; } @@ -381,7 +382,7 @@ void func_808F395C(EnIn* this, GlobalContext* globalCtx) { if (this->unk4B0 == 0) { this->actionFunc = func_808F5A94; } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; this->actionFunc = func_808F5A34; this->unk48C = 1; @@ -418,19 +419,19 @@ void func_808F39DC(EnIn* this, GlobalContext* globalCtx) { this->actor.textId = textId; this->actionFunc = func_808F395C; if (this->unk4B0 == 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_IN_LOST); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_IN_JOY0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); } } void func_808F3AD4(EnIn* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); } } @@ -444,17 +445,17 @@ void func_808F3B40(EnIn* this, GlobalContext* globalCtx) { textId = gSaveContext.day != 3 ? 0x3481 : 0x34A4; this->actor.textId = textId; } else { - func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); } } void func_808F3BD4(EnIn* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); } } @@ -468,17 +469,17 @@ void func_808F3C40(EnIn* this, GlobalContext* globalCtx) { textId = gSaveContext.day != 3 ? 0x346A : 0x3492; this->actor.textId = textId; } else { - func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); } } void func_808F3CD4(EnIn* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); } } @@ -492,7 +493,7 @@ void func_808F3D40(EnIn* this, GlobalContext* globalCtx) { this->actor.textId = textId; this->actor.flags |= 0x10000; } else { - func_800B8A1C(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); } } @@ -606,7 +607,7 @@ void func_808F4054(GlobalContext* globalCtx, EnIn* this, s32 arg2, u16 textId) { } void func_808F4108(EnIn* this, GlobalContext* globalCtx, u16 textId) { - func_800B86C8(&this->actor, globalCtx, &this->unk4A4->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk4A4->actor); this->actor.textId = 0; this->unk4A4->actor.textId = textId; this->unk4A4->unk48C = 2; @@ -792,7 +793,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { if (func_80114E90()) { this->actionFunc = func_808F3C40; - func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); func_801159EC(-globalCtx->msgCtx.unk1206C); ret = true; } else { @@ -938,7 +939,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_808F35D8(this, globalCtx); if (func_80114E90()) { this->actionFunc = func_808F3B40; - func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); ret = true; } else { func_800E8EA0(globalCtx, &this->actor, 0x347F); @@ -962,7 +963,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x347C: this->actionFunc = func_808F3D40; - func_800B8A1C(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); func_808F35D8(this, globalCtx); ret = true; break; @@ -1044,7 +1045,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { if (func_80114E90()) { this->actionFunc = func_808F3C40; - func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); func_801159EC(-globalCtx->msgCtx.unk1206C); ret = true; } else { @@ -1127,7 +1128,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x349F: this->actionFunc = func_808F3D40; - func_800B8A1C(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); func_808F35D8(this, globalCtx); ret = true; break; @@ -1142,7 +1143,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_808F35D8(this, globalCtx); if (func_80114E90()) { this->actionFunc = func_808F3B40; - func_800B8A1C(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); ret = true; } else { func_800E8EA0(globalCtx, &this->actor, 0x34A2); @@ -1222,7 +1223,7 @@ s32 func_808F5674(GlobalContext* globalCtx, EnIn* this, s32 arg2) { s32 pad; s32 ret = false; - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 2: func_808F4054(globalCtx, this, arg2, this->actor.textId); ret = true; @@ -1257,7 +1258,7 @@ s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { *arg3 = 1; return 0; } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { *arg3 = 1; return 1; } @@ -1379,9 +1380,9 @@ void func_808F5C98(EnIn* this, GlobalContext* globalCtx) { } if (this->unk4A8 == 2) { if (this->unk4B0 == 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_IN_LOST); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_IN_JOY0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); } this->unk4A8 = 3; } else if (this->unk4A8 < 3) { @@ -1400,7 +1401,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { s16 type; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 30.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06014EA8, NULL, this->jointTable, this->morphTable, 20); func_808F30B0(&this->skelAnime, 0); Collider_InitCylinder(globalCtx, &this->colliderCylinder); @@ -1519,7 +1520,7 @@ void func_808F6334(EnIn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 newUnk4C8; - newUnk4C8 = func_80152498(&globalCtx->msgCtx); + newUnk4C8 = Message_GetState(&globalCtx->msgCtx); this->unk4C4 += this->unk4C0 != 0.0f ? 40.0f : -40.0f; this->unk4C4 = CLAMP(this->unk4C4, 0.0f, 80.0f); diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 94a360df8c..37b6aace56 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -561,7 +561,7 @@ static InitChainEntry sInitChainRomani[] = { static InitChainEntry D_80B4EC68[] = { ICHAIN_F32(uncullZoneForward, 20000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_CONTINUE), ICHAIN_VEC3S(shape.rot, 0, ICHAIN_CONTINUE), - ICHAIN_F32(minVelocityY, -100, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), + ICHAIN_F32(terminalVelocity, -100, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; static InitChainEntry sInitChainDog[] = { @@ -1131,7 +1131,7 @@ void func_80B44A90(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.velocity.y *= 0.8f; this->actor.speedXZ *= 0.8f; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 40.0f, 0.0f, 5); } @@ -1207,7 +1207,7 @@ s32 func_80B44C80(EnInvadepoh* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(((sp60.z + temp_f0_2) * 0.9f) + sp6C.z, ((sp60.x + temp_f0_3) * 0.9f) + sp6C.x), 4, 0xFA0, 0x64); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (func_80B440B8(this, 50.0f, 15.0f)) { phi_v0 = 4; } else { @@ -1220,7 +1220,7 @@ s32 func_80B44C80(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B44E90(EnInvadepoh* this, GlobalContext* globalCtx) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 15.0f, 0.0f, 5); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x1F40, 0x64); } @@ -1377,7 +1377,7 @@ void EnInvadepoh_SetSysMatrix(Vec3f* vec) { s32 func_80B45550(EnInvadepoh* this, GlobalContext* globalCtx, f32 range, s32 arg3) { s32 pad; - Actor* actorIterator = globalCtx->actorCtx.actorList[ACTORCAT_DOOR].first; + Actor* actorIterator = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; s32 retVal = false; while (actorIterator != NULL) { @@ -1412,7 +1412,7 @@ s32 func_80B456A8(GlobalContext* globalCtx, Vec3f* vec) { Vec3f multDest; f32 wDest; - func_800B4EDC(globalCtx, vec, &multDest, &wDest); + Actor_GetProjectedPos(globalCtx, vec, &multDest, &wDest); if (((multDest.z > 1.0f) && (fabsf(multDest.x * wDest) < 1.0f)) && (fabsf(multDest.y * wDest) < 1.0f)) { s32 wX = (multDest.x * wDest * 160.0f) + 160.0f; s32 wY = (multDest.y * wDest * -120.0f) + 120.0f; @@ -1720,7 +1720,7 @@ void EnInvadepoh_InitAlien(EnInvadepoh* this, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, D_80B4EC24); Collider_InitCylinder(globalCtx, &this->collider); - ActorShape_Init(&this->actor.shape, 6800.0f, func_800B4088, 150.0f); + ActorShape_Init(&this->actor.shape, 6800.0f, ActorShadow_DrawWhiteCircle, 150.0f); this->actor.shape.shadowAlpha = 140; this->actor.flags = 0x80001010; if (INVADEPOH_TYPE(this) == TYPE_ALIEN1) { @@ -1768,7 +1768,7 @@ void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_NPC); Collider_InitCylinder(globalCtx, &this->collider); if (temp != 4) { - ActorShape_Init(&this->actor.shape, 0, func_800B3FC0, 18.0f); + ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 18.0f); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitRomaniAndCremia); this->actor.colChkInfo.mass = MASS_IMMOVABLE; } @@ -1842,7 +1842,7 @@ void EnInvadepoh_InitDog(EnInvadepoh* this, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitDog); this->actor.colChkInfo.mass = 0x50; - ActorShape_Init(&this->actor.shape, 0, func_800B3FC0, 24.0f); + ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 24.0f); this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_DOG); if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); @@ -1858,7 +1858,7 @@ void EnInvadepoh_InitCremia(EnInvadepoh* this, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitRomaniAndCremia); this->actor.colChkInfo.mass = MASS_HEAVY; - ActorShape_Init(&this->actor.shape, 0, func_800B3FC0, 18.0f); + ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 18.0f); this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MA2); if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); @@ -2231,7 +2231,7 @@ void func_80B47830(EnInvadepoh* this) { this->collider.base.acFlags &= ~1; this->collider.base.ocFlags1 |= 1; Animation_PlayLoop(&this->skelAnime, &D_060006C8); - func_800BCB70(&this->actor, 0x4000, 255, 0, 16); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); this->alienAlpha = 255; this->actor.draw = func_80B4DB14; this->drawAlien = true; @@ -2323,7 +2323,7 @@ void func_80B47BAC(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B45080(); this->actor.update = func_80B47D30; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004E50, &D_06001D80, this->jointTable, this->morphTable, @@ -2406,7 +2406,7 @@ void func_80B47FA8(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, thisx); + Actor_SetObjectDependency(globalCtx, thisx); this->actor.update = func_80B48060; this->actor.draw = func_80B4E158; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004010, NULL, this->jointTable, this->morphTable, 6); @@ -2449,7 +2449,7 @@ void func_80B481C4(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); this->actor.update = func_80B4827C; this->actor.draw = func_80B4E1B0; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004C30, NULL, this->jointTable, this->morphTable, 6); @@ -2562,7 +2562,7 @@ void func_80B48620(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); this->actor.update = func_80B4873C; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06009E58, this->jointTable, this->morphTable, @@ -2619,7 +2619,7 @@ void func_80B48848(EnInvadepoh* this, GlobalContext* globalCtx) { func_80B43E6C(this, 6, this->behaviorInfo.unk4C, 0x46); if (((this->actor.flags & 0x40) == 0x40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } if (this->actionTimer > 0) { this->actionTimer--; @@ -2754,7 +2754,7 @@ void func_80B48E4C(EnInvadepoh* this, GlobalContext* globalCtx) { diff = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); temp_v1 = diff * 0.7f; substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { func_80B48948(this); } } @@ -2764,7 +2764,7 @@ void func_80B48FB0(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); this->actor.update = func_80B490F0; this->actor.draw = func_80B4E324; @@ -2784,7 +2784,7 @@ void func_80B490F0(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; s32 sp2C = (this->actor.flags & 0x40) == 0x40; - s32 isTalking = func_800B84D0(&this->actor, globalCtx); + s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { func_80151BB4(globalCtx, 5); @@ -2815,7 +2815,7 @@ void func_80B49228(EnInvadepoh* this, GlobalContext* globalCtx) { s32 pad; f32 temp_f0; - Actor_SetVelocityYRotationAndGravity(&this->actor); + Actor_UpdateVelocityWithGravity(&this->actor); this->actor.velocity.y *= 0.97f; temp_f0 = Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y + D_80B4E934.y + 300.0f, 0.7f, fabsf(this->actor.velocity.y), 1.0f); @@ -2844,7 +2844,7 @@ void func_80B4934C(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.gravity = -2.0f; } this->actor.velocity.y *= 0.96f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_800B9010(&this->actor, NA_SE_EV_UFO_APPEAR - SFX_FLAG); this->actionTimer--; if (this->actionTimer <= 0) { @@ -2931,7 +2931,7 @@ void func_80B49670(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.gravity = 2.0f; } this->actor.velocity.y *= 0.97f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (D_80B4E940 == 3) { func_80B499BC(this); } @@ -2961,7 +2961,7 @@ void func_80B497EC(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.gravity = 2.0f; } this->actor.velocity.y *= 0.97f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (this->actionTimer > 0) { this->actionTimer--; } else { @@ -2981,7 +2981,7 @@ void func_80B49904(EnInvadepoh* this) { void func_80B4994C(EnInvadepoh* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 150.0f, 4.0f); this->actor.velocity.y *= 0.95f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (this->actionTimer > 0) { this->actionTimer--; } else { @@ -3013,7 +3013,7 @@ void func_80B49A00(EnInvadepoh* this, GlobalContext* globalCtx) { } else { this->actor.gravity = 2.0f; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (this->actionTimer > 0) { this->actionTimer--; @@ -3072,7 +3072,7 @@ void func_80B49C38(EnInvadepoh* this, GlobalContext* globalCtx) { if (((this->actor.flags & 0x40) == 0x40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } if (this->clockTime >= 0.9999f) { Actor_MarkForDeath(&this->actor); @@ -3102,7 +3102,7 @@ void func_80B49DFC(EnInvadepoh* this, GlobalContext* globalCtx) { temp_v1 = diff; temp_v1 *= 0.7f; substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { if (this->actor.textId == 0x332D) { gSaveContext.weekEventReg[54] |= 0x10; this->actor.textId = 0x332E; @@ -3119,7 +3119,7 @@ void func_80B49F88(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { sp38 = gSaveContext.time; this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->jointTable, this->morphTable, 23); @@ -3167,7 +3167,7 @@ void func_80B4A1B8(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; s32 sp2C = (this->actor.flags & 0x40) == 0x40; - s32 isTalking = func_800B84D0(&this->actor, globalCtx); + s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { func_80151BB4(globalCtx, 5); @@ -3298,7 +3298,7 @@ void func_80B4A67C(EnInvadepoh* this, GlobalContext* globalCtx) { } if (((this->actor.flags & 0x40) == 0x40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } if (this->pathIndex == this->endPoint) { func_80B4A2C0(this); @@ -3329,7 +3329,7 @@ void func_80B4A81C(EnInvadepoh* this, GlobalContext* globalCtx) { temp_v1 *= 0.7f; substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { if (this->actor.textId == 0x332D) { gSaveContext.weekEventReg[54] |= 0x10; this->actor.textId = 0x332E; @@ -3350,7 +3350,7 @@ void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { sp38 = gSaveContext.time; this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->jointTable, this->morphTable, 23); @@ -3396,7 +3396,7 @@ void func_80B4ABDC(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; s32 sp2C = (this->actor.flags & 0x40) == 0x40; - s32 isTalking = func_800B84D0(&this->actor, globalCtx); + s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { func_80151BB4(globalCtx, 5); @@ -3432,7 +3432,7 @@ void func_80B4AD3C(EnInvadepoh* this) { } void func_80B4AD60(EnInvadepoh* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { EnInvadepoh_SetTextID(this, globalCtx, 0x3331); func_80B4ADB8(this); } else { @@ -3445,7 +3445,7 @@ void func_80B4ADB8(EnInvadepoh* this) { } void func_80B4ADCC(EnInvadepoh* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { if (this->textId == 0x3331) { if (gSaveContext.weekEventReg[22] & 2) { EnInvadepoh_SetTextID(this, globalCtx, 0x3334); @@ -3482,7 +3482,7 @@ void func_80B4AEDC(EnInvadepoh* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[22] |= 2; func_80B4AF80(this); } else { - func_800B8A1C(&this->actor, globalCtx, GI_MILK_BOTTLE, 2000.0f, 2000.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK_BOTTLE, 2000.0f, 2000.0f); } } @@ -3491,14 +3491,14 @@ void func_80B4AF80(EnInvadepoh* this) { } void func_80B4AF94(EnInvadepoh* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { EnInvadepoh_SetTextID(this, globalCtx, 0x3334); func_80151BB4(globalCtx, 0x1E); func_80151BB4(globalCtx, 0x1D); func_80151BB4(globalCtx, 5); func_80B4ADB8(this); } else { - func_800B85E0(&this->actor, globalCtx, 2000.0f, -1); + func_800B85E0(&this->actor, globalCtx, 2000.0f, EXCH_ITEM_MINUS1); } } @@ -3511,7 +3511,7 @@ void func_80B4B048(EnInvadepoh* this, GlobalContext* globalCtx) { if (globalCtx->msgCtx.unk120B1 == 0) { if (globalCtx->msgCtx.unk11F22 == 0) { D_80B4E998 = 1; - } else if ((func_80152498(&globalCtx->msgCtx) == 6) || (func_80152498(&globalCtx->msgCtx) == 5)) { + } else if ((Message_GetState(&globalCtx->msgCtx) == 6) || (Message_GetState(&globalCtx->msgCtx) == 5)) { D_80B4E998 = 1; } } @@ -3524,7 +3524,7 @@ void func_80B4B0C4(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); this->actor.update = func_80B4B218; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->jointTable, this->morphTable, @@ -3571,7 +3571,7 @@ void func_80B4B3DC(EnInvadepoh* this) { s32 pad; if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 7.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_MONKEY_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); } } @@ -3634,7 +3634,7 @@ void func_80B4B564(EnInvadepoh* this, GlobalContext* globalCtx) { this->actionTimer--; } else if (this->unk3BC >= 0) { if ((D_80B50348 == 0) && (Rand_ZeroOne() < 0.4f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); } func_80B4B724(this); } else { @@ -3655,7 +3655,7 @@ void func_80B4B768(EnInvadepoh* this, GlobalContext* globalCtx) { 0x64); func_80B44E90(this, globalCtx); if (Animation_OnFrame(&this->skelAnime, 13.0f) || Animation_OnFrame(&this->skelAnime, 19.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); } if (this->animPlayFlag) { func_80B4B510(this); @@ -3681,7 +3681,7 @@ void func_80B4B8BC(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060080F0, &D_060021C8, this->jointTable, this->morphTable, 13); func_80B45C04(&this->behaviorInfo, 0, 0, 0, 0, &gZeroVec3s, 3000, 0.1f, 0.0f, 0.0f); @@ -3832,7 +3832,7 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { if (((this->actor.flags & 0x40) == 0x40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } if (gSaveContext.time > CLOCK_TIME(20, 15)) { Actor_MarkForDeath(&this->actor); @@ -3868,7 +3868,7 @@ void func_80B4C058(EnInvadepoh* this, GlobalContext* globalCtx) { substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { func_80B4BBE0(this); } } @@ -3914,7 +3914,7 @@ void func_80B4C3A0(Actor* thisx, GlobalContext* globalCtx) { s32 currentTime = gSaveContext.time; this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44FEC(); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06015C28, &D_06016720, this->jointTable, this->morphTable, 22); @@ -3958,7 +3958,7 @@ void func_80B4C5C0(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; s32 sp2C = (this->actor.flags & 0x40) == 0x40; - s32 isTalking = func_800B84D0(&this->actor, globalCtx); + s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { func_80151BB4(globalCtx, 6); @@ -4053,7 +4053,7 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { if (((this->actor.flags & 0x40) == 0x40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } if (this->clockTime >= 0.9999f) { @@ -4090,7 +4090,7 @@ void func_80B4CB0C(EnInvadepoh* this, GlobalContext* globalCtx) { temp_v1 = diff; temp_v1 *= 0.7f; substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { func_80B4C6C8(this); } } @@ -4135,7 +4135,7 @@ void func_80B4CE54(Actor* thisx, GlobalContext* globalCtx) { sp38 = gSaveContext.time; this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, &D_06014088, this->jointTable, this->morphTable, 23); @@ -4174,7 +4174,7 @@ void func_80B4D054(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; s32 sp2C = (this->actor.flags & 0x40) == 0x40; - s32 isTalking = func_800B84D0(&this->actor, globalCtx); + s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { func_80151BB4(globalCtx, 5); @@ -4323,7 +4323,7 @@ void func_80B4D670(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { invadepohType = this->actor.params & 7; this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); func_80B45080(); this->actor.update = func_80B4D760; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004E50, &D_06001674, this->jointTable, this->morphTable, diff --git a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c index 603420f76f..ff1f9b6cac 100644 --- a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c +++ b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c @@ -68,7 +68,7 @@ static InitChainEntry D_80C1AAB0[] = { ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_CONTINUE), ICHAIN_VEC3S(shape.rot, 0, ICHAIN_CONTINUE), - ICHAIN_F32(minVelocityY, -100, ICHAIN_CONTINUE), + ICHAIN_F32(terminalVelocity, -100, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 800, ICHAIN_STOP), }; diff --git a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c index f459fbf53a..3609275335 100644 --- a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c +++ b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c @@ -78,7 +78,7 @@ void func_80C2590C(EnInvisibleRuppe* this, GlobalContext* globalCtx) { } if (this->unk_190 >= 0) { - Actor_SetSwitchFlag(globalCtx, this->unk_190); + Flags_SetSwitch(globalCtx, this->unk_190); } this->actionFunc = func_80C259E8; diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index a7ed2025a7..abc5474d84 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -5,6 +5,9 @@ */ #include "z_en_ishi.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_ishi/object_ishi.h" #define FLAGS 0x00800010 @@ -14,14 +17,31 @@ void EnIshi_Init(Actor* thisx, GlobalContext* globalCtx); void EnIshi_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnIshi_Update(Actor* thisx, GlobalContext* globalCtx); +void func_8095D804(Actor* thisx, GlobalContext* globalCtx); +void func_8095DABC(Actor* thisx, GlobalContext* globalCtx); +void func_8095DDA8(EnIshi* this, GlobalContext* globalCtx); +void func_8095DE9C(EnIshi* this, GlobalContext* globalCtx); +void func_8095E5AC(EnIshi* this); void func_8095E5C0(EnIshi* this, GlobalContext* globalCtx); +void func_8095E64C(EnIshi* this); void func_8095E660(EnIshi* this, GlobalContext* globalCtx); +void func_8095E934(EnIshi* this); void func_8095E95C(EnIshi* this, GlobalContext* globalCtx); +void func_8095EA70(EnIshi* this); void func_8095EBDC(EnIshi* this, GlobalContext* globalCtx); +void func_8095F060(EnIshi* this); void func_8095F0A4(EnIshi* this, GlobalContext* globalCtx); +void func_8095F180(EnIshi* this); void func_8095F194(EnIshi* this, GlobalContext* globalCtx); +void func_8095F210(EnIshi* this, GlobalContext* globalCtx); +void func_8095F36C(EnIshi* this, GlobalContext* globalCtx); +void func_8095F61C(Actor* thisx, GlobalContext* globalCtx); +void func_8095F654(Actor* thisx, GlobalContext* globalCtx); + +static s16 D_8095F690 = 0; + +static s16 D_8095F694 = 0; -#if 0 const ActorInit En_Ishi_InitVars = { ACTOR_EN_ISHI, ACTORCAT_PROP, @@ -34,109 +54,702 @@ const ActorInit En_Ishi_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8095F6EC = { - { COLTYPE_HARD, AT_ON | AT_TYPE_PLAYER, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x01C37FBE, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 10, 18, -2, { 0, 0, 0 } }, +static f32 D_8095F6B8[] = { 0.1f, 0.4f }; + +static f32 D_8095F6C0[] = { 58.0f, 80.0f }; + +static f32 D_8095F6C8[] = { 0.0f, 0.005f }; + +static u16 D_8095F6D0[] = { NA_SE_EV_ROCK_BROKEN, NA_SE_EV_WALL_BROKEN }; + +static u8 D_8095F6D4[] = { 25, 40 }; + +static EnIshiUnkFunc2 D_8095F6D8[] = { func_8095D804, func_8095DABC }; + +static EnIshiUnkFunc D_8095F6E0[] = { func_8095DDA8, func_8095DE9C }; + +static s16 D_8095F6E8[] = { GAMEPLAY_FIELD_KEEP, OBJECT_ISHI }; + +static ColliderCylinderInit sCylinderInit[] = { + { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x01C37FBE, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 10, 18, -2, { 0, 0, 0 } }, + }, + { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 55, 70, 0, { 0, 0, 0 } }, + }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8095F718 = { - { COLTYPE_HARD, AT_ON | AT_TYPE_PLAYER, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 55, 70, 0, { 0, 0, 0 } }, +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE }; + +static s16 D_8095F74C[] = { 16, 13, 11, 9, 7, 5 }; + +static s16 D_8095F758[] = { 145, 135, 120, 100, 70, 50, 45, 40, 35 }; + +static s16 D_8095F76C[] = { -1, 1, 2, 20, 8, 0 }; + +static Vec3f D_8095F778 = { 0.0f, 1.0f, 0.0f }; + +static InitChainEntry sInitChain[][5] = { + { + ICHAIN_F32_DIV1000(gravity, -1200, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), + }, + { + ICHAIN_F32_DIV1000(gravity, -2500, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 250, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP), + }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_8095F744 = { 0, 12, 60, MASS_IMMOVABLE }; +static u16 D_8095F7AC[] = { NA_SE_PL_PULL_UP_ROCK, NA_SE_PL_PULL_UP_BIGROCK }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8095F784[] = { - ICHAIN_F32_DIV1000(gravity, -1200, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), -}; +static EnIshiUnkFunc D_8095F7B0[] = { func_8095F210, func_8095F36C }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8095F798[] = { - ICHAIN_F32_DIV1000(gravity, -2500, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 250, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP), -}; +void func_8095D6E0(Actor* thisx, GlobalContext* globalCtx) { + EnIshi* this = THIS; -#endif + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit[ENISHI_GET_1(&this->actor)]); + Collider_UpdateCylinder(&this->actor, &this->collider); +} -extern ColliderCylinderInit D_8095F6EC; -extern ColliderCylinderInit D_8095F718; -extern CollisionCheckInfoInit D_8095F744; -extern InitChainEntry D_8095F784[]; -extern InitChainEntry D_8095F798[]; +s32 func_8095D758(EnIshi* this, GlobalContext* globalCtx, f32 arg2) { + Vec3f sp24; + s32 sp20; -extern UNK_TYPE D_060009B0; + sp24.x = this->actor.world.pos.x; + sp24.y = this->actor.world.pos.y + 30.0f; + sp24.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp20, &this->actor, &sp24); + if (this->actor.floorHeight > BGCHECK_Y_MIN) { + this->actor.world.pos.y = this->actor.floorHeight + arg2; + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095D6E0.s") +void func_8095D804(Actor* thisx, GlobalContext* globalCtx) { + EnIshi* this = THIS; + s32 i; + s16 temp; + Gfx* phi_s4; + Vec3f spC4; + Vec3f spB8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095D758.s") + if (!ENISHI_GET_8(&this->actor)) { + phi_s4 = gameplay_field_keep_DL_0066B0; + } else { + phi_s4 = object_ishi_DL_0009B0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095D804.s") + temp = D_8095F6E8[ENISHI_GET_8(&this->actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095DABC.s") + for (i = 0; i < ARRAY_COUNT(D_8095F74C); i++) { + spB8.x = ((Rand_ZeroOne() - 0.5f) * 8.0f) + this->actor.world.pos.x; + spB8.y = (Rand_ZeroOne() * 5.0f) + this->actor.world.pos.y + 5.0f; + spB8.z = ((Rand_ZeroOne() - 0.5f) * 8.0f) + this->actor.world.pos.z; + Math_Vec3f_Copy(&spC4, &this->actor.velocity); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095DDA8.s") + if (this->actor.bgCheckFlags & 1) { + spC4.x *= 0.6f; + spC4.y *= -0.3f; + spC4.z *= 0.6f; + } else if (this->actor.bgCheckFlags & 8) { + spC4.x *= -0.5f; + spC4.y *= 0.5f; + spC4.z *= -0.5f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095DE9C.s") + spC4.x += (Rand_ZeroOne() - 0.5f) * 11.0f; + spC4.y += (Rand_ZeroOne() * 7.0f) + 6.0f; + spC4.z += (Rand_ZeroOne() - 0.5f) * 11.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095DF90.s") + EffectSsKakera_Spawn(globalCtx, &spB8, &spC4, &spB8, -420, (Rand_Next() > 0) ? 65 : 33, 30, 5, 0, D_8095F74C[i], + 3, 10, 40, -1, temp, phi_s4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095DFF0.s") +void func_8095DABC(Actor* thisx, GlobalContext* globalCtx) { + EnIshi* this = THIS; + Vec3f spD8; + Vec3f spCC; + f32 temp_f20; + s16 temp_s1 = 0x1000; + s32 i; + s16 phi_v0; + s16 phi_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E14C.s") + for (i = 0; i < ARRAY_COUNT(D_8095F758); i++) { + temp_s1 += 0x4E20; + temp_f20 = Rand_ZeroOne() * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E180.s") + spCC.x = (Math_SinS(temp_s1) * temp_f20) + this->actor.world.pos.x; + spCC.y = (Rand_ZeroOne() * 40.0f) + this->actor.world.pos.y + 5.0f; + spCC.z = (Math_CosS(temp_s1) * temp_f20) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E204.s") + Math_Vec3f_Copy(&spD8, &this->actor.velocity); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E2B0.s") + if (this->actor.bgCheckFlags & 1) { + spD8.x *= 0.9f; + spD8.y *= -0.8f; + spD8.z *= 0.9f; + } else if (this->actor.bgCheckFlags & 8) { + spD8.x *= -0.9f; + spD8.y *= 0.8f; + spD8.z *= -0.9f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/EnIshi_Init.s") + temp_f20 = Rand_ZeroOne() * 10.0f; + spD8.x += temp_f20 * Math_SinS(temp_s1); + spD8.y += (Rand_ZeroOne() * 4.0f) + (Rand_ZeroOne() * i * 0.7f); + spD8.z += temp_f20 * Math_CosS(temp_s1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/EnIshi_Destroy.s") + if (i == 0) { + phi_v0 = 41; + phi_v1 = -450; + } else if (i < 4) { + phi_v0 = 37; + phi_v1 = -380; + } else { + phi_v0 = 69; + phi_v1 = -320; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E5AC.s") + EffectSsKakera_Spawn(globalCtx, &spCC, &spD8, &this->actor.world.pos, phi_v1, phi_v0, 30, 5, 0, D_8095F758[i], + 5, 2, 70, 0, 2, gameplay_field_keep_DL_006420); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E5C0.s") +void func_8095DDA8(EnIshi* this, GlobalContext* globalCtx) { + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E64C.s") + Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); + if (this->actor.bgCheckFlags & 1) { + sp2C.x += 2.0f * this->actor.velocity.x; + sp2C.y -= 2.0f * this->actor.velocity.y; + sp2C.z += 2.0f * this->actor.velocity.z; + } else if (this->actor.bgCheckFlags & 8) { + sp2C.x -= 2.0f * this->actor.velocity.x; + sp2C.y += 2.0f * this->actor.velocity.y; + sp2C.z -= 2.0f * this->actor.velocity.z; + } + func_800BBFB0(globalCtx, &sp2C, 60.0f, 3, 80, 60, 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E660.s") +void func_8095DE9C(EnIshi* this, GlobalContext* globalCtx) { + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E934.s") + Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); + if (this->actor.bgCheckFlags & 1) { + sp2C.x += 2.0f * this->actor.velocity.x; + sp2C.y -= 2.0f * this->actor.velocity.y; + sp2C.z += 2.0f * this->actor.velocity.z; + } else if (this->actor.bgCheckFlags & 8) { + sp2C.x -= 2.0f * this->actor.velocity.x; + sp2C.y += 2.0f * this->actor.velocity.y; + sp2C.z -= 2.0f * this->actor.velocity.z; + } + func_800BBFB0(globalCtx, &sp2C, 140.0f, 10, 180, 90, 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095E95C.s") +void func_8095DF90(EnIshi* this, GlobalContext* globalCtx) { + if (!ENISHI_GET_1(&this->actor) && !ENISHI_GET_100(&this->actor)) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, ENISHI_GET_F0(&this->actor) * 0x10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095EA70.s") +void func_8095DFF0(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + s32 temp = D_8095F76C[ENISHI_GET_70(&this->actor)]; + Actor* sp3C; + Vec3f sp30; + f32 sp2C; + f32 temp_f2; + s16 temp_v1_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095EBDC.s") + if (temp >= 0) { + sp3C = Item_DropCollectible(globalCtx, &this->actor.world.pos, temp | (ENISHI_GET_FE00(&this->actor) << 8)); + if (sp3C != NULL) { + Matrix_StatePush(); + Matrix_RotateY(this->actor.shape.rot.y, 0); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, 1); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, 1); + Matrix_GetStateTranslationAndScaledY(1.0f, &sp30); + sp2C = Math3D_Parallel(&sp30, &D_8095F778); + if (sp2C < 0.707f) { + temp_v1_2 = Math_FAtan2F(sp30.z, sp30.x) - sp3C->world.rot.y; + if (ABS_ALT(temp_v1_2) > 0x4000) { + sp3C->world.rot.y = BINANG_ROT180(sp3C->world.rot.y); + } + temp_f2 = sp2C + 0.5f; + if (temp_f2 < 0.5f) { + temp_f2 = 0.5f; + } + sp3C->velocity.y *= temp_f2; + } + Matrix_StatePop(); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F060.s") +void func_8095E14C(EnIshi* this) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F0A4.s") +void func_8095E180(Vec3f* arg0, f32 arg1) { + arg1 += ((Rand_ZeroOne() * 0.2f) - 0.1f) * arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F180.s") + arg0->x -= arg0->x * arg1; + arg0->y -= arg0->y * arg1; + arg0->z -= arg0->z * arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F194.s") +void func_8095E204(EnIshi* this, GlobalContext* globalCtx) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/EnIshi_Update.s") + for (i = 0; i < 3; i++) { + if (Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_INSECT, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 1, + this->actor.cutscene, this->actor.unk20, NULL) == NULL) { + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F210.s") +s32 func_8095E2B0(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* sp30; + f32 sp2C; + s32 sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F36C.s") + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, + &sp30, &sp28) && + (this->actor.world.pos.y < sp2C)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F61C.s") +void EnIshi_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnIshi* this = THIS; + s32 sp34 = ENISHI_GET_1(&this->actor); + s32 sp30 = ENISHI_GET_4(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ishi/func_8095F654.s") + if ((sp34 == 0) && (sp30 != 0)) { + this->unk_197 |= 2; + } + + Actor_ProcessInitChain(&this->actor, sInitChain[sp34]); + + if (globalCtx->csCtx.state != 0) { + this->actor.uncullZoneForward += 1000.0f; + } + + if ((this->actor.shape.rot.y == 0) && !(this->unk_197 & 2)) { + this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + } + + Actor_SetScale(&this->actor, D_8095F6B8[sp34]); + func_8095D6E0(&this->actor, globalCtx); + + if ((sp34 == 1) && Flags_GetSwitch(globalCtx, ENISHI_GET_FE00(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } + + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + + if (sp34 == 1) { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.shape.shadowScale = 2.3f; + } else { + this->actor.shape.shadowScale = 2.4f; + this->actor.shape.shadowAlpha = 160; + } + + this->actor.shape.yOffset = D_8095F6C0[sp34]; + + if ((sp30 == 0) && !func_8095D758(this, globalCtx, 0)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_8095E2B0(this, globalCtx)) { + this->unk_197 |= 1; + } + + this->unk_196 = Object_GetIndex(&globalCtx->objectCtx, D_8095F6E8[ENISHI_GET_8(&this->actor)]); + if (this->unk_196 < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + + func_8095E5AC(this); +} + +void EnIshi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyCylinder(globalCtx, &THIS->collider); +} + +void func_8095E5AC(EnIshi* this) { + this->actionFunc = func_8095E5C0; +} + +void func_8095E5C0(EnIshi* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_196)) { + this->actor.objBankIndex = this->unk_196; + this->actor.flags &= ~0x10; + if (!ENISHI_GET_8(&this->actor)) { + this->actor.draw = func_8095F61C; + } else { + this->actor.draw = func_8095F654; + } + func_8095E64C(this); + } +} + +void func_8095E64C(EnIshi* this) { + this->actionFunc = func_8095E660; +} + +void func_8095E660(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp38 = ENISHI_GET_1(&this->actor); + s32 sp34 = (this->collider.base.acFlags & AC_HIT) != 0; + s32 sp30 = this->unk_197 & 2; + + if (sp34) { + this->collider.base.acFlags &= ~AC_HIT; + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + func_8095E934(this); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, D_8095F7AC[sp38]); + if (ENISHI_GET_2(&this->actor)) { + func_8095E204(this, globalCtx); + } + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + return; + } + + if (sp34 && (sp38 == 0) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x508)) { + if (sp30 != 0) { + func_8095DFF0(this, globalCtx); + func_8095F060(this); + return; + } + func_8095DF90(this, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, D_8095F6D4[sp38], D_8095F6D0[sp38]); + D_8095F6D8[sp38](&this->actor, globalCtx); + D_8095F6E0[sp38](this, globalCtx); + Actor_MarkForDeath(&this->actor); + return; + } + + if (sp34) { + this->unk_195 = 5; + } + + if ((this->actor.xzDistToPlayer < 600.0f) || (sp30 != 0)) { + if (this->unk_195 > 0) { + this->unk_195--; + if (this->unk_195 == 0) { + this->collider.base.colType = sCylinderInit[sp38].base.colType; + } else { + this->collider.base.colType = COLTYPE_NONE; + } + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if ((this->actor.xzDistToPlayer < 90.0f) && (sp30 == 0)) { + if (sp38 == 1) { + Actor_PickUp(&this->actor, globalCtx, 0, 80.0f, 20.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, 0, 50.0f, 10.0f); + } + } + } +} + +void func_8095E934(EnIshi* this) { + this->actionFunc = func_8095E95C; + this->actor.room = -1; + this->actor.flags |= 0x10; +} + +void func_8095E95C(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + s32 sp2C; + + if (Actor_HasNoParent(&this->actor, globalCtx)) { + this->actor.room = globalCtx->roomCtx.currRoom.num; + if (ENISHI_GET_1(&this->actor) == 1) { + Flags_SetSwitch(globalCtx, ENISHI_GET_FE00(&this->actor)); + } + func_8095EA70(this); + func_8095E14C(this); + func_8095E180(&this->actor.velocity, D_8095F6C8[ENISHI_GET_1(&this->actor)]); + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + } else { + sp30.x = this->actor.world.pos.x; + sp30.y = this->actor.world.pos.y + 20.0f; + sp30.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); + } +} + +void func_8095EA70(EnIshi* this) { + f32 sp24; + + this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; + this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; + if (!ENISHI_GET_1(&this->actor)) { + sp24 = Rand_ZeroOne() - 0.9f; + D_8095F690 = sp24 * 11000.0f; + D_8095F694 = ((Rand_ZeroOne() - 0.5f) * 3000.0f) * (fabsf(sp24) + 0.1f); + } else { + sp24 = Rand_ZeroOne() - 0.5f; + D_8095F690 = sp24 * 6000.0f; + D_8095F694 = ((Rand_ZeroOne() - 0.5f) * 1200.0f) * (fabsf(sp24) + 0.5f); + } + this->actor.colChkInfo.mass = 200; + this->unk_194 = 100; + this->actionFunc = func_8095EBDC; +} + +void func_8095EBDC(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp70 = ENISHI_GET_1(&this->actor); + s16 temp_s0; + s32 i; + s16 phi_s0; + Vec3f sp58; + s32 temp_v0 = (this->collider.base.atFlags & AT_HIT) != 0; + + if (temp_v0) { + this->collider.base.atFlags &= ~AT_HIT; + } + + this->unk_194--; + + if ((this->actor.bgCheckFlags & 9) || temp_v0 || (this->unk_194 <= 0)) { + func_8095DF90(this, globalCtx); + D_8095F6D8[sp70](&this->actor, globalCtx); + + if (!(this->actor.bgCheckFlags & 0x20)) { + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, D_8095F6D4[sp70], D_8095F6D0[sp70]); + D_8095F6E0[sp70](this, globalCtx); + } + + if (sp70 == 1) { + s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + + Quake_SetSpeed(quake, 0x4350); + Quake_SetQuakeValues(quake, 3, 0, 0, 0); + Quake_SetCountdown(quake, 7); + func_8013ECE0(this->actor.xyzDistToPlayerSq, 255, 20, 150); + } + + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->actor.bgCheckFlags & 0x40) { + if (sp70 == 0) { + sp58.x = this->actor.world.pos.x; + sp58.y = this->actor.world.pos.y + this->actor.depthInWater; + sp58.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 350); + EffectSsGRipple_Spawn(globalCtx, &sp58, 150, 650, 0); + } else { + sp58.y = this->actor.world.pos.y + this->actor.depthInWater; + + for (phi_s0 = 0, i = 0; i < 11; i++, phi_s0 += 0x1746) { + sp58.x = (Math_SinS((s32)(Rand_ZeroOne() * 2000.0f) + phi_s0) * 50.0f) + this->actor.world.pos.x; + sp58.z = (Math_CosS((s32)(Rand_ZeroOne() * 2000.0f) + phi_s0) * 50.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 350); + } + + sp58.x = this->actor.world.pos.x; + sp58.z = this->actor.world.pos.z; + EffectSsGRipple_Spawn(globalCtx, &sp58, 500, 900, 4); + } + + this->actor.terminalVelocity = -6.0f; + this->actor.velocity.x *= 0.12f; + this->actor.velocity.y *= 0.4f; + this->actor.velocity.z *= 0.12f; + this->actor.gravity *= 0.5f; + + D_8095F690 >>= 2; + D_8095F694 >>= 2; + + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + this->actor.bgCheckFlags &= ~0x40; + } + + Math_StepToF(&this->actor.shape.yOffset, 0.0f, 2.0f); + func_8095E14C(this); + func_8095E180(&this->actor.velocity, D_8095F6C8[sp70]); + Actor_UpdatePos(&this->actor); + this->actor.shape.rot.x += D_8095F690; + this->actor.shape.rot.y += D_8095F694; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_8095F060(EnIshi* this) { + this->actor.flags |= 0x10; + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_8095F0A4; +} + +void func_8095F0A4(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp28 = ENISHI_GET_1(&this->actor); + + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, D_8095F6D4[sp28], D_8095F6D0[sp28]); + D_8095F6D8[sp28](&this->actor, globalCtx); + D_8095F6E0[sp28](this, globalCtx); + this->actor.draw = NULL; + func_8095F180(this); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_8095F180(EnIshi* this) { + this->actionFunc = func_8095F194; +} + +void func_8095F194(EnIshi* this, GlobalContext* globalCtx) { + if (this->actor.cutscene < 0) { + Actor_MarkForDeath(&this->actor); + } else if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnIshi_Update(Actor* thisx, GlobalContext* globalCtx) { + EnIshi* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_8095F210(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp28; + + if ((this->actor.projectedPos.z <= 1200.0f) || ((this->unk_197 & 1) && (this->actor.projectedPos.z < 1300.0f))) { + Gfx_DrawDListOpa(globalCtx, gameplay_field_keep_DL_0066B0); + return; + } + + if (this->actor.projectedPos.z < 1300.0f) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + sp28 = (1300.0f - this->actor.projectedPos.z) * 2.55f; + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s32)sp28); + gSPDisplayList(POLY_XLU_DISP++, gameplay_field_keep_DL_006760); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_8095F36C(EnIshi* this, GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((this->actor.projectedPos.z <= 2150.0f) || ((this->unk_197 & 1) && (this->actor.projectedPos.z < 2250.0f))) { + this->actor.shape.shadowAlpha = 160; + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_field_keep_DL_0061E8); + } else if (this->actor.projectedPos.z < 2250.0f) { + f32 sp20 = (2250.0f - this->actor.projectedPos.z) * 2.55f; + + this->actor.shape.shadowAlpha = sp20 * 0.627451f; + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s32)sp20); + gSPDisplayList(POLY_XLU_DISP++, gameplay_field_keep_DL_0061E8); + } else { + this->actor.shape.shadowAlpha = 0; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_8095F61C(Actor* thisx, GlobalContext* globalCtx) { + EnIshi* this = THIS; + + D_8095F7B0[ENISHI_GET_1(&this->actor)](this, globalCtx); +} + +void func_8095F654(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_ishi_DL_0009B0); +} diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.h b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.h index f68667c7d3..404fec2b1b 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.h +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.h @@ -6,12 +6,26 @@ struct EnIshi; typedef void (*EnIshiActionFunc)(struct EnIshi*, GlobalContext*); +typedef void (*EnIshiUnkFunc)(struct EnIshi*, GlobalContext*); +typedef void (*EnIshiUnkFunc2)(Actor*, GlobalContext*); + +#define ENISHI_GET_1(thisx) ((thisx)->params & 1) +#define ENISHI_GET_2(thisx) (((thisx)->params >> 1) & 1) +#define ENISHI_GET_4(thisx) (((thisx)->params >> 2) & 1) +#define ENISHI_GET_8(thisx) (((thisx)->params >> 3) & 1) +#define ENISHI_GET_70(thisx) (((thisx)->params >> 4) & 7) +#define ENISHI_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) +#define ENISHI_GET_100(thisx) (((thisx)->params >> 8) & 1) +#define ENISHI_GET_FE00(thisx) (((thisx)->params >> 9) & 0x7F) typedef struct EnIshi { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; + /* 0x0144 */ ColliderCylinder collider; /* 0x0190 */ EnIshiActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x4]; + /* 0x0194 */ s8 unk_194; + /* 0x0195 */ s8 unk_195; + /* 0x0196 */ s8 unk_196; + /* 0x0197 */ u8 unk_197; } EnIshi; // size = 0x198 extern const ActorInit En_Ishi_InitVars; diff --git a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c index 7390d9f7c9..c1b5d13277 100644 --- a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c +++ b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c @@ -94,7 +94,7 @@ s32 EnJcMato_CheckForHit(EnJcMato* this, GlobalContext* globalCtx) { this->collider.dim.worldSphere.center.z = this->pos.z; if ((this->collider.base.acFlags & AC_HIT) && !this->hitFlag && (this->actor.colChkInfo.damageEffect == 0xF)) { this->collider.base.acFlags &= ~AC_HIT; - Audio_PlayActorSound2(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); globalCtx->interfaceCtx.unk_25C = 1; this->hitFlag = 1; return 1; @@ -128,7 +128,7 @@ void EnJcMato_Idle(EnJcMato* this, GlobalContext* globalCtx) { void EnJcMato_Init(Actor* thisx, GlobalContext* globalCtx) { EnJcMato* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); Collider_InitSphere(globalCtx, &this->collider); Collider_SetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); this->collider.dim.worldSphere.radius = 0xF; 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 be3fe843d2..60857e8602 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -190,7 +190,7 @@ void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { this->songSummonDist = 80.0f; EnKakasi_SetupIdleUnderground(this); } else { - Actor_SetHeight(&this->actor, 60.0f); + Actor_SetFocus(&this->actor, 60.0f); this->unkFunc = EnKakasi_8096F88C; if (gSaveContext.weekEventReg[83] & 0x1) { EnKakasi_InitTimeSkipDialogue(this); @@ -221,24 +221,24 @@ void EnKakasi_8096F88C(GlobalContext* globalCtx, EnKakasi* this) { void EnKakasi_CheckAnimationSfx(EnKakasi* this) { if (this->animIndex == ENKAKASI_ANIM_SIDEWAYS_SHAKING || this->animIndex == ENKAKASI_ANIM_ARMS_CROSSED_STILL) { if (Animation_OnFrame(&this->skelanime, 1.0f) || Animation_OnFrame(&this->skelanime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_SWING); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KAKASHI_SWING); } } if (this->animIndex == ENKAKASI_ANIM_HOPPING_REGULAR || this->animIndex == ENKAKASI_ANIM_SLOWROLL) { if (Animation_OnFrame(&this->skelanime, 4.0f) || Animation_OnFrame(&this->skelanime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_SWING); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KAKASHI_SWING); } if (Animation_OnFrame(&this->skelanime, 1.0f) || Animation_OnFrame(&this->skelanime, 9.0f) || Animation_OnFrame(&this->skelanime, 16.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_IT_KAKASHI_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_KAKASHI_JUMP); } if (Animation_OnFrame(&this->skelanime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KAKASHI_ROLL); } } if (this->animIndex == ENKAKASI_ANIM_SPIN_REACH_OFFER || this->animIndex == ENKAKASI_ANIM_TWIRL) { if (Animation_OnFrame(&this->skelanime, 1.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASH_LONGI_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KAKASH_LONGI_ROLL); } } } @@ -323,7 +323,7 @@ void EnKakasi_TimeSkipDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->actor.flags |= 0x10000; } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->stateFlags1 &= ~0x20; this->unkState196 = 2; this->actor.flags &= ~0x10000; @@ -347,18 +347,18 @@ void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { // first talk to scarecrow dialogue this->actor.textId = 0x1644; - if (func_800B8718(&this->actor, globalCtx) != 0) { + if (func_800B8718(&this->actor, &globalCtx->state)) { this->skelanime.playSpeed = 1.0f; EnKakasi_SetupSongTeach(this, globalCtx); return; } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->skelanime.playSpeed = 1.0f; EnKakasi_SetupDialogue(this); return; } if (globalCtx->actorCtx.unk5 & 0x4) { - func_800B8898(globalCtx, &this->actor, &passedValue1, &passedValue2); + Actor_GetScreenPos(globalCtx, &this->actor, &passedValue1, &passedValue2); if (this->actor.projectedPos.z > -20.0f && passedValue1 > 0 && passedValue1 < 0x140 && passedValue2 > 0 && passedValue2 < 0xF0 && this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { // faster shaking @@ -424,7 +424,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->unkState1A8 = 0; } - if (this->unkMsgState1AC == func_80152498(&globalCtx->msgCtx) && func_80147624(globalCtx) != 0) { + if (this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx) && func_80147624(globalCtx) != 0) { func_801477B4(globalCtx); if (this->unkMsgState1AC == 5) { // bad song input @@ -569,7 +569,7 @@ void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { * before actually teaching */ void EnKakasi_OcarinaRemark(EnKakasi* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { func_80152434(globalCtx, 0x35); this->unkState1A8 = 0; if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -631,7 +631,7 @@ void EnKakasi_TeachingSong(EnKakasi* this, GlobalContext* globalCtx) { this->unk190 = 0; this->unkCounter1A4 = 0; ActorCutscene_Stop(this->actorCutscenes[0]); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_YASE_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YASE_DEAD); if (this) {} this->unkState196 = 2; this->cutsceneCamId = MAIN_CAM; @@ -743,7 +743,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { func_8096FAAC(this, globalCtx); - if (this->unkState1A8 != 0 && func_80152498(&globalCtx->msgCtx) == this->unkMsgState1AC && + if (this->unkState1A8 != 0 && Message_GetState(&globalCtx->msgCtx) == this->unkMsgState1AC && func_80147624(globalCtx) != 0) { func_801477B4(globalCtx); @@ -1014,9 +1014,9 @@ void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx) { Audio_PlaySoundAtPosition(globalCtx, &tempWorldPos, 0x32, NA_SE_EV_BOMB_DROP_WATER); } else { - func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 5, - 4.0f, 200, 10, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, + this->actor.shape.shadowScale - 20.0f, 5, 4.0f, 200, 10, 1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); } } @@ -1065,7 +1065,7 @@ void EnKakasi_SetupRiseOutOfGround(EnKakasi* this, GlobalContext* globalCtx) { } else { ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[cutsceneIndex], &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actor.draw = EnKakasi_Draw; this->unkState196 = 6; this->actionFunc = EnKakasi_RisingOutOfGround; @@ -1080,9 +1080,9 @@ void EnKakasi_RisingOutOfGround(EnKakasi* this, GlobalContext* globalCtx) { } if (this->actor.shape.yOffset < -10.0f) { if ((globalCtx->gameplayFrames % 8) == 0) { - func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 10, - 8.0f, 500, 10, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, + this->actor.shape.shadowScale - 20.0f, 10, 8.0f, 500, 10, 1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); } Math_ApproachF(&this->actor.shape.yOffset, 0.0f, 0.5f, 200.0f); } else { @@ -1100,7 +1100,7 @@ void EnKakasi_SetupIdleRisen(EnKakasi* this) { void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnKakasi_RisenDialogue; } else { func_800B8614(&this->actor, globalCtx, 70.0f); @@ -1110,7 +1110,7 @@ void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_RisenDialogue(EnKakasi* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { func_801477B4(globalCtx); EnKakasi_SetupIdleRisen(this); } @@ -1140,11 +1140,11 @@ void EnKakasi_Update(Actor* thisx, GlobalContext* globalCtx) { } } } else { - Actor_SetHeight(&this->actor, this->unkHeight); + Actor_SetFocus(&this->actor, this->unkHeight); } this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 0x1C); if (this->actor.draw != NULL) { Collider_UpdateCylinder(&this->actor, &this->collider); diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.c b/src/overlays/actors/ovl_En_Kame/z_en_kame.c index c8cceba619..7aae7b7dd7 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -5,6 +5,7 @@ */ #include "z_en_kame.h" +#include "objects/object_tl/object_tl.h" #define FLAGS 0x00000405 @@ -15,21 +16,31 @@ void EnKame_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKame_Update(Actor* thisx, GlobalContext* globalCtx); void EnKame_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80AD70A0(EnKame* this); void func_80AD70EC(EnKame* this, GlobalContext* globalCtx); +void func_80AD71B4(EnKame* this); void func_80AD7254(EnKame* this, GlobalContext* globalCtx); +void func_80AD73A8(EnKame* this); void func_80AD7424(EnKame* this, GlobalContext* globalCtx); +void func_80AD76CC(EnKame* this); void func_80AD7798(EnKame* this, GlobalContext* globalCtx); +void func_80AD792C(EnKame* this); void func_80AD7948(EnKame* this, GlobalContext* globalCtx); +void func_80AD7B18(EnKame* this); void func_80AD7B90(EnKame* this, GlobalContext* globalCtx); void func_80AD7D40(EnKame* this, GlobalContext* globalCtx); +void func_80AD7DA4(EnKame* this); void func_80AD7E0C(EnKame* this, GlobalContext* globalCtx); +void func_80AD7EC0(EnKame* this); void func_80AD7F10(EnKame* this, GlobalContext* globalCtx); void func_80AD7FF8(EnKame* this, GlobalContext* globalCtx); void func_80AD810C(EnKame* this, GlobalContext* globalCtx); +void func_80AD8148(EnKame* this, GlobalContext* globalCtx); void func_80AD825C(EnKame* this, GlobalContext* globalCtx); +void func_80AD8364(EnKame* this); void func_80AD8388(EnKame* this, GlobalContext* globalCtx); +void func_80AD8D64(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Kame_InitVars = { ACTOR_EN_KAME, ACTORCAT_ENEMY, @@ -42,18 +53,29 @@ const ActorInit En_Kame_InitVars = { (ActorFunc)EnKame_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AD8DE0 = { - { COLTYPE_HARD, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7CF7FFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7CF7FFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 35, 40, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80AD8E0C = { 3, 15, 30, 80 }; +static CollisionCheckInfoInit sColChkInfoInit = { 3, 15, 30, 80 }; -// static DamageTable sDamageTable = { -static DamageTable D_80AD8E14 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -88,107 +110,733 @@ static DamageTable D_80AD8E14 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AD8E44[] = { +static TexturePtr D_80AD8E34[] = { object_tl_Tex_0055A0, object_tl_Tex_0057A0, object_tl_Tex_0059A0, + object_tl_Tex_0057A0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 1, ICHAIN_CONTINUE), ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3500, ICHAIN_STOP), }; -#endif +static s32 D_80AD8E50 = false; -extern ColliderCylinderInit D_80AD8DE0; -extern CollisionCheckInfoInit D_80AD8E0C; -extern DamageTable D_80AD8E14; -extern InitChainEntry D_80AD8E44[]; +void EnKame_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKame* this = THIS; -extern UNK_TYPE D_060008B4; -extern UNK_TYPE D_06000AF4; -extern UNK_TYPE D_06001C68; -extern UNK_TYPE D_06002510; -extern UNK_TYPE D_060027D8; -extern UNK_TYPE D_06002F88; -extern UNK_TYPE D_060031DC; -extern UNK_TYPE D_060035EC; -extern UNK_TYPE D_06004210; -extern UNK_TYPE D_0600823C; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime1, &object_tl_Skel_007C70, &object_tl_Anim_004210, this->jointTable1, + this->morphTable1, 13); + SkelAnime_InitFlex(globalCtx, &this->skelAnime2, &object_tl_Skel_001A50, &object_tl_Anim_000B30, this->jointTable2, + this->morphTable2, 4); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 55.0f); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/EnKame_Init.s") + if (!D_80AD8E50) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/EnKame_Destroy.s") + for (i = 0; i < ARRAY_COUNT(D_80AD8E34); i++) { + D_80AD8E34[i] = Lib_SegmentedToVirtual(D_80AD8E34[i]); + } + D_80AD8E50 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD6F34.s") + func_80AD70A0(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD6F9C.s") +void EnKame_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKame* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7018.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD70A0.s") +void func_80AD6F34(EnKame* this) { + if (this->unk_29C != 0) { + this->unk_29C++; + if (this->unk_29C == 4) { + this->unk_29C = 0; + } + } else if (Rand_ZeroOne() < 0.05f) { + this->unk_29C = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD70EC.s") +void func_80AD6F9C(EnKame* this) { + this->unk_29D = 10; + this->unk_2B4 = 0.6f; + this->unk_2B8 = 0.90000004f; + this->unk_2B0 = 1.0f; + this->collider.base.colType = COLTYPE_HIT3; + this->unk_2A2 = 80; + this->actor.flags &= ~0x400; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD71B4.s") +void func_80AD7018(EnKame* this, GlobalContext* globalCtx) { + if (this->unk_29D == 10) { + this->unk_29D = 0; + this->collider.base.colType = COLTYPE_HIT6; + this->unk_2B0 = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2C8, 10, 2, 0.3f, 0.2f); + this->actor.flags |= 0x400; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7254.s") +void func_80AD70A0(EnKame* this) { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_004210, -5.0f); + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80AD70EC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD73A8.s") +void func_80AD70EC(EnKame* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7424.s") + if (Animation_OnFrame(&this->skelAnime1, 10.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_VOICE); + this->unk_2A0 = 40; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7568.s") + if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && !(player->stateFlags1 & 0x800000) && + (this->actor.xzDistToPlayer < 240.0f)) { + func_80AD73A8(this); + } else if (SkelAnime_Update(&this->skelAnime1)) { + func_80AD71B4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD75A8.s") +void func_80AD71B4(EnKame* this) { + Animation_MorphToLoop(&this->skelAnime1, &object_tl_Anim_00823C, -5.0f); + this->actor.speedXZ = 0.5f; + this->unk_29E = Animation_GetLastFrame(&object_tl_Anim_00823C) * ((s32)Rand_ZeroFloat(5.0f) + 3); + this->unk_2A4 = this->actor.shape.rot.y; + this->collider.base.acFlags |= (AC_HARD | AC_ON); + this->collider.base.colType = COLTYPE_HARD; + this->actionFunc = func_80AD7254; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD76CC.s") +void func_80AD7254(EnKame* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7798.s") + if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && !(player->stateFlags1 & 0x800000) && + (this->actor.xzDistToPlayer < 240.0f)) { + func_80AD73A8(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD792C.s") + SkelAnime_Update(&this->skelAnime1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7948.s") + if (this->unk_2A4 != this->actor.shape.rot.y) { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->unk_2A4, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 40.0f) { + this->unk_2A4 = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + (Rand_Next() >> 0x14); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7B18.s") + this->unk_29E--; + if (this->unk_29E == 0) { + func_80AD70A0(this); + } else if (Animation_OnFrame(&this->skelAnime1, 0.0f) || Animation_OnFrame(&this->skelAnime1, 15.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_WALK); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7B90.s") +void func_80AD73A8(EnKame* this) { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_001C68, -3.0f); + this->unk_29E = 0; + this->unk_2AC = 1.0f; + this->unk_2A8 = 1.0f; + this->actor.speedXZ = 0.0f; + if (this->unk_2A0 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_VOICE); + } + this->actionFunc = func_80AD7424; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7C54.s") +void func_80AD7424(EnKame* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7D40.s") + if (SkelAnime_Update(&this->skelAnime1)) { + if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && !(player->stateFlags1 & 0x800000) && + ((this->unk_29E == 0) || (this->actor.xzDistToPlayer < 120.0f))) { + func_80AD76CC(this); + } else { + this->unk_29E--; + if (this->unk_29E == 0) { + func_80AD7B18(this); + } + } + } else if (this->skelAnime1.curFrame > 2.0f) { + this->unk_2AC = 1.5f - ((this->skelAnime1.curFrame - 2.0f) * (7.0f / 30)); + this->unk_2A8 = 1.5f - ((this->skelAnime1.curFrame - 2.0f) * (1.0f / 12)); + } else { + f32 frame = this->skelAnime1.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7DA4.s") + this->unk_2AC = (0.25f * frame) + 1.0f; + this->unk_2A8 = (0.25f * frame) + 1.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7E0C.s") +void func_80AD7568(EnKame* this) { + this->actor.speedXZ = this->unk_2A6 * (5.0f / 7552); + this->actor.shape.rot.z = this->unk_2A6 * 0.11016949f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7EC0.s") +void func_80AD75A8(EnKame* this, GlobalContext* globalCtx) { + static Color_RGBA8 D_80AD8E54 = { 250, 250, 250, 255 }; + static Color_RGBA8 D_80AD8E58 = { 180, 180, 180, 255 }; + static Vec3f D_80AD8E5C = { 0.0f, 0.75f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7F10.s") + if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ >= 3.0f)) { + if ((globalCtx->gameplayFrames % 2) == 0) { + u32 temp_v0 = func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7FA4.s") + if ((temp_v0 == 0) || (temp_v0 == 1)) { + func_800B1210(globalCtx, &this->actor.world.pos, &D_80AD8E5C, &gZeroVec3f, 550, 100); + } else if (temp_v0 == 14) { + func_800B0DE0(globalCtx, &this->actor.world.pos, &D_80AD8E5C, &gZeroVec3f, &D_80AD8E54, &D_80AD8E58, + 550, 100); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD7FF8.s") + if (this->unk_2A6 > 0x1200) { + func_800B9010(&this->actor, NA_SE_EN_PAMET_ROLL - SFX_FLAG); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8060.s") +void func_80AD76CC(EnKame* this) { + if (this->actor.draw == EnKame_Draw) { + this->actor.draw = func_80AD8D64; + this->unk_2A6 = 0x3B00; + this->unk_2AC = 0.5f; + func_80AD7568(this); + this->unk_29E = 15; + this->actor.speedXZ = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_CUTTER_ON); + this->unk_2BC.y = this->actor.home.pos.y - 100.0f; + } else { + this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + Math_Vec3f_Copy(&this->unk_2BC, &this->actor.home.pos); + this->unk_29E = 0; + } + this->actor.flags |= 0x10; + this->actionFunc = func_80AD7798; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD810C.s") +void func_80AD7798(EnKame* this, GlobalContext* globalCtx) { + if (this->unk_29E == 15) { + this->unk_2AC += 0.2f; + if (this->unk_2AC > 1.1f) { + this->unk_29E--; + this->collider.base.atFlags |= AT_ON; + this->unk_2AC = 1.0f; + } + } else if (this->unk_29E > 0) { + this->unk_29E--; + } else if (Math_ScaledStepToS(&this->unk_2A6, 0x3B00, (s32)(this->unk_2A6 * 0.09f) + 45)) { + if (this->unk_2BC.y < this->actor.home.pos.y) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->unk_2BC.x = (Math_SinS(this->actor.world.rot.y) * 360.0f) + this->actor.world.pos.x; + this->unk_2BC.z = (Math_CosS(this->actor.world.rot.y) * 360.0f) + this->actor.world.pos.z; + } + func_80AD792C(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8148.s") + this->actor.shape.rot.y += this->unk_2A6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD825C.s") + if (!(this->unk_2BC.y < this->actor.home.pos.y) || (this->actionFunc != func_80AD7798)) { + func_80AD7568(this); + } + func_80AD75A8(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8364.s") +void func_80AD792C(EnKame* this) { + this->unk_29E = -1; + this->actionFunc = func_80AD7948; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8388.s") +void func_80AD7948(EnKame* this, GlobalContext* globalCtx) { + s32 temp_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD84C0.s") + this->actor.shape.rot.y += this->unk_2A6; + func_80AD75A8(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/EnKame_Update.s") + if (this->unk_29E == -1) { + s16 temp_v0 = Actor_YawToPoint(&this->actor, &this->unk_2BC) - this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8A48.s") + temp_v1 = ABS_ALT(temp_v0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8AF8.s") + if ((this->actor.bgCheckFlags & 8) || (temp_v1 > 0x3000) || + (Actor_XZDistanceToPoint(&this->actor, &this->unk_2BC) < 50.0f)) { + s8 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/EnKame_Draw.s") + if (this->unk_2BC.y < this->actor.home.pos.y) { + this->unk_29E = 0x300; + } else { + this->unk_29E = 0; + } + } + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8CEC.s") + if (Math_ScaledStepToS(&this->unk_2A6, this->unk_29E, (s32)(this->unk_2A6 * 0.09f) + 45)) { + if (this->unk_29E == 0) { + if (this->unk_2AC >= 1.0f) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_CUTTER_OFF); + } + this->unk_2AC -= 0.1f; + this->collider.base.atFlags &= ~AT_ON; + if (this->unk_2AC < 0.5f) { + this->actor.flags &= ~0x10; + func_80AD7B18(this); + } + } else { + func_80AD76CC(this); + } + } + func_80AD7568(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kame/func_80AD8D64.s") +void func_80AD7B18(EnKame* this) { + this->actor.draw = EnKame_Draw; + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_0031DC, -3.0f); + this->actor.speedXZ = 0.0f; + this->unk_2AC = 0.1f; + this->unk_2A8 = 1.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = func_80AD7B90; +} + +void func_80AD7B90(EnKame* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime1)) { + func_80AD71B4(this); + } else if (this->skelAnime1.curFrame > 7.0f) { + this->unk_2AC = 1.5f - ((this->skelAnime1.curFrame - 7.0f) * (1.0f / 6)); + this->unk_2A8 = 1.5f - ((this->skelAnime1.curFrame - 7.0f) * (1.0f / 6)); + } else { + f32 frame = this->skelAnime1.curFrame; + + this->unk_2AC = (0.2f * frame) + 0.1f; + this->unk_2A8 = ((1.0f / 14) * frame) + 1.0f; + } +} + +void func_80AD7C54(EnKame* this) { + if (this->actionFunc == func_80AD7E0C) { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_0035EC, -3.0f); + this->unk_29E = 1; + this->collider.info.bumper.dmgFlags &= ~0x8000; + } else { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_0039C0, -3.0f); + this->unk_29E = 0; + this->collider.info.bumper.dmgFlags |= 0x8000; + } + + this->actor.draw = EnKame_Draw; + this->actor.speedXZ = 0.0f; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); + this->actor.flags &= ~0x10; + this->actor.shape.rot.z = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_REVERSE); + this->actionFunc = func_80AD7D40; +} + +void func_80AD7D40(EnKame* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime1)) { + if (this->unk_29E == 1) { + func_80AD71B4(this); + } else { + this->unk_29E = 200; + func_80AD7DA4(this); + } + } +} + +void func_80AD7DA4(EnKame* this) { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_0027D8, -3.0f); + this->collider.base.acFlags |= AC_ON; + this->collider.base.acFlags &= ~AC_HARD; + this->collider.base.colType = COLTYPE_HIT6; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80AD7E0C; +} + +void func_80AD7E0C(EnKame* this, GlobalContext* globalCtx) { + if (this->unk_29E > 0) { + this->unk_29E--; + if (SkelAnime_Update(&this->skelAnime1)) { + if (Rand_ZeroOne() > 0.5f) { + Animation_PlayOnce(&this->skelAnime1, &object_tl_Anim_0027D8); + } else { + Animation_PlayOnce(&this->skelAnime1, &object_tl_Anim_002F88); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_ROAR); + } + } + } else { + func_80AD7EC0(this); + } +} + +void func_80AD7EC0(EnKame* this) { + Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_002510, -3.0f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_WAKEUP); + this->actionFunc = func_80AD7F10; +} + +void func_80AD7F10(EnKame* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime1)) { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + func_80AD71B4(this); + } else if (this->skelAnime1.curFrame >= 10.0f) { + this->actor.shape.shadowDraw = NULL; + this->collider.base.acFlags &= ~AC_ON; + this->collider.info.bumper.dmgFlags &= ~0x8000; + } +} + +void func_80AD7FA4(EnKame* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + func_800BE504(&this->actor, &this->collider); + this->actionFunc = func_80AD7FF8; +} + +void func_80AD7FF8(EnKame* this, GlobalContext* globalCtx) { + if (this->unk_2A2 != 0) { + this->unk_2A2--; + } + + if (this->unk_2A2 == 0) { + func_80AD7018(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + func_80AD8148(this, NULL); + } else { + this->actor.world.rot.y = this->actor.shape.rot.y; + func_80AD7DA4(this); + } + } +} + +void func_80AD8060(EnKame* this) { + s16 sp36 = Animation_GetLastFrame(&object_tl_Anim_0008B4); + + Animation_Change(&this->skelAnime1, &object_tl_Anim_0008B4, 1.0f, 0.0f, sp36, 2, -3.0f); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, sp36); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_DAMAGE); + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = func_80AD810C; +} + +void func_80AD810C(EnKame* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime1)) { + func_80AD7DA4(this); + } +} + +void func_80AD8148(EnKame* this, GlobalContext* globalCtx) { + Animation_PlayLoop(&this->skelAnime1, &object_tl_Anim_000AF4); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.atFlags &= ~(AC_HARD | AC_HIT); + this->actor.velocity.y = 15.0f; + this->actor.speedXZ = 1.5f; + if (globalCtx != NULL) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + if (this->actor.draw == func_80AD8D64) { + this->actor.draw = EnKame_Draw; + } else { + func_800BE504(&this->actor, &this->collider); + } + } + this->actor.bgCheckFlags &= ~0x1; + this->actor.flags &= ~0x1; + this->actor.flags |= 0x10; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_DEAD); + this->unk_29E = 0; + this->actionFunc = func_80AD825C; +} + +void func_80AD825C(EnKame* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime1); + if ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_LAND); + func_80AD8364(this); + } else { + if (this->unk_29E == 1) { + this->actor.colorFilterTimer = 100; + } else if (this->actor.colorFilterTimer == 0) { + Actor_SetColorFilter(&this->actor, 0xC000, 255, 0, 100); + } + this->actor.shape.rot.x += Rand_S16Offset(0x700, 0x1400); + this->actor.shape.rot.y += (s16)Rand_ZeroFloat(5120.0f); + this->actor.shape.rot.z += Rand_S16Offset(0x700, 0x1400); + } +} + +void func_80AD8364(EnKame* this) { + this->unk_29E = 20; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80AD8388; +} + +void func_80AD8388(EnKame* this, GlobalContext* globalCtx) { + Vec3f sp34; + + SkelAnime_Update(&this->skelAnime1); + this->actor.colorFilterTimer = 100; + if (this->unk_29E > 0) { + this->unk_29E--; + if (this->unk_29E == 0) { + func_800F0590(globalCtx, &this->actor.world.pos, 21, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } + } else { + this->actor.scale.x -= 0.001f; + if (this->actor.scale.x <= 0.0f) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + Actor_MarkForDeath(&this->actor); + } else { + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; + } + sp34.x = randPlusMinusPoint5Scaled(40.0f) + this->actor.world.pos.x; + sp34.y = this->actor.world.pos.y + 15.0f; + sp34.z = randPlusMinusPoint5Scaled(40.0f) + this->actor.world.pos.z; + func_800B3030(globalCtx, &sp34, &gZeroVec3f, &gZeroVec3f, 100, 0, 2); + } +} + +void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + + Actor_SetDropFlag(&this->actor, &this->collider.info); + if ((this->unk_29D == 10) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + return; + } + + func_80AD7018(this, globalCtx); + if (this->actor.colChkInfo.damageEffect == 13) { + return; + } + + if (this->actor.colChkInfo.damageEffect == 14) { + func_80AD8148(this, globalCtx); + } else if (this->actor.colChkInfo.damageEffect == 15) { + if (this->collider.base.acFlags & AC_HARD) { + func_80AD7C54(this); + } else if (!Actor_ApplyDamage(&this->actor)) { + func_80AD8148(this, globalCtx); + } else { + func_80AD8060(this); + } + } else if ((this->actionFunc == func_80AD70EC) || (this->actionFunc == func_80AD7254)) { + func_80AD73A8(this); + this->unk_29E = 21; + } else if (!(this->collider.base.acFlags & AC_HARD)) { + if (this->actor.colChkInfo.damageEffect == 5) { + this->unk_2A2 = 40; + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->unk_2B4 = 0.6f; + this->unk_2B0 = 2.0f; + this->unk_29D = 30; + func_80AD7FA4(this); + } else if (this->actor.colChkInfo.damageEffect == 1) { + this->unk_2A2 = 40; + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + func_80AD7FA4(this); + } else if (this->actor.colChkInfo.damageEffect == 3) { + func_80AD6F9C(this); + if (!Actor_ApplyDamage(&this->actor)) { + this->unk_2A2 = 3; + this->collider.base.acFlags &= ~AC_ON; + } + func_80AD7FA4(this); + } else { + if (this->actor.colChkInfo.damageEffect == 2) { + this->unk_2B4 = 0.6f; + this->unk_2B0 = 4.0f; + this->unk_29D = 0; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_2B4 = 0.6f; + this->unk_2B0 = 4.0f; + this->unk_29D = 20; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, + this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + + if (!Actor_ApplyDamage(&this->actor)) { + func_80AD8148(this, globalCtx); + } else { + func_80AD8060(this); + } + } + } + } + + if ((globalCtx->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < 40000.0f) && + (this->collider.base.acFlags & AC_ON)) { + func_80AD7018(this, globalCtx); + func_80AD7C54(this); + } +} + +void EnKame_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnKame* this = THIS; + + func_80AD6F34(this); + + if (this->unk_2A0 != 0) { + this->unk_2A0--; + } + + func_80AD84C0(this, globalCtx); + + if ((this->collider.base.atFlags & AT_HIT) && (this->collider.base.atFlags & AT_BOUNCED)) { + this->collider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); + func_80AD76CC(this); + if (Actor_XZDistanceToPoint(&this->actor, &this->unk_2BC) < 50.0f) { + this->collider.base.atFlags &= ~AT_ON; + } + this->unk_2A6 = 0x3B00; + func_80AD7568(this); + } + + this->actionFunc(this, globalCtx); + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 60.0f, 40.0f, 0x1F); + + if (this->actor.shape.shadowDraw != NULL) { + Actor_SetFocus(&this->actor, 25.0f); + Collider_UpdateCylinder(&this->actor, &this->collider); + } + + if (this->collider.base.atFlags & AT_ON) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->unk_2B0 > 0.0f) { + if (this->unk_29D != 10) { + Math_StepToF(&this->unk_2B0, 0.0f, 0.05f); + this->unk_2B4 = (this->unk_2B0 + 1.0f) * 0.3f; + if (this->unk_2B4 > 0.6f) { + this->unk_2B4 = 0.6f; + } else { + this->unk_2B4 = this->unk_2B4; + } + } else if (!Math_StepToF(&this->unk_2B8, 0.6f, 0.015000001f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +s32 func_80AD8A48(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnKame* this = THIS; + + if ((this->actionFunc == func_80AD7424) || (this->actionFunc == func_80AD7B90)) { + if (limbIndex == 2) { + Matrix_Scale(this->unk_2A8, this->unk_2AC, this->unk_2A8, MTXMODE_APPLY); + } else if ((limbIndex == 11) || (limbIndex == 9) || (limbIndex == 7) || (limbIndex == 5)) { + Matrix_Scale(this->unk_2A8, this->unk_2AC, this->unk_2AC, MTXMODE_APPLY); + } + } + return false; +} + +void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80AD8E68[] = { + { 1500.0f, 0.0f, -2000.0f }, { 1500.0f, 0.0f, 2000.0f }, { 1500.0f, 2000.0f, 0.0f }, + { 1500.0f, -2000.0f, 0.0f }, { 2500.0f, 0.0f, 0.0f }, + }; + static s8 D_80AD8EA4[] = { -1, -1, -1, 0, -1, -1, 1, -1, 2, -1, 3, -1, 4 }; + EnKame* this = THIS; + + if (D_80AD8EA4[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->unk_2C8[D_80AD8EA4[limbIndex]]); + } + + if (limbIndex == 1) { + s32 i; + Vec3f* ptr; + Vec3f* ptr2; + + if (this->actor.shape.shadowDraw == NULL) { + Matrix_GetStateTranslation(&this->actor.world.pos); + } + + ptr2 = D_80AD8E68; + ptr = &this->unk_2C8[5]; + for (i = 0; i < ARRAY_COUNT(D_80AD8E68); i++) { + Matrix_MultiplyVector3fByState(ptr2, ptr); + ptr2++; + ptr++; + } + } +} + +void EnKame_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKame* this = THIS; + Vec3f sp40; + + if (this->actor.shape.shadowDraw == 0) { + Math_Vec3f_Copy(&sp40, &this->actor.world.pos); + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_80AD8E34[this->unk_29C]); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime1.skeleton, this->skelAnime1.jointTable, + this->skelAnime1.dListCount, func_80AD8A48, func_80AD8AF8, &this->actor); + func_800BE680(globalCtx, &this->actor, this->unk_2C8, 10, this->unk_2B4, this->unk_2B8, this->unk_2B0, + this->unk_29D); + + if (this->actor.shape.shadowDraw == NULL) { + ActorShadow_DrawCircle(&this->actor, NULL, globalCtx); + Actor_SetFocus(&this->actor, 25.0f); + Collider_UpdateCylinder(&this->actor, &this->collider); + Math_Vec3f_Copy(&this->actor.world.pos, &sp40); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 Enkame_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnKame* this = THIS; + + if (limbIndex == 1) { + pos->y -= 700.0f; + } + + if ((this->unk_2AC != 1.0f) && (limbIndex == 3)) { + Matrix_Scale(1.0f, this->unk_2AC, this->unk_2AC, MTXMODE_APPLY); + } + return false; +} + +void func_80AD8D64(Actor* thisx, GlobalContext* globalCtx) { + EnKame* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime2.skeleton, this->skelAnime2.jointTable, + this->skelAnime2.dListCount, Enkame_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.h b/src/overlays/actors/ovl_En_Kame/z_en_kame.h index efdff38123..115bf137fd 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.h +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.h @@ -9,9 +9,28 @@ typedef void (*EnKameActionFunc)(struct EnKame*, GlobalContext*); typedef struct EnKame { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x154]; + /* 0x0144 */ SkelAnime skelAnime1; + /* 0x0188 */ Vec3s jointTable1[13]; + /* 0x01D6 */ Vec3s morphTable1[13]; + /* 0x0224 */ SkelAnime skelAnime2; + /* 0x0268 */ Vec3s jointTable2[4]; + /* 0x0280 */ Vec3s morphTable2[4]; /* 0x0298 */ EnKameActionFunc actionFunc; - /* 0x029C */ char unk_29C[0xF0]; + /* 0x029C */ u8 unk_29C; + /* 0x029D */ u8 unk_29D; + /* 0x029E */ s16 unk_29E; + /* 0x02A0 */ s16 unk_2A0; + /* 0x02A2 */ s16 unk_2A2; + /* 0x02A4 */ s16 unk_2A4; + /* 0x02A6 */ s16 unk_2A6; + /* 0x02A8 */ f32 unk_2A8; + /* 0x02AC */ f32 unk_2AC; + /* 0x02B0 */ f32 unk_2B0; + /* 0x02B4 */ f32 unk_2B4; + /* 0x02B8 */ f32 unk_2B8; + /* 0x02BC */ Vec3f unk_2BC; + /* 0x02C8 */ Vec3f unk_2C8[10]; + /* 0x0340 */ ColliderCylinder collider; } EnKame; // size = 0x38C extern const ActorInit En_Kame_InitVars; diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h index 1ac4367046..40eeb10609 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h @@ -10,6 +10,8 @@ typedef struct EnKanban { /* 0x144 */ char unk_144[0xAC]; } EnKanban; // size = 0x1F0 +#define ENKANBAN_FISHING 0x300 + extern const ActorInit En_Kanban_InitVars; #endif // Z_EN_KANBAN_H diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c index db4363228d..4d0e7f9fe1 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -74,9 +74,9 @@ void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2E2 = -1; this->zubora = EnKgy_FindZubora(globalCtx); this->iceBlock = EnKgy_FindIceBlock(globalCtx); - Actor_UnsetSwitchFlag(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); + Flags_UnsetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor)) || (gSaveContext.weekEventReg[33] & 0x80)) { - Actor_SetSwitchFlag(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); + Flags_SetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); globalCtx->envCtx.unk_C3 = 1; gSaveContext.weekEventReg[21] |= 1; if (!func_80B40D64(globalCtx)) { @@ -143,7 +143,7 @@ void func_80B40BC0(EnKgy* this, s16 arg1) { } EnKbt* EnKgy_FindZubora(GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (actor != NULL) { if (actor->id == ACTOR_EN_KBT) { @@ -155,7 +155,7 @@ EnKbt* EnKgy_FindZubora(GlobalContext* globalCtx) { } ObjIcePoly* EnKgy_FindIceBlock(GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_ITEMACTION].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (actor != NULL) { if (actor->id == ACTOR_OBJ_ICE_POLY) { @@ -258,7 +258,7 @@ void func_80B40EE8(EnKgy* this, GlobalContext* globalCtx) { f32 sp34; f32 temp_f0; - func_800B4EDC(globalCtx, &this->unk_2B4, &sp38, &sp34); + Actor_GetProjectedPos(globalCtx, &this->unk_2B4, &sp38, &sp34); temp_f0 = sp38.x * sp34; if (this->unk_2E6 > 0) { this->unk_2E6--; @@ -458,7 +458,7 @@ void func_80B4163C(EnKgy* this, GlobalContext* globalCtx) { this->lightInfo.params.point.y = this->unk_2C0.y; this->lightInfo.params.point.z = this->unk_2C0.z; this->unk_300 = 200; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SWORD_FORGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SWORD_FORGE); break; } @@ -470,7 +470,7 @@ void func_80B4163C(EnKgy* this, GlobalContext* globalCtx) { void func_80B417B8(EnKgy* this, GlobalContext* globalCtx) { func_80B4163C(this, globalCtx); - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); func_80B413C8(this); this->actor.flags &= ~0x100; @@ -494,7 +494,7 @@ void func_80B41858(EnKgy* this, GlobalContext* globalCtx) { void func_80B418C4(EnKgy* this, GlobalContext* globalCtx) { func_80B4163C(this, globalCtx); if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx) && + (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx) && ((globalCtx->msgCtx.unk11F04 == 0xC4E) || (globalCtx->msgCtx.unk11F04 == 0xC4F))) { func_801477B4(globalCtx); this->actor.textId = 0xC4F; @@ -511,7 +511,7 @@ void func_80B419B0(EnKgy* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); func_80B4163C(this, globalCtx); - if (func_800B84D0(&this->actor, globalCtx) || (&this->actor == player->targetActor)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) || (&this->actor == player->targetActor)) { func_80B411DC(this, globalCtx, 4); func_80B40E18(this, this->actor.textId); if (this->actor.textId == 0xC37) { @@ -537,7 +537,7 @@ void func_80B41ACC(EnKgy* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); SkelAnime_Update(&this->skelAnime); - if (func_80152498(&globalCtx->msgCtx) == 0x10) { + if (Message_GetState(&globalCtx->msgCtx) == 0x10) { itemActionParam = func_80123810(globalCtx); if (itemActionParam != PLAYER_AP_NONE) { this->actionFunc = func_80B41E18; @@ -586,7 +586,7 @@ void func_80B41C30(EnKgy* this, GlobalContext* globalCtx) { void func_80B41C54(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->actionFunc = func_80B41C30; this->actor.flags &= ~0x100; } @@ -595,13 +595,13 @@ void func_80B41C54(EnKgy* this, GlobalContext* globalCtx) { void func_80B41CBC(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; func_80B40E18(this, this->actor.textId); this->actionFunc = func_80B41E18; func_80B411DC(this, globalCtx, 4); } else { - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } } @@ -610,9 +610,9 @@ void func_80B41D64(EnKgy* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actionFunc = func_80B41CBC; this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } else { - func_800B8A1C(&this->actor, globalCtx, this->unk_2EA, 2000.0f, 1000.0f); + Actor_PickUp(&this->actor, globalCtx, this->unk_2EA, 2000.0f, 1000.0f); } func_80B40EE8(this, globalCtx); } @@ -627,7 +627,7 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && func_80B40E54(this) == 0) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 4: if (func_80147624(globalCtx)) { temp = globalCtx->msgCtx.unk11F04; @@ -759,7 +759,7 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { case 0xC46: case 0xC55: func_80123D50(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); - player->unk_A87 = PLAYER_AP_NONE; + player->exchangeItemId = EXCH_ITEM_NONE; this->unk_29C &= ~0x8; globalCtx->msgCtx.unk11F10 = 0; func_80B41368(this, globalCtx, 4); @@ -774,7 +774,7 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { case 0xC47: func_80B40BC0(this, 1); if (this->unk_29C & 8) { - player->unk_A87 = PLAYER_AP_NONE; + player->exchangeItemId = EXCH_ITEM_NONE; this->unk_29C &= ~8; } func_80B40EBC(this, globalCtx, temp); @@ -813,7 +813,7 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { func_801477B4(globalCtx); this->actionFunc = func_80B41D64; func_80B413C8(this); - func_800B8A1C(&this->actor, globalCtx, this->unk_2EA, 2000.0f, 1000.0f); + Actor_PickUp(&this->actor, globalCtx, this->unk_2EA, 2000.0f, 1000.0f); break; case 0xC51: @@ -846,7 +846,7 @@ void func_80B42508(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if (func_800B84D0(&this->actor, globalCtx) || (&this->actor == player->targetActor)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) || (&this->actor == player->targetActor)) { this->actionFunc = func_80B41E18; func_80B411DC(this, globalCtx, 4); func_80B40E18(this, this->actor.textId); @@ -856,7 +856,7 @@ void func_80B42508(EnKgy* this, GlobalContext* globalCtx) { void func_80B425A0(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B41E18; func_80B40BC0(this, 1); func_80B411DC(this, globalCtx, 0); @@ -869,7 +869,7 @@ void func_80B425A0(EnKgy* this, GlobalContext* globalCtx) { void func_80B42660(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); func_80B413C8(this); this->actor.flags &= ~0x100; @@ -885,7 +885,7 @@ void func_80B42714(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if (func_800B84D0(&this->actor, globalCtx) || (&this->actor == player->targetActor)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) || (&this->actor == player->targetActor)) { func_80B411DC(this, globalCtx, 4); func_80B40E18(this, this->actor.textId); if (this->actor.textId == 0xC37) { @@ -910,7 +910,7 @@ void func_80B427C8(EnKgy* this, GlobalContext* globalCtx) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { temp_a2 = globalCtx->msgCtx.unk11F04; switch (temp_a2) { @@ -951,7 +951,7 @@ void func_80B4296C(EnKgy* this, GlobalContext* globalCtx) { } this->actor.focus.pos = this->unk_2A8; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B427C8; if (this->unk_2D2 == 4) { func_80B40BC0(this, 7); @@ -963,7 +963,7 @@ void func_80B4296C(EnKgy* this, GlobalContext* globalCtx) { this->actor.flags &= ~0x10000; } else { this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, 0); + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_NONE); } } @@ -982,7 +982,7 @@ void func_80B42A8C(EnKgy* this, GlobalContext* globalCtx) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { temp_a2 = globalCtx->msgCtx.unk11F04; switch (temp_a2) { case 0xC1D: @@ -1063,7 +1063,7 @@ void func_80B42D28(EnKgy* this, GlobalContext* globalCtx) { } this->actor.focus.pos = this->unk_2A8; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B42A8C; if (this->actor.textId == 0xC2D) { func_80B40BC0(this, 1); diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index 3a2f74983d..194b99b7a1 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -49,7 +49,7 @@ static CollisionCheckInfoInit D_8093670C = { 0, 12, 30, MASS_IMMOVABLE }; static InitChainEntry D_80936754[] = { ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -17000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), 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 df691b0df1..8fd3a4075e 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -845,7 +845,7 @@ void func_80A5D178(EnKusa2* this) { } static InitChainEntry sInitChain[] = { - ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(minVelocityY, -17000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), }; @@ -960,7 +960,7 @@ void func_80A5D7C4(EnKusa2* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.shape.shadowAlpha = 60; this->actor.room = -1; func_80A5BD94(this); @@ -970,14 +970,14 @@ void func_80A5D7C4(EnKusa2* this, GlobalContext* globalCtx) { if (!func_80A5BFD8(this, globalCtx)) { if ((this->unk_1C0 != NULL) && (this->unk_1C0->unk_1BE != 0)) { - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; if (this2->unk_1C0 != NULL) { sp2A = Actor_YawBetweenActors(&this->unk_1C0->actor, &this->actor); this->actor.home.rot.y = Rand_S16Offset(-1500, 3000) + sp2A; } this->unk_1C8 = Rand_S16Offset(72, 16); this->actor.velocity.y = 8.8f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); func_80A5DC70(this); } @@ -986,7 +986,7 @@ void func_80A5D7C4(EnKusa2* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer < 400.0f) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer < 100.0f) { - func_800B8BB0(&this->actor, globalCtx); + Actor_LiftActor(&this->actor, globalCtx); } } } @@ -1035,7 +1035,7 @@ void func_80A5D9C8(EnKusa2* this, GlobalContext* globalCtx) { this->actor.home.rot.y = this->actor.world.rot.y; this->actor.velocity.y = 12.5f; this->actor.speedXZ += 3.0f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80A5BAFC(this, globalCtx); func_80A5CD0C(this); this->unk_1C8 = 30; @@ -1051,7 +1051,7 @@ void func_80A5D9C8(EnKusa2* this, GlobalContext* globalCtx) { this->unk_1D0--; if (this->unk_1D0 <= 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); this->unk_1D0 = ((u32)Rand_Next() >> 0x1D) + 14; } @@ -1078,7 +1078,7 @@ void func_80A5DC98(EnKusa2* this, GlobalContext* globalCtx) { this->actor.scale.z = this->actor.scale.x; Math_StepToF(&this->actor.gravity, -7.0f, 1.8f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80A5BAFC(this, globalCtx); func_80A5BF38(this, 4); func_80A5BF84(this, globalCtx); @@ -1086,7 +1086,7 @@ void func_80A5DC98(EnKusa2* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { func_80A5CD0C(this); func_80A5BB40(this, globalCtx, 1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); func_80A5DE18(this); } else if (this->actor.bgCheckFlags & 0x20) { func_80A5BDB0(this, globalCtx); @@ -1118,14 +1118,14 @@ void func_80A5DEB4(EnKusa2* this, GlobalContext* globalCtx) { if (this->unk_1D0 > 0) { this->unk_1D0--; if (this->unk_1D0 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); } } if (this->unk_1D1 > 0) { this->unk_1D1--; if (this->unk_1D1 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); } } @@ -1139,7 +1139,7 @@ void func_80A5DEB4(EnKusa2* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); this->actor.world.rot.y = (s32)(Math_SinS(this->unk_1C4) * 3000.0f) + this->actor.home.rot.y; this->actor.shape.rot.y = this->actor.world.rot.y; @@ -1204,7 +1204,7 @@ void func_80A5E210(EnKusa2* this, GlobalContext* globalCtx) { } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80A5BAFC(this, globalCtx); if (this->actor.velocity.y > 0.01f) { @@ -1244,7 +1244,7 @@ void func_80A5E210(EnKusa2* this, GlobalContext* globalCtx) { } void func_80A5E418(EnKusa2* this) { - this->actor.minVelocityY = -4.0f; + this->actor.terminalVelocity = -4.0f; this->actor.velocity.x *= 0.1f; this->actor.velocity.y *= 0.25f; this->actor.velocity.z *= 0.1f; @@ -1259,7 +1259,7 @@ void func_80A5E4BC(EnKusa2* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.scale.y, 0.4f, 0.032f); Math_StepToF(&this->actor.scale.x, 0.4f, 0.032f); this->actor.scale.z = this->actor.scale.x; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80A5BAFC(this, globalCtx); func_80A5BF60(this, 6); this->actor.shape.rot.x -= 0x5DC; @@ -1354,7 +1354,7 @@ void EnKusa2_Draw(Actor* thisx, GlobalContext* globalCtx) { (this->actor.projectedPos.z < 400.0f)) { func_80A5B954(&D_80A60908[this->unk_1CE], 0.0015f); } - func_800BDFC0(globalCtx, D_050078A0); + Gfx_DrawDListOpa(globalCtx, D_050078A0); } else if (this->actor.projectedPos.z < 1300.0f) { func_80A5E80C(globalCtx, (1300.0f - this->actor.projectedPos.z) * 2.55f); } @@ -1368,14 +1368,14 @@ void func_80A5E9B4(Actor* thisx, GlobalContext* globalCtx) { sp18.z = thisx->shape.rot.z + D_80A5EAFC.z; Matrix_SetStateRotationAndTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, &sp18); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - func_800BDFC0(globalCtx, D_050078A0); + Gfx_DrawDListOpa(globalCtx, D_050078A0); } void func_80A5EA48(Actor* thisx, GlobalContext* globalCtx) { EnKusa2* this = THIS; if (this->unk_1CF == 0xFF) { - func_800BDFC0(globalCtx, D_050078A0); + Gfx_DrawDListOpa(globalCtx, D_050078A0); } else { func_80A5E80C(globalCtx, this->unk_1CF); } diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index 92908ac6d9..0901fd9b22 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -200,7 +200,7 @@ void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { EnMa4* this = THIS; s32 pad; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 18.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, NULL, this->jointTable, this->morphTable, MA1_LIMB_MAX); @@ -287,7 +287,7 @@ void EnMa4_RunInCircles(EnMa4* this, GlobalContext* globalCtx) { } if (sCurrentAnim == 13 && Animation_OnFrame(&this->skelAnime, 37.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROMANI_BOW_FLICK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROMANI_BOW_FLICK); } sp34.x = this->pathPoints[this->pathIndex].x; @@ -317,10 +317,10 @@ void EnMa4_RunInCircles(EnMa4* this, GlobalContext* globalCtx) { } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (this->skelAnime.animation == &D_06007328) { // Walking animation if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 4.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_ROMANI_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } } } @@ -363,7 +363,7 @@ void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { } } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { EnMa4_StartDialogue(this, globalCtx); EnMa4_SetupDialogueHandler(this); } else if (this->type != MA4_TYPE_ALIENS_WON || ABS_ALT(yaw) < 0x4000) { @@ -648,7 +648,7 @@ void EnMa4_SetupDialogueHandler(EnMa4* this) { void EnMa4_DialogueHandler(EnMa4* this, GlobalContext* globalCtx) { s32 temp_v0; - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { default: break; @@ -692,7 +692,7 @@ void EnMa4_BeginHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { } void EnMa4_HorsebackGameCheckPlayerInteractions(EnMa4* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { // "You're feeling confident" func_801518B0(globalCtx, 0x336E, &this->actor); this->actionFunc = EnMa4_HorsebackGameTalking; @@ -702,7 +702,7 @@ void EnMa4_HorsebackGameCheckPlayerInteractions(EnMa4* this, GlobalContext* glob } void EnMa4_HorsebackGameTalking(EnMa4* this, GlobalContext* globalCtx) { - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->actionFunc = EnMa4_HorsebackGameWait; } } @@ -760,7 +760,7 @@ void EnMa4_HorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { if (player->stateFlags1 & 0x100000) { globalCtx->actorCtx.unk268 = 1; - globalCtx->actorCtx.unk278 = 0x8000; + globalCtx->actorCtx.unk_26C.press.button = BTN_A; } else { globalCtx->actorCtx.unk268 = 1; } @@ -850,7 +850,7 @@ void EnMa4_EponasSongCs(EnMa4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); player->stateFlags1 |= 0x20; - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); D_80AC0260 = 99; this->hasBow = true; EnMa4_SetupEndEponasSongCs(this); @@ -865,14 +865,14 @@ void EnMa4_EndEponasSongCs(EnMa4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); this->actor.flags |= 0x10000; - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { player->stateFlags1 &= ~0x20; func_801518B0(globalCtx, 0x334C, &this->actor); this->textId = 0x334C; this->actor.flags &= ~0x10000; EnMa4_SetupDialogueHandler(this); } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); } } diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index 6b55a48a74..92a56a4198 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -188,7 +188,7 @@ void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 18.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06015C28, NULL, this->jointTable, this->morphTable, MA2_LIMB_MAX); EnMaYto_InitAnimation(this, globalCtx); @@ -321,7 +321,7 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx) { } s32 EnMaYto_SearchRomani(EnMaYto* this, GlobalContext* globalCtx) { - Actor* npcActor = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + Actor* npcActor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (npcActor != NULL) { if (npcActor->id == ACTOR_EN_MA_YTS) { @@ -425,7 +425,7 @@ void EnMaYto_DefaultWait(EnMaYto* this, GlobalContext* globalCtx) { EnMaYto_ChangeAnim(this, 11); } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { EnMaYto_DefaultStartDialogue(this, globalCtx); EnMaYto_SetupDefaultDialogueHandler(this); } else if (ABS_ALT(direction) < 0x1555) { @@ -440,7 +440,7 @@ void EnMaYto_SetupDefaultDialogueHandler(EnMaYto* this) { } void EnMaYto_DefaultDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 4: EnMaYto_DefaultHandlePlayerChoice(this, globalCtx); break; @@ -535,14 +535,14 @@ void EnMaYto_SetupDinnerWait(EnMaYto* this) { void EnMaYto_DinnerWait(EnMaYto* this, GlobalContext* globalCtx) { s16 direction = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { EnMaYto_DinnerStartDialogue(this, globalCtx); EnMaYto_SetupDinnerDialogueHandler(this); } else { Actor* child = this->actor.child; - if (child != NULL && func_800B84D0(child, globalCtx)) { - func_800B86C8(&this->actor, globalCtx, &this->actor); + if (child != NULL && Actor_ProcessTalkRequest(child, &globalCtx->state)) { + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_DinnerStartDialogue(this, globalCtx); EnMaYto_SetupDinnerDialogueHandler(this); } else if (ABS_ALT(direction) < 0x4000) { @@ -572,7 +572,7 @@ void EnMaYto_SetupDinnerDialogueHandler(EnMaYto* this) { } void EnMaYto_DinnerDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 4: EnMaYto_DinnerHandlePlayerChoice(this, globalCtx); break; @@ -635,7 +635,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 0x339B: - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); func_80B90E50(this, 0); EnMaYto_SetRomaniFaceExpression(this, 3, 3); func_801518B0(globalCtx, 0x339C, &this->actor); @@ -644,7 +644,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x339C: this->unk31E = 1; - func_800B86C8(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_SetFaceExpression(this, 0, 2); func_801518B0(globalCtx, 0x339D, &this->actor); this->textId = 0x339D; @@ -652,7 +652,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x339D: func_80B90E50(this, 1); - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 1); func_801518B0(globalCtx, 0x339E, &this->actor); this->textId = 0x339E; @@ -673,7 +673,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x33A1: func_80B90E50(this, 1); - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 2); func_801518B0(globalCtx, 0x33A2, &this->actor); this->textId = 0x33A2; @@ -681,7 +681,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x33A2: this->unk31E = 1; - func_800B86C8(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_SetFaceExpression(this, 4, 3); func_801518B0(globalCtx, 0x33A3, &this->actor); this->textId = 0x33A3; @@ -730,14 +730,14 @@ void EnMaYto_BarnWait(EnMaYto* this, GlobalContext* globalCtx) { s16 direction = this->actor.shape.rot.y + 0x471C; direction -= this->actor.yawTowardsPlayer; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { EnMaYto_BarnStartDialogue(this, globalCtx); EnMaYto_SetupBarnDialogueHandler(this); } else { Actor* child = this->actor.child; - if (child != NULL && func_800B84D0(child, globalCtx)) { - func_800B86C8(&this->actor, globalCtx, &this->actor); + if (child != NULL && Actor_ProcessTalkRequest(child, &globalCtx->state)) { + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_BarnStartDialogue(this, globalCtx); EnMaYto_SetupBarnDialogueHandler(this); } else if (!(gSaveContext.weekEventReg[0x16] & 1) || ABS_ALT(direction) < 0x2000) { @@ -762,7 +762,7 @@ void EnMaYto_SetupBarnDialogueHandler(EnMaYto* this) { } void EnMaYto_BarnDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 5: EnMaYto_BarnChooseNextDialogue(this, globalCtx); break; @@ -788,14 +788,14 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { switch (this->textId) { case 0x33A9: func_80B90E50(this, 0); - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 3); func_801518B0(globalCtx, 0x33AA, &this->actor); this->textId = 0x33AA; break; case 0x33AA: - func_800B86C8(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); this->unk31E = 1; func_801518B0(globalCtx, 0x33AB, &this->actor); this->textId = 0x33AB; @@ -803,7 +803,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x33AB: func_80B90E50(this, 1); - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 1); func_801518B0(globalCtx, 0x33AC, &this->actor); this->textId = 0x33AC; @@ -811,7 +811,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x33AC: this->unk31E = 0; - func_800B86C8(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); func_801518B0(globalCtx, 0x33AD, &this->actor); this->textId = 0x33AD; func_80151BB4(globalCtx, 6); @@ -820,7 +820,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x33AE: func_80B90E50(this, 1); - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 4, 2); func_801518B0(globalCtx, 0x33AF, &this->actor); this->textId = 0x33AF; @@ -828,7 +828,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x33AF: this->unk31E = 1; - func_800B86C8(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_SetFaceExpression(this, 4, 2); func_801518B0(globalCtx, 0x33B0, &this->actor); this->textId = 0x33B0; @@ -846,7 +846,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 0x33C6: - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); this->unk31E = 0; EnMaYto_SetFaceExpression(this, 0, 1); func_801518B0(globalCtx, 0x33C7, &this->actor); @@ -854,7 +854,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 0x33C7: - func_800B86C8(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); this->unk31E = 1; EnMaYto_SetFaceExpression(this, 0, 1); func_801518B0(globalCtx, 0x33C8, &this->actor); @@ -862,7 +862,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 0x33C8: - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); func_80B90E50(this, 1); EnMaYto_SetRomaniFaceExpression(this, 0, 2); func_801518B0(globalCtx, 0x33C9, &this->actor); @@ -870,7 +870,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 0x33C9: - func_800B86C8(&this->actor, globalCtx, &this->actor); + Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); this->unk31E = 1; EnMaYto_SetFaceExpression(this, 3, 1); func_801518B0(globalCtx, 0x33CA, &this->actor); @@ -884,7 +884,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 0x33CB: - func_800B86C8(&this->actor, globalCtx, this->actor.child); + Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); func_80B90E50(this, 1); EnMaYto_SetRomaniFaceExpression(this, 3, 3); func_801518B0(globalCtx, 0x33CC, &this->actor); @@ -912,7 +912,7 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx) { this->actor.flags |= 0x10000; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; if (gSaveContext.weekEventReg[0x34] & 1) { // if (ProtectedCremia) @@ -942,7 +942,7 @@ void EnMaYto_SetupAfterMilkRunDialogueHandler(EnMaYto* this) { } void EnMaYto_AfterMilkRunDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: case 1: case 2: @@ -986,10 +986,10 @@ void EnMaYto_PostMilkRunGiveReward(EnMaYto* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { EnMaYto_SetupPostMilkRunExplainReward(this); } else if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_HUGE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_HUGE, 500.0f, 100.0f); this->unk310 = 2; } else { - func_800B8A1C(&this->actor, globalCtx, GI_MASK_ROMANI, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MASK_ROMANI, 500.0f, 100.0f); this->unk310 = 1; } } @@ -999,7 +999,7 @@ void EnMaYto_SetupPostMilkRunExplainReward(EnMaYto* this) { } void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->unk310 == 1) { // Romani's mask explanation EnMaYto_SetFaceExpression(this, 0, 1); @@ -1024,7 +1024,7 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { EnMaYto_SetupPostMilkRunWaitDialogueEnd(this); } } else { - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); } } @@ -1095,14 +1095,14 @@ void EnMaYto_SetupPostMilkRunWaitDialogueEnd(EnMaYto* this) { } void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 6 || func_80152498(&globalCtx->msgCtx) == 5) { - if (func_80147624(globalCtx) && func_80152498(&globalCtx->msgCtx) == 5) { + if (Message_GetState(&globalCtx->msgCtx) == 6 || Message_GetState(&globalCtx->msgCtx) == 5) { + if (func_80147624(globalCtx) && Message_GetState(&globalCtx->msgCtx) == 5) { func_800B7298(globalCtx, &this->actor, 7); func_801477B4(globalCtx); } } - if (func_80152498(&globalCtx->msgCtx) == 0 && globalCtx->msgCtx.unk120B1 == 0) { + if (Message_GetState(&globalCtx->msgCtx) == 0 && globalCtx->msgCtx.unk120B1 == 0) { EnMaYto_SetupPostMilkRunEnd(this); } } diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index 266ba90e96..1ed32213a7 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -245,7 +245,8 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { if (!EnMaYts_CheckValidSpawn(this, globalCtx)) { Actor_MarkForDeath(&this->actor); } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 18.0f); + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06013928, NULL, this->jointTable, this->morphTable, MA1_LIMB_MAX); EnMaYts_InitAnimation(this, globalCtx); @@ -317,7 +318,7 @@ void EnMaYts_SetupStartDialogue(EnMaYts* this) { void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { s16 sp26 = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; - if (func_800B84D0(&this->actor, globalCtx)) { // if (Actor_IsTalking) + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (!(gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { if (!(gSaveContext.weekEventReg[0x41] & 0x80)) { // Saying to non-human Link: "Cremia went to town." @@ -374,7 +375,7 @@ void EnMaYts_SetupDialogueHandler(EnMaYts* this) { } void EnMaYts_DialogueHandler(EnMaYts* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 5: // End message block EnMaYts_ChooseNextDialogue(this, globalCtx); break; diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 4b5585086d..9892af79b7 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -91,7 +91,7 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { int i; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 15.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 15.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B538, &D_06001534, this->jointTable, this->morphTable, 24); CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -164,7 +164,7 @@ void EnMinifrog_Destroy(Actor* thisx, GlobalContext* globalCtx) { } EnMinifrog* EnMinifrog_GetFrog(GlobalContext* globalCtx) { - EnMinifrog* frog = (EnMinifrog*)globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + EnMinifrog* frog = (EnMinifrog*)globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (frog != NULL) { if ((frog->actor.id != ACTOR_EN_MINIFROG) || (frog->actor.params & 0xF)) { @@ -200,7 +200,7 @@ void EnMinifrog_Jump(EnMinifrog* this) { if (Animation_OnFrame(&this->skelAnime, 4.0f)) { this->actor.bgCheckFlags &= ~1; this->actor.velocity.y = 6.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FROG_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_JUMP); this->jumpState = MINIFROG_STATE_AIR; } break; @@ -262,7 +262,7 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { EnMinifrog_SetJumpState(this); switch (globalCtx->msgCtx.unk11F04) { @@ -329,12 +329,12 @@ void EnMinifrog_Idle(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); EnMinifrog_JumpTimer(this); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnMinifrog_ReturnFrogCutscene; if (this->actor.cutscene != -1) { this->flags |= 1; } - } else if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (Player_GetMask(globalCtx) == PLAYER_MASK_DON_GERO)) { func_800B8614(&this->actor, globalCtx, 110.0f); } @@ -473,11 +473,11 @@ void EnMinifrog_BeginChoirCutscene(EnMinifrog* this, GlobalContext* globalCtx) { void EnMinifrog_EndChoir(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, 0xD7E, &this->actor); // "Let us do it again sometime." this->actionFunc = EnMinifrog_YellowFrogDialog; } else { - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } } @@ -488,16 +488,16 @@ void EnMinifrog_GetFrogHP(EnMinifrog* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = EnMinifrog_EndChoir; this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, 0); + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_NONE); } else { - func_800B8A1C(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); } } void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 4: if (func_80147624(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { @@ -565,7 +565,7 @@ void EnMinifrog_SetupYellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); EnMinifrog_JumpTimer(this); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnMinifrog_YellowFrogDialog; if (!(gSaveContext.weekEventReg[34] & 1)) { // Not spoken with MINIFROG_YELLOW func_801518B0(globalCtx, 0xD76, @@ -575,8 +575,7 @@ void EnMinifrog_SetupYellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx func_801518B0(globalCtx, 0xD7F, &this->actor); // "Well, if it isn't the great Don Gero." } } else if ((this->actor.xzDistToPlayer < 150.0f) && - (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) || - ((this->actor.flags & 0x10000) == 0x10000)) && + (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) || ((this->actor.flags & 0x10000) == 0x10000)) && Player_GetMask(globalCtx) == PLAYER_MASK_DON_GERO) { func_800B8614(&this->actor, globalCtx, 160.0f); } @@ -587,7 +586,7 @@ void EnMinifrog_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 12.0f, 0.0f, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index bb7fd235e1..b2b8dd5ba7 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -202,7 +202,7 @@ void EnMinislime_AddIceShardEffect(EnMinislime* this) { } this->frozenAlpha = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ICE_BROKEN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); } void EnMinislime_AddIceSmokeEffect(EnMinislime* this, GlobalContext* globalCtx) { @@ -391,7 +391,7 @@ void EnMinislime_SetupGrowAndShrink(EnMinislime* this) { this->actor.scale.x = 0.19f; this->actor.scale.y = 0.044999998f; this->actor.scale.z = 0.19f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SLIME_JUMP2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_SLIME_JUMP2); this->actionFunc = EnMinislime_GrowAndShrink; } @@ -453,7 +453,7 @@ void EnMinislime_Idle(EnMinislime* this, GlobalContext* globalCtx) { void EnMinislime_SetupBounce(EnMinislime* this) { this->actor.speedXZ = 0.0f; this->bounceTimer = (this->actionFunc == EnMinislime_GrowAndShrink) ? 1 : 4; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SLIME_JUMP1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_SLIME_JUMP1); this->actionFunc = EnMinislime_Bounce; } @@ -736,9 +736,9 @@ void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->actionFunc != EnMinislime_Disappear) && (this->actionFunc != EnMinislime_Despawn)) { if (this->actionFunc == EnMinislime_MoveToBigslime) { - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); } else { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } EnMinislime_CheckBackgroundCollision(this); 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 1bedf7901f..019e7a848f 100644 --- a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c +++ b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c @@ -85,7 +85,7 @@ static DamageTable D_80A4F754 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_80A4F774[] = { ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), - ICHAIN_F32(minVelocityY, -5, ICHAIN_CONTINUE), + ICHAIN_F32(terminalVelocity, -5, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3000, ICHAIN_STOP), }; diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.c b/src/overlays/actors/ovl_En_Mm/z_en_mm.c index 00bf38f8ab..58de48dbd7 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -79,7 +79,7 @@ void EnMm_Init(Actor* thisx, GlobalContext* globalCtx) { return; } Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 50.0f, func_800B3FC0, 1.2f); + ActorShape_Init(&this->actor.shape, 50.0f, ActorShadow_DrawCircle, 1.2f); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); if (this->actor.parent != NULL) { @@ -123,7 +123,7 @@ void func_80965DB4(EnMm* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { func_80965BBC(this); - Audio_PlayActorSound2(&this->actor, NA_SE_PL_PULL_UP_ROCK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PULL_UP_ROCK); } else { if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & 0x10)) { this->actor.velocity.y = 0.0f; @@ -134,7 +134,7 @@ void func_80965DB4(EnMm* this, GlobalContext* globalCtx) { this->actor.world.rot.y += BINANG_SUB(0x8000, (s16)(angle * 2)); this->actor.speedXZ *= 0.5f; CollisionCheck_SpawnShieldParticles(globalCtx, &this->actor.world.pos); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HUMAN_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); } if (!(this->actor.bgCheckFlags & 1)) { @@ -168,13 +168,13 @@ void func_80965DB4(EnMm* this, GlobalContext* globalCtx) { this->actor.bgCheckFlags &= ~1; } - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HUMAN_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); } else { - func_800B8A1C(&this->actor, globalCtx, GI_NONE, 50.0f, 30.0f); + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 50.0f, 30.0f); } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } Collider_UpdateCylinder(&this->actor, &this->collider); @@ -200,7 +200,7 @@ void EnMm_Update(Actor* thisx, GlobalContext* globalCtx) { Collider_ResetCylinderAC(globalCtx, &this->collider.base); this->actionFunc(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 10.0f, 20.0f, 31); - Actor_SetHeight(&this->actor, 20.0f); + Actor_SetFocus(&this->actor, 20.0f); } void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c index 69823ad0e1..94507b0014 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c @@ -15,10 +15,9 @@ void EnMm2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMm2_Update(Actor* thisx, GlobalContext* globalCtx); void EnMm2_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809A2080(EnMm2* this, GlobalContext* globalCtx); -void func_809A20FC(EnMm2* this, GlobalContext* globalCtx); +void EnMm2_Reading(EnMm2* this, GlobalContext* globalCtx); +void EnMm2_WaitForRead(EnMm2* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Mm2_InitVars = { ACTOR_EN_MM2, ACTORCAT_ITEMACTION, @@ -31,16 +30,59 @@ const ActorInit En_Mm2_InitVars = { (ActorFunc)EnMm2_Draw, }; -#endif +#include "overlays/ovl_En_Mm2/ovl_En_Mm2.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm2/EnMm2_Init.s") +void EnMm2_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMm2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm2/EnMm2_Destroy.s") + Actor_SetScale(&this->actor, 0.015f); + this->actionFunc = EnMm2_WaitForRead; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm2/func_809A2080.s") +void EnMm2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm2/func_809A20FC.s") +/** + * Action function whilst Link is reading the letter. + */ +void EnMm2_Reading(EnMm2* this, GlobalContext* globalCtx) { + u8 talkState = Message_GetState(&globalCtx->msgCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm2/EnMm2_Update.s") + if (talkState != 2) { + if (talkState == 5 && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = EnMm2_WaitForRead; + } + } else { + this->actionFunc = EnMm2_WaitForRead; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm2/EnMm2_Draw.s") +/** + * Action function that awaits Link to read the letter, changing the A button to "Check" when he is within range to do + * so (and facing the letter). + */ +void EnMm2_WaitForRead(EnMm2* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_801518B0(globalCtx, 0x277B, &this->actor); + this->actionFunc = EnMm2_Reading; + } else if ((this->actor.xzDistToPlayer < 60.0f) && (Player_IsFacingActor(&this->actor, 0x3000, globalCtx))) { + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} + +void EnMm2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMm2* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void EnMm2_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sEnMm2DL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.c b/src/overlays/actors/ovl_En_Ms/z_en_ms.c index efc0ea175b..77b3d70dda 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -66,7 +66,7 @@ void EnMs_Init(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06003DC0, &D_060005EC, this->jointTable, this->morphTable, 9); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 35.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); Actor_SetScale(&this->actor, 0.015f); this->actor.colChkInfo.mass = MASS_IMMOVABLE; // Eating Magic Beans all day will do that to you this->actionFunc = EnMs_Wait; @@ -90,7 +90,7 @@ void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { this->actor.textId = 0x932; // "[...] So you liked my Magic Beans [...]" } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnMs_Talk; } else if ((this->actor.xzDistToPlayer < 90.0f) && (ABS_ALT(yawDiff) < 0x2000)) { func_800B8614(&this->actor, globalCtx, 90.0f); @@ -98,7 +98,7 @@ void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { } void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 6: if (func_80147624(globalCtx) != 0) { this->actionFunc = EnMs_Wait; @@ -108,8 +108,8 @@ void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { case 5: if (func_80147624(globalCtx) != 0) { func_801477B4(globalCtx); - func_800B8A1C(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, - this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, + this->actor.playerHeightRel); this->actionFunc = EnMs_Sell; } break; @@ -127,7 +127,7 @@ void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { func_80151938(globalCtx, 0x937); // "[...] You can't carry anymore." } else { func_8019F208(); - func_800B8A1C(&this->actor, globalCtx, GI_MAGIC_BEANS, 90.0f, 10.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MAGIC_BEANS, 90.0f, 10.0f); func_801159EC(-10); this->actionFunc = EnMs_Sell; } @@ -152,12 +152,12 @@ void EnMs_Sell(EnMs* this, GlobalContext* globalCtx) { func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); this->actionFunc = EnMs_TalkAfterPurchase; } else { - func_800B8A1C(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } void EnMs_TalkAfterPurchase(EnMs* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80151938(globalCtx, 0x936); // "You can plant 'em whenever you want [...]" this->actionFunc = EnMs_Talk; } else { @@ -169,7 +169,7 @@ void EnMs_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnMs* this = THIS; - Actor_SetHeight(&this->actor, 20.0f); + Actor_SetFocus(&this->actor, 20.0f); this->actor.targetArrowOffset = 500.0f; Actor_SetScale(&this->actor, 0.015f); SkelAnime_Update(&this->skelAnime); diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c index 70945999f3..ab94425ea8 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -138,7 +138,7 @@ s32 func_80A68860(EnMushi2* this, GlobalContext* globalCtx) { } s32 func_80A68910(EnMushi2* this, GlobalContext* globalCtx) { - Actor* bean = globalCtx->actorCtx.actorList[ACTORCAT_ITEMACTION].first; + Actor* bean = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; f32 minDistSq = SQ(100.0f); s32 ret = false; f32 temp_f0; @@ -206,7 +206,7 @@ void func_80A68BC8(EnMushi2* this) { if (this->unk_36C > 0) { this->unk_36C--; } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MUSI_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MUSI_WALK); this->unk_36C = 3.0f / CLAMP_MIN(this->skelAnime.playSpeed, 0.12f); if (this->unk_36C < 2) { @@ -280,7 +280,7 @@ void func_80A68ED8(EnMushi2* this) { this->actor.velocity.x = this->actor.speedXZ * this->unk_328.x; this->actor.velocity.y = this->actor.speedXZ * this->unk_328.y; this->actor.velocity.z = this->actor.speedXZ * this->unk_328.z; - Actor_ApplyMovement(&this->actor); + Actor_UpdatePos(&this->actor); } void func_80A68F24(EnMushi2* this) { @@ -789,7 +789,7 @@ void EnMushi2_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80A6A300(EnMushi2* this) { this->unk_368 = 100; this->actor.gravity = -0.25f; - this->actor.minVelocityY = -3.5f; + this->actor.terminalVelocity = -3.5f; this->unk_370 = Rand_S16Offset(-1000, 2000); this->skelAnime.playSpeed = 1.5f; this->actionFunc = func_80A6A36C; @@ -801,7 +801,7 @@ void func_80A6A36C(EnMushi2* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); this->actor.velocity.y -= this->actor.velocity.y * D_80A6BA14[ENMUSHI2_GET_3(&this->actor)]; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80A69424(this, globalCtx); this->actor.shape.rot.y += this->unk_370; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -822,7 +822,7 @@ void func_80A6A36C(EnMushi2* this, GlobalContext* globalCtx) { } else if (this->actor.bgCheckFlags & 0x20) { func_80A6AAA4(this); } else if (this->actor.bgCheckFlags & 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_WALK); func_80A68F24(this); func_80A691EC(this, this->actor.floorPoly, -1.0f); func_80A69388(this); @@ -949,7 +949,7 @@ void func_80A6A9E4(EnMushi2* this, GlobalContext* globalCtx) { void func_80A6AAA4(EnMushi2* this) { this->actor.velocity.y = -1.2f; - this->actor.minVelocityY = -1.2f; + this->actor.terminalVelocity = -1.2f; this->actor.gravity = -0.5f; this->unk_368 = Rand_S16Offset(120, 50); this->unk_36E = 0; @@ -967,7 +967,7 @@ void func_80A6AB08(EnMushi2* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.02f); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80A69424(this, globalCtx); Math_StepToF(&this->actor.world.pos.y, this->actor.world.pos.y + this->actor.depthInWater, 2.8f); this->skelAnime.playSpeed = this->unk_368 * 0.018f; @@ -1013,7 +1013,7 @@ void func_80A6AE14(EnMushi2* this) { this->unk_30C &= ~1; this->unk_368 = 100; this->actor.velocity.y = 0.0f; - this->actor.minVelocityY = -0.8f; + this->actor.terminalVelocity = -0.8f; this->actor.gravity = -0.04f; func_80A68B6C(this); this->actionFunc = func_80A6AE7C; @@ -1029,7 +1029,7 @@ void func_80A6AE7C(EnMushi2* this, GlobalContext* globalCtx) { this->actor.world.rot.y += (s16)((Rand_ZeroOne() - 0.5f) * 2000.0f); this->actor.gravity = -0.04f - (Rand_ZeroOne() * 0.02f); this->actor.velocity.y *= 0.95f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80A69424(this, globalCtx); temp_f2 = this->actor.scale.x - (1.0f / 20000.0f); Actor_SetScale(&this->actor, CLAMP_MIN(temp_f2, 0.001f)); @@ -1048,7 +1048,7 @@ void func_80A6B078(EnMushi2* this) { this->unk_30C &= ~1; this->unk_368 = 50; this->skelAnime.playSpeed = 1.9f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTURA_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); func_80A68B6C(this); this->actionFunc = func_80A6B0D8; } @@ -1224,7 +1224,7 @@ void EnMushi2_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((this->unk_30C & 1) && func_80A68DD4(this, globalCtx)) { - func_800B8A1C(&this->actor, globalCtx, GI_MAX, 60.0f, 30.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 60.0f, 30.0f); } } } diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.c b/src/overlays/actors/ovl_En_Muto/z_en_muto.c index 131fbebcc3..00c3ed0c98 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -64,7 +64,7 @@ void EnMuto_Init(Actor* thisx, GlobalContext* globalCtx) { EnMuto* this = THIS; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 40.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06007150, &D_06000E50, this->jointTable, this->morphTable, 17); this->isInMayorsRoom = this->actor.params; @@ -148,7 +148,7 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { this->actor.textId = 0x2363; } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { EnMuto_SetupDialogue(this, globalCtx); return; } @@ -186,7 +186,7 @@ void EnMuto_SetupDialogue(EnMuto* this, GlobalContext* globalCtx) { if (this->targetActor != NULL) { this->shouldSetHeadRotation = true; this->cutsceneState = 1; - func_800B86C8(this->targetActor, globalCtx, this->targetActor); + Actor_ChangeFocus(this->targetActor, globalCtx, this->targetActor); } this->isInDialogue = true; @@ -196,7 +196,7 @@ void EnMuto_SetupDialogue(EnMuto* this, GlobalContext* globalCtx) { void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx) { if (!this->isInMayorsRoom) { this->yawTowardsTarget = this->actor.yawTowardsPlayer; - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { func_801477B4(globalCtx); if (this->actor.textId == 0x62C) { @@ -263,8 +263,8 @@ void EnMuto_Update(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetScale(&this->actor, 0.01f); this->actor.shape.rot.y = this->actor.world.rot.y; - Actor_SetHeight(&this->actor, 60.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_SetFocus(&this->actor, 60.0f); + Actor_MoveWithGravity(&this->actor); Math_SmoothStepToS(&this->headRot.y, this->headRotTarget.y, 1, 0xBB8, 0); Math_SmoothStepToS(&this->headRot.x, this->headRotTarget.x, 1, 0x3E8, 0); diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index c65d794bb6..41730f4d44 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -124,7 +124,7 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags |= 0x1; // targetable ON - ActorShape_Init(&thisx->shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 25.0f); SkelAnime_InitFlex(globalCtx, &this->skelanime, &D_06002530, &D_060000E8, this->jointTable, this->morphTable, ENNIW_LIMBCOUNT); @@ -147,7 +147,7 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->niwType == ENNIW_TYPE_UNK2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->unkTimer250 = 30; this->actor.flags &= ~0x1; // targetable OFF @@ -342,7 +342,7 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { if (this->niwType == ENNIW_TYPE_REGULAR) { if (Actor_HasParent(&this->actor, globalCtx)) { // picked up - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->unkTimer250 = 30; this->actor.flags &= ~0x1; // targetable OFF @@ -351,7 +351,7 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { this->actionFunc = EnNiw_Held; return; } else { - func_800B8BB0(&this->actor, globalCtx); + Actor_LiftActor(&this->actor, globalCtx); } } else { this->unkTimer252 = 10; @@ -493,7 +493,7 @@ void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { // picked up again before could run off - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->unk2EC = 0; this->unkTimer250 = 30; @@ -503,7 +503,7 @@ void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; } else { if (this->unkTimer252 > 5) { - func_800B8BB0(&this->actor, globalCtx); + Actor_LiftActor(&this->actor, globalCtx); } func_80891320(this, globalCtx, 2); } @@ -603,7 +603,7 @@ void EnNiw_SetupCuccoStorm(EnNiw* this, GlobalContext* globalCtx) { this->unk264[1] = 0.0f; this->unk264[2] = 0.0f; this->unkTimer24C = 10; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow } if (this->unkTimer252 == 0) { this->unkTimer252 = 10; @@ -685,7 +685,7 @@ void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx) { this->unkTimer260 = 10; this->sfxTimer1 = 30; this->unk29E = 1; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->unkTimer254 = 100; this->unk2EC = 0; EnNiw_SetupRunAway(this); @@ -722,7 +722,7 @@ void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx) { this->unkTimer260 = 10; this->sfxTimer1 = 30; this->unk29E = 1; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->unkTimer254 = 100; this->unk2EC = 0; EnNiw_SetupRunAway(this); @@ -805,8 +805,8 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.rot = this->actor.world.rot; this->actor.shape.shadowScale = 15.0f; this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, this->unk308); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_SetFocus(&this->actor, this->unk308); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1F); @@ -878,16 +878,16 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { EnNiw_CheckRage(this, globalCtx); if ((this->flutterSfxTimer == 0) && (this->unknownState28E == 4)) { this->flutterSfxTimer = 7; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); } if (this->sfxTimer1 == 0) { if (this->unknownState28E != 0) { this->sfxTimer1 = 30; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_A); // attack cluck + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); // attack cluck } else { this->sfxTimer1 = 300; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_N); // cluck + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_N); // cluck } } diff --git a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c index dc93bf7cdb..d106901045 100644 --- a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c +++ b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c @@ -77,7 +77,7 @@ void func_80C08828(EnNnh* this) { } void func_80C0883C(EnNnh* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, 0x228U, &this->actor); func_80C088A4(this); return; @@ -90,7 +90,7 @@ void func_80C088A4(EnNnh* this) { } void func_80C088B8(EnNnh* this, GlobalContext* globalCtx) { - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { func_80C08828(this); } } 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 10f9a1783e..1af1ec8b8a 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -53,7 +53,7 @@ static ColliderCylinderInit sCylinderInit = { void EnNutsball_Init(Actor* thisx, GlobalContext* globalCtx) { EnNutsball* this = THIS; - ActorShape_Init(&this->actor.shape, 400.0f, (ActorShadowFunc)func_800B3FC0, 13.0f); + ActorShape_Init(&this->actor.shape, 400.0f, ActorShadow_DrawCircle, 13.0f); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.shape.rot.y = 0; this->actor.speedXZ = 10.0f; @@ -133,7 +133,7 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx) { } } - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); Math_Vec3f_Copy(&worldPos, &this->actor.world.pos); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 5.0f, 10.0f, 0x7); 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 be2c4b5706..9a1a076402 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -256,7 +256,7 @@ void EnOssan_UpdateCursorPos(GlobalContext* globalCtx, EnOssan* this) { s16 x; s16 y; - func_800B8898(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); this->cursorPos.x = x; this->cursorPos.y = y; } @@ -264,7 +264,7 @@ void EnOssan_UpdateCursorPos(GlobalContext* globalCtx, EnOssan* this) { void EnOssan_EndInteraction(GlobalContext* globalCtx, EnOssan* this) { Player* player = GET_PLAYER(globalCtx); - func_800B84D0(&this->actor, globalCtx); + Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; Interface_ChangeAlpha(50); @@ -330,7 +330,7 @@ void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); func_8013D9C8(globalCtx, this->limbRotTableY, this->limbRotTableZ, 19); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->stateFlags2 |= 0x20000000; EnOssan_SetupAction(this, EnOssan_BeginInteraction); if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { @@ -523,7 +523,7 @@ u8 EnOssan_CursorLeft(EnOssan* this, u8 cursorIdx, u8 shelfSlotMax) { void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { ActorAnimationEntryS* animations = sAnimations[this->actor.params]; - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; Player* player = GET_PLAYER(globalCtx); @@ -551,7 +551,7 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { func_8013BC6C(&this->skelAnime, animations, 9); } if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HANKO); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } } @@ -581,7 +581,7 @@ s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, GlobalContext* globalCtx } void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; Player* player = GET_PLAYER(globalCtx); u8 cursorIdx; @@ -630,7 +630,7 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_TalkToShopkeeper(EnOssan* this, GlobalContext* globalCtx) { ActorAnimationEntryS* animations = sAnimations[this->actor.params]; - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { if (this->animationIdx == 9 && this->actor.params == ENOSSAN_PART_TIME_WORKER) { this->animationIdx = 1; func_8013BC6C(&this->skelAnime, animations, 1); @@ -804,7 +804,7 @@ s32 EnOssan_HasPlayerSelectedItem(GlobalContext* globalCtx, EnOssan* this, Input } void EnOssan_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; u8 prevCursorIndex = this->cursorIdx; u8 cursorIdx; @@ -862,7 +862,7 @@ void EnOssan_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; u8 prevCursorIndex = this->cursorIdx; u8 cursorIdx; @@ -946,7 +946,7 @@ void EnOssan_LookToShopkeeperFromShelf(EnOssan* this, GlobalContext* globalCtx) void EnOssan_SetupBuyItemWithFanfare(GlobalContext* globalCtx, EnOssan* this) { Player* player = GET_PLAYER(globalCtx); - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; player->stateFlags2 &= ~0x20000000; @@ -1014,7 +1014,7 @@ void EnOssan_HandleCanBuyItem(GlobalContext* globalCtx, EnOssan* this) { } void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (EnOssan_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); @@ -1034,7 +1034,7 @@ void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_CannotBuy(EnOssan* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); } @@ -1043,7 +1043,7 @@ void EnOssan_CannotBuy(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_CanBuy(EnOssan* this, GlobalContext* globalCtx) { EnGirlA* item; - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1058,12 +1058,12 @@ void EnOssan_BuyItemWithFanfare(EnOssan* this, GlobalContext* globalCtx) { this->actor.parent = NULL; EnOssan_SetupAction(this, EnOssan_SetupItemPurchased); } else { - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); } } void EnOssan_SetupItemPurchased(EnOssan* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; EnOssan_SetupAction(this, EnOssan_ItemPurchased); @@ -1074,12 +1074,12 @@ void EnOssan_SetupItemPurchased(EnOssan* this, GlobalContext* globalCtx) { this->cutscene = this->lookToShopkeeperCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); } - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); } } void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); EnGirlA* item; @@ -1097,7 +1097,7 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { player->stateFlags2 |= 0x20000000; func_801518B0(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, true); - func_800B85E0(&this->actor, globalCtx, 100.0f, -1); + func_800B85E0(&this->actor, globalCtx, 100.0f, EXCH_ITEM_MINUS1); break; case 1: default: @@ -1115,7 +1115,7 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { player->stateFlags2 |= 0x20000000; func_801518B0(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, true); - func_800B85E0(&this->actor, globalCtx, 100.0f, -1); + func_800B85E0(&this->actor, globalCtx, 100.0f, EXCH_ITEM_MINUS1); } } @@ -1136,10 +1136,10 @@ void EnOssan_ItemPurchased(EnOssan* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80151938(globalCtx, 0x642); } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); } } @@ -1429,9 +1429,9 @@ void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { this->actor.flags &= ~0x10; this->actor.objBankIndex = this->objIndex; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); shopItems = sShops[this->actor.params]; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); sInitFuncs[this->actor.params](this, globalCtx); this->textId = sWelcomeHumanTextIds[this->actor.params]; EnOssan_GetCutscenes(this, globalCtx); @@ -1518,7 +1518,7 @@ void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx) { EnOssan_UpdateCursorAnim(this); func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unk2CC, this->actor.focus.pos); this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, 90.0f); + Actor_SetFocus(&this->actor, 90.0f); SkelAnime_Update(&this->skelAnime); } else { this->actionFunc(this, globalCtx); 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 65fd93e867..24acaa6a1b 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -155,7 +155,7 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 30.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004800, &D_060008D8, this->jointTable, this->morphTable, 19); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); Animation_Change(&this->skelAnime, sAnimations[0].animationSeg, 1.0f, @@ -338,7 +338,7 @@ void func_80B5BED4(EnOt* this, GlobalContext* globalCtx) { 0x38E); this->actor.speedXZ = 3.5f; this->actor.world.pos.y = this->unk_360->actor.world.pos.y; - Actor_SetVelocityAndMoveXYRotationReverse(&this->actor); + Actor_MoveWithoutGravityReverse(&this->actor); } void func_80B5BF60(EnOt* this, GlobalContext* globalCtx) { @@ -377,7 +377,7 @@ void func_80B5BFB8(EnOt* this, GlobalContext* globalCtx) { func_80B5C684(this->unk_360, globalCtx); func_80B5C684(this, globalCtx); } else { - Actor_SetVelocityAndMoveXYRotationReverse(&this->actor); + Actor_MoveWithoutGravityReverse(&this->actor); } } @@ -388,7 +388,7 @@ void func_80B5C154(EnOt* this, GlobalContext* globalCtx) { this->unk_38C = GI_HEART_PIECE; gSaveContext.weekEventReg[32] |= 1; } - func_800B8A1C(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_80B5C1CC; } @@ -398,7 +398,7 @@ void func_80B5C1CC(EnOt* this, GlobalContext* globalCtx) { func_80B5C244(this, globalCtx); func_80B5C244(this->unk_360, globalCtx); } else { - func_800B8A1C(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_PickUp(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } @@ -536,7 +536,7 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { if ((gSaveContext.weekEventReg[84] & 0x10) && (this->unk_33C == 1)) { this->actor.textId = 0; this->unk_384 = 1; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_3A0 = BINANG_ADD(sp3E, 0x4000); this->unk_360->unk_3A0 = this->unk_3A0; func_80B5C9A8(this, globalCtx); @@ -561,7 +561,7 @@ void func_80B5C910(EnOt* this, GlobalContext* globalCtx) { void func_80B5C950(EnOt* this, GlobalContext* globalCtx) { if (this->unk_32C & 8) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); gSaveContext.weekEventReg[25] |= 4; func_80B5CAD0(this, globalCtx); } @@ -582,7 +582,7 @@ void func_80B5C9D0(EnOt* this, GlobalContext* globalCtx) { this->actor.world.rot.x = this->actor.world.rot.x; this->actor.world.rot.y = this->actor.world.rot.y; this->actor.world.rot.z = this->actor.world.rot.z; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); this->actionFunc = func_80B5CA30; } @@ -617,7 +617,7 @@ void func_80B5CBA0(EnOt* this, GlobalContext* globalCtx) { } void func_80B5CBEC(EnOt* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; func_80B5CC88(this, globalCtx); } else { @@ -649,7 +649,7 @@ void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 temp; - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: temp = Math_SmoothStepToS(&this->actor.shape.rot.y, BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), 3, 0xE38, 0x38E); @@ -691,7 +691,7 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { s32 pad; this->actor.textId = 0; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80B5D114(this, globalCtx); return; } @@ -745,7 +745,7 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { u16 phi_a1; s32 temp; - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: temp = Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); this->actor.world.rot.y = this->actor.shape.rot.y; @@ -900,7 +900,7 @@ void func_80B5D648(EnOt* this, GlobalContext* globalCtx) { func_8013E1C8(&this->skelAnime, sAnimations, 1, &this->animIdx); this->actor.flags |= 0x8000000; this->actor.flags &= ~(0x8 | 0x1); - Actor_SetSwitchFlag(globalCtx, ENOT_GET_3F80(&this->actor)); + Flags_SetSwitch(globalCtx, ENOT_GET_3F80(&this->actor)); this->actionFunc = func_80B5D750; } @@ -939,7 +939,7 @@ void EnOt_Update(Actor* thisx, GlobalContext* globalCtx) { EnOt* this = THIS; if ((this->animIdx == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SEAHORSE_SWIM); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SEAHORSE_SWIM); } this->actionFunc(this, globalCtx); @@ -963,7 +963,7 @@ void EnOt_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.prevPos.y = this->actor.floorHeight + 50.0f; } - Actor_SetHeight(&this->actor, 12.0f); + Actor_SetFocus(&this->actor, 12.0f); SkelAnime_Update(&this->skelAnime); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); @@ -981,7 +981,7 @@ void func_80B5DAEC(Actor* thisx, GlobalContext* globalCtx) { EnOt* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, 12.0f); + Actor_SetFocus(&this->actor, 12.0f); SkelAnime_Update(&this->skelAnime); func_80B5BB38(&this->unk_747, &this->unk_744, 0.7f); if (this->unk_32C & 0x400) { 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 ab5e2520a1..5bf520f91b 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -138,14 +138,14 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 36.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime1, &D_0600C5F8, &D_06001ADC, this->jointTable1, this->morphTable1, 21); SkelAnime_InitFlex(globalCtx, &this->skelAnime2, &D_060105C0, &D_0600CDB0, this->jointTable2, this->morphTable2, 16); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.minVelocityY = -10.0f; + this->actor.terminalVelocity = -10.0f; this->actor.targetArrowOffset = 500.0f; EnOwl_ChangeMode(this, func_8095BF58, func_8095C484, &this->skelAnime2, &D_0600CDB0, 0.0f); @@ -233,27 +233,27 @@ void func_8095A920(EnOwl* this, GlobalContext* globalCtx) { } s32 func_8095A978(EnOwl* this, GlobalContext* globalCtx, u16 textId, f32 targetDist, f32 arg4) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { return true; } this->actor.textId = textId; if (this->actor.xzDistToPlayer < targetDist) { this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, targetDist, arg4, 0); + func_800B8500(&this->actor, globalCtx, targetDist, arg4, EXCH_ITEM_NONE); } return false; } s32 func_8095A9FC(EnOwl* this, GlobalContext* globalCtx, u16 textId) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { return true; } this->actor.textId = textId; if (this->actor.xzDistToPlayer < 120.0f) { - func_800B8500(&this->actor, globalCtx, 350.0f, 1000.0f, 0); + func_800B8500(&this->actor, globalCtx, 350.0f, 1000.0f, EXCH_ITEM_NONE); } return false; @@ -269,7 +269,7 @@ void func_8095AAD0(EnOwl* this, GlobalContext* globalCtx) { s32 switchFlag = ENOWL_GET_SWITCHFLAG(&this->actor); if (switchFlag < 0x7F) { - Actor_SetSwitchFlag(globalCtx, switchFlag); + Flags_SetSwitch(globalCtx, switchFlag); } func_8095AA70(this); @@ -302,7 +302,7 @@ void func_8095ABA8(EnOwl* this) { } void func_8095ABF0(EnOwl* this, GlobalContext* globalCtx) { - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { Audio_QueueSeqCmd(0x110000FF); func_8095AAD0(this, globalCtx); this->actor.flags &= ~0x10000; @@ -311,7 +311,7 @@ void func_8095ABF0(EnOwl* this, GlobalContext* globalCtx) { // Unused? void func_8095AC50(EnOwl* this, GlobalContext* globalCtx) { - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { Audio_QueueSeqCmd(0x110000FF); if ((this->unk_3DA % 64) == 0) { func_8095AAD0(this, globalCtx); @@ -335,7 +335,7 @@ void func_8095ACEC(EnOwl* this) { } void func_8095AD54(EnOwl* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case OWL_REPEAT: func_80151938(globalCtx, 0x7D1); @@ -351,14 +351,14 @@ void func_8095AD54(EnOwl* this, GlobalContext* globalCtx) { } void func_8095AE00(EnOwl* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_80151938(globalCtx, 0x7D2); this->actionFunc = func_8095AD54; } } void func_8095AE60(EnOwl* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_80151938(globalCtx, 0x7D1); this->actionFunc = func_8095AE00; } @@ -373,7 +373,7 @@ void func_8095AEC0(EnOwl* this, GlobalContext* globalCtx) { } void func_8095AF2C(EnOwl* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 5: if (func_80147624(globalCtx)) { if (globalCtx->msgCtx.unk11F04 == 0xBFE) { @@ -430,7 +430,7 @@ void func_8095B158(EnOwl* this) { if (Animation_OnFrame(&this->skelAnime1, 2.0f) || Animation_OnFrame(&this->skelAnime1, 9.0f) || Animation_OnFrame(&this->skelAnime1, 23.0f) || Animation_OnFrame(&this->skelAnime1, 40.0f) || Animation_OnFrame(&this->skelAnime1, 58.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OWL_FLUTTER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OWL_FLUTTER); } } @@ -509,14 +509,14 @@ void func_8095B480(EnOwl* this, GlobalContext* globalCtx) { void func_8095B574(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_8095BA84; func_801A3098(NA_BGM_OWL); this->actionFlags |= 0x40; this->unk_406 = 2; } else if (this->actor.xzDistToPlayer < 200.0f) { this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, 200.0f, 400.0f, 0); + func_800B8500(&this->actor, globalCtx, 200.0f, 400.0f, EXCH_ITEM_NONE); } else { this->actor.flags &= ~0x10000; } @@ -615,7 +615,7 @@ void func_8095B9FC(EnOwl* this, GlobalContext* globalCtx) { void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 4: if (func_80147624(globalCtx)) { switch (globalCtx->msgCtx.unk11F04) { @@ -719,18 +719,18 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { void func_8095BE0C(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_8095BA84; func_801A3098(NA_BGM_OWL); this->unk_406 = 1; this->actionFlags |= 0x40; } else if (this->actor.textId == 0xBF0) { if (this->actor.isTargeted) { - func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, 0); + func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, EXCH_ITEM_NONE); } } else if (this->actor.xzDistToPlayer < 200.0f) { this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, 0); + func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, EXCH_ITEM_NONE); } else { this->actor.flags &= ~0x10000; } @@ -891,7 +891,7 @@ void EnOwl_Update(Actor* thisx, GlobalContext* globalCtx) { s16 sp36; if (this->actor.draw != NULL) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } if (this->unk_414 != NULL) { @@ -905,7 +905,7 @@ void EnOwl_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); if (this->actor.update != NULL) { if ((this->skelAnime1.animation == &D_06001ADC) && Animation_OnFrame(&this->skelAnime1, 4.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_OWL_FLUTTER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OWL_FLUTTER); } if (this->actionFlags & 2) { diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index 14ad82b2d7..525606bc38 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -151,7 +151,7 @@ void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx) { EnPamera* this = THIS; Vec3f sp44; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 15.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 15.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06008448, &D_060005BC, this->jointTable, this->morphTable, PAMERA_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); @@ -196,7 +196,7 @@ void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80BD84F0(EnPamera* this, GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_DOOR].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; while (actor != NULL) { if ((actor->id == ACTOR_EN_DOOR) && (Math_Vec3f_DistXZ(&this->actor.world.pos, &actor->world.pos) < 200.0f)) { @@ -249,7 +249,7 @@ void EnPamera_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80BD8700(EnPamera* this) { this->hideInisdeTimer = 0; this->actor.flags &= ~1; - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BD8758; } @@ -259,7 +259,7 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[0], &this->actor); func_800E02AC(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[0])), &this->actor); this->actor.speedXZ = 1.5f; - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actor.shape.rot.y = this->actor.home.rot.y; this->actor.world.rot.y = this->actor.home.rot.y; func_80BD9338(this, globalCtx); @@ -268,7 +268,7 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscenes[0]); } else { this->actor.speedXZ = 1.5f; - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actor.shape.rot.y = this->actor.home.rot.y; this->actor.world.rot.y = this->actor.home.rot.y; func_80BD9338(this, globalCtx); @@ -290,7 +290,7 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { void func_80BD8908(EnPamera* this) { this->actor.draw = EnPamera_Draw; this->actor.flags |= 1; - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BD8964; } @@ -303,14 +303,14 @@ void func_80BD8964(EnPamera* this, GlobalContext* globalCtx) { if (Math_Vec3f_StepTo(&this->actor.world.pos, &vec, 1.0f) < 5.0f) { this->actor.speedXZ = 1.5f; - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); gSaveContext.weekEventReg[59] |= 1; func_80BD8B50(this); } } void func_80BD8A38(EnPamera* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BD8A7C; } @@ -357,14 +357,14 @@ void func_80BD8B70(EnPamera* this, GlobalContext* globalCtx) { void func_80BD8CCC(EnPamera* this) { this->hideInisdeTimer = 0; this->actor.speedXZ = 0.0f; - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); this->actionFunc = func_80BD8D1C; } void func_80BD8D1C(EnPamera* this, GlobalContext* globalCtx) { if (this->hideInisdeTimer++ > 200) { this->actor.speedXZ = 1.5f; - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); func_80BD8D80(this); } } @@ -400,14 +400,14 @@ void func_80BD8DB0(EnPamera* this, GlobalContext* globalCtx) { void EnPamera_LookDownWell(EnPamera* this) { func_80BD93CC(this, 1, 1); - func_800BDC5C(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); this->actionFunc = func_80BD8F60; } void func_80BD8F60(EnPamera* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x3000, 0x1000); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); this->actor.speedXZ = 3.0f; func_80BD93CC(this, 0, 0); func_80BD8D80(this); @@ -424,7 +424,7 @@ void func_80BD8FF0(EnPamera* this) { pameraYaw = Math_Vec3f_Yaw(&pameraPos, &this->actor.world.pos); this->actor.shape.rot.y = pameraYaw; this->actor.world.rot.y = pameraYaw; - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); this->actionFunc = func_80BD909C; } @@ -454,7 +454,7 @@ void func_80BD90AC(EnPamera* this, GlobalContext* globalCtx) { } s32 func_80BD9234(EnPamera* this, GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (actor != NULL) { if ((actor->id == ACTOR_EN_BOM) && (Math_Vec3f_DistXZ(&this->actor.world.pos, &actor->world.pos) < 500.0f) && @@ -512,11 +512,11 @@ void func_80BD93F4(EnPamera* this, GlobalContext* globalCtx) { (this->actionFunc == func_80BD8964) || (this->actionFunc == func_80BD8A7C)) { if (this->skelAnime.animation == &D_06008AE0) { if (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } } else if ((this->skelAnime.animation == &D_06008E38) && (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } } } @@ -609,7 +609,7 @@ void func_80BD9938(EnPamera* this) { } void func_80BD994C(EnPamera* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { if (1) {} func_80BD93CC(this, 0, 1); @@ -642,7 +642,7 @@ void func_80BD9A9C(EnPamera* this) { } void EnPamera_HandleDialogue(EnPamera* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: case 1: case 2: @@ -760,7 +760,7 @@ void func_80BD9E78(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9E88(EnPamera* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); this->unk_31E = 0; this->setupFunc = func_80BD9ED0; } @@ -769,7 +769,7 @@ void func_80BD9ED0(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9EE0(EnPamera* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); func_80BD93CC(this, 1, 0); this->unk_31E = 1; this->setupFunc = func_80BD9F3C; @@ -781,19 +781,19 @@ void func_80BD9F3C(EnPamera* this, GlobalContext* globalCtx) { Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 14.0f) || Animation_OnFrame(&this->skelAnime, 18.0f) || Animation_OnFrame(&this->skelAnime, 22.0f) || Animation_OnFrame(&this->skelAnime, 25.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - func_800BDC5C(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); } } } void func_80BDA038(EnPamera* this) { func_80BD93CC(this, 0, 1); - func_800BDC5C(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); this->unk_31E = 0; this->setupFunc = func_80BDA090; } @@ -803,7 +803,7 @@ void func_80BDA090(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA0A0(EnPamera* this) { func_80BD93CC(this, 0, 1); - func_800BDC5C(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); this->unk_31E = 1; this->setupFunc = func_80BDA0FC; } @@ -813,7 +813,7 @@ void func_80BDA0FC(EnPamera* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - func_800BDC5C(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); } } } @@ -821,7 +821,7 @@ void func_80BDA0FC(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA170(EnPamera* this) { this->unk_31E = 1; func_80BD93CC(this, 0, 1); - func_800BDC5C(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); this->setupFunc = func_80BDA1C8; } @@ -829,12 +829,12 @@ void func_80BDA1C8(EnPamera* this, GlobalContext* globalCtx) { if (this->unk_31E == 1) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 14.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - func_800BDC5C(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); } } } @@ -842,7 +842,7 @@ void func_80BDA1C8(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA288(EnPamera* this) { this->unk_31E = 1; func_80BD93CC(this, 0, 0); - func_800BDC5C(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); this->setupFunc = func_80BDA2E0; } @@ -850,7 +850,7 @@ void func_80BDA2E0(EnPamera* this, GlobalContext* globalCtx) { if (this->unk_31E == 1) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; - func_800BDC5C(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); } } } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index cb796119a0..c85f1ac495 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -184,13 +184,13 @@ void EnPametfrog_Init(Actor* thisx, GlobalContext* globalCtx) { s32 i; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 55.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 55.0f); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInit); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGekkoSkel, &gGekkoBoxingStanceAnim, this->jointTable, this->morphTable, GEKKO_LIMB_MAX); Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colElement); this->params = CLAMP(this->actor.params, 1, 4); - if (Actor_GetRoomCleared(globalCtx, globalCtx->roomCtx.currRoom.num)) { + if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { Actor_MarkForDeath(&this->actor); if (!(gSaveContext.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & (u8)isFrogReturnedFlags[this->actor.params - 1])) { @@ -246,7 +246,7 @@ void EnPametfrog_Thaw(EnPametfrog* this, GlobalContext* globalCtx) { this->collider.base.colType = COLTYPE_HIT6; this->collider.elements->info.elemType = ELEMTYPE_UNK1; this->unk_2C4 = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); } } @@ -378,10 +378,10 @@ void EnPametfrog_PlaceSnapper(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_JumpOnGround(EnPametfrog* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_JUMP); } else if (Animation_OnFrame(&this->skelAnime, 11.0f)) { EnPametfrog_JumpWaterEffects(this, globalCtx); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WALK_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALK_WATER); } } @@ -404,8 +404,8 @@ void EnPametfrog_ApplyMagicArrowEffects(EnPametfrog* this, GlobalContext* global void EnPametfrog_ApplyElectricStun(EnPametfrog* this) { this->freezeTimer = 40; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); - func_800BCB70(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); this->drawEffect = GEKKO_DRAW_EFFECT_ELECTRIC_STUN; this->unk_2C8 = 0.75f; this->unk_2C4 = 2.0f; @@ -413,8 +413,8 @@ void EnPametfrog_ApplyElectricStun(EnPametfrog* this) { void EnPametfrog_ApplyStun(EnPametfrog* this) { this->freezeTimer = 40; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); - func_800BCB70(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); } void EnPametfrog_SetupRearOnSnapper(EnPametfrog* this) { @@ -511,7 +511,7 @@ void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx eye.y = this->actor.focus.pos.y + 100.0f; eye.z = (Math_CosS(yaw) * 300.0f) + this->actor.focus.pos.z; Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &eye); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DAMAGE); this->actionFunc = EnPametfrog_FallOffSnapper; } @@ -538,7 +538,7 @@ void EnPametfrog_SetupJumpToWall(EnPametfrog* this) { this->actor.shape.rot.x = 0; this->actor.shape.rot.z = 0; this->actor.bgCheckFlags &= ~8; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_VOICE2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_VOICE2); this->actionFunc = EnPametfrog_JumpToWall; } @@ -581,7 +581,7 @@ void EnPametfrog_SetupWallCrawl(EnPametfrog* this) { this->skelAnime.playSpeed = 1.0f; } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_RUNAWAY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_RUNAWAY); this->actor.speedXZ = 8.0f; this->timer = Rand_S16Offset(35, 15); this->actionFunc = EnPametfrog_WallCrawl; @@ -639,11 +639,11 @@ void EnPametfrog_WallCrawl(EnPametfrog* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 15.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_BOMCHU_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_WALK); } if (((globalCtx->gameplayFrames % 60) == 0) && (Rand_ZeroOne() < 0.8f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_REAL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_REAL); } if ((this->timer == 0) || @@ -671,7 +671,7 @@ void EnPametfrog_SetupWallPause(EnPametfrog* this) { this->wallRotation = (Rand_ZeroOne() < 0.5f ? -1 : 1) * (0x1000 + randFloat) * (M_PI / (15 * 0x8000)); } this->timer = 15; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_RUNAWAY2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_RUNAWAY2); this->actionFunc = EnPametfrog_WallPause; } @@ -689,7 +689,7 @@ void EnPametfrog_WallPause(EnPametfrog* this, GlobalContext* globalCtx) { Math3D_CrossProduct(&this->unk_2DC, &this->unk_2D0, &this->unk_2E8); func_8086A238(this); if (((globalCtx->gameplayFrames % 60) == 0) && (Rand_ZeroOne() < 0.8f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_REAL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_REAL); } if (this->timer == 0) { @@ -768,7 +768,7 @@ void EnPametfrog_SetupJumpOnSnapper(EnPametfrog* this) { this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->actor.child); this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.params = GEKKO_JUMP_ON_SNAPPER; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_GREET); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_GREET); this->actionFunc = EnPametfrog_JumpOnSnapper; } @@ -819,12 +819,12 @@ void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_ON; this->timer = 10; if (this->actor.colChkInfo.health == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DEAD); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DAMAGE); } - func_800BCB70(&this->actor, 0x4000, 255, 0, 16); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); this->actor.world.pos.x += 30.0f * Math_SinS(yaw); this->actor.world.pos.z += 30.0f * Math_CosS(yaw); @@ -878,7 +878,7 @@ void EnPametfrog_SetupFallOnGround(EnPametfrog* this, GlobalContext* globalCtx) this->timer = 5; EnPametfrog_Thaw(this, globalCtx); EnPametfrog_JumpWaterEffects(this, globalCtx); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_WALK_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALK_WATER); this->actionFunc = EnPametfrog_FallOnGround; } @@ -965,7 +965,7 @@ void EnPametfrog_SetupSpawnFrog(EnPametfrog* this, GlobalContext* globalCtx) { this->collider.base.ocFlags1 &= ~OC1_ON; func_800B0DE0(globalCtx, &vec1, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 800, 50); Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_NPC_APPEAR); - Actor_SetRoomClearedTemp(globalCtx, globalCtx->roomCtx.currRoom.num); + Flags_SetClearTemp(globalCtx, globalCtx->roomCtx.currRoom.num); for (i = 0; i < 25; i++) { vel.x = randPlusMinusPoint5Scaled(5.0f); @@ -1063,7 +1063,7 @@ void EnPametfrog_JumpToLink(EnPametfrog* this, GlobalContext* globalCtx) { } if ((this->collider.base.ocFlags1 & OC1_HIT) && (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) && - Actor_IsActorFacingLink(&this->actor, 0x3000) && + Actor_IsFacingPlayer(&this->actor, 0x3000) && (this->skelAnime.curFrame <= 2.0f || this->skelAnime.curFrame >= 11.0f)) { EnPametfrog_SetupMeleeAttack(this); } @@ -1102,9 +1102,9 @@ void EnPametfrog_MeleeAttack(EnPametfrog* this, GlobalContext* globalCtx) { ((this->skelAnime.animation == &gGekkoWindupPunchAnim) && Animation_OnFrame(&this->skelAnime, 27.0f))) { this->collider.base.atFlags |= AT_ON; if (this->skelAnime.animation == &gGekkoKickAnim) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_KICK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_KICK); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_PUNCH1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_PUNCH1); } } else { this->collider.base.atFlags &= ~AT_ON; @@ -1117,8 +1117,8 @@ void EnPametfrog_SetupDamage(EnPametfrog* this) { this->collider.base.atFlags &= ~AT_ON; this->collider.base.acFlags &= ~AC_ON; this->actor.speedXZ = 10.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_DAMAGE); - func_800BCB70(&this->actor, 0x4000, 255, 0, 20); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DAMAGE); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); func_800BE5CC(&this->actor, &this->collider, 0); this->actor.shape.rot.y = BINANG_ROT180(this->actor.world.rot.y); this->actionFunc = EnPametfrog_Damage; @@ -1171,7 +1171,7 @@ void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { s16 yawDiff; Animation_MorphToPlayOnce(&this->skelAnime, &gGekkoCallAnim, 3.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_FROG_GREET); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_GREET); this->actor.flags &= ~1; this->actor.colChkInfo.health = 6; this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); @@ -1281,7 +1281,7 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_ICE) { EnPametfrog_Freeze(this); this->freezeTimer = 80; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 0x50); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0x50); EnPametfrog_SetupStun(this); } else { EnPametfrog_Thaw(this, globalCtx); @@ -1336,11 +1336,11 @@ void EnPametfrog_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if ((this->actionFunc != EnPametfrog_JumpOnSnapper) && (this->actionFunc != EnPametfrog_RearOnSnapperRise)) { if (this->actor.gravity < -0.1f) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); arg3 = this->actionFunc == EnPametfrog_FallInAir ? 3.0f : 15.0f; Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, arg3, 3.0f, 0x1F); } else if (this->freezeTimer == 0) { - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); this->actor.floorHeight = this->actor.world.pos.y; } } diff --git a/src/overlays/actors/ovl_En_Part/z_en_part.h b/src/overlays/actors/ovl_En_Part/z_en_part.h index be5c5b503a..fa3dd410f1 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.h +++ b/src/overlays/actors/ovl_En_Part/z_en_part.h @@ -7,7 +7,8 @@ struct EnPart; typedef struct EnPart { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x10]; + /* 0x144 */ char unk_144[0xC]; + /* 0x150 */ Gfx* unk_150; } EnPart; // size = 0x154 extern const ActorInit En_Part_InitVars; diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index 5f51217bb8..11a15bdc2b 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -5,6 +5,8 @@ */ #include "z_en_peehat.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/object_ph/object_ph.h" #define FLAGS 0x00000015 @@ -15,7 +17,26 @@ void EnPeehat_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx); void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80897498(EnPeehat* this); +void func_80897520(EnPeehat* this, GlobalContext* globalCtx); +void func_80897648(EnPeehat* this); +void func_808976DC(EnPeehat* this, GlobalContext* globalCtx); +void func_80897910(EnPeehat* this, GlobalContext* globalCtx); +void func_80897A34(EnPeehat* this); +void func_80897A94(EnPeehat* this, GlobalContext* globalCtx); +void func_80897D48(EnPeehat* this, GlobalContext* globalCtx); +void func_80897EAC(EnPeehat* this); +void func_80897F44(EnPeehat* this, GlobalContext* globalCtx); +void func_80898124(EnPeehat* this); +void func_80898144(EnPeehat* this, GlobalContext* globalCtx); +void func_808982E0(EnPeehat* this); +void func_80898338(EnPeehat* this, GlobalContext* globalCtx); +void func_80898454(EnPeehat* this, GlobalContext* globalCtx); +void func_808984E0(EnPeehat* this); +void func_80898594(EnPeehat* this, GlobalContext* globalCtx); +void func_80898654(EnPeehat* this); +void func_808986A4(EnPeehat* this, GlobalContext* globalCtx); + const ActorInit En_Peehat_InitVars = { ACTOR_EN_PEEHAT, ACTORCAT_ENEMY, @@ -28,40 +49,85 @@ const ActorInit En_Peehat_InitVars = { (ActorFunc)EnPeehat_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80899430 = { - { COLTYPE_WOOD, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_WOOD, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 50, 120, -20, { 0, 0, 0 } }, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_8089945C = { - { COLTYPE_HIT6, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 40 }, 100 }, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_80899488[2] = { +static ColliderTrisElementInit sTrisElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80899500 = { - { COLTYPE_METAL, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_TRIS, }, - 2, D_80899488, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_METAL, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_80899510 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -96,98 +162,787 @@ static DamageTable D_80899510 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80899530 = { 15, 50, 120, -20, MASS_HEAVY }; +static CollisionCheckInfoInit2 sColChkInfoInit1 = { 15, 50, 120, -20, MASS_HEAVY }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_8089953C = { 1, 20, 15, -5, 30 }; +static CollisionCheckInfoInit2 sColChkInfoInit2 = { 1, 20, 15, -5, 30 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80899548[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1800, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 700, ICHAIN_STOP), }; -#endif +void EnPeehat_Init(Actor* thisx, GlobalContext* globalCtx) { + EnPeehat* this = THIS; -extern ColliderCylinderInit D_80899430; -extern ColliderSphereInit D_8089945C; -extern ColliderTrisElementInit D_80899488[2]; -extern ColliderTrisInit D_80899500; -extern DamageTable D_80899510; -extern CollisionCheckInfoInit2 D_80899530; -extern CollisionCheckInfoInit2 D_8089953C; -extern InitChainEntry D_80899548[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_ph_Skel_001C80, &object_ph_Anim_0009C4, this->jointTable, + this->morphTable, 24); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 27.0f); + this->unk_2B0 = 0; + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); + this->actor.floorHeight = this->actor.world.pos.y; + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + Collider_InitAndSetSphere(globalCtx, &this->colliderSphere, &this->actor, &sSphereInit); + Collider_InitAndSetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTriElements); -extern UNK_TYPE D_06000350; -extern UNK_TYPE D_060005C4; -extern UNK_TYPE D_06000844; -extern UNK_TYPE D_060009C4; + if (this->actor.params == 0) { + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit1); + if (gSaveContext.isNight) { + this->actor.shape.yOffset = -1000.0f; + } + Actor_SetScale(&this->actor, 0.036f); + this->actor.hintId = 0x48; + func_80897498(this); + } else { + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); + this->actor.scale.z = this->actor.scale.x = 0.006f; + this->actor.scale.y = 0.003f; + this->actor.velocity.y = 6.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/EnPeehat_Init.s") + this->colliderCylinder.dim.radius = 20; + this->colliderCylinder.dim.height = 15; + this->colliderCylinder.dim.yShift = -5; + this->actor.hintId = 0x49; + this->colliderCylinder.base.ocFlags1 &= ~OC1_ON; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/EnPeehat_Destroy.s") + func_80897A34(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897170.s") +void EnPeehat_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPeehat* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_808971DC.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroySphere(globalCtx, &this->colliderSphere); + Collider_DestroyTris(globalCtx, &this->colliderTris); + if (this->actor.params != 0) { + EnPeehat* parent = (EnPeehat*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897258.s") + if ((parent != NULL) && (parent->actor.update != NULL)) { + parent->unk_2AC--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897390.s") +void func_80897170(EnPeehat* this) { + this->unk_2AE = 10; + this->unk_2CC = 1.1f; + this->unk_2D0 = 1.6500001f; + this->unk_2C8 = 1.0f; + this->colliderSphere.base.colType = COLTYPE_HIT3; + this->unk_2B0 = 80; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897498.s") +void func_808971DC(EnPeehat* this, GlobalContext* globalCtx) { + if (this->unk_2AE == 10) { + this->unk_2AE = 0; + this->colliderSphere.base.colType = COLTYPE_HIT6; + this->unk_2C8 = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2EC, ARRAY_COUNT(this->unk_2EC), 2, 0.5f, 0.35f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897520.s") +void func_80897258(GlobalContext* globalCtx, EnPeehat* this, Vec3f* arg2, f32 arg3, f32 arg4) { + static Vec3f D_80899558 = { 0.0f, 8.0f, 0.0f }; + static Vec3f D_80899564 = { 0.0f, -1.5f, 0.0f }; + Vec3f sp44; + s16 sp42 = Rand_Next() >> 0x10; + s32 temp_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897648.s") + sp44.y = this->actor.floorHeight; + sp44.x = (Math_SinS(sp42) * arg3) + arg2->x; + sp44.z = (Math_CosS(sp42) * arg3) + arg2->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_808976DC.s") + D_80899564.x = randPlusMinusPoint5Scaled(1.05f); + D_80899564.z = randPlusMinusPoint5Scaled(1.05f); + D_80899558.y = randPlusMinusPoint5Scaled(4.0f) + 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897864.s") + EffectSsHahen_Spawn(globalCtx, &sp44, &D_80899558, &D_80899564, 0, (Rand_ZeroFloat(5.0f) + 12.0f) * arg4, -1, 10, + NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897910.s") +void func_80897390(EnPeehat* this, GlobalContext* globalCtx) { + s32 i; + s16 phi_s2 = BINANG_ROT180(this->actor.yawTowardsPlayer); + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897A34.s") + this->colliderCylinder.base.acFlags &= ~AC_HIT; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897A94.s") + for (i = 3 - this->unk_2AC; i > 0; i--) { + actor = + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PEEHAT, this->actor.world.pos.x, + this->actor.world.pos.y + 50.0f, this->actor.world.pos.z, 0, phi_s2, 0, 1); + phi_s2 += 0x5555; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897D00.s") + if (actor != NULL) { + this->unk_2AC++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897D48.s") + this->unk_2B0 = 8; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIHAT_DAMAGE); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897EAC.s") +void func_80897498(EnPeehat* this) { + Animation_Change(&this->skelAnime, &object_ph_Anim_0009C4, 0.0f, 3.0f, + Animation_GetLastFrame(&object_ph_Anim_0009C4), 2, 0.0f); + this->unk_2B0 = 0; + this->unk_2AD = 1; + this->colliderCylinder.base.acFlags &= ~AC_HIT; + this->actionFunc = func_80897520; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80897F44.s") +void func_80897520(EnPeehat* this, GlobalContext* globalCtx) { + if (!gSaveContext.isNight) { + this->actor.flags |= 1; + this->colliderSphere.base.acFlags |= AC_ON; + if (this->actor.xzDistToPlayer < 740.0f) { + func_80897648(this); + } else { + Math_StepToF(&this->actor.shape.yOffset, -1000.0f, 10.0f); + } + } else { + this->actor.flags &= ~1; + this->colliderSphere.base.acFlags &= ~AC_ON; + Math_StepToF(&this->actor.shape.yOffset, -1000.0f, 50.0f); + if (this->unk_2B0 != 0) { + this->unk_2B0--; + if (this->unk_2B0 & 4) { + Math_StepToF(&this->unk_2C4, 0.205f, 0.235f); + } else { + Math_StepToF(&this->unk_2C4, 0.0f, 0.005f); + } + } else if (this->colliderCylinder.base.acFlags & AC_HIT) { + func_80897390(this, globalCtx); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898124.s") +void func_80897648(EnPeehat* this) { + if (this->actionFunc != func_80898454) { + Animation_Change(&this->skelAnime, &object_ph_Anim_0009C4, 0.0f, 3.0f, + Animation_GetLastFrame(&object_ph_Anim_0009C4), 2, 0.0f); + } + this->unk_2B0 = 16; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIHAT_UP); + this->actionFunc = func_808976DC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898144.s") +void func_808976DC(EnPeehat* this, GlobalContext* globalCtx) { + Vec3f sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_808982E0.s") + Math_StepToF(&this->actor.shape.yOffset, 0.0f, 50.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898338.s") + if (Math_ScaledStepToS(&this->unk_2B2, 4000, 800)) { + if (this->unk_2B0 != 0) { + this->unk_2B0--; + if ((this->unk_2B0 == 0) && (this->skelAnime.playSpeed < 0.5f)) { + this->unk_2B0 = -1; + this->skelAnime.playSpeed = 1.0f; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898414.s") + if (SkelAnime_Update(&this->skelAnime) || (this->unk_2B0 == 0)) { + func_80897EAC(this); + } else { + this->actor.world.pos.y += 6.5f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898454.s") + if ((this->actor.world.pos.y - this->actor.floorHeight) < 80.0f) { + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp34.y = this->actor.floorHeight; + func_800BBFB0(globalCtx, &sp34, 90.0f, 1, 150, 100, 1); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_808984E0.s") + func_80897258(globalCtx, this, &this->actor.world.pos, 75.0f, 2.0f); + Math_StepToF(&this->unk_2C4, 0.075f, 0.005f); + this->unk_2B4 += this->unk_2B2; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898594.s") +void func_80897864(EnPeehat* this) { + Animation_PlayLoop(&this->skelAnime, &object_ph_Anim_0005C4); + this->unk_2B8 = 0.0f; + if (this->actionFunc == func_80898338) { + this->unk_2AD = -this->unk_2AD; + } else { + this->unk_2AD = (Rand_ZeroOne() < 0.5f) ? 1 : -1; + } + this->colliderTris.base.atFlags |= AT_ON; + this->actionFunc = func_80897910; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898654.s") +void func_80897910(EnPeehat* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_808986A4.s") + Math_StepToF(&this->actor.speedXZ, 3.0f, 0.25f); + Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 80.0f, 3.0f); + SkelAnime_Update(&this->skelAnime); + if (!gSaveContext.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { + Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1000); + this->actor.shape.rot.y += (s16)(this->unk_2AD * 450); + } else { + func_80898124(this); + } + Math_ScaledStepToS(&this->unk_2B2, 4000, 500); + this->unk_2B4 += this->unk_2B2; + Math_StepToF(&this->unk_2C4, 0.075f, 0.005f); + func_800B9010(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_8089874C.s") +void func_80897A34(EnPeehat* this) { + Animation_PlayLoop(&this->skelAnime, &object_ph_Anim_0005C4); + this->unk_2B0 = 30; + this->actor.speedXZ = 5.3f; + this->colliderTris.base.atFlags |= AT_ON; + this->actionFunc = func_80897A94; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/EnPeehat_Update.s") +void func_80897A94(EnPeehat* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80898E74.s") + if ((this->actor.parent != NULL) && (this->actor.parent->update == NULL)) { + this->actor.parent = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/func_80899024.s") + if ((this->actor.world.pos.y - this->actor.floorHeight) >= 70.0f) { + Math_StepToF(&this->actor.velocity.y, -1.3f, 0.5f); + } else { + Math_StepToF(&this->actor.velocity.y, -0.135f, 0.05f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Peehat/EnPeehat_Draw.s") + if (this->unk_2B0 > 0) { + this->unk_2B0--; + } else { + Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x33E); + this->colliderCylinder.base.ocFlags1 |= OC1_ON; + } + + this->actor.shape.rot.y += 0x15E; + SkelAnime_Update(&this->skelAnime); + Math_ScaledStepToS(&this->unk_2B2, 4000, 500); + this->unk_2B4 += this->unk_2B2; + Math_StepToF(&this->unk_2C4, 0.075f, 0.005f); + func_800B9010(&this->actor, NA_SE_EN_PIHAT_SM_FLY - SFX_FLAG); + + if (this->colliderTris.base.atFlags & AT_BOUNCED) { + this->colliderTris.base.atFlags &= ~(AT_BOUNCED | AT_ON); + this->actor.colChkInfo.health = 0; + func_808982E0(this); + } else if ((this->colliderCylinder.base.acFlags & AC_HIT) || (this->actor.bgCheckFlags & 1)) { + func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 40, 7, 0); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + if (!(this->actor.bgCheckFlags & 1)) { + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_PIHAT_SM_DEAD); + } + Actor_MarkForDeath(&this->actor); + } else if (this->colliderTris.base.atFlags & AT_HIT) { + this->colliderTris.base.atFlags &= ~AT_HIT; + if (BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.world.rot.y) > 0) { + this->actor.world.rot.y -= 0x2000; + } else { + this->actor.world.rot.y += 0x2000; + } + this->unk_2B0 = 40; + } else if (this->colliderCylinder.base.ocFlags1 & OC1_HIT) { + this->colliderCylinder.base.ocFlags1 &= ~OC1_HIT; + if ((BINANG_SUB(Actor_YawBetweenActors(&this->actor, this->colliderCylinder.base.oc), + this->actor.world.rot.y)) > 0) { + this->actor.world.rot.y -= 0x2000; + } else { + this->actor.world.rot.y += 0x2000; + } + this->unk_2B0 = 10; + } +} + +void func_80897D00(EnPeehat* this) { + Animation_PlayOnce(&this->skelAnime, &object_ph_Anim_000350); + this->colliderTris.base.atFlags &= ~AT_ON; + this->actionFunc = func_80897D48; +} + +void func_80897D48(EnPeehat* this, GlobalContext* globalCtx) { + Vec3f sp34; + + Math_StepToF(&this->actor.shape.yOffset, -1000.0f, 50.0f); + Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); + Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 50); + if (SkelAnime_Update(&this->skelAnime)) { + func_80897498(this); + this->actor.world.pos.y = this->actor.floorHeight; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIHAT_LAND); + } else if (this->actor.floorHeight < this->actor.world.pos.y) { + Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.floorHeight, 0.3f, 3.5f, 0.25f); + if ((this->actor.world.pos.y - this->actor.floorHeight) < 60.0f) { + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp34.y = this->actor.floorHeight; + func_800BBFB0(globalCtx, &sp34, 80.0f, 1, 150, 100, 1); + func_80897258(globalCtx, this, &sp34, 75.0f, 2.0f); + } + } + Math_ScaledStepToS(&this->unk_2B2, 0, 100); + this->unk_2B4 += this->unk_2B2; +} + +void func_80897EAC(EnPeehat* this) { + Animation_PlayLoop(&this->skelAnime, &object_ph_Anim_0005C4); + this->actor.speedXZ = Rand_ZeroFloat(0.5f) + 2.5f; + this->unk_2B0 = Rand_ZeroFloat(10.0f) + 10.0f; + this->colliderTris.base.atFlags |= AT_ON; + this->colliderSphere.base.acFlags |= AC_ON; + this->actionFunc = func_80897F44; +} + +void func_80897F44(EnPeehat* this, GlobalContext* globalCtx) { + s32 pad; + f32 cos; + Player* player = GET_PLAYER(globalCtx); + + if ((this->actor.world.pos.y - this->actor.floorHeight) > 75.0f) { + this->actor.world.pos.y -= 1.0f; + } + + cos = cos_rad(this->unk_2B8); + this->actor.world.pos.y += cos * 1.4f; + this->unk_2B8 += fabsf(cos * 0.18f) + 0.07f; + this->unk_2B0--; + + if (this->unk_2B0 <= 0) { + this->actor.speedXZ = Rand_ZeroFloat(0.5f) + 2.5f; + this->unk_2B0 = Rand_ZeroFloat(10.0f) + 10.0f; + this->unk_2B6 = randPlusMinusPoint5Scaled(1000.0f); + } + + SkelAnime_Update(&this->skelAnime); + this->actor.world.rot.y += this->unk_2B6; + this->actor.shape.rot.y += 0x15E; + + if (!gSaveContext.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + func_80897864(this); + } else { + func_80898124(this); + } + + Math_ScaledStepToS(&this->unk_2B2, 4000, 500); + this->unk_2B4 += this->unk_2B2; + Math_StepToF(&this->unk_2C4, 0.075f, 0.005f); + func_800B9010(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); +} + +void func_80898124(EnPeehat* this) { + this->actionFunc = func_80898144; + this->actor.speedXZ = 2.5f; +} + +void func_80898144(EnPeehat* this, GlobalContext* globalCtx) { + s32 step; + f32 cos; + Player* player = GET_PLAYER(globalCtx); + + if ((this->actor.world.pos.y - this->actor.floorHeight) > 75.0f) { + this->actor.world.pos.y -= 1.0f; + } else { + this->actor.world.pos.y += 1.0f; + } + cos = cos_rad(this->unk_2B8); + this->actor.world.pos.y += cos * 1.4f; + + cos = cos_rad(this->unk_2B8); + this->unk_2B8 += fabsf(cos * 0.18f) + 0.07f; + + step = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); + Math_ScaledStepToS(&this->actor.world.rot.y, step, 0x258); + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x1194, 0x258); + + this->actor.shape.rot.y += 0x15E; + this->unk_2B4 += this->unk_2B2; + + if (Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) < 2.0f) { + func_80897D00(this); + } + + if (!gSaveContext.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { + func_80897864(this); + } + func_800B9010(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); +} + +void func_808982E0(EnPeehat* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_ph_Anim_000844, -4.0f); + this->actor.speedXZ = -9.0f; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actionFunc = func_80898338; +} + +void func_80898338(EnPeehat* this, GlobalContext* globalCtx) { + this->unk_2B4 += this->unk_2B2; + SkelAnime_Update(&this->skelAnime); + + if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f)) { + if (this->actor.params != 0) { + func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 40, 7, 0); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_EXTINCT); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_PIHAT_SM_DEAD); + Actor_MarkForDeath(&this->actor); + } else { + func_80897864(this); + } + } + func_800B9010(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); +} + +void func_80898414(EnPeehat* this) { + func_800BE568(&this->actor, &this->colliderSphere); + this->unk_2B2 = 0; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80898454; +} + +void func_80898454(EnPeehat* this, GlobalContext* globalCtx) { + if (this->unk_2B0 != 0) { + this->unk_2B0--; + } + + Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight, 8.0f); + + if (this->unk_2B0 == 0) { + func_808971DC(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + func_808984E0(this); + } else { + func_80897648(this); + } + } +} + +void func_808984E0(EnPeehat* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_ph_Anim_000844, -4.0f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIHAT_DAMAGE); + this->unk_2B2 = 4000; + this->unk_2B0 = 14; + this->actor.speedXZ = 10.0f; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 14); + this->colliderSphere.base.acFlags &= ~AC_ON; + this->unk_2C4 = 0.0f; + if (this->actor.colChkInfo.health == 0) { + this->actor.velocity.y = 6.0f; + } + this->actionFunc = func_80898594; +} + +void func_80898594(EnPeehat* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + this->unk_2B4 += this->unk_2B2; + Math_ScaledStepToS(&this->unk_2B2, 4000, 250); + Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 88.5f, 3.0f); + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + this->unk_2B0--; + if (this->unk_2B0 <= 0) { + if (this->actor.colChkInfo.health == 0) { + func_80898654(this); + } else { + func_80897EAC(this); + } + } +} + +void func_80898654(EnPeehat* this) { + Animation_PlayLoop(&this->skelAnime, &object_ph_Anim_0005C4); + this->unk_2B0 = 5; + this->unk_2B8 = 0.0f; + this->actionFunc = func_808986A4; +} + +void func_808986A4(EnPeehat* this, GlobalContext* globalCtx) { + if (this->unk_2B0 == 5) { + EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0x602, 0); + + if (bomb != NULL) { + bomb->timer = 0; + } + } + + this->unk_2B0--; + + if (this->unk_2B0 == 0) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xE0); + Actor_MarkForDeath(&this->actor); + } +} + +void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { + if (this->colliderTris.base.acFlags & AC_BOUNCED) { + this->colliderTris.base.acFlags &= ~AC_BOUNCED; + this->colliderSphere.base.acFlags &= ~AC_HIT; + return; + } + + if (this->colliderSphere.base.acFlags & AC_HIT) { + this->colliderSphere.base.acFlags &= ~AC_HIT; + if ((this->unk_2AE != 10) || !(this->colliderSphere.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if (!Actor_ApplyDamage(&this->actor)) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + this->colliderTris.base.atFlags &= ~(AT_HIT | AT_ON); + Actor_SetDropFlag(&this->actor, &this->colliderSphere.info); + func_808971DC(this, globalCtx); + + if (this->actor.colChkInfo.damageEffect == 5) { + this->unk_2B0 = 40; + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->unk_2CC = 1.1f; + this->unk_2C8 = 2.0f; + this->unk_2AE = 32; + func_80898414(this); + } else if (this->actor.colChkInfo.damageEffect == 1) { + this->unk_2B0 = 40; + Actor_SetColorFilter(&this->actor, 0, 200, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + func_80898414(this); + } else if (this->actor.colChkInfo.damageEffect == 3) { + func_80897170(this); + if (this->actor.colChkInfo.health == 0) { + this->unk_2B0 = 3; + this->colliderSphere.base.acFlags &= ~AC_ON; + } + func_80898414(this); + } else { + if (this->actor.colChkInfo.damageEffect == 2) { + this->unk_2C8 = 4.0f; + this->unk_2CC = 2.1f; + this->unk_2AE = 0; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_2C8 = 4.0f; + this->unk_2CC = 1.1f; + this->unk_2AE = 20; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->colliderSphere.info.bumper.hitPos.x, this->colliderSphere.info.bumper.hitPos.y, + this->colliderSphere.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + func_800BE568(&this->actor, &this->colliderSphere); + func_808984E0(this); + } + } + } else if ((this->unk_2AE == 10) && (this->colliderCylinder.base.acFlags & AC_HIT) && + ((this->unk_2AE != 10) || !(this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + func_808971DC(this, globalCtx); + this->actor.colorFilterTimer = 0; + func_80897648(this); + } +} + +void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnPeehat* this = THIS; + + if (thisx->params == 0) { + func_8089874C(this, globalCtx); + } + Actor_MoveWithGravity(thisx); + Actor_UpdateBgCheckInfo(globalCtx, thisx, 25.0f, 30.0f, 30.0f, 5); + + this->actionFunc(this, globalCtx); + + if ((globalCtx->gameplayFrames % 128) == 0) { + this->unk_2C0 = Rand_ZeroFloat(0.25f) + 0.5f; + } + + this->unk_2BC += this->unk_2C0; + if (thisx->params == 0) { + if (this->actionFunc == func_80897910) { + Math_ScaledStepToS(&thisx->shape.rot.x, 6000, 300); + } else { + Math_ScaledStepToS(&thisx->shape.rot.x, 0, 300); + } + } else { + Actor_SetFocus(thisx, 0.0f); + } + + Collider_UpdateCylinder(thisx, &this->colliderCylinder); + this->colliderCylinder.dim.pos.y += (s16)(thisx->shape.yOffset * thisx->scale.y); + if (this->colliderCylinder.base.ocFlags1 & OC1_ON) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + + if (thisx->params == 0) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + if (this->colliderSphere.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base); + } + } + + if (this->colliderTris.base.atFlags & AT_HIT) { + this->colliderTris.base.atFlags &= ~AT_HIT; + func_808982E0(this); + } + + if (this->colliderTris.base.atFlags & AT_ON) { + thisx->flags |= 0x1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + if (thisx->params == 0) { + Vec3f sp74; + CollisionPoly* sp70; + s32 sp6C; + s32 i; + + sp70 = NULL; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + + for (i = 1; i >= 0; i--) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &thisx->world.pos, &this->unk_2D4[i], &sp74, &sp70, 1, + 1, 0, 1, &sp6C)) { + func_800BBFB0(globalCtx, &sp74, 0.0f, 1, 300, 150, 1); + func_80897258(globalCtx, this, &sp74, 0.0f, 1.5f); + } + } + } + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + + if (this->actionFunc != func_80898454) { + Math_StepToF(&this->unk_2C4, 0.0f, 0.001f); + } + + if (this->unk_2C8 > 0.0f) { + if (this->unk_2AE != 10) { + Math_StepToF(&this->unk_2C8, 0.0f, 0.05f); + if (this->unk_2AE == 0) { + this->unk_2CC = (this->unk_2C8 + 1.0f) * 1.05f; + this->unk_2CC = CLAMP_MAX(this->unk_2CC, 2.1f); + } else { + this->unk_2CC = (this->unk_2C8 + 1.0f) * 0.55f; + this->unk_2CC = CLAMP_MAX(this->unk_2CC, 1.1f); + } + } else if (!Math_StepToF(&this->unk_2D0, 1.1f, 0.0275f)) { + func_800B9010(thisx, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +s32 EnPeehat_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnPeehat* this = THIS; + s32 pad; + + if (limbIndex == 4) { + rot->x = -this->unk_2B4; + } else if ((limbIndex == 3) || + ((limbIndex == 23) && ((this->actionFunc == func_80898594) || (this->actionFunc == func_80897520)))) { + OPEN_DISPS(globalCtx->state.gfxCtx); + Gfx* gfx = POLY_OPA_DISP; + + Matrix_StatePush(); + Matrix_RotateStateAroundXAxis(this->unk_2BC * 0.115f); + Matrix_InsertYRotation_f(this->unk_2BC * 0.13f, MTXMODE_APPLY); + Matrix_InsertZRotation_f(this->unk_2BC * 0.1f, MTXMODE_APPLY); + Matrix_Scale(1.0f - this->unk_2C4, this->unk_2C4 + 1.0f, 1.0f - this->unk_2C4, MTXMODE_APPLY); + Matrix_InsertZRotation_f(-(this->unk_2BC * 0.1f), MTXMODE_APPLY); + Matrix_InsertYRotation_f(-(this->unk_2BC * 0.13f), MTXMODE_APPLY); + Matrix_RotateStateAroundXAxis(-(this->unk_2BC * 0.115f)); + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], *dList); + + Matrix_StatePop(); + + POLY_OPA_DISP = &gfx[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + return true; + } + return false; +} + +void EnPeehat_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80899570[] = { + { 1300.0f, 1200.0f, 0.0f }, + { 1300.0f, -1200.0f, 0.0f }, + { 1300.0f, 0.0f, 1200.0f }, + { 1300.0f, 0.0f, -1200.0f }, + }; + static s8 D_808995A0[] = { + -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 2, -1, -1, 4, -1, -1, 6, -1, -1, 8, -1, -1, 10, -1, + }; + GlobalContext* globalCtx = globalCtx2; + EnPeehat* this = THIS; + s32 i; + s32 index = D_808995A0[limbIndex]; + Gfx* gfx; + + if (index != -1) { + Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_2EC[index]); + Matrix_GetStateTranslationAndScaledX(4000.0f, &this->unk_2EC[index + 1]); + } + + if (limbIndex == 4) { + Matrix_GetStateTranslationAndScaledZ(5500.0f, &this->unk_2D4[0]); + Matrix_GetStateTranslationAndScaledZ(-5500.0f, &this->unk_2D4[1]); + } else if ((limbIndex == 3) && (thisx->params == 0)) { + Vec3f* vec = &D_80899570[0]; + Vec3f* vec2 = &this->unk_2EC[12]; + + for (i = 0; i < ARRAY_COUNT(D_80899570); i++, vec++, vec2++) { + Matrix_MultiplyVector3fByState(vec, vec2); + } + + Matrix_GetStateTranslationAndScaledX(3000.0f, vec2++); + Matrix_GetStateTranslationAndScaledX(-400.0f, vec2); + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_OPA_DISP; + + Matrix_InsertTranslation(-1000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Collider_UpdateSphere(0, &this->colliderSphere); + Matrix_InsertTranslation(500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertYRotation_f(3.2f, MTXMODE_APPLY); + Matrix_Scale(0.3f, 0.2f, 0.2f, MTXMODE_APPLY); + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], *dList); + + POLY_OPA_DISP = &gfx[2]; + Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->colliderSphere.dim.worldSphere.center); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPeehat* this = THIS; + Vec3f sp58; + Vec3f sp4C; + Vec3f sp40; + s32 i; + + func_8012C28C(globalCtx->state.gfxCtx); + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnPeehat_OverrideLimbDraw, + (this->actor.params == 0) ? EnPeehat_PostLimbDraw : NULL, &this->actor); + + if ((this->actor.speedXZ != 0.0f) || (this->actor.velocity.y != 0.0f)) { + Matrix_GetStateTranslationAndScaledZ(4500.0f, &sp40); + Matrix_GetStateTranslationAndScaledZ(-4500.0f, &sp4C); + Matrix_GetStateTranslationAndScaledX(4500.0f, &sp58); + Collider_SetTrisVertices(&this->colliderTris, 0, &sp40, &sp4C, &sp58); + Matrix_GetStateTranslationAndScaledX(-4500.0f, &sp58); + Collider_SetTrisVertices(&this->colliderTris, 1, &sp40, &sp58, &sp4C); + } + + if (this->unk_2AE == 0) { + for (i = 0; i < ARRAY_COUNT(this->unk_2EC); i++) { + this->unk_2EC[i].y -= 50.0f; + } + } + + func_800BE680(globalCtx, &this->actor, this->unk_2EC, ARRAY_COUNT(this->unk_2EC), this->unk_2CC, this->unk_2D0, + this->unk_2C8, this->unk_2AE); +} diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h index c6303311a4..0aee3a7427 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h @@ -8,10 +8,31 @@ struct EnPeehat; typedef void (*EnPeehatActionFunc)(struct EnPeehat*, GlobalContext*); typedef struct EnPeehat { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x164]; - /* 0x02A8 */ EnPeehatActionFunc actionFunc; - /* 0x02AC */ char unk_2AC[0x294]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[24]; + /* 0x188 */ Vec3s morphTable[24]; + /* 0x2A8 */ EnPeehatActionFunc actionFunc; + /* 0x2AC */ u8 unk_2AC; + /* 0x2AD */ s8 unk_2AD; + /* 0x2AE */ u8 unk_2AE; + /* 0x2B0 */ s16 unk_2B0; + /* 0x2B2 */ s16 unk_2B2; + /* 0x2B4 */ s16 unk_2B4; + /* 0x2B6 */ s16 unk_2B6; + /* 0x2B8 */ f32 unk_2B8; + /* 0x2BC */ f32 unk_2BC; + /* 0x2C0 */ f32 unk_2C0; + /* 0x2C4 */ f32 unk_2C4; + /* 0x2C8 */ f32 unk_2C8; + /* 0x2CC */ f32 unk_2CC; + /* 0x2D0 */ f32 unk_2D0; + /* 0x2D4 */ Vec3f unk_2D4[2]; + /* 0x2EC */ Vec3f unk_2EC[18]; + /* 0x3C4 */ ColliderCylinder colliderCylinder; + /* 0x410 */ ColliderSphere colliderSphere; + /* 0x468 */ ColliderTris colliderTris; + /* 0x488 */ ColliderTrisElement colliderTriElements[2]; } EnPeehat; // size = 0x540 extern const ActorInit En_Peehat_InitVars; diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 5993ab3664..df73227a2b 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -315,7 +315,7 @@ Actor* func_80AF7CB0(EnPm* this, GlobalContext* globalCtx, u8 actorCat, s16 acto Actor* actor; while (true) { - actor = func_ActorCategoryIterateById(globalCtx, phi_s0, actorCat, actorId); + actor = SubS_FindActor(globalCtx, phi_s0, actorCat, actorId); phi_s0 = actor; if (actor == NULL) { @@ -338,7 +338,7 @@ Actor* func_80AF7CB0(EnPm* this, GlobalContext* globalCtx, u8 actorCat, s16 acto return phi_s0; } -Actor* func_80AF7D60(GlobalContext* globalCtx, s32 arg1) { +EnDoor* func_80AF7D60(GlobalContext* globalCtx, s32 arg1) { s32 phi_a1; switch (arg1) { @@ -367,7 +367,7 @@ Actor* func_80AF7D60(GlobalContext* globalCtx, s32 arg1) { return NULL; } - return func_8013A7C0(globalCtx, phi_a1); + return SubS_FindDoor(globalCtx, phi_a1); } Actor* func_80AF7DC4(EnPm* this, GlobalContext* globalCtx, s32 arg2) { @@ -375,7 +375,7 @@ Actor* func_80AF7DC4(EnPm* this, GlobalContext* globalCtx, s32 arg2) { Actor* actor; while (true) { - actor = func_ActorCategoryIterateById(globalCtx, phi_s0, ACTORCAT_PROP, ACTOR_EN_PST); + actor = SubS_FindActor(globalCtx, phi_s0, ACTORCAT_PROP, ACTOR_EN_PST); phi_s0 = actor; if (actor == NULL) { @@ -710,7 +710,7 @@ UNK_TYPE* func_80AF8540(EnPm* this, GlobalContext* globalCtx) { s32 func_80AF86F0(EnPm* this, GlobalContext* globalCtx) { s32 ret = false; - if ((this->unk_356 & 7) && func_800B84D0(&this->actor, globalCtx)) { + if ((this->unk_356 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_8013AED4(&this->unk_356, 0, 7); this->unk_398 = 0; this->unk_378 = 0; @@ -845,7 +845,7 @@ void func_80AF8BA8(s32 arg0) { void func_80AF8C68(EnPm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s32 sp28 = func_80152498(&globalCtx->msgCtx); + s32 sp28 = Message_GetState(&globalCtx->msgCtx); u16 temp_a0 = globalCtx->msgCtx.unk11F04; if ((player->targetActor == &this->actor) && ((temp_a0 < 255) || (temp_a0 > 512)) && (sp28 == 3) && @@ -942,7 +942,7 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { u16 sp56 = gSaveContext.time - 0x3FFC; u8 sp55 = this->actor.params & 0xFF; - Actor* sp50; + EnDoor* sp50; Vec3s* sp4C; Vec3f sp40; Vec3f sp34; @@ -955,7 +955,7 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = func_8013BB34(globalCtx, sp55, D_80AFB430[arg2->unk0]); } - if ((sp50 != NULL) && (sp50->update != NULL)) { + if ((sp50 != NULL) && (sp50->actor.update != NULL)) { if (this->unk_234 != 0) { sp4C = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); @@ -964,7 +964,7 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->unk_278, &sp34); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); - temp = this->actor.world.rot.y - sp50->shape.rot.y; + temp = this->actor.world.rot.y - sp50->actor.shape.rot.y; if (ABS_ALT(temp) <= 0x4000) { this->unk_260 = -0x4B; } else { @@ -1024,8 +1024,8 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_356 &= ~8; this->unk_356 &= ~0x10; if (this->unk_258 == 27) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROOM_CARTAIN); - Actor_UnsetSwitchFlag(globalCtx, 0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROOM_CARTAIN); + Flags_UnsetSwitch(globalCtx, 0); } switch (arg2->unk0) { @@ -1089,8 +1089,8 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &sp40); Math_Vec3f_Copy(&this->actor.prevPos, &sp40); if (arg2->unk0 == 24) { - Actor_UnsetSwitchFlag(globalCtx, 0); - Actor_UnsetSwitchFlag(globalCtx, 1); + Flags_UnsetSwitch(globalCtx, 0); + Flags_UnsetSwitch(globalCtx, 1); this->unk_394 = 0; this->unk_368 = 60.0f; func_80AF7E98(this, 9); @@ -1144,8 +1144,8 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar switch (arg2->unk0) { case 27: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ROOM_CARTAIN); - Actor_SetSwitchFlag(globalCtx, 0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROOM_CARTAIN); + Flags_SetSwitch(globalCtx, 0); this->unk_36C = 20; func_8013AED4(&this->unk_356, 3, 7); func_80AF7E98(this, 3); @@ -1409,7 +1409,7 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { - EnDoor* sp44 = (EnDoor*)func_80AF7D60(globalCtx, this->unk_258); + EnDoor* sp44 = func_80AF7D60(globalCtx, this->unk_258); Vec3f sp38; Vec3f* sp28; f32 temp; @@ -1430,7 +1430,7 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { Lib_Vec3f_TranslateAndRotateY(&this->unk_26C, this->actor.world.rot.y, &sp38, &this->actor.world.pos); this->unk_36E += this->unk_374; if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_POSTMAN_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); } } return false; @@ -1485,7 +1485,7 @@ s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { this->unk_238 = sp58; } else if ((this->unk_258 != 91) && (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_POSTMAN_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); } if ((this->unk_356 & 0x10) && (this->unk_258 == 90)) { @@ -1533,7 +1533,7 @@ s32 func_80AFA170(EnPm* this, GlobalContext* globalCtx) { } if ((this->unk_384 == 11) && Animation_OnFrame(&this->skelAnime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_POSTMACHINE_HIT_OPEN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMACHINE_HIT_OPEN); } if (this->unk_258 == 19) { @@ -1569,7 +1569,7 @@ s32 func_80AFA334(EnPm* this, GlobalContext* globalCtx) { case 27: if (DECR(this->unk_36C) == 0) { - Actor_SetSwitchFlag(globalCtx, 1); + Flags_SetSwitch(globalCtx, 1); } break; @@ -1578,7 +1578,7 @@ s32 func_80AFA334(EnPm* this, GlobalContext* globalCtx) { case 21: case 22: if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_VO_NP_SLEEP_OUT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_NP_SLEEP_OUT); } break; @@ -1714,7 +1714,7 @@ void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { this->actor.flags &= ~1; sp2C.unk0 = 0; } else { - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= 1; } @@ -1755,10 +1755,10 @@ void func_80AFA5FC(EnPm* this, GlobalContext* globalCtx) { } void func_80AFA724(EnPm* this, GlobalContext* globalCtx) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_POSTMAN_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); } } @@ -1802,7 +1802,7 @@ void EnPm_Update(Actor* thisx, GlobalContext* globalCtx) { func_80AF7E6C(this); func_80AF8AC8(this); func_8013C964(&this->actor, globalCtx, this->unk_368, 30.0f, this->unk_394, this->unk_356 & 7); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); func_80AF7F68(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c index c578e3d378..fe96f5a37f 100644 --- a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c +++ b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c @@ -112,7 +112,7 @@ void EnPoFusen_Init(Actor* thisx, GlobalContext* globalCtx) { if (0) {} this->collider.dim.worldSphere.radius = 40; SkelAnime_InitFlex(globalCtx, &this->anime, &D_060024F0, &D_06000040, this->jointTable, this->morphTable, 10); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); if (EnPoFusen_CheckParent(this, globalCtx) == 0) { @@ -150,7 +150,7 @@ void EnPoFusen_Destroy(Actor* thisx, GlobalContext* globalCtx) { u16 EnPoFusen_CheckParent(EnPoFusen* this, GlobalContext* globalCtx) { struct Actor* actorPtr; - actorPtr = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + actorPtr = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; if (GET_IS_FUSE_TYPE_PARAM(this)) { return 1; } @@ -243,7 +243,7 @@ void EnPoFusen_IncrementRomaniPop(EnPoFusen* this) { void EnPoFusen_Pop(EnPoFusen* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y + 20.0f, this->actor.world.pos.z, 255, 255, 200, CLEAR_TAG_POP); - Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index 6f267771b3..a2e299290f 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -158,7 +158,7 @@ void EnPoSisters_Init(Actor* thisx, GlobalContext* globalCtx) { EnPoSisters* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 50.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &D_060065C8, &D_060014CC, this->jointTable, this->morphTable, 12); this->unk_226 = 255; this->unk_227 = 255; @@ -303,7 +303,7 @@ void func_80B1AAE8(EnPoSisters* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (DECR(this->unk_192) == 0) { this->unk_192 = Rand_S16Offset(100, 50); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); } } @@ -407,7 +407,7 @@ void func_80B1B020(EnPoSisters* this, GlobalContext* globalCtx) { this->actor.shape.rot.y += ((s32)((this->skelAnime.endFrame + 1.0f) * 3.0f) - this->unk_192) * 0x180; if ((this->unk_192 == 18) || (this->unk_192 == 7)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); } else if (this->unk_192 == 0) { func_80B1B0E0(this); } @@ -445,13 +445,13 @@ void func_80B1B168(EnPoSisters* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_HARD; func_80B1AC40(this); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); func_80B1BE4C(this, globalCtx); } } } if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); } } @@ -473,7 +473,7 @@ void func_80B1B2F0(EnPoSisters* this, GlobalContext* globalCtx) { if (this->unk_18C != 0) { func_80B1AC40(this); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); func_80B1BE4C(this, globalCtx); } } @@ -490,7 +490,7 @@ void func_80B1B3A8(EnPoSisters* this) { } this->unk_191 &= ~(0x8 | 0x2 | 0x1); - func_800BCB70(&this->actor, 0x4000, 255, 0, 16); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); this->actionFunc = func_80B1B444; } @@ -557,8 +557,8 @@ void func_80B1B70C(EnPoSisters* this) { this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->unk_191 &= ~(0x4 | 0x1); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DISAPPEAR); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DISAPPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); this->actionFunc = func_80B1B7BC; } @@ -588,7 +588,7 @@ void func_80B1B860(EnPoSisters* this, GlobalContext* globalCtx) { this->unk_192 = 15; this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); this->unk_191 &= ~0x1; this->actionFunc = func_80B1B940; } @@ -666,7 +666,7 @@ void func_80B1BA90(EnPoSisters* this, GlobalContext* globalCtx) { } if (this->unk_192 == 16) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); } } @@ -826,7 +826,7 @@ void func_80B1C0A4(EnPoSisters* this, GlobalContext* globalCtx) { void func_80B1C2E8(EnPoSisters* this) { Animation_PlayOnce(&this->skelAnime, &D_0600119C); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); this->unk_229 = 0; this->unk_191 = 0x20; this->actionFunc = func_80B1C340; @@ -855,11 +855,11 @@ void func_80B1C408(EnPoSisters* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - func_800BE258(&this->actor, &this->collider.info); + Actor_SetDropFlag(&this->actor, &this->collider.info); if (this->unk_18D != 0) { ((EnPoSisters*)this->actor.parent)->unk_194--; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); func_80B1BE4C(this, globalCtx); if (Rand_ZeroOne() < 0.2f) { sp3C.x = this->actor.world.pos.x; @@ -879,10 +879,10 @@ void func_80B1C408(EnPoSisters* this, GlobalContext* globalCtx) { } } else { if (Actor_ApplyDamage(&this->actor)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DAMAGE); } else { Enemy_StartFinishingBlow(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_SISTER_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_SISTER_DEAD); } if (this->actor.colChkInfo.damageEffect == 4) { @@ -921,7 +921,7 @@ void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { func_80B1A894(this, globalCtx); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (this->unk_191 & 0x10) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 0.0f, 5); @@ -934,7 +934,7 @@ void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { } this->actor.shape.shadowAlpha = this->unk_229; - Actor_SetHeight(&this->actor, 40.0f); + Actor_SetFocus(&this->actor, 40.0f); if (this->unk_2F0 > 0.0f) { Math_StepToF(&this->unk_2F0, 0.0f, 0.05f); diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index f9dc6ddf44..aedd9efc18 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -162,7 +162,7 @@ void EnPoh_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 30.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); Collider_InitAndSetJntSph(globalCtx, &this->colliderSph, &this->actor, &sJntSphInit, this->colliderSphElements); this->colliderSph.elements[0].dim.worldSphere.radius = 0; this->colliderSph.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; @@ -312,7 +312,7 @@ void func_80B2CD64(EnPoh* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer > 280.0f) { func_80B2CB60(this); } else if ((this->unk_18E == 0) && (this->actor.xzDistToPlayer < 140.0f) && - !Actor_IsLinkFacingActor(&this->actor, 0x2AAA, globalCtx)) { + !Player_IsFacingActor(&this->actor, 0x2AAA, globalCtx)) { func_80B2CEC8(this); } @@ -325,14 +325,14 @@ void func_80B2CEC8(EnPoh* this) { Animation_MorphToLoop(&this->skelAnime, &D_060001A8, -6.0f); this->unk_18E = 12; this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); this->actionFunc = func_80B2CF28; } void func_80B2CF28(EnPoh* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_KANTERA); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_KANTERA); if (this->unk_18E != 0) { this->unk_18E--; } @@ -355,7 +355,7 @@ void func_80B2CFF8(EnPoh* this) { func_800BE504(&this->actor, &this->colliderCylinder); this->colliderCylinder.base.acFlags &= ~AC_ON; this->actor.speedXZ = 5.0f; - func_800BCB70(&this->actor, 0x4000, 255, 0, 16); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); this->actionFunc = func_80B2D07C; } @@ -388,7 +388,7 @@ void func_80B2D140(EnPoh* this, GlobalContext* globalCtx) { } if ((this->skelAnime.playSpeed < 0.5f) && (this->actor.xzDistToPlayer < 280.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); this->skelAnime.playSpeed = 1.0f; } } @@ -447,7 +447,7 @@ void func_80B2D300(EnPoh* this, GlobalContext* globalCtx) { } if (this->unk_18E == 18) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); } } @@ -493,8 +493,8 @@ void func_80B2D76C(EnPoh* this) { this->unk_192 = 0x2000; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DISAPPEAR); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DISAPPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); this->colliderCylinder.base.acFlags &= ~AC_ON; this->actionFunc = func_80B2D7D4; } @@ -523,8 +523,8 @@ void func_80B2D924(EnPoh* this) { this->unk_18C = 0; this->unk_192 = 0x2000; this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKIDS_APPEAR); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); this->colliderCylinder.base.acFlags &= ~AC_ON; this->actionFunc = func_80B2D980; } @@ -596,7 +596,7 @@ void func_80B2DD2C(EnPoh* this, GlobalContext* globalCtx) { func_80B2E0B0(this); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); } @@ -638,7 +638,7 @@ void func_80B2E0B0(EnPoh* this) { this->actor.home.pos.y = this->actor.world.pos.y; this->actor.scale.x = 0.0f; this->actor.scale.y = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_METAL_BOX_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_METAL_BOX_BOUND); this->actionFunc = func_80B2E180; } @@ -652,7 +652,7 @@ void func_80B2E180(EnPoh* this, GlobalContext* globalCtx) { void func_80B2E1D8(EnPoh* this) { this->actor.home.pos.y = this->actor.world.pos.y; - Actor_SetHeight(&this->actor, -10.0f); + Actor_SetFocus(&this->actor, -10.0f); this->unk_18E = 200; this->unk_18D = 32; this->actor.flags |= 1; @@ -672,7 +672,7 @@ void func_80B2E230(EnPoh* this, GlobalContext* globalCtx) { return; } - func_800B8A1C(&this->actor, globalCtx, GI_MAX, 35.0f, 60.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 35.0f, 60.0f); this->actor.world.pos.y = (Math_SinS(this->unk_18D * 0x800) * 5.0f) + this->actor.home.pos.y; if (this->unk_18D) { this->unk_18D--; @@ -682,14 +682,14 @@ void func_80B2E230(EnPoh* this, GlobalContext* globalCtx) { this->unk_18D = 32; } - Actor_SetHeight(&this->actor, -10.0f); + Actor_SetFocus(&this->actor, -10.0f); Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 100, 0, 150, this->unk_197 * (40.0f / 51.0f)); } void func_80B2E3B0(EnPoh* this) { func_801A7328(&this->actor.projectedPos, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); this->actionFunc = func_80B2E3F8; } @@ -705,9 +705,9 @@ void func_80B2E438(EnPoh* this, GlobalContext* globalCtx) { this->colliderCylinder.base.acFlags &= ~AC_HIT; if (!Actor_ApplyDamage(&this->actor)) { Enemy_StartFinishingBlow(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DEAD); } else if (this->actor.colChkInfo.damage != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PO_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DAMAGE); } if (this->actor.colChkInfo.damageEffect != 14) { @@ -817,7 +817,7 @@ void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx2) { func_80B2E438(this, globalCtx); func_80B2E55C(this); this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if ((this->actionFunc == func_80B2CF28) && (this->unk_18E < 10)) { this->actor.flags |= 0x1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); @@ -830,7 +830,7 @@ void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); - Actor_SetHeight(&this->actor, 42.0f); + Actor_SetFocus(&this->actor, 42.0f); if ((this->actionFunc != func_80B2D07C) && (this->actionFunc != func_80B2D628)) { if (this->actionFunc == func_80B2DB44) { diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c index 280c898cef..d287414b38 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c @@ -237,7 +237,7 @@ s32 func_80B70B04(EnRailSkb* this, Vec3f pos) { } void func_80B70D24(EnRailSkb* this, GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_PROP].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; while (actor != NULL) { if ((actor->id == ACTOR_OBJ_HAKAISI) && func_80B70B04(this, actor->world.pos)) { @@ -263,7 +263,7 @@ void EnRailSkb_Init(Actor* thisx, GlobalContext* globalCtx) { EnRailSkb* this = THIS; func_80B708C0(this, globalCtx); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 36.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &object_skb_Skel_005EF8, &object_skb_Anim_0064E0, this->jointTable, this->morphTable, 20); Collider_InitJntSph(globalCtx, &this->collider); @@ -306,7 +306,7 @@ void EnRailSkb_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80B70FA0(EnRailSkb* this) { this->unk_3F2 = 0; if (this->actionFunc != func_80B716A8) { - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); } this->actionFunc = func_80B70FF8; } @@ -328,7 +328,7 @@ void func_80B70FF8(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B710AC(EnRailSkb* this) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = func_80B710E4; } @@ -339,7 +339,7 @@ void func_80B710E4(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B71114(EnRailSkb* this) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = func_80B7114C; } @@ -349,9 +349,9 @@ void func_80B7114C(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_2F0 = 0.0f; this->unk_2EC = 0.0f; if (this->actor.colChkInfo.health != 0) { - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); - func_800BDC5C(&this->skelAnime, sAnimations, 3); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_402 |= 1; func_80B712FC(this); } else { @@ -373,9 +373,9 @@ void func_80B7123C(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_2F0 = 0.0f; this->unk_2EC = 0.0f; if (this->actor.colChkInfo.health != 0) { - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); - func_800BDC5C(&this->skelAnime, sAnimations, 3); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_402 |= 1; func_80B712FC(this); } else { @@ -399,8 +399,8 @@ void func_80B71314(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B71354(EnRailSkb* this) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80B713A4; } @@ -409,7 +409,7 @@ void func_80B713A4(EnRailSkb* this, GlobalContext* globalCtx) { if ((this->actor.xzDistToPlayer > 65.0f) || (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN)) { func_80B70FA0(this); } else { - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); } } @@ -446,11 +446,11 @@ void func_80B7151C(EnRailSkb* this) { this->actor.colChkInfo.health = 2; this->unk_402 = 0; this->actor.flags |= 1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); this->actor.draw = EnRailSkb_Draw; this->actor.shape.shadowAlpha = 0; this->actor.shape.rot.y = this->actor.world.rot.y; - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80B715AC; } @@ -473,13 +473,13 @@ void func_80B715AC(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71650(EnRailSkb* this) { this->unk_3FE = 0; if (this->actionFunc != func_80B70FF8) { - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); } this->actionFunc = func_80B716A8; } void func_80B716A8(EnRailSkb* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_3FE = 1; func_80B71D8C(this, globalCtx, func_80B723F8); if (!func_80B7285C(this)) { @@ -490,7 +490,7 @@ void func_80B716A8(EnRailSkb* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, 0x13F5, &this->actor); this->unk_400 = 0x13F5; } - func_800BDC5C(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); func_80B717C8(this); } else if ((this->actor.xzDistToPlayer < 100.0f) && !(this->collider.base.acFlags & AC_HIT)) { func_800B8614(&this->actor, globalCtx, 100.0f); @@ -506,7 +506,7 @@ void func_80B717C8(EnRailSkb* this) { void func_80B717E0(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_3FA = 0; - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: case 1: case 2: @@ -552,7 +552,7 @@ void func_80B718C4(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B71910(EnRailSkb* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80B71954; } @@ -565,12 +565,12 @@ void func_80B71954(EnRailSkb* this, GlobalContext* globalCtx) { if (sp30 < 80.0f) { func_80B71A08(this); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80B71A08(EnRailSkb* this) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80B71A58; } @@ -578,8 +578,8 @@ void func_80B71A58(EnRailSkb* this, GlobalContext* globalCtx) { s16 sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->actor.world.pos); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); if (this->unk_2E8 < this->unk_22C->actor.colChkInfo.health) { this->unk_22C->actor.colChkInfo.health--; } else { @@ -602,7 +602,7 @@ void func_80B71A58(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71B6C(EnRailSkb* this) { this->unk_3F2 = 10; - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80B71BB8; } @@ -620,7 +620,7 @@ void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx) { Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->actor.world.pos), 1, 0x71C, 0xB6); if ((this->actor.bgCheckFlags & 1) && (this->unk_22C->actor.colChkInfo.health == 0)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } else { this->actor.velocity.y += this->actor.gravity; this->actor.world.pos.y += this->actor.velocity.y; @@ -634,8 +634,8 @@ void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx) { } if ((sp34 < 50.0f) && (this->actor.bgCheckFlags & 1)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); - func_800BDC5C(&this->skelAnime, sAnimations, 9); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); this->actor.velocity.y = 10.0f; for (i = 0; i < 4; i++) { @@ -645,7 +645,7 @@ void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B71D8C(EnRailSkb* this, GlobalContext* globalCtx, EnRailSkbUnkFunc unkFunc) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_ENEMY].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; while (actor != NULL) { if (actor->id == ACTOR_EN_RAIL_SKB) { @@ -668,7 +668,7 @@ void func_80B71DF0(EnRailSkb* this) { this->unk_3F0 = 0; } - func_800BDC5C(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); this->actionFunc = func_80B71EA8; } @@ -767,7 +767,7 @@ void func_80B72190(EnRailSkb* this, GlobalContext* globalCtx) { if ((this->actionFunc != func_80B714D8) && (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 15.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_WALK); } if (this->actor.parent == NULL) { @@ -811,7 +811,7 @@ void func_80B72190(EnRailSkb* this, GlobalContext* globalCtx) { } else { this->unk_2E0 = 0; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } } @@ -978,12 +978,12 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_403 = 30; this->unk_2EC = 1.0f; this->unk_2F0 = 0.0f; - func_800BCB70(&this->actor, 0, 120, 0, 40); + Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); func_80B710AC(this); break; case 1: - func_800BCB70(&this->actor, 0, 120, 0, 40); + Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); func_80B710AC(this); break; @@ -992,16 +992,16 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_403 = 0; this->unk_2EC = 1.0f; this->unk_2F0 = 0.0f; - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_DAMAGE); - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); this->unk_402 |= 1; func_80B712FC(this); break; case 3: if (this->actor.colChkInfo.health != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3F0 = 80; } else { this->unk_3F0 = 3; @@ -1009,7 +1009,7 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_403 = 11; this->unk_2EC = 1.0f; this->unk_2F0 = 0.5f; - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); func_80B71114(this); break; @@ -1018,9 +1018,9 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_403 = 20; this->unk_2EC = 1.0f; this->unk_2F0 = 0.5f; - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_DAMAGE); - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); func_80B71228(this); break; @@ -1035,9 +1035,9 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { } case 13: - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_DAMAGE); - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); func_80B712FC(this); break; @@ -1112,10 +1112,10 @@ void EnRailSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Collider_UpdateSpheres(limbIndex, &this->collider); if ((limbIndex == 11) && (this->unk_402 & 1) && !(this->unk_402 & 2)) { - func_800BBCEC(&this->actor, globalCtx, 1, dList); + Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); this->unk_402 |= 2; } else if ((this->unk_402 & 0x40) && ((limbIndex != 11) || !(this->unk_402 & 1)) && (limbIndex != 12)) { - func_800BBCEC(&this->actor, globalCtx, 1, dList); + Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); } if (this->unk_3F0 != 0) { diff --git a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c index de64df7dfd..16b8d4fe6d 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -212,14 +212,14 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_402 = gSaveContext.time; this->unk_404 = 0; this->unk_3F8 = 0; - this->unk_400 = 0; + this->textId = 0; this->unk_3FA = 0; if (this->actor.parent == NULL) { this->unk_3EC = 1; this->unk_3EE = 1; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 28.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060053E8, &D_0600ABE0, this->jointTable, this->morphTable, 26); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -239,7 +239,7 @@ void EnRailgibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80BA57A8(EnRailgibud* this) { this->actor.speedXZ = 0.6f; - func_800BDC5C(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); this->actionFunc = func_80BA57F8; } @@ -283,11 +283,11 @@ void func_80BA57F8(EnRailgibud* this, GlobalContext* globalCtx) { } else { this->unk_298 = 0; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80BA59F0(EnRailgibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); this->actionFunc = func_80BA5A34; } @@ -300,14 +300,14 @@ void func_80BA5A34(EnRailgibud* this, GlobalContext* globalCtx) { player->actor.freezeTimer = 60; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); func_80BA5AF0(this); } func_80BA6B9C(this, globalCtx); } void func_80BA5AF0(EnRailgibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); this->actor.speedXZ = 0.4f; if (this->actionFunc == func_80BA5A34) { this->unk_3F2 = 80; @@ -325,7 +325,7 @@ void func_80BA5B64(EnRailgibud* this, GlobalContext* globalCtx) { this->actor.world.rot = this->actor.shape.rot; Math_SmoothStepToS(&this->unk_3E2, 0, 1, 0x64, 0); Math_SmoothStepToS(&this->unk_3E8, 0, 1, 0x64, 0); - if (func_80BA6D10(this, globalCtx) && Actor_IsActorFacingLink(&this->actor, 0x38E3)) { + if (func_80BA6D10(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { if ((this->unk_3F4 == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { player->actor.freezeTimer = 0; if ((gSaveContext.playerForm == PLAYER_FORM_GORON) || (gSaveContext.playerForm == PLAYER_FORM_DEKU)) { @@ -339,7 +339,7 @@ void func_80BA5B64(EnRailgibud* this, GlobalContext* globalCtx) { this->unk_3F2 = 60; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); } else { this->unk_3F2--; } @@ -355,14 +355,14 @@ void func_80BA5B64(EnRailgibud* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); } else if ((globalCtx->gameplayFrames & 95) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } void func_80BA5DBC(EnRailgibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); this->actor.flags &= ~1; this->unk_3F2 = 0; this->unk_3F0 = 0; @@ -380,9 +380,9 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { sp34 = func_80BA7088(this, globalCtx); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (sp34 == 1)) { this->unk_3F0 = 1; - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); } else if (!(player->stateFlags2 & 0x80)) { - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actor.flags |= 1; this->unk_3F0 = 2; this->unk_3F2 = 0; @@ -395,7 +395,7 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { sp32 = player->ageProperties->unk_92 + 0x6805; globalCtx->damagePlayer(globalCtx, -8); - func_800B8E58(&player->actor, sp32); + func_800B8E58(player, sp32); func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); this->unk_3F2 = 0; } else { @@ -403,7 +403,7 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); } if (!(player->stateFlags2 & 0x80) || (player->unk_B62 != 0)) { @@ -411,7 +411,7 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x80; player->unk_AE8 = 100; } - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actor.flags |= 1; this->unk_3F0 = 2; this->unk_3F2 = 0; @@ -431,8 +431,8 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA6054(EnRailgibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 7); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->actor.speedXZ = -2.0f; this->actionFunc = func_80BA60B0; } @@ -453,7 +453,7 @@ void func_80BA60B0(EnRailgibud* this, GlobalContext* globalCtx) { void func_80BA6158(EnRailgibud* this) { this->unk_3F2 = 0; - func_800BDC5C(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); this->actionFunc = func_80BA61A0; } @@ -470,7 +470,7 @@ void func_80BA61A0(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA6284(EnRailgibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); this->actor.speedXZ = 0.4f; this->actionFunc = func_80BA62D4; } @@ -495,15 +495,15 @@ void func_80BA62D4(EnRailgibud* this, GlobalContext* globalCtx) { } if (func_80BA6D10(this, globalCtx)) { if ((gSaveContext.playerForm != PLAYER_FORM_GORON) && (gSaveContext.playerForm != PLAYER_FORM_DEKU) && - Actor_IsActorFacingLink(&this->actor, 0x38E3)) { + Actor_IsFacingPlayer(&this->actor, 0x38E3)) { func_80BA5AF0(this); } } } void func_80BA6440(EnRailgibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 7); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->unk_3F2 = 0; this->unk_3F4 = 0; this->actor.world.rot.y = this->actor.yawTowardsPlayer; @@ -532,9 +532,9 @@ void func_80BA6584(EnRailgibud* this) { this->actor.world.rot.y = this->actor.shape.rot.y; this->unk_3F2 = 10; if (this->unk_3F6 != 0) { - func_800BCB70(&this->actor, 0, 0xC8, 0, 0x28); + Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } else { - func_800BCB70(&this->actor, 0, 0xC8, 0, 0x28); + Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } this->actionFunc = func_80BA6604; } @@ -554,9 +554,9 @@ void func_80BA6604(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA6664(EnRailgibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); this->actor.flags &= ~1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); this->unk_3F2 = 0; this->actionFunc = func_80BA66C8; } @@ -699,7 +699,7 @@ void func_80BA6DF8(EnRailgibud* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 15: - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (player->unk_ADC != 0) { this->unk_405 = player->unk_ADD; } @@ -720,7 +720,7 @@ void func_80BA6DF8(EnRailgibud* this, GlobalContext* globalCtx) { break; case 2: - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (this->actor.colChkInfo.health == 0) { func_80BA6664(this); } else { @@ -732,7 +732,7 @@ void func_80BA6DF8(EnRailgibud* this, GlobalContext* globalCtx) { break; case 4: - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (this->actor.colChkInfo.health == 0) { func_80BA6664(this); } else { @@ -790,7 +790,7 @@ s32 func_80BA7088(EnRailgibud* this, GlobalContext* globalCtx) { void func_80BA71E4(EnRailgibud* this, GlobalContext* globalCtx) { if ((this->actionFunc == func_80BA5B64) || (this->actionFunc == func_80BA62D4) || (this->actionFunc == func_80BA64AC)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } } @@ -854,28 +854,28 @@ void func_80BA7434(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA7578(EnRailgibud* this, GlobalContext* globalCtx) { - if ((this->unk_400 == 0) && (this->unk_3F8 == 0)) { - if (func_800B84D0(&this->actor, globalCtx)) { + if ((this->textId == 0) && (this->unk_3F8 == 0)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_3FA = 1; func_801518B0(globalCtx, 0x13B2, &this->actor); - this->unk_400 = 0x13B2; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); + this->textId = 0x13B2; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); this->actor.speedXZ = 0.0f; } else if (((this->actor.flags & 9) == 9) && !(this->collider.base.acFlags & AC_HIT)) { func_800B8614(&this->actor, globalCtx, 100.0f); } } else { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 5: if (func_80147624(globalCtx)) { func_801518B0(globalCtx, 0x13B3, &this->actor); - this->unk_400 = 0x13B3; + this->textId = 0x13B3; } break; case 6: if (func_80147624(globalCtx)) { - this->unk_400 = 0; + this->textId = 0; this->unk_3FA = 0; this->actor.speedXZ = 0.6f; } @@ -995,7 +995,7 @@ void func_80BA7B6C(EnRailgibud* this, GlobalContext* globalCtx) { this->unk_3FE = 99; this->actor.flags |= 0x100000; this->actor.flags |= 0x10; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 28.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060053E8, &D_0600ABE0, this->jointTable, this->morphTable, 26); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -1067,37 +1067,37 @@ s32 func_80BA7DC8(EnRailgibud* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.npcActions[sp2C]->unk0) { case 1: this->unk_3F0 = 9; - func_800BDC5C(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); break; case 2: this->unk_3F0 = 15; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_WEAKENED2); - func_800BDC5C(&this->skelAnime, sAnimations, 15); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_WEAKENED2); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 15); break; case 3: this->unk_3F0 = 17; - func_800BDC5C(&this->skelAnime, sAnimations, 17); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 17); break; case 4: this->unk_3F0 = 18; - func_800BDC5C(&this->skelAnime, sAnimations, 18); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 18); break; case 5: this->unk_3F0 = 10; - func_800BDC5C(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (this->unk_3F0 == 15) { this->unk_3F0 = 16; - func_800BDC5C(&this->skelAnime, sAnimations, 16); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 16); } else if (this->unk_3F0 == 18) { this->unk_3F0 = 19; - func_800BDC5C(&this->skelAnime, sAnimations, 19); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 19); func_80BA7D14(this); } } @@ -1115,9 +1115,9 @@ s32 func_80BA7DC8(EnRailgibud* this, GlobalContext* globalCtx) { case 5: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (globalCtx->csCtx.frames < 280) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_WEAKENED1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_WEAKENED1); } } break; diff --git a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h index 35cb83cd2d..546a885b5b 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h @@ -41,7 +41,7 @@ typedef struct EnRailgibud { /* 0x03FA */ s16 unk_3FA; /* 0x03FC */ u16 unk_3FC; /* 0x03FE */ u16 unk_3FE; - /* 0x0400 */ u16 unk_400; + /* 0x0400 */ u16 textId; /* 0x0402 */ s16 unk_402; /* 0x0404 */ u8 unk_404; /* 0x0405 */ s8 unk_405; diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index be62210ea0..766d03070d 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -244,7 +244,7 @@ void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_808D4190(GlobalContext* globalCtx, EnRd* this, s32 arg2) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_ENEMY].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; while (actor != NULL) { if ((actor->id != ACTOR_EN_RD) || (this == (EnRd*)actor) || (actor->params < ENRD_GET_0)) { @@ -338,7 +338,7 @@ void func_808D43AC(EnRd* this, GlobalContext* globalCtx) { } if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -381,7 +381,7 @@ void func_808D4660(EnRd* this, GlobalContext* globalCtx) { } if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -424,14 +424,14 @@ void func_808D4868(EnRd* this, GlobalContext* globalCtx) { } if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } void func_808D49E4(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } this->unk_3E4++; @@ -483,7 +483,7 @@ void func_808D4B20(EnRd* this, GlobalContext* globalCtx) { } if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -499,7 +499,7 @@ void func_808D4B20(EnRd* this, GlobalContext* globalCtx) { void func_808D4CA8(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } this->actor.world.rot.y -= this->unk_3E4; @@ -537,7 +537,7 @@ void func_808D4E60(EnRd* this, GlobalContext* globalCtx) { } } else { if (this->actor.world.pos.y == this->actor.home.pos.y) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 50.0f, 0.3f, 2.0f, 0.3f) == 0.0f) { @@ -587,7 +587,7 @@ void func_808D506C(EnRd* this, GlobalContext* globalCtx) { func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); } this->unk_3ED = 60; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); } } else { func_808D53C0(this, globalCtx); @@ -599,7 +599,7 @@ void func_808D506C(EnRd* this, GlobalContext* globalCtx) { } if (!this->unk_3EE && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 45.0f) && - Actor_IsActorFacingLink(&this->actor, 0x38E3)) { + Actor_IsFacingPlayer(&this->actor, 0x38E3)) { player->actor.freezeTimer = 0; if ((player->transformation == PLAYER_FORM_GORON) || (player->transformation == PLAYER_FORM_DEKU)) { if (Actor_DistanceToPoint(&this->actor, &this->actor.home.pos) < 150.0f) { @@ -620,9 +620,9 @@ void func_808D506C(EnRd* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -670,9 +670,9 @@ void func_808D5440(EnRd* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -715,9 +715,9 @@ void func_808D56E4(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); } else if ((globalCtx->gameplayFrames & 0x5F) == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -786,7 +786,7 @@ void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 6000, 0); if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); } this->unk_3EA--; @@ -794,7 +794,7 @@ void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { globalCtx->damagePlayer(globalCtx, -8); func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); this->unk_3EA = 20; - func_800B8E58(&player->actor, player->ageProperties->unk_92 + 0x6805); + func_800B8E58(player, player->ageProperties->unk_92 + 0x6805); } break; @@ -833,7 +833,7 @@ void func_808D5CCC(EnRd* this, GlobalContext* globalCtx) { func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); func_808D4FE0(this, globalCtx); } } @@ -842,7 +842,7 @@ void func_808D5D88(EnRd* this) { this->unk_3EF = 8; Animation_MorphToPlayOnce(&this->skelAnime, &D_06009900, -6.0f); this->actor.speedXZ = -2.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->unk_3EF = 8; this->actionFunc = func_808D5DF4; } @@ -919,7 +919,7 @@ void func_808D616C(EnRd* this) { } this->actor.flags |= 1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->unk_3EF = 11; this->actionFunc = func_808D6200; } @@ -954,7 +954,7 @@ void func_808D6310(EnRd* this) { this->unk_3D6 = 300; this->actor.flags &= ~1; this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); this->actionFunc = func_808D6388; } @@ -969,7 +969,7 @@ void func_808D6388(EnRd* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_3D6 == 0) { if (!Flags_GetSwitch(globalCtx, this->unk_3DC & 0x7F)) { - Actor_SetSwitchFlag(globalCtx, this->unk_3DC & 0x7F); + Flags_SetSwitch(globalCtx, this->unk_3DC & 0x7F); } if (this->unk_3DE != 0) { @@ -985,7 +985,7 @@ void func_808D6388(EnRd* this, GlobalContext* globalCtx) { this->unk_3D6--; } } else if (Animation_OnFrame(&this->skelAnime, 33.0f) || Animation_OnFrame(&this->skelAnime, 40.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } } @@ -997,12 +997,12 @@ void func_808D64D0(EnRd* this) { if (gSaveContext.unk_3F58 != 0) { this->unk_3E9 = 1; this->unk_3E0 = 600; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIGHT_ARROW_HIT); - func_800BCB70(&this->actor, 0x8000, 0x80C8, 0, 255); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIGHT_ARROW_HIT); + Actor_SetColorFilter(&this->actor, 0x8000, 0x80C8, 0, 255); } else if (this->unk_3F0 == 1) { - func_800BCB70(&this->actor, 0, 0xC8, 0, 40); + Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 40); } else if (this->unk_3F0 == 12) { - func_800BCB70(&this->actor, 0, 0xC8, 0, 40); + Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 40); } this->actionFunc = func_808D65BC; } @@ -1016,7 +1016,7 @@ void func_808D65BC(EnRd* this, GlobalContext* globalCtx) { if (this->unk_3E0 != 0) { this->unk_3E0--; if (this->unk_3E0 >= 255) { - func_800BCB70(&this->actor, 0x8000, 0x80C8, 0, 255); + Actor_SetColorFilter(&this->actor, 0x8000, 0x80C8, 0, 255); } if (this->unk_3E0 == 0) { @@ -1074,7 +1074,7 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { return; } - func_800BE258(&this->actor, &this->collider.info); + Actor_SetDropFlag(&this->actor, &this->collider.info); if (player->unk_ADC != 0) { this->unk_3F1 = player->unk_ADD; @@ -1096,7 +1096,7 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { return; case 2: - func_800BCB70(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); this->unk_3E6 = 180; this->unk_3E8 = 0; this->unk_3E9 = 0; @@ -1105,7 +1105,7 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { break; case 4: - func_800BCB70(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); this->unk_3E6 = 60; this->unk_3E8 = 20; this->unk_3E9 = 0; @@ -1114,13 +1114,13 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { break; case 15: - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); this->unk_3E9 = 0; this->unk_3E0 = 0; break; case 14: - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); this->unk_3E9 = 0; this->unk_3E0 = 0; this->actor.colChkInfo.health = 0; @@ -1183,7 +1183,7 @@ void EnRd_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if ((this->unk_3EF != 10) && (this->actor.speedXZ != 0.0f)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } if ((this->actor.shape.rot.x == 0) && (this->unk_3EF != 10) && (this->actor.speedXZ != 0.0f)) { diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 07f3ca850a..baa7aadadc 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -108,9 +108,9 @@ void EnRecepgirl_Wait(EnRecepgirl* this, GlobalContext* globalCtx) { } } - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { EnRecepgirl_SetupTalk(this); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2000)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2000)) { func_800B8614(&this->actor, globalCtx, 60.0f); if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { this->actor.textId = 0x2367; // "... doesn't Kafei want to break off his engagement ... ?" @@ -148,13 +148,13 @@ void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { } } - temp_v0_2 = func_80152498(&globalCtx->msgCtx); + temp_v0_2 = Message_GetState(&globalCtx->msgCtx); if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; // hear directions again? EnRecepgirl_SetupWait(this); } else if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." - Actor_SetSwitchFlag(globalCtx, this->actor.params); + Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); if (gSaveContext.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c index f012353277..c52c7c1786 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -148,7 +148,7 @@ void EnRr_Init(Actor* thisx, GlobalContext* globalCtx) { } Collider_UpdateCylinder(&this->actor, &this->collider2); - Actor_SetHeight(&this->actor, this->actor.scale.y * 2000.0f); + Actor_SetFocus(&this->actor, this->actor.scale.y * 2000.0f); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if ((this->actor.params == ENRR_2) || (this->actor.params == ENRR_3)) { @@ -197,7 +197,7 @@ void func_808FA11C(EnRr* this) { this->unk_224 = 1.2750001f; this->unk_21C = 1.0f; this->actor.flags &= ~0x400; - func_800BCB70(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808FA19C(EnRr* this, GlobalContext* globalCtx) { @@ -207,15 +207,15 @@ void func_808FA19C(EnRr* this, GlobalContext* globalCtx) { this->collider1.base.colType = COLTYPE_HIT0; this->collider1.info.elemType = ELEMTYPE_UNK1; this->unk_21C = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->unk_234, 20, 2, this->actor.scale.y * 23.333334f, - this->actor.scale.y * 20.000002f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_234, 20, 2, this->actor.scale.y * 23.333334f, + this->actor.scale.y * 20.000002f); this->actor.flags |= 0x400; } } void func_808FA238(EnRr* this, f32 arg1) { this->actor.speedXZ = arg1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIKE_WALK); } void func_808FA260(EnRr* this) { @@ -236,7 +236,7 @@ void func_808FA260(EnRr* this) { this->actionFunc = func_808FB088; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_UNARI); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIKE_UNARI); } void func_808FA344(EnRr* this) { @@ -286,7 +286,7 @@ void func_808FA3F8(EnRr* this, Player* player) { } this->actionFunc = func_808FB1C0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SUISEN_DRINK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_SUISEN_DRINK); } void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { @@ -313,7 +313,7 @@ void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { sp34 = false; } - if (sp34 && (func_80152498(&globalCtx->msgCtx) == 0)) { + if (sp34 && (Message_GetState(&globalCtx->msgCtx) == 0)) { func_801518B0(globalCtx, 0xF6, NULL); } @@ -331,7 +331,7 @@ void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { player->actor.world.pos.z += sp30 * Math_CosS(this->actor.shape.rot.y); func_800B8D50(globalCtx, &this->actor, sp30, this->actor.shape.rot.y, sp2C, sp38); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_SUISEN_THROW); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_SUISEN_THROW); } } @@ -344,7 +344,7 @@ void func_808FA6B8(EnRr* this) { } else { this->unk_1EC = 40; } - func_800BCB70(&this->actor, 0x4000, 255, 0, this->unk_1EC); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, this->unk_1EC); this->unk_1E6 = 20; this->unk_1F6 = 2500; @@ -360,7 +360,7 @@ void func_808FA6B8(EnRr* this) { } this->actionFunc = func_808FB398; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIKE_DAMAGE); } void func_808FA7AC(EnRr* this) { @@ -405,7 +405,7 @@ void func_808FA910(EnRr* this) { this->unk_1E4 = 0; this->unk_214 = 0.0f; - func_800BCB70(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); this->unk_210 = 0.0f; for (i = 0; i < ARRAY_COUNT(this->unk_324); i++) { @@ -415,7 +415,7 @@ void func_808FA910(EnRr* this) { } this->actionFunc = func_808FB42C; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIKE_DEAD); this->actor.flags &= ~1; } @@ -465,7 +465,7 @@ s32 func_808FAA94(EnRr* this, GlobalContext* globalCtx) { return false; } - func_800BE258(&this->actor, &sp2C->info); + Actor_SetDropFlag(&this->actor, &sp2C->info); func_808FA4F4(this, globalCtx); func_808FA19C(this, globalCtx); @@ -481,8 +481,8 @@ s32 func_808FAA94(EnRr* this, GlobalContext* globalCtx) { func_808FA910(this); } } else if (this->actor.colChkInfo.damageEffect == 1) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); - func_800BCB70(&this->actor, 0, 255, 0, 80); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 80); this->unk_1EE = 80; func_808FA9CC(this); } else if (this->actor.colChkInfo.damageEffect == 3) { @@ -630,7 +630,7 @@ void func_808FB1C0(EnRr* this, GlobalContext* globalCtx) { func_8013ECE0(this->actor.xyzDistToPlayerSq, 120, 2, 120); if (!(this->unk_1E4 & 7)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_DEMO_EYE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEMO_EYE); } player->unk_AE8 = 0; @@ -786,7 +786,7 @@ void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_1F0--; } - Actor_SetHeight(&this->actor, this->actor.scale.y * 2000.0f); + Actor_SetFocus(&this->actor, this->actor.scale.y * 2000.0f); func_808FAE50(this, globalCtx); if (!func_808FAA94(this, globalCtx)) { @@ -801,7 +801,7 @@ void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.1f); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, this->collider1.dim.radius, 0.0f, 0x5D); func_808FB794(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c index 3adecaad3f..78af19c644 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -37,7 +37,7 @@ extern Gfx D_06005458[]; static ActorAnimationEntry animations[] = { { &D_0600788C, 1.0f, 0.0f, 0.0f, 0x00, 0.0f } }; void func_80C25D40(EnRsn* this) { - func_800BDC5C(&this->skelAnime, animations, 0); + Actor_ChangeAnimation(&this->skelAnime, animations, 0); this->actionFunc = func_80C25D84; } @@ -47,7 +47,7 @@ void func_80C25D84(EnRsn* this, GlobalContext* globalCtx) { void EnRsn_Init(Actor* thisx, GlobalContext* globalCtx) { EnRsn* this = THIS; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06009220, &D_06009120, NULL, NULL, 0); this->actor.flags &= ~1; func_80C25D40(this); @@ -63,7 +63,7 @@ void EnRsn_Update(Actor* thisx, GlobalContext* globalCtx) { EnRsn* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); SkelAnime_Update(&this->skelAnime); func_800E9250(globalCtx, &this->actor, &this->unk1D8, &this->unk1DE, this->actor.focus.pos); } diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c index ba851d64d2..cebb90123d 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c @@ -5,17 +5,41 @@ */ #include "z_en_ruppecrow.h" +#include "objects/object_crow/object_crow.h" #define FLAGS 0x00004030 #define THIS ((EnRuppecrow*)thisx) +enum { + ENRUPPECROW_EFFECT_NONE = 0, + ENRUPPECROW_EFFECT_ICE = 10, + ENRUPPECROW_EFFECT_LIGHT = 20, +}; + void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx); void EnRuppecrow_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRuppecrow_Update(Actor* thisx, GlobalContext* globalCtx); void EnRuppecrow_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnRuppecrow_HandleSong(EnRuppecrow*, GlobalContext*); +s32 EnRuppecrow_UpdateCollision(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_UpdateRupees(EnRuppecrow*); +void EnRuppecrow_UpdateDamage(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_HandleDeath(EnRuppecrow*); +void EnRuppecrow_FallToDespawn(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_ShatterIce(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_UpdatePosition(EnRuppecrow*, GlobalContext*); +s32 EnRuppecrow_CheckPlayedMatchingSong(GlobalContext*); +void EnRuppecrow_HandleSongCutscene(EnRuppecrow*, GlobalContext*); +s32 EnRuppecrow_ReachedPointClockwise(EnRuppecrow*, Path*, s32); +s32 EnRuppecrow_ReachedPointCounterClockwise(EnRuppecrow*, Path*, s32); +f32 EnRuppecrow_GetPointDirection(Path*, s32, PosRot*, Vec3s*); +s32 EnRuppecrow_CanSpawnBlueRupees(GlobalContext*); +void EnRuppecrow_SpawnRupee(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_FlyWhileDroppingRupees(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_UpdateSpeed(EnRuppecrow*, GlobalContext*); +void EnRuppecrow_FlyToDespawn(EnRuppecrow*, GlobalContext*); -#if 0 const ActorInit En_Ruppecrow_InitVars = { ACTOR_EN_RUPPECROW, ACTORCAT_ENEMY, @@ -28,25 +52,36 @@ const ActorInit En_Ruppecrow_InitVars = { (ActorFunc)EnRuppecrow_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80BE39B0[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80BE39D4 = { - { COLTYPE_HIT3, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80BE39B0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80BE39E4 = { 1, 15, 30, 30 }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 30, 30 }; -// static DamageTable sDamageTable = { -static DamageTable D_80BE39EC = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -81,62 +116,558 @@ static DamageTable D_80BE39EC = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BE3A0C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -#endif +s32 EnRuppecrow_UpdateCollision(EnRuppecrow* this, GlobalContext* globalCtx) { + s32 pad; -extern ColliderJntSphElementInit D_80BE39B0[1]; -extern ColliderJntSphInit D_80BE39D4; -extern CollisionCheckInfoInit D_80BE39E4; -extern DamageTable D_80BE39EC; -extern InitChainEntry D_80BE3A0C[]; + this->collider.elements->dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements->dim.worldSphere.center.y = + sJntSphInit.elements->dim.modelSphere.center.y + this->actor.world.pos.y; + this->collider.elements->dim.worldSphere.center.z = this->actor.world.pos.z; -extern UNK_TYPE D_060000F0; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f, 25.0f, 50.0f, 0x07); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2260.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2330.s") +s32 EnRuppecrow_ReachedPointClockwise(EnRuppecrow* this, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 pathCount = path->count; + s32 currentPoint = pointIndex; + s32 reached = false; + f32 diffX; + f32 diffZ; + f32 px; + f32 pz; + f32 d; + Vec3f point; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE24CC.s") + Math_Vec3s_ToVec3f(&point, &points[currentPoint]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2668.s") + if (currentPoint == 0) { + diffX = points[1].x - points[0].x; + diffZ = points[1].z - points[0].z; + } else { + if (currentPoint == (pathCount - 1)) { + diffX = points[pathCount - 1].x - points[pathCount - 2].x; + diffZ = points[pathCount - 1].z - points[pathCount - 2].z; + } else { + diffX = points[currentPoint + 1].x - points[currentPoint - 1].x; + diffZ = points[currentPoint + 1].z - points[currentPoint - 1].z; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2728.s") + func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + if (((this->actor.world.pos.x * px) + (pz * this->actor.world.pos.z) + d) > 0.0f) { + reached = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2794.s") + return reached; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2808.s") +s32 EnRuppecrow_ReachedPointCounterClockwise(EnRuppecrow* this, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 pathCount = path->count; + s32 currentPoint = pointIndex; + s32 reached = false; + f32 diffX; + f32 diffZ; + f32 px; + f32 pz; + f32 d; + Vec3f point; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2874.s") + Math_Vec3s_ToVec3f(&point, &points[currentPoint]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2B80.s") + if (currentPoint == 0) { + diffX = points[0].x - points[1].x; + diffZ = points[0].z - points[1].z; + } else { + if (currentPoint == (pathCount - 1)) { + diffX = points[pathCount - 2].x - points[pathCount - 1].x; + diffZ = points[pathCount - 2].z - points[pathCount - 1].z; + } else { + diffX = points[currentPoint - 1].x - points[currentPoint + 1].x; + diffZ = points[currentPoint - 1].z - points[currentPoint + 1].z; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2D4C.s") + func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + if (((this->actor.world.pos.x * px) + (pz * this->actor.world.pos.z) + d) > 0.0f) { + reached = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2E18.s") + return reached; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE2F6C.s") +f32 EnRuppecrow_GetPointDirection(Path* path, s32 pointIndex, PosRot* world, Vec3s* direction) { + Vec3s* points; + Vec3f point; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE30F4.s") + if (path != NULL) { + points = Lib_SegmentedToVirtual(path->points); + points = &points[pointIndex]; + VEC_SET(point, points->x, points->y, points->z); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE3178.s") + direction->y = Math_Vec3f_Yaw(&world->pos, &point); + direction->x = Math_Vec3f_Pitch(&world->pos, &point); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE32DC.s") + return point.y - world->pos.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE3354.s") +void EnRuppecrow_ShatterIce(EnRuppecrow* this, GlobalContext* globalCtx) { + if (this->currentEffect == ENRUPPECROW_EFFECT_ICE) { + this->currentEffect = ENRUPPECROW_EFFECT_NONE; + this->unk_2C8 = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ENRUPPECROW_LIMB_POS_COUNT, 0x2, 0.2f, 0.2f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE348C.s") +s32 EnRuppecrow_CanSpawnBlueRupees(GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/func_80BE35A4.s") + switch (player->transformation) { + case PLAYER_FORM_DEKU: + return false; + case PLAYER_FORM_GORON: + return true; + case PLAYER_FORM_ZORA: + return false; + case PLAYER_FORM_HUMAN: + if (player->stateFlags1 & 0x800000) { + return true; + } else { + return false; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/EnRuppecrow_Init.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/EnRuppecrow_Destroy.s") +void EnRuppecrow_UpdateRupees(EnRuppecrow* this) { + EnItem00* rupee; + s16 rupeeIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/EnRuppecrow_Update.s") + for (rupeeIndex = 0; rupeeIndex < ENRUPPECROW_RUPEE_COUNT; rupeeIndex++) { + rupee = this->rupees[rupeeIndex]; + if (rupee != NULL && rupee->unk152 == 0) { + Actor_MarkForDeath(&rupee->actor); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ruppecrow/EnRuppecrow_Draw.s") +void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 xOffset; + EnItem00* rupee; + s16 rupeeIndex = this->rupeeIndex; + + if (!(player->stateFlags3 & 0x1000)) { + xOffset = (this->rupeeIndex & 1) ? 10.0f : -10.0f; + } else { + xOffset = 0.0f; + } + + if (EnRuppecrow_CanSpawnBlueRupees(globalCtx) && (this->rupeeIndex % 5) == 4) { + if (this->rupeeIndex == 19) { + rupee = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, + this->actor.world.pos.x + xOffset, this->actor.world.pos.y, + this->actor.world.pos.z, 0x0, 0x0, 0x0, ITEM00_RUPEE_RED); + this->rupees[rupeeIndex] = rupee; + this->rupees[rupeeIndex]->actor.gravity = -5.0f; + this->rupees[rupeeIndex]->actor.velocity.y = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); + rupee = this->rupees[rupeeIndex]; + rupee->unk152 = 60; + this->rupees[rupeeIndex]->actor.flags |= 0x10; + } else { + rupee = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, + this->actor.world.pos.x + xOffset, this->actor.world.pos.y, + this->actor.world.pos.z, 0x0, 0x0, 0x0, ITEM00_RUPEE_BLUE); + this->rupees[rupeeIndex] = rupee; + this->rupees[rupeeIndex]->actor.gravity = -5.0f; + this->rupees[rupeeIndex]->actor.velocity.y = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); + rupee = this->rupees[rupeeIndex]; + rupee->unk152 = 60; + this->rupees[rupeeIndex]->actor.flags |= 0x10; + } + } else if (this->rupeeIndex == 19) { + rupee = + (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, this->actor.world.pos.x + xOffset, + this->actor.world.pos.y, this->actor.world.pos.z, 0x0, 0x0, 0x0, ITEM00_RUPEE_RED); + this->rupees[rupeeIndex] = rupee; + this->rupees[rupeeIndex]->actor.gravity = -5.0f; + this->rupees[rupeeIndex]->actor.velocity.y = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); + rupee = this->rupees[rupeeIndex]; + rupee->unk152 = 60; + this->rupees[rupeeIndex]->actor.flags |= 0x10; + } else { + rupee = + (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, this->actor.world.pos.x + xOffset, + this->actor.world.pos.y, this->actor.world.pos.z, 0x0, 0x0, 0x0, ITEM00_RUPEE_GREEN); + this->rupees[rupeeIndex] = rupee; + this->rupees[rupeeIndex]->actor.gravity = -5.0f; + this->rupees[rupeeIndex]->actor.velocity.y = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); + rupee = this->rupees[rupeeIndex]; + rupee->unk152 = 60; + this->rupees[rupeeIndex]->actor.flags |= 0x10; + } + + this->rupeeIndex++; +} + +void EnRuppecrow_UpdatePosition(EnRuppecrow* this, GlobalContext* globalCtx) { + Vec3s nextPointDirection; + + EnRuppecrow_GetPointDirection(this->path, this->currentPoint, &this->actor.world, &nextPointDirection); + if (this->actor.bgCheckFlags & 0x8) { + nextPointDirection.y = this->actor.wallYaw; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, nextPointDirection.y, 0x4, 0x3E8, 0x1); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.world.rot.x, -nextPointDirection.x, 0x4, 0x3E8, 0x1); + + if (this->isGoingCounterClockwise & 1) { + if (EnRuppecrow_ReachedPointCounterClockwise(this, this->path, this->currentPoint)) { + if (this->currentPoint <= 0) { + this->currentPoint = this->path->count - 1; + } else { + this->currentPoint--; + } + + if (this->actionFunc == EnRuppecrow_FlyWhileDroppingRupees && + (!EnRuppecrow_CanSpawnBlueRupees(globalCtx) || (this->currentPoint % -2) == 0)) { + EnRuppecrow_SpawnRupee(this, globalCtx); + } + } + } else if (EnRuppecrow_ReachedPointClockwise(this, this->path, this->currentPoint)) { + if (this->currentPoint >= this->path->count - 1) { + this->currentPoint = 0; + } else { + this->currentPoint++; + } + + if (this->actionFunc == EnRuppecrow_FlyWhileDroppingRupees && + (!EnRuppecrow_CanSpawnBlueRupees(globalCtx) || (this->currentPoint % -2) == 0)) { + EnRuppecrow_SpawnRupee(this, globalCtx); + } + } +} + +s32 EnRuppecrow_CheckPlayedMatchingSong(GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (globalCtx->msgCtx.unk1202A == 0x3) { + switch (player->transformation) { + case PLAYER_FORM_DEKU: + if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_SONATA) { + return true; + } + break; + case PLAYER_FORM_GORON: + if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_GORON_LULLABY) { + return true; + } + break; + case PLAYER_FORM_ZORA: + if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_NEW_WAVE) { + return true; + } + break; + case PLAYER_FORM_HUMAN: + if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_SONATA) { + return true; + } else if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_GORON_LULLABY) { + return true; + } else if (globalCtx->msgCtx.unk1202E == OCARINA_SONG_NEW_WAVE) { + return true; + } + break; + } + } + + return false; +} + +void EnRuppecrow_UpdateSpeed(EnRuppecrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (player->transformation) { + case PLAYER_FORM_DEKU: + this->speedModifier = 7.0f; + break; + case PLAYER_FORM_GORON: + if (player->stateFlags3 & 0x1000) { // Goron Link is curled + this->speedModifier = 19.0f; + } else { + this->speedModifier = 7.0f; + } + break; + case PLAYER_FORM_ZORA: + this->speedModifier = 7.0f; + break; + case PLAYER_FORM_HUMAN: + if (player->stateFlags1 & 0x800000) { + this->speedModifier = 16.0f; + } else { + this->speedModifier = 7.0f; + } + break; + } + + this->skelAnime.playSpeed = this->speedModifier / 6.0f; + if (this->actor.xzDistToPlayer > 800.0f) { + this->speedModifier *= 0.5f; + } else if (this->actor.xzDistToPlayer > 500.0f) { + this->speedModifier *= 0.8f; + } else if (this->actor.xzDistToPlayer < 150.0f) { + this->speedModifier *= 1.2f; + } +} + +void EnRuppecrow_HandleDeath(EnRuppecrow* this) { + f32 scale; + + this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); + this->actor.velocity.y = 0.0f; + Animation_Change(&this->skelAnime, &object_crow_Anim_0000F0, 0.4f, 0.0f, 0.0f, 0x1, -3.0f); + + this->actor.shape.yOffset = 0.0f; + this->actor.targetArrowOffset = 0.0f; + this->actor.bgCheckFlags &= ~0x1; + + scale = this->actor.scale.x * 100.0f; + this->actor.world.pos.y += 20.0f * scale; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); + + this->unk_2CC = 0.5f; + if (this->actor.colChkInfo.damageEffect == 0x3) { + this->currentEffect = ENRUPPECROW_EFFECT_ICE; + this->unk_2C8 = 1.0f; + this->iceSfxTimer = 0.75f; + } else if (this->actor.colChkInfo.damageEffect == 0x4) { + this->currentEffect = ENRUPPECROW_EFFECT_LIGHT; + this->unk_2C8 = 5.0f; + } else if (this->actor.colChkInfo.damageEffect == 0x2) { + this->currentEffect = ENRUPPECROW_EFFECT_NONE; + this->unk_2C8 = 5.0f; + } + + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x0, 0x28); + if (this->actor.flags & 0x8000) { + this->actor.speedXZ = 0.0f; + } + + this->collider.base.acFlags &= ~AC_ON; + this->actor.flags |= 0x10; + this->actionFunc = EnRuppecrow_FallToDespawn; +} + +void EnRuppecrow_UpdateDamage(EnRuppecrow* this, GlobalContext* globalCtx) { + 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 != 0x1) { + this->actor.colChkInfo.health = 0; + this->actor.flags &= ~0x1; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + EnRuppecrow_HandleDeath(this); + } + } +} + +void EnRuppecrow_HandleSong(EnRuppecrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + EnRuppecrow_UpdatePosition(this, globalCtx); + if (this->actor.xzDistToPlayer < 1000.0f && EnRuppecrow_CheckPlayedMatchingSong(globalCtx)) { + // If Link is in front, the guay will turn around and go the other way + if (Actor_IsFacingPlayer(&this->actor, 0x4000)) { + this->isGoingCounterClockwise |= 1; + if (this->currentPoint > 0) { + this->currentPoint--; + } else { + this->currentPoint = this->path->count - 1; + } + } + + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = EnRuppecrow_HandleSongCutscene; + } + + if (player->stateFlags2 & 0x8000000) { + Math_ApproachF(&this->actor.speedXZ, 0.0f, 0.1f, 1.0f); + } else { + Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.1f, 0.1f); + } + + Actor_MoveWithoutGravity(&this->actor); + this->yOffset += 0x1000; + this->actor.shape.yOffset = Math_SinS(this->yOffset) * 500.0f; + + if ((globalCtx->state.frames % 43) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + } +} + +void EnRuppecrow_HandleSongCutscene(EnRuppecrow* this, GlobalContext* globalCtx) { + EnRuppecrow_UpdatePosition(this, globalCtx); + + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + EnRuppecrow_UpdateSpeed(this, globalCtx); + this->actionFunc = EnRuppecrow_FlyWhileDroppingRupees; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + + Actor_MoveWithoutGravity(&this->actor); +} + +void EnRuppecrow_FlyWhileDroppingRupees(EnRuppecrow* this, GlobalContext* globalCtx) { + EnRuppecrow_UpdatePosition(this, globalCtx); + + if (this->rupeeIndex >= ENRUPPECROW_RUPEE_COUNT) { + // Finished spawning rupees; fly up and then despawn + this->speedModifier = 6.0f; + + // Source of the "Termina Field Guay Glitch"; guay will no longer fall if killed after this point + this->actor.gravity = 0.0f; + + Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); + Math_ApproachF(&this->actor.velocity.y, 3.0f, 0.2f, 0.5f); + + this->actionFunc = EnRuppecrow_FlyToDespawn; + this->skelAnime.playSpeed = 1.0f; + Actor_MoveWithGravity(&this->actor); + } else { + if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + EnRuppecrow_UpdateSpeed(this, globalCtx); + Math_ApproachF(&this->actor.speedXZ, this->speedModifier, 0.2f, 0.5f); + } + + Actor_MoveWithoutGravity(&this->actor); + this->yOffset += 0x1000; + this->actor.shape.yOffset = Math_SinS(this->yOffset) * 500.0f; + + if ((globalCtx->state.frames % 43) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + } + } +} + +void EnRuppecrow_FlyToDespawn(EnRuppecrow* this, GlobalContext* globalCtx) { + if (this->actor.bgCheckFlags & 0x8) { + this->actor.world.rot.y *= -0x1; + } + + Math_ApproachF(&this->actor.speedXZ, this->speedModifier, 0.1f, 0.1f); + Math_ApproachF(&this->actor.velocity.y, 3.0f, 0.2f, 0.5f); + + if (this->actor.world.pos.y > 1000.0f || this->actor.xzDistToPlayer > 2000.0f) { + Actor_MarkForDeath(&this->actor); + } else { + this->yOffset += 0x800; + this->actor.shape.yOffset = Math_SinS(this->yOffset) * 500.0f; + + Actor_MoveWithGravity(&this->actor); + + if ((globalCtx->state.frames % 43) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + } + } +} + +void EnRuppecrow_FallToDespawn(EnRuppecrow* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + + if (this->currentEffect != ENRUPPECROW_EFFECT_ICE) { + Math_StepToF(&this->unk_2C8, 0.0f, 0.05f); + this->unk_2CC = (this->unk_2C8 + 1.0f) * 0.25f; + this->unk_2CC = CLAMP_MAX(this->unk_2CC, 0.5f); + } else if (!Math_StepToF(&this->iceSfxTimer, 0.5f, 0.0125f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + + this->actor.colorFilterTimer = 40; + if (!(this->actor.flags & 0x8000)) { + if (this->currentEffect != ENRUPPECROW_EFFECT_ICE) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); + this->actor.shape.rot.z += 0x1780; + } + + if (this->actor.bgCheckFlags & 0x1 || this->actor.floorHeight == BGCHECK_Y_MIN) { + EnRuppecrow_ShatterIce(this, globalCtx); + func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, (this->actor.scale.x * 10000.0f), + 0x0, 0x0); + + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 0xB, NA_SE_EN_EXTINCT); + Actor_MarkForDeath(&this->actor); + return; + } + } + + Actor_MoveWithGravity(&this->actor); +} + +void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx2) { + EnRuppecrow* this = THIS; + GlobalContext* globalCtx = globalCtx2; + + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_crow_Skel_0010C0, &object_crow_Anim_0000F0, this->joinTable, + this->morphTable, ENRUPPECROW_LIMB_COUNT); + ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); + + Collider_InitJntSph(globalCtx, &this->collider); + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->colliderElement); + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements->dim.modelSphere.radius; + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + Actor_SetScale(&this->actor, 0.01f); + this->actor.flags |= 0x2000000; + + this->path = func_8013D648(globalCtx, ENRUPPECROW_GET_PATH(&this->actor), 0x3F); + if (this->path != NULL) { + this->actionFunc = EnRuppecrow_HandleSong; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void EnRuppecrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRuppecrow* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); +} + +void EnRuppecrow_Update(Actor* thisx, GlobalContext* globalCtx) { + EnRuppecrow* this = THIS; + + EnRuppecrow_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + EnRuppecrow_UpdateRupees(this); + this->actor.focus.pos = this->actor.world.pos; + SkelAnime_Update(&this->skelAnime); + EnRuppecrow_UpdateCollision(this, globalCtx); +} + +void EnRuppecrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnRuppecrow* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h index eeba6774d8..4c9cafa675 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h @@ -3,15 +3,38 @@ #include "global.h" +#define ENRUPPECROW_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 0xA) + +#define ENRUPPECROW_RUPEE_COUNT 20 +#define ENRUPPECROW_LIMB_COUNT 9 +#define ENRUPPECROW_LIMB_POS_COUNT 4 + struct EnRuppecrow; typedef void (*EnRuppecrowActionFunc)(struct EnRuppecrow*, GlobalContext*); typedef struct EnRuppecrow { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x94]; - /* 0x01D8 */ EnRuppecrowActionFunc actionFunc; - /* 0x01DC */ char unk_1DC[0x128]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnItem00* rupees[ENRUPPECROW_RUPEE_COUNT]; + /* 0x194 */ SkelAnime skelAnime; + /* 0x1D8 */ EnRuppecrowActionFunc actionFunc; + /* 0x1DC */ UNK_TYPE4 unk_1DC; // unused + /* 0x1E0 */ Vec3s joinTable[ENRUPPECROW_LIMB_COUNT]; + /* 0x216 */ Vec3s morphTable[ENRUPPECROW_LIMB_COUNT]; + /* 0x24C */ Path* path; + /* 0x250 */ s32 currentPoint; + /* 0x254 */ ColliderJntSph collider; + /* 0x274 */ ColliderJntSphElement colliderElement; + /* 0x2B4 */ u16 isGoingCounterClockwise; + /* 0x2B8 */ f32 speedModifier; + /* 0x2BC */ s16 rupeeIndex; + /* 0x2BE */ s16 yOffset; + /* 0x2C0 */ UNK_TYPE4 unk_2C0; // unused + /* 0x2C4 */ u8 currentEffect; + /* 0x2C8 */ f32 unk_2C8; // set but not used + /* 0x2CC */ f32 unk_2CC; // set but not used + /* 0x2D0 */ f32 iceSfxTimer; + /* 0x2D4 */ Vec3f limbPos[ENRUPPECROW_LIMB_POS_COUNT]; } EnRuppecrow; // size = 0x304 extern const ActorInit En_Ruppecrow_InitVars; diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.c b/src/overlays/actors/ovl_En_Sb/z_en_sb.c index c355f99344..78f36abfd6 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -158,7 +158,7 @@ void EnSb_SetupOpen(EnSb* this) { Animation_Change(&this->skelAnime, &D_06000194, 1.0f, 0, Animation_GetLastFrame(&D_06000194), 2, 0.0f); this->state = SHELLBLADE_OPEN; this->actionFunc = EnSb_Open; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); } void EnSb_SetupWaitOpen(EnSb* this) { @@ -174,7 +174,7 @@ void EnSb_SetupLunge(EnSb* this) { Animation_Change(&this->skelAnime, &D_06000124, playbackSpeed, 0.0f, frameCount, 2, 0); this->state = SHELLBLADE_LUNGE; this->actionFunc = EnSb_Lunge; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); } void EnSb_SetupBounce(EnSb* this) { @@ -271,7 +271,7 @@ void EnSb_Lunge(EnSb* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); if (this->actor.velocity.y <= -0.1f || this->actor.bgCheckFlags & 2) { if (!(this->actor.depthInWater > 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } this->actor.bgCheckFlags &= ~2; EnSb_SetupBounce(this); @@ -332,7 +332,7 @@ void EnSb_UpdateDamage(EnSb* this, GlobalContext* globalCtx) { hitPlayer = 0; if (this->vulnerableTimer != 0) { Actor_ApplyDamage(&this->actor); - func_800BCB70(&this->actor, 0x4000, 0xFF, 0x2000, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 80); hitPlayer = 1; } } @@ -371,8 +371,8 @@ void EnSb_Update(Actor* thisx, GlobalContext* globalCtx) { Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x80); Actor_MarkForDeath(&this->actor); } else { - Actor_SetHeight(&this->actor, 20.0f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_SetFocus(&this->actor, 20.0f); + Actor_MoveWithGravity(&this->actor); this->actionFunc(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 20.0f, 5); EnSb_UpdateDamage(this, globalCtx); @@ -394,7 +394,7 @@ void EnSb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (this->isDrawn != false) { if (limbIndex < 7) { phi_a2 = (this->actor.depthInWater > 0) ? 4 : 1; - func_800BBCEC(thisx, globalCtx, phi_a2, dList); + Actor_SpawnBodyParts(thisx, globalCtx, phi_a2, dList); } if (limbIndex == 6) { this->isDrawn = false; diff --git a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c index b90ab3db92..e71a241e7c 100644 --- a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c +++ b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c @@ -35,7 +35,7 @@ void func_80BFCFA0(EnScopecoin* this, GlobalContext* globalCtx) { } void func_80BFCFB8(EnScopecoin* this, GlobalContext* globalCtx) { - if (Actor_GetCollectibleFlag(globalCtx, (this->actor.params & 0x7F0) >> 4)) { + if (Flags_GetCollectible(globalCtx, (this->actor.params & 0x7F0) >> 4)) { Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_RED); Actor_MarkForDeath(&this->actor); } @@ -45,7 +45,7 @@ void EnScopecoin_Init(Actor* thisx, GlobalContext* globalCtx) { EnScopecoin* this = THIS; Actor_SetScale(&this->actor, 0.01f); - ActorShape_Init(&this->actor.shape, 0, func_800B3FC0, 10.0f); + ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 10.0f); this->unk148 = (this->actor.params & 0xF); if (this->unk148 < 0 || this->unk148 >= 8) { this->unk148 = 0; @@ -53,7 +53,7 @@ void EnScopecoin_Init(Actor* thisx, GlobalContext* globalCtx) { if (globalCtx->actorCtx.unk5 & 2) { if (this->unk148 == 2 || this->unk148 == 6) { - if (Actor_GetCollectibleFlag(globalCtx, (this->actor.params & 0x7F0) >> 4)) { + if (Flags_GetCollectible(globalCtx, (this->actor.params & 0x7F0) >> 4)) { Actor_MarkForDeath(&this->actor); return; } @@ -63,7 +63,7 @@ void EnScopecoin_Init(Actor* thisx, GlobalContext* globalCtx) { return; } if (this->unk148 == 2 || this->unk148 == 6) { - if (Actor_GetCollectibleFlag(globalCtx, (this->actor.params & 0x7F0) >> 4)) { + if (Flags_GetCollectible(globalCtx, (this->actor.params & 0x7F0) >> 4)) { Actor_MarkForDeath(&this->actor); } else { this->actor.draw = NULL; diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index dd5db5c868..e07b6895c0 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -219,7 +219,7 @@ void func_80ADAFC0(EnSellnuts* this) { } Actor* func_80ADB040(GlobalContext* globalCtx) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (actor != NULL) { if ((actor->id == ACTOR_EN_SELLNUTS) && !ENSELLNUTS_GET_1(actor)) { @@ -304,7 +304,7 @@ void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); if (((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f) ? true : false) && ((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80ADB4F4; this->unk_34C = 3; this->collider.dim.height = 64; @@ -313,12 +313,12 @@ void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { if ((this->unk_34C == 4) || (this->unk_34C == 18)) { this->unk_34C = 17; this->collider.dim.height = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); func_8013BC6C(&this->skelAnime, D_80ADD990, 17); } else if (this->unk_34C == 2) { this->unk_34C = 16; this->collider.dim.height = 32; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); func_8013BC6C(&this->skelAnime, D_80ADD990, 16); } else if (this->unk_34C == 17) { if (DECR(this->unk_34E) == 0) { @@ -350,8 +350,8 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x7D0, 0); this->actor.world.rot.y = this->actor.shape.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { - if (func_800B8708(globalCtx) == 0x2A) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (Player_GetExchangeItemId(globalCtx) == EXCH_ITEM_2A) { player->actor.textId = D_80ADD928[this->unk_33A]; this->unk_340 = player->actor.textId; this->actionFunc = func_80ADBAB8; @@ -392,7 +392,7 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { } else if (((this->actor.xzDistToPlayer < 80.0f) && (((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false)) || this->actor.isTargeted) { - func_800B85E0(&this->actor, globalCtx, 80.0f, 0x2A); + func_800B85E0(&this->actor, globalCtx, 80.0f, EXCH_ITEM_2A); if (player->transformation == PLAYER_FORM_DEKU) { if (gSaveContext.day == 3) { this->unk_33A = 2; @@ -426,16 +426,16 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u8 temp_v0 = func_80152498(&globalCtx->msgCtx); - s32 itemActionParam; + u8 msgState = Message_GetState(&globalCtx->msgCtx); + s32 item; - if (temp_v0 == 0x10) { - itemActionParam = func_80123810(globalCtx); - if (itemActionParam > PLAYER_AP_NONE) { - if (itemActionParam == PLAYER_AP_MOON_TEAR) { + if (msgState == 0x10) { + item = func_80123810(globalCtx); + if (item > EXCH_ITEM_NONE) { + if (item == EXCH_ITEM_2A) { player->actor.textId = D_80ADD928[this->unk_33A]; this->unk_340 = player->actor.textId; - player->unk_A87 = itemActionParam; + player->exchangeItemId = item; this->actionFunc = func_80ADBAB8; } else { player->actor.textId = D_80ADD920[this->unk_33A]; @@ -443,12 +443,12 @@ void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80ADB0D8; } func_801477B4(globalCtx); - } else if (itemActionParam < PLAYER_AP_NONE) { + } else if (item < EXCH_ITEM_NONE) { this->unk_340 = D_80ADD920[this->unk_33A]; func_80151938(globalCtx, this->unk_340); this->actionFunc = func_80ADB0D8; } - } else if ((temp_v0 == 5) && func_80147624(globalCtx)) { + } else if ((msgState == 5) && func_80147624(globalCtx)) { if (this->unk_340 == D_80ADD910[this->unk_33A]) { this->unk_340 = D_80ADD938[this->unk_33A]; func_80151938(globalCtx, this->unk_340); @@ -462,7 +462,7 @@ void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADBAB8(EnSellnuts* this, GlobalContext* globalCtx) { - u8 sp27 = func_80152498(&globalCtx->msgCtx); + u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 currentFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); @@ -492,30 +492,30 @@ void func_80ADBBEC(EnSellnuts* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[17] |= 0x80; this->actionFunc = func_80ADBCE4; } else { - func_800B8A1C(&this->actor, globalCtx, GI_DEED_LAND, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, GI_DEED_LAND, 300.0f, 300.0f); } } void func_80ADBC60(EnSellnuts* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); this->unk_340 = D_80ADD930[this->unk_33A]; } } void func_80ADBCE4(EnSellnuts* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); this->unk_340 = D_80ADD930[this->unk_33A]; this->actionFunc = func_80ADBC60; } } void func_80ADBD64(EnSellnuts* this, GlobalContext* globalCtx) { - u8 sp27 = func_80152498(&globalCtx->msgCtx); + u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 currentFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); @@ -557,7 +557,7 @@ void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_350 = 4; this->unk_34C = 19; func_8013BC6C(&this->skelAnime, D_80ADD990, 19); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_338 &= ~1; this->unk_338 |= 8; this->unk_32C = this->actor.world.pos.y; @@ -566,7 +566,7 @@ void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADBFA0(EnSellnuts* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; if (this->unk_34C == 0) { @@ -626,7 +626,7 @@ void func_80ADC118(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_34C = 9; this->unk_360 = 0.3f; func_8013BC6C(&this->skelAnime, D_80ADD990, 9); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80ADC034; } } @@ -680,7 +680,7 @@ void func_80ADC37C(EnSellnuts* this, GlobalContext* globalCtx) { } Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); if (this->unk_366 == 2) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); @@ -706,7 +706,7 @@ void func_80ADC580(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->linearVelocity = 0.0f; this->actor.flags &= ~0x10000; func_801518B0(globalCtx, this->unk_340, &this->actor); @@ -729,7 +729,7 @@ void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADC6D0(EnSellnuts* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; if (player->transformation == PLAYER_FORM_DEKU) { @@ -747,7 +747,7 @@ void func_80ADC6D0(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADC7B4(EnSellnuts* this, GlobalContext* globalCtx) { - s32 temp = func_80152498(&globalCtx->msgCtx); + s32 temp = Message_GetState(&globalCtx->msgCtx); if (this->unk_366 == 0) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -812,7 +812,7 @@ void func_80ADC8C4(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_334++; } Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.2f, 1.0f); - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); } } @@ -832,7 +832,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_34C = 19; this->actor.velocity.y = 0.0f; func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); } return; } @@ -893,7 +893,7 @@ void func_80ADCD3C(EnSellnuts* this, GlobalContext* globalCtx) { this->collider.dim.height = 64; this->unk_34C = 3; this->unk_350 = 4; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADCC04; } else if (D_80ADD940 != 0) { @@ -965,7 +965,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600AC70, &D_06005488, this->jointTable, this->morphTable, 28); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 35.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); this->path = func_8013D648(globalCtx, ENSELLNUTS_GET_FC00(&this->actor), 0x3F); this->cutscene = this->actor.cutscene; Actor_SetScale(&this->actor, 0.01f); @@ -1053,10 +1053,10 @@ void EnSellnuts_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_33A = 0; } - Actor_SetHeight(&this->actor, 60.0f); + Actor_SetFocus(&this->actor, 60.0f); Actor_SetScale(&this->actor, 0.01f); SkelAnime_Update(&this->skelAnime); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); this->actionFunc(this, globalCtx); if (this->unk_338 & 8) { func_800B9010(&this->actor, NA_SE_EN_AKINDO_FLY - SFX_FLAG); diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index 0f8a95f967..333717941c 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -215,7 +215,7 @@ void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.colChkInfo.damageTable = &sDamageTable; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 0.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); this->unk_3E0 = 0; this->unk_3E2 = 0; Actor_SetScale(&this->actor, 0.01f); @@ -279,7 +279,7 @@ void EnSkb_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80994DA8(EnSkb* this, GlobalContext* globalCtx) { - if (Actor_IsActorFacingLink(&this->actor, 0x11C7) && (this->actor.xzDistToPlayer < 60.0f) && + if (Actor_IsFacingPlayer(&this->actor, 0x11C7) && (this->actor.xzDistToPlayer < 60.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_CAPTAIN)) { func_80995C24(this); } else { @@ -288,9 +288,9 @@ void func_80994DA8(EnSkb* this, GlobalContext* globalCtx) { } void func_80994E2C(EnSkb* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); this->actor.flags &= ~1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); this->unk_3D0 = 0; this->unk_3DE = 0; this->actionFunc = func_80994E94; @@ -317,7 +317,7 @@ void func_80994E94(EnSkb* this, GlobalContext* globalCtx) { } void func_80994F7C(EnSkb* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_3E2 = 1; if (this->unk_3E0 == 1) { func_801518B0(globalCtx, 0x13F8, &this->actor); @@ -327,7 +327,7 @@ void func_80994F7C(EnSkb* this, GlobalContext* globalCtx) { } this->actionFunc = func_80995190; this->actor.speedXZ = 0.0f; - } else if (Actor_IsActorFacingLink(&this->actor, 0x2AAA) && !(this->collider.base.acFlags & AC_HIT)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && !(this->collider.base.acFlags & AC_HIT)) { func_800B8614(&this->actor, globalCtx, 100.0f); } } @@ -338,12 +338,12 @@ void func_8099504C(EnSkb* this) { } void func_80995068(EnSkb* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_3E2 = 1; if (this->unk_3E0 == 1) { func_801518B0(globalCtx, 0x13F8, &this->actor); if (this->unk_3DE == 2) { - func_800BDC5C(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); } } else { func_801518B0(globalCtx, 0x13F6, &this->actor); @@ -363,7 +363,7 @@ void func_80995068(EnSkb* this, GlobalContext* globalCtx) { } void func_80995190(EnSkb* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: case 1: case 2: @@ -375,7 +375,7 @@ void func_80995190(EnSkb* this, GlobalContext* globalCtx) { if (func_80147624(globalCtx)) { func_801518B0(globalCtx, 0x13F7, &this->actor); if (this->unk_3DE == 2) { - func_800BDC5C(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); } } break; @@ -413,7 +413,7 @@ void func_80995244(EnSkb* this, GlobalContext* globalCtx) { } void func_809952D8(EnSkb* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 9; this->actionFunc = func_8099533C; @@ -427,7 +427,7 @@ void func_8099533C(EnSkb* this, GlobalContext* globalCtx) { this->actor.flags &= ~(0x4 | 0x1); this->actor.flags |= (0x8 | 0x1); func_80994F7C(this, globalCtx); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { this->actor.hintId = 0x55; this->actor.colChkInfo.mass = MASS_HEAVY; func_8099571C(this); @@ -435,7 +435,7 @@ void func_8099533C(EnSkb* this, GlobalContext* globalCtx) { } void func_809953E8(EnSkb* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 10; this->actionFunc = func_8099544C; @@ -449,7 +449,7 @@ void func_8099544C(EnSkb* this, GlobalContext* globalCtx) { this->actor.flags &= ~(0x4 | 0x1); this->actor.flags |= (0x8 | 0x1); func_80994F7C(this, globalCtx); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { this->actor.hintId = 0x55; this->actor.colChkInfo.mass = MASS_HEAVY; func_8099571C(this); @@ -457,7 +457,7 @@ void func_8099544C(EnSkb* this, GlobalContext* globalCtx) { } void func_809954F8(EnSkb* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 11; this->actionFunc = func_8099556C; @@ -486,7 +486,7 @@ void func_8099556C(EnSkb* this, GlobalContext* globalCtx) { this->actor.flags &= ~(0x4 | 0x1); this->actor.flags |= (0x8 | 0x1); func_80994F7C(this, globalCtx); - } else if (Actor_IsActorFacingLink(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f) && + } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f) && (this->skelAnime.curFrame > 24.0f) && (this->skelAnime.curFrame < 28.0f)) { this->actor.hintId = 0x55; this->actor.colChkInfo.mass = MASS_HEAVY; @@ -496,18 +496,18 @@ void func_8099556C(EnSkb* this, GlobalContext* globalCtx) { } void func_8099571C(EnSkb* this) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_3DC = 0; this->actor.shape.shadowScale = 0.0f; if (this->unk_3DE == 9) { - func_800BDC5C(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); this->actor.speedXZ = 2.4f; this->actor.gravity = -1.0f; this->actor.velocity.y = 3.0f; } else if (this->unk_3DE == 0xA) { - func_800BDC5C(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); } else if (this->unk_3DE == 0xB) { - func_800BDC5C(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); this->actor.speedXZ = 3.2f; this->actor.gravity = -1.0f; this->actor.velocity.y = 2.0f; @@ -540,7 +540,7 @@ void func_809958F4(EnSkb* this) { this->unk_3E4 = 0; this->actor.flags &= ~1; this->actor.speedXZ = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->unk_3DE = 1; this->actionFunc = func_8099599C; } @@ -560,7 +560,7 @@ void func_8099599C(EnSkb* this, GlobalContext* globalCtx) { } void func_80995A30(EnSkb* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); this->actor.speedXZ = 1.6f; this->unk_3DA = 0; this->unk_3DE = 2; @@ -573,7 +573,7 @@ void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { this->actor.flags |= (0x8 | 0x1); this->actor.hintId = 0xFF; this->actor.colChkInfo.mass = MASS_HEAVY; - func_800BDC5C(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); func_8099504C(this); return; } @@ -585,18 +585,18 @@ void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->unk_3DA, 1, 0x2EE, 0); this->actor.world.rot.y = this->actor.shape.rot.y; if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { - Audio_PlayActorSound2(&this->actor, 0x3830); + Actor_PlaySfxAtPos(&this->actor, 0x3830); } if ((this->actor.xzDistToPlayer > 800.0f) || func_80996594(this, globalCtx)) { func_809958F4(this); - } else if (Actor_IsActorFacingLink(&this->actor, 0x11C7) && (this->actor.xzDistToPlayer < 60.0f)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x11C7) && (this->actor.xzDistToPlayer < 60.0f)) { func_80995C24(this); } } void func_80995C24(EnSkb* this) { - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); this->collider.base.atFlags &= ~AT_BOUNCED; this->actor.speedXZ = 0.0f; this->unk_3DE = 3; @@ -605,7 +605,7 @@ void func_80995C24(EnSkb* this) { void func_80995C84(EnSkb* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 3.0f) && (this->unk_3E4 == 0)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_3E4 = 1; } else if (Animation_OnFrame(&this->skelAnime, 6.0f)) { this->unk_3E4 = 0; @@ -637,7 +637,7 @@ void func_80995E08(EnSkb* this) { if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = 0.0f; } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->unk_3E4 = 0; this->unk_3DE = 5; this->actionFunc = func_80995E64; @@ -681,22 +681,22 @@ void func_80995E64(EnSkb* this, GlobalContext* globalCtx) { void func_80995F98(EnSkb* this) { if ((this->unk_3DE == 9) || (this->unk_3DE == 0xA)) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - func_800BDC5C(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); this->actor.gravity = -1.0f; this->actor.speedXZ = 1.0f; } else if (this->unk_3DE == 0xB) { - func_800BDC5C(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); this->actor.speedXZ = 3.2f; this->actor.velocity.y = 2.0f; this->actor.gravity = -1.0f; } else { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -4.0f; } } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3DE = 6; this->actionFunc = func_809960AC; } @@ -727,7 +727,7 @@ void func_809960AC(EnSkb* this, GlobalContext* globalCtx) { } void func_809961E4(EnSkb* this, GlobalContext* globalCtx) { - func_800BDC5C(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); this->unk_3D8 |= 0x40; if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -6.0f; @@ -748,7 +748,7 @@ void func_80996284(EnSkb* this, GlobalContext* globalCtx) { } void func_809962D4(EnSkb* this) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = func_8099630C; } @@ -758,8 +758,8 @@ void func_8099630C(EnSkb* this, GlobalContext* globalCtx) { this->unk_230 = 0.0f; this->unk_22C = 0.0f; if (this->actor.colChkInfo.health != 0) { - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); this->unk_3D8 |= 1; func_80995F98(this); } else { @@ -780,8 +780,8 @@ void func_809963D8(EnSkb* this, GlobalContext* globalCtx) { this->unk_230 = 0.0f; this->unk_22C = 0.0f; if (this->actor.colChkInfo.health != 0) { - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); this->unk_3D8 |= 1; func_80995F98(this); } else { @@ -912,12 +912,12 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { this->unk_3D2 = 40; this->unk_22C = 1.0f; this->unk_230 = 0.0f; - func_800BCB70(&this->actor, 0, 0x78, 0, 40); + Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); func_80995E08(this); break; case 1: - func_800BCB70(&this->actor, 0, 0x78, 0, 40); + Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); func_80995E08(this); break; @@ -926,14 +926,14 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { this->unk_3E6 = 0; this->unk_22C = 1.0f; this->unk_230 = 0.0f; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); this->unk_3D8 |= 1; func_80995F98(this); break; case 3: if (this->actor.colChkInfo.health != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3D2 = 0x50; } else { this->unk_3D2 = 3; @@ -941,7 +941,7 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { this->unk_3E6 = 0xB; this->unk_22C = 1.0f; this->unk_230 = 0.5f; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); func_809962D4(this); break; @@ -950,9 +950,9 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { this->unk_3E6 = 0x14; this->unk_22C = 1.0f; this->unk_230 = 0.5f; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_DAMAGE); - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); func_809963C4(this); break; @@ -967,8 +967,8 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { } case 13: - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); - func_800BDC5C(&this->skelAnime, sAnimations, 3); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); func_80995F98(this); break; } @@ -1054,7 +1054,7 @@ void EnSkb_Update(Actor* thisx, GlobalContext* globalCtx) { func_8099672C(this, globalCtx); if ((this->actionFunc != func_8099630C) && (this->actionFunc != func_809963D8) && (this->actionFunc != func_80995E64)) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 60.0f, 0x1D); @@ -1099,12 +1099,12 @@ void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Collider_UpdateSpheres(limbIndex, &this->collider); if ((this->unk_3D8 & 1) && !(this->unk_3D8 & 2)) { if (limbIndex == 11) { - func_800BBCEC(&this->actor, globalCtx, 1, dList); + Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); this->unk_3D8 |= 2; } } else if ((this->unk_3D8 & 0x40) && !(this->unk_3D8 & 0x80) && ((limbIndex != 11) || !(this->unk_3D8 & 1)) && (limbIndex != 12)) { - func_800BBCEC(&this->actor, globalCtx, 1, dList); + Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); } if (this->unk_3D2 != 0) { diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 140fc2c710..4d0b5f094b 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -436,7 +436,7 @@ void EnSob1_UpdateCursorPos(GlobalContext* globalCtx, EnSob1* this) { f32 xOffset = 0.0f; f32 yOffset = 17.0f; - func_800B8898(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); this->cursorPos.x = x + xOffset; this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; @@ -449,7 +449,7 @@ void EnSob1_EndInteraction(GlobalContext* globalCtx, EnSob1* this) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; } - func_800B84D0(&this->actor, globalCtx); + Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; Interface_ChangeAlpha(50); @@ -516,7 +516,7 @@ void EnSob1_SetupLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnSob1* thi } void EnSob1_EndingInteraction(EnSob1* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { EnSob1_EndInteraction(globalCtx, this); } } @@ -534,7 +534,7 @@ void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); this->headRotTarget = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -610,7 +610,7 @@ u8 EnSob1_SetCursorIndexFromNeutral(EnSob1* this, u8 shelfOffset) { } void EnSob1_Hello(EnSob1* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -650,7 +650,7 @@ s32 EnSob1_FacingShopkeeperDialogResult(EnSob1* this, GlobalContext* globalCtx) void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { s32 pad[2]; - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); u8 cursorIdx; if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { @@ -690,7 +690,7 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_TalkingToShopkeeper(EnSob1* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { EnSob1_StartShopping(globalCtx, this); } } @@ -737,7 +737,7 @@ void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { EnSob1_SetupAction(this, EnSob1_SetupIdle); } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void EnSob1_SetupIdle(EnSob1* this, GlobalContext* globalCtx) { @@ -777,7 +777,7 @@ void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx) { } } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); EnSob1_Walking(this, globalCtx); } @@ -792,7 +792,7 @@ void EnSob1_Walking(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -832,10 +832,10 @@ void EnSob1_ItemPurchased(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80151938(globalCtx, 0x647); } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); } } @@ -910,7 +910,7 @@ s32 EnSob1_HasPlayerSelectedItem(GlobalContext* globalCtx, EnSob1* this, Input* } void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; u8 prevCursorIdx = this->cursorIdx; u8 cursorIdx; @@ -940,7 +940,7 @@ void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_SetupBuyItemWithFanfare(GlobalContext* globalCtx, EnSob1* this) { Player* player = GET_PLAYER(globalCtx); - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; player->stateFlags2 &= ~0x20000000; @@ -1029,7 +1029,7 @@ void EnSob1_HandleCanBuyItem(GlobalContext* globalCtx, EnSob1* this) { } void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (EnSob1_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); @@ -1049,7 +1049,7 @@ void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5) { + if (Message_GetState(&globalCtx->msgCtx) == 5) { if (func_80147624(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); @@ -1060,7 +1060,7 @@ void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_CanBuy(EnSob1* this, GlobalContext* globalCtx) { EnGirlA* item; - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnSob1_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1075,12 +1075,12 @@ void EnSob1_BuyItemWithFanfare(EnSob1* this, GlobalContext* globalCtx) { this->actor.parent = NULL; EnSob1_SetupAction(this, EnSob1_SetupItemPurchased); } else { - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); } } void EnSob1_SetupItemPurchased(EnSob1* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; EnSob1_SetupAction(this, EnSob1_ItemPurchased); @@ -1091,7 +1091,7 @@ void EnSob1_SetupItemPurchased(EnSob1* this, GlobalContext* globalCtx) { this->cutscene = this->lookToShopkeeperCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); } - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); } } @@ -1099,7 +1099,7 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnGirlA* item; - if ((func_80152498(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { EnSob1_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); @@ -1107,7 +1107,7 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { player->stateFlags2 |= 0x20000000; func_801518B0(globalCtx, this->welcomeTextId, &this->actor); EnSob1_SetupStartShopping(globalCtx, this, true); - func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); } } @@ -1368,7 +1368,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { if (EnSob1_AreObjectsLoaded(this, globalCtx)) { this->actor.flags &= ~0x10; this->actor.objBankIndex = this->objIndices[0]; - Actor_SetObjectSegment(globalCtx, &this->actor); + Actor_SetObjectDependency(globalCtx, &this->actor); posOffset = &sPosOffset[this->shopType]; this->actor.world.pos.x += posOffset->x; this->actor.world.pos.y += posOffset->y; @@ -1381,7 +1381,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; EnSob1_GetCutscenes(this); this->cutscene = this->lookFowardCutscene; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); sInitFuncs[this->shopType](this, globalCtx); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.colChkInfo.cylRadius = 50; @@ -1473,7 +1473,7 @@ void EnSob1_Update(Actor* thisx, GlobalContext* globalCtx) { EnSob1_UpdateCursorAnim(this); Math_StepToS(&this->headRot, this->headRotTarget, 0x190); this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, 90.0f); + Actor_SetFocus(&this->actor, 90.0f); changeObjectFunc = this->changeObjectFunc; if (changeObjectFunc != NULL) { changeObjectFunc(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c index 827491ee12..26fdf6f08d 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -5,6 +5,7 @@ */ #include "z_en_ssh.h" +#include "objects/object_ssh/object_ssh.h" #define FLAGS 0x00000035 @@ -15,16 +16,15 @@ void EnSsh_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSsh_Update(Actor* thisx, GlobalContext* globalCtx); void EnSsh_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809755C0(EnSsh* this, GlobalContext* globalCtx); -void func_80975720(EnSsh* this, GlobalContext* globalCtx); -void func_809758B0(EnSsh* this, GlobalContext* globalCtx); -void func_80975998(EnSsh* this, GlobalContext* globalCtx); -void func_80975A98(EnSsh* this, GlobalContext* globalCtx); -void func_80975C14(EnSsh* this, GlobalContext* globalCtx); +void EnSsh_Wait(EnSsh* this, GlobalContext* globalCtx); +void EnSsh_Idle(EnSsh* this, GlobalContext* globalCtx); +void EnSsh_Land(EnSsh* this, GlobalContext* globalCtx); +void EnSsh_Drop(EnSsh* this, GlobalContext* globalCtx); +void EnSsh_Return(EnSsh* this, GlobalContext* globalCtx); +void EnSsh_Start(EnSsh* this, GlobalContext* globalCtx); -void EnSsh_SetupAction(EnSsh* this, EnSshActionFunc actionFunc); +extern AnimationHeader D_06000304; -#if 0 const ActorInit En_Ssh_InitVars = { ACTOR_EN_SSH, ACTORCAT_NPC, @@ -37,139 +37,900 @@ const ActorInit En_Ssh_InitVars = { (ActorFunc)EnSsh_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80976030 = { - { COLTYPE_HIT6, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 32, 50, -24, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_8097605C = { 1, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80976068 = { - { COLTYPE_HIT6, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT6, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 20, 60, -30, { 0, 0, 0 } }, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80976094[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 1, { { 0, -240, 0 }, 28 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809760B8 = { - { COLTYPE_HIT6, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80976094, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -#endif +void EnSsh_SetupAction(EnSsh* this, EnSshActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern ColliderCylinderInit D_80976030; -extern CollisionCheckInfoInit2 D_8097605C; -extern ColliderCylinderInit D_80976068; -extern ColliderJntSphElementInit D_80976094[1]; -extern ColliderJntSphInit D_809760B8; +void EnSsh_SpawnShockwave(EnSsh* this, GlobalContext* globalCtx) { + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + Vec3f pos; -extern UNK_TYPE D_060000D8; -extern UNK_TYPE D_06000304; -extern UNK_TYPE D_06005850; + pos.x = this->actor.world.pos.x; + pos.y = this->actor.floorHeight; + pos.z = this->actor.world.pos.z; + EffectSsBlast_SpawnWhiteCustomScale(globalCtx, &pos, &zeroVec, &zeroVec, 100, 220, 8); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/EnSsh_SetupAction.s") +s32 EnSsh_CreateBlureEffect(GlobalContext* globalCtx) { + EffectBlureInit1 blureInit; + u8 sP1StartColor[4] = { 255, 255, 255, 75 }; + u8 sP2StartColor[4] = { 255, 255, 255, 75 }; + u8 sP1EndColor[4] = { 255, 255, 255, 0 }; + u8 sP2EndColor[4] = { 255, 255, 255, 0 }; + s32 i; + s32 blureIdx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80973EFC.s") + for (i = 0; i < ARRAY_COUNT(blureInit.p1StartColor); i++) { + blureInit.p1StartColor[i] = sP1StartColor[i]; + blureInit.p2StartColor[i] = sP2StartColor[i]; + blureInit.p1EndColor[i] = sP1EndColor[i]; + blureInit.p2EndColor[i] = sP2EndColor[i]; + } + blureInit.elemDuration = 6; + blureInit.unkFlag = false; + blureInit.calcMode = 3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80973F84.s") + Effect_Add(globalCtx, &blureIdx, 1, 0, 0, &blureInit); + return blureIdx; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974080.s") +s32 EnSsh_CheckCeilingPos(EnSsh* this, GlobalContext* globalCtx) { + CollisionPoly* poly; + s32 bgId; + Vec3f posB; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974118.s") + posB.x = this->actor.world.pos.x; + posB.y = this->actor.world.pos.y + 1000.0f; + posB.z = this->actor.world.pos.z; + if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &posB, &this->ceilingPos, &poly, 0, 0, 1, + 1, &bgId)) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974220.s") +void EnSsh_AddBlureVertex(EnSsh* this) { + Vec3f p1Base = { 834.0f, 834.0f, 0.0f }; + Vec3f p2Base = { 834.0f, -584.0f, 0.0f }; + Vec3f p1; + Vec3f p2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_8097424C.s") + p1Base.x *= this->colliderScale; + p1Base.y *= this->colliderScale; + p1Base.z *= this->colliderScale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974374.s") + p2Base.x *= this->colliderScale; + p2Base.y *= this->colliderScale; + p2Base.z *= this->colliderScale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809744A8.s") + Matrix_StatePush(); + Matrix_MultiplyVector3fByState(&p1Base, &p1); + Matrix_MultiplyVector3fByState(&p2Base, &p2); + Matrix_StatePop(); + EffectBlure_AddVertex(Effect_GetByIndex(this->blureIdx), &p1, &p2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809744C8.s") +void EnSsh_AddBlureSpace(EnSsh* this) { + EffectBlure_AddSpace(Effect_GetByIndex(this->blureIdx)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809744FC.s") +void EnSsh_InitColliders(EnSsh* this, GlobalContext* globalCtx) { + ColliderCylinderInit* cylinders[] = { + &sCylinderInit1, &sCylinderInit1, &sCylinderInit1, &sCylinderInit2, &sCylinderInit2, &sCylinderInit2, + }; + s32 i; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974540.s") + for (i = 0; i < ARRAY_COUNT(this->collider1); i++) { + Collider_InitAndSetCylinder(globalCtx, &this->collider1[i], &this->actor, cylinders[i]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974590.s") + this->collider1[0].info.bumper.dmgFlags = 0x38A9; + this->collider1[1].info.bumper.dmgFlags = ~0x83038A9; + this->collider1[2].base.colType = COLTYPE_METAL; + this->collider1[2].info.bumperFlags = (BUMP_NO_AT_INFO | BUMP_HOOKABLE | BUMP_ON); + this->collider1[2].info.elemType = ELEMTYPE_UNK2; + this->collider1[2].info.bumper.dmgFlags = ~0x83038A9; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809745BC.s") + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(2), &sColChkInfoInit); + Collider_InitJntSph(globalCtx, &this->collider2); + Collider_SetJntSph(globalCtx, &this->collider2, &this->actor, &sJntSphInit, this->collider2Elements); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974730.s") +f32 EnSsh_SetAnimation(EnSsh* this, s32 arg0) { + AnimationHeader* animation[] = { &object_ssh_Anim_006D78, &object_ssh_Anim_001494, &object_ssh_Anim_001494, + &object_ssh_Anim_006788, &object_ssh_Anim_001494, &object_ssh_Anim_001494, + &object_ssh_Anim_006D78 }; + f32 playerbackSpeed[] = { 1.0f, 4.0f, 1.0f, 1.0f, 8.0f, 6.0f, 2.0f }; + u8 mode[] = { + ANIMMODE_ONCE_INTERP, ANIMMODE_ONCE_INTERP, ANIMMODE_LOOP_INTERP, ANIMMODE_ONCE_INTERP, + ANIMMODE_LOOP_INTERP, ANIMMODE_LOOP_INTERP, ANIMMODE_LOOP_INTERP, + }; + f32 frameCount = Animation_GetLastFrame(animation[arg0]); + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_8097480C.s") + Animation_Change(&this->skelAnime, animation[arg0], playerbackSpeed[arg0], 0.0f, frameCount, mode[arg0], -6.0f); + return frameCount; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809748DC.s") +void EnSsh_SetWaitAnimation(EnSsh* this) { + EnSsh_SetAnimation(this, SSH_ANIM_WAIT); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_8097497C.s") +void EnSsh_SetReturnAnimation(EnSsh* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_UP); + EnSsh_SetAnimation(this, SSH_ANIM_UP); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809749B8.s") +void EnSsh_SetLandAnimation(EnSsh* this) { + this->actor.world.pos.y = this->floorHeightOffset + this->actor.floorHeight; + this->animTimer = EnSsh_SetAnimation(this, SSH_ANIM_LAND); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974A24.s") +void EnSsh_SetDropAnimation(EnSsh* this) { + if (this->unkTimer == 0) { + this->animTimer = EnSsh_SetAnimation(this, SSH_ANIM_DROP); + } + this->actor.velocity.y = -10.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974B0C.s") +void EnSsh_SetStunned(EnSsh* this) { + if (this->stunTimer == 0) { + this->stateFlags |= SSH_STATE_ATTACKED; + this->stunTimer = 120; + this->actor.colorFilterTimer = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974B44.s") +void EnSsh_SetColliderScale(EnSsh* this, f32 arg1, f32 arg2) { + s32 i; + f32 radius = this->collider2.elements[0].dim.modelSphere.radius; + f32 height; + f32 yShift; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974B84.s") + radius *= arg1; + this->collider2.elements[0].dim.modelSphere.radius = radius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974CC8.s") + for (i = 0; i < ARRAY_COUNT(this->collider1); i++) { + yShift = this->collider1[i].dim.yShift; + radius = this->collider1[i].dim.radius; + height = this->collider1[i].dim.height; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974D3C.s") + height *= arg1; + yShift *= arg1; + radius *= arg1 * arg2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974E44.s") + this->collider1[i].dim.yShift = yShift; + this->collider1[i].dim.radius = radius; + this->collider1[i].dim.height = height; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974EA0.s") + Actor_SetScale(&this->actor, 0.04f * arg1); + this->floorHeightOffset = 60.0f * arg1; + this->colliderScale = arg1 * 1.5f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80974F78.s") +s32 EnSsh_Damaged(EnSsh* this) { + if ((this->stunTimer == 120) && (this->stateFlags & SSH_STATE_STUNNED)) { + Actor_SetColorFilter(&this->actor, 0, 200, 0, this->stunTimer); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_8097502C.s") + if (DECR(this->stunTimer) != 0) { + Math_SmoothStepToS(&this->maxTurnRate, 10000, 10, 1000, 1); + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975070.s") + this->stunTimer = 0; + this->stateFlags &= ~SSH_STATE_STUNNED; + this->spinTimer = 0; + if (this->swayTimer == 0) { + this->spinTimer = 30; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975128.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_ST_ATTACK); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975300.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/EnSsh_Init.s") +void EnSsh_Turn(EnSsh* this, GlobalContext* globalCtx) { + if (this->hitTimer != 0) { + this->hitTimer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/EnSsh_Destroy.s") + if (DECR(this->spinTimer) != 0) { + this->actor.world.rot.y += (s16)(10000.0f * (this->spinTimer / 30.0f)); + } else if ((this->swayTimer == 0) && (this->stunTimer == 0)) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 4, 10000, 1); + } + this->actor.shape.rot.y = this->actor.world.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809755C0.s") +void EnSsh_Stunned(EnSsh* this, GlobalContext* globalCtx) { + if ((this->swayTimer == 0) && (this->stunTimer == 0)) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer ^ 0x8000, 4, this->maxTurnRate, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_8097561C.s") + this->actor.shape.rot.y = this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809756D0.s") + if (this->stunTimer < 30) { + if (this->stunTimer & 1) { + this->actor.shape.rot.y += 2000; + } else { + this->actor.shape.rot.y -= 2000; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975720.s") +void EnSsh_UpdateYaw(EnSsh* this, GlobalContext* globalCtx) { + if (this->stunTimer != 0) { + EnSsh_Stunned(this, globalCtx); + } else { + EnSsh_Turn(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_809758B0.s") +void EnSsh_Bob(EnSsh* this, GlobalContext* globalCtx) { + f32 bobVel = 0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975998.s") + if (globalCtx->state.frames & 8) { + bobVel *= -1.0f; + } + Math_SmoothStepToF(&this->actor.velocity.y, bobVel, 0.4f, 1000.0f, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975A98.s") +s32 EnSsh_IsCloseToLink(EnSsh* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 yDist; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975B6C.s") + if (this->stateFlags & SSH_STATE_GROUND_START) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975C14.s") + if (this->unkTimer != 0) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/EnSsh_Update.s") + if (this->swayTimer != 0) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975DBC.s") + if (this->animTimer != 0) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/func_80975EB8.s") + if (this->actor.xzDistToPlayer > 160.0f) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ssh/EnSsh_Draw.s") + yDist = this->actor.world.pos.y - player->actor.world.pos.y; + if ((yDist < 0.0f) || (yDist > 400.0f)) { + return false; + } + + if (player->actor.world.pos.y < this->actor.floorHeight) { + return false; + } + + return true; +} + +s32 EnSsh_IsCloseToHome(EnSsh* this) { + f32 vel = this->actor.velocity.y; + f32 nextY = this->actor.world.pos.y + vel * 2.0f; + + if (this->actor.home.pos.y <= nextY) { + return true; + } + return false; +} + +s32 EnSsh_IsCloseToGround(EnSsh* this) { + f32 vel = this->actor.velocity.y; + f32 nextY = this->actor.world.pos.y + vel * 2.0f; + + if ((nextY - this->actor.floorHeight) <= this->floorHeightOffset) { + return true; + } + return false; +} + +void EnSsh_Sway(EnSsh* this) { + Vec3f swayVecBase; + Vec3f swayVec; + f32 temp_f20; + s16 swayAngle; + + if (this->swayTimer != 0) { + this->swayAngle += 1600; + this->swayTimer--; + if (this->swayTimer == 0) { + this->swayAngle = 0; + } + + temp_f20 = (this->swayTimer * (1.0f / 6)); + swayAngle = Math_SinS(this->swayAngle) * (temp_f20 * (0x10000 / 360.0f)); + temp_f20 = this->actor.world.pos.y - this->ceilingPos.y; + + swayVecBase.x = Math_SinS(swayAngle) * temp_f20; + swayVecBase.y = Math_CosS(swayAngle) * temp_f20; + swayVecBase.z = 0.0f; + + Matrix_StatePush(); + Matrix_InsertTranslation(this->ceilingPos.x, this->ceilingPos.y, this->ceilingPos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f(this->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&swayVecBase, &swayVec); + Matrix_StatePop(); + + this->actor.shape.rot.z = -(swayAngle * 2); + this->actor.world.pos.x = swayVec.x; + this->actor.world.pos.z = swayVec.z; + } +} + +void EnSsh_CheckBodyStickHit(EnSsh* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + ColliderInfo* colliderInfo = &this->collider1[0].info; + + if (player->unk_B28 != 0) { + colliderInfo->bumper.dmgFlags |= 2; + this->collider1[1].info.bumper.dmgFlags &= ~2; + this->collider1[2].info.bumper.dmgFlags &= ~2; + } else { + colliderInfo->bumper.dmgFlags &= ~2; + this->collider1[1].info.bumper.dmgFlags |= 2; + this->collider1[2].info.bumper.dmgFlags |= 2; + } +} + +s32 EnSsh_CheckHitPlayer(EnSsh* this, GlobalContext* globalCtx) { + s32 i; + s32 hit = false; + + if ((this->hitCount == 0) && (this->spinTimer == 0)) { + return false; + } + + for (i = 0; i < ARRAY_COUNT(this->collider1) / 2; i++) { + if (this->collider1[3 + i].base.ocFlags2 & OC2_HIT_PLAYER) { + this->collider1[3 + i].base.ocFlags2 &= ~OC2_HIT_PLAYER; + hit = true; + } + } + + if (!hit) { + return false; + } + + this->hitTimer = 30; + if (this->swayTimer == 0) { + this->spinTimer = this->hitTimer; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_ST_ATTACK); + + globalCtx->damagePlayer(globalCtx, -8); + + func_800B8D98(globalCtx, &this->actor, 4.0f, this->actor.yawTowardsPlayer, 6.0f); + this->hitCount--; + return true; +} + +s32 EnSsh_CheckHitFront(EnSsh* this) { + u32 acFlags; + + if (this->collider1[2].base.acFlags) {} + acFlags = this->collider1[2].base.acFlags; + + if (!!(acFlags & AC_HIT) == 0) { + return false; + } + + this->collider1[2].base.acFlags &= ~AC_HIT; + this->invincibilityTimer = 8; + + if ((this->swayTimer == 0) && (this->hitTimer == 0) && (this->stunTimer == 0)) { + this->swayTimer = 60; + } + + return true; +} + +s32 EnSsh_CheckHitBack(EnSsh* this, GlobalContext* globalCtx) { + ColliderCylinder* collider = &this->collider1[0]; + s32 hit = false; + + if (collider->base.acFlags & AC_HIT) { + collider->base.acFlags &= ~AC_HIT; + hit = true; + } + + collider = &this->collider1[1]; + if (collider->base.acFlags & AC_HIT) { + collider->base.acFlags &= ~AC_HIT; + hit = true; + } + + if (!hit) { + return false; + } + + this->invincibilityTimer = 8; + if (this->hitCount <= 0) { + this->hitCount++; + } + + if (this->stunTimer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_ST_DAMAGE); + } + + EnSsh_SetStunned(this); + this->stateFlags |= SSH_STATE_STUNNED; + return false; +} + +s32 EnSsh_CollisionCheck(EnSsh* this, GlobalContext* globalCtx) { + if (this->stunTimer == 0) { + EnSsh_CheckHitPlayer(this, globalCtx); + } + + if (EnSsh_CheckHitFront(this)) { + return false; + } + + if (globalCtx->actorCtx.unk2 != 0) { + this->invincibilityTimer = 8; + if (this->stunTimer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_ST_DAMAGE); + } + EnSsh_SetStunned(this); + this->stateFlags |= SSH_STATE_STUNNED; + return false; + } + + return EnSsh_CheckHitBack(this, globalCtx); +} + +void EnSsh_SetBodyCylinderAC(EnSsh* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider1[0]); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1[0].base); +} + +void EnSsh_SetLegsCylinderAC(EnSsh* this, GlobalContext* globalCtx) { + s16 angleTowardsLink = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)); + + if (angleTowardsLink < (90 * (0x10000 / 360))) { + Collider_UpdateCylinder(&this->actor, &this->collider1[2]); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1[2].base); + } else { + Collider_UpdateCylinder(&this->actor, &this->collider1[1]); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1[1].base); + } +} + +s32 EnSsh_SetCylinderOC(EnSsh* this, GlobalContext* globalCtx) { + Vec3f colliderOffsets[] = { { 40.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { -40.0f, 0.0f, 0.0f } }; + Vec3f colliderPos; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->collider1) / 2; i++) { + colliderPos = this->actor.world.pos; + + colliderOffsets[i].x *= this->colliderScale; + colliderOffsets[i].y *= this->colliderScale; + colliderOffsets[i].z *= this->colliderScale; + + Matrix_StatePush(); + Matrix_InsertTranslation(colliderPos.x, colliderPos.y, colliderPos.z, MTXMODE_NEW); + Matrix_InsertYRotation_f(BINANG_TO_RAD(this->initialYaw), MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&colliderOffsets[i], &colliderPos); + Matrix_StatePop(); + + this->collider1[3 + i].dim.pos.x = colliderPos.x; + this->collider1[3 + i].dim.pos.y = colliderPos.y; + this->collider1[3 + i].dim.pos.z = colliderPos.z; + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1[3 + i].base); + } + + return true; +} + +void EnSsh_SetColliders(EnSsh* this, GlobalContext* globalCtx) { + if (this->actor.colChkInfo.health == 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + return; + } + + if (this->hitTimer == 0) { + EnSsh_SetCylinderOC(this, globalCtx); + } + + if (DECR(this->invincibilityTimer) == 0) { + EnSsh_SetBodyCylinderAC(this, globalCtx); + EnSsh_SetLegsCylinderAC(this, globalCtx); + } +} + +void EnSsh_Init(Actor* thisx, GlobalContext* globalCtx) { + // @bug - this symbol no longer exists, reads from a random place in object_ssh_Tex_000190 instead + f32 frameCount = Animation_GetLastFrame(&D_06000304); + s32 pad; + EnSsh* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_ssh_Skel_006470, NULL, this->jointTable, this->morphtable, 30); + Animation_Change(&this->skelAnime, &object_ssh_Anim_001494, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP_INTERP, 0.0f); + this->blureIdx = EnSsh_CreateBlureEffect(globalCtx); + EnSsh_InitColliders(this, globalCtx); + this->stateFlags = 0; + this->hitCount = 0; + EnSsh_CheckCeilingPos(this, globalCtx); + + if (!ENSSH_IS_CHILD(&this->actor)) { + this->stateFlags |= SSH_STATE_FATHER; + } + + if (!(this->stateFlags & SSH_STATE_FATHER)) { + EnSsh_SetColliderScale(this, 0.5f, 1.0f); + } else { + EnSsh_SetColliderScale(this, 0.75f, 1.0f); + } + + this->actor.gravity = 0.0f; + this->initialYaw = this->actor.world.rot.y; + EnSsh_SetupAction(this, EnSsh_Start); + if (func_8012F22C(globalCtx->sceneNum) >= 30) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnSsh_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSsh* this = THIS; + s32 i; + + Effect_Destroy(globalCtx, this->blureIdx); + + for (i = 0; i < ARRAY_COUNT(this->collider1); i++) { + Collider_DestroyCylinder(globalCtx, &this->collider1[i]); + } + + Collider_DestroyJntSph(globalCtx, &this->collider2); +} + +void EnSsh_Wait(EnSsh* this, GlobalContext* globalCtx) { + if (EnSsh_IsCloseToLink(this, globalCtx)) { + EnSsh_SetDropAnimation(this); + EnSsh_SetupAction(this, EnSsh_Drop); + } else { + EnSsh_Bob(this, globalCtx); + } +} + +void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { + EnSsh_Bob(this, globalCtx); + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x904: + case 0x905: + case 0x906: + case 0x908: + case 0x910: + case 0x911: + case 0x912: + case 0x914: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = EnSsh_Idle; + break; + } + } +} + +void func_809756D0(EnSsh* this, GlobalContext* globalCtx) { + u16 phi_a1; + + if (gSaveContext.weekEventReg[34] & 8) { + phi_a1 = 0x914; + } else { + phi_a1 = 0x910; + gSaveContext.weekEventReg[34] |= 8; + } + func_801518B0(globalCtx, phi_a1, &this->actor); +} + +void EnSsh_Idle(EnSsh* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = EnSsh_Talk; + func_809756D0(this, globalCtx); + return; + } + + if ((this->unkTimer != 0) && (DECR(this->unkTimer) == 0)) { + EnSsh_SetAnimation(this, SSH_ANIM_WAIT); + } + + if ((this->animTimer != 0) && (DECR(this->animTimer) == 0)) { + EnSsh_SetAnimation(this, SSH_ANIM_WAIT); + } + + if (!EnSsh_IsCloseToLink(this, globalCtx)) { + EnSsh_SetReturnAnimation(this); + EnSsh_SetupAction(this, EnSsh_Return); + return; + } + + if (DECR(this->sfxTimer) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_LAUGH); + this->sfxTimer = 64; + } + + EnSsh_Bob(this, globalCtx); + + if ((this->unkTimer == 0) && (this->animTimer == 0) && (this->actor.xzDistToPlayer < 100.0f) && + Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } +} + +void EnSsh_Land(EnSsh* this, GlobalContext* globalCtx) { + if ((this->unkTimer != 0) && (DECR(this->unkTimer) == 0)) { + EnSsh_SetAnimation(this, SSH_ANIM_WAIT); + } + + if ((this->animTimer != 0) && (DECR(this->animTimer) == 0)) { + EnSsh_SetAnimation(this, SSH_ANIM_WAIT); + } + + if ((this->actor.floorHeight + this->floorHeightOffset) <= this->actor.world.pos.y) { + EnSsh_SetupAction(this, EnSsh_Idle); + } else { + Math_SmoothStepToF(&this->actor.velocity.y, 2.0f, 0.6f, 1000.0f, 0.0f); + } +} + +void EnSsh_Drop(EnSsh* this, GlobalContext* globalCtx) { + if ((this->unkTimer != 0) && (DECR(this->unkTimer) == 0)) { + EnSsh_SetAnimation(this, SSH_ANIM_DROP); + } + + if (!EnSsh_IsCloseToLink(this, globalCtx)) { + EnSsh_SetReturnAnimation(this); + EnSsh_SetupAction(this, EnSsh_Return); + } else if (EnSsh_IsCloseToGround(this)) { + EnSsh_SpawnShockwave(this, globalCtx); + EnSsh_SetLandAnimation(this); + EnSsh_SetupAction(this, EnSsh_Land); + } else if (DECR(this->sfxTimer) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_DOWN); + this->sfxTimer = 3; + } +} + +void EnSsh_Return(EnSsh* this, GlobalContext* globalCtx) { + f32 frameRatio = this->skelAnime.curFrame / (this->skelAnime.animLength - 1.0f); + + if (frameRatio == 1.0f) { + EnSsh_SetReturnAnimation(this); + } + + if (EnSsh_IsCloseToLink(this, globalCtx)) { + EnSsh_SetDropAnimation(this); + EnSsh_SetupAction(this, EnSsh_Drop); + } else if (EnSsh_IsCloseToHome(this)) { + EnSsh_SetWaitAnimation(this); + EnSsh_SetupAction(this, EnSsh_Wait); + } else { + this->actor.velocity.y = 4.0f * frameRatio; + } +} + +void EnSsh_UpdateColliderScale(EnSsh* this) { + if (this->stateFlags & SSH_STATE_SPIN) { + if (this->spinTimer == 0) { + this->stateFlags &= ~SSH_STATE_SPIN; + if (!(this->stateFlags & SSH_STATE_FATHER)) { + EnSsh_SetColliderScale(this, 0.5f, 1.0f); + } else { + EnSsh_SetColliderScale(this, 0.75f, 1.0f); + } + } + } else if (this->spinTimer != 0) { + this->stateFlags |= SSH_STATE_SPIN; + if (!(this->stateFlags & SSH_STATE_FATHER)) { + EnSsh_SetColliderScale(this, 0.5f, 2.0f); + } else { + EnSsh_SetColliderScale(this, 0.75f, 2.0f); + } + } +} + +void EnSsh_Start(EnSsh* this, GlobalContext* globalCtx) { + if (!EnSsh_IsCloseToGround(this)) { + EnSsh_SetupAction(this, EnSsh_Wait); + EnSsh_Wait(this, globalCtx); + } else { + EnSsh_SetLandAnimation(this); + this->stateFlags |= SSH_STATE_GROUND_START; + EnSsh_SetupAction(this, EnSsh_Land); + EnSsh_Land(this, globalCtx); + } +} + +void EnSsh_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSsh* this = THIS; + + EnSsh_UpdateColliderScale(this); + + if (EnSsh_CollisionCheck(this, globalCtx)) { + return; + } + + if (this->stunTimer != 0) { + EnSsh_Damaged(this); + } else { + SkelAnime_Update(&this->skelAnime); + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + this->actionFunc(this, globalCtx); + } + + EnSsh_UpdateYaw(this, globalCtx); + + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(60, 60); + } + + this->blinkState = this->blinkTimer; + if (this->blinkState >= 3) { + this->blinkState = 0; + } + + EnSsh_SetColliders(this, globalCtx); + Actor_SetFocus(&this->actor, 0.0f); +} + +s32 EnSsh_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnSsh* this = THIS; + + switch (limbIndex) { + case 1: + if ((this->spinTimer != 0) && (this->swayTimer == 0)) { + if (this->spinTimer >= 2) { + EnSsh_AddBlureVertex(this); + } else { + EnSsh_AddBlureSpace(this); + } + } + break; + + case 4: + if (this->stateFlags & SSH_STATE_FATHER) { + *dList = object_ssh_DL_005850; + } + break; + + case 5: + if (this->stateFlags & SSH_STATE_FATHER) { + *dList = object_ssh_DL_005210; + } + break; + + case 8: + if (this->stateFlags & SSH_STATE_FATHER) { + *dList = object_ssh_DL_005F78; + } + break; + } + return false; +} + +void EnSsh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnSsh* this = THIS; + + if ((limbIndex == 5) && (this->stateFlags & SSH_STATE_FATHER)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, object_ssh_DL_0000D8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + Collider_UpdateSpheres(limbIndex, &this->collider2); +} + +void EnSsh_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr D_80976178[] = { object_ssh_Tex_001970, object_ssh_Tex_001DF0, object_ssh_Tex_0021F0 }; + s32 pad; + EnSsh* this = THIS; + + EnSsh_CheckBodyStickHit(this, globalCtx); + EnSsh_Sway(this); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_80976178[this->blinkState])); + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSsh_OverrideLimbDraw, + EnSsh_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h index 7d081f88c2..172ecf0a51 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h @@ -7,11 +7,53 @@ struct EnSsh; typedef void (*EnSshActionFunc)(struct EnSsh*, GlobalContext*); +#define SSH_STATE_STUNNED (1 << 0) +#define SSH_STATE_GROUND_START (1 << 2) +#define SSH_STATE_ATTACKED (1 << 3) +#define SSH_STATE_SPIN (1 << 4) +#define SSH_STATE_FATHER (1 << 5) + +typedef enum { + SSH_ANIM_UNK0, // Unused animation. Possibly being knocked back? + SSH_ANIM_UP, + SSH_ANIM_WAIT, + SSH_ANIM_LAND, + SSH_ANIM_DROP, + SSH_ANIM_UNK5, // Slower version of ANIM_DROP + SSH_ANIM_UNK6 // Faster repeating version of ANIM_UNK0 +} EnSshAnimation; + +#define ENSSH_IS_CHILD(thisx) ((thisx)->params & 0xF) + typedef struct EnSsh { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1AC]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[30]; + /* 0x023C */ Vec3s morphtable[30]; /* 0x02F0 */ EnSshActionFunc actionFunc; - /* 0x02F4 */ char unk_2F4[0x2D8]; + /* 0x02F4 */ ColliderCylinder collider1[6]; + /* 0x04BC */ ColliderJntSph collider2; + /* 0x04DC */ ColliderJntSphElement collider2Elements[1]; + /* 0x051C */ s16 initialYaw; + /* 0x051E */ s16 maxTurnRate; + /* 0x0520 */ s16 unkTimer; + /* 0x0522 */ s16 spinTimer; + /* 0x0524 */ s16 hitTimer; + /* 0x0526 */ s16 invincibilityTimer; + /* 0x0528 */ s16 sfxTimer; + /* 0x052A */ s16 stunTimer; + /* 0x052C */ s16 animTimer; + /* 0x052E */ s16 swayTimer; + /* 0x0530 */ s32 blureIdx; + /* 0x0534 */ f32 colliderScale; + /* 0x0538 */ f32 floorHeightOffset; + /* 0x053C */ Vec3f ceilingPos; + /* 0x0548 */ UNK_TYPE1 unk_548[0x78]; + /* 0x05C0 */ s16 swayAngle; + /* 0x05C2 */ u16 stateFlags; + /* 0x05C4 */ u8 hitCount; + /* 0x05C6 */ s16 blinkState; + /* 0x05C8 */ s16 blinkTimer; } EnSsh; // size = 0x5CC extern const ActorInit En_Ssh_InitVars; diff --git a/src/overlays/actors/ovl_En_St/z_en_st.c b/src/overlays/actors/ovl_En_St/z_en_st.c index c8335d92c1..4d6520bb3a 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -5,6 +5,8 @@ */ #include "z_en_st.h" +#include "objects/object_st/object_st.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x01004035 @@ -19,8 +21,8 @@ void func_808A6C04(EnSt* this, GlobalContext* globalCtx); void func_808A6D84(EnSt* this, GlobalContext* globalCtx); void func_808A6E24(EnSt* this, GlobalContext* globalCtx); void func_808A701C(EnSt* this, GlobalContext* globalCtx); +void func_808A7478(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_St_InitVars = { ACTOR_EN_ST, ACTORCAT_ENEMY, @@ -33,39 +35,89 @@ const ActorInit En_St_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808A75B0 = { - { COLTYPE_HIT2, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x800C3829, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HIT2, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x800C3829, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 18, 48, -20, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808A75DC = { - { COLTYPE_HIT2, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x77C3C7D6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT2, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x77C3C7D6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 18, 48, -20, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808A7608 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0x77C3C7D6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit3 = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0x77C3C7D6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 18, 48, -20, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808A7634 = { - { COLTYPE_HIT2, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x800C3829, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit4 = { + { + COLTYPE_HIT2, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x800C3829, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 18, 48, -20, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_808A7660 = { 2, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 2, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_808A766C = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -100,73 +152,791 @@ static DamageTable D_808A766C = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -#endif +static ActorAnimationEntryS sAnimations[] = { + { &object_st_Anim_000304, 1.0f, 0, -1, 0, 0 }, { &object_st_Anim_005B98, 1.0f, 0, -1, 2, -4 }, + { &object_st_Anim_000304, 4.0f, 0, -1, 2, -4 }, { &object_st_Anim_000304, 1.0f, 0, -1, 0, -4 }, + { &object_st_Anim_0055A8, 1.0f, 0, -1, 2, -4 }, { &object_st_Anim_000304, 8.0f, 0, -1, 0, -4 }, + { &object_st_Anim_000304, 6.0f, 0, -1, 2, -4 }, { &object_st_Anim_005B98, 2.0f, 0, -1, 0, -4 }, +}; -extern ColliderCylinderInit D_808A75B0; -extern ColliderCylinderInit D_808A75DC; -extern ColliderCylinderInit D_808A7608; -extern ColliderCylinderInit D_808A7634; -extern CollisionCheckInfoInit2 D_808A7660; -extern DamageTable D_808A766C; +void func_808A5050(EnSt* this, GlobalContext* globalCtx) { + static Color_RGBA8 D_808A770C = { 170, 130, 90, 255 }; + static Color_RGBA8 D_808A7710 = { 100, 60, 20, 0 }; + s32 i; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + s32 rand; + s16 temp_s0 = (Rand_ZeroOne() - 0.5f) * 0x10000; -extern UNK_TYPE D_06005298; + spA0.y = this->actor.floorHeight; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5050.s") + for (i = 0; i < 16; i++, temp_s0 += 0xFFF) { + rand = (Rand_ZeroOne() * 4.0f) + 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A52A8.s") + sp94.x = 0.0f; + sp94.y = (Rand_ZeroOne() * 0.2f) + 0.1f; + sp94.z = Rand_ZeroOne() + 1.0f; + Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, temp_s0, &sp94, &spAC); + sp94.x = 0.0f; + sp94.y = 1.0f; + sp94.z = 5.0f; + Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, temp_s0, &sp94, &spB8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A54B0.s") + spA0.x = this->actor.world.pos.x + (2.0f * spB8.x); + spA0.z = this->actor.world.pos.z + (2.0f * spB8.z); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A576C.s") + func_800B0EB0(globalCtx, &spA0, &spB8, &spAC, &D_808A770C, &D_808A7710, 100, 40, rand); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5988.s") + spA0.x = this->actor.world.pos.x; + spA0.z = this->actor.world.pos.z; + spA0.y = this->actor.floorHeight; + EffectSsBlast_SpawnWhiteCustomScale(globalCtx, &spA0, &gZeroVec3f, &gZeroVec3f, 100, 220, 8); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5AF8.s") +void func_808A52A8(EnSt* this, GlobalContext* globalCtx) { + static Color_RGBA8 D_808A7714 = { 170, 130, 90, 255 }; + static Color_RGBA8 D_808A7718 = { 100, 60, 20, 0 }; + s32 pad; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + s32 i; + s16 temp_s0 = (Rand_ZeroOne() - 0.5f) * 0x10000; + s32 rand; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5BEC.s") + spA0.y = this->actor.floorHeight; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5CCC.s") + for (i = 0; i < 8; i++, temp_s0 += 0x1FFE) { + rand = (Rand_ZeroOne() * 4.0f) + 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5D7C.s") + sp94.x = 0.0f; + sp94.y = (Rand_ZeroOne() * 0.2f) + 0.1f; + sp94.z = Rand_ZeroOne() + 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5DCC.s") + Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, temp_s0, &sp94, &spAC); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A5F28.s") + sp94.x = 0.0f; + sp94.y = 1.0f; + sp94.z = 4.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6064.s") + Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, temp_s0, &sp94, &spB8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A60E0.s") + spA0.x = this->actor.world.pos.x + (2.0f * spB8.x); + spA0.z = this->actor.world.pos.z + (2.0f * spB8.z); + func_800B0EB0(globalCtx, &spA0, &spB8, &spAC, &D_808A7714, &D_808A7718, 100, 40, rand); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A61F4.s") +void func_808A54B0(EnSt* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6220.s") + if ((this->unk_18C & 1) && (this->actor.colChkInfo.health != 0)) { + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A63E8.s") + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[this->unk_2C0].segment); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6468.s") + gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_2C0].segment); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A650C.s") + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.06f, 0.12f, 0.06f, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6580.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 195, 0, 0x40, 0x20, 1, 215, 0, 8, 8)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6A3C.s") + temp_f0 = (f32)this->unk_310 / 8; + if (temp_f0 > 1.0f) { + temp_f0 = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6A78.s") + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u8)(255 * temp_f0)); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_025850); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_025970); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6C04.s") + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6D84.s") +s32 func_808A576C(EnSt* this) { + s32 i; + s16 phi_s2 = (s16)((s16)(Rand_ZeroOne() * 1000.0f) % 12) * 0x1555; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A6E24.s") + for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++, phi_s2 += 0x1555) { + if (this->unk_18E != 10) { + this->unk_31C[i] = (Rand_ZeroOne() * 16.0f) + 8.0f; + } else { + this->unk_31C[i] = 80; + } + this->unk_334[i] = this->unk_31C[i]; + this->unk_2DC[i] = 0.90000004f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A701C.s") + if ((this->unk_18E == 0) || (this->unk_18E == 1)) { + this->unk_358[i].y = ((Rand_ZeroOne() - 0.5f) * 40.0f) - 10.0f; + } else { + this->unk_358[i].y = ((Rand_ZeroOne() - 0.5f) * 30.0f) + 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/EnSt_Init.s") + this->unk_358[i].x = Math_SinS(phi_s2) * 18.0f; + this->unk_358[i].z = Math_CosS(phi_s2) * 18.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/EnSt_Destroy.s") + this->unk_31A = 1; + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/EnSt_Update.s") +s32 func_808A5988(EnSt* this, GlobalContext* globalCtx, s32 arg2) { + s32 ret = false; + u8 sp53; + Vec3f sp44; + f32 sp40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A73E8.s") + if (arg2 < this->unk_31A) { + if (this->unk_31C[arg2] != 0) { + sp40 = (f32)this->unk_31C[arg2] / this->unk_334[arg2]; + sp53 = this->unk_18E; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_St/func_808A7478.s") + Math_ApproachF(&this->unk_2DC[arg2], 0.6f, 0.3f, 0.5f); + Math_Vec3f_Copy(&sp44, &this->actor.world.pos); + + sp44.x += this->unk_358[arg2].x; + sp44.y += this->unk_358[arg2].y; + sp44.z += this->unk_358[arg2].z; + + if (sp53 == 10) { + if ((this->unk_334[arg2] - this->unk_31C[arg2]) < 20) { + sp53 = 11; + } + sp40 = 1.0f; + } + func_800BE680(globalCtx, &this->actor, &sp44, 1, 0.6f, this->unk_2DC[arg2], sp40, sp53); + ret = true; + } + } + return ret; +} + +void func_808A5AF8(EnSt* this, GlobalContext* globalCtx) { + Vec3f sp54; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_358); i++) { + Math_Vec3f_Copy(&sp54, &this->actor.world.pos); + sp54.x += this->unk_358[i].x; + sp54.y += this->unk_358[i].y; + sp54.z += this->unk_358[i].z; + Math_Vec3f_Copy(&this->unk_358[i], &sp54); + } + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_358, 12, 3, 0.1f, 0.3f); +} + +s16 func_808A5BEC(EnSt* this) { + s16 ret; + + if (!(this->unk_18C & 4) || (this->actor.xzDistToPlayer > 180.0f)) { + ret = this->actor.home.rot.y; + } else { + ret = this->actor.yawTowardsPlayer; + if (DECR(this->unk_30E) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_ROLL); + this->unk_18C ^= 2; + this->unk_310 = 8; + if (this->unk_18C & 1) { + this->unk_310 *= 2; + } + this->unk_30E = 30; + } + + if (this->unk_18C & 2) { + ret = BINANG_ROT180(ret); + } + } + + return ret; +} + +void func_808A5CCC(EnSt* this) { + if (this->unk_310 != 0) { + this->unk_310--; + } + + if (this->unk_310 < 8) { + Math_ApproachS(&this->actor.world.rot.y, func_808A5BEC(this), 3, 0x1FFE); + } else { + this->actor.world.rot.y += 0x2AA8; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (DECR(this->unk_310) == 0) { + this->unk_18C &= ~1; + } +} + +void func_808A5D7C(EnSt* this) { + if (this->unk_2C8 > 0.0f) { + this->actor.world.pos.y = this->actor.home.pos.y - 10.0f; + } else { + this->actor.world.pos.y = this->actor.floorHeight + 20.0f; + } +} + +void func_808A5DCC(EnSt* this, Color_RGB8* colour) { + if (this->unk_2D8 == 0.0f) { + Math_SmoothStepToF(&this->unk_34C, 0.0f, 0.3f, 1000.0f, 0.0f); + } else { + this->unk_34C += this->unk_2D8; + if (this->unk_34C >= 255.0f) { + this->unk_34C = 255.0f; + this->unk_2D8 *= -1.0f; + } + + if (this->unk_34C <= 0.0f) { + this->unk_34C = 0.0f; + this->unk_2D8 *= -1.0f; + } + } + + colour->r = this->unk_34C; + colour->g = 0; + colour->b = 0; +} + +s32 func_808A5F28(EnSt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 ret = false; + + if (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) { + if (this->unk_2C8 <= 0.0f) { + return false; + } + return true; + } + + if ((((this->unk_2C8 > 0.0f) && (this->actor.world.pos.y < player->actor.world.pos.y)) || + ((this->unk_2C8 > 0.0f) && (this->actor.xzDistToPlayer > 180.0f)) || + ((this->unk_2C8 < 0.0f) && (player->actor.world.pos.y <= this->actor.world.pos.y) && + (this->actor.floorHeight <= player->actor.world.pos.y) && (this->actor.xzDistToPlayer < 120.0f))) && + !(this->unk_18C & 8)) { + ret = true; + } + + return ret; +} + +s32 func_808A6064(EnSt* this) { + s32 ret = false; + + if (this->unk_2C8 > 0.0f) { + if ((this->actor.home.pos.y - 10.0f) < this->actor.world.pos.y) { + ret = true; + } + } else if (this->actor.world.pos.y < (this->actor.floorHeight + 20.0f)) { + ret = true; + } + return ret; +} + +void func_808A60E0(EnSt* this) { + s32 idx = (this->unk_2C8 > 0.0f) ? 2 : 6; + f32 sp20 = (this->unk_2C8 > 0.0f) ? 4.0f : 9.0f; + f32 sp1C; + u16 sfxId = (this->unk_2C8 < 0.0f) ? NA_SE_EN_STALTU_DOWN : NA_SE_EN_STALTU_UP; + + sp1C = this->skelAnime.curFrame / (this->skelAnime.animLength - 1.0f); + + if (sp1C == 1.0f) { + func_8013BC6C(&this->skelAnime, sAnimations, idx); + Actor_PlaySfxAtPos(&this->actor, sfxId); + } + + this->unk_2D4 = (1.0f - sp1C) * sp20 * this->unk_2C8; + + if (this->unk_2C8 < 0.0f) { + this->unk_2D4 = this->unk_2C8 * sp20; + } +} + +s32 func_808A61F4(EnSt* this) { + if (this->actor.colChkInfo.damage < this->actor.colChkInfo.health) { + this->actor.colChkInfo.health -= this->actor.colChkInfo.damage; + } else { + this->actor.colChkInfo.health = 0; + } + return this->actor.colChkInfo.health; +} + +void func_808A6220(EnSt* this, GlobalContext* globalCtx) { + s32 pad; + + if ((DECR(this->unk_314) == 0) && (this->actor.colChkInfo.health != 0)) { + Collider_UpdateCylinder(&this->actor, &this->collider2); + Collider_UpdateCylinder(&this->actor, &this->collider3); + Collider_UpdateCylinder(&this->actor, &this->collider4); + if ((s16)ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)) < 0x4E00) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider3.base); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider4.base); + } + + if (this->actor.colChkInfo.health != 0) { + Collider_UpdateCylinder(&this->actor, &this->collider1); + if (((this->unk_2C8 < 0.0f) && (this->unk_18C & 0x10)) || (this->unk_18C & 1)) { + this->collider1.dim.yShift = -40; + this->collider1.dim.radius = 56; + this->collider1.dim.height = 80; + } else { + this->collider1.dim.yShift = -20; + this->collider1.dim.radius = 18; + this->collider1.dim.height = 48; + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + } +} + +void func_808A63E8(EnSt* this) { + func_8013BC6C(&this->skelAnime, sAnimations, 3); + this->unk_2C8 = 1.0f; + func_808A5D7C(this); + this->unk_30C = 0; + this->unk_18C &= ~0x10; + this->unk_2C8 = -1.0f; + this->unk_2D4 = 0.0f; + this->unk_2CC = 0.0f; + this->unk_2C4 = 1.0f; +} + +void func_808A6468(EnSt* this, GlobalContext* globalCtx) { + func_808A5050(this, globalCtx); + func_8013BC6C(&this->skelAnime, sAnimations, 4); + this->unk_18C |= (0x8 | 0x4); + this->unk_18C &= ~(0x10 | 0x2); + this->unk_2C8 = -1.0f; + func_808A5D7C(this); + this->unk_30E = 30; + this->unk_30C = 0; + this->unk_2C8 = 1.0f; + this->unk_2D8 = 30.0f; + this->unk_2D4 = 0.0f; + this->unk_2CC = 0.0f; + this->unk_2C4 = 6.0f; +} + +void func_808A650C(EnSt* this) { + s32 idx = (this->unk_2C8 > 0.0f) ? 2 : 6; + + func_8013BC6C(&this->skelAnime, sAnimations, idx); + this->unk_2CC = 0.0f; + this->unk_2D4 = 0.0f; + this->unk_2D8 = 0.0f; + this->unk_18C &= ~4; + this->unk_18C |= 0x10; +} + +s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { + Player* sp3C = GET_PLAYER(globalCtx); + s32 ret = false; + s32 i; + + if (this->unk_316 != 0) { + this->unk_316--; + } + + if (this->collider3.base.acFlags & AC_HIT) { + if (this->unk_18E == 10) { + // clang-format off + for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { this->unk_31C[i] = 0; } + // clang-format on + + this->unk_318 = 0; + } + + if (this->actor.colChkInfo.damageEffect == 4) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + this->collider3.base.acFlags &= ~AC_HIT; + } + + if ((this->collider2.base.acFlags & AC_HIT) || (this->collider4.base.acFlags & AC_HIT)) { + this->collider2.base.acFlags &= ~AC_HIT; + this->collider4.base.acFlags &= ~AC_HIT; + if (this->actor.colChkInfo.damageEffect == 4) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + + if (this->unk_18E == 10) { + // clang-format off + for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { this->unk_31C[i] = 0; } + // clang-format on + + this->unk_318 = 0; + } else if (func_808A61F4(this)) { + switch (this->actor.colChkInfo.damageEffect) { + case 1: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->unk_312 = 40; + Actor_SetColorFilter(&this->actor, 0, 200, 0, this->unk_312); + break; + + case 5: + this->unk_18E = 30; + this->unk_312 = 40; + func_808A576C(this); + Actor_SetColorFilter(&this->actor, 0, 200, 0, this->unk_312); + break; + + default: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_DAMAGE); + this->unk_314 = 20; + this->unk_312 = 0; + Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->unk_314); + func_8013BC6C(&this->skelAnime, sAnimations, 1); + this->unk_18C |= 8; + this->actionFunc = func_808A6D84; + this->unk_2C8 = -1.0f; + break; + } + } else { + if (ENST_GET_3F(&this->actor) != ENST_3F_63) { + Flags_SetSwitch(globalCtx, ENST_GET_3F(&this->actor)); + } + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALTU_DEAD); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + + this->actor.flags &= ~1; + + switch (this->actor.colChkInfo.damageEffect) { + case 4: + this->unk_18E = 20; + this->unk_318 = 20; + func_808A576C(this); + break; + + case 3: + this->unk_18E = 10; + this->unk_318 = 0; + func_808A576C(this); + break; + + case 2: + this->unk_18E = 0; + this->unk_318 = 20; + func_808A576C(this); + break; + + default: + this->unk_18E = 1; + this->unk_318 = 0; + break; + } + + if (this->unk_18E != 10) { + func_8013BC6C(&this->skelAnime, sAnimations, 7); + this->unk_2CC = 0.0f; + this->unk_2D4 = 0.0f; + this->actor.gravity = -1.0f; + } + this->unk_314 = 20; + this->unk_312 = 0; + Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->unk_314); + ret = true; + } + this->unk_310 = 0; + this->unk_18C &= ~1; + } + + if ((this->collider1.base.ocFlags2 & OC2_HIT_PLAYER) || (this->collider1.base.atFlags & AT_HIT)) { + if ((this->unk_316 == 0) && (this->unk_314 == 0) && (this->unk_312 == 0) && + !(this->collider1.base.atFlags & AT_BOUNCED) && (this->actor.colChkInfo.health != 0)) { + globalCtx->damagePlayer(globalCtx, -8); + Actor_PlaySfxAtPos(&sp3C->actor, NA_SE_PL_BODY_HIT); + func_800B8D98(globalCtx, &this->actor, 4.0f, this->actor.yawTowardsPlayer, 6.0f); + this->unk_316 = 10; + this->unk_18C |= 1; + this->unk_30E = 0; + } + this->collider1.base.ocFlags1 &= ~OC1_HIT; + this->collider1.base.atFlags &= ~AT_HIT; + } + return ret; +} + +s32 func_808A6A3C(EnSt* this) { + s32 ret = false; + + if ((ENST_GET_1C0(&this->actor) == ENST_1C0_1) && (this->actor.colChkInfo.health != 0)) { + ret = true; + } + return ret; +} + +void func_808A6A78(EnSt* this, GlobalContext* globalCtx) { + s32 pad[2]; + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_2C0)) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 8.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_st_Skel_005298, NULL, this->jointTable, this->morphTable, + 30); + func_8013BC6C(&this->skelAnime, sAnimations, 0); + + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); + Collider_InitAndSetCylinder(globalCtx, &this->collider3, &this->actor, &sCylinderInit3); + Collider_InitAndSetCylinder(globalCtx, &this->collider4, &this->actor, &sCylinderInit4); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + if (ENST_GET_1C0(&this->actor) == ENST_1C0_1) { + this->actor.flags |= 0x80; + } + + Actor_SetScale(&this->actor, 0.04f); + this->actor.draw = func_808A7478; + this->actor.hintId = 4; + this->actor.gravity = 0.0f; + func_808A63E8(this); + this->unk_18C = 0; + this->unk_18C &= ~0x10; + this->actionFunc = func_808A6C04; + } +} + +void func_808A6C04(EnSt* this, GlobalContext* globalCtx) { + this->unk_2CC = Math_SinS(this->unk_30C) * this->unk_2C4; + this->unk_30C += 0xE00; + Math_ApproachF(&this->unk_2C4, 1.0f, 0.1f, 0.3f); + this->actor.velocity.y = this->unk_2D4 + this->unk_2CC; + Actor_MoveWithGravity(&this->actor); + + if ((this->unk_18C & 8) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_8013BC6C(&this->skelAnime, sAnimations, 3); + this->unk_18C &= ~8; + } else if ((this->unk_310 == 0) && func_808A5F28(this, globalCtx) && !func_808A6064(this)) { + func_808A650C(this); + this->actionFunc = func_808A6D84; + } else { + if ((this->unk_316 == 0) && (this->unk_314 == 0) && (this->unk_312 == 0) && (this->unk_2C8 > 0.0f) && + (this->actor.xzDistToPlayer < 62.0f)) { + this->unk_30E = 0; + this->unk_18C |= 1; + } + func_808A5CCC(this); + } +} + +void func_808A6D84(EnSt* this, GlobalContext* globalCtx) { + func_808A60E0(this); + this->actor.velocity.y = this->unk_2D4 + this->unk_2CC; + Actor_MoveWithGravity(&this->actor); + if (func_808A6064(this)) { + if (this->unk_2C8 < 0.0f) { + func_808A6468(this, globalCtx); + } else { + func_808A63E8(this); + } + this->actionFunc = func_808A6C04; + } + func_808A5CCC(this); +} + +void func_808A6E24(EnSt* this, GlobalContext* globalCtx) { + s32 i; + s32 count = 0; + + if (this->unk_18E == 10) { + for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { + if (DECR(this->unk_31C[i]) == 0) { + count++; + } + } + + if (count == ARRAY_COUNT(this->unk_31C)) { + func_8013BC6C(&this->skelAnime, sAnimations, 7); + this->unk_18E = 1; + this->unk_2CC = 0.0f; + this->unk_2D4 = 0.0f; + this->actor.gravity = -1.0f; + func_808A5AF8(this, globalCtx); + } + } else if (this->unk_18C & 0x80) { + this->actionFunc = func_808A701C; + this->actor.gravity = 0.0f; + this->unk_2CC = 0.0f; + this->unk_2D4 = 0.0f; + } else { + if (this->actor.bgCheckFlags & 1) { + this->actor.shape.yOffset = 400.0f; + this->actor.world.rot.x = 0x4000; + this->actor.shape.rot.x = this->actor.world.rot.x; + this->unk_2D0 = this->actor.velocity.y = fabsf(this->actor.velocity.y) * 0.6f; + this->actor.speedXZ = 0.0f; + + if ((s32)this->unk_2D0 != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + } else { + this->actor.velocity.y = 0.0f; + this->actionFunc = func_808A701C; + } + + if ((s32)this->actor.velocity.y >= 2) { + func_808A52A8(this, globalCtx); + } + } else { + Math_ApproachF(&this->actor.shape.yOffset, 400.0f, 0.3f, 1000.0f); + this->actor.world.rot.x += 0x1000; + if (this->actor.world.rot.x >= 0x4000) { + this->actor.world.rot.x = 0x4000; + } + this->actor.shape.rot.x = this->actor.world.rot.x; + } + Actor_MoveWithGravity(&this->actor); + } +} + +void func_808A701C(EnSt* this, GlobalContext* globalCtx) { + s32 i; + s32 count = 0; + + if (this->unk_18C & 0x40) { + if (DECR(this->unk_318) == 0) { + this->unk_18C |= 0x20; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { + if (DECR(this->unk_31C[i]) == 0) { + count++; + } + } + + if (count == ARRAY_COUNT(this->unk_31C)) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0); + Actor_MarkForDeath(&this->actor); + } + } else if (DECR(this->unk_318) == 0) { + this->unk_18C |= 0x40; + if (this->unk_18E == 1) { + func_808A576C(this); + this->unk_318 = 10; + } + } +} + +void EnSt_Init(Actor* thisx, GlobalContext* globalCtx) { + EnSt* this = THIS; + + this->unk_2C0 = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_KEEP); + if (((ENST_GET_3F(&this->actor) != ENST_3F_63) && Flags_GetSwitch(globalCtx, ENST_GET_3F(&this->actor))) || + (this->unk_2C0 < 0)) { + Actor_MarkForDeath(&this->actor); + } else { + this->actionFunc = func_808A6A78; + } +} + +void EnSt_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSt* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyCylinder(globalCtx, &this->collider2); + Collider_DestroyCylinder(globalCtx, &this->collider3); + Collider_DestroyCylinder(globalCtx, &this->collider4); +} + +void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSt* this = THIS; + + if (this->actor.flags & 0x8000) { + SkelAnime_Update(&this->skelAnime); + this->unk_18C |= 0x80; + return; + } + + if (!(this->actor.flags & 0x80) && func_808A6A3C(this)) { + this->actor.flags |= 0x80; + } + + if (func_808A6580(this, globalCtx)) { + this->actionFunc = func_808A6E24; + } else if (DECR(this->unk_312) == 0) { + this->actionFunc(this, globalCtx); + if (this->unk_18E != 10) { + SkelAnime_Update(&this->skelAnime); + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 5); + } else if (this->unk_312 < 20) { + s16 idx = (this->unk_312 % 2) ? -1 : 1; + + idx *= 0x800; + idx += this->actor.world.rot.y; + this->actor.shape.rot.y = idx; + + if (this->unk_18E == 30) { + if (this->unk_312 == 1) { + s32 i; + + // clang-format off + for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { this->unk_31C[i] = 0; } + // clang-format on + } + } + } + + Actor_SetFocus(&this->actor, 0.0f); + func_808A6220(this, globalCtx); +} + +s32 EnSt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnSt* this = THIS; + Color_RGB8 sp20; + + if (limbIndex == 4) { + func_808A5DCC(this, &sp20); + + gDPPipeSync((*gfx)++); + gDPSetEnvColor((*gfx)++, sp20.r, sp20.g, sp20.b, 0); + } + return false; +} + +void func_808A7478(Actor* thisx, GlobalContext* globalCtx) { + EnSt* this = THIS; + s32 i; + s32 count; + + if (!(this->unk_18C & 0x20)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (func_808A6A3C(this)) { + func_8012C2DC(globalCtx->state.gfxCtx); + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + EnSt_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); + } else { + func_8012C28C(globalCtx->state.gfxCtx); + POLY_OPA_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + EnSt_OverrideLimbDraw, NULL, &this->actor, POLY_OPA_DISP); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + for (i = 0, count = 0; i < ARRAY_COUNT(this->unk_31C); i++) { + count += func_808A5988(this, globalCtx, i); + } + + if (count != 0) { + this->unk_31A += 2; + } + + func_808A54B0(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_St/z_en_st.h b/src/overlays/actors/ovl_En_St/z_en_st.h index 0ad88efef6..a82ff397b4 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.h +++ b/src/overlays/actors/ovl_En_St/z_en_st.h @@ -7,11 +7,45 @@ struct EnSt; typedef void (*EnStActionFunc)(struct EnSt*, GlobalContext*); +#define ENST_GET_3F(thisx) (((thisx)->params & 0x3F) & 0xFF) +#define ENST_GET_1C0(thisx) ((((thisx)->params & 0x1C0) >> 6) & 0xFF) + +#define ENST_3F_63 63 +#define ENST_1C0_1 1 + typedef struct EnSt { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnStActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x3C4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnStActionFunc actionFunc; + /* 0x18C */ u16 unk_18C; + /* 0x18E */ u8 unk_18E; + /* 0x190 */ ColliderCylinder collider1; + /* 0x1DC */ ColliderCylinder collider2; + /* 0x228 */ ColliderCylinder collider3; + /* 0x274 */ ColliderCylinder collider4; + /* 0x2C0 */ s8 unk_2C0; + /* 0x2C4 */ f32 unk_2C4; + /* 0x2C8 */ f32 unk_2C8; + /* 0x2CC */ f32 unk_2CC; + /* 0x2D0 */ f32 unk_2D0; + /* 0x2D4 */ f32 unk_2D4; + /* 0x2D8 */ f32 unk_2D8; + /* 0x2DC */ f32 unk_2DC[12]; + /* 0x30C */ s16 unk_30C; + /* 0x30E */ s16 unk_30E; + /* 0x310 */ s16 unk_310; + /* 0x312 */ s16 unk_312; + /* 0x314 */ s16 unk_314; + /* 0x316 */ s16 unk_316; + /* 0x318 */ s16 unk_318; + /* 0x31A */ s16 unk_31A; + /* 0x31C */ s16 unk_31C[12]; + /* 0x334 */ s16 unk_334[12]; + /* 0x34C */ f32 unk_34C; + /* 0x350 */ UNK_TYPE1 unk_350[0x8]; + /* 0x358 */ Vec3f unk_358[12]; + /* 0x3E8 */ Vec3s jointTable[30]; + /* 0x49C */ Vec3s morphTable[30]; } EnSt; // size = 0x550 extern const ActorInit En_St_InitVars; diff --git a/src/overlays/actors/ovl_En_Stream/z_en_stream.c b/src/overlays/actors/ovl_En_Stream/z_en_stream.c index 6f20e1bd5b..9ce7ac906f 100644 --- a/src/overlays/actors/ovl_En_Stream/z_en_stream.c +++ b/src/overlays/actors/ovl_En_Stream/z_en_stream.c @@ -5,6 +5,7 @@ */ #include "z_en_stream.h" +#include "objects/object_stream/object_stream.h" #define FLAGS 0x00000010 @@ -33,8 +34,6 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 20, ICHAIN_STOP), }; -extern Gfx D_06000950[]; - void EnStream_SetupAction(EnStream* this, EnStreamActionFunc actionFunc) { this->actionFunc = actionFunc; } @@ -144,7 +143,7 @@ void EnStream_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(&gfx[1], 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, frames * 30, -multipliedFrames, 64, 64, 1, multipliedFrames, -multipliedFrames, 64, 64)); - gSPDisplayList(&gfx[2], D_06000950); + gSPDisplayList(&gfx[2], gWaterVortexDL); POLY_XLU_DISP = &gfx[3]; CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 9cc8897a2e..55fae4cadd 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -173,7 +173,7 @@ void EnSuttari_UpdateCollider(EnSuttari* this, GlobalContext* globalCtx) { } Actor* EnSuttari_GetActorById(GlobalContext* globalCtx, s16 actorId) { - Actor* actor = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (actor != NULL) { if (actor->id == actorId) { @@ -229,13 +229,13 @@ void func_80BAA9B4(EnSuttari* this) { case 0x145B: if ((this->animationIdx != 8) && (curFrame == frameCount)) { this->animationIdx = 8; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } break; default: if ((this->animationIdx != 1) && (curFrame == frameCount)) { this->animationIdx = 1; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } } } @@ -244,7 +244,7 @@ void func_80BAAA94(EnSuttari* this) { switch (this->textId) { case 0x29E5: this->animationIdx = 1; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); break; case 0x29E9: this->enFsn->flags |= ENFSN_ANGRY; @@ -257,11 +257,11 @@ void func_80BAAA94(EnSuttari* this) { break; case 0x29EC: this->animationIdx = 7; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); break; case 0x29ED: this->animationIdx = 1; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); break; } } @@ -387,10 +387,10 @@ void func_80BAAF1C(EnSuttari* this) { if (this->animationIdx == 5) { this->animationIdx = 3; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } else if ((this->animationIdx == 3) && (curFrame == frameCount)) { this->animationIdx = 6; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); this->flags1 &= ~0x100; } } @@ -469,7 +469,7 @@ void func_80BAB374(EnSuttari* this, GlobalContext* globalCtx) { sp38.x = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.x; sp38.y = this->actor.world.pos.y; sp38.z = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.z; - func_800BBDAC(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 0, 0, 0); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 0, 0, 0); } } @@ -689,7 +689,7 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg if (this->unk428 == 10 || this->unk428 == 11 || this->unk428 == 2) { return 0; } - sp48 = (EnDoor*)func_8013BB7C(&this->actor, globalCtx, ACTORCAT_DOOR, ACTOR_EN_DOOR); + sp48 = (EnDoor*)SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_DOOR, ACTOR_EN_DOOR); sp24 = D_80BAE8F8[unkStruct->unk0]; if ((sp48 != NULL) && (sp24 >= 0)) { this->unk404 = func_8013BB34(globalCtx, sp47, sp24); @@ -823,7 +823,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { case 15: if ((this->animationIdx == 1) && (curFrame == frameCount)) { this->animationIdx = 2; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } if (!(gSaveContext.weekEventReg[0x53] & 4) && !(this->flags1 & 0x1000)) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0])) { @@ -856,7 +856,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { this->enFsn->flags &= ~ENFSN_HAGGLE; if (this->animationIdx != 2) { this->animationIdx = 2; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } func_80BAC220(this, globalCtx); break; @@ -887,7 +887,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { if (!(gSaveContext.weekEventReg[0x21] & 8)) { if (this->animationIdx == 2 || this->animationIdx == 1) { this->animationIdx = 5; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } this->flags1 |= 0x10; if (this->flags2 & 2) { @@ -915,7 +915,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { this->flags1 |= 1; if (gSaveContext.day == 1 || gSaveContext.day == 2) { this->animationIdx = 2; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); this->flags1 |= 0x80; this->actionFunc = func_80BACA14; return; @@ -923,7 +923,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { !(gSaveContext.weekEventReg[0x3D] & 8) && !(gSaveContext.weekEventReg[0x21] & 8) && (gSaveContext.weekEventReg[0x33] & 8)) { this->animationIdx = 2; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); this->actionFunc = func_80BACEE0; return; } @@ -939,7 +939,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { this->flags1 |= 0x80; this->flags1 |= 8; this->animationIdx = 1; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); this->actionFunc = func_80BAD004; return; } else if (globalCtx->sceneNum == SCENE_ICHIBA) { @@ -948,7 +948,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { return; } this->animationIdx = 0; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); this->flags1 |= 2; this->actionFunc = func_80BAD5F8; return; @@ -958,7 +958,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { return; } this->animationIdx = 0; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); this->cutscenes[0] = this->actor.cutscene; this->cutscenes[1] = ActorCutscene_GetAdditionalCutscene(this->cutscenes[0]); this->flags1 |= 4; @@ -978,7 +978,7 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { if (this->animationIdx == 1 || this->animationIdx == 8) { this->animationIdx = 2; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } func_80BABA90(this, 0, 0); func_80BAB434(this); @@ -988,7 +988,7 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { this->actionFunc = func_80BACBB0; } } else if ((player->transformation == PLAYER_FORM_HUMAN) && CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) != 0) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk3F2 = this->unk2DC.y; func_80BAAB78(this, globalCtx); this->actionFunc = func_80BADA9C; @@ -997,7 +997,7 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { } } Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 0.1f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { @@ -1023,7 +1023,7 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { this->actionFunc = func_80BACD2C; this->actor.speedXZ = 0.0f; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (!(this->actor.bgCheckFlags & 1)) { this->actor.world.pos = this->actor.prevPos; this->actor.world.rot.y = -this->actor.world.rot.y; @@ -1045,7 +1045,7 @@ void func_80BACD2C(EnSuttari* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (!(this->actor.bgCheckFlags & 1)) { this->actor.world.pos = this->actor.prevPos; this->actor.world.rot.y = -this->actor.world.rot.y; @@ -1057,7 +1057,7 @@ void func_80BACE4C(EnSuttari* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer > 100.0f) { this->actionFunc = func_80BACBB0; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (this->actor.world.pos.y != this->actor.floorHeight) { this->actor.world.pos = this->actor.prevPos; this->actor.world.rot.y = -this->actor.world.rot.y; @@ -1087,7 +1087,7 @@ void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { } else if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { func_80BAB1A0(this, globalCtx); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { @@ -1104,17 +1104,17 @@ void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { } this->unk428 = unkStruct.unk0; func_80BAC2FC(this, globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, 0x2A3A, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 200.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80BAD130(EnSuttari* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { globalCtx->msgCtx.unk11F22 = 0x43; @@ -1147,7 +1147,7 @@ void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD2B4(EnSuttari* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { if (this->textId == 0x2A30) { ActorCutscene_Stop(this->cutscenes[0]); ActorCutscene_SetIntentToPlay(this->cutscenes[1]); @@ -1164,7 +1164,7 @@ void func_80BAD2B4(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); if ((player->stateFlags1 & 0x40) && (globalCtx->msgCtx.unk11F04 != 0x2A31)) { @@ -1206,7 +1206,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { } else { this->unk3F2 = this->unk2DC.y; Math_ApproachF(&this->actor.speedXZ, 4.0f, 0.2f, 0.5f); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_80BAB374(this, globalCtx); } } @@ -1220,7 +1220,7 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { if ((curFrame == frameCount) && (this->animationIdx == 0) && (this->flags1 & 0x20)) { this->animationIdx = 2; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || @@ -1238,14 +1238,14 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { } func_80BAB434(this); if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.unk0 != 7)) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { @@ -1259,7 +1259,7 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { } else { if ((this->flags1 & 0x2000) && (this->animationIdx == 1) && (curFrame == frameCount)) { this->animationIdx = 2; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || @@ -1276,19 +1276,19 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { return; } if ((this->flags1 & 0x20) && (unkStruct.unk0 != 9)) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); } } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } } void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; func_80BAAB78(this, globalCtx); gSaveContext.weekEventReg[0x51] |= 4; @@ -1299,7 +1299,7 @@ void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { - u8 talkstate = func_80152498(&globalCtx->msgCtx); + u8 talkstate = Message_GetState(&globalCtx->msgCtx); s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); @@ -1308,7 +1308,7 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { func_80BAA9B4(this); } else if ((this->animationIdx == 7) && (curFrame == frameCount)) { this->animationIdx = 1; - func_800BDC5C(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); } if (talkstate == 5) { if (func_80147624(globalCtx)) { @@ -1372,7 +1372,7 @@ void func_80BADDB4(EnSuttari* this, GlobalContext* globalCtx) { if (gSaveContext.weekEventReg[0x33] & 0x10) { this->actionFunc = func_80BADE14; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80BADE14(EnSuttari* this, GlobalContext* globalCtx) { @@ -1383,13 +1383,13 @@ void func_80BADE14(EnSuttari* this, GlobalContext* globalCtx) { this->unk3F2 = this->unk2DC.y; Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void func_80BADE8C(EnSuttari* this, GlobalContext* globalCtx) { this->unk3F2 = this->unk2DC.y; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; func_801518B0(globalCtx, 0x2A3A, &this->actor); this->actionFunc = func_80BAD130; @@ -1408,7 +1408,7 @@ void func_80BADF3C(EnSuttari* this, GlobalContext* globalCtx) { if (DECR(this->unk3F6) == 0) { Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } void EnSuttari_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -1456,11 +1456,11 @@ void EnSuttari_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->unk428 != 0) { if (this->animationIdx == 2 || this->animationIdx == 6) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 16.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } } else if (this->animationIdx == 0 || this->animationIdx == 5) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } } } 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 204d251d19..d7d547afd4 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -248,7 +248,7 @@ void func_808D8ED0(EnSw* this, GlobalContext* globalCtx) { sp54.z += this->unk_380[i].z; Math_Vec3f_Copy(&this->unk_380[i], &sp54); } - func_800BF7CC(globalCtx, &this->actor, this->unk_380, ARRAY_COUNT(this->unk_380), 3, 0.1f, 0.3f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_380, ARRAY_COUNT(this->unk_380), 3, 0.1f, 0.3f); } void func_808D8FC4(EnSw* this, GlobalContext* globalCtx) { @@ -458,7 +458,7 @@ void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 } if (arg2 == 1) { - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); } } #else @@ -498,10 +498,10 @@ void func_808D9894(EnSw* this, Vec3f* vec) { s32 func_808D9968(EnSw* this, GlobalContext* globalCtx) { s32 ret = false; - u8 param = ENSW_GET_3FC(&this->actor); + s32 param = ENSW_GET_3FC(&this->actor) & 0xFF; if (ENSW_GET_3(&this->actor)) { - if ((param != 0x3F) && Actor_GetChestFlag(globalCtx, param)) { + if ((param != 0x3F) && Flags_GetTreasure(globalCtx, param)) { ret = true; } } @@ -536,9 +536,9 @@ s32 func_808D9A70(EnSw* this, GlobalContext* globalCtx) { } else { if (this->unk_456 != 0) { if (!ENSW_GET_3(&this->actor)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_ROLL); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); } this->unk_456--; this->skelAnime.curFrame = 0.0f; @@ -587,7 +587,7 @@ s32 func_808D9C18(EnSw* this) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTURA_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_APPEAR); if (ENSW_GET_3(&this->actor) == 1) { Actor_SetScale(&this->actor, 0.0f); @@ -729,19 +729,19 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { } this->unk_458 = 20; this->unk_45A = 0; - func_800BCB70(&this->actor, 0x4000, 200, 0, this->unk_458); + Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->unk_458); ret = true; } else if (this->actor.colChkInfo.damageEffect == 1) { if (this->unk_45A == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->unk_45A = 40; - func_800BCB70(&this->actor, 0, 200, 0, this->unk_45A); + Actor_SetColorFilter(&this->actor, 0, 200, 0, this->unk_45A); } } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTU_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_DAMAGE); this->unk_458 = 20; this->unk_45A = 0; - func_800BCB70(&this->actor, 0x4000, 200, 0, this->unk_458); + Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->unk_458); } } return ret; @@ -751,7 +751,7 @@ void func_808DA350(EnSw* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if ((player->stateFlags1 & 0x200000) && (this->actor.xyzDistToPlayerSq < 8000.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_LAUGH); Math_Vec3f_Copy(&this->unk_374, &player->actor.world.pos); this->unk_410 &= ~0x20; this->unk_414 = 0.0f; @@ -776,7 +776,7 @@ void func_808DA3F4(EnSw* this, GlobalContext* globalCtx) { temp_v0 = Math_FAtan2F(sp38.z, sp38.x); if (ABS_ALT(temp_v0) < temp_s1) { this->skelAnime.curFrame = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); this->unk_414 = 0.0f; if (this->unk_410 & 0x20) { this->actionFunc = func_808DA6FC; @@ -787,7 +787,7 @@ void func_808DA3F4(EnSw* this, GlobalContext* globalCtx) { } temp_s1 *= (temp_v0 < 0) ? -1 : 1; } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_ROLL); this->skelAnime.curFrame = 0.0f; } func_808D94D0(this, globalCtx, 0, 0, temp_s1); @@ -813,7 +813,7 @@ void func_808DA578(EnSw* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&this->unk_374, &this->actor.home.pos); this->actionFunc = func_808DA3F4; } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); this->skelAnime.curFrame = 0.0f; } @@ -849,7 +849,7 @@ void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { func_808D94D0(this, globalCtx, 0, 0, Math_FAtan2F(sp38.z, sp38.x)); } } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); this->skelAnime.curFrame = 0.0f; } @@ -912,7 +912,7 @@ void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { this->unk_448 = temp_f2; this->actor.speedXZ = 0.0f; if ((s32)temp_f2 != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTURA_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); } else { this->actionFunc = func_808DAEB4; this->actor.velocity.y = 0.0f; @@ -924,7 +924,7 @@ void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.shape.yOffset, 400.0f, 0.3f, 1000.0f); } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); } @@ -948,7 +948,7 @@ void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { temp_v0 = Math_FAtan2F(sp34.z, sp34.x); if (ABS_ALT(temp_v0) < sp40) { this->skelAnime.curFrame = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); Math_Vec3s_ToVec3f(&this->unk_374, &sp44[this->unk_4A0]); this->actionFunc = func_808DACF4; this->unk_414 = 0.0f; @@ -958,7 +958,7 @@ void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { } } else { if (this->unk_456 != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); this->unk_456--; this->skelAnime.curFrame = 0.0f; } else { @@ -1001,7 +1001,7 @@ void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { func_808D94D0(this, globalCtx, 0, 0, Math_FAtan2F(sp38.z, sp38.x)); } } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); this->skelAnime.curFrame = 0.0f; } @@ -1108,9 +1108,9 @@ void func_808DB100(EnSw* this, GlobalContext* globalCtx) { if ((DECR(this->unk_454) == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (this->unk_456 != 0) { if (!ENSW_GET_3(&this->actor)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALWALL_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_ROLL); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); } this->unk_456--; this->skelAnime.curFrame = 0.0f; @@ -1145,7 +1145,7 @@ void func_808DB2E0(EnSw* this, GlobalContext* globalCtx) { this->actor.velocity.z *= 0.5f; if ((s32)temp_f2 != 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALTURA_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); } else { func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); @@ -1161,7 +1161,7 @@ void func_808DB2E0(EnSw* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.scale.x, 0.02f, 0.4f, 1.0f); Actor_SetScale(&this->actor, this->actor.scale.x); this->actor.velocity.y += this->actor.gravity; - Actor_ApplyMovement(&this->actor); + Actor_UpdatePos(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); } @@ -1266,7 +1266,7 @@ void EnSw_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); } - Actor_SetHeight(&this->actor, 0.0f); + Actor_SetFocus(&this->actor, 0.0f); func_808D8FC4(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 5137628056..6defe10cb3 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 @@ -193,7 +193,7 @@ s32 func_809C6720(GlobalContext* globalCtx, Vec3f arg1) { } globalCtx->actorCtx.unk268 = 1; - func_800B6F20(globalCtx, globalCtx->actorCtx.pad26C, phi_f0, sp22); + func_800B6F20(globalCtx, &globalCtx->actorCtx.unk_26C, phi_f0, sp22); if (sp28 < 5.0f) { return true; @@ -213,10 +213,10 @@ void func_809C6810(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { u16 sp22; - func_800BDC5C(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); sp22 = Text_GetFaceReaction(globalCtx, 0x31); if (sp22 != 0) { func_801518B0(globalCtx, sp22, &this->actor); @@ -381,7 +381,7 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x20; } - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 2: this->actionFunc = func_809C6848; this->unk_26A = 0; @@ -419,7 +419,7 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { if (this->skelAnime.animation == &D_0600D2F8) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_800BDC5C(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); } } } @@ -427,7 +427,7 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { switch (gSaveContext.playerForm) { case PLAYER_FORM_HUMAN: - Actor_SetAllChestFlag(globalCtx, Actor_GetAllChestFlag(globalCtx) + 1); + Flags_SetAllTreasure(globalCtx, Flags_GetAllTreasure(globalCtx) + 1); if (CURRENT_DAY != 3) { if (!(this->unk_282 & 1)) { this->unk_282 |= 1; @@ -510,7 +510,7 @@ void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C72D8(EnSyatekiMan* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { u16 sp26 = Text_GetFaceReaction(globalCtx, 0x30); if (sp26 != 0) { @@ -715,7 +715,7 @@ void func_809C7990(EnSyatekiMan* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x20; } - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 2: this->actionFunc = func_809C72D8; this->unk_26A = 0; @@ -763,13 +763,13 @@ void func_809C7A90(EnSyatekiMan* this, GlobalContext* globalCtx) { this->actionFunc = func_809C7C14; } else { if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.weekEventReg[59] & 0x10)) { - func_800B8A1C(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); } else if (this->unk_280 < 0x884) { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_RED, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 500.0f, 100.0f); } else if (!(gSaveContext.weekEventReg[32] & 2)) { - func_800B8A1C(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); } player->actor.shape.rot.y = -0x8000; @@ -782,7 +782,7 @@ void func_809C7A90(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C7C14(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if ((CURRENT_DAY == 3) && (gSaveContext.time > CLOCK_TIME(12, 00))) { func_801518B0(globalCtx, 0xA36, &this->actor); this->unk_284 = 0xA36; @@ -796,7 +796,7 @@ void func_809C7C14(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_26A = 0; this->actionFunc = func_809C6E30; } else { - func_800B85E0(&this->actor, globalCtx, 500.0f, -1); + func_800B85E0(&this->actor, globalCtx, 500.0f, EXCH_ITEM_MINUS1); } } @@ -820,14 +820,14 @@ void func_809C7D14(EnSyatekiMan* this, GlobalContext* globalCtx) { } else { if (this->unk_284 == 0x407) { if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.weekEventReg[59] & 0x20)) { - func_800B8A1C(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); } } else if (!(gSaveContext.weekEventReg[32] & 4)) { - func_800B8A1C(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_HUGE, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_HUGE, 500.0f, 100.0f); } player->actor.shape.rot.y = -0x8000; @@ -841,7 +841,7 @@ void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (CURRENT_DAY != 3) { - if ((func_80152498(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { player->stateFlags1 &= ~0x20; this->unk_280 = 0; this->unk_26A = 0; @@ -849,7 +849,7 @@ void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[63] &= (u8)~2; this->actionFunc = func_809C6810; } - } else if (func_800B84D0(&this->actor, globalCtx)) { + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, 0x408, &this->actor); this->unk_284 = 0x408; player->stateFlags1 &= ~0x20; @@ -858,7 +858,7 @@ void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_26A = 0; this->actionFunc = func_809C7990; } else { - func_800B85E0(&this->actor, globalCtx, 500.0f, -1); + func_800B85E0(&this->actor, globalCtx, 500.0f, EXCH_ITEM_MINUS1); } } @@ -895,7 +895,7 @@ void func_809C80C0(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_27E = 0; this->unk_280 = 0; player->stateFlags1 &= ~0x20; - Audio_PlayActorSound2(&this->actor, NA_SE_SY_FOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_FOUND); this->unk_272 = 0x1F; this->unk_274 = 0; this->unk_276 = 0; @@ -917,7 +917,7 @@ void func_809C81D0(EnSyatekiMan* this, GlobalContext* globalCtx) { if (((this->unk_272 == 0) || (this->unk_26C > 140)) && (D_809C949C == 0) && (this->unk_27C < 4)) { D_809C949C = 1; this->unk_26C = 0; - Audio_PlayActorSound2(&this->actor, NA_SE_SY_FOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_FOUND); this->unk_274 = D_809C91C8[this->unk_27E]; if (this->unk_27E == 3) { this->unk_27E = 0; @@ -1037,7 +1037,7 @@ void func_809C8610(EnSyatekiMan* this, GlobalContext* globalCtx) { gSaveContext.unk_3E88[1] += 100; globalCtx->interfaceCtx.unk_25C += 10; this->unk_280 += 10; - Audio_PlayActorSound2(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); D_809C94A0 = 0; } else { D_809C94A0++; @@ -1144,7 +1144,7 @@ void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx) { if ((D_809C94A8 == (sp30 % 50)) && (this->unk_26C >= 70)) { if (this->unk_27E < 15) { this->unk_190 = D_809C94D0[this->unk_27E++]; - Audio_PlayActorSound2(&this->actor, NA_SE_SY_FOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_FOUND); this->unk_26C = 0; } } @@ -1171,7 +1171,7 @@ void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx) { if (this->unk_26A == 1) { this->unk_190 = 0; if ((this->unk_270 <= 0) && (globalCtx->interfaceCtx.unk_286 == 0)) { - Actor_SetAllChestFlag(globalCtx, this->unk_280); + Flags_SetAllTreasure(globalCtx, this->unk_280); this->unk_270 = 15; if (((s32)(gSaveContext.roomInf[127][6] & 0xFFFF) < this->unk_280) || (this->unk_280 == 50)) { if ((s32)(gSaveContext.roomInf[127][6] & 0xFFFF) < this->unk_280) { @@ -1239,7 +1239,7 @@ void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); func_809C8DE8(this); this->actor.focus.pos.y = 70.0f; - Actor_SetHeight(&this->actor, 70.0f); + Actor_SetFocus(&this->actor, 70.0f); if (this->unk_26A != 1) { SkelAnime_Update(&this->skelAnime); func_800E9250(globalCtx, &this->actor, &this->unk_258, &this->unk_25E, this->actor.focus.pos); diff --git a/src/overlays/actors/ovl_En_Talk/z_en_talk.c b/src/overlays/actors/ovl_En_Talk/z_en_talk.c index d85e293dca..fcfa36a4d6 100644 --- a/src/overlays/actors/ovl_En_Talk/z_en_talk.c +++ b/src/overlays/actors/ovl_En_Talk/z_en_talk.c @@ -45,18 +45,18 @@ void EnTalk_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80BDE058(EnTalk* this, GlobalContext* globalCtx) { - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->actionFunc = func_80BDE090; } } void func_80BDE090(EnTalk* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80BDE058; return; } - if ((this->actor.xzDistToPlayer < 40.0f && Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx)) || + if ((this->actor.xzDistToPlayer < 40.0f && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) || this->actor.isTargeted) { func_800B8614(&this->actor, globalCtx, 120.0f); } diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index 5b9e6079b5..931715a53d 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -213,7 +213,7 @@ void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 0; this->actor.hintId = 0x2D; this->actor.textId = 0; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 28.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_0053E8, &object_rd_Anim_00ABE0, this->jointTable, this->morphTable, EN_TALK_GIBUD_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); @@ -260,7 +260,7 @@ void EnTalkGibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnTalkGibud_SetupIdle(EnTalkGibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); this->actionFunc = EnTalkGibud_Idle; } @@ -277,7 +277,7 @@ void EnTalkGibud_Idle(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupAttemptPlayerStun(EnTalkGibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); this->actionFunc = EnTalkGibud_AttemptPlayerStun; } @@ -290,14 +290,14 @@ void EnTalkGibud_AttemptPlayerStun(EnTalkGibud* this, GlobalContext* globalCtx) player->actor.freezeTimer = 60; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); EnTalkGibud_SetupWalkToPlayer(this); } EnTalkGibud_TurnTowardsPlayer(this, globalCtx); } void EnTalkGibud_SetupWalkToPlayer(EnTalkGibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); this->actor.speedXZ = 0.4f; if (this->actionFunc == EnTalkGibud_AttemptPlayerStun) { this->playerStunWaitTimer = 80; @@ -315,7 +315,7 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { this->actor.world.rot = this->actor.shape.rot; Math_SmoothStepToS(&this->headRotation.y, 0, 1, 100, 0); Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 100, 0); - if (EnTalkGibud_PlayerInRangeWithCorrectState(this, globalCtx) && Actor_IsActorFacingLink(&this->actor, 0x38E3)) { + if (EnTalkGibud_PlayerInRangeWithCorrectState(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { if (this->grabWaitTimer == 0 && this->actor.xzDistToPlayer <= 45.0f) { player->actor.freezeTimer = 0; if (gSaveContext.playerForm == PLAYER_FORM_GORON || gSaveContext.playerForm == PLAYER_FORM_DEKU) { @@ -331,7 +331,7 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { this->playerStunWaitTimer = 60; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); } else { this->playerStunWaitTimer--; } @@ -346,14 +346,14 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); } else if (!(globalCtx->gameplayFrames & 0x5F)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } void EnTalkGibud_SetupGrab(EnTalkGibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_START); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_START); this->grabDamageTimer = 0; this->actor.flags &= ~1; this->grabState = EN_TALK_GIBUD_GRAB_START; @@ -375,7 +375,7 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { inPositionToAttack = EnTalkGibud_MoveToIdealGrabPositionAndRotation(this, globalCtx); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && inPositionToAttack == true) { this->grabState = EN_TALK_GIBUD_GRAB_ATTACK; - func_800BDC5C(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK); } break; @@ -385,7 +385,7 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { damageSfxId = player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S; globalCtx->damagePlayer(globalCtx, -8); - func_800B8E58(playerActor, damageSfxId); + func_800B8E58(player, damageSfxId); func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); this->grabDamageTimer = 0; } else { @@ -393,7 +393,7 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); } if (!(player->stateFlags2 & 0x80) || player->unk_B62 != 0) { @@ -401,7 +401,7 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x80; player->unk_AE8 = 100; } - func_800BDC5C(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_END); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_END); this->actor.flags |= 1; this->grabState = EN_TALK_GIBUD_GRAB_RELEASE; this->grabDamageTimer = 0; @@ -421,8 +421,8 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupGrabFail(EnTalkGibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->actionFunc = EnTalkGibud_GrabFail; this->actor.speedXZ = -2.0f; } @@ -442,7 +442,7 @@ void EnTalkGibud_GrabFail(EnTalkGibud* this, GlobalContext* globalCtx) { void EnTalkGibud_SetupTurnAwayAndShakeHead(EnTalkGibud* this) { this->headShakeTimer = 0; - func_800BDC5C(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); this->actionFunc = EnTalkGibud_TurnAwayAndShakeHead; } @@ -460,7 +460,7 @@ void EnTalkGibud_TurnAwayAndShakeHead(EnTalkGibud* this, GlobalContext* globalCt } void EnTalkGibud_SetupWalkToHome(EnTalkGibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); this->actor.speedXZ = 0.4f; this->actionFunc = EnTalkGibud_WalkToHome; } @@ -485,7 +485,7 @@ void EnTalkGibud_WalkToHome(EnTalkGibud* this, GlobalContext* globalCtx) { } if (EnTalkGibud_PlayerInRangeWithCorrectState(this, globalCtx)) { if (gSaveContext.playerForm != PLAYER_FORM_GORON && gSaveContext.playerForm != PLAYER_FORM_DEKU && - Actor_IsActorFacingLink(&this->actor, 0x38E3)) { + Actor_IsFacingPlayer(&this->actor, 0x38E3)) { EnTalkGibud_SetupWalkToPlayer(this); } } @@ -496,9 +496,9 @@ void EnTalkGibud_SetupStunned(EnTalkGibud* this) { this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; if (this->effectTimer != 0) { - func_800BCB70(&this->actor, 0, 0xC8, 0, 0x28); + Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } else { - func_800BCB70(&this->actor, 0, 0xC8, 0, 0x28); + Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } this->actionFunc = EnTalkGibud_Stunned; } @@ -517,8 +517,8 @@ void EnTalkGibud_Stunned(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupDamage(EnTalkGibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->stunTimer = 0; this->grabWaitTimer = 0; this->actor.world.rot.y = this->actor.yawTowardsPlayer; @@ -550,9 +550,9 @@ void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupDead(EnTalkGibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DEATH); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DEATH); this->actor.flags &= ~1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); this->deathTimer = 0; this->actionFunc = EnTalkGibud_Dead; } @@ -577,7 +577,7 @@ void EnTalkGibud_SetupRevive(EnTalkGibud* this) { Animation_Change(&this->skelAnime, &object_rd_Anim_009298, -1.0f, Animation_GetLastFrame(&object_rd_Anim_009298), 0.0f, 2, -8.0f); this->actor.flags |= 1; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_REVERSE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_REVERSE); this->deathTimer = 0; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = EnTalkGibud_Revive; @@ -714,7 +714,7 @@ void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, GlobalContext* globalCtx) void EnTalkGibud_SetupPassiveIdle(EnTalkGibud* this) { this->isTalking = false; if (this->actionFunc != EnTalkGibud_Talk) { - func_800BDC5C(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); } this->actionFunc = EnTalkGibud_PassiveIdle; } @@ -724,11 +724,11 @@ void EnTalkGibud_SetupPassiveIdle(EnTalkGibud* this) { * Gibdo will not attempt to attack the player and can be spoken to. */ void EnTalkGibud_PassiveIdle(EnTalkGibud* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->isTalking = true; func_801518B0(globalCtx, 0x1388, &this->actor); this->textId = 0x1388; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); EnTalkGibud_SetupTalk(this); } else if (this->actor.xzDistToPlayer < 100.0f && !(this->collider.base.acFlags & AC_HIT)) { func_800E9250(globalCtx, &this->actor, &this->headRotation, &this->upperBodyRotation, this->actor.focus.pos); @@ -748,7 +748,7 @@ void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnTalkGibudRequestedItem* requestedItem; - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: case 1: case 2: @@ -792,7 +792,7 @@ void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupDisappear(EnTalkGibud* this) { - func_800BDC5C(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); this->actor.flags &= ~1; this->disappearanceTimer = 40; this->actionFunc = EnTalkGibud_Disappear; @@ -822,7 +822,7 @@ void EnTalkGibud_Disappear(EnTalkGibud* this, GlobalContext* globalCtx) { this->disappearanceTimer--; } else { if (this->switchFlag != -1) { - Actor_SetSwitchFlag(globalCtx, this->switchFlag); + Flags_SetSwitch(globalCtx, this->switchFlag); } player->stateFlags1 &= ~0x20; player->stateFlags1 &= ~0x20000000; @@ -950,7 +950,7 @@ void EnTalkGibud_PlayAnimation(EnTalkGibud* this, GlobalContext* globalCtx) { void EnTalkGibud_MoveWithGravity(EnTalkGibud* this, GlobalContext* globalCtx) { if (this->actionFunc == EnTalkGibud_WalkToPlayer || this->actionFunc == EnTalkGibud_WalkToHome || this->actionFunc == EnTalkGibud_Damage) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } } @@ -963,7 +963,7 @@ void EnTalkGibud_CheckDamageEffect(EnTalkGibud* this, GlobalContext* globalCtx) switch (this->actor.colChkInfo.damageEffect) { case EN_TALK_GIBUD_DMGEFF_DAMAGE: - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (player->unk_ADC != 0) { this->unk_3F7 = player->unk_ADD; } @@ -984,7 +984,7 @@ void EnTalkGibud_CheckDamageEffect(EnTalkGibud* this, GlobalContext* globalCtx) break; case EN_TALK_GIBUD_DMGEFF_FIRE_ARROW: - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (this->actor.colChkInfo.health == 0) { EnTalkGibud_SetupDead(this); } else { @@ -996,7 +996,7 @@ void EnTalkGibud_CheckDamageEffect(EnTalkGibud* this, GlobalContext* globalCtx) break; case EN_TALK_GIBUD_DMGEFF_LIGHT_ARROW: - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (this->actor.colChkInfo.health == 0) { EnTalkGibud_SetupDead(this); } else { diff --git a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c index 313a0a1fdb..c735f4ca25 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c @@ -199,7 +199,7 @@ void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&this->targetPos, &player->actor.world.pos); if (!(this->timer & 0xF)) { if (Rand_ZeroOne() < 0.5f && this->actor.xzDistToPlayer <= 200.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_PIRANHA_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_ATTACK); } } @@ -260,7 +260,7 @@ void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { Math_ApproachS(&this->rotationStep, this->targetRotationStep, 1, 0x100); Math_ApproachF(&this->actor.speedXZ, this->targetSpeedXZ, 1.0f, this->speedMaxStep); - Actor_SetVelocityAndMoveXYRotationReverse(&this->actor); + Actor_MoveWithoutGravityReverse(&this->actor); } else { switch (this->isBeached) { case false: @@ -315,7 +315,7 @@ void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { } break; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } this->currentRotationAngle += this->nextRotationAngle; @@ -341,11 +341,11 @@ void EnTanron3_SetupDie(EnTanron3* this, GlobalContext* globalCtx) { this->actor.world.rot.y = Math_FAtan2F(zDistance, xDistance); this->workTimer[TANRON3_WORK_TIMER_DIE] = 6; this->actor.speedXZ = 10.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KONB_MINI_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_MINI_DEAD); } void EnTanron3_Die(EnTanron3* this, GlobalContext* globalCtx) { - Actor_SetVelocityAndMoveXYRotationReverse(&this->actor); + Actor_MoveWithoutGravityReverse(&this->actor); if (this->workTimer[TANRON3_WORK_TIMER_DIE] == 0) { EnTanron3_SpawnBubbles(this, globalCtx); Actor_MarkForDeath(&this->actor); @@ -407,7 +407,7 @@ void EnTanron3_Update(Actor* thisx, GlobalContext* globalCtx) { splashPos.y = this->waterSurfaceYPos + 10.0f; splashPos.z = this->actor.world.pos.z; EffectSsGSplash_Spawn(globalCtx, &splashPos, NULL, NULL, 1, 500); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_OUT_OF_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); } } diff --git a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c index 2c855d36a9..c34d2e5b5d 100644 --- a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c +++ b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c @@ -69,7 +69,7 @@ void EnTanron6_Init(Actor* thisx, GlobalContext* globalCtx) { EnTanron6* this = THIS; this->actor.colChkInfo.mass = 10; - ActorShape_Init(&this->actor.shape, 0, func_800B3FC0, 19.0f); + ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 19.0f); this->actor.colChkInfo.health = 1; this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.targetMode = 6; @@ -90,7 +90,7 @@ void EnTanron6_Update(Actor* thisx, GlobalContext* globalCtx) { EnTanron6* this = THIS; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 40.0f, 40.0f, 0x1D); } diff --git a/src/overlays/actors/ovl_En_Test5/z_en_test5.c b/src/overlays/actors/ovl_En_Test5/z_en_test5.c index f1ec4e817e..0360af9271 100644 --- a/src/overlays/actors/ovl_En_Test5/z_en_test5.c +++ b/src/overlays/actors/ovl_En_Test5/z_en_test5.c @@ -66,15 +66,15 @@ void EnTest5_HandleBottleAction(EnTest5* this, GlobalContext* globalCtx) { player = GET_PLAYER(globalCtx); - if (player->unk_388 == NULL || player->unk_384 != GI_MAX) { + if (player->interactRangeActor == NULL || player->getItemId != GI_MAX) { Math_Vec3f_DistXYZAndStoreDiff(&this->minPos, &player->actor.world.pos, &playerPosRelativeToWater); // Make sure that the player is within the bounds of the water and deep enough to grab some if (playerPosRelativeToWater.x >= 0.0f && playerPosRelativeToWater.x <= this->xLength && playerPosRelativeToWater.z >= 0.0f && playerPosRelativeToWater.z <= this->zLength && fabsf(playerPosRelativeToWater.y) < 100.0f && player->actor.depthInWater > 12.0f) { - func_800B8A1C(&this->actor, globalCtx, GI_MAX, this->actor.xzDistToPlayer, - fabsf(this->actor.playerHeightRel)); + Actor_PickUp(&this->actor, globalCtx, GI_MAX, this->actor.xzDistToPlayer, + fabsf(this->actor.playerHeightRel)); } } } diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index cb33c2621a..b28c8b1cca 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -174,7 +174,7 @@ void EnThiefbird_Init(Actor* thisx, GlobalContext* globalCtx) { } CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - ActorShape_Init(&this->actor.shape, 1500.0f, func_800B3FC0, 35.0f); + ActorShape_Init(&this->actor.shape, 1500.0f, ActorShadow_DrawCircle, 35.0f); if (this->actor.params == 1) { D_80C1392C = 1; Math_Vec3f_Copy(&D_80C13920, &this->actor.world.pos); @@ -251,7 +251,7 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { if (isItemFound) { func_801149A0(itemId2, slotId); this->unk_3E8 = D_060033B0; - if (!func_80152498(&globalCtx->msgCtx)) { + if (!Message_GetState(&globalCtx->msgCtx)) { func_801518B0(globalCtx, 0xF4, NULL); } itemId1 = ITEM_BOTTLE; @@ -275,7 +275,7 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_3E8 = D_80C13680[phi_a3 - 1]; } - if (!func_80152498(&globalCtx->msgCtx)) { + if (!Message_GetState(&globalCtx->msgCtx)) { func_801518B0(globalCtx, 0xF5, NULL); } } else { @@ -401,12 +401,12 @@ s32 func_80C10E98(GlobalContext* globalCtx) { sp64.y = player->actor.world.pos.y + 20.0f; sp64.z = (Math_CosS(phi_s3) * 40.0f) + player->actor.world.pos.z; if (dropItem00Ids[i] != ITEM00_NO_DROP) { - EnItem00* temp_s1_5 = Item_DropCollectible(globalCtx, &sp64, dropItem00Ids[i]); + Actor* temp_s1_5 = Item_DropCollectible(globalCtx, &sp64, dropItem00Ids[i]); if (temp_s1_5 != NULL) { - temp_s1_5->actor.velocity.y = Rand_ZeroFloat(3.0f) + 6.0f; - temp_s1_5->actor.speedXZ = Rand_ZeroFloat(3.0f) + 3.0f; - temp_s1_5->actor.world.rot.y = phi_s3; + temp_s1_5->velocity.y = Rand_ZeroFloat(3.0f) + 6.0f; + temp_s1_5->speedXZ = Rand_ZeroFloat(3.0f) + 3.0f; + temp_s1_5->world.rot.y = phi_s3; } phi_s3 += (s16)(0x10000 / (spB0 + spAC + phi_s0_2 + spA0 + phi_s2 + spA8)); } @@ -429,7 +429,7 @@ void func_80C11338(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_3EC = NULL; do { - item = (EnItem00*)func_ActorCategoryIterateById(globalCtx, &item->actor, ACTORCAT_MISC, ACTOR_EN_ITEM00); + item = (EnItem00*)SubS_FindActor(globalCtx, &item->actor, ACTORCAT_MISC, ACTOR_EN_ITEM00); if (item != NULL) { if (item->unk152 > 0) { if (Actor_XZDistanceBetweenActors(&player->actor, &item->actor) > 10.0f) { @@ -459,14 +459,14 @@ void func_80C11454(EnThiefbird* this) { this->unk_3DC = 0.75f; this->unk_3D4 = 1.0f; this->actor.flags &= ~0x200; - func_800BCB70(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_80C114C0(EnThiefbird* this, GlobalContext* globalCtx) { if (this->unk_18C == 10) { this->unk_18C = 0; this->unk_3D4 = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->unk_350, 11, 2, 0.2f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_350, 11, 2, 0.2f, 0.2f); this->actor.flags |= 0x200; } } @@ -503,7 +503,7 @@ void func_80C11590(EnThiefbird* this, GlobalContext* globalCtx) { } else { this->unk_192 -= Rand_S16Offset(4096, 4096); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); } if ((this->actor.depthInWater > -40.0f) || (this->actor.bgCheckFlags & 1)) { @@ -548,7 +548,7 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KAICHO_FLUTTER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_FLUTTER); } if (this->unk_18E != 0) { @@ -560,7 +560,7 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.x, pitch, 4, 0x800, 0x80); if (this->actor.bgCheckFlags & 8) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 6, 0x1000, 0x100); - } else if (Actor_IsActorFacingLink(&this->actor, 0x3C00) || (this->actor.xzDistToPlayer > 120.0f)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x3C00) || (this->actor.xzDistToPlayer > 120.0f)) { s16 rot = BINANG_ROT180(this->actor.yawTowardsPlayer - player->actor.shape.rot.y); if (rot > 0x4000) { @@ -578,7 +578,7 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { (this->actor.depthInWater > -40.0f)) { if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); if (!(this->collider.base.atFlags & AT_BOUNCED)) { if ((D_80C1392C != 0) && CUR_UPG_VALUE(UPG_QUIVER) && (!((gSaveContext.roomInf[126][5] & 0xFF000000) >> 0x18) || @@ -608,8 +608,8 @@ void func_80C11C60(EnThiefbird* this) { this->actor.shape.rot.x = 0; this->unk_18E = 40; this->actor.velocity.y = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_THIEFBIRD_DEAD); - func_800BCB70(&this->actor, 0x4000, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_DEAD); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); this->collider.base.acFlags &= ~AC_ON; this->actor.flags |= 0x10; this->unk_192 = 0x1C00; @@ -684,14 +684,14 @@ void func_80C11F6C(EnThiefbird* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 5) { - func_800BCB70(&this->actor, 0, 255, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); } else if (this->actor.colChkInfo.damageEffect == 1) { - func_800BCB70(&this->actor, 0, 255, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); } else { - func_800BCB70(&this->actor, 0x4000, 255, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_THIEFBIRD_DAMAGE); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_DAMAGE); } this->collider.base.acFlags &= ~AC_ON; @@ -931,7 +931,7 @@ void func_80C12B1C(EnThiefbird* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; this->collider.base.atFlags &= ~AT_HIT; - func_800BE258(&this->actor, this->collider.elements); + Actor_SetDropFlag(&this->actor, &this->collider.elements->info); func_80C114C0(this, globalCtx); this->unk_194 = 0; @@ -1016,9 +1016,9 @@ void EnThiefbird_Update(Actor* thisx, GlobalContext* globalCtx2) { this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.world.rot.x = -this->actor.shape.rot.x; if (this->actor.colChkInfo.health != 0) { - Actor_SetVelocityAndMoveXYRotation(&this->actor); + Actor_MoveWithoutGravity(&this->actor); } else { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 25.0f, 50.0f, 7); @@ -1044,7 +1044,7 @@ void EnThiefbird_Update(Actor* thisx, GlobalContext* globalCtx2) { func_80C12D00(this); if (((this->skelAnime.animation == &D_06000604) && Animation_OnFrame(&this->skelAnime, 13.0f)) || ((this->skelAnime.animation == &D_06000278) && Animation_OnFrame(&this->skelAnime, 1.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KAICHO_FLUTTER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_FLUTTER); } } diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index bcf8547eff..041a688184 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -140,7 +140,7 @@ static Vec3f D_80896B44 = { 0.0f, 0.45f, 0.0f }; static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 70, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), - ICHAIN_F32(minVelocityY, -40, ICHAIN_CONTINUE), + ICHAIN_F32(terminalVelocity, -40, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), }; @@ -154,8 +154,8 @@ void EnTite_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); SkelAnime_Init(globalCtx, &this->skelAnime, &D_06003A20, &D_060012E4, this->jointTable, this->morphTable, 25); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 60.0f); - Actor_SetHeight(&this->actor, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 60.0f); + Actor_SetFocus(&this->actor, 20.0f); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; @@ -271,7 +271,7 @@ void func_80893BCC(EnTite* this, GlobalContext* globalCtx) { } } } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } } @@ -282,7 +282,7 @@ void func_80893DD4(EnTite* this) { this->unk_2C8 = 0.5f; this->unk_2CC = 0.75f; this->unk_2C4 = 1.0f; - func_800BCB70(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); this->actor.flags &= ~0x200; } @@ -291,7 +291,7 @@ void func_80893E54(EnTite* this, GlobalContext* globalCtx) { this->unk_2BB = 0; this->collider.base.colType = COLTYPE_HIT6; this->unk_2C4 = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->unk_2D0, 9, 2, 0.2f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D0, 9, 2, 0.2f, 0.2f); this->actor.flags |= 0x200; } } @@ -335,10 +335,10 @@ void func_80894024(EnTite* this, GlobalContext* globalCtx) { void func_8089408C(EnTite* this, GlobalContext* globalCtx) { Animation_PlayOnce(&this->skelAnime, &D_060004F8); if (!func_80893ADC(this)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); } else { this->actor.world.pos.y += this->actor.depthInWater; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); } if (this->actor.shape.yOffset < 0.0f) { @@ -361,7 +361,7 @@ void func_8089408C(EnTite* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.shape.rot.y; - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= 1; this->actor.velocity.y = 10.0f; } else { @@ -389,7 +389,7 @@ void func_808942B4(EnTite* this, GlobalContext* globalCtx) { func_8089452C(this, globalCtx); } else { this->actor.velocity.y = 0.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); func_80894414(this); } } @@ -412,7 +412,7 @@ void func_80894454(EnTite* this, GlobalContext* globalCtx) { if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (this->actor.xzDistToPlayer > 450.0f) || (this->actor.playerHeightRel > 80.0f)) { func_80893ED4(this); - } else if (!Actor_IsActorFacingLink(&this->actor, 0x2328)) { + } else if (!Actor_IsFacingPlayer(&this->actor, 0x2328)) { func_808945EC(this); } else { func_80893A9C(this, globalCtx); @@ -430,7 +430,7 @@ void func_8089452C(EnTite* this, GlobalContext* globalCtx) { sp2C.y += this->actor.depthInWater; this->actor.velocity.y *= 0.75f; EffectSsGRipple_Spawn(globalCtx, &sp2C, 0, 500, 0); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER); this->actionFunc = func_808945B4; } @@ -466,9 +466,9 @@ void func_80894638(EnTite* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 7.0f)) { if (func_80893ADC(this)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_WALK_WATER); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_WALK); } } @@ -476,7 +476,7 @@ void func_80894638(EnTite* this, GlobalContext* globalCtx) { (this->actor.playerHeightRel > 80.0f)) { func_80893ED4(this); } else if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.depthInWater < 10.0f))) && - Actor_IsActorFacingLink(&this->actor, 0xE38)) { + Actor_IsFacingPlayer(&this->actor, 0xE38)) { if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.playerHeightRel <= 80.0f)) { func_80893A9C(this, globalCtx); } else { @@ -495,9 +495,9 @@ void func_8089484C(EnTite* this) { this->actor.speedXZ = 4.0f; if (func_80893ADC(this)) { this->actor.world.pos.y += this->actor.depthInWater; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); } this->actionFunc = func_80894910; } @@ -508,7 +508,7 @@ void func_80894910(EnTite* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 1.0f, 0.0f); SkelAnime_Update(&this->skelAnime); if (this->actor.bgCheckFlags & 0x40) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER); if (func_80893ADC(this)) { Math_Vec3f_Copy(&sp34, &this->actor.world.pos); @@ -569,7 +569,7 @@ void func_80894BC8(EnTite* this, GlobalContext* globalCtx) { } if (this->actor.bgCheckFlags & 0x40) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); } else { func_80893BCC(this, globalCtx); } @@ -582,7 +582,7 @@ void func_80894BC8(EnTite* this, GlobalContext* globalCtx) { (ABS_ALT(this->actor.shape.rot.x) < 4000) && (ABS_ALT(this->actor.shape.rot.z) < 4000))) { func_80893ED4(this); } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.playerHeightRel <= 80.0f) && - Actor_IsActorFacingLink(&this->actor, 0x1770)) { + Actor_IsFacingPlayer(&this->actor, 0x1770)) { func_80893A9C(this, globalCtx); } else { func_8089484C(this); @@ -611,7 +611,7 @@ void func_80894E0C(EnTite* this, GlobalContext* globalCtx) { } if (this->actor.bgCheckFlags & 0x40) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); } else { func_80893BCC(this, globalCtx); } @@ -627,7 +627,7 @@ void func_80894E0C(EnTite* this, GlobalContext* globalCtx) { (ABS_ALT(this->actor.shape.rot.x) < 4000) && (ABS_ALT(this->actor.shape.rot.z) < 4000))) { func_80893ED4(this); } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.playerHeightRel <= 80.0f) && - Actor_IsActorFacingLink(&this->actor, 0x1770)) { + Actor_IsFacingPlayer(&this->actor, 0x1770)) { func_80893A9C(this, globalCtx); } else { func_8089484C(this); @@ -691,7 +691,7 @@ void func_808951B8(EnTite* this, GlobalContext* globalCtx) { void func_808952EC(EnTite* this) { Animation_PlayLoopSetSpeed(&this->skelAnime, &D_06000A14, 1.5f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); this->collider.base.acFlags &= ~AC_ON; func_80893A18(this); this->unk_2B9 = 1; @@ -718,8 +718,8 @@ void func_80895424(EnTite* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { this->collider.base.acFlags |= AC_ON; if (this->actor.bgCheckFlags & 2) { - func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, 20.0f, 11, 4.0f, 0, 0, 0); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 20.0f, 11, 4.0f, 0, 0, 0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } if (this->unk_2BC == 0) { @@ -735,7 +735,7 @@ void func_80895424(EnTite* this, GlobalContext* globalCtx) { void func_808955E4(EnTite* this) { this->unk_2B9 = 0; this->actor.velocity.y = 13.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); this->actor.bgCheckFlags &= ~1; this->collider.base.acFlags &= ~AC_ON; this->actionFunc = func_80895640; @@ -801,7 +801,7 @@ void func_80895738(EnTite* this, GlobalContext* globalCtx) { if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (this->actor.xzDistToPlayer > 450.0f) || (this->actor.playerHeightRel > 80.0f)) { func_80893ED4(this); - } else if (!Actor_IsActorFacingLink(&this->actor, 0x2328)) { + } else if (!Actor_IsFacingPlayer(&this->actor, 0x2328)) { func_808945EC(this); } else { func_80893A9C(this, globalCtx); @@ -839,7 +839,7 @@ void func_80895AC0(EnTite* this, GlobalContext* globalCtx) { if (Rand_ZeroOne() < 0.25f) { func_8089595C(this, globalCtx); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_WALK); } if ((this->unk_2BC == 1) || (this->unk_2BC == -1)) { @@ -885,7 +885,7 @@ void func_80895D08(EnTite* this, GlobalContext* globalCtx) { if (Rand_ZeroOne() < 0.5f) { func_8089595C(this, globalCtx); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_WALK); } if ((this->actor.xzDistToPlayer < 240.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { func_8089408C(this, globalCtx); @@ -899,7 +899,7 @@ void func_80895D08(EnTite* this, GlobalContext* globalCtx) { void func_80895DE8(EnTite* this) { this->collider.base.acFlags &= ~AC_ON; - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->skelAnime.playSpeed = 1.0f; this->actor.speedXZ = 0.0f; this->actionFunc = func_80895E28; @@ -950,7 +950,7 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { return; } - func_800BE258(&this->actor, &this->collider.info); + Actor_SetDropFlag(&this->actor, &this->collider.info); if ((this->unk_2BB != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { func_80893E54(this, globalCtx); @@ -966,8 +966,8 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect != 0xF) { if (this->actor.colChkInfo.damageEffect == 5) { this->unk_2BC = 40; - func_800BCB70(&this->actor, 0, 200, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 200, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); this->unk_2BB = 32; this->unk_2C8 = 0.5f; this->unk_2C4 = 2.0f; @@ -977,8 +977,8 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 1) { this->unk_2BC = 40; - func_800BCB70(&this->actor, 0, 200, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 200, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_80894DD0(this); return; } @@ -1006,12 +1006,12 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } - func_800BCB70(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (this->actor.colChkInfo.health == 0) { func_80895020(this, globalCtx); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_DAMAGE); if (this->unk_2B9 == 0) { func_80894B2C(this); @@ -1028,7 +1028,7 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { this->actor.flags |= 1; if (this->actor.shape.yOffset < 0.0f) { this->actor.shape.yOffset = 0.0f; - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; } if (this->unk_2B9 != 0) { func_808955E4(this); @@ -1067,7 +1067,7 @@ void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (this->actionFunc != func_808951B8) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 40.0f, 20.0f, this->unk_2C0); func_808963B4(this, globalCtx); if (this->actor.bgCheckFlags & 1) { @@ -1085,7 +1085,7 @@ void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { } } - Actor_SetHeight(&this->actor, this->actor.scale.y * 2000.0f); + Actor_SetFocus(&this->actor, this->actor.scale.y * 2000.0f); this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; this->collider.dim.worldSphere.center.y = (s32)this->actor.world.pos.y + 15; this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 74577c188b..102286a257 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -235,7 +235,7 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B9E8, NULL, this->jointTable, this->morphTable, 18); Animation_Change(&this->skelAnime, &D_060030A4, 1.0f, 0.0f, Animation_GetLastFrame(&D_060030A4.common), 0, 0.0f); this->unk_318 = 0; @@ -299,7 +299,7 @@ void func_80AECA3C(EnTk* this, GlobalContext* globalCtx) { } void func_80AECA90(EnTk* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.unk11F22 = 0; globalCtx->msgCtx.unk11F10 = 0; func_80AEDE10(this, globalCtx); @@ -326,7 +326,7 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { struct_80133038_arg2 sp34; this->actor.textId = 0; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.unk11F22 = 0; globalCtx->msgCtx.unk11F10 = 0; func_80AED4F8(this, globalCtx); @@ -450,7 +450,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { door1 = NULL; label: do { - door1 = func_ActorCategoryIterateById(globalCtx, door1, ACTORCAT_DOOR, ACTOR_EN_DOOR); + door1 = SubS_FindActor(globalCtx, door1, ACTORCAT_DOOR, ACTOR_EN_DOOR); if (door1 != NULL) { if (Actor_XZDistanceBetweenActors(&this->actor, door1) <= 120.0f) { if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &door1->world.pos), this->actor.shape.rot.y)) <= @@ -466,7 +466,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { } else { door2 = NULL; do { - door2 = func_ActorCategoryIterateById(globalCtx, door2, ACTORCAT_DOOR, ACTOR_EN_DOOR); + door2 = SubS_FindActor(globalCtx, door2, ACTORCAT_DOOR, ACTOR_EN_DOOR); if (door2 != NULL) { if (Actor_XZDistanceBetweenActors(&this->actor, door2) <= 160.0f) { sp4C4 = (EnDoor*)door2; @@ -480,7 +480,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { if ((sp4C4 != NULL) && (this->unk_2CA & 0x400)) { Vec3f sp5C; - Actor_CalcOffsetOrientedToDrawRotation(&this->actor, &sp5C, &sp4C4->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->actor, &sp5C, &sp4C4->actor.world.pos); sp4C4->unk_1A7 = 2; if (sp5C.z < -20.0f) { this->unk_2CA &= ~0x400; @@ -562,7 +562,7 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - 0x1555, 0x71C)) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { @@ -682,7 +682,7 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { actor = NULL; do { - actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_TK); + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_TK); if (actor != NULL) { if (ENTK_GET_F(actor) == 1) { Math_Vec3f_Copy(&this->unk_2EC, &actor->world.pos); @@ -696,7 +696,7 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { } while (actor != NULL); } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_2CA &= ~0x80; this->actor.flags &= ~0x10000; globalCtx->msgCtx.unk11F22 = 0; @@ -801,7 +801,7 @@ void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: switch (this->unk_2E6) { case 0x1404: @@ -933,7 +933,7 @@ void func_80AEE374(EnTk* this, GlobalContext* globalCtx) { sp30.unk_00 = NULL; sp30.unk_04 = FLT_MAX; - func_8013E640(globalCtx, &this->actor, NULL, ACTORCAT_NPC, ACTOR_EN_TK, &sp30, func_80AEE300); + SubS_FindActorCustom(globalCtx, &this->actor, NULL, ACTORCAT_NPC, ACTOR_EN_TK, &sp30, func_80AEE300); if (sp30.unk_00 == 0) { Actor_MarkForDeath(&this->actor); } else { @@ -964,14 +964,14 @@ void func_80AEE4D0(EnTk* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 33.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_DIG_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIG_UP); } if (!(this->unk_2CA & 0x20)) { if (Animation_OnFrame(&this->skelAnime, 37.0f)) { bigPoe = NULL; do { - bigPoe = func_ActorCategoryIterateById(globalCtx, bigPoe, ACTORCAT_PROP, ACTOR_EN_BIGPO); + bigPoe = SubS_FindActor(globalCtx, bigPoe, ACTORCAT_PROP, ACTOR_EN_BIGPO); if (bigPoe != NULL) { if ((bigPoe->params == 3) && (Actor_DistanceBetweenActors(&this->actor, bigPoe) < 80.0f)) { @@ -1197,7 +1197,7 @@ void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; } - if (!func_80152498(&globalCtx->msgCtx) && !func_801690CC(globalCtx) && (this->unk_2C6-- <= 0)) { + if (!Message_GetState(&globalCtx->msgCtx) && !func_801690CC(globalCtx) && (this->unk_2C6-- <= 0)) { func_801518B0(globalCtx, 0x140C, NULL); this->unk_2CA |= 0x4000; this->unk_2C6 = 200; @@ -1270,12 +1270,12 @@ void func_80AEF2D8(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.draw != NULL) && ((this->unk_2D4 == 0) || (this->unk_2D4 == 1)) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 24.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_WALK); } this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 4); func_80AEC460(this); } @@ -1292,7 +1292,7 @@ void EnTk_Update(Actor* thisx, GlobalContext* globalCtx) { if (((this->unk_2D4 == 0) || (this->unk_2D4 == 1)) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 24.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOLON_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_WALK); } this->unk_2CA &= ~1; @@ -1315,7 +1315,7 @@ void EnTk_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 0.0f, 5); if ((this->unk_2B0 == 0) && @@ -1331,7 +1331,7 @@ void EnTk_Update(Actor* thisx, GlobalContext* globalCtx) { if (!(this->actor.bgCheckFlags & 1)) { func_800B9010(&this->actor, NA_SE_EV_HONEYCOMB_FALL - SFX_FLAG); } else if (this->actor.bgCheckFlags & 2) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_HUMAN_BOUND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); } } } diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c index ba6945b841..9f0ce13f8d 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -88,7 +88,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx) { } this->actor.gravity = -1.0f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 70.0f, 0x05); if (this->framesUntilNextState == 0) { @@ -140,7 +140,7 @@ void EnTorch2_UpdateDeath(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } else { this->actor.gravity = -1.0f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } } @@ -154,11 +154,11 @@ void EnTorch2_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->alpha == 0xFF) { Scene_SetRenderModeXlu(globalCtx, 0, 0x01); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); - func_800BDFC0(globalCtx, gfx); + Gfx_DrawDListOpa(globalCtx, gfx); } else { Scene_SetRenderModeXlu(globalCtx, 1, 0x02); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->alpha); - func_800BE03C(globalCtx, gfx); + Gfx_DrawDListXlu(globalCtx, gfx); } CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index 0acdc04856..f92ef5afda 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -203,7 +203,7 @@ void EnToto_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 30.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); this->actor.bgCheckFlags |= 0x400; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600A978, ((globalCtx->sceneNum == 0x12) ? &D_06003AA8 : &D_0600C880), this->jointTable, this->morphTable, @@ -227,7 +227,7 @@ void func_80BA383C(EnToto* this, GlobalContext* globalCtx) { } Animation_PlayOnce(&this->skelAnime, D_80BA5078[this->unk2B4]); } - func_800BBB74(&this->unk260, 0x14, 0x50, 3); + func_800BBB74(this->unk260, 0x14, 0x50, 3); } void func_80BA3930(EnToto* this, GlobalContext* globalCtx) { @@ -253,12 +253,12 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); func_80BA383C(this, globalCtx); - if (func_800B84D0(&this->actor, globalCtx) != 0) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80BA36C0(this, globalCtx, 1); if (globalCtx->sceneNum != 0x12) { - Actor_SetSwitchFlag(globalCtx, this->actor.params & 0x7F); + Flags_SetSwitch(globalCtx, this->actor.params & 0x7F); } else if (player->transformation == PLAYER_FORM_DEKU) { - Actor_SetSwitchFlag(globalCtx, this->actor.home.rot.x); + Flags_SetSwitch(globalCtx, this->actor.home.rot.x); } this->unk2B6 = 0; return; @@ -269,7 +269,7 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { if (this->unk2B6 != 0) { this->text = D_80BA5044; this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, 0); + func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, EXCH_ITEM_NONE); } else { this->actor.flags &= ~0x10000; func_800B8614(&this->actor, globalCtx, 50.0f); @@ -315,7 +315,7 @@ void func_80BA3C88(EnToto* this) { void func_80BA3CC4(EnToto* this, GlobalContext* globalCtx) { func_80BA383C(this, globalCtx); func_80BA3C88(this); - if (func_800B867C(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { func_80BA36C0(this, globalCtx, this->text->unk1); } else { func_80BA4C44(this, globalCtx); @@ -327,7 +327,7 @@ void func_80BA3D38(EnToto* this, GlobalContext* globalCtx) { this->text = ENTOTO_WEEK_EVENT_FLAGS ? D_80BA50BC : D_80BA5088; func_80BA4C0C(this, globalCtx); globalCtx->actorCtx.unk5 |= 0x20; - this->unk260 = 0; + this->unk260[0] = 0; } void func_80BA3DBC(EnToto* this, GlobalContext* globalCtx) { @@ -419,21 +419,21 @@ s32 func_80BA407C(EnToto* this, GlobalContext* globalCtx) { } s32 func_80BA40D4(EnToto* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { return 1; } return 0; } s32 func_80BA4128(EnToto* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 2) { + if (Message_GetState(&globalCtx->msgCtx) == 2) { return 1; } return 0; } s32 func_80BA415C(EnToto* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 4 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 4 && func_80147624(globalCtx)) { if (globalCtx->msgCtx.choiceIndex != 0) { func_8019F230(); } else { @@ -655,14 +655,14 @@ s32 func_80BA4B24(EnToto* this, GlobalContext* globalCtx) { Animation_MorphToPlayOnce(&this->skelAnime, &D_060028B8, -4.0f); if (player->transformation == PLAYER_FORM_ZORA) { if (!Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { - Actor_SetSwitchFlag(globalCtx, this->actor.params & 0x7F); + Flags_SetSwitch(globalCtx, this->actor.params & 0x7F); return 1; } else { return 3; } } else { if (!Flags_GetSwitch(globalCtx, (this->actor.params >> 7) & 0x7F)) { - Actor_SetSwitchFlag(globalCtx, (this->actor.params >> 7) & 0x7F); + Flags_SetSwitch(globalCtx, (this->actor.params >> 7) & 0x7F); return 4; } else { return 7; @@ -712,7 +712,7 @@ void func_80BA4CB4(EnToto* this, GlobalContext* globalCtx) { } } if (this->unk2B5 == 4 && !Actor_HasParent(&this->actor, globalCtx)) { - func_800B8A1C(&this->actor, globalCtx, GI_MASK_CIRCUS_LEADER, 9999.9f, 9999.9f); + Actor_PickUp(&this->actor, globalCtx, GI_MASK_CIRCUS_LEADER, 9999.9f, 9999.9f); } } @@ -730,7 +730,7 @@ void EnToto_Update(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - Actor_SetHeight(&this->actor, 40.0f); + Actor_SetFocus(&this->actor, 40.0f); } void EnToto_Draw(Actor* thisx, GlobalContext* globalCtx) { @@ -741,7 +741,7 @@ void EnToto_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp4C[this->unk260])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp4C[this->unk260[0]])); Scene_SetRenderModeXlu(globalCtx, 0, 1); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, NULL, &this->actor); diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.h b/src/overlays/actors/ovl_En_Toto/z_en_toto.h index aa96284266..cdfe3294ea 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.h +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.h @@ -26,7 +26,7 @@ typedef struct EnToto { /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ Vec3s jointTable[18]; /* 0x1F4 */ Vec3s morphTable[18]; - /* 0x260 */ s16 unk260; + /* 0x260 */ s16 unk260[2]; /* 0x264 */ ColliderCylinder collider; /* 0x2B0 */ u8 actionFuncIndex; /* 0x2B1 */ u8 unk2B1; diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index e6cd134b5e..98bcf100b7 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -159,7 +159,7 @@ void EnTrt_UpdateCursorPos(GlobalContext* globalCtx, EnTrt* this) { f32 xOffset = 0.0f; f32 yOffset = 17.0f; - func_800B8898(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); this->cursorPos.x = x + xOffset; this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; @@ -213,7 +213,7 @@ void EnTrt_EndInteraction(GlobalContext* globalCtx, EnTrt* this) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } - func_800B84D0(&this->actor, globalCtx); + Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; Interface_ChangeAlpha(50); @@ -312,7 +312,7 @@ u8 EnTrt_SetCursorIndexFromNeutral(EnTrt* this, u8 shelfOffset) { } void EnTrt_Hello(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -331,7 +331,7 @@ void EnTrt_Hello(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_GetMushroom(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); this->tmpGetMushroomCutscene = this->getMushroomCutscene; @@ -375,12 +375,12 @@ void EnTrt_PayForMushroom(EnTrt* this, GlobalContext* globalCtx) { func_80123D50(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); this->actionFunc = EnTrt_SetupItemGiven; } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_RED, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 300.0f, 300.0f); } } void EnTrt_Goodbye(EnTrt* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { switch (this->textId) { case 0x886: this->textId = 0x887; @@ -395,7 +395,7 @@ void EnTrt_Goodbye(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { if (this->textId == 0x88F) { if (func_80114E90() || !(gSaveContext.weekEventReg[0xC] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { @@ -450,9 +450,9 @@ void EnTrt_GiveRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x20000000; this->actionFunc = EnTrt_GivenRedPotionForKoume; } else if (gSaveContext.weekEventReg[0xC] & 0x10) { - func_800B8A1C(&this->actor, globalCtx, GI_POTION_RED, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, GI_POTION_RED, 300.0f, 300.0f); } else { - func_800B8A1C(&this->actor, globalCtx, GI_BOTTLE_POTION_RED, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, GI_BOTTLE_POTION_RED, 300.0f, 300.0f); } } @@ -460,7 +460,7 @@ void EnTrt_GivenRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { //! @bug: player is set to NULL not PLAYER Player* player = NULL; - if (func_80152498(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); @@ -476,13 +476,13 @@ void EnTrt_GivenRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); this->actionFunc = EnTrt_ItemGiven; } } void EnTrt_EndConversation(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { if (func_80147624(globalCtx)) { @@ -510,7 +510,7 @@ s32 EnTrt_FacingShopkeeperDialogResult(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_FaceShopkeeper(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); u8 cursorIdx; if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { @@ -617,7 +617,7 @@ s32 EnTrt_HasPlayerSelectedItem(GlobalContext* globalCtx, EnTrt* this, Input* in } void EnTrt_BrowseShelf(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; u8 prevCursorIdx = this->cursorIdx; u8 cursorIdx; @@ -646,7 +646,7 @@ void EnTrt_BrowseShelf(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_SetupBuyItemWithFanfare(GlobalContext* globalCtx, EnTrt* this) { Player* player = GET_PLAYER(globalCtx); - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); globalCtx->msgCtx.unk11F22 = 0x43; globalCtx->msgCtx.unk12023 = 4; player->stateFlags2 &= ~0x20000000; @@ -712,7 +712,7 @@ void EnTrt_HandleCanBuyItem(GlobalContext* globalCtx, EnTrt* this) { void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { EnGirlA* item = this->items[this->cursorIdx]; - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (EnTrt_TakeItemOffShelf(this)) { if (talkState == 4) { @@ -774,7 +774,7 @@ void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_SCENTS) { this->textId = 0x890; } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (player->transformation == PLAYER_FORM_HUMAN) { this->flags |= ENTRT_MET; } @@ -818,7 +818,7 @@ void EnTrt_IdleAwake(EnTrt* this, GlobalContext* globalCtx) { } else { this->textId = 0x850; } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -869,7 +869,7 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { this->blinkFunc = EnTrt_OpenEyesThenSetToBlink; this->timer = 10; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KOTAKE_SURPRISED2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOTAKE_SURPRISED2); } } else { this->blinkFunc = EnTrt_OpenEyesThenSetToBlink; @@ -923,7 +923,7 @@ void EnTrt_Surprised(EnTrt* this, GlobalContext* globalCtx) { EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 4); this->animationIdx = 4; this->blinkFunc = EnTrt_OpenEyes2; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KOTAKE_SURPRISED); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOTAKE_SURPRISED); this->timer = 30; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; } @@ -937,7 +937,7 @@ void EnTrt_Surprised(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); this->blinkFunc = EnTrt_Blink; if (talkState == 6 && func_80147624(globalCtx)) { @@ -958,7 +958,7 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt } void EnTrt_TryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { if (this->textId == 0x83C) { if (func_80114E90()) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { @@ -999,7 +999,7 @@ void EnTrt_ItemGiven(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { switch (this->textId) { case 0x889: this->textId = 0x88A; @@ -1020,21 +1020,21 @@ void EnTrt_ItemGiven(EnTrt* this, GlobalContext* globalCtx) { } func_80151938(globalCtx, this->textId); } else { - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); } } void EnTrt_SetupEndInteraction(EnTrt* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { EnTrt_EndInteraction(globalCtx, this); } } void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, this->textId, &this->actor); } else { if ((player->actor.world.pos.x >= -50.0f && player->actor.world.pos.x <= 50.0f) && @@ -1055,7 +1055,7 @@ void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_CannotBuy(EnTrt* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, EnTrt_GetItemTextId(this)); } @@ -1064,7 +1064,7 @@ void EnTrt_CannotBuy(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_CanBuy(EnTrt* this, GlobalContext* globalCtx) { EnGirlA* item; - if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1079,12 +1079,12 @@ void EnTrt_BuyItemWithFanfare(EnTrt* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = EnTrt_SetupItemGiven; } else { - func_800B8A1C(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); } } void EnTrt_SetupItemGiven(EnTrt* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { this->actionFunc = EnTrt_ItemGiven; if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -1093,12 +1093,12 @@ void EnTrt_SetupItemGiven(EnTrt* this, GlobalContext* globalCtx) { this->cutscene = this->lookToShopkeeperCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); } - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); } } void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); EnGirlA* item; @@ -1116,7 +1116,7 @@ void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { player->stateFlags2 |= 0x20000000; func_801518B0(globalCtx, this->textId, &this->actor); EnTrt_SetupStartShopping(globalCtx, this, true); - func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); break; case 1: default: @@ -1368,9 +1368,9 @@ void EnTrt_OpenEyesThenSetToBlink(EnTrt* this) { } void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); - s32 itemActionParam; + s32 itemGiven; if (talkState == 5) { if (func_80147624(globalCtx)) { @@ -1381,16 +1381,16 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { } } } else if (talkState == 16) { - itemActionParam = func_80123810(globalCtx); - if (itemActionParam > PLAYER_AP_NONE) { - if (itemActionParam == PLAYER_AP_BOTTLE_MUSHROOM) { + itemGiven = func_80123810(globalCtx); + if (itemGiven > EXCH_ITEM_NONE) { + if (itemGiven == EXCH_ITEM_1E) { if (gSaveContext.weekEventReg[0x35] & 8) { player->actor.textId = 0x888; } else { player->actor.textId = 0x883; } this->textId = player->actor.textId; - player->unk_A87 = itemActionParam; + player->exchangeItemId = itemGiven; this->actionFunc = EnTrt_GetMushroom; } else { if (this->flags & ENTRT_GIVEN_MUSHROOM) { @@ -1402,7 +1402,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { this->actionFunc = EnTrt_Goodbye; } func_801477B4(globalCtx); - } else if (itemActionParam < PLAYER_AP_NONE) { + } else if (itemGiven < EXCH_ITEM_NONE) { if (this->flags & ENTRT_GIVEN_MUSHROOM) { this->textId = 0x88B; } else { @@ -1466,7 +1466,7 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { EnTrt_GetCutscenes(this, globalCtx); this->cutscene = this->lookForwardCutscene; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); EnTrt_InitShopkeeper(this, globalCtx); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.colChkInfo.cylRadius = 50; @@ -1690,7 +1690,7 @@ void EnTrt_Update(Actor* thisx, GlobalContext* globalCtx) { EnTrt_UpdateCursorAnim(this); EnTrt_UpdateHeadYawAndPitch(this, globalCtx); this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->actor, 90.0f); + Actor_SetFocus(&this->actor, 90.0f); SkelAnime_Update(&this->skelAnime); EnTrt_UpdateCollider(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index cbb31ebc35..74037ce2f7 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -661,16 +661,16 @@ s32 func_80A872AC(EnTru* this, GlobalContext* globalCtx) { s32 ret = false; if (this->unk_34E & 7) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (player->transformation == PLAYER_FORM_HUMAN) { this->unk_34E &= ~0x80; } this->unk_34E &= ~(0x4000 | 0x2000); - if ((player->unk_A87 == 35) || (player->unk_A87 == 36)) { + if ((player->exchangeItemId == 35) || (player->exchangeItemId == 36)) { this->unk_34E |= 0x2000; - this->unk_38C = player->unk_A87; - } else if (player->unk_A87 != 0) { + this->unk_38C = player->exchangeItemId; + } else if (player->exchangeItemId != 0) { this->unk_34E |= 0x4000; } @@ -730,7 +730,7 @@ s32 func_80A87400(EnTru* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.world.rot.y, phi_a1, 4, 3640); this->actor.shape.rot.y = this->actor.world.rot.y; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if ((s32)(this->actor.floorHeight + 80.0f) >= (s32)this->actor.world.pos.y) { func_80A86770(this); } @@ -801,7 +801,7 @@ s32 func_80A8777C(Actor* thisx, GlobalContext* globalCtx) { s32 temp_v0; s32 ret = 0; - temp_v0 = func_80152498(&globalCtx->msgCtx); + temp_v0 = Message_GetState(&globalCtx->msgCtx); switch (temp_v0) { default: @@ -894,9 +894,9 @@ s32 func_80A87880(Actor* thisx, GlobalContext* globalCtx) { this->unk_34E &= ~0x400; func_80123D50(globalCtx, player, 18, 21); } - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KOUME_DRINK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DRINK); } else if (Animation_OnFrame(&this->skelAnime, 90.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KOUME_REGAIN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_REGAIN); } if ((this->skelAnime.curFrame > 90.0f) && (this->skelAnime.curFrame < 95.0f)) { @@ -940,7 +940,7 @@ s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx) { this->unk_372 = 10; this->unk_364++; } else if (Animation_OnFrame(&this->skelAnime, 22.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KOUME_MAGIC); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_MAGIC); func_80A85AA4(this->unk_394, &this->unk_1F8, 1.0f, 0.1f, 40.0f); } break; @@ -952,8 +952,8 @@ s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.shadowDraw = NULL; this->unk_34E |= (0x200 | 0x8); this->unk_34E &= ~0x800; - if (player->unk_A87 != 0) { - player->unk_A87 = 0; + if (player->exchangeItemId != 0) { + player->exchangeItemId = 0; } func_80A86924(this, 12); } @@ -996,8 +996,8 @@ s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx) { case 2: func_801A75E8(NA_SE_EN_KOUME_MAGIC); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KOUME_AWAY); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_KOUME_LAUGH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_AWAY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_LAUGH); func_80A86924(this, 13); this->skelAnime.baseTransl.y = 0; this->skelAnime.moveFlags = 2; @@ -1111,7 +1111,7 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 24.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tru_Skel_01AA60, NULL, this->jointTable, this->morphTable, 27); Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c index 667f9a841c..b09eb87ae7 100644 --- a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c +++ b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c @@ -5,6 +5,7 @@ */ #include "z_en_tubo_trap.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #define FLAGS 0x00000000 @@ -63,7 +64,7 @@ void EnTuboTrap_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.shape.rot.z = 0; this->actor.world.rot.z = 0; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 1.8f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 1.8f); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actionFunc = EnTuboTrap_Idle; @@ -245,7 +246,7 @@ void EnTuboTrap_Idle(EnTuboTrap* this, GlobalContext* globalCtx) { this->targetHeight += transformationHeight; } this->originPos = this->actor.world.pos; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_POT_MOVE_START); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POT_MOVE_START); this->actionFunc = EnTuboTrap_Levitate; } } @@ -272,7 +273,7 @@ void EnTuboTrap_FlyAtPlayer(EnTuboTrap* this, GlobalContext* globalCtx) { // But in MM, certain sfxIds got reordered and devs forgot to update: // In MM, NA_SE_EN_MIZUBABA2_ATTACK is the old value 0x3837 // In MM, NA_SE_EN_TUBOOCK_FLY is the new value 0x3AE0 - Audio_PlayActorSound2(&this->actor, NA_SE_EN_MIZUBABA2_ATTACK - SFX_FLAG); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MIZUBABA2_ATTACK - SFX_FLAG); if ((SQ(dX) + SQ(dY) + SQ(dZ) > SQ(240.0f))) { Math_ApproachF(&this->actor.gravity, -3.0f, 0.2f, 0.5f); @@ -287,17 +288,17 @@ void EnTuboTrap_Update(Actor* thisx, GlobalContext* globalCtx) { s32 padding; this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f, 10.0f, 20.0f, 0x1F); - Actor_SetHeight(&this->actor, 0.0f); + Actor_SetFocus(&this->actor, 0.0f); if (this->actor.projectedPos.z < 811.0f) { if (this->actor.projectedPos.z > 300.0f) { this->actor.shape.shadowAlpha = (u8)((811 - (s32)this->actor.projectedPos.z) >> 1); - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; } else if (this->actor.projectedPos.z > -10.0f) { this->actor.shape.shadowAlpha = 255; - this->actor.shape.shadowDraw = func_800B3FC0; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; } else { this->actor.shape.shadowDraw = NULL; } @@ -311,6 +312,5 @@ void EnTuboTrap_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnTuboTrap_Draw(Actor* thisx, GlobalContext* globalCtx) { - // Gfx_DrawDListOpa with a display list - func_800BDFC0(globalCtx, D_05017EA0); + Gfx_DrawDListOpa(globalCtx, gameplay_dangeon_keep_DL_017EA0); } diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c index 2031127f7c..5959841904 100644 --- a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c +++ b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c @@ -96,7 +96,7 @@ void func_80A66278(EnWarpUzu* this, GlobalContext* globalCtx) { do { player = GET_PLAYER(globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80A66384(this, globalCtx); } else { phi_a0 = ABS((s16)(Actor_YawBetweenActors(&this->actor, &player->actor) - this->actor.shape.rot.y)); @@ -133,5 +133,5 @@ void EnWarpUzu_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnWarpUzu_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000EC0); + Gfx_DrawDListOpa(globalCtx, D_06000EC0); } diff --git a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c index 236881f252..843294728c 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c @@ -5,6 +5,8 @@ */ #include "z_en_water_effect.h" +#include "objects/object_water_effect/object_water_effect.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000035 @@ -15,7 +17,11 @@ void EnWaterEffect_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWaterEffect_Update(Actor* thisx, GlobalContext* globalCtx); void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A59C04(Actor* thisx, GlobalContext* globalCtx2); +void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2); +void func_80A5A534(Actor* thisx, GlobalContext* globalCtx); +void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2); + const ActorInit En_Water_Effect_InitVars = { ACTOR_EN_WATER_EFFECT, ACTORCAT_BOSS, @@ -28,30 +34,672 @@ const ActorInit En_Water_Effect_InitVars = { (ActorFunc)EnWaterEffect_Draw, }; -#endif +static Vec3f D_80A5AFB0 = { 0.0f, 0.0f, 0.0f }; +static Vec3f D_80A5AFBC = { 0.0f, -1.0f, 0.0f }; -extern UNK_TYPE D_06000DE0; -extern UNK_TYPE D_060042B0; -extern UNK_TYPE D_060043E8; +void func_80A587A0(EnWaterEffect* this, Vec3f* arg1, u8 arg2) { + s16 i; + EnWaterEffectStruct* ptr = &this->unk_144[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/func_80A587A0.s") + for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { + if (!ptr->unk_00) { + ptr->unk_00 = true; + ptr->unk_04 = *arg1; + ptr->unk_10 = D_80A5AFB0; + ptr->unk_1C = D_80A5AFB0; + ptr->unk_2C.x = 0.1f; + ptr->unk_2C.y = 0.0f; + ptr->unk_2C.z = Rand_ZeroFloat(M_PI * 2); + ptr->unk_01 = Rand_ZeroFloat(100.0f); + ptr->unk_2A = arg2; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/func_80A58908.s") +void func_80A58908(EnWaterEffect* this, Vec3f* arg1, Vec3f* arg2, u8 arg3) { + Vec3f sp2C = D_80A5AFBC; + EnWaterEffectStruct* ptr = &this->unk_144[0]; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/EnWaterEffect_Init.s") + for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = 2; + ptr->unk_04 = *arg1; + ptr->unk_10 = *arg2; + ptr->unk_1C = sp2C; + ptr->unk_2C.y = Rand_ZeroFloat(0.02f) + 0.02f; + ptr->unk_2C.x = ptr->unk_2C.y; + ptr->unk_2C.z = Rand_ZeroFloat(M_PI * 2); + ptr->unk_01 = Rand_ZeroFloat(100.0f); + ptr->unk_2A = arg3; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/EnWaterEffect_Destroy.s") +void EnWaterEffect_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWaterEffect* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/EnWaterEffect_Update.s") + this->actor.flags &= ~1; + this->unk_DC4 = Rand_ZeroFloat(100.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/EnWaterEffect_Draw.s") + if (this->actor.params == ENWATEREFFECT_1) { + this->actor.update = func_80A59C04; + this->actor.draw = func_80A5A184; + this->unk_DC6 = Rand_ZeroFloat(100.0f) + 60.0f; + } else if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_778) || + (this->actor.params == ENWATEREFFECT_779) || (this->actor.params == ENWATEREFFECT_780)) { + this->actor.update = func_80A5A534; + this->actor.draw = func_80A5A6B8; + this->actor.shape.rot.y = Rand_ZeroFloat(0x10000); + Actor_SetScale(&this->actor, this->actor.shape.rot.z * 0.0002f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/func_80A599E8.s") + if (this->actor.params == ENWATEREFFECT_777) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, this->actor.shape.rot.z, 0x30A); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, this->actor.shape.rot.z, 0x30B); + } else if (this->actor.params == ENWATEREFFECT_778) { + this->unk_DC4 = -3; + } else if (this->actor.params == ENWATEREFFECT_779) { + this->unk_DC4 = -6; + } else if (this->actor.params == ENWATEREFFECT_780) { + this->unk_DC4 = 23; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/func_80A59C04.s") + this->unk_E08[1] = 0.2f; + this->unk_E18[1] = -0.017f; + this->unk_E08[2] = 0.2f; + this->unk_E18[2] = -0.018f; + this->unk_E08[3] = 0.2f; + this->unk_E18[3] = -0.019f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/func_80A5A184.s") + this->unk_DC8[1].y = 1.0f; + this->unk_DC8[2].y = 1.0f; + this->unk_DC8[3].y = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/func_80A5A534.s") + this->unk_E2C = 255.0f; + this->unk_E34 = 255.0f; + this->unk_E30 = 200.0f; + this->unk_E38 = 191.25f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Water_Effect/func_80A5A6B8.s") +void EnWaterEffect_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnWaterEffect_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnWaterEffect* this = THIS; + Player* player = GET_PLAYER(globalCtx); + EnWaterEffectStruct* ptr = &this->unk_144[0]; + s16 i; + s16 j; + s32 phi_v0; + Vec3f spA4; + Vec3f sp98; + u8 phi_v1; + Vec3f sp88; + + if (!Flags_GetSwitch(globalCtx, this->actor.params)) { + this->unk_DC4++; + if ((this->unk_DC4 % 32) == 0) { + if (Rand_ZeroOne() < 0.5f) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 10.0f, 40.0f, 4); + sp88.x = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.x; + sp88.y = this->actor.world.pos.y; + sp88.z = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.z; + if ((this->actor.world.pos.y + this->actor.depthInWater) <= this->actor.floorHeight) { + phi_v1 = 0; + } else { + phi_v1 = 1; + this->actor.floorHeight = this->actor.world.pos.y + this->actor.depthInWater; + } + func_80A587A0(this, &sp88, phi_v1); + } + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { + if (ptr->unk_00 != 0) { + ptr->unk_01++; + + ptr->unk_04.x += ptr->unk_10.x; + ptr->unk_04.y += ptr->unk_10.y; + ptr->unk_04.z += ptr->unk_10.z; + ptr->unk_10.y += ptr->unk_1C.y; + + Math_ApproachF(&ptr->unk_38, (ptr->unk_01 & 6) ? 80.0f : 200.0f, 1.0f, 80); + + if (ptr->unk_00 == 1) { + ptr->unk_2C.z += 0.15f; + Math_ApproachF(&ptr->unk_2C.x, 0.03f, 0.5f, 0.005f); + Math_ApproachF(&ptr->unk_2C.y, 0.5f, 0.5f, 0.02f); + + if (ptr->unk_2C.y > 0.15f) { + ptr->unk_1C.y = -1.0f; + if (ptr->unk_10.y < -20.0f) { + ptr->unk_10.y = -20.0f; + } + } + + if ((fabsf(ptr->unk_04.x - player->actor.world.pos.x) < 15.0f) && + (fabsf(ptr->unk_04.z - player->actor.world.pos.z) < 15.0f) && + (player->actor.world.pos.y < ptr->unk_04.y) && + ((ptr->unk_04.y - player->actor.world.pos.y) < 40.0f)) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if ((ptr->unk_04.y <= this->actor.floorHeight) || phi_v0) { + + if (phi_v0) { + ptr->unk_00 = 0; + Audio_PlaySoundAtPosition(globalCtx, &ptr->unk_04, 30, NA_SE_EV_BOMB_DROP_WATER); + } else { + ptr->unk_04.y = this->actor.floorHeight; + if (ptr->unk_2A == 0) { + Audio_PlaySoundAtPosition(globalCtx, &ptr->unk_04, 30, NA_SE_EV_WATERDROP_GRD); + ptr->unk_00 = 3; + ptr->unk_2C.x = 0.1f; + ptr->unk_2C.y = 0.6f; + ptr->unk_10 = D_80A5AFB0; + ptr->unk_1C = D_80A5AFB0; + ptr->unk_3C = 200; + ptr->unk_28 = 9; + Math_Vec3f_Copy(&sp98, &ptr->unk_04); + sp98.y += 3.0f; + EffectSsGSplash_Spawn(globalCtx, &sp98, NULL, NULL, 1, 100); + } else { + ptr->unk_00 = 0; + Audio_PlaySoundAtPosition(globalCtx, &ptr->unk_04, 30, NA_SE_EV_WATERDROP); + EffectSsGRipple_Spawn(globalCtx, &ptr->unk_04, 70, 500, 0); + EffectSsGRipple_Spawn(globalCtx, &ptr->unk_04, 70, 500, 10); + Math_Vec3f_Copy(&sp98, &ptr->unk_04); + sp98.y += 10.0f; + EffectSsGSplash_Spawn(globalCtx, &sp98, NULL, NULL, 1, 300); + } + } + + for (j = 0; j < 12; j++) { + Matrix_InsertYRotation_f((2.0f * (j * M_PI)) / 5.5f, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(1.5f) + 1.5f, &spA4); + spA4.y = Rand_ZeroFloat(4.0f) + 2.0f; + func_80A58908(this, &ptr->unk_04, &spA4, ptr->unk_2A); + } + } + } else if (ptr->unk_00 == 2) { + ptr->unk_2C.z += 0.15f; + if (ptr->unk_10.y < -8.0f) { + ptr->unk_10.y = -8.0f; + } + + if (ptr->unk_10.y < 0.0f) { + if (ptr->unk_04.y <= this->actor.floorHeight) { + ptr->unk_04.y = this->actor.floorHeight; + if (ptr->unk_2A == 0) { + ptr->unk_00 = 3; + ptr->unk_2C.x = 0.05f; + ptr->unk_2C.y = 0.2f; + ptr->unk_10 = D_80A5AFB0; + ptr->unk_1C = D_80A5AFB0; + ptr->unk_3C = 150; + ptr->unk_28 = Rand_ZeroFloat(5.0f) + 7.0f; + } else { + EffectSsGRipple_Spawn(globalCtx, &ptr->unk_04, 0, 200, 0); + ptr->unk_00 = 0; + } + } + } + } else if (ptr->unk_00 == 3) { + Math_ApproachF(&ptr->unk_2C.x, ptr->unk_2C.y, 0.1f, 0.6f); + ptr->unk_3C -= ptr->unk_28; + if (ptr->unk_3C <= 0) { + ptr->unk_3C = 0; + ptr->unk_00 = 0; + } + } + } + } +} + +void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + EnWaterEffect* this = THIS; + s32 pad; + EnWaterEffectStruct* backupPtr = &this->unk_144[0]; + EnWaterEffectStruct* ptr = backupPtr; + u8 phi_s4 = false; + s16 i; + + OPEN_DISPS(gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { + if ((ptr->unk_00 == 1) || (ptr->unk_00 == 2)) { + if (!phi_s4) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_08DBE0)); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); + phi_s4++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)ptr->unk_38, (u8)(((void)0, ptr->unk_38) + 55.0f), 225, 150); + + Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + + if (ptr->unk_00 == 1) { + Matrix_RotateY(func_800DFC68(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + } else { + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + } + + Matrix_Scale(ptr->unk_2C.x, ptr->unk_2C.y, 1.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_f(ptr->unk_2C.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042B0); + } + } + + phi_s4 = false; + ptr = backupPtr; + + for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { + if (ptr->unk_00 == 3) { + if (!phi_s4) { + func_8012C448(gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_08DBE0)); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); + phi_s4++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)ptr->unk_38, (u8)(((void)0, ptr->unk_38) + 55.0f), 225, + ptr->unk_3C); + + Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Scale(ptr->unk_2C.x, 1.0f, ptr->unk_2C.x, MTXMODE_APPLY); + Matrix_InsertYRotation_f(ptr->unk_2C.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042F8); + } + } + + CLOSE_DISPS(gfxCtx); +} + +void func_80A599E8(EnWaterEffect* this, Vec3f* arg1, u8 arg2) { + s16 i; + EnWaterEffectStruct* ptr = &this->unk_144[0]; + + for (i = 0; i < ARRAY_COUNT(this->unk_144); i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = 4; + ptr->unk_04 = *arg1; + + ptr->unk_1C = D_80A5AFB0; + ptr->unk_10 = D_80A5AFB0; + + if ((arg2 == 0) || (arg2 == 2)) { + ptr->unk_1C.y = -1.0f; + } + + if (arg2 >= 2) { + if (arg2 == 2) { + ptr->unk_10.x = randPlusMinusPoint5Scaled(10.0f); + ptr->unk_10.y = Rand_ZeroFloat(3.0f) + 5.0f; + ptr->unk_10.z = randPlusMinusPoint5Scaled(10.0f); + } + ptr->unk_2C.z = 0.0017f; + ptr->unk_2C.x = 0.003f; + ptr->unk_2C.y = 0.0018f; + } else { + ptr->unk_2C.z = 0.003f; + ptr->unk_2C.x = 0.003f; + ptr->unk_2C.y = 0.003f; + } + ptr->unk_38 = 255.0f; + ptr->unk_28 = Rand_ZeroFloat(0x10000); + ptr->unk_3C = 255; + ptr->unk_01 = Rand_ZeroFloat(200.0f); + ptr->unk_2A = arg2; + break; + } + } +} + +void func_80A59C04(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnWaterEffect* this = THIS; + s16 i; + s16 j; + f32 temp_f0_2; + Player* player = GET_PLAYER(globalCtx); + Vec3f sp90; + Actor* rotaryRoom = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; + CollisionPoly* sp88; + EnWaterEffectStruct* ptr = &this->unk_144[0]; + u8 phi_s5; + Vec3f sp74; + + while (rotaryRoom != NULL) { + if (rotaryRoom->id == ACTOR_BG_IKANA_ROTARYROOM) { + break; + } + rotaryRoom = rotaryRoom->next; + } + + if (this->unk_DC6 != 0) { + this->unk_DC6--; + } + + if ((rotaryRoom != NULL) && Flags_GetSwitch(globalCtx, (rotaryRoom->params >> 1) & 0x7F)) { + this->unk_DC6 = Rand_ZeroFloat(150.0f) + 100.0f; + } else if (!func_801690CC(globalCtx)) { + this->unk_DC4++; + if (this->unk_DC6 == 0) { + this->unk_DC6 = Rand_ZeroFloat(150.0f) + 100.0f; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 10.0f, 40.0f, 4); + sp74.x = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.x; + sp74.y = this->actor.world.pos.y; + sp74.z = randPlusMinusPoint5Scaled(50.0f) + this->actor.world.pos.z; + func_80A599E8(this, &sp74, 0); + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_144); i++, ptr++) { + phi_s5 = false; + + if (ptr->unk_00 != 0) { + ptr->unk_01++; + + ptr->unk_04.x += ptr->unk_10.x; + ptr->unk_04.y += ptr->unk_10.y; + ptr->unk_04.z += ptr->unk_10.z; + ptr->unk_10.y = ptr->unk_10.y + ptr->unk_1C.y; + + if (ptr->unk_00 == 4) { + if (ptr->unk_2A > 0) { + if (ptr->unk_2A == 1) { + Math_ApproachF(&ptr->unk_2C.x, 0.001f, 0.5f, 0.0002f); + } + + if (ptr->unk_2A & 1) { + Math_ApproachZeroF(&ptr->unk_38, 1.0f, 30.0f); + if (ptr->unk_2A == 1) { + ptr->unk_3C -= 20; + } else { + ptr->unk_3C -= 10; + } + if (ptr->unk_3C <= 0) { + ptr->unk_00 = 0; + } + Math_ApproachZeroF(&ptr->unk_10.x, 1.0f, 1.0f); + Math_ApproachZeroF(&ptr->unk_10.z, 1.0f, 1.0f); + } + } + + if ((ptr->unk_2A % 2) == 0) { + if (ptr->unk_2A == 0) { + func_80A599E8(this, &ptr->unk_04, 1); + } else if ((ptr->unk_01 & 1) == 0) { + func_80A599E8(this, &ptr->unk_04, 3); + } + + if (ptr->unk_10.y < -20.0f) { + ptr->unk_10.y = -20.0f; + } + + ptr->unk_28 += 0x800; + if ((fabsf(ptr->unk_04.x - player->actor.world.pos.x) < 20.0f) && + (fabsf(ptr->unk_04.z - player->actor.world.pos.z) < 20.0f) && + (fabsf(ptr->unk_04.y - (player->actor.world.pos.y + 25.0f)) < 30.0f)) { + phi_s5 = true; + if ((player->transformation != PLAYER_FORM_GORON) && !player->isBurning) { + func_800B8D50(globalCtx, &this->actor, 2.0f, Rand_ZeroFloat(0x10000), 0.0f, 0x10); + for (j = 0; j < ARRAY_COUNT(player->flameTimers); j++) { + player->flameTimers[j] = Rand_S16Offset(0, 200); + } + player->isBurning = true; + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DEMO_DAMAGE); + } + } + + Math_Vec3f_Copy(&sp90, &ptr->unk_04); + sp90.y += 30.0f; + + temp_f0_2 = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp88, &sp90); + if (fabsf(temp_f0_2 - this->actor.floorHeight) > 200.0f) { + phi_s5 = true; + } + + if ((ptr->unk_04.y <= temp_f0_2) || (phi_s5 != 0)) { + if (phi_s5 == 0) { + ptr->unk_04.y = temp_f0_2; + } + ptr->unk_10.y = 0.0f; + ptr->unk_1C.y = 0.0f; + if (ptr->unk_2A == 0) { + for (j = 0; j < 5; j++) { + func_80A599E8(this, &ptr->unk_04, 2); + } + Audio_PlaySoundAtPosition(globalCtx, &ptr->unk_04, 30, NA_SE_EV_PLANT_BROKEN); + } + ptr->unk_2A++; + } + } + } + } + } +} + +void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnWaterEffect* this = THIS; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + EnWaterEffectStruct* ptr = &this->unk_144[0]; + u8 flag = false; + s16 i; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_144); i++, ptr++) { + if (ptr->unk_00 == 4) { + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004340); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 500, 3600); + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, (u8)ptr->unk_38, 0, 0, (u8)ptr->unk_3C); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (ptr->unk_01 * -20) & 0x1FF, + 0x20, 0x80)); + + Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + + if (ptr->unk_2A >= 2) { + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + } else { + Matrix_RotateY(func_800DFC68(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + } + + Matrix_Scale(ptr->unk_2C.x, ptr->unk_2C.y, 1.0f, MTXMODE_APPLY); + + if ((i & 1) != 0) { + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0043E8); + + if ((ptr->unk_2A & 1) == 0) { + Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y + 5.0f, ptr->unk_04.z, MTXMODE_NEW); + Matrix_InsertXRotation_s(ptr->unk_28, MTXMODE_APPLY); + Matrix_Scale(ptr->unk_2C.z, ptr->unk_2C.z, ptr->unk_2C.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06AB30); + } + } + } + + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + + CLOSE_DISPS(gfxCtx); +} + +void func_80A5A534(Actor* thisx, GlobalContext* globalCtx) { + EnWaterEffect* this = THIS; + s32 i; + + if (this->unk_E38 < 1.0f) { + Actor_MarkForDeath(&this->actor); + } + + this->unk_DC4++; + + if (this->unk_DC4 >= 0) { + for (i = 1; i < 4; i++) { + this->unk_DC8[i].z += this->unk_E08[i]; + this->unk_E08[i] += this->unk_E18[i]; + if (this->unk_DC8[i].z <= 0.0f) { + this->unk_DC8[i].z = 0.0f; + this->unk_E08[i] = 0.0f; + } + } + + Math_ApproachF(&this->unk_DC8[1].y, 20.0f, 1.0f, 0.025f); + Math_ApproachF(&this->unk_DC8[2].y, 20.0f, 1.0f, 0.075f); + Math_ApproachF(&this->unk_DC8[3].y, 20.0f, 1.0f, 0.1f); + + if (this->unk_DC4 >= 24) { + Math_ApproachF(&this->unk_DC8[4].y, 2.0f, 0.1f, 0.2f); + Math_ApproachZeroF(&this->unk_E2C, 1.0f, 26.0f); + Math_ApproachZeroF(&this->unk_E30, 1.0f, 26.0f); + Math_ApproachZeroF(&this->unk_E34, 1.0f, 24.0f); + if (this->unk_DC4 >= 50) { + Math_ApproachZeroF(&this->unk_E38, 1.0f, 3.75f); + } + } + } +} + +void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnWaterEffect* this = THIS; + EnWaterEffectStruct* ptr = &this->unk_144[0]; + u8 phi_s4 = false; + s16 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_XLU_DISP++, 165, 235, 255, 128); + + Matrix_StatePush(); + Matrix_StatePush(); + Matrix_StatePush(); + + if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_778)) { + if (this->unk_E2C > 1.0f) { + func_8012C2DC(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_water_effect_Matanimheader_000DE0)); + Matrix_Scale(this->unk_DC8[1].y, this->unk_DC8[1].z, this->unk_DC8[1].y, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->unk_E2C); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000420); + } + + Matrix_StatePop(); + + if (this->unk_E30 > 1.0f) { + func_8012C2DC(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_water_effect_Matanimheader_000E0C)); + Matrix_Scale(this->unk_DC8[2].y, this->unk_DC8[2].z, this->unk_DC8[2].y, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->unk_E30); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000730); + } + Matrix_StatePop(); + } else { + Matrix_StatePop(); + Matrix_StatePop(); + } + + if ((this->unk_E34 > 1.0f) && (this->actor.params != ENWATEREFFECT_780)) { + func_8012C2DC(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_water_effect_Matanimheader_000E40)); + Matrix_Scale(this->unk_DC8[3].y, this->unk_DC8[3].z, this->unk_DC8[3].y, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->unk_E34); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000A48); + } + + Matrix_StatePop(); + + if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_780)) { + func_8012C2DC(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_water_effect_Matanimheader_000E58)); + Matrix_Scale(this->unk_DC8[4].y, this->unk_DC8[4].z, this->unk_DC8[4].y, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->unk_E38); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000CD8); + } + + if (this->actor.params == ENWATEREFFECT_777) { + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_144) / 2; i++, ptr++) { + if (ptr->unk_00 == 3) { + if (!phi_s4) { + func_8012C448(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_08DBE0)); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); + phi_s4++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)ptr->unk_38, (u8)(((void)0, ptr->unk_38) + 55.0f), 225, + ptr->unk_3C); + + Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Scale(ptr->unk_2C.x, 1.0f, ptr->unk_2C.x, MTXMODE_APPLY); + Matrix_InsertYRotation_f(ptr->unk_2C.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042F8); + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h index f7805ddca8..774b858cda 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h @@ -5,9 +5,41 @@ struct EnWaterEffect; +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; + /* 0x04 */ Vec3f unk_04; + /* 0x10 */ Vec3f unk_10; + /* 0x1C */ Vec3f unk_1C; + /* 0x28 */ s16 unk_28; + /* 0x2A */ u8 unk_2A; + /* 0x2C */ Vec3f unk_2C; + /* 0x38 */ f32 unk_38; + /* 0x3C */ s16 unk_3C; +} EnWaterEffectStruct; // size = 0x40 + +enum { + /* 0x 1 */ ENWATEREFFECT_1 = 1, + /* 0x309 */ ENWATEREFFECT_777 = 777, + /* 0x30A */ ENWATEREFFECT_778, + /* 0x30B */ ENWATEREFFECT_779, + /* 0x30C */ ENWATEREFFECT_780, +}; + typedef struct EnWaterEffect { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xCF8]; + /* 0x144 */ EnWaterEffectStruct unk_144[50]; + /* 0xDC4 */ s16 unk_DC4; + /* 0xDC6 */ s16 unk_DC6; + /* 0xDC8 */ Vec3f unk_DC8[5]; + /* 0xE04 */ UNK_TYPE1 unk_E04[4]; + /* 0xE04 */ f32 unk_E08[4]; + /* 0xE18 */ f32 unk_E18[4]; + /* 0xE28 */ UNK_TYPE1 unk_E28[4]; + /* 0xE2C */ f32 unk_E2C; + /* 0xE30 */ f32 unk_E30; + /* 0xE34 */ f32 unk_E34; + /* 0xE38 */ f32 unk_E38; } EnWaterEffect; // size = 0xE3C extern const ActorInit En_Water_Effect_InitVars; diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/src/overlays/actors/ovl_En_Wf/z_en_wf.c index 931d283e47..e1786b78cf 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -283,7 +283,7 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { s32 temp_s0; Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 70.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 70.0f); this->actor.shape.shadowAlpha = 150; Collider_InitAndSetJntSph(globalCtx, &this->collider1, &this->actor, &sJntSphInit, this->collider1Elements); Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit1); @@ -325,7 +325,7 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { } } - if (Actor_GetRoomCleared(globalCtx, this->actor.room)) { + if (Flags_GetClear(globalCtx, this->actor.room)) { Actor_MarkForDeath(&this->actor); return; } @@ -384,7 +384,7 @@ void func_809907D4(EnWf* this) { this->collider3.base.colType = COLTYPE_HIT3; this->unk_2A0 = 80; this->actor.flags &= ~0x400; - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 80); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); } void func_80990854(EnWf* this, GlobalContext* globalCtx) { @@ -393,7 +393,7 @@ void func_80990854(EnWf* this, GlobalContext* globalCtx) { this->collider2.base.colType = COLTYPE_HIT5; this->collider3.base.colType = COLTYPE_HIT5; this->unk_2AC = 0.0f; - func_800BF7CC(globalCtx, &this->actor, this->unk_2B8, 10, 2, 0.3f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2B8, 10, 2, 0.3f, 0.2f); this->actor.flags |= 0x400; } } @@ -463,13 +463,13 @@ s32 func_80990948(GlobalContext* globalCtx, EnWf* this, s16 arg2) { } if (arg2 != 0) { - if (!Actor_IsActorFacingLink(&this->actor, 7000)) { + if (!Actor_IsFacingPlayer(&this->actor, 7000)) { func_80992A74(this, globalCtx); return true; } sp2E = player->actor.shape.rot.y - this->actor.shape.rot.y; - if ((this->actor.xzDistToPlayer <= 80.0f) && !func_800BC5EC(globalCtx, &this->actor)) { + if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(globalCtx, &this->actor)) { if (((globalCtx->gameplayFrames % 8) != 0) || (ABS_ALT(sp2E) < 0x38E0)) { func_80991C04(this); return true; @@ -518,7 +518,7 @@ void func_80990C6C(EnWf* this, GlobalContext* globalCtx, s32 arg2) { void func_80990E4C(EnWf* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 1.0f) && (this->actor.bgCheckFlags & 1)) { func_80990C6C(this, globalCtx, 2); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_WALK); } } @@ -534,7 +534,7 @@ s32 func_80990EAC(EnWf* this) { void func_80990ED4(EnWf* this) { this->actor.child = NULL; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_APPEAR); func_80991438(this); } @@ -578,7 +578,7 @@ void func_80991040(EnWf* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.shape.shadowScale, 70.0f, 14.0f); this->unk_2A0--; if (this->unk_2A0 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_APPEAR); } } else if (SkelAnime_Update(&this->skelAnime)) { this->actor.scale.y = this->actor.scale.x; @@ -639,7 +639,7 @@ void func_80991280(EnWf* this, GlobalContext* globalCtx) { } else { this->unk_2A0--; if (this->unk_2A0 == 0) { - if (Actor_IsActorFacingLink(&this->actor, 0x1555)) { + if (Actor_IsFacingPlayer(&this->actor, 0x1555)) { if (Rand_ZeroOne() > 0.3f) { func_80991438(this); } else { @@ -650,7 +650,7 @@ void func_80991280(EnWf* this, GlobalContext* globalCtx) { } if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } } } @@ -674,7 +674,7 @@ void func_8099149C(EnWf* this, GlobalContext* globalCtx) { if (!func_8099408C(globalCtx, this)) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 500); this->actor.world.rot.y = this->actor.shape.rot.y; - if (func_800BC5EC(globalCtx, &this->actor)) { + if (Actor_OtherIsTargeted(globalCtx, &this->actor)) { sp2C = 150.0f; } else { sp2C = 0.0f; @@ -693,17 +693,17 @@ void func_8099149C(EnWf* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (!func_80990948(globalCtx, this, 0)) { - if (!Actor_IsActorFacingLink(&this->actor, 0x11C7)) { + if (!Actor_IsFacingPlayer(&this->actor, 0x11C7)) { if (Rand_ZeroOne() > 0.5f) { func_80991948(this); } else { func_80991200(this); } } else if (this->actor.xzDistToPlayer < (90.0f + sp2C)) { - if (!func_800BC5EC(globalCtx, &this->actor) && + if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && ((Rand_ZeroOne() > 0.03f) || ((this->actor.xzDistToPlayer <= 80.0f) && (sp28 < 0x38E0)))) { func_80991C04(this); - } else if (func_800BC5EC(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { + } else if (Actor_OtherIsTargeted(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { func_8099223C(this); } else { func_80991948(this); @@ -711,7 +711,7 @@ void func_8099149C(EnWf* this, GlobalContext* globalCtx) { } if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } func_80990E4C(this, globalCtx); @@ -757,7 +757,7 @@ void func_8099177C(EnWf* this, GlobalContext* globalCtx) { this->skelAnime.playSpeed = -phi_f2; SkelAnime_Update(&this->skelAnime); - if (Actor_IsActorFacingLink(&this->actor, 0x1555)) { + if (Actor_IsFacingPlayer(&this->actor, 0x1555)) { if (Rand_ZeroOne() > 0.8f) { func_80991948(this); } else { @@ -765,7 +765,7 @@ void func_8099177C(EnWf* this, GlobalContext* globalCtx) { } } if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } } } @@ -804,16 +804,16 @@ void func_809919F4(EnWf* this, GlobalContext* globalCtx) { func_80990E4C(this, globalCtx); if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } - if ((Math_CosS(sp26 - this->actor.shape.rot.y) < -0.85f) && !func_800BC5EC(globalCtx, &this->actor) && + if ((Math_CosS(sp26 - this->actor.shape.rot.y) < -0.85f) && !Actor_OtherIsTargeted(globalCtx, &this->actor) && (this->actor.xzDistToPlayer <= 80.0f)) { func_80991C04(this); } else { this->unk_2A0--; if (this->unk_2A0 == 0) { - if (func_800BC5EC(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { + if (Actor_OtherIsTargeted(globalCtx, &this->actor) && (Rand_ZeroOne() > 0.5f)) { func_8099223C(this); } else { func_80991200(this); @@ -848,7 +848,7 @@ void func_80991C80(EnWf* this, GlobalContext* globalCtx) { if (((this->skelAnime.curFrame >= 9.0f) && (this->skelAnime.curFrame < 13.0f)) || ((this->skelAnime.curFrame >= 17.0f) && (this->skelAnime.curFrame < 20.0f))) { if (!(this->collider1.base.atFlags & AT_ON)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_ATTACK); } this->collider1.base.atFlags |= AT_ON; } else { @@ -856,14 +856,14 @@ void func_80991C80(EnWf* this, GlobalContext* globalCtx) { } sp2C = Animation_OnFrame(&this->skelAnime, 15.0f); - if (((sp2C != 0) && !func_800BC5B8(globalCtx, &this->actor) && - (!Actor_IsActorFacingLink(&this->actor, 0x2000) || (this->actor.xzDistToPlayer >= 100.0f))) || + if (((sp2C != 0) && !Actor_IsTargeted(globalCtx, &this->actor) && + (!Actor_IsFacingPlayer(&this->actor, 0x2000) || (this->actor.xzDistToPlayer >= 100.0f))) || SkelAnime_Update(&this->skelAnime)) { if ((sp2C == 0) && (this->unk_2A0 != 0)) { this->actor.shape.rot.y += (s16)(0xCCC * (1.5f + ((this->unk_2A0 - 4) * 0.4f))); func_80990C6C(this, globalCtx, 1); this->unk_2A0--; - } else if (!Actor_IsActorFacingLink(&this->actor, 0x1554) && (sp2C == 0)) { + } else if (!Actor_IsFacingPlayer(&this->actor, 0x1554) && (sp2C == 0)) { func_80991200(this); this->unk_2A0 = (s32)Rand_ZeroFloat(5.0f) + 5; if (sp30 >= 0x32C9) { @@ -910,7 +910,7 @@ void func_80992068(EnWf* this, GlobalContext* globalCtx) { sp28 = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)); if (SkelAnime_Update(&this->skelAnime)) { - if (!Actor_IsActorFacingLink(&this->actor, 0x1554)) { + if (!Actor_IsFacingPlayer(&this->actor, 0x1554)) { func_80991200(this); this->unk_2A0 = (s32)Rand_ZeroFloat(5.0f) + 5; if (sp28 > 0x32C8) { @@ -944,13 +944,13 @@ void func_8099223C(EnWf* this) { this->actor.speedXZ = -6.0f; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); this->actionFunc = func_809922B4; } void func_809922B4(EnWf* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { - if (!func_800BC5EC(globalCtx, &this->actor) && (this->actor.xzDistToPlayer < 170.0f) && + if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && (this->actor.xzDistToPlayer < 170.0f) && (this->actor.xzDistToPlayer > 140.0f) && (Rand_ZeroOne() < 0.2f)) { func_80991438(this); } else if ((globalCtx->gameplayFrames % 2) != 0) { @@ -960,7 +960,7 @@ void func_809922B4(EnWf* this, GlobalContext* globalCtx) { } } if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } } @@ -995,7 +995,7 @@ void func_8099245C(EnWf* this) { } this->unk_298 = 0; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_DAMAGE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_DAMAGE); this->actionFunc = func_809924EC; } @@ -1021,7 +1021,7 @@ void func_809924EC(EnWf* this, GlobalContext* globalCtx) { if ((this->actor.bgCheckFlags & 8) && (ABS_ALT(sp26) < 0x2EE0) && (this->actor.xzDistToPlayer < 120.0f)) { func_809926D0(this); } else if (!func_8099408C(globalCtx, this)) { - if ((this->actor.xzDistToPlayer <= 80.0f) && !func_800BC5EC(globalCtx, &this->actor) && + if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(globalCtx, &this->actor) && ((globalCtx->gameplayFrames % 8) != 0)) { func_80991C04(this); } else if (Rand_ZeroOne() > 0.5f) { @@ -1041,7 +1041,7 @@ void func_809926D0(EnWf* this) { this->unk_2A0 = 0; this->actor.speedXZ = 6.5f; this->actor.velocity.y = 15.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TEKU_JUMP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_80992784; } @@ -1055,7 +1055,7 @@ void func_80992784(EnWf* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; this->actor.speedXZ = 0.0f; this->actor.world.pos.y = this->actor.floorHeight; - if (!func_800BC5EC(globalCtx, &this->actor)) { + if (!Actor_OtherIsTargeted(globalCtx, &this->actor)) { func_80991C04(this); } else { func_80991200(this); @@ -1085,10 +1085,10 @@ void func_809928CC(EnWf* this, GlobalContext* globalCtx) { } else { func_8099223C(this); } - } else if (Actor_IsActorFacingLink(&this->actor, 0x4000) && (this->actor.xzDistToPlayer < 60.0f) && + } else if (Actor_IsFacingPlayer(&this->actor, 0x4000) && (this->actor.xzDistToPlayer < 60.0f) && (fabsf(this->actor.playerHeightRel) < 50.0f)) { sp2A = player->actor.shape.rot.y - this->actor.shape.rot.y; - if (!func_800BC5EC(globalCtx, &this->actor) && + if (!Actor_OtherIsTargeted(globalCtx, &this->actor) && (((globalCtx->gameplayFrames % 2) != 0) || (ABS_ALT(sp2A) < 0x38E0))) { func_80991C04(this); } else { @@ -1148,7 +1148,7 @@ void func_80992B8C(EnWf* this, GlobalContext* globalCtx) { this->unk_2A0 = (s32)Rand_ZeroFloat(3.0f) + 1; } else { this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->actor.xzDistToPlayer <= 80.0f) && !func_800BC5EC(globalCtx, &this->actor) && + if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(globalCtx, &this->actor) && (((globalCtx->gameplayFrames % 4) == 0) || (sp28 < 0x38E0))) { func_80991C04(this); } else { @@ -1160,7 +1160,7 @@ void func_80992B8C(EnWf* this, GlobalContext* globalCtx) { func_80990E4C(this, globalCtx); if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } } } @@ -1174,7 +1174,7 @@ void func_80992D6C(EnWf* this) { } this->actor.flags &= ~1; this->unk_2A0 = 25; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_DEAD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_DEAD); this->actionFunc = func_80992E0C; } @@ -1285,13 +1285,13 @@ void func_80993194(EnWf* this, GlobalContext* globalCtx) { } if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } } void func_80993350(EnWf* this) { Animation_MorphToLoop(&this->skelAnime, &D_06005700, -4.0f); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_APPEAR); this->actionFunc = func_809933A0; } @@ -1325,7 +1325,7 @@ void func_809933A0(EnWf* this, GlobalContext* globalCtx) { func_80990ED4(this); } if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } } @@ -1378,7 +1378,7 @@ void func_8099357C(EnWf* this, GlobalContext* globalCtx) { } if (this->unk_2A2 == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } } @@ -1407,15 +1407,15 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { if ((this->collider2.base.acFlags & AC_HIT) || (this->collider3.base.acFlags & AC_HIT)) { if ((!(this->collider2.base.acFlags & AC_HIT) && (this->collider3.base.acFlags & AC_HIT)) || - !Actor_IsActorFacingLink(&this->actor, 0x4A38)) { + !Actor_IsFacingPlayer(&this->actor, 0x4A38)) { this->actor.colChkInfo.damage *= 4; } if (this->collider2.base.acFlags & AC_HIT) { - func_800BE258(&this->actor, &this->collider2.info); + Actor_SetDropFlag(&this->actor, &this->collider2.info); collider = &this->collider2; } else { - func_800BE258(&this->actor, &this->collider3.info); + Actor_SetDropFlag(&this->actor, &this->collider3.info); collider = &this->collider3; } @@ -1435,16 +1435,16 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 1) { this->unk_2A0 = 40; - func_800BCB70(&this->actor, 0, 0x78, 0, 40); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_809923B0(this); } else if (this->actor.colChkInfo.damageEffect == 5) { this->unk_2A0 = 40; - func_800BCB70(&this->actor, 0, 0xFF, 0, 40); + Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); this->unk_296 = 30; this->unk_2B0 = 0.75f; this->unk_2AC = 2.0f; - Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_809923B0(this); } else if (this->actor.colChkInfo.damageEffect == 3) { func_809907D4(this); @@ -1467,7 +1467,7 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { CLEAR_TAG_LARGE_LIGHT_RAYS); } - func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); if (this->actor.colChkInfo.health == 0) { func_80992D6C(this); } else { @@ -1495,7 +1495,7 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 32.0f, 30.0f, 60.0f, 0x1D); func_80993738(this, globalCtx); @@ -1528,7 +1528,7 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { } } - Actor_SetHeight(&this->actor, 25.0f); + Actor_SetFocus(&this->actor, 25.0f); if (this->unk_2AC > 0.0f) { if (this->unk_296 != 10) { diff --git a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h index 5bbf270296..1388260cf4 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h @@ -11,9 +11,13 @@ typedef struct EnWiz { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x268]; /* 0x03AC */ EnWizActionFunc actionFunc; - /* 0x03B0 */ char unk_3B0[0x98]; + /* 0x03B0 */ char unk_3B0[0xA]; + /* 0x03BA */ s16 unk_3BA; + /* 0x03BC */ char unk_3BC[0x8C]; /* 0x0448 */ s32 unk_448; - /* 0x044C */ char unk_44C[0x934]; + /* 0x044C */ char unk_44C[0x2FE]; + /* 0x074A */ s16 unk_74A; + /* 0x074C */ char unk_74C[0x634]; } EnWiz; // size = 0xD80 extern const ActorInit En_Wiz_InitVars; 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 480bdaeaa4..4dd2db5a57 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 @@ -5,6 +5,8 @@ */ #include "z_en_wiz_fire.h" +#include "overlays/actors/ovl_En_Wiz/z_en_wiz.h" +#include "objects/object_wiz/object_wiz.h" #define FLAGS 0x08000015 @@ -21,8 +23,13 @@ void func_80A49F38(EnWizFire* this, GlobalContext* globalCtx); void func_80A49FD8(EnWizFire* this, GlobalContext* globalCtx); void func_80A4A11C(EnWizFire* this, GlobalContext* globalCtx); void func_80A4A608(EnWizFire* this, GlobalContext* globalCtx); +void func_80A4BAB4(Actor* thisx, GlobalContext* globalCtx); +void func_80A4BC74(EnWizFire* this, Vec3f* arg1, Vec3f* arg2); +void func_80A4BDDC(EnWizFire* this, GlobalContext* globalCtx); +void func_80A4BF78(EnWizFire* this, GlobalContext* globalCtx); + +static s32 D_80A4C1C0 = 0; -#if 0 const ActorInit En_Wiz_Fire_InitVars = { ACTOR_EN_WIZ_FIRE, ACTORCAT_ENEMY, @@ -35,51 +42,838 @@ const ActorInit En_Wiz_Fire_InitVars = { (ActorFunc)EnWizFire_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A4C1E4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x09, 0x10 }, { 0x01001202, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x09, 0x10 }, + { 0x01001202, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 0, 0, 0, { 0, 0, 0 } }, }; -#endif +void EnWizFire_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWizFire* this = THIS; -extern ColliderCylinderInit D_80A4C1E4; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->unk_162 = this->actor.params; + this->actor.targetMode = 3; + this->unk_172 = 10; + this->unk_1FC = 255.0f; + this->actor.flags &= ~1; -extern UNK_TYPE D_06000FD8; -extern UNK_TYPE D_06002630; -extern UNK_TYPE D_06002B40; -extern UNK_TYPE D_06003120; -extern UNK_TYPE D_06005190; + if (!func_8012405C(globalCtx)) { + this->collider.info.toucher.dmgFlags = 0x20000000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/EnWizFire_Init.s") + switch (this->unk_162) { + case 4: + this->unk_166 = 1; + this->collider.info.toucher.damage = 8; + this->collider.info.toucher.effect = 2; + this->collider.info.bumper.dmgFlags = (0x1000000 | 0x800 | 0x200 | 0x2); + this->unk_162 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/EnWizFire_Destroy.s") + case 0: + if (this->unk_162 == 4) { + this->unk_162 = 0; + this->collider.info.toucher.damage = 8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4984C.s") + case 1: + case 3: + this->actionFunc = func_80A4984C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A49A44.s") + case 2: + this->actor.draw = func_80A4BAB4; + this->unk_170 = Rand_S16Offset(0, 10000); + this->unk_160 = 1; + this->collider.info.toucher.damage = 2; + this->actionFunc = func_80A49F38; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A49F38.s") +void EnWizFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWizFire* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A49FD8.s") + if (this->unk_162 == 0) { + globalCtx->envCtx.unk_8C.fogColor[2] = 0; + globalCtx->envCtx.unk_8C.fogColor[1] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.fogColor[0] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.diffuseColor2[2] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.diffuseColor2[1] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.diffuseColor2[0] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.diffuseColor1[2] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.diffuseColor1[1] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.diffuseColor1[0] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.ambientColor[2] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.ambientColor[1] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.ambientColor[0] = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.unk_8C.fogNear = globalCtx->envCtx.unk_8C.fogColor[2]; + } + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4A11C.s") +void func_80A4984C(EnWizFire* this, GlobalContext* globalCtx) { + Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4A608.s") + for (i = 0; i < ARRAY_COUNT(this->unk_178); i++) { + this->unk_178[i] = this->actor.world.pos; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/EnWizFire_Update.s") + this->unk_16E = 0; + Matrix_StatePush(); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->actor.world.rot.x, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4B0C8.s") + if (this->unk_162 != 0) { + sp44.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; + } else { + sp44.z = 12.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4B33C.s") + Matrix_MultiplyVector3fByState(&sp44, &this->actor.velocity); + Matrix_StatePop(); + this->actor.world.rot.x = this->actor.world.rot.y = this->actor.world.rot.z = 0; + this->unk_168 = 50; + if (this->unk_162 != 0) { + this->actor.velocity.y = 10.0f; + this->actor.gravity = -1.0f; + this->unk_150 = 0.01f; + } else { + this->unk_150 = 0.02f; + this->unk_168 = 100; + } + this->unk_160 = 0; + this->actionFunc = func_80A49A44; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/EnWizFire_Draw.s") +void func_80A49A44(EnWizFire* this, GlobalContext* globalCtx) { + Vec3f sp54 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4BAB4.s") + this->actor.world.rot.z += 5000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4BC74.s") + if (this->unk_162 != 0) { + this->unk_150 = 0.01f; + } else { + this->unk_150 = 0.02f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4BDDC.s") + if ((this->unk_168 == 0) && (this->unk_14C < 0.001f)) { + Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); + this->unk_160 = 3; + this->unk_16A = 0; + this->actionFunc = func_80A4A608; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Fire/func_80A4BF78.s") + if (this->unk_168 == 0) { + this->unk_150 = 0.0f; + } + + Math_ApproachF(&this->unk_14C, this->unk_150, 0.2f, 0.01f); + + if (this->unk_172 == 0) { + if ((this->actor.bgCheckFlags & 8) && (this->unk_162 == 0) && (this->unk_168 != 0) && + (this->actor.bgCheckFlags & 8)) { + D_80A4C1C0 = 0; + this->unk_168 = 0; + this->unk_150 = 0.0f; + } + } + + if ((this->actor.bgCheckFlags & 1) && (this->unk_16A == 0)) { + s32 i; + s16 phi_s0; + s32 temp; + + if (this->unk_162 == 1) { + this->unk_16A = 10; + + Matrix_StatePush(); + Matrix_RotateY((s16)randPlusMinusPoint5Scaled(0x100) + this->actor.world.rot.y, MTXMODE_NEW); + sp54.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; + Matrix_MultiplyVector3fByState(&sp54, &this->actor.velocity); + Matrix_StatePop(); + + this->actor.velocity.y = 6.0f; + this->actor.gravity = -0.7f; + + if (this->unk_164 == 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WIZ_FIRE, this->actor.world.pos.x, + this->actor.world.pos.y - 10.0f, this->actor.world.pos.z, 0, 0, 0, 2); + this->unk_164 = 1; + } + + this->unk_168 = 0; + this->unk_14C = 0.0f; + Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); + this->unk_160 = 3; + this->unk_16A = 0; + this->actionFunc = func_80A4A608; + return; + } + + if ((this->unk_162 == 0) && (this->unk_168 != 0)) { + if (this->actor.floorBgId == BGCHECK_SCENE) { + this->unk_16A = 100; + if (this->unk_166 == 0) { + phi_s0 = 0; + + for (i = 0; i < 5; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WIZ_FIRE, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, phi_s0, 0, 1); + phi_s0 += BINANG_ADD((s32)randPlusMinusPoint5Scaled(0x1000), 0x3333); + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + this->unk_16A = Rand_S16Offset(70, 30); + if (this->unk_16A != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_EXP - SFX_FLAG); + } + } else if (this->unk_16A != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); + this->unk_168 = 0; + this->unk_160 = 2; + this->unk_14C = 0.0f; + this->actionFunc = func_80A4A11C; + } + return; + } + } + + if ((this->unk_162 != 3) && (this->unk_168 != 0)) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000) { + this->unk_168 = 0; + this->unk_148 = 1; + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); + } + } + + if (func_8012405C(globalCtx) && (this->collider.base.atFlags & AT_BOUNCED)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SHIELD_REFLECT_MG); + this->collider.base.atFlags &= ~(AT_TYPE_ENEMY | AT_BOUNCED | AT_HIT); + this->collider.base.atFlags |= AT_TYPE_PLAYER; + this->collider.info.toucher.dmgFlags = 0x20; + this->collider.info.toucher.damage = 2; + this->unk_168 = 100; + this->unk_162 = 3; + this->actor.velocity.x *= -1.0f; + this->actor.velocity.y *= -0.5f; + this->actor.velocity.z *= -1.0f; + + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && + (this->actor.parent->update != NULL)) { + ((EnWiz*)this->actor.parent)->unk_3BA = 0; + } + } + } +} + +void func_80A49F38(EnWizFire* this, GlobalContext* globalCtx) { + this->unk_150 = 0.02f; + this->unk_168 = Rand_S16Offset(50, 50); + this->unk_154 = randPlusMinusPoint5Scaled(1.0f) * 0.007f; + this->unk_158 = randPlusMinusPoint5Scaled(1.0f) * 0.005f; + this->unk_15C = randPlusMinusPoint5Scaled(1.0f) * 0.007f; + this->actionFunc = func_80A49FD8; +} + +void func_80A49FD8(EnWizFire* this, GlobalContext* globalCtx) { + if (this->unk_168 > 10) { + Math_ApproachF(&this->unk_14C, this->unk_150, 0.3f, 0.01f); + } else { + Math_ApproachF(&this->unk_14C, 2.0f * this->unk_150, 0.2f, 0.002f); + Math_ApproachZeroF(&this->unk_1FC, 1.0f, 35.0f); + if ((this->unk_168 == 0) && (this->unk_1FC < 2.0f)) { + Actor_MarkForDeath(&this->actor); + } + return; + } + + if (this->collider.base.acFlags & AC_HIT) { + if (this->unk_168 != 0) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->unk_168 > 10) { + this->unk_168 -= 10; + } + + if (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000) { + this->unk_168 = 0; + this->unk_148 = 1; + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); + } + } + } + + if (this->unk_168 != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); + } +} + +void func_80A4A11C(EnWizFire* this, GlobalContext* globalCtx) { + s32 pad; + + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && + (this->actor.parent->update != NULL) && (this->actor.parent->colChkInfo.health == 0)) { + this->unk_16A = 0; + this->unk_174 = 1; + } + + this->unk_16E++; + + if (this->unk_16E > 10) { + this->unk_16E = 10; + } + + if (this->unk_16A != 0) { + Math_ApproachF(&this->unk_200, 60.0f, 0.5f, 10.0f); + if (this->unk_166 == 1) { + Vec3f sp40 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp34; + + sp40.x = randPlusMinusPoint5Scaled(3.0f) / 10.0f; + sp40.y = 0.23f; + sp40.z = randPlusMinusPoint5Scaled(3.0f) / 10.0f; + + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp34.x += randPlusMinusPoint5Scaled(150.0f); + sp34.z += randPlusMinusPoint5Scaled(150.0f); + + Math_ApproachF(&this->unk_1F0, 0.022f, 0.3f, 0.01f); + this->collider.dim.radius = this->unk_1F0 * 4300.0f; + this->collider.dim.height = 30; + this->collider.dim.yShift = 15; + func_80A4BC74(this, &sp34, &sp40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + return; + } + + Math_ApproachF(&this->unk_1F0, 0.02f, 0.3f, 0.002f); + Math_ApproachF(&this->unk_1F8, 0.02f, 0.3f, 0.002f); + Math_ApproachF(&this->unk_1F4, 0.02f, 0.3f, 0.2f); + this->collider.dim.radius = this->unk_1F0 * 4000.0f; + this->collider.dim.height = this->unk_1F4 * 1850.0f; + this->collider.dim.yShift = -15; + + if (this->collider.dim.height < 2) { + this->collider.dim.height = 2; + } + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + if ((D_80A4C1C0 == 0) && (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000)) { + D_80A4C1C0 = 1; + this->unk_148 = 1; + this->unk_16A = 0; + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); + } + } + this->actor.world.pos.y = this->actor.floorHeight + 10.0f; + Actor_SetFocus(&this->actor, 0.0f); + return; + } + + Math_ApproachZeroF(&this->unk_200, 0.2f, 3.0f); + + if (this->unk_166 == 1) { + Math_ApproachZeroF(&this->unk_1F0, 0.046f, 0.001f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + + if (this->unk_164 == 0) { + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->unk_1F0 < 0.05f)) { + EnWiz* wiz = (EnWiz*)this->actor.parent; + + this->collider.dim.yShift = -15; + this->unk_164 = 1; + wiz->unk_3BA = 0; + } + } + + if ((this->unk_164 != 0) && (this->unk_1F0 < 0.05f)) { + Math_ApproachZeroF(&this->unk_1FC, 1.0f, 5.0f); + } + + if ((this->unk_1F0 < 0.001f) && (this->unk_204 < 0.001f)) { + D_80A4C1C0 = 0; + Actor_MarkForDeath(&this->actor); + } + return; + } + + Math_ApproachZeroF(&this->unk_1F4, 0.1f, 0.01f); + + if (this->unk_1F4 < 0.01f) { + Math_ApproachZeroF(&this->unk_1FC, 1.0f, 10.0f); + if ((this->unk_1FC < 10.0f) && (this->unk_204 < 0.001f)) { + D_80A4C1C0 = 0; + if ((this->actor.parent != NULL) && (this->unk_162 == 0) && (this->actor.parent->id == ACTOR_EN_WIZ) && + (this->actor.parent->update != NULL)) { + EnWiz* wiz = (EnWiz*)this->actor.parent; + + wiz->unk_3BA = 0; + } + Actor_MarkForDeath(&this->actor); + } + } +} + +void func_80A4A608(EnWizFire* this, GlobalContext* globalCtx) { + if (this->unk_16A == 0) { + this->unk_16A = 2; + this->unk_16E++; + if (this->unk_16E >= 6) { + if ((this->actor.parent != NULL) && (this->unk_162 == 0) && (this->actor.parent->id == ACTOR_EN_WIZ)) { + EnWiz* wiz = (EnWiz*)this->actor.parent; + + D_80A4C1C0 = 0; + if (wiz->actor.update != NULL) { + wiz->unk_3BA = 0; + } + } + Actor_MarkForDeath(&this->actor); + } + } +} + +void EnWizFire_Update(Actor* thisx, GlobalContext* globalCtx2) { + static Color_RGB8 D_80A4C234[] = { + { 100, 40, 40 }, { 180, 0x78, 80 }, { 155, 80, 80 }, { 125, 20, 0 }, + { 0, 0, 0 }, { 200, 250, 250 }, { 100, 250, 250 }, { 225, 255, 235 }, + }; + static Color_RGBA8 D_80A4C24C = { 250, 250, 250, 255 }; + static Color_RGBA8 D_80A4C250 = { 180, 180, 180, 255 }; + GlobalContext* globalCtx = globalCtx2; + EnWizFire* this = THIS; + Player* player = GET_PLAYER(globalCtx); + s32 j; + s16 temp_s0; + s16 idx; + + Actor_SetScale(&this->actor, this->unk_14C); + func_80A4BDDC(this, globalCtx); + this->unk_204 = this->unk_200 / 60.0f; + + if (this->unk_162 == 0) { + Actor* wiz = this->actor.parent; + + if ((wiz != NULL) && (wiz->id == ACTOR_EN_WIZ) && (wiz->update != NULL) && (((EnWiz*)wiz)->unk_74A != 2)) { + f32 phi_f0; + + idx = this->unk_166 * 4; + + phi_f0 = 970.0f; + if (this->unk_166 == 0) { + phi_f0 = 968.0f; + } + + globalCtx->envCtx.unk_8C.fogNear = (phi_f0 - (s16)globalCtx->envCtx.unk_C4.fogNear) * this->unk_204; + + globalCtx->envCtx.unk_8C.ambientColor[0] = + ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.ambientColor[0]) * this->unk_204; + globalCtx->envCtx.unk_8C.ambientColor[1] = + ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.ambientColor[1]) * this->unk_204; + globalCtx->envCtx.unk_8C.ambientColor[2] = + ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.ambientColor[2]) * this->unk_204; + + idx++; + globalCtx->envCtx.unk_8C.diffuseColor1[0] = + ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.diffuseColor1[0]) * this->unk_204; + globalCtx->envCtx.unk_8C.diffuseColor1[1] = + ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.diffuseColor1[1]) * this->unk_204; + globalCtx->envCtx.unk_8C.diffuseColor1[2] = + ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.diffuseColor1[2]) * this->unk_204; + + idx++; + globalCtx->envCtx.unk_8C.diffuseColor2[0] = + ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.diffuseColor[0]) * this->unk_204; + globalCtx->envCtx.unk_8C.diffuseColor2[1] = + ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.diffuseColor[1]) * this->unk_204; + globalCtx->envCtx.unk_8C.diffuseColor2[2] = + ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.diffuseColor[2]) * this->unk_204; + + idx++; + globalCtx->envCtx.unk_8C.fogColor[0] = + ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.fogColor[0]) * this->unk_204; + globalCtx->envCtx.unk_8C.fogColor[1] = + ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.fogColor[1]) * this->unk_204; + globalCtx->envCtx.unk_8C.fogColor[2] = + ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.fogColor[2]) * this->unk_204; + } + } + + this->unk_170++; + + this->actionFunc(this, globalCtx); + + this->actor.shape.yOffset = 10.0f; + Actor_UpdatePos(&this->actor); + + this->unk_178[0] = this->actor.world.pos; + + for (j = 8; j >= 0; j--) { + this->unk_178[j + 1] = this->unk_178[j]; + } + + this->actor.velocity.y += this->actor.gravity; + + if (this->unk_172 != 0) { + this->unk_172--; + } + + if (this->unk_168 != 0) { + this->unk_168--; + } + + if (this->unk_16C != 0) { + this->unk_16C--; + } + + if (this->unk_16A != 0) { + this->unk_16A--; + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 5.0f, 10, 0x1D); + + if (((this->unk_148 != 0) || (D_80A4C1C0 != 0)) && (this->unk_16C == 0)) { + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + f32 sp54; + s32 i; + + sp70.x = 0.0f; + sp70.y = 1.0f; + sp70.z = 0.0f; + sp64.x = 0.0f; + sp64.y = 1.0f; + sp64.z = 0.0f; + + sp54 = Rand_S16Offset(20, 10); + if (this->unk_162 == 0) { + sp54 = Rand_S16Offset(40, 20); + } + + this->unk_16C = Rand_S16Offset(2, 2); + + for (i = 0; i < 2; i++) { + temp_s0 = Rand_S16Offset(20, 20); + sp58.x = ((f32)((Rand_ZeroOne() < 0.5f) ? -1 : 1) * temp_s0) + this->actor.world.pos.x; + sp58.y = (Rand_ZeroOne() * 20.0f) + this->actor.floorHeight; + temp_s0 = Rand_S16Offset(20, 20); + sp58.z = ((f32)((Rand_ZeroOne() < .5f) ? -1 : 1) * temp_s0) + this->actor.world.pos.z; + func_800B0DE0(globalCtx, &sp58, &sp64, &sp70, &D_80A4C24C, &D_80A4C250, Rand_S16Offset(350, 100), sp54); + } + } + + if (this->unk_160 < 2) { + this->collider.dim.radius = (this->unk_14C * 15.0f) + 25.0f; + this->collider.dim.height = (this->unk_14C * 15.0f) + 25.0f; + this->collider.dim.yShift = (this->unk_14C * -0.75f) - 5.0f; + } + + if (this->unk_162 == 2) { + this->collider.dim.radius = 10; + this->collider.dim.height = this->unk_14C * 5000.0f; + this->collider.dim.yShift = 0; + } + + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + if (this->unk_162 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_LAUGH2); + if (player->invincibilityTimer > 0) { + player->invincibilityTimer += 40; + if (this->unk_166 != 0) { + player->invincibilityTimer += 50; + this->unk_174 = 1; + } + } + } + } + + if ((player->stateFlags2 & 0x4000) && (player->unk_AE8 < 90)) { + player->unk_AE8 = 90; + } + + if ((this->unk_148 == 0) && (D_80A4C1C0 == 0) && ((this->unk_162 != 0) || (this->unk_1FC > 200.0f))) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (player->invincibilityTimer == 0) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void func_80A4B0C8(EnWizFire* this, GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((this->unk_162 == 0) && (this->unk_160 == 2)) { + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_Scale(this->unk_1F0, this->unk_1F0, this->unk_1F0, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)this->unk_1FC); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 40, 30, 80); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_005190); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 215, 215, 215, (s8)this->unk_1FC); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 128); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, -globalCtx->state.frames & 0x7F, + -globalCtx->state.frames & 0x7F, 0x20, 0x40, 1, globalCtx->state.frames & 0xFF, + globalCtx->state.frames & 0xFF, 0x10, 0x10)); + + Matrix_RotateY(0, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_005750); + } + + func_80A4BF78(this, globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A4B33C(EnWizFire* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((this->unk_162 == 0) && (this->unk_160 == 2)) { + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_StatePush(); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_Scale(this->unk_1F0, this->unk_1F0, this->unk_1F0, MTXMODE_APPLY); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, -globalCtx->state.frames % 128, 0, 0x20, 0x20, 1, + (globalCtx->state.frames * 2) % 128, 0, 0x20, 0x20)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 40, 0, (s8)this->unk_1FC); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 245, 255, 128); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003120); + + Matrix_StatePop(); + Matrix_StatePush(); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->state.frames % 128, + (-globalCtx->state.frames * 6) % 256, 0x20, 0x40, 1, + (globalCtx->state.frames * 2) % 128, (-globalCtx->state.frames * 6) % 256, 0x20, + 0x40)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 80, 0, 0, (s8)this->unk_1FC); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 100); + + Matrix_Scale(this->unk_1F8, this->unk_1F8, this->unk_1F8, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003640); + + Matrix_StatePop(); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, 0); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (-globalCtx->state.frames * 3) % 128, 0, 0x20, 0x20, 1, + 0, (-globalCtx->state.frames * 10) % 256, 0x20, 0x40)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 50, 0, 255); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 235, 240, 128); + + Matrix_Scale(this->unk_1F4, this->unk_1F4, this->unk_1F4, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003FC0); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnWizFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnWizFire* this = THIS; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_StatePush(); + + for (i = 9; i >= this->unk_16E; i--) { + f32 temp_f20 = this->actor.scale.x - (i * -0.0019f); + + if (temp_f20 > 0.0f) { + if (this->unk_166 == 0) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255 - (i * 25), 0, 255 - (i * 25)); + gDPSetEnvColor(POLY_XLU_DISP++, 255 - (i * 25), 0, 0, 0); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255 - (i * 7), 255 - (i * 3), 255 - (i * 3), 255 - (i * 25)); + gDPSetEnvColor(POLY_XLU_DISP++, 220, 255, 235, 0); + } + + Matrix_InsertTranslation(this->unk_178[i].x, this->unk_178[i].y + this->actor.shape.yOffset, + this->unk_178[i].z, MTXMODE_NEW); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_InsertZRotation_s(this->actor.world.rot.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_002B40); + } + } + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_166 == 0) { + func_80A4B33C(this, globalCtx); + } else { + func_80A4B0C8(this, globalCtx); + } +} + +void func_80A4BAB4(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWizFire* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight + 20.0f, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_Scale(this->unk_14C + this->unk_154, this->unk_14C + this->unk_158, this->unk_14C + this->unk_15C, + MTXMODE_APPLY); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, this->unk_170 & 0x7F, + (-this->unk_170 * 10) & 0x7F, 0x20, 0x20)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 100, 50, 0, (s8)this->unk_1FC); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 235, 245, 255); + + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_002630); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A4BC74(EnWizFire* this, Vec3f* arg1, Vec3f* arg2) { + s16 i; + EnWizFireStruct* ptr = this->unk_254; + + for (i = 0; i < ARRAY_COUNT(this->unk_254); i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = 1; + Math_Vec3f_Copy(&ptr->unk_1C, &gZeroVec3f); + ptr->unk_01 = Rand_ZeroFloat(100.0f); + ptr->unk_10 = *arg1; + ptr->unk_28 = *arg2; + ptr->unk_0C = (Rand_ZeroFloat(5.0f) + 20.0f) * 0.001f; + ptr->unk_08 = 0; + ptr->unk_06 = 0; + break; + } + } +} + +void func_80A4BDDC(EnWizFire* this, GlobalContext* globalCtx) { + s32 i; + EnWizFireStruct* ptr = &this->unk_254[0]; + + for (i = 0; i < ARRAY_COUNT(this->unk_254); i++, ptr++) { + if (ptr->unk_00 != 0) { + ptr->unk_01++; + + ptr->unk_10.x += ptr->unk_1C.x; + ptr->unk_10.y += ptr->unk_1C.y; + ptr->unk_10.z += ptr->unk_1C.z; + + ptr->unk_1C.x += ptr->unk_28.x; + ptr->unk_1C.y += ptr->unk_28.y; + ptr->unk_1C.z += ptr->unk_28.z; + + if (ptr->unk_08 == 0) { + ptr->unk_06 += 10; + if (ptr->unk_06 >= 100) { + ptr->unk_08 = 1; + } + } else { + ptr->unk_06 -= 8; + if (ptr->unk_06 <= 0) { + ptr->unk_06 = 0; + ptr->unk_00 = 0; + } + } + } + } +} + +void func_80A4BF78(EnWizFire* this, GlobalContext* globalCtx) { + s16 i; + u8 flag; + EnWizFireStruct* ptr = &this->unk_254[0]; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + flag = false; + for (i = 0; i < ARRAY_COUNT(this->unk_254); i++, ptr++) { + if (ptr->unk_00 != 0) { + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_000E70); + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, ptr->unk_06); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_01 * 3) & 0x7F, + (ptr->unk_01 * 0xF) & 0xFF, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + + Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(ptr->unk_0C, ptr->unk_0C, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); + gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BACK | G_FOG); + gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_000FD8); + } + } + + CLOSE_DISPS(gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h index 0f5b705f5c..df396da97b 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.h @@ -7,10 +7,48 @@ struct EnWizFire; typedef void (*EnWizFireActionFunc)(struct EnWizFire*, GlobalContext*); +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; + /* 0x02 */ UNK_TYPE1 unk02[0x4]; + /* 0x06 */ s16 unk_06; + /* 0x08 */ s16 unk_08; + /* 0x0A */ UNK_TYPE1 unk0A[0x2]; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ Vec3f unk_10; + /* 0x1C */ Vec3f unk_1C; + /* 0x28 */ Vec3f unk_28; +} EnWizFireStruct; // size = 0x34 + typedef struct EnWizFire { /* 0x0000 */ Actor actor; /* 0x0144 */ EnWizFireActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x29AC]; + /* 0x0148 */ u8 unk_148; + /* 0x014C */ f32 unk_14C; + /* 0x0150 */ f32 unk_150; + /* 0x0154 */ f32 unk_154; + /* 0x0158 */ f32 unk_158; + /* 0x015C */ f32 unk_15C; + /* 0x0160 */ s16 unk_160; + /* 0x0162 */ s16 unk_162; + /* 0x0164 */ u8 unk_164; + /* 0x0166 */ s16 unk_166; + /* 0x0168 */ s16 unk_168; + /* 0x016A */ s16 unk_16A; + /* 0x016C */ s16 unk_16C; + /* 0x016E */ s16 unk_16E; + /* 0x0170 */ s16 unk_170; + /* 0x0172 */ s16 unk_172; + /* 0x0174 */ s8 unk_174; + /* 0x0178 */ Vec3f unk_178[10]; + /* 0x01F0 */ f32 unk_1F0; + /* 0x01F4 */ f32 unk_1F4; + /* 0x01F8 */ f32 unk_1F8; + /* 0x01FC */ f32 unk_1FC; + /* 0x0200 */ f32 unk_200; + /* 0x0204 */ f32 unk_204; + /* 0x0208 */ ColliderCylinder collider; + /* 0x0254 */ EnWizFireStruct unk_254[200]; } EnWizFire; // size = 0x2AF4 extern const ActorInit En_Wiz_Fire_InitVars; diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index a8a10008be..3306fc7866 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -156,7 +156,7 @@ void func_80B93310(Actor* thisx, Lights* mapper, GlobalContext* globalCtx) { this->actor.world.pos.y = sp34.y; } this->actor.scale.z *= sp2C * (1 / 12.0f); - func_800B3FC0(&this->actor, mapper, globalCtx); + ActorShadow_DrawCircle(&this->actor, mapper, globalCtx); this->actor.scale.z = this->actor.scale.x; Math_Vec3f_Copy(&this->actor.world.pos, &sp34); } @@ -212,7 +212,7 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - this->actor.minVelocityY = -4.0f; + this->actor.terminalVelocity = -4.0f; this->actor.gravity = -1.0f; this->actor.uncullZoneScale = 3000.0f; this->actor.shape.yOffset = 1000.0f; @@ -466,7 +466,7 @@ s32 func_80B93EA0(EnZog* this, GlobalContext* globalCtx) { switch (this->unk_306) { case 2: if (globalCtx->csCtx.frames == 60) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_JUMP_SAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_JUMP_SAND); } break; @@ -607,12 +607,12 @@ void func_80B943EC(EnZog* this, GlobalContext* globalCtx) { } } else if ((player->stateFlags2 & 0x8000000) && (this->actor.xzDistToPlayer < 120.0f)) { this->unk_30A |= 0x10; - Audio_PlayActorSound2(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); } } void func_80B94470(EnZog* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 5) { + if (Message_GetState(&globalCtx->msgCtx) == 5) { if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x103C)) { func_801477B4(globalCtx); this->actionFunc = func_80B9451C; @@ -625,7 +625,7 @@ void func_80B94470(EnZog* this, GlobalContext* globalCtx) { } void func_80B9451C(EnZog* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_300 = 2; this->actionFunc = func_80B94470; } else if ((globalCtx->msgCtx.unk1202A == 3) && (this->actor.xzDistToPlayer < 120.0f)) { @@ -662,7 +662,7 @@ void func_80B946B4(EnZog* this, GlobalContext* globalCtx) { } void func_80B946FC(EnZog* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 4: if (func_80147624(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { @@ -713,7 +713,7 @@ void func_80B946FC(EnZog* this, GlobalContext* globalCtx) { } void func_80B948A8(EnZog* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_300 = 2; this->actionFunc = func_80B946FC; } else if ((globalCtx->msgCtx.unk1202A == 3) && (this->actor.xzDistToPlayer < 120.0f)) { @@ -780,15 +780,15 @@ void func_80B94A00(EnZog* this, GlobalContext* globalCtx) { if ((this->unk_304 == 4) && (Animation_OnFrame(&this->skelAnime, 136.0f) || Animation_OnFrame(&this->skelAnime, 155.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_WATER0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_WATER0); } if ((this->unk_304 == 5) && (Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 37.0f))) { if (this->actor.depthInWater > 0.0f) { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_WATER0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_WATER0); } else { - Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_SAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_SAND); } } } @@ -800,7 +800,7 @@ void func_80B94C5C(EnZog* this, GlobalContext* globalCtx) { this->actor.shape.yOffset -= 20.0f; } this->actor.velocity.y = -1.0f; - this->actor.minVelocityY = -1.0f; + this->actor.terminalVelocity = -1.0f; } if ((this->unk_2FC == 1) && (this->unk_302 == 0)) { @@ -827,7 +827,7 @@ void func_80B94D0C(EnZog* this, GlobalContext* globalCtx) { this->unk_31E = 0; } - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { this->unk_320 = 5; switch (globalCtx->msgCtx.unk11F04) { case 0x1004: @@ -875,21 +875,21 @@ void func_80B94E34(EnZog* this, GlobalContext* globalCtx) { if ((player->actor.speedXZ > 3.0f) && (this->unk_324 == 0)) { this->unk_324 = 25; - func_800B8E58(&player->actor, player->ageProperties->unk_92 + 0x6818); + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_PUSH); } } this->actor.speedXZ *= 0.3f; } if (ABS_ALT(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0x5000) { - func_800B8A1C(&this->actor, globalCtx, 0, 60.0f, 40.0f); + Actor_PickUp(&this->actor, globalCtx, 0, 60.0f, 40.0f); } if (this->unk_324 > 0) { this->unk_324--; } - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B94D0C; this->actor.speedXZ = 0.0f; this->unk_300 = 2; @@ -899,7 +899,7 @@ void func_80B94E34(EnZog* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; this->unk_2FE = 1; this->actor.velocity.y = 0.0f; - this->actor.minVelocityY = 0.0f; + this->actor.terminalVelocity = 0.0f; this->actor.gravity = 0.0f; this->unk_31C = 1; this->unk_31E = 0; @@ -918,7 +918,7 @@ void func_80B95128(EnZog* this, GlobalContext* globalCtx) { func_80B93D2C(this, globalCtx); func_80B93BE0(this, globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B94D0C; this->unk_300 = 2; this->actor.speedXZ = 0.0f; @@ -954,7 +954,7 @@ void EnZog_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnZog* this = THIS; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 5); if (func_800EE29C(globalCtx, 0x1D7) && (ENZOG_GET_F(&this->actor) != ENZOG_F_2)) { this->actionFunc = func_80B9461C; @@ -965,7 +965,7 @@ void EnZog_Update(Actor* thisx, GlobalContext* globalCtx) { if (((this->unk_304 == 6) && Animation_OnFrame(&this->skelAnime, 43.0f)) || ((this->unk_304 == 17) && Animation_OnFrame(&this->skelAnime, 14.0f))) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_LAND_SAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_LAND_SAND); } if (this->unk_30A & 1) { diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index fe2b2cbefd..c179517cde 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -97,7 +97,7 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; s32 i; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 20.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80B97100; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600D208, &D_06004248, this->jointTable, this->morphTable, 20); @@ -110,7 +110,7 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.world.rot.z = this->actor.shape.rot.z = 0; this->actor.targetMode = 6; - this->actor.minVelocityY = -4.0f; + this->actor.terminalVelocity = -4.0f; this->actor.gravity = -4.0f; switch (ENZOT_GET_1F(thisx)) { @@ -288,7 +288,7 @@ void func_80B96D4C(EnZot* this) { } s32 func_80B96DF0(EnZot* this, GlobalContext* globalCtx) { - if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsActorFacingLink(&this->actor, 0x3000) && + if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x3000) && (this->actor.xzDistToPlayer < 100.0f)) { return true; } @@ -391,7 +391,7 @@ void func_80B97110(EnZot* this, GlobalContext* globalCtx) { } void func_80B97194(EnZot* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { switch (globalCtx->msgCtx.unk11F04) { case 0x125C: case 0x125F: @@ -410,11 +410,11 @@ void func_80B97194(EnZot* this, GlobalContext* globalCtx) { } void func_80B97240(EnZot* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B97194; func_80B97110(this, globalCtx); - } else if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && - Actor_IsActorFacingLink(&this->actor, 0x3000)) { + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x3000)) { func_800B8614(&this->actor, globalCtx, 120.0f); } } @@ -460,7 +460,7 @@ void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { func_80B96D4C(this); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { switch (globalCtx->msgCtx.unk11F04) { case 0x126E: case 0x1270: @@ -525,10 +525,10 @@ void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { void func_80B975F8(EnZot* this, GlobalContext* globalCtx) { func_80B96D4C(this); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B973BC; } else { - func_800B8500(&this->actor, globalCtx, 10000.0f, 1000.0f, 0); + func_800B8500(&this->actor, globalCtx, 10000.0f, 1000.0f, EXCH_ITEM_NONE); } } @@ -537,7 +537,7 @@ void func_80B9765C(EnZot* this, GlobalContext* globalCtx) { do { } while (0); } func_80B96D4C(this); - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { u16 temp = globalCtx->msgCtx.unk11F04; u32 temp2; @@ -558,7 +558,7 @@ void func_80B97708(EnZot* this, GlobalContext* globalCtx) { func_80B96D4C(this); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B9765C; func_80B972E8(this, globalCtx); return; @@ -670,7 +670,7 @@ void func_80B979DC(EnZot* this, GlobalContext* globalCtx) { } void func_80B97A44(EnZot* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { switch (globalCtx->msgCtx.unk11F04) { case 0x1279: case 0x127C: @@ -708,7 +708,7 @@ void func_80B97A44(EnZot* this, GlobalContext* globalCtx) { void func_80B97B5C(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B97A44; func_80B9787C(this, globalCtx); } else if (func_80B96DF0(this, globalCtx)) { @@ -730,17 +730,17 @@ void func_80B97BF8(EnZot* this, GlobalContext* globalCtx) { void func_80B97C40(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); this->actionFunc = func_80B97CC8; } } void func_80B97CC8(EnZot* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B97C40; func_801518B0(globalCtx, 0x128B, &this->actor); - } else if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + } else if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { func_800B8614(&this->actor, globalCtx, 120.0f); } } @@ -755,7 +755,7 @@ void func_80B97D6C(EnZot* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_ZORA_WALK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_WALK); } } @@ -779,7 +779,7 @@ void func_80B97E4C(EnZot* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { switch (globalCtx->msgCtx.unk11F04) { case 0x128C: this->unk_2F2 &= ~4; @@ -812,7 +812,7 @@ void func_80B97E4C(EnZot* this, GlobalContext* globalCtx) { void func_80B97FD0(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B97E4C; func_80B97BF8(this, globalCtx); } else if (gSaveContext.weekEventReg[38] & 8) { @@ -821,7 +821,7 @@ void func_80B97FD0(EnZot* this, GlobalContext* globalCtx) { this->actionFunc = func_80B97E0C; func_80B96BEC(this, 6, 2); } - } else if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + } else if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { func_800B8614(&this->actor, globalCtx, 120.0f); } } @@ -916,7 +916,7 @@ void func_80B98348(EnZot* this, GlobalContext* globalCtx) { if (ENZOT_GET_1F(&this->actor) == 7) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - } else if (Actor_IsActorFacingLink(&this->actor, 0x3000)) { + } else if (Actor_IsFacingPlayer(&this->actor, 0x3000)) { this->unk_2F2 &= ~8; } else { this->unk_2F2 |= 8; @@ -935,7 +935,7 @@ void func_80B98348(EnZot* this, GlobalContext* globalCtx) { void func_80B9849C(EnZot* this, GlobalContext* globalCtx) { func_80B98348(this, globalCtx); - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->unk_2D4 == 2) { func_801518B0(globalCtx, 0x12AD, &this->actor); } else { @@ -943,7 +943,7 @@ void func_80B9849C(EnZot* this, GlobalContext* globalCtx) { } this->actionFunc = func_80B98728; } else { - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } } @@ -953,9 +953,9 @@ void func_80B9854C(EnZot* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = func_80B9849C; this->actor.flags |= 0x10000; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } else { - func_800B8A1C(&this->actor, globalCtx, this->unk_2D4, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, globalCtx, this->unk_2D4, 10000.0f, 50.0f); } } @@ -964,7 +964,7 @@ void func_80B985EC(EnZot* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); func_80B98348(this, globalCtx); - if (func_80152498(&globalCtx->msgCtx) == 0x10) { + if (Message_GetState(&globalCtx->msgCtx) == 0x10) { itemActionParam = func_80123810(globalCtx); if (itemActionParam > PLAYER_AP_NONE) { func_801477B4(globalCtx); @@ -989,7 +989,7 @@ void func_80B985EC(EnZot* this, GlobalContext* globalCtx) { void func_80B98728(EnZot* this, GlobalContext* globalCtx) { func_80B98348(this, globalCtx); - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 4: if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1293)) { switch (globalCtx->msgCtx.choiceIndex) { @@ -1074,11 +1074,11 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { void func_80B98998(EnZot* this, GlobalContext* globalCtx) { this->unk_2F2 &= ~8; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B98728; func_80B98178(this, globalCtx); - } else if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && - Actor_IsActorFacingLink(&this->actor, 0x7000)) { + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x7000)) { func_800B8614(&this->actor, globalCtx, 120.0f); } } @@ -1103,7 +1103,7 @@ void func_80B98A4C(EnZot* this, GlobalContext* globalCtx) { } void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { switch (globalCtx->msgCtx.unk11F04) { case 0x12B1: case 0x12B4: @@ -1135,7 +1135,7 @@ void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { } void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~0x10000; if (gSaveContext.weekEventReg[41] & 0x20) { func_801518B0(globalCtx, 0x12B7, &this->actor); @@ -1150,17 +1150,17 @@ void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { } void func_80B98CA8(EnZot* this, GlobalContext* globalCtx) { - if (func_800B8718(&this->actor, globalCtx)) { + if (func_800B8718(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.unk1202A = 4; func_8019B544(0xFFFF); this->actionFunc = func_80B98BF4; this->actor.flags |= 0x10000; func_800B8614(&this->actor, globalCtx, 120.0f); - } else if (func_800B84D0(&this->actor, globalCtx)) { + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B98AD0; func_80B98A4C(this, globalCtx); } else { - if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx)) { + if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { func_800B8614(&this->actor, globalCtx, 120.0f); } @@ -1215,7 +1215,7 @@ void func_80B98F30(EnZot* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = func_80B990A4; } else { - func_800B8A1C(&this->actor, globalCtx, GI_RUPEE_BLUE, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 10000.0f, 50.0f); } } @@ -1225,7 +1225,7 @@ void func_80B98F94(EnZot* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { switch (globalCtx->msgCtx.unk11F04) { case 0x12BB: this->unk_2F2 &= ~4; @@ -1253,10 +1253,10 @@ void func_80B98F94(EnZot* this, GlobalContext* globalCtx) { void func_80B990A4(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B98F94; func_80B98E10(this, globalCtx); - } else if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + } else if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { func_800B8614(&this->actor, globalCtx, 120.0f); } } @@ -1286,7 +1286,7 @@ void func_80B991E4(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { u16 temp = globalCtx->msgCtx.unk11F04; u32 temp2; @@ -1302,13 +1302,13 @@ void func_80B991E4(EnZot* this, GlobalContext* globalCtx) { } void func_80B992C0(EnZot* this, GlobalContext* globalCtx) { - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B991E4; func_80B99160(this, globalCtx); this->actor.speedXZ = 0.0f; func_80B96BEC(this, 0, 0); } else { - if (Actor_IsLinkFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { + if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { func_800B8614(&this->actor, globalCtx, 120.0f); } this->actor.speedXZ = 1.5f; @@ -1323,7 +1323,7 @@ void EnZot_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnZot* this = THIS; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 15.0f, 30.0f, 5); diff --git a/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c b/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c index 2bac5660d3..519d87e7fb 100644 --- a/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c +++ b/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c @@ -42,7 +42,7 @@ extern Gfx D_06001470[]; void ItemBHeart_Init(Actor* thisx, GlobalContext* globalCtx) { ItemBHeart* this = THIS; - if (Actor_GetCollectibleFlag(globalCtx, 0x1F)) { + if (Flags_GetCollectible(globalCtx, 0x1F)) { Actor_MarkForDeath(&this->actor); return; } @@ -69,10 +69,10 @@ void ItemBHeart_Update(Actor* thisx, GlobalContext* globalCtx) { if (!(this->unk_168 < 0.5f)) { if (Actor_HasParent(&this->actor, globalCtx)) { - Actor_SetCollectibleFlag(globalCtx, 0x1F); + Flags_SetCollectible(globalCtx, 0x1F); Actor_MarkForDeath(&this->actor); } else { - func_800B8A1C(&this->actor, globalCtx, GI_HEART_CONTAINER, 30.0f, 80.0f); + Actor_PickUp(&this->actor, globalCtx, GI_HEART_CONTAINER, 30.0f, 80.0f); } } } @@ -90,7 +90,7 @@ void ItemBHeart_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - blueWarpActor = globalCtx->actorCtx.actorList[ACTORCAT_ITEMACTION].first; + blueWarpActor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (blueWarpActor != NULL) { if ((blueWarpActor->id == ACTOR_DOOR_WARP1) && (blueWarpActor->projectedPos.z > this->actor.projectedPos.z)) { diff --git a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c index d30a74878d..a006270f35 100644 --- a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c +++ b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c @@ -40,7 +40,7 @@ void ItemInbox_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void ItemInbox_Idle(ItemInbox* this, GlobalContext* globalCtx) { - if (Actor_GetChestFlag(globalCtx, (this->actor.params >> 8) & 0x1F)) { + if (Flags_GetTreasure(globalCtx, (this->actor.params >> 8) & 0x1F)) { Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c index acef9d1ab6..385ca2cc2a 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -58,7 +58,7 @@ static ColliderCylinderInit sCylinderInit = { static InitChainEntry sInitChain[] = { ICHAIN_VEC3S(shape.rot, 0, ICHAIN_CONTINUE), ICHAIN_VEC3S(world.rot, 0, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -900, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(minVelocityY, -4000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -900, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 300, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), }; @@ -150,7 +150,7 @@ void ObjAqua_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.scale.z = 0.0009f; Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 60.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 60.0f); if (1) {}; this->actor.shape.shadowAlpha = 140; this->alpha = 255; @@ -180,7 +180,7 @@ void func_80ACBC8C(ObjAqua* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { func_80ACB7F4(this, globalCtx); func_80ACBA10(this); - Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOTTLE_WATERING); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOTTLE_WATERING); func_80ACBD34(this); } else { func_80ACB6A0(this, globalCtx); @@ -254,7 +254,7 @@ void ObjAqua_Update(Actor* thisx, GlobalContext* globalCtx) { Math_Vec3f_StepTo(&this->actor.scale, &D_80ACC320, 0.0004f); } this->actor.velocity.y *= 0.9f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f, 4.0f, 0.0f, 5); if (this->actionFunc != func_80ACBDFC) { Collider_UpdateCylinder(&this->actor, &this->collider); diff --git a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c index 55b8f301f5..651adf6d22 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c @@ -198,11 +198,11 @@ s32 func_80A357A8(ObjBell* this, GlobalContext* globalCtx) { this->unk_20E = 10; switch (this->dyna.actor.colChkInfo.damageEffect) { case 15: - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BIGBELL); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGBELL); func_80A35510(this, 1); break; case 14: - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BIGBELL); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGBELL); func_80A35510(this, 2); break; default: diff --git a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c index 0d5a2c1b94..a0d6301f33 100644 --- a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c +++ b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c @@ -182,5 +182,5 @@ void ObjBoyo_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjBoyo* this = THIS; AnimatedMat_Draw(globalCtx, this->unk_190); - func_800BDFC0(globalCtx, D_06000300); + Gfx_DrawDListOpa(globalCtx, D_06000300); } diff --git a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c index 98f66c014d..a75bc0a3b6 100644 --- a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c +++ b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c @@ -14,7 +14,9 @@ void ObjDowsing_Init(Actor* thisx, GlobalContext* globalCtx); void ObjDowsing_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjDowsing_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 ObjDowsing_GetFlag(ObjDowsing* this, GlobalContext* globalCtx); +s32 ObjDowsing_CheckValidSpawn(ObjDowsing* this, GlobalContext* globalCtx); + const ActorInit Obj_Dowsing_InitVars = { ACTOR_OBJ_DOWSING, ACTORCAT_ITEMACTION, @@ -27,14 +29,42 @@ const ActorInit Obj_Dowsing_InitVars = { (ActorFunc)NULL, }; -#endif +s32 ObjDowsing_GetFlag(ObjDowsing* this, GlobalContext* globalCtx) { + s32 type = DOWSING_GET_TYPE(&this->actor); + s32 flag = DOWSING_GET_FLAG(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dowsing/func_80B23D50.s") + if (type == DOWSING_COLLECTIBLE) { + return Flags_GetCollectible(globalCtx, flag); + } else if (type == DOWSING_CHEST) { + return Flags_GetTreasure(globalCtx, flag); + } else if (type == DOWSING_SWITCH) { + return Flags_GetSwitch(globalCtx, flag); + } else { + return 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dowsing/func_80B23DD0.s") +s32 ObjDowsing_CheckValidSpawn(ObjDowsing* this, GlobalContext* globalCtx) { + if (ObjDowsing_GetFlag(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dowsing/ObjDowsing_Init.s") +void ObjDowsing_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjDowsing* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dowsing/ObjDowsing_Destroy.s") + ObjDowsing_CheckValidSpawn(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dowsing/ObjDowsing_Update.s") +void ObjDowsing_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void ObjDowsing_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjDowsing* this = THIS; + + if (!ObjDowsing_CheckValidSpawn(this, globalCtx)) { + func_800B8C50(thisx, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.h b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.h index 5a2982cab7..7b1125a283 100644 --- a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.h +++ b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.h @@ -3,8 +3,17 @@ #include "global.h" +#define DOWSING_GET_TYPE(thisx) ((thisx)->params >> 7) +#define DOWSING_GET_FLAG(thisx) ((thisx)->params & 0x7F) + struct ObjDowsing; +typedef enum { + /* 1 */ DOWSING_COLLECTIBLE = 1, + /* 2 */ DOWSING_CHEST, + /* 3 */ DOWSING_SWITCH +} DowsingType; + typedef struct ObjDowsing { /* 0x000 */ Actor actor; } ObjDowsing; // size = 0x144 diff --git a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c index 7ae7399ca4..cb6aabaff7 100644 --- a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c +++ b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c @@ -65,10 +65,10 @@ void ObjEnding_Draw(Actor* thisx, GlobalContext* globalCtx) { } dl1 = this->modelInfo->dLists[0]; if (dl1 != NULL) { - func_800BDFC0(globalCtx, dl1); + Gfx_DrawDListOpa(globalCtx, dl1); } dl2 = this->modelInfo->dLists[1]; if (dl2 != NULL) { - func_800BE03C(globalCtx, dl2); + Gfx_DrawDListXlu(globalCtx, dl2); } } diff --git a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c index a4eb9ad9ac..ca6ea9f6f0 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c @@ -5,6 +5,7 @@ */ #include "z_obj_etcetera.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000010 @@ -14,8 +15,8 @@ void ObjEtcetera_Init(Actor* thisx, GlobalContext* globalCtx); void ObjEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjEtcetera_Update(Actor* thisx, GlobalContext* globalCtx); -void ObjEtcetera_PlaySmallFlutterAnimation(ObjEtcetera* this, GlobalContext* globalCtx); -void ObjEtcetera_DoIntenseOscillation(ObjEtcetera* this, GlobalContext* globalCtx); +void ObjEtcetera_PlayRustleAnimation(ObjEtcetera* this, GlobalContext* globalCtx); +void ObjEtcetera_DoBounceOscillation(ObjEtcetera* this, GlobalContext* globalCtx); void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx); void ObjEtcetera_DrawIdle(Actor* thisx, GlobalContext* globalCtx); void ObjEtcetera_DrawAnimated(Actor* thisx, GlobalContext* globalCtx); @@ -105,6 +106,11 @@ void ObjEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } +/** + * This function will make the flower oscillate on the X and Z axes in most situations + * where something interacts with it. When the player launches out of the flower, the + * oscillation is handled by ObjEtcetera_DoBounceOscillation instead. + */ void ObjEtcetera_DoNormalOscillation(ObjEtcetera* this, GlobalContext* globalCtx) { if (this->oscillationTimer > 0) { s32 requiredScopeTemp; @@ -119,10 +125,11 @@ void ObjEtcetera_DoNormalOscillation(ObjEtcetera* this, GlobalContext* globalCtx } } -void ObjEtcetera_StartSmallFlutterAnimation(ObjEtcetera* this) { - Animation_Change(&this->skelAnime, &D_040117A8, 1.0f, 0.0f, Animation_GetLastFrame(&D_040117A8), 2, 0.0f); +void ObjEtcetera_StartRustleAnimation(ObjEtcetera* this) { + Animation_Change(&this->skelAnime, &gDekuFlowerRustleAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuFlowerRustleAnim), 2, 0.0f); this->dyna.actor.draw = ObjEtcetera_DrawAnimated; - this->actionFunc = ObjEtcetera_PlaySmallFlutterAnimation; + this->actionFunc = ObjEtcetera_PlayRustleAnimation; } void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { @@ -131,12 +138,13 @@ void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { if ((player->stateFlags3 & 0x200) && (this->dyna.actor.xzDistToPlayer < 20.0f)) { // Player is launching out of the Deku Flower - Animation_Change(&this->skelAnime, &D_0400EB7C, 1.0f, 0.0f, Animation_GetLastFrame(&D_0400EB7C), 2, 0.0f); + Animation_Change(&this->skelAnime, &gDekuFlowerBounceAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuFlowerBounceAnim), 2, 0.0f); this->dyna.actor.draw = ObjEtcetera_DrawAnimated; - this->actionFunc = ObjEtcetera_DoIntenseOscillation; + this->actionFunc = ObjEtcetera_DoBounceOscillation; Actor_SetScale(&this->dyna.actor, 0.01f); this->dyna.actor.scale.y = 0.02f; - this->intenseOscillationScale = 0.003f; + this->bounceOscillationScale = 0.003f; this->oscillationTimer = 30; this->burrowFlag &= ~1; } else if ((player->stateFlags3 & 0x2000) && (this->dyna.actor.xzDistToPlayer < 30.0f) && @@ -151,7 +159,7 @@ void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { if (!(this->burrowFlag & 1)) { // Player is walking onto the Deku Flower, or falling on it from a height this->oscillationTimer = 10; - ObjEtcetera_StartSmallFlutterAnimation(this); + ObjEtcetera_StartRustleAnimation(this); } else if ((player->actor.speedXZ > 0.1f) || ((player->unk_ABC < 0.0f) && !(player->stateFlags3 & 0x100))) { // Player is walking on top of the Deku Flower, is at the very start of burrowing, or is at the very // start of launching @@ -162,19 +170,19 @@ void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { if (this->burrowFlag & 1) { // Player is walking off the Deku Flower this->oscillationTimer = 10; - ObjEtcetera_StartSmallFlutterAnimation(this); + ObjEtcetera_StartRustleAnimation(this); } this->burrowFlag &= ~1; } } if ((this->collider.base.acFlags & AC_HIT)) { this->oscillationTimer = 10; - ObjEtcetera_StartSmallFlutterAnimation(this); + ObjEtcetera_StartRustleAnimation(this); } ObjEtcetera_DoNormalOscillation(this, globalCtx); } -void ObjEtcetera_PlaySmallFlutterAnimation(ObjEtcetera* this, GlobalContext* globalCtx) { +void ObjEtcetera_PlayRustleAnimation(ObjEtcetera* this, GlobalContext* globalCtx) { if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { this->burrowFlag |= 1; } else { @@ -187,7 +195,12 @@ void ObjEtcetera_PlaySmallFlutterAnimation(ObjEtcetera* this, GlobalContext* glo ObjEtcetera_DoNormalOscillation(this, globalCtx); } -void ObjEtcetera_DoIntenseOscillation(ObjEtcetera* this, GlobalContext* globalCtx) { +/** + * When the bounce animation plays (either because the player launched out of the flower, + * or because the flower spawned after killing a Mad Scrub), this function makes the + * flower oscillate stronger than it normally does, including an oscillation on the Y-axis. + */ +void ObjEtcetera_DoBounceOscillation(ObjEtcetera* this, GlobalContext* globalCtx) { // In order to match, we are seemingly required to access scale.x at one point // without using this. We can create a thisx or dyna pointer to achieve that, but // it's more likely they used dyna given that DynaPolyActor_IsInRidingMovingState takes a DynaPolyActor. @@ -208,12 +221,12 @@ void ObjEtcetera_DoIntenseOscillation(ObjEtcetera* this, GlobalContext* globalCt Actor_SetScale(&this->dyna.actor, 0.01f); this->dyna.actor.scale.y = 0.02f; this->oscillationTimer = 0; - this->intenseOscillationScale = 0.0f; + this->bounceOscillationScale = 0.0f; return; } - this->intenseOscillationScale *= 0.8f; - this->intenseOscillationScale -= (this->dyna.actor.scale.x - 0.01f) * 0.4f; - scaleTemp = dyna->actor.scale.x + this->intenseOscillationScale; + this->bounceOscillationScale *= 0.8f; + this->bounceOscillationScale -= (this->dyna.actor.scale.x - 0.01f) * 0.4f; + scaleTemp = dyna->actor.scale.x + this->bounceOscillationScale; Actor_SetScale(&this->dyna.actor, scaleTemp); this->dyna.actor.scale.y = 2.0f * scaleTemp; } @@ -221,7 +234,12 @@ void ObjEtcetera_DoIntenseOscillation(ObjEtcetera* this, GlobalContext* globalCt void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx) { CollisionHeader* colHeader = NULL; s32 type; - CollisionHeader* collisionHeaders[] = { &D_0400E710, &D_0400E710, &D_040118D8, &D_040118D8 }; + CollisionHeader* collisionHeaders[] = { + &gPinkDekuFlowerCol, + &gPinkDekuFlowerCol, + &gGoldDekuFlowerCol, + &gGoldDekuFlowerCol, + }; s32 pad; CollisionHeader* thisCollisionHeader; @@ -232,7 +250,7 @@ void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { this->dyna.actor.objBankIndex = this->objIndex; - Actor_SetObjectSegment(globalCtx, &this->dyna.actor); + Actor_SetObjectDependency(globalCtx, &this->dyna.actor); DynaPolyActor_Init(&this->dyna, 1); thisCollisionHeader = collisionHeaders[type]; if (thisCollisionHeader != 0) { @@ -244,15 +262,15 @@ void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx) { switch (type) { case DEKU_FLOWER_TYPE_PINK: case DEKU_FLOWER_TYPE_PINK_SPAWNED_FROM_MAD_SCRUB: - SkelAnime_Init(globalCtx, &this->skelAnime, &D_04011518, &D_0400EB7C, this->jointTable, - this->morphTable, 11); - this->dList = &D_0400ED80; + SkelAnime_Init(globalCtx, &this->skelAnime, &gPinkDekuFlowerSkel, &gDekuFlowerBounceAnim, + this->jointTable, this->morphTable, DEKU_FLOWER_LIMB_MAX); + this->dList = gPinkDekuFlowerIdleDL; break; case DEKU_FLOWER_TYPE_GOLD: case DEKU_FLOWER_TYPE_GOLD_SPAWNED_FROM_MAD_SCRUB: - this->dList = &D_04011BD0; - SkelAnime_Init(globalCtx, &this->skelAnime, &D_040127E8, &D_0400EB7C, this->jointTable, - this->morphTable, 11); + this->dList = gGoldDekuFlowerIdleDL; + SkelAnime_Init(globalCtx, &this->skelAnime, &gGoldDekuFlowerSkel.sh, &gDekuFlowerBounceAnim, + this->jointTable, this->morphTable, DEKU_FLOWER_LIMB_MAX); this->collider.dim.height = 20; break; } @@ -270,13 +288,13 @@ void ObjEtcetera_Setup(ObjEtcetera* this, GlobalContext* globalCtx) { break; case DEKU_FLOWER_TYPE_PINK_SPAWNED_FROM_MAD_SCRUB: case DEKU_FLOWER_TYPE_GOLD_SPAWNED_FROM_MAD_SCRUB: - Animation_Change(&this->skelAnime, &D_0400EB7C, 1.0f, 0.0f, Animation_GetLastFrame(&D_0400EB7C), 2, - 0.0f); + Animation_Change(&this->skelAnime, &gDekuFlowerBounceAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuFlowerBounceAnim), 2, 0.0f); this->dyna.actor.draw = ObjEtcetera_DrawAnimated; - this->actionFunc = ObjEtcetera_DoIntenseOscillation; + this->actionFunc = ObjEtcetera_DoBounceOscillation; Actor_SetScale(&this->dyna.actor, 0.0f); this->oscillationTimer = 30; - this->intenseOscillationScale = 0.0f; + this->bounceOscillationScale = 0.0f; this->dyna.actor.focus.pos.y = this->dyna.actor.home.pos.y + 10.0f; this->dyna.actor.targetMode = 3; break; @@ -299,6 +317,11 @@ void ObjEtcetera_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } +/** + * When the flower isn't animating, this function is used to draw it. + * It draws the flower as a single, non-moving display list that encompasses the whole flower. + * When an animation is finished, functions are expected to set the actor's draw function to this. + */ void ObjEtcetera_DrawIdle(Actor* thisx, GlobalContext* globalCtx) { ObjEtcetera* this = THIS; @@ -311,6 +334,11 @@ void ObjEtcetera_DrawIdle(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } +/** + * When the flower is animating, this function is used to draw it. + * It draws the flower as an animated bunch of limbs using the SkelAnime system. + * When a function wants to play an animation, it is expected to set the actor's draw function to this. + */ void ObjEtcetera_DrawAnimated(Actor* thisx, GlobalContext* globalCtx) { ObjEtcetera* this = THIS; diff --git a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h index f5642ff282..a52f5ae2ef 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h @@ -13,6 +13,26 @@ typedef enum { /* 4 */ DEKU_FLOWER_TYPE_MAX, } DekuFlowerType; +/** + * For the petal/leaf directions, "back" is negative and "front" is positive + * on the flower's local Z-axis. "Left" and "right" are relative to the front + * and back. + */ +typedef enum { + /* 0 */ DEKU_FLOWER_LIMB_NONE, + /* 1 */ DEKU_FLOWER_LIMB_BASE, + /* 2 */ DEKU_FLOWER_LIMB_CENTER, + /* 3 */ DEKU_FLOWER_LIMB_BACK_PETAL_OR_LEAF, + /* 4 */ DEKU_FLOWER_LIMB_FRONT_PETAL_OR_LEAF, + /* 5 */ DEKU_FLOWER_LIMB_FRONT_RIGHT_PETAL, + /* 6 */ DEKU_FLOWER_LIMB_BACK_RIGHT_PETAL, + /* 7 */ DEKU_FLOWER_LIMB_RIGHT_PETAL_OR_LEAF, + /* 8 */ DEKU_FLOWER_LIMB_FRONT_LEFT_PETAL, + /* 9 */ DEKU_FLOWER_LIMB_LEFT_PETAL_OR_LEAF, + /* 10 */ DEKU_FLOWER_LIMB_BACK_LEFT_PETAL, + /* 11 */ DEKU_FLOWER_LIMB_MAX, +} DekuFlowerLimbs; + struct ObjEtcetera; typedef void (*ObjEtceteraActionFunc)(struct ObjEtcetera*, GlobalContext*); @@ -21,9 +41,9 @@ typedef struct ObjEtcetera { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ SkelAnime skelAnime; /* 0x1A0 */ ColliderCylinder collider; - /* 0x1EC */ Vec3s jointTable[11]; - /* 0x22E */ Vec3s morphTable[11]; - /* 0x270 */ f32 intenseOscillationScale; + /* 0x1EC */ Vec3s jointTable[DEKU_FLOWER_LIMB_MAX]; + /* 0x22E */ Vec3s morphTable[DEKU_FLOWER_LIMB_MAX]; + /* 0x270 */ f32 bounceOscillationScale; /* 0x274 */ s16 oscillationTimer; /* 0x276 */ u16 burrowFlag; /* 0x278 */ s8 objIndex; diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c index 8a67950942..bd91aaaf08 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -5,6 +5,7 @@ */ #include "z_obj_flowerpot.h" +#include "objects/object_flowerpot/object_flowerpot.h" #define FLAGS 0x00000000 @@ -15,7 +16,21 @@ void ObjFlowerpot_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjFlowerpot_Update(Actor* thisx, GlobalContext* globalCtx); void ObjFlowerpot_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A1C818(ObjFlowerpot* this); +void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx); +void func_80A1CBF8(ObjFlowerpot* this); +void func_80A1CC0C(ObjFlowerpot* this, GlobalContext* globalCtx); +void func_80A1CD10(ObjFlowerpot* this); +void func_80A1CEF4(ObjFlowerpot* this2, GlobalContext* globalCtx); + +static u32 D_80A1D830; +static MtxF D_80A1D838[8]; +static s16 D_80A1DA38; +static s16 D_80A1DA3A; +static s16 D_80A1DA3C; +static s16 D_80A1DA3E; +static s16 D_80A1DA40; + const ActorInit Obj_Flowerpot_InitVars = { ACTOR_OBJ_FLOWERPOT, ACTORCAT_PROP, @@ -28,86 +43,649 @@ const ActorInit Obj_Flowerpot_InitVars = { (ActorFunc)ObjFlowerpot_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_80A1D3A0[2] = { +static ColliderJntSphElementInit sJntSphElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x05CBFFBE, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x05CBFFBE, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 100, 0 }, 12 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x0580C71C, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x0580C71C, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 1, { { 0, 300, 0 }, 12 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80A1D3E8 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 2, D_80A1D3A0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A1D414[] = { - ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 1600, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), +static s16 D_80A1D3F8 = 0; + +static s16 D_80A1D3FC = 0; + +static s16 D_80A1D400 = 0; + +static u8 D_80A1D404 = true; + +static Vec3f D_80A1D408 = { 0.0f, 20.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1600, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), }; -#endif +void func_80A1B3D0(void) { + s32 i; + s32 pad; + f32 spB4; + f32* ptr; + f32 spAC; + f32 spA8; + f32 tempf1; + f32 tempf2; + f32 tempf3; + f32 tempf4; + f32 tempf5; + f32 sp74[8]; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + f32 temp_f26; + f32 temp_f28; + f32 temp_f0; + f32 temp_f30; -extern ColliderJntSphElementInit D_80A1D3A0[2]; -extern ColliderJntSphInit D_80A1D3E8; -extern InitChainEntry D_80A1D414[]; + D_80A1DA38 += 70; + D_80A1DA3A += 300; + D_80A1DA3C += 700; + D_80A1DA3E += 1300; + D_80A1DA40 += 8900; -extern UNK_TYPE D_060012E0; -extern UNK_TYPE D_060014F0; -extern UNK_TYPE D_060015B0; + temp_f28 = Math_SinS(D_80A1DA38); + spB4 = Math_SinS(D_80A1DA3A); + temp_f30 = Math_SinS(D_80A1DA3C); + spAC = Math_SinS(D_80A1DA3E); + spA8 = Math_SinS(D_80A1DA40); + temp_f26 = Math_CosS(D_80A1DA38); + temp_f20 = Math_CosS(D_80A1DA3A); + temp_f22 = Math_CosS(D_80A1DA3C); + temp_f24 = Math_CosS(D_80A1DA3E); + temp_f0 = Math_CosS(D_80A1DA40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1B3D0.s") + sp74[0] = (temp_f28 - temp_f20) * temp_f30 * temp_f26 * temp_f28 * 0.0012f; + sp74[1] = (spB4 - temp_f22) * spAC * temp_f20 * temp_f28 * 0.0012f; + sp74[2] = (temp_f30 - temp_f24) * temp_f22 * temp_f28 * temp_f26 * 0.0012f; + sp74[3] = (spAC - temp_f20) * temp_f24 * spB4 * temp_f26 * 0.0012f; + sp74[4] = (temp_f28 - temp_f22) * temp_f28 * spB4 * spA8 * 0.0013f; + sp74[5] = (spB4 - temp_f24) * temp_f30 * spAC * spA8 * 0.0013f; + sp74[6] = (temp_f30 - temp_f26) * temp_f26 * temp_f20 * temp_f0 * 0.0013f; + sp74[7] = (spAC - temp_f20) * temp_f22 * temp_f24 * temp_f0 * 0.0013f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1B840.s") + for (i = 0; i < ARRAY_COUNT(D_80A1D838); i++) { + ptr = (f32*)&D_80A1D838[i].mf[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1B914.s") + tempf1 = sp74[(i + 0) & 7]; + tempf2 = sp74[(i + 1) & 7]; + tempf3 = sp74[(i + 2) & 7]; + tempf4 = sp74[(i + 3) & 7]; + tempf5 = sp74[(i + 4) & 7]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1B994.s") + ptr[0] = sp74[1] * 0.2f; + ptr[1] = tempf1; + ptr[2] = tempf2; + ptr[3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1B9CC.s") + ptr[4] = tempf3; + ptr[5] = sp74[0]; + ptr[6] = tempf3; + ptr[7] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1BA04.s") + ptr[8] = tempf4; + ptr[9] = tempf5; + ptr[10] = sp74[3] * 0.2f; + ptr[11] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1BA44.s") + ptr[12] = 0.0f; + ptr[13] = 0.0f; + ptr[14] = 0.0f; + ptr[15] = 0.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1BD80.s") +void func_80A1B840(MtxF* matrix) { + MtxF* temp = Matrix_GetCurrentState(); + f32* tmp = (f32*)&temp->mf[0]; + f32* tmp2 = (f32*)&matrix->mf[0]; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1C0FC.s") + for (i = 0; i < 16; i++) { + *tmp++ += *tmp2++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1C328.s") +void func_80A1B914(ObjFlowerpot* this, GlobalContext* globalCtx) { + if (!(this->unk_1EA & 4)) { + s32 temp_v0 = func_800A8150(ENOBJFLOWERPOT_GET_3F(&this->actor)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1C554.s") + if (temp_v0 >= 0) { + s32 params = ENOBJFLOWERPOT_GET_7F00(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1C5E8.s") + Item_DropCollectible(globalCtx, &this->actor.world.pos, temp_v0 | (params << 8)); + this->unk_1EA |= 4; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1C62C.s") +void func_80A1B994(ObjFlowerpot* this, GlobalContext* globalCtx) { + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/ObjFlowerpot_Init.s") +void func_80A1B9CC(ObjFlowerpot* this, GlobalContext* globalCtx) { + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/ObjFlowerpot_Destroy.s") +void func_80A1BA04(ObjFlowerpot* this, Vec3f* arg1) { + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_MultiplyVector3fByState(&D_80A1D408, arg1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1C818.s") +void func_80A1BA44(ObjFlowerpot* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spD0; + Vec3f spC4; + Vec3f spB8; + f32 temp_f0; + f32 temp_f20; + s16 phi_s3; + s32 phi_s0; + s32 phi_s1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1C838.s") + spD0.x = this->actor.world.pos.x; + spD0.y = this->actor.world.pos.y; + spD0.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1CBF8.s") + for (i = 0, phi_s3 = 0; i < 18; i++, phi_s3 += 0xE38) { + temp_f20 = (Rand_ZeroOne() * 8.0f) + 2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1CC0C.s") + spC4.x = Math_SinS((s32)(Rand_ZeroOne() * 3640.0f) + phi_s3) * temp_f20; + spC4.y = Rand_ZeroOne() * 30.0f; + spC4.z = Math_CosS((s32)(Rand_ZeroOne() * 3640.0f) + phi_s3) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1CD10.s") + spB8.x = spC4.x * 0.27f; + spB8.y = (Rand_ZeroOne() * 6.0f) + 2.6f + ((30.0f - spC4.y) * 0.2f); + spB8.z = spC4.z * 0.27f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/func_80A1CEF4.s") + Math_Vec3f_Sum(&spC4, &spD0, &spC4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/ObjFlowerpot_Update.s") + temp_f0 = Rand_ZeroOne(); + if (temp_f0 < 0.2f) { + phi_s0 = 32; + phi_s1 = 0; + } else if (temp_f0 < 0.6f) { + phi_s0 = 65; + phi_s1 = 1; + } else { + phi_s0 = 64; + phi_s1 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Flowerpot/ObjFlowerpot_Draw.s") + EffectSsKakera_Spawn(globalCtx, &spC4, &spB8, &spC4, -600, phi_s0, 30, 0, 0, (Rand_ZeroOne() * 12.0f) + 16.6f, + phi_s1, 0, 35, -1, ACTOR_DEMO_GETITEM, object_flowerpot_DL_0015B0); + } + + spD0.y += 20.0f; + + func_800BBFB0(globalCtx, &spD0, 30.0f, 2, 20, 50, 1); + func_800BBFB0(globalCtx, &spD0, 30.0f, 2, 10, 80, 1); + func_800BBFB0(globalCtx, &spD0, 30.0f, 1, 10, 40, 1); +} + +void func_80A1BD80(ObjFlowerpot* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + f32 temp_f20; + s16 phi_s1; + s32 phi_s0; + + spC8.x = this->actor.world.pos.x; + spC8.y = this->actor.world.pos.y; + spC8.z = this->actor.world.pos.z; + + for (i = 0, phi_s1 = 0; i < 14; i++, phi_s1 += 0x1249) { + temp_f20 = (Rand_ZeroOne() * 8.0f) + 2.0f; + + spBC.x = Math_SinS((s32)(Rand_ZeroOne() * 4681.0f) + phi_s1) * temp_f20; + spBC.y = Rand_ZeroOne() * 20.0f; + spBC.z = Math_CosS((s32)(Rand_ZeroOne() * 4681.0f) + phi_s1) * temp_f20; + + spB0.x = spBC.x * 0.17f; + spB0.y = (Rand_ZeroOne() * 5.0f) + 1.4f; + spB0.z = spBC.z * 0.17f; + + Math_Vec3f_Sum(&spBC, &spC8, &spBC); + + if (Rand_ZeroOne() < 0.2f) { + phi_s0 = 64; + } else { + phi_s0 = 32; + } + + EffectSsKakera_Spawn(globalCtx, &spBC, &spB0, &spBC, -240, phi_s0, 40, 0, 0, (Rand_ZeroOne() * 20.0f) + 10.6f, + 0, 0, 42, -1, ACTOR_DEMO_GETITEM, object_flowerpot_DL_0015B0); + } + + spBC.y = this->actor.world.pos.y + this->actor.depthInWater; + + for (phi_s1 = 0, i = 0; i < 4; i++, phi_s1 += 0x4000) { + spBC.x = (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s1) * 15.0f) + this->actor.world.pos.x; + spBC.z = (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s1) * 15.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &spBC, NULL, NULL, 0, 200); + } + + spBC.x = this->actor.world.pos.x; + spBC.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &spBC, NULL, NULL, 0, 350); + EffectSsGRipple_Spawn(globalCtx, &spBC, 150, 650, 0); +} + +void func_80A1C0FC(ObjFlowerpot* this, GlobalContext* globalCtx) { + Vec3f spC4; + Vec3f spB8; + Vec3f spAC; + f32 temp_f20; + s16 phi_s0; + s32 i; + + func_80A1BA04(this, &spC4); + + for (i = 0, phi_s0 = 0; i < 10; i++, phi_s0 += 0x1999) { + temp_f20 = (Rand_ZeroOne() * 18.0f) + 2.0f; + + spB8.x = Math_SinS((s32)(Rand_ZeroOne() * 6553.0f) + phi_s0) * temp_f20; + spB8.y = Rand_ZeroOne() * 15.0f; + spB8.z = Math_CosS((s32)(Rand_ZeroOne() * 6553.0f) + phi_s0) * temp_f20; + + spAC.x = spB8.x * 0.23f; + spAC.y = (Rand_ZeroOne() * 8.0f) + 1.5f; + spAC.z = spB8.z * 0.23f; + + Math_Vec3f_Sum(&spB8, &spC4, &spB8); + EffectSsKakera_Spawn(globalCtx, &spB8, &spAC, &spB8, -100, 64, 40, 0, 0, (Rand_ZeroOne() * 16.0f) + 14.0f, 0, 0, + 80, -1, ACTOR_DEMO_GETITEM, object_flowerpot_DL_0014F0); + } +} + +void func_80A1C328(ObjFlowerpot* this, GlobalContext* globalCtx) { + Vec3f spC4; + Vec3f spB8; + Vec3f spAC; + f32 temp_f20; + s16 phi_s0; + s32 i; + + func_80A1BA04(this, &spC4); + + for (i = 0, phi_s0 = 0; i < 10; i++, phi_s0 += 0x1999) { + temp_f20 = (Rand_ZeroOne() * 18.0f) + 2.0f; + + spB8.x = Math_SinS((s32)(Rand_ZeroOne() * 6553.0f) + phi_s0) * temp_f20; + spB8.y = Rand_ZeroOne() * 15.0f; + spB8.z = Math_CosS((s32)(Rand_ZeroOne() * 6553.0f) + phi_s0) * temp_f20; + + spAC.x = spB8.x * 0.18f; + spAC.y = (Rand_ZeroOne() * 4.0f) + 1.2f; + spAC.z = spB8.z * 0.18f; + + Math_Vec3f_Sum(&spB8, &spC4, &spB8); + EffectSsKakera_Spawn(globalCtx, &spB8, &spAC, &spB8, -80, 64, 44, 0, 0, (Rand_ZeroOne() * 16.0f) + 14.0f, 0, 0, + 80, -1, ACTOR_DEMO_GETITEM, object_flowerpot_DL_0014F0); + } +} + +void func_80A1C554(ObjFlowerpot* this) { + if ((this->actor.projectedPos.z < 455.0f) && (this->actor.projectedPos.z > -10.0f)) { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.shape.shadowScale = 1.9f; + if (this->actor.projectedPos.z < 255.0f) { + this->actor.shape.shadowAlpha = 200; + } else { + this->actor.shape.shadowAlpha = 455 - (s32)this->actor.projectedPos.z; + } + } else { + this->actor.shape.shadowDraw = NULL; + } +} + +void func_80A1C5E8(ObjFlowerpot* this, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); +} + +void func_80A1C62C(ObjFlowerpot* this, GlobalContext* globalCtx) { + if (!(this->unk_1EA & 4) && (globalCtx->roomCtx.currRoom.num != this->unk_1EC)) { + this->unk_1EA |= 4; + } +} + +void ObjFlowerpot_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjFlowerpot* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (this->actor.shape.rot.y == 0) { + this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + } + + Collider_InitJntSph(globalCtx, &this->collider); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + Matrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + &this->actor.shape.rot); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Collider_UpdateSpheres(0, &this->collider); + Collider_UpdateSpheres(1, &this->collider); + + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->unk_1EC = this->actor.room; + func_80A1C818(this); + + if (D_80A1D404) { + D_80A1DA38 = (u32)Rand_Next() >> 0x10; + D_80A1DA3A = (u32)Rand_Next() >> 0x10; + D_80A1DA3C = (u32)Rand_Next() >> 0x10; + D_80A1DA3E = (u32)Rand_Next() >> 0x10; + D_80A1DA40 = (u32)Rand_Next() >> 0x10; + D_80A1D404 = false; + func_80A1B3D0(); + D_80A1D830 = globalCtx->gameplayFrames; + } + this->unk_1EB = D_80A1D400 & 7; + D_80A1D400++; +} + +void ObjFlowerpot_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyJntSph(globalCtx, &THIS->collider); +} + +void func_80A1C818(ObjFlowerpot* this) { + this->actionFunc = func_80A1C838; + this->unk_1EA |= 1; +} + +void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { + s32 pad; + + if (Actor_HasParent(&this->actor, globalCtx)) { + func_80A1CBF8(this); + this->actor.room = -1; + this->actor.colChkInfo.mass = 180; + this->actor.flags |= 0x10; + if (func_800A817C(ENOBJFLOWERPOT_GET_3F(&this->actor))) { + func_80A1B914(this, globalCtx); + } + + //! @bug: This function should only pass Player*: it uses *(this + 0x153), which is meant to be + //! player->currentMask, but in this case is garbage in the collider + func_800B8E58((Player*)this, NA_SE_PL_PULL_UP_POT); + } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 19.0f)) { + if (!(this->unk_1EA & 2)) { + func_80A1B914(this, globalCtx); + func_80A1C328(this, globalCtx); + func_80A1B9CC(this, globalCtx); + this->unk_1EA |= 2; + } + func_80A1BD80(this, globalCtx); + func_80A1B994(this, globalCtx); + Actor_MarkForDeath(&this->actor); + } else if ((this->collider.elements[0].info.bumperFlags & 2) && + (this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x058BFFBC)) { + if (!(this->unk_1EA & 2)) { + func_80A1B914(this, globalCtx); + func_80A1C0FC(this, globalCtx); + func_80A1B9CC(this, globalCtx); + this->unk_1EA |= 2; + } + func_80A1BA44(this, globalCtx); + func_80A1B994(this, globalCtx); + Actor_MarkForDeath(&this->actor); + } else { + if (this->collider.elements[1].info.bumperFlags & 2) { + if (!(this->unk_1EA & 2)) { + this->unk_1EA |= 2; + this->collider.elements[1].info.bumperFlags &= ~0x1; + func_80A1C0FC(this, globalCtx); + func_80A1B914(this, globalCtx); + func_80A1B9CC(this, globalCtx); + } + } + + if (this->unk_1EA & 1) { + Actor_MoveWithGravity(&this->actor); + func_80A1C5E8(this, globalCtx); + if (this->actor.bgCheckFlags & 1) { + if (this->actor.colChkInfo.mass == MASS_IMMOVABLE) { + if (DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId) == NULL) { + this->actor.flags &= ~0x10; + this->unk_1EA &= ~0x1; + } + } else if (Math3D_Vec3fDistSq(&this->actor.world.pos, &this->actor.prevPos) < 0.01f) { + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + } + } + } + + if (!(this->collider.base.ocFlags1 & OC1_TYPE_PLAYER) && (this->actor.xzDistToPlayer > 28.0f)) { + this->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; + } + + this->collider.base.acFlags &= ~AC_HIT; + + if (this->actor.xzDistToPlayer < 600.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actor.xzDistToPlayer < 180.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actor.xzDistToPlayer < 100.0f) { + s16 temp_v0_3 = this->actor.yawTowardsPlayer - GET_PLAYER(globalCtx)->actor.world.rot.y; + + if (ABS_ALT(temp_v0_3) >= 0x5556) { + Actor_PickUp(&this->actor, globalCtx, 0, 36.0f, 30.0f); + } + } + } + } + } +} + +void func_80A1CBF8(ObjFlowerpot* this) { + this->actionFunc = func_80A1CC0C; +} + +void func_80A1CC0C(ObjFlowerpot* this, GlobalContext* globalCtx) { + s32 pad; + + func_80A1C62C(this, globalCtx); + + if (Actor_HasNoParent(&this->actor, globalCtx)) { + this->actor.room = globalCtx->roomCtx.currRoom.num; + if (fabsf(this->actor.speedXZ) < 0.1f) { + func_80A1C818(this); + func_800B8E58(GET_PLAYER(globalCtx), NA_SE_PL_PUT_DOWN_POT); + this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; + } else { + Actor_MoveWithGravity(&this->actor); + func_80A1CD10(this); + } + func_80A1C5E8(this, globalCtx); + } else { + Vec3f sp30; + s32 sp2C; + + sp30.x = this->actor.world.pos.x; + sp30.y = this->actor.world.pos.y + 20.0f; + sp30.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); + } +} + +void func_80A1CD10(ObjFlowerpot* this) { + f32 sp1C; + + this->actionFunc = func_80A1CEF4; + this->unk_1E8 = 64; + + if (this->unk_1EA & 2) { + sp1C = (Rand_ZeroOne() * 1.2f) - 1.1f; + if (sp1C < -0.9f) { + sp1C = -0.9f; + } + D_80A1D3F8 = sp1C * 8000.0f; + D_80A1D3FC = ((Rand_ZeroOne() - 0.5f) * 3800.0f) * (fabsf(sp1C) + 0.1f); + this->actor.shape.yOffset = -71.5f; + this->actor.world.pos.y += 7.15f; + } else { + sp1C = (Rand_ZeroOne() - 0.78f) * 1.3f; + if (sp1C < -0.78f) { + sp1C = -0.78f; + } else if (sp1C > 0.22000003f) { + sp1C = 0.22000003f; + } + D_80A1D3F8 = sp1C * 6200.0f; + D_80A1D3FC = (Rand_ZeroOne() - 0.5f) * 4200.0f; + this->actor.shape.yOffset = -110.0f; + this->actor.world.pos.y += 11.0f; + } +} + +void func_80A1CEF4(ObjFlowerpot* this2, GlobalContext* globalCtx) { + ObjFlowerpot* this = this2; + s32 sp28 = this->collider.elements[0].info.toucherFlags & TOUCH_HIT; + + if (sp28) { + this->collider.elements[0].info.toucherFlags &= ~TOUCH_ON; + } + + if (this->unk_1E8 > 0) { + this->unk_1E8--; + } + + func_80A1C62C(this, globalCtx); + + if ((this->actor.bgCheckFlags & (0x8 | 0x2 | 0x1)) || sp28 || (this->unk_1E8 <= 0)) { + if (!(this->unk_1EA & 2)) { + func_80A1B914(this, globalCtx); + func_80A1C0FC(this, globalCtx); + func_80A1B9CC(this, globalCtx); + this->unk_1EA |= 2; + } + func_80A1BA44(this, globalCtx); + func_80A1B994(this, globalCtx); + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->actor.bgCheckFlags & 0x40) { + if (!(this->unk_1EA & 2)) { + func_80A1B914(this, globalCtx); + func_80A1C328(this, globalCtx); + func_80A1B9CC(this, globalCtx); + this->unk_1EA |= 2; + } + func_80A1BD80(this, globalCtx); + func_80A1B994(this, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + Actor_MarkForDeath(&this->actor); + return; + } + + Actor_MoveWithGravity(&this->actor); + + if (!(this->unk_1EA & 2)) { + D_80A1D3F8 += (s16)(this->actor.shape.rot.x * -0.06f); + } else { + Math_StepToS(&D_80A1D3F8, 0, 80); + Math_StepToS(&D_80A1D3FC, 0, 20); + } + + this->actor.shape.rot.x += D_80A1D3F8; + this->actor.shape.rot.y += D_80A1D3FC; + + func_80A1C5E8(this, globalCtx); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjFlowerpot_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjFlowerpot* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80A1C554(this); + + if ((D_80A1D830 != globalCtx->gameplayFrames) && (globalCtx->roomCtx.currRoom.unk3 == 0)) { + func_80A1B3D0(); + D_80A1D830 = globalCtx->gameplayFrames; + } +} + +void ObjFlowerpot_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjFlowerpot* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_flowerpot_DL_0012E0); + + if ((this->actionFunc != func_80A1C838) || (this->unk_1EA & 1)) { + Collider_UpdateSpheres(0, &this->collider); + if (!(this->unk_1EA & 2)) { + Collider_UpdateSpheres(1, &this->collider); + } + } + + if (!(this->unk_1EA & 2)) { + if ((globalCtx->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == func_80A1C838)) { + if ((this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { + func_80A1B840(&D_80A1D838[this->unk_1EB]); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + } + + gSPDisplayList(POLY_OPA_DISP++, object_flowerpot_DL_001408); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h index 3396a1abaf..01557bc2bb 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h @@ -7,11 +7,18 @@ struct ObjFlowerpot; typedef void (*ObjFlowerpotActionFunc)(struct ObjFlowerpot*, GlobalContext*); +#define ENOBJFLOWERPOT_GET_3F(thisx) ((thisx)->params & 0x3F) +#define ENOBJFLOWERPOT_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) + typedef struct ObjFlowerpot { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xA0]; + /* 0x0144 */ ColliderJntSph collider; + /* 0x0164 */ ColliderJntSphElement colliderElements[2]; /* 0x01E4 */ ObjFlowerpotActionFunc actionFunc; - /* 0x01E8 */ char unk_1E8[0x8]; + /* 0x01E8 */ s16 unk_1E8; + /* 0x01EA */ u8 unk_1EA; + /* 0x01EB */ s8 unk_1EB; + /* 0x01EC */ s8 unk_1EC; } ObjFlowerpot; // size = 0x1F0 extern const ActorInit Obj_Flowerpot_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c index 4cfc3fcf7b..49a5a7dbe8 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -75,7 +75,7 @@ void func_80B3C39C(ObjGhaka* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 distDiff = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.shape.rot.y; - if (func_800B84D0(&this->dyna.actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state)) { func_80B3C29C(this); } else if (this->dyna.actor.xzDistToPlayer < 100.0f || this->dyna.actor.isTargeted) { if (distDiff <= -0x5556 || distDiff >= 0x5556) { @@ -97,7 +97,7 @@ void func_80B3C39C(ObjGhaka* this, GlobalContext* globalCtx) { } void func_80B3C4E0(ObjGhaka* this, GlobalContext* globalCtx) { - u8 talkState = func_80152498(&globalCtx->msgCtx); + u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { if (func_80147624(globalCtx)) { diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c index af5ebd44a9..4d717fabd7 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c @@ -37,7 +37,7 @@ static ColliderCylinderInit D_809ABBD0 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_809ABC4C[] = { ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -17000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_STOP), }; diff --git a/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c b/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c index b82932eaa5..d7e0d66332 100644 --- a/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c +++ b/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c @@ -49,5 +49,5 @@ void ObjHana_Update(Actor* thisx, GlobalContext* globalCtx) { } void ObjHana_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000500); + Gfx_DrawDListOpa(globalCtx, D_06000500); } diff --git a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c index 0b32504fa1..c11fa4903c 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c @@ -49,7 +49,7 @@ static s32 unused = 0; static s32 unused2 = 0; void ObjHgdoor_SetChild(ObjHgdoor* this, GlobalContext* globalCtx) { - Actor* actorIterator = globalCtx->actorCtx.actorList[ACTORCAT_PROP].first; + Actor* actorIterator = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; while (actorIterator) { if ((actorIterator->id == ACTOR_OBJ_HGDOOR) && (&this->dyna.actor != actorIterator)) { @@ -61,7 +61,7 @@ void ObjHgdoor_SetChild(ObjHgdoor* this, GlobalContext* globalCtx) { } void ObjHgdoor_SetParent(ObjHgdoor* this, GlobalContext* globalCtx) { - Actor* actorIterator = globalCtx->actorCtx.actorList[ACTORCAT_PROP].first; + Actor* actorIterator = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; while (actorIterator) { if (actorIterator->id == ACTOR_EN_HG) { @@ -142,7 +142,7 @@ void func_80BD4358(ObjHgdoor* this, GlobalContext* globalCtx) { this->unk166 = globalCtx->csCtx.npcActions[actionIndex]->unk0; switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { case 1: - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WOOD_DOOR_OPEN_SPEEDY); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOOD_DOOR_OPEN_SPEEDY); if ((this->dyna.actor.parent != NULL) && (this->dyna.actor.parent->id == ACTOR_EN_HG)) { this->dyna.actor.parent->colChkInfo.health = 1; } diff --git a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c index d7001bed0f..cf84a1bd7e 100644 --- a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c +++ b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c @@ -146,5 +146,5 @@ void ObjHsStump_Update(Actor* thisx, GlobalContext* globalCtx) { } void ObjHsStump_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_060003B8); + Gfx_DrawDListOpa(globalCtx, D_060003B8); } diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c index 6731feda71..2c204e7baa 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -5,6 +5,7 @@ */ #include "z_obj_hugebombiwa.h" +#include "objects/object_bombiwa/object_bombiwa.h" #define FLAGS 0x00000010 @@ -15,7 +16,16 @@ void ObjHugebombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHugebombiwa_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHugebombiwa_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A54BF0(ObjHugebombiwa* this); +void func_80A54C04(ObjHugebombiwa* this, GlobalContext* globalCtx); +void func_80A54CD8(ObjHugebombiwa* this); +void func_80A54CEC(ObjHugebombiwa* this, GlobalContext* globalCtx); +void func_80A54E10(ObjHugebombiwa* this); +void func_80A55064(ObjHugebombiwa* this, GlobalContext* globalCtx); +void func_80A55310(ObjHugebombiwa* this); +void func_80A55564(ObjHugebombiwa* this, GlobalContext* globalCtx); +void func_80A55B34(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Hugebombiwa_InitVars = { ACTOR_OBJ_HUGEBOMBIWA, ACTORCAT_PROP, @@ -28,64 +38,683 @@ const ActorInit Obj_Hugebombiwa_InitVars = { (ActorFunc)ObjHugebombiwa_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A55D00 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x81C37BB6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x81C37BB6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 180, 226, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A55D7C[] = { +static Vec3f D_80A55D2C = { 0.0f, 0.3f, 0.0f }; + +void func_80A53BE0(GlobalContext* globalCtx, Vec3f* arg1) { + Vec3f spBC; + Vec3f spB0; + s32 i; + s32 gravity; + s16 phi_v0; + s16 life; + s16 phi_v1; + + for (i = 0, gravity = -300; i < 16; i++, gravity -= 30) { + spBC.x = (Rand_ZeroOne() - 0.5f) * 260.0f; + spBC.y = i * (40.0f / 3); + spBC.z = (Rand_ZeroOne() - 0.5f) * 260.0f; + + spB0.x = ((Rand_ZeroOne() - 0.5f) * 5.7f) + (spBC.x * 0.035f); + spB0.y = (Rand_ZeroOne() * 16.0f) + 5.0f + ((16 - i) * 0.25f); + spB0.z = ((Rand_ZeroOne() - 0.5f) * 5.7f) + (spBC.z * 0.035f); + + spBC.x += arg1->x; + spBC.y += arg1->y; + spBC.z += arg1->z; + + if (i >= 14) { + phi_v0 = 37; + life = 70; + } else { + phi_v0 = 65; + if (i >= 12) { + life = 70; + } else { + life = 40; + if (Rand_ZeroOne() < 0.7f) { + phi_v0 = 64; + } else { + phi_v0 = 32; + } + } + } + + phi_v1 = i; + if (phi_v1 <= 0) { + phi_v1 = 1; + if (1) {} + } + + EffectSsKakera_Spawn(globalCtx, &spBC, &spB0, &spBC, gravity, phi_v0, 15, 0, 0, phi_v1, 1, 0, life, -1, + OBJECT_BOMBIWA, object_bombiwa_DL_001990); + } +} + +void func_80A53E60(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, f32 arg3) { + static Color_RGBA8 D_80A55D38 = { 210, 210, 210, 255 }; + static Color_RGBA8 D_80A55D3C = { 140, 140, 140, 255 }; + static f32 D_80A55D40[] = { 3.0f, 5.0f, 9.0f, 18.0f }; + Vec3f spDC; + Vec3f spD0; + s32 i; + f32 temp_f0; + s32 phi_s1; + s32 phi_s2; + s32 phi_v0; + s32 phi_v1; + s16 phi_s0; + s32 pad; + + for (phi_s2 = -300, i = 0; phi_s2 > -540; phi_s2 -= 60, i++) { + spDC.x = (Rand_ZeroOne() - 0.5f) * 11.0f; + spDC.y = (Rand_ZeroOne() - 0.2f) * 8.0f; + spDC.z = (Rand_ZeroOne() - 0.5f) * 11.0f; + + spD0.x = ((Rand_ZeroOne() - 0.5f) * 5.0f) + (spDC.x * 1.4f); + spD0.y = (Rand_ZeroOne() * 13.0f) + 8.2f + (arg2 * -0.26f); + if (1) {} + spD0.z = ((Rand_ZeroOne() - 0.5f) * 5.0f) + (spDC.z * 1.4f); + + spDC.x += arg1->x; + spDC.y += arg1->y; + spDC.z += arg1->z; + + if ((s32)(phi_s2 & 0xFFFFFFFF) == -480) { + phi_v0 = 33; + phi_s0 = 70; + } else { + phi_v0 = 65; + if (phi_s2 == -420) { + phi_s0 = 70; + } else { + phi_s0 = 40; + if (Rand_ZeroOne() < 0.7f) { + phi_v0 = 64; + } else { + phi_v0 = 32; + } + } + } + + temp_f0 = D_80A55D40[i] * arg3; + if (temp_f0 <= 1.0f) { + phi_v1 = 1; + } else { + phi_v1 = temp_f0; + } + + EffectSsKakera_Spawn(globalCtx, &spDC, &spD0, &spDC, phi_s2, phi_v0, 15, 0, 0, phi_v1, 1, 0, phi_s0, -1, + OBJECT_BOMBIWA, object_bombiwa_DL_001990); + + spDC.x += (Rand_ZeroOne() - 0.5f) * 270.0f; + spDC.y += (Rand_ZeroOne() - 0.1f) * 150.0f; + spDC.z += (Rand_ZeroOne() - 0.5f) * 270.0f; + + phi_s0 = (Rand_ZeroOne() * 160.0f) + 140.0f; + phi_s1 = (Rand_ZeroOne() * 180.0f) + 120.0f; + func_800B0E48(globalCtx, &spDC, &gZeroVec3f, &D_80A55D2C, &D_80A55D38, &D_80A55D3C, phi_s0, phi_s1); + } +} + +void func_80A541F4(ObjHugebombiwa* this, GlobalContext* globalCtx) { + static s16 D_80A55D50[] = { 24, 17, 13, 7, 6, 5, 3, 2 }; + s32 i; + s32 pad[2]; + s32 phi_s2; + Vec3f spF4; + Vec3f spE8; + Vec3f spDC; + Vec3f spD0; + Vec3f spC4; + f32 temp_f0; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + s32 phi_s0; + f32 phi_f30; + + for (i = 0, phi_s2 = 0, phi_f30 = 0.0f; i < 13; i++, phi_s2 += 0x4E20, phi_f30 += (230.0f / 13)) { + temp_f0 = Rand_ZeroOne(); + temp_f22 = (1.0f - SQ(temp_f0)) * 120.0f; + temp_f20 = Math_SinS(phi_s2 & 0xFFFF); + temp_f24 = Math_CosS(phi_s2 & 0xFFFF); + + spF4.x = (temp_f20 * temp_f22) + this->actor.world.pos.x; + spF4.y = this->actor.world.pos.y + phi_f30; + spF4.z = (temp_f24 * temp_f22) + this->actor.world.pos.z; + + spE8.x = temp_f20 * 10.0f; + spE8.y = (Rand_ZeroOne() * 18.0f) + 10.0f; + spE8.z = temp_f24 * 10.0f; + + EffectSsKakera_Spawn(globalCtx, &spF4, &spE8, &spF4, -650, 37, 15, 0, 0, D_80A55D50[i & 7], 1, 0, 60, -1, + OBJECT_BOMBIWA, object_bombiwa_DL_0009E0); + + spDC.x = ((Rand_ZeroOne() - 0.5f) * 230.0f) + spF4.x; + spDC.y = ((Rand_ZeroOne() - 0.2f) * 200.0f) + spF4.y; + spDC.z = ((Rand_ZeroOne() - 0.5f) * 230.0f) + spF4.z; + + spD0.x = temp_f20 * 7.0f; + spD0.y = -7.0f; + spD0.z = temp_f24 * 7.0f; + + spC4.x = temp_f20 * -0.07f; + spC4.y = 0.24f; + spC4.z = temp_f24 * -0.07f; + + func_800B12F0(globalCtx, &spDC, &spD0, &spC4, (s32)(Rand_ZeroOne() * 800.0f) + 1000, -49, 20); + + spDC.x = ((Rand_ZeroOne() - 0.5f) * 160.0f) + spF4.x; + spDC.y = ((Rand_ZeroOne() - 0.2f) * 140.0f) + spF4.y; + spDC.z = ((Rand_ZeroOne() - 0.5f) * 160.0f) + spF4.z; + + spD0.x = temp_f20 * 15.0f; + spD0.y = 0.0f; + spD0.z = temp_f24 * 15.0f; + + spC4.x = temp_f20 * -0.09f; + spC4.y = 0.3f; + spC4.z = temp_f24 * -0.09f; + + func_800B12F0(globalCtx, &spDC, &spD0, &spC4, (s32)(Rand_ZeroOne() * 100.0f) + 40, + (s32)(Rand_ZeroOne() * 200.0f) + 20, 10); + } +} + +void func_80A54600(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, f32 arg3) { + static f32 D_80A55D60[] = { 3.0f, 5.0f, 9.0f, 18.0f }; + static s8 D_80A55D70 = 0; + Vec3f spCC; + Vec3f spC0; + s32 i; + f32 spA0; + s16 temp_s0; + s16 temp_s1; + s32 phi_v0; + s16 phi_v1; + f32 temp; + + for (i = 0; i < 2; i++) { + spCC.x = (Rand_ZeroOne() - 0.5f) * 11.0f; + spCC.y = (Rand_ZeroOne() - 0.2f) * 8.0f; + spCC.z = (Rand_ZeroOne() - 0.5f) * 11.0f; + + spC0.x = ((Rand_ZeroOne() - 0.5f) * 5.0f) + (spCC.x * 1.4f); + spC0.y = (Rand_ZeroOne() * 13.0f) + 8.2f + (arg2 * -0.38f); + spC0.z = ((Rand_ZeroOne() - 0.5f) * 5.0f) + (spCC.z * 1.4f); + + spCC.x += arg1->x; + spCC.y += arg1->y; + spCC.z += arg1->z; + + temp = D_80A55D60[D_80A55D70] * arg3; + phi_v1 = (D_80A55D70 * -90) - 350; + D_80A55D70++; + D_80A55D70 &= 3; + + if (temp <= 1.0f) { + phi_v0 = 1; + } else { + phi_v0 = temp; + } + + EffectSsKakera_Spawn(globalCtx, &spCC, &spC0, &spCC, phi_v1, 33, 15, 0, 0, phi_v0, 1, 0, 70, -1, OBJECT_BOMBIWA, + object_bombiwa_DL_0009E0); + + spCC.x += (Rand_ZeroOne() - 0.5f) * 270.0f; + spCC.y += (Rand_ZeroOne() - 0.1f) * 150.0f; + spCC.z += (Rand_ZeroOne() - 0.5f) * 270.0f; + + temp_s0 = (Rand_ZeroOne() * 160.0f) + 140.0f; + temp_s1 = (Rand_ZeroOne() * 180.0f) + 120.0f; + func_800B1210(globalCtx, &spCC, &gZeroVec3f, &D_80A55D2C, temp_s0, temp_s1); + } +} + +void func_80A54980(ObjHugebombiwa* this, GlobalContext* globalCtx, s32 arg2) { + s32 pad[2]; + s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + + Quake_SetSpeed(quake, 0x4E20); + Quake_SetQuakeValues(quake, arg2, 0, 0, 0); + Quake_SetCountdown(quake, 7); + func_8013ECE0(this->actor.xyzDistToPlayerSq, 255, 20, 150); +} + +s32 func_80A54A0C(ObjHugebombiwa* this) { + static f32 D_80A55D74[] = { 62500.0f, 108900.0f }; + s32 sp2C; + Actor* ac; + s32 params; + Vec3f sp20; + + if ((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000)) { + ac = this->collider.base.ac; + params = ENHUGEBOMBIWA_GET_100(&this->actor); + + sp20.x = this->actor.world.pos.x; + sp20.y = this->actor.world.pos.y + 50.0f; + sp20.z = this->actor.world.pos.z; + if (ac != NULL) { + if (Math3D_Vec3fDistSq(&sp20, &ac->world.pos) < D_80A55D74[params]) { + return true; + } + } + } + return false; +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 3700, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 900, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 900, ICHAIN_STOP), }; -#endif +void ObjHugebombiwa_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjHugebombiwa* this = THIS; -extern ColliderCylinderInit D_80A55D00; -extern InitChainEntry D_80A55D7C[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitCylinder(globalCtx, &this->collider); -extern UNK_TYPE D_060009E0; -extern UNK_TYPE D_06001820; -extern UNK_TYPE D_06001990; -extern UNK_TYPE D_06002F60; + if (Flags_GetSwitch(globalCtx, ENHUGEBOMBIWA_GET_7F(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A53BE0.s") + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + if ((ENHUGEBOMBIWA_GET_100(&this->actor)) == 1) { + this->actor.draw = func_80A55B34; + Actor_SetScale(&this->actor, 0.74f); + this->collider.dim.radius = 204; + this->collider.dim.height = 230; + } else { + Actor_SetScale(&this->actor, 0.067f); + this->collider.dim.radius = 120; + this->collider.dim.height = 151; + } + func_80A54BF0(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A53E60.s") +void ObjHugebombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyCylinder(globalCtx, &THIS->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A541F4.s") +void func_80A54BF0(ObjHugebombiwa* this) { + this->actionFunc = func_80A54C04; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54600.s") +void func_80A54C04(ObjHugebombiwa* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54980.s") + if (this->collider.base.acFlags & AC_HIT) { + this->unk_4B3 = 5; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54A0C.s") + if (func_80A54A0C(this)) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + func_80A54CD8(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/ObjHugebombiwa_Init.s") + this->collider.base.acFlags &= ~AC_HIT; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/ObjHugebombiwa_Destroy.s") + if (this->unk_4B3 > 0) { + this->unk_4B3--; + if (this->unk_4B3 == 0) { + this->collider.base.colType = COLTYPE_HARD; + } else { + this->collider.base.colType = COLTYPE_NONE; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54BF0.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54C04.s") +void func_80A54CD8(ObjHugebombiwa* this) { + this->actionFunc = func_80A54CEC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54CD8.s") +void func_80A54CEC(ObjHugebombiwa* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54CEC.s") + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + Flags_SetSwitch(globalCtx, ENHUGEBOMBIWA_GET_7F(&this->actor)); + if (!(ENHUGEBOMBIWA_GET_100(&this->actor)) && + ((globalCtx->sceneNum == SCENE_17SETUGEN) || (globalCtx->sceneNum == SCENE_17SETUGEN2))) { + gSaveContext.weekEventReg[19] |= 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A54E10.s") + if (!(ENHUGEBOMBIWA_GET_100(&this->actor))) { + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 80, NA_SE_EV_WALL_BROKEN); + } else { + Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 80, NA_SE_EV_SNOWBALL_BROKEN); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A55064.s") + if (!(ENHUGEBOMBIWA_GET_100(&this->actor))) { + func_80A53BE0(globalCtx, &this->actor.world.pos); + func_80A54E10(this); + } else { + func_80A541F4(this, globalCtx); + func_80A55310(this); + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A55310.s") +void func_80A54E10(ObjHugebombiwa* this) { + s32 i; + EnHugebombiwaStruct* ptr; + f32 temp_f20; + f32 temp_f20_2; + s16 phi_s2; + s32 pad; + Vec3f sp84; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A55564.s") + Matrix_StatePush(); + Matrix_RotateY(this->actor.shape.rot.y, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/ObjHugebombiwa_Update.s") + for (i = 0, phi_s2 = 0x1000; i < 20; i++, phi_s2 += 0x4000) { + ptr = &this->unk_190[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/ObjHugebombiwa_Draw.s") + temp_f20 = (Rand_ZeroOne() * 0.06f) + 0.013f; + ptr->unk_00.x = ((Rand_ZeroOne() * 0.6f) + 0.6f) * temp_f20; + ptr->unk_00.y = ((Rand_ZeroOne() * 0.6f) + 0.4f) * temp_f20; + ptr->unk_00.z = ((Rand_ZeroOne() * 0.6f) + 0.6f) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hugebombiwa/func_80A55B34.s") + temp_f20_2 = (Rand_ZeroOne() * 55.0f) + 47.0f; + sp84.x = Math_SinS(phi_s2) * temp_f20_2; + sp84.y = (i + 1) * 10.0f; + sp84.z = fabsf(Math_CosS(phi_s2)) * temp_f20_2; + + Matrix_MultiplyVector3fByState(&sp84, &ptr->unk_0C); + + ptr->unk_0C.x += this->actor.world.pos.x; + ptr->unk_0C.y += this->actor.world.pos.y; + ptr->unk_0C.z += this->actor.world.pos.z; + + ptr->unk_18 = (i * 1.04f) + 2.4f; + ptr->unk_1C.x = phi_s2; + ptr->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr->unk_1C.z = 0; + ptr->unk_22 = Rand_ZeroFloat(5000.0f); + ptr->unk_24 = 0; + } + + this->unk_4B0 = 0; + this->unk_4B2 = 100; + Matrix_StatePop(); + this->actionFunc = func_80A55064; +} + +void func_80A55064(ObjHugebombiwa* this, GlobalContext* globalCtx) { + s32 i; + s32 pad; + Vec3f spA4; + s32 pad2; + CollisionPoly* sp9C; + s32 sp98; + f32 temp_f0; + EnHugebombiwaStruct* ptr; + s16 phi_s3 = this->actor.shape.rot.y - 0x4000; + + for (i = 0; i < ARRAY_COUNT(this->unk_190); i++, phi_s3 += 0x666) { + ptr = &this->unk_190[i]; + if (ptr->unk_24 != 0) { + continue; + } + + ptr->unk_18 -= 3.0f; + if (ptr->unk_18 < -30.0f) { + ptr->unk_18 = -30.0f; + } + + ptr->unk_0C.x += Math_SinS(phi_s3) * 4.0f; + ptr->unk_0C.y += ptr->unk_18; + ptr->unk_0C.z += Math_CosS(phi_s3) * 4.0f; + + ptr->unk_1C.x += ptr->unk_22; + + spA4.x = ptr->unk_0C.x; + spA4.y = ptr->unk_0C.y + 60.0f; + spA4.z = ptr->unk_0C.z; + + temp_f0 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp9C, &sp98, &this->actor, &spA4); + if ((temp_f0 <= BGCHECK_Y_MIN + 10.0f) || ((ptr->unk_0C.y - (350.0f * ptr->unk_00.y)) < temp_f0)) { + this->unk_4B0++; + ptr->unk_24 = 1; + func_80A53E60(globalCtx, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 9.8f); + if ((globalCtx->gameplayFrames % 4) == 0) { + func_80A54980(this, globalCtx, (s32)(Rand_ZeroOne() * 5.5f) + 1); + } + } + } + + this->unk_4B2--; + if ((this->unk_4B0 >= 20) || (this->unk_4B2 <= 0)) { + ActorCutscene_Stop(this->actor.cutscene); + Actor_MarkForDeath(&this->actor); + } +} + +void func_80A55310(ObjHugebombiwa* this) { + s32 i; + EnHugebombiwaStruct* ptr; + s32 pad; + f32 temp_f20; + f32 temp_f20_2; + s16 phi_s2; + Vec3f sp84; + + Matrix_StatePush(); + Matrix_RotateY(this->actor.shape.rot.y, 0); + + for (i = 0, phi_s2 = 0x1000; i < ARRAY_COUNT(this->unk_190); i++, phi_s2 += 0x4000) { + ptr = &this->unk_190[i]; + + temp_f20 = (Rand_ZeroOne() * 0.09f) + 0.016f; + ptr->unk_00.x = ((Rand_ZeroOne() * 0.1f) + 0.95f) * temp_f20; + ptr->unk_00.y = ((Rand_ZeroOne() * 0.1f) + 0.95f) * temp_f20; + ptr->unk_00.z = ((Rand_ZeroOne() * 0.1f) + 0.95f) * temp_f20; + + temp_f20_2 = (Rand_ZeroOne() * 85.0f) + 77.0f; + sp84.x = Math_SinS(phi_s2) * temp_f20_2; + sp84.y = (i + 1) * 14.0f; + sp84.z = fabsf(Math_CosS(phi_s2)) * temp_f20_2; + Matrix_MultiplyVector3fByState(&sp84, &ptr->unk_0C); + + ptr->unk_0C.x += this->actor.world.pos.x; + ptr->unk_0C.y += this->actor.world.pos.y; + ptr->unk_0C.z += this->actor.world.pos.z; + + ptr->unk_18 = (i * 1.04f) + 2.4f; + + ptr->unk_1C.x = phi_s2; + ptr->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr->unk_1C.z = 0; + + ptr->unk_22 = Rand_ZeroFloat(5000.0f); + ptr->unk_24 = 0; + } + + this->unk_4B0 = 0; + this->unk_4B2 = 100; + Matrix_StatePop(); + this->actionFunc = func_80A55564; +} + +void func_80A55564(ObjHugebombiwa* this, GlobalContext* globalCtx) { + s32 i; + EnHugebombiwaStruct* ptr; + Vec3f spA4; + s32 pad; + CollisionPoly* sp9C; + s32 sp98; + f32 temp_f0; + s16 phi_s3 = this->actor.shape.rot.y - 0x4000; + + for (i = 0; i < ARRAY_COUNT(this->unk_190); i++, phi_s3 += 0x666) { + ptr = &this->unk_190[i]; + + if (ptr->unk_24 != 0) { + continue; + } + + ptr->unk_18 -= 3.0f; + if (ptr->unk_18 < -30.0f) { + ptr->unk_18 = -30.0f; + } + + ptr->unk_0C.x += (Math_SinS(phi_s3) * 4.0f); + ptr->unk_0C.y += ptr->unk_18; + ptr->unk_0C.z += (Math_CosS(phi_s3) * 4.0f); + + ptr->unk_1C.x += ptr->unk_22; + + spA4.x = ptr->unk_0C.x; + spA4.y = ptr->unk_0C.y + 60.0f; + spA4.z = ptr->unk_0C.z; + + temp_f0 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp9C, &sp98, &this->actor, &spA4); + if ((temp_f0 <= BGCHECK_Y_MIN + 10.0f) || (ptr->unk_0C.y < temp_f0)) { + this->unk_4B0++; + ptr->unk_24 = 1; + func_80A54600(globalCtx, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 10.1f); + if ((globalCtx->gameplayFrames % 4) == 0) { + func_80A54980(this, globalCtx, (s32)(Rand_ZeroOne() * 5.5f) + 1); + } + } + } + + this->unk_4B2--; + if ((this->unk_4B0 >= 20) || (this->unk_4B2 <= 0)) { + ActorCutscene_Stop(this->actor.cutscene); + Actor_MarkForDeath(&this->actor); + } +} + +void ObjHugebombiwa_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjHugebombiwa* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void ObjHugebombiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHugebombiwa* this = THIS; + s32 pad[8]; + f32 sp38; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((this->actionFunc == func_80A54C04) || (this->actionFunc == func_80A54CEC)) { + if (this->actor.projectedPos.z <= 4300.0f) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0xFF, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, object_bombiwa_DL_002F60); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_003110); + + } else if (this->actor.projectedPos.z < 4500.0f) { + sp38 = (4500.0f - this->actor.projectedPos.z) * 1.275f; + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, 255, (s32)sp38); + gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_002F60); + } + } else { + s32 i; + EnHugebombiwaStruct* ptr; + Gfx* gfx = POLY_OPA_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + + for (i = 0; i < ARRAY_COUNT(this->unk_190); i++) { + ptr = &this->unk_190[i]; + + if (ptr->unk_24 == 0) { + Matrix_SetStateRotationAndTranslation(ptr->unk_0C.x, ptr->unk_0C.y, ptr->unk_0C.z, &ptr->unk_1C); + Matrix_Scale(ptr->unk_00.x, ptr->unk_00.x, ptr->unk_00.x, MTXMODE_APPLY); + + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, object_bombiwa_DL_001990); + } + } + + POLY_OPA_DISP = gfx; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A55B34(Actor* thisx, GlobalContext* globalCtx) { + ObjHugebombiwa* this = THIS; + s32 i; + Gfx* gfx; + EnHugebombiwaStruct* ptr; + + if ((this->actionFunc == func_80A54C04) || (this->actionFunc == func_80A54CEC)) { + Gfx_DrawDListOpa(globalCtx, object_bombiwa_DL_001820); + return; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_OPA_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + + for (i = 0; i < ARRAY_COUNT(this->unk_190); i++) { + ptr = &this->unk_190[i]; + + if (ptr->unk_24 != 0) { + continue; + } + + Matrix_SetStateRotationAndTranslation(ptr->unk_0C.x, ptr->unk_0C.y + (325.0f * ptr->unk_00.y), ptr->unk_0C.z, + &ptr->unk_1C); + Matrix_Scale(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -325.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, object_bombiwa_DL_0009E0); + } + + POLY_OPA_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.h b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.h index b85add2efa..f1d26aaf4b 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.h +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.h @@ -7,9 +7,25 @@ struct ObjHugebombiwa; typedef void (*ObjHugebombiwaActionFunc)(struct ObjHugebombiwa*, GlobalContext*); +#define ENHUGEBOMBIWA_GET_7F(thisx) ((thisx)->params & 0x7F) +#define ENHUGEBOMBIWA_GET_100(thisx) (((thisx)->params >> 8) & 1) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ f32 unk_18; + /* 0x1C */ Vec3s unk_1C; + /* 0x22 */ s16 unk_22; + /* 0x24 */ s16 unk_24; +} EnHugebombiwaStruct; // size = 0x28 + typedef struct ObjHugebombiwa { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x370]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ EnHugebombiwaStruct unk_190[20]; + /* 0x04B0 */ s16 unk_4B0; + /* 0x04B2 */ s8 unk_4B2; + /* 0x04B3 */ s8 unk_4B3; /* 0x04B4 */ ObjHugebombiwaActionFunc actionFunc; } ObjHugebombiwa; // size = 0x4B8 diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c index f623ca4f88..0c4f8f63e1 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -193,8 +193,8 @@ void func_80A2339C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, f32 arg3, s3 void func_80A23690(ObjIceblock* this) { this->dyna.actor.velocity.y += this->dyna.actor.gravity; - if (this->dyna.actor.velocity.y < this->dyna.actor.minVelocityY) { - this->dyna.actor.velocity.y = this->dyna.actor.minVelocityY; + if (this->dyna.actor.velocity.y < this->dyna.actor.terminalVelocity) { + this->dyna.actor.velocity.y = this->dyna.actor.terminalVelocity; } this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; } @@ -893,9 +893,12 @@ void func_80A25440(ObjIceblock* this) { } static InitChainEntry sInitChain[] = { - ICHAIN_F32_DIV1000(speedXZ, 16000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1800, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -26000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(speedXZ, 16000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -1800, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -26000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; @@ -1093,13 +1096,13 @@ void func_80A25BBC(ObjIceblock* this, GlobalContext* globalCtx) { func_80A23690(this); if (func_80A23F90(this, globalCtx)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } if (func_80A24954(this, globalCtx)) { func_80A2491C(this); if (this->unk_2B0 == 3) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_DIVE_INTO_WATER_L); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DIVE_INTO_WATER_L); } } } @@ -1172,7 +1175,7 @@ void func_80A25E50(ObjIceblock* this, GlobalContext* globalCtx) { func_80A25BA0(this); } else if (sp38) { if (func_80A24118(this, globalCtx, 59.9f, &sp28)) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } func_80A2541C(this, globalCtx); func_80A25CF4(this); @@ -1201,7 +1204,7 @@ void func_80A25FD4(ObjIceblock* this, GlobalContext* globalCtx) { if (sp2C == -1) { sp30 = false; } else if (!(this->unk_1B0 & 2) && (this->unk_26E[sp2C] >= 11) && !func_80A24118(this, globalCtx, 2.0f, &sp20) && - !func_801233E4(globalCtx)) { + !Player_InCsMode(&globalCtx->state)) { func_80A23370(this, sp2C); func_80A260E8(this); sp30 = false; @@ -1259,7 +1262,7 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { func_80A23B88(this); func_80A25BA0(this); } else if (sp28) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); func_80A23B88(this); func_80A25FA0(this); } else { @@ -1495,7 +1498,7 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { } func_80A25440(this); - Actor_SetHeight(&this->dyna.actor, this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y); + Actor_SetFocus(&this->dyna.actor, this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y); this->unk_1B0 &= ~0x2; if (parent) {} @@ -1505,10 +1508,10 @@ void func_80A26B64(ObjIceblock* this, GlobalContext* globalCtx) { } void func_80A26B74(ObjIceblock* this, GlobalContext* globalCtx) { - func_800BE03C(globalCtx, object_ice_block_DL_0001A0); + Gfx_DrawDListXlu(globalCtx, object_ice_block_DL_0001A0); if (OBJICEBLOCK_GET_1(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_ice_block_Matanimheader_0009D0)); - func_800BE03C(globalCtx, object_ice_block_DL_0007F0); + Gfx_DrawDListXlu(globalCtx, object_ice_block_DL_0007F0); } } diff --git a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c index e855487587..4334659864 100644 --- a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c +++ b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c @@ -15,7 +15,6 @@ void ObjJgGakki_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjJgGakki_Update(Actor* thisx, GlobalContext* globalCtx); void ObjJgGakki_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Jg_Gakki_InitVars = { ACTOR_OBJ_JG_GAKKI, ACTORCAT_PROP, @@ -28,14 +27,42 @@ const ActorInit Obj_Jg_Gakki_InitVars = { (ActorFunc)ObjJgGakki_Draw, }; -#endif +extern AnimationHeader D_0601B1E8; // gGoronElderDrumAnim +extern SkeletonHeader D_0601B210; // gGoronElderDrumSkel -extern UNK_TYPE D_0601B1E8; +void ObjJgGakki_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjJgGakki* this = THIS; + f32 frameCount = Animation_GetLastFrame(&D_0601B1E8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jg_Gakki/ObjJgGakki_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &D_0601B210, NULL, NULL, NULL, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jg_Gakki/ObjJgGakki_Destroy.s") + if (((globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7)) && + (globalCtx->csCtx.unk_12 == 0)) { + Animation_Change(&this->skelAnime, &D_0601B1E8, 1.0f, frameCount, frameCount, 2, 0.0f); + } else if ((globalCtx->sceneNum == SCENE_17SETUGEN) || (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA)) { + Animation_Change(&this->skelAnime, &D_0601B1E8, 1.0f, 0.0f, frameCount, 2, 0.0f); + } else { + Actor_MarkForDeath(&this->actor); + } + Actor_SetScale(&this->actor, 0.01f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jg_Gakki/ObjJgGakki_Update.s") +void ObjJgGakki_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjJgGakki* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Jg_Gakki/ObjJgGakki_Draw.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void ObjJgGakki_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjJgGakki* this = THIS; + + SkelAnime_Update(&this->skelAnime); +} + +void ObjJgGakki_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjJgGakki* this = THIS; + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.h b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.h index 75a02ed4aa..a3e8ae8eb8 100644 --- a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.h +++ b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.h @@ -7,7 +7,8 @@ struct ObjJgGakki; typedef struct ObjJgGakki { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x90]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ ColliderCylinder collider; } ObjJgGakki; // size = 0x1D4 extern const ActorInit Obj_Jg_Gakki_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c b/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c index 65a39be35b..6782e15ebe 100644 --- a/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c +++ b/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.c @@ -57,5 +57,5 @@ void ObjKepnKoya_Update(Actor* thisx, GlobalContext* globalCtx) { } void ObjKepnKoya_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06003478); + Gfx_DrawDListOpa(globalCtx, D_06003478); } diff --git a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c index 204b506630..8558127c8a 100644 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c @@ -5,6 +5,8 @@ */ #include "z_obj_kibako.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "objects/object_kibako/object_kibako.h" #define FLAGS 0x04000010 @@ -66,18 +68,15 @@ static ColliderCylinderInit sCylinderInit = { { 15, 30, 0, { 0, 0, 0 } }, }; -extern Gfx D_06001A70[]; -extern Gfx D_06001180[]; - static s16 sObjectIdList[] = { GAMEPLAY_DANGEON_KEEP, OBJECT_KIBAKO }; -static Gfx* sKakeraDisplayLists[] = { D_05007980, D_06001A70 }; +static Gfx* sKakeraDisplayLists[] = { gameplay_dangeon_keep_DL_007980, gSmallCrateFragmentDL }; -static Gfx* sDisplayLists[] = { D_05007890, D_06001180 }; +static Gfx* sDisplayLists[] = { gameplay_dangeon_keep_DL_007890, gSmallCrateDL }; static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -1500, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -18000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -18000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 60, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 60, ICHAIN_STOP), }; @@ -97,7 +96,7 @@ void ObjKibako_SpawnCollectible(ObjKibako* this, GlobalContext* globalCtx) { void ObjKibako_SetShadow(ObjKibako* this) { if ((this->actor.projectedPos.z < 370.0f) && (this->actor.projectedPos.z > -10.0f)) { - this->actor.shape.shadowDraw = func_800B4024; + this->actor.shape.shadowDraw = ActorShadow_DrawSquare; this->actor.shape.shadowScale = 1.4f; this->actor.shape.shadowAlpha = (this->actor.projectedPos.z < 200.0f) ? 100 : (400 - ((s32)this->actor.projectedPos.z)) >> 1; @@ -121,8 +120,8 @@ void func_80926318(ObjKibako* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer < 100.0f) { angle = this->actor.yawTowardsPlayer - GET_PLAYER(globalCtx)->actor.world.rot.y; - if (ABS_ALT(angle) >= 0x5556) { - func_800B8A1C(&this->actor, globalCtx, GI_NONE, 36.0f, 30.0f); + if (ABS_ALT(angle) > 0x5555) { + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 36.0f, 30.0f); } } } @@ -252,7 +251,7 @@ void func_80926B40(ObjKibako* this) { } void func_80926B54(ObjKibako* this, GlobalContext* globalCtx) { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.draw = ObjKibako_Draw; @@ -276,7 +275,10 @@ void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx) { if (func_800A817C(KIBAKO_COLLECTIBLE_ID(&this->actor))) { ObjKibako_SpawnCollectible(this, globalCtx); } - func_800B8E58(&this->actor, NA_SE_PL_PULL_UP_WOODBOX); + + //! @bug: This function should only pass Player*: it uses *(this + 0x153), which is meant to be + //! player->currentMask, but in this case is garbage in the collider + func_800B8E58((Player*)this, NA_SE_PL_PULL_UP_WOODBOX); } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 19.0f)) { ObjKibako_WaterBreak(this, globalCtx); ObjKibako_SpawnCollectible(this, globalCtx); @@ -289,7 +291,7 @@ void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx) { Audio_PlaySoundAtPosition(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); Actor_MarkForDeath(&this->actor); } else { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); func_809262BC(this); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); @@ -341,9 +343,9 @@ void ObjKibako_Held(ObjKibako* this, GlobalContext* globalCtx) { if (fabsf(this->actor.speedXZ) < 0.1f) { ObjKibako_SetupIdle(this); this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_PUT_DOWN_WOODBOX); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PUT_DOWN_WOODBOX); } else { - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); ObjKibako_SetupThrown(this); this->actor.flags &= ~0x4000000; } @@ -398,7 +400,7 @@ void ObjKibako_Thrown(ObjKibako* this, GlobalContext* globalCtx) { if (this->actor.velocity.y < -0.05f) { this->actor.gravity = -2.3f; } - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Math_StepToS(&D_80927384, D_80927380, 0xA0); Math_StepToS(&D_8092738C, D_80927388, 0xA0); this->actor.shape.rot.x = (s16)(this->actor.shape.rot.x + D_80927384); @@ -419,5 +421,5 @@ void ObjKibako_Update(Actor* thisx, GlobalContext* globalCtx) { } void ObjKibako_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, sDisplayLists[KIBAKO_BANK_INDEX(thisx)]); + Gfx_DrawDListOpa(globalCtx, sDisplayLists[KIBAKO_BANK_INDEX(thisx)]); } diff --git a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c index 69bfaad18c..478dd0cf70 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c @@ -5,6 +5,7 @@ */ #include "z_obj_kibako2.h" +#include "objects/object_kibako2/object_kibako2.h" #include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" #define FLAGS 0x00000000 @@ -57,10 +58,6 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -extern Gfx D_06000960[]; -extern CollisionHeader D_06000B70; -extern Gfx D_06001040[]; - s32 ObjKibako2_ContainsSkulltula(ObjKibako2* this, GlobalContext* globalCtx) { s32 actorSpawnParam = KIBAKO2_SKULLTULA_SPAWN_PARAM(&this->dyna.actor); s32 flag = -1; @@ -68,7 +65,7 @@ s32 ObjKibako2_ContainsSkulltula(ObjKibako2* this, GlobalContext* globalCtx) { if ((u16)actorSpawnParam & 3) { flag = ((actorSpawnParam & 0x3FC) >> 2) & 0xFF; } - return !(flag >= 0 && Actor_GetChestFlag(globalCtx, flag)); + return !(flag >= 0 && Flags_GetTreasure(globalCtx, flag)); } void ObjKibako2_Break(ObjKibako2* this, GlobalContext* globalCtx) { @@ -103,7 +100,7 @@ void ObjKibako2_Break(ObjKibako2* this, GlobalContext* globalCtx) { phi_s0 = 0x20; } EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -200, phi_s0, 28, 2, 0, (Rand_ZeroOne() * 30.0f) + 5.0f, - 0, 0, 70, KAKERA_COLOR_NONE, OBJECT_KIBAKO2, D_06001040); + 0, 0, 70, KAKERA_COLOR_NONE, OBJECT_KIBAKO2, gLargeCrateFragment1DL); } func_800BBFB0(globalCtx, thisPos, 90.0f, 6, 100, 160, 1); } @@ -147,12 +144,12 @@ void ObjKibako2_SpawnContents(ObjKibako2* this, GlobalContext* globalCtx) { void ObjKibako2_Init(Actor* thisx, GlobalContext* globalCtx) { ObjKibako2* this = THIS; s32 pad; - ObjKibako2Contents contents = KIBAKO2_CONTENTS(&this->dyna.actor); + s32 contents = KIBAKO2_CONTENTS(&this->dyna.actor); DynaPolyActor_Init(&this->dyna, 0); Collider_InitCylinder(globalCtx, &this->collider); Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &D_06000B70); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gLargeCrateCol); Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); this->dyna.actor.home.rot.z = 0; @@ -236,7 +233,7 @@ void ObjKibako2_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->skulltulaNoiseTimer >= 0) { if (this->skulltulaNoiseTimer == 0) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_STALGOLD_ROLL); if (Rand_ZeroOne() < 0.1f) { this->skulltulaNoiseTimer = Rand_S16Offset(40, 80); } else { @@ -250,5 +247,5 @@ void ObjKibako2_Update(Actor* thisx, GlobalContext* globalCtx) { } void ObjKibako2_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000960); + Gfx_DrawDListOpa(globalCtx, gLargeCrateDL); } diff --git a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.h b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.h index b6de7da89c..dd4687ab21 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.h +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.h @@ -18,11 +18,11 @@ struct ObjKibako2; typedef void (*ObjKibako2ActionFunc)(struct ObjKibako2*, GlobalContext*); typedef struct ObjKibako2 { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ ObjKibako2ActionFunc actionFunc; - /* 0x01AC */ s8 unk_1AC; - /* 0x01AD */ s8 skulltulaNoiseTimer; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ ObjKibako2ActionFunc actionFunc; + /* 0x1AC */ s8 unk_1AC; + /* 0x1AD */ s8 skulltulaNoiseTimer; } ObjKibako2; // size = 0x1B0 extern const ActorInit Obj_Kibako2_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c index c6fd52f13d..481cc22f6a 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c @@ -31,7 +31,7 @@ const ActorInit Obj_Lift_InitVars = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_8093DD84[] = { ICHAIN_F32_DIV1000(gravity, -600, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -15000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -15000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 350, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 350, ICHAIN_STOP), diff --git a/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c b/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c index 9f4b8c2b0d..185361c41b 100644 --- a/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c +++ b/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c @@ -148,7 +148,7 @@ void func_80AF3B8C(ObjLightblock* this) { void func_80AF3BA0(ObjLightblock* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - Actor_SetSwitchFlag(globalCtx, LIGHTBLOCK_DESTROYED(&this->dyna.actor)); + Flags_SetSwitch(globalCtx, LIGHTBLOCK_DESTROYED(&this->dyna.actor)); func_80AF3910(this, globalCtx); func_80AF3C18(this); } else { diff --git a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c index eab5d8f1cf..3d8b8d307d 100644 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -106,9 +106,9 @@ void ObjLightswitch_UpdateSwitchFlags(ObjLightswitch* this, GlobalContext* globa if (this) {} if (set) { - Actor_SetSwitchFlag(globalCtx, GET_LIGHTSWITCH_SWITCHFLAG(this)); + Flags_SetSwitch(globalCtx, GET_LIGHTSWITCH_SWITCHFLAG(this)); } else { - Actor_UnsetSwitchFlag(globalCtx, GET_LIGHTSWITCH_SWITCHFLAG(this)); + Flags_UnsetSwitch(globalCtx, GET_LIGHTSWITCH_SWITCHFLAG(this)); } } @@ -159,7 +159,7 @@ void ObjLightswitch_Init(Actor* thisx, GlobalContext* globalCtx) { isSwitchActivated = Flags_GetSwitch(globalCtx, GET_LIGHTSWITCH_SWITCHFLAG(this)); isTriggered = false; Actor_ProcessInitChain(&this->actor, sInitChain); - Actor_SetHeight(&this->actor, 0.0f); + Actor_SetFocus(&this->actor, 0.0f); if (isSwitchActivated) { if (GET_LIGHTSWITCH_TYPE(this) == LIGHTSWITCH_TYPE_FAKE) { @@ -237,7 +237,7 @@ void ObjLightSwitch_SetupAsleep(ObjLightswitch* this) { void ObjLightSwitch_Asleep(ObjLightswitch* this, GlobalContext* globalCtx) { if (this->colorShiftTimer == 0) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_SUN_MARK_FLASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SUN_MARK_FLASH); } this->colorShiftTimer++; @@ -250,7 +250,7 @@ void ObjLightSwitch_Asleep(ObjLightswitch* this, GlobalContext* globalCtx) { ObjLightSwitch_SetupEnabled(this); } else if (this->colorShiftTimer == 15) { this->faceState = LIGHTSWITCH_FACE_WAKING; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FOOT_SWITCH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FOOT_SWITCH); } } @@ -308,7 +308,7 @@ void ObjLightSwitch_Disabled(ObjLightswitch* this, GlobalContext* globalCtx) { ObjLightswitch_SetupIdle(this); } else if (this->colorShiftTimer == 15) { this->faceState = LIGHTSWITCH_FACE_ASLEEP; - Audio_PlayActorSound2(&this->actor, NA_SE_EV_FOOT_SWITCH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FOOT_SWITCH); } } diff --git a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c index e864e86b42..c7f49d683a 100644 --- a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c +++ b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c @@ -43,15 +43,15 @@ void ObjMakeoshihiki_SetSwitchFlags(ObjMakeoshihiki* this, GlobalContext* global switchFlag1 = OBJMAKEOSHIHIKI_GET_SWITCHFLAG_1(this); if (pathIndex & 2) { - Actor_SetSwitchFlag(globalCtx, switchFlag2); + Flags_SetSwitch(globalCtx, switchFlag2); } else { - Actor_UnsetSwitchFlag(globalCtx, switchFlag2); + Flags_UnsetSwitch(globalCtx, switchFlag2); } if (pathIndex & 1) { - Actor_SetSwitchFlag(globalCtx, switchFlag1); + Flags_SetSwitch(globalCtx, switchFlag1); } else { - Actor_UnsetSwitchFlag(globalCtx, switchFlag1); + Flags_UnsetSwitch(globalCtx, switchFlag1); } } diff --git a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c index 5af8763039..9a614c47d2 100644 --- a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c +++ b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c @@ -100,6 +100,6 @@ void ObjMilkBin_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjMilkBin* this = THIS; if (!(this->disableDraw & 1)) { - func_800BDFC0(globalCtx, D_060004B0); + Gfx_DrawDListOpa(globalCtx, D_060004B0); } } diff --git a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c index 153a4a914b..6bacc61642 100644 --- a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c +++ b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c @@ -78,7 +78,7 @@ void func_80C06640(ObjMoonStone* this, GlobalContext* globalCtx) { s16 sp1A = this->actor.yawTowardsPlayer - 0x8000; sp1A -= player->actor.shape.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.colChkInfo.health = 1; func_801518B0(globalCtx, 0x5E3U, &this->actor); func_80C066F8(this); @@ -95,7 +95,7 @@ void func_80C066F8(ObjMoonStone* this) { } void func_80C0670C(ObjMoonStone* this, GlobalContext* globalCtx) { - if (func_800B867C(&this->actor, globalCtx) != 0) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->actor.colChkInfo.health = 0; func_80C0662C(this); } @@ -122,7 +122,7 @@ void func_80C06768(ObjMoonStone* this, GlobalContext* globalCtx) { this->actor.draw = NULL; func_80C0685C(this); } else if (this->actor.xzDistToPlayer < 25.0f) { - func_800B8A1C(&this->actor, globalCtx, GI_MOON_TEAR, 100.0f, 30.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MOON_TEAR, 100.0f, 30.0f); } } } @@ -132,7 +132,7 @@ void func_80C0685C(ObjMoonStone* this) { } void func_80C06870(ObjMoonStone* this, GlobalContext* globalCtx) { - if (func_80152498(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { gSaveContext.weekEventReg[74] |= 0x40; Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c index 0e510d6b31..04fe449916 100644 --- a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c +++ b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c @@ -63,7 +63,7 @@ void func_80C06B5C(ObjMuPict* this) { void func_80C06B70(ObjMuPict* this, GlobalContext* globalCtx) { s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; - if (func_800B84D0(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->actor.cutscene < 0) { func_80C06DC8(this, globalCtx); func_80C06CC4(this); @@ -98,7 +98,7 @@ void func_80C06CC4(ObjMuPict* this) { } void func_80C06CD8(ObjMuPict* this, GlobalContext* globalCtx) { - switch (func_80152498(&globalCtx->msgCtx)) { + switch (Message_GetState(&globalCtx->msgCtx)) { case 0: case 1: case 2: @@ -122,7 +122,7 @@ void func_80C06CD8(ObjMuPict* this, GlobalContext* globalCtx) { } void func_80C06D90(ObjMuPict* this, GlobalContext* globalCtx) { - Actor* actorPtr = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first; + Actor* actorPtr = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (actorPtr != NULL) { if (actorPtr->id == ACTOR_EN_HGO) { diff --git a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c index 041e869826..45bb9ffca9 100644 --- a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c +++ b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c @@ -226,7 +226,7 @@ void ObjRaillift_Update(Actor* thisx, GlobalContext* globalCtx) { f32 step; this->actionFunc(this, globalCtx); - Actor_SetHeight(&this->dyna.actor, 10.0f); + Actor_SetFocus(&this->dyna.actor, 10.0f); if (this->cutsceneTimer > 0) { this->cutsceneTimer--; if (this->cutsceneTimer == 0) { @@ -283,12 +283,12 @@ void ObjRaillift_Draw(Actor* thisx, GlobalContext* globalCtx) { The non-colorful platforms are the ones found in Woodfall Temple */ void ObjRaillift_DrawDekuFlowerPlatform(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_06000208); + Gfx_DrawDListOpa(globalCtx, D_06000208); } /* The colorful platforms are the ones found in Deku Palace */ void ObjRaillift_DrawDekuFlowerPlatformColorful(Actor* thisx, GlobalContext* globalCtx) { - func_800BDFC0(globalCtx, D_060071B8); + Gfx_DrawDListOpa(globalCtx, D_060071B8); } diff --git a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c index e398d3336a..d7f15477a7 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c @@ -18,7 +18,6 @@ void func_80973CD8(ObjRoomtimer* this, GlobalContext* globalCtx); void func_80973D3C(ObjRoomtimer* this, GlobalContext* globalCtx); void func_80973DE0(ObjRoomtimer* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Roomtimer_InitVars = { ACTOR_OBJ_ROOMTIMER, ACTORCAT_ENEMY, @@ -31,16 +30,64 @@ const ActorInit Obj_Roomtimer_InitVars = { (ActorFunc)NULL, }; -#endif +void ObjRoomtimer_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjRoomtimer* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/ObjRoomtimer_Init.s") + this->switchFlag = ROOMTIMER_GET_SWITCHFLAG(thisx); + this->actor.params &= 0x1FF; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/ObjRoomtimer_Destroy.s") + if (this->actor.params != 0x1FF) { + this->actor.params = CLAMP_MAX(this->actor.params, 500); + } + this->actionFunc = func_80973CD8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/func_80973CD8.s") +void ObjRoomtimer_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjRoomtimer* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/func_80973D3C.s") + if (this->actor.params != 0x1FF && gSaveContext.unk_3DD0[4] > 0) { + gSaveContext.unk_3DD0[4] = 5; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/func_80973DE0.s") +void func_80973CD8(ObjRoomtimer* this, GlobalContext* globalCtx) { + if (this->actor.params != 0x1FF) { + func_8010E9F0(4, this->actor.params); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/ObjRoomtimer_Update.s") + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); + this->actionFunc = func_80973D3C; +} + +void func_80973D3C(ObjRoomtimer* this, GlobalContext* globalCtx) { + if (Flags_GetClearTemp(globalCtx, this->actor.room)) { + if (this->actor.params != 0x1FF) { + gSaveContext.unk_3DD0[4] = 5; + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_80973DE0; + } else if (this->actor.params != 0x1FF && gSaveContext.unk_3DD0[4] == 0) { + play_sound(NA_SE_OC_ABYSS); + func_80169EFC(globalCtx); + Actor_MarkForDeath(&this->actor); + } +} + +void func_80973DE0(ObjRoomtimer* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + Flags_SetClear(globalCtx, this->actor.room); + Flags_SetSwitch(globalCtx, this->switchFlag); + if (ActorCutscene_GetLength(this->actor.cutscene) != -1) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } + Actor_MarkForDeath(&this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void ObjRoomtimer_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjRoomtimer* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h index db43c5c16b..b58d5da495 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h @@ -3,6 +3,8 @@ #include "global.h" +#define ROOMTIMER_GET_SWITCHFLAG(thisx) (((thisx)->params >> 9) & 0x7F) + struct ObjRoomtimer; typedef void (*ObjRoomtimerActionFunc)(struct ObjRoomtimer*, GlobalContext*); @@ -10,7 +12,7 @@ typedef void (*ObjRoomtimerActionFunc)(struct ObjRoomtimer*, GlobalContext*); typedef struct ObjRoomtimer { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjRoomtimerActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4]; + /* 0x0148 */ s32 switchFlag; } ObjRoomtimer; // size = 0x14C extern const ActorInit Obj_Roomtimer_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c index 677ab56b98..7bd1dfc1e1 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c @@ -31,7 +31,7 @@ const ActorInit Obj_Skateblock_InitVars = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_80A22AE0[] = { ICHAIN_F32_DIV1000(gravity, -1700, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c index 42cec66230..9eb0ae99f4 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -5,6 +5,8 @@ */ #include "z_obj_snowball.h" +#include "objects/object_goroiwa/object_goroiwa.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000000 @@ -15,7 +17,22 @@ void ObjSnowball_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSnowball_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSnowball_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B02CD0(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B02D58(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B02DB0(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B02E54(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04338(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04350(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04540(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B0457C(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04608(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04648(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B046E4(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B047C0(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04B48(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04B60(ObjSnowball* this, GlobalContext* globalCtx); +void func_80B04D34(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Snowball_InitVars = { ACTOR_OBJ_SNOWBALL, ACTORCAT_PROP, @@ -28,80 +45,799 @@ const ActorInit Obj_Snowball_InitVars = { (ActorFunc)ObjSnowball_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80B04F50[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x81837FBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x81837FBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 73 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B04F74 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, D_80B04F50, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B04FD4[] = { +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ ObjSnowballActionFunc unk_04; +} ObjSnowballStruct2; + +static ObjSnowballStruct2 D_80B04F84[] = { + { -1, 0, func_80B02D58 }, + { ACTOR_EN_JG, 0, func_80B02DB0 }, + { ACTOR_EN_WF, 1, func_80B02E54 }, + { ACTOR_EN_TITE, -4, func_80B02CD0 }, + { ACTOR_EN_KAME, 0, func_80B02CD0 }, + { -1, 0, NULL }, +}; + +static Color_RGBA8 D_80B04FB4 = { 250, 250, 250, 255 }; +static Color_RGBA8 D_80B04FB8 = { 180, 180, 180, 255 }; +static Vec3f D_80B04FBC = { 0.0f, 0.3f, 0.0f }; + +static Gfx* D_80B04FC8[] = { + object_goroiwa_DL_0072F0, + object_goroiwa_DL_0077D0, + object_goroiwa_DL_007C60, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), }; +void func_80B02CD0(ObjSnowball* this, GlobalContext* globalCtx) { + ObjSnowballStruct2* ptr = &D_80B04F84[this->actor.home.rot.y]; + + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ptr->unk_00, this->actor.home.pos.x, + this->actor.home.pos.y, this->actor.home.pos.z, this->actor.home.rot.x, 0, + this->actor.home.rot.z, ptr->unk_02, -1, this->actor.unk20, NULL); +} + +void func_80B02D58(ObjSnowball* this, GlobalContext* globalCtx) { + s32 temp_v0 = func_800A8150(OBJSNOWBALL_GET_3F(&this->actor)); + + if (temp_v0 >= 0) { + Item_DropCollectible(globalCtx, &this->actor.home.pos, (OBJSNOWBALL_GET_7F00(&this->actor) << 8) | temp_v0); + } +} + +void func_80B02DB0(ObjSnowball* this, GlobalContext* globalCtx) { + s32 pad; + ObjSnowballStruct2* ptr = &D_80B04F84[this->actor.home.rot.y]; + + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ptr->unk_00, this->actor.home.pos.x, + this->actor.home.pos.y, this->actor.home.pos.z, this->actor.home.rot.x, 0, + this->actor.home.rot.z, this->actor.params | ptr->unk_02, + ActorCutscene_GetAdditionalCutscene(this->actor.cutscene), this->actor.unk20, NULL); +} + +void func_80B02E54(ObjSnowball* this, GlobalContext* globalCtx) { + ObjSnowballStruct2* ptr = &D_80B04F84[this->actor.home.rot.y]; + + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ptr->unk_00, this->actor.home.pos.x, + this->actor.home.pos.y, this->actor.home.pos.z, this->actor.home.rot.x, 0, + this->actor.home.rot.z, this->actor.params | ptr->unk_02, -1, this->actor.unk20, + NULL); +} + +void func_80B02EE4(ObjSnowball* this, GlobalContext* globalCtx) { + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + Vec3s* hitPos = &this->collider.elements->info.bumper.hitPos; + s32 i; + + for (i = 0; i < 4; i++) { + sp94.x = ((Rand_ZeroOne() * 14.0f) - 7.0f) + hitPos->x; + sp94.y = ((Rand_ZeroOne() * 14.0f) - 7.0f) + hitPos->y; + sp94.z = ((Rand_ZeroOne() * 14.0f) - 7.0f) + hitPos->z; + + spA0.x = (Rand_ZeroOne() - 0.5f) * 1.6f; + spA0.y = -0.8f; + spA0.z = (Rand_ZeroOne() - 0.5f) * 1.6f; + + spAC.x = spA0.x * -0.06f; + spAC.y = spA0.y * -0.06f; + spAC.z = spA0.z * -0.06f; + + func_800B0E48(globalCtx, &sp94, &spA0, &spAC, &D_80B04FB4, &D_80B04FB8, (s32)(Rand_ZeroOne() * 30.0f) + 15, + (s32)(Rand_ZeroOne() * 40.0f) + 30); + } +} + +void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp_f28 = sqrtf(this->unk_20C); + Vec3f spFC; + Vec3f spF0; + Vec3f spE4; + s32 i; + s32 phi_s6; + Gfx* temp_s2; + s16 scale; + s32 temp_s1; + f32 temp_f20; + f32 temp_f22; + f32 temp_f26; + s16 temp_s0; + s32 temp_s7; + f32 phi_f22; + s32 gravity; + s32 phi_s0; + s32 phi_s4; + + for (i = 0, phi_s6 = 0; i < 25; i++, phi_s6 += 0xA3D) { + temp_s7 = i & 7; + if (temp_s7 < 4) { + temp_s2 = D_80B04FC8[2]; + gravity = -280; + phi_s4 = 0; + phi_s0 = 0x40; + phi_f22 = 1.0f; + } else if (temp_s7 < 6) { + temp_s2 = D_80B04FC8[1]; + gravity = -340; + phi_s4 = 0; + phi_f22 = 0.9f; + if (Rand_ZeroOne() < 0.4f) { + phi_s0 = 0x20; + } else { + phi_s0 = 0x40; + } + } else { + temp_s2 = D_80B04FC8[0]; + gravity = -400; + phi_s4 = 1; + phi_f22 = 0.8f; + if (Rand_Next() > 0) { + phi_s0 = 0x21; + } else { + phi_s0 = 0x41; + } + } + + temp_f20 = (Rand_ZeroOne() * (40.0f * this->unk_20C)) + 20.0f; + + spFC.x = Math_SinS((s32)(Rand_ZeroOne() * 2621.44f) + phi_s6) * temp_f20; + spFC.y = (Rand_ZeroOne() - 0.4f) * temp_f20 * 1.6666666f; + spFC.z = Math_CosS((s32)(Rand_ZeroOne() * 2621.44f) + phi_s6) * temp_f20; + + spF0.x = spFC.x * 0.16f * phi_f22; + spF0.y = (Rand_ZeroOne() * 16.0f) + 3.0f; + spF0.z = spFC.z * 0.16f * phi_f22; + + spFC.x += this->actor.world.pos.x; + spFC.y += this->actor.world.pos.y; + spFC.z += this->actor.world.pos.z; + + scale = ((Rand_ZeroOne() * 15.0f) + 30.0f) * this->unk_20C; + + EffectSsKakera_Spawn(globalCtx, &spFC, &spF0, &spFC, gravity, phi_s0, 30, 0, 0, scale, phi_s4, 0, 50, -1, 0xEF, + temp_s2); + if ((this->unk_210 == 0) && (temp_s7 >= 3)) { + spFC.x += (Rand_ZeroOne() * 120.0f) - 60.0f; + spFC.y += Rand_ZeroOne() * 80.0f; + spFC.z += (Rand_ZeroOne() * 120.0f) - 60.0f; + + temp_s0 = (s32)(Rand_ZeroOne() * 50.0f * temp_f28) + 40; + temp_s1 = (s32)(Rand_ZeroOne() * 60.0f * temp_f28) + 50; + func_800B0E48(globalCtx, &spFC, &gZeroVec3f, &D_80B04FBC, &D_80B04FB4, &D_80B04FB8, temp_s0, temp_s1); + } + } + + if (this->unk_210 != 0) { + temp_f26 = this->unk_20C * 60.0f; + + for (i = 0, phi_s6 = 0; i < 16; i++, phi_s6 += 0x1000) { + temp_s0 = (u32)Rand_Next() >> 0x10; + temp_f20 = Math_SinS(temp_s0); + temp_f22 = Math_CosS(temp_s0); + + spFC.x = Math_SinS(phi_s6); + spFC.z = Math_CosS(phi_s6); + + spF0.x = 2.0f * spFC.x; + spF0.y = (2.0f * Rand_ZeroOne()) + 1.0f; + spF0.z = 2.0f * spFC.z; + + spFC.x *= temp_f22 * temp_f26; + spFC.y = temp_f20 * temp_f26; + spFC.z *= temp_f22 * temp_f26; + + spFC.x += this->actor.world.pos.x; + spFC.y += this->actor.world.pos.y; + spFC.z += this->actor.world.pos.z; + + spE4.x = spF0.x * -0.02f; + spE4.y = spF0.y * -0.05f; + spE4.z = spF0.z * -0.02f; + + EffectSsIceSmoke_Spawn(globalCtx, &spFC, &spF0, &spE4, ((s32)(Rand_ZeroOne() * 170.0f) + 150) * temp_f28); + } + } +} + +void func_80B03688(ObjSnowball* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + s32 pad[2]; + f32 temp_f20; + f32 temp_f22 = sqrtf(this->unk_20C); + s16 temp_s3; + s32 phi_s0; + + if (this->unk_210 == 0) { + for (i = 0, phi_s0 = 0; i < 10; i++, phi_s0 += 0x1999) { + temp_f20 = (Rand_ZeroOne() * (45.0f * this->unk_20C)) + 50.0f; + + spB8.x = Math_SinS((s32)(Rand_ZeroOne() * 6553.6f) + phi_s0) * temp_f20; + spB8.y = Rand_ZeroOne() * 20.0f; + spB8.z = Math_CosS((s32)(Rand_ZeroOne() * 6553.6f) + phi_s0) * temp_f20; + + spAC.x = spB8.x * 0.06f; + spAC.y = 0.0f; + spAC.z = spB8.z * 0.06f; + + spA0.x = spAC.x * -0.08f; + spA0.y = 0.3f; + spA0.z = spAC.z * -0.08f; + + spB8.x += this->actor.home.pos.x; + spB8.y += this->actor.home.pos.y; + spB8.z += this->actor.home.pos.z; + + temp_s3 = (s32)(Rand_ZeroOne() * 60.0f * temp_f22) + 70; + + func_800B0E48(globalCtx, &spB8, &spAC, &spA0, &D_80B04FB4, &D_80B04FB8, temp_s3, + (s32)(Rand_ZeroOne() * 70.0f * temp_f22) + 70); + } + } else { + for (i = 0, phi_s0 = 0; i < 18; i++, phi_s0 += 0xE38) { + temp_f20 = (Rand_ZeroOne() * (45.0f * this->unk_20C)) + 50.0f; + + spB8.x = Math_SinS((s32)(Rand_ZeroOne() * 3640.889f) + phi_s0); + spB8.z = Math_CosS((s32)(Rand_ZeroOne() * 3640.889f) + phi_s0); + + spAC.x = spB8.x * 3.0f * temp_f22; + spAC.y = 0.0f; + spAC.z = spB8.z * 3.0f * temp_f22; + + spA0.x = spAC.x * -0.02f; + spA0.y = 0.03f; + spA0.z = spAC.z * -0.02f; + + spB8.x = (spB8.x * temp_f20) + this->actor.home.pos.x; + spB8.y = (Rand_ZeroOne() * 20.0f) + this->actor.home.pos.y; + spB8.z = (spB8.z * temp_f20) + this->actor.home.pos.z; + + EffectSsIceSmoke_Spawn(globalCtx, &spB8, &spAC, &spA0, (s32)(Rand_ZeroOne() * 140.0f * temp_f22) + 100); + } + } +} + +#ifdef NON_MATCHING +void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { + f32 temp_f30 = sqrtf(arg1); + Vec3f spD8; + Vec3f spCC; + s32 i; + Gfx* temp_s1; + f32 temp_f20; + s32 phi_s5; + s32 pad; + s16 phi_s2; + s32 pad2; + s16 phi_s0; + s16 phi_s3; + + for (i = 0, phi_s5 = 0; i < 13; i++, phi_s5 += 0x1999) { + temp_f20 = (Rand_ZeroOne() * (40.0f * arg1)) + 20.0f; + + spD8.x = Math_SinS((s32)(Rand_ZeroOne() * 6553.6f) + phi_s5) * temp_f20; + spD8.y = Rand_ZeroOne() * temp_f20; + spD8.z = Math_CosS((s32)(Rand_ZeroOne() * 6553.6f) + phi_s5) * temp_f20; + + spCC.x = spD8.x * 0.17f; + spCC.y = (Rand_ZeroOne() * 14.0f) + 3.0f; + spCC.z = spD8.z * 0.17f; + + spD8.x += arg2->x; + spD8.y += arg2->y; + spD8.z += arg2->z; + + if ((i & 3) == 0) { + temp_s1 = D_80B04FC8[0]; + phi_s2 = -400; + phi_s3 = 1; + if (Rand_Next() > 0) { + phi_s0 = 0x21; + } else { + phi_s0 = 0x41; + } + } else if ((i & 3) == 1) { + temp_s1 = D_80B04FC8[1]; + phi_s2 = -340; + phi_s3 = 1; + if (Rand_Next() > 0) { + phi_s0 = 0x21; + } else { + phi_s0 = 0x41; + } + } else { + temp_s1 = D_80B04FC8[2]; + phi_s2 = -280; + phi_s3 = 0; + phi_s0 = 0x40; + } + + EffectSsKakera_Spawn(globalCtx, &spD8, &spCC, &spD8, phi_s2, phi_s0, 30, 0, 0, + ((Rand_ZeroOne() * 15.0f) + 25.0f) * arg1, phi_s3, 0, 0x36, -1, 0xEF, temp_s1); + + spD8.x += (Rand_ZeroOne() * 80.0f) - 40.0f; + spD8.y += Rand_ZeroOne() * 55.0f; + spD8.z += (Rand_ZeroOne() * 80.0f) - 40.0f; + + phi_s0 = (s32)(Rand_ZeroOne() * 60.0f * temp_f30) + 60; + + func_800B0E48(globalCtx, &spD8, &gZeroVec3f, &D_80B04FBC, &D_80B04FB4, &D_80B04FB8, phi_s0, + (s32)(Rand_ZeroOne() * 30.0f * temp_f30) + 60); + } +} +#else +void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B03A80.s") #endif -extern ColliderJntSphElementInit D_80B04F50[1]; -extern ColliderJntSphInit D_80B04F74; -extern InitChainEntry D_80B04FD4[]; +void func_80B03E2C(ObjSnowball* this, GlobalContext* globalCtx) { + ObjSnowballStruct* ptr; + s32 i; -extern UNK_TYPE D_060082D0; -extern UNK_TYPE D_06008B90; + this->unk_1A8[0].unk_1C.y = this->actor.yawTowardsPlayer - 0x4000; + this->unk_1A8[0].unk_24 = Rand_ZeroOne() * -600.0f; + this->unk_1A8[1].unk_1C.y = this->actor.yawTowardsPlayer + 0x4000; + this->unk_1A8[1].unk_24 = Rand_ZeroOne() * 600.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B02CD0.s") + for (i = 0; i < ARRAY_COUNT(this->unk_1A8); i++) { + ptr = &this->unk_1A8[i]; + ptr->unk_00.x = this->actor.home.pos.x; + ptr->unk_00.y = this->actor.home.pos.y + (61.0f * this->unk_20C); + ptr->unk_00.z = this->actor.home.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B02D58.s") + ptr->unk_0C = Math_SinS(ptr->unk_1C.y) * (Rand_ZeroOne() + 5.0f); + ptr->unk_10 = (Rand_ZeroOne() * 11.0f) + 20.0f; + ptr->unk_14 = Math_CosS(ptr->unk_1C.y) * (Rand_ZeroOne() + 5.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B02DB0.s") + ptr->unk_1C.x = 0; + ptr->unk_1C.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B02E54.s") + ptr->unk_22 = (s32)(Rand_ZeroOne() * 400.0f) + 1100; + ptr->unk_26 = Rand_ZeroOne() * -600.0f; + ptr->unk_2D = 0; + ptr->unk_2C = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B02EE4.s") +void func_80B03FF8(ObjSnowball* this, GlobalContext* globalCtx) { + s32 pad; + s16 rotY = this->actor.home.rot.y; + ObjSnowballStruct2* sp18 = &D_80B04F84[rotY]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B030F8.s") + if (sp18->unk_04 != NULL) { + sp18->unk_04(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B03688.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SNOWBALL_BROKEN); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B03A80.s") + if (rotY == 5) { + Flags_SetSwitch(globalCtx, OBJSNOWBALL_GET_3F(&this->actor)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B03E2C.s") +void ObjSnowball_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball* this = THIS; + Sphere16* sphere; + ColliderJntSphElementDim* elementDim; + Vec3f sp48; + s32 sp44; + s32 sp40 = this->actor.home.rot.y; + f32 phi_f20; + s32 sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B03FF8.s") + Actor_ProcessInitChain(&this->actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/ObjSnowball_Init.s") + sp34 = sp40 == 1; + if (sp34) { + phi_f20 = 1.5f; + } else { + phi_f20 = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/ObjSnowball_Destroy.s") + Actor_SetScale(&this->actor, 0.1f * phi_f20); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04338.s") + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + this->actor.world.pos.y += 20.0f * phi_f20; + this->actor.uncullZoneScale = 150.0f * phi_f20; + this->actor.uncullZoneDownward = 300.0f * phi_f20; + this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->unk_20C = phi_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04350.s") + if (sp34) { + this->actor.textId = 0x238; + this->actor.flags |= 1; + this->actor.targetArrowOffset = 1400.0f / 3.0f; + Actor_SetFocus(&this->actor, 24.0f); + this->actor.targetMode = 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04540.s") + Collider_InitJntSph(globalCtx, &this->collider); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + this->actor.colChkInfo.mass = MASS_HEAVY; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B0457C.s") + sphere = &this->collider.elements[0].dim.worldSphere; + sphere->center.x = this->actor.world.pos.x; + sphere->center.y = this->actor.world.pos.y; + sphere->center.z = this->actor.world.pos.z; + sphere->radius = + (this->collider.elements[0].dim.scale * this->collider.elements[0].dim.modelSphere.radius) * phi_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04608.s") + sp48.x = this->actor.home.pos.x; + sp48.y = this->actor.home.pos.y + 30.0f; + sp48.z = this->actor.home.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04648.s") + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp44, &this->actor, &sp48); + if (this->actor.floorHeight < (this->actor.home.pos.y - 10.0f)) { + this->actor.floorPoly = NULL; + } else { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 13.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B046E4.s") + func_80B04338(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B047C0.s") + if ((sp40 == 5) && Flags_GetSwitch(globalCtx, OBJSNOWBALL_GET_3F(&this->actor))) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04B48.s") +void ObjSnowball_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04B60.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/ObjSnowball_Update.s") +void func_80B04338(ObjSnowball* this, GlobalContext* globalCtx) { + this->actionFunc = func_80B04350; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/ObjSnowball_Draw.s") +void func_80B04350(ObjSnowball* this, GlobalContext* globalCtx) { + s32 pad; + s32 flag = (this->collider.base.acFlags & AC_HIT) != 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B04D34.s") + if (flag) { + this->collider.base.acFlags &= ~AC_HIT; + } + + if (flag && (this->unk_211 == 0) && + (this->collider.elements->info.acHitInfo->toucher.dmgFlags & + (0x80000000 | 0x4000 | 0x800 | 0x400 | 0x100 | 0x8))) { + this->actor.flags |= 0x10; + if (this->actor.home.rot.y == 1) { + this->actor.flags &= ~(8 | 1); + } + + if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x4000) { + this->unk_20A = 1; + } else { + if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x800) { + this->unk_210 = 1; + } + this->unk_20A = 0; + } + + if (this->actor.cutscene < 0) { + func_80B03FF8(this, globalCtx); + if (this->unk_20A == 0) { + func_80B04608(this, globalCtx); + } else { + func_80B046E4(this, globalCtx); + } + } else { + func_80B04540(this, globalCtx); + } + return; + } + + if (flag && + !(this->collider.elements->info.acHitInfo->toucher.dmgFlags & (0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20))) { + if (this->unk_209 <= 0) { + func_80B02EE4(this, globalCtx); + if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x1000000) { + this->unk_209 = 25; + } else { + this->unk_209 = 10; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_REFLECTION_SNOW); + } + } + + if (this->unk_209 > 0) { + this->unk_209--; + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80B04540(ObjSnowball* this, GlobalContext* globalCtx) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_80B0457C; +} + +void func_80B0457C(ObjSnowball* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + func_80B03FF8(this, globalCtx); + this->unk_20B = 1; + if (this->unk_20A == 0) { + func_80B04608(this, globalCtx); + } else { + func_80B046E4(this, globalCtx); + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80B04608(ObjSnowball* this, GlobalContext* globalCtx) { + func_80B030F8(this, globalCtx); + this->actor.draw = NULL; + this->unk_208 = 50; + this->actor.floorPoly = NULL; + this->actionFunc = func_80B04648; +} + +void func_80B04648(ObjSnowball* this, GlobalContext* globalCtx) { + this->unk_208--; + if (this->unk_208 <= 0) { + if (this->unk_20B != 0) { + ActorCutscene_Stop(this->actor.cutscene); + } + + if (this->actor.home.rot.y == 1) { + func_80B04B48(this, globalCtx); + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (this->unk_208 == 0x2D) { + func_80B03688(this, globalCtx); + } +} + +void func_80B046E4(ObjSnowball* this, GlobalContext* globalCtx) { + Vec3f sp44; + s32 i; + + func_80B03E2C(this, globalCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_1A8); i++) { + sp44.x = this->unk_1A8[i].unk_00.x; + sp44.y = this->unk_1A8[i].unk_00.y - (60.0f * this->unk_20C); + sp44.z = this->unk_1A8[i].unk_00.z; + func_80B03A80(globalCtx, this->unk_20C, &sp44); + } + + this->actor.draw = func_80B04D34; + this->actor.floorPoly = NULL; + this->unk_208 = 50; + this->actionFunc = func_80B047C0; +} + +void func_80B047C0(ObjSnowball* this, GlobalContext* globalCtx) { + static Vec3f D_80B04FD8 = { 0.0f, 1.0f, 0.0f }; + static Vec3f D_80B04FE4 = { 0.0f, 0.0f, 1.0f }; + s32 pad; + ObjSnowballStruct* ptr; + Vec3f sp9C; + s32 sp98; + s32 i; + Vec3f sp88; + f32 sp84; + f32 phi_f2; + f32 sp7C; + Vec3f sp70; + + for (i = 0; i < ARRAY_COUNT(this->unk_1A8); i++) { + ptr = &this->unk_1A8[i]; + + if (!(ptr->unk_2D & 1)) { + ptr->unk_10 -= 6.0f; + ptr->unk_10 *= 0.96f; + if (ptr->unk_10 < -20.0f) { + ptr->unk_10 = -20.0f; + } + + ptr->unk_00.x += ptr->unk_0C; + ptr->unk_00.y += ptr->unk_10; + ptr->unk_00.z += ptr->unk_14; + + ptr->unk_1C.x += ptr->unk_22; + ptr->unk_1C.y += ptr->unk_24; + ptr->unk_1C.z += ptr->unk_26; + + sp9C.x = ptr->unk_00.x; + sp9C.y = ptr->unk_00.y + 25.0f; + sp9C.z = ptr->unk_00.z; + + ptr->unk_18 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &ptr->unk_28, &sp98, &this->actor, &sp9C); + + if (ptr->unk_10 <= 0.0f) { + Matrix_InsertRotation(ptr->unk_1C.x, ptr->unk_1C.y, ptr->unk_1C.z, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&D_80B04FE4, &sp88); + + sp84 = this->unk_20C * 60.0f * 0.9f; + if (sp88.y > 0.0f) { + if (Math3D_AngleBetweenVectors(&D_80B04FD8, &sp88, &sp7C)) { + phi_f2 = 1.0f; + } else { + phi_f2 = 1.0f - SQ(sp7C); + } + + if (phi_f2 <= 0.0f) { + sp84 = 0.0f; + } else { + sp84 *= sqrtf(phi_f2); + } + } + + if (((ptr->unk_00.y - sp84) < ptr->unk_18) || (ptr->unk_18 < BGCHECK_Y_MIN + 10.0f)) { + ptr->unk_2D |= 1; + sp70.x = ptr->unk_00.x; + sp70.y = ptr->unk_00.y - sp84; + sp70.z = ptr->unk_00.z; + func_80B03A80(globalCtx, this->unk_20C, &sp70); + } + } + } + } + + this->unk_208--; + + if ((this->unk_208 <= 0) || ((this->unk_1A8[0].unk_2D & 1) && (this->unk_1A8[1].unk_2D & 1))) { + if (this->unk_20B != 0) { + ActorCutscene_Stop(this->actor.cutscene); + } + + if (this->actor.home.rot.y == 1) { + func_80B04B48(this, globalCtx); + } else { + Actor_MarkForDeath(&this->actor); + } + } else { + for (i = 0; i < ARRAY_COUNT(this->unk_1A8); i++) { + ptr = &this->unk_1A8[i]; + + if (ptr->unk_2D & 1) { + ptr->unk_2C = 0; + } else if (ptr->unk_2C < 136) { + ptr->unk_2C += 24; + } else { + ptr->unk_2C = 160; + } + } + } +} + +void func_80B04B48(ObjSnowball* this, GlobalContext* globalCtx) { + this->actionFunc = func_80B04B60; +} + +void func_80B04B60(ObjSnowball* this, GlobalContext* globalCtx) { +} + +void ObjSnowball_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSnowball* this = THIS; + s32 sp24 = false; + + if (this->actor.home.rot.y == 1) { + if (this->unk_211 != 0) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + this->actor.flags &= ~0x10; + this->unk_211 = 0; + } + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags |= 0x10; + this->unk_211 = 1; + } else if (this->actor.isTargeted) { + sp24 = true; + } + } + + this->actionFunc(this, globalCtx); + + if (sp24 && (this->actionFunc == func_80B04350)) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } + + if ((this->actor.floorPoly != NULL) && (this->actor.projectedPos.z < 920.0f)) { + if (this->actor.projectedPos.z > 400.0f) { + this->actor.shape.shadowAlpha = (920 - (s32)this->actor.projectedPos.z) >> 2; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } else if (this->actor.projectedPos.z > -30.0f) { + this->actor.shape.shadowAlpha = 130; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } else { + this->actor.shape.shadowDraw = NULL; + } + } else { + this->actor.shape.shadowDraw = NULL; + } +} + +void ObjSnowball_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball* this = THIS; + + Gfx_DrawDListOpa(globalCtx, object_goroiwa_DL_008B90); +} + +void func_80B04D34(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSnowball* this = THIS; + ObjSnowballStruct* ptr; + s32 i; + MtxF sp88; + Vec3s sp80; + + for (i = 0; i < ARRAY_COUNT(this->unk_1A8); i++) { + ptr = &this->unk_1A8[i]; + + if (!(ptr->unk_2D & 1)) { + sp80.x = ptr->unk_1C.x; + sp80.y = ptr->unk_1C.y; + sp80.z = ptr->unk_1C.z; + + Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, object_goroiwa_DL_0082D0); + + if ((ptr->unk_28 != NULL) && (ptr->unk_2C > 0)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, + 0, COMBINED); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, ptr->unk_2C); + + func_800C0094(ptr->unk_28, ptr->unk_00.x, ptr->unk_18, ptr->unk_00.z, &sp88); + Matrix_SetCurrentState(&sp88); + Matrix_Scale(this->actor.scale.x * 7.5f, 1.0f, this->actor.scale.z * 7.5f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } + } +} diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.h b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.h index fc5aafddee..c6bc03100e 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.h +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.h @@ -7,11 +7,37 @@ struct ObjSnowball; typedef void (*ObjSnowballActionFunc)(struct ObjSnowball*, GlobalContext*); +#define OBJSNOWBALL_GET_3F(thisx) ((thisx)->params & 0x3F) +#define OBJSNOWBALL_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ Vec3s unk_1C; + /* 0x22 */ s16 unk_22; + /* 0x24 */ s16 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ CollisionPoly* unk_28; + /* 0x2C */ u8 unk_2C; + /* 0x2D */ u8 unk_2D; +} ObjSnowballStruct; // size = 0x30 + typedef struct ObjSnowball { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x60]; - /* 0x01A4 */ ObjSnowballActionFunc actionFunc; - /* 0x01A8 */ char unk_1A8[0x6C]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderJntSph collider; + /* 0x164 */ ColliderJntSphElement colliderElements[1]; + /* 0x1A4 */ ObjSnowballActionFunc actionFunc; + /* 0x1A8 */ ObjSnowballStruct unk_1A8[2]; + /* 0x208 */ s8 unk_208; + /* 0x209 */ s8 unk_209; + /* 0x20A */ s8 unk_20A; + /* 0x20B */ s8 unk_20B; + /* 0x20C */ f32 unk_20C; + /* 0x210 */ s8 unk_210; + /* 0x211 */ s8 unk_211; } ObjSnowball; // size = 0x214 extern const ActorInit Obj_Snowball_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c index ea554c4cf7..d21acc8b5a 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -45,7 +45,7 @@ static ColliderJntSphInit D_80B3A904 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_80B3A93C[] = { ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), diff --git a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c index b88dc23fae..5454c9be32 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -116,7 +116,7 @@ void ObjSyokudai_Init(Actor* thisx, GlobalContext* globalCtx) { sNumLitTorchesInGroup = 0; } this->flameTexScroll = (u32)(Rand_ZeroOne() * OBJ_SYOKUDAI_SNUFF_DEFAULT); - Actor_SetHeight(thisx, 60.0f); + Actor_SetFocus(thisx, 60.0f); } void ObjSyokudai_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -146,7 +146,7 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { if (ActorCutscene_GetCanPlayNext(thisx->cutscene) != 0) { ActorCutscene_StartAndSetUnkLinkFields(thisx->cutscene, thisx); if (this->pendingAction >= OBJ_SYOKUDAI_PENDING_ACTION_CUTSCENE_AND_SWITCH) { - Actor_SetSwitchFlag(globalCtx, switchFlag); + Flags_SetSwitch(globalCtx, switchFlag); } } else { ActorCutscene_SetIntentToPlay(thisx->cutscene); @@ -162,7 +162,7 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { this->snuffTimer = OBJ_SYOKUDAI_SNUFF_OUT; if (type == OBJ_SYOKUDAI_TYPE_FLAME_CAUSES_SWITCH) { - Actor_UnsetSwitchFlag(globalCtx, switchFlag); + Flags_UnsetSwitch(globalCtx, switchFlag); if (groupSize != 0) { this->snuffTimer = OBJ_SYOKUDAI_SNUFF_GROUP_BY_WATER; } @@ -242,7 +242,7 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { } else if (thisx->cutscene >= 0) { this->pendingAction = OBJ_SYOKUDAI_PENDING_ACTION_CUTSCENE_AND_SWITCH; } else { - Actor_SetSwitchFlag(globalCtx, switchFlag); + Flags_SetSwitch(globalCtx, switchFlag); this->snuffTimer = OBJ_SYOKUDAI_SNUFF_NEVER; } } else { @@ -253,8 +253,8 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { OBJ_SYOKUDAI_SNUFF_TIMER_INITIAL(groupSize) + OBJ_SYOKUDAI_SNUFF_TIMER_JUST_LIT_BONUS; } } - func_801A5CFC(NA_SE_EV_FLAME_IGNITION, &thisx->projectedPos, 4, &D_801DB4B0, &D_801DB4B0, - &D_801DB4B8); + Audio_PlaySfxGeneral(NA_SE_EV_FLAME_IGNITION, &thisx->projectedPos, 4, &D_801DB4B0, &D_801DB4B0, + &D_801DB4B8); } } } diff --git a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c index 7bb44cc94d..bf535300b5 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c @@ -41,7 +41,7 @@ static ColliderCylinderInit D_809A4CB0 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_809A4D14[] = { - ICHAIN_F32_DIV1000(minVelocityY, 0, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 150, ICHAIN_STOP), diff --git a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c index f7710909f6..50f879aec9 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c @@ -153,7 +153,7 @@ s32 ObjTokeiStep_OpenProcess(ObjTokeiStep* this, GlobalContext* globalCtx) { if (hasPrevBounced && (panel->numBounces < 3) && (panel->startFallingTimer <= 0)) { finalPosY = sPanelXOffsets[i] + this->dyna.actor.world.pos.y; if (!panel->hasSoundPlayed) { - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_CLOCK_TOWER_STAIR_MOVE); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CLOCK_TOWER_STAIR_MOVE); panel->hasSoundPlayed = true; } panel->posChangeY += -2.5f; @@ -266,7 +266,7 @@ void ObjTokeiStep_Update(Actor* thisx, GlobalContext* globalCtx) { void ObjTokeiStep_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjTokeiStep* this = THIS; - func_800BDFC0(globalCtx, gClocktowerPanelDL); + Gfx_DrawDListOpa(globalCtx, gClocktowerPanelDL); } void ObjTokeiStep_DrawOpen(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c index c545324b7d..ef53d67dba 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -292,7 +292,7 @@ void ObjTokeidai_RotateOnMinuteChange(ObjTokeidai* this, s32 playSfx) { if (currentClockMinute != this->clockMinute) { if (this->minuteRingOrExteriorGearRotationTimer == 8 && playSfx) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CLOCK_TOWER_SECOND_HAND); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_SECOND_HAND); } if (this->minuteRingOrExteriorGearRotationTimer > 8) { @@ -330,7 +330,7 @@ void ObjTokeidai_ExteriorGear_Collapse(ObjTokeidai* this, GlobalContext* globalC } else { this->actor.shape.rot.x += 0x50; this->actor.shape.rot.z += 0x50; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); } } @@ -340,7 +340,7 @@ void ObjTokeidai_ExteriorGear_OpenedIdle(ObjTokeidai* this, GlobalContext* globa this->actionFunc = ObjTokeidai_ExteriorGear_Collapse; this->actor.speedXZ = this->actor.scale.y * 5.0f; this->actor.velocity.y = 0.0f; - this->actor.minVelocityY = this->actor.scale.y * -50.0f; + this->actor.terminalVelocity = this->actor.scale.y * -50.0f; this->actor.gravity = this->actor.scale.y * -5.0f; } } @@ -356,7 +356,7 @@ void ObjTokeidai_TowerClock_Fall(ObjTokeidai* this, GlobalContext* globalCtx) { } this->actor.world.pos.z += 4.0f; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); if (this->actor.world.pos.y < 0.0f) { this->actionFunc = ObjTokeidai_DoNothing; } @@ -390,7 +390,7 @@ void ObjTokeidai_TowerClock_SlideOff(ObjTokeidai* this, GlobalContext* globalCtx } else { thisx->shape.rot.x += this->fallingClockFaceRotationalVelocity; this->actionFunc = ObjTokeidai_TowerClock_Fall; - thisx->minVelocityY = -7.5f; + thisx->terminalVelocity = -7.5f; thisx->gravity = -0.75f; thisx->velocity.y = -2.0f; } @@ -415,7 +415,7 @@ void ObjTokeidai_Counterweight_Collapse(ObjTokeidai* this, GlobalContext* global this->actionFunc = ObjTokeidai_DoNothing; } else { this->xRotation += 0x64; - Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_MoveWithGravity(&this->actor); } } @@ -424,7 +424,7 @@ void ObjTokeidai_Counterweight_OpenedIdle(ObjTokeidai* this, GlobalContext* glob this->actionFunc = ObjTokeidai_Counterweight_Collapse; this->xRotation = 0; this->actor.velocity.y = 0.0f; - this->actor.minVelocityY = this->actor.scale.y * -50.0f; + this->actor.terminalVelocity = this->actor.scale.y * -50.0f; this->actor.gravity = this->actor.scale.y * -5.0f; } } @@ -506,15 +506,15 @@ void ObjTokeidai_TowerOpening_DropCounterweight(ObjTokeidai* this, GlobalContext this->xRotation = 0x4000; switch (this->boundCount) { case 0: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CLOCK_TOWER_BOUND_0); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_BOUND_0); break; case 1: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CLOCK_TOWER_BOUND_1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_BOUND_1); break; case 2: - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CLOCK_TOWER_BOUND_2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_BOUND_2); break; } this->boundCount++; @@ -554,7 +554,7 @@ void ObjTokeidai_TowerOpening_FinishRaise(ObjTokeidai* this, GlobalContext* glob type = OBJ_TOKEIDAI_TYPE(&this->actor); if ((type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_CLOCK_TOWN) || (type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CLOCK_TOWER_FALL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_FALL); } this->yTranslation = 3400; this->actionFunc = ObjTokeidai_TowerOpening_DropCounterweight; @@ -578,7 +578,7 @@ void ObjTokeidai_TowerOpening_RaiseTower(ObjTokeidai* this, GlobalContext* globa type = OBJ_TOKEIDAI_TYPE(&this->actor); if ((type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_CLOCK_TOWN) || (type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD)) { - Audio_PlayActorSound2(&this->actor, NA_SE_EV_CLOCK_TOWER_STOP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_STOP); } this->yTranslation = 3400; this->actionFunc = ObjTokeidai_TowerOpening_FinishRaise; diff --git a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c index 0ffa733316..7b756a10f8 100644 --- a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c +++ b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c @@ -144,7 +144,7 @@ void ObTree_SetupSway(ObjTree* this) { this->timer = 0; this->swayAmplitude = 546.0f; this->swayVelocity = 35 * 0x10000 / 360; - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_TREE_SWING); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_TREE_SWING); this->actionFunc = ObTree_Sway; } diff --git a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c index 5eac816e2d..e91c3387fb 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -43,7 +43,7 @@ static ColliderCylinderInit D_809295B0 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_809295DC[] = { ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(minVelocityY, -20000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), diff --git a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c index 427400f99a..ea27c1ad99 100644 --- a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c +++ b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c @@ -51,5 +51,5 @@ void ObjVisiblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void ObjVisiblock_Draw(Actor* thisx, GlobalContext* globalCtx) { - func_800BE03C(globalCtx, D_06000140); + Gfx_DrawDListXlu(globalCtx, D_06000140); } diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index 6e66c9cabe..1563ea2fa9 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -71,7 +71,7 @@ void ObjWarpstone_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); - Actor_SetHeight(&this->dyna.actor, 40.0f); + Actor_SetFocus(&this->dyna.actor, 40.0f); if (!OBJ_WARPSTONE_IS_ACTIVATED(OBJ_WARPSTONE_GET_ID(this))) { ObjWarpstone_SetupAction(this, ObjWarpstone_ClosedIdle); @@ -102,7 +102,7 @@ s32 ObjWarpstone_BeginOpeningCutscene(ObjWarpstone* this, GlobalContext* globalC if (this->dyna.actor.cutscene < 0 || ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); ObjWarpstone_SetupAction(this, ObjWarpstone_PlayOpeningCutscene); - Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_OWL_WARP_SWITCH_ON); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_OWL_WARP_SWITCH_ON); } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); } @@ -138,9 +138,9 @@ void ObjWarpstone_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; if (this->isTalking) { - if (func_800B867C(&this->dyna.actor, globalCtx) != 0) { + if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { this->isTalking = false; - } else if ((func_80152498(&globalCtx->msgCtx) == 4) && (func_80147624(globalCtx))) { + } else if ((Message_GetState(&globalCtx->msgCtx) == 4) && (func_80147624(globalCtx))) { if (globalCtx->msgCtx.choiceIndex != 0) { func_8019F208(); globalCtx->msgCtx.unk11F22 = 0x4D; @@ -151,11 +151,12 @@ void ObjWarpstone_Update(Actor* thisx, GlobalContext* globalCtx) { func_801477B4(globalCtx); } } - } else if (func_800B84D0(&this->dyna.actor, globalCtx)) { + } else if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state)) { this->isTalking = true; } else if (!this->actionFunc(this, globalCtx)) { func_800B863C(&this->dyna.actor, globalCtx); } + Collider_ResetCylinderAC(globalCtx, &this->collider.base); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); @@ -166,7 +167,7 @@ void ObjWarpstone_Draw(Actor* thisx, GlobalContext* globalCtx2) { ObjWarpstone* this = THIS; GlobalContext* globalCtx = globalCtx2; - func_800BDFC0(globalCtx, sOwlStatueDLs[this->modelIndex]); + Gfx_DrawDListOpa(globalCtx, sOwlStatueDLs[this->modelIndex]); if (this->dyna.actor.home.rot.x != 0) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c index 2d8689d4fd..3d34f1bf4b 100644 --- a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c +++ b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c @@ -69,8 +69,8 @@ void ObjYado_Draw(Actor* thisx, GlobalContext* globalCtx) { } AnimatedMat_Draw(globalCtx, D_80C16470); - func_800BDFC0(globalCtx, D_06000430); - func_800BE03C(globalCtx, D_06000320); + Gfx_DrawDListOpa(globalCtx, D_06000430); + Gfx_DrawDListXlu(globalCtx, D_06000320); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index ce88071314..0c0a722793 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -5,6 +5,7 @@ */ #include "z_object_kankyo.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x02000030 @@ -15,12 +16,17 @@ void ObjectKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjectKankyo_Update(Actor* thisx, GlobalContext* globalCtx); void ObjectKankyo_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjectKankyo_SetupAction(ObjectKankyo* this, ObjectKankyoActionFunc actionFunc); +void func_808DC18C(ObjectKankyo* this, GlobalContext* globalCtx); void func_808DCB7C(ObjectKankyo* this, GlobalContext* globalCtx); void func_808DCBF8(ObjectKankyo* this, GlobalContext* globalCtx); +void func_808DCDB4(ObjectKankyo* this, GlobalContext* globalCtx); +void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2); +void func_808DD970(Actor* thisx, GlobalContext* globalCtx2); +void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2); -void ObjectKankyo_SetupAction(ObjectKankyo* this, ObjectKankyoActionFunc actionFunc); +static f32 D_808DE5B0; -#if 0 const ActorInit Object_Kankyo_InitVars = { ACTOR_OBJECT_KANKYO, ACTORCAT_ITEMACTION, @@ -33,42 +39,694 @@ const ActorInit Object_Kankyo_InitVars = { (ActorFunc)ObjectKankyo_Draw, }; -#endif +static u16 D_808DE340 = 0; -extern UNK_TYPE D_01000000; +void ObjectKankyo_SetupAction(ObjectKankyo* this, ObjectKankyoActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/ObjectKankyo_SetupAction.s") +void func_808DBE8C(ObjectKankyo* this) { + ObjectKankyo_SetupAction(this, func_808DC18C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DBE8C.s") +void func_808DBEB0(ObjectKankyo* this, GlobalContext* globalCtx) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DBEB0.s") + D_808DE5B0 = 0.0f; + this->unk_144 = Rand_ZeroOne() * 360.0f; + this->unk_148 = Rand_ZeroOne() * 360.0f; + if (globalCtx->envCtx.unk_F2[2] == 128) { + D_808DE5B0 = 1.0f; + this->unk_114E = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DBFB0.s") + for (i = 0; i < globalCtx->envCtx.unk_F2[2]; i++) { + this->unk_14C[i].unk_10 = Rand_ZeroOne() * -200.0f; + } + } else { + this->unk_114E = 0; + } + ObjectKankyo_SetupAction(this, func_808DCB7C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DC038.s") +void func_808DBFB0(ObjectKankyo* this, GlobalContext* globalCtx) { + D_808DE5B0 = 0.0f; + this->unk_114E = 0; + this->unk_144 = Rand_ZeroOne() * 360.0f; + this->unk_148 = Rand_ZeroOne() * 360.0f; + this->unk_114C = D_808DE340; + D_808DE340++; + ObjectKankyo_SetupAction(this, func_808DCBF8); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/ObjectKankyo_Init.s") +void func_808DC038(ObjectKankyo* this, GlobalContext* globalCtx) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/ObjectKankyo_Destroy.s") + this->unk_144 = Rand_ZeroOne() * 360.0f; + this->unk_148 = Rand_ZeroOne() * 360.0f; + this->unk_114C = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DC18C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_14C); i++) { + this->unk_14C[i].unk_1C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DC454.s") + ObjectKankyo_SetupAction(this, func_808DCDB4); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DCB7C.s") +void ObjectKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjectKankyo* this = THIS; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DCBF8.s") + for (i = 0; i < ARRAY_COUNT(this->unk_14C); i++) { + this->unk_14C[i].unk_1C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DCDB4.s") + this->actor.room = -1; + switch (this->actor.params) { + case 0: + func_808DBE8C(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/ObjectKankyo_Update.s") + case 2: + globalCtx->envCtx.unk_F2[2] = 0x80; + func_808DBFB0(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/ObjectKankyo_Draw.s") + case 1: + case 3: + func_808DBEB0(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DD3C8.s") + case 4: + func_808DC038(this, globalCtx); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DD970.s") +void ObjectKankyo_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjectKankyo* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DDE74.s") + Actor_MarkForDeath(&this->actor); +} +void func_808DC18C(ObjectKankyo* this, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + s32 pad3; + f32 magnitude; + f32 y; + f32 z; + f32 temp_f18; + Vec3f sp30; + f32 x; + f32 sp1C; + + x = globalCtx->view.at.x - globalCtx->view.eye.x; + y = globalCtx->view.at.y - globalCtx->view.eye.y; + z = globalCtx->view.at.z - globalCtx->view.eye.z; + magnitude = sqrtf(SQ(x) + SQ(y) + SQ(z)); + + temp_f18 = x / magnitude; + x = z / magnitude; + sp1C = (y / magnitude) * 120.0f; + + this->unk_14C[0].unk_00 = globalCtx->view.eye.x + (temp_f18 * 50.0f); + this->unk_14C[0].unk_04 = globalCtx->view.eye.y + sp1C; + this->unk_14C[0].unk_08 = globalCtx->view.eye.z + (x * 50.0f); + this->unk_14C[1].unk_00 = globalCtx->view.eye.x + (temp_f18 * 220.0f); + this->unk_14C[1].unk_08 = globalCtx->view.eye.z + (x * 220.0f); + this->unk_114C = 0; + this->unk_144 = 100.0f; + + if ((this->unk_14C[0].unk_00 < -252.0f) && (this->unk_14C[0].unk_00 > -500.0f)) { + if ((this->unk_14C[0].unk_08 > 3820.0f) && (this->unk_14C[0].unk_08 < 4150.0f)) { + this->unk_114C = 1; + this->unk_144 = 400.0f; + if (x < 0.0f) { + this->unk_14C[0].unk_00 = -350.0f; + this->unk_14C[0].unk_04 = globalCtx->view.eye.y + sp1C; + this->unk_14C[0].unk_08 = 3680.0f; + this->unk_14C[1].unk_00 = -350.0f; + this->unk_14C[1].unk_08 = 3680.0f; + } else { + this->unk_14C[0].unk_00 = -350.0f; + this->unk_14C[0].unk_04 = globalCtx->view.eye.y + sp1C; + this->unk_14C[0].unk_08 = 4280.0f; + this->unk_14C[1].unk_00 = -350.0f; + this->unk_14C[1].unk_08 = 4280.0f; + } + } + } + + magnitude = globalCtx->envCtx.windSpeed / 60.0f; + magnitude = CLAMP(magnitude, 0.0f, 1.0f); + + sp30.x = globalCtx->envCtx.windDir.x * magnitude; + sp30.y = globalCtx->envCtx.windDir.y + 100.0f; + sp30.z = globalCtx->envCtx.windDir.z * magnitude; + this->unk_14C[2].unk_00 = 0x4000 - Math_Vec3f_Pitch(&gZeroVec3f, &sp30); + this->unk_14C[2].unk_04 = Math_Vec3f_Yaw(&gZeroVec3f, &sp30) + 0x8000; +} + +void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { + s16 i; + u32 tempI; + f32 phi_f20; + f32 spD0; + f32 spCC; + f32 spC8; + f32 spC4; + f32 spC0; + f32 spBC; + f32 temp_f0_4; + f32 temp_f22; + f32 temp_f24; + f32 temp_f28; + f32 x = globalCtx->view.at.x - globalCtx->view.eye.x; + f32 y = globalCtx->view.at.y - globalCtx->view.eye.y; + f32 z = globalCtx->view.at.z - globalCtx->view.eye.z; + f32 magnitude = sqrtf(SQ(x) + SQ(y) + SQ(z)); + f32 temp_120 = 120.0f; + f32 temp_f30; + Vec3f sp88; + s32 pad; + + spD0 = x / magnitude; + spCC = y / magnitude; + spC8 = z / magnitude; + + for (i = 0; i < globalCtx->envCtx.unk_F2[2]; i++) { + switch (this->unk_14C[i].unk_1C) { + case 0: + this->unk_14C[i].unk_00 = globalCtx->view.eye.x + (spD0 * 120.0f); + this->unk_14C[i].unk_04 = globalCtx->view.eye.y + (spCC * 120.0f); + this->unk_14C[i].unk_08 = globalCtx->view.eye.z + (spC8 * 120.0f); + this->unk_14C[i].unk_0C = (Rand_ZeroOne() - 0.5f) * (2.0f * temp_120); + + temp_f22 = (func_800DFCB4(GET_ACTIVE_CAM(globalCtx)) * 0.004f) + 60.0f; + if (temp_f22 < 20.0f) { + temp_f22 = 20.0f; + } + + if (this->unk_114E == 0) { + this->unk_14C[i].unk_10 = temp_f22; + } else { + this->unk_14C[i].unk_10 += temp_f22; + tempI = i; + if (globalCtx->envCtx.unk_F2[2] == (tempI + 1)) { + this->unk_114E = 0; + } + } + + this->unk_14C[i].unk_14 = (Rand_ZeroOne() - 0.5f) * (2.0f * temp_120); + if (globalCtx->envCtx.unk_F2[4] == 0) { + this->unk_14C[i].unk_18 = (Rand_ZeroOne() * 3.0f) + 1.0f; + } else { + this->unk_14C[i].unk_18 = (Rand_ZeroOne() * 3.0f) + 8.0f; + } + this->unk_14C[i].unk_1C++; + break; + + case 1: + temp_f24 = globalCtx->view.eye.x + (spD0 * 120.0f); + temp_f28 = globalCtx->view.eye.y + (spCC * 120.0f); + temp_f30 = globalCtx->view.eye.z + (spC8 * 120.0f); + + magnitude = sqrtf((f32)SQ(globalCtx->envCtx.windDir.x) + SQ(globalCtx->envCtx.windDir.y) + + SQ(globalCtx->envCtx.windDir.z)); + if (magnitude == 0.0f) { + magnitude = 0.001f; + } + spC4 = -globalCtx->envCtx.windDir.x / magnitude; + spC0 = -globalCtx->envCtx.windDir.y / magnitude; + spBC = -globalCtx->envCtx.windDir.z / magnitude; + + if (i == 0) { + this->unk_144 += 0.049999997f * Rand_ZeroOne(); + this->unk_148 += 0.049999997f * Rand_ZeroOne(); + } + + phi_f20 = globalCtx->envCtx.windSpeed / 120.0f; + phi_f20 = CLAMP(phi_f20, 0.0f, 1.0f); + + this->unk_14C[i].unk_0C += __sinf((this->unk_144 + (i * 100.0f)) * 0.01f) + (spC4 * 10.0f * phi_f20); + this->unk_14C[i].unk_14 += __cosf((this->unk_148 + (i * 100.0f)) * 0.01f) + (spBC * 10.0f * phi_f20); + this->unk_14C[i].unk_10 -= + this->unk_14C[i].unk_18 - (spC0 * 3.0f * (globalCtx->envCtx.windSpeed / 100.0f)); + + temp_f22 = (-func_800DFCB4(GET_ACTIVE_CAM(globalCtx)) * 0.012f) + 40.0f; + if (temp_f22 < -40.0f) { + temp_f22 = -40.0f; + } + + if (((this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C) - temp_f24) > temp_120) { + this->unk_14C[i].unk_00 = temp_f24 - temp_120; + } + + if (((this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C) - temp_f24) < -temp_120) { + this->unk_14C[i].unk_00 = temp_f24 + temp_120; + } + + sp88.x = this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C; + sp88.y = this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10; + sp88.z = this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14; + + phi_f20 = Math_Vec3f_DistXZ(&sp88, &globalCtx->view.eye) / 200.0f; + phi_f20 = CLAMP(phi_f20, 0.0f, 1.0f); + temp_f0_4 = 100.0f + phi_f20 + 60.0f; + + if (temp_f0_4 < (this->unk_14C[i].unk_04 + (this->unk_14C[i].unk_10) - temp_f28)) { + this->unk_14C[i].unk_04 = temp_f28 - temp_f0_4; + } + + if (((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) - temp_f28) < -temp_f0_4) { + this->unk_14C[i].unk_04 = temp_f28 + temp_f0_4; + } + + if (((this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14) - temp_f30) > temp_120) { + this->unk_14C[i].unk_08 = temp_f30 - temp_120; + } + + if (((this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14) - temp_f30) < -temp_120) { + this->unk_14C[i].unk_08 = temp_f30 + temp_120; + } + + if ((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) < + ((globalCtx->view.eye.y - temp_f22) - 40.0f)) { + this->unk_14C[i].unk_1C = 0; + } + break; + } + } +} + +void func_808DCB7C(ObjectKankyo* this, GlobalContext* globalCtx) { + if (globalCtx->envCtx.unk_F2[2] < globalCtx->envCtx.unk_F2[3]) { + if ((globalCtx->state.frames % 16) == 0) { + globalCtx->envCtx.unk_F2[2] += 2; + } + } else if (globalCtx->envCtx.unk_F2[3] < globalCtx->envCtx.unk_F2[2]) { + if ((globalCtx->state.frames % 16) == 0) { + globalCtx->envCtx.unk_F2[2] -= 2; + } + } + func_808DC454(this, globalCtx); +} + +void func_808DCBF8(ObjectKankyo* this, GlobalContext* globalCtx) { + f32 temp_f0; + + if ((globalCtx->envCtx.unk_F2[2] > 0) && (this->unk_114C == 0)) { + if ((globalCtx->state.frames % 16) == 0) { + globalCtx->envCtx.unk_F2[2] -= 9; + if ((s8)globalCtx->envCtx.unk_F2[2] < 0) { + globalCtx->envCtx.unk_F2[2] = 0; + } + } + } + + temp_f0 = (f32)globalCtx->envCtx.unk_F2[2] / 128; + temp_f0 = CLAMP(temp_f0, 0.0f, 1.0f); + + if (temp_f0 > 0.01f) { + D_801F4E30 = 155.0f * temp_f0; + globalCtx->envCtx.unk_EA = 10; + } else { + D_801F4E30 = 0; + globalCtx->envCtx.unk_EA = 10; + } + func_808DC454(this, globalCtx); +} + +void func_808DCDB4(ObjectKankyo* this, GlobalContext* globalCtx) { + s16 i; + f32 magnitude; + f32 temp_80; + f32 temp_120; + f32 spAC; + f32 spA8; + f32 spA4; + f32 spA0; + f32 sp9C; + f32 x; + f32 y; + f32 z; + f32 temp_f18; + f32 temp_f20; + f32 temp_f26; + f32 temp_f28; + + if (this->unk_114C < 0x80) { + this->unk_114C++; + } + + x = globalCtx->view.at.x - globalCtx->view.eye.x; + y = globalCtx->view.at.y - globalCtx->view.eye.y; + z = globalCtx->view.at.z - globalCtx->view.eye.z; + + magnitude = sqrtf(SQ(x) + SQ(y) + SQ(z)); + + spAC = x / magnitude; + spA8 = y / magnitude; + spA4 = z / magnitude; + + temp_80 = 80.0f; + temp_120 = 120.0f; + + for (i = 0; i < this->unk_114C; i++) { + switch (this->unk_14C[i].unk_1C) { + case 0: + this->unk_14C[i].unk_00 = globalCtx->view.eye.x + (spAC * 120.0f); + this->unk_14C[i].unk_04 = globalCtx->view.eye.y + (spA8 * 120.0f); + this->unk_14C[i].unk_08 = globalCtx->view.eye.z + (spA4 * 120.0f); + this->unk_14C[i].unk_0C = (Rand_ZeroOne() - 0.5f) * (temp_120 * 2.0f); + if ((i % 2) == 0) { + this->unk_14C[i].unk_10 = -100.0f; + } else { + this->unk_14C[i].unk_10 = 100.0f; + } + this->unk_14C[i].unk_14 = (Rand_ZeroOne() - 0.5f) * (temp_120 * 2.0f); + this->unk_14C[i].unk_18 = Rand_ZeroOne() + 0.2f; + this->unk_14C[i].unk_1C++; + break; + + case 1: + + temp_f26 = globalCtx->view.eye.x + (spAC * 120.0f); + temp_f28 = globalCtx->view.eye.y + (spA8 * 120.0f); + temp_f18 = globalCtx->view.eye.z + (spA4 * 120.0f); + + magnitude = sqrtf((f32)SQ(globalCtx->envCtx.windDir.x) + SQ(globalCtx->envCtx.windDir.y) + + SQ(globalCtx->envCtx.windDir.z)); + if (magnitude == 0.0f) { + magnitude = 0.001f; + } + + spA0 = -globalCtx->envCtx.windDir.x / magnitude; + sp9C = -globalCtx->envCtx.windDir.z / magnitude; + + if (i == 0) { + this->unk_144 += 0.049999997f * Rand_ZeroOne(); + this->unk_148 += 0.049999997f * Rand_ZeroOne(); + } + temp_f20 = globalCtx->envCtx.windSpeed / 120.0f; + temp_f20 = CLAMP(temp_f20, 0.0f, 1.0f); + + this->unk_14C[i].unk_0C += __sinf((this->unk_144 + i) * 0.01f) + (spA0 * 10.0f * temp_f20); + this->unk_14C[i].unk_14 += __cosf((this->unk_148 + i) * 0.01f) + (sp9C * 10.0f * temp_f20); + + if ((i % 2) == 0) { + this->unk_14C[i].unk_10 += this->unk_14C[i].unk_18; + if ((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) > (globalCtx->view.eye.y + 100.0f)) { + this->unk_14C[i].unk_1C = 0; + } + } else { + this->unk_14C[i].unk_10 -= this->unk_14C[i].unk_18; + if ((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) < (globalCtx->view.eye.y - 100.0f)) { + this->unk_14C[i].unk_1C = 0; + } + } + + if (((this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C) - temp_f26) > temp_80) { + this->unk_14C[i].unk_00 = temp_f26 - temp_80; + } + + if (((this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C) - temp_f26) < -temp_80) { + this->unk_14C[i].unk_00 = temp_f26 + temp_80; + } + + if (((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) - temp_f28) > temp_80) { + this->unk_14C[i].unk_04 = temp_f28 - temp_80; + } + + if (((this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10) - temp_f28) < -temp_80) { + this->unk_14C[i].unk_04 = temp_f28 + temp_80; + } + + if (((this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14) - temp_f18) > temp_80) { + this->unk_14C[i].unk_08 = temp_f18 - temp_80; + } + + if (((this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14) - temp_f18) < -temp_80) { + this->unk_14C[i].unk_08 = temp_f18 + temp_80; + } + break; + } + } +} + +void ObjectKankyo_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjectKankyo* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void ObjectKankyo_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjectKankyo* this = THIS; + + switch (this->actor.params) { + case 0: + func_808DDE9C(thisx, globalCtx); + break; + + case 1: + case 2: + case 3: + func_808DD3C8(thisx, globalCtx); + break; + + case 4: + func_808DD970(thisx, globalCtx); + break; + } +} + +void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjectKankyo* this = THIS; + Vec3f spC4; + Vec3f spB8; + s16 i; + u8 pad2; + u8 spB4; + f32 temp_f0; + u8 sp68; + s32 pad; + f32 temp_f2; + f32 tempf; + + if ((globalCtx->cameraPtrs[MAIN_CAM]->flags2 & 0x100) || ((u8)globalCtx->envCtx.unk_E2 == 0)) { + return; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + spB4 = false; + + if (this->actor.params == 3) { + temp_f0 = func_80173B48(&globalCtx->state) / 1.4e7f; + temp_f0 = CLAMP(temp_f0, 0.0f, 1.0f); + Math_SmoothStepToF(&D_808DE5B0, temp_f0, 0.2f, 0.1f, 0.001f); + + sp68 = globalCtx->envCtx.unk_F2[2]; + sp68 *= D_808DE5B0; + + if ((globalCtx->envCtx.unk_F2[2] >= 32) && (sp68 < 32)) { + sp68 = 32; + } + } else { + sp68 = globalCtx->envCtx.unk_F2[2]; + } + + for (i = 0; i < sp68; i++) { + spC4.x = this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C; + spC4.y = this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10; + spC4.z = this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14; + func_80169474(globalCtx, &spC4, &spB8); + + if ((spB8.x >= 0.0f) && (spB8.x < 320.0f) && (spB8.y >= 0.0f) && (spB8.y < 240.0f)) { + if (!spB4) { + spB4 = true; + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 255); + gSPClearGeometryMode(POLY_XLU_DISP++, G_LIGHTING); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_CLD_SURF2); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_08EBE0)); + } + + Matrix_InsertTranslation(spC4.x, spC4.y, spC4.z, MTXMODE_NEW); + tempf = (i & 7) * 0.008f; + Matrix_Scale(0.05f + tempf, 0.05f + tempf, 0.05f + tempf, MTXMODE_APPLY); + temp_f2 = Math_Vec3f_DistXYZ(&spC4, &globalCtx->view.eye) / 300.0f; + temp_f2 = ((1.0f < temp_f2) ? 0.0f : (((1.0f - temp_f2) > 1.0f) ? 1.0f : 1.0f - temp_f2)); + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(160.0f * temp_f2)); + + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023130); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { + f32 temp_f0; + f32 temp_f20; + Vec3f spBC; + Vec3f spB0; + f32 tempf; + s16 i; + f32 phi_f26; + GlobalContext* globalCtx = globalCtx2; + ObjectKankyo* this = THIS; + f32 tempA; + + if (globalCtx->sceneNum == SCENE_KYOJINNOMA) { + phi_f26 = 1.0f; + } else { + tempA = func_800E031C(GET_ACTIVE_CAM(globalCtx)); + if (tempA != BGCHECK_Y_MIN) { + tempA -= globalCtx->view.eye.y; + phi_f26 = tempA / 4000.0f; + } else { + phi_f26 = 0.0f; + } + + phi_f26 = CLAMP_MAX(phi_f26, 1.0f); + + if (!(globalCtx->cameraPtrs[MAIN_CAM]->flags2 & 0x100) || (phi_f26 == 0.0f)) { + return; + } + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + for (i = 0; i < this->unk_114C; i++) { + spBC.x = this->unk_14C[i].unk_00 + this->unk_14C[i].unk_0C; + spBC.y = this->unk_14C[i].unk_04 + this->unk_14C[i].unk_10; + spBC.z = this->unk_14C[i].unk_08 + this->unk_14C[i].unk_14; + func_80169474(globalCtx, &spBC, &spB0); + + if ((spB0.x >= 0.0f) && (spB0.x < 320.0f) && (spB0.y >= 0.0f) && (spB0.y < 240.0f)) { + Matrix_InsertTranslation(spBC.x, spBC.y, spBC.z, MTXMODE_NEW); + Matrix_Scale(0.03f, 0.03f, 0.03f, MTXMODE_APPLY); + temp_f0 = Math_Vec3f_DistXYZ(&spBC, &globalCtx->view.eye); + temp_f0 = (u8)(255.0f * phi_f26) * (1.0f - (temp_f0 / 300.0f)); + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 55, temp_f0); + gDPSetEnvColor(POLY_XLU_DISP++, 55, 50, 255, temp_f0); + + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_08EBE0)); + gSPClearGeometryMode(POLY_XLU_DISP++, G_LIGHTING); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_CLD_SURF2); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023130); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +f32 func_808DDE74(void) { + return Rand_ZeroOne() - 0.5f; +} + +#ifdef NON_MATCHING +// globalCtx->envCtx.unk_F2[1] needs to be laoded into s0 and then copied to s7 +void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjectKankyo* this = THIS; + Player* player = GET_PLAYER(globalCtx); + s32 i; + s16 temp; + f32 temp_f12; + f32 temp_f20; + f32 temp_f22; + f32 temp_f2; + u8 phi_s5; + s32 end = globalCtx->envCtx.unk_F2[1]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (end != 0) { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 150, 255, 255, 25); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); + } + + for (i = 0; i < end; i++) { + temp_f20 = this->unk_14C[0].unk_00 + ((Rand_ZeroOne() - 0.7f) * this->unk_144); + temp_f22 = this->unk_14C[0].unk_04 + ((Rand_ZeroOne() - 0.7f) * this->unk_144); + temp_f2 = this->unk_14C[0].unk_08 + ((Rand_ZeroOne() - 0.7f) * this->unk_144); + + if ((temp_f20 < -252.0f) && (temp_f20 > -500.0f) && (temp_f2 > 3820.0f) && (temp_f2 < 4150.0f)) { + continue; + } + + Matrix_InsertTranslation(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); + + gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + + Matrix_RotateY((s16)this->unk_14C[2].unk_04 + (s16)(i << 5), MTXMODE_APPLY); + Matrix_InsertXRotation_s((s16)this->unk_14C[2].unk_00 + (s16)(i << 5), MTXMODE_APPLY); + + if (this->unk_114C == 0) { + Matrix_Scale(0.5f, 1.0f, 0.5f, MTXMODE_APPLY); + } else { + Matrix_Scale(2.0f, 4.0f, 2.0f, MTXMODE_APPLY); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0706E0); + } + + phi_s5 = false; + if (player->actor.floorHeight < globalCtx->view.eye.y) { + for (i = 0; i < end; i++) { + if (!phi_s5) { + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 255); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 100); + phi_s5++; + } + + temp_f20 = this->unk_14C[1].unk_00 + (func_808DDE74() * 220.0f); + temp_f22 = player->actor.floorHeight + 2.0f; + temp_f2 = this->unk_14C[1].unk_08 + (func_808DDE74() * 220.0f); + + if ((temp_f20 < -252.0f) && (temp_f20 > -500.0f) && (temp_f2 > 3820.0f) && (temp_f2 < 4150.0f)) { + continue; + } + + Matrix_InsertTranslation(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); + temp_f12 = (Rand_ZeroOne() * 0.05f) + 0.05f; + Matrix_Scale(temp_f12, temp_f12, temp_f12, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_030100); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Object_Kankyo/func_808DDE9C.s") +#endif diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h index f61d140d84..646863be0a 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.h @@ -7,9 +7,24 @@ struct ObjectKankyo; typedef void (*ObjectKankyoActionFunc)(struct ObjectKankyo*, GlobalContext*); +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ u8 unk_1C; +} ObjectKankyoStruct; // size = 0x20 + typedef struct ObjectKankyo { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x100C]; + /* 0x0144 */ f32 unk_144; + /* 0x0148 */ f32 unk_148; + /* 0x014C */ ObjectKankyoStruct unk_14C[128]; + /* 0x114C */ u16 unk_114C; + /* 0x114E */ u8 unk_114E; /* 0x1150 */ ObjectKankyoActionFunc actionFunc; } ObjectKankyo; // size = 0x1154 diff --git a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c index d1a6afb3e2..9dcf3ab159 100644 --- a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c +++ b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c @@ -56,7 +56,7 @@ void TGSw_ActionExecuteOneShot(TGSw* this, GlobalContext* globalCtx) { if (1) {} do { - actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_ENEMY, ACTOR_EN_SW); + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_ENEMY, ACTOR_EN_SW); if (actor == NULL) { break; } @@ -71,7 +71,7 @@ void TGSw_ActionExecuteOneShot(TGSw* this, GlobalContext* globalCtx) { actor = NULL; do { - actor = func_ActorCategoryIterateById(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_SW); + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_SW); if (actor == NULL) { break; diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c index 39f9e51d5f..0d26eec89c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.c @@ -20,8 +20,6 @@ const EffectSsInit Effect_Ss_Dead_Dd_InitVars = { #endif -extern UNK_TYPE D_01000000; - #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Dd/EffectSsDeadDd_Init.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Dd/EffectSsDeadDd_Draw.s") diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index a98b8e24a5..9b36a7e148 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -74,7 +74,7 @@ void Title_Draw(GameState* thisx) { eye.y = 4002.5417f; eye.z = 1119.0837f; - func_800B7FE0(&object, &eye, &lightDir, this->gameState.gfxCtx); + Hilite_DrawOpa(&object, &eye, &lightDir, this->gameState.gfxCtx); gSPSetLights1(POLY_OPA_DISP++, sTitleLights); diff --git a/tools/ZAPDConfigs/MM/Config.xml b/tools/ZAPDConfigs/MM/Config.xml index 6570400107..02656c7df7 100644 --- a/tools/ZAPDConfigs/MM/Config.xml +++ b/tools/ZAPDConfigs/MM/Config.xml @@ -4,10 +4,5 @@ - - diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 77fe5d38a3..28b982bc5e 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -51,6 +51,33 @@ animdict = { "func_8012404c": "Player_RemoveMask", "Actor_SpawnWithParentAndCutscene": "Actor_SpawnAsChildAndCutscene", "Actor_SpawnWithParent": "Actor_SpawnAsChild", + "Actor_IsLinkFacingActor": "Player_IsFacingActor", + "Actor_IsActorFacingLink": "Actor_IsFacingPlayer", + "Actor_IsActorFacingLinkAndWithinRange": "Actor_IsFacingAndNearPlayer", + "Actor_IsActorFacingActorAndWithinRange": "Actor_ActorAIsFacingAndNearActorB", + "Actor_IsActorFacingActor": "Actor_ActorAIsFacingActorB", + "Actor_IsActorFacedByActor": "Actor_ActorBIsFacingActorA", + "func_800B84D0": "Actor_ProcessTalkRequest", + "func_8017D668": "Math3D_PointDistToLine2D", + "func_800BDFC0": "Gfx_DrawDListOpa", + "func_800BE03C": "Gfx_DrawDListXlu", + "func_800B6FC8": "Player_GetHeight", + "Actor_InitCurrPosition": "Actor_SetWorldToHome", + "Actor_SetHeight": "Actor_SetFocus", + "Actor_SetRotationFromDrawRotation": "Actor_SetWorldRotToShape", + "Actor_InitDrawRotation": "Actor_SetShapeRotToWorld", + "Actor_CalcOffsetOrientedToDrawRotation": "Actor_OffsetOfPointInActorCoords", + "Actor_ApplyMovement": "Actor_UpdatePos", + "Actor_SetVelocityYRotationAndGravity": "Actor_UpdateVelocityWithGravity", + "Actor_SetVelocityAndMoveYRotationAndGravity": "Actor_MoveWithGravity", + "Actor_SetVelocityXYRotation": "Actor_UpdateVelocityWithoutGravity", + "Actor_SetVelocityAndMoveXYRotation": "Actor_MoveWithoutGravity", + "Actor_SetVelocityXYRotationReverse": "Actor_UpdateVelocityWithoutGravityReverse", + "Actor_SetVelocityAndMoveXYRotationReverse": "Actor_MoveWithoutGravityReverse", + "func_800B6C04": "Actor_SetSpeeds", + "func_800B81E0": "Actor_GetFocus", + "func_800B8214": "Actor_GetWorld", + "func_800B8248": "Actor_GetWorldPosShapeRot", "func_800BE22C": "Actor_ApplyDamage", "func_800F0568": "Audio_PlaySoundAtPosition", "func_8016970C": "Play_CameraSetAtEye", @@ -144,6 +171,53 @@ animdict = { "SkelAnime_CopyVec3s": "SkelAnime_CopyFrameTable", "SysMatrix_StatePop": "Matrix_StatePop", "SysMatrix_GetCurrentState": "Matrix_GetCurrentState", + "Actor_SetObjectSegment": "Actor_SetObjectDependency", + "func_800B3FC0": "ActorShadow_DrawCircle", + "func_800B4024": "ActorShadow_DrawSquare", + "func_800B4088": "ActorShadow_DrawWhiteCircle", + "func_800B40B8": "ActorShadow_DrawHorse", + "func_800B40E0": "ActorShadow_DrawFoot", + "func_800B42F8": "ActorShadow_DrawFeet", + "func_800B4A98": "Actor_SetFeetPos", + "Actor_SetSwitchFlag": "Flags_SetSwitch", + "Actor_UnsetSwitchFlag": "Flags_UnsetSwitch", + "Actor_GetChestFlag": "Flags_GetTreasure", + "Actor_SetChestFlag": "Flags_SetTreasure", + "Actor_SetAllChestFlag": "Flags_SetAllTreasure", + "Actor_GetAllChestFlag": "Flags_GetAllTreasure", + "Actor_GetRoomCleared(": "Flags_GetClear(", + "Actor_SetRoomCleared(": "Flags_SetClear(", + "Actor_UnsetRoomCleared(": "Flags_UnsetClear(", + "Actor_GetRoomClearedTemp(": "Flags_GetClearTemp(", + "Actor_SetRoomClearedTemp(": "Flags_SetClearTemp(", + "Actor_UnsetRoomClearedTemp(": "Flags_UnsetTempClear(", + "Actor_GetCollectibleFlag": "Flags_GetCollectible", + "Actor_SetCollectibleFlag": "Flags_SetCollectible", + "func_800B8A1C": "Actor_PickUp", + "func_800B8B84": "Actor_PickUpNearby", + "func_800B8BB0": "Actor_LiftActor", + "func_800B8BD0": "Actor_PickUpFar", + "func_801A5CFC": "Audio_PlaySfxGeneral", + "func_800BBDAC": "Actor_SpawnFloorDustRing", + "func_800B8708": "Player_GetExchangeItemId", + "func_801233E4": "Player_InCsMode", + "func_800BC4EC": "Actor_TestFloorInDirection", + "func_800BC5B8": "Actor_IsTargeted", + "func_800BC5EC": "Actor_OtherIsTargeted", + "func_800BCB70": "Actor_SetColorFilter", + "func_800BE0B8": "Actor_FindNearby", + "func_800BE258": "Actor_SetDropFlag", + "func_800BE2B8": "Actor_SetDropFlagJntSph", + "Actor_TitleCardCreate": "TitleCard_InitBossName", + "func_800B867C": "Actor_TextboxIsClosing", + "func_800BDC5C": "Actor_ChangeAnimation", + "func_80152498": "Message_GetState", + "func_800B8898": "Actor_GetScreenPos", + "Audio_PlayActorSound2": "Actor_PlaySfxAtPos", + "func_800BF7CC": "Actor_SpawnIceEffects", + "Actor_IsFacingPlayerAndWithinRange": "Actor_IsFacingAndNearPlayer", + "func_800BC8B8": "Actor_DrawDoorLock", + "func_800B86C8": "Actor_ChangeFocus", "zelda_malloc(": "ZeldaArena_Malloc(", "zelda_mallocR(": "ZeldaArena_MallocR(", "zelda_realloc": "ZeldaArena_Realloc", @@ -301,29 +375,15 @@ animdict = { "func_8017F9C0": "Math3D_XZInSphere", "func_8017FA34": "Math3D_XYInSphere", "func_8017FAA8": "Math3D_YZInSphere", + "func_8013A7C0": "SubS_FindDoor", + "func_8013E640": "SubS_FindActorCustom", + "func_ActorCategoryIterateById": "SubS_FindActor", + "func_8013BB7C": "SubS_FindNearestActor", "func_800A81F0": "EffectBlure_AddVertex", "func_800A8514": "EffectBlure_AddSpace", "Effect_GetParams": "Effect_GetByIndex", - "D_0407D590": "gGameplayKeepDrawFlameDL", - - "skelanime.unk03": "skelanime.taper", - "skelanime.animCurrentSeg": "skelanime.animation", - "skelanime.initialFrame": "skelanime.startFrame", - "skelanime.animFrameCount": "skelanime.endFrame", - "skelanime.totalFrames": "skelanime.animLength", - "skelanime.animCurrentFrame": "skelanime.curFrame", - "skelanime.animPlaybackSpeed": "skelanime.playSpeed", - "skelanime.limbDrawTbl": "skelanime.jointTable", - "skelanime.transitionDrawTbl": "skelanime.morphTable", - "skelanime.transCurrentFrame": "skelanime.morphWeight", - "skelanime.transitionStep": "skelanime.morphRate", - "skelanime.animUpdate": "skelanime.update", - "skelanime.flags": "skelanime.moveFlags", - "skelanime.prevFrameRot": "skelanime.prevRot", - "skelanime.prevFramePos": "skelanime.prevTransl", - "skelanime.unk3E": "skelanime.baseTransl", - + # Structs members "skelAnime.unk03": "skelAnime.taper", "skelAnime.animCurrentSeg": "skelAnime.animation", "skelAnime.initialFrame": "skelAnime.startFrame", @@ -340,16 +400,30 @@ animdict = { "skelAnime.prevFrameRot": "skelAnime.prevRot", "skelAnime.prevFramePos": "skelAnime.prevTransl", "skelAnime.unk3E": "skelAnime.baseTransl", + "actor.minVelocityY": "actor.terminalVelocity", "actor.yDistToWater" : "actor.depthInWater", - "actor.yDistToPlayer" : "actor.playerHeightRel", - + "actor.yDistToPlayer": "actor.playerHeightRel", "globalCtx->mf_187FC" : "globalCtx->billboardMtxF", "globalCtx->projectionMatrix" : "globalCtx->viewProjectionMtxF", + "player->unk_A87": "player->exchangeItemId", + "player->leftHandActor": "player->heldActor", + "player->unk_384": "player->getItemId", + "player->unk_386": "player->getItemDirection", + "player->unk_388": "player->interactRangeActor", + "player->unk_38C": "player->mountSide", + "player->unk_394": "player->csMode", + "player->unk_A87": "player->exchangeItemId", + "globalCtx->actorCtx.actorList[": "globalCtx->actorCtx.actorLists[", - "D_801D15B0" : "gZeroVec3f", - "D_801D15BC" : "gZeroVec3s", - "D_801D1DE0" : "gIdentityMtx", - "D_801D1E20" : "gIdentityMtxF", + # Variables + "D_0407D590": "gGameplayKeepDrawFlameDL", + "D_801D15B0": "gZeroVec3f", + "D_801D15BC": "gZeroVec3s", + "D_801D1DE0": "gIdentityMtx", + "D_801D1E20": "gIdentityMtxF", + + "ICHAIN_F32_DIV1000(minVelocityY,": "ICHAIN_F32_DIV1000(terminalVelocity,", + "ICHAIN_F32(minVelocityY,": "ICHAIN_F32(terminalVelocity,", } def replace_anim(file): diff --git a/tools/disasm/disasm.py b/tools/disasm/disasm.py index 42473379e2..e0b7705ea0 100755 --- a/tools/disasm/disasm.py +++ b/tools/disasm/disasm.py @@ -4,9 +4,20 @@ import argparse, ast, math, os, re, struct import bisect from mips_isa import * from multiprocessing import * +from pathlib import Path parser = argparse.ArgumentParser() -parser.add_argument('-j', dest='jobs', type=int, default=1, help='number of processes to run at once') +parser.add_argument( + "-j", dest="jobs", type=int, default=1, help="number of processes to run at once" +) +parser.add_argument( + "--full", + "-f", + dest="full", + action="store_true", + default=False, + help="Decompile all files regardless of whether they are used or not", +) args = parser.parse_args() jobs = args.jobs @@ -14,127 +25,242 @@ jobs = args.jobs ASM_OUT = "asm/" DATA_OUT = "data/" + +def discard_decomped_files(files_spec): + root_path = Path(__file__).parent.parent.parent + + with open(root_path / "spec", "r") as f: + spec = f.read() + # No need to check anything beyond here + spec = spec[: spec.find('name "gameplay_keep"')].splitlines()[:-2] + + new_spec = [] + for f in files_spec: + name, _, type, _, file_list = f + + # Find the beginseg for this file + i = 0 + while i < len(spec): + if spec[i].startswith("beginseg") and f'"{name}"' in spec[i + 1]: + break + i += 1 + + # For every file within this segment, look through the seg for lines with this file's name + # if found, check whether it's still in build/asm/ or build/data/, in which case it's not decomped + # if all references to it are in build/src/ then it should be ok to skip, some code/boot files are a bit different + + seg_start = i + new_files = {} + included = False + saved_off = 0 + for offset, file in file_list.items(): + if file == "[PADDING]": + continue + + # some files aren't named + if file == "": + file = f"{type}_{offset:08X}" + include = True + # flg_set_table is not in the spec, and buffers has its own section, just add them + elif file == "flg_set_table" or "buffers" in file: + include = True + else: + include = False + i = seg_start + last_line = "" + while not spec[i].startswith("endseg"): + if f"/{file}." in spec[i]: + if spec[i].count(".") == 1: + last_line = spec[i] + if "build/asm/" in spec[i] or "build/data/" in spec[i]: + include = True + break + i += 1 + else: + # Many code/boot files only have a single section (i.e .text) + # In that case it will be inside build/src/ and pragma in the asm + # For these files, open the source and look for the pragmas to be sure + # Overlays always have at least a data section we can check in the spec, so it's not needed for them + if type != "overlay" and last_line != "": + assert last_line.count(".") == 1 + last_line = ( + last_line.strip() + .split("build/", 1)[1] + .replace(".o", ".c")[:-1] + ) + with open(root_path / last_line, "r") as f2: + if "GLOBAL_ASM" in f2.read(): + include = True + + if include: + new_files[offset] = file + included = True + + if type == "overlay" and not included: + continue + if included: + f[4] = new_files + + new_spec.append(f) + + return new_spec + + MIPS_BRANCH_LIKELY_INSNS = [ - MIPS_INS_BEQL, MIPS_INS_BGEZALL, - MIPS_INS_BGEZL, MIPS_INS_BGTZL, - MIPS_INS_BLEZL, MIPS_INS_BLTZALL, - MIPS_INS_BLTZL, MIPS_INS_BNEL, - MIPS_INS_BC1TL, MIPS_INS_BC1FL, + MIPS_INS_BEQL, + MIPS_INS_BGEZALL, + MIPS_INS_BGEZL, + MIPS_INS_BGTZL, + MIPS_INS_BLEZL, + MIPS_INS_BLTZALL, + MIPS_INS_BLTZL, + MIPS_INS_BNEL, + MIPS_INS_BC1TL, + MIPS_INS_BC1FL, ] MIPS_BRANCH_INSNS = [ *MIPS_BRANCH_LIKELY_INSNS, MIPS_INS_BEQ, - MIPS_INS_BGEZ, MIPS_INS_BGEZAL, + MIPS_INS_BGEZ, + MIPS_INS_BGEZAL, MIPS_INS_BGTZ, MIPS_INS_BNE, - MIPS_INS_BLTZ, MIPS_INS_BLTZAL, + MIPS_INS_BLTZ, + MIPS_INS_BLTZAL, MIPS_INS_BLEZ, - MIPS_INS_BC1T, MIPS_INS_BC1F, - + MIPS_INS_BC1T, + MIPS_INS_BC1F, MIPS_INS_BEQZ, MIPS_INS_BNEZ, MIPS_INS_B, ] -MIPS_JUMP_INSNS = [ - MIPS_INS_JAL, MIPS_INS_JALR, MIPS_INS_J, MIPS_INS_JR -] +MIPS_JUMP_INSNS = [MIPS_INS_JAL, MIPS_INS_JALR, MIPS_INS_J, MIPS_INS_JR] -MIPS_FP_LOAD_INSNS = [ - MIPS_INS_LWC1, MIPS_INS_LDC1 -] +MIPS_FP_LOAD_INSNS = [MIPS_INS_LWC1, MIPS_INS_LDC1] -MIPS_FP_STORE_INSNS = [ - MIPS_INS_SWC1, MIPS_INS_SDC1 -] +MIPS_FP_STORE_INSNS = [MIPS_INS_SWC1, MIPS_INS_SDC1] -MIPS_FP_LOAD_STORE_INSNS = [ - *MIPS_FP_LOAD_INSNS, *MIPS_FP_STORE_INSNS -] +MIPS_FP_LOAD_STORE_INSNS = [*MIPS_FP_LOAD_INSNS, *MIPS_FP_STORE_INSNS] MIPS_STORE_INSNS = [ - MIPS_INS_SB, - MIPS_INS_SH, - MIPS_INS_SW, MIPS_INS_SWL, MIPS_INS_SWR, - MIPS_INS_SD, MIPS_INS_SDL, MIPS_INS_SDR, - MIPS_INS_SC, MIPS_INS_SCD, - *MIPS_FP_STORE_INSNS + MIPS_INS_SB, + MIPS_INS_SH, + MIPS_INS_SW, + MIPS_INS_SWL, + MIPS_INS_SWR, + MIPS_INS_SD, + MIPS_INS_SDL, + MIPS_INS_SDR, + MIPS_INS_SC, + MIPS_INS_SCD, + *MIPS_FP_STORE_INSNS, ] MIPS_LOAD_STORE_INSNS = [ - MIPS_INS_LB, MIPS_INS_LBU, - MIPS_INS_LH, MIPS_INS_LHU, - MIPS_INS_LW, MIPS_INS_LWL, MIPS_INS_LWR, MIPS_INS_LWU, - MIPS_INS_LD, MIPS_INS_LDL, MIPS_INS_LDR, - MIPS_INS_LL, MIPS_INS_LLD, + MIPS_INS_LB, + MIPS_INS_LBU, + MIPS_INS_LH, + MIPS_INS_LHU, + MIPS_INS_LW, + MIPS_INS_LWL, + MIPS_INS_LWR, + MIPS_INS_LWU, + MIPS_INS_LD, + MIPS_INS_LDL, + MIPS_INS_LDR, + MIPS_INS_LL, + MIPS_INS_LLD, *MIPS_STORE_INSNS, - *MIPS_FP_LOAD_STORE_INSNS + *MIPS_FP_LOAD_STORE_INSNS, ] -functions = set() # vram of functions -data_labels = set() # vram of data labels, TODO this + functions can merge into something more general eventually +VRAM_BASE = { + "code": {"data": 0x801AAAB0, "rodata": 0x801DBDF0, "bss": 0x801E3FA0}, + "boot": {"data": 0x800969C0, "rodata": 0x80098190, "bss": 0x80099500}, +} +functions = set() # vram of functions +# vram of data labels, TODO this + functions can merge into something more general eventually +data_labels = set() branch_labels = set() # vram of branch labels via branch/jump instructions -jtbls = set() # vram of jump tables -jtbl_labels = set() # vram of branch labels via jtbls, higher output priority than regular branch labels -floats = set() # vram of floats -doubles = set() # vram of doubles -prospective_strings = set() # vram of possible strings -strings = set() # vram of confirmed strings -symbols = {} # lui/addiu pairs : {addr of %hi : full symbol} AND {addr of %lo : full symbol} , twice the space complexity but much less time complexity -constants = {} # lui/ori pairs : {addr of %hi : full constant} AND {addr of %lo : full constant} , twice the space complexity but much less time complexity -dwords = set() # doublewords -multiply_referenced_rodata = set() # rodata with more than 1 reference outside of the same function cannot be migrated +jtbls = set() # vram of jump tables +# vram of branch labels via jtbls, higher output priority than regular branch labels +jtbl_labels = set() +floats = set() # vram of floats +doubles = set() # vram of doubles +prospective_strings = set() # vram of possible strings +strings = set() # vram of confirmed strings +# lui/addiu pairs : {addr of %hi : full symbol} AND {addr of %lo : full symbol} , +# twice the space complexity but much less time complexity +symbols = {} +# lui/ori pairs : {addr of %hi : full constant} AND {addr of %lo : full constant} , +# twice the space complexity but much less time complexity +constants = {} +dwords = set() # doublewords +# rodata with more than 1 reference outside of the same function cannot be migrated +multiply_referenced_rodata = set() +files = set() # vram start of file -files = set() # vram start of file - -vrom_variables = list() # (name,addr) -vrom_addrs = set() # set of addrs from vrom_variables, for faster lookup +vrom_variables = list() # (name,addr) +vrom_addrs = set() # set of addrs from vrom_variables, for faster lookup functions_ast = None variables_ast = None variable_addrs = None +files_text = {} + + def proper_name(symbol, in_data=False, is_symbol=True): # hacks - if symbol == 0x809C46F0: # ovl_En_Encount4 fake symbol at the very end of the data section + # ovl_En_Encount4 fake symbol at the very end of the data section + if symbol == 0x809C46F0: return variables_ast[0x809C46DC][0] + " + 0x14" - elif symbol == 0x801EF66D: # z_message_nes constant-folding stray fairy array + elif symbol == 0x801EF66D: # z_message_nes constant-folding stray fairy array return variables_ast[0x801EF670][0] + f" - 0x{0x801EF670 - 0x801EF66D:X}" - elif symbol == 0x80A09740: # boss_07 symbol with large addend folded into %lo + elif symbol == 0x80A09740: # boss_07 symbol with large addend folded into %lo return variables_ast[0x80A09A60][0] + f" - 0x{0x80A09A60 - 0x80A09740:X}" - elif symbol == 0x80B80248: # bg_ikana_mirror symbol with large addend folded into %lo + # bg_ikana_mirror symbol with large addend folded into %lo + elif symbol == 0x80B80248: return variables_ast[0x80B801A8][0] + f" + 0x{0x80B80248 - 0x80B801A8:X}" - elif symbol == 0x8084D2FC: # player symbol with very large addend folded into %lo, since we don't know the real symbol just use the first data symbol for now + # player symbol with very large addend folded into %lo, since we don't know the real symbol just use the first data symbol for now + elif symbol == 0x8084D2FC: return variables_ast[0x8085B9F0][0] + f" - 0x{0x8085B9F0 - 0x8084D2FC:X}" - elif symbol == 0x001ABAB0 or symbol == 0x001E3BB0: # OS_K0_TO_PHYSICAL on rspS2DEX text and data symbols + # OS_K0_TO_PHYSICAL on rspS2DEX text and data symbols + elif symbol == 0x001ABAB0 or symbol == 0x001E3BB0: return variables_ast[symbol + 0x80000000][0] + " - 0x80000000" - elif symbol == 0x00AC0480: # do_action_static + 0x480, this is the only rom segment that has a constant offset folded into it so just hack it + # do_action_static + 0x480, this is the only rom segment that has a constant offset folded into it so just hack it + elif symbol == 0x00AC0480: return "_do_action_staticSegmentRomStart + 0x480" # real names - if symbol in functions and symbol in functions_ast.keys(): + if symbol in functions_ast.keys(): return functions_ast[symbol][0] elif symbol in variables_ast.keys(): return variables_ast[symbol][0] elif symbol in vrom_addrs: # prefer "start" vrom symbols - if symbol in [addr for name,addr in vrom_variables if "SegmentRomStart" in name]: - return [name for name,addr in vrom_variables if "SegmentRomStart" in name and addr == symbol][0] + filteredVromSymbols = { + addr: name + for name, addr in vrom_variables + if "SegmentRomStart" in name and addr == symbol + } + if symbol in filteredVromSymbols: + return filteredVromSymbols[symbol] else: - return [name for name,addr in vrom_variables if addr == symbol][0] + return [name for name, addr in vrom_variables if addr == symbol][0] # addends if is_symbol: symbol_index = bisect.bisect(variable_addrs, symbol) if symbol_index: - vram_addr = variable_addrs[symbol_index-1] + vram_addr = variable_addrs[symbol_index - 1] symbol_name, _, _, symbol_size = variables_ast[vram_addr] if vram_addr < symbol < vram_addr + symbol_size: return f"{symbol_name} + 0x{symbol-vram_addr:X}" - # generated names if symbol in functions and not in_data: return f"func_{symbol:08X}" @@ -148,63 +274,77 @@ def proper_name(symbol, in_data=False, is_symbol=True): else: return f"0x{symbol:08X}" + def lookup_name(symbol, word): # hacks for vrom variables in data if word in vrom_addrs: - if word == 0: # no makerom segment start + if word == 0: # no makerom segment start return "0x00000000" - if symbol in [0x801AE4A0, # effect table - 0x801C2740, # object table - 0x801C2650, # elf_message table - 0x801C3CA0, # scene table - 0x801AEFD0, # actor table - 0x801D0B70, # kaleido table - 0x801D0BB0, # fbdemo table - 0x801BE4D4, # kankyo skybox table - 0x801BD910, # gamestate table - 0x801C2660 # scene textures table - ]: # data labels that are allowed to have vrom variables + if symbol in [ + 0x801AE4A0, # effect table + 0x801C2740, # object table + 0x801C2650, # elf_message table + 0x801C3CA0, # scene table + 0x801AEFD0, # actor table + 0x801D0B70, # kaleido table + 0x801D0BB0, # fbdemo table + 0x801BE4D4, # kankyo skybox table + 0x801BD910, # gamestate table + 0x801C2660, # scene textures table + ]: # data labels that are allowed to have vrom variables return proper_name(word, is_symbol=False) else: return f"0x{word:08X}" # hacks for variables with references to variables with addends (i.e. gSaveContext + 0x...) - if symbol in [0x800980C4, 0x801AE8F0]: # __osViNext and flg_set table + if symbol in [0x800980C4, 0x801AE8F0]: # __osViNext and flg_set table return proper_name(word, is_symbol=True) return proper_name(word, is_symbol=False) + def as_double(b): return struct.unpack(">d", b)[0] + def as_float(b): return struct.unpack(">f", b)[0] + def as_dword(b): return struct.unpack(">Q", b)[0] + def as_word(b): return struct.unpack(">I", b)[0] + def as_hword(b): return struct.unpack(">H", b)[0] + def as_double_list(b): return [i[0] for i in struct.iter_unpack(">d", b)] + def as_float_list(b): return [i[0] for i in struct.iter_unpack(">f", b)] + def as_dword_list(b): return [i[0] for i in struct.iter_unpack(">Q", b)] + def as_word_list(b): return [i[0] for i in struct.iter_unpack(">I", b)] + def as_hword_list(b): return [h[0] for h in struct.iter_unpack(">H", b)] + STR_INDENT = " " -def try_decode_string(data_bytes, output_ends = True, force_ascii = False): + +def try_decode_string(data_bytes, output_ends=True, force_ascii=False): """ Swiss Cheese """ @@ -225,20 +365,49 @@ def try_decode_string(data_bytes, output_ends = True, force_ascii = False): char = "\\x1B" index = data_bytes.index(0x1B) else: - assert False , "???" + assert False, "???" part1 = try_decode_string(data_bytes[0:index], output_ends=False) - part2 = try_decode_string(data_bytes[index+1:], output_ends=False) + part2 = try_decode_string(data_bytes[index + 1 :], output_ends=False) if part2 != "": - result = part1 + (("\"\n" + STR_INDENT + ".ascii \"") if part2[0] in hex_digits and part1 != "" else "") + \ - char + (("\"\n" + STR_INDENT + ".asciz \"") if part2[0] in hex_digits else "") + part2 + result = ( + part1 + + ( + ('"\n' + STR_INDENT + '.ascii "') + if part2[0] in hex_digits and part1 != "" + else "" + ) + + char + + (('"\n' + STR_INDENT + '.asciz "') if part2[0] in hex_digits else "") + + part2 + ) if output_ends and part2[0] in hex_digits and part1 == "": directive = "ascii" else: - result = part1 + (("\"\n" + STR_INDENT + ".ascii \"") if part2[0] in hex_digits and part1 != "" else "") + char + "\"\n" + result = ( + part1 + + ( + ('"\n' + STR_INDENT + '.ascii "') + if part2[0] in hex_digits and part1 != "" + else "" + ) + + char + + '"\n' + ) else: - result = data_bytes.decode("EUC-JP").replace("\n", "\\n").replace("\r", "\\r").replace("\t", "\\t").replace("\0", "") + result = ( + data_bytes.decode("EUC-JP") + .replace("\n", "\\n") + .replace("\r", "\\r") + .replace("\t", "\\t") + .replace("\0", "") + ) + + return ( + (("." + directive + ' "') if output_ends else "") + + result + + ('"' if output_ends else "") + ) - return (("." + directive + " \"") if output_ends else "") + result + ("\"" if output_ends else "") def reduce_float(flt_str, is_double=False): def n_digits(str): @@ -249,8 +418,8 @@ def reduce_float(flt_str, is_double=False): def str_round(string, precision): if "." not in string or precision < 0: return string - int_part = string.split(".")[0] - frac_part = string.split(".")[1] + int_part = string.split(".")[0] + frac_part = string.split(".")[1] while len(frac_part) > precision: last_digit = int(frac_part[-1]) @@ -271,7 +440,9 @@ def reduce_float(flt_str, is_double=False): return int_part + "." + frac_part def to_binary(flt_str): - return as_dword(struct.pack(">d", float(flt_str))) if is_double else as_word(struct.pack(">f", float(flt_str))) + if is_double: + return as_dword(struct.pack(">d", float(flt_str))) + return as_word(struct.pack(">f", float(flt_str))) exponent = "" if "e" in flt_str: @@ -300,18 +471,20 @@ def reduce_float(flt_str, is_double=False): return flt_str + exponent + def format_f64(d_dwd): d = as_double(struct.pack(">Q", d_dwd)) if math.isnan(d): return f".long 0x{d_dwd:016X}" return f".double {reduce_float(repr(d), is_double=True)}" + def format_f32(f_wd): # GNU AS isn't ieee compliant? if f_wd in [0xB8E4AECD, 0xB8E4C3AA, 0x38D1B718]: return f".word 0x{f_wd:08X}" - if f_wd == 0x7F7FFFFF: # FLT_MAX + if f_wd == 0x7F7FFFFF: # FLT_MAX return ".float 3.4028235e+38" f = as_float(struct.pack(">I", f_wd)) @@ -319,19 +492,30 @@ def format_f32(f_wd): return f".word 0x{f_wd:08X}" return f".float {reduce_float(repr(f))}" + def put_symbol(symbols_dict, setname, symbol): if setname in symbols_dict: symbols_dict[setname].add(symbol) else: symbols_dict[setname] = {symbol} + def put_symbols(symbols_dict, setname, symbols): if setname in symbols_dict: symbols_dict[setname].update(symbols) else: symbols_dict[setname] = symbols.copy() + +def put_text(name, text): + files_text[name] = text + + def update_symbols_from_dict(symbols_dict): + file_text = [] + if type(symbols_dict) == tuple: + symbols_dict, file_text = symbols_dict + for setname, symbol in symbols_dict.items(): if setname == "functions": functions.update(symbol) @@ -360,10 +544,18 @@ def update_symbols_from_dict(symbols_dict): elif setname == "files": files.update(symbol) -def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, segment_name): + for file in file_text: + put_text(file[0], file[1]) + + +def find_symbols_in_text(section, rodata_section, data_regions): + data, rodata = section[4], rodata_section[4] if rodata_section else None + vram, vram_rodata = section[0], rodata_section[0] if rodata_section else None + relocs, info = section[5], section[-1] + symbols_dict = dict() - print(f"Finding symbols from .text in {segment_name}") + print(f"Finding symbols from .text in {info['name']}") if rodata is not None: rodata_words = as_word_list(rodata) @@ -376,14 +568,15 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, put_symbol(symbols_dict, "files", vram) # lui trackers are saved at branches to be restored when the branch target is reached - saved_lui_trackers = {} # vram: tracker list + saved_lui_trackers = {} # vram: tracker list + def save_tracker(restore_at, tracker): if restore_at in saved_lui_trackers.keys(): saved_lui_trackers[restore_at].update(tracker) else: saved_lui_trackers.update({restore_at: tracker}) - lui_tracker = {} # register : (addr, immediate) + lui_tracker = {} # register : (addr, immediate) prospective_jtbls = set() @@ -391,7 +584,7 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, func_jtbl_labels = set() individual_jtbl_labels = {} - clobber_later = {} # addr : reg + clobber_later = {} # addr : reg delay_slot = False delayed_insn = None @@ -409,8 +602,14 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, # print(f"insn: {insn.mnemonic}, rt: {insn.rt}, first: {insn.value_forname(insn.fields[0])}") # assert insn.id not in [MIPS_INS_ORI, MIPS_INS_ADDIU, *MIPS_LOAD_STORE_INSNS] or insn.rt == insn.value_forname(insn.fields[0]) - if delay_slot and delayed_insn is not None and delayed_insn.id in MIPS_BRANCH_LIKELY_INSNS: - clobber_later.update({delayed_insn.offset : insn.value_forname(insn.fields[0])}) + if ( + delay_slot + and delayed_insn is not None + and delayed_insn.id in MIPS_BRANCH_LIKELY_INSNS + ): + clobber_later.update( + {delayed_insn.offset: insn.value_forname(insn.fields[0])} + ) else: lui_tracker.pop(insn.value_forname(insn.fields[0]), None) @@ -420,45 +619,9 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, if region[1] % 0x10 == 0: put_symbol(symbols_dict, "files", region[1]) - if relocs is not None: - """ - Relocation info is our friend. Get symbols via relocations first. - """ - prev_hi = None - hi_vram = -1 - for reloc in relocs: - insn = decode_insn(raw_insns[reloc[2]//4], vram + reloc[2]) - - if reloc[1] == 2: # R_MIPS_32 - assert False , "R_MIPS_32 in .text section?" - elif reloc[1] == 4: # R_MIPS_26 - """ - Relocated jump targets give us functions in this section - """ - assert insn.id == MIPS_INS_JAL , f"R_MIPS_26 applied to {insn.mnemonic} when it should be JAL" - put_symbol(symbols_dict, "functions", insn.target) - elif reloc[1] == 5: # R_MIPS_HI16 - """ - Relocated %hi gives us %hi values to match with associated %lo - """ - assert insn.id == MIPS_INS_LUI , f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be LUI" - prev_hi = insn.imm - hi_vram = vram + reloc[2] - elif reloc[1] == 6: # R_MIPS_LO16 - """ - Relocated %lo + a %hi to match with gives us relocated symbols in data sections - """ - assert insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS , f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be ADDIU or a load/store" - symbol_value = (prev_hi << 0x10) + insn.imm - put_symbols(symbols_dict, "symbols", {hi_vram : symbol_value}) - put_symbols(symbols_dict, "symbols", {vram + reloc[2] : symbol_value}) - else: - assert False , "Invalid relocation type encountered" - - for i,raw_insn in enumerate(raw_insns,0): - i *= 4 - vaddr = vram + i - insn = decode_insn(raw_insn, vaddr) + insns = [] + for i, raw_insn in enumerate(raw_insns, 0): + insn = decode_insn(raw_insn, vram + i * 4) if insn.id == MIPS_INS_JR and insn.rs != MIPS_REG_RA: # It's hard to find when two jump tables next to each other end, so do a naive first pass @@ -469,17 +632,72 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, # addu $at, $at, $reg # lw $reg, %lo(jtbl)($at) # jr $reg - insn_m1 = decode_insn(raw_insns[i//4 - 1], vaddr - 0x4) - insn_m2 = decode_insn(raw_insns[i//4 - 2], vaddr - 0x8) - insn_m3 = decode_insn(raw_insns[i//4 - 3], vaddr - 0xC) - - if insn_m1.id == MIPS_INS_LW and insn_m2.id == MIPS_INS_ADDU and insn_m3.id == MIPS_INS_LUI: + insn_m1 = insns[-1] + insn_m2 = insns[-2] + insn_m3 = insns[-3] + if ( + insn_m1.id == MIPS_INS_LW + and insn_m2.id == MIPS_INS_ADDU + and insn_m3.id == MIPS_INS_LUI + ): prospective_jtbls.add((insn_m3.imm << 0x10) + insn_m1.imm) + insns.append(insn) - for i,raw_insn in enumerate(raw_insns,0): - i *= 4 - vaddr = vram + i - insn = decode_insn(raw_insn, vaddr) + if relocs is not None: + """ + Relocation info is our friend. Get symbols via relocations first. + """ + prev_hi = None + hi_vram = -1 + for reloc in relocs: + insn = insns[reloc[2] // 4] + + if reloc[1] == 2: # R_MIPS_32 + assert False, "R_MIPS_32 in .text section?" + elif reloc[1] == 4: # R_MIPS_26 + """ + Relocated jump targets give us functions in this section + """ + assert ( + insn.id == MIPS_INS_JAL + ), f"R_MIPS_26 applied to {insn.mnemonic} when it should be JAL" + put_symbol(symbols_dict, "functions", insn.target) + elif reloc[1] == 5: # R_MIPS_HI16 + """ + Relocated %hi gives us %hi values to match with associated %lo + """ + assert ( + insn.id == MIPS_INS_LUI + ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be LUI" + prev_hi = insn.imm + hi_vram = vram + reloc[2] + elif reloc[1] == 6: # R_MIPS_LO16 + """ + Relocated %lo + a %hi to match with gives us relocated symbols in data sections + """ + assert ( + insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS + ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be ADDIU or a load/store" + symbol_value = (prev_hi << 0x10) + insn.imm + put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) + put_symbols(symbols_dict, "symbols", {vram + reloc[2]: symbol_value}) + else: + assert False, "Invalid relocation type encountered" + + result_files = [] + results = [asm_header(".text")] + raw_insns = as_word_list(data) + + cur_file = "" + cur_vaddr = 0 + + segment_dirname = ("" if info["type"] != "overlay" else "overlays/") + info["name"] + + delayed_insn = None + delay_slot = False + + for i, insn in enumerate(insns, 0): + vaddr = vram + i * 4 # sometimes there's data embedded in .text in handwritten asm files that don't respect section contents in_data = False @@ -488,6 +706,16 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, in_data = True break if in_data: + results.append( + { + "vaddr": vaddr, + "insn": {"id": insn.id}, + "addr": f"/* {i*4:06X} {vaddr:08X} {raw_insns[i]:08X} */ ", + "mnem": "", + "op": [f" .word 0x{raw_insns[i]:08X}"], + "data": True, + } + ) continue if vaddr in functions or vaddr in symbols_dict["functions"]: @@ -525,64 +753,99 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, func_branch_labels.add(insn.target) elif insn.id == MIPS_INS_JR: # check if anything branches past it in either branch or jtbl labels - if vaddr >= max(func_branch_labels, default=0) and vaddr >= max(func_jtbl_labels, default=0): # vaddr being largest in list means nothing branches past here + if vaddr >= max(func_branch_labels, default=0) and vaddr >= max( + func_jtbl_labels, default=0 + ): # vaddr being largest in list means nothing branches past here # mark next function after delay slot and after any nop padding if present - if len(raw_insns) > i//4 + 2: + if len(insns) > i + 2: n_padding = 0 end = False - while (raw_insns[i//4 + 2 + n_padding] == 0): + while raw_insns[i + 2 + n_padding] == 0: n_padding += 1 - if len(raw_insns) <= i//4 + 2 + n_padding: + if len(raw_insns) <= i + 2 + n_padding: end = True break if not end: if n_padding > 0: - assert (vaddr + 8 + n_padding * 4) % 0x10 == 0 , f"padding to non-0x10 alignment?, 0x{vaddr + 8 + n_padding * 4:08X}" - put_symbol(symbols_dict, "functions", vaddr + 8 + n_padding * 4) - put_symbol(symbols_dict, "functions", vaddr + 8 + n_padding * 4) + assert ( + vaddr + 8 + n_padding * 4 + ) % 0x10 == 0, f"padding to non-0x10 alignment?, 0x{vaddr + 8 + n_padding * 4:08X}" + put_symbol( + symbols_dict, "functions", vaddr + 8 + n_padding * 4 + ) + put_symbol( + symbols_dict, "functions", vaddr + 8 + n_padding * 4 + ) delayed_insn = insn elif insn.id == MIPS_INS_LUI: """ Process LUI instruction - + All symbol loading involves LUI, and tracking how %hi values loaded via LUI instructions propagate through a function is key to identifying symbol references """ # add lui to tracker - if delay_slot and delayed_insn is not None and delayed_insn.id in MIPS_BRANCH_LIKELY_INSNS: + if ( + delay_slot + and delayed_insn is not None + and delayed_insn.id in MIPS_BRANCH_LIKELY_INSNS + ): # for branch likelies, the current tracker does not update but the lui is saved to be tracked at the branch target - save_tracker(delayed_insn.offset, {insn.rt : (vaddr, insn.imm)}) + save_tracker(delayed_insn.offset, {insn.rt: (vaddr, insn.imm)}) else: - lui_tracker.update({insn.rt : (vaddr, insn.imm)}) + lui_tracker.update({insn.rt: (vaddr, insn.imm)}) elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: # try match with tracked lui and mark symbol - hi_vram, imm_value = lui_tracker.get(insn.rs if insn.id == MIPS_INS_ADDIU else insn.base, (None, None)) + hi_vram, imm_value = lui_tracker.get( + insn.rs if insn.id == MIPS_INS_ADDIU else insn.base, (None, None) + ) # if a match was found, validate and record the symbol, TODO improve validation - if hi_vram != None and ((((imm_value >> 0x8) & 0xF) != 0 and imm_value < 0x1000) or \ - (imm_value >= 0x8000 and imm_value < 0x80D0) or \ - (imm_value >= 0xA400 and imm_value < 0xA480) or (imm_value < 0x0400 and insn.id == MIPS_INS_ADDIU)): + if hi_vram != None and ( + (((imm_value >> 0x8) & 0xF) != 0 and imm_value < 0x1000) + or (imm_value >= 0x8000 and imm_value < 0x80D0) + or (imm_value >= 0xA400 and imm_value < 0xA480) + or (imm_value < 0x0400 and insn.id == MIPS_INS_ADDIU) + ): lo_vram = vaddr symbol_value = (imm_value << 0x10) + insn.imm - put_symbols(symbols_dict, "symbols", {hi_vram : symbol_value}) - put_symbols(symbols_dict, "symbols", {lo_vram : symbol_value}) + put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) + put_symbols(symbols_dict, "symbols", {lo_vram: symbol_value}) if insn.id == MIPS_INS_LW: # try find jr within the same block - cur_idx = i//4 - lookahead_insn = decode_insn(raw_insns[cur_idx], vram + cur_idx * 4) # TODO fix vaddr here + cur_idx = i + lookahead_insn = insns[cur_idx] # TODO fix vaddr here # still in same block unless one of these instructions are found - while lookahead_insn.id not in [*MIPS_BRANCH_INSNS, MIPS_INS_JAL, MIPS_INS_JALR, MIPS_INS_J]: + while lookahead_insn.id not in [ + *MIPS_BRANCH_INSNS, + MIPS_INS_JAL, + MIPS_INS_JALR, + MIPS_INS_J, + ]: if lookahead_insn.id == MIPS_INS_JR: - if lookahead_insn.rs == (insn.ft if insn.id in MIPS_FP_LOAD_STORE_INSNS else insn.rt): + if lookahead_insn.rs == ( + insn.ft + if insn.id in MIPS_FP_LOAD_STORE_INSNS + else insn.rt + ): # read the jtbl and add targets to func_jtbl_labels - assert rodata is not None , "A rodata section should be present if functions use jump tables" + assert ( + rodata is not None + ), "A rodata section should be present if functions use jump tables" next_jtbl_jr = vaddr + cur_idx * 4 - individual_jtbl_labels.update({next_jtbl_jr : set()}) + individual_jtbl_labels.update({next_jtbl_jr: set()}) - offset = (symbol_value - vram_rodata)//4 + offset = (symbol_value - vram_rodata) // 4 label = rodata_words[offset] - while label >= vram and label < vram + len(data) and \ - (vram_rodata + offset * 4 not in prospective_jtbls or vram_rodata + offset * 4 == symbol_value): + while ( + label >= vram + and label < vram + len(data) + and ( + vram_rodata + offset * 4 + not in prospective_jtbls + or vram_rodata + offset * 4 == symbol_value + ) + ): func_jtbl_labels.add(label) individual_jtbl_labels[next_jtbl_jr].add(label) offset += 1 @@ -593,44 +856,55 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, put_symbol(symbols_dict, "jtbls", symbol_value) # found a jr that matches, no need to keep searching break - elif (insn.ft if insn.id in MIPS_FP_LOAD_STORE_INSNS else insn.rt) in [lookahead_insn.value_forname(field) for field in lookahead_insn.fields[1:]]: + elif ( + insn.ft if insn.id in MIPS_FP_LOAD_STORE_INSNS else insn.rt + ) in [ + lookahead_insn.value_forname(field) + for field in lookahead_insn.fields[1:] + ]: # register clobbered, no need to keep searching break cur_idx += 1 # found end before finding jr insn, not a jtbl if cur_idx >= len(raw_insns): break - lookahead_insn = decode_insn(raw_insns[cur_idx], vram + cur_idx * 4) # TODO fix vaddr here - elif insn.id == MIPS_INS_LD: # doubleword loads + lookahead_insn = insns[cur_idx] # TODO fix vaddr here + elif insn.id == MIPS_INS_LD: # doubleword loads put_symbol(symbols_dict, "dwords", symbol_value) - elif insn.id in [MIPS_INS_LWC1, MIPS_INS_SWC1]: # float load/stores + elif insn.id in [MIPS_INS_LWC1, MIPS_INS_SWC1]: # float load/stores # add float put_symbol(symbols_dict, "floats", symbol_value) - elif insn.id in [MIPS_INS_LDC1, MIPS_INS_SDC1]: # double load/stores + elif insn.id in [MIPS_INS_LDC1, MIPS_INS_SDC1]: # double load/stores # add double put_symbol(symbols_dict, "doubles", symbol_value) - elif insn.id == MIPS_INS_ADDIU and vaddr % 4 == 0: # strings seem to only ever be 4-byte aligned + elif ( + insn.id == MIPS_INS_ADDIU and vaddr % 4 == 0 + ): # strings seem to only ever be 4-byte aligned # add possible string put_symbol(symbols_dict, "prospective_strings", symbol_value) # clear lui tracking state if register is clobbered by the addiu/load instruction itself - # insn.rt == (insn.rs if insn.id == MIPS_INS_ADDIU else insn.base) and + # insn.rt == (insn.rs if insn.id == MIPS_INS_ADDIU else insn.base) and if insn.id not in MIPS_STORE_INSNS and insn.id not in MIPS_FP_LOAD_INSNS: clobber_conditionally(insn) elif insn.id == MIPS_INS_ORI: # try match with tracked lui and mark constant hi_vram, imm_value = lui_tracker.get(insn.rs, (None, None)) - if hi_vram != None: # found match + if hi_vram != None: # found match lo_vram = vaddr const_value = (imm_value << 0x10) | insn.imm - put_symbols(symbols_dict, "constants", {hi_vram : const_value}) - put_symbols(symbols_dict, "constants", {lo_vram : const_value}) + put_symbols(symbols_dict, "constants", {hi_vram: const_value}) + put_symbols(symbols_dict, "constants", {lo_vram: const_value}) # clear lui tracking state if register is clobbered by the ori instruction itself - # insn.rt == insn.rs or + # insn.rt == insn.rs or if insn.rt in lui_tracker.keys(): clobber_conditionally(insn) else: # clear lui tracking if register is clobbered by something unrelated - if insn.id == MIPS_INS_ADDU and insn.rs in lui_tracker.keys() and (insn.rd == insn.rs): + if ( + insn.id == MIPS_INS_ADDU + and insn.rs in lui_tracker.keys() + and (insn.rd == insn.rs) + ): # array accesses optimisation: # lui reg, %hi(symbol) # addu reg, reg, idx @@ -639,22 +913,113 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, # if the output is not currently tracked it will behave as intended anyway pass # insns listed either write to fprs/cop0 or don't write to any - elif insn.id not in [MIPS_INS_MTC0, MIPS_INS_MTC1, MIPS_INS_DMTC1, - MIPS_INS_MULT, MIPS_INS_MULTU, MIPS_INS_DMULT, MIPS_INS_DMULTU, - MIPS_INS_DIV, MIPS_INS_DIVU, MIPS_INS_DDIV, MIPS_INS_DDIVU, - MIPS_INS_MTHI, MIPS_INS_MTLO, - MIPS_INS_CTC1, - MIPS_INS_NOP, - MIPS_INS_BREAK, - MIPS_INS_TLBP, MIPS_INS_TLBR, MIPS_INS_TLBWI, - MIPS_INS_MOV_S, MIPS_INS_MOV_D, MIPS_INS_C_LT_S, MIPS_INS_C_LT_D, - MIPS_INS_DIV_S, MIPS_INS_MUL_S, MIPS_INS_TRUNC_W_S, MIPS_INS_CVT_S_W, - MIPS_INS_SUB_S, MIPS_INS_ADD_S]: + elif insn.id not in [ + MIPS_INS_MTC0, + MIPS_INS_MTC1, + MIPS_INS_DMTC1, + MIPS_INS_MULT, + MIPS_INS_MULTU, + MIPS_INS_DMULT, + MIPS_INS_DMULTU, + MIPS_INS_DIV, + MIPS_INS_DIVU, + MIPS_INS_DDIV, + MIPS_INS_DDIVU, + MIPS_INS_MTHI, + MIPS_INS_MTLO, + MIPS_INS_CTC1, + MIPS_INS_NOP, + MIPS_INS_BREAK, + MIPS_INS_TLBP, + MIPS_INS_TLBR, + MIPS_INS_TLBWI, + MIPS_INS_MOV_S, + MIPS_INS_MOV_D, + MIPS_INS_C_LT_S, + MIPS_INS_C_LT_D, + MIPS_INS_DIV_S, + MIPS_INS_MUL_S, + MIPS_INS_TRUNC_W_S, + MIPS_INS_CVT_S_W, + MIPS_INS_SUB_S, + MIPS_INS_ADD_S, + ]: clobber_conditionally(insn) + ############# Start text disassembly ########## + # Symbols aren't avaialble here yet, so placeholders are added + # in each instruction, to be looked up later + mnemonic = f" {insn.mnemonic}" if delay_slot else insn.mnemonic + op_str = insn.op_str + instr = {"id": insn.id} + + if vaddr in full_file_list[info["name"]]: + if cur_file != "": + if cur_vaddr in info["syms"]: + result_files.append([cur_file, results]) + results = [asm_header(".text")] + cur_vaddr = vaddr + cur_file = full_file_list[info["name"]][vaddr] + if cur_file == "": + cur_file = f"{info['name']}_{vaddr:08X}" + + if insn.id in MIPS_BRANCH_INSNS: + op_str_parts = [] + for field in insn.fields: + if field == "offset": + op_str_parts.append(f".L{insn.offset:08X}") + else: + op_str_parts.append(insn.format_field(field)) + op_str = [", ".join(op_str_parts)] + + elif insn.id in MIPS_JUMP_INSNS: + op_str = [] + op_str_parts = [] + for field in insn.fields: + if field == "target": + op_str_parts.append([insn.target, False, True]) + else: + op_str_parts.append(insn.format_field(field)) + for x, part in enumerate(op_str_parts): + if x + 1 < len(op_str_parts): + part += ", " + op_str.append(part) + + elif insn.id == MIPS_INS_LUI: + op_str = [op_str] + instr["rt"] = insn.rt + + elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + op_str = [op_str] + instr["rt"] = insn.rt + instr["rs"] = insn.rs + instr["ft"] = insn.ft + instr["base"] = insn.base + + elif insn.id == MIPS_INS_ORI: + op_str = [op_str] + instr["rt"] = insn.rt + instr["rs"] = insn.rs + + results.append( + { + "vaddr": vaddr, + "insn": instr, + "addr": f"/* {i*4:06X} {vaddr:08X} {raw_insns[i]:08X} */ ", + "mnem": mnemonic, + "op": op_str, + "data": False, + } + ) + + ######### End text disassembly ############## + if delay_slot and delayed_insn is not None: - if delayed_insn.id == MIPS_INS_JAL or delayed_insn.id == MIPS_INS_JALR or \ - (delayed_insn.id == MIPS_INS_JR and delayed_insn.rs == MIPS_REG_RA): + if ( + delayed_insn.id == MIPS_INS_JAL + or delayed_insn.id == MIPS_INS_JALR + or (delayed_insn.id == MIPS_INS_JR and delayed_insn.rs == MIPS_REG_RA) + ): # destroy lui tracking state lui_tracker.clear() elif delayed_insn.id == MIPS_INS_JR and vaddr == next_jtbl_jr + 4: @@ -673,82 +1038,124 @@ def find_symbols_in_text(data, rodata, vram, vram_rodata, data_regions, relocs, delay_slot = delayed_insn is not None + result_files.append([cur_file, results]) + put_symbols(symbols_dict, "branch_labels", func_branch_labels) put_symbols(symbols_dict, "jtbl_labels", func_jtbl_labels) - return symbols_dict + return symbols_dict, result_files -def find_symbols_in_data(data, vram, end, relocs, segment_name): + +def find_symbols_in_data(section): + data, vram, end, relocs = section[4], section[0], section[1], section[5] symbols_dict = dict() - print(f"Finding symbols from .data in {segment_name}") + print(f"Finding symbols from .data in {section[-1]['name']}") # read relocations for symbols if relocs is not None: for reloc in relocs: - if reloc[1] == 2: # R_MIPS_32 - put_symbol(symbols_dict, "data_labels", as_word(data[reloc[2] : reloc[2] + 4])) - elif reloc[1] == 4: # R_MIPS_26 - assert False , "R_MIPS_26 in .data section?" - elif reloc[1] == 5: # R_MIPS_HI16 - assert False , "R_MIPS_HI16 in .data section?" - elif reloc[1] == 6: # R_MIPS_LO16 - assert False , "R_MIPS_LO16 in .data section?" + if reloc[1] == 2: # R_MIPS_32 + put_symbol( + symbols_dict, "data_labels", as_word(data[reloc[2] : reloc[2] + 4]) + ) + elif reloc[1] == 4: # R_MIPS_26 + assert False, "R_MIPS_26 in .data section?" + elif reloc[1] == 5: # R_MIPS_HI16 + assert False, "R_MIPS_HI16 in .data section?" + elif reloc[1] == 6: # R_MIPS_LO16 + assert False, "R_MIPS_LO16 in .data section?" else: - assert False , "Invalid relocation type encountered" + assert False, "Invalid relocation type encountered" return symbols_dict # TODO more -# matches several codepoint regions of EUC-JP -strings_regex = re.compile(rb'^(?:[\x00\x1A\x1B\n\t\x20-\x7E\x8C\x8D]|\x30[\x00-\xFF]|[\x4E-\x9F][\x00-\xFF]|[\xA4\xA5\xBB][\xA1-\xF6]|[\xA1-\xA3\xB0-\xBF\xC0-\xCF][\xA1-\xFE]|\xFF[\x00-\xEF])+$') -def find_symbols_in_rodata(data, vram, end, relocs, segment): +# matches several codepoint regions of EUC-JP +strings_regex = re.compile( + rb"^(?:[\x00\x1A\x1B\n\t\x20-\x7E\x8C\x8D]|\x30[\x00-\xFF]|[\x4E-\x9F][\x00-\xFF]|[\xA4\xA5\xBB][\xA1-\xF6]|[\xA1-\xA3\xB0-\xBF\xC0-\xCF][\xA1-\xFE]|\xFF[\x00-\xEF])+$" +) + + +def find_symbols_in_rodata(section): + data, vram, end, relocs = section[4], section[0], section[1], section[5] + symbols_dict = dict() + + print(f"Finding symbols from .rodata in {section[-1]['name']}") + # read relocations for symbols if relocs is not None: for reloc in relocs: - if reloc[1] == 2: # R_MIPS_32 - data_labels.add(as_word(data[reloc[2] : reloc[2] + 4])) - elif reloc[1] == 4: # R_MIPS_26 - assert False , "R_MIPS_26 in .rodata section?" - elif reloc[1] == 5: # R_MIPS_HI16 - assert False , "R_MIPS_HI16 in .rodata section?" - elif reloc[1] == 6: # R_MIPS_LO16 - assert False , "R_MIPS_LO16 in .rodata section?" + if reloc[1] == 2: # R_MIPS_32 + put_symbol( + symbols_dict, "data_labels", as_word(data[reloc[2] : reloc[2] + 4]) + ) + elif reloc[1] == 4: # R_MIPS_26 + assert False, "R_MIPS_26 in .rodata section?" + elif reloc[1] == 5: # R_MIPS_HI16 + assert False, "R_MIPS_HI16 in .rodata section?" + elif reloc[1] == 6: # R_MIPS_LO16 + assert False, "R_MIPS_LO16 in .rodata section?" else: - assert False , "Invalid relocation type encountered" + assert False, "Invalid relocation type encountered" - section_symbols = set([sym for sym in symbols.values() if sym >= vram and sym < end]) + section_symbols = set( + [sym for sym in symbols.values() if sym >= vram and sym < end] + ) section_symbols.add(vram) - section_symbols.update(set([sym for sym in data_labels if sym >= vram and sym < end])) + section_symbols.update( + set([sym for sym in data_labels if sym >= vram and sym < end]) + ) # TODO temp hack, move - for data_file_st in [sym for sym in segment[4].keys() if sym >= vram and sym < end]: + for data_file_st in [ + sym for sym in section[-1]["syms"].keys() if sym >= vram and sym < end + ]: section_symbols.add(data_file_st) - rodata_starts = [addr for addr,name in segment[4].items() if addr >= vram and addr < end] + rodata_starts = [ + addr + for addr, name in section[-1]["syms"].items() + if addr >= vram and addr < end + ] section_symbols.update(set(rodata_starts)) section_symbols = list(section_symbols) section_symbols.sort() - section_late_rodata = [sym for sym in section_symbols if sym in floats or sym in doubles or sym in jtbls] + section_late_rodata = [ + sym + for sym in section_symbols + if sym in floats or sym in doubles or sym in jtbls + ] # string finding is best done per-file as the late_rodata sections are not merged per-segment, so you get stripes of # rodata - late_rodata -(file boundary)- rodata - late_rodata -(file boundary)- etc. # all rodata file starts - for fi,rodata_start in enumerate(rodata_starts,0): - next_rodata_start = rodata_starts[fi + 1] if fi < len(rodata_starts) - 1 else end + for fi, rodata_start in enumerate(rodata_starts, 0): + next_rodata_start = ( + rodata_starts[fi + 1] if fi < len(rodata_starts) - 1 else end + ) # symbols in this file - file_symbols = [sym for sym in section_symbols if sym >= rodata_start and sym < next_rodata_start] + file_symbols = [ + sym + for sym in section_symbols + if sym >= rodata_start and sym < next_rodata_start + ] # the first (minimum st_value) symbol in section_late_rodata in this file is the start of late_rodata - late_rodata_start = min([sym for sym in file_symbols if sym in section_late_rodata], default=next_rodata_start) + late_rodata_start = min( + [sym for sym in file_symbols if sym in section_late_rodata], + default=next_rodata_start, + ) - for i,symbol in enumerate(file_symbols,0): - next_symbol = file_symbols[i + 1] if i < len(file_symbols) - 1 else next_rodata_start + for i, symbol in enumerate(file_symbols, 0): + next_symbol = ( + file_symbols[i + 1] if i < len(file_symbols) - 1 else next_rodata_start + ) # not late_rodata if symbol >= late_rodata_start: @@ -759,7 +1166,7 @@ def find_symbols_in_rodata(data, vram, end, relocs, segment): data_offset = symbol - vram data_size = next_symbol - symbol - string_data = data[data_offset:data_offset+data_size] + string_data = data[data_offset : data_offset + data_size] if len(string_data) > 0 and string_data[0] == 0: # empty strings that are auto-detected are dubious @@ -769,8 +1176,10 @@ def find_symbols_in_rodata(data, vram, end, relocs, segment): if strings_regex.match(string_data) != None: k = 0 done = False - for j,b in enumerate(string_data,0): - if b == 0 and (j + 1 >= len(string_data) or string_data[j + 1] != 0): + for j, b in enumerate(string_data, 0): + if b == 0 and ( + j + 1 >= len(string_data) or string_data[j + 1] != 0 + ): # try: # decoded = try_decode_string(string_data[k:string_data.index(0)]) # except UnicodeDecodeError: @@ -778,14 +1187,16 @@ def find_symbols_in_rodata(data, vram, end, relocs, segment): # done = True # if done: # break - data_labels.add(symbol + k) - strings.add(symbol + k) - data_labels.add(symbol + j + 1) + put_symbol(symbols_dict, "data_labels", symbol + k) + put_symbol(symbols_dict, "data_labels", symbol + j + 1) + put_symbol(symbols_dict, "strings", symbol + k) k = j + 1 # TODO more + return symbols_dict -def asm_header(section_name): + +def asm_header(section_name): return f""".include "macro.inc" # assembler directives @@ -798,36 +1209,128 @@ def asm_header(section_name): .balign 16 """ -def disassemble_text(data, vram, data_regions, segment): + +def fixup_text_symbols(data, vram, data_regions, info): + segment_dirname = "" if info["type"] != "overlay" else "overlays/" + if info["type"] in ("boot", "code"): + segment_dirname += info["type"] + else: + segment_dirname += info["name"] + + os.makedirs(f"{ASM_OUT}/{segment_dirname}/", exist_ok=True) + + file = files_text[info["name"]] + # header + text = [file.pop(0)] + + # We didn't have full symbols available during initial disassembly, + # so here we loop over each instruction, and do symbol lookups, add labels etc + + for i, entry in enumerate(file): + vaddr = entry["vaddr"] + + if vaddr in functions: + text.append(f"\nglabel {proper_name(vaddr, in_data=entry['data'])}\n") + if vaddr in jtbl_labels: + text.append(f"glabel L{vaddr:08X}\n") + if vaddr in branch_labels: + text.append(f".L{vaddr:08X}:\n") + + line = entry["addr"] + if not entry["data"]: + line += f"{entry['mnem']:12}" + + insn = entry["insn"] + if insn["id"] in MIPS_JUMP_INSNS: + for op_part in entry["op"]: + if type(op_part) == list: + line += proper_name( + op_part[0], in_data=op_part[1], is_symbol=op_part[2] + ) + else: + line += op_part + + elif insn["id"] == MIPS_INS_LUI: + symbol_value = symbols.get(vaddr, None) + if symbol_value is not None: + line += ( + f"{mips_gpr_names[insn['rt']]}, %hi({proper_name(symbol_value)})" + ) + else: + constant_value = constants.get(vaddr, None) + if constant_value is not None: + line += ( + f"{mips_gpr_names[insn['rt']]}, (0x{constant_value:08X} >> 16)" + ) + else: + line += entry["op"][0] + + elif insn["id"] == MIPS_INS_ADDIU or insn["id"] in MIPS_LOAD_STORE_INSNS: + symbol_value = symbols.get(vaddr, None) + if symbol_value is not None: + if insn["id"] == MIPS_INS_ADDIU: + line += f"{mips_gpr_names[insn['rt']]}, {mips_gpr_names[insn['rs']]}, %lo({proper_name(symbol_value)})" + else: + line += f"{mips_fpr_names[insn['ft']] if insn['id'] in MIPS_FP_LOAD_STORE_INSNS else mips_gpr_names[insn['rt']]}, %lo({proper_name(symbol_value)})({mips_gpr_names[insn['base']]})" + else: + line += entry["op"][0] + + elif insn["id"] == MIPS_INS_ORI: + constant_value = constants.get(vaddr, None) + if constant_value is not None: + line += f"{mips_gpr_names[insn['rt']]}, {mips_gpr_names[insn['rs']]}, (0x{constant_value:08X} & 0xFFFF)" + else: + line += entry["op"][0] + + else: + for part in entry["op"]: + if type(part) == list: + line += ( + f"{proper_name(part[0], in_data=part[1], is_symbol=part[2])}" + ) + else: + line += part + + line += "\n" + text.append(line) + + with open(f"{ASM_OUT}/{segment_dirname}/{info['name']}.text.s", "w") as outfile: + outfile.write("".join(text)) + + +def disassemble_text(data, vram, data_regions, info): result = asm_header(".text") raw_insns = as_word_list(data) cur_file = "" + cur_vaddr = 0 - segment_dirname = ("" if segment[2] != "overlay" else "overlays/") + segment[0] + segment_dirname = ("" if info["type"] != "overlay" else "overlays/") + info["name"] + os.makedirs(f"{ASM_OUT}/{segment_dirname}/", exist_ok=True) delayed_insn = None delay_slot = False - for i,raw_insn in enumerate(raw_insns,0): + for i, raw_insn in enumerate(raw_insns, 0): i *= 4 vaddr = vram + i - insn = decode_insn(raw_insns[i//4], vaddr) + insn = decode_insn(raw_insns[i // 4], vaddr) mnemonic = insn.mnemonic op_str = insn.op_str - if vaddr in segment[4].keys(): + if vaddr in full_file_list[info["name"]]: if cur_file != "": - os.makedirs(f"{ASM_OUT}/{segment_dirname}/", exist_ok=True) - with open(f"{ASM_OUT}/{segment_dirname}/{cur_file}.text.s", "w") as outfile: - outfile.write(result) + if cur_vaddr in info["syms"]: + os.makedirs(f"{ASM_OUT}/{segment_dirname}/", exist_ok=True) + with open( + f"{ASM_OUT}/{segment_dirname}/{cur_file}.text.s", "w" + ) as outfile: + outfile.write(result) result = asm_header(".text") - cur_file = segment[4][vaddr] + cur_vaddr = vaddr + cur_file = full_file_list[info["name"]][vaddr] if cur_file == "": - cur_file = f"{segment[0]}_{vaddr:08X}" - - if cur_file == "[PADDING]": # workaround for assumed linker bug - continue + cur_file = f"{info['name']}_{vaddr:08X}" # DATA EMBEDDED IN TEXT in_data = False @@ -836,9 +1339,12 @@ def disassemble_text(data, vram, data_regions, segment): in_data = True break if in_data: - if vaddr in functions: # TODO not really a function if it falls in a data region... + # TODO not really a function if it falls in a data region... + if vaddr in functions: result += f"\nglabel {proper_name(vaddr, True)}\n" - result += f"/* {i:06X} {vaddr:08X} {raw_insn:08X} */ .word 0x{raw_insn:08X}\n" + result += ( + f"/* {i:06X} {vaddr:08X} {raw_insn:08X} */ .word 0x{raw_insn:08X}\n" + ) continue # LABELS @@ -853,7 +1359,7 @@ def disassemble_text(data, vram, data_regions, segment): if insn.id in MIPS_BRANCH_INSNS: op_str_parts = [] for field in insn.fields: - if field == 'offset': + if field == "offset": op_str_parts.append(f".L{insn.offset:08X}") else: op_str_parts.append(insn.format_field(field)) @@ -862,7 +1368,7 @@ def disassemble_text(data, vram, data_regions, segment): elif insn.id in MIPS_JUMP_INSNS: op_str_parts = [] for field in insn.fields: - if field == 'target': + if field == "target": op_str_parts.append(proper_name(insn.target, is_symbol=True)) else: op_str_parts.append(insn.format_field(field)) @@ -875,7 +1381,9 @@ def disassemble_text(data, vram, data_regions, segment): else: constant_value = constants.get(vaddr, None) if constant_value is not None: - op_str = f"{mips_gpr_names[insn.rt]}, (0x{constant_value:08X} >> 16)" + op_str = ( + f"{mips_gpr_names[insn.rt]}, (0x{constant_value:08X} >> 16)" + ) elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: @@ -897,194 +1405,458 @@ def disassemble_text(data, vram, data_regions, segment): result += f"/* {i:06X} {vaddr:08X} {raw_insn:08X} */ {mnemonic:12}{op_str}\n" - os.makedirs(f"{ASM_OUT}/{segment_dirname}/", exist_ok=True) with open(f"{ASM_OUT}/{segment_dirname}/{cur_file}.text.s", "w") as outfile: outfile.write(result) -def disassemble_data(data, vram, end, segment): + +def disassemble_data(data, vram, end, info): section_symbols = [sym for sym in symbols.values() if sym >= vram and sym < end] section_symbols.append(vram) section_symbols.extend([sym for sym in data_labels if sym >= vram and sym < end]) - section_symbols.extend([sym for sym in variables_ast.keys() if sym >= vram and sym < end]) + section_symbols.extend( + [sym for sym in variables_ast.keys() if sym >= vram and sym < end] + ) # TODO temp hack, move - section_symbols.extend([sym for sym in segment[4].keys() if sym >= vram and sym < end]) + section_symbols.extend( + [sym for sym in info["syms"].keys() if sym >= vram and sym < end] + ) # remove symbols that are addends of other symbols - section_symbols = [sym for sym in section_symbols if " + 0x" not in proper_name(sym, True) and " - 0x" not in proper_name(sym, True)] + section_symbols = [ + sym + for sym in section_symbols + if " + 0x" not in proper_name(sym, True) + and " - 0x" not in proper_name(sym, True) + ] section_symbols = list(set(section_symbols)) section_symbols.sort() - segment_dirname = ("" if segment[2] != "overlay" else "overlays/") + segment[0] - - result = asm_header(".data") - cur_file = "" - - for i,symbol in enumerate(section_symbols,0): - next_symbol = section_symbols[i + 1] if i < len(section_symbols) - 1 else end - - # assert symbol % 4 == 0 , f"Unaligned .data symbol 0x{symbol:08X}" - - if symbol in segment[4].keys(): - if cur_file != "": - os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) - with open(f"{DATA_OUT}/{segment_dirname}/{cur_file}.data.s", "w") as outfile: - outfile.write(result) - result = asm_header(".data") - cur_file = segment[4][symbol] - if cur_file == "": - cur_file = f"{segment[0]}_{symbol:08X}" - - data_offset = symbol - vram - data_size = next_symbol - symbol - - if data_offset == len(data): - continue - - result += f"\nglabel {proper_name(symbol, True)}\n" - - if symbol % 8 == 0 and data_size % 8 == 0 and symbol in doubles: - result += "\n".join(\ - [f"/* {data_offset + j * 8:06X} {symbol + j * 8:08X} {dbl_dwd:016X} */ {format_f64(dbl_dwd)}" for j,dbl_dwd in enumerate(as_dword_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - elif symbol % 8 == 0 and data_size % 8 == 0 and symbol in dwords: - result += "\n".join(\ - [f"/* {data_offset + j * 8:06X} {symbol + j * 8:08X} */ .quad 0x{dword:08X}" for j,dword in enumerate(as_dword_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - elif symbol % 4 == 0 and data_size % 4 == 0: - if symbol in floats: - result += "\n".join(\ - [f"/* {data_offset + j * 4:06X} {symbol + j * 4:08X} {flt_wd:08X} */ {format_f32(flt_wd)}" for j,flt_wd in enumerate(as_word_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - else: - result += "\n".join(\ - [f"/* {data_offset + j * 4:06X} {symbol + j * 4:08X} */ .word {lookup_name(symbol, word)}" for j,word in enumerate(as_word_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - elif symbol % 2 == 0 and data_size % 2 == 0: - result += "\n".join(\ - [f"/* {data_offset + j * 2:06X} {symbol + j * 2:08X} */ .half 0x{hword:04X}" for j,hword in enumerate(as_hword_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - else: - result += "\n".join(\ - [f"/* {data_offset + j:06X} {symbol + j:08X} */ .byte 0x{byte:02X}" for j,byte in enumerate(data[data_offset:data_offset + data_size], 0)]) + "\n" - - os.makedirs(f"{DATA_OUT}/{segment[0]}/", exist_ok=True) - with open(f"{DATA_OUT}/{segment[0]}/{cur_file}.data.s", "w") as outfile: - outfile.write(result) - -def disassemble_rodata(data, vram, end, segment): - section_symbols = [sym for sym in symbols.values() if sym >= vram and sym < end] - section_symbols.append(vram) - section_symbols.extend([sym for sym in data_labels if sym >= vram and sym < end]) - section_symbols.extend([sym for sym in variables_ast.keys() if sym >= vram and sym < end]) - # TODO temp hack, move - section_symbols.extend([sym for sym in segment[4].keys() if sym >= vram and sym < end]) - - # remove symbols that are addends of other symbols - section_symbols = [sym for sym in section_symbols if " + 0x" not in proper_name(sym, True) and " - 0x" not in proper_name(sym, True)] - - section_symbols = list(set(section_symbols)) - - section_symbols.sort() - - segment_dirname = ("" if segment[2] != "overlay" else "overlays/") + segment[0] - - result = asm_header(".rodata") - cur_file = "" - - force_ascii_str = False # hack for non-null-terminated strings in .data - - for i,symbol in enumerate(section_symbols,0): - next_symbol = section_symbols[i + 1] if i < len(section_symbols) - 1 else end - - # assert symbol % 4 == 0 , f"Unaligned .data symbol 0x{symbol:08X}" - - if symbol in segment[4].keys(): - if cur_file != "": - os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) - with open(f"{DATA_OUT}/{segment_dirname}/{cur_file}.rodata.s", "w") as outfile: - outfile.write(result) - result = asm_header(".rodata") - cur_file = segment[4][symbol] - if cur_file == "": - cur_file = f"{segment[0]}_{symbol:08X}" - - data_offset = symbol - vram - data_size = next_symbol - symbol - - if data_offset == len(data): - continue - - force_ascii_str = symbol in [0x801D0708] - - result += f"\nglabel {proper_name(symbol, True)}\n" - - if symbol in strings: - string_data = data[data_offset:data_offset+data_size] - string_data = string_data[:string_data.index(0)] - assert all([b != 0 for b in string_data[:-1]]) , f"{symbol:08X} , {data_size:X} , {string_data}" # ensure strings don't have a null char midway through - result += f"/* {data_offset:06X} {symbol:08X} */ {try_decode_string(string_data, force_ascii=force_ascii_str)}\n{STR_INDENT}.balign 4\n" - elif symbol % 8 == 0 and data_size % 8 == 0 and symbol in doubles: - result += "\n".join(\ - [f"/* {data_offset + j * 8:06X} {symbol + j * 8:08X} {dbl_dwd:016X} */ {format_f64(dbl_dwd)}" for j,dbl_dwd in enumerate(as_dword_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - elif symbol % 4 == 0 and data_size % 4 == 0: - if symbol in floats: - result += "\n".join(\ - [f"/* {data_offset + j * 4:06X} {symbol + j * 4:08X} {flt_wd:08X} */ {format_f32(flt_wd)}" for j,flt_wd in enumerate(as_word_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - else: - result += "\n".join(\ - [f"/* {data_offset + j * 4:06X} {symbol + j * 4:08X} */ .word {lookup_name(symbol, word)}" for j,word in enumerate(as_word_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - elif symbol % 2 == 0 and data_size % 2 == 0: - result += "\n".join(\ - [f"/* {data_offset + j * 2:06X} {symbol + j * 2:08X} */ .half 0x{hword:04X}" for j,hword in enumerate(as_hword_list(data[data_offset:data_offset + data_size]), 0)]) + "\n" - else: - result += "\n".join(\ - [f"/* {data_offset + j:06X} {symbol + j:08X} */ .byte 0x{byte:02X}" for j,byte in enumerate(data[data_offset:data_offset + data_size], 0)]) + "\n" - - os.makedirs(f"{DATA_OUT}/{segment[0]}/", exist_ok=True) - with open(f"{DATA_OUT}/{segment[0]}/{cur_file}.rodata.s", "w") as outfile: - outfile.write(result) - -def disassemble_bss(vram, end, segment): - section_symbols = [sym for sym in symbols.values() if sym >= vram and sym < end] - section_symbols.append(vram) - section_symbols.extend([sym for sym in data_labels if sym >= vram and sym < end]) - section_symbols.extend([sym for sym in variables_ast.keys() if sym >= vram and sym < end]) - # TODO temp hack, move - section_symbols.extend([sym for sym in segment[4].keys() if sym >= vram and sym < end]) - - # remove symbols that are addends of other symbols - section_symbols = [sym for sym in section_symbols if " + 0x" not in proper_name(sym, True) and " - 0x" not in proper_name(sym, True)] - - section_symbols = list(set(section_symbols)) - - section_symbols.sort() - - # ("" if segment[2] != "overlay" else "overlays/" - segment_dirname = segment[0] - - result = asm_header(".bss") - cur_file = "" - - for i,symbol in enumerate(section_symbols,0): - next_symbol = section_symbols[i + 1] if i < len(section_symbols) - 1 else end - - if symbol in segment[4].keys(): - if cur_file != "": - os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) - with open(f"{DATA_OUT}/{segment_dirname}/{cur_file}.bss.s", "w") as outfile: - outfile.write(result) - result = asm_header(".bss") - cur_file = segment[4][symbol] - if cur_file == "": - cur_file = f"{segment[0]}_{symbol:08X}" - - result += f"\nglabel {proper_name(symbol, True)}\n" - result += f"/* {symbol - vram:06X} {symbol:08X} */ .space 0x{next_symbol - symbol:X}\n" + segment_dirname = info["name"] + if info["type"] in ("boot", "code"): + segment_dirname = info["type"] os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) - with open(f"{DATA_OUT}/{segment_dirname}/{cur_file}.bss.s", "w") as outfile: - outfile.write(result) + + if info["type"] in ("boot", "code"): + sym_list = full_file_list[info["type"]] + else: + sym_list = full_file_list[info["name"]] + + file_syms = [] + syms = [] + file_name = "" + for i, sym in enumerate(section_symbols): + if i == 0: + if info["type"] == "overlay": + file_name = info["name"] + else: + file_name = sym_list[sym] + + if sym in sym_list: + new_file = sym_list[sym] + if file_name != new_file: + file_syms.append( + {"name": file_name, "first_sym": syms[0], "syms": syms} + ) + syms = [] + file_name = new_file + syms.append(sym) + if len(syms) > 0: + file_syms.append({"name": file_name, "first_sym": syms[0], "syms": syms}) + + for i, file in enumerate(file_syms): + if file["first_sym"] not in info["syms"]: + continue + + result = [asm_header(".data")] + + for x, symbol in enumerate(file["syms"]): + if symbol >= end: + break + if x + 1 < len(file["syms"]): + next_symbol = file["syms"][x + 1] + elif i + 1 < len(file_syms): + next_symbol = file_syms[i + 1]["first_sym"] + else: + next_symbol = end + + data_base = symbol - info["base"] + data_offset = symbol - vram + data_size = next_symbol - symbol + + if data_offset == len(data): + continue + + r = f"\nglabel {proper_name(symbol, True)}\n" + + if symbol % 8 == 0 and data_size % 8 == 0 and symbol in doubles: + r += ( + "\n".join( + [ + f"/* {data_base + j * 8:06X} {symbol + j * 8:08X} {dbl_dwd:016X} */ {format_f64(dbl_dwd)}" + for j, dbl_dwd in enumerate( + as_dword_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + elif symbol % 8 == 0 and data_size % 8 == 0 and symbol in dwords: + r += ( + "\n".join( + [ + f"/* {data_base + j * 8:06X} {symbol + j * 8:08X} */ .quad 0x{dword:08X}" + for j, dword in enumerate( + as_dword_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + elif symbol % 4 == 0 and data_size % 4 == 0: + if symbol in floats: + r += ( + "\n".join( + [ + f"/* {data_base + j * 4:06X} {symbol + j * 4:08X} {flt_wd:08X} */ {format_f32(flt_wd)}" + for j, flt_wd in enumerate( + as_word_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + else: + r += ( + "\n".join( + [ + f"/* {data_base + j * 4:06X} {symbol + j * 4:08X} */ .word {lookup_name(symbol, word)}" + for j, word in enumerate( + as_word_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + elif symbol % 2 == 0 and data_size % 2 == 0: + r += ( + "\n".join( + [ + f"/* {data_base + j * 2:06X} {symbol + j * 2:08X} */ .half 0x{hword:04X}" + for j, hword in enumerate( + as_hword_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + else: + r += ( + "\n".join( + [ + f"/* {data_base + j:06X} {symbol + j:08X} */ .byte 0x{byte:02X}" + for j, byte in enumerate( + data[data_offset : data_offset + data_size], 0 + ) + ] + ) + + "\n" + ) + result.append(r) + + if len(result) > 1: + with open( + f"{DATA_OUT}/{segment_dirname}/{file['name']}.data.s", "w" + ) as outfile: + outfile.write("".join(result)) + + +def disassemble_rodata(data, vram, end, info): + section_symbols = [sym for sym in symbols.values() if sym >= vram and sym < end] + section_symbols.append(vram) + section_symbols.extend([sym for sym in data_labels if sym >= vram and sym < end]) + section_symbols.extend( + [sym for sym in variables_ast.keys() if sym >= vram and sym < end] + ) + # TODO temp hack, move + section_symbols.extend( + [sym for sym in info["syms"].keys() if sym >= vram and sym < end] + ) + + # remove symbols that are addends of other symbols + section_symbols = [ + sym + for sym in section_symbols + if " + 0x" not in proper_name(sym, True) + and " - 0x" not in proper_name(sym, True) + ] + + section_symbols = list(set(section_symbols)) + + if len(section_symbols) == 0: + return + + section_symbols.sort() + + segment_dirname = info["name"] + if info["type"] in ("boot", "code"): + segment_dirname = info["type"] + os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) + + if info["type"] in ("boot", "code"): + sym_list = full_file_list[info["type"]] + else: + sym_list = full_file_list[info["name"]] + + force_ascii_str = False # hack for non-null-terminated strings in .data + + file_syms = [] + syms = [] + file_name = "" + for i, sym in enumerate(section_symbols): + if i == 0: + if info["type"] == "overlay": + file_name = info["name"] + else: + file_name = sym_list[sym] + + if sym in sym_list: + new_file = sym_list[sym] + if file_name != new_file: + file_syms.append( + {"name": file_name, "first_sym": syms[0], "syms": syms} + ) + syms = [] + file_name = new_file + syms.append(sym) + if len(syms) > 0: + file_syms.append({"name": file_name, "first_sym": syms[0], "syms": syms}) + + for i, file in enumerate(file_syms): + if file["first_sym"] not in info["syms"]: + continue + + result = [asm_header(".rodata")] + + for x, symbol in enumerate(file["syms"]): + if symbol >= end: + break + if x + 1 < len(file["syms"]): + next_symbol = file["syms"][x + 1] + elif i + 1 < len(file_syms): + next_symbol = file_syms[i + 1]["first_sym"] + else: + next_symbol = end + + data_base = symbol - info["base"] + data_offset = symbol - vram + data_size = next_symbol - symbol + + if data_offset == len(data): + continue + + force_ascii_str = symbol in [0x801D0708] + + r = f"\nglabel {proper_name(symbol, True)}\n" + + if symbol in strings: + string_data = data[data_offset : data_offset + data_size] + string_data = string_data[: string_data.index(0)] + # ensure strings don't have a null char midway through + assert all( + [b != 0 for b in string_data[:-1]] + ), f"{symbol:08X} , {data_size:X} , {string_data}" + r += f"/* {data_base:06X} {symbol:08X} */ {try_decode_string(string_data, force_ascii=force_ascii_str)}\n{STR_INDENT}.balign 4\n" + elif symbol % 8 == 0 and data_size % 8 == 0 and symbol in doubles: + r += ( + "\n".join( + [ + f"/* {data_base + j * 8:06X} {symbol + j * 8:08X} {dbl_dwd:016X} */ {format_f64(dbl_dwd)}" + for j, dbl_dwd in enumerate( + as_dword_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + elif symbol % 4 == 0 and data_size % 4 == 0: + if symbol in floats: + r += ( + "\n".join( + [ + f"/* {data_base + j * 4:06X} {symbol + j * 4:08X} {flt_wd:08X} */ {format_f32(flt_wd)}" + for j, flt_wd in enumerate( + as_word_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + else: + r += ( + "\n".join( + [ + f"/* {data_base + j * 4:06X} {symbol + j * 4:08X} */ .word {lookup_name(symbol, word)}" + for j, word in enumerate( + as_word_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + elif symbol % 2 == 0 and data_size % 2 == 0: + r += ( + "\n".join( + [ + f"/* {data_base + j * 2:06X} {symbol + j * 2:08X} */ .half 0x{hword:04X}" + for j, hword in enumerate( + as_hword_list( + data[data_offset : data_offset + data_size] + ), + 0, + ) + ] + ) + + "\n" + ) + else: + r += ( + "\n".join( + [ + f"/* {data_base + j:06X} {symbol + j:08X} */ .byte 0x{byte:02X}" + for j, byte in enumerate( + data[data_offset : data_offset + data_size], 0 + ) + ] + ) + + "\n" + ) + + result.append(r) + + if len(result) > 1: + with open( + f"{DATA_OUT}/{segment_dirname}/{file['name']}.rodata.s", "w" + ) as outfile: + outfile.write("".join(result)) + + +def disassemble_bss(vram, end, info): + section_symbols = [sym for sym in symbols.values() if sym >= vram and sym < end] + section_symbols.append(vram) + section_symbols.extend([sym for sym in data_labels if sym >= vram and sym < end]) + section_symbols.extend( + [sym for sym in variables_ast.keys() if sym >= vram and sym < end] + ) + # TODO temp hack, move + section_symbols.extend( + [sym for sym in info["syms"].keys() if sym >= vram and sym < end] + ) + + # remove symbols that are addends of other symbols + section_symbols = [ + sym + for sym in section_symbols + if " + 0x" not in proper_name(sym, True) + and " - 0x" not in proper_name(sym, True) + ] + + section_symbols = list(set(section_symbols)) + + section_symbols.sort() + + # ("" if info["type"] != "overlay" else "overlays/" + segment_dirname = ( + info["name"] if info["type"] not in ("boot", "code") else info["type"] + ) + os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) + + if info["type"] in ("boot", "code"): + sym_list = full_file_list[info["type"]] + else: + sym_list = full_file_list[info["name"]] + + file_syms = [] + syms = [] + file_name = "" + for i, sym in enumerate(section_symbols): + if i == 0: + if info["type"] == "overlay": + file_name = info["name"] + else: + file_name = sym_list[sym] + + if sym in sym_list: + new_file = sym_list[sym] + if file_name != new_file: + file_syms.append( + {"name": file_name, "first_sym": syms[0], "syms": syms} + ) + syms = [] + file_name = new_file + syms.append(sym) + if len(syms) > 0: + file_syms.append({"name": file_name, "first_sym": syms[0], "syms": syms}) + + for i, file in enumerate(file_syms): + if file["first_sym"] not in info["syms"]: + continue + + result = [asm_header(".bss")] + + for x, symbol in enumerate(file["syms"]): + if symbol >= end: + break + if x + 1 < len(file["syms"]): + next_symbol = file["syms"][x + 1] + elif i + 1 < len(file_syms): + next_symbol = file_syms[i + 1]["first_sym"] + else: + next_symbol = end + + result.append(f"\nglabel {proper_name(symbol, True)}\n") + result.append( + f"/* {symbol - vram:06X} {symbol:08X} */ .space 0x{next_symbol - symbol:X}\n" + ) + + if len(result) > 1: + with open( + f"{DATA_OUT}/{segment_dirname}/{file['name']}.bss.s", "w" + ) as outfile: + outfile.write("".join(result)) + def get_overlay_sections(vram, overlay): header_loc = len(overlay) - as_word_list(overlay)[-1] - text_size, data_size, rodata_size, bss_size, n_relocs = as_word_list(overlay[header_loc:header_loc + 0x14]) + text_size, data_size, rodata_size, bss_size, n_relocs = as_word_list( + overlay[header_loc : header_loc + 0x14] + ) text_vram = vram data_vram = vram + text_size rodata_vram = data_vram + data_size @@ -1092,154 +1864,66 @@ def get_overlay_sections(vram, overlay): bss_vram = vram + len(overlay) bss_end_vram = bss_vram + bss_size - reloc = as_word_list(overlay[header_loc + 0x14: header_loc + 0x14 + n_relocs * 4]) - reloc = [((rel >> 30) & ((1 << 2) - 1), (rel >> 24) & ((1 << 6) - 1), (rel) & ((1 << 24) - 1)) for rel in reloc] + reloc = as_word_list(overlay[header_loc + 0x14 : header_loc + 0x14 + n_relocs * 4]) + reloc = [ + ( + (rel >> 30) & ((1 << 2) - 1), + (rel >> 24) & ((1 << 6) - 1), + (rel) & ((1 << 24) - 1), + ) + for rel in reloc + ] rel_text = [r for r in reloc if r[0] == 1] rel_data = [r for r in reloc if r[0] == 2] rel_rodata = [r for r in reloc if r[0] == 3] rel_bss = [r for r in reloc if r[0] == 4] - return [[text_vram, data_vram, 'text', None, overlay[0:text_size], rel_text], \ - [data_vram, rodata_vram, 'data', None, overlay[text_size:text_size+data_size], rel_data], \ - [rodata_vram, bss_vram, 'rodata', None, overlay[text_size+data_size:text_size+data_size+rodata_size], rel_rodata], \ - [bss_vram, bss_end_vram, 'bss', None, None, rel_bss], \ - [bss_end_vram, bss_end_vram, 'reloc', None, overlay[header_loc:], None]] + return [ + [text_vram, data_vram, "text", None, overlay[0:text_size], rel_text], + [ + data_vram, + rodata_vram, + "data", + None, + overlay[text_size : text_size + data_size], + rel_data, + ], + [ + rodata_vram, + bss_vram, + "rodata", + None, + overlay[text_size + data_size : text_size + data_size + rodata_size], + rel_rodata, + ], + [bss_vram, bss_end_vram, "bss", None, None, rel_bss], + [bss_end_vram, bss_end_vram, "reloc", None, overlay[header_loc:], None], + ] -# -print("Setting Up") - -files_spec = None -with open("tools/disasm/files.txt", "r") as infile: - files_spec = ast.literal_eval(infile.read()) - -with open("tools/disasm/functions.txt", "r") as infile: - functions_ast = ast.literal_eval(infile.read()) - -with open("tools/disasm/variables.txt", "r") as infile: - variables_ast = ast.literal_eval(infile.read()) - -# Find floats, doubles, and strings -for var in sorted(variables_ast.keys()): - var_type = variables_ast[var][1] - - if var_type == "f64": - doubles.add(var) - elif var_type == "f32": - floats.add(var) - elif var_type == "char" and variables_ast[var][2].startswith("["): - strings.add(var) - -# Read in binary and relocation data for each segment -for segment in files_spec: - binary = None - with open(segment[1] + "/" + segment[0],"rb") as infile: - binary = bytes(infile.read()) - - if segment[2] == "overlay": - segment_start = list(segment[4])[0] # start addr of first file in segment - segment[3] = get_overlay_sections(segment_start, binary) - segment[4] = {} - for section in segment[3]: - segment[4].update({ section[0] : segment[0] }) - else: - segment_start = segment[3][0][0] # start addr of first section of segment's sections - # read section binary regions - for section in segment[3]: - if section[2] == 'bss': - continue - section.append(binary[section[0] - segment_start:section[1] - segment_start]) # section[4] - section.append(None) # section[5] - -print(f"Finding Symbols") - -for segment in files_spec: - if segment[2] == 'makerom': - continue - - print(f"Finding segment positions in {segment[0]}") - - # vram segment start - if segment[3][0][0] not in variables_ast: - variables_ast.update({segment[3][0][0] : (f"_{segment[0]}SegmentStart","u8","[]",0x1)}) - # vram segment end - if segment[3][-1][1] not in variables_ast: - variables_ast.update({segment[3][-1][1] : (f"_{segment[0]}SegmentEnd","u8","[]",0x1)}) - -# Construct variable_addrs, now that variable_addrs is fully constructed -variable_addrs = sorted(variables_ast.keys()) - -pool = get_context("fork").Pool(jobs) -# Find symbols for each segment -for segment in files_spec: - if segment[2] == 'makerom': - continue - - #print(f"Finding symbols from .text and .data in {segment[0]}") - - for section in segment[3]: - if section[2] == 'text': - data_regions = [] - if section[3] is not None: - for override_region in section[3]: - if override_region[2] == 'data': - data_regions.append((override_region[0], override_region[1])) - # try find a rodata section - for find_section in segment[3]: - if find_section[2] == 'rodata' and find_section[1] != find_section[0]: - rodata_section = find_section - break - else: - rodata_section = None - pool.apply_async(find_symbols_in_text, args=(section[4], rodata_section[4] if rodata_section is not None else None, - section[0], rodata_section[0] if rodata_section is not None else None, data_regions, section[5], segment[0]), callback=update_symbols_from_dict) - elif section[2] == 'data': - pool.apply_async(find_symbols_in_data, args=(section[4], section[0], section[1], section[5], segment[0]), callback=update_symbols_from_dict) - -pool.close() -pool.join() - -for segment in files_spec: - if segment[2] == 'makerom': - continue - - print(f"Finding symbols from .rodata and .dmadata in {segment[0]}") - - for section in segment[3]: - if section[2] == 'rodata': - find_symbols_in_rodata(section[4], section[0], section[1], section[5], segment) - elif section[2] == 'dmadata': - filenames = [] - with open("tools/disasm/dma_filenames.txt","r") as infile: - filenames = ast.literal_eval(infile.read()) - - dmadata = segment[3][0][4] - i = 0 - dmadata_entry = dmadata[i*0x10:(i+1)*0x10] - while any([word != 0 for word in as_word_list(dmadata_entry)]): - vrom_start,vrom_end,prom_start,prom_end = as_word_list(dmadata_entry) - # print(f"{vrom_start:08X},{vrom_end:08X},{prom_start:08X},{prom_end:08X} : {filenames[i]}") - vrom_variables.append(("_" + filenames[i] + "SegmentRomStart", vrom_start)) - vrom_variables.append(("_" + filenames[i] + "SegmentRomEnd", vrom_end)) - i += 1 - dmadata_entry = dmadata[i*0x10:(i+1)*0x10] - -# Construct vrom_addrs, now that vrom_variables is fully constructed -vrom_addrs = {addr for _, addr in vrom_variables} - -def disassemble_makerom(segment): +def disassemble_makerom(section): os.makedirs(f"{ASM_OUT}/makerom/", exist_ok=True) - rom_header = segment[3][0][4] - ipl3 = segment[3][1][4] - entry = segment[3][2][4] - pi_dom1_reg, clockrate, entrypoint, revision, \ - chksum1, chksum2, pad1, pad2, \ - rom_name, pad3, cart, cart_id, \ - region, version = struct.unpack(">IIIIIIII20sII2s1sB", rom_header) + if section[2] == "rom_header": + ( + pi_dom1_reg, + clockrate, + entrypoint, + revision, + chksum1, + chksum2, + pad1, + pad2, + rom_name, + pad3, + cart, + cart_id, + region, + version, + ) = struct.unpack(">IIIIIIII20sII2s1sB", section[4]) - out = f"""/* + out = f"""/* * The Legend of Zelda: Majora's Mask ROM header */ @@ -1258,49 +1942,51 @@ def disassemble_makerom(segment): .ascii "{region.decode('ascii')}" /* Region */ .byte 0x{version:02X} /* Version */ """ - with open(ASM_OUT + "/makerom/rom_header.s", "w") as outfile: - outfile.write(out) + with open(ASM_OUT + "/makerom/rom_header.s", "w") as outfile: + outfile.write(out) - # TODO disassemble this eventually, low priority - out = f"{asm_header('.text')}\n.incbin \"baserom/makerom\", 0x40, 0xFC0\n" + elif section[-1]["type"] == "ipl3": + # TODO disassemble this eventually, low priority + out = f"{asm_header('.text')}\n.incbin \"baserom/makerom\", 0x40, 0xFC0\n" - with open(ASM_OUT + "/makerom/ipl3.s", "w") as outfile: - outfile.write(out) + with open(ASM_OUT + "/makerom/ipl3.s", "w") as outfile: + outfile.write(out) - # hack: add symbol relocations manually - entry_addr = 0x80080000 + elif section[-1]["type"] == "entry": + # hack: add symbol relocations manually + entry_addr = 0x80080000 - functions.add(entry_addr) - symbols.update({entry_addr + 0x00 : 0x80099500, - entry_addr + 0x04 : 0x80099500, - entry_addr + 0x20 : 0x80080060, - entry_addr + 0x24 : 0x80099EF0, - entry_addr + 0x28 : 0x80080060, - entry_addr + 0x30 : 0x80099EF0}) - branch_labels.add(entry_addr + 0xC) + functions.add(entry_addr) + symbols.update( + { + entry_addr + 0x00: 0x80099500, + entry_addr + 0x04: 0x80099500, + entry_addr + 0x20: 0x80080060, + entry_addr + 0x24: 0x80099EF0, + entry_addr + 0x28: 0x80080060, + entry_addr + 0x30: 0x80099EF0, + } + ) + branch_labels.add(entry_addr + 0xC) + disassemble_text(section[4], entry_addr, [], section[-1]) - disassemble_text(entry, entry_addr, [], segment) + # manually set boot bss size... + entry_asm = "" + with open(f"{ASM_OUT}/makerom/entry.text.s") as infile: + entry_asm = infile.read() - # manually set boot bss size... - entry_asm = "" - with open(f"{ASM_OUT}/makerom/entry.text.s") as infile: - entry_asm = infile.read() + entry_asm = entry_asm.replace("0x63b0", "%lo(_bootSegmentBssSize)") + with open(f"{ASM_OUT}/makerom/entry.s", "w") as outfile: + outfile.write(entry_asm) - entry_asm = entry_asm.replace("0x63b0", "%lo(_bootSegmentBssSize)") - with open(f"{ASM_OUT}/makerom/entry.s", "w") as outfile: - outfile.write(entry_asm) + os.remove(f"{ASM_OUT}/makerom/entry.text.s") - os.remove(f"{ASM_OUT}/makerom/entry.text.s") - #out = f"{asm_header('.text')}\n.incbin \"baserom/makerom\", 0x1000, 0x60\n" - - #with open(ASM_OUT + "/makerom/entry.s", "w") as outfile: - # outfile.write(out) - -def disassemble_segment(segment): - if segment[2] == 'dmadata': - os.makedirs(f"{ASM_OUT}/dmadata/", exist_ok=True) - out = f""".include "macro.inc" +def disassemble_dmadata(section): + if section[2] == "bss": + return + os.makedirs(f"{ASM_OUT}/dmadata/", exist_ok=True) + out = f""".include "macro.inc" .macro DMA_TABLE_ENTRY segment .4byte _\segment\()SegmentRomStart @@ -1318,137 +2004,132 @@ def disassemble_segment(segment): glabel {variables_ast[0x8009F8B0][0]} """ - filenames = [] - with open("tools/disasm/dma_filenames.txt","r") as infile: - filenames = ast.literal_eval(infile.read()) + filenames = [] + with open("tools/disasm/dma_filenames.txt", "r") as infile: + filenames = ast.literal_eval(infile.read()) - dmadata = segment[3][0][4] - i = 0 - dmadata_entry = dmadata[i*0x10:(i+1)*0x10] - while any([word != 0 for word in as_word_list(dmadata_entry)]): - vrom_start,vrom_end,prom_start,prom_end = as_word_list(dmadata_entry) - if prom_start == 0xFFFFFFFF and prom_end == 0xFFFFFFFF: - out += f"DMA_TABLE_ENTRY_UNSET {filenames[i]}\n" - else: - out += f"DMA_TABLE_ENTRY {filenames[i]}\n" - i += 1 - dmadata_entry = dmadata[i*0x10:(i+1)*0x10] + dmadata = section[4] + i = 0 + dmadata_entry = dmadata[i * 0x10 : (i + 1) * 0x10] + while any([word != 0 for word in as_word_list(dmadata_entry)]): + vrom_start, vrom_end, prom_start, prom_end = as_word_list(dmadata_entry) + if prom_start == 0xFFFFFFFF and prom_end == 0xFFFFFFFF: + out += f"DMA_TABLE_ENTRY_UNSET {filenames[i]}\n" + else: + out += f"DMA_TABLE_ENTRY {filenames[i]}\n" - out += """ + vrom_variables.append(("_" + filenames[i] + "SegmentRomStart", vrom_start)) + vrom_variables.append(("_" + filenames[i] + "SegmentRomEnd", vrom_end)) + + i += 1 + dmadata_entry = dmadata[i * 0x10 : (i + 1) * 0x10] + + out += """ .space 0x100 .section .bss .space 0x10 """ - with open(ASM_OUT + "/dmadata/dmadata.s", "w") as outfile: - outfile.write(out) + with open(ASM_OUT + "/dmadata/dmadata.s", "w") as outfile: + outfile.write(out) + + +def disassemble_segment(section): + if section[-1]["name"] == "[PADDING]": return - for section in segment[3]: - if (section[0] == section[1] and section[2] != 'reloc') or (section[2] != 'bss' and len(section[4]) == 0): - continue - print(f"Disassembling {segment[0]} .{section[2]}") - if section[2] == 'text': - data_regions = [] - if section[3] is not None: - for override_region in section[3]: - if override_region[2] == 'data': - data_regions.append((override_region[0], override_region[1])) + print(f"Disassembling {section[-1]['name']} .{section[2]}") - disassemble_text(section[4], section[0], data_regions, segment) - elif section[2] == 'data': - disassemble_data(section[4], section[0], section[1], segment) - elif section[2] == 'rodata': - disassemble_rodata(section[4], section[0], section[1], segment) - elif section[2] == 'bss': - disassemble_bss(section[0], section[1], segment) - elif section[2] == 'reloc': - words = as_word_list(section[4]) + if section[2] == "text": + fixup_text_symbols(section[4], section[0], data_regions, section[-1]) + elif section[2] == "data": + disassemble_data(section[4], section[0], section[1], section[-1]) + elif section[2] == "rodata": + disassemble_rodata(section[4], section[0], section[1], section[-1]) + elif section[2] == "bss": + disassemble_bss(section[0], section[1], section[-1]) + elif section[2] == "reloc": + words = as_word_list(section[4]) - # ("" if segment[2] != "overlay" else "overlays/") + - segment_dirname = segment[0] + segment_dirname = section[-1]["name"] - result = asm_header(".rodata") - result += f"\nglabel {segment[0]}_Reloc\n" + result = asm_header(".rodata") + result += f"\nglabel {section[-1]['name']}_Reloc\n" - lines = [words[i*8:(i+1)*8] for i in range(0, (len(words) // 8) + 1)] - for line in [line for line in lines if len(line) != 0]: - result += f" .word {', '.join([f'0x{word:08X}' for word in line])}\n" + lines = [words[i * 8 : (i + 1) * 8] for i in range(0, (len(words) // 8) + 1)] + for line in [line for line in lines if len(line) != 0]: + result += f" .word {', '.join([f'0x{word:08X}' for word in line])}\n" - os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) - with open(f"{DATA_OUT}/{segment_dirname}/{segment[0]}.reloc.s", "w") as outfile: - outfile.write(result) + os.makedirs(f"{DATA_OUT}/{segment_dirname}/", exist_ok=True) + with open( + f"{DATA_OUT}/{segment_dirname}/{section[-1]['name']}.reloc.s", "w" + ) as outfile: + outfile.write(result) -print("Disassembling Segments") - -disassemble_makerom(next(segment for segment in files_spec if segment[2] == 'makerom')) - -# Textual disassembly for each segment -with get_context("fork").Pool(jobs) as p: - p.map(disassemble_segment, (segment for segment in files_spec if segment[2] != 'makerom')) - -print("Splitting text and migrating rodata") - -func_regex = re.compile(r'\n\nglabel \S+\n') -rodata_symbols_regex = re.compile(r'(?<=\n)glabel (.+)(?=\n)') -asm_symbols_regex = re.compile(r'%(?:lo|hi)\((.+?)\)') def rodata_block_size(block): def align(x, n): - while (x % n != 0): + while x % n != 0: x += 1 return x accumulator = 0 - for part in block.split(' */ .'): + for part in block.split(" */ ."): part = part.strip() - if part.startswith('# '): + if part.startswith("# "): continue - elif part.startswith('asciz '): - part = part[len('asciz '):] - string = part[1:-1].encode('utf-8', 'ignore').decode('unicode_escape') - accumulator += len(string.encode('euc-jp') + b'\x00') - elif part.startswith('ascii'): - part = part[len('ascii '):] - string = part[1:-1].encode('utf-8', 'ignore').decode('unicode_escape') - accumulator += len(string.encode('euc-jp')) - elif part.startswith('balign '): - part = part[len('balign '):] - accumulator = align(accumulator, int(part, 16 if part.startswith('0x') else 10)) - elif part.startswith('double '): - part = part[len('double '):] + elif part.startswith("asciz "): + part = part[len("asciz ") :] + string = part[1:-1].encode("utf-8", "ignore").decode("unicode_escape") + accumulator += len(string.encode("euc-jp") + b"\x00") + elif part.startswith("ascii"): + part = part[len("ascii ") :] + string = part[1:-1].encode("utf-8", "ignore").decode("unicode_escape") + accumulator += len(string.encode("euc-jp")) + elif part.startswith("balign "): + part = part[len("balign ") :] + accumulator = align( + accumulator, int(part, 16 if part.startswith("0x") else 10) + ) + elif part.startswith("double "): + part = part[len("double ") :] accumulator = align(accumulator, 8) - accumulator += 8 * (part.count(',') + 1) - elif part.startswith('float '): - part = part[len('float '):] + accumulator += 8 * (part.count(",") + 1) + elif part.startswith("float "): + part = part[len("float ") :] accumulator = align(accumulator, 4) - accumulator += 4 * (part.count(',') + 1) - elif part.startswith('word '): - part = part[len('word '):] + accumulator += 4 * (part.count(",") + 1) + elif part.startswith("word "): + part = part[len("word ") :] accumulator = align(accumulator, 4) - accumulator += 4 * (part.count(',') + 1) - elif part.startswith('half '): - part = part[len('half '):] + accumulator += 4 * (part.count(",") + 1) + elif part.startswith("half "): + part = part[len("half ") :] accumulator = align(accumulator, 2) - accumulator += 2 * (part.count(',') + 1) - elif part.startswith('byte '): - part = part[len('byte '):] - accumulator += 1 * (part.count(',') + 1) + accumulator += 2 * (part.count(",") + 1) + elif part.startswith("byte "): + part = part[len("byte ") :] + accumulator += 1 * (part.count(",") + 1) return accumulator + def late_rodata_size(blocks): return sum([rodata_block_size(block) for block in blocks]) + def text_block_size(asm): - return 4*len([line for line in asm.split("\n") if line.startswith("/*")]) + return 4 * len([line for line in asm.split("\n") if line.startswith("/*")]) + def rodata_syms(rodata): return re.findall(rodata_symbols_regex, rodata) + def rodata_blocks(rodata): return ["glabel" + b for b in rodata.split("glabel")[1:]] + def find_late_rodata_start(rodata): """ Returns the symbol that is the first late_rodata symbol, or None if there is no late_rodata @@ -1460,7 +2141,7 @@ def find_late_rodata_start(rodata): """ first = None - for sym,body in rodata: + for sym, body in rodata: if sym.startswith("jtbl_") and ".word L" in body: # jump tables are always late_rodata, so we can return early # floats and doubles are very rarely not late_rodata, this is mostly seen in libultra, so we cannot return early for those @@ -1472,25 +2153,281 @@ def find_late_rodata_start(rodata): # may be late_rodata, but we aren't sure yet # it is confirmed either by reaching the end or by finding a jumptable, and it is proven wrong if something that is not late_rodata occurs after it first = sym - elif (".asciz" in body or (".word " in body and ".float" not in body) or ".half " in body or ".byte " in body) and first is not None: + elif ( + ".asciz" in body + or (".word " in body and ".float" not in body) + or ".half " in body + or ".byte " in body + ) and first is not None: # reset first if something that is definitely not late_rodata is found # word and not float is due to some floats needing to be output as words either due to being a specific NaN value, or GAS can't convert it properly first = None # May still be None at this point, that just means there is no late_rodata return first + +# ==========================================# + +print("Setting Up") + +files_spec = None +with open("tools/disasm/files.txt", "r") as infile: + files_spec = ast.literal_eval(infile.read()) + +with open("tools/disasm/functions.txt", "r") as infile: + functions_ast = ast.literal_eval(infile.read()) + +with open("tools/disasm/variables.txt", "r") as infile: + variables_ast = ast.literal_eval(infile.read()) + +# We need to keep a full list of original file offsets to know where to split files later +full_file_list = {} +for segment in files_spec: + new = {} + for offset, name in segment[4].items(): + if name == "": + name = f"{segment[2]}_{offset:08X}" + new[offset] = name + full_file_list[segment[0]] = new + +if args.full: + for segment in files_spec: + for offset, name in segment[4].items(): + if name == "": + name = f"{segment[2]}_{offset:08X}" + segment[4][offset] = name +else: + # Prune + old_file_count = sum([len(f[4].keys()) for f in files_spec]) + + files_spec = discard_decomped_files(files_spec) + + new_file_count = sum([len(f[4].keys()) for f in files_spec]) + + pruned = old_file_count - new_file_count + print(f"Pruned {pruned}/{old_file_count} files ({pruned / old_file_count:.02%})") + +# Find floats, doubles, and strings +for var in sorted(variables_ast.keys()): + var_type = variables_ast[var][1] + + if var_type == "f64": + doubles.add(var) + elif var_type == "f32": + floats.add(var) + elif var_type == "char" and variables_ast[var][2].startswith("["): + strings.add(var) + +# Read in binary and relocation data for each segment +for seg, segment in enumerate(files_spec): + binary = None + with open(segment[1] + "/" + segment[0], "rb") as infile: + binary = bytes(infile.read()) + + if segment[2] == "overlay": + segment_start = list(segment[4])[0] # start addr of first file in segment + segment[3] = get_overlay_sections(segment_start, binary) + segment[4] = {} + for section in segment[3]: + segment[4].update({section[0]: segment[0]}) + else: + # start addr of first section of segment's sections + segment_start = segment[3][0][0] + # read section binary regions + for i, section in enumerate(segment[3]): + if section[2] == "bss": + continue + # section[4] + section.append( + binary[section[0] - segment_start : section[1] - segment_start] + ) + section.append(None) # section[5] + +print(f"Finding segment positions") + +for segment in files_spec: + if segment[2] == "makerom": + continue + + print(f"Finding segment positions in {segment[0]}") + + # vram segment start + if segment[3][0][0] not in variables_ast: + variables_ast.update( + {segment[3][0][0]: (f"_{segment[0]}SegmentStart", "u8", "[]", 0x1)} + ) + # vram segment end + if segment[3][-2][1] not in variables_ast: + variables_ast.update( + {segment[3][-2][1]: (f"_{segment[0]}SegmentEnd", "u8", "[]", 0x1)} + ) + +# Construct variable_addrs, now that variable_addrs is fully constructed +variable_addrs = sorted(variables_ast.keys()) + +# Flatten out files_spec so we can process everything evenly +# Otherwise the entire code and boot sections are done by a single thread +all_sections = [] +for segment in files_spec: + if segment[0] == "boot" or segment[0] == "code": + file_list = list(full_file_list[segment[0]]) + section_starts = [x[0] for x in segment[3]] + + for off, name in segment[4].items(): + # loop over the vram starts for this segment's sections to find where it belongs (text, data, etc) + for i, s in enumerate(section_starts): + if off < s: + break + else: + i = len(section_starts) + i -= 1 + + # Calculate the offset and size of this section relative to the section + data_offset = off - segment[3][i][0] + full_index = file_list.index(off) + if segment[0] == "code" and name == "buffers" and segment[3][i][2] == "bss": + # This is the end of code, hardcode it + data_size = 0x80800000 - file_list[full_index] + elif segment[0] == "boot" and name == "vimgr" and segment[3][i][2] == "bss": + # This is the end of boot, hardcode it + data_size = 0x800A5AC0 - file_list[full_index] + else: + data_size = file_list[full_index + 1] - file_list[full_index] + + # Create the section entry for this file + new_entry = [ + off, + off + data_size, + segment[3][i][2], + None, + segment[3][i][4][data_offset : data_offset + data_size] + if segment[3][i][2] not in ("bss") + else None, + None if segment[3][i][2] in ["text", "reloc", "data"] else [], + { + "name": name, + "type": segment[2], + "base": segment[3][0][0], + "syms": { + x: name for x in segment[4] if x >= off and x < off + data_size + }, + }, + ] + + all_sections.append(new_entry) + + # I don't remember what this is for but it's still needed + for i, entry in enumerate(segment[3]): + if segment[0] == "makerom" and i == 1: + segment[2] = "ipl3" + elif segment[0] == "makerom" and i == 2: + segment[2] = "entry" + entry.append( + { + "name": segment[0], + "type": segment[2], + "base": segment[3][0][0], + "syms": segment[4], + } + ) + + all_sections.extend(segment[3]) + +del files_spec[:] + +pool = get_context("fork").Pool(jobs) +# Find symbols for each segment +for section in all_sections: + if section[-1]["name"] == "makerom": + continue + + if section[2] == "text": + data_regions = [] + if section[3] is not None: + for override_region in section[3]: + if override_region[2] == "data": + data_regions.append((override_region[0], override_region[1])) + # try find a rodata section + for s in all_sections: + if ( + s[-1]["name"] == section[-1]["name"] + and s[2] == "rodata" + and s[0] != s[1] + ): + rodata_section = s + break + else: + rodata_section = None + pool.apply_async( + find_symbols_in_text, + args=(section, rodata_section if rodata_section else None, data_regions), + callback=update_symbols_from_dict, + ) + elif section[2] == "data": + pool.apply_async( + find_symbols_in_data, args=(section), callback=update_symbols_from_dict + ) + +pool.close() +pool.join() + +pool = get_context("fork").Pool(jobs) +for section in all_sections: + if section[-1]["type"] == "makerom": + continue + + if section[2] == "rodata": + pool.apply_async( + find_symbols_in_rodata, args=(section), callback=update_symbols_from_dict + ) + +pool.close() +pool.join() + +for section in all_sections: + if section[-1]["name"] == "makerom": + print(f"Disassembling makerom") + disassemble_makerom(section) + elif section[-1]["name"] == "dmadata": + print(f"Disassembling dmadata") + disassemble_dmadata(section) + +# Construct vrom_addrs, now that vrom_variables is fully constructed +vrom_addrs = {addr for _, addr in vrom_variables} + +# Textual disassembly for each segment +with get_context("fork").Pool(jobs) as p: + p.map( + disassemble_segment, + [ + sec + for sec in all_sections + if sec[-1]["name"] not in ("boot", "code", "makerom", "dmadata") + ], + ) + +print("Splitting text and migrating rodata") + +func_regex = re.compile(r"\n\nglabel \S+\n") +rodata_symbols_regex = re.compile(r"(?<=\n)glabel (.+)(?=\n)") +asm_symbols_regex = re.compile(r"%(?:lo|hi)\((.+?)\)") + # Split files and migrate rodata that should be migrated -for root,dirs,files in os.walk(ASM_OUT): +for root, dirs, files in os.walk(ASM_OUT): for f in files: if "non_matchings" in root: continue - asm_path = os.path.join(root,f) - rodata_path = asm_path.replace(ASM_OUT + "overlays/", DATA_OUT).replace(ASM_OUT, DATA_OUT).replace(".text.s", ".rodata.s") + asm_path = os.path.join(root, f) + rodata_path = ( + asm_path.replace(ASM_OUT + "overlays/", DATA_OUT) + .replace(ASM_OUT, DATA_OUT) + .replace(".text.s", ".rodata.s") + ) print(asm_path) asm = "" - with open(asm_path,"r") as infile: + with open(asm_path, "r") as infile: asm = infile.read() rodata = "" @@ -1505,15 +2442,21 @@ for root,dirs,files in os.walk(ASM_OUT): first_late_rodata = find_late_rodata_start(rodata_info) rdata_info = [] late_rodata_info = [] - target = rdata_info # first populate rdata - for sym,block in rodata_info: - if sym == first_late_rodata: # now populate late_rodata, if there is any + target = rdata_info # first populate rdata + for sym, block in rodata_info: + # now populate late_rodata, if there is any + if sym == first_late_rodata: target = late_rodata_info - target.append((sym,block)) + target.append((sym, block)) # print([(sym,block.split("\n")[1:]) for sym,block in zip(rdata_syms,rdata_blocks)]) - function_info = list(zip([s.replace("glabel","").strip() for s in func_regex.findall(asm)], func_regex.split(asm)[1:])) + function_info = list( + zip( + [s.replace("glabel", "").strip() for s in func_regex.findall(asm)], + func_regex.split(asm)[1:], + ) + ) rdata_map = {} late_rodata_map = {} @@ -1522,18 +2465,20 @@ for root,dirs,files in os.walk(ASM_OUT): if rodata != "": last_fn = None - referenced_in = {} # key=rodata label , value=function label + referenced_in = {} # key=rodata label , value=function label - for sym,_ in rodata_info: - all_refs = [label for label,body in function_info if "%lo(" + sym + ")" in body] + for sym, _ in rodata_info: + all_refs = [ + label for label, body in function_info if "%lo(" + sym + ")" in body + ] # ignore multiple refs, take only the first - referenced_in.update({ sym : all_refs[0] if len(all_refs) != 0 else None }) + referenced_in.update({sym: all_refs[0] if len(all_refs) != 0 else None}) def do_splits(out_dict, info): first = True last_ref = None cr = None - for sym,block in info: + for sym, block in info: ref = referenced_in[sym] if first: cr = ref or sym @@ -1545,11 +2490,11 @@ for root,dirs,files in os.walk(ASM_OUT): elif last_ref is not None: # new GLOBAL_ASM cr = sym - + # add to output if cr not in out_dict.keys(): - out_dict.update({cr : []}) - out_dict[cr].append((sym,block)) + out_dict.update({cr: []}) + out_dict[cr].append((sym, block)) # setup next iter last_ref = ref @@ -1559,7 +2504,9 @@ for root,dirs,files in os.walk(ASM_OUT): do_splits(late_rodata_map, late_rodata_info) # all output files, order is irrelevant at this point - all_output = set([label for label,_ in function_info]).union(set(rdata_map.keys()),set(late_rodata_map.keys())) + all_output = set([label for label, _ in function_info]).union( + set(rdata_map.keys()), set(late_rodata_map.keys()) + ) # pass 2 to output splits for label in all_output: @@ -1567,7 +2514,7 @@ for root,dirs,files in os.walk(ASM_OUT): text_out = "" rodata_out = "" - + if fn_body is not None: text_out = "glabel " + label.strip() + "\n" + fn_body.strip() + "\n" @@ -1578,43 +2525,81 @@ for root,dirs,files in os.walk(ASM_OUT): # check for late_rodata_alignment late_rodata_alignment = "" if fn_body is not None and late_rodata is not None: - ratio = late_rodata_size([block for _,block in late_rodata]) / text_block_size(fn_body) - if ratio > 1./3: + ratio = late_rodata_size( + [block for _, block in late_rodata] + ) / text_block_size(fn_body) + if ratio > 1.0 / 3: # print(f"{label} : {ratio}") # TODO hack: getting the address from a comment first_block_split = late_rodata[0][1].split(" */ .") vaddr = None - if first_block_split[1].startswith("float") or first_block_split[1].startswith("double"): + if first_block_split[1].startswith( + "float" + ) or first_block_split[1].startswith("double"): vaddr = first_block_split[0].split(" ")[-2] else: vaddr = first_block_split[0].split(" ")[-1] assert vaddr is not None - vaddr = int(vaddr,16) - if vaddr not in [0x801E0E28, 0x80C1C2B0, 0x80AA7820, 0x80AA3CC0, - 0x80AA418C, 0x80BE0160, 0x80B591D8, 0x80B59610, - 0x80B59780, 0x80964E00, 0x80964F10, 0x80BB40A0, - 0x80952038, 0x80AFB920, 0x80AFBBFC, 0x80AFBE28, - 0x80983320]: # hacks for especially badly behaved rodata, TODO these are ALL jumptables associated with - # comparatively tiny functions, can we swat these programmatically? + vaddr = int(vaddr, 16) + if vaddr not in [ + 0x801E0E28, + 0x80C1C2B0, + 0x80AA7820, + 0x80AA3CC0, + 0x80AA418C, + 0x80BE0160, + 0x80B591D8, + 0x80B59610, + 0x80B59780, + 0x80964E00, + 0x80964F10, + 0x80BB40A0, + 0x80952038, + 0x80AFB920, + 0x80AFBBFC, + 0x80AFBE28, + 0x80983320, + ]: + # hacks for especially badly behaved rodata, TODO these are ALL jumptables associated with + # comparatively tiny functions, can we swat these programmatically? late_rodata_alignment = f".late_rodata_alignment {'8' if vaddr % 8 == 0 else '4'}\n" rdata_out = "" if rdata is not None: - rdata_out = ".rdata\n" + "".join([block for _,block in rdata]) + rdata_out = ".rdata\n" + "".join([block for _, block in rdata]) late_rodata_out = "" if late_rodata is not None: - late_rodata_out = ".late_rodata\n" + late_rodata_alignment + "".join([block for _,block in late_rodata]) + late_rodata_out = ( + ".late_rodata\n" + + late_rodata_alignment + + "".join([block for _, block in late_rodata]) + ) - rodata_out = rdata_out + late_rodata_out + ("\n.text\n" if ((rdata is not None or late_rodata is not None) and fn_body is not None) else "") + rodata_out = ( + rdata_out + + late_rodata_out + + ( + "\n.text\n" + if ( + (rdata is not None or late_rodata is not None) + and fn_body is not None + ) + else "" + ) + ) all_out = rodata_out + text_out # write it out - out_path = root.replace(ASM_OUT, f"{ASM_OUT}/non_matchings/") + "/" + ((f.replace(".text.s","") + "/") if "overlays" not in root else "") + out_path = ( + root.replace(ASM_OUT, f"{ASM_OUT}/non_matchings/") + + "/" + + ((f.replace(".text.s", "") + "/") if "overlays" not in root else "") + ) os.makedirs(out_path, exist_ok=True) with open(out_path + label + ".s", "w") as outfile: outfile.write(all_out.strip() + "\n") - + # remove rodata and unsplit file # TODO diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index 586c2653be..04e4a5f39a 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -511,6 +511,7 @@ 0x801AE330 : "", 0x801AE3A0 : "z_effect_soft_sprite", 0x801AE3B0 : "z_effect_soft_sprite_old_init", + 0x801AE4A0 : "z_effect_soft_sprite_dlftbls", 0x801AE8F0 : "flg_set_table", 0x801AEC70 : "flg_set", 0x801AEC80 : "z_actor", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index d3f56b56e8..a1ec36bb9d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -659,42 +659,42 @@ 0x800B3AD0:("Actor_PrintLists",), 0x800B3BA4:("ActorShape_Init",), 0x800B3BC8:("ActorShadow_Draw",), - 0x800B3FC0:("func_800B3FC0",), - 0x800B4024:("func_800B4024",), - 0x800B4088:("func_800B4088",), - 0x800B40B8:("func_800B40B8",), - 0x800B40E0:("func_800B40E0",), - 0x800B42F8:("func_800B42F8",), - 0x800B4A98:("func_800B4A98",), + 0x800B3FC0:("ActorShadow_DrawCircle",), + 0x800B4024:("ActorShadow_DrawSquare",), + 0x800B4088:("ActorShadow_DrawWhiteCircle",), + 0x800B40B8:("ActorShadow_DrawHorse",), + 0x800B40E0:("ActorShadow_DrawFoot",), + 0x800B42F8:("ActorShadow_DrawFeet",), + 0x800B4A98:("Actor_SetFeetPos",), 0x800B4AEC:("func_800B4AEC",), 0x800B4B50:("func_800B4B50",), - 0x800B4EDC:("func_800B4EDC",), - 0x800B4F40:("func_800B4F40",), + 0x800B4EDC:("Actor_GetProjectedPos",), + 0x800B4F40:("Target_SetPos",), 0x800B4F78:("func_800B4F78",), - 0x800B5040:("func_800B5040",), + 0x800B5040:("Target_SetColors",), 0x800B51A4:("Actor_TargetContextInit",), - 0x800B5208:("func_800B5208",), + 0x800B5208:("Actor_DrawZTarget",), 0x800B5814:("func_800B5814",), 0x800B5BB0:("Flags_GetSwitch",), - 0x800B5BF4:("Actor_SetSwitchFlag",), - 0x800B5C34:("Actor_UnsetSwitchFlag",), - 0x800B5C78:("Actor_GetChestFlag",), - 0x800B5C90:("Actor_SetChestFlag",), - 0x800B5CAC:("Actor_SetAllChestFlag",), - 0x800B5CB8:("Actor_GetAllChestFlag",), - 0x800B5CC4:("Actor_GetRoomCleared",), - 0x800B5CDC:("Actor_SetRoomCleared",), - 0x800B5CF8:("Actor_UnsetRoomCleared",), - 0x800B5D18:("Actor_GetRoomClearedTemp",), - 0x800B5D30:("Actor_SetRoomClearedTemp",), - 0x800B5D4C:("Actor_UnsetRoomClearedTemp",), - 0x800B5D6C:("Actor_GetCollectibleFlag",), - 0x800B5DB0:("Actor_SetCollectibleFlag",), - 0x800B5DF0:("Actor_TitleCardContextInit",), - 0x800B5E0C:("Actor_TitleCardCreate",), - 0x800B5E50:("Actor_Nop800B5E50",), - 0x800B5E68:("Actor_TitleCardUpdate",), - 0x800B5F24:("Actor_TitleCardDraw",), + 0x800B5BF4:("Flags_SetSwitch",), + 0x800B5C34:("Flags_UnsetSwitch",), + 0x800B5C78:("Flags_GetTreasure",), + 0x800B5C90:("Flags_SetTreasure",), + 0x800B5CAC:("Flags_SetAllTreasure",), + 0x800B5CB8:("Flags_GetAllTreasure",), + 0x800B5CC4:("Flags_GetClear",), + 0x800B5CDC:("Flags_SetClear",), + 0x800B5CF8:("Flags_UnsetClear",), + 0x800B5D18:("Flags_GetClearTemp",), + 0x800B5D30:("Flags_SetClearTemp",), + 0x800B5D4C:("Flags_UnsetClearTemp",), + 0x800B5D6C:("Flags_GetCollectible",), + 0x800B5DB0:("Flags_SetCollectible",), + 0x800B5DF0:("TitleCard_ContextInit",), + 0x800B5E0C:("TitleCard_InitBossName",), + 0x800B5E50:("TitleCard_InitPlaceName",), + 0x800B5E68:("TitleCard_Update",), + 0x800B5F24:("TitleCard_Draw",), 0x800B6434:("func_800B6434",), 0x800B6468:("func_800B6468",), 0x800B6474:("func_800B6474",), @@ -704,24 +704,24 @@ 0x800B6608:("func_800B6608",), 0x800B6680:("func_800B6680",), 0x800B670C:("Actor_MarkForDeath",), - 0x800B672C:("Actor_InitCurrPosition",), - 0x800B675C:("Actor_SetHeight",), - 0x800B67A0:("Actor_SetRotationFromDrawRotation",), - 0x800B67C0:("Actor_InitDrawRotation",), + 0x800B672C:("Actor_SetWorldToHome",), + 0x800B675C:("Actor_SetFocus",), + 0x800B67A0:("Actor_SetWorldRotToShape",), + 0x800B67C0:("Actor_SetShapeRotToWorld",), 0x800B67E0:("Actor_SetScale",), - 0x800B67FC:("Actor_SetObjectSegment",), - 0x800B6834:("Actor_InitToDefaultValues",), - 0x800B6948:("Actor_FiniActor",), + 0x800B67FC:("Actor_SetObjectDependency",), + 0x800B6834:("Actor_Init",), + 0x800B6948:("Actor_Destroy",), 0x800B6988:("Actor_SetMovementScale",), - 0x800B69AC:("Actor_ApplyMovement",), - 0x800B6A10:("Actor_SetVelocityYRotationAndGravity",), - 0x800B6A88:("Actor_SetVelocityAndMoveYRotationAndGravity",), - 0x800B6AB4:("Actor_SetVelocityXYRotation",), - 0x800B6B24:("Actor_SetVelocityAndMoveXYRotation",), - 0x800B6B50:("Actor_SetVelocityXYRotationReverse",), - 0x800B6BD8:("Actor_SetVelocityAndMoveXYRotationReverse",), - 0x800B6C04:("func_800B6C04",), - 0x800B6C58:("func_800B6C58",), + 0x800B69AC:("Actor_UpdatePos",), + 0x800B6A10:("Actor_UpdateVelocityWithGravity",), + 0x800B6A88:("Actor_MoveWithGravity",), + 0x800B6AB4:("Actor_UpdateVelocityWithoutGravity",), + 0x800B6B24:("Actor_MoveWithoutGravity",), + 0x800B6B50:("Actor_UpdateVelocityWithoutGravityReverse",), + 0x800B6BD8:("Actor_MoveWithoutGravityReverse",), + 0x800B6C04:("Actor_SetSpeeds",), + 0x800B6C58:("Actor_UpdatePosFromSkelAnime",), 0x800B6CD4:("Actor_YawBetweenActors",), 0x800B6D00:("Actor_YawBetweenActorsTop",), 0x800B6D2C:("Actor_YawToPoint",), @@ -732,76 +732,76 @@ 0x800B6DF8:("Actor_DistanceToPoint",), 0x800B6E1C:("Actor_XZDistanceBetweenActors",), 0x800B6E48:("Actor_XZDistanceToPoint",), - 0x800B6E6C:("Actor_CalcOffsetOrientedToDrawRotation",), - 0x800B6F0C:("Actor_YDistance",), + 0x800B6E6C:("Actor_OffsetOfPointInActorCoords",), + 0x800B6F0C:("Actor_HeightDiff",), 0x800B6F20:("func_800B6F20",), - 0x800B6FC8:("func_800B6FC8",), - 0x800B7090:("func_800B7090",), + 0x800B6FC8:("Player_GetHeight",), + 0x800B7090:("Player_GetRunSpeedLimit",), 0x800B7118:("func_800B7118",), 0x800B7128:("func_800B7128",), 0x800B715C:("func_800B715C",), - 0x800B7170:("func_800B7170",), - 0x800B71DC:("func_800B71DC",), + 0x800B7170:("Actor_SetCameraHorseSetting",), + 0x800B71DC:("Actor_MountHorse",), 0x800B7200:("func_800B7200",), 0x800B722C:("func_800B722C",), 0x800B724C:("func_800B724C",), 0x800B7298:("func_800B7298",), 0x800B72E0:("func_800B72E0",), 0x800B72F8:("func_800B72F8",), - 0x800B7320:("Actor_IsLinkFacingActor",), - 0x800B7378:("Actor_IsActorFacedByActor",), - 0x800B73E0:("Actor_IsActorFacingLink",), - 0x800B742C:("Actor_IsActorFacingActor",), - 0x800B748C:("Actor_IsActorFacingLinkAndWithinRange",), - 0x800B750C:("Actor_IsActorFacingActorAndWithinRange",), + 0x800B7320:("Player_IsFacingActor",), + 0x800B7378:("Actor_ActorBIsFacingActorA",), + 0x800B73E0:("Actor_IsFacingPlayer",), + 0x800B742C:("Actor_ActorAIsFacingActorB",), + 0x800B748C:("Actor_IsFacingAndNearPlayer",), + 0x800B750C:("Actor_ActorAIsFacingAndNearActorB",), 0x800B75A0:("func_800B75A0",), 0x800B761C:("func_800B761C",), 0x800B7678:("func_800B7678",), 0x800B78B8:("Actor_UpdateBgCheckInfo",), - 0x800B7E04:("func_800B7E04",), - 0x800B7FE0:("func_800B7FE0",), - 0x800B8018:("func_800B8018",), + 0x800B7E04:("Hilite_Draw",), + 0x800B7FE0:("Hilite_DrawOpa",), + 0x800B8018:("Hilite_DrawXlu",), 0x800B8050:("func_800B8050",), 0x800B8118:("func_800B8118",), - 0x800B81E0:("func_800B81E0",), - 0x800B8214:("func_800B8214",), - 0x800B8248:("func_800B8248",), + 0x800B81E0:("Actor_GetFocus",), + 0x800B8214:("Actor_GetWorld",), + 0x800B8248:("Actor_GetWorldPosShapeRot",), 0x800B82EC:("func_800B82EC",), 0x800B83BC:("func_800B83BC",), 0x800B83F8:("func_800B83F8",), - 0x800B84D0:("func_800B84D0",), + 0x800B84D0:("Actor_ProcessTalkRequest",), 0x800B8500:("func_800B8500",), 0x800B85E0:("func_800B85E0",), 0x800B8614:("func_800B8614",), 0x800B863C:("func_800B863C",), - 0x800B867C:("func_800B867C",), - 0x800B86C8:("func_800B86C8",), - 0x800B8708:("func_800B8708",), + 0x800B867C:("Actor_TextboxIsClosing",), + 0x800B86C8:("Actor_ChangeFocus",), + 0x800B8708:("Player_GetExchangeItemId",), 0x800B8718:("func_800B8718",), 0x800B874C:("func_800B874C",), 0x800B8804:("func_800B8804",), 0x800B882C:("func_800B882C",), 0x800B886C:("func_800B886C",), - 0x800B8898:("func_800B8898",), + 0x800B8898:("Actor_GetScreenPos",), 0x800B8934:("func_800B8934",), 0x800B89F8:("Actor_HasParent",), - 0x800B8A1C:("func_800B8A1C",), - 0x800B8B84:("func_800B8B84",), - 0x800B8BB0:("func_800B8BB0",), - 0x800B8BD0:("func_800B8BD0",), + 0x800B8A1C:("Actor_PickUp",), + 0x800B8B84:("Actor_PickUpNearby",), + 0x800B8BB0:("Actor_LiftActor",), + 0x800B8BD0:("Actor_PickUpFar",), 0x800B8BFC:("Actor_HasNoParent",), 0x800B8C20:("func_800B8C20",), 0x800B8C50:("func_800B8C50",), - 0x800B8C78:("func_800B8C78",), - 0x800B8C9C:("func_800B8C9C",), - 0x800B8CEC:("func_800B8CEC",), + 0x800B8C78:("Actor_HasRider",), + 0x800B8C9C:("Actor_SetRideActor",), + 0x800B8CEC:("Actor_HasNoRider",), 0x800B8D10:("func_800B8D10",), 0x800B8D50:("func_800B8D50",), 0x800B8D98:("func_800B8D98",), 0x800B8DD4:("func_800B8DD4",), 0x800B8E1C:("func_800B8E1C",), 0x800B8E58:("func_800B8E58",), - 0x800B8EC8:("Audio_PlayActorSound2",), + 0x800B8EC8:("Actor_PlaySfxAtPos",), 0x800B8EF4:("func_800B8EF4",), 0x800B8F98:("func_800B8F98",), 0x800B8FC0:("func_800B8FC0",), @@ -813,11 +813,11 @@ 0x800B90AC:("func_800B90AC",), 0x800B90F4:("func_800B90F4",), 0x800B9120:("func_800B9120",), - 0x800B9170:("Actor_Init",), - 0x800B9334:("func_800B9334",), + 0x800B9170:("Actor_InitContext",), + 0x800B9334:("Actor_SpawnSetupActors",), 0x800B948C:("Actor_UpdateActor",), 0x800B9780:("Actor_UpdateAll",), - 0x800B9A04:("Actor_DrawActor",), + 0x800B9A04:("Actor_Draw",), 0x800B9D1C:("func_800B9D1C",), 0x800B9E3C:("Actor_DrawAllSetup",), 0x800B9E4C:("Actor_RecordUndrawnActor",), @@ -829,17 +829,17 @@ 0x800BA6FC:("func_800BA6FC",), 0x800BA798:("func_800BA798",), 0x800BA8B8:("func_800BA8B8",), - 0x800BA9B4:("func_800BA9B4",), - 0x800BAAB4:("Actor_InsertIntoTypeList",), - 0x800BAB24:("Actor_RemoveFromTypeList",), + 0x800BA9B4:("Actor_CleanupContext",), + 0x800BAAB4:("Actor_AddToCategory",), + 0x800BAB24:("Actor_RemoveFromCategory",), 0x800BABFC:("Actor_FreeOverlay",), 0x800BAC60:("Actor_Spawn",), 0x800BACD4:("Actor_LoadOverlay",), 0x800BAE14:("Actor_SpawnAsChildAndCutscene",), 0x800BB0C0:("Actor_SpawnAsChild",), 0x800BB140:("Actor_SpawnTransitionActors",), - 0x800BB2D0:("func_800BB2D0",), - 0x800BB498:("func_800BB498",), + 0x800BB2D0:("Actor_SpawnEntry",), + 0x800BB498:("Actor_Delete",), 0x800BB59C:("func_800BB59C",), 0x800BB604:("func_800BB604",), 0x800BB8EC:("func_800BB8EC",), @@ -847,24 +847,24 @@ 0x800BBAC0:("func_800BBAC0",), 0x800BBB74:("func_800BBB74",), 0x800BBC20:("func_800BBC20",), - 0x800BBCEC:("func_800BBCEC",), - 0x800BBDAC:("func_800BBDAC",), + 0x800BBCEC:("Actor_SpawnBodyParts",), + 0x800BBDAC:("Actor_SpawnFloorDustRing",), 0x800BBFB0:("func_800BBFB0",), 0x800BC154:("func_800BC154",), 0x800BC188:("func_800BC188",), 0x800BC1B4:("func_800BC1B4",), 0x800BC270:("func_800BC270",), 0x800BC444:("func_800BC444",), - 0x800BC4EC:("func_800BC4EC",), - 0x800BC5B8:("func_800BC5B8",), - 0x800BC5EC:("func_800BC5EC",), + 0x800BC4EC:("Actor_TestFloorInDirection",), + 0x800BC5B8:("Actor_IsTargeted",), + 0x800BC5EC:("Actor_OtherIsTargeted",), 0x800BC620:("func_800BC620",), 0x800BC770:("func_800BC770",), 0x800BC7D8:("func_800BC7D8",), 0x800BC848:("func_800BC848",), - 0x800BC8B8:("func_800BC8B8",), - 0x800BCB50:("func_800BCB50",), - 0x800BCB70:("func_800BCB70",), + 0x800BC8B8:("Actor_DrawDoorLock",), + 0x800BCB50:("Actor_SpawnShieldParticlesMetal",), + 0x800BCB70:("Actor_SetColorFilter",), 0x800BCBF4:("func_800BCBF4",), 0x800BCC68:("func_800BCC68",), 0x800BCCDC:("func_800BCCDC",), @@ -877,16 +877,16 @@ 0x800BD9E0:("func_800BD9E0",), 0x800BDAA0:("func_800BDAA0",), 0x800BDB6C:("func_800BDB6C",), - 0x800BDC5C:("func_800BDC5C",), + 0x800BDC5C:("Actor_ChangeAnimation",), 0x800BDCF4:("func_800BDCF4",), 0x800BDFB0:("Actor_Noop",), - 0x800BDFC0:("func_800BDFC0",), - 0x800BE03C:("func_800BE03C",), - 0x800BE0B8:("func_800BE0B8",), + 0x800BDFC0:("Gfx_DrawDListOpa",), + 0x800BE03C:("Gfx_DrawDListXlu",), + 0x800BE0B8:("Actor_FindNearby",), 0x800BE184:("func_800BE184",), 0x800BE22C:("Actor_ApplyDamage",), - 0x800BE258:("func_800BE258",), - 0x800BE2B8:("func_800BE2B8",), + 0x800BE258:("Actor_SetDropFlag",), + 0x800BE2B8:("Actor_SetDropFlagJntSph",), 0x800BE33C:("func_800BE33C",), 0x800BE3D0:("func_800BE3D0",), 0x800BE504:("func_800BE504",), @@ -894,7 +894,7 @@ 0x800BE5CC:("func_800BE5CC",), 0x800BE63C:("func_800BE63C",), 0x800BE680:("func_800BE680",), - 0x800BF7CC:("func_800BF7CC",), + 0x800BF7CC:("Actor_SpawnIceEffects",), 0x800BF9A0:("ActorOverlayTable_FaultPrint",), 0x800BFA78:("ActorOverlayTable_FaultAddrConv",), 0x800BFAE8:("ActorOverlayTable_Init",), @@ -1268,7 +1268,7 @@ 0x800DE9B0:("Camera_Update",), 0x800DF498:("func_800DF498",), 0x800DF4D0:("Camera_SetMode",), - 0x800DF840:("func_800DF840",), + 0x800DF840:("Camera_ChangeMode",), 0x800DF86C:("func_800DF86C",), 0x800DF8EC:("func_800DF8EC",), 0x800DFAC8:("func_800DFAC8",), @@ -2191,7 +2191,7 @@ 0x8012301C:("func_8012301C",), 0x80123140:("func_80123140",), 0x80123358:("func_80123358",), - 0x801233E4:("func_801233E4",), + 0x801233E4:("Player_InCsMode",), 0x80123420:("func_80123420",), 0x80123434:("func_80123434",), 0x80123448:("func_80123448",), @@ -2229,7 +2229,7 @@ 0x801241E0:("func_801241E0",), 0x8012420C:("func_8012420C",), 0x8012422C:("func_8012422C",), - 0x80124258:("func_80124258",), + 0x80124258:("Player_GetExplosiveHeld",), 0x80124278:("func_80124278",), 0x801242B4:("func_801242B4",), 0x801242DC:("func_801242DC",), @@ -2655,7 +2655,7 @@ 0x8013A4C4:("func_8013A4C4",), 0x8013A504:("func_8013A504",), 0x8013A530:("func_8013A530",), - 0x8013A7C0:("func_8013A7C0",), + 0x8013A7C0:("SubS_FindDoor",), 0x8013A860:("func_8013A860",), 0x8013AB00:("func_8013AB00",), 0x8013AD6C:("func_8013AD6C",), @@ -2668,7 +2668,7 @@ 0x8013B6B0:("func_8013B6B0",), 0x8013B878:("func_8013B878",), 0x8013BB34:("func_8013BB34",), - 0x8013BB7C:("func_8013BB7C",), + 0x8013BB7C:("SubS_FindNearestActor",), 0x8013BC6C:("func_8013BC6C",), 0x8013BD40:("func_8013BD40",), 0x8013BEDC:("func_8013BEDC",), @@ -2689,7 +2689,7 @@ 0x8013D83C:("func_8013D83C",), 0x8013D8DC:("func_8013D8DC",), 0x8013D924:("func_8013D924",), - 0x8013D960:("func_ActorCategoryIterateById",), + 0x8013D960:("SubS_FindActor",), 0x8013D9C8:("func_8013D9C8",), 0x8013DB90:("func_8013DB90",), 0x8013DC40:("func_8013DC40",), @@ -2705,7 +2705,7 @@ 0x8013E3B8:("func_8013E3B8",), 0x8013E4B0:("func_8013E4B0",), 0x8013E5CC:("func_8013E5CC",), - 0x8013E640:("func_8013E640",), + 0x8013E640:("SubS_FindActorCustom",), 0x8013E748:("func_8013E748",), 0x8013E7C0:("func_8013E7C0",), 0x8013E8F8:("func_8013E8F8",), @@ -2860,7 +2860,7 @@ 0x80151DA4:("func_80151DA4",), 0x80152434:("func_80152434",), 0x80152464:("func_80152464",), - 0x80152498:("func_80152498",), + 0x80152498:("Message_GetState",), 0x8015268C:("func_8015268C",), 0x80152C64:("func_80152C64",), 0x80152CAC:("func_80152CAC",), @@ -3324,7 +3324,7 @@ 0x8017D404:("func_8017D404",), 0x8017D568:("Math3D_TriSetCoords",), 0x8017D618:("Math3D_IsPointInSphere",), - 0x8017D668:("func_8017D668",), + 0x8017D668:("Math3D_PointDistToLine2D",), 0x8017D7C0:("func_8017D7C0",), 0x8017D814:("func_8017D814",), 0x8017D91C:("func_8017D91C",), @@ -4033,7 +4033,7 @@ 0x801A5BD0:("func_801A5BD0",), 0x801A5C28:("func_801A5C28",), 0x801A5C8C:("func_801A5C8C",), - 0x801A5CFC:("func_801A5CFC",), + 0x801A5CFC:("Audio_PlaySfxGeneral",), 0x801A5DDC:("func_801A5DDC",), 0x801A5F7C:("func_801A5F7C",), 0x801A6430:("func_801A6430",), @@ -5527,8 +5527,8 @@ 0x808986A4:("func_808986A4",), 0x8089874C:("func_8089874C",), 0x80898A28:("EnPeehat_Update",), - 0x80898E74:("func_80898E74",), - 0x80899024:("func_80899024",), + 0x80898E74:("EnPeehat_OverrideLimbDraw",), + 0x80899024:("EnPeehat_PostLimbDraw",), 0x80899218:("EnPeehat_Draw",), 0x80899960:("EnHoll_SetupAction",), 0x808999B0:("EnHoll_SetPlayerSide",), @@ -5736,7 +5736,7 @@ 0x808A7138:("EnSt_Init",), 0x808A71D0:("EnSt_Destroy",), 0x808A7230:("EnSt_Update",), - 0x808A73E8:("func_808A73E8",), + 0x808A73E8:("EnSt_OverrideLimbDraw",), 0x808A7478:("func_808A7478",), 0x808A7930:("ObjWturn_Init",), 0x808A7954:("func_808A7954",), @@ -6818,52 +6818,52 @@ 0x808FC550:("EnFr_Init",), 0x808FC5AC:("EnFr_Destroy",), 0x808FC5BC:("EnFr_Update",), - 0x808FC6C0:("func_808FC6C0",), - 0x808FC770:("func_808FC770",), - 0x808FC790:("func_808FC790",), - 0x808FC8B8:("func_808FC8B8",), - 0x808FC964:("func_808FC964",), - 0x808FCABC:("func_808FCABC",), - 0x808FCC0C:("func_808FCC0C",), - 0x808FCDBC:("func_808FCDBC",), - 0x808FCF60:("func_808FCF60",), - 0x808FD054:("func_808FD054",), + 0x808FC6C0:("EnFishing_SetColliderElement",), + 0x808FC770:("EnFishing_SeedRand",), + 0x808FC790:("EnFishing_RandZeroOne",), + 0x808FC8B8:("EnFishing_SmoothStepToS",), + 0x808FC964:("EnFishing_SpawnRipple",), + 0x808FCABC:("EnFishing_SpawnDustSplash",), + 0x808FCC0C:("EnFishing_SpawnWaterDust",), + 0x808FCDBC:("EnFishing_SpawnBubble",), + 0x808FCF60:("EnFishing_SpawnRainDrop",), + 0x808FD054:("EnFishing_InitPondProps",), 0x808FD368:("EnFishing_Init",), 0x808FDC64:("EnFishing_Destroy",), - 0x808FDCDC:("func_808FDCDC",), - 0x808FE3F8:("func_808FE3F8",), - 0x808FEE1C:("func_808FEE1C",), + 0x808FDCDC:("EnFishing_UpdateEffects",), + 0x808FE3F8:("EnFishing_DrawEffects",), + 0x808FEE1C:("EnFishing_DrawStreamSplash",), 0x808FEF70:("func_808FEF70",), - 0x808FF064:("func_808FF064",), - 0x808FF5E0:("func_808FF5E0",), - 0x808FF750:("func_808FF750",), - 0x808FFC44:("func_808FFC44",), - 0x808FFF3C:("func_808FFF3C",), - 0x80900228:("func_80900228",), - 0x80900A04:("func_80900A04",), - 0x80901480:("func_80901480",), + 0x808FF064:("EnFishing_UpdateLine",), + 0x808FF5E0:("EnFishing_UpdateLinePos",), + 0x808FF750:("EnFishing_DrawLureHook",), + 0x808FFC44:("EnFishing_UpdateSinkingLure",), + 0x808FFF3C:("EnFishing_DrawSinkingLure",), + 0x80900228:("EnFishing_DrawLureAndLine",), + 0x80900A04:("EnFishing_DrawRod",), + 0x80901480:("EnFishing_UpdateLure",), 0x809033F0:("func_809033F0",), 0x809036BC:("func_809036BC",), 0x809038A4:("func_809038A4",), 0x80903C60:("func_80903C60",), - 0x80903E20:("func_80903E20",), - 0x80903FE0:("EnFishing_Update",), - 0x80908554:("func_80908554",), - 0x80908674:("func_80908674",), - 0x809086B4:("func_809086B4",), - 0x80908734:("func_80908734",), - 0x80908774:("EnFishing_Draw",), - 0x809089B8:("func_809089B8",), - 0x80908A64:("func_80908A64",), - 0x80908B4C:("func_80908B4C",), - 0x80908E08:("func_80908E08",), - 0x80909234:("func_80909234",), - 0x80909AD0:("func_80909AD0",), - 0x80909CC0:("func_80909CC0",), - 0x8090AB6C:("func_8090AB6C",), - 0x8090C884:("func_8090C884",), - 0x8090C8BC:("func_8090C8BC",), - 0x8090C96C:("func_8090C96C",), + 0x80903E20:("EnFishing_HandleAquariumDialog",), + 0x80903FE0:("EnFishing_UpdateFish",), + 0x80908554:("EnFishing_FishOverrideLimbDraw",), + 0x80908674:("EnFishing_FishPostLimbDraw",), + 0x809086B4:("EnFishing_LoachOverrideLimbDraw",), + 0x80908734:("EnFishing_LoachPostLimbDraw",), + 0x80908774:("EnFishing_DrawFish",), + 0x809089B8:("EnFishing_HandleReedContact",), + 0x80908A64:("EnFishing_HandleLilyPadContact",), + 0x80908B4C:("EnFishing_UpdatePondProps",), + 0x80908E08:("EnFishing_DrawPondProps",), + 0x80909234:("EnFishing_UpdateGroupFishes",), + 0x80909AD0:("EnFishing_DrawGroupFishes",), + 0x80909CC0:("EnFishing_HandleOwnerDialog",), + 0x8090AB6C:("EnFishing_UpdateOwner",), + 0x8090C884:("EnFishing_OwnerOverrideLimbDraw",), + 0x8090C8BC:("EnFishing_OwnerPostLimbDraw",), + 0x8090C96C:("EnFishing_DrawOwner",), 0x80917290:("func_80917290",), 0x809172E4:("func_809172E4",), 0x8091734C:("func_8091734C",), @@ -8077,51 +8077,51 @@ 0x80973DE0:("func_80973DE0",), 0x80973E60:("ObjRoomtimer_Update",), 0x80973EF0:("EnSsh_SetupAction",), - 0x80973EFC:("func_80973EFC",), - 0x80973F84:("func_80973F84",), - 0x80974080:("func_80974080",), - 0x80974118:("func_80974118",), - 0x80974220:("func_80974220",), - 0x8097424C:("func_8097424C",), - 0x80974374:("func_80974374",), - 0x809744A8:("func_809744A8",), - 0x809744C8:("func_809744C8",), - 0x809744FC:("func_809744FC",), - 0x80974540:("func_80974540",), - 0x80974590:("func_80974590",), - 0x809745BC:("func_809745BC",), - 0x80974730:("func_80974730",), - 0x8097480C:("func_8097480C",), - 0x809748DC:("func_809748DC",), - 0x8097497C:("func_8097497C",), - 0x809749B8:("func_809749B8",), - 0x80974A24:("func_80974A24",), - 0x80974B0C:("func_80974B0C",), - 0x80974B44:("func_80974B44",), - 0x80974B84:("func_80974B84",), - 0x80974CC8:("func_80974CC8",), - 0x80974D3C:("func_80974D3C",), - 0x80974E44:("func_80974E44",), - 0x80974EA0:("func_80974EA0",), - 0x80974F78:("func_80974F78",), - 0x8097502C:("func_8097502C",), - 0x80975070:("func_80975070",), - 0x80975128:("func_80975128",), - 0x80975300:("func_80975300",), + 0x80973EFC:("EnSsh_SpawnShockwave",), + 0x80973F84:("EnSsh_CreateBlureEffect",), + 0x80974080:("EnSsh_CheckCeilingPos",), + 0x80974118:("EnSsh_AddBlureVertex",), + 0x80974220:("EnSsh_AddBlureSpace",), + 0x8097424C:("EnSsh_InitColliders",), + 0x80974374:("EnSsh_SetAnimation",), + 0x809744A8:("EnSsh_SetWaitAnimation",), + 0x809744C8:("EnSsh_SetReturnAnimation",), + 0x809744FC:("EnSsh_SetLandAnimation",), + 0x80974540:("EnSsh_SetDropAnimation",), + 0x80974590:("EnSsh_SetStunned",), + 0x809745BC:("EnSsh_SetColliderScale",), + 0x80974730:("EnSsh_Damaged",), + 0x8097480C:("EnSsh_Turn",), + 0x809748DC:("EnSsh_Stunned",), + 0x8097497C:("EnSsh_UpdateYaw",), + 0x809749B8:("EnSsh_Bob",), + 0x80974A24:("EnSsh_IsCloseToLink",), + 0x80974B0C:("EnSsh_IsCloseToHome",), + 0x80974B44:("EnSsh_IsCloseToGround",), + 0x80974B84:("EnSsh_Sway",), + 0x80974CC8:("EnSsh_CheckBodyStickHit",), + 0x80974D3C:("EnSsh_CheckHitPlayer",), + 0x80974E44:("EnSsh_CheckHitFront",), + 0x80974EA0:("EnSsh_CheckHitBack",), + 0x80974F78:("EnSsh_CollisionCheck",), + 0x8097502C:("EnSsh_SetBodyCylinderAC",), + 0x80975070:("EnSsh_SetLegsCylinderAC",), + 0x80975128:("EnSsh_SetCylinderOC",), + 0x80975300:("EnSsh_SetColliders",), 0x809753C8:("EnSsh_Init",), 0x80975540:("EnSsh_Destroy",), - 0x809755C0:("func_809755C0",), - 0x8097561C:("func_8097561C",), + 0x809755C0:("EnSsh_Wait",), + 0x8097561C:("EnSsh_Talk",), 0x809756D0:("func_809756D0",), - 0x80975720:("func_80975720",), - 0x809758B0:("func_809758B0",), - 0x80975998:("func_80975998",), - 0x80975A98:("func_80975A98",), - 0x80975B6C:("func_80975B6C",), - 0x80975C14:("func_80975C14",), + 0x80975720:("EnSsh_Idle",), + 0x809758B0:("EnSsh_Land",), + 0x80975998:("EnSsh_Drop",), + 0x80975A98:("EnSsh_Return",), + 0x80975B6C:("EnSsh_UpdateColliderScale",), + 0x80975C14:("EnSsh_Start",), 0x80975C9C:("EnSsh_Update",), - 0x80975DBC:("func_80975DBC",), - 0x80975EB8:("func_80975EB8",), + 0x80975DBC:("EnSsh_OverrideLimbDraw",), + 0x80975EB8:("EnSsh_PostLimbDraw",), 0x80975F38:("EnSsh_Draw",), 0x809764B0:("OceffWipe_Init",), 0x8097650C:("OceffWipe_Destroy",), @@ -8678,8 +8678,8 @@ 0x809A1E60:("EnZl4_Draw",), 0x809A2030:("EnMm2_Init",), 0x809A2070:("EnMm2_Destroy",), - 0x809A2080:("func_809A2080",), - 0x809A20FC:("func_809A20FC",), + 0x809A2080:("EnMm2_Reading",), + 0x809A20FC:("EnMm2_WaitForRead",), 0x809A2194:("EnMm2_Update",), 0x809A21B8:("EnMm2_Draw",), 0x809A2B60:("DoorSpiral_SetupAction",), @@ -9375,8 +9375,8 @@ 0x809ED45C:("func_809ED45C",), 0x809ED50C:("func_809ED50C",), 0x809ED8BC:("Boss04_Update",), - 0x809EDCCC:("func_809EDCCC",), - 0x809EDECC:("func_809EDECC",), + 0x809EDCCC:("Boss04_OverrideLimbDraw",), + 0x809EDECC:("Boss04_PostLimbDraw",), 0x809EDF58:("Boss04_Draw",), 0x809EE4E0:("func_809EE4E0",), 0x809EE668:("func_809EE668",), @@ -9742,8 +9742,8 @@ 0x80A15960:("EnGo_Destroy",), 0x80A159B0:("EnGo_Update",), 0x80A15B80:("func_80A15B80",), - 0x80A15D04:("func_80A15D04",), - 0x80A15E38:("func_80A15E38",), + 0x80A15D04:("EnGo_OverrideLimbDraw",), + 0x80A15E38:("EnGo_UnkDraw",), 0x80A15FEC:("func_80A15FEC",), 0x80A16D40:("func_80A16D40",), 0x80A16D6C:("func_80A16D6C",), @@ -11100,10 +11100,10 @@ 0x80A7BC70:("ObjEtcetera_Init",), 0x80A7BD80:("ObjEtcetera_Destroy",), 0x80A7BDC8:("ObjEtcetera_DoNormalOscillation",), - 0x80A7BE8C:("ObjEtcetera_StartSmallFlutterAnimation",), + 0x80A7BE8C:("ObjEtcetera_StartRustleAnimation",), 0x80A7BF08:("ObjEtcetera_Idle",), - 0x80A7C168:("ObjEtcetera_PlaySmallFlutterAnimation",), - 0x80A7C1F0:("ObjEtcetera_DoIntenseOscillation",), + 0x80A7C168:("ObjEtcetera_PlayRustleAnimation",), + 0x80A7C1F0:("ObjEtcetera_DoBounceOscillation",), 0x80A7C308:("ObjEtcetera_Setup",), 0x80A7C5EC:("ObjEtcetera_Update",), 0x80A7C690:("ObjEtcetera_DrawIdle",), @@ -12276,7 +12276,7 @@ 0x80AD8A48:("func_80AD8A48",), 0x80AD8AF8:("func_80AD8AF8",), 0x80AD8BC0:("EnKame_Draw",), - 0x80AD8CEC:("func_80AD8CEC",), + 0x80AD8CEC:("Enkame_OverrideLimbDraw",), 0x80AD8D64:("func_80AD8D64",), 0x80AD9240:("func_80AD9240",), 0x80AD92FC:("func_80AD92FC",), @@ -12805,7 +12805,7 @@ 0x80AFDD34:("EnColMan_Destroy",), 0x80AFDD60:("func_80AFDD60",), 0x80AFDE00:("func_80AFDE00",), - 0x80AFDF00:("func_80AFDF00",), + 0x80AFDF00:("EnColMan_SetHeartPieceCollectedAndKill",), 0x80AFDF60:("func_80AFDF60",), 0x80AFDFB4:("func_80AFDFB4",), 0x80AFE234:("func_80AFE234",), @@ -13021,8 +13021,8 @@ 0x80B1137C:("EnGb2_Init",), 0x80B116E4:("EnGb2_Destroy",), 0x80B11710:("EnGb2_Update",), - 0x80B1179C:("func_80B1179C",), - 0x80B117FC:("func_80B117FC",), + 0x80B1179C:("EnGb2_OverrideLimbDraw",), + 0x80B117FC:("EnGb2_PostLimbDraw",), 0x80B11858:("EnGb2_Draw",), 0x80B11E60:("EnOnpuman_Init",), 0x80B11F18:("EnOnpuman_Destroy",), @@ -16483,7 +16483,7 @@ 0x80C00234:("func_80C00234",), 0x80C00284:("func_80C00284",), 0x80C00644:("EnBomjima_Update",), - 0x80C007F4:("func_80C007F4",), + 0x80C007F4:("EnBomjima_OverrideLimbDraw",), 0x80C008B4:("EnBomjima_Draw",), 0x80C00EA0:("EnBomjimb_Init",), 0x80C01110:("EnBomjimb_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 72ce60c95d..60e39862cc 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -398,7 +398,7 @@ 0x801AE2DC:("D_801AE2DC","UNK_TYPE4","",0x4), 0x801AE2F0:("sEffectShieldParticleVertices","F3DVertex","[4]",0x40), 0x801AE330:("sEffectInfoTable","EffectInfo","[5]",0x64), - 0x801AE3A0:("EffectSS2Info","EffectSsInfo","",0xc), + 0x801AE3A0:("sEffectSsInfo","EffectSsInfo","",0xc), 0x801AE3B0:("D_801AE3B0","Color_RGBA8","",0x4), 0x801AE3B4:("D_801AE3B4","Color_RGBA8","",0x4), 0x801AE3B8:("D_801AE3B8","Color_RGBA8","",0x4), @@ -419,32 +419,28 @@ 0x801AE480:("D_801AE480","Color_RGBA8","",0x4), 0x801AE484:("D_801AE484","Color_RGBA8","",0x4), 0x801AE488:("D_801AE488","Color_RGBA8","",0x4), - 0x801AE489:("D_801AE489","UNK_TYPE1","",0x1), - 0x801AE48A:("D_801AE48A","UNK_TYPE1","",0x1), 0x801AE48C:("D_801AE48C","Color_RGBA8","",0x4), 0x801AE490:("D_801AE490","Color_RGBA8","[4]",0x10), - 0x801AE4A0:("particleOverlayTable","EffectSsOverlay","[39]",0x444), + 0x801AE4A0:("gParticleOverlayTable","EffectSsOverlay","[39]",0x444), 0x801AE8F0:("sFlagEntries","FlagSetEntry","[112]",0x8), 0x801AEC70:("sEntryIndex","s32","",0x4), 0x801AEC74:("sCurrentBit","u32","",0x4), 0x801AEC78:("sTimer","s32","",0x4), 0x801AEC80:("D_801AEC80","Color_RGBA8","",0x4), - 0x801AEC84:("D_801AEC84","s801AEC84","[13]",0x68), + 0x801AEC84:("sTatlColorList","TatlColor","[13]",0x68), 0x801AECEC:("actorMovementScale","f32","",0x4), - 0x801AECF0:("D_801AECF0","f32","",0x4), - 0x801AECF4:("D_801AECF4","f32","",0x4), - 0x801AED48:("D_801AED48","UNK_TYPE1","",0x1), + 0x801AECF0:("gTargetRanges","f32","[]",0x58), + 0x801AED48:("D_801AED48","s16","[8]",0x10), 0x801AED58:("D_801AED58","UNK_TYPE4","",0x4), 0x801AED88:("actorDefaultHitColor","Color_RGBA8","",0x4), 0x801AED8C:("D_801AED8C","UNK_TYPE1","",0x1), - 0x801AED98:("D_801AED98","UNK_TYPE4","",0x4), + 0x801AED98:("D_801AED98","Vec3f","",0xC), 0x801AEDA4:("D_801AEDA4","UNK_TYPE4","",0x4), 0x801AEDB0:("D_801AEDB0","UNK_TYPE1","",0x1), 0x801AEDD4:("D_801AEDD4","UNK_TYPE4","",0x4), 0x801AEE28:("D_801AEE28","UNK_TYPE4","",0x4), 0x801AEE30:("D_801AEE30","UNK_TYPE4","",0x4), - 0x801AEE38:("D_801AEE38","UNK_TYPE4","",0x4), - 0x801AEE4C:("D_801AEE4C","UNK_TYPE2","",0x2), + 0x801AEE38:("D_801AEE38","struct_801AEE38","[14]",0x150), 0x801AEF88:("D_801AEF88","UNK_TYPE1","",0x1), 0x801AEFA0:("D_801AEFA0","UNK_TYPE1","",0x1), 0x801AEFA8:("D_801AEFA8","UNK_TYPE1","",0x1), @@ -3890,7 +3886,7 @@ 0x801E3FB0:("sEffectContext","EffectContext","",0x98E0), 0x801ED890:("D_801ED890","UNK_TYPE1","",0x1), 0x801ED894:("D_801ED894","UNK_TYPE1","",0x1), - 0x801ED8A0:("D_801ED8A0","UNK_TYPE1","",0x1), + 0x801ED8A0:("sActorFaultClient","UNK_TYPE1","",0x1), 0x801ED8B0:("D_801ED8B0","UNK_TYPE1","",0x1), 0x801ED8B4:("D_801ED8B4","UNK_TYPE1","",0x1), 0x801ED8B8:("D_801ED8B8","UNK_TYPE1","",0x1), @@ -3898,7 +3894,7 @@ 0x801ED8C0:("D_801ED8C0","UNK_TYPE1","",0x1), 0x801ED8C4:("D_801ED8C4","UNK_TYPE1","",0x1), 0x801ED8C8:("D_801ED8C8","f32","",0x4), - 0x801ED8CC:("D_801ED8CC","f32","",0x4), + 0x801ED8CC:("sBgmEnemyDistSq","f32","",0x4), 0x801ED8D0:("D_801ED8D0","f32","",0x4), 0x801ED8D4:("D_801ED8D4","UNK_TYPE1","",0x1), 0x801ED8D8:("D_801ED8D8","UNK_TYPE1","",0x1), @@ -7547,12 +7543,11 @@ 0x808FC670:("En_Fr_InitVars","UNK_TYPE1","",0x1), 0x8090CCB0:("En_Fishing_InitVars","UNK_TYPE1","",0x1), 0x8090CCD0:("D_8090CCD0","f32","",0x4), - 0x8090CCD4:("D_8090CCD4","UNK_TYPE1","",0x1), + 0x8090CCD4:("D_8090CCD4","u8","",0x1), 0x8090CCD8:("D_8090CCD8","f32","",0x4), - 0x8090CCDC:("D_8090CCDC","UNK_TYPE1","",0x1), - 0x8090CCE4:("D_8090CCE4","UNK_TYPE4","",0x4), - 0x8090CCE8:("D_8090CCE8","UNK_TYPE4","",0x4), - 0x8090CCEC:("D_8090CCEC","UNK_TYPE1","",0x1), + 0x8090CCDC:("D_8090CCDC","Vec3f","",0xC), + 0x8090CCE8:("D_8090CCE8","f32","",0x4), + 0x8090CCEC:("sSinkingLureLocation","u8","",0x1), 0x8090CCF0:("D_8090CCF0","f32","",0x4), 0x8090CCF4:("D_8090CCF4","UNK_TYPE1","",0x1), 0x8090CCF8:("D_8090CCF8","UNK_TYPE2","",0x2), @@ -7563,18 +7558,17 @@ 0x8090CD0C:("D_8090CD0C","UNK_TYPE1","",0x1), 0x8090CD10:("D_8090CD10","UNK_TYPE1","",0x1), 0x8090CD14:("D_8090CD14","UNK_TYPE2","",0x2), - 0x8090CD18:("D_8090CD18","UNK_TYPE1","",0x1), - 0x8090CD1C:("D_8090CD1C","f32","",0x4), + 0x8090CD18:("sFishMouthOffset","Vec3f","",0xC), 0x8090CD24:("D_8090CD24","UNK_TYPE1","",0x1), 0x8090CD28:("D_8090CD28","f32","",0x4), 0x8090CD2C:("D_8090CD2C","f32","",0x4), 0x8090CD30:("D_8090CD30","f32","",0x4), 0x8090CD34:("D_8090CD34","f32","",0x4), - 0x8090CD38:("D_8090CD38","UNK_TYPE4","",0x4), + 0x8090CD38:("D_8090CD38","f32","",0x4), 0x8090CD3C:("D_8090CD3C","f32","",0x4), 0x8090CD40:("D_8090CD40","f32","",0x4), - 0x8090CD44:("D_8090CD44","UNK_TYPE2","",0x2), - 0x8090CD48:("D_8090CD48","UNK_TYPE2","",0x2), + 0x8090CD44:("D_8090CD44","s16","",0x2), + 0x8090CD48:("D_8090CD48","s16","",0x2), 0x8090CD4C:("D_8090CD4C","UNK_TYPE1","",0x1), 0x8090CD50:("D_8090CD50","UNK_TYPE1","",0x1), 0x8090CD54:("D_8090CD54","UNK_TYPE1","",0x1), @@ -7584,7 +7578,8 @@ 0x8090CD8C:("D_8090CD8C","UNK_TYPE1","",0x1), 0x8090CF08:("D_8090CF08","UNK_TYPE1","",0x1), 0x8090CF18:("D_8090CF18","UNK_TYPE1","",0x1), - 0x8090CF1C:("D_8090CF1C","UNK_TYPE4","",0x4), + 0x8090CF1C:("sZeroVec","Vec3f","",0xC), + 0x8090CF28:("D_8090CF28","Vec3f","",0xC), 0x8090CF34:("D_8090CF34","UNK_TYPE4","",0x4), 0x8090CF40:("D_8090CF40","UNK_TYPE4","",0x4), 0x8090CF4C:("D_8090CF4C","UNK_TYPE4","",0x4), @@ -7598,14 +7593,14 @@ 0x8090D508:("D_8090D508","UNK_TYPE1","",0x1), 0x8090D558:("D_8090D558","UNK_TYPE1","",0x1), 0x8090D5B0:("D_8090D5B0","UNK_TYPE4","",0x4), - 0x8090D608:("D_8090D608","UNK_TYPE1","",0x1), - 0x8090D614:("D_8090D614","UNK_TYPE1","",0x1), - 0x8090D620:("D_8090D620","UNK_TYPE4","",0x4), + 0x8090D608:("sRodTipOffset","Vec3f","",0xC), + 0x8090D614:("D_8090D614","Vec3f","",0xC), + 0x8090D620:("D_8090D620","Vec3f","",0xC), 0x8090D62C:("D_8090D62C","UNK_TYPE1","",0x1), 0x8090D638:("D_8090D638","UNK_TYPE1","",0x1), - 0x8090D644:("D_8090D644","UNK_TYPE1","",0x1), - 0x8090D650:("D_8090D650","UNK_TYPE1","",0x1), - 0x8090D65C:("D_8090D65C","UNK_TYPE1","",0x1), + 0x8090D644:("D_8090D644","s16","[5]",0xA), + 0x8090D650:("sStreamSoundPos","Vec3f","",0xC), + 0x8090D65C:("sSinkingLureLocationPos","Vec3s","[4]",0x18), 0x8090D674:("D_8090D674","UNK_TYPE1","",0x1), 0x8090D680:("D_8090D680","f32","",0x4), 0x8090D684:("D_8090D684","f32","",0x4), @@ -7891,46 +7886,37 @@ 0x809101C8:("D_809101C8","f32","",0x4), 0x809101CC:("D_809101CC","UNK_TYPE1","",0x1), 0x809101D0:("D_809101D0","UNK_TYPE1","",0x1), - 0x809101D8:("D_809101D8","UNK_TYPE1","",0x1), - 0x809101E8:("D_809101E8","UNK_TYPE1","",0x1), - 0x80910B3C:("D_80910B3C","f32","",0x4), - 0x80910B40:("D_80910B40","f32","",0x4), - 0x80910B44:("D_80910B44","f32","",0x4), - 0x80910B48:("D_80910B48","UNK_TYPE1","",0x1), - 0x809114A8:("D_809114A8","UNK_TYPE1","",0x1), - 0x80911E08:("D_80911E08","UNK_TYPE1","",0x1), - 0x80911E14:("D_80911E14","UNK_TYPE1","",0x1), - 0x80911E20:("D_80911E20","UNK_TYPE1","",0x1), + 0x809101D8:("sRodTipPos","Vec3f","",0xC), + 0x809101E8:("sReelLinePos","Vec3f","[200]",0x960), + 0x80910B48:("sReelLineRot","Vec3f","[200]",0x960), + 0x809114A8:("sReelLineUnk","Vec3f","[200]",0x960), + 0x80911E08:("sLureHookRefPos","Vec3f","[2]",0x18), + 0x80911E20:("sLureHookRotY","f32","[2]",0x8), 0x80911E28:("D_80911E28","UNK_TYPE1","",0x1), - 0x80911E30:("D_80911E30","UNK_TYPE1","",0x1), - 0x80911E3C:("D_80911E3C","UNK_TYPE1","",0x1), + 0x80911E30:("sSinkingLurePos","Vec3f","[20]",0xF0), 0x80911F20:("D_80911F20","UNK_TYPE1","",0x1), - 0x80911F24:("D_80911F24","UNK_TYPE1","",0x1), - 0x80911F28:("D_80911F28","f32","",0x4), - 0x80911F2C:("D_80911F2C","f32","",0x4), - 0x80911F30:("D_80911F30","UNK_TYPE1","",0x1), - 0x80911F38:("D_80911F38","f32","",0x4), - 0x80911F3C:("D_80911F3C","f32","",0x4), - 0x80911F40:("D_80911F40","f32","",0x4), - 0x80911F44:("D_80911F44","UNK_TYPE1","",0x1), + 0x80911F24:("sProjectedW","f32","",0x4), + 0x80911F28:("sCameraEye","Vec3f","",0xC), + 0x80911F38:("sCameraAt","Vec3f","",0xC), + 0x80911F44:("sCameraId","s32","",0x4), 0x80911F48:("D_80911F48","f32","",0x4), 0x80911F4C:("D_80911F4C","f32","",0x4), 0x80911F50:("D_80911F50","UNK_TYPE1","",0x1), - 0x80911F58:("D_80911F58","UNK_TYPE1","",0x1), + 0x80911F58:("sSinkingLureBasePos","Vec3f","",0xC), 0x80911F64:("D_80911F64","f32","",0x4), - 0x80911F68:("D_80911F68","UNK_TYPE1","",0x1), - 0x80911F6C:("D_80911F6C","UNK_TYPE1","",0x1), - 0x80911F70:("D_80911F70","UNK_TYPE1","",0x1), - 0x80911F78:("D_80911F78","UNK_TYPE1","",0x1), - 0x80914048:("D_80914048","UNK_TYPE1","",0x1), - 0x80915128:("D_80915128","f32","",0x4), - 0x8091512C:("D_8091512C","f32","",0x4), - 0x80915130:("D_80915130","UNK_TYPE1","",0x1), - 0x80915138:("D_80915138","UNK_TYPE1","",0x1), - 0x809171B8:("D_809171B8","UNK_TYPE1","",0x1), - 0x809171C4:("D_809171C4","UNK_TYPE1","",0x1), + 0x80911F68:("sRandSeed0","s32","",0x4), + 0x80911F6C:("sRandSeed1","s32","",0x4), + 0x80911F70:("sRandSeed2","s32","",0x4), + 0x80911F78:("sPondProps","UNK_TYPE1","[140]",0x20D0), + 0x80914048:("sGroupFishes","UNK_TYPE1","[60]",0x10E0), + 0x80915128:("sFishGroupAngle1","f32","",0x4), + 0x8091512C:("sFishGroupAngle2","f32","",0x4), + 0x80915130:("sFishGroupAngle3","f32","",0x4), + 0x80915138:("sFishingEffects","UNK_TYPE1","[130]",0x2080), + 0x809171B8:("sStreamSoundProjectedPos","Vec3f","",0xC), + 0x809171C4:("sFishingMain","UNK_TYPE","",0x4), 0x809171C8:("D_809171C8","UNK_TYPE1","",0x1), - 0x809171C9:("D_809171C9","UNK_TYPE1","",0x1), + 0x809171C9:("sLinkAge","UNK_TYPE1","",0x1), 0x809171CA:("D_809171CA","UNK_TYPE1","",0x1), 0x809171CB:("D_809171CB","UNK_TYPE1","",0x1), 0x809171CC:("D_809171CC","f32","",0x4), @@ -7942,29 +7928,23 @@ 0x809171D8:("D_809171D8","UNK_TYPE1","",0x1), 0x809171DA:("D_809171DA","UNK_TYPE1","",0x1), 0x809171DC:("D_809171DC","UNK_TYPE1","",0x1), - 0x809171E0:("D_809171E0","UNK_TYPE1","",0x1), - 0x809171EC:("D_809171EC","UNK_TYPE1","",0x1), - 0x809171EE:("D_809171EE","UNK_TYPE1","",0x1), - 0x809171F0:("D_809171F0","UNK_TYPE1","",0x1), + 0x809171E0:("sOwnerHeadPos","Vec3f","",0xC), + 0x809171EC:("sEffOwnerHatRot","Vec3s","",0x6), 0x809171F2:("D_809171F2","UNK_TYPE1","",0x1), 0x809171F4:("D_809171F4","UNK_TYPE1","",0x1), 0x809171F6:("D_809171F6","UNK_TYPE1","",0x1), - 0x809171F8:("D_809171F8","UNK_TYPE1","",0x1), + 0x809171F8:("sFishingHookedFish","UNK_TYPE","",0x4), 0x809171FC:("D_809171FC","UNK_TYPE1","",0x1), 0x809171FE:("D_809171FE","UNK_TYPE1","",0x1), 0x80917200:("D_80917200","UNK_TYPE1","",0x1), 0x80917202:("D_80917202","UNK_TYPE1","",0x1), 0x80917204:("D_80917204","UNK_TYPE1","",0x1), 0x80917206:("D_80917206","UNK_TYPE1","",0x1), - 0x80917208:("D_80917208","f32","",0x4), - 0x8091720C:("D_8091720C","f32","",0x4), - 0x80917210:("D_80917210","UNK_TYPE1","",0x1), + 0x80917208:("sLurePos","Vec3f","",0xC), 0x80917218:("D_80917218","UNK_TYPE1","",0x1), - 0x80917228:("D_80917228","UNK_TYPE1","",0x1), - 0x8091722C:("D_8091722C","UNK_TYPE1","",0x1), - 0x80917238:("D_80917238","UNK_TYPE1","",0x1), - 0x8091723C:("D_8091723C","UNK_TYPE1","",0x1), - 0x80917248:("D_80917248","UNK_TYPE1","",0x1), + 0x80917228:("sLureRot","Vec3f","",0xC), + 0x80917238:("D_80917238","Vec3f","",0xC), + 0x80917248:("D_80917248","Vec3f","",0xC), 0x80917254:("D_80917254","f32","",0x4), 0x80917258:("D_80917258","UNK_TYPE1","",0x1), 0x8091725C:("D_8091725C","f32","",0x4), @@ -7976,8 +7956,7 @@ 0x80917270:("D_80917270","UNK_TYPE1","",0x1), 0x80917272:("D_80917272","UNK_TYPE1","",0x1), 0x80917274:("D_80917274","UNK_TYPE1","",0x1), - 0x80917278:("D_80917278","UNK_TYPE1","",0x1), - 0x8091727C:("D_8091727C","UNK_TYPE1","",0x1), + 0x80917278:("D_80917278","Vec3f","",0xC), 0x80918830:("Obj_Oshihiki_InitVars","UNK_TYPE1","",0x1), 0x80918850:("D_80918850","UNK_TYPE1","",0x1), 0x80918868:("D_80918868","UNK_TYPE1","",0x1), diff --git a/tools/filelists/mm.us.rev1/interface.csv b/tools/filelists/mm.us.rev1/interface.csv index db78965de0..726df54678 100644 --- a/tools/filelists/mm.us.rev1/interface.csv +++ b/tools/filelists/mm.us.rev1/interface.csv @@ -9,3 +9,5 @@ 26,message_static 27,message_texture_static 28,nes_font_static +1126,parameter_static +1127,week_static diff --git a/tools/filelists/mm.us.rev1/misc.csv b/tools/filelists/mm.us.rev1/misc.csv index caebc3bb1b..1d2c8bfa3a 100644 --- a/tools/filelists/mm.us.rev1/misc.csv +++ b/tools/filelists/mm.us.rev1/misc.csv @@ -12,8 +12,6 @@ 1123,title_static 1124,memerrmsg 1125,locerrmsg -1126,parameter_static -1127,week_static 1128,daytelop_static 1129,ger_daytelop_static 1130,fra_daytelop_static @@ -21,4 +19,3 @@ 1132,d2_fine_static 1133,d2_cloud_static 1134,d2_fine_pal_static -1538,bump_texture_static diff --git a/tools/filelists/mm.us.rev1/segments.csv b/tools/filelists/mm.us.rev1/segments.csv index b22534d94e..4362b8db6f 100644 --- a/tools/filelists/mm.us.rev1/segments.csv +++ b/tools/filelists/mm.us.rev1/segments.csv @@ -1,4 +1,5 @@ 652,gameplay_object_exchange_static +1538,bump_texture_static 1539,anime_model_1_static 1540,anime_model_2_static 1541,anime_model_3_static diff --git a/tools/ido_recomp/linux/5.3/as1 b/tools/ido_recomp/linux/5.3/as1 index 17ff2aa7c1..41c2545afb 100755 Binary files a/tools/ido_recomp/linux/5.3/as1 and b/tools/ido_recomp/linux/5.3/as1 differ diff --git a/tools/ido_recomp/linux/5.3/cc b/tools/ido_recomp/linux/5.3/cc index 6dbb85eb10..3dcc537985 100755 Binary files a/tools/ido_recomp/linux/5.3/cc and b/tools/ido_recomp/linux/5.3/cc differ diff --git a/tools/ido_recomp/linux/5.3/cfe b/tools/ido_recomp/linux/5.3/cfe index d742f7b2ed..e9594fafcb 100755 Binary files a/tools/ido_recomp/linux/5.3/cfe and b/tools/ido_recomp/linux/5.3/cfe differ diff --git a/tools/ido_recomp/linux/5.3/ugen b/tools/ido_recomp/linux/5.3/ugen index 692086f0ca..b2b662f1d3 100755 Binary files a/tools/ido_recomp/linux/5.3/ugen and b/tools/ido_recomp/linux/5.3/ugen differ diff --git a/tools/ido_recomp/linux/5.3/ujoin b/tools/ido_recomp/linux/5.3/ujoin new file mode 100644 index 0000000000..f9c90b8bec Binary files /dev/null and b/tools/ido_recomp/linux/5.3/ujoin differ diff --git a/tools/ido_recomp/linux/5.3/uld b/tools/ido_recomp/linux/5.3/uld new file mode 100644 index 0000000000..f227222bce Binary files /dev/null and b/tools/ido_recomp/linux/5.3/uld differ diff --git a/tools/ido_recomp/linux/5.3/umerge b/tools/ido_recomp/linux/5.3/umerge new file mode 100644 index 0000000000..00a8281d23 Binary files /dev/null and b/tools/ido_recomp/linux/5.3/umerge differ diff --git a/tools/ido_recomp/linux/5.3/uopt b/tools/ido_recomp/linux/5.3/uopt index 49558be9f8..5afe7a11c1 100755 Binary files a/tools/ido_recomp/linux/5.3/uopt and b/tools/ido_recomp/linux/5.3/uopt differ diff --git a/tools/ido_recomp/linux/5.3/usplit b/tools/ido_recomp/linux/5.3/usplit new file mode 100644 index 0000000000..a1c5ebad62 Binary files /dev/null and b/tools/ido_recomp/linux/5.3/usplit differ diff --git a/tools/ido_recomp/linux/7.1/as1 b/tools/ido_recomp/linux/7.1/as1 index a7bb3adc37..01dbc6f6b4 100755 Binary files a/tools/ido_recomp/linux/7.1/as1 and b/tools/ido_recomp/linux/7.1/as1 differ diff --git a/tools/ido_recomp/linux/7.1/cc b/tools/ido_recomp/linux/7.1/cc index e926b545e1..a7f06afa8a 100755 Binary files a/tools/ido_recomp/linux/7.1/cc and b/tools/ido_recomp/linux/7.1/cc differ diff --git a/tools/ido_recomp/linux/7.1/cfe b/tools/ido_recomp/linux/7.1/cfe index 3a3e983131..2c6767e69d 100755 Binary files a/tools/ido_recomp/linux/7.1/cfe and b/tools/ido_recomp/linux/7.1/cfe differ diff --git a/tools/ido_recomp/linux/7.1/ugen b/tools/ido_recomp/linux/7.1/ugen index e8e875635a..f5c1a2e20c 100755 Binary files a/tools/ido_recomp/linux/7.1/ugen and b/tools/ido_recomp/linux/7.1/ugen differ diff --git a/tools/ido_recomp/linux/7.1/umerge b/tools/ido_recomp/linux/7.1/umerge new file mode 100644 index 0000000000..b0c8c1778b Binary files /dev/null and b/tools/ido_recomp/linux/7.1/umerge differ diff --git a/tools/ido_recomp/linux/7.1/uopt b/tools/ido_recomp/linux/7.1/uopt index fd93d2dc5e..ecf7eab725 100755 Binary files a/tools/ido_recomp/linux/7.1/uopt and b/tools/ido_recomp/linux/7.1/uopt differ diff --git a/tools/ido_recomp/macos/5.3/acpp b/tools/ido_recomp/macos/5.3/acpp new file mode 100755 index 0000000000..0431627703 Binary files /dev/null and b/tools/ido_recomp/macos/5.3/acpp differ diff --git a/tools/ido_recomp/macos/5.3/as0 b/tools/ido_recomp/macos/5.3/as0 new file mode 100755 index 0000000000..9cff1dcd78 Binary files /dev/null and b/tools/ido_recomp/macos/5.3/as0 differ diff --git a/tools/ido_recomp/macos/5.3/as1 b/tools/ido_recomp/macos/5.3/as1 index 692fe600c2..df0142e869 100755 Binary files a/tools/ido_recomp/macos/5.3/as1 and b/tools/ido_recomp/macos/5.3/as1 differ diff --git a/tools/ido_recomp/macos/5.3/cc b/tools/ido_recomp/macos/5.3/cc index 90ffc74096..e9b599bdad 100755 Binary files a/tools/ido_recomp/macos/5.3/cc and b/tools/ido_recomp/macos/5.3/cc differ diff --git a/tools/ido_recomp/macos/5.3/cfe b/tools/ido_recomp/macos/5.3/cfe index 753be0d6c7..30e514947f 100755 Binary files a/tools/ido_recomp/macos/5.3/cfe and b/tools/ido_recomp/macos/5.3/cfe differ diff --git a/tools/ido_recomp/macos/5.3/copt b/tools/ido_recomp/macos/5.3/copt new file mode 100755 index 0000000000..243c37a291 Binary files /dev/null and b/tools/ido_recomp/macos/5.3/copt differ diff --git a/tools/ido_recomp/macos/5.3/err.english.cc b/tools/ido_recomp/macos/5.3/err.english.cc old mode 100755 new mode 100644 diff --git a/tools/ido_recomp/macos/5.3/ugen b/tools/ido_recomp/macos/5.3/ugen index c7020aa493..7f18bf44bb 100755 Binary files a/tools/ido_recomp/macos/5.3/ugen and b/tools/ido_recomp/macos/5.3/ugen differ diff --git a/tools/ido_recomp/macos/5.3/ujoin b/tools/ido_recomp/macos/5.3/ujoin new file mode 100755 index 0000000000..30503f95d0 Binary files /dev/null and b/tools/ido_recomp/macos/5.3/ujoin differ diff --git a/tools/ido_recomp/macos/5.3/uld b/tools/ido_recomp/macos/5.3/uld new file mode 100755 index 0000000000..13aa261f5a Binary files /dev/null and b/tools/ido_recomp/macos/5.3/uld differ diff --git a/tools/ido_recomp/macos/5.3/umerge b/tools/ido_recomp/macos/5.3/umerge new file mode 100755 index 0000000000..c31c866d53 Binary files /dev/null and b/tools/ido_recomp/macos/5.3/umerge differ diff --git a/tools/ido_recomp/macos/5.3/uopt b/tools/ido_recomp/macos/5.3/uopt index e23f6beda8..7bbaac2986 100755 Binary files a/tools/ido_recomp/macos/5.3/uopt and b/tools/ido_recomp/macos/5.3/uopt differ diff --git a/tools/ido_recomp/macos/5.3/usplit b/tools/ido_recomp/macos/5.3/usplit new file mode 100755 index 0000000000..a959848032 Binary files /dev/null and b/tools/ido_recomp/macos/5.3/usplit differ diff --git a/tools/ido_recomp/macos/7.1/as1 b/tools/ido_recomp/macos/7.1/as1 index 358712e331..88b9f1f7ec 100755 Binary files a/tools/ido_recomp/macos/7.1/as1 and b/tools/ido_recomp/macos/7.1/as1 differ diff --git a/tools/ido_recomp/macos/7.1/cc b/tools/ido_recomp/macos/7.1/cc index fb68103471..ae54cdbcde 100755 Binary files a/tools/ido_recomp/macos/7.1/cc and b/tools/ido_recomp/macos/7.1/cc differ diff --git a/tools/ido_recomp/macos/7.1/cfe b/tools/ido_recomp/macos/7.1/cfe index 1e13228628..6c468c3360 100755 Binary files a/tools/ido_recomp/macos/7.1/cfe and b/tools/ido_recomp/macos/7.1/cfe differ diff --git a/tools/ido_recomp/macos/7.1/err.english.cc b/tools/ido_recomp/macos/7.1/err.english.cc old mode 100755 new mode 100644 diff --git a/tools/ido_recomp/macos/7.1/ugen b/tools/ido_recomp/macos/7.1/ugen index fe90904a43..3fa7d48fc5 100755 Binary files a/tools/ido_recomp/macos/7.1/ugen and b/tools/ido_recomp/macos/7.1/ugen differ diff --git a/tools/ido_recomp/macos/7.1/umerge b/tools/ido_recomp/macos/7.1/umerge new file mode 100755 index 0000000000..3a9d5440cb Binary files /dev/null and b/tools/ido_recomp/macos/7.1/umerge differ diff --git a/tools/ido_recomp/macos/7.1/uopt b/tools/ido_recomp/macos/7.1/uopt index bb68f5d53a..b025fa2c5b 100755 Binary files a/tools/ido_recomp/macos/7.1/uopt and b/tools/ido_recomp/macos/7.1/uopt differ diff --git a/tools/m2ctx.py b/tools/m2ctx.py index 16087885b3..c2e50d59fd 100755 --- a/tools/m2ctx.py +++ b/tools/m2ctx.py @@ -41,7 +41,7 @@ def custom_replacements(output): actorList.append(actorListText.replace("first;", f"{actorCats[x]};") + "\n") if x == 2: actorList[x] = actorList[x].replace("Actor*", "Player*") - elif "ActorListEntry actorList[12];" in line: + elif "ActorListEntry actorLists[ACTORCAT_MAX];" in line: output[i] = "struct {\n" + "".join(actorList) + "};" ######################################################## diff --git a/tools/permuter_settings.toml b/tools/permuter_settings.toml index f5805056b5..eb2f1ac4b0 100644 --- a/tools/permuter_settings.toml +++ b/tools/permuter_settings.toml @@ -13,6 +13,7 @@ SQ = "int" CLAMP = "int" CLOCK_TIME = "int" CURRENT_DAY = "int" +NULL = "int" [decompme.compilers] "tools/ido_recomp/linux/7.1/cc" = "ido7.1" diff --git a/tools/rename_sym.sh b/tools/rename_sym.sh index e68966ca7a..227db4df72 100755 --- a/tools/rename_sym.sh +++ b/tools/rename_sym.sh @@ -10,4 +10,4 @@ fi #echo "Replace $1 with $2?" #read -grep -rl "$1" asm/**/*.s src/**/*.{c,h} include/**/*.h tools/disasm/functions.txt tools/disasm/variables.txt | xargs sed -i "s/\b$1\b/$2/g" \ No newline at end of file +grep -rl "$1" asm/**/*.s src/**/*.{c,h} include/**/*.h tools/disasm/functions.txt tools/disasm/variables.txt tools/sizes/*.csv | xargs sed -i "s/\b$1\b/$2/g" diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 02830ae3be..bfc0f86b8d 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -173,42 +173,42 @@ asm/non_matchings/code/z_DLF/Overlay_FreeGameState.s,Overlay_FreeGameState,0x800 asm/non_matchings/code/z_actor/Actor_PrintLists.s,Actor_PrintLists,0x800B3AD0,0x35 asm/non_matchings/code/z_actor/ActorShape_Init.s,ActorShape_Init,0x800B3BA4,0x9 asm/non_matchings/code/z_actor/ActorShadow_Draw.s,ActorShadow_Draw,0x800B3BC8,0xFE -asm/non_matchings/code/z_actor/func_800B3FC0.s,func_800B3FC0,0x800B3FC0,0x19 -asm/non_matchings/code/z_actor/func_800B4024.s,func_800B4024,0x800B4024,0x19 -asm/non_matchings/code/z_actor/func_800B4088.s,func_800B4088,0x800B4088,0xC -asm/non_matchings/code/z_actor/func_800B40B8.s,func_800B40B8,0x800B40B8,0xA -asm/non_matchings/code/z_actor/func_800B40E0.s,func_800B40E0,0x800B40E0,0x86 -asm/non_matchings/code/z_actor/func_800B42F8.s,func_800B42F8,0x800B42F8,0x1E8 -asm/non_matchings/code/z_actor/func_800B4A98.s,func_800B4A98,0x800B4A98,0x15 +asm/non_matchings/code/z_actor/ActorShadow_DrawCircle.s,ActorShadow_DrawCircle,0x800B3FC0,0x19 +asm/non_matchings/code/z_actor/ActorShadow_DrawSquare.s,ActorShadow_DrawSquare,0x800B4024,0x19 +asm/non_matchings/code/z_actor/ActorShadow_DrawWhiteCircle.s,ActorShadow_DrawWhiteCircle,0x800B4088,0xC +asm/non_matchings/code/z_actor/ActorShadow_DrawHorse.s,ActorShadow_DrawHorse,0x800B40B8,0xA +asm/non_matchings/code/z_actor/ActorShadow_DrawFoot.s,ActorShadow_DrawFoot,0x800B40E0,0x86 +asm/non_matchings/code/z_actor/ActorShadow_DrawFeet.s,ActorShadow_DrawFeet,0x800B42F8,0x1E8 +asm/non_matchings/code/z_actor/Actor_SetFeetPos.s,Actor_SetFeetPos,0x800B4A98,0x15 asm/non_matchings/code/z_actor/func_800B4AEC.s,func_800B4AEC,0x800B4AEC,0x19 asm/non_matchings/code/z_actor/func_800B4B50.s,func_800B4B50,0x800B4B50,0xE3 -asm/non_matchings/code/z_actor/func_800B4EDC.s,func_800B4EDC,0x800B4EDC,0x19 -asm/non_matchings/code/z_actor/func_800B4F40.s,func_800B4F40,0x800B4F40,0xE +asm/non_matchings/code/z_actor/Actor_GetProjectedPos.s,Actor_GetProjectedPos,0x800B4EDC,0x19 +asm/non_matchings/code/z_actor/Target_SetPos.s,Target_SetPos,0x800B4F40,0xE asm/non_matchings/code/z_actor/func_800B4F78.s,func_800B4F78,0x800B4F78,0x32 -asm/non_matchings/code/z_actor/func_800B5040.s,func_800B5040,0x800B5040,0x59 +asm/non_matchings/code/z_actor/Target_SetColors.s,Target_SetColors,0x800B5040,0x59 asm/non_matchings/code/z_actor/Actor_TargetContextInit.s,Actor_TargetContextInit,0x800B51A4,0x19 -asm/non_matchings/code/z_actor/func_800B5208.s,func_800B5208,0x800B5208,0x183 +asm/non_matchings/code/z_actor/Actor_DrawZTarget.s,Actor_DrawZTarget,0x800B5208,0x183 asm/non_matchings/code/z_actor/func_800B5814.s,func_800B5814,0x800B5814,0xE7 asm/non_matchings/code/z_actor/Flags_GetSwitch.s,Flags_GetSwitch,0x800B5BB0,0x11 -asm/non_matchings/code/z_actor/Actor_SetSwitchFlag.s,Actor_SetSwitchFlag,0x800B5BF4,0x10 -asm/non_matchings/code/z_actor/Actor_UnsetSwitchFlag.s,Actor_UnsetSwitchFlag,0x800B5C34,0x11 -asm/non_matchings/code/z_actor/Actor_GetChestFlag.s,Actor_GetChestFlag,0x800B5C78,0x6 -asm/non_matchings/code/z_actor/Actor_SetChestFlag.s,Actor_SetChestFlag,0x800B5C90,0x7 -asm/non_matchings/code/z_actor/Actor_SetAllChestFlag.s,Actor_SetAllChestFlag,0x800B5CAC,0x3 -asm/non_matchings/code/z_actor/Actor_GetAllChestFlag.s,Actor_GetAllChestFlag,0x800B5CB8,0x3 -asm/non_matchings/code/z_actor/Actor_GetRoomCleared.s,Actor_GetRoomCleared,0x800B5CC4,0x6 -asm/non_matchings/code/z_actor/Actor_SetRoomCleared.s,Actor_SetRoomCleared,0x800B5CDC,0x7 -asm/non_matchings/code/z_actor/Actor_UnsetRoomCleared.s,Actor_UnsetRoomCleared,0x800B5CF8,0x8 -asm/non_matchings/code/z_actor/Actor_GetRoomClearedTemp.s,Actor_GetRoomClearedTemp,0x800B5D18,0x6 -asm/non_matchings/code/z_actor/Actor_SetRoomClearedTemp.s,Actor_SetRoomClearedTemp,0x800B5D30,0x7 -asm/non_matchings/code/z_actor/Actor_UnsetRoomClearedTemp.s,Actor_UnsetRoomClearedTemp,0x800B5D4C,0x8 -asm/non_matchings/code/z_actor/Actor_GetCollectibleFlag.s,Actor_GetCollectibleFlag,0x800B5D6C,0x11 -asm/non_matchings/code/z_actor/Actor_SetCollectibleFlag.s,Actor_SetCollectibleFlag,0x800B5DB0,0x10 -asm/non_matchings/code/z_actor/Actor_TitleCardContextInit.s,Actor_TitleCardContextInit,0x800B5DF0,0x7 -asm/non_matchings/code/z_actor/Actor_TitleCardCreate.s,Actor_TitleCardCreate,0x800B5E0C,0x11 -asm/non_matchings/code/z_actor/Actor_Nop800B5E50.s,Actor_Nop800B5E50,0x800B5E50,0x6 -asm/non_matchings/code/z_actor/Actor_TitleCardUpdate.s,Actor_TitleCardUpdate,0x800B5E68,0x2F -asm/non_matchings/code/z_actor/Actor_TitleCardDraw.s,Actor_TitleCardDraw,0x800B5F24,0x144 +asm/non_matchings/code/z_actor/Flags_SetSwitch.s,Flags_SetSwitch,0x800B5BF4,0x10 +asm/non_matchings/code/z_actor/Flags_UnsetSwitch.s,Flags_UnsetSwitch,0x800B5C34,0x11 +asm/non_matchings/code/z_actor/Flags_GetTreasure.s,Flags_GetTreasure,0x800B5C78,0x6 +asm/non_matchings/code/z_actor/Flags_SetTreasure.s,Flags_SetTreasure,0x800B5C90,0x7 +asm/non_matchings/code/z_actor/Flags_SetAllTreasure.s,Flags_SetAllTreasure,0x800B5CAC,0x3 +asm/non_matchings/code/z_actor/Flags_GetAllTreasure.s,Flags_GetAllTreasure,0x800B5CB8,0x3 +asm/non_matchings/code/z_actor/Flags_GetClear.s,Flags_GetClear,0x800B5CC4,0x6 +asm/non_matchings/code/z_actor/Flags_SetClear.s,Flags_SetClear,0x800B5CDC,0x7 +asm/non_matchings/code/z_actor/Flags_UnsetClear.s,Flags_UnsetClear,0x800B5CF8,0x8 +asm/non_matchings/code/z_actor/Flags_GetClearTemp.s,Flags_GetClearTemp,0x800B5D18,0x6 +asm/non_matchings/code/z_actor/Flags_SetClearTemp.s,Flags_SetClearTemp,0x800B5D30,0x7 +asm/non_matchings/code/z_actor/Flags_UnsetClearTemp.s,Flags_UnsetClearTemp,0x800B5D4C,0x8 +asm/non_matchings/code/z_actor/Flags_GetCollectible.s,Flags_GetCollectible,0x800B5D6C,0x11 +asm/non_matchings/code/z_actor/Flags_SetCollectible.s,Flags_SetCollectible,0x800B5DB0,0x10 +asm/non_matchings/code/z_actor/TitleCard_ContextInit.s,TitleCard_ContextInit,0x800B5DF0,0x7 +asm/non_matchings/code/z_actor/TitleCard_InitBossName.s,TitleCard_InitBossName,0x800B5E0C,0x11 +asm/non_matchings/code/z_actor/TitleCard_InitPlaceName.s,TitleCard_InitPlaceName,0x800B5E50,0x6 +asm/non_matchings/code/z_actor/TitleCard_Update.s,TitleCard_Update,0x800B5E68,0x2F +asm/non_matchings/code/z_actor/TitleCard_Draw.s,TitleCard_Draw,0x800B5F24,0x144 asm/non_matchings/code/z_actor/func_800B6434.s,func_800B6434,0x800B6434,0xD asm/non_matchings/code/z_actor/func_800B6468.s,func_800B6468,0x800B6468,0x3 asm/non_matchings/code/z_actor/func_800B6474.s,func_800B6474,0x800B6474,0x6 @@ -218,24 +218,24 @@ asm/non_matchings/code/z_actor/func_800B6584.s,func_800B6584,0x800B6584,0x21 asm/non_matchings/code/z_actor/func_800B6608.s,func_800B6608,0x800B6608,0x1E asm/non_matchings/code/z_actor/func_800B6680.s,func_800B6680,0x800B6680,0x23 asm/non_matchings/code/z_actor/Actor_MarkForDeath.s,Actor_MarkForDeath,0x800B670C,0x8 -asm/non_matchings/code/z_actor/Actor_InitCurrPosition.s,Actor_InitCurrPosition,0x800B672C,0xC -asm/non_matchings/code/z_actor/Actor_SetHeight.s,Actor_SetHeight,0x800B675C,0x11 -asm/non_matchings/code/z_actor/Actor_SetRotationFromDrawRotation.s,Actor_SetRotationFromDrawRotation,0x800B67A0,0x8 -asm/non_matchings/code/z_actor/Actor_InitDrawRotation.s,Actor_InitDrawRotation,0x800B67C0,0x8 +asm/non_matchings/code/z_actor/Actor_SetWorldToHome.s,Actor_SetWorldToHome,0x800B672C,0xC +asm/non_matchings/code/z_actor/Actor_SetFocus.s,Actor_SetFocus,0x800B675C,0x11 +asm/non_matchings/code/z_actor/Actor_SetWorldRotToShape.s,Actor_SetWorldRotToShape,0x800B67A0,0x8 +asm/non_matchings/code/z_actor/Actor_SetShapeRotToWorld.s,Actor_SetShapeRotToWorld,0x800B67C0,0x8 asm/non_matchings/code/z_actor/Actor_SetScale.s,Actor_SetScale,0x800B67E0,0x7 -asm/non_matchings/code/z_actor/Actor_SetObjectSegment.s,Actor_SetObjectSegment,0x800B67FC,0xE -asm/non_matchings/code/z_actor/Actor_InitToDefaultValues.s,Actor_InitToDefaultValues,0x800B6834,0x45 -asm/non_matchings/code/z_actor/Actor_FiniActor.s,Actor_FiniActor,0x800B6948,0x10 +asm/non_matchings/code/z_actor/Actor_SetObjectDependency.s,Actor_SetObjectDependency,0x800B67FC,0xE +asm/non_matchings/code/z_actor/Actor_Init.s,Actor_Init,0x800B6834,0x45 +asm/non_matchings/code/z_actor/Actor_Destroy.s,Actor_Destroy,0x800B6948,0x10 asm/non_matchings/code/z_actor/Actor_SetMovementScale.s,Actor_SetMovementScale,0x800B6988,0x9 -asm/non_matchings/code/z_actor/Actor_ApplyMovement.s,Actor_ApplyMovement,0x800B69AC,0x19 -asm/non_matchings/code/z_actor/Actor_SetVelocityYRotationAndGravity.s,Actor_SetVelocityYRotationAndGravity,0x800B6A10,0x1E -asm/non_matchings/code/z_actor/Actor_SetVelocityAndMoveYRotationAndGravity.s,Actor_SetVelocityAndMoveYRotationAndGravity,0x800B6A88,0xB -asm/non_matchings/code/z_actor/Actor_SetVelocityXYRotation.s,Actor_SetVelocityXYRotation,0x800B6AB4,0x1C -asm/non_matchings/code/z_actor/Actor_SetVelocityAndMoveXYRotation.s,Actor_SetVelocityAndMoveXYRotation,0x800B6B24,0xB -asm/non_matchings/code/z_actor/Actor_SetVelocityXYRotationReverse.s,Actor_SetVelocityXYRotationReverse,0x800B6B50,0x22 -asm/non_matchings/code/z_actor/Actor_SetVelocityAndMoveXYRotationReverse.s,Actor_SetVelocityAndMoveXYRotationReverse,0x800B6BD8,0xB -asm/non_matchings/code/z_actor/func_800B6C04.s,func_800B6C04,0x800B6C04,0x15 -asm/non_matchings/code/z_actor/func_800B6C58.s,func_800B6C58,0x800B6C58,0x1F +asm/non_matchings/code/z_actor/Actor_UpdatePos.s,Actor_UpdatePos,0x800B69AC,0x19 +asm/non_matchings/code/z_actor/Actor_UpdateVelocityWithGravity.s,Actor_UpdateVelocityWithGravity,0x800B6A10,0x1E +asm/non_matchings/code/z_actor/Actor_MoveWithGravity.s,Actor_MoveWithGravity,0x800B6A88,0xB +asm/non_matchings/code/z_actor/Actor_UpdateVelocityWithoutGravity.s,Actor_UpdateVelocityWithoutGravity,0x800B6AB4,0x1C +asm/non_matchings/code/z_actor/Actor_MoveWithoutGravity.s,Actor_MoveWithoutGravity,0x800B6B24,0xB +asm/non_matchings/code/z_actor/Actor_UpdateVelocityWithoutGravityReverse.s,Actor_UpdateVelocityWithoutGravityReverse,0x800B6B50,0x22 +asm/non_matchings/code/z_actor/Actor_MoveWithoutGravityReverse.s,Actor_MoveWithoutGravityReverse,0x800B6BD8,0xB +asm/non_matchings/code/z_actor/Actor_SetSpeeds.s,Actor_SetSpeeds,0x800B6C04,0x15 +asm/non_matchings/code/z_actor/Actor_UpdatePosFromSkelAnime.s,Actor_UpdatePosFromSkelAnime,0x800B6C58,0x1F asm/non_matchings/code/z_actor/Actor_YawBetweenActors.s,Actor_YawBetweenActors,0x800B6CD4,0xB asm/non_matchings/code/z_actor/Actor_YawBetweenActorsTop.s,Actor_YawBetweenActorsTop,0x800B6D00,0xB asm/non_matchings/code/z_actor/Actor_YawToPoint.s,Actor_YawToPoint,0x800B6D2C,0x9 @@ -246,76 +246,76 @@ asm/non_matchings/code/z_actor/Actor_DistanceBetweenActors.s,Actor_DistanceBetwe asm/non_matchings/code/z_actor/Actor_DistanceToPoint.s,Actor_DistanceToPoint,0x800B6DF8,0x9 asm/non_matchings/code/z_actor/Actor_XZDistanceBetweenActors.s,Actor_XZDistanceBetweenActors,0x800B6E1C,0xB asm/non_matchings/code/z_actor/Actor_XZDistanceToPoint.s,Actor_XZDistanceToPoint,0x800B6E48,0x9 -asm/non_matchings/code/z_actor/Actor_CalcOffsetOrientedToDrawRotation.s,Actor_CalcOffsetOrientedToDrawRotation,0x800B6E6C,0x28 -asm/non_matchings/code/z_actor/Actor_YDistance.s,Actor_YDistance,0x800B6F0C,0x5 +asm/non_matchings/code/z_actor/Actor_OffsetOfPointInActorCoords.s,Actor_OffsetOfPointInActorCoords,0x800B6E6C,0x28 +asm/non_matchings/code/z_actor/Actor_HeightDiff.s,Actor_HeightDiff,0x800B6F0C,0x5 asm/non_matchings/code/z_actor/func_800B6F20.s,func_800B6F20,0x800B6F20,0x2A -asm/non_matchings/code/z_actor/func_800B6FC8.s,func_800B6FC8,0x800B6FC8,0x32 -asm/non_matchings/code/z_actor/func_800B7090.s,func_800B7090,0x800B7090,0x22 +asm/non_matchings/code/z_actor/Player_GetHeight.s,Player_GetHeight,0x800B6FC8,0x32 +asm/non_matchings/code/z_actor/Player_GetRunSpeedLimit.s,Player_GetRunSpeedLimit,0x800B7090,0x22 asm/non_matchings/code/z_actor/func_800B7118.s,func_800B7118,0x800B7118,0x4 asm/non_matchings/code/z_actor/func_800B7128.s,func_800B7128,0x800B7128,0xD asm/non_matchings/code/z_actor/func_800B715C.s,func_800B715C,0x800B715C,0x5 -asm/non_matchings/code/z_actor/func_800B7170.s,func_800B7170,0x800B7170,0x1B -asm/non_matchings/code/z_actor/func_800B71DC.s,func_800B71DC,0x800B71DC,0x9 +asm/non_matchings/code/z_actor/Actor_SetCameraHorseSetting.s,Actor_SetCameraHorseSetting,0x800B7170,0x1B +asm/non_matchings/code/z_actor/Actor_MountHorse.s,Actor_MountHorse,0x800B71DC,0x9 asm/non_matchings/code/z_actor/func_800B7200.s,func_800B7200,0x800B7200,0xB asm/non_matchings/code/z_actor/func_800B722C.s,func_800B722C,0x800B722C,0x8 asm/non_matchings/code/z_actor/func_800B724C.s,func_800B724C,0x800B724C,0x13 asm/non_matchings/code/z_actor/func_800B7298.s,func_800B7298,0x800B7298,0x12 asm/non_matchings/code/z_actor/func_800B72E0.s,func_800B72E0,0x800B72E0,0x6 asm/non_matchings/code/z_actor/func_800B72F8.s,func_800B72F8,0x800B72F8,0xA -asm/non_matchings/code/z_actor/Actor_IsLinkFacingActor.s,Actor_IsLinkFacingActor,0x800B7320,0x16 -asm/non_matchings/code/z_actor/Actor_IsActorFacedByActor.s,Actor_IsActorFacedByActor,0x800B7378,0x1A -asm/non_matchings/code/z_actor/Actor_IsActorFacingLink.s,Actor_IsActorFacingLink,0x800B73E0,0x13 -asm/non_matchings/code/z_actor/Actor_IsActorFacingActor.s,Actor_IsActorFacingActor,0x800B742C,0x18 -asm/non_matchings/code/z_actor/Actor_IsActorFacingLinkAndWithinRange.s,Actor_IsActorFacingLinkAndWithinRange,0x800B748C,0x20 -asm/non_matchings/code/z_actor/Actor_IsActorFacingActorAndWithinRange.s,Actor_IsActorFacingActorAndWithinRange,0x800B750C,0x25 +asm/non_matchings/code/z_actor/Player_IsFacingActor.s,Player_IsFacingActor,0x800B7320,0x16 +asm/non_matchings/code/z_actor/Actor_ActorBIsFacingActorA.s,Actor_ActorBIsFacingActorA,0x800B7378,0x1A +asm/non_matchings/code/z_actor/Actor_IsFacingPlayer.s,Actor_IsFacingPlayer,0x800B73E0,0x13 +asm/non_matchings/code/z_actor/Actor_ActorAIsFacingActorB.s,Actor_ActorAIsFacingActorB,0x800B742C,0x18 +asm/non_matchings/code/z_actor/Actor_IsFacingAndNearPlayer.s,Actor_IsFacingAndNearPlayer,0x800B748C,0x20 +asm/non_matchings/code/z_actor/Actor_ActorAIsFacingAndNearActorB.s,Actor_ActorAIsFacingAndNearActorB,0x800B750C,0x25 asm/non_matchings/code/z_actor/func_800B75A0.s,func_800B75A0,0x800B75A0,0x1F asm/non_matchings/code/z_actor/func_800B761C.s,func_800B761C,0x800B761C,0x17 asm/non_matchings/code/z_actor/func_800B7678.s,func_800B7678,0x800B7678,0x90 asm/non_matchings/code/z_actor/Actor_UpdateBgCheckInfo.s,Actor_UpdateBgCheckInfo,0x800B78B8,0x153 -asm/non_matchings/code/z_actor/func_800B7E04.s,func_800B7E04,0x800B7E04,0x77 -asm/non_matchings/code/z_actor/func_800B7FE0.s,func_800B7FE0,0x800B7FE0,0xE -asm/non_matchings/code/z_actor/func_800B8018.s,func_800B8018,0x800B8018,0xE +asm/non_matchings/code/z_actor/Hilite_Draw.s,Hilite_Draw,0x800B7E04,0x77 +asm/non_matchings/code/z_actor/Hilite_DrawOpa.s,Hilite_DrawOpa,0x800B7FE0,0xE +asm/non_matchings/code/z_actor/Hilite_DrawXlu.s,Hilite_DrawXlu,0x800B8018,0xE asm/non_matchings/code/z_actor/func_800B8050.s,func_800B8050,0x800B8050,0x32 asm/non_matchings/code/z_actor/func_800B8118.s,func_800B8118,0x800B8118,0x32 -asm/non_matchings/code/z_actor/func_800B81E0.s,func_800B81E0,0x800B81E0,0xD -asm/non_matchings/code/z_actor/func_800B8214.s,func_800B8214,0x800B8214,0xD -asm/non_matchings/code/z_actor/func_800B8248.s,func_800B8248,0x800B8248,0x29 +asm/non_matchings/code/z_actor/Actor_GetFocus.s,Actor_GetFocus,0x800B81E0,0xD +asm/non_matchings/code/z_actor/Actor_GetWorld.s,Actor_GetWorld,0x800B8214,0xD +asm/non_matchings/code/z_actor/Actor_GetWorldPosShapeRot.s,Actor_GetWorldPosShapeRot,0x800B8248,0x29 asm/non_matchings/code/z_actor/func_800B82EC.s,func_800B82EC,0x800B82EC,0x34 asm/non_matchings/code/z_actor/func_800B83BC.s,func_800B83BC,0x800B83BC,0xF asm/non_matchings/code/z_actor/func_800B83F8.s,func_800B83F8,0x800B83F8,0x36 -asm/non_matchings/code/z_actor/func_800B84D0.s,func_800B84D0,0x800B84D0,0xC +asm/non_matchings/code/z_actor/Actor_ProcessTalkRequest.s,Actor_ProcessTalkRequest,0x800B84D0,0xC asm/non_matchings/code/z_actor/func_800B8500.s,func_800B8500,0x800B8500,0x38 asm/non_matchings/code/z_actor/func_800B85E0.s,func_800B85E0,0x800B85E0,0xD asm/non_matchings/code/z_actor/func_800B8614.s,func_800B8614,0x800B8614,0xA asm/non_matchings/code/z_actor/func_800B863C.s,func_800B863C,0x800B863C,0x10 -asm/non_matchings/code/z_actor/func_800B867C.s,func_800B867C,0x800B867C,0x13 -asm/non_matchings/code/z_actor/func_800B86C8.s,func_800B86C8,0x800B86C8,0x10 -asm/non_matchings/code/z_actor/func_800B8708.s,func_800B8708,0x800B8708,0x4 +asm/non_matchings/code/z_actor/Actor_TextboxIsClosing.s,Actor_TextboxIsClosing,0x800B867C,0x13 +asm/non_matchings/code/z_actor/Actor_ChangeFocus.s,Actor_ChangeFocus,0x800B86C8,0x10 +asm/non_matchings/code/z_actor/Player_GetExchangeItemId.s,Player_GetExchangeItemId,0x800B8708,0x4 asm/non_matchings/code/z_actor/func_800B8718.s,func_800B8718,0x800B8718,0xD asm/non_matchings/code/z_actor/func_800B874C.s,func_800B874C,0x800B874C,0x2E asm/non_matchings/code/z_actor/func_800B8804.s,func_800B8804,0x800B8804,0xA asm/non_matchings/code/z_actor/func_800B882C.s,func_800B882C,0x800B882C,0x10 asm/non_matchings/code/z_actor/func_800B886C.s,func_800B886C,0x800B886C,0xB -asm/non_matchings/code/z_actor/func_800B8898.s,func_800B8898,0x800B8898,0x27 +asm/non_matchings/code/z_actor/Actor_GetScreenPos.s,Actor_GetScreenPos,0x800B8898,0x27 asm/non_matchings/code/z_actor/func_800B8934.s,func_800B8934,0x800B8934,0x31 asm/non_matchings/code/z_actor/Actor_HasParent.s,Actor_HasParent,0x800B89F8,0x9 -asm/non_matchings/code/z_actor/func_800B8A1C.s,func_800B8A1C,0x800B8A1C,0x5A -asm/non_matchings/code/z_actor/func_800B8B84.s,func_800B8B84,0x800B8B84,0xB -asm/non_matchings/code/z_actor/func_800B8BB0.s,func_800B8BB0,0x800B8BB0,0x8 -asm/non_matchings/code/z_actor/func_800B8BD0.s,func_800B8BD0,0x800B8BD0,0xB +asm/non_matchings/code/z_actor/Actor_PickUp.s,Actor_PickUp,0x800B8A1C,0x5A +asm/non_matchings/code/z_actor/Actor_PickUpNearby.s,Actor_PickUpNearby,0x800B8B84,0xB +asm/non_matchings/code/z_actor/Actor_LiftActor.s,Actor_LiftActor,0x800B8BB0,0x8 +asm/non_matchings/code/z_actor/Actor_PickUpFar.s,Actor_PickUpFar,0x800B8BD0,0xB asm/non_matchings/code/z_actor/Actor_HasNoParent.s,Actor_HasNoParent,0x800B8BFC,0x9 asm/non_matchings/code/z_actor/func_800B8C20.s,func_800B8C20,0x800B8C20,0xC asm/non_matchings/code/z_actor/func_800B8C50.s,func_800B8C50,0x800B8C50,0xA -asm/non_matchings/code/z_actor/func_800B8C78.s,func_800B8C78,0x800B8C78,0x9 -asm/non_matchings/code/z_actor/func_800B8C9C.s,func_800B8C9C,0x800B8C9C,0x14 -asm/non_matchings/code/z_actor/func_800B8CEC.s,func_800B8CEC,0x800B8CEC,0x9 +asm/non_matchings/code/z_actor/Actor_HasRider.s,Actor_HasRider,0x800B8C78,0x9 +asm/non_matchings/code/z_actor/Actor_SetRideActor.s,Actor_SetRideActor,0x800B8C9C,0x14 +asm/non_matchings/code/z_actor/Actor_HasNoRider.s,Actor_HasNoRider,0x800B8CEC,0x9 asm/non_matchings/code/z_actor/func_800B8D10.s,func_800B8D10,0x800B8D10,0x10 asm/non_matchings/code/z_actor/func_800B8D50.s,func_800B8D50,0x800B8D50,0x12 asm/non_matchings/code/z_actor/func_800B8D98.s,func_800B8D98,0x800B8D98,0xF asm/non_matchings/code/z_actor/func_800B8DD4.s,func_800B8DD4,0x800B8DD4,0x12 asm/non_matchings/code/z_actor/func_800B8E1C.s,func_800B8E1C,0x800B8E1C,0xF asm/non_matchings/code/z_actor/func_800B8E58.s,func_800B8E58,0x800B8E58,0x1C -asm/non_matchings/code/z_actor/Audio_PlayActorSound2.s,Audio_PlayActorSound2,0x800B8EC8,0xB +asm/non_matchings/code/z_actor/Actor_PlaySfxAtPos.s,Actor_PlaySfxAtPos,0x800B8EC8,0xB asm/non_matchings/code/z_actor/func_800B8EF4.s,func_800B8EF4,0x800B8EF4,0x29 asm/non_matchings/code/z_actor/func_800B8F98.s,func_800B8F98,0x800B8F98,0xA asm/non_matchings/code/z_actor/func_800B8FC0.s,func_800B8FC0,0x800B8FC0,0xA @@ -327,11 +327,11 @@ asm/non_matchings/code/z_actor/func_800B9098.s,func_800B9098,0x800B9098,0x5 asm/non_matchings/code/z_actor/func_800B90AC.s,func_800B90AC,0x800B90AC,0x12 asm/non_matchings/code/z_actor/func_800B90F4.s,func_800B90F4,0x800B90F4,0xB asm/non_matchings/code/z_actor/func_800B9120.s,func_800B9120,0x800B9120,0x14 -asm/non_matchings/code/z_actor/Actor_Init.s,Actor_Init,0x800B9170,0x71 -asm/non_matchings/code/z_actor/func_800B9334.s,func_800B9334,0x800B9334,0x56 +asm/non_matchings/code/z_actor/Actor_InitContext.s,Actor_InitContext,0x800B9170,0x71 +asm/non_matchings/code/z_actor/Actor_SpawnSetupActors.s,Actor_SpawnSetupActors,0x800B9334,0x56 asm/non_matchings/code/z_actor/Actor_UpdateActor.s,Actor_UpdateActor,0x800B948C,0xBD asm/non_matchings/code/z_actor/Actor_UpdateAll.s,Actor_UpdateAll,0x800B9780,0xA1 -asm/non_matchings/code/z_actor/Actor_DrawActor.s,Actor_DrawActor,0x800B9A04,0xC6 +asm/non_matchings/code/z_actor/Actor_Draw.s,Actor_Draw,0x800B9A04,0xC6 asm/non_matchings/code/z_actor/func_800B9D1C.s,func_800B9D1C,0x800B9D1C,0x48 asm/non_matchings/code/z_actor/Actor_DrawAllSetup.s,Actor_DrawAllSetup,0x800B9E3C,0x4 asm/non_matchings/code/z_actor/Actor_RecordUndrawnActor.s,Actor_RecordUndrawnActor,0x800B9E4C,0xE @@ -343,17 +343,17 @@ asm/non_matchings/code/z_actor/Actor_DrawAll.s,Actor_DrawAll,0x800BA42C,0xB4 asm/non_matchings/code/z_actor/func_800BA6FC.s,func_800BA6FC,0x800BA6FC,0x27 asm/non_matchings/code/z_actor/func_800BA798.s,func_800BA798,0x800BA798,0x48 asm/non_matchings/code/z_actor/func_800BA8B8.s,func_800BA8B8,0x800BA8B8,0x3F -asm/non_matchings/code/z_actor/func_800BA9B4.s,func_800BA9B4,0x800BA9B4,0x40 -asm/non_matchings/code/z_actor/Actor_InsertIntoTypeList.s,Actor_InsertIntoTypeList,0x800BAAB4,0x1C -asm/non_matchings/code/z_actor/Actor_RemoveFromTypeList.s,Actor_RemoveFromTypeList,0x800BAB24,0x36 +asm/non_matchings/code/z_actor/Actor_CleanupContext.s,Actor_CleanupContext,0x800BA9B4,0x40 +asm/non_matchings/code/z_actor/Actor_AddToCategory.s,Actor_AddToCategory,0x800BAAB4,0x1C +asm/non_matchings/code/z_actor/Actor_RemoveFromCategory.s,Actor_RemoveFromCategory,0x800BAB24,0x36 asm/non_matchings/code/z_actor/Actor_FreeOverlay.s,Actor_FreeOverlay,0x800BABFC,0x19 asm/non_matchings/code/z_actor/Actor_Spawn.s,Actor_Spawn,0x800BAC60,0x1D asm/non_matchings/code/z_actor/Actor_LoadOverlay.s,Actor_LoadOverlay,0x800BACD4,0x50 asm/non_matchings/code/z_actor/Actor_SpawnAsChildAndCutscene.s,Actor_SpawnAsChildAndCutscene,0x800BAE14,0xAB asm/non_matchings/code/z_actor/Actor_SpawnAsChild.s,Actor_SpawnAsChild,0x800BB0C0,0x20 asm/non_matchings/code/z_actor/Actor_SpawnTransitionActors.s,Actor_SpawnTransitionActors,0x800BB140,0x64 -asm/non_matchings/code/z_actor/func_800BB2D0.s,func_800BB2D0,0x800BB2D0,0x72 -asm/non_matchings/code/z_actor/func_800BB498.s,func_800BB498,0x800BB498,0x41 +asm/non_matchings/code/z_actor/Actor_SpawnEntry.s,Actor_SpawnEntry,0x800BB2D0,0x72 +asm/non_matchings/code/z_actor/Actor_Delete.s,Actor_Delete,0x800BB498,0x41 asm/non_matchings/code/z_actor/func_800BB59C.s,func_800BB59C,0x800BB59C,0x1A asm/non_matchings/code/z_actor/func_800BB604.s,func_800BB604,0x800BB604,0xBA asm/non_matchings/code/z_actor/func_800BB8EC.s,func_800BB8EC,0x800BB8EC,0x67 @@ -361,24 +361,24 @@ asm/non_matchings/code/z_actor/Enemy_StartFinishingBlow.s,Enemy_StartFinishingBl asm/non_matchings/code/z_actor/func_800BBAC0.s,func_800BBAC0,0x800BBAC0,0x2D asm/non_matchings/code/z_actor/func_800BBB74.s,func_800BBB74,0x800BBB74,0x2B asm/non_matchings/code/z_actor/func_800BBC20.s,func_800BBC20,0x800BBC20,0x33 -asm/non_matchings/code/z_actor/func_800BBCEC.s,func_800BBCEC,0x800BBCEC,0x30 -asm/non_matchings/code/z_actor/func_800BBDAC.s,func_800BBDAC,0x800BBDAC,0x81 +asm/non_matchings/code/z_actor/Actor_SpawnBodyParts.s,Actor_SpawnBodyParts,0x800BBCEC,0x30 +asm/non_matchings/code/z_actor/Actor_SpawnFloorDustRing.s,Actor_SpawnFloorDustRing,0x800BBDAC,0x81 asm/non_matchings/code/z_actor/func_800BBFB0.s,func_800BBFB0,0x800BBFB0,0x69 asm/non_matchings/code/z_actor/func_800BC154.s,func_800BC154,0x800BC154,0xD asm/non_matchings/code/z_actor/func_800BC188.s,func_800BC188,0x800BC188,0xB asm/non_matchings/code/z_actor/func_800BC1B4.s,func_800BC1B4,0x800BC1B4,0x2F asm/non_matchings/code/z_actor/func_800BC270.s,func_800BC270,0x800BC270,0x75 asm/non_matchings/code/z_actor/func_800BC444.s,func_800BC444,0x800BC444,0x2A -asm/non_matchings/code/z_actor/func_800BC4EC.s,func_800BC4EC,0x800BC4EC,0x33 -asm/non_matchings/code/z_actor/func_800BC5B8.s,func_800BC5B8,0x800BC5B8,0xD -asm/non_matchings/code/z_actor/func_800BC5EC.s,func_800BC5EC,0x800BC5EC,0xD +asm/non_matchings/code/z_actor/Actor_TestFloorInDirection.s,Actor_TestFloorInDirection,0x800BC4EC,0x33 +asm/non_matchings/code/z_actor/Actor_IsTargeted.s,Actor_IsTargeted,0x800BC5B8,0xD +asm/non_matchings/code/z_actor/Actor_OtherIsTargeted.s,Actor_OtherIsTargeted,0x800BC5EC,0xD asm/non_matchings/code/z_actor/func_800BC620.s,func_800BC620,0x800BC620,0x54 asm/non_matchings/code/z_actor/func_800BC770.s,func_800BC770,0x800BC770,0x1A asm/non_matchings/code/z_actor/func_800BC7D8.s,func_800BC7D8,0x800BC7D8,0x1C asm/non_matchings/code/z_actor/func_800BC848.s,func_800BC848,0x800BC848,0x1C -asm/non_matchings/code/z_actor/func_800BC8B8.s,func_800BC8B8,0x800BC8B8,0xA6 -asm/non_matchings/code/z_actor/func_800BCB50.s,func_800BCB50,0x800BCB50,0x8 -asm/non_matchings/code/z_actor/func_800BCB70.s,func_800BCB70,0x800BCB70,0x21 +asm/non_matchings/code/z_actor/Actor_DrawDoorLock.s,Actor_DrawDoorLock,0x800BC8B8,0xA6 +asm/non_matchings/code/z_actor/Actor_SpawnShieldParticlesMetal.s,Actor_SpawnShieldParticlesMetal,0x800BCB50,0x8 +asm/non_matchings/code/z_actor/Actor_SetColorFilter.s,Actor_SetColorFilter,0x800BCB70,0x21 asm/non_matchings/code/z_actor/func_800BCBF4.s,func_800BCBF4,0x800BCBF4,0x1D asm/non_matchings/code/z_actor/func_800BCC68.s,func_800BCC68,0x800BCC68,0x1D asm/non_matchings/code/z_actor/func_800BCCDC.s,func_800BCCDC,0x800BCCDC,0x176 @@ -391,16 +391,16 @@ asm/non_matchings/code/z_actor/func_800BD9A0.s,func_800BD9A0,0x800BD9A0,0x10 asm/non_matchings/code/z_actor/func_800BD9E0.s,func_800BD9E0,0x800BD9E0,0x30 asm/non_matchings/code/z_actor/func_800BDAA0.s,func_800BDAA0,0x800BDAA0,0x33 asm/non_matchings/code/z_actor/func_800BDB6C.s,func_800BDB6C,0x800BDB6C,0x3C -asm/non_matchings/code/z_actor/func_800BDC5C.s,func_800BDC5C,0x800BDC5C,0x26 +asm/non_matchings/code/z_actor/Actor_ChangeAnimation.s,Actor_ChangeAnimation,0x800BDC5C,0x26 asm/non_matchings/code/z_actor/func_800BDCF4.s,func_800BDCF4,0x800BDCF4,0xAF asm/non_matchings/code/z_actor/Actor_Noop.s,Actor_Noop,0x800BDFB0,0x4 -asm/non_matchings/code/z_actor/func_800BDFC0.s,func_800BDFC0,0x800BDFC0,0x1F -asm/non_matchings/code/z_actor/func_800BE03C.s,func_800BE03C,0x800BE03C,0x1F -asm/non_matchings/code/z_actor/func_800BE0B8.s,func_800BE0B8,0x800BE0B8,0x33 +asm/non_matchings/code/z_actor/Gfx_DrawDListOpa.s,Gfx_DrawDListOpa,0x800BDFC0,0x1F +asm/non_matchings/code/z_actor/Gfx_DrawDListXlu.s,Gfx_DrawDListXlu,0x800BE03C,0x1F +asm/non_matchings/code/z_actor/Actor_FindNearby.s,Actor_FindNearby,0x800BE0B8,0x33 asm/non_matchings/code/z_actor/func_800BE184.s,func_800BE184,0x800BE184,0x2A asm/non_matchings/code/z_actor/Actor_ApplyDamage.s,Actor_ApplyDamage,0x800BE22C,0xB -asm/non_matchings/code/z_actor/func_800BE258.s,func_800BE258,0x800BE258,0x18 -asm/non_matchings/code/z_actor/func_800BE2B8.s,func_800BE2B8,0x800BE2B8,0x21 +asm/non_matchings/code/z_actor/Actor_SetDropFlag.s,Actor_SetDropFlag,0x800BE258,0x18 +asm/non_matchings/code/z_actor/Actor_SetDropFlagJntSph.s,Actor_SetDropFlagJntSph,0x800BE2B8,0x21 asm/non_matchings/code/z_actor/func_800BE33C.s,func_800BE33C,0x800BE33C,0x25 asm/non_matchings/code/z_actor/func_800BE3D0.s,func_800BE3D0,0x800BE3D0,0x4D asm/non_matchings/code/z_actor/func_800BE504.s,func_800BE504,0x800BE504,0x19 @@ -408,7 +408,7 @@ asm/non_matchings/code/z_actor/func_800BE568.s,func_800BE568,0x800BE568,0x19 asm/non_matchings/code/z_actor/func_800BE5CC.s,func_800BE5CC,0x800BE5CC,0x1C asm/non_matchings/code/z_actor/func_800BE63C.s,func_800BE63C,0x800BE63C,0x11 asm/non_matchings/code/z_actor/func_800BE680.s,func_800BE680,0x800BE680,0x453 -asm/non_matchings/code/z_actor/func_800BF7CC.s,func_800BF7CC,0x800BF7CC,0x75 +asm/non_matchings/code/z_actor/Actor_SpawnIceEffects.s,Actor_SpawnIceEffects,0x800BF7CC,0x75 asm/non_matchings/code/z_actor_dlftbls/ActorOverlayTable_FaultPrint.s,ActorOverlayTable_FaultPrint,0x800BF9A0,0x36 asm/non_matchings/code/z_actor_dlftbls/ActorOverlayTable_FaultAddrConv.s,ActorOverlayTable_FaultAddrConv,0x800BFA78,0x1C asm/non_matchings/code/z_actor_dlftbls/ActorOverlayTable_Init.s,ActorOverlayTable_Init,0x800BFAE8,0x16 @@ -782,7 +782,7 @@ asm/non_matchings/code/z_camera/func_800DE954.s,func_800DE954,0x800DE954,0x17 asm/non_matchings/code/z_camera/Camera_Update.s,Camera_Update,0x800DE9B0,0x2BA asm/non_matchings/code/z_camera/func_800DF498.s,func_800DF498,0x800DF498,0xE asm/non_matchings/code/z_camera/Camera_SetMode.s,Camera_SetMode,0x800DF4D0,0xDC -asm/non_matchings/code/z_camera/func_800DF840.s,func_800DF840,0x800DF840,0xB +asm/non_matchings/code/z_camera/Camera_ChangeMode.s,Camera_ChangeMode,0x800DF840,0xB asm/non_matchings/code/z_camera/func_800DF86C.s,func_800DF86C,0x800DF86C,0x20 asm/non_matchings/code/z_camera/func_800DF8EC.s,func_800DF8EC,0x800DF8EC,0x77 asm/non_matchings/code/z_camera/func_800DFAC8.s,func_800DFAC8,0x800DFAC8,0x13 @@ -1705,7 +1705,7 @@ asm/non_matchings/code/z_player_lib/func_8012300C.s,func_8012300C,0x8012300C,0x4 asm/non_matchings/code/z_player_lib/func_8012301C.s,func_8012301C,0x8012301C,0x49 asm/non_matchings/code/z_player_lib/func_80123140.s,func_80123140,0x80123140,0x86 asm/non_matchings/code/z_player_lib/func_80123358.s,func_80123358,0x80123358,0x23 -asm/non_matchings/code/z_player_lib/func_801233E4.s,func_801233E4,0x801233E4,0xF +asm/non_matchings/code/z_player_lib/Player_InCsMode.s,Player_InCsMode,0x801233E4,0xF asm/non_matchings/code/z_player_lib/func_80123420.s,func_80123420,0x80123420,0x5 asm/non_matchings/code/z_player_lib/func_80123434.s,func_80123434,0x80123434,0x5 asm/non_matchings/code/z_player_lib/func_80123448.s,func_80123448,0x80123448,0x1A @@ -1743,7 +1743,7 @@ asm/non_matchings/code/z_player_lib/func_801241B4.s,func_801241B4,0x801241B4,0xB asm/non_matchings/code/z_player_lib/func_801241E0.s,func_801241E0,0x801241E0,0xB asm/non_matchings/code/z_player_lib/func_8012420C.s,func_8012420C,0x8012420C,0x8 asm/non_matchings/code/z_player_lib/func_8012422C.s,func_8012422C,0x8012422C,0xB -asm/non_matchings/code/z_player_lib/func_80124258.s,func_80124258,0x80124258,0x8 +asm/non_matchings/code/z_player_lib/Player_GetExplosiveHeld.s,Player_GetExplosiveHeld,0x80124258,0x8 asm/non_matchings/code/z_player_lib/func_80124278.s,func_80124278,0x80124278,0xF asm/non_matchings/code/z_player_lib/func_801242B4.s,func_801242B4,0x801242B4,0xA asm/non_matchings/code/z_player_lib/func_801242DC.s,func_801242DC,0x801242DC,0x51 @@ -2169,7 +2169,7 @@ asm/non_matchings/code/z_snap/func_8013A46C.s,func_8013A46C,0x8013A46C,0x16 asm/non_matchings/code/z_snap/func_8013A4C4.s,func_8013A4C4,0x8013A4C4,0x10 asm/non_matchings/code/z_snap/func_8013A504.s,func_8013A504,0x8013A504,0xB asm/non_matchings/code/z_snap/func_8013A530.s,func_8013A530,0x8013A530,0xA4 -asm/non_matchings/code/z_sub_s/func_8013A7C0.s,func_8013A7C0,0x8013A7C0,0x28 +asm/non_matchings/code/z_sub_s/SubS_FindDoor.s,SubS_FindDoor,0x8013A7C0,0x28 asm/non_matchings/code/z_sub_s/func_8013A860.s,func_8013A860,0x8013A860,0xA8 asm/non_matchings/code/z_sub_s/func_8013AB00.s,func_8013AB00,0x8013AB00,0x9B asm/non_matchings/code/z_sub_s/func_8013AD6C.s,func_8013AD6C,0x8013AD6C,0xC @@ -2182,7 +2182,7 @@ asm/non_matchings/code/z_sub_s/func_8013B350.s,func_8013B350,0x8013B350,0xD8 asm/non_matchings/code/z_sub_s/func_8013B6B0.s,func_8013B6B0,0x8013B6B0,0x72 asm/non_matchings/code/z_sub_s/func_8013B878.s,func_8013B878,0x8013B878,0xAF asm/non_matchings/code/z_sub_s/func_8013BB34.s,func_8013BB34,0x8013BB34,0x12 -asm/non_matchings/code/z_sub_s/func_8013BB7C.s,func_8013BB7C,0x8013BB7C,0x3C +asm/non_matchings/code/z_sub_s/SubS_FindNearestActor.s,SubS_FindNearestActor,0x8013BB7C,0x3C asm/non_matchings/code/z_sub_s/func_8013BC6C.s,func_8013BC6C,0x8013BC6C,0x35 asm/non_matchings/code/z_sub_s/func_8013BD40.s,func_8013BD40,0x8013BD40,0x67 asm/non_matchings/code/z_sub_s/func_8013BEDC.s,func_8013BEDC,0x8013BEDC,0x63 @@ -2203,7 +2203,7 @@ asm/non_matchings/code/z_sub_s/func_8013D768.s,func_8013D768,0x8013D768,0x35 asm/non_matchings/code/z_sub_s/func_8013D83C.s,func_8013D83C,0x8013D83C,0x28 asm/non_matchings/code/z_sub_s/func_8013D8DC.s,func_8013D8DC,0x8013D8DC,0x12 asm/non_matchings/code/z_sub_s/func_8013D924.s,func_8013D924,0x8013D924,0xF -asm/non_matchings/code/z_sub_s/func_ActorCategoryIterateById.s,func_ActorCategoryIterateById,0x8013D960,0x1A +asm/non_matchings/code/z_sub_s/SubS_FindActor.s,SubS_FindActor,0x8013D960,0x1A asm/non_matchings/code/z_sub_s/func_8013D9C8.s,func_8013D9C8,0x8013D9C8,0x72 asm/non_matchings/code/z_sub_s/func_8013DB90.s,func_8013DB90,0x8013DB90,0x2C asm/non_matchings/code/z_sub_s/func_8013DC40.s,func_8013DC40,0x8013DC40,0x23 @@ -2219,7 +2219,7 @@ asm/non_matchings/code/z_sub_s/func_8013E2D4.s,func_8013E2D4,0x8013E2D4,0x39 asm/non_matchings/code/z_sub_s/func_8013E3B8.s,func_8013E3B8,0x8013E3B8,0x3E asm/non_matchings/code/z_sub_s/func_8013E4B0.s,func_8013E4B0,0x8013E4B0,0x47 asm/non_matchings/code/z_sub_s/func_8013E5CC.s,func_8013E5CC,0x8013E5CC,0x1D -asm/non_matchings/code/z_sub_s/func_8013E640.s,func_8013E640,0x8013E640,0x42 +asm/non_matchings/code/z_sub_s/SubS_FindActorCustom.s,SubS_FindActorCustom,0x8013E640,0x42 asm/non_matchings/code/z_sub_s/func_8013E748.s,func_8013E748,0x8013E748,0x1E asm/non_matchings/code/z_sub_s/func_8013E7C0.s,func_8013E7C0,0x8013E7C0,0x4E asm/non_matchings/code/z_sub_s/func_8013E8F8.s,func_8013E8F8,0x8013E8F8,0x16 @@ -2374,7 +2374,7 @@ asm/non_matchings/code/z_message/func_80151C9C.s,func_80151C9C,0x80151C9C,0x42 asm/non_matchings/code/z_message/func_80151DA4.s,func_80151DA4,0x80151DA4,0x1A4 asm/non_matchings/code/z_message/func_80152434.s,func_80152434,0x80152434,0xC asm/non_matchings/code/z_message/func_80152464.s,func_80152464,0x80152464,0xD -asm/non_matchings/code/z_message/func_80152498.s,func_80152498,0x80152498,0x7D +asm/non_matchings/code/z_message/Message_GetState.s,Message_GetState,0x80152498,0x7D asm/non_matchings/code/z_message/func_8015268C.s,func_8015268C,0x8015268C,0x176 asm/non_matchings/code/z_message/func_80152C64.s,func_80152C64,0x80152C64,0x12 asm/non_matchings/code/z_message/func_80152CAC.s,func_80152CAC,0x80152CAC,0x85 @@ -2838,7 +2838,7 @@ asm/non_matchings/code/sys_math3d/func_8017D2FC.s,func_8017D2FC,0x8017D2FC,0x42 asm/non_matchings/code/sys_math3d/func_8017D404.s,func_8017D404,0x8017D404,0x59 asm/non_matchings/code/sys_math3d/Math3D_TriSetCoords.s,Math3D_TriSetCoords,0x8017D568,0x2C asm/non_matchings/code/sys_math3d/Math3D_IsPointInSphere.s,Math3D_IsPointInSphere,0x8017D618,0x14 -asm/non_matchings/code/sys_math3d/func_8017D668.s,func_8017D668,0x8017D668,0x56 +asm/non_matchings/code/sys_math3d/Math3D_PointDistToLine2D.s,Math3D_PointDistToLine2D,0x8017D668,0x56 asm/non_matchings/code/sys_math3d/func_8017D7C0.s,func_8017D7C0,0x8017D7C0,0x15 asm/non_matchings/code/sys_math3d/func_8017D814.s,func_8017D814,0x8017D814,0x42 asm/non_matchings/code/sys_math3d/func_8017D91C.s,func_8017D91C,0x8017D91C,0x42 @@ -3551,7 +3551,7 @@ asm/non_matchings/code/code_801A51F0/func_801A5A1C.s,func_801A5A1C,0x801A5A1C,0x asm/non_matchings/code/code_801A5BD0/func_801A5BD0.s,func_801A5BD0,0x801A5BD0,0x16 asm/non_matchings/code/code_801A5BD0/func_801A5C28.s,func_801A5C28,0x801A5C28,0x19 asm/non_matchings/code/code_801A5BD0/func_801A5C8C.s,func_801A5C8C,0x801A5C8C,0x1C -asm/non_matchings/code/code_801A5BD0/func_801A5CFC.s,func_801A5CFC,0x801A5CFC,0x38 +asm/non_matchings/code/code_801A5BD0/Audio_PlaySfxGeneral.s,Audio_PlaySfxGeneral,0x801A5CFC,0x38 asm/non_matchings/code/code_801A5BD0/func_801A5DDC.s,func_801A5DDC,0x801A5DDC,0x68 asm/non_matchings/code/code_801A5BD0/func_801A5F7C.s,func_801A5F7C,0x801A5F7C,0x12D asm/non_matchings/code/code_801A5BD0/func_801A6430.s,func_801A6430,0x801A6430,0x66 diff --git a/undefined_syms.txt b/undefined_syms.txt index b20f97bd79..9cca916c00 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -403,7 +403,6 @@ D_0401A590 = 0x0401A590; D_0401A620 = 0x0401A620; D_0401ACF0 = 0x0401ACF0; D_0401ED00 = 0x0401ED00; -D_0401F0F0 = 0x0401F0F0; D_0401F740 = 0x0401F740; D_0401F7C0 = 0x0401F7C0; D_0401F8C0 = 0x0401F8C0; @@ -521,14 +520,11 @@ D_04073F00 = 0x04073F00; D_04074330 = 0x04074330; D_04075400 = 0x04075400; D_04075A40 = 0x04075A40; -D_04075B30 = 0x04075B30; D_04076BC0 = 0x04076BC0; -D_04077480 = 0x04077480; D_04079B10 = 0x04079B10; D_0407AB10 = 0x0407AB10; D_0407AB58 = 0x0407AB58; D_0407AB70 = 0x0407AB70; -D_0407AE00 = 0x0407AE00; D_0407AFB0 = 0x0407AFB0; D_0407D590 = 0x0407D590; D_0407D650 = 0x0407D650; @@ -549,6 +545,10 @@ D_0408F3E0 = 0x0408F3E0; D_0408F7E0 = 0x0408F7E0; D_04091BE0 = 0x04091BE0; D_04091CE0 = 0x04091CE0; +D_04091DE0 = 0x04091DE0; +D_04091FE0 = 0x04091FE0; +D_040921E0 = 0x040921E0; +D_040923E0 = 0x040923E0; // segment 0x05 @@ -1087,13 +1087,6 @@ D_06009C14 = 0x06009C14; D_06009CF8 = 0x06009CF8; D_0600A6C8 = 0x0600A6C8; -// ovl_Boss_04 - -D_0600004C = 0x0600004C; -D_06004510 = 0x06004510; -D_06004550 = 0x06004550; -D_060045E8 = 0x060045E8; - // ovl_Boss_05 D_060006A4 = 0x060006A4; @@ -1488,6 +1481,7 @@ D_06013EA8 = 0x06013EA8; // ovl_Door_Warp1 +D_06003230 = 0x06003230; D_060044D8 = 0x060044D8; D_06004690 = 0x06004690; D_060057D8 = 0x060057D8; @@ -1696,7 +1690,7 @@ D_06000340 = 0x06000340; D_06000408 = 0x06000408; D_06000530 = 0x06000530; -// ovl_En_Bomjima +// ovl_En_Bomjimb D_060064B8 = 0x060064B8; D_0600F82C = 0x0600F82C; @@ -2211,48 +2205,8 @@ D_06006190 = 0x06006190; // ovl_En_Fishing -D_0600007C = 0x0600007C; -D_060029C0 = 0x060029C0; -D_06003230 = 0x06003230; -D_06003460 = 0x06003460; -D_060034C0 = 0x060034C0; -D_06003610 = 0x06003610; -D_06003680 = 0x06003680; -D_06003710 = 0x06003710; -D_06003760 = 0x06003760; -D_060039A8 = 0x060039A8; -D_06003A18 = 0x06003A18; -D_0600453C = 0x0600453C; -D_06007350 = 0x06007350; -D_060074C8 = 0x060074C8; -D_060085F8 = 0x060085F8; -D_06008610 = 0x06008610; -D_06008678 = 0x06008678; -D_060088C0 = 0x060088C0; -D_06008970 = 0x06008970; -D_0600B950 = 0x0600B950; -D_0600B9C0 = 0x0600B9C0; -D_0600C220 = 0x0600C220; -D_0600C298 = 0x0600C298; D_0600CFE0 = 0x0600CFE0; D_06011058 = 0x06011058; -D_06011070 = 0x06011070; -D_06011170 = 0x06011170; -D_06011270 = 0x06011270; -D_060113D0 = 0x060113D0; -D_06011410 = 0x06011410; -D_06012160 = 0x06012160; -D_060121F0 = 0x060121F0; -D_06013330 = 0x06013330; -D_060133B0 = 0x060133B0; -D_06013590 = 0x06013590; -D_06013610 = 0x06013610; -D_06013F50 = 0x06013F50; -D_06013FD0 = 0x06013FD0; -D_06014030 = 0x06014030; -D_060140B0 = 0x060140B0; -D_060153D0 = 0x060153D0; -D_06015470 = 0x06015470; // ovl_En_Floormas @@ -2317,11 +2271,6 @@ D_060015C0 = 0x060015C0; D_060023D4 = 0x060023D4; D_06002720 = 0x06002720; -// ovl_En_Gb2 - -D_0600049C = 0x0600049C; -D_06007230 = 0x06007230; - // ovl_En_Ge1 D_06002B98 = 0x06002B98; @@ -2352,30 +2301,6 @@ D_0600F6C0 = 0x0600F6C0; D_0600F578 = 0x0600F578; D_0600F6C0 = 0x0600F6C0; -// ovl_En_Giant - -D_06002168 = 0x06002168; -D_06005A80 = 0x06005A80; -D_06006280 = 0x06006280; -D_06006A80 = 0x06006A80; -D_06007610 = 0x06007610; -D_060079B0 = 0x060079B0; -D_06008394 = 0x06008394; -D_060096E4 = 0x060096E4; -D_0600A1C4 = 0x0600A1C4; -D_0600ACA4 = 0x0600ACA4; -D_0600B784 = 0x0600B784; -D_0600C5D4 = 0x0600C5D4; -D_0600D040 = 0x0600D040; -D_0600DE84 = 0x0600DE84; -D_060102A4 = 0x060102A4; -D_060116E4 = 0x060116E4; -D_06012A38 = 0x06012A38; -D_06013004 = 0x06013004; -D_06013FE8 = 0x06013FE8; -D_06015334 = 0x06015334; -D_06017944 = 0x06017944; - // ovl_En_Ginko_Man D_060008C0 = 0x060008C0; @@ -2414,22 +2339,6 @@ D_0600B990 = 0x0600B990; D_0600BA80 = 0x0600BA80; D_0600C03C = 0x0600C03C; -// ovl_En_Go - -D_060003D0 = 0x060003D0; -D_06000458 = 0x06000458; -D_060008C0 = 0x060008C0; -D_06000948 = 0x06000948; -D_06000D50 = 0x06000D50; -D_06000DD8 = 0x06000DD8; -D_06001560 = 0x06001560; -D_060031A0 = 0x060031A0; -D_06003258 = 0x06003258; -D_060091A8 = 0x060091A8; -D_06011AC8 = 0x06011AC8; -D_06014CF0 = 0x06014CF0; -D_06014D00 = 0x06014D00; - // ovl_En_Goroiwa D_060032E0 = 0x060032E0; @@ -2691,10 +2600,6 @@ D_06012FC8 = 0x06012FC8; D_06013928 = 0x06013928; D_06016588 = 0x06016588; -// ovl_En_Ishi - -D_060009B0 = 0x060009B0; - // ovl_En_Ja D_0600BA30 = 0x0600BA30; @@ -2754,23 +2659,6 @@ D_0600686C = 0x0600686C; D_060081A4 = 0x060081A4; D_06000214 = 0x06000214; -// ovl_En_Kame - -D_060008B4 = 0x060008B4; -D_06000AF4 = 0x06000AF4; -D_06000B30 = 0x06000B30; -D_06001A50 = 0x06001A50; -D_06001C68 = 0x06001C68; -D_06002510 = 0x06002510; -D_060027D8 = 0x060027D8; -D_06002F88 = 0x06002F88; -D_060031DC = 0x060031DC; -D_060035EC = 0x060035EC; -D_060039C0 = 0x060039C0; -D_06004210 = 0x06004210; -D_06007C70 = 0x06007C70; -D_0600823C = 0x0600823C; - // ovl_En_Kanban D_06000C30 = 0x06000C30; @@ -3179,14 +3067,6 @@ D_060073E8 = 0x060073E8; D_0600D5A0 = 0x0600D5A0; -// ovl_En_Peehat - -D_06000350 = 0x06000350; -D_060005C4 = 0x060005C4; -D_06000844 = 0x06000844; -D_060009C4 = 0x060009C4; -D_06001C80 = 0x06001C80; - // ovl_En_Pm D_06008348 = 0x06008348; @@ -3379,11 +3259,6 @@ D_06009220 = 0x06009220; D_0600C700 = 0x0600C700; -// ovl_En_Ruppecrow - -D_060000F0 = 0x060000F0; -D_060010C0 = 0x060010C0; - // ovl_En_Rz D_06003A20 = 0x06003A20; @@ -3497,17 +3372,7 @@ D_06011038 = 0x06011038; // ovl_En_Ssh -D_060000D8 = 0x060000D8; D_06000304 = 0x06000304; -D_06001494 = 0x06001494; -D_06005210 = 0x06005210; -D_06005850 = 0x06005850; -D_06005F78 = 0x06005F78; -D_06006470 = 0x06006470; - -// ovl_En_St - -D_06005298 = 0x06005298; // ovl_En_Sth @@ -3530,10 +3395,6 @@ D_0600D640 = 0x0600D640; D_06006C18 = 0x06006C18; D_0600D640 = 0x0600D640; -// ovl_En_Stream - -D_06000950 = 0x06000950; - // ovl_En_Suttari D_0600071C = 0x0600071C; @@ -3792,22 +3653,6 @@ D_0600A054 = 0x0600A054; D_06000EC0 = 0x06000EC0; -// ovl_En_Water_Effect - -D_06000420 = 0x06000420; -D_06000730 = 0x06000730; -D_06000A48 = 0x06000A48; -D_06000CD8 = 0x06000CD8; -D_06000DE0 = 0x06000DE0; -D_06000E0C = 0x06000E0C; -D_06000E40 = 0x06000E40; -D_06000E58 = 0x06000E58; -D_06004260 = 0x06004260; -D_060042B0 = 0x060042B0; -D_060042F8 = 0x060042F8; -D_06004340 = 0x06004340; -D_060043E8 = 0x060043E8; - // ovl_En_Wdhand D_060000F4 = 0x060000F4; @@ -3852,18 +3697,6 @@ D_06001690 = 0x06001690; D_06005870 = 0x06005870; D_06005C64 = 0x06005C64; -// ovl_En_Wiz_Fire - -D_06000E70 = 0x06000E70; -D_06000FD8 = 0x06000FD8; -D_06002630 = 0x06002630; -D_06002B40 = 0x06002B40; -D_06003120 = 0x06003120; -D_06003640 = 0x06003640; -D_06003FC0 = 0x06003FC0; -D_06005190 = 0x06005190; -D_06005750 = 0x06005750; - // ovl_En_Wood02 D_06000700 = 0x06000700; @@ -4063,13 +3896,6 @@ D_06003440 = 0x06003440; D_06000158 = 0x06000158; D_06001C00 = 0x06001C00; -// ovl_Obj_Flowerpot - -D_060012E0 = 0x060012E0; -D_06001408 = 0x06001408; -D_060014F0 = 0x060014F0; -D_060015B0 = 0x060015B0; - // ovl_Obj_Funen D_060000D0 = 0x060000D0; @@ -4112,14 +3938,6 @@ D_06001D10 = 0x06001D10; D_060003B8 = 0x060003B8; D_060011B0 = 0x060011B0; -// ovl_Obj_Hugebombiwa - -D_060009E0 = 0x060009E0; -D_06001820 = 0x06001820; -D_06001990 = 0x06001990; -D_06002F60 = 0x06002F60; -D_06003110 = 0x06003110; - // ovl_Obj_Hunsui D_06000220 = 0x06000220; @@ -4146,17 +3964,6 @@ D_06000180 = 0x06000180; D_06003478 = 0x06003478; D_0600805C = 0x0600805C; -// ovl_Obj_Kibako - -D_06001180 = 0x06001180; -D_06001A70 = 0x06001A70; - -// ovl_Obj_Kibako2 - -D_06000960 = 0x06000960; -D_06000B70 = 0x06000B70; -D_06001040 = 0x06001040; - // ovl_Obj_Kzsaku D_06000040 = 0x06000040; @@ -4228,11 +4035,6 @@ D_060011E0 = 0x060011E0; D_06001C00 = 0x06001C00; -// ovl_Obj_Snowball - -D_060082D0 = 0x060082D0; -D_06008B90 = 0x06008B90; - // ovl_Obj_Snowball2 D_06008B90 = 0x06008B90;