diff --git a/.gitignore b/.gitignore index aa3f65077..ee2d1e325 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ tags # Project-specific ignores *.z64 +*.n64 +*.v64 *.sra *.bin *.elf diff --git a/Makefile b/Makefile index 75ad3a54c..892d0355b 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ OBJCOPY := $(MIPS_BINUTILS_PREFIX)objcopy OBJDUMP := $(MIPS_BINUTILS_PREFIX)objdump ASM_PROC := python3 tools/asm-processor/build.py -ASM_PROC_FLAGS := --input-enc=utf-8 --output-enc=euc-jp +ASM_PROC_FLAGS := --input-enc=utf-8 --output-enc=euc-jp --convert-statics=global-with-filename IINC := -Iinclude -Isrc -Iassets -Ibuild -I. @@ -210,7 +210,7 @@ build/src/libultra/rmon/%.o: OPTFLAGS := -O2 build/src/libultra/flash/%.o: OPTFLAGS := -g build/src/libultra/flash/%.o: MIPS_VERSION := -mips1 -build/src/code/audio/%.o: OPTFLAGS := -O2 +build/src/audio/%.o: OPTFLAGS := -O2 build/assets/%.o: OPTFLAGS := -O1 build/assets/%.o: ASM_PROC_FLAGS := @@ -238,7 +238,7 @@ build/src/libultra/%.o: CC := $(CC_OLD) build/src/libultra/voice/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC_OLD) -- $(AS) $(ASFLAGS) -- build/src/code/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- -build/src/code/audio/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- +build/src/audio/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- build/src/overlays/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- diff --git a/assets/xml/code/debug_display.xml b/assets/xml/code/debug_display.xml index c8ac659bc..7a25bbd0c 100644 --- a/assets/xml/code/debug_display.xml +++ b/assets/xml/code/debug_display.xml @@ -4,7 +4,7 @@ - + diff --git a/assets/xml/code/eff_footmark.xml b/assets/xml/code/eff_footmark.xml new file mode 100644 index 000000000..2fae1fe16 --- /dev/null +++ b/assets/xml/code/eff_footmark.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 16cbf0b85..8a78a1709 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -787,7 +787,7 @@ - + @@ -1145,8 +1145,8 @@ - - + + @@ -1223,7 +1223,9 @@ + + @@ -1477,7 +1479,7 @@ - + @@ -1487,7 +1489,7 @@ - + diff --git a/assets/xml/objects/object_ahg.xml b/assets/xml/objects/object_ahg.xml index 7eb4c7126..8233a5b27 100644 --- a/assets/xml/objects/object_ahg.xml +++ b/assets/xml/objects/object_ahg.xml @@ -1,53 +1,62 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_am.xml b/assets/xml/objects/object_am.xml index 259700dc8..bec26eb3a 100644 --- a/assets/xml/objects/object_am.xml +++ b/assets/xml/objects/object_am.xml @@ -1,6 +1,6 @@  - + @@ -36,6 +36,6 @@ - + diff --git a/assets/xml/objects/object_and.xml b/assets/xml/objects/object_and.xml index a076a1c07..69ffebc7b 100644 --- a/assets/xml/objects/object_and.xml +++ b/assets/xml/objects/object_and.xml @@ -1,79 +1,80 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_astr_obj.xml b/assets/xml/objects/object_astr_obj.xml index 75a8e7ca2..233de785b 100644 --- a/assets/xml/objects/object_astr_obj.xml +++ b/assets/xml/objects/object_astr_obj.xml @@ -8,6 +8,6 @@ - + diff --git a/assets/xml/objects/object_boss03.xml b/assets/xml/objects/object_boss03.xml index da17bf406..f4def4991 100644 --- a/assets/xml/objects/object_boss03.xml +++ b/assets/xml/objects/object_boss03.xml @@ -46,7 +46,7 @@ - + diff --git a/assets/xml/objects/object_boss07.xml b/assets/xml/objects/object_boss07.xml index b1f6cb417..ac2f9afc1 100644 --- a/assets/xml/objects/object_boss07.xml +++ b/assets/xml/objects/object_boss07.xml @@ -200,9 +200,9 @@ - - - + + + diff --git a/assets/xml/objects/object_boss_hakugin.xml b/assets/xml/objects/object_boss_hakugin.xml index ba04a3071..7c7232ecf 100644 --- a/assets/xml/objects/object_boss_hakugin.xml +++ b/assets/xml/objects/object_boss_hakugin.xml @@ -101,6 +101,6 @@ - + diff --git a/assets/xml/objects/object_botihasira.xml b/assets/xml/objects/object_botihasira.xml index f949abcc7..0a2212760 100644 --- a/assets/xml/objects/object_botihasira.xml +++ b/assets/xml/objects/object_botihasira.xml @@ -6,6 +6,6 @@ - + diff --git a/assets/xml/objects/object_box.xml b/assets/xml/objects/object_box.xml index be4f34b87..c0603a6cf 100644 --- a/assets/xml/objects/object_box.xml +++ b/assets/xml/objects/object_box.xml @@ -48,6 +48,6 @@ - + diff --git a/assets/xml/objects/object_crace_object.xml b/assets/xml/objects/object_crace_object.xml index af0cb89e0..63dd9913d 100644 --- a/assets/xml/objects/object_crace_object.xml +++ b/assets/xml/objects/object_crace_object.xml @@ -4,6 +4,6 @@ - + diff --git a/assets/xml/objects/object_ctower_rot.xml b/assets/xml/objects/object_ctower_rot.xml index ad2336257..044443c98 100644 --- a/assets/xml/objects/object_ctower_rot.xml +++ b/assets/xml/objects/object_ctower_rot.xml @@ -73,12 +73,12 @@ - + - + @@ -86,15 +86,15 @@ - + - + - + diff --git a/assets/xml/objects/object_d_hsblock.xml b/assets/xml/objects/object_d_hsblock.xml index b43647dc3..ee61d0a54 100644 --- a/assets/xml/objects/object_d_hsblock.xml +++ b/assets/xml/objects/object_d_hsblock.xml @@ -1,10 +1,10 @@  - - - - + + + + diff --git a/assets/xml/objects/object_d_lift.xml b/assets/xml/objects/object_d_lift.xml index 475f7fd3e..868eccd85 100644 --- a/assets/xml/objects/object_d_lift.xml +++ b/assets/xml/objects/object_d_lift.xml @@ -3,8 +3,8 @@ - - + + diff --git a/assets/xml/objects/object_dai.xml b/assets/xml/objects/object_dai.xml index b547897f8..927e3f1e1 100644 --- a/assets/xml/objects/object_dai.xml +++ b/assets/xml/objects/object_dai.xml @@ -2,21 +2,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_daiku.xml b/assets/xml/objects/object_daiku.xml index 17d8ddbf0..0152a6e7d 100644 --- a/assets/xml/objects/object_daiku.xml +++ b/assets/xml/objects/object_daiku.xml @@ -1,11 +1,11 @@  - - - - - - + + + + + + @@ -39,10 +39,10 @@ - + - + @@ -66,11 +66,11 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_danpei_object.xml b/assets/xml/objects/object_danpei_object.xml index 3f373a8ce..8e86f2f79 100644 --- a/assets/xml/objects/object_danpei_object.xml +++ b/assets/xml/objects/object_danpei_object.xml @@ -3,9 +3,9 @@ - - - + + + diff --git a/assets/xml/objects/object_dblue_object.xml b/assets/xml/objects/object_dblue_object.xml index 8611c539b..08cb20ec3 100644 --- a/assets/xml/objects/object_dblue_object.xml +++ b/assets/xml/objects/object_dblue_object.xml @@ -4,17 +4,17 @@ - + - + - + @@ -25,22 +25,22 @@ - + - - + + - + @@ -50,17 +50,17 @@ - + - + - + diff --git a/assets/xml/objects/object_death.xml b/assets/xml/objects/object_death.xml index 77d4ccd4a..7588c484a 100644 --- a/assets/xml/objects/object_death.xml +++ b/assets/xml/objects/object_death.xml @@ -1,17 +1,17 @@  - - - - - - - + + + + + + + - - + + @@ -41,7 +41,7 @@ - + @@ -76,9 +76,9 @@ - - - + + + diff --git a/assets/xml/objects/object_dekubaba.xml b/assets/xml/objects/object_dekubaba.xml index eb80e770b..053b82f61 100644 --- a/assets/xml/objects/object_dekubaba.xml +++ b/assets/xml/objects/object_dekubaba.xml @@ -1,27 +1,40 @@  + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dekucity_obj.xml b/assets/xml/objects/object_dekucity_obj.xml index 1d680965e..2d1da14a0 100644 --- a/assets/xml/objects/object_dekucity_obj.xml +++ b/assets/xml/objects/object_dekucity_obj.xml @@ -1,22 +1,22 @@  - - + + - + - + - + diff --git a/assets/xml/objects/object_delf.xml b/assets/xml/objects/object_delf.xml index 39996c0f0..85f3138e1 100644 --- a/assets/xml/objects/object_delf.xml +++ b/assets/xml/objects/object_delf.xml @@ -1,82 +1,82 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dhouse.xml b/assets/xml/objects/object_dhouse.xml index dd95b8b98..a5894a4df 100644 --- a/assets/xml/objects/object_dhouse.xml +++ b/assets/xml/objects/object_dhouse.xml @@ -9,25 +9,25 @@ - + - + - + - + - + - + - + - + - - + + - + diff --git a/assets/xml/objects/object_dinofos.xml b/assets/xml/objects/object_dinofos.xml index 8db9c7c4a..435d60e95 100644 --- a/assets/xml/objects/object_dinofos.xml +++ b/assets/xml/objects/object_dinofos.xml @@ -1,13 +1,13 @@  - - - - - - - - + + + + + + + + @@ -62,10 +62,10 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_dkjail_obj.xml b/assets/xml/objects/object_dkjail_obj.xml index ada181475..d0d2775c3 100644 --- a/assets/xml/objects/object_dkjail_obj.xml +++ b/assets/xml/objects/object_dkjail_obj.xml @@ -1,9 +1,9 @@  - + - + diff --git a/assets/xml/objects/object_dmask.xml b/assets/xml/objects/object_dmask.xml index a7b3874ec..29f245b1b 100644 --- a/assets/xml/objects/object_dmask.xml +++ b/assets/xml/objects/object_dmask.xml @@ -1,17 +1,17 @@  - - + + - + - - + + @@ -21,7 +21,7 @@ - + diff --git a/assets/xml/objects/object_dnk.xml b/assets/xml/objects/object_dnk.xml index bec6ce45d..b085eed28 100644 --- a/assets/xml/objects/object_dnk.xml +++ b/assets/xml/objects/object_dnk.xml @@ -1,11 +1,11 @@  - - - - - + + + + + @@ -45,7 +45,7 @@ - - + + diff --git a/assets/xml/objects/object_dnt.xml b/assets/xml/objects/object_dnt.xml index 96b793849..9f3fcf996 100644 --- a/assets/xml/objects/object_dnt.xml +++ b/assets/xml/objects/object_dnt.xml @@ -1,25 +1,25 @@  - - + + - - - - - - - - - + + + + + + + + + - - - - - - + + + + + + @@ -85,7 +85,7 @@ - + diff --git a/assets/xml/objects/object_dodongo.xml b/assets/xml/objects/object_dodongo.xml index 8de3f4653..cc9b41e25 100644 --- a/assets/xml/objects/object_dodongo.xml +++ b/assets/xml/objects/object_dodongo.xml @@ -1,15 +1,15 @@  - + - - - - + + + + - - - + + + @@ -59,9 +59,9 @@ - - - + + + diff --git a/assets/xml/objects/object_dor01.xml b/assets/xml/objects/object_dor01.xml index 39c950680..9708d97c6 100644 --- a/assets/xml/objects/object_dor01.xml +++ b/assets/xml/objects/object_dor01.xml @@ -1,7 +1,7 @@  - - + + diff --git a/assets/xml/objects/object_dor02.xml b/assets/xml/objects/object_dor02.xml index c60fa9ba9..3cc3d1411 100644 --- a/assets/xml/objects/object_dor02.xml +++ b/assets/xml/objects/object_dor02.xml @@ -1,7 +1,7 @@  - - + + diff --git a/assets/xml/objects/object_dor03.xml b/assets/xml/objects/object_dor03.xml index 941fa6fcc..c7971db0c 100644 --- a/assets/xml/objects/object_dor03.xml +++ b/assets/xml/objects/object_dor03.xml @@ -1,6 +1,6 @@  - + diff --git a/assets/xml/objects/object_dor04.xml b/assets/xml/objects/object_dor04.xml index 394f5a6fe..4e78d9efe 100644 --- a/assets/xml/objects/object_dor04.xml +++ b/assets/xml/objects/object_dor04.xml @@ -1,7 +1,7 @@  - - + + diff --git a/assets/xml/objects/object_dora.xml b/assets/xml/objects/object_dora.xml index ab4b09cf7..09732ba0a 100644 --- a/assets/xml/objects/object_dora.xml +++ b/assets/xml/objects/object_dora.xml @@ -1,17 +1,17 @@  - + - - - - + + + + - - + + diff --git a/assets/xml/objects/object_driftice.xml b/assets/xml/objects/object_driftice.xml index 0ddb6e204..c380c09c1 100644 --- a/assets/xml/objects/object_driftice.xml +++ b/assets/xml/objects/object_driftice.xml @@ -5,7 +5,7 @@ - - + + diff --git a/assets/xml/objects/object_drs.xml b/assets/xml/objects/object_drs.xml index 1b6c29597..ef9788fd5 100644 --- a/assets/xml/objects/object_drs.xml +++ b/assets/xml/objects/object_drs.xml @@ -1,7 +1,7 @@  - + diff --git a/assets/xml/objects/object_ds2.xml b/assets/xml/objects/object_ds2.xml index 1794c4bf8..0eb35db79 100644 --- a/assets/xml/objects/object_ds2.xml +++ b/assets/xml/objects/object_ds2.xml @@ -1,6 +1,6 @@  - + diff --git a/assets/xml/objects/object_ds2n.xml b/assets/xml/objects/object_ds2n.xml index 7e7d45f0c..da6ce5e87 100644 --- a/assets/xml/objects/object_ds2n.xml +++ b/assets/xml/objects/object_ds2n.xml @@ -65,7 +65,7 @@ - + diff --git a/assets/xml/objects/object_dt.xml b/assets/xml/objects/object_dt.xml index 8b2a90217..3acf0c442 100644 --- a/assets/xml/objects/object_dt.xml +++ b/assets/xml/objects/object_dt.xml @@ -1,10 +1,10 @@  - - - - - + + + + + @@ -28,8 +28,8 @@ - - + + @@ -37,15 +37,15 @@ - + - - - + + + - - + + @@ -62,6 +62,6 @@ - + diff --git a/assets/xml/objects/object_dy_obj.xml b/assets/xml/objects/object_dy_obj.xml index a64bc975b..91b9a55fb 100644 --- a/assets/xml/objects/object_dy_obj.xml +++ b/assets/xml/objects/object_dy_obj.xml @@ -1,15 +1,15 @@  - - - - - - - - - - + + + + + + + + + + @@ -18,7 +18,7 @@ - + diff --git a/assets/xml/objects/object_efc_star_field.xml b/assets/xml/objects/object_efc_star_field.xml index 72b7ef636..90ea17929 100644 --- a/assets/xml/objects/object_efc_star_field.xml +++ b/assets/xml/objects/object_efc_star_field.xml @@ -1,8 +1,8 @@  - + - + diff --git a/assets/xml/objects/object_efc_tw.xml b/assets/xml/objects/object_efc_tw.xml index 709224f9d..a7ca81b55 100644 --- a/assets/xml/objects/object_efc_tw.xml +++ b/assets/xml/objects/object_efc_tw.xml @@ -4,7 +4,7 @@ - + diff --git a/assets/xml/objects/object_eg.xml b/assets/xml/objects/object_eg.xml index 6aba85e62..26e5c86bc 100644 --- a/assets/xml/objects/object_eg.xml +++ b/assets/xml/objects/object_eg.xml @@ -2,20 +2,20 @@ - + - + - + - + - + @@ -24,7 +24,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -105,32 +105,32 @@ - - - - - - - - - - - - + + + + + + + + + + + + - + - - - - - + + + + + - + diff --git a/assets/xml/objects/object_ending_obj.xml b/assets/xml/objects/object_ending_obj.xml index ad13ce7b8..f8902e353 100644 --- a/assets/xml/objects/object_ending_obj.xml +++ b/assets/xml/objects/object_ending_obj.xml @@ -1,13 +1,13 @@  - + - - + + diff --git a/assets/xml/objects/object_f40_obj.xml b/assets/xml/objects/object_f40_obj.xml index 59bff9d05..17e7210de 100644 --- a/assets/xml/objects/object_f40_obj.xml +++ b/assets/xml/objects/object_f40_obj.xml @@ -11,7 +11,7 @@ - - + + diff --git a/assets/xml/objects/object_f40_switch.xml b/assets/xml/objects/object_f40_switch.xml index a5c823baa..7e7fb5b1c 100644 --- a/assets/xml/objects/object_f40_switch.xml +++ b/assets/xml/objects/object_f40_switch.xml @@ -1,8 +1,8 @@  - - - + + + diff --git a/assets/xml/objects/object_f52_obj.xml b/assets/xml/objects/object_f52_obj.xml index f80b67696..697a5b100 100644 --- a/assets/xml/objects/object_f52_obj.xml +++ b/assets/xml/objects/object_f52_obj.xml @@ -1,16 +1,16 @@  - - + + - - + + - + diff --git a/assets/xml/objects/object_f53_obj.xml b/assets/xml/objects/object_f53_obj.xml index 424d7c003..d93048a9d 100644 --- a/assets/xml/objects/object_f53_obj.xml +++ b/assets/xml/objects/object_f53_obj.xml @@ -1,13 +1,13 @@  - + - + diff --git a/assets/xml/objects/object_fall.xml b/assets/xml/objects/object_fall.xml index 47fa1da70..04c1ff058 100644 --- a/assets/xml/objects/object_fall.xml +++ b/assets/xml/objects/object_fall.xml @@ -7,14 +7,14 @@ --> - + - + - - - - \ + + + + @@ -22,7 +22,7 @@ - + @@ -30,7 +30,7 @@ - + @@ -43,7 +43,7 @@ - + diff --git a/assets/xml/objects/object_fall2.xml b/assets/xml/objects/object_fall2.xml index 25439a50a..12299ab74 100644 --- a/assets/xml/objects/object_fall2.xml +++ b/assets/xml/objects/object_fall2.xml @@ -4,7 +4,7 @@ moon's mouth, both used in the cutscene before warping to the moon. --> - + @@ -12,7 +12,7 @@ - + @@ -29,6 +29,6 @@ - + diff --git a/assets/xml/objects/object_famos.xml b/assets/xml/objects/object_famos.xml index d12a94d66..186e2b59b 100644 --- a/assets/xml/objects/object_famos.xml +++ b/assets/xml/objects/object_famos.xml @@ -1,7 +1,7 @@  - + @@ -24,7 +24,7 @@ - + diff --git a/assets/xml/objects/object_fb.xml b/assets/xml/objects/object_fb.xml index bb630781c..59ecaf9e5 100644 --- a/assets/xml/objects/object_fb.xml +++ b/assets/xml/objects/object_fb.xml @@ -1,10 +1,10 @@  - - - - - + + + + + diff --git a/assets/xml/objects/object_firefly.xml b/assets/xml/objects/object_firefly.xml index 4c6aacd16..acdcedb1d 100644 --- a/assets/xml/objects/object_firefly.xml +++ b/assets/xml/objects/object_firefly.xml @@ -1,6 +1,6 @@  - + diff --git a/assets/xml/objects/object_fish.xml b/assets/xml/objects/object_fish.xml index 4d9a86e51..918c0eb5f 100644 --- a/assets/xml/objects/object_fish.xml +++ b/assets/xml/objects/object_fish.xml @@ -1,6 +1,6 @@  - + @@ -54,10 +54,10 @@ - + - + @@ -78,7 +78,7 @@ - + @@ -99,10 +99,10 @@ - + - + @@ -137,26 +137,26 @@ - + - - + + - + - + - + diff --git a/assets/xml/objects/object_flowerpot.xml b/assets/xml/objects/object_flowerpot.xml index b6adc70d4..01d16b663 100644 --- a/assets/xml/objects/object_flowerpot.xml +++ b/assets/xml/objects/object_flowerpot.xml @@ -3,9 +3,9 @@ - - - - + + + + diff --git a/assets/xml/objects/object_fr.xml b/assets/xml/objects/object_fr.xml index 0cd28760e..f7fa4354b 100644 --- a/assets/xml/objects/object_fr.xml +++ b/assets/xml/objects/object_fr.xml @@ -1,8 +1,8 @@  - - - + + + diff --git a/assets/xml/objects/object_fsn.xml b/assets/xml/objects/object_fsn.xml index dd67874f0..37867dc32 100644 --- a/assets/xml/objects/object_fsn.xml +++ b/assets/xml/objects/object_fsn.xml @@ -57,15 +57,14 @@ - - - - - - - - - + + + + + + + + @@ -78,8 +77,8 @@ - - + + @@ -106,7 +105,7 @@ - - + + diff --git a/assets/xml/objects/object_fu.xml b/assets/xml/objects/object_fu.xml index 19404f90e..fb41a85e8 100644 --- a/assets/xml/objects/object_fu.xml +++ b/assets/xml/objects/object_fu.xml @@ -1,7 +1,7 @@  - - + + diff --git a/assets/xml/objects/object_fu_kaiten.xml b/assets/xml/objects/object_fu_kaiten.xml index 37a7ec4bc..ad277bb26 100644 --- a/assets/xml/objects/object_fu_kaiten.xml +++ b/assets/xml/objects/object_fu_kaiten.xml @@ -1,18 +1,18 @@  - + - - + + - + diff --git a/assets/xml/objects/object_fu_mato.xml b/assets/xml/objects/object_fu_mato.xml index b28899f3c..bedf6906f 100644 --- a/assets/xml/objects/object_fu_mato.xml +++ b/assets/xml/objects/object_fu_mato.xml @@ -1,21 +1,21 @@  - - - - - - + + + + + + - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_funen.xml b/assets/xml/objects/object_funen.xml index 5f8c18c3d..7a0410008 100644 --- a/assets/xml/objects/object_funen.xml +++ b/assets/xml/objects/object_funen.xml @@ -1,6 +1,6 @@  - + diff --git a/assets/xml/objects/object_fusen.xml b/assets/xml/objects/object_fusen.xml index 2e115b2b7..2ee47097a 100644 --- a/assets/xml/objects/object_fusen.xml +++ b/assets/xml/objects/object_fusen.xml @@ -1,8 +1,8 @@  - - + + - + diff --git a/assets/xml/objects/object_fwall.xml b/assets/xml/objects/object_fwall.xml index 1bbb5d572..a4311c173 100644 --- a/assets/xml/objects/object_fwall.xml +++ b/assets/xml/objects/object_fwall.xml @@ -1,6 +1,6 @@  - + diff --git a/assets/xml/objects/object_gla.xml b/assets/xml/objects/object_gla.xml index 7463cd2e0..757e652c9 100644 --- a/assets/xml/objects/object_gla.xml +++ b/assets/xml/objects/object_gla.xml @@ -1,73 +1,78 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_child.xml b/assets/xml/objects/object_link_child.xml index 23d3cf09c..dd045c1d8 100644 --- a/assets/xml/objects/object_link_child.xml +++ b/assets/xml/objects/object_link_child.xml @@ -101,7 +101,7 @@ - + @@ -110,17 +110,17 @@ - - + + - + - - + + @@ -143,12 +143,12 @@ - - + + - + diff --git a/assets/xml/objects/object_link_goron.xml b/assets/xml/objects/object_link_goron.xml index 48eef4dd9..76017884e 100644 --- a/assets/xml/objects/object_link_goron.xml +++ b/assets/xml/objects/object_link_goron.xml @@ -90,7 +90,7 @@ - + diff --git a/assets/xml/objects/object_link_nuts.xml b/assets/xml/objects/object_link_nuts.xml index a00c44db4..9247d3db4 100644 --- a/assets/xml/objects/object_link_nuts.xml +++ b/assets/xml/objects/object_link_nuts.xml @@ -40,10 +40,10 @@ - + - + diff --git a/assets/xml/objects/object_po_fusen.xml b/assets/xml/objects/object_po_fusen.xml index a25c9d960..23bfbe075 100644 --- a/assets/xml/objects/object_po_fusen.xml +++ b/assets/xml/objects/object_po_fusen.xml @@ -1,32 +1,39 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_po_sisters.xml b/assets/xml/objects/object_po_sisters.xml index e2e57a31a..cc00b50a1 100644 --- a/assets/xml/objects/object_po_sisters.xml +++ b/assets/xml/objects/object_po_sisters.xml @@ -3,68 +3,68 @@ - + - + - - - + + + - - - - - + + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - + + + + + + - - - - - - - + + + + + + + - + diff --git a/assets/xml/objects/object_slime.xml b/assets/xml/objects/object_slime.xml index f17633eff..c8516e45f 100644 --- a/assets/xml/objects/object_slime.xml +++ b/assets/xml/objects/object_slime.xml @@ -1,14 +1,17 @@  + - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_sth.xml b/assets/xml/objects/object_sth.xml index b176cd8cc..53040ae05 100644 --- a/assets/xml/objects/object_sth.xml +++ b/assets/xml/objects/object_sth.xml @@ -1,42 +1,53 @@  + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_wf.xml b/assets/xml/objects/object_wf.xml index b6c5b640d..0d8fdb68c 100644 --- a/assets/xml/objects/object_wf.xml +++ b/assets/xml/objects/object_wf.xml @@ -65,11 +65,11 @@ - - - - - + + + + + @@ -135,8 +135,8 @@ - + - + diff --git a/assets/xml/overlays/ovl_Arrow_fire.xml b/assets/xml/overlays/ovl_Arrow_Fire.xml similarity index 100% rename from assets/xml/overlays/ovl_Arrow_fire.xml rename to assets/xml/overlays/ovl_Arrow_Fire.xml diff --git a/assets/xml/overlays/ovl_En_Sth.xml b/assets/xml/overlays/ovl_En_Sth.xml index 51b29870d..a0d90d9e8 100644 --- a/assets/xml/overlays/ovl_En_Sth.xml +++ b/assets/xml/overlays/ovl_En_Sth.xml @@ -1,14 +1,15 @@ - - - - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_fbdemo_triforce.xml b/assets/xml/overlays/ovl_fbdemo_triforce.xml similarity index 56% rename from assets/xml/objects/object_fbdemo_triforce.xml rename to assets/xml/overlays/ovl_fbdemo_triforce.xml index a00c9bf13..ed23e36c3 100644 --- a/assets/xml/objects/object_fbdemo_triforce.xml +++ b/assets/xml/overlays/ovl_fbdemo_triforce.xml @@ -1,7 +1,7 @@ - - + + diff --git a/assets/xml/overlays/ovl_fbdemo_wipe1.xml b/assets/xml/overlays/ovl_fbdemo_wipe1.xml new file mode 100644 index 000000000..281c8ebfb --- /dev/null +++ b/assets/xml/overlays/ovl_fbdemo_wipe1.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 493486e79..2f4c9854a 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -14,7 +14,7 @@ Most discussions happen on our [Discord Server](https://discord.zelda64.dev) whe - [Style Guide](STYLE.md) - Description of the project style that we ask contributors to adhere to. - [Code Review Guidelines](REVIEWING.md) - These are the guidelines that reviewers will be using when reviewing your code. Good to be familiar with these before submitting your code. -- [Zelda 64 Reverse Engineering Website](https://zelda64.dev/mm) - Our homepage, with FAQ and progress graph :chart_with_upwards_trend:. +- [Zelda 64 Reverse Engineering Website](https://zelda64.dev/games/mm) - Our homepage, with FAQ and progress graph :chart_with_upwards_trend:. - [MM decomp tutorial](tutorial/contents.md) Detailed tutorial for learning in general how decomp works and how to decompile a small, simple file. - [Introduction to OOT decomp](https://github.com/zeldaret/oot/blob/master/docs/tutorial/contents.md) - The tutorial the MM one was based on. For OOT, but largely applicable to MM as well. Covers slightly different topics, including how to get your data OK with `vbindiff`. - The `#resources` channel on the Discord contains many more links on specific details of decompiling IDO MIPS code. diff --git a/docs/tools.md b/docs/tools.md index 0aba4fa47..5005f7f93 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -127,7 +127,7 @@ Gives the progress output that the website uses. Run for that warm glow. ### `tools/regconvert.py` -Convert `mips2c`'s `gGameInfo->data[n]` output (or a raw offset) into the appropriate variable in the REG pages. Can also be run on a file to mass-convert them: run with `-h` for details. +Convert `mips2c`'s `gRegEditor->data[n]` output (or a raw offset) into the appropriate variable in the REG pages. Can also be run on a file to mass-convert them: run with `-h` for details. ### `tools/rename_global_asm.py` diff --git a/docs/tutorial/advanced_control_flow.md b/docs/tutorial/advanced_control_flow.md index 96ba7a43d..43e9e6d46 100644 --- a/docs/tutorial/advanced_control_flow.md +++ b/docs/tutorial/advanced_control_flow.md @@ -67,7 +67,7 @@ void EnMs_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.015f); this->actor.colChkInfo.mass = 0xFF; this->actionFunc = func_80952734; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; this->actor.gravity = -1.0f; } @@ -81,7 +81,7 @@ void EnMs_Destroy(Actor* thisx, PlayState* play) { void func_80952734(EnMs* this, PlayState* play) { s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (gSaveContext.save.inventory.items[10] == ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[10] == ITEM_NONE) { this->actor.textId = 0x92E; } else { this->actor.textId = 0x932; @@ -107,13 +107,13 @@ void func_809529AC(EnMs* this, PlayState* play) { func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); this->actionFunc = func_80952A1C; } else { - Actor_PickUp(&this->actor, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_OfferGetItem(&this->actor, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } void func_80952A1C(EnMs* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - func_80151938(play, 0x936U); + Message_ContinueTextbox(play, 0x936U); this->actionFunc = func_809527F8; } else { func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, -1); @@ -167,8 +167,8 @@ void func_809527F8(EnMs* this, PlayState* play) { return; } if (Message_ShouldAdvance(play) != 0) { - func_801477B4(play); - Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Message_CloseTextbox(play); + Actor_OfferGetItem((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; } @@ -182,23 +182,23 @@ void func_809527F8(EnMs* this, PlayState* play) { } func_8019F230(); - func_80151938(play, 0x934U); + Message_ContinueTextbox(play, 0x934U); // Duplicate return node #17. Try simplifying control flow for better match return; } - func_801477B4(play); - if ((s32) gSaveContext.save.playerData.rupees < 0xA) { + Message_CloseTextbox(play); + if ((s32) gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(play, 0x935U); + Message_ContinueTextbox(play, 0x935U); return; } - if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if ((s32) gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(play, 0x937U); + Message_ContinueTextbox(play, 0x937U); return; } func_8019F208(); - Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Actor_OfferGetItem((Actor *) this, play, 0x35, 90.0f, 10.0f); Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; } @@ -256,8 +256,8 @@ block_5: if (Message_ShouldAdvance(play) == 0) { goto block_17; } - func_801477B4(play); - Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Message_CloseTextbox(play); + Actor_OfferGetItem((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: @@ -273,29 +273,29 @@ block_7: } goto block_16; block_11: - func_801477B4(play); - if ((s32) gSaveContext.save.playerData.rupees >= 0xA) { + Message_CloseTextbox(play); + if ((s32) gSaveContext.save.saveInfo.playerData.rupees >= 0xA) { goto block_13; } play_sound(0x4806U); - func_80151938(play, 0x935U); + Message_ContinueTextbox(play, 0x935U); return; block_13: - if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] < 0x14) { + if ((s32) gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] < 0x14) { goto block_15; } play_sound(0x4806U); - func_80151938(play, 0x937U); + Message_ContinueTextbox(play, 0x937U); return; block_15: func_8019F208(); - Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Actor_OfferGetItem((Actor *) this, play, 0x35, 90.0f, 10.0f); Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; return; block_16: func_8019F230(); - func_80151938(play, 0x934U); + Message_ContinueTextbox(play, 0x934U); block_17: return; } @@ -312,11 +312,11 @@ which in many ways looks worse: you can see why the use of gotos in code is stro The simplest sort of block label to eliminate is one that is only used once, and where the corresponding goto jumps over a simple block of code with no extra internal control flow structure. There are two obvious examples of this here, the first being ```C - if ((s32) gSaveContext.save.playerData.rupees >= 0xA) { + if ((s32) gSaveContext.save.saveInfo.playerData.rupees >= 0xA) { goto block_13; } play_sound(0x4806U); - func_80151938(play, 0x935U); + Message_ContinueTextbox(play, 0x935U); return; block_13: ``` @@ -324,9 +324,9 @@ block_13: Currently, this says to jump over the code block `play_sound...` if the condition in the if is satisfied. In non-goto terms, this means that the block should be run if the condition is *not* satisfied. This also illustrates a general property of goto-only mode: you have to reverse the senses of all of the ifs. Therefore the appropriate approach is to swap the if round, put the code block inside, and remove the goto and the label: ```C - if (gSaveContext.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(play, 0x935U); + Message_ContinueTextbox(play, 0x935U); return; } ``` @@ -359,8 +359,8 @@ block_5: if (Message_ShouldAdvance(play) == 0) { goto block_17; } - func_801477B4(play); - Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Message_CloseTextbox(play); + Actor_OfferGetItem((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: @@ -376,27 +376,27 @@ block_7: } goto block_16; block_11: - func_801477B4(play); + Message_CloseTextbox(play); - if (gSaveContext.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(play, 0x935U); + Message_ContinueTextbox(play, 0x935U); return; } - if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if (gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(play, 0x937U); + Message_ContinueTextbox(play, 0x937U); return; } func_8019F208(); - Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Actor_OfferGetItem((Actor *) this, play, 0x35, 90.0f, 10.0f); Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; return; block_16: func_8019F230(); - func_80151938(play, 0x934U); + Message_ContinueTextbox(play, 0x934U); block_17: return; } @@ -428,8 +428,8 @@ block_5: if (Message_ShouldAdvance(play) == 0) { return; } - func_801477B4(play); - Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Message_CloseTextbox(play); + Actor_OfferGetItem((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: @@ -445,27 +445,27 @@ block_7: } goto block_16; block_11: - func_801477B4(play); + Message_CloseTextbox(play); - if (gSaveContext.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(play, 0x935U); + Message_ContinueTextbox(play, 0x935U); return; } - if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if (gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(play, 0x937U); + Message_ContinueTextbox(play, 0x937U); return; } func_8019F208(); - Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Actor_OfferGetItem((Actor *) this, play, 0x35, 90.0f, 10.0f); Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; return; block_16: func_8019F230(); - func_80151938(play, 0x934U); + Message_ContinueTextbox(play, 0x934U); } ``` @@ -495,21 +495,21 @@ So let us rewrite the entire second half as a switch: ```C switch (play->msgCtx.choiceIndex) { case 0: - func_801477B4(play); + Message_CloseTextbox(play); - if (gSaveContext.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(play, 0x935U); + Message_ContinueTextbox(play, 0x935U); return; } - if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if (gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(play, 0x937U); + Message_ContinueTextbox(play, 0x937U); return; } func_8019F208(); - Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Actor_OfferGetItem((Actor *) this, play, 0x35, 90.0f, 10.0f); Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; return; @@ -518,7 +518,7 @@ So let us rewrite the entire second half as a switch: case 1: default: func_8019F230(); - func_80151938(play, 0x934U); + Message_ContinueTextbox(play, 0x934U); break; } ``` @@ -531,17 +531,17 @@ There's a couple of other obvious things here: ```C switch (play->msgCtx.choiceIndex) { case 0: - func_801477B4(play); + Message_CloseTextbox(play); - if (gSaveContext.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(play, 0x935U); - } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + Message_ContinueTextbox(play, 0x935U); + } else if (gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(play, 0x937U); + Message_ContinueTextbox(play, 0x937U); } else { func_8019F208(); - Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Actor_OfferGetItem((Actor *) this, play, 0x35, 90.0f, 10.0f); Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; } @@ -550,7 +550,7 @@ There's a couple of other obvious things here: case 1: default: func_8019F230(); - func_80151938(play, 0x934U); + Message_ContinueTextbox(play, 0x934U); break; } ``` @@ -588,25 +588,25 @@ block_5: if (Message_ShouldAdvance(play) == 0) { return; } - func_801477B4(play); - Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Message_CloseTextbox(play); + Actor_OfferGetItem((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; return; block_7: if (Message_ShouldAdvance(play) != 0) { switch (play->msgCtx.choiceIndex) { case 0: - func_801477B4(play); + Message_CloseTextbox(play); - if (gSaveContext.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(play, 0x935U); - } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + Message_ContinueTextbox(play, 0x935U); + } else if (gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(play, 0x937U); + Message_ContinueTextbox(play, 0x937U); } else { func_8019F208(); - Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Actor_OfferGetItem((Actor *) this, play, 0x35, 90.0f, 10.0f); Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; } @@ -615,7 +615,7 @@ block_7: case 1: default: func_8019F230(); - func_80151938(play, 0x934U); + Message_ContinueTextbox(play, 0x934U); break; } } @@ -652,8 +652,8 @@ void func_809527F8(EnMs* this, PlayState* play) { if (Message_ShouldAdvance(play) == 0) { return; } - func_801477B4(play); - Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Message_CloseTextbox(play); + Actor_OfferGetItem((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; break; @@ -661,17 +661,17 @@ void func_809527F8(EnMs* this, PlayState* play) { if (Message_ShouldAdvance(play) != 0) { switch (play->msgCtx.choiceIndex) { case 0: - func_801477B4(play); + Message_CloseTextbox(play); - if (gSaveContext.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(play, 0x935U); - } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + Message_ContinueTextbox(play, 0x935U); + } else if (gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(play, 0x937U); + Message_ContinueTextbox(play, 0x937U); } else { func_8019F208(); - Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Actor_OfferGetItem((Actor *) this, play, 0x35, 90.0f, 10.0f); Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; } @@ -680,7 +680,7 @@ void func_809527F8(EnMs* this, PlayState* play) { case 1: default: func_8019F230(); - func_80151938(play, 0x934U); + Message_ContinueTextbox(play, 0x934U); break; } } @@ -703,8 +703,8 @@ void func_809527F8(EnMs* this, PlayState* play) { case 5: if (Message_ShouldAdvance(play) != 0) { - func_801477B4(play); - Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Message_CloseTextbox(play); + Actor_OfferGetItem((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; } break; @@ -713,17 +713,17 @@ void func_809527F8(EnMs* this, PlayState* play) { if (Message_ShouldAdvance(play) != 0) { switch (play->msgCtx.choiceIndex) { case 0: - func_801477B4(play); + Message_CloseTextbox(play); - if (gSaveContext.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); - func_80151938(play, 0x935U); - } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + Message_ContinueTextbox(play, 0x935U); + } else if (gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); - func_80151938(play, 0x937U); + Message_ContinueTextbox(play, 0x937U); } else { func_8019F208(); - Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f); + Actor_OfferGetItem((Actor *) this, play, 0x35, 90.0f, 10.0f); Rupees_ChangeBy(-0xA); this->actionFunc = func_809529AC; } @@ -732,7 +732,7 @@ void func_809527F8(EnMs* this, PlayState* play) { case 1: default: func_8019F230(); - func_80151938(play, 0x934U); + Message_ContinueTextbox(play, 0x934U); break; } } diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index 68c90ef66..71f3347e3 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -185,7 +185,7 @@ void func_80C102D4(EnRecepgirl* this, PlayState* play) { if (this->actor.textId == 0x2AD9) { Flags_SetSwitch(play, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); - if ((gSaveContext.save.weekEventReg[63] & 0x80)) { + if ((gSaveContext.save.saveInfo.weekEventReg[63] & 0x80)) { this->actor.textId = 0x2ADF; } else { this->actor.textId = 0x2ADA; @@ -203,7 +203,7 @@ void func_80C102D4(EnRecepgirl* this, PlayState* play) { this->actor.textId = 0x2AE0; } } - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); } } @@ -327,17 +327,13 @@ the fourth element is the object (it is actually an enum, but the file itself ha ## Z64Utils -The latest release of Z64Utils can be downloaded from [https://github.com/Random06457/Z64Utils/releases]. To use it with MM, you also need a json file to fill in the file names: the latest version can be obtained from [https://github.com/Random06457/Z64Utils-Config]. It should work on Wine. Some graphics cards don't love it, but the 3D graphical part is only required for skeleton and animations. +The latest release of Z64Utils can be downloaded from [https://github.com/zeldaret/Z64Utils/releases]. It should work on Wine. Some graphics cards don't love it, but the 3D graphical part is only required for skeleton and animations. Having downloaded and unzipped it, open the baserom file. This will populate the main window with a list: ![Z64Utils' main window](images/z64utils_main.png) -Search for the object file, right-click and select "Open in Object Analyzer". It will ask you to choose a segment: this is the segment that the file is put on, and allows Z64Utils to resolve the segmented addresses it references into symbols. The json already knows it should be segment `6`, so just click okay. This will open this window: - -![Z64Utils' object analyzer window](images/z64utils_object_analyzer.png) - -Go to "Analysis -> Find Dlists" and press OK (the defaults are usually fine). This will automatically search for displaylists in the object, which are a sufficiently distinctive format to be easy to find. We want to see the other stuff in the object too, so also do "Analysis -> Analyze Dlists". This will populate the window with even more stuff: +Search for the object file, then either double-click it or right-click it and select "Open in Object Analyzer" to open it. It will ask you to choose a segment: this is the segment that the file is put on, and allows Z64Utils to resolve the segmented addresses it references into symbols. The json already knows it should be segment `6`, so just click okay. This will open this window; displaylists and other data will automatically be analyzed when the object is opened: ![Z64Utils, with an analyzed object](images/z64utils_object_analyzed.png) @@ -347,7 +343,7 @@ We will talk about what all these types of data are next time, but for now, all static void* D_80C106B0[4] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; ``` -actually are. We know they are set on segment 8, so we need to find where the skeleton uses them. We know from `object_bg_Skel_011B60` that this is at `0x06011B60`, so scroll down to it, right-click on it, and choose "Open in Skeleton Viewer". Pick an animation that we know it uses (sometimes Z64Utils misidentifies other things for animations), such as `object_bg_Anim_000968`, and you will get this error: +actually are. We know they are set on segment 8, so we need to find where the skeleton uses them. We know from `object_bg_Skel_011B60` that this is at `0x06011B60`, so scroll down to it and either double-click on it or right-click on it and choose "Open in Skeleton Viewer". Pick an animation that we know it uses (sometimes Z64Utils misidentifies other things for animations), such as `object_bg_Anim_000968`, and you will get this error: ![Z64Utils, error when viewing skeleton](images/z64utils_skeleton_error.png) @@ -447,7 +443,7 @@ void EnRecepgirl_UnkLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { } ``` -It is used to do a rotation of whatever limb `5` is. (The `+=` is because `rot->x` is the base rotation of the limb, and we have to add the same thing to it every frame to keep the angle changed and constant.) We can use Z64Utils to : setting segment `8` to one of what we know now are the eye textures, we can view the model in the skeleton viewer. The limb numbers in the object are one smaller than those in the actor (the root limb is only a concept for the code, not the object), so we find limb 4: +It is used to do a rotation of whatever limb `5` is. (The `+=` is because `rot->x` is the base rotation of the limb, and we have to add the same thing to it every frame to keep the angle changed and constant.) We can use Z64Utils to figure this out: setting segment `8` to one of what we know now are the eye textures, we can view the model in the skeleton viewer. The limb numbers in the object are one smaller than those in the actor (the root limb is only a concept for the code, not the object), so we find limb 4: ![Z64Utils highlighting a limb](images/z64utils_skeleton_head.png) @@ -520,7 +516,7 @@ void func_80C102D4(EnRecepgirl* this, PlayState* play) { if (this->actor.textId == 0x2AD9) { // "Welcome..." Flags_SetSwitch(play, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); - if (gSaveContext.save.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting + if (gSaveContext.save.saveInfo.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) } else { this->actor.textId = 0x2ADA; // Mayor's office is on the left (meeting ongoing) @@ -540,7 +536,7 @@ void func_80C102D4(EnRecepgirl* this, PlayState* play) { this->actor.textId = 0x2AE0; // drawing room on the right, don't go in without an appointment } } - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); } } ``` diff --git a/docs/tutorial/images/z64utils_object_analyzer.png b/docs/tutorial/images/z64utils_object_analyzer.png deleted file mode 100644 index 7a6adec3d..000000000 Binary files a/docs/tutorial/images/z64utils_object_analyzer.png and /dev/null differ diff --git a/docs/tutorial/introduction.md b/docs/tutorial/introduction.md index 2115faace..aba8beede 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 Actor_PickUp +/* 0003E4 80952A04 0C02E287 */ jal Actor_OfferGetItem /* 0003E8 80952A08 E7A40010 */ swc1 $f4, 0x10($sp) .L80952A0C: /* 0003EC 80952A0C 8FBF001C */ lw $ra, 0x1c($sp) @@ -46,7 +46,7 @@ void func_809529AC(EnMs* this, PlayState* play) { func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); this->actionFunc = func_80952A1C; } else { - Actor_PickUp(&this->actor, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_OfferGetItem(&this->actor, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } ``` diff --git a/docs/tutorial/object_decomp.md b/docs/tutorial/object_decomp.md index 90ed70405..2406b715d 100644 --- a/docs/tutorial/object_decomp.md +++ b/docs/tutorial/object_decomp.md @@ -111,7 +111,7 @@ If in doubt, look at completed objects in the repo, and if still in doubt, ask. We are very fortunate that several nice tools have been written recently that are excellent for documenting asset files: -- [Z64Utils](https://github.com/Random06457/Z64Utils/releases), for looking at displaylists, textures they reference, the skeleton, animations, etc. +- [Z64Utils](https://github.com/zeldaret/Z64Utils/releases), for looking at displaylists, textures they reference, the skeleton, animations, etc. - [Texture64](https://github.com/queueRAM/Texture64/releases), for looking at textures in all the common N64 formats (needed since Z64Utils cannot interpret textures not explicitly referenced in displaylists currently) ## Building and investigative modding diff --git a/docs/tutorial/object_decomp_example.md b/docs/tutorial/object_decomp_example.md index f4030be5b..829dbb917 100644 --- a/docs/tutorial/object_decomp_example.md +++ b/docs/tutorial/object_decomp_example.md @@ -6,11 +6,11 @@ Let's take a look at `object_dns`, which is a pretty typical NPC object. It's us ## Step 1: Naming the skeleton and limbs -We already went through the steps of opening an object file in Z64Utils in the [documenting step](documenting.md#z64utils), but we'll do it in more detail here. First, search for the object file, then right-click and select "Open in Object Analyzer". It will ask you to choose a segment: this is the segment that the file is put on, and allows Z64Utils to resolve the segmented addresses it references into symbols. The json already knows it should be segment 6, so just click OK. +We already went through the steps of opening an object file in Z64Utils in the [documenting step](documenting.md#z64utils), but we'll do it in more detail here. First, search for the object file, then either double-click on it or right-click it and select "Open in Object Analyzer". It will ask you to choose a segment: this is the segment that the file is put on, and allows Z64Utils to resolve the segmented addresses it references into symbols. The json already knows it should be segment 6, so just click OK. ![Opening object_dns in Z64Utils](images/z64utils_open_dns.png) -In the resulting window, go to "Analysis -> Find Dlists" and press OK (the defaults are usually fine). This will only find display lists, so to find everything else in the obect, do "Analysis -> Analyze Dlists". We're looking for the skeleton, so scroll down to the SkeletonHeader, right-click it, and select "Open in Skeleton Viewer": +In the resulting window, you'll see displaylists, textures, and other assets. We're looking for the skeleton, so scroll down to the SkeletonHeader, then either double-click on it or right-click it and select "Open in Skeleton Viewer": ![Finding object_dns's SkeletonHeader in Z64Utils](images/z64utils_dns_skeletonheader.png) @@ -186,7 +186,7 @@ For some actors, there may be a few other things left to name that are directly gSPDisplayList(POLY_OPA_DISP++, &D_06002C48); ``` -In Z64Utils, scroll to find this display list, then right-click and select "Open in Dlist Viewer": +In Z64Utils, scroll to find this display list, then either double-click it or right-click it and select "Open in Dlist Viewer": ![Opening dlist_00002C48 in Z64Utils](images/z64utils_dns_display_list.png) diff --git a/docs/tutorial/other_functions.md b/docs/tutorial/other_functions.md index 1c8ba6b5b..f73902ca5 100644 --- a/docs/tutorial/other_functions.md +++ b/docs/tutorial/other_functions.md @@ -334,7 +334,7 @@ void func_80C102D4(EnRecepgirl* this, PlayState* play) { this->actor.textId = 0x2AE0; } } - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); } } ``` @@ -392,7 +392,7 @@ void func_80C102D4(EnRecepgirl* this, PlayState* play) { this->actor.textId = 0x2AE0; } } - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); } } ``` @@ -404,7 +404,7 @@ There remains one thing we need to fix before trying to compile it, namely `*(&g /* 0x0F5C */ u32 regionsVisited; // "area_arrival" ``` -so it's somewhere in `weekEventReg`. `0xF37 - 0xEF8 = 0x3F = 63`, and it's a byte array, so the access is actually `gSaveContext.save.weekEventReg[63] & 0x80`. Now it will compile. We also don't use `!= 0` for flag comparisons: just `if (gSaveContext.save.weekEventReg[63] & 0x80)` will do. +so it's somewhere in `weekEventReg`. `0xF37 - 0xEF8 = 0x3F = 63`, and it's a byte array, so the access is actually `gSaveContext.save.saveInfo.weekEventReg[63] & 0x80`. Now it will compile. We also don't use `!= 0` for flag comparisons: just `if (gSaveContext.save.saveInfo.weekEventReg[63] & 0x80)` will do. Running `./diff.py -mwo3 func_80C102D4` and scrolling down, we discover that this doesn't match! diff --git a/format.py b/format.py index 5b3cd3158..5e2c29feb 100755 --- a/format.py +++ b/format.py @@ -52,7 +52,7 @@ def get_tidy_version(tidy_executable: str): CLANG_FORMAT = get_clang_executable([f"clang-format-{CLANG_VER}"]) if CLANG_FORMAT is None: - sys.exit(f"Error: clang-format-{CLANG_VER} found") + sys.exit(f"Error: clang-format-{CLANG_VER} not found") CLANG_TIDY = get_clang_executable([f"clang-tidy-{CLANG_VER}", "clang-tidy"]) if CLANG_TIDY is None: diff --git a/include/PR/gbi.h b/include/PR/gbi.h index 07fa0ac2c..3ba8748b0 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -4082,7 +4082,7 @@ _DW({ \ #define gDPLoadTextureTile(pkt, timg, fmt, siz, width, height, \ uls, ult, lrs, lrt, pal, \ cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ +_DW({ \ gDPSetTextureImage(pkt, fmt, siz, width, timg); \ gDPSetTile(pkt, fmt, siz, \ (((((lrs)-(uls)+1) * siz##_TILE_BYTES)+7)>>3), 0, \ @@ -4104,7 +4104,7 @@ _DW({ \ (ult)<work.p +#define POLY_OPA_DISP __gfxCtx->polyOpa.p +#define POLY_XLU_DISP __gfxCtx->polyXlu.p +#define OVERLAY_DISP __gfxCtx->overlay.p +#define DEBUG_DISP __gfxCtx->debug.p + +// __gfxCtx shouldn't be used directly. +// Use the DISP macros defined above when writing to display buffers. +#define OPEN_DISPS(gfxCtx) \ + { \ + GraphicsContext* __gfxCtx = gfxCtx; \ + s32 __dispPad + +#define CLOSE_DISPS(gfxCtx) \ + (void)0; \ + } \ + (void)0 + +#define GRAPH_ALLOC(gfxCtx, size) ((void*)((gfxCtx)->polyOpa.d = (Gfx*)((u8*)(gfxCtx)->polyOpa.d - ALIGN16(size)))) + +// Custom gbi macro +#define gDPSetTileCustom(pkt, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ + { \ + gDPPipeSync(pkt); \ + gDPTileSync(pkt); \ + gDPSetTile(pkt, fmt, siz, (((width)*siz##_TILE_BYTES) + 7) >> 3, 0, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, \ + masks, shifts); \ + gDPTileSync(pkt); \ + gDPSetTile(pkt, fmt, siz, (((width)*siz##_TILE_BYTES) + 7) >> 3, 0, G_TX_RENDERTILE, pal, cmt, maskt, shiftt, \ + cms, masks, shifts); \ + gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1) << G_TEXTURE_IMAGE_FRAC); \ + } \ + (void)0 + +#endif diff --git a/include/initvars.h b/include/initvars.h deleted file mode 100644 index 50668a14c..000000000 --- a/include/initvars.h +++ /dev/null @@ -1,45 +0,0 @@ -#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 TransitionInit TransitionFade_InitVars; -extern TransitionInit TransitionTriforce_InitVars; -extern TransitionInit TransitionWipe1_InitVars; -extern TransitionInit TransitionWipe3_InitVars; -extern TransitionInit TransitionWipe4_InitVars; -extern TransitionInit TransitionCircle_InitVars; -extern TransitionInit TransitionWipe5_InitVars; - -#endif diff --git a/include/io/controller.h b/include/io/controller.h index 4321df096..b588b4198 100644 --- a/include/io/controller.h +++ b/include/io/controller.h @@ -35,10 +35,6 @@ #define CONT_CMD_WRITE_EEPROM_RX 1 #define CONT_CMD_RESET_RX 3 -#define CONT_CMD_NOP 0xFF -#define CONT_CMD_END 0xFE // Indicates end of a command -#define CONT_CMD_EXE 1 // Set pif ram status byte to this to do a command - #define CONT_ERR_NO_CONTROLLER PFS_ERR_NOPACK /* 1 */ #define CONT_ERR_CONTRFAIL CONT_OVERRUN_ERROR /* 4 */ #define CONT_ERR_INVALID PFS_ERR_INVALID /* 5 */ @@ -48,6 +44,52 @@ #define CONT_ERR_VOICE_WORD 14 #define CONT_ERR_VOICE_NO_RESPONSE 15 +// Joybus commands +#define CONT_CMD_REQUEST_STATUS 0 +#define CONT_CMD_READ_BUTTON 1 +#define CONT_CMD_READ_PAK 2 +#define CONT_CMD_WRITE_PAK 3 +#define CONT_CMD_READ_EEPROM 4 +#define CONT_CMD_WRITE_EEPROM 5 +#define CONT_CMD_READ36_VOICE 9 +#define CONT_CMD_WRITE20_VOICE 10 +#define CONT_CMD_READ2_VOICE 11 +#define CONT_CMD_WRITE4_VOICE 12 +#define CONT_CMD_SWRITE_VOICE 13 +#define CONT_CMD_CHANNEL_RESET 0xFD +#define CONT_CMD_RESET 0xFF + +// Bytes transmitted for each joybus command +#define CONT_CMD_REQUEST_STATUS_TX 1 +#define CONT_CMD_READ_BUTTON_TX 1 +#define CONT_CMD_READ_PAK_TX 3 +#define CONT_CMD_WRITE_PAK_TX 35 +#define CONT_CMD_READ_EEPROM_TX 2 +#define CONT_CMD_WRITE_EEPROM_TX 10 +#define CONT_CMD_READ36_VOICE_TX 3 +#define CONT_CMD_WRITE20_VOICE_TX 23 +#define CONT_CMD_READ2_VOICE_TX 3 +#define CONT_CMD_WRITE4_VOICE_TX 7 +#define CONT_CMD_SWRITE_VOICE_TX 3 +#define CONT_CMD_RESET_TX 1 + +// Bytes received for each joybus command +#define CONT_CMD_REQUEST_STATUS_RX 3 +#define CONT_CMD_READ_BUTTON_RX 4 +#define CONT_CMD_READ_PAK_RX 33 +#define CONT_CMD_WRITE_PAK_RX 1 +#define CONT_CMD_READ_EEPROM_RX 8 +#define CONT_CMD_WRITE_EEPROM_RX 1 +#define CONT_CMD_READ36_VOICE_RX 37 +#define CONT_CMD_WRITE20_VOICE_RX 1 +#define CONT_CMD_READ2_VOICE_RX 3 +#define CONT_CMD_WRITE4_VOICE_RX 1 +#define CONT_CMD_SWRITE_VOICE_RX 1 +#define CONT_CMD_RESET_RX 3 + +#define CONT_CMD_NOP 0xFF +#define CONT_CMD_END 0xFE // Indicates end of a command +#define CONT_CMD_EXE 1 // Set pif ram status byte to this to do a command #define DIR_STATUS_EMPTY 0 #define DIR_STATUS_UNKNOWN 1 @@ -81,6 +123,26 @@ #define CONT_ADDR_CRC_ER 0x04 #define CONT_EEPROM_BUSY 0x80 +// Accessory detection +#define CONT_ADDR_DETECT 0x8000 +// Rumble +#define CONT_ADDR_RUMBLE 0xC000 +// Controller Pak +// Transfer Pak +#define CONT_ADDR_GB_POWER 0x8000 // Same as the detection address, but semantically different +#define CONT_ADDR_GB_BANK 0xA000 +#define CONT_ADDR_GB_STATUS 0xB000 + +// Addresses sent to controller accessories are in blocks, not bytes +#define CONT_BLOCKS(x) ((x) / BLOCKSIZE) + +// Block addresses of the above +#define CONT_BLOCK_DETECT CONT_BLOCKS(CONT_ADDR_DETECT) +#define CONT_BLOCK_RUMBLE CONT_BLOCKS(CONT_ADDR_RUMBLE) +#define CONT_BLOCK_GB_POWER CONT_BLOCKS(CONT_ADDR_GB_POWER) +#define CONT_BLOCK_GB_BANK CONT_BLOCKS(CONT_ADDR_GB_BANK) +#define CONT_BLOCK_GB_STATUS CONT_BLOCKS(CONT_ADDR_GB_STATUS) + /* Buttons */ #define BTN_CRIGHT 0x0001 #define BTN_CLEFT 0x0002 @@ -88,6 +150,7 @@ #define BTN_CUP 0x0008 #define BTN_R 0x0010 #define BTN_L 0x0020 +#define BTN_RESET 0x0080 #define BTN_DRIGHT 0x0100 #define BTN_DLEFT 0x0200 #define BTN_DDOWN 0x0400 @@ -146,6 +209,8 @@ typedef struct { /* 0x26 */ u8 datacrc; } __OSContRamReadFormat; +#define READFORMAT(ptr) ((__OSContRamReadFormat*)(ptr)) + extern OSPifRam __osContPifRam; // extern UNK_TYPE1 D_8009CF0C; extern u8 __osContLastPoll; @@ -153,11 +218,4 @@ 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/irqmgr.h b/include/irqmgr.h index 40ed322d1..ac2c74960 100644 --- a/include/irqmgr.h +++ b/include/irqmgr.h @@ -1,9 +1,14 @@ #ifndef IRQMGR_H #define IRQMGR_H -#include "PR/ultratypes.h" #include "PR/sched.h" -#include "ultra64/message.h" +#include "os.h" +#include "ultra64.h" + +#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 +#define OS_SC_PRE_NMI_MSG 4 typedef struct IrqMgrClient { /* 0x0 */ struct IrqMgrClient* next; diff --git a/include/macros.h b/include/macros.h index 913ccac4a..9e74c40cd 100644 --- a/include/macros.h +++ b/include/macros.h @@ -47,9 +47,9 @@ #define CLOCK_TIME_MINUTE (CLOCK_TIME(0, 1)) #define DAY_LENGTH (CLOCK_TIME(24, 0)) +#define TIME_TO_HOURS_F(time) ((time) * (24.0f / 0x10000)) #define TIME_TO_MINUTES_F(time) ((time) * ((24.0f * 60.0f) / 0x10000)) // 0.021972656f #define TIME_TO_MINUTES_ALT_F(time) ((time) / (0x10000 / (24.0f * 60.0f))) - #define TIME_TO_SECONDS_F(time) ((time) * ((24.0f * 60.0f * 60.0f) / 0x10000)) #define CLOCK_TIME_F(hr, min) (((hr) * 60.0f + (min)) * (0x10000 / (24.0f * 60.0f))) @@ -60,7 +60,7 @@ #define CUR_CAPACITY(upg) CAPACITY(upg, CUR_UPG_VALUE(upg)) // To be used with `Magic_Add`, but ensures enough magic is added to fill the magic bar to capacity -#define MAGIC_FILL_TO_CAPACITY (((void)0, gSaveContext.magicFillTarget) + (gSaveContext.save.playerData.isDoubleMagicAcquired + 1) * MAGIC_NORMAL_METER) +#define MAGIC_FILL_TO_CAPACITY (((void)0, gSaveContext.magicFillTarget) + (gSaveContext.save.saveInfo.playerData.isDoubleMagicAcquired + 1) * MAGIC_NORMAL_METER) #define CONTROLLER1(gameState) (&(gameState)->input[0]) #define CONTROLLER2(gameState) (&(gameState)->input[1]) @@ -77,26 +77,6 @@ #define ALIGN64(val) (((val) + 0x3F) & ~0x3F) #define ALIGN256(val) (((val) + 0xFF) & ~0xFF) -extern GraphicsContext* __gfxCtx; - -#define WORK_DISP __gfxCtx->work.p -#define POLY_OPA_DISP __gfxCtx->polyOpa.p -#define POLY_XLU_DISP __gfxCtx->polyXlu.p -#define OVERLAY_DISP __gfxCtx->overlay.p -#define DEBUG_DISP __gfxCtx->debug.p - -// __gfxCtx shouldn't be used directly. -// Use the DISP macros defined above when writing to display buffers. -#define OPEN_DISPS(gfxCtx) \ - { \ - GraphicsContext* __gfxCtx = gfxCtx; \ - s32 __dispPad - -#define CLOSE_DISPS(gfxCtx) \ - (void)0; \ - } \ - (void)0 - /** * `x` vertex x * `y` vertex y @@ -114,23 +94,6 @@ extern GraphicsContext* __gfxCtx; #define VTX_T(x, y, z, s, t, cr, cg, cb, a) \ { { x, y, z }, 0, { s, t }, { cr, cg, cb, a }, } -#define GRAPH_ALLOC(gfxCtx, size) ((void*)((gfxCtx)->polyOpa.d = (Gfx*)((u8*)(gfxCtx)->polyOpa.d - ALIGN16(size)))) - -// Custom gbi macro -#define gDPSetTileCustom(pkt, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ - { \ - gDPPipeSync(pkt); \ - gDPTileSync(pkt); \ - gDPSetTile(pkt, fmt, siz, (((width)*siz##_TILE_BYTES) + 7) >> 3, 0, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, \ - masks, shifts); \ - gDPTileSync(pkt); \ - gDPSetTile(pkt, fmt, siz, (((width)*siz##_TILE_BYTES) + 7) >> 3, 0, G_TX_RENDERTILE, pal, cmt, maskt, shiftt, \ - cms, masks, shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC); \ - } \ - (void)0 - #define SQ(x) ((x) * (x)) #define ABS(x) ((x) >= 0 ? (x) : -(x)) #define ABS_ALT(x) ((x) < 0 ? -(x) : (x)) @@ -140,14 +103,19 @@ extern GraphicsContext* __gfxCtx; #define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x)) #define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x)) +#define RGBA16_GET_R(pixel) (((pixel) >> 11) & 0x1F) +#define RGBA16_GET_G(pixel) (((pixel) >> 6) & 0x1F) +#define RGBA16_GET_B(pixel) (((pixel) >> 1) & 0x1F) + #define ROUND(x) (s32)(((x) >= 0.0) ? ((x) + 0.5) : ((x) - 0.5)) -#define SWAP(type, a, b) \ - { \ - type _temp = (a); \ - (a) = (b); \ - (b) = _temp; \ - } +#define SWAP(type, a, b) \ + { \ + type _temp = (a); \ + (a) = (b); \ + (b) = _temp; \ + } \ + (void)0 #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)) diff --git a/include/padmgr.h b/include/padmgr.h new file mode 100644 index 000000000..674c9bc4e --- /dev/null +++ b/include/padmgr.h @@ -0,0 +1,97 @@ +#ifndef PADMGR_H +#define PADMGR_H + +#include "libc/stdbool.h" +#include "io/controller.h" +#include "irqmgr.h" + +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 enum { + /* 0 */ PADMGR_CONT_NONE, + /* 1 */ PADMGR_CONT_NORMAL, + /* 3 */ PADMGR_CONT_MOUSE = 3, + /* 4 */ PADMGR_CONT_VOICE_PLUGGED, // VRU plugged but not initialized + /* 5 */ PADMGR_CONT_VOICE, + /* -1 */ PADMGR_CONT_UNK = 0xFF +} ControllerDeviceType; + +typedef enum { + /* 0 */ CONT_PAK_NONE, + /* 1 */ CONT_PAK_RUMBLE, + /* 2 */ CONT_PAK_OTHER +} ControllerPakType; + +typedef struct { + /* 0x000 */ u8 validCtrlrsMask; + /* 0x004 */ void (*rumbleRetraceCallback)(void*); + /* 0x008 */ void* rumbleRetraceArg; + /* 0x00C */ void (*inputRetraceCallback)(void*); + /* 0x010 */ void* inputRetraceArg; + /* 0x014 */ OSContStatus padStatus[MAXCONTROLLERS]; + /* 0x024 */ OSMesg serialMsg; + /* 0x028 */ OSMesg lockMsg; + /* 0x02C */ OSMesg interruptMsgBuf[8]; + /* 0x04C */ OSMesgQueue serialLockQueue; + /* 0x064 */ OSMesgQueue lockQueue; + /* 0x07C */ OSMesgQueue interruptQueue; + /* 0x094 */ IrqMgrClient irqClient; + /* 0x09C */ IrqMgr* irqMgr; + /* 0x0A0 */ OSThread thread; + /* 0x250 */ Input inputs[MAXCONTROLLERS]; + /* 0x2B0 */ OSContPad pads[MAXCONTROLLERS]; + /* 0x2C8 */ u8 nControllers; + /* 0x2C9 */ u8 ctrlrType[MAXCONTROLLERS]; // type of controller currently connected to each port + /* 0x2CD */ u8 pakType[MAXCONTROLLERS]; // type of controller pak for each port (if applicable) + /* 0x2D1 */ u8 rumbleEnable[MAXCONTROLLERS]; // whether rumble is active for each port + /* 0x2D5 */ u8 rumbleTimer[MAXCONTROLLERS]; + /* 0x2DC */ OSPfs rumblePfs[MAXCONTROLLERS]; + /* 0x47C */ vu8 rumbleOffTimer; // amount of VI retraces to not rumble for, takes priority over rumbleOnTimer + /* 0x47D */ vu8 rumbleOnTimer; // amount of VI retraces to rumble for + /* 0x47E */ u8 isResetting; +} PadMgr; // size = 0x480 + +extern PadMgr gPadMgr; + +// Initialization + +s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status); +void PadMgr_Init(OSMesgQueue* siEvtQ, IrqMgr* irqMgr, OSId threadId, OSPri pri, void* stack); + +// Fetching inputs + +void PadMgr_GetInputNoLock(Input* inputs, s32 gameRequest); +void PadMgr_GetInput(Input* inputs, s32 gameRequest); +void PadMgr_GetInput2(Input* inputs, s32 gameRequest); + +// Callbacks + +void PadMgr_SetRumbleRetraceCallback(void (*callback)(void*), void* arg); +void PadMgr_UnsetRumbleRetraceCallback(void (*callback)(void*), void* arg); + +void PadMgr_SetInputRetraceCallback(void (*callback)(void*), void* arg); +void PadMgr_UnsetInputRetraceCallback(void (*callback)(void*), void* arg); + +// Valid controllers + +u8 PadMgr_GetValidControllersMask(void); + +// Voice queue + +OSMesgQueue* PadMgr_VoiceAcquireSerialEventQueue(void); +void PadMgr_VoiceReleaseSerialEventQueue(OSMesgQueue* serialEventQueue); + +// Rumble + +void PadMgr_RumbleStop(void); +void PadMgr_RumblePause(void); +void PadMgr_RumbleSetSingle(s32 port, s32 enable); +void PadMgr_RumbleSet(u8 enable[MAXCONTROLLERS]); +s32 PadMgr_ControllerHasRumblePak(s32 port); + +#endif diff --git a/include/regs.h b/include/regs.h index b19131748..112a00239 100644 --- a/include/regs.h +++ b/include/regs.h @@ -4,13 +4,28 @@ #ifndef REGS_H #define REGS_H +#include "ultra64.h" + #define REG_GROUPS 29 // number of REG groups, i.e. REG, SREG, OREG, etc. #define REG_PAGES 6 #define REG_PER_PAGE 16 #define REG_PER_GROUP REG_PAGES * REG_PER_PAGE -/* We probably want a better name for gGameInfo based on OoT discussions */ -#define BASE_REG(n, r) gGameInfo->data[n * REG_PER_GROUP + r] +typedef struct RegEditor { + /* 0x00 */ u8 regPage; // 0: no page selected (reg editor is not active); 1: first page; `REG_PAGES`: last page + /* 0x01 */ u8 regGroup; // Indexed from 0 to `REG_GROUPS`-1. Each group has its own character to identify it. + /* 0x02 */ u8 regCur; // Selected reg, indexed from 0 as the page start + /* 0x03 */ u8 dPadInputPrev; + /* 0x04 */ u32 inputRepeatTimer; + /* 0x08 */ UNK_TYPE1 pad_08[0xC]; + /* 0x14 */ s16 data[REG_GROUPS * REG_PER_GROUP]; // Accessed through *REG macros +} RegEditor; // size = 0x15D4 + +void Regs_Init(void); + +extern RegEditor* gRegEditor; + +#define BASE_REG(n, r) (gRegEditor->data[n * REG_PER_GROUP + r]) #define REG(r) BASE_REG(0, r) #define SREG(r) BASE_REG(1, r) @@ -42,16 +57,23 @@ #define kREG(r) BASE_REG(27, r) #define bREG(r) BASE_REG(28, r) -/* TODO: Actually confirm these, in case of miss-match it's at least a simple list to `sed` */ +/* TODO: There are still a few OoT defines here that need confirmation */ + #define R_TIME_SPEED REG(15) #define R_RUN_SPEED_LIMIT REG(45) #define R_ENABLE_ARENA_DBG SREG(0) // Same as OoT +#define R_ROOM_IMAGE_NODRAW_FLAGS SREG(25) #define R_UPDATE_RATE SREG(30) #define R_FB_FILTER_TYPE SREG(80) #define R_FB_FILTER_PRIM_COLOR(c) SREG(81 + c) #define R_FB_FILTER_A SREG(84) #define R_FB_FILTER_ENV_COLOR(c) SREG(85 + c) +#define R_PICTO_PHOTO_STATE SREG(89) +#define R_MOTION_BLUR_ALPHA SREG(90) +#define R_MOTION_BLUR_ENABLED SREG(91) +#define R_MOTION_BLUR_PRIORITY_ALPHA SREG(92) +#define R_MOTION_BLUR_PRIORITY_ENABLED SREG(93) #define R_PAUSE_BG_PRERENDER_STATE SREG(94) #define R_PLAY_FILL_SCREEN_ON MREG(64) @@ -117,6 +139,12 @@ #define R_REVERSE_FLOOR_INDEX XREG(94) #define R_MINIMAP_DISABLED XREG(95) +#define R_TRANS_FADE_FLASH_ALPHA_STEP iREG(50) // Set to a negative number to start the flash +#define R_ROOM_CULL_DEBUG_MODE iREG(86) +#define R_ROOM_CULL_NUM_ENTRIES iREG(87) +#define R_ROOM_CULL_USED_ENTRIES iREG(88) +#define R_ROOM_CULL_DEBUG_TARGET iREG(89) + #define R_B_LABEL_DD WREG(0) #define R_OW_MINIMAP_X WREG(29) #define R_OW_MINIMAP_Y WREG(30) @@ -138,4 +166,7 @@ #define R_ITEM_ICON_WIDTH(i) VREG(76 + i) #define R_ITEM_BTN_WIDTH(i) VREG(80 + i) +// Name inferred from OoT. Set to true to manually set play->csCtx.script +#define R_USE_DEBUG_CUTSCENE dREG(95) + #endif diff --git a/include/segment_symbols.h b/include/segment_symbols.h index ccb5488d1..9fc49a6cb 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -88,508 +88,15 @@ DECLARE_OVERLAY_SEGMENT(player_actor) #undef DEFINE_ACTOR_INTERNAL #undef DEFINE_ACTOR_UNSET -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Dust) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Kirakira) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Bomb2) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Blast) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_G_Spk) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_D_Fire) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Bubble) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_G_Ripple) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_G_Splash) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_G_Fire) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Lightning) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Dt_Bubble) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Hahen) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Stick) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Sibuki) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Stone1) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Hitmark) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Fhg_Flash) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_K_Fire) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Solder_Srch_Ball) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Kakera) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Ice_Piece) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_En_Ice) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Fire_Tail) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_En_Fire) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Extra) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Dead_Db) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Dead_Dd) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Dead_Ds) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Ice_Smoke) -DECLARE_OVERLAY_SEGMENT(Effect_En_Ice_Block) -DECLARE_OVERLAY_SEGMENT(fbdemo_triforce) -DECLARE_OVERLAY_SEGMENT(fbdemo_wipe1) -DECLARE_OVERLAY_SEGMENT(fbdemo_wipe3) -DECLARE_OVERLAY_SEGMENT(fbdemo_wipe4) -DECLARE_OVERLAY_SEGMENT(fbdemo_wipe5) -DECLARE_OVERLAY_SEGMENT(Effect_Ss_Sbn) +#define DEFINE_OBJECT(name, _enumValue) DECLARE_ROM_SEGMENT(name) +#define DEFINE_OBJECT_UNSET(_enumValue) +#define DEFINE_OBJECT_SIZE_ZERO(_name, _enumValue) -DECLARE_ROM_SEGMENT(gameplay_keep) -DECLARE_ROM_SEGMENT(gameplay_field_keep) -DECLARE_ROM_SEGMENT(gameplay_dangeon_keep) -DECLARE_ROM_SEGMENT(object_link_boy) -DECLARE_ROM_SEGMENT(object_link_child) -DECLARE_ROM_SEGMENT(object_link_goron) -DECLARE_ROM_SEGMENT(object_link_zora) -DECLARE_ROM_SEGMENT(object_link_nuts) -DECLARE_ROM_SEGMENT(object_mask_ki_tan) -DECLARE_ROM_SEGMENT(object_mask_rabit) -DECLARE_ROM_SEGMENT(object_mask_skj) -DECLARE_ROM_SEGMENT(object_mask_truth) -DECLARE_ROM_SEGMENT(object_mask_gibudo) -DECLARE_ROM_SEGMENT(object_mask_json) -DECLARE_ROM_SEGMENT(object_mask_kerfay) -DECLARE_ROM_SEGMENT(object_mask_bigelf) -DECLARE_ROM_SEGMENT(object_mask_kyojin) -DECLARE_ROM_SEGMENT(object_mask_romerny) -DECLARE_ROM_SEGMENT(object_mask_posthat) -DECLARE_ROM_SEGMENT(object_mask_zacho) -DECLARE_ROM_SEGMENT(object_mask_stone) -DECLARE_ROM_SEGMENT(object_mask_bree) -DECLARE_ROM_SEGMENT(object_mask_gero) -DECLARE_ROM_SEGMENT(object_mask_yofukasi) -DECLARE_ROM_SEGMENT(object_mask_meoto) -DECLARE_ROM_SEGMENT(object_mask_dancer) -DECLARE_ROM_SEGMENT(object_mask_bakuretu) -DECLARE_ROM_SEGMENT(object_mask_bu_san) -DECLARE_ROM_SEGMENT(object_mask_goron) -DECLARE_ROM_SEGMENT(object_mask_zora) -DECLARE_ROM_SEGMENT(object_mask_nuts) -DECLARE_ROM_SEGMENT(object_mask_boy) -DECLARE_ROM_SEGMENT(object_box) -DECLARE_ROM_SEGMENT(object_okuta) -DECLARE_ROM_SEGMENT(object_wallmaster) -DECLARE_ROM_SEGMENT(object_dy_obj) -DECLARE_ROM_SEGMENT(object_firefly) -DECLARE_ROM_SEGMENT(object_dodongo) -DECLARE_ROM_SEGMENT(object_niw) -DECLARE_ROM_SEGMENT(object_tite) -DECLARE_ROM_SEGMENT(object_ph) -DECLARE_ROM_SEGMENT(object_dinofos) -DECLARE_ROM_SEGMENT(object_zl1) -DECLARE_ROM_SEGMENT(object_bubble) -DECLARE_ROM_SEGMENT(object_test3) -DECLARE_ROM_SEGMENT(object_famos) -DECLARE_ROM_SEGMENT(object_st) -DECLARE_ROM_SEGMENT(object_thiefbird) -DECLARE_ROM_SEGMENT(object_bombf) -DECLARE_ROM_SEGMENT(object_am) -DECLARE_ROM_SEGMENT(object_dekubaba) -DECLARE_ROM_SEGMENT(object_warp1) -DECLARE_ROM_SEGMENT(object_b_heart) -DECLARE_ROM_SEGMENT(object_dekunuts) -DECLARE_ROM_SEGMENT(object_bb) -DECLARE_ROM_SEGMENT(object_death) -DECLARE_ROM_SEGMENT(object_hata) -DECLARE_ROM_SEGMENT(object_wood02) -DECLARE_ROM_SEGMENT(object_trap) -DECLARE_ROM_SEGMENT(object_vm) -DECLARE_ROM_SEGMENT(object_efc_star_field) -DECLARE_ROM_SEGMENT(object_rd) -DECLARE_ROM_SEGMENT(object_yukimura_obj) -DECLARE_ROM_SEGMENT(object_horse_link_child) -DECLARE_ROM_SEGMENT(object_syokudai) -DECLARE_ROM_SEGMENT(object_efc_tw) -DECLARE_ROM_SEGMENT(object_gi_key) -DECLARE_ROM_SEGMENT(object_mir_ray) -DECLARE_ROM_SEGMENT(object_ctower_rot) -DECLARE_ROM_SEGMENT(object_bdoor) -DECLARE_ROM_SEGMENT(object_sb) -DECLARE_ROM_SEGMENT(object_gi_melody) -DECLARE_ROM_SEGMENT(object_gi_heart) -DECLARE_ROM_SEGMENT(object_gi_compass) -DECLARE_ROM_SEGMENT(object_gi_bosskey) -DECLARE_ROM_SEGMENT(object_gi_nuts) -DECLARE_ROM_SEGMENT(object_gi_hearts) -DECLARE_ROM_SEGMENT(object_gi_arrowcase) -DECLARE_ROM_SEGMENT(object_gi_bombpouch) -DECLARE_ROM_SEGMENT(object_in) -DECLARE_ROM_SEGMENT(object_os_anime) -DECLARE_ROM_SEGMENT(object_gi_bottle) -DECLARE_ROM_SEGMENT(object_gi_stick) -DECLARE_ROM_SEGMENT(object_gi_map) -DECLARE_ROM_SEGMENT(object_oF1d_map) -DECLARE_ROM_SEGMENT(object_ru2) -DECLARE_ROM_SEGMENT(object_gi_magicpot) -DECLARE_ROM_SEGMENT(object_gi_bomb_1) -DECLARE_ROM_SEGMENT(object_ma2) -DECLARE_ROM_SEGMENT(object_gi_purse) -DECLARE_ROM_SEGMENT(object_rr) -DECLARE_ROM_SEGMENT(object_gi_arrow) -DECLARE_ROM_SEGMENT(object_gi_bomb_2) -DECLARE_ROM_SEGMENT(object_gi_shield_2) -DECLARE_ROM_SEGMENT(object_gi_hookshot) -DECLARE_ROM_SEGMENT(object_gi_ocarina) -DECLARE_ROM_SEGMENT(object_gi_milk) -DECLARE_ROM_SEGMENT(object_ma1) -DECLARE_ROM_SEGMENT(object_ny) -DECLARE_ROM_SEGMENT(object_fr) -DECLARE_ROM_SEGMENT(object_gi_bow) -DECLARE_ROM_SEGMENT(object_gi_glasses) -DECLARE_ROM_SEGMENT(object_gi_liquid) -DECLARE_ROM_SEGMENT(object_ani) -DECLARE_ROM_SEGMENT(object_gi_shield_3) -DECLARE_ROM_SEGMENT(object_gi_bean) -DECLARE_ROM_SEGMENT(object_gi_fish) -DECLARE_ROM_SEGMENT(object_gi_longsword) -DECLARE_ROM_SEGMENT(object_zo) -DECLARE_ROM_SEGMENT(object_umajump) -DECLARE_ROM_SEGMENT(object_mastergolon) -DECLARE_ROM_SEGMENT(object_masterzoora) -DECLARE_ROM_SEGMENT(object_aob) -DECLARE_ROM_SEGMENT(object_ik) -DECLARE_ROM_SEGMENT(object_ahg) -DECLARE_ROM_SEGMENT(object_cne) -DECLARE_ROM_SEGMENT(object_bji) -DECLARE_ROM_SEGMENT(object_bba) -DECLARE_ROM_SEGMENT(object_an1) -DECLARE_ROM_SEGMENT(object_boj) -DECLARE_ROM_SEGMENT(object_fz) -DECLARE_ROM_SEGMENT(object_bob) -DECLARE_ROM_SEGMENT(object_ge1) -DECLARE_ROM_SEGMENT(object_yabusame_point) -DECLARE_ROM_SEGMENT(object_d_hsblock) -DECLARE_ROM_SEGMENT(object_d_lift) -DECLARE_ROM_SEGMENT(object_mamenoki) -DECLARE_ROM_SEGMENT(object_goroiwa) -DECLARE_ROM_SEGMENT(object_toryo) -DECLARE_ROM_SEGMENT(object_daiku) -DECLARE_ROM_SEGMENT(object_nwc) -DECLARE_ROM_SEGMENT(object_gm) -DECLARE_ROM_SEGMENT(object_ms) -DECLARE_ROM_SEGMENT(object_hs) -DECLARE_ROM_SEGMENT(object_lightswitch) -DECLARE_ROM_SEGMENT(object_kusa) -DECLARE_ROM_SEGMENT(object_tsubo) -DECLARE_ROM_SEGMENT(object_kanban) -DECLARE_ROM_SEGMENT(object_owl) -DECLARE_ROM_SEGMENT(object_mk) -DECLARE_ROM_SEGMENT(object_fu) -DECLARE_ROM_SEGMENT(object_gi_ki_tan_mask) -DECLARE_ROM_SEGMENT(object_gi_mask18) -DECLARE_ROM_SEGMENT(object_gi_rabit_mask) -DECLARE_ROM_SEGMENT(object_gi_truth_mask) -DECLARE_ROM_SEGMENT(object_stream) -DECLARE_ROM_SEGMENT(object_mm) -DECLARE_ROM_SEGMENT(object_js) -DECLARE_ROM_SEGMENT(object_cs) -DECLARE_ROM_SEGMENT(object_gi_soldout) -DECLARE_ROM_SEGMENT(object_mag) -DECLARE_ROM_SEGMENT(object_gi_golonmask) -DECLARE_ROM_SEGMENT(object_gi_zoramask) -DECLARE_ROM_SEGMENT(object_ka) -DECLARE_ROM_SEGMENT(object_zg) -DECLARE_ROM_SEGMENT(object_gi_m_arrow) -DECLARE_ROM_SEGMENT(object_ds2) -DECLARE_ROM_SEGMENT(object_fish) -DECLARE_ROM_SEGMENT(object_gi_sutaru) -DECLARE_ROM_SEGMENT(object_ssh) -DECLARE_ROM_SEGMENT(object_bigslime) -DECLARE_ROM_SEGMENT(object_bg) -DECLARE_ROM_SEGMENT(object_bombiwa) -DECLARE_ROM_SEGMENT(object_hintnuts) -DECLARE_ROM_SEGMENT(object_rs) -DECLARE_ROM_SEGMENT(object_gla) -DECLARE_ROM_SEGMENT(object_geldb) -DECLARE_ROM_SEGMENT(object_dog) -DECLARE_ROM_SEGMENT(object_kibako2) -DECLARE_ROM_SEGMENT(object_dns) -DECLARE_ROM_SEGMENT(object_dnk) -DECLARE_ROM_SEGMENT(object_gi_insect) -DECLARE_ROM_SEGMENT(object_gi_ghost) -DECLARE_ROM_SEGMENT(object_gi_soul) -DECLARE_ROM_SEGMENT(object_f40_obj) -DECLARE_ROM_SEGMENT(object_gi_rupy) -DECLARE_ROM_SEGMENT(object_po_composer) -DECLARE_ROM_SEGMENT(object_mu) -DECLARE_ROM_SEGMENT(object_wf) -DECLARE_ROM_SEGMENT(object_skb) -DECLARE_ROM_SEGMENT(object_gs) -DECLARE_ROM_SEGMENT(object_ps) -DECLARE_ROM_SEGMENT(object_omoya_obj) -DECLARE_ROM_SEGMENT(object_crow) -DECLARE_ROM_SEGMENT(object_cow) -DECLARE_ROM_SEGMENT(object_gi_sword_1) -DECLARE_ROM_SEGMENT(object_zl4) -DECLARE_ROM_SEGMENT(object_grasshopper) -DECLARE_ROM_SEGMENT(object_boyo) -DECLARE_ROM_SEGMENT(object_fwall) -DECLARE_ROM_SEGMENT(object_jso) -DECLARE_ROM_SEGMENT(object_knight) -DECLARE_ROM_SEGMENT(object_icicle) -DECLARE_ROM_SEGMENT(object_spdweb) -DECLARE_ROM_SEGMENT(object_boss01) -DECLARE_ROM_SEGMENT(object_boss02) -DECLARE_ROM_SEGMENT(object_boss03) -DECLARE_ROM_SEGMENT(object_boss04) -DECLARE_ROM_SEGMENT(object_boss05) -DECLARE_ROM_SEGMENT(object_boss07) -DECLARE_ROM_SEGMENT(object_raf) -DECLARE_ROM_SEGMENT(object_funen) -DECLARE_ROM_SEGMENT(object_raillift) -DECLARE_ROM_SEGMENT(object_numa_obj) -DECLARE_ROM_SEGMENT(object_flowerpot) -DECLARE_ROM_SEGMENT(object_spinyroll) -DECLARE_ROM_SEGMENT(object_ice_block) -DECLARE_ROM_SEGMENT(object_keikoku_demo) -DECLARE_ROM_SEGMENT(object_slime) -DECLARE_ROM_SEGMENT(object_pr) -DECLARE_ROM_SEGMENT(object_f52_obj) -DECLARE_ROM_SEGMENT(object_f53_obj) -DECLARE_ROM_SEGMENT(object_kibako) -DECLARE_ROM_SEGMENT(object_sek) -DECLARE_ROM_SEGMENT(object_gmo) -DECLARE_ROM_SEGMENT(object_bat) -DECLARE_ROM_SEGMENT(object_sekihil) -DECLARE_ROM_SEGMENT(object_sekihig) -DECLARE_ROM_SEGMENT(object_sekihin) -DECLARE_ROM_SEGMENT(object_sekihiz) -DECLARE_ROM_SEGMENT(object_wiz) -DECLARE_ROM_SEGMENT(object_ladder) -DECLARE_ROM_SEGMENT(object_mkk) -DECLARE_ROM_SEGMENT(object_keikoku_obj) -DECLARE_ROM_SEGMENT(object_sichitai_obj) -DECLARE_ROM_SEGMENT(object_dekucity_ana_obj) -DECLARE_ROM_SEGMENT(object_rat) -DECLARE_ROM_SEGMENT(object_water_effect) -DECLARE_ROM_SEGMENT(object_dblue_object) -DECLARE_ROM_SEGMENT(object_bal) -DECLARE_ROM_SEGMENT(object_warp_uzu) -DECLARE_ROM_SEGMENT(object_driftice) -DECLARE_ROM_SEGMENT(object_fall) -DECLARE_ROM_SEGMENT(object_hanareyama_obj) -DECLARE_ROM_SEGMENT(object_crace_object) -DECLARE_ROM_SEGMENT(object_dno) -DECLARE_ROM_SEGMENT(object_obj_tokeidai) -DECLARE_ROM_SEGMENT(object_eg) -DECLARE_ROM_SEGMENT(object_tru) -DECLARE_ROM_SEGMENT(object_trt) -DECLARE_ROM_SEGMENT(object_hakugin_obj) -DECLARE_ROM_SEGMENT(object_horse_game_check) -DECLARE_ROM_SEGMENT(object_stk) -DECLARE_ROM_SEGMENT(object_mnk) -DECLARE_ROM_SEGMENT(object_gi_bottle_red) -DECLARE_ROM_SEGMENT(object_tokei_tobira) -DECLARE_ROM_SEGMENT(object_az) -DECLARE_ROM_SEGMENT(object_twig) -DECLARE_ROM_SEGMENT(object_dekucity_obj) -DECLARE_ROM_SEGMENT(object_po_fusen) -DECLARE_ROM_SEGMENT(object_racetsubo) -DECLARE_ROM_SEGMENT(object_ha) -DECLARE_ROM_SEGMENT(object_bigokuta) -DECLARE_ROM_SEGMENT(object_open_obj) -DECLARE_ROM_SEGMENT(object_fu_kaiten) -DECLARE_ROM_SEGMENT(object_fu_mato) -DECLARE_ROM_SEGMENT(object_mtoride) -DECLARE_ROM_SEGMENT(object_osn) -DECLARE_ROM_SEGMENT(object_tokei_step) -DECLARE_ROM_SEGMENT(object_lotus) -DECLARE_ROM_SEGMENT(object_tl) -DECLARE_ROM_SEGMENT(object_dkjail_obj) -DECLARE_ROM_SEGMENT(object_visiblock) -DECLARE_ROM_SEGMENT(object_tsn) -DECLARE_ROM_SEGMENT(object_ds2n) -DECLARE_ROM_SEGMENT(object_fsn) -DECLARE_ROM_SEGMENT(object_shn) -DECLARE_ROM_SEGMENT(object_bigicicle) -DECLARE_ROM_SEGMENT(object_gi_bottle_15) -DECLARE_ROM_SEGMENT(object_tk) -DECLARE_ROM_SEGMENT(object_market_obj) -DECLARE_ROM_SEGMENT(object_gi_reserve00) -DECLARE_ROM_SEGMENT(object_gi_reserve01) -DECLARE_ROM_SEGMENT(object_lightblock) -DECLARE_ROM_SEGMENT(object_takaraya_objects) -DECLARE_ROM_SEGMENT(object_wdhand) -DECLARE_ROM_SEGMENT(object_sdn) -DECLARE_ROM_SEGMENT(object_snowwd) -DECLARE_ROM_SEGMENT(object_giant) -DECLARE_ROM_SEGMENT(object_comb) -DECLARE_ROM_SEGMENT(object_hana) -DECLARE_ROM_SEGMENT(object_boss_hakugin) -DECLARE_ROM_SEGMENT(object_meganeana_obj) -DECLARE_ROM_SEGMENT(object_gi_nutsmask) -DECLARE_ROM_SEGMENT(object_stk2) -DECLARE_ROM_SEGMENT(object_spot11_obj) -DECLARE_ROM_SEGMENT(object_danpei_object) -DECLARE_ROM_SEGMENT(object_dhouse) -DECLARE_ROM_SEGMENT(object_hakaisi) -DECLARE_ROM_SEGMENT(object_po) -DECLARE_ROM_SEGMENT(object_snowman) -DECLARE_ROM_SEGMENT(object_po_sisters) -DECLARE_ROM_SEGMENT(object_pp) -DECLARE_ROM_SEGMENT(object_goronswitch) -DECLARE_ROM_SEGMENT(object_delf) -DECLARE_ROM_SEGMENT(object_botihasira) -DECLARE_ROM_SEGMENT(object_gi_bigbomb) -DECLARE_ROM_SEGMENT(object_pst) -DECLARE_ROM_SEGMENT(object_bsmask) -DECLARE_ROM_SEGMENT(object_spidertent) -DECLARE_ROM_SEGMENT(object_zoraegg) -DECLARE_ROM_SEGMENT(object_kbt) -DECLARE_ROM_SEGMENT(object_gg) -DECLARE_ROM_SEGMENT(object_maruta) -DECLARE_ROM_SEGMENT(object_ghaka) -DECLARE_ROM_SEGMENT(object_oyu) -DECLARE_ROM_SEGMENT(object_dnq) -DECLARE_ROM_SEGMENT(object_dai) -DECLARE_ROM_SEGMENT(object_kgy) -DECLARE_ROM_SEGMENT(object_fb) -DECLARE_ROM_SEGMENT(object_taisou) -DECLARE_ROM_SEGMENT(object_gk) -DECLARE_ROM_SEGMENT(object_haka_obj) -DECLARE_ROM_SEGMENT(object_dnt) -DECLARE_ROM_SEGMENT(object_yukiyama) -DECLARE_ROM_SEGMENT(object_icefloe) -DECLARE_ROM_SEGMENT(object_gi_gold_dust) -DECLARE_ROM_SEGMENT(object_gi_bottle_16) -DECLARE_ROM_SEGMENT(object_gi_bottle_22) -DECLARE_ROM_SEGMENT(object_bee) -DECLARE_ROM_SEGMENT(object_ot) -DECLARE_ROM_SEGMENT(object_utubo) -DECLARE_ROM_SEGMENT(object_dora) -DECLARE_ROM_SEGMENT(object_gi_loach) -DECLARE_ROM_SEGMENT(object_gi_seahorse) -DECLARE_ROM_SEGMENT(object_bigpo) -DECLARE_ROM_SEGMENT(object_hariko) -DECLARE_ROM_SEGMENT(object_dnj) -DECLARE_ROM_SEGMENT(object_sinkai_kabe) -DECLARE_ROM_SEGMENT(object_kin2_obj) -DECLARE_ROM_SEGMENT(object_ishi) -DECLARE_ROM_SEGMENT(object_hakugin_demo) -DECLARE_ROM_SEGMENT(object_jg) -DECLARE_ROM_SEGMENT(object_gi_sword_2) -DECLARE_ROM_SEGMENT(object_gi_sword_3) -DECLARE_ROM_SEGMENT(object_gi_sword_4) -DECLARE_ROM_SEGMENT(object_um) -DECLARE_ROM_SEGMENT(object_rb) -DECLARE_ROM_SEGMENT(object_mbar_obj) -DECLARE_ROM_SEGMENT(object_ikana_obj) -DECLARE_ROM_SEGMENT(object_kz) -DECLARE_ROM_SEGMENT(object_tokei_turret) -DECLARE_ROM_SEGMENT(object_zog) -DECLARE_ROM_SEGMENT(object_rotlift) -DECLARE_ROM_SEGMENT(object_posthouse_obj) -DECLARE_ROM_SEGMENT(object_gi_mask09) -DECLARE_ROM_SEGMENT(object_gi_mask14) -DECLARE_ROM_SEGMENT(object_gi_mask15) -DECLARE_ROM_SEGMENT(object_inibs_object) -DECLARE_ROM_SEGMENT(object_tree) -DECLARE_ROM_SEGMENT(object_kaizoku_obj) -DECLARE_ROM_SEGMENT(object_gi_reserve_b_00) -DECLARE_ROM_SEGMENT(object_gi_reserve_c_00) -DECLARE_ROM_SEGMENT(object_zob) -DECLARE_ROM_SEGMENT(object_milkbar) -DECLARE_ROM_SEGMENT(object_dmask) -DECLARE_ROM_SEGMENT(object_gi_reserve_c_01) -DECLARE_ROM_SEGMENT(object_zod) -DECLARE_ROM_SEGMENT(object_kumo30) -DECLARE_ROM_SEGMENT(object_obj_yasi) -DECLARE_ROM_SEGMENT(object_tanron1) -DECLARE_ROM_SEGMENT(object_tanron2) -DECLARE_ROM_SEGMENT(object_tanron3) -DECLARE_ROM_SEGMENT(object_gi_magicmushroom) -DECLARE_ROM_SEGMENT(object_obj_chan) -DECLARE_ROM_SEGMENT(object_gi_mask10) -DECLARE_ROM_SEGMENT(object_zos) -DECLARE_ROM_SEGMENT(object_an2) -DECLARE_ROM_SEGMENT(object_an3) -DECLARE_ROM_SEGMENT(object_f40_switch) -DECLARE_ROM_SEGMENT(object_lodmoon) -DECLARE_ROM_SEGMENT(object_tro) -DECLARE_ROM_SEGMENT(object_gi_mask12) -DECLARE_ROM_SEGMENT(object_gi_mask23) -DECLARE_ROM_SEGMENT(object_gi_bottle_21) -DECLARE_ROM_SEGMENT(object_gi_camera) -DECLARE_ROM_SEGMENT(object_kamejima) -DECLARE_ROM_SEGMENT(object_nb) -DECLARE_ROM_SEGMENT(object_harfgibud) -DECLARE_ROM_SEGMENT(object_zov) -DECLARE_ROM_SEGMENT(object_ah) -DECLARE_ROM_SEGMENT(object_hgdoor) -DECLARE_ROM_SEGMENT(object_dor01) -DECLARE_ROM_SEGMENT(object_dor02) -DECLARE_ROM_SEGMENT(object_dor03) -DECLARE_ROM_SEGMENT(object_dor04) -DECLARE_ROM_SEGMENT(object_last_obj) -DECLARE_ROM_SEGMENT(object_redead_obj) -DECLARE_ROM_SEGMENT(object_ikninside_obj) -DECLARE_ROM_SEGMENT(object_iknv_obj) -DECLARE_ROM_SEGMENT(object_pamera) -DECLARE_ROM_SEGMENT(object_hsstump) -DECLARE_ROM_SEGMENT(object_zm) -DECLARE_ROM_SEGMENT(object_al) -DECLARE_ROM_SEGMENT(object_tab) -DECLARE_ROM_SEGMENT(object_secom_obj) -DECLARE_ROM_SEGMENT(object_dt) -DECLARE_ROM_SEGMENT(object_gi_mask03) -DECLARE_ROM_SEGMENT(object_cha) -DECLARE_ROM_SEGMENT(object_obj_dinner) -DECLARE_ROM_SEGMENT(object_gi_reserve_b_01) -DECLARE_ROM_SEGMENT(object_lastday) -DECLARE_ROM_SEGMENT(object_bai) -DECLARE_ROM_SEGMENT(object_ikn_demo) -DECLARE_ROM_SEGMENT(object_gi_fieldmap) -DECLARE_ROM_SEGMENT(object_big_fwall) -DECLARE_ROM_SEGMENT(object_hunsui) -DECLARE_ROM_SEGMENT(object_uch) -DECLARE_ROM_SEGMENT(object_tanron4) -DECLARE_ROM_SEGMENT(object_tanron5) -DECLARE_ROM_SEGMENT(object_in2) -DECLARE_ROM_SEGMENT(object_yb) -DECLARE_ROM_SEGMENT(object_rz) -DECLARE_ROM_SEGMENT(object_bjt) -DECLARE_ROM_SEGMENT(object_taru) -DECLARE_ROM_SEGMENT(object_moonston) -DECLARE_ROM_SEGMENT(object_gi_schedule) -DECLARE_ROM_SEGMENT(object_gi_stonemask) -DECLARE_ROM_SEGMENT(object_zoraband) -DECLARE_ROM_SEGMENT(object_kepn_koya) -DECLARE_ROM_SEGMENT(object_obj_usiyane) -DECLARE_ROM_SEGMENT(object_gi_mask05) -DECLARE_ROM_SEGMENT(object_gi_mask11) -DECLARE_ROM_SEGMENT(object_gi_mask20) -DECLARE_ROM_SEGMENT(object_nnh) -DECLARE_ROM_SEGMENT(object_kzsaku) -DECLARE_ROM_SEGMENT(object_obj_milk_bin) -DECLARE_ROM_SEGMENT(object_random_obj) -DECLARE_ROM_SEGMENT(object_kujiya) -DECLARE_ROM_SEGMENT(object_kitan) -DECLARE_ROM_SEGMENT(object_gi_mask06) -DECLARE_ROM_SEGMENT(object_gi_mask16) -DECLARE_ROM_SEGMENT(object_astr_obj) -DECLARE_ROM_SEGMENT(object_bsb) -DECLARE_ROM_SEGMENT(object_fall2) -DECLARE_ROM_SEGMENT(object_sth) -DECLARE_ROM_SEGMENT(object_gi_mssa) -DECLARE_ROM_SEGMENT(object_smtower) -DECLARE_ROM_SEGMENT(object_gi_mask21) -DECLARE_ROM_SEGMENT(object_yado_obj) -DECLARE_ROM_SEGMENT(object_syoten) -DECLARE_ROM_SEGMENT(object_moonend) -DECLARE_ROM_SEGMENT(object_ob) -DECLARE_ROM_SEGMENT(object_gi_bottle_04) -DECLARE_ROM_SEGMENT(object_and) -DECLARE_ROM_SEGMENT(object_obj_danpeilift) -DECLARE_ROM_SEGMENT(object_drs) -DECLARE_ROM_SEGMENT(object_msmo) -DECLARE_ROM_SEGMENT(object_an4) -DECLARE_ROM_SEGMENT(object_wdor01) -DECLARE_ROM_SEGMENT(object_wdor02) -DECLARE_ROM_SEGMENT(object_wdor03) -DECLARE_ROM_SEGMENT(object_wdor04) -DECLARE_ROM_SEGMENT(object_wdor05) -DECLARE_ROM_SEGMENT(object_stk3) -DECLARE_ROM_SEGMENT(object_kinsta1_obj) -DECLARE_ROM_SEGMENT(object_kinsta2_obj) -DECLARE_ROM_SEGMENT(object_bh) -DECLARE_ROM_SEGMENT(object_gi_mask17) -DECLARE_ROM_SEGMENT(object_gi_mask22) -DECLARE_ROM_SEGMENT(object_lbfshot) -DECLARE_ROM_SEGMENT(object_fusen) -DECLARE_ROM_SEGMENT(object_ending_obj) -DECLARE_ROM_SEGMENT(object_gi_mask13) +#include "tables/object_table.h" + +#undef DEFINE_OBJECT +#undef DEFINE_OBJECT_UNSET +#undef DEFINE_OBJECT_SIZE_ZERO DECLARE_ROM_SEGMENT(scene_texture_01) DECLARE_ROM_SEGMENT(scene_texture_02) @@ -1121,4 +628,5 @@ DECLARE_ROM_SEGMENT(KAKUSIANA_room_13) DECLARE_ROM_SEGMENT(KAKUSIANA_room_14) DECLARE_ROM_SEGMENT(bump_texture_static) + #endif diff --git a/include/seqcmd.h b/include/seqcmd.h new file mode 100644 index 000000000..a7db69dad --- /dev/null +++ b/include/seqcmd.h @@ -0,0 +1,521 @@ +#ifndef SEQCMD_H +#define SEQCMD_H + +// ==== Primary commands ==== + +#define SEQCMD_OP_MASK 0xF0000000 +#define SEQCMD_ASYNC_ACTIVE 0x8000000 +#define SEQCMD_SEQPLAYER_MASK 0x7000000 +#define SEQCMD_SEQID_MASK 0xFF // Only applies to certain seqcmds + +typedef enum { + /* 0x0 */ SEQCMD_OP_PLAY_SEQUENCE, + /* 0x1 */ SEQCMD_OP_STOP_SEQUENCE, + /* 0x2 */ SEQCMD_OP_QUEUE_SEQUENCE, + /* 0x3 */ SEQCMD_OP_UNQUEUE_SEQUENCE, + /* 0x4 */ SEQCMD_OP_SET_SEQPLAYER_VOLUME, + /* 0x5 */ SEQCMD_OP_SET_SEQPLAYER_FREQ, + /* 0x6 */ SEQCMD_OP_SET_CHANNEL_VOLUME, + /* 0x7 */ SEQCMD_OP_SET_SEQPLAYER_IO, + /* 0x8 */ SEQCMD_OP_SET_CHANNEL_IO, + /* 0x9 */ SEQCMD_OP_SET_CHANNEL_IO_DISABLE_MASK, + /* 0xA */ SEQCMD_OP_SET_CHANNEL_DISABLE_MASK, + /* 0xB */ SEQCMD_OP_TEMPO_CMD, + /* 0xC */ SEQCMD_OP_SETUP_CMD, + /* 0xD */ SEQCMD_OP_SET_CHANNEL_FREQ, + /* 0xE */ SEQCMD_OP_GLOBAL_CMD, + /* 0xF */ SEQCMD_OP_RESET_AUDIO_HEAP +} SeqCmdOp; + +// ==== Secondary commands ==== + +// Subset of `SEQCMD_OP_TEMPO_CMD` +typedef enum { + /* 0x0 */ SEQCMD_SUB_OP_TEMPO_SET, + /* 0x1 */ SEQCMD_SUB_OP_TEMPO_SPEED_UP, + /* 0x2 */ SEQCMD_SUB_OP_TEMPO_SLOW_DOWN, + /* 0x3 */ SEQCMD_SUB_OP_TEMPO_SCALE, + /* 0x4 */ SEQCMD_SUB_OP_TEMPO_RESET +} SeqCmdTempoCmdOp; + +// Subset of `SEQCMD_OP_SETUP_CMD` +typedef enum { + /* 0x0 */ SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME, + /* 0x1 */ SEQCMD_SUB_OP_SETUP_SEQ_UNQUEUE, + /* 0x2 */ SEQCMD_SUB_OP_SETUP_RESTART_SEQ, + /* 0x3 */ SEQCMD_SUB_OP_SETUP_TEMPO_SCALE, + /* 0x4 */ SEQCMD_SUB_OP_SETUP_TEMPO_RESET, + /* 0x5 */ SEQCMD_SUB_OP_SETUP_PLAY_SEQ, + /* 0x6 */ SEQCMD_SUB_OP_SETUP_SET_FADE_TIMER, + /* 0x7 */ SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_IF_QUEUED, + /* 0x8 */ SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX, + /* 0x9 */ SEQCMD_SUB_OP_SETUP_SET_CHANNEL_DISABLE_MASK, + /* 0xA */ SEQCMD_SUB_OP_SETUP_SET_SEQPLAYER_FREQ, + /* 0xE */ SEQCMD_SUB_OP_SETUP_POP_PERSISTENT_CACHE = 0xE, + /* 0xF */ SEQCMD_SUB_OP_SETUP_RESET_SETUP_CMDS +} SeqCmdSetupCmdOp; + +// Subset of `SEQCMD_OP_GLOBAL_CMD` +typedef enum { + /* 0x0 */ SEQCMD_SUB_OP_GLOBAL_SET_SOUND_MODE, + /* 0x1 */ SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES, + /* 0x2 */ SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES_2 +} SeqCmdSubCmdOp; + +// ==== Audio Sequence Primary Commands ==== + +/** + * Play a sequence on a given seqPlayer + * + * @param seqPlayerIndex the index of the seqPlayer to play the sequence + * @param fadeInDuration effect will depend on seqArg. See below + * @param seqArg no effect: < 0x7F, skip ticks: = 0x7F, play after loading asynchronously: >= 0x80 (see note) + * @param seqId the id of the sequence to play, see `SeqId` + * + * @note seqArg will also be stored in gActiveSeqs.seqId, any check against that seqId must also include seqArg. + * seqArg = 0x7F will interpret the duration as the number of ticks to skip. + * seqArg >= 0x80 load the soundFont asynchronously, will only start playing once loaded. + */ +#define SEQCMD_PLAY_SEQUENCE(seqPlayerIndex, fadeInDuration, seqId) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_PLAY_SEQUENCE << 28) | ((seqPlayerIndex) << 24) | ((u32)(fadeInDuration) << 16) | \ + (u32)(seqId)) + +/** + * Stop a sequence on a given seqPlayer + * + * @param seqPlayerIndex the index of the seqPlayer to stop the sequence + * @param fadeOutDuration duration the sequence will fade out over + * + * @note the 0xFF in the command is not read from at all, but is common in all Stop SeqPlayer Commands + */ +#define SEQCMD_STOP_SEQUENCE(seqPlayerIndex, fadeOutDuration) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_STOP_SEQUENCE << 28) | 0xFF | ((u8)(seqPlayerIndex) << 24) | \ + ((fadeOutDuration) << 16)) + +/** + * Add a sequence to a queue of sequences associated with a given seqPlayer. + * If the sequence is first in queue, play the sequence + * + * @param seqPlayerIndex the index of the seqPlayer to queue the sequence + * @param fadeInDuration if the sequence is played, duration the sequence will fade in over + * @param priority priority in the queue. The highest valued priority will be queued to play first. Also used as `seqArg`. + * @param seqId the id of the sequence to play, see `SeqId` + * + * @note for the next sequence in the queue to play, the current sequence must be unqueued with the unqueue command + * @note for a priority >= 0x7F, similar effects happen as `seqArg` in the play sequence command + */ +#define SEQCMD_QUEUE_SEQUENCE(seqPlayerIndex, fadeInDuration, priority, seqId) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_QUEUE_SEQUENCE << 28) | ((u8)(seqPlayerIndex) << 24) | \ + ((u8)(fadeInDuration) << 16) | ((u8)(priority) << 8) | (u8)(seqId)) + +/** + * Remove a sequence from a queue of sequences associated with a given seqPlayer. + * If the sequence is first in queue, stop the sequence, and play the next one in queue if any + * + * @param seqPlayerIndex the index of the seqPlayer to queue the sequence + * @param fadeInDuration if the sequence is stopped, duration the sequence will fade out over, and duration the next seq will fade in over + * @param seqId the id of the sequence to remove, see `SeqId` + * + * @note for the next sequence in the queue to play, the current sequence must be unqueued with this command + */ +#define SEQCMD_UNQUEUE_SEQUENCE(seqPlayerIndex, fadeOutInDuration, seqId) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_UNQUEUE_SEQUENCE << 28) | ((u32)(seqPlayerIndex) << 24) | \ + ((u8)(fadeOutInDuration) << 16) | (u32)(seqId)) + +/** + * Set the volume of an entire sequence on a given seqPlayer. Fade to the volume over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the volume + * @param volume the target volume for the sequence. Ranged from 0-0xFF, with 0x7F mapping to 1.0f + */ +#define SEQCMD_SET_SEQPLAYER_VOLUME(seqPlayerIndex, duration, volume) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_SEQPLAYER_VOLUME << 28) | ((u32)(seqPlayerIndex) << 24) | \ + ((u32)(duration) << 16) | (volume)) + +/** + * Scale the frequency of every channel on a given seqPlayer over a specified duration. + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the frequency + * @param freqScale the scaling factor to shift the pitch. Ranged from 0-0xFFFF, with 1000 mapping to 1.0f + * + * @note 2000 will double the frequency (raise an octave), 500 will halve the frequency (lower an octave). + * Cannot be used with `SEQCMD_SET_CHANNEL_FREQ` as they will overwrite one another. + */ +#define SEQCMD_SET_SEQPLAYER_FREQ(seqPlayerIndex, duration, freqScale) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_SEQPLAYER_FREQ << 28) | (u32)((seqPlayerIndex) << 24) | \ + ((u32)((duration) << 16)) | (u16)(freqScale)) + +/** + * Scale the frequency of a specific channel on a given seqPlayer over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param duration duration to transition to the frequency + * @param freqScale the scaling factor to shift the pitch. Ranged from 0-0xFFF, with 1000 mapping to 1.0f + * + * @note a frequency of 2000 will double the frequency (raise an octave), 500 will halve the frequency (lower an + * octave). Cannot be used with `SEQCMD_SET_SEQPLAYER_FREQ` as they will overwrite one another. + */ +#define SEQCMD_SET_CHANNEL_FREQ(seqPlayerIndex, channelIndex, duration, freqScale) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_FREQ << 28) | ((u8)(seqPlayerIndex) << 24) | ((duration) << 16) | \ + ((channelIndex) << 12) | (freqScale)) + +/** + * Set the volume of a specific channel on a given seqPlayer. Fade to the volume over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param duration duration to transition to the volume + * @param volume the target volume for the sequence. Ranged from 0-0xFF, with 0x7F mapping to 1.0f + */ +#define SEQCMD_SET_CHANNEL_VOLUME(seqPlayerIndex, channelIndex, duration, volume) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_VOLUME << 28) | ((u32)(seqPlayerIndex) << 24) | \ + ((u32)(duration) << 16) | ((u32)(channelIndex) << 8) | (volume)) + +/** + * Write a value that can be read as input directly by the sequence itself. This will be set to the global + * ioPort, which can affect the entire sequence. + * + * @param seqPlayerIndex the index of the seqPlayer to write the input to + * @param ioPort the index of the array to store the input-output value + * @param ioData the value s8 that's written to the input-output array + * + * @note Each seqPlayer has 8 global ioPorts indexed 0-7. + * ioPort 0 and 1 are read-only-once, and will reset after being read by the sequence. + * ioPort 2-7 can be read multiple times. + */ +#define SEQCMD_SET_SEQPLAYER_IO(seqPlayerIndex, ioPort, ioData) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_SEQPLAYER_IO << 28) | ((u32)(seqPlayerIndex) << 24) | ((u32)(ioPort) << 16) | \ + (u32)(ioData)) + +/** + * Write a value that can be read as input directly by the sequence itself. This will be set to the channel + * ioPort, which will only affect a single channel. + * + * @param seqPlayerIndex the index of the seqPlayer to write the input to + * @param channelIndex the index of the channel to write the input to + * @param ioPort the index of the array to store the input-output value + * @param ioData the value s8 that's written to the input-output array + * + * @note Each channel has 8 channel ioPorts indexed 0-7. + * ioPort 0 and 1 are read-only-once, and will reset after being read by the sequence. + * ioPort 2-7 can be read multiple times. + */ +#define SEQCMD_SET_CHANNEL_IO(seqPlayerIndex, channelIndex, ioPort, ioData) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_IO << 28) | ((u32)(seqPlayerIndex) << 24) | ((u32)(ioPort) << 16) | \ + ((u32)(channelIndex) << 8) | (u32)(ioData)) + +/** + * Disable (or reenable) specific channels from receiving input set by `SEQCMD_SET_CHANNEL_IO` + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelMask a 16 bit mask where each bit maps to a channel. Bitflag on to disable + * + * @note using Audio_QueueCmdS8 0x06 will bypass this channelMask + */ +#define SEQCMD_SET_CHANNEL_IO_DISABLE_MASK(seqPlayerIndex, channelMask) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_IO_DISABLE_MASK << 28) | ((u8)(seqPlayerIndex) << 24) | \ + (u16)(channelMask)) + +/** + * Disable (or reenable) specific channels + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelMask a 16 bit mask where each bit maps to a channel. Bitflag on to disable + */ +#define SEQCMD_SET_CHANNEL_DISABLE_MASK(seqPlayerIndex, channelMask) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_DISABLE_MASK << 28) | ((u32)(seqPlayerIndex) << 24) | \ + (u32)(channelMask)) + +// ==== Audio Sequence Tempo Commands ==== + +/** + * Set the absolute tempo of a sequence on a given seqPlayer, fading over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the tempo + * @param tempoTarget the target tempo for the sequence + * + * @note the absolute tempo is constrained to a maximum of 300 + */ +#define SEQCMD_SET_TEMPO(seqPlayerIndex, duration, tempoTarget) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_SET << 12) | \ + ((u8)(seqPlayerIndex) << 24) | ((u8)(duration) << 16) | (u8)(tempoTarget)) + +/** + * Increase the tempo of a sequence by a relative value on a given seqPlayer over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the tempo + * @param tempoIncrease the change to add to the current tempo + * + * @note the absolute tempo is constrained to a maximum of 300 + */ +#define SEQCMD_SPEED_UP_TEMPO(seqPlayerIndex, duration, tempoIncrease) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_SPEED_UP << 12) | \ + ((u8)(seqPlayerIndex) << 24) | ((u8)(duration) << 16) | (u16)(tempoIncrease)) + +/** + * Decrease the tempo of a sequence by a relative value on a given seqPlayer over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the tempo + * @param tempoDecrease the change to subtract to the current tempo + * + * @note the absolute tempo is constrained to a maximum of 300 + */ +#define SEQCMD_SLOW_DOWN_TEMPO(seqPlayerIndex, duration, tempoDecrease) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_SLOW_DOWN << 12) | \ + ((u8)(seqPlayerIndex) << 24) | ((u8)(duration) << 16) | (u16)(tempoDecrease)) + +/** + * Scale the tempo of a sequence by a multiplicative value on a given seqPlayer over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the tempo + * @param tempoScale the scaling factor of the tempo, relative to 100 + * + * @note a tempoScale of 200 will go double-time, 50 will go half-time. + * the absolute tempo is constrained to a maximum of 300 + */ +#define SEQCMD_SCALE_TEMPO(seqPlayerIndex, duration, tempoScale) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_SCALE << 12) | ((u8)(seqPlayerIndex) << 24) | \ + ((u8)(duration) << 16) | (u16)(tempoScale)) + +/** + * Reset the tempo of a sequence to the original tempo on a given seqPlayer over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the tempo + */ +#define SEQCMD_RESET_TEMPO(seqPlayerIndex, duration) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_RESET << 12) | ((u8)(seqPlayerIndex) << 24) | \ + ((u8)(duration) << 16)) + +/** + * ==== Audio Sequence Setup Commands ==== + * + * The setup commands are designed to wait to be executed. + * Up to 8 commands can be queued per `seqPlayerIndex`. + * These commands will only execute once that `seqPlayerIndex` is finished playing and is no longer enabled. + * They will often target a different player (`targetSeqPlayerIndex`) but not always. + */ + +/** + * Setup a request to restore a volume on target seqPlayer once a setup seqPlayer is finished playing and disabled + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the volume + */ +#define SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME(setupSeqPlayerIndex, targetSeqPlayerIndex, duration) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | (u8)(duration)) + +/** + * Setup a request to unqueue a seqPlayer once that same setup seqPlayer is finished playing and disabled + * + * @param setupSeqPlayerIndex the index of the seqPlayer to unqueue once the same seqPlayer is disabled + * + * @bug this command was misimplemented and fails to unqueue. The command relies on `gActiveSeqs.seqId` for + * unqueueing, but seqId is reset before being used to unqueue. A simple fix is to unqueue based on + * `gActiveSeqs.prevSeqId` instead. + */ +#define SEQCMD_SETUP_UNQUEUE_SEQUENCE(setupSeqPlayerIndex) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_SEQ_UNQUEUE << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24)) + +/** + * Setup a request to restart and play an active sequence currently playing on a target seqPlayer + * once a setup seqPlayer is finished playing and disabled + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to restart its active sequence + */ +#define SEQCMD_SETUP_RESTART_SEQUENCE(setupSeqPlayerIndex, targetSeqPlayerIndex) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESTART_SEQ << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16)) + +/** + * Setup a request to scale the tempo of a sequence by a multiplicative value on a target seqPlayer + * once a setup seqPlayer is finished playing and disabled + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the tempo + * @param tempoScale the scaling factor of the tempo, relative to 100 + * + * @note a tempoScale of 200 will go double-time, 50 will go half-time. + * the absolute tempo is constrained to a maximum of 300 + */ +#define SEQCMD_SETUP_SCALE_TEMPO(setupSeqPlayerIndex, targetSeqPlayerIndex, duration, tempoScale) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_TEMPO_SCALE << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | \ + ((u8)(duration) << 8) | (u8)(tempoScale)) + +/** + * Setup a request to reset the tempo of a sequence to the original tempo on a target seqPlayer + * once a setup seqPlayer is finished playing and disabled + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the tempo + */ +#define SEQCMD_SETUP_RESET_TEMPO(setupSeqPlayerIndex, targetSeqPlayerIndex, duration) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_TEMPO_RESET << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | (u8)(duration)) + +/** + * Setup a request to play a sequence on a target seqPlayer once a setup seqPlayer is finished playing and disabled. + * This command is optionally paired with `SEQCMD_SETUP_SET_FADE_IN_TIMER` to set the fade in duration + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to play the sequence + * @param seqId the id of the sequence to play, see `SeqId` + */ +#define SEQCMD_SETUP_PLAY_SEQUENCE(setupSeqPlayerIndex, targetSeqPlayerIndex, seqId) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_PLAY_SEQ << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | (u16)(seqId)) + +/** + * This command is an optional command before `SEQCMD_SETUP_PLAY_SEQUENCE` to set the fade in duration + * (see cmd above) + * + * @param targetSeqPlayerIndex the index of the seqPlayer to play the sequence + * @param fadeInDuration duration the sequence will fade in over + */ +#define SEQCMD_SETUP_SET_FADE_IN_TIMER(targetSeqPlayerIndex, fadeInDuration) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_SET_FADE_TIMER << 20) | \ + ((u8)(targetSeqPlayerIndex) << 24) | ((u8)(fadeInDuration) << 8)) + +/** + * Setup a request to restore a volume on target seqPlayer once a setup seqPlayer is finished playing and disabled. + * Specifically, it will only restore volume if the number of queued requests on the setup seqPlayer matches + * the number of sequences queued + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the volume + * @param numSeqRequests the number of sequence requests queued that must match the actual number of sequence requests + */ +#define SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME_IF_QUEUED(setupSeqPlayerIndex, targetSeqPlayerIndex, duration, \ + numSeqRequests) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | \ + (SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_IF_QUEUED << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | \ + ((u8)(duration) << 8) | (u8)(numSeqRequests)) + +/** + * Setup a request to restore a volume on target seqPlayer once a setup seqPlayer is finished playing and disabled. + * Allows `scaleIndex` to be specified. + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to modify + * @param scaleIndex the scale index of a seqPlayer + * @param duration duration to transition to the volume + */ +#define SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX(setupSeqPlayerIndex, targetSeqPlayerIndex, scaleIndex, \ + duration) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | \ + (SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | \ + ((u8)(scaleIndex) << 8) | (u8)(duration)) + +/** + * Setup a request to disable (or reenable) specific channels on a target seqPlayer + * once a setup seqPlayer is finished playing and disabled. + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to modify + * @param channelMask a 16 bit mask where each bit maps to a channel. Bitflag on to disable + */ +#define SEQCMD_SETUP_SET_CHANNEL_DISABLE_MASK(setupSeqPlayerIndex, targetSeqPlayerIndex, channelMask) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_SET_CHANNEL_DISABLE_MASK << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | (u16)(channelMask)) + +/** + * Queue a request to scale the frequency of an entire sequence on a target seqPlayer + * once a setup seqPlayer is finished playing and disabled. + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the frequency + * @param freqScale the scaling factor to shift the pitch. Ranged from 0-0xFF, with 100 mapping to 1.0f + * + * @note The base value for frequency, 100, is 10 times smaller than other frequency commands. + * 200 will double the frequency (raise an octave), 50 will halve the frequency (lower an octave). + */ +#define SEQCMD_SETUP_SET_SEQPLAYER_FREQ(setupSeqPlayerIndex, targetSeqPlayerIndex, duration, freqScale) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_SET_SEQPLAYER_FREQ << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | \ + ((u8)(duration) << 8) | (u8)(freqScale)) + +/** + * Queue a request to discard audio data by popping an entry from the persistent caches on the audio heap, + * once a setup seqPlayer is finished playing and disabled. + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param tableTypeFlag All tables with the flag `(tableTypeFlag & (1 << tableType))` will be discarded. Specifically: + * `(tableTypeFlag & 1)` will discard the `SEQUENCE_TABLE` + * `(tableTypeFlag & 2)` will discard the `FONT_TABLE` + * `(tableTypeFlag & 4)` will discard the `SAMPLE_TABLE` + */ +#define SEQCMD_SETUP_POP_PERSISTENT_CACHE(setupSeqPlayerIndex, tableTypeFlag) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_POP_PERSISTENT_CACHE << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)tableTypeFlag)) + +/** + * Discard all setup command requests on a seqPlayerIndex by resetting the setup command queue + * + * @param setupSeqPlayerIndex the index of the seqPlayer to disable all setup commands + */ +#define SEQCMD_RESET_SETUP_CMDS(setupSeqPlayerIndex) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESET_SETUP_CMDS << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24)) + +/** + * ==== Audio Sequence Global Commands ==== + * + * The global commands will apply to the entire audio system and all 4 sequence players + */ + +/** + * Change the sound mode of audio + * + * @param soundMode see the `SoundMode` enum + */ +#define SEQCMD_SET_SOUND_MODE(soundMode) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_GLOBAL_CMD << 28) | (SEQCMD_SUB_OP_GLOBAL_SET_SOUND_MODE << 8) | (soundMode)) + +/** + * Disable (or reenable) new sequences from starting + * + * @param isDisabled true to disable, false to enable + * + * @note this does not disable the sfx player + */ +#define SEQCMD_DISABLE_PLAY_SEQUENCES(isDisabled) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_GLOBAL_CMD << 28) | (SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES << 8) | \ + (u16)(isDisabled)) + +#define SEQCMD_DISABLE_PLAY_SEQUENCES_2(isDisabled) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_GLOBAL_CMD << 28) | (SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES_2 << 8) | \ + (u16)(isDisabled)) + +/** + * Restart the audio heap with the specified settings + * + * @param fadeReverb bitmask for reverb indices indicating which reverbs to fade leading into audio heap reset + * @param sfxChannelLayout index for different mappings between the 7 banks and the 16 channels + * @param specId index for the audio specifications to set high-level audio parameters + * + * @note: For sfxChannelLayout, There are 4 possible layouts indexed by 0-3. + * However, only index 0 is properly implemented. Other indices lead to bugs and softlocks. + */ +#define SEQCMD_RESET_AUDIO_HEAP(fadeReverb, sfxChannelLayout, specId) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_RESET_AUDIO_HEAP << 28) | ((u8)(fadeReverb) << 16) | \ + ((u8)(sfxChannelLayout) << 8) | (u8)(specId)) + +#endif diff --git a/include/sequence.h b/include/sequence.h index 857609d4b..d8a9cd95a 100644 --- a/include/sequence.h +++ b/include/sequence.h @@ -1,8 +1,6 @@ #ifndef SEQUENCE_H #define SEQUENCE_H -#define NA_BGM_STOP 0x100000FF - #define NA_BGM_GENERAL_SFX 0x00 // General Sound Effects #define NA_BGM_AMBIENCE 0x01 // Ambient background noises #define NA_BGM_TERMINA_FIELD 0x02 // Termina Field @@ -133,12 +131,15 @@ #define NA_BGM_END_CREDITS_2 0x82 // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF +#define SEQ_FLAG_ASYNC 0x8000 + typedef enum { /* 0 */ SEQ_PLAYER_BGM_MAIN, /* 1 */ SEQ_PLAYER_FANFARE, /* 2 */ SEQ_PLAYER_SFX, /* 3 */ SEQ_PLAYER_BGM_SUB, /* 4 */ SEQ_PLAYER_AMBIENCE, + /* 5 */ SEQ_PLAYER_MAX, /* 0xFF */ SEQ_PLAYER_INVALID = 0xFF } SequencePlayerId; @@ -160,6 +161,14 @@ typedef enum { /* 0x7 */ CHANNEL_IO_PORT_7 } ChannelIOPort; +typedef enum { + /* 0 */ VOL_SCALE_INDEX_BGM_MAIN, + /* 1 */ VOL_SCALE_INDEX_FANFARE, + /* 2 */ VOL_SCALE_INDEX_SFX, + /* 3 */ VOL_SCALE_INDEX_BGM_SUB, + /* 4 */ VOL_SCALE_INDEX_MAX +} VolumeScaleIndex; // May be worth using SequencePlayerId instead + typedef enum { /* 0x0 */ AMBIENCE_CHANNEL_STREAM_0, /* 0x1 */ AMBIENCE_CHANNEL_CRITTER_0, @@ -174,7 +183,7 @@ typedef enum { /* 0xD */ AMBIENCE_CHANNEL_SOUND_MODE, /* 0xE */ AMBIENCE_CHANNEL_RAIN, /* 0xF */ AMBIENCE_CHANNEL_LIGHTNING -} AmbienceChannelIndex; // playerIndex = SEQ_PLAYER_AMBIENCE +} AmbienceChannelIndex; // seqPlayerIndex = SEQ_PLAYER_AMBIENCE typedef enum { /* 0x00 */ AMBIENCE_ID_00, @@ -198,7 +207,7 @@ typedef enum { /* 0x12 */ AMBIENCE_ID_12, /* 0x13 */ AMBIENCE_ID_13, /* 0xFF */ AMBIENCE_ID_DISABLED = 0xFF -} AmbienceId; // playerIndex = SEQ_PLAYER_AMBIENCE +} AmbienceId; // seqPlayerIndex = SEQ_PLAYER_AMBIENCE typedef enum { /* 0x00 */ AMBIENCE_STREAM_0, diff --git a/include/sfx.h b/include/sfx.h index 33c79abf4..b55fbb357 100644 --- a/include/sfx.h +++ b/include/sfx.h @@ -16,6 +16,8 @@ #define SFX_FLAG_MASK 0xC00 #define SFX_FLAG 0x800 +#define NA_SE_NONE 0 + // ------------ PLAYER ------------ #define NA_SE_PL_WALK_GROUND 0x800 diff --git a/include/slowly.h b/include/slowly.h new file mode 100644 index 000000000..b91d652d9 --- /dev/null +++ b/include/slowly.h @@ -0,0 +1,31 @@ +#ifndef SLOWLY_H +#define SLOWLY_H + +#include "ultra64.h" + +#define SLOWLY_STATUS_DONE (1 << 0) +#define SLOWLY_STATUS_STARTED (1 << 1) + +typedef void (*SlowlyCallbackZero)(void); +typedef void (*SlowlyCallbackOne)(void*); +typedef void (*SlowlyCallbackTwo)(void*, void*); + +typedef union { + SlowlyCallbackZero zero; + SlowlyCallbackOne one; + SlowlyCallbackTwo two; +} SlowlyCallback; // size = 0x4 + +typedef struct { + /* 0x000 */ OSThread thread; + /* 0x1B0 */ u8 argCount; + /* 0x1B1 */ u8 status; + /* 0x1B4 */ SlowlyCallback callback; + /* 0x1B8 */ void* arg0; + /* 0x1BC */ void* arg1; +} SlowlyMgr; // size = 0x1C0 + +void Slowly_Init(SlowlyMgr* slowly, void* stack, SlowlyCallbackTwo callback, void* arg0, void* arg1); +void Slowly_Destroy(SlowlyMgr* slowly); + +#endif diff --git a/include/stack.h b/include/stack.h new file mode 100644 index 000000000..3667862cb --- /dev/null +++ b/include/stack.h @@ -0,0 +1,12 @@ +#ifndef STACK_H +#define STACK_H + +#include "alignment.h" + +#define STACK(stack, size) \ + u64 stack[ALIGN8(size) / sizeof(u64)] + +#define STACK_TOP(stack) \ + ((u8*)(stack) + sizeof(stack)) + +#endif diff --git a/include/stackcheck.h b/include/stackcheck.h new file mode 100644 index 000000000..aeb55df28 --- /dev/null +++ b/include/stackcheck.h @@ -0,0 +1,26 @@ +#ifndef STACKCHECK_H +#define STACKCHECK_H + +#include "ultra64.h" + +typedef enum StackStatus { + /* 0 */ STACK_STATUS_OK, + /* 1 */ STACK_STATUS_WARNING, + /* 2 */ STACK_STATUS_OVERFLOW +} StackStatus; + +typedef struct StackEntry { + /* 0x00 */ struct StackEntry* next; + /* 0x04 */ struct StackEntry* prev; + /* 0x08 */ void* head; + /* 0x0C */ void* tail; + /* 0x10 */ u32 initValue; + /* 0x14 */ s32 minSpace; + /* 0x18 */ const char* name; +} StackEntry; // size = 0x1C + +void StackCheck_Init(StackEntry* entry, void* stackBottom, void* stackTop, u32 initValue, s32 minSpace, const char* name); +void StackCheck_Cleanup(StackEntry* entry); +u32 StackCheck_Check(StackEntry* entry); + +#endif diff --git a/include/tables/effect_ss_table.h b/include/tables/effect_ss_table.h new file mode 100644 index 000000000..c51847995 --- /dev/null +++ b/include/tables/effect_ss_table.h @@ -0,0 +1,48 @@ +/** + * Effect Soft Sprite Table + * + * DEFINE_EFFECT_SS should be used for normal effects soft sprites + * - Argument 0: Name of the effect (without the ovl_ part) + * - Argument 1: Enum value for this effect + * + * DEFINE_EFFECT_SS_UNSET is needed to define empty entries from the original game + */ +/* 0x00 */ DEFINE_EFFECT_SS(Effect_Ss_Dust, EFFECT_SS_DUST) +/* 0x01 */ DEFINE_EFFECT_SS(Effect_Ss_Kirakira, EFFECT_SS_KIRAKIRA) +/* 0x02 */ DEFINE_EFFECT_SS_UNSET(EFFECT_SS_UNSET_02) +/* 0x03 */ DEFINE_EFFECT_SS(Effect_Ss_Bomb2, EFFECT_SS_BOMB2) +/* 0x04 */ DEFINE_EFFECT_SS(Effect_Ss_Blast, EFFECT_SS_BLAST) +/* 0x05 */ DEFINE_EFFECT_SS(Effect_Ss_G_Spk, EFFECT_SS_G_SPK) +/* 0x06 */ DEFINE_EFFECT_SS(Effect_Ss_D_Fire, EFFECT_SS_D_FIRE) +/* 0x07 */ DEFINE_EFFECT_SS(Effect_Ss_Bubble, EFFECT_SS_BUBBLE) +/* 0x08 */ DEFINE_EFFECT_SS_UNSET(EFFECT_SS_UNSET_08) +/* 0x09 */ DEFINE_EFFECT_SS(Effect_Ss_G_Ripple, EFFECT_SS_G_RIPPLE) +/* 0x0A */ DEFINE_EFFECT_SS(Effect_Ss_G_Splash, EFFECT_SS_G_SPLASH) +/* 0x0B */ DEFINE_EFFECT_SS_UNSET(EFFECT_SS_UNSET_0B) +/* 0x0C */ DEFINE_EFFECT_SS(Effect_Ss_G_Fire, EFFECT_SS_G_FIRE) +/* 0x0D */ DEFINE_EFFECT_SS(Effect_Ss_Lightning, EFFECT_SS_LIGHTNING) +/* 0x0E */ DEFINE_EFFECT_SS(Effect_Ss_Dt_Bubble, EFFECT_SS_DT_BUBBLE) +/* 0x0F */ DEFINE_EFFECT_SS(Effect_Ss_Hahen, EFFECT_SS_HAHEN) +/* 0x10 */ DEFINE_EFFECT_SS(Effect_Ss_Stick, EFFECT_SS_STICK) +/* 0x11 */ DEFINE_EFFECT_SS(Effect_Ss_Sibuki, EFFECT_SS_SIBUKI) +/* 0x12 */ DEFINE_EFFECT_SS_UNSET(EFFECT_SS_UNSET_12) +/* 0x13 */ DEFINE_EFFECT_SS_UNSET(EFFECT_SS_UNSET_13) +/* 0x14 */ DEFINE_EFFECT_SS(Effect_Ss_Stone1, EFFECT_SS_STONE1) +/* 0x15 */ DEFINE_EFFECT_SS(Effect_Ss_Hitmark, EFFECT_SS_HITMARK) +/* 0x16 */ DEFINE_EFFECT_SS(Effect_Ss_Fhg_Flash, EFFECT_SS_FHG_FLASH) +/* 0x17 */ DEFINE_EFFECT_SS(Effect_Ss_K_Fire, EFFECT_SS_K_FIRE) +/* 0x18 */ DEFINE_EFFECT_SS(Effect_Ss_Solder_Srch_Ball, EFFECT_SS_SOLDER_SRCH_BALL) +/* 0x19 */ DEFINE_EFFECT_SS(Effect_Ss_Kakera, EFFECT_SS_KAKERA) +/* 0x1A */ DEFINE_EFFECT_SS(Effect_Ss_Ice_Piece, EFFECT_SS_ICE_PIECE) +/* 0x1B */ DEFINE_EFFECT_SS(Effect_Ss_En_Ice, EFFECT_SS_EN_ICE) +/* 0x1C */ DEFINE_EFFECT_SS(Effect_Ss_Fire_Tail, EFFECT_SS_FIRE_TAIL) +/* 0x1D */ DEFINE_EFFECT_SS(Effect_Ss_En_Fire, EFFECT_SS_EN_FIRE) +/* 0x1E */ DEFINE_EFFECT_SS(Effect_Ss_Extra, EFFECT_SS_EXTRA) +/* 0x1F */ DEFINE_EFFECT_SS_UNSET(EFFECT_SS_UNSET_1F) +/* 0x20 */ DEFINE_EFFECT_SS(Effect_Ss_Dead_Db, EFFECT_SS_DEAD_DB) +/* 0x21 */ DEFINE_EFFECT_SS(Effect_Ss_Dead_Dd, EFFECT_SS_DEAD_DD) +/* 0x22 */ DEFINE_EFFECT_SS(Effect_Ss_Dead_Ds, EFFECT_SS_DEAD_DS) +/* 0x23 */ DEFINE_EFFECT_SS_UNSET(EFFECT_SS_UNSET_23) +/* 0x24 */ DEFINE_EFFECT_SS(Effect_Ss_Ice_Smoke, EFFECT_SS_ICE_SMOKE) +/* 0x25 */ DEFINE_EFFECT_SS(Effect_En_Ice_Block, EFFECT_EN_ICE_BLOCK) +/* 0x26 */ DEFINE_EFFECT_SS(Effect_Ss_Sbn, EFFECT_SS_SBN) diff --git a/include/tables/object_table.h b/include/tables/object_table.h new file mode 100644 index 000000000..61175c118 --- /dev/null +++ b/include/tables/object_table.h @@ -0,0 +1,659 @@ +/** + * Object Table + * + * DEFINE_OBJECT should be used for normal objects + * - Argument 0: Name of the object segment in spec + * - Argument 1: Enum value for this object + * + * DEFINE_OBJECT_UNSET and DEFINE_OBJECT_SIZE_ZERO are needed to define empty entries from the original game + * + * DEFINE_OBJECT_UNSET is used to declare a placeholder enum value which maps to an entry with zeroes in `gObjectTable` + * - Argument 0: Enum value for this object + * + * DEFINE_OBJECT_SIZE_ZERO is used to declare a placeholder enum value which maps to a zero-size entry in `gObjectTable`, with no corresponding segment in the rom. + * - Argument 0: Name of the object segment in spec + * - Argument 1: Enum value for this object + */ +/* 0x000 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_0) +/* 0x001 */ DEFINE_OBJECT(gameplay_keep, GAMEPLAY_KEEP) +/* 0x002 */ DEFINE_OBJECT(gameplay_field_keep, GAMEPLAY_FIELD_KEEP) +/* 0x003 */ DEFINE_OBJECT(gameplay_dangeon_keep, GAMEPLAY_DANGEON_KEEP) +/* 0x004 */ DEFINE_OBJECT(object_nb, OBJECT_NB) +/* 0x005 */ DEFINE_OBJECT(object_okuta, OBJECT_OKUTA) +/* 0x006 */ DEFINE_OBJECT(object_crow, OBJECT_CROW) +/* 0x007 */ DEFINE_OBJECT(object_ah, OBJECT_AH) +/* 0x008 */ DEFINE_OBJECT(object_dy_obj, OBJECT_DY_OBJ) +/* 0x009 */ DEFINE_OBJECT(object_wallmaster, OBJECT_WALLMASTER) +/* 0x00A */ DEFINE_OBJECT(object_dodongo, OBJECT_DODONGO) +/* 0x00B */ DEFINE_OBJECT(object_firefly, OBJECT_FIREFLY) +/* 0x00C */ DEFINE_OBJECT(object_box, OBJECT_BOX) +/* 0x00D */ DEFINE_OBJECT(object_al, OBJECT_AL) +/* 0x00E */ DEFINE_OBJECT(object_bubble, OBJECT_BUBBLE) +/* 0x00F */ DEFINE_OBJECT(object_niw, OBJECT_NIW) +/* 0x010 */ DEFINE_OBJECT(object_link_boy, OBJECT_LINK_BOY) +/* 0x011 */ DEFINE_OBJECT(object_link_child, OBJECT_LINK_CHILD) +/* 0x012 */ DEFINE_OBJECT(object_tite, OBJECT_TITE) +/* 0x013 */ DEFINE_OBJECT(object_tab, OBJECT_TAB) +/* 0x014 */ DEFINE_OBJECT(object_ph, OBJECT_PH) +/* 0x015 */ DEFINE_OBJECT(object_and, OBJECT_AND) +/* 0x016 */ DEFINE_OBJECT(object_msmo, OBJECT_MSMO) +/* 0x017 */ DEFINE_OBJECT(object_dinofos, OBJECT_DINOFOS) +/* 0x018 */ DEFINE_OBJECT(object_drs, OBJECT_DRS) +/* 0x019 */ DEFINE_OBJECT(object_zl1, OBJECT_ZL1) +/* 0x01A */ DEFINE_OBJECT(object_an4, OBJECT_AN4) +/* 0x01B */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_1B) +/* 0x01C */ DEFINE_OBJECT(object_test3, OBJECT_TEST3) +/* 0x01D */ DEFINE_OBJECT(object_famos, OBJECT_FAMOS) +/* 0x01E */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_1E) +/* 0x01F */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_1F) +/* 0x020 */ DEFINE_OBJECT(object_st, OBJECT_ST) +/* 0x021 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_21) +/* 0x022 */ DEFINE_OBJECT(object_thiefbird, OBJECT_THIEFBIRD) +/* 0x023 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_23) +/* 0x024 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_24) +/* 0x025 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_25) +/* 0x026 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_26) +/* 0x027 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_27) +/* 0x028 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_28) +/* 0x029 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_29) +/* 0x02A */ DEFINE_OBJECT(object_bombf, OBJECT_BOMBF) +/* 0x02B */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_2B) +/* 0x02C */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_2C) +/* 0x02D */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_2D) +/* 0x02E */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_2E) +/* 0x02F */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_2F) +/* 0x030 */ DEFINE_OBJECT(object_am, OBJECT_AM) +/* 0x031 */ DEFINE_OBJECT(object_dekubaba, OBJECT_DEKUBABA) +/* 0x032 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_32) +/* 0x033 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_33) +/* 0x034 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_34) +/* 0x035 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_35) +/* 0x036 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_36) +/* 0x037 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_37) +/* 0x038 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_38) +/* 0x039 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_39) +/* 0x03A */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_3A) +/* 0x03B */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_3B) +/* 0x03C */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_3C) +/* 0x03D */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_3D) +/* 0x03E */ DEFINE_OBJECT(object_warp1, OBJECT_WARP1) +/* 0x03F */ DEFINE_OBJECT(object_b_heart, OBJECT_B_HEART) +/* 0x040 */ DEFINE_OBJECT(object_dekunuts, OBJECT_DEKUNUTS) +/* 0x041 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_41) +/* 0x042 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_42) +/* 0x043 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_43) +/* 0x044 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_44) +/* 0x045 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_45) +/* 0x046 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_46) +/* 0x047 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_47) +/* 0x048 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_48) +/* 0x049 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_49) +/* 0x04A */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_4A) +/* 0x04B */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_4B) +/* 0x04C */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_4C) +/* 0x04D */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_4D) +/* 0x04E */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_4E) +/* 0x04F */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_4F) +/* 0x050 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_50) +/* 0x051 */ DEFINE_OBJECT(object_bb, OBJECT_BB) +/* 0x052 */ DEFINE_OBJECT(object_death, OBJECT_DEATH) +/* 0x053 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_53) +/* 0x054 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_54) +/* 0x055 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_55) +/* 0x056 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_56) +/* 0x057 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_57) +/* 0x058 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_58) +/* 0x059 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_59) +/* 0x05A */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_5A) +/* 0x05B */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_5B) +/* 0x05C */ DEFINE_OBJECT(object_f40_obj, OBJECT_F40_OBJ) +/* 0x05D */ DEFINE_OBJECT(object_po_composer, OBJECT_PO_COMPOSER) +/* 0x05E */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_5E) +/* 0x05F */ DEFINE_OBJECT(object_hata, OBJECT_HATA) +/* 0x060 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_60) +/* 0x061 */ DEFINE_OBJECT(object_wood02, OBJECT_WOOD02) +/* 0x062 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_62) +/* 0x063 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_63) +/* 0x064 */ DEFINE_OBJECT(object_trap, OBJECT_TRAP) +/* 0x065 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_65) +/* 0x066 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_66) +/* 0x067 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_67) +/* 0x068 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_68) +/* 0x069 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_69) +/* 0x06A */ DEFINE_OBJECT(object_vm, OBJECT_VM) +/* 0x06B */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_6B) +/* 0x06C */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_6C) +/* 0x06D */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_6D) +/* 0x06E */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_6E) +/* 0x06F */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_6F) +/* 0x070 */ DEFINE_OBJECT(object_efc_star_field, OBJECT_EFC_STAR_FIELD) +/* 0x071 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_71) +/* 0x072 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_72) +/* 0x073 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_73) +/* 0x074 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_74) +/* 0x075 */ DEFINE_OBJECT(object_rd, OBJECT_RD) +/* 0x076 */ DEFINE_OBJECT(object_yukimura_obj, OBJECT_YUKIMURA_OBJ) +/* 0x077 */ DEFINE_OBJECT_UNSET(OBJECT_HEAVY_OBJECT) +/* 0x078 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_78) +/* 0x079 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_79) +/* 0x07A */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_7A) +/* 0x07B */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_7B) +/* 0x07C */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_7C) +/* 0x07D */ DEFINE_OBJECT(object_horse_link_child, OBJECT_HORSE_LINK_CHILD) +/* 0x07E */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_7E) +/* 0x07F */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_7F) +/* 0x080 */ DEFINE_OBJECT(object_syokudai, OBJECT_SYOKUDAI) +/* 0x081 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_81) +/* 0x082 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_82) +/* 0x083 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_83) +/* 0x084 */ DEFINE_OBJECT(object_efc_tw, OBJECT_EFC_TW) +/* 0x085 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_85) +/* 0x086 */ DEFINE_OBJECT(object_gi_key, OBJECT_GI_KEY) +/* 0x087 */ DEFINE_OBJECT(object_mir_ray, OBJECT_MIR_RAY) +/* 0x088 */ DEFINE_OBJECT(object_ctower_rot, OBJECT_CTOWER_ROT) +/* 0x089 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_89) +/* 0x08A */ DEFINE_OBJECT(object_bdoor, OBJECT_BDOOR) +/* 0x08B */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_8B) +/* 0x08C */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_8C) +/* 0x08D */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_8D) +/* 0x08E */ DEFINE_OBJECT(object_sb, OBJECT_SB) +/* 0x08F */ DEFINE_OBJECT(object_gi_melody, OBJECT_GI_MELODY) +/* 0x090 */ DEFINE_OBJECT(object_gi_heart, OBJECT_GI_HEART) +/* 0x091 */ DEFINE_OBJECT(object_gi_compass, OBJECT_GI_COMPASS) +/* 0x092 */ DEFINE_OBJECT(object_gi_bosskey, OBJECT_GI_BOSSKEY) +/* 0x093 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_93) +/* 0x094 */ DEFINE_OBJECT(object_gi_nuts, OBJECT_GI_NUTS) +/* 0x095 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_95) +/* 0x096 */ DEFINE_OBJECT(object_gi_hearts, OBJECT_GI_HEARTS) +/* 0x097 */ DEFINE_OBJECT(object_gi_arrowcase, OBJECT_GI_ARROWCASE) +/* 0x098 */ DEFINE_OBJECT(object_gi_bombpouch, OBJECT_GI_BOMBPOUCH) +/* 0x099 */ DEFINE_OBJECT(object_in, OBJECT_IN) +/* 0x09A */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_9A) +/* 0x09B */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_9B) +/* 0x09C */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_9C) +/* 0x09D */ DEFINE_OBJECT(object_os_anime, OBJECT_OS_ANIME) +/* 0x09E */ DEFINE_OBJECT(object_gi_bottle, OBJECT_GI_BOTTLE) +/* 0x09F */ DEFINE_OBJECT(object_gi_stick, OBJECT_GI_STICK) +/* 0x0A0 */ DEFINE_OBJECT(object_gi_map, OBJECT_GI_MAP) +/* 0x0A1 */ DEFINE_OBJECT(object_oF1d_map, OBJECT_OF1D_MAP) +/* 0x0A2 */ DEFINE_OBJECT(object_ru2, OBJECT_RU2) +/* 0x0A3 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_A3) +/* 0x0A4 */ DEFINE_OBJECT(object_gi_magicpot, OBJECT_GI_MAGICPOT) +/* 0x0A5 */ DEFINE_OBJECT(object_gi_bomb_1, OBJECT_GI_BOMB_1) +/* 0x0A6 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_A6) +/* 0x0A7 */ DEFINE_OBJECT(object_ma2, OBJECT_MA2) +/* 0x0A8 */ DEFINE_OBJECT(object_gi_purse, OBJECT_GI_PURSE) +/* 0x0A9 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_A9) +/* 0x0AA */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_AA) +/* 0x0AB */ DEFINE_OBJECT(object_rr, OBJECT_RR) +/* 0x0AC */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_AC) +/* 0x0AD */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_AD) +/* 0x0AE */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_AE) +/* 0x0AF */ DEFINE_OBJECT(object_gi_arrow, OBJECT_GI_ARROW) +/* 0x0B0 */ DEFINE_OBJECT(object_gi_bomb_2, OBJECT_GI_BOMB_2) +/* 0x0B1 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_B1) +/* 0x0B2 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_B2) +/* 0x0B3 */ DEFINE_OBJECT(object_gi_shield_2, OBJECT_GI_SHIELD_2) +/* 0x0B4 */ DEFINE_OBJECT(object_gi_hookshot, OBJECT_GI_HOOKSHOT) +/* 0x0B5 */ DEFINE_OBJECT(object_gi_ocarina, OBJECT_GI_OCARINA) +/* 0x0B6 */ DEFINE_OBJECT(object_gi_milk, OBJECT_GI_MILK) +/* 0x0B7 */ DEFINE_OBJECT(object_ma1, OBJECT_MA1) +/* 0x0B8 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_B8) +/* 0x0B9 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_B9) +/* 0x0BA */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_BA) +/* 0x0BB */ DEFINE_OBJECT(object_ny, OBJECT_NY) +/* 0x0BC */ DEFINE_OBJECT(object_fr, OBJECT_FR) +/* 0x0BD */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_BD) +/* 0x0BE */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_BE) +/* 0x0BF */ DEFINE_OBJECT(object_gi_bow, OBJECT_GI_BOW) +/* 0x0C0 */ DEFINE_OBJECT(object_gi_glasses, OBJECT_GI_GLASSES) +/* 0x0C1 */ DEFINE_OBJECT(object_gi_liquid, OBJECT_GI_LIQUID) +/* 0x0C2 */ DEFINE_OBJECT(object_ani, OBJECT_ANI) +/* 0x0C3 */ DEFINE_OBJECT(object_gi_shield_3, OBJECT_GI_SHIELD_3) +/* 0x0C4 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_C4) +/* 0x0C5 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_C5) +/* 0x0C6 */ DEFINE_OBJECT(object_gi_bean, OBJECT_GI_BEAN) +/* 0x0C7 */ DEFINE_OBJECT(object_gi_fish, OBJECT_GI_FISH) +/* 0x0C8 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_C8) +/* 0x0C9 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_C9) +/* 0x0CA */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_CA) +/* 0x0CB */ DEFINE_OBJECT(object_gi_longsword, OBJECT_GI_LONGSWORD) +/* 0x0CC */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_CC) +/* 0x0CD */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_CD) +/* 0x0CE */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_CE) +/* 0x0CF */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_CF) +/* 0x0D0 */ DEFINE_OBJECT(object_zo, OBJECT_ZO) +/* 0x0D1 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_D1) +/* 0x0D2 */ DEFINE_OBJECT(object_umajump, OBJECT_UMAJUMP) +/* 0x0D3 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_D3) +/* 0x0D4 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_D4) +/* 0x0D5 */ DEFINE_OBJECT(object_mastergolon, OBJECT_MASTERGOLON) +/* 0x0D6 */ DEFINE_OBJECT(object_masterzoora, OBJECT_MASTERZOORA) +/* 0x0D7 */ DEFINE_OBJECT(object_aob, OBJECT_AOB) +/* 0x0D8 */ DEFINE_OBJECT(object_ik, OBJECT_IK) +/* 0x0D9 */ DEFINE_OBJECT(object_ahg, OBJECT_AHG) +/* 0x0DA */ DEFINE_OBJECT(object_cne, OBJECT_CNE) +/* 0x0DB */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_DB) +/* 0x0DC */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_DC) +/* 0x0DD */ DEFINE_OBJECT(object_an3, OBJECT_AN3) +/* 0x0DE */ DEFINE_OBJECT(object_bji, OBJECT_BJI) +/* 0x0DF */ DEFINE_OBJECT(object_bba, OBJECT_BBA) +/* 0x0E0 */ DEFINE_OBJECT(object_an2, OBJECT_AN2) +/* 0x0E1 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_E1) +/* 0x0E2 */ DEFINE_OBJECT(object_an1, OBJECT_AN1) +/* 0x0E3 */ DEFINE_OBJECT(object_boj, OBJECT_BOJ) +/* 0x0E4 */ DEFINE_OBJECT(object_fz, OBJECT_FZ) +/* 0x0E5 */ DEFINE_OBJECT(object_bob, OBJECT_BOB) +/* 0x0E6 */ DEFINE_OBJECT(object_ge1, OBJECT_GE1) +/* 0x0E7 */ DEFINE_OBJECT(object_yabusame_point, OBJECT_YABUSAME_POINT) +/* 0x0E8 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_E8) +/* 0x0E9 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_E9) +/* 0x0EA */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_EA) +/* 0x0EB */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_EB) +/* 0x0EC */ DEFINE_OBJECT(object_d_hsblock, OBJECT_D_HSBLOCK) +/* 0x0ED */ DEFINE_OBJECT(object_d_lift, OBJECT_D_LIFT) +/* 0x0EE */ DEFINE_OBJECT(object_mamenoki, OBJECT_MAMENOKI) +/* 0x0EF */ DEFINE_OBJECT(object_goroiwa, OBJECT_GOROIWA) +/* 0x0F0 */ DEFINE_OBJECT(object_toryo, OBJECT_TORYO) +/* 0x0F1 */ DEFINE_OBJECT(object_daiku, OBJECT_DAIKU) +/* 0x0F2 */ DEFINE_OBJECT(object_nwc, OBJECT_NWC) +/* 0x0F3 */ DEFINE_OBJECT(object_gm, OBJECT_GM) +/* 0x0F4 */ DEFINE_OBJECT(object_ms, OBJECT_MS) +/* 0x0F5 */ DEFINE_OBJECT(object_hs, OBJECT_HS) +/* 0x0F6 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_F6) +/* 0x0F7 */ DEFINE_OBJECT(object_lightswitch, OBJECT_LIGHTSWITCH) +/* 0x0F8 */ DEFINE_OBJECT(object_kusa, OBJECT_KUSA) +/* 0x0F9 */ DEFINE_OBJECT(object_tsubo, OBJECT_TSUBO) +/* 0x0FA */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_FA) +/* 0x0FB */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_FB) +/* 0x0FC */ DEFINE_OBJECT(object_kanban, OBJECT_KANBAN) +/* 0x0FD */ DEFINE_OBJECT(object_owl, OBJECT_OWL) +/* 0x0FE */ DEFINE_OBJECT(object_mk, OBJECT_MK) +/* 0x0FF */ DEFINE_OBJECT(object_fu, OBJECT_FU) +/* 0x100 */ DEFINE_OBJECT(object_gi_ki_tan_mask, OBJECT_GI_KI_TAN_MASK) +/* 0x101 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_101) +/* 0x102 */ DEFINE_OBJECT(object_gi_mask18, OBJECT_GI_MASK18) +/* 0x103 */ DEFINE_OBJECT(object_gi_rabit_mask, OBJECT_GI_RABIT_MASK) +/* 0x104 */ DEFINE_OBJECT(object_gi_truth_mask, OBJECT_GI_TRUTH_MASK) +/* 0x105 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_105) +/* 0x106 */ DEFINE_OBJECT(object_stream, OBJECT_STREAM) +/* 0x107 */ DEFINE_OBJECT(object_mm, OBJECT_MM) +/* 0x108 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_108) +/* 0x109 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_109) +/* 0x10A */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_10A) +/* 0x10B */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_10B) +/* 0x10C */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_10C) +/* 0x10D */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_10D) +/* 0x10E */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_10E) +/* 0x10F */ DEFINE_OBJECT(object_js, OBJECT_JS) +/* 0x110 */ DEFINE_OBJECT(object_cs, OBJECT_CS) +/* 0x111 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_111) +/* 0x112 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_112) +/* 0x113 */ DEFINE_OBJECT(object_gi_soldout, OBJECT_GI_SOLDOUT) +/* 0x114 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_114) +/* 0x115 */ DEFINE_OBJECT(object_mag, OBJECT_MAG) +/* 0x116 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_116) +/* 0x117 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_117) +/* 0x118 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_118) +/* 0x119 */ DEFINE_OBJECT(object_gi_golonmask, OBJECT_GI_GOLONMASK) +/* 0x11A */ DEFINE_OBJECT(object_gi_zoramask, OBJECT_GI_ZORAMASK) +/* 0x11B */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_11B) +/* 0x11C */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_11C) +/* 0x11D */ DEFINE_OBJECT(object_ka, OBJECT_KA) +/* 0x11E */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_11E) +/* 0x11F */ DEFINE_OBJECT(object_zg, OBJECT_ZG) +/* 0x120 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_120) +/* 0x121 */ DEFINE_OBJECT(object_gi_m_arrow, OBJECT_GI_M_ARROW) +/* 0x122 */ DEFINE_OBJECT(object_ds2, OBJECT_DS2) +/* 0x123 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_123) +/* 0x124 */ DEFINE_OBJECT(object_fish, OBJECT_FISH) +/* 0x125 */ DEFINE_OBJECT(object_gi_sutaru, OBJECT_GI_SUTARU) +/* 0x126 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_126) +/* 0x127 */ DEFINE_OBJECT(object_ssh, OBJECT_SSH) +/* 0x128 */ DEFINE_OBJECT(object_bigslime, OBJECT_BIGSLIME) +/* 0x129 */ DEFINE_OBJECT(object_bg, OBJECT_BG) +/* 0x12A */ DEFINE_OBJECT(object_bombiwa, OBJECT_BOMBIWA) +/* 0x12B */ DEFINE_OBJECT(object_hintnuts, OBJECT_HINTNUTS) +/* 0x12C */ DEFINE_OBJECT(object_rs, OBJECT_RS) +/* 0x12D */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_12D) +/* 0x12E */ DEFINE_OBJECT(object_gla, OBJECT_GLA) +/* 0x12F */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_12F) +/* 0x130 */ DEFINE_OBJECT(object_geldb, OBJECT_GELDB) +/* 0x131 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_131) +/* 0x132 */ DEFINE_OBJECT(object_dog, OBJECT_DOG) +/* 0x133 */ DEFINE_OBJECT(object_kibako2, OBJECT_KIBAKO2) +/* 0x134 */ DEFINE_OBJECT(object_dns, OBJECT_DNS) +/* 0x135 */ DEFINE_OBJECT(object_dnk, OBJECT_DNK) +/* 0x136 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_136) +/* 0x137 */ DEFINE_OBJECT(object_gi_insect, OBJECT_GI_INSECT) +/* 0x138 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_138) +/* 0x139 */ DEFINE_OBJECT(object_gi_ghost, OBJECT_GI_GHOST) +/* 0x13A */ DEFINE_OBJECT(object_gi_soul, OBJECT_GI_SOUL) +/* 0x13B */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_13B) +/* 0x13C */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_13C) +/* 0x13D */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_13D) +/* 0x13E */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_13E) +/* 0x13F */ DEFINE_OBJECT(object_gi_rupy, OBJECT_GI_RUPY) +/* 0x140 */ DEFINE_OBJECT(object_mu, OBJECT_MU) +/* 0x141 */ DEFINE_OBJECT(object_wf, OBJECT_WF) +/* 0x142 */ DEFINE_OBJECT(object_skb, OBJECT_SKB) +/* 0x143 */ DEFINE_OBJECT(object_gs, OBJECT_GS) +/* 0x144 */ DEFINE_OBJECT(object_ps, OBJECT_PS) +/* 0x145 */ DEFINE_OBJECT(object_omoya_obj, OBJECT_OMOYA_OBJ) +/* 0x146 */ DEFINE_OBJECT(object_cow, OBJECT_COW) +/* 0x147 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_147) +/* 0x148 */ DEFINE_OBJECT(object_gi_sword_1, OBJECT_GI_SWORD_1) +/* 0x149 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_149) +/* 0x14A */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_14A) +/* 0x14B */ DEFINE_OBJECT(object_zl4, OBJECT_ZL4) +/* 0x14C */ DEFINE_OBJECT(object_link_goron, OBJECT_LINK_GORON) +/* 0x14D */ DEFINE_OBJECT(object_link_zora, OBJECT_LINK_ZORA) +/* 0x14E */ DEFINE_OBJECT(object_grasshopper, OBJECT_GRASSHOPPER) +/* 0x14F */ DEFINE_OBJECT(object_boyo, OBJECT_BOYO) +/* 0x150 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_150) +/* 0x151 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_151) +/* 0x152 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_152) +/* 0x153 */ DEFINE_OBJECT(object_fwall, OBJECT_FWALL) +/* 0x154 */ DEFINE_OBJECT(object_link_nuts, OBJECT_LINK_NUTS) +/* 0x155 */ DEFINE_OBJECT(object_jso, OBJECT_JSO) +/* 0x156 */ DEFINE_OBJECT(object_knight, OBJECT_KNIGHT) +/* 0x157 */ DEFINE_OBJECT(object_icicle, OBJECT_ICICLE) +/* 0x158 */ DEFINE_OBJECT(object_spdweb, OBJECT_SPDWEB) +/* 0x159 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_159) +/* 0x15A */ DEFINE_OBJECT(object_boss01, OBJECT_BOSS01) +/* 0x15B */ DEFINE_OBJECT(object_boss02, OBJECT_BOSS02) +/* 0x15C */ DEFINE_OBJECT(object_boss03, OBJECT_BOSS03) +/* 0x15D */ DEFINE_OBJECT(object_boss04, OBJECT_BOSS04) +/* 0x15E */ DEFINE_OBJECT(object_boss05, OBJECT_BOSS05) +/* 0x15F */ DEFINE_OBJECT_SIZE_ZERO(object_boss07, OBJECT_UNSET_15F) // unused duplicate with size 0 +/* 0x160 */ DEFINE_OBJECT(object_boss07, OBJECT_BOSS07) +/* 0x161 */ DEFINE_OBJECT(object_raf, OBJECT_RAF) +/* 0x162 */ DEFINE_OBJECT(object_funen, OBJECT_FUNEN) +/* 0x163 */ DEFINE_OBJECT(object_raillift, OBJECT_RAILLIFT) +/* 0x164 */ DEFINE_OBJECT(object_numa_obj, OBJECT_NUMA_OBJ) +/* 0x165 */ DEFINE_OBJECT(object_flowerpot, OBJECT_FLOWERPOT) +/* 0x166 */ DEFINE_OBJECT(object_spinyroll, OBJECT_SPINYROLL) +/* 0x167 */ DEFINE_OBJECT(object_ice_block, OBJECT_ICE_BLOCK) +/* 0x168 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_168) +/* 0x169 */ DEFINE_OBJECT(object_keikoku_demo, OBJECT_KEIKOKU_DEMO) +/* 0x16A */ DEFINE_OBJECT(object_slime, OBJECT_SLIME) +/* 0x16B */ DEFINE_OBJECT(object_pr, OBJECT_PR) +/* 0x16C */ DEFINE_OBJECT(object_f52_obj, OBJECT_F52_OBJ) +/* 0x16D */ DEFINE_OBJECT(object_f53_obj, OBJECT_F53_OBJ) +/* 0x16E */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_16E) +/* 0x16F */ DEFINE_OBJECT(object_kibako, OBJECT_KIBAKO) +/* 0x170 */ DEFINE_OBJECT(object_sek, OBJECT_SEK) +/* 0x171 */ DEFINE_OBJECT(object_gmo, OBJECT_GMO) +/* 0x172 */ DEFINE_OBJECT(object_bat, OBJECT_BAT) +/* 0x173 */ DEFINE_OBJECT(object_sekihil, OBJECT_SEKIHIL) +/* 0x174 */ DEFINE_OBJECT(object_sekihig, OBJECT_SEKIHIG) +/* 0x175 */ DEFINE_OBJECT(object_sekihin, OBJECT_SEKIHIN) +/* 0x176 */ DEFINE_OBJECT(object_sekihiz, OBJECT_SEKIHIZ) +/* 0x177 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_177) +/* 0x178 */ DEFINE_OBJECT(object_wiz, OBJECT_WIZ) +/* 0x179 */ DEFINE_OBJECT(object_ladder, OBJECT_LADDER) +/* 0x17A */ DEFINE_OBJECT(object_mkk, OBJECT_MKK) +/* 0x17B */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_17B) +/* 0x17C */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_17C) +/* 0x17D */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_17D) +/* 0x17E */ DEFINE_OBJECT(object_keikoku_obj, OBJECT_KEIKOKU_OBJ) +/* 0x17F */ DEFINE_OBJECT(object_sichitai_obj, OBJECT_SICHITAI_OBJ) +/* 0x180 */ DEFINE_OBJECT(object_dekucity_ana_obj, OBJECT_DEKUCITY_ANA_OBJ) +/* 0x181 */ DEFINE_OBJECT(object_rat, OBJECT_RAT) +/* 0x182 */ DEFINE_OBJECT(object_water_effect, OBJECT_WATER_EFFECT) +/* 0x183 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_183) +/* 0x184 */ DEFINE_OBJECT(object_dblue_object, OBJECT_DBLUE_OBJECT) +/* 0x185 */ DEFINE_OBJECT(object_bal, OBJECT_BAL) +/* 0x186 */ DEFINE_OBJECT(object_warp_uzu, OBJECT_WARP_UZU) +/* 0x187 */ DEFINE_OBJECT(object_driftice, OBJECT_DRIFTICE) +/* 0x188 */ DEFINE_OBJECT(object_fall, OBJECT_FALL) +/* 0x189 */ DEFINE_OBJECT(object_hanareyama_obj, OBJECT_HANAREYAMA_OBJ) +/* 0x18A */ DEFINE_OBJECT(object_crace_object, OBJECT_CRACE_OBJECT) +/* 0x18B */ DEFINE_OBJECT(object_dno, OBJECT_DNO) +/* 0x18C */ DEFINE_OBJECT(object_obj_tokeidai, OBJECT_OBJ_TOKEIDAI) +/* 0x18D */ DEFINE_OBJECT(object_eg, OBJECT_EG) +/* 0x18E */ DEFINE_OBJECT(object_tru, OBJECT_TRU) +/* 0x18F */ DEFINE_OBJECT(object_trt, OBJECT_TRT) +/* 0x190 */ DEFINE_OBJECT(object_hakugin_obj, OBJECT_HAKUGIN_OBJ) +/* 0x191 */ DEFINE_OBJECT(object_horse_game_check, OBJECT_HORSE_GAME_CHECK) +/* 0x192 */ DEFINE_OBJECT(object_stk, OBJECT_STK) +/* 0x193 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_193) +/* 0x194 */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_194) +/* 0x195 */ DEFINE_OBJECT(object_mnk, OBJECT_MNK) +/* 0x196 */ DEFINE_OBJECT(object_gi_bottle_red, OBJECT_GI_BOTTLE_RED) +/* 0x197 */ DEFINE_OBJECT(object_tokei_tobira, OBJECT_TOKEI_TOBIRA) +/* 0x198 */ DEFINE_OBJECT(object_az, OBJECT_AZ) +/* 0x199 */ DEFINE_OBJECT(object_twig, OBJECT_TWIG) +/* 0x19A */ DEFINE_OBJECT(object_dekucity_obj, OBJECT_DEKUCITY_OBJ) +/* 0x19B */ DEFINE_OBJECT(object_po_fusen, OBJECT_PO_FUSEN) +/* 0x19C */ DEFINE_OBJECT(object_racetsubo, OBJECT_RACETSUBO) +/* 0x19D */ DEFINE_OBJECT(object_ha, OBJECT_HA) +/* 0x19E */ DEFINE_OBJECT(object_bigokuta, OBJECT_BIGOKUTA) +/* 0x19F */ DEFINE_OBJECT(object_open_obj, OBJECT_OPEN_OBJ) +/* 0x1A0 */ DEFINE_OBJECT(object_fu_kaiten, OBJECT_FU_KAITEN) +/* 0x1A1 */ DEFINE_OBJECT(object_fu_mato, OBJECT_FU_MATO) +/* 0x1A2 */ DEFINE_OBJECT(object_mtoride, OBJECT_MTORIDE) +/* 0x1A3 */ DEFINE_OBJECT(object_osn, OBJECT_OSN) +/* 0x1A4 */ DEFINE_OBJECT(object_tokei_step, OBJECT_TOKEI_STEP) +/* 0x1A5 */ DEFINE_OBJECT(object_lotus, OBJECT_LOTUS) +/* 0x1A6 */ DEFINE_OBJECT(object_tl, OBJECT_TL) +/* 0x1A7 */ DEFINE_OBJECT(object_dkjail_obj, OBJECT_DKJAIL_OBJ) +/* 0x1A8 */ DEFINE_OBJECT(object_visiblock, OBJECT_VISIBLOCK) +/* 0x1A9 */ DEFINE_OBJECT(object_tsn, OBJECT_TSN) +/* 0x1AA */ DEFINE_OBJECT(object_ds2n, OBJECT_DS2N) +/* 0x1AB */ DEFINE_OBJECT(object_fsn, OBJECT_FSN) +/* 0x1AC */ DEFINE_OBJECT(object_shn, OBJECT_SHN) +/* 0x1AD */ DEFINE_OBJECT(object_bigicicle, OBJECT_BIGICICLE) +/* 0x1AE */ DEFINE_OBJECT(object_gi_bottle_15, OBJECT_GI_BOTTLE_15) +/* 0x1AF */ DEFINE_OBJECT(object_tk, OBJECT_TK) +/* 0x1B0 */ DEFINE_OBJECT(object_market_obj, OBJECT_MARKET_OBJ) +/* 0x1B1 */ DEFINE_OBJECT(object_gi_reserve00, OBJECT_GI_RESERVE00) +/* 0x1B2 */ DEFINE_OBJECT(object_gi_reserve01, OBJECT_GI_RESERVE01) +/* 0x1B3 */ DEFINE_OBJECT(object_lightblock, OBJECT_LIGHTBLOCK) +/* 0x1B4 */ DEFINE_OBJECT(object_takaraya_objects, OBJECT_TAKARAYA_OBJECTS) +/* 0x1B5 */ DEFINE_OBJECT(object_wdhand, OBJECT_WDHAND) +/* 0x1B6 */ DEFINE_OBJECT(object_sdn, OBJECT_SDN) +/* 0x1B7 */ DEFINE_OBJECT(object_snowwd, OBJECT_SNOWWD) +/* 0x1B8 */ DEFINE_OBJECT(object_giant, OBJECT_GIANT) +/* 0x1B9 */ DEFINE_OBJECT(object_comb, OBJECT_COMB) +/* 0x1BA */ DEFINE_OBJECT(object_hana, OBJECT_HANA) +/* 0x1BB */ DEFINE_OBJECT(object_boss_hakugin, OBJECT_BOSS_HAKUGIN) +/* 0x1BC */ DEFINE_OBJECT(object_meganeana_obj, OBJECT_MEGANEANA_OBJ) +/* 0x1BD */ DEFINE_OBJECT(object_gi_nutsmask, OBJECT_GI_NUTSMASK) +/* 0x1BE */ DEFINE_OBJECT(object_stk2, OBJECT_STK2) +/* 0x1BF */ DEFINE_OBJECT(object_spot11_obj, OBJECT_SPOT11_OBJ) +/* 0x1C0 */ DEFINE_OBJECT(object_danpei_object, OBJECT_DANPEI_OBJECT) +/* 0x1C1 */ DEFINE_OBJECT(object_dhouse, OBJECT_DHOUSE) +/* 0x1C2 */ DEFINE_OBJECT(object_hakaisi, OBJECT_HAKAISI) +/* 0x1C3 */ DEFINE_OBJECT(object_po, OBJECT_PO) +/* 0x1C4 */ DEFINE_OBJECT(object_snowman, OBJECT_SNOWMAN) +/* 0x1C5 */ DEFINE_OBJECT(object_po_sisters, OBJECT_PO_SISTERS) +/* 0x1C6 */ DEFINE_OBJECT(object_pp, OBJECT_PP) +/* 0x1C7 */ DEFINE_OBJECT(object_goronswitch, OBJECT_GORONSWITCH) +/* 0x1C8 */ DEFINE_OBJECT(object_delf, OBJECT_DELF) +/* 0x1C9 */ DEFINE_OBJECT(object_botihasira, OBJECT_BOTIHASIRA) +/* 0x1CA */ DEFINE_OBJECT(object_gi_bigbomb, OBJECT_GI_BIGBOMB) +/* 0x1CB */ DEFINE_OBJECT(object_pst, OBJECT_PST) +/* 0x1CC */ DEFINE_OBJECT(object_bsmask, OBJECT_BSMASK) +/* 0x1CD */ DEFINE_OBJECT(object_spidertent, OBJECT_SPIDERTENT) +/* 0x1CE */ DEFINE_OBJECT(object_zoraegg, OBJECT_ZORAEGG) +/* 0x1CF */ DEFINE_OBJECT(object_kbt, OBJECT_KBT) +/* 0x1D0 */ DEFINE_OBJECT(object_gg, OBJECT_GG) +/* 0x1D1 */ DEFINE_OBJECT(object_maruta, OBJECT_MARUTA) +/* 0x1D2 */ DEFINE_OBJECT(object_ghaka, OBJECT_GHAKA) +/* 0x1D3 */ DEFINE_OBJECT(object_oyu, OBJECT_OYU) +/* 0x1D4 */ DEFINE_OBJECT(object_dnq, OBJECT_DNQ) +/* 0x1D5 */ DEFINE_OBJECT(object_dai, OBJECT_DAI) +/* 0x1D6 */ DEFINE_OBJECT(object_kgy, OBJECT_KGY) +/* 0x1D7 */ DEFINE_OBJECT(object_fb, OBJECT_FB) +/* 0x1D8 */ DEFINE_OBJECT(object_taisou, OBJECT_TAISOU) +/* 0x1D9 */ DEFINE_OBJECT(object_mask_bu_san, OBJECT_MASK_BU_SAN) +/* 0x1DA */ DEFINE_OBJECT(object_mask_ki_tan, OBJECT_MASK_KI_TAN) +/* 0x1DB */ DEFINE_OBJECT(object_mask_rabit, OBJECT_MASK_RABIT) +/* 0x1DC */ DEFINE_OBJECT(object_mask_skj, OBJECT_MASK_SKJ) +/* 0x1DD */ DEFINE_OBJECT(object_mask_bakuretu, OBJECT_MASK_BAKURETU) +/* 0x1DE */ DEFINE_OBJECT(object_mask_truth, OBJECT_MASK_TRUTH) +/* 0x1DF */ DEFINE_OBJECT(object_gk, OBJECT_GK) +/* 0x1E0 */ DEFINE_OBJECT(object_haka_obj, OBJECT_HAKA_OBJ) +/* 0x1E1 */ DEFINE_OBJECT(object_mask_goron, OBJECT_MASK_GORON) +/* 0x1E2 */ DEFINE_OBJECT(object_mask_zora, OBJECT_MASK_ZORA) +/* 0x1E3 */ DEFINE_OBJECT(object_mask_nuts, OBJECT_MASK_NUTS) +/* 0x1E4 */ DEFINE_OBJECT(object_mask_boy, OBJECT_MASK_BOY) +/* 0x1E5 */ DEFINE_OBJECT(object_dnt, OBJECT_DNT) +/* 0x1E6 */ DEFINE_OBJECT(object_yukiyama, OBJECT_YUKIYAMA) +/* 0x1E7 */ DEFINE_OBJECT(object_icefloe, OBJECT_ICEFLOE) +/* 0x1E8 */ DEFINE_OBJECT(object_gi_gold_dust, OBJECT_GI_GOLD_DUST) +/* 0x1E9 */ DEFINE_OBJECT(object_gi_bottle_16, OBJECT_GI_BOTTLE_16) +/* 0x1EA */ DEFINE_OBJECT(object_gi_bottle_22, OBJECT_GI_BOTTLE_22) +/* 0x1EB */ DEFINE_OBJECT(object_bee, OBJECT_BEE) +/* 0x1EC */ DEFINE_OBJECT(object_ot, OBJECT_OT) +/* 0x1ED */ DEFINE_OBJECT(object_utubo, OBJECT_UTUBO) +/* 0x1EE */ DEFINE_OBJECT(object_dora, OBJECT_DORA) +/* 0x1EF */ DEFINE_OBJECT(object_gi_loach, OBJECT_GI_LOACH) +/* 0x1F0 */ DEFINE_OBJECT(object_gi_seahorse, OBJECT_GI_SEAHORSE) +/* 0x1F1 */ DEFINE_OBJECT(object_bigpo, OBJECT_BIGPO) +/* 0x1F2 */ DEFINE_OBJECT(object_hariko, OBJECT_HARIKO) +/* 0x1F3 */ DEFINE_OBJECT(object_dnj, OBJECT_DNJ) +/* 0x1F4 */ DEFINE_OBJECT(object_sinkai_kabe, OBJECT_SINKAI_KABE) +/* 0x1F5 */ DEFINE_OBJECT(object_kin2_obj, OBJECT_KIN2_OBJ) +/* 0x1F6 */ DEFINE_OBJECT(object_ishi, OBJECT_ISHI) +/* 0x1F7 */ DEFINE_OBJECT(object_hakugin_demo, OBJECT_HAKUGIN_DEMO) +/* 0x1F8 */ DEFINE_OBJECT(object_jg, OBJECT_JG) +/* 0x1F9 */ DEFINE_OBJECT(object_gi_sword_2, OBJECT_GI_SWORD_2) +/* 0x1FA */ DEFINE_OBJECT(object_gi_sword_3, OBJECT_GI_SWORD_3) +/* 0x1FB */ DEFINE_OBJECT(object_gi_sword_4, OBJECT_GI_SWORD_4) +/* 0x1FC */ DEFINE_OBJECT(object_um, OBJECT_UM) +/* 0x1FD */ DEFINE_OBJECT(object_mask_gibudo, OBJECT_MASK_GIBUDO) +/* 0x1FE */ DEFINE_OBJECT(object_mask_json, OBJECT_MASK_JSON) +/* 0x1FF */ DEFINE_OBJECT(object_mask_kerfay, OBJECT_MASK_KERFAY) +/* 0x200 */ DEFINE_OBJECT(object_mask_bigelf, OBJECT_MASK_BIGELF) +/* 0x201 */ DEFINE_OBJECT(object_rb, OBJECT_RB) +/* 0x202 */ DEFINE_OBJECT(object_mbar_obj, OBJECT_MBAR_OBJ) +/* 0x203 */ DEFINE_OBJECT(object_ikana_obj, OBJECT_IKANA_OBJ) +/* 0x204 */ DEFINE_OBJECT(object_kz, OBJECT_KZ) +/* 0x205 */ DEFINE_OBJECT(object_tokei_turret, OBJECT_TOKEI_TURRET) +/* 0x206 */ DEFINE_OBJECT(object_zog, OBJECT_ZOG) +/* 0x207 */ DEFINE_OBJECT(object_rotlift, OBJECT_ROTLIFT) +/* 0x208 */ DEFINE_OBJECT(object_posthouse_obj, OBJECT_POSTHOUSE_OBJ) +/* 0x209 */ DEFINE_OBJECT(object_gi_mask09, OBJECT_GI_MASK09) +/* 0x20A */ DEFINE_OBJECT(object_gi_mask14, OBJECT_GI_MASK14) +/* 0x20B */ DEFINE_OBJECT(object_gi_mask15, OBJECT_GI_MASK15) +/* 0x20C */ DEFINE_OBJECT(object_inibs_object, OBJECT_INIBS_OBJECT) +/* 0x20D */ DEFINE_OBJECT(object_tree, OBJECT_TREE) +/* 0x20E */ DEFINE_OBJECT(object_kaizoku_obj, OBJECT_KAIZOKU_OBJ) +/* 0x20F */ DEFINE_OBJECT(object_gi_reserve_b_00, OBJECT_GI_RESERVE_B_00) +/* 0x210 */ DEFINE_OBJECT(object_gi_reserve_c_00, OBJECT_GI_RESERVE_C_00) +/* 0x211 */ DEFINE_OBJECT(object_zob, OBJECT_ZOB) +/* 0x212 */ DEFINE_OBJECT(object_milkbar, OBJECT_MILKBAR) +/* 0x213 */ DEFINE_OBJECT(object_dmask, OBJECT_DMASK) +/* 0x214 */ DEFINE_OBJECT(object_mask_kyojin, OBJECT_MASK_KYOJIN) +/* 0x215 */ DEFINE_OBJECT(object_gi_reserve_c_01, OBJECT_GI_RESERVE_C_01) +/* 0x216 */ DEFINE_OBJECT(object_zod, OBJECT_ZOD) +/* 0x217 */ DEFINE_OBJECT(object_kumo30, OBJECT_KUMO30) +/* 0x218 */ DEFINE_OBJECT(object_obj_yasi, OBJECT_OBJ_YASI) +/* 0x219 */ DEFINE_OBJECT(object_mask_romerny, OBJECT_MASK_ROMERNY) +/* 0x21A */ DEFINE_OBJECT(object_tanron1, OBJECT_TANRON1) +/* 0x21B */ DEFINE_OBJECT(object_tanron2, OBJECT_TANRON2) +/* 0x21C */ DEFINE_OBJECT(object_tanron3, OBJECT_TANRON3) +/* 0x21D */ DEFINE_OBJECT(object_gi_magicmushroom, OBJECT_GI_MAGICMUSHROOM) +/* 0x21E */ DEFINE_OBJECT(object_obj_chan, OBJECT_OBJ_CHAN) +/* 0x21F */ DEFINE_OBJECT(object_gi_mask10, OBJECT_GI_MASK10) +/* 0x220 */ DEFINE_OBJECT(object_zos, OBJECT_ZOS) +/* 0x221 */ DEFINE_OBJECT(object_mask_posthat, OBJECT_MASK_POSTHAT) +/* 0x222 */ DEFINE_OBJECT(object_f40_switch, OBJECT_F40_SWITCH) +/* 0x223 */ DEFINE_OBJECT(object_lodmoon, OBJECT_LODMOON) +/* 0x224 */ DEFINE_OBJECT(object_tro, OBJECT_TRO) +/* 0x225 */ DEFINE_OBJECT(object_gi_mask12, OBJECT_GI_MASK12) +/* 0x226 */ DEFINE_OBJECT(object_gi_mask23, OBJECT_GI_MASK23) +/* 0x227 */ DEFINE_OBJECT(object_gi_bottle_21, OBJECT_GI_BOTTLE_21) +/* 0x228 */ DEFINE_OBJECT(object_gi_camera, OBJECT_GI_CAMERA) +/* 0x229 */ DEFINE_OBJECT(object_kamejima, OBJECT_KAMEJIMA) +/* 0x22A */ DEFINE_OBJECT(object_harfgibud, OBJECT_HARFGIBUD) +/* 0x22B */ DEFINE_OBJECT(object_zov, OBJECT_ZOV) +/* 0x22C */ DEFINE_OBJECT(object_hgdoor, OBJECT_HGDOOR) +/* 0x22D */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_22D) +/* 0x22E */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_22E) +/* 0x22F */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_22F) +/* 0x230 */ DEFINE_OBJECT(object_dor01, OBJECT_DOR01) +/* 0x231 */ DEFINE_OBJECT(object_dor02, OBJECT_DOR02) +/* 0x232 */ DEFINE_OBJECT(object_dor03, OBJECT_DOR03) +/* 0x233 */ DEFINE_OBJECT(object_dor04, OBJECT_DOR04) +/* 0x234 */ DEFINE_OBJECT(object_last_obj, OBJECT_LAST_OBJ) +/* 0x235 */ DEFINE_OBJECT(object_redead_obj, OBJECT_REDEAD_OBJ) +/* 0x236 */ DEFINE_OBJECT(object_ikninside_obj, OBJECT_IKNINSIDE_OBJ) +/* 0x237 */ DEFINE_OBJECT(object_iknv_obj, OBJECT_IKNV_OBJ) +/* 0x238 */ DEFINE_OBJECT(object_pamera, OBJECT_PAMERA) +/* 0x239 */ DEFINE_OBJECT(object_hsstump, OBJECT_HSSTUMP) +/* 0x23A */ DEFINE_OBJECT(object_zm, OBJECT_ZM) +/* 0x23B */ DEFINE_OBJECT(object_big_fwall, OBJECT_BIG_FWALL) +/* 0x23C */ DEFINE_OBJECT(object_secom_obj, OBJECT_SECOM_OBJ) +/* 0x23D */ DEFINE_OBJECT(object_hunsui, OBJECT_HUNSUI) +/* 0x23E */ DEFINE_OBJECT(object_uch, OBJECT_UCH) +/* 0x23F */ DEFINE_OBJECT(object_tanron4, OBJECT_TANRON4) +/* 0x240 */ DEFINE_OBJECT(object_tanron5, OBJECT_TANRON5) +/* 0x241 */ DEFINE_OBJECT(object_dt, OBJECT_DT) +/* 0x242 */ DEFINE_OBJECT(object_gi_mask03, OBJECT_GI_MASK03) +/* 0x243 */ DEFINE_OBJECT(object_cha, OBJECT_CHA) +/* 0x244 */ DEFINE_OBJECT(object_obj_dinner, OBJECT_OBJ_DINNER) +/* 0x245 */ DEFINE_OBJECT(object_gi_reserve_b_01, OBJECT_GI_RESERVE_B_01) +/* 0x246 */ DEFINE_OBJECT(object_lastday, OBJECT_LASTDAY) +/* 0x247 */ DEFINE_OBJECT(object_bai, OBJECT_BAI) +/* 0x248 */ DEFINE_OBJECT(object_in2, OBJECT_IN2) +/* 0x249 */ DEFINE_OBJECT(object_ikn_demo, OBJECT_IKN_DEMO) +/* 0x24A */ DEFINE_OBJECT(object_yb, OBJECT_YB) +/* 0x24B */ DEFINE_OBJECT(object_rz, OBJECT_RZ) +/* 0x24C */ DEFINE_OBJECT(object_mask_zacho, OBJECT_MASK_ZACHO) +/* 0x24D */ DEFINE_OBJECT(object_gi_fieldmap, OBJECT_GI_FIELDMAP) +/* 0x24E */ DEFINE_OBJECT(object_mask_stone, OBJECT_MASK_STONE) +/* 0x24F */ DEFINE_OBJECT(object_bjt, OBJECT_BJT) +/* 0x250 */ DEFINE_OBJECT(object_taru, OBJECT_TARU) +/* 0x251 */ DEFINE_OBJECT(object_moonston, OBJECT_MOONSTON) +/* 0x252 */ DEFINE_OBJECT(object_mask_bree, OBJECT_MASK_BREE) +/* 0x253 */ DEFINE_OBJECT(object_gi_schedule, OBJECT_GI_SCHEDULE) +/* 0x254 */ DEFINE_OBJECT(object_gi_stonemask, OBJECT_GI_STONEMASK) +/* 0x255 */ DEFINE_OBJECT(object_zoraband, OBJECT_ZORABAND) +/* 0x256 */ DEFINE_OBJECT(object_kepn_koya, OBJECT_KEPN_KOYA) +/* 0x257 */ DEFINE_OBJECT(object_obj_usiyane, OBJECT_OBJ_USIYANE) +/* 0x258 */ DEFINE_OBJECT(object_gi_mask05, OBJECT_GI_MASK05) +/* 0x259 */ DEFINE_OBJECT(object_gi_mask11, OBJECT_GI_MASK11) +/* 0x25A */ DEFINE_OBJECT(object_gi_mask20, OBJECT_GI_MASK20) +/* 0x25B */ DEFINE_OBJECT(object_nnh, OBJECT_NNH) +/* 0x25C */ DEFINE_OBJECT(object_mask_gero, OBJECT_MASK_GERO) +/* 0x25D */ DEFINE_OBJECT(object_mask_yofukasi, OBJECT_MASK_YOFUKASI) +/* 0x25E */ DEFINE_OBJECT(object_mask_meoto, OBJECT_MASK_MEOTO) +/* 0x25F */ DEFINE_OBJECT(object_mask_dancer, OBJECT_MASK_DANCER) +/* 0x260 */ DEFINE_OBJECT(object_kzsaku, OBJECT_KZSAKU) +/* 0x261 */ DEFINE_OBJECT(object_obj_milk_bin, OBJECT_OBJ_MILK_BIN) +/* 0x262 */ DEFINE_OBJECT(object_random_obj, OBJECT_RANDOM_OBJ) +/* 0x263 */ DEFINE_OBJECT(object_kujiya, OBJECT_KUJIYA) +/* 0x264 */ DEFINE_OBJECT(object_kitan, OBJECT_KITAN) +/* 0x265 */ DEFINE_OBJECT(object_gi_mask06, OBJECT_GI_MASK06) +/* 0x266 */ DEFINE_OBJECT(object_gi_mask16, OBJECT_GI_MASK16) +/* 0x267 */ DEFINE_OBJECT(object_astr_obj, OBJECT_ASTR_OBJ) +/* 0x268 */ DEFINE_OBJECT(object_bsb, OBJECT_BSB) +/* 0x269 */ DEFINE_OBJECT(object_fall2, OBJECT_FALL2) +/* 0x26A */ DEFINE_OBJECT(object_sth, OBJECT_STH) +/* 0x26B */ DEFINE_OBJECT(object_gi_mssa, OBJECT_GI_MSSA) +/* 0x26C */ DEFINE_OBJECT(object_smtower, OBJECT_SMTOWER) +/* 0x26D */ DEFINE_OBJECT(object_gi_mask21, OBJECT_GI_MASK21) +/* 0x26E */ DEFINE_OBJECT(object_yado_obj, OBJECT_YADO_OBJ) +/* 0x26F */ DEFINE_OBJECT(object_syoten, OBJECT_SYOTEN) +/* 0x270 */ DEFINE_OBJECT(object_moonend, OBJECT_MOONEND) +/* 0x271 */ DEFINE_OBJECT(object_ob, OBJECT_OB) +/* 0x272 */ DEFINE_OBJECT(object_gi_bottle_04, OBJECT_GI_BOTTLE_04) +/* 0x273 */ DEFINE_OBJECT(object_obj_danpeilift, OBJECT_OBJ_DANPEILIFT) +/* 0x274 */ DEFINE_OBJECT(object_wdor01, OBJECT_WDOR01) +/* 0x275 */ DEFINE_OBJECT(object_wdor02, OBJECT_WDOR02) +/* 0x276 */ DEFINE_OBJECT(object_wdor03, OBJECT_WDOR03) +/* 0x277 */ DEFINE_OBJECT(object_stk3, OBJECT_STK3) +/* 0x278 */ DEFINE_OBJECT(object_kinsta1_obj, OBJECT_KINSTA1_OBJ) +/* 0x279 */ DEFINE_OBJECT(object_kinsta2_obj, OBJECT_KINSTA2_OBJ) +/* 0x27A */ DEFINE_OBJECT(object_bh, OBJECT_BH) +/* 0x27B */ DEFINE_OBJECT(object_wdor04, OBJECT_WDOR04) +/* 0x27C */ DEFINE_OBJECT(object_wdor05, OBJECT_WDOR05) +/* 0x27D */ DEFINE_OBJECT(object_gi_mask17, OBJECT_GI_MASK17) +/* 0x27E */ DEFINE_OBJECT(object_gi_mask22, OBJECT_GI_MASK22) +/* 0x27F */ DEFINE_OBJECT(object_lbfshot, OBJECT_LBFSHOT) +/* 0x280 */ DEFINE_OBJECT(object_fusen, OBJECT_FUSEN) +/* 0x281 */ DEFINE_OBJECT(object_ending_obj, OBJECT_ENDING_OBJ) +/* 0x282 */ DEFINE_OBJECT(object_gi_mask13, OBJECT_GI_MASK13) diff --git a/include/tables/transition_table.h b/include/tables/transition_table.h new file mode 100644 index 000000000..d623d76bb --- /dev/null +++ b/include/tables/transition_table.h @@ -0,0 +1,21 @@ +/** + * Transition Table + * + * DEFINE_TRANSITION should be used for normal transitions + * - Argument 0: Enum value for this transition + * - Argument 1: Name of the effect struct + * - Argument 2: Instance name + * - Argument 3: Name of the effect (without the ovl_ part) + * + * DEFINE_TRANSITION_INTERNAL should be used for transitions that aren't an overlay + * - Argument 0: Enum value for this transition + * - Argument 1: Name of the effect struct + * - Argument 2: Instance name + */ +/* 0 */ DEFINE_TRANSITION_INTERNAL(FBDEMO_FADE, TransitionFade, fade) +/* 1 */ DEFINE_TRANSITION(FBDEMO_TRIFORCE, TransitionTriforce, triforce, fbdemo_triforce) +/* 2 */ DEFINE_TRANSITION(FBDEMO_WIPE1, TransitionWipe1, wipe1, fbdemo_wipe1) +/* 3 */ DEFINE_TRANSITION(FBDEMO_WIPE3, TransitionWipe3, wipe3, fbdemo_wipe3) +/* 4 */ DEFINE_TRANSITION(FBDEMO_WIPE4, TransitionWipe4, wipe4, fbdemo_wipe4) +/* 5 */ DEFINE_TRANSITION_INTERNAL(FBDEMO_CIRCLE, TransitionCircle, circle) +/* 6 */ DEFINE_TRANSITION(FBDEMO_WIPE5, TransitionWipe5, wipe5, fbdemo_wipe5) diff --git a/include/tha.h b/include/tha.h new file mode 100644 index 000000000..805d421f9 --- /dev/null +++ b/include/tha.h @@ -0,0 +1,28 @@ +#ifndef THA_H +#define THA_H + +#include "ultra64.h" +#include "libc/stdint.h" + +typedef struct TwoHeadArena { + /* 0x0 */ size_t size; + /* 0x4 */ void* start; + /* 0x8 */ void* head; + /* 0xC */ void* tail; +} TwoHeadArena; // size = 0x10 + +void* THA_GetHead(TwoHeadArena* tha); +void THA_SetHead(TwoHeadArena* tha, void* newHead); +void* THA_GetTail(TwoHeadArena* tha); +void* THA_AllocHead(TwoHeadArena* tha, size_t size); +void* THA_AllocHeadByte(TwoHeadArena* tha); +void* THA_AllocTail(TwoHeadArena* tha, size_t size); +void* THA_AllocTailAlign16(TwoHeadArena* tha, size_t size); +void* THA_AllocTailAlign(TwoHeadArena* tha, size_t size, uintptr_t mask); +s32 THA_GetRemaining(TwoHeadArena* tha); +u32 THA_IsCrash(TwoHeadArena* tha); +void THA_Reset(TwoHeadArena* tha); +void THA_Init(TwoHeadArena* tha, void* start, size_t size); +void THA_Destroy(TwoHeadArena* tha); + +#endif diff --git a/include/thga.h b/include/thga.h new file mode 100644 index 000000000..351c36407 --- /dev/null +++ b/include/thga.h @@ -0,0 +1,33 @@ +#ifndef THGA_H +#define THGA_H + +#include "tha.h" + +typedef union TwoHeadGfxArena { + struct { // Same as TwoHeadArena, with different types and field names for the head and tail pointers + /* 0x0 */ size_t size; + /* 0x4 */ void* start; + /* 0x8 */ Gfx* p; + /* 0xC */ void* d; + }; + /* 0x0 */ TwoHeadArena tha; +} TwoHeadGfxArena; // size = 0x10 + +void THGA_Init(TwoHeadGfxArena* thga, void* start, size_t size); +void THGA_Destroy(TwoHeadGfxArena* thga); +u32 THGA_IsCrash(TwoHeadGfxArena* thga); +void THGA_Reset(TwoHeadGfxArena* thga); +s32 THGA_GetRemaining(TwoHeadGfxArena* thga); +Gfx* THGA_GetHead(TwoHeadGfxArena* thga); +void THGA_SetHead(TwoHeadGfxArena* thga, Gfx* newHead); +void* THGA_GetTail(TwoHeadGfxArena* thga); +Gfx* THGA_AllocDisplayList(TwoHeadGfxArena* thga, size_t num); +Gfx* THGA_AllocGfx(TwoHeadGfxArena* thga); +Gfx* THGA_AllocGfx2(TwoHeadGfxArena* thga); +void* THGA_AllocTail(TwoHeadGfxArena* thga, size_t size); +Mtx* THGA_AllocMtxArray(TwoHeadGfxArena* thga, size_t num); +Mtx* THGA_AllocMtx(TwoHeadGfxArena* thga); +Vtx* THGA_AllocVtxArray(TwoHeadGfxArena* thga, size_t num); +Vtx* THGA_AllocVtx(TwoHeadGfxArena* thga); + +#endif diff --git a/include/ultra64/message.h b/include/ultra64/message.h index a049ae363..de0c39b83 100644 --- a/include/ultra64/message.h +++ b/include/ultra64/message.h @@ -1,5 +1,5 @@ -#ifndef _ULTRA64_MESSAGE_H_ -#define _ULTRA64_MESSAGE_H_ +#ifndef ULTRA64_MESSAGE_H +#define ULTRA64_MESSAGE_H #include "ultra64/thread.h" diff --git a/include/ultra64/motor.h b/include/ultra64/motor.h index ad6828132..ed969b3de 100644 --- a/include/ultra64/motor.h +++ b/include/ultra64/motor.h @@ -5,13 +5,14 @@ #include "PR/pfs.h" #include "ultra64/message.h" -#define MOTOR_START 1 -#define MOTOR_STOP 0 +#define MOTOR_START 1 +#define MOTOR_STOP 0 -#define osMotorStart(x) __osMotorAccess((x), MOTOR_START) -#define osMotorStop(x) __osMotorAccess((x), MOTOR_STOP) +#define osMotorStart(x) __osMotorAccess((x), MOTOR_START) +#define osMotorStop(x) __osMotorAccess((x), MOTOR_STOP) -s32 __osMotorAccess(OSPfs* pfs, u32 vibrate); -s32 osMotorInit(OSMesgQueue* ctrlrqueue, OSPfs* pfs, s32 channel); +s32 __osMotorAccess(OSPfs* pfs, s32 flag); + +s32 osMotorInit(OSMesgQueue* mq, OSPfs* pfs, s32 channel); #endif diff --git a/include/ultra64/rcp.h b/include/ultra64/rcp.h index 6bd778ccf..7a336be28 100644 --- a/include/ultra64/rcp.h +++ b/include/ultra64/rcp.h @@ -11,4 +11,12 @@ #define DEVICE_TYPE_SRAM 3 /* SRAM */ #define DEVICE_TYPE_INIT 7 /* initial value */ + +#define CHNL_ERR_NORESP 0x80 /* Bit 7 (Rx): No response error */ +#define CHNL_ERR_OVERRUN 0x40 /* Bit 6 (Rx): Overrun error */ +#define CHNL_ERR_FRAME 0x80 /* Bit 7 (Tx): Frame error */ +#define CHNL_ERR_COLLISION 0x40 /* Bit 6 (Tx): Collision error */ + +#define CHNL_ERR_MASK 0xC0 /* Bit 6-7: channel errors */ + #endif diff --git a/include/ultra64/thread.h b/include/ultra64/thread.h index f3cd68890..62cbdcd1b 100644 --- a/include/ultra64/thread.h +++ b/include/ultra64/thread.h @@ -54,16 +54,16 @@ typedef struct { } __OSThreadprofile; // size = 0x10 typedef struct OSThread { - /*0x00*/ struct OSThread* next; - /*0x04*/ OSPri priority; - /*0x08*/ struct OSThread** queue; - /*0x0C*/ struct OSThread* tlnext; - /*0x10*/ u16 state; - /*0x12*/ u16 flags; - /*0x14*/ OSId id; - /*0x18*/ s32 fp; - /*0x1C*/ __OSThreadprofile* thprof; - /*0x20*/ __OSThreadContext context; + /* 0x00 */ struct OSThread* next; + /* 0x04 */ OSPri priority; + /* 0x08 */ struct OSThread** queue; + /* 0x0C */ struct OSThread* tlnext; + /* 0x10 */ u16 state; + /* 0x12 */ u16 flags; + /* 0x14 */ OSId id; + /* 0x18 */ s32 fp; + /* 0x1C */ __OSThreadprofile* thprof; + /* 0x20 */ __OSThreadContext context; } OSThread; // size = 0x1B0 #endif diff --git a/include/variables.h b/include/variables.h index 600fa8ecf..a128b33b1 100644 --- a/include/variables.h +++ b/include/variables.h @@ -37,8 +37,7 @@ extern FaultDrawer* sFaultDrawContext; extern FaultDrawer sFaultDrawerDefault; extern s32 gLoadLogSeverity; extern s32 gLoad2LogSeverity; -extern StackEntry* sStackInfoListStart; -extern StackEntry* sStackInfoListEnd; + // extern UNK_TYPE1 sGfxPrintFontTLUT; // extern UNK_TYPE1 sGfxPrintRainbowTLUT; // extern UNK_TYPE1 sGfxPrintRainbowData; @@ -282,43 +281,24 @@ extern f64 D_800994C8; extern char gBuildTeam[]; extern char gBuildDate[]; extern char gBuildMakeOption[]; -// extern StackEntry sBootThreadInfo; -// extern OSThread sIdleThread; -// extern u8 sIdleThreadStack[0x400]; -// extern StackEntry sIdleThreadInfo; -// extern u8 sBootThreadStack[0x400]; + extern IrqMgr gIrqMgr; -// extern u8 sIrqMgrStack[0x500]; -// extern StackEntry sIrqMgrStackInfo; -// extern OSThread gMainThread; -// extern u8 sMainStack[0x900]; -// extern StackEntry sMainStackInfo; -// extern OSMesg sPiMgrCmdBuff[50]; -// extern OSMesgQueue gPiMgrCmdQ; + extern OSViMode gViConfigMode; extern u8 D_8009B290; -extern StackEntry sDmaMgrStackInfo; -extern u16 numDmaEntries; -extern OSMesgQueue sDmaMgrMsgQueue; -extern OSMesg sDmaMgrMsgs[32]; -extern OSThread sDmaMgrThread; -extern u8 sDmaMgrStack[0x500]; + extern u8 sYaz0DataBuffer[0x400]; extern u8* sYaz0CurDataEnd; extern u32 sYaz0CurRomStart; extern u32 sYaz0CurSize; extern u8* sYaz0MaxPtr; -extern u8* D_8009BE20; +extern void* gYaz0DecompressDstEnd; // extern UNK_TYPE4 D_8009BE30; // extern UNK_TYPE4 D_8009BE34; // extern FaultClient romInfoFaultClient; -extern FaultThreadStruct* sFaultContext; -extern f32 D_8009BE54; -extern u32 faultCustomOptions; -extern u32 faultCopyToLog; -extern u8 sFaultStack[0x600]; -extern StackEntry sFaultThreadInfo; + extern FaultThreadStruct gFaultStruct; + extern FaultDrawer sFaultDrawerStruct; // extern UNK_TYPE4 D_8009CD10; extern u32 sRandFloat; @@ -333,10 +313,7 @@ extern UNK_TYPE1 D_8009CF60; extern OSThread __osThreadSave; extern OSPiHandle D_8009D130; extern OSPiHandle D_8009D1A8; -// extern OSThread D_8009D220; -// extern u8 piManagerStack[0x1000]; -// extern OSMesgQueue D_8009E3D0; -// extern OSMesg D_8009E3E8[1]; + extern OSMesg D_8009E3F0[1]; extern OSMesgQueue __osPiAccessQueue; extern __OSInode __osPfsInodeCache; @@ -348,13 +325,7 @@ extern u32 __osViIntrCount; extern u32 __osTimerCounter; extern OSPifRam __osPfsPifRam; extern OSPiHandle CartRomHandle; -extern OSThread viThread; -extern u8 viThreadStack[0x1000]; -extern OSMesgQueue viEventQueue; -// extern OSMesg viEventBuf[5]; -// extern OSIoMesg viRetraceMsg; -// extern OSIoMesg viCounterMsg; -extern u16 viRetrace; + extern DmaEntry dmadata[1568]; // extern UNK_TYPE1 D_80186028; extern u64 aspMainTextStart[]; @@ -406,47 +377,13 @@ extern EffectSsOverlay gParticleOverlayTable[39]; // extern s32 sEntryIndex; // extern u32 sCurrentBit; // extern s32 sTimer; -extern f32 actorMovementScale; -extern TargetRangeParams gTargetRanges[]; -extern s16 D_801AED48[8]; -extern Color_RGBA8 actorDefaultHitColor; -// extern UNK_TYPE1 D_801AED8C; -// extern UNK_TYPE4 D_801AED98; -// extern UNK_TYPE4 D_801AEDA4; -// extern UNK_TYPE1 D_801AEDB0; -// extern UNK_TYPE4 D_801AEDD4; -// extern UNK_TYPE4 D_801AEE28; -// extern UNK_TYPE4 D_801AEE30; -// extern UNK_TYPE4 D_801AEE38; -// extern UNK_TYPE2 D_801AEE4C; -extern Gfx D_801AEF88[]; -extern Gfx D_801AEFA0[]; -// extern UNK_TYPE1 D_801AEFB8; -// extern UNK_TYPE1 D_801AEFBC; -// extern UNK_TYPE1 D_801AEFC0; + extern ActorOverlay gActorOverlayTable[ACTOR_ID_MAX]; extern ActorId gMaxActorId; extern BgCheckSceneSubdivisionEntry sSceneSubdivisionList[]; extern BgSpecialSceneMaxObjects sCustomDynapolyMem[]; // extern UNK_TYPE1 D_801B4708; -// extern UNK_TYPE4 D_801B9E0C; -// extern UNK_TYPE4 D_801B9E10; -// extern UNK_TYPE4 D_801B9E14; -// extern UNK_TYPE2 D_801B9E18; -// extern UNK_TYPE2 D_801B9E34; -// extern UNK_TYPE4 D_801B9E50; -// extern UNK_TYPE4 D_801B9E54; -// extern UNK_TYPE4 D_801B9E58; -// extern UNK_TYPE4 D_801B9E5C; -// extern UNK_TYPE4 D_801B9E60; -// extern UNK_TYPE1 D_801B9E64; -// extern UNK_TYPE1 D_801B9E84; -// extern UNK_TYPE4 D_801B9EB4; -// extern UNK_TYPE4 D_801B9ED4; -// extern UNK_TYPE4 sEarthquakeFreq; -// extern UNK_TYPE2 sEarthquakeTimer; -extern UNK_TYPE4 D_801B9F10; extern DamageTable sDamageTablePresets[23]; extern f32 damageMultipliers[16]; extern Collider defaultCollider; @@ -477,24 +414,11 @@ extern EffectShieldParticleInit shieldParticleInitWood; // extern UNK_TYPE2 D_801BB0FC; // extern UNK_TYPE1 D_801BB100; -extern u8 D_801BB12C; +extern u8 gOpeningEntranceIndex; -// extern UNK_TYPE1 D_801BC210; -extern Gfx D_801BC240[9]; -extern Gfx D_801BC288[3]; -// extern UNK_TYPE1 D_801BC41E; -extern ActorCutscene actorCutscenesGlobalCutscenes[8]; -extern s16 actorCutsceneCurrent; -extern s16 actorCutsceneCurrentLength; -extern s16 actorCutsceneEnding; -extern s16 actorCutsceneCurrentCamera; -extern Actor* actorCutsceneCurrentCutsceneActor; -// extern UNK_TYPE4 actorCutsceneStartMethod; -extern PlayState* actorCutscenesPlayState; -extern s16 actorCutsceneReturnCamera; -extern s16 D_801BD8C6; +extern ActorCutscene sGlobalCutsceneList[8]; extern GameStateOverlay gGameStateOverlayTable[]; -extern s32 graphNumGameStates; +extern s32 gGraphNumGameStates; // extern UNK_TYPE2 D_801BDA70; // extern UNK_TYPE2 D_801BDA74; // extern UNK_TYPE2 D_801BDA78; @@ -637,11 +561,6 @@ extern struct_80124618 D_801C0490[]; extern Gfx gCullBackDList[]; extern Gfx gCullFrontDList[]; -extern Gfx sSetupDL[438]; -extern Gfx sFillSetupDL[12]; -extern Gfx gEmptyDL[1]; -extern Vec3f D_801C1D10; -extern room_draw_func roomDrawFuncs[4]; extern u32 gBitFlags[32]; extern u16 gEquipMasks[]; extern u16 gEquipNegMasks[]; @@ -657,8 +576,11 @@ extern u8 gItemSlots[]; extern s16 gItemPrices[]; extern u16 gSceneIdsPerRegion[11][27]; extern u8 gPlayerFormItemRestrictions[PLAYER_FORM_MAX][114]; -extern s16 gPlayerFormObjectIndices[8]; -extern RomFile gObjectTable[643]; + +extern s16 gPlayerFormObjectIndices[PLAYER_FORM_MAX]; +extern ObjectId gObjectTableSize; +extern RomFile gObjectTable[OBJECT_ID_MAX]; + extern SceneTableEntry gSceneTable[]; extern UNK_PTR D_801C5C50; // extern UNK_TYPE1 D_801C5C9C; @@ -804,16 +726,14 @@ extern char D_801D039C[]; extern KaleidoMgrOverlay gKaleidoMgrOverlayTable[2]; // extern UNK_TYPE1 D_801D0B8C; extern KaleidoMgrOverlay* gKaleidoMgrCurOvl; -// extern UNK_TYPE4 D_801D0BB0; // extern UNK_TYPE1 D_801D0C80; // extern UNK_TYPE1 D_801D0CB0; -extern Gfx D_801D0D00[]; extern s32 gDbgCamEnabled; // extern UNK_TYPE1 D_801D0D54; -// extern UNK_TYPE2 D_801D0D58; -// extern UNK_TYPE2 D_801D0D5C; +// extern UNK_TYPE2 sQuakeIndex; +// extern UNK_TYPE2 sIsCameraUnderwater; extern Input* D_801D0D60; -// extern UNK_TYPE2 D_801D0D64; +// extern UNK_TYPE2 sPlayerCsIdToCsCamId; // extern UNK_TYPE1 D_801D0D7A; // extern UNK_TYPE1 D_801D0D80; // extern UNK_TYPE1 D_801D11F4; @@ -872,9 +792,6 @@ extern u32 cfbIdx[3]; extern s32 gScreenWidth; extern s32 gScreenHeight; extern u32 startHeapSize; -extern PadMgr* padmgrContext; -// extern UNK_TYPE4 controllerInputsCaptured; -// extern UNK_TYPE4 D_801D1538; extern UNK_PTR D_801D1540; // extern f32 sFactorialTbl[13]; extern Vec3f gZeroVec3f; @@ -1043,14 +960,9 @@ extern u8 gSfxChannelLayout; extern Vec3f gSfxDefaultPos; extern f32 gSfxDefaultFreqAndVolScale; extern s8 gSfxDefaultReverb; -// extern UNK_TYPE1 D_801DB4C0; -// extern UNK_TYPE1 D_801DB4C4; -// extern UNK_TYPE1 D_801DB4C8; -// extern UNK_TYPE1 D_801DB4CC; extern u8 gAudioSpecId; -// extern UNK_TYPE1 D_801DB4D8; -// extern UNK_TYPE4 D_801DB4DC; -extern ReverbSettings* gReverbSettingsTable[]; +extern u8 gAudioHeapResetState; +extern ReverbSettings* gReverbSettingsTable[10]; extern AudioSpec gAudioSpecs[21]; // rodata @@ -2305,14 +2217,14 @@ extern f32 D_801ED8D0; // extern UNK_TYPE1 D_801ED8D8; // extern UNK_TYPE1 D_801ED8DC; extern Mtx D_801ED8E0; -// extern UNK_TYPE1 D_801ED920; -extern FaultClient D_801ED930; -extern FaultAddrConvClient D_801ED940; +extern Actor* D_801ED920; +extern FaultClient sActorOverlayTableFaultClient; +extern FaultAddrConvClient sActorOverlayTableFaultAddrConvClient; extern char D_801ED950[80]; extern char D_801ED9A0[80]; extern Vec3f D_801ED9F0[3]; extern Vec3f D_801EDA18[3]; -extern MtxF D_801EDA40; +extern MtxF sModelToWorldMtxF; extern Vec3f D_801EDA80[3]; extern char D_801EDAA8[80]; extern char D_801EDAF8[80]; @@ -2321,30 +2233,7 @@ extern Vec3f D_801EDB70[3]; extern Plane D_801EDB98; extern Sphere16 D_801EDBA8; extern TriNorm D_801EDBB0; -// extern UNK_TYPE1 D_801EDBD4; -// extern UNK_TYPE1 D_801EDBD8; -// extern UNK_TYPE1 D_801EDBDC; -// extern UNK_TYPE1 D_801EDBE0; -// extern UNK_TYPE1 D_801EDBF4; -// extern UNK_TYPE1 D_801EDBF8; -// extern UNK_TYPE1 D_801EDC00; -// extern UNK_TYPE1 D_801EDC04; -// extern UNK_TYPE1 D_801EDC08; -// extern UNK_TYPE1 D_801EDC0C; -// extern UNK_TYPE1 D_801EDC10; -// extern UNK_TYPE1 D_801EDC14; -// extern UNK_TYPE1 D_801EDC28; -// extern UNK_TYPE1 D_801EDC30; -// extern UNK_TYPE1 D_801EDC8C; -// extern UNK_TYPE1 D_801EDC90; -// extern UNK_TYPE1 D_801EDC92; -// extern UNK_TYPE1 D_801EDC94; -// extern UNK_TYPE1 D_801EDC96; -// extern UNK_TYPE1 D_801EDDD0; -// extern UNK_TYPE1 D_801EDDD4; -// extern UNK_TYPE1 D_801EDDD8; -// extern UNK_TYPE1 D_801EDDE0; -// extern UNK_TYPE1 D_801EDDF0; + extern Vec3f D_801EDE00; extern Vec3f D_801EDE10; extern Vec3f D_801EDE20; @@ -2392,20 +2281,20 @@ extern SaveContext gSaveContext; // extern UNK_TYPE1 D_801F3F42; // extern UNK_TYPE1 D_801F3F4A; // extern UNK_TYPE1 D_801F3F5A; -extern GameInfo* gGameInfo; + // extern UNK_TYPE1 D_801F3F80; // extern UNK_TYPE1 D_801F3F83; // extern UNK_TYPE1 D_801F48C8; extern UNK_TYPE D_801F4DDC; -extern u8 D_801F4DE0; -extern s16 D_801F4DE2; +extern u8 gDisablePlayerCsModeStartPos; +extern s16 gDungeonBossWarpSceneId; -extern ActorCutscene* actorCutscenes; -extern s16 actorCutsceneCount; -extern u8 actorCutsceneWaiting[16]; +extern ActorCutscene* sSceneCutsceneList; +extern s16 sSceneCutsceneCount; +extern u8 sWaitingCutsceneList[16]; // extern UNK_TYPE1 D_801F4E08; -extern u8 actorCutsceneNextCutscenes[16]; +extern u8 sNextCutsceneList[16]; // extern UNK_TYPE1 D_801F4E20; extern u8 D_801F4E30; // extern UNK_TYPE1 D_801F4E31; @@ -2482,31 +2371,26 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F6B1E; // extern UNK_TYPE1 D_801F6B20; // extern UNK_TYPE1 D_801F6B22; -// extern UNK_TYPE4 D_801F6B50; +// extern UNK_TYPE4 sCurCsCamera; // extern UNK_TYPE1 D_801F6B58; extern void (*sKaleidoScopeUpdateFunc)(PlayState* play); extern void (*sKaleidoScopeDrawFunc)(PlayState* play); -extern FaultAddrConvClient sKaleidoAreaFaultClient; -// extern UNK_TYPE1 D_801F6C10; +extern FaultAddrConvClient sKaleidoMgrFaultAddrConvClient; +extern s16 sTransitionFillTimer; extern Input D_801F6C18; -// extern UNK_TYPE1 D_801F6C30; -// extern UNK_TYPE1 D_801F6D0C; -extern UNK_TYPE4 D_801F6D10; -// extern UNK_TYPE1 D_801F6D18; -extern Color_RGBA8 D_801F6D30; -// extern UNK_TYPE1 D_801F6D38; -// extern UNK_TYPE4 D_801F6D4C; -// extern UNK_TYPE1 D_801F6D50; -extern u8 D_801F6DFC; -// extern UNK_TYPE1 D_801F6DFD; -extern SlowlyTask D_801F6E00; -extern s32 D_801F6FC0; -extern StackEntry slowlyStackEntry; -extern u8 slowlyStack[0x1000]; -extern UNK_TYPE1 D_801F7FE8; +extern TransitionTile sTransitionTile; +extern s32 gTransitionTileState; +extern VisMono sVisMono; +extern Color_RGBA8_u32 gVisMonoColor; +extern Struct_80140E80 D_801F6D38; +extern Struct_80140E80* D_801F6D4C; +extern BombersNotebook sBombersNotebook; +extern u8 sBombersNotebookOpen; +extern u8 sMotionBlurStatus; + extern UNK_TYPE1 D_801F7FF0; extern struct_801F8010 D_801F8010; -extern struct_801F8020 D_801F8020; +extern VisZbuf sVisZbuf; extern VisMono sMonoColors; extern UNK_TYPE1 D_801F8048; extern FaultAddrConvClient sGraphFaultAddrConvClient; @@ -2514,24 +2398,12 @@ extern FaultClient sGraphFaultClient; extern GfxMasterList* gGfxMasterDL; extern CfbInfo sGraphCfbInfos[3]; extern OSTime sGraphTaskStartTime; -extern OSMesgQueue sSiIntMsgQ; -extern OSMesg sSiIntMsgBuf[1]; + extern u32 gSegments[NUM_SEGMENTS]; extern SchedContext gSchedContext; -extern IrqMgrClient irqClient; -extern OSMesgQueue irqMgrMsgQ; -extern OSMesg irqMgrMsgBuf[60]; -extern OSThread sGraphThread; -extern u8 sGraphStack[6144]; -extern u8 schedStack[1536]; -extern u8 audioStack[2048]; -extern u8 padmgrStack[1280]; -extern StackEntry sGraphStackInfo; -extern StackEntry schedStackEntry; -extern StackEntry audioStackEntry; -extern StackEntry padmgrStackEntry; -extern AudioMgr audioContext; -extern PadMgr D_801FB620; + +extern OSThread gGraphThread; + extern FaultClient sSchedFaultClient; extern OSTime sRSPGFXStartTime; extern OSTime sRSPAudioStartTime; @@ -2572,8 +2444,7 @@ extern UNK_TYPE2 D_801FBBCC; extern UNK_TYPE2 D_801FBBCE; // extern UNK_TYPE1 D_801FBBD0; // extern UNK_TYPE1 D_801FBBD2; -// extern UNK_TYPE1 D_801FBBD4; -// extern UNK_TYPE1 D_801FBBE0; +extern u8 D_801FBBD4; extern Vec3f D_801FBBF0; extern LineSegment Math3D_ColSphereTri_line; extern Vec3f Math3D_ColSphereTri_point; @@ -2648,15 +2519,7 @@ extern Vec3f D_801FBDA4; extern Vec3f D_801FBDE8; extern MtxF* sMatrixStack; extern MtxF* sCurrentMatrix; -// extern UNK_TYPE1 D_801FBE10; -// extern UNK_TYPE1 D_801FBE28; -// extern UNK_TYPE1 D_801FBE2C; -// extern UNK_TYPE4 D_801FBE30; -extern u8 sys_flashromStack[0x1000]; -extern StackEntry sys_flashromStackEntry; -extern OSThread sys_flashromOSThread; -extern s80185D40 D_801FD008; -extern OSMesg D_801FD034; + extern s32 D_801FD120; // extern UNK_TYPE1 D_801FD140; // extern UNK_TYPE1 D_801FD158; @@ -2745,61 +2608,26 @@ extern s32 D_801FD120; // extern UNK_TYPE1 D_801FD598; // extern UNK_TYPE1 D_801FD5A0; // extern UNK_TYPE1 D_801FD5A4; -// extern UNK_TYPE1 D_801FD5B8; +extern OSVoiceHandle gVoiceHandle; // extern UNK_TYPE1 D_801FD5C4; // extern UNK_TYPE1 D_801FD5C8; // extern UNK_TYPE1 D_801FD5E8; // extern UNK_TYPE1 D_801FD608; // extern UNK_TYPE1 D_801FD610; -// extern UNK_TYPE1 sSfxPlayerBank; -// extern UNK_TYPE1 sSfxItemBank; -// extern UNK_TYPE1 sSfxEnvironmentBank; -// extern UNK_TYPE1 sSfxEnemyBank; -// extern UNK_TYPE1 sSfxSystemBank; -// extern UNK_TYPE1 sSfxOcarinaBank; -// extern UNK_TYPE1 sSfxVoiceBank; -// extern SfxRequest sSfxRequests[0x100]; -// extern UNK_TYPE1 sSfxBankListEnd; -// extern UNK_TYPE1 sSfxBankFreeListStart; -// extern UNK_TYPE1 sSfxBankUnused; extern ActiveSfx gActiveSfx[7][3]; -// extern UNK_TYPE1 sCurSfxPlayerChannelIndex; -// extern UNK_TYPE1 gSfxBankMuted; -// extern UNK_TYPE1 sUnusedBankLerp; -// extern UNK_TYPE1 D_801FFD00; -// extern UNK_TYPE1 D_801FFD34; -// extern UNK_TYPE1 D_801FFD40; -// extern UNK_TYPE1 D_80200000; -// extern UNK_TYPE1 D_80200002; -// extern UNK_TYPE1 D_80200004; -// extern UNK_TYPE1 D_80200008; -// extern UNK_TYPE1 D_8020001E; -// extern UNK_TYPE1 D_802000C9; -// extern UNK_TYPE1 D_802000D4; +extern SeqRequest sSeqRequests[][5]; +extern u8 sNumSeqRequests[5]; +extern u32 sAudioSeqCmds[0xB0]; extern ActiveSequence gActiveSeqs[]; -// extern UNK_TYPE1 D_8020034A; -// extern UNK_TYPE1 D_80200B88; -// extern UNK_TYPE1 D_80200BBA; -// extern UNK_TYPE1 D_80200BCC; -// extern UNK_TYPE1 D_80200BCE; -// extern UNK_TYPE1 D_80200BD0; +extern u8 sResetAudioHeapTimer; +extern u16 sResetAudioHeapFadeReverbVolume; +extern u16 sResetAudioHeapFadeReverbVolumeStep; extern AudioContext gAudioCtx; // at 0x80200C70 extern AudioCustomUpdateFunction gAudioCustomUpdateFunction; extern AudioCustomSeqFunction gAudioCustomSeqFunction; extern AudioCustomReverbFunction gAudioCustomReverbFunction; extern AudioCustomSynthFunction gAudioCustomSynthFunction; -// post-code buffers -extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; -extern u8 gGfxSPTaskStack[0x400]; -extern GfxPool gGfxPools[2]; -extern u8 gAudioHeap[0x138000]; -extern u8 gSystemHeap[UNK_SIZE]; - -extern u8 gPictoPhotoI8[PICTO_PHOTO_SIZE]; -extern u8 D_80784600[0x56200]; -extern u16 gFramebuffer0[SCREEN_HEIGHT][SCREEN_WIDTH]; - // other segments extern GfxMasterList D_0E000000; extern Mtx D_01000000; diff --git a/include/z64.h b/include/z64.h index 5d0639ef6..b299d883c 100644 --- a/include/z64.h +++ b/include/z64.h @@ -14,19 +14,25 @@ #include "osint.h" #include "os.h" #include "irqmgr.h" +#include "padmgr.h" #include "scheduler.h" #include "xstdio.h" #include "color.h" #include "ichain.h" #include "sequence.h" +#include "seqcmd.h" #include "sfx.h" #include "message_data_static.h" +#include "gfx.h" #include "gfxprint.h" #include "sys_matrix.h" +#include "tha.h" +#include "thga.h" #include "z64actor.h" #include "z64animation.h" +#include "z64animation_legacy.h" #include "z64audio.h" #include "z64bgcheck.h" #include "z64camera.h" @@ -34,7 +40,10 @@ #include "z64curve.h" #include "z64cutscene.h" #include "z64dma.h" +#include "z64eff_footmark.h" #include "z64effect.h" +#include "z64frameadvance.h" +#include "z64game_over.h" #include "z64interface.h" #include "z64item.h" #include "z64light.h" @@ -48,6 +57,7 @@ #include "z64map.h" #include "z64schedule.h" #include "z64skin.h" +#include "z64skybox.h" #include "z64subs.h" #include "z64transition.h" #include "z64view.h" @@ -79,19 +89,6 @@ typedef enum { /* 4 */ EQUIP_SLOT_A } EquipSlot; -typedef struct { - /* 0x0 */ s16 priority; // Lower means higher priority. -1 means it ignores priority - /* 0x2 */ s16 length; - /* 0x4 */ s16 csCamSceneDataId; // Index of CsCameraEntry to use. Negative indices use sGlobalCamDataSettings. Indices 0 and above use CsCameraEntry from scene - /* 0x6 */ s16 unk6; - /* 0x8 */ s16 additionalCutscene; - /* 0xA */ u8 sound; - /* 0xB */ u8 unkB; - /* 0xC */ s16 unkC; - /* 0xE */ u8 unkE; - /* 0xF */ u8 letterboxSize; -} ActorCutscene; // size = 0x10 - typedef struct { /* 0x0 */ s8 segment; /* 0x2 */ s16 type; @@ -112,163 +109,6 @@ typedef struct { /* 0x8 */ void* end; } PolygonType2; // size = 0xC -typedef struct { - /* 0x0 */ s16 x; - /* 0x2 */ s16 y; - /* 0x4 */ s16 z; - /* 0x6 */ s16 reserved; - /* 0x8 */ s16 s; - /* 0xA */ s16 t; - /* 0xC */ s8 r; - /* 0xD */ s8 g; - /* 0xE */ s8 b; - /* 0xF */ s8 a; -} F3DVertexColor; // size = 0x10 - -typedef struct { - /* 0x0 */ s16 x; - /* 0x2 */ s16 y; - /* 0x4 */ s16 z; - /* 0x6 */ s16 reserved; - /* 0x8 */ s16 s; - /* 0xA */ s16 t; - /* 0xC */ s8 normalX; - /* 0xD */ s8 normalY; - /* 0xE */ s8 normalZ; - /* 0xF */ s8 a; -} F3DVertexNormal; // size = 0x10 - -typedef struct { - /* 0x0 */ f32 size; - /* 0x4 */ f32 dynamicSizeStep; - /* 0x8 */ u8 state; - /* 0x9 */ u8 sizeGrowsCos2; - /* 0xA */ u8 colorsIndex; - /* 0xB */ u8 flags; - /* 0xC */ u8 lightParamsIndex; -} FireObjInitParams; // size = 0x10 - -typedef struct FireObjColors { - /* 0x0 */ Color_RGBA8 primColor; - /* 0x4 */ u8 lod; - /* 0x5 */ Color_RGB8 envColor; -} FireObjColors; // size = 0x8 - -typedef struct FireObjLightParams { - /* 0x0 */ s16 radius; - /* 0x2 */ Color_RGB8 color; - /* 0x5 */ Color_RGB8 maxColorAdj; -} FireObjLightParams; // size = 0x8 - -// Game Info aka. Static Context -// Data normally accessed through REG macros (see regs.h) -typedef struct { - /* 0x00 */ u8 unk_00; // regPage;? // 1 is first page - /* 0x01 */ u8 unk_01; // regGroup;? // "register" group (R, RS, RO, RP etc.) - /* 0x02 */ u8 unk_02; // regCur;? // selected register within page - /* 0x03 */ u8 unk_03; // dpadLast;? - /* 0x04 */ u32 unk_04; // repeat;? - /* 0x08 */ UNK_TYPE1 pad_08[0xC]; - /* 0x14 */ s16 data[REG_GROUPS * REG_PER_GROUP]; // 0xAE0 entries -} GameInfo; // size = 0x15D4 - -typedef struct { - /* 0x0 */ u32 size; - /* 0x4 */ void* bufp; - /* 0x8 */ void* head; - /* 0xC */ void* tail; -} TwoHeadArena; // size = 0x10 - -typedef struct { - /* 0x0 */ u32 size; - /* 0x4 */ Gfx* bufp; - /* 0x8 */ Gfx* p; - /* 0xC */ Gfx* d; -} TwoHeadGfxArena; // size = 0x10 - -typedef struct { - /* 0x000 */ Gfx taskStart[9]; - /* 0x048 */ Gfx clearZBuffer[8]; // original name: clear_zb_dl - /* 0x088 */ Gfx clearFrameBuffer[5]; // original name: clear_fb_dl - /* 0x0B0 */ Gfx setupBuffers[6]; // setup framebuffer and zbuffer - /* 0x0E0 */ Gfx unk_E0[12]; // unused - /* 0x140 */ Gfx syncSegments[17]; - /* 0x1C8 */ Gfx setScissor[2]; - /* 0x1D8 */ Gfx unk_1D8[25]; // unused - /* 0x2A0 */ Gfx disps[5]; - /* 0x2C8 */ Gfx clearFillRect[3]; // fillrect for clearing buffers - /* 0x2E0 */ Gfx fillRect[3]; // fillrect for general purpose - /* 0x2F8 */ Gfx debugDisp[1]; -} GfxMasterList; // size = 0x300 - -#define GFXPOOL_HEAD_MAGIC 0x1234 -#define GFXPOOL_TAIL_MAGIC 0x5678 - -typedef struct { - /* 0x00000 */ u16 headMagic; // 1234 - /* 0x00008 */ GfxMasterList master; - /* 0x00308 */ Gfx polyXluBuffer[2048]; - /* 0x04308 */ Gfx overlayBuffer[1024]; - /* 0x06308 */ Gfx workBuffer[64]; - /* 0x06508 */ Gfx debugBuffer[64]; - /* 0x06708 */ Gfx polyOpaBuffer[13184]; - /* 0x20308 */ u16 tailMagic; // 5678 -} GfxPool; // size = 0x20310 - -typedef struct GraphicsContext { - /* 0x000 */ Gfx* polyOpaBuffer; // Pointer to "Zelda 0" - /* 0x004 */ Gfx* polyXluBuffer; // Pointer to "Zelda 1" - /* 0x008 */ char unk_8[0x8]; // Unused, could this be pointers to "Zelda 2" / "Zelda 3" - /* 0x010 */ Gfx* overlayBuffer; // Pointer to "Zelda 4" - /* 0x014 */ u32 unk_14; - /* 0x018 */ char unk_18[0x20]; - /* 0x038 */ OSMesg msgBuff[8]; - /* 0x058 */ OSMesgQueue* schedMsgQ; - /* 0x05C */ OSMesgQueue queue; - /* 0x074 */ char unk_74[0x04]; - /* 0x078 */ OSScTask task; - /* 0x0E0 */ char unk_E0[0xD0]; - /* 0x1B0 */ Gfx* workBuffer; - /* 0x1B4 */ TwoHeadGfxArena work; - /* 0x1C4 */ Gfx* debugBuffer; - /* 0x1C8 */ TwoHeadGfxArena debug; - /* 0x1D8 */ char unk_1D8[0xAC]; - /* 0x284 */ OSViMode* viMode; - /* 0x288 */ void* zbuffer; - /* 0x28C */ char unk_28C[0x1C]; - /* 0x2A8 */ TwoHeadGfxArena overlay; // "Zelda 4" - /* 0x2B8 */ TwoHeadGfxArena polyOpa; // "Zelda 0" - /* 0x2C8 */ TwoHeadGfxArena polyXlu; // "Zelda 1" - /* 0x2D8 */ u32 gfxPoolIdx; - /* 0x2DC */ u16* curFrameBuffer; - /* 0x2E0 */ char unk_2E0[0x4]; - /* 0x2E4 */ u32 viConfigFeatures; - /* 0x2E8 */ char unk_2E8[0x2]; - /* 0x2EA */ u8 updateViMode; - /* 0x2EB */ u8 framebufferIdx; - /* 0x2EC */ void (*callback)(struct GraphicsContext*, u32); - /* 0x2F0 */ u32 callbackParam; - /* 0x2F4 */ f32 xScale; - /* 0x2F8 */ f32 yScale; - /* 0x2FC */ GfxMasterList* masterList; -} GraphicsContext; // size = 0x300 - -typedef enum IRQ_MSG_TYPE { - IRQ_VERTICAL_RETRACE_MSG = 0x1, - IRQ_PRENMI_2_MSG = 0x3, - IRQ_PRENMI_1_MSG = 0x4 -} IRQ_MSG_TYPE; - -typedef enum IRQ_TYPE { - IRQ_VERTICAL_RETRACE = 0x29A, - IRQ_SP = 0x29B, - IRQ_DP = 0x29C, - IRQ_PRENMI_1 = 0x29D, - IRQ_PRENMI_2 = 0x29F, - IRQ_PRENMI_3 = 0x2A0, - IRQ_PRENMI_4 = 0x2A1 -} IRQ_TYPE; - typedef struct { /* 0x00 */ u32 resetting; /* 0x04 */ u32 resetCount; @@ -276,27 +116,6 @@ typedef struct { /* 0x10 */ OSTime resetTime; } NmiBuff; // size >= 0x18 -typedef void(*osCreateThread_func)(void*); - -typedef enum { - SLOWLY_CALLBACK_NO_ARGS, - SLOWLY_CALLBACK_ONE_ARG, - SLOWLY_CALLBACK_TWO_ARGS -} SlowlyCallbackArgCount; - -typedef struct { - /* 0x000 */ OSThread thread; - /* 0x1B0 */ u8 callbackArgCount; - /* 0x1B1 */ u8 status; - /* 0x1B4 */ union { - void (*callback0)(void); - void (*callback1)(void*); - void (*callback2)(void*, void*); - }; - /* 0x1B8 */ void* callbackArg0; - /* 0x1BC */ void* callbackArg1; -} SlowlyTask; // size = 0x1C0 - typedef struct { /* 0x00 */ int unk0; /* 0x04 */ void* unk4; @@ -306,41 +125,6 @@ typedef struct { /* 0x14 */ OSMesgQueue unk14; } s80185D40; // size = 0x2C -typedef struct { - /* 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; - /* 0x0C */ Vec3f unkC; - /* 0x18 */ s16 unk18; - /* 0x1A */ s16 unk1A; -} s80874650; // size = 0x1C - -typedef union { - F3DVertexColor color; - F3DVertexNormal normal; -} F3DVertex; // size = 0x10 - // End of RDRAM without the Expansion Pak installed #define NORMAL_RDRAM_END 0x80400000 // End of RDRAM with the Expansion Pak installed @@ -396,11 +180,11 @@ typedef struct { /* 0x188 */ Vtx* questPageVtx; /* 0x18C */ Vtx* maskPageVtx; /* 0x190 */ Vtx* itemVtx; - /* 0x194 */ Vtx* mapVtx; + /* 0x194 */ Vtx* mapVtx; // inferred /* 0x198 */ Vtx* questVtx; /* 0x19C */ Vtx* maskVtx; - /* 0x1A0 */ Vtx* unk_1A0; - /* 0x1A4 */ Vtx* unk_1A4; + /* 0x1A0 */ Vtx* promptPageVtx; + /* 0x1A4 */ Vtx* infoPanelVtx; /* 0x1A8 */ Vtx* cursorVtx; /* 0x1AC */ OcarinaStaff* ocarinaStaff; /* 0x1B0 */ UNK_TYPE1 unk_1B0[0x20]; @@ -416,10 +200,10 @@ typedef struct { /* 0x206 */ u16 switchPageTimer; /* 0x208 */ u16 savePromptState; /* 0x20C */ f32 unk_20C; - /* 0x210 */ f32 itemPageRoll; // rotation (-z) of the item page into the screen - /* 0x214 */ f32 mapPageRoll; // rotation (+x) of the map page into the screen - /* 0x218 */ f32 questPageRoll; // rotation (+z) of the quest page into the screen - /* 0x21C */ f32 maskPageRoll; // rotation (-z) of the mask page into the screen + /* 0x210 */ f32 itemPageRoll; // rotation (-z) of the item page into the screen + /* 0x214 */ f32 mapPageRoll; // rotation (+x) of the map page into the screen + /* 0x218 */ f32 questPageRoll; // rotation (+z) of the quest page into the screen + /* 0x21C */ f32 maskPageRoll; // rotation (-z) of the mask page into the screen /* 0x220 */ f32 roll; /* 0x224 */ u16 alpha; /* 0x226 */ s16 offsetY; @@ -534,44 +318,14 @@ typedef struct { /* 0xE5 */ u8 fillScreen; /* 0xE6 */ u8 screenFillColor[4]; /* 0xEA */ u8 sandstormState; - /* 0xEB */ u8 unk_EB; - /* 0xEC */ u8 unk_EC; + /* 0xEB */ u8 sandstormPrimA; + /* 0xEC */ u8 sandstormEnvA; /* 0xED */ u8 unk_ED; /* 0xEE */ u8 unk_EE[4]; /* 0xF2 */ u8 unk_F2[8]; // [3] is used by both DemoKankyo and ObjectKankyo effect count /* 0xFA */ u8 unk_FA[4]; } EnvironmentContext; // size = 0x100 -typedef struct { - /* 0x000 */ View view; - /* 0x168 */ void* staticSegments[4]; - /* 0x178 */ void* paletteStaticSegment; - /* 0x17C */ Gfx (*dListBuf)[150]; - /* 0x180 */ Gfx* roomDL; - /* 0x184 */ Vtx* roomVtx; - /* 0x188 */ DmaRequest unk188; - /* 0x1A8 */ DmaRequest unk1A8; - /* 0x1C8 */ DmaRequest unk1C8; - /* 0x1E8 */ OSMesgQueue loadQueue; - /* 0x200 */ OSMesg loadMsg; - /* 0x204 */ s16 skyboxShouldDraw; - /* 0x208 */ f32 rotX; - /* 0x20C */ f32 rotY; - /* 0x210 */ f32 rotZ; - /* 0x214 */ Vec3f eye; - /* 0x220 */ s16 angle; - /* 0x222 */ u8 primR; - /* 0x223 */ u8 primG; - /* 0x224 */ u8 primB; - /* 0x225 */ u8 envR; - /* 0x226 */ u8 envG; - /* 0x227 */ u8 envB; -} SkyboxContext; // size = 0x228 - -typedef enum { - /* 0x05 */ SKYBOX_CUTSCENE_MAP = 5 -} SkyboxId; - typedef struct ListAlloc { /* 0x0 */ struct ListAlloc* prev; /* 0x4 */ struct ListAlloc* next; @@ -619,64 +373,6 @@ typedef struct { /* 0x24 */ u32 flags; } PreRenderParams; // size = 0x28 -#define TRANS_TRIGGER_OFF 0 // transition is not active -#define TRANS_TRIGGER_START 20 // start transition (exiting an area) -#define TRANS_TRIGGER_END -20 // transition is ending (arriving in a new area) - -typedef enum TransitionMode { - /* 0 */ TRANS_MODE_OFF, - /* 1 */ TRANS_MODE_01, - /* 2 */ TRANS_MODE_02, - /* 3 */ TRANS_MODE_03, - /* 4 */ TRANS_MODE_04, - /* 5 */ TRANS_MODE_05, - /* 6 */ TRANS_MODE_06, - /* 7 */ TRANS_MODE_07, - /* 8 */ TRANS_MODE_08, - /* 9 */ TRANS_MODE_09, - /* 10 */ TRANS_MODE_10, - /* 11 */ TRANS_MODE_11, - /* 12 */ TRANS_MODE_12, - /* 13 */ TRANS_MODE_13, - /* 14 */ TRANS_MODE_14, - /* 15 */ TRANS_MODE_15, - /* 16 */ TRANS_MODE_16, - /* 17 */ TRANS_MODE_17 -} TransitionMode; - -typedef enum TransitionType { - /* 0 */ TRANS_TYPE_00, - /* 1 */ TRANS_TYPE_01, - /* 2 */ TRANS_TYPE_02, - /* 3 */ TRANS_TYPE_03, - /* 4 */ TRANS_TYPE_04, - /* 5 */ TRANS_TYPE_05, - /* 6 */ TRANS_TYPE_06, - /* 7 */ TRANS_TYPE_07, - /* 8 */ TRANS_TYPE_08, - /* 9 */ TRANS_TYPE_09, - /* 10 */ TRANS_TYPE_10, - /* 11 */ TRANS_TYPE_11, - /* 12 */ TRANS_TYPE_12, - /* 13 */ TRANS_TYPE_13, - /* 14 */ TRANS_TYPE_14, - /* 15 */ TRANS_TYPE_15, - /* 16 */ TRANS_TYPE_16, - /* 17 */ TRANS_TYPE_17, - /* 18 */ TRANS_TYPE_18, - /* 19 */ TRANS_TYPE_19, - /* 20 */ TRANS_TYPE_20, - /* 21 */ TRANS_TYPE_21, - /* 64 */ TRANS_TYPE_64 = 64, - /* 70 */ TRANS_TYPE_70 = 70, - /* 72 */ TRANS_TYPE_72 = 72, - /* 73 */ TRANS_TYPE_73, - /* 80 */ TRANS_TYPE_80 = 80, - /* 86 */ TRANS_TYPE_86 = 86 -} TransitionType; - -#define TRANS_NEXT_TYPE_DEFAULT 0xFF - typedef struct FaultAddrConvClient { /* 0x0 */ struct FaultAddrConvClient* next; /* 0x4 */ void* (*callback)(void*, void*); @@ -704,14 +400,10 @@ typedef struct { /* 0x7D8 */ FaultClient* clients; /* 0x7DC */ FaultAddrConvClient* addrConvClients; /* 0x7E0 */ UNK_TYPE1 pad7E0[0x4]; - /* 0x7E4 */ Input padInput[4]; + /* 0x7E4 */ Input padInput[MAXCONTROLLERS]; /* 0x844 */ void* fb; } FaultThreadStruct; // size = 0x848 -typedef struct FireObj FireObj; - -typedef struct FireObjLight FireObjLight; - struct GameState; typedef void (*GameStateFunc)(struct GameState* gameState); @@ -749,7 +441,7 @@ typedef struct GameState { /* 0x08 */ GameStateFunc destroy; /* 0x0C */ GameStateFunc init; // Usually the current game state's init, though after stopping, the graph thread will look here to determine the next game state to load. /* 0x10 */ size_t size; - /* 0x14 */ Input input[4]; + /* 0x14 */ Input input[MAXCONTROLLERS]; /* 0x74 */ TwoHeadArena heap; /* 0x84 */ GameAlloc alloc; /* 0x98 */ UNK_TYPE1 pad98[0x3]; @@ -760,72 +452,13 @@ typedef struct GameState { /* 0xA3 */ u8 unk_A3; } GameState; // size = 0xA4 -typedef struct { - /* 0x00 */ u32 resetting; - /* 0x04 */ u32 resetCount; - /* 0x08 */ OSTime duration; - /* 0x10 */ OSTime resetTime; -} PreNmiBuff; // size = 0x18 (actually osAppNmiBuffer is 0x40 bytes large but the rest is unused) +struct PlayState; -typedef struct PlayState PlayState; - -typedef s32 (*ColChkResetFunc)(PlayState*, Collider*); -typedef void (*ColChkBloodFunc)(PlayState*, Collider*, Vec3f*); -typedef void (*ColChkApplyFunc)(PlayState*, CollisionCheckContext*, Collider*); -typedef void (*ColChkVsFunc)(PlayState*, CollisionCheckContext*, Collider*, Collider*); -typedef s32 (*ColChkLineFunc)(PlayState*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*); - -typedef void(*room_draw_func)(PlayState* play, Room* room, u32 flags); - -typedef struct { - /* 0x000 */ u8 controllers; // bit 0 is set if controller 1 is plugged in, etc. - /* 0x001 */ UNK_TYPE1 pad1[0x13]; - /* 0x014 */ OSContStatus statuses[4]; - /* 0x024 */ UNK_TYPE4 unk24; - /* 0x028 */ OSMesg lockMesg[1]; - /* 0x02C */ OSMesg interrupts[8]; - /* 0x04C */ OSMesgQueue sSiIntMsgQ; - /* 0x064 */ OSMesgQueue lock; - /* 0x07C */ OSMesgQueue irqmgrCallbackQueue; - /* 0x094 */ IrqMgrClient irqmgrCallbackQueueNode; - /* 0x09C */ IrqMgr* irqmgr; - /* 0x0A0 */ OSThread thread; - /* 0x250 */ Input input[4]; - /* 0x2B0 */ OSContPad controllerState1[4]; - /* 0x2C8 */ u8 maxNumControllers; - /* 0x2C9 */ UNK_TYPE1 pad2C9[0x1B3]; - /* 0x47C */ u8 unk47C; - /* 0x47D */ u8 unk47D; - /* 0x47E */ u8 hasStopped; - /* 0x47F */ UNK_TYPE1 pad47F[0x1]; -} PadMgr; // size = 0x480 - -typedef struct StackEntry { - /* 0x00 */ struct StackEntry* next; - /* 0x04 */ struct StackEntry* prev; - /* 0x08 */ u32 head; - /* 0x0C */ u32 tail; - /* 0x10 */ u32 initValue; - /* 0x14 */ s32 minSpace; - /* 0x18 */ const char* name; -} StackEntry; // size = 0x1C - -typedef enum { - STACK_STATUS_OK = 0, - STACK_STATUS_WARNING = 1, - STACK_STATUS_OVERFLOW = 2 -} StackStatus; - -struct FireObjLight { - /* 0x00 */ LightNode* light; - /* 0x04 */ LightInfo lightInfo; - /* 0x12 */ u8 lightParamsIndex; -}; // size = 0x14 - -#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 -#define OS_SC_PRE_NMI_MSG 4 +typedef s32 (*ColChkResetFunc)(struct PlayState*, Collider*); +typedef void (*ColChkBloodFunc)(struct PlayState*, Collider*, Vec3f*); +typedef void (*ColChkApplyFunc)(struct PlayState*, CollisionCheckContext*, Collider*); +typedef void (*ColChkVsFunc)(struct PlayState*, CollisionCheckContext*, Collider*, Collider*); +typedef s32 (*ColChkLineFunc)(struct PlayState*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*); typedef struct { /* 0x000 */ IrqMgr* irqMgr; @@ -842,69 +475,12 @@ typedef struct { /* 0x130 */ OSThread thread; } AudioMgr; // size = 0x2E0 -typedef struct { - /* 0x00 */ MtxF displayMatrix; - /* 0x40 */ Actor* actor; - /* 0x44 */ Vec3f location; - /* 0x50 */ u8 flags; // bit 0 - footmark fades out - /* 0x51 */ u8 id; - /* 0x52 */ u8 red; - /* 0x53 */ u8 blue; - /* 0x54 */ u8 green; - /* 0x55 */ UNK_TYPE1 pad55[0x1]; - /* 0x56 */ u16 alpha; - /* 0x58 */ u16 alphaChange; - /* 0x5A */ u16 size; - /* 0x5C */ u16 fadeoutDelay; - /* 0x5E */ u16 age; -} EffFootmark; // size = 0x60 - -struct FireObj { - /* 0x00 */ Vec3f position; - /* 0x0C */ f32 size; - /* 0x10 */ f32 sizeInv; - /* 0x14 */ f32 xScale; - /* 0x18 */ f32 yScale; - /* 0x1C */ f32 dynamicSize; - /* 0x20 */ f32 dynamicSizeStep; - /* 0x24 */ u8 state; // 0 - growing, 1 - shrinking, 2 - fully lit, 3 - not lit - /* 0x25 */ u8 sizeGrowsCos2; - /* 0x26 */ u8 unk26; - /* 0x27 */ u8 colorsIndex; - /* 0x28 */ u8 flags; // bit 0 - ?, bit 1 - ? - /* 0x29 */ UNK_TYPE1 pad29[0x1]; - /* 0x2A */ s16 ignitionDelay; - /* 0x2C */ ColliderCylinder collision; - /* 0x78 */ FireObjLight light; -}; // size = 0x8B - typedef struct { /* 0x0 */ u8 seqId; /* 0x1 */ u8 ambienceId; } SequenceContext; // size = 0x2 -typedef struct { - /* 0x0 */ s32 enabled; - /* 0x4 */ s32 timer; -} FrameAdvanceContext; // size = 0x8 - -typedef enum { - /* 0 */ GAMEOVER_INACTIVE, - /* 1 */ GAMEOVER_DEATH_START, - /* 2 */ GAMEOVER_DEATH_WAIT_GROUND, // wait for player to fall and hit the ground - /* 3 */ GAMEOVER_DEATH_FADE_OUT, // wait before fading out - /* 20 */ GAMEOVER_REVIVE_START = 20, - /* 21 */ GAMEOVER_REVIVE_RUMBLE, - /* 22 */ GAMEOVER_REVIVE_WAIT_GROUND, // wait for player to fall and hit the ground - /* 23 */ GAMEOVER_REVIVE_WAIT_FAIRY, // wait for the fairy to rise all the way up out of player's body - /* 24 */ GAMEOVER_REVIVE_FADE_OUT // fade out the game over lights as player is revived and gets back up -} GameOverState; - -typedef struct { - /* 0x0 */ u16 state; -} GameOverContext; // size = 0x2 - -struct PlayState { +typedef struct PlayState { /* 0x00000 */ GameState state; /* 0x000A4 */ s16 sceneId; /* 0x000A6 */ u8 sceneConfig; @@ -948,15 +524,15 @@ struct PlayState { /* 0x1878C */ void (*unk_1878C)(struct PlayState* play); /* 0x18790 */ void (*unk_18790)(struct PlayState* play, s16 arg1); /* 0x18794 */ PlayerItemAction (*unk_18794)(struct PlayState* play, Player* player, ItemId itemId); - /* 0x18798 */ s32 (*setPlayerTalkAnim)(struct PlayState* play, LinkAnimationHeader* talkAnim, s32 animMode); - /* 0x1879C */ s16 playerActorCsIds[10]; + /* 0x18798 */ s32 (*setPlayerTalkAnim)(struct PlayState* play, PlayerAnimationHeader* talkAnim, AnimationMode animMode); + /* 0x1879C */ s16 playerCsIds[PLAYER_CS_ID_MAX]; /* 0x187B0 */ MtxF viewProjectionMtxF; - /* 0x187F0 */ Vec3f unk_187F0; + /* 0x187F0 */ Vec3f projectionMtxFDiagonal; /* 0x187FC */ MtxF billboardMtxF; /* 0x1883C */ Mtx* billboardMtx; /* 0x18840 */ u32 gameplayFrames; - /* 0x18844 */ u8 unk_18844; - /* 0x18845 */ u8 unk_18845; + /* 0x18844 */ u8 unk_18844; // bool + /* 0x18845 */ u8 haltAllActors; /* 0x18846 */ s16 numSetupActors; /* 0x18848 */ u8 numRooms; /* 0x1884C */ RomFile* roomList; @@ -969,9 +545,9 @@ struct PlayState { /* 0x18868 */ void* naviQuestHints; // leftover from OoT, system which processes this is removed /* 0x1886C */ AnimatedMaterial* sceneMaterialAnims; /* 0x18870 */ void* specialEffects; - /* 0x18874 */ u8 skyboxId; + /* 0x18874 */ u8 skyboxId; // @see SkyboxId enum /* 0x18875 */ s8 transitionTrigger; // "fade_direction" - /* 0x18876 */ s16 unk_18876; + /* 0x18876 */ s16 worldCoverAlpha; /* 0x18878 */ s16 bgCoverAlpha; /* 0x1887A */ u16 nextEntrance; /* 0x1887C */ s8 unk_1887C; // shootingGalleryStatus? @@ -980,40 +556,57 @@ struct PlayState { /* 0x1887F */ u8 transitionType; // fadeTransition /* 0x18880 */ u8 unk_18880; /* 0x18884 */ CollisionCheckContext colChkCtx; - /* 0x18B20 */ u16 envFlags[20]; + /* 0x18B20 */ u16 cutsceneFlags[20]; /* 0x18B48 */ u8 curSpawn; /* 0x18B49 */ u8 unk_18B49; /* 0x18B4A */ u8 transitionMode; /* 0x18B4C */ PreRender pauseBgPreRender; - /* 0x18B9C */ char unk_18B9C[0x2B8]; + /* 0x18B9C */ char unk_18B9C[0x54]; + /* 0x18BF0 */ TransitionContext transitionCtx; + /* 0x18E48 */ TransitionFade unk_18E48; /* 0x18E54 */ SceneTableEntry* loadedScene; - /* 0x18E58 */ char unk_18E58[0x4]; + /* 0x18E58 */ void* unk_18E58; /* 0x18E5C */ TexturePtr pictoPhotoI8; - /* 0x18E60 */ char unk_18E60[0x8]; - /* 0x18E68 */ void* unk_18E68; + /* 0x18E60 */ void* unk_18E60; + /* 0x18E64 */ void* unk_18E64; + /* 0x18E68 */ void* unk_18E68; // framebuffer related to Lens of Truth /* 0x18E6C */ char unk_18E6C[0x3EC]; -}; // size = 0x19258 +} PlayState; // size = 0x19258 typedef struct { - /* 0x00 */ s32 unk0; - /* 0x04 */ s32 unk4; - /* 0x08 */ s32 unk8; - /* 0x0C */ s32 unkC; - /* 0x10 */ s32 unk10; -} struct_801C5F44; // size = 0x14 + /* 0x00 */ u8 unk_00; + /* 0x01 */ char unk_01[0x3F]; + /* 0x40 */ void* unk_40; + /* 0x44 */ u32 unk_44; + /* 0x48 */ u32 unk_48; + /* 0x4C */ DmaRequest unk_4C; + /* 0x6C */ OSMesgQueue unk_6C; + /* 0x84 */ OSMesg unk_84[1]; + /* 0x88 */ void* unk_88; + /* 0x8C */ uintptr_t unk_8C; + /* 0x90 */ size_t unk_90; + /* 0x94 */ s32 unk_94; + /* 0x98 */ s32 unk_98; + /* 0x9C */ s32 unk_9C; + /* 0xA0 */ char unk_A0[0x4]; + /* 0xA4 */ s32 unk_A4; + /* 0xA8 */ s32 unk_A8; +} BombersNotebook; // size = 0xAC + +typedef enum { + /* 0 */ PICTO_PHOTO_STATE_OFF, + /* 1 */ PICTO_PHOTO_STATE_SETUP, + /* 2 */ PICTO_PHOTO_STATE_PROCESS, + /* 3 */ PICTO_PHOTO_STATE_READY +} PictoPhotoState; -// From OoT's struct_80034A14_arg1 typedef struct { - /* 0x00 */ s16 unk_00; - /* 0x02 */ s16 unk_02; - /* 0x04 */ s16 unk_04; - /* 0x06 */ s16 unk_06; - /* 0x08 */ Vec3s unk_08; - /* 0x0E */ Vec3s unk_0E; - /* 0x14 */ f32 unk_14; - /* 0x18 */ Vec3f unk_18; // Usually setted to Player's position or Player's focus - /* 0x24 */ s16 unk_24; -} struct_800BD888_arg1; // size = 0x28 + /* 0x00 */ u8 mode; + /* 0x04 */ f32 scale; + /* 0x08 */ f32 lodProportion; // expected to be between 0.0f and 1.0f + /* 0x0C */ Color_RGBA8_u32 primColor; + /* 0x10 */ Color_RGBA8_u32 envColor; +} Struct_80140E80; // size = 0x14 typedef struct { /* 0x0 */ u32 type; @@ -1025,9 +618,9 @@ typedef struct { typedef struct { /* 0x0 */ u32 useRgba; /* 0x4 */ u32 setScissor; - /* 0x8 */ Color_RGBA8 primColor; - /* 0xC */ Color_RGBA8 envColor; -} struct_801F8020; // size = 0x10 + /* 0x8 */ Color_RGBA8_u32 primColor; + /* 0xC */ Color_RGBA8_u32 envColor; +} VisZbuf; // size = 0x10 typedef struct { /* 0x00 */ u32 unk_00; @@ -1038,21 +631,6 @@ typedef struct { /* 0x14 */ Gfx* dList; } VisMono; // size = 0x18 -typedef struct DebugDispObject { - /* 0x00 */ Vec3f pos; - /* 0x0C */ Vec3s rot; - /* 0x14 */ Vec3f scale; - /* 0x20 */ Color_RGBA8 color; - /* 0x24 */ s16 type; - /* 0x28 */ struct DebugDispObject* next; - /* 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 { /* 0x0 */ u8* value; /* 0x4 */ const char* name; @@ -1097,35 +675,4 @@ enum fram_mode { FRAM_MODE_STATUS }; -typedef struct { - /* 0x00 */ UNK_TYPE1 unk_00[0x14]; - /* 0x14 */ s16 unk_14; - /* 0x16 */ s16 unk_16; - /* 0x18 */ s16 unk_18; - /* 0x1A */ UNK_TYPE1 unk_1A[0x3]; - /* 0x0C */ u8 unk_1D; - /* 0x1E */ UNK_TYPE1 unk_1E[0xC]; - /* 0x2A */ s16 unk_2A; - /* 0x1E */ UNK_TYPE1 unk_2C[0x1]; - /* 0x2D */ u8 unk_2D; - /* 0x2E */ UNK_TYPE1 unk_2E[2]; -} DbCameraUnkSubStruct; // size = 0x30 - -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 */ s16 unk_0C; - /* 0x0E */ UNK_TYPE1 unk_0E[0x02]; - /* 0x10 */ DbCameraUnkSubStruct unk_10; - /* 0x40 */ DbCameraUnkSubStruct unk_40; - /* 0x70 */ UNK_PTR unk_70; - /* 0x74 */ UNK_PTR unk_74; - /* 0x78 */ UNK_PTR unk_78; - /* 0x7C */ Camera* camera; -} DbCameraUnkStruct; // size = 0x80 - #endif diff --git a/include/z64actor.h b/include/z64actor.h index 370b49e75..3a646fe8f 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -22,6 +22,8 @@ struct EnBox; struct EnTorch2; typedef void(*ActorFunc)(struct Actor* this, struct PlayState* play); +typedef u16 (*NpcGetTextIdFunc)(struct PlayState*, struct Actor*); +typedef s16 (*NpcUpdateTalkStateFunc)(struct PlayState*, struct Actor*); typedef struct { /* 0x00 */ Vec3f pos; @@ -99,13 +101,13 @@ typedef struct { /* 0x1C */ ActorFunc draw; } ActorInit; // size = 0x20 -typedef enum { - ALLOCTYPE_NORMAL, - ALLOCTYPE_ABSOLUTE, - ALLOCTYPE_PERMANENT +typedef enum AllocType { + /* 0 */ ALLOCTYPE_NORMAL, + /* 1 */ ALLOCTYPE_ABSOLUTE, + /* 2 */ ALLOCTYPE_PERMANENT } AllocType; -typedef struct { +typedef struct ActorOverlay { /* 0x00 */ uintptr_t vromStart; /* 0x04 */ uintptr_t vromEnd; /* 0x08 */ void* vramStart; @@ -132,6 +134,35 @@ typedef struct { /* 0x18 */ Vec3f feetPos[2]; // Update by using `Actor_SetFeetPos` in PostLimbDrawOpa } ActorShape; // size = 0x30 +// Flags for bgCheckFlags +#define BGCHECKFLAG_GROUND (1 << 0) // Standing on the ground +#define BGCHECKFLAG_GROUND_TOUCH (1 << 1) // Has touched the ground (only active for 1 frame) +#define BGCHECKFLAG_GROUND_LEAVE (1 << 2) // Has left the ground (only active for 1 frame) +#define BGCHECKFLAG_WALL (1 << 3) // Touching a wall +#define BGCHECKFLAG_CEILING (1 << 4) // Touching a ceiling +#define BGCHECKFLAG_WATER (1 << 5) // In water +#define BGCHECKFLAG_WATER_TOUCH (1 << 6) // Has touched water (reset when leaving water) +#define BGCHECKFLAG_GROUND_STRICT (1 << 7) // Similar to BGCHECKFLAG_GROUND but with no velocity check and is cleared every frame +#define BGCHECKFLAG_CRUSHED (1 << 8) // Crushed between a floor and ceiling (triggers a void for player) +#define BGCHECKFLAG_PLAYER_WALL_INTERACT (1 << 9) // Only set/used by player, related to interacting with walls +#define BGCHECKFLAG_PLAYER_400 (1 << 10) // +#define BGCHECKFLAG_PLAYER_800 (1 << 11) // +#define BGCHECKFLAG_PLAYER_1000 (1 << 12) // + +// Flags for Actor_UpdateBgCheckInfo +#define UPDBGCHECKINFO_FLAG_1 (1 << 0) // check wall +#define UPDBGCHECKINFO_FLAG_2 (1 << 1) // check ceiling +#define UPDBGCHECKINFO_FLAG_4 (1 << 2) // check floor and water +#define UPDBGCHECKINFO_FLAG_8 (1 << 3) +#define UPDBGCHECKINFO_FLAG_10 (1 << 4) +#define UPDBGCHECKINFO_FLAG_20 (1 << 5) // unused +#define UPDBGCHECKINFO_FLAG_40 (1 << 6) // disable water ripples +#define UPDBGCHECKINFO_FLAG_80 (1 << 7) +#define UPDBGCHECKINFO_FLAG_100 (1 << 8) +#define UPDBGCHECKINFO_FLAG_200 (1 << 9) +#define UPDBGCHECKINFO_FLAG_400 (1 << 10) // check water +#define UPDBGCHECKINFO_FLAG_800 (1 << 11) + typedef struct Actor { /* 0x000 */ s16 id; // Actor ID /* 0x002 */ u8 category; // Actor category. Refer to the corresponding enum for values @@ -141,16 +172,16 @@ typedef struct Actor { /* 0x01C */ s16 params; // Configurable variable set by the actor's spawn data; original name: "args_data" /* 0x01E */ s8 objBankIndex; // Object bank index of the actor's object dependency; original name: "bank" /* 0x01F */ s8 targetMode; // Controls how far the actor can be targeted from and how far it can stay locked on - /* 0x020 */ s16 unk20; + /* 0x020 */ s16 halfDaysBits; // Bitmask indicating which half-days this actor is allowed to not be killed(?) (TODO: not sure how to word this). If the current halfDayBit is not part of this mask then the actor is killed when spawning the setup actors /* 0x024 */ PosRot world; // Position/rotation in the world - /* 0x038 */ s8 cutscene; + /* 0x038 */ s8 csId; // ActorCutscene index, see `CutsceneId` /* 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 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 + /* 0x070 */ f32 speed; // Context dependent speed value. Can be used for XZ or XYZ depending on which move function is used /* 0x074 */ f32 gravity; // Acceleration due to gravity. Value is added to Y velocity every frame /* 0x078 */ f32 terminalVelocity; // Sets the lower bounds cap on velocity along the Y axis /* 0x07C */ struct CollisionPoly* wallPoly; // Wall polygon the actor is touching @@ -160,7 +191,7 @@ typedef struct Actor { /* 0x086 */ s16 wallYaw; // Y rotation of the wall polygon the actor is touching /* 0x088 */ f32 floorHeight; // Y position of the floor polygon directly below the actor /* 0x08C */ f32 depthInWater; // Directed distance to the surface of active waterbox. Negative value means water is below. - /* 0x090 */ u16 bgCheckFlags; // See comments below actor struct for wip docs. TODO: macros for these flags + /* 0x090 */ u16 bgCheckFlags; // Flags indicating how the actor is interacting with collision /* 0x092 */ s16 yawTowardsPlayer; // Y rotation difference between the actor and the player /* 0x094 */ f32 xyzDistToPlayerSq; // Squared distance between the actor and the player in the x,y,z axis /* 0x098 */ f32 xzDistToPlayer; // Distance between the actor and the player in the XZ plane @@ -198,19 +229,14 @@ typedef enum { /* 1 */ FOOT_RIGHT } ActorFootIndex; -/** - * BgCheckFlags WIP documentation (logical masks): - * 0x001 : Standing on the ground - * 0x002 : Has touched the ground (only active for 1 frame) - * 0x004 : Has left the ground (only active for 1 frame) - * 0x008 : Touching a wall - * 0x010 : Touching a ceiling - * 0x020 : On or below water surface - * 0x040 : Has touched water (actor is responsible for unsetting this the frame it touches the water) - * 0x080 : Similar to & 0x1 but with no velocity check and is cleared every frame - * 0x100 : Crushed between a floor and ceiling (triggers a void for player) - * 0x200 : Only set/used by player, related to interacting with walls - */ +#define DYNA_TRANSFORM_POS (1 << 0) // Position of the actors on top follows the dynapoly actor's movement. +#define DYNA_TRANSFORM_ROT_Y (1 << 1) // The Y rotation of the actors on top follows the dynapoly actor's Y rotation. + +#define DYNA_INTERACT_ACTOR_ON_TOP (1 << 0) // There is an actor standing on the collision of the dynapoly actor +#define DYNA_INTERACT_PLAYER_ON_TOP (1 << 1) // The player actor is standing on the collision of the dynapoly actor +#define DYNA_INTERACT_PLAYER_ABOVE (1 << 2) // The player is directly above the collision of the dynapoly actor (any distance above) +#define DYNA_INTERACT_ACTOR_ON_SWITCH (1 << 3) // Like the ACTOR_ON_TOP flag but only actors with ACTOR_FLAG_CAN_PRESS_SWITCH +#define DYNA_INTERACT_ACTOR_ON_HEAVY_SWITCH (1 << 4) // Like the ACTOR_ON_TOP flag but only actors with ACTOR_FLAG_CAN_PRESS_HEAVY_SWITCH typedef struct { /* 0x000 */ Actor actor; @@ -218,10 +244,8 @@ typedef struct { /* 0x148 */ f32 pushForce; /* 0x14C */ f32 unk14C; /* 0x150 */ s16 yRotation; - /* 0x152 */ u16 unk152; - /* 0x154 */ u32 flags; - /* 0x158 */ u8 stateFlags; - /* 0x15A */ s16 pad15A; + /* 0x154 */ u32 transformFlags; + /* 0x158 */ u8 interactFlags; } DynaPolyActor; // size = 0x15C @@ -365,6 +389,19 @@ typedef struct { /* 0xE */ s16 intensity; } TitleCardContext; // size = 0x10 +typedef enum { + /* 0 */ PLAYER_IMPACT_GORON_GROUND_POUND, + /* 1 */ PLAYER_IMPACT_ZORA_BARRIER, + /* 2 */ PLAYER_IMPACT_BONK // also activated by goron attack +} PlayerImpactType; + +typedef struct PlayerImpact { + /* 0x00 */ u8 type; + /* 0x01 */ u8 timer; + /* 0x04 */ f32 dist; + /* 0x08 */ Vec3f pos; +} PlayerImpact; // size = 0x14 + typedef struct ActorContext_unk_20C { /* 0x0 */ s16 id; /* 0x2 */ s8 isDynamicallyInitialised; @@ -385,9 +422,31 @@ typedef struct ActorListEntry { /* 0x8 */ s32 unk_08; } ActorListEntry; // size = 0xC +typedef enum { + /* 0 */ LENS_MODE_HIDE_ACTORS, // lens actors are visible by default, and hidden by using lens (for example, fake walls) + /* 1 */ LENS_MODE_SHOW_ACTORS // lens actors are invisible by default, and shown by using lens (for example, invisible enemies) +} LensMode; + +#define LENS_ACTOR_MAX 32 + // Target size when activated #define LENS_MASK_ACTIVE_SIZE 100 +#define HALFDAYBIT_DAY0_DAWN (1 << 9) +#define HALFDAYBIT_DAY0_NIGHT (1 << 8) +#define HALFDAYBIT_DAY1_DAWN (1 << 7) +#define HALFDAYBIT_DAY1_NIGHT (1 << 6) +#define HALFDAYBIT_DAY2_DAWN (1 << 5) +#define HALFDAYBIT_DAY2_NIGHT (1 << 4) +#define HALFDAYBIT_DAY3_DAWN (1 << 3) +#define HALFDAYBIT_DAY3_NIGHT (1 << 2) +#define HALFDAYBIT_DAY4_DAWN (1 << 1) +#define HALFDAYBIT_DAY4_NIGHT (1 << 0) + +#define HALFDAYBIT_DAWNS (HALFDAYBIT_DAY0_DAWN | HALFDAYBIT_DAY1_DAWN | HALFDAYBIT_DAY2_DAWN | HALFDAYBIT_DAY3_DAWN | HALFDAYBIT_DAY4_DAWN) +#define HALFDAYBIT_NIGHTS (HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY1_NIGHT | HALFDAYBIT_DAY2_NIGHT | HALFDAYBIT_DAY3_NIGHT | HALFDAYBIT_DAY4_NIGHT) +#define HALFDAYBIT_ALL (HALFDAYBIT_DAWNS | HALFDAYBIT_NIGHTS) + typedef struct ActorContext { /* 0x000 */ u8 freezeFlashTimer; /* 0x001 */ UNK_TYPE1 pad1; @@ -397,19 +456,15 @@ typedef struct ActorContext { /* 0x005 */ u8 flags; /* 0x006 */ UNK_TYPE1 pad6[0x5]; /* 0x00B */ s8 lensActorsDrawn; - /* 0x00C */ s16 unkC; + /* 0x00C */ s16 halfDaysBit; // A single bit indicating the current half-day. It is one of HALFDAYBIT_DAYX_ macro values /* 0x00E */ u8 totalLoadedActors; - /* 0x00F */ u8 undrawnActorCount; + /* 0x00F */ u8 numLensActors; /* 0x010 */ ActorListEntry actorLists[ACTORCAT_MAX]; - /* 0x0A0 */ Actor* undrawnActors[32]; // Records the first 32 actors drawn each frame + /* 0x0A0 */ Actor* lensActors[LENS_ACTOR_MAX]; // Draws up to LENS_ACTOR_MAX number of invisible actors /* 0x120 */ TargetContext targetContext; /* 0x1B8 */ ActorContextSceneFlags sceneFlags; /* 0x1E4 */ TitleCardContext titleCtxt; - /* 0x1F4 */ u8 unk1F4; - /* 0x1F5 */ u8 unk1F5; - /* 0x1F6 */ UNK_TYPE1 pad1F6[0x2]; - /* 0x1F8 */ f32 unk1F8; - /* 0x1FC */ Vec3f unk1FC; + /* 0x1F4 */ PlayerImpact playerImpact; /* 0x208 */ UNK_TYPE1 unk_208[0x4]; /* 0x20C */ ActorContext_unk_20C unk_20C[8]; /* 0x24C */ UNK_TYPE1 unk_24C[0x4]; @@ -467,18 +522,18 @@ typedef enum { #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) +// hidden or revealed by Lens of Truth (depending on room lensMode) +#define ACTOR_FLAG_REACT_TO_LENS (1 << 7) +// Player has requested to talk to the actor; Player uses this flag differently than every other actor +#define ACTOR_FLAG_TALK_REQUESTED (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) +// Actor will not shake when a quake occurs +#define ACTOR_FLAG_IGNORE_QUAKE (1 << 12) // #define ACTOR_FLAG_2000 (1 << 13) // @@ -487,8 +542,8 @@ typedef enum { #define ACTOR_FLAG_8000 (1 << 15) // #define ACTOR_FLAG_10000 (1 << 16) -// -#define ACTOR_FLAG_20000 (1 << 17) +// actor can press and hold down heavy switches +#define ACTOR_FLAG_CAN_PRESS_HEAVY_SWITCH (1 << 17) // #define ACTOR_FLAG_40000 (1 << 18) // @@ -505,10 +560,10 @@ typedef enum { #define ACTOR_FLAG_1000000 (1 << 24) // #define ACTOR_FLAG_2000000 (1 << 25) -// -#define ACTOR_FLAG_4000000 (1 << 26) -// -#define ACTOR_FLAG_8000000 (1 << 27) +// actor can press and hold down switches +#define ACTOR_FLAG_CAN_PRESS_SWITCH (1 << 26) +// Prevents locking on with Z targeting an actor even if Tatl is floating over it +#define ACTOR_FLAG_CANT_LOCK_ON (1 << 27) // #define ACTOR_FLAG_10000000 (1 << 28) // @@ -518,6 +573,25 @@ typedef enum { // #define ACTOR_FLAG_80000000 (1 << 31) +#define DROPFLAG_NONE (0) +#define DROPFLAG_1 (1 << 0) +#define DROPFLAG_2 (1 << 1) +#define DROPFLAG_20 (1 << 5) + +#define COLORFILTER_GET_COLORFLAG(colorFilterParams) ((colorFilterParams) & 0xC000) +#define COLORFILTER_GET_COLORINTENSITY(colorFilterParams) (((colorFilterParams) & 0x1F00) >> 5) +#define COLORFILTER_GET_DURATION(colorFilterParams) ((colorFilterParams) & 0xFF) + +#define COLORFILTER_COLORFLAG_NONE 0xC000 +#define COLORFILTER_COLORFLAG_GRAY 0x8000 +#define COLORFILTER_COLORFLAG_RED 0x4000 +#define COLORFILTER_COLORFLAG_BLUE 0x0000 + +#define COLORFILTER_INTENSITY_FLAG 0x8000 + +#define COLORFILTER_BUFFLAG_XLU 0x2000 +#define COLORFILTER_BUFFLAG_OPA 0x0000 + typedef enum { /* 0x00 */ CLEAR_TAG_SMALL_EXPLOSION, /* 0x01 */ CLEAR_TAG_LARGE_EXPLOSION, @@ -633,4 +707,41 @@ typedef enum { /* 0xFF */ TATL_HINT_ID_NONE = 0xFF } TatlHintId; +typedef struct TargetRangeParams { + /* 0x0 */ f32 rangeSq; + /* 0x4 */ f32 leashScale; +} TargetRangeParams; // size = 0x8 + +typedef enum NpcTalkState { + /* 0 */ NPC_TALK_STATE_IDLE, // NPC not currently talking to player + /* 1 */ NPC_TALK_STATE_TALKING, // NPC is currently talking to player + /* 2 */ NPC_TALK_STATE_ACTION, // An NPC-defined action triggered in the conversation + /* 3 */ NPC_TALK_STATE_ITEM_GIVEN // NPC finished giving an item and text box is done +} NpcTalkState; + +typedef enum NpcTrackingMode { + /* 0 */ NPC_TRACKING_PLAYER_AUTO_TURN, // Determine tracking mode based on player position, see Npc_UpdateAutoTurn + /* 1 */ NPC_TRACKING_NONE, // Don't track the target (usually the player) + /* 2 */ NPC_TRACKING_HEAD_AND_TORSO, // Track target by turning the head and the torso + /* 3 */ NPC_TRACKING_HEAD, // Track target by turning the head + /* 4 */ NPC_TRACKING_FULL_BODY // Track target by turning the body, torso and head +} NpcTrackingMode; + +typedef struct NpcInteractInfo { + /* 0x00 */ s16 talkState; + /* 0x02 */ s16 trackingMode; + /* 0x04 */ s16 autoTurnTimer; + /* 0x06 */ s16 autoTurnState; + /* 0x08 */ Vec3s headRot; + /* 0x0E */ Vec3s torsoRot; + /* 0x14 */ f32 yOffset; // Y position offset to add to actor position when calculating angle to target + /* 0x18 */ Vec3f trackPos; + /* 0x24 */ UNK_TYPE1 unk_24[0x4]; +} NpcInteractInfo; // size = 0x28 + +extern TargetRangeParams gTargetRanges[]; +extern s16 D_801AED48[8]; +extern Gfx D_801AEF88[]; +extern Gfx D_801AEFA0[]; + #endif diff --git a/include/z64animation.h b/include/z64animation.h index 272a4fb84..44c35312d 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -1,5 +1,5 @@ -#ifndef Z64_ANIMATION_H -#define Z64_ANIMATION_H +#ifndef Z64ANIMATION_H +#define Z64ANIMATION_H #include "PR/ultratypes.h" #include "PR/gbi.h" @@ -11,10 +11,7 @@ struct Actor; struct SkelAnime; struct PlayerAnimationFrame; -#define LINK_ANIMETION_OFFSET(addr, offset) \ - (SEGMENT_ROM_START(link_animetion) + ((uintptr_t)addr & 0xFFFFFF) + ((u32)offset)) #define LIMB_DONE 0xFF -#define ANIMATION_ENTRY_MAX 50 #define ANIM_FLAG_1 (1 << 0) #define ANIM_FLAG_UPDATEY (1 << 1) @@ -30,9 +27,9 @@ typedef enum AnimationMode { /* 5 */ ANIMMODE_LOOP_PARTIAL_INTERP } AnimationMode; -typedef enum { +typedef enum { /* -1 */ ANIMTAPER_DECEL = -1, - /* 0 */ ANIMTAPER_NONE, + /* 0 */ ANIMTAPER_NONE, /* 1 */ ANIMTAPER_ACCEL } AnimationTapers; @@ -82,35 +79,19 @@ typedef struct { /* 0xC */ u16 staticIndexMax; } AnimationHeader; // size = 0x10 -typedef struct { - /* 0x00 */ s16 xMax; - /* 0x02 */ s16 x; - /* 0x04 */ s16 yMax; - /* 0x06 */ s16 y; - /* 0x08 */ s16 zMax; - /* 0x10 */ s16 z; -} JointKey; // size = 0x12 - -typedef struct { - /* 0x0 */ s16 frameCount; - /* 0x2 */ s16 limbCount; - /* 0x4 */ s16* frameData; - /* 0x8 */ JointKey* jointKey; -} LegacyAnimationHeader; // size = 0xC - typedef enum { - ANIMATION_LINKANIMETION, - ANIMENTRY_COPYALL, - ANIMENTRY_INTERP, - ANIMENTRY_COPYTRUE, - ANIMENTRY_COPYFALSE, - ANIMENTRY_MOVEACTOR + /* 0 */ ANIMATION_LINKANIMETION, + /* 1 */ ANIMENTRY_COPYALL, + /* 2 */ ANIMENTRY_INTERP, + /* 3 */ ANIMENTRY_COPYTRUE, + /* 4 */ ANIMENTRY_COPYFALSE, + /* 5 */ ANIMENTRY_MOVEACTOR } AnimationType; typedef struct { /* 0x00 */ DmaRequest req; /* 0x20 */ OSMesgQueue msgQueue; - /* 0x38 */ OSMesg msg; + /* 0x38 */ OSMesg msg[1]; } AnimEntryLoadFrame; // size = 0x3C typedef struct { @@ -166,16 +147,16 @@ typedef struct { typedef struct AnimationContext { /* 0x000 */ s16 animationCount; - /* 0x004 */ AnimationEntry entries[ANIMATION_ENTRY_MAX]; + /* 0x004 */ AnimationEntry entries[50]; } AnimationContext; // size = 0xC84 typedef struct { /* 0x0 */ AnimationHeaderCommon common; /* 0x4 */ union { void* segmentVoid; - struct PlayerAnimationFrame* segment; + struct PlayerAnimationFrame* linkAnimSegment; }; -} LinkAnimationHeader; // size = 0x8 +} PlayerAnimationHeader; // size = 0x8 typedef struct SkelAnime { /* 0x00 */ u8 limbCount; // Number of limbs in the skeleton @@ -183,7 +164,7 @@ typedef struct SkelAnime { /* 0x02 */ u8 dListCount; // Number of display lists in a flexible skeleton /* 0x03 */ s8 taper; // Tapering to use when morphing between animations. Only used by Door_Warp1. /* 0x04 */ void** skeleton; // An array of pointers to limbs. Can be StandardLimb, LodLimb, or SkinLimb. - /* 0x08 */ void* animation; // Can be an AnimationHeader or LinkAnimationHeader. + /* 0x08 */ void* animation; // Can be an AnimationHeader or PlayerAnimationHeader. /* 0x0C */ f32 startFrame; // In mode 4, start of partial loop. /* 0x10 */ f32 endFrame; // In mode 2, Update returns true when curFrame is equal to this. In mode 4, end of partial loop. /* 0x14 */ f32 animLength; // Total number of frames in the current animation's file. @@ -195,10 +176,10 @@ typedef struct SkelAnime { /* 0x2C */ f32 morphRate; // Reciprocal of the number of frames in the morph /* 0x30 */ union { s32 (*normal)(struct SkelAnime*);// Can be Loop, Partial loop, Play once, Morph, or Tapered morph - s32 (*link)(struct PlayState*, struct SkelAnime*); // Loop, Play once, and Morph + s32 (*player)(struct PlayState*, struct SkelAnime*); // Loop, Play once, and Morph } update; - /* 0x34 */ s8 initFlags; // Flags used when initializing Link's skeleton - /* 0x35 */ u8 moveFlags; // Flags used for animations that move the actor in worldspace. + /* 0x34 */ s8 initFlags; // Flags used when initializing Player's skeleton + /* 0x35 */ u8 moveFlags; // Flags used for animations that move the actor in worldspace. /* 0x36 */ s16 prevRot; // Previous rotation in worldspace. /* 0x38 */ Vec3s prevTransl; // Previous modelspace translation. /* 0x3E */ Vec3s baseTransl; // Base modelspace translation. @@ -228,8 +209,6 @@ typedef void (*TransformLimbDraw)(struct PlayState* play, s32 limbIndex, struct typedef void (*AnimationEntryCallback)(struct PlayState*, AnimationEntryData*); -extern u32 link_animetion_segment; - typedef struct { /* 0x00 */ AnimationHeader* animation; /* 0x04 */ f32 playSpeed; @@ -324,4 +303,68 @@ typedef s32 (*OverrideKeyframeDrawScaled)(struct PlayState* play, SkeletonInfo* typedef void (*PostKeyframeDrawScaled)(struct PlayState* play, SkeletonInfo* skeleton, s32 limbIndex, Gfx** dList, u8* flags, struct Actor* actor, Vec3f* scale, Vec3s* rot, Vec3f* pos); +void SkelAnime_DrawLod(struct PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, struct Actor* actor, s32 lod); +void SkelAnime_DrawFlexLod(struct PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, struct Actor* actor, s32 lod); +void SkelAnime_DrawOpa(struct PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, struct Actor* actor); +void SkelAnime_DrawFlexOpa(struct PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, struct Actor* actor); +void SkelAnime_DrawTransformFlexOpa(struct PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, struct Actor* actor); +s16 Animation_GetLastFrame(void* animation); +Gfx* SkelAnime_Draw(struct PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, struct Actor* actor, Gfx* gfx); +Gfx* SkelAnime_DrawFlex(struct PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, struct Actor* actor, Gfx* gfx); + +void AnimationContext_Reset(AnimationContext* animationCtx); +void AnimationContext_SetNextQueue(struct PlayState* play); +void AnimationContext_DisableQueue(struct PlayState* play); +void AnimationContext_SetLoadFrame(struct PlayState* play, PlayerAnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable); +void AnimationContext_SetCopyAll(struct PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src); +void AnimationContext_SetInterp(struct PlayState* play, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight); +void AnimationContext_SetCopyTrue(struct PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag); +void AnimationContext_SetCopyFalse(struct PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag); +void AnimationContext_SetMoveActor(struct PlayState* play, struct Actor* actor, SkelAnime* skelAnime, f32 arg3); + +void AnimationContext_Update(struct PlayState* play, AnimationContext* animationCtx); +void SkelAnime_InitPlayer(struct PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, PlayerAnimationHeader* animation, s32 flags, void* jointTableBuffer, void* morphTableBuffer, s32 limbBufCount); +void PlayerAnimation_SetUpdateFunction(SkelAnime* skelAnime); +s32 PlayerAnimation_Update(struct PlayState* play, SkelAnime* skelAnime); +void Animation_SetMorph(struct PlayState* play, SkelAnime* skelAnime, f32 morphFrames); +void PlayerAnimation_Change(struct PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames); +void PlayerAnimation_PlayOnce(struct PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation); +void PlayerAnimation_PlayOnceSetSpeed(struct PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation, f32 playSpeed); +void PlayerAnimation_PlayLoop(struct PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation); +void PlayerAnimation_PlayLoopSetSpeed(struct PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation, f32 playSpeed); +void PlayerAnimation_CopyJointToMorph(struct PlayState* play, SkelAnime* skelAnime); +void PlayerAnimation_CopyMorphToJoint(struct PlayState* play, SkelAnime* skelAnime); +void PlayerAnimation_LoadToMorph(struct PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation, f32 frame); +void PlayerAnimation_LoadToJoint(struct PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation, f32 frame); +void PlayerAnimation_InterpJointMorph(struct PlayState* play, SkelAnime* skelAnime, f32 weight); +void PlayerAnimation_BlendToJoint(struct PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation1, f32 frame1, PlayerAnimationHeader* animation2, f32 frame2, f32 blendWeight, void* blendTableBuffer); +void PlayerAnimation_BlendToMorph(struct PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation1, f32 frame1, PlayerAnimationHeader* animation2, f32 frame2, f32 blendWeight, void* blendTableBuffer); +void PlayerAnimation_EndLoop(SkelAnime* skelAnime); +s32 PlayerAnimation_OnFrame(SkelAnime* skelAnime, f32 frame); + +void SkelAnime_Init(struct PlayState* play, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); +void SkelAnime_InitFlex(struct PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); +void SkelAnime_InitSkin(struct GameState* gameState, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation); + +s32 SkelAnime_Update(SkelAnime* skelAnime); +void Animation_ChangeImpl(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames, s8 taper); +void Animation_Change(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames); +void Animation_PlayOnce(SkelAnime* skelAnime, AnimationHeader* animation); +void Animation_MorphToPlayOnce(SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames); +void Animation_PlayOnceSetSpeed(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed); +void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animation); +void Animation_MorphToLoop(SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames); +void Animation_PlayLoopSetSpeed(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed); +void Animation_EndLoop(SkelAnime* skelAnime); +void Animation_Reverse(SkelAnime* skelAnime); +void SkelAnime_CopyFrameTableTrue(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* copyFlag); +void SkelAnime_CopyFrameTableFalse(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* copyFlag); +void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* diff, s16 angle); +s32 Animation_OnFrame(SkelAnime* skelAnime, f32 frame); +void SkelAnime_Free(SkelAnime* skelAnime, struct PlayState* play); + +// ZAPD compatibility typedefs +// TODO: Remove when ZAPD adds support for them +typedef PlayerAnimationHeader LinkAnimationHeader; + #endif diff --git a/include/z64animation_legacy.h b/include/z64animation_legacy.h new file mode 100644 index 000000000..238939f74 --- /dev/null +++ b/include/z64animation_legacy.h @@ -0,0 +1,36 @@ +#ifndef Z64_ANIMATION_LEGACY_H +#define Z64_ANIMATION_LEGACY_H + +#include "ultra64.h" +#include "z64math.h" + +typedef struct LegacyLimb { + /* 0x00 */ Gfx* dList; + /* 0x04 */ Vec3f trans; + /* 0x10 */ Vec3s rot; + /* 0x18 */ struct LegacyLimb* sibling; + /* 0x1C */ struct LegacyLimb* child; +} LegacyLimb; // size = 0x20 + +typedef struct { + /* 0x00 */ s16 xMax; + /* 0x02 */ s16 x; + /* 0x04 */ s16 yMax; + /* 0x06 */ s16 y; + /* 0x08 */ s16 zMax; + /* 0x10 */ s16 z; +} LegacyJointKey; // size = 0x12 + +typedef struct { + /* 0x0 */ s16 frameCount; + /* 0x2 */ s16 limbCount; + /* 0x4 */ s16* frameData; + /* 0x8 */ LegacyJointKey* jointKey; +} LegacyAnimationHeader; // size = 0xC + +s16 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Vec3s* frameTable); +s16 Animation_GetLimbCountLegacy(LegacyAnimationHeader* animation); +s16 Animation_GetLengthLegacy(LegacyAnimationHeader* animation); +s16 Animation_GetLastFrameLegacy(LegacyAnimationHeader* animation); + +#endif diff --git a/include/z64audio.h b/include/z64audio.h index bfb66a23a..a37760566 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -1,5 +1,5 @@ -#ifndef Z64_AUDIO_H -#define Z64_AUDIO_H +#ifndef Z64AUDIO_H +#define Z64AUDIO_H #include "audiothread_cmd.h" @@ -11,6 +11,12 @@ #define SEQ_NUM_CHANNELS 16 #define SEQ_IO_VAL_NONE -1 +typedef enum { + /* 0 */ AUDIO_HEAP_RESET_STATE_NONE, + /* 1 */ AUDIO_HEAP_RESET_STATE_RESETTING, + /* 2 */ AUDIO_HEAP_RESET_STATE_RESETTING_ALT // Never set to +} AudioHeapResetState; + typedef enum { /* 0x00 */ AUDIO_CUSTOM_FUNCTION_SEQ_0, /* 0x01 */ AUDIO_CUSTOM_FUNCTION_SEQ_1, @@ -1090,50 +1096,50 @@ typedef struct { } AudioHeapInitSizes; // size = 0xC typedef struct { - /* 0x00 */ f32 unk_00; - /* 0x04 */ f32 unk_04; - /* 0x08 */ f32 unk_08; - /* 0x0C */ f32 unk_10; - /* 0x10 */ f32 unk_14; - /* 0x14 */ f32 unk_18; - /* 0x18 */ u16 unk_0C; - /* 0x1A */ u16 unk_1C; -} unk_50_s; // size = 0x1C + /* 0x00 */ f32 volCur; + /* 0x04 */ f32 volTarget; + /* 0x08 */ f32 volStep; + /* 0x0C */ f32 freqScaleCur; + /* 0x10 */ f32 freqScaleTarget; + /* 0x14 */ f32 freqScaleStep; + /* 0x18 */ u16 volTimer; + /* 0x1A */ u16 freqScaleTimer; +} ActiveSequenceChannelData; // size = 0x1C typedef struct { - /* 0x000 */ unk_50_s unk_50[0x10]; + /* 0x000 */ ActiveSequenceChannelData channelData[SEQ_NUM_CHANNELS]; /* 0x1C0 */ f32 volCur; /* 0x1C4 */ f32 volTarget; - /* 0x1C8 */ f32 unk_08; - /* 0x1CC */ u32 unk_14; - /* 0x1D0 */ f32 unk_1C; - /* 0x1D4 */ f32 unk_20; - /* 0x1D8 */ f32 unk_24; - /* 0x1DC */ u32 unk_2C[8]; - /* 0x1FC */ u32 unk_25C; - /* 0x200 */ u16 unk_0C; - /* 0x202 */ u16 unk_18; - /* 0x204 */ u16 unk_28; - /* 0x206 */ u16 unk_250; - /* 0x208 */ u16 unk_252; + /* 0x1C8 */ f32 volStep; + /* 0x1CC */ u32 tempoCmd; + /* 0x1D0 */ f32 tempoCur; + /* 0x1D4 */ f32 tempoTarget; + /* 0x1D8 */ f32 tempoStep; + /* 0x1DC */ u32 setupCmd[8]; // setup commands + /* 0x1FC */ u32 startAsyncSeqCmd; // temporarily stores the seqCmd used in SEQCMD_PLAY_SEQUENCE, to be called again once the font is reloaded in + /* 0x200 */ u16 volTimer; + /* 0x202 */ u16 tempoOriginal; + /* 0x204 */ u16 tempoTimer; + /* 0x206 */ u16 freqScaleChannelFlags; + /* 0x208 */ u16 volChannelFlags; /* 0x20A */ u16 seqId; - /* 0x20C */ u16 unk_256; - /* 0x20E */ u16 unk_258; - /* 0x210 */ u8 unk_260; - /* 0x211 */ u8 unk_261[0x1]; - /* 0x212 */ u8 volScales[0x4]; + /* 0x20C */ u16 prevSeqId; // last seqId played on a player + /* 0x20E */ u16 channelPortMask; + /* 0x210 */ u8 isWaitingForFonts; + /* 0x211 */ u8 fontId; + /* 0x212 */ u8 volScales[VOL_SCALE_INDEX_MAX]; /* 0x216 */ u8 volFadeTimer; /* 0x217 */ u8 fadeVolUpdate; - /* 0x218 */ u8 unk_4C; - /* 0x219 */ u8 unk_4D; - /* 0x21A */ u8 unk_4E; - /* 0x21B */ u8 unk_21B; + /* 0x218 */ u8 setupCmdTimer; + /* 0x219 */ u8 setupCmdNum; // number of setup commands + /* 0x21A */ u8 setupFadeTimer; + /* 0x21B */ u8 isSeqPlayerInit; } ActiveSequence; // size = 0x21C typedef struct { - /* 0x0 */ u8 unk_0; - /* 0x1 */ u8 unk_1; // importance? -} Struct_8016E320; // size = 0x02 + /* 0x0 */ u8 seqId; + /* 0x1 */ u8 priority; +} SeqRequest; // size = 0x02 typedef enum { /* 0 */ BANK_PLAYER, diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index ad5d4c4fb..91a892e03 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -1,5 +1,5 @@ -#ifndef Z64_BGCHECK_H -#define Z64_BGCHECK_H +#ifndef Z64BGCHECK_H +#define Z64BGCHECK_H struct PlayState; struct Actor; @@ -48,11 +48,6 @@ struct DynaPolyActor; #define COLPOLY_IGNORE_ENTITY (1 << 1) #define COLPOLY_IGNORE_PROJECTILES (1 << 2) -// Surface Types -#define COLPOLY_SURFACE_GROUND 0 -#define COLPOLY_SURFACE_SAND 1 -#define COLPOLY_SURFACE_SNOW 14 - // CollisionContext flags #define BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW 1 @@ -96,7 +91,10 @@ typedef struct { /* 0x00 */ Vec3s pos; /* 0x06 */ Vec3s rot; /* 0x0C */ s16 fov; - /* 0x0E */ s16 unk_0E; + /* 0x0E */ union { + s16 roomImageOverrideBgCamIndex; + s16 unk_0E; + }; /* 0x10 */ s16 unk_10; } BgCamFuncData; // size = 0x12 @@ -111,6 +109,120 @@ typedef struct { // 0x0000_00FF = bgCam index } WaterBox; // size = 0x10 +typedef enum FloorType { + /* 0 */ FLOOR_TYPE_0, + /* 1 */ FLOOR_TYPE_1, + /* 2 */ FLOOR_TYPE_2, + /* 3 */ FLOOR_TYPE_3, + /* 4 */ FLOOR_TYPE_4, + /* 5 */ FLOOR_TYPE_5, + /* 6 */ FLOOR_TYPE_6, + /* 7 */ FLOOR_TYPE_7, + /* 8 */ FLOOR_TYPE_8, + /* 9 */ FLOOR_TYPE_9, + /* 10 */ FLOOR_TYPE_10, + /* 11 */ FLOOR_TYPE_11, + /* 12 */ FLOOR_TYPE_12, + /* 13 */ FLOOR_TYPE_13, + /* 14 */ FLOOR_TYPE_14, + /* 15 */ FLOOR_TYPE_15 +} FloorType; + +typedef enum WallType { + /* 0 */ WALL_TYPE_0, + /* 1 */ WALL_TYPE_1, + /* 2 */ WALL_TYPE_2, + /* 3 */ WALL_TYPE_3, + /* 4 */ WALL_TYPE_4, + /* 5 */ WALL_TYPE_5, + /* 6 */ WALL_TYPE_6, + /* 7 */ WALL_TYPE_7, + /* 8 */ WALL_TYPE_8, + /* 9 */ WALL_TYPE_9, + /* 10 */ WALL_TYPE_10, + /* 11 */ WALL_TYPE_11, + /* 12 */ WALL_TYPE_12, + /* 32 */ WALL_TYPE_MAX = 32 +} WallType; + +#define WALL_FLAG_0 (1 << 0) +#define WALL_FLAG_1 (1 << 1) +#define WALL_FLAG_2 (1 << 2) +#define WALL_FLAG_3 (1 << 3) +#define WALL_FLAG_4 (1 << 4) +#define WALL_FLAG_5 (1 << 5) +#define WALL_FLAG_6 (1 << 6) + +// SurfaceType can leave footsteps imprints in the material +#define MATERIAL_PROPERTY_SOFT_IMPRINT (1 << 0) + +typedef enum FloorProperty { + /* 0 */ FLOOR_PROPERTY_0, + /* 1 */ FLOOR_PROPERTY_1, + /* 2 */ FLOOR_PROPERTY_2, + /* 5 */ FLOOR_PROPERTY_5 = 5, + /* 6 */ FLOOR_PROPERTY_6, + /* 7 */ FLOOR_PROPERTY_7, + /* 8 */ FLOOR_PROPERTY_8, + /* 9 */ FLOOR_PROPERTY_9, + /* 11 */ FLOOR_PROPERTY_11 = 11, + /* 12 */ FLOOR_PROPERTY_12, + /* 13 */ FLOOR_PROPERTY_13 +} FloorProperty; + +typedef enum SurfaceSfxOffset { + /* 0 */ SURFACE_SFX_OFFSET_DIRT, + /* 1 */ SURFACE_SFX_OFFSET_SAND, + /* 2 */ SURFACE_SFX_OFFSET_STONE, + /* 3 */ SURFACE_SFX_OFFSET_DIRT_SHALLOW, + /* 4 */ SURFACE_SFX_OFFSET_WATER_SHALLOW, + /* 5 */ SURFACE_SFX_OFFSET_WATER_DEEP, + /* 6 */ SURFACE_SFX_OFFSET_TALL_GRASS, + /* 7 */ SURFACE_SFX_OFFSET_LAVA, // MAGMA? + /* 8 */ SURFACE_SFX_OFFSET_GRASS, + /* 9 */ SURFACE_SFX_OFFSET_CARPET, + /* 10 */ SURFACE_SFX_OFFSET_WOOD, + /* 11 */ SURFACE_SFX_OFFSET_BRIDGE, // WOOD_PLANK? + /* 12 */ SURFACE_SFX_OFFSET_VINE, // METAL? + /* 13 */ SURFACE_SFX_OFFSET_DIRT_DEEP, + /* 14 */ SURFACE_SFX_OFFSET_SNOW, + /* 15 */ SURFACE_SFX_OFFSET_ICE +} SurfaceSfxOffset; + +typedef enum SurfaceMaterial { + /* 0 */ SURFACE_MATERIAL_DIRT, + /* 1 */ SURFACE_MATERIAL_SAND, + /* 2 */ SURFACE_MATERIAL_STONE, + /* 3 */ SURFACE_MATERIAL_DIRT_SHALLOW, + /* 4 */ SURFACE_MATERIAL_WATER_SHALLOW, + /* 5 */ SURFACE_MATERIAL_WATER_DEEP, + /* 6 */ SURFACE_MATERIAL_TALL_GRASS, + /* 7 */ SURFACE_MATERIAL_LAVA, // MAGMA? + /* 8 */ SURFACE_MATERIAL_GRASS, + /* 9 */ SURFACE_MATERIAL_BRIDGE, // WOOD_PLANK? + /* 10 */ SURFACE_MATERIAL_WOOD, + /* 11 */ SURFACE_MATERIAL_DIRT_SOFT, + /* 12 */ SURFACE_MATERIAL_ICE, + /* 13 */ SURFACE_MATERIAL_CARPET, + /* 14 */ SURFACE_MATERIAL_SNOW, + /* 15 */ SURFACE_MATERIAL_MAX +} SurfaceMaterial; + +typedef enum FloorEffect { + /* 0 */ FLOOR_EFFECT_0, + /* 1 */ FLOOR_EFFECT_1, + /* 2 */ FLOOR_EFFECT_2, + /* 3 */ FLOOR_EFFECT_3 +} FloorEffect; + +typedef enum ConveyorSpeed { + /* 0 */ CONVEYOR_SPEED_DISABLED, + /* 1 */ CONVEYOR_SPEED_SLOW, + /* 2 */ CONVEYOR_SPEED_MEDIUM, + /* 3 */ CONVEYOR_SPEED_FAST, + /* 4 */ CONVEYOR_SPEED_MAX +} ConveyorSpeed; + typedef struct { /* 0x0 */ u32 data[2]; @@ -143,7 +255,7 @@ typedef struct { /* 0x14 */ u16 numPolygons; /* 0x18 */ CollisionPoly* polyList; /* 0x1C */ SurfaceType* surfaceTypeList; - /* 0x20 */ CamData* bgCamList; + /* 0x20 */ BgCamInfo* bgCamList; /* 0x24 */ u16 numWaterBoxes; /* 0x28 */ WaterBox* waterBoxes; } CollisionHeader; // size = 0x2C @@ -202,10 +314,16 @@ typedef struct { /* 0x60 */ f32 maxY; } BgActor; // size = 0x64 +#define BGACTOR_IN_USE (1 << 0) // The bgActor entry is in use +#define BGACTOR_1 (1 << 1) +#define BGACTOR_COLLISION_DISABLED (1 << 2) // The collision of the bgActor is disabled +#define BGACTOR_CEILING_COLLISION_DISABLED (1 << 3) // The ceiling collision of the bgActor is ignored +#define BGACTOR_FLOOR_COLLISION_DISABLED (1 << 5) // The floor collision of the bgActor is ignored + typedef struct { /* 0x0000 */ u8 bitFlag; /* 0x0004 */ BgActor bgActors[BG_ACTOR_MAX]; - /* 0x138C */ u16 bgActorFlags[BG_ACTOR_MAX]; // bit 0 - Is mesh active + /* 0x138C */ u16 bgActorFlags[BG_ACTOR_MAX]; /* 0x13F0 */ CollisionPoly* polyList; /* 0x13F4 */ Vec3s* vtxList; /* 0x13F8 */ DynaWaterBoxList waterBoxList; @@ -216,14 +334,14 @@ typedef struct { } DynaCollisionContext; // size = 0x1418 typedef struct { - /* 0x00 */ CollisionHeader* colHeader; // scene's static collision - /* 0x04 */ Vec3f minBounds; // minimum coordinates of collision bounding box - /* 0x10 */ Vec3f maxBounds; // maximum coordinates of collision bounding box - /* 0x1C */ Vec3i subdivAmount; // x, y, z subdivisions of the scene's static collision - /* 0x28 */ Vec3f subdivLength; // x, y, z subdivision worldspace lengths - /* 0x34 */ Vec3f subdivLengthInv; // inverse of subdivision length - /* 0x40 */ StaticLookup* lookupTbl; // 3d array of length subdivAmount - /* 0x44 */ SSNodeList polyNodes; + /* 0x0000 */ CollisionHeader* colHeader; // scene's static collision + /* 0x0004 */ Vec3f minBounds; // minimum coordinates of collision bounding box + /* 0x0010 */ Vec3f maxBounds; // maximum coordinates of collision bounding box + /* 0x001C */ Vec3i subdivAmount; // x, y, z subdivisions of the scene's static collision + /* 0x0028 */ Vec3f subdivLength; // x, y, z subdivision worldspace lengths + /* 0x0034 */ Vec3f subdivLengthInv; // inverse of subdivision length + /* 0x0040 */ StaticLookup* lookupTbl; // 3d array of length subdivAmount + /* 0x0044 */ SSNodeList polyNodes; /* 0x0050 */ DynaCollisionContext dyna; /* 0x1468 */ u32 memSize; // Size of all allocated memory plus CollisionContext /* 0x146C */ u32 flags; // bit 0 reverses conveyor direction (i.e. water flow in Great Bay Temple) @@ -314,4 +432,162 @@ typedef struct { /* 0x8 */ s32 nodeListMax; // if -1, dynamically compute max nodes } BgCheckSceneSubdivisionEntry; // size = 0xC +void SSNode_SetValue(SSNode* node, s16* polyIndex, u16 next); +void SSList_SetNull(SSList* ssList); +void SSNodeList_SetSSListHead(SSNodeList* list, SSList* ssList, s16* polyIndex); +void DynaSSNodeList_SetSSListHead(DynaSSNodeList* list, SSList* ssList, s16* polyIndex); +void DynaSSNodeList_Init(struct PlayState* play, DynaSSNodeList* list); +void DynaSSNodeList_Alloc(struct PlayState* play, DynaSSNodeList* list, u32 numNodes); +void DynaSSNodeList_ResetCount(DynaSSNodeList* list); +u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* list); +void BgCheck_Vec3sToVec3f(Vec3s* src, Vec3f* dest); +void BgCheck_Vec3fToVec3s(Vec3s* dest, Vec3f* src); +f32 func_800BFD84(CollisionPoly *poly, f32 arg1, f32 arg2); +s32 func_800BFDEC(CollisionPoly* polyA, CollisionPoly* polyB, u32* outVtxId0, u32* outVtxId1); +s16 CollisionPoly_GetMinY(CollisionPoly* poly, Vec3s* vertices); +void CollisionPoly_GetNormalF(CollisionPoly* poly, f32* nx, f32* ny, f32* nz); +void func_800C0094(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest); +f32 CollisionPoly_GetPointDistanceFromPlane(CollisionPoly* poly, Vec3f* point); +void CollisionPoly_GetVerticesByBgId(CollisionPoly* poly, s32 bgId, CollisionContext* colCtx, Vec3f* dest); +s32 CollisionPoly_SphVsPoly(CollisionPoly* poly, Vec3s* vtxList, Vec3f* center, f32 radius); +void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, CollisionPoly* polyList, Vec3s* vtxList, s16 polyId); +void StaticLookup_AddPoly(StaticLookup* lookup, CollisionContext* colCtx, CollisionPoly* polyList, Vec3s* vtxList, s16 index); +void BgCheck_GetSubdivisionMinBounds(CollisionContext* colCtx, Vec3f* pos, s32* sx, s32* sy, s32* sz); +void BgCheck_GetSubdivisionMaxBounds(CollisionContext* colCtx, Vec3f* pos, s32* sx, s32* sy, s32* sz); +void BgCheck_GetPolySubdivisionBounds(CollisionContext* colCtx, Vec3s* vtxList, CollisionPoly* polyList, s32* subdivMinX, s32* subdivMinY, s32* subdivMinZ, s32* subdivMaxX, s32* subdivMaxY, s32* subdivMaxZ, s16 polyId); +s32 BgCheck_PolyIntersectsSubdivision(Vec3f* min, Vec3f* max, CollisionPoly* polyList, Vec3s* vtxList, s16 polyId); +u32 BgCheck_InitStaticLookup(CollisionContext* colCtx, struct PlayState* play, StaticLookup* lookupTbl); +s32 BgCheck_IsSmallMemScene(struct PlayState* play); +s32 BgCheck_TryGetCustomMemsize(s32 sceneId, u32* memSize); +void BgCheck_SetSubdivisionDimension(f32 min, s32 subdivAmount, f32* max, f32* subdivLength, f32* subdivLengthInv); +s32 BgCheck_GetSpecialSceneMaxObjects(struct PlayState* play, s32* maxNodes, s32* maxPolygons, s32* maxVertices); +void BgCheck_Allocate(CollisionContext* colCtx, struct PlayState* play, CollisionHeader* colHeader); +void BgCheck_SetContextFlags(CollisionContext* colCtx, u32 flags); +void BgCheck_UnsetContextFlags(CollisionContext* colCtx, u32 flags); +CollisionHeader* BgCheck_GetCollisionHeader(CollisionContext* colCtx, s32 bgId); +f32 BgCheck_RaycastFloorImpl(struct PlayState* play, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, Vec3f* pos, Actor* actor, u32 arg7, f32 checkDist, s32 arg9); +f32 BgCheck_CameraRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor2(struct PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor2_1(struct PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor3(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor5(CollisionContext* colCtx, CollisionPoly** outPoly, s32* outBgId, Actor* actor, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor5_2(struct PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor5_3(struct PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor6(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos, f32 checkDist); +f32 BgCheck_EntityRaycastFloor7(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); +f32 BgCheck_AnyRaycastFloor1(CollisionContext* colCtx, CollisionPoly* outPoly, Vec3f* pos); +f32 BgCheck_AnyRaycastFloor2(CollisionContext* colCtx, CollisionPoly* outPoly, s32* bgId, Vec3f* pos); +f32 BgCheck_CameraRaycastFloor2(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor8(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); +f32 BgCheck_EntityRaycastFloor9(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Vec3f* pos); +s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight, u8 argA); +s32 BgCheck_EntitySphVsWall1(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, CollisionPoly** outPoly, f32 checkHeight); +s32 BgCheck_EntitySphVsWall2(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, CollisionPoly** outPoly, s32* outBgId, f32 checkHeight); +s32 BgCheck_EntitySphVsWall3(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight); +s32 BgCheck_EntitySphVsWall4(CollisionContext* colCtx, Vec3f* posResult, Vec3f* posNext, Vec3f* posPrev, f32 radius, CollisionPoly** outPoly, s32* outBgId, Actor* actor, f32 checkHeight); +s32 BgCheck_CheckCeilingImpl(CollisionContext* colCtx, u16 xpFlags, f32* outY, Vec3f* pos, f32 checkHeight, CollisionPoly** outPoly, s32* outBgId, Actor* actor); +s32 BgCheck_AnyCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight); +s32 BgCheck_EntityCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight, CollisionPoly** outPoly, s32* outBgId, Actor* actor); +s32 BgCheck_CameraLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId); +s32 BgCheck_CameraLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId); +s32 BgCheck_EntityLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId); +s32 BgCheck_EntityLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId, Actor* actor); +s32 BgCheck_EntityLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId, Actor* actor, f32 checkDist); +s32 BgCheck_ProjectileLineTest(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId); +s32 BgCheck_AnyLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkOneFace); +s32 BgCheck_AnyLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace); +s32 BgCheck_AnyLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId); +s32 BgCheck_SphVsFirstPolyImpl(CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, Vec3f* center, f32 radius, Actor* actor, u16 bciFlags); +s32 BgCheck_SphVsFirstPoly(CollisionContext* colCtx, Vec3f* center, f32 radius); +s32 BgCheck_SphVsFirstWall(CollisionContext* colCtx, Vec3f* center, f32 radius); +void SSNodeList_Init(SSNodeList* this); +void SSNodeList_Alloc(struct PlayState* play, SSNodeList* this, s32 tblMax, s32 numPolys); +SSNode* SSNodeList_GetNextNode(SSNodeList* this); +u16 SSNodeList_GetNextNodeIdx(SSNodeList* this); +void ScaleRotPos_Init(ScaleRotPos* srp); +void ScaleRotPos_SetValue(ScaleRotPos* srp, Vec3f* scale, Vec3s* rot, Vec3f* pos); +s32 ScaleRotPos_IsEqual(ScaleRotPos* a, ScaleRotPos* b); +void DynaLookup_ResetLists(DynaLookup* dynaLookup); +void DynaLookup_Reset(DynaLookup* dynaLookup); +void DynaLookup_ResetVtxStartIndex(u16* vtxStartIndex); +void DynaLookup_ResetWaterBoxStartIndex(u16* waterBoxStartIndex); +void BgActor_Init(struct PlayState* play, BgActor* bgActor); +void BgActor_SetActor(BgActor* bgActor, Actor* actor, CollisionHeader* colHeader); +s32 BgActor_IsTransformUnchanged(BgActor* bgActor); +void DynaPoly_NullPolyList(CollisionPoly** polyList); +void DynaPoly_AllocPolyList(struct PlayState* play, CollisionPoly** polyList, s32 numPolys); +void DynaPoly_NullVtxList(Vec3s** vtxList); +void DynaPoly_AllocVtxList(struct PlayState* play, Vec3s** vtxList, s32 numVtx); +void DynaPoly_InitWaterBoxList(DynaWaterBoxList* waterBoxList); +void DynaPoly_AllocWaterBoxList(struct PlayState* play, DynaWaterBoxList* waterBoxList, s32 numWaterBoxes); +void DynaPoly_SetBgActorPrevTransform(struct PlayState* play, BgActor* bgActor); +s32 DynaPoly_IsBgIdBgActor(s32 bgId); +void DynaPoly_Init(struct PlayState* play, DynaCollisionContext* dyna); +void DynaPoly_Alloc(struct PlayState* play, DynaCollisionContext* dyna); +s32 DynaPoly_SetBgActor(struct PlayState* play, DynaCollisionContext* dyna, Actor* actor, CollisionHeader* colHeader); +DynaPolyActor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId); +void DynaPoly_DisableCollision(struct PlayState* play, DynaCollisionContext* dyna, s32 bgId); +void DynaPoly_EnableCollision(struct PlayState* play, DynaCollisionContext* dyna, s32 bgId); +void DynaPoly_DisableCeilingCollision(struct PlayState* play, DynaCollisionContext* dyna, s32 bgId); +void DynaPoly_EnableCeilingCollision(struct PlayState* play, DynaCollisionContext* dyna, s32 bgId); +void DynaPoly_DisableFloorCollision(struct PlayState* play, DynaCollisionContext* dyna, s32 bgId); +void DynaPoly_EnableFloorCollision(struct PlayState* play, DynaCollisionContext* dyna, s32 bgId); +void DynaPoly_InvalidateLookup(struct PlayState* play, DynaCollisionContext* dyna); +void DynaPoly_DeleteBgActor(struct PlayState* play, DynaCollisionContext* dyna, s32 bgId); +void BgCheck_CalcWaterboxDimensions(Vec3f* minPos, Vec3f* maxXPos, Vec3f* maxZPos, Vec3s* minPosOut, s16* xLength, s16* zLength); +void DynaPoly_AddBgActorToLookup(struct PlayState* play, DynaCollisionContext* dyna, s32 bgId, s32* vtxStartIndex, s32* polyStartIndex, s32* waterBoxStartIndex); +void DynaPoly_UnsetAllInteractFlags(struct PlayState* play, DynaCollisionContext* dyna, Actor* actor); +void DynaPoly_UpdateContext(struct PlayState* play, DynaCollisionContext* dyna); +void func_800C756C(DynaCollisionContext* dyna, s32* numPolygons, s32* numVertices, s32* numWaterBoxes); +void DynaPoly_UpdateBgActorTransforms(struct PlayState* play, DynaCollisionContext* dyna); +void CollisionHeader_SegmentedToVirtual(CollisionHeader* colHeader); +void CollisionHeader_GetVirtual(CollisionHeader* colHeader, CollisionHeader** dest); +void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, struct PlayState* play); + +u32 SurfaceType_GetBgCamIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u16 BgCheck_GetBgCamSettingImpl(CollisionContext* colCtx, u32 bgCamIndex, s32 bgId); +u16 BgCheck_GetBgCamSetting(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u16 BgCheck_GetBgCamCountImpl(CollisionContext* colCtx, u32 bgCamIndex, s32 bgId); +u16 BgCheck_GetBgCamCount(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +Vec3s* BgCheck_GetBgCamFuncDataImpl(CollisionContext* colCtx, s32 bgCamIndex, s32 bgId); +Vec3s* BgCheck_GetBgCamFuncData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); + +u32 SurfaceType_GetSceneExitIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +FloorType SurfaceType_GetFloorType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 func_800C99FC(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_GetWallFlags(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_CheckWallFlag0(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_CheckWallFlag1(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_CheckWallFlag2(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +FloorProperty SurfaceType_GetFloorProperty2(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +FloorProperty SurfaceType_GetFloorProperty(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_IsSoft(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_IsHorseBlocked(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +SurfaceMaterial SurfaceType_GetMaterial(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u16 SurfaceType_GetSfxOffset(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_HasMaterialProperty(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, s32 propertyType); +FloorEffect SurfaceType_GetFloorEffect(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_GetLightSettingIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_GetEcho(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_IsHookshotSurface(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_IsIgnoredByEntities(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_IsIgnoredByProjectiles(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_IsFloorConveyor(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 func_800C9DDC(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +ConveyorSpeed SurfaceType_GetConveyorSpeed(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_GetConveyorDirection(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 WaterBox_GetSurfaceImpl(struct PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId); +s32 WaterBox_GetSurface1(struct PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); +s32 WaterBox_GetSurface1_2(struct PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); +s32 WaterBox_GetSurface2(struct PlayState* play, CollisionContext* colCtx, Vec3f* pos, f32 surfaceCheckDist, WaterBox** outWaterBox, s32* bgId); +f32 func_800CA568(CollisionContext* colCtx, s32 waterBoxId, s32 bgId); +u16 WaterBox_GetBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox, s32 bgId); +void WaterBox_GetSceneBgCamSetting(CollisionContext* colCtx, WaterBox* waterBox); +u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox); +s32 func_800CA6F0(struct PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId); +s32 func_800CA9D0(struct PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); +s32 func_800CAA14(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec3f* pointB, Vec3f* closestPoint); + #endif diff --git a/include/z64camera.h b/include/z64camera.h index 9c101bf73..54cf748ac 100644 --- a/include/z64camera.h +++ b/include/z64camera.h @@ -90,18 +90,18 @@ #define CAM_BEHAVIOR_SETTING_2 (1 << 4) // Mode (0x2, 0x20) #define CAM_BEHAVIOR_MODE_1 (1 << 1) -#define CAM_BEHAVIOR_MODE_2 (1 << 5) +#define CAM_BEHAVIOR_MODE_VALID (1 << 5) // bgCam (0x4, 0x40) #define CAM_BEHAVIOR_BGCAM_1 (1 << 2) #define CAM_BEHAVIOR_BGCAM_2 (1 << 6) // Camera stateFlags. Variety of generic flags #define CAM_STATE_0 (1 << 0) // Must be set for the camera from changing settings based on the bg surface -#define CAM_STATE_1 (1 << 1) +#define CAM_STATE_CHECK_WATER (1 << 1) #define CAM_STATE_2 (1 << 2) #define CAM_STATE_3 (1 << 3) #define CAM_STATE_4 (1 << 4) -#define CAM_STATE_5 (1 << 5) +#define CAM_STATE_DISABLE_MODE_CHANGE (1 << 5) #define CAM_STATE_6 (1 << 6) #define CAM_STATE_7 (1 << 7) #define CAM_STATE_UNDERWATER (1 << 8) @@ -110,7 +110,7 @@ #define CAM_STATE_11 (1 << 11) #define CAM_STATE_12 (1 << 12) #define CAM_STATE_13 (1 << 13) -#define CAM_STATE_14 (1 << 14) +#define CAM_STATE_INITIALIZED (1 << 14) #define CAM_STATE_15 ((s16)(1 << 15)) // Camera viewFlags. Set params related to view @@ -340,13 +340,13 @@ typedef enum { } CameraFuncType; typedef enum { - /* 0x00 */ CAM_DATA_00, + /* 0x00 */ CAM_DATA_Y_OFFSET, /* 0x01 */ CAM_DATA_01, /* 0x02 */ CAM_DATA_02, - /* 0x03 */ CAM_DATA_03, + /* 0x03 */ CAM_DATA_PITCH_TARGET, /* 0x04 */ CAM_DATA_04, /* 0x05 */ CAM_DATA_05, - /* 0x06 */ CAM_DATA_06, + /* 0x06 */ CAM_DATA_YAW_DIFF_RANGE, /* 0x07 */ CAM_DATA_FOV, /* 0x08 */ CAM_DATA_08, /* 0x09 */ CAM_DATA_INTERFACE_FLAGS, @@ -374,7 +374,7 @@ typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f norm; /* 0x18 */ CollisionPoly* poly; - /* 0x1C */ VecSph sphNorm; + /* 0x1C */ VecGeo geoNorm; /* 0x24 */ s32 bgId; } CameraCollision; // size = 0x28 @@ -405,13 +405,13 @@ typedef struct { */ #define CAM_FUNCDATA_NORM1(yOffset, data01, data02, pitchTarget, eyeStepScale, posStepScale, yawDiffRange, fov, data08, interfaceFlags) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data01, CAM_DATA_01 }, \ { data02, CAM_DATA_02 }, \ - { pitchTarget, CAM_DATA_03 }, \ + { pitchTarget, CAM_DATA_PITCH_TARGET }, \ { eyeStepScale, CAM_DATA_04 }, \ { posStepScale, CAM_DATA_05 }, \ - { yawDiffRange, CAM_DATA_06 }, \ + { yawDiffRange, CAM_DATA_YAW_DIFF_RANGE }, \ { fov, CAM_DATA_FOV }, \ { data08, CAM_DATA_08 }, \ { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } @@ -462,10 +462,10 @@ typedef struct { // Unused Camera RemoteBomb Setting #define CAM_FUNCDATA_NORM2(yOffset, data01, data02, pitchTarget, data04, fov, data08, interfaceFlags) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data01, CAM_DATA_01 }, \ { data02, CAM_DATA_02 }, \ - { pitchTarget, CAM_DATA_03 }, \ + { pitchTarget, CAM_DATA_PITCH_TARGET }, \ { data04, CAM_DATA_04 }, \ { fov, CAM_DATA_FOV }, \ { data08, CAM_DATA_08 }, \ @@ -480,10 +480,10 @@ typedef struct { */ #define CAM_FUNCDATA_NORM3(yOffset, data01, data02, pitchTarget, eyeStepScale, posStepScale, fov, data08, interfaceFlags) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data01, CAM_DATA_01 }, \ { data02, CAM_DATA_02 }, \ - { pitchTarget, CAM_DATA_03 }, \ + { pitchTarget, CAM_DATA_PITCH_TARGET }, \ { eyeStepScale, CAM_DATA_04 }, \ { posStepScale, CAM_DATA_05 }, \ { fov, CAM_DATA_FOV }, \ @@ -530,12 +530,12 @@ typedef struct { */ #define CAM_FUNCDATA_NORM0(yOffset, data01, data02, data21, data04, yawDiffRange, fov, data08, interfaceFlags) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data01, CAM_DATA_01 }, \ { data02, CAM_DATA_02 }, \ { data21, CAM_DATA_21 }, \ { data04, CAM_DATA_04 }, \ - { yawDiffRange, CAM_DATA_06 }, \ + { yawDiffRange, CAM_DATA_YAW_DIFF_RANGE }, \ { fov, CAM_DATA_FOV }, \ { data08, CAM_DATA_08 }, \ { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } @@ -581,10 +581,10 @@ typedef struct { */ #define CAM_FUNCDATA_PARA1(yOffset, data01, data02, pitchTarget, data10, data04, data05, fov, data08, interfaceFlags, data11, data12) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data01, CAM_DATA_01 }, \ { data02, CAM_DATA_02 }, \ - { pitchTarget, CAM_DATA_03 }, \ + { pitchTarget, CAM_DATA_PITCH_TARGET }, \ { data10, CAM_DATA_10 }, \ { data04, CAM_DATA_04 }, \ { data05, CAM_DATA_05 }, \ @@ -596,10 +596,10 @@ typedef struct { // Same as above but with extra unused entry #define CAM_FUNCDATA_PARA1_ALT(yOffset, data01, data02, pitchTarget, data10, data04, data05, fov, data08, interfaceFlags, data11, data12, data18) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data01, CAM_DATA_01 }, \ { data02, CAM_DATA_02 }, \ - { pitchTarget, CAM_DATA_03 }, \ + { pitchTarget, CAM_DATA_PITCH_TARGET }, \ { data10, CAM_DATA_10 }, \ { data04, CAM_DATA_04 }, \ { data05, CAM_DATA_05 }, \ @@ -662,10 +662,10 @@ typedef struct { // Unused Camera Maze Setting #define CAM_FUNCDATA_PARA2(yOffset, data02, data01, pitchTarget, data04, fov, data08, interfaceFlags) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data02, CAM_DATA_02 }, \ { data01, CAM_DATA_01 }, \ - { pitchTarget, CAM_DATA_03 }, \ + { pitchTarget, CAM_DATA_PITCH_TARGET }, \ { data04, CAM_DATA_04 }, \ { fov, CAM_DATA_FOV }, \ { data08, CAM_DATA_08 }, \ @@ -680,7 +680,7 @@ typedef struct { */ #define CAM_FUNCDATA_JUMP2(yOffset, data01, data02, data20, data04, data05, fov, data08, interfaceFlags) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data01, CAM_DATA_01 }, \ { data02, CAM_DATA_02 }, \ { data20, CAM_DATA_20 }, \ @@ -729,13 +729,13 @@ typedef struct { */ #define CAM_FUNCDATA_JUMP3(yOffset, data01, data02, pitchTarget, data04, data05, yawDiffRange, fov, data08, interfaceFlags) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data01, CAM_DATA_01 }, \ { data02, CAM_DATA_02 }, \ - { pitchTarget, CAM_DATA_03 }, \ + { pitchTarget, CAM_DATA_PITCH_TARGET }, \ { data04, CAM_DATA_04 }, \ { data05, CAM_DATA_05 }, \ - { yawDiffRange, CAM_DATA_06 }, \ + { yawDiffRange, CAM_DATA_YAW_DIFF_RANGE }, \ { fov, CAM_DATA_FOV }, \ { data08, CAM_DATA_08 }, \ { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } @@ -785,7 +785,7 @@ typedef struct { */ #define CAM_FUNCDATA_BATT1(yOffset, data01, data02, data13, data14, data15, data16, data17, fov, data08, interfaceFlags, data11, data18) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data01, CAM_DATA_01 }, \ { data02, CAM_DATA_02 }, \ { data13, CAM_DATA_13 }, \ @@ -845,7 +845,7 @@ typedef struct { */ #define CAM_FUNCDATA_KEEP1(yOffset, data01, data02, data13, data14, data15, data16, data17, fov, data08, interfaceFlags, data11) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data01, CAM_DATA_01 }, \ { data02, CAM_DATA_02 }, \ { data13, CAM_DATA_13 }, \ @@ -902,7 +902,7 @@ typedef struct { */ #define CAM_FUNCDATA_KEEP3(yOffset, data01, data02, data13, data14, data15, data16, data17, fov, data08, timer, interfaceFlags, data18) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data01, CAM_DATA_01 }, \ { data02, CAM_DATA_02 }, \ { data13, CAM_DATA_13 }, \ @@ -957,9 +957,9 @@ typedef struct { */ #define CAM_FUNCDATA_KEEP4(yOffset, data01, pitchTarget, data10, data18, fov, interfaceFlags, data04, timer) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data01, CAM_DATA_01 }, \ - { pitchTarget, CAM_DATA_03 }, \ + { pitchTarget, CAM_DATA_PITCH_TARGET }, \ { data10, CAM_DATA_10 }, \ { data18, CAM_DATA_18 }, \ { fov, CAM_DATA_FOV }, \ @@ -1008,7 +1008,7 @@ typedef struct { */ #define CAM_FUNCDATA_FIXD1(yOffset, data04, fov, interfaceFlags) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data04, CAM_DATA_04 }, \ { fov, CAM_DATA_FOV }, \ { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } @@ -1040,7 +1040,7 @@ typedef struct { */ #define CAM_FUNCDATA_FIXD2(yOffset, data01, data02, data04, data05, fov, interfaceFlags) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data01, CAM_DATA_01 }, \ { data02, CAM_DATA_02 }, \ { data04, CAM_DATA_04 }, \ @@ -1097,7 +1097,7 @@ typedef struct { */ #define CAM_FUNCDATA_SUBJ1(yOffset, data01, data02, data04, data19, data17, data18, fov, interfaceFlags) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data01, CAM_DATA_01 }, \ { data02, CAM_DATA_02 }, \ { data04, CAM_DATA_04 }, \ @@ -1140,7 +1140,7 @@ typedef struct { */ #define CAM_FUNCDATA_UNIQ2(yOffset, data01, fov, interfaceFlags) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data01, CAM_DATA_01 }, \ { fov, CAM_DATA_FOV }, \ { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } @@ -1175,7 +1175,7 @@ typedef struct { */ #define CAM_FUNCDATA_UNIQ0(yOffset, data04, interfaceFlags) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { data04, CAM_DATA_04 }, \ { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } @@ -1244,8 +1244,8 @@ typedef struct { typedef struct { /* 0x00 */ Vec3f unk_00; - /* 0x0C */ VecSph unk_0C; - /* 0x14 */ VecSph unk_14; + /* 0x0C */ VecGeo unk_0C; + /* 0x14 */ VecGeo unk_14; /* 0x1C */ s16 unk_1C; } Demo1ReadWriteData; // size = 0x20 @@ -1319,7 +1319,7 @@ typedef struct { /* 0x0C */ f32 unk_0C; /* 0x10 */ f32 unk_10; /* 0x14 */ f32 unk_14; - /* 0x18 */ VecSph unk_18; // sp18-1C-20--24-26-28 // CutsceneCameraPoint? + /* 0x18 */ VecGeo unk_18; /* 0x20 */ s16 unk_20; /* 0x22 */ s16 timer; } Demo4ReadWriteData; // size = 0x24 @@ -1345,7 +1345,7 @@ typedef struct { /* 0x10 */ f32 unk_10; /* 0x14 */ f32 unk_14; /* 0x18 */ f32 unk_18; - /* 0x1C */ VecSph unk_1C; + /* 0x1C */ VecGeo unk_1C; /* 0x24 */ s16 unk_24; /* 0x26 */ s16 timer; } Demo5ReadWriteData; // size = 0x28 @@ -1367,8 +1367,8 @@ typedef struct { typedef struct { /* 0x00 */ f32 unk_00; - /* 0x04 */ VecSph subAtToEye; - /* 0x0C */ VecSph atToEye; + /* 0x04 */ VecGeo subAtToEye; + /* 0x0C */ VecGeo atToEye; /* 0x14 */ s16 unk_14; /* 0x16 */ s16 unk_16; /* 0x18 */ s16 unk_18; @@ -1387,10 +1387,10 @@ typedef struct { */ #define CAM_FUNCDATA_SPEC5(yOffset, eyeDist, minDistForRot, fov, atMaxLERPScale, timerInit, pitch, interfaceFlags) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { eyeDist, CAM_DATA_01 }, \ { minDistForRot, CAM_DATA_02 }, \ - { fov, CAM_DATA_03 }, \ + { fov, CAM_DATA_PITCH_TARGET }, \ { atMaxLERPScale, CAM_DATA_FOV }, \ { timerInit, CAM_DATA_08 }, \ { pitch, CAM_DATA_12 }, \ @@ -1446,7 +1446,7 @@ typedef struct { */ #define CAM_FUNCDATA_SPEC8(yOffset, eyeStepScale, posStepScale, fov, spiralDoorCsLength, interfaceFlags) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { eyeStepScale, CAM_DATA_04 }, \ { posStepScale, CAM_DATA_05 }, \ { fov, CAM_DATA_FOV }, \ @@ -1483,7 +1483,7 @@ typedef struct { */ #define CAM_FUNCDATA_SPEC9(yOffset, fov, interfaceFlags) \ - { yOffset, CAM_DATA_00 }, \ + { yOffset, CAM_DATA_Y_OFFSET }, \ { fov, CAM_DATA_FOV }, \ { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } @@ -1565,11 +1565,11 @@ typedef struct Camera { /* 0x0D8 */ f32 xzSpeed; /* 0x0DC */ f32 dist; /* 0x0E0 */ f32 speedRatio; - /* 0x0E4 */ Vec3f atActorOffset; - /* 0x0F0 */ Vec3f focalActorOffset; + /* 0x0E4 */ Vec3f focalActorAtOffset; // Offset between the camera's at Pos and the focalActor's Pos + /* 0x0F0 */ Vec3f unk_0F0; // Offset between the focalActor's Pos and the camera's focalActor's Pos from the previous frame /* 0x0FC */ f32 fov; /* 0x100 */ f32 atLerpStepScale; - /* 0x104 */ f32 playerFloorHeight; + /* 0x104 */ f32 focalActorFloorHeight; /* 0x108 */ Vec3f floorNorm; /* 0x114 */ f32 waterYPos; /* 0x118 */ s32 waterPrevBgCamDataId; @@ -1588,11 +1588,11 @@ typedef struct Camera { /* 0x142 */ s16 setting; /* 0x144 */ s16 mode; /* 0x146 */ s16 bgId; - /* 0x148 */ s16 bgCamDataId; + /* 0x148 */ s16 bgCamIndex; /* 0x14A */ s16 behaviorFlags; /* 0x14C */ s16 stateFlags; /* 0x14E */ s16 childCamId; - /* 0x150 */ s16 doorTimer1; // a door timer used when door cam is indexed from bgCamDataId + /* 0x150 */ s16 doorTimer1; // a door timer used when door cam is indexed from bgCamIndex /* 0x152 */ s16 unk152; /* 0x154 */ s16 prevSetting; /* 0x156 */ s16 nextCamSceneDataId; @@ -1600,8 +1600,8 @@ typedef struct Camera { /* 0x15A */ s16 roll; /* 0x15C */ s16 viewFlags; /* 0x15E */ s16 animState; // Determines the current state of the current camera behavior function - /* 0x160 */ s16 unk160; - /* 0x162 */ s16 doorTimer2; // a door timer used when door cam is indexed from bgCamDataId + /* 0x160 */ s16 timer; // Unused remnant of OoT: originally destoryed subCamera when timer ran out + /* 0x162 */ s16 doorTimer2; // a door timer used when door cam is indexed from bgCamIndex /* 0x164 */ s16 camId; /* 0x166 */ s16 prevBgCamDataId; /* 0x168 */ s16 unk168; diff --git a/include/z64collision_check.h b/include/z64collision_check.h index 836fd3555..e5032584c 100644 --- a/include/z64collision_check.h +++ b/include/z64collision_check.h @@ -1,5 +1,5 @@ -#ifndef _Z_COLLISION_CHECK_H_ -#define _Z_COLLISION_CHECK_H_ +#ifndef Z64COLLISION_CHECK_H +#define Z64COLLISION_CHECK_H #include "PR/ultratypes.h" #include "z64math.h" diff --git a/include/z64curve.h b/include/z64curve.h index f4923e3bf..77174be5e 100644 --- a/include/z64curve.h +++ b/include/z64curve.h @@ -1,5 +1,5 @@ -#ifndef Z64_CURVE_H -#define Z64_CURVE_H +#ifndef Z64CURVE_H +#define Z64CURVE_H #include "PR/ultratypes.h" #include "z64math.h" diff --git a/include/z64cutscene.h b/include/z64cutscene.h index f4cc10802..1fc32be28 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -4,158 +4,575 @@ #include "ultra64.h" #include "unk.h" -typedef struct { - /* 0x0 */ s8 continueFlag; - /* 0x1 */ s8 cameraRoll; - /* 0x2 */ u16 nextPointFrame; - /* 0x4 */ f32 viewAngle; // in degrees - /* 0x8 */ Vec3s pos; -} CutsceneCameraPoint; // size = 0x10 -typedef struct { - /* 0x00 */ Vec3f at; - /* 0x0C */ Vec3f eye; - /* 0x18 */ s16 roll; - /* 0x1A */ s16 fov; -} CutsceneCameraAngle; // size = 0x1C - -typedef struct { - /* 0x0 */ CutsceneCameraPoint* atPoints; - /* 0x4 */ CutsceneCameraPoint* eyePoints; - /* 0x8 */ s16 relativeToPlayer; -} CutsceneCameraMove; // size = 0xC - -typedef struct { - /* 0x00 */ u16 action; // "dousa" - /* 0x02 */ u16 startFrame; - /* 0x04 */ u16 endFrame; - union { - /* 0x06 */ Vec3s rot; - /* 0x06 */ Vec3us urot; +typedef union { + struct { + /* 0x00 */ u16 id; // "dousa" + /* 0x02 */ u16 startFrame; + /* 0x04 */ u16 endFrame; + /* 0x06 */ Vec3us rot; + /* 0x0C */ Vec3i startPos; + /* 0x18 */ Vec3i endPos; + /* 0x24 */ Vec3f normal; }; - /* 0x0C */ Vec3i startPos; - /* 0x18 */ Vec3i endPos; - /* 0x24 */ Vec3f normal; -} CsCmdActorAction; // size = 0x30 + s32 _words[12]; +} CsCmdActorCue; // size = 0x30 -typedef struct { - /* 0x0 */ u16 base; - /* 0x2 */ u16 startFrame; - /* 0x4 */ u16 endFrame; - /* 0x6 */ u16 unk_06; -} CsCmdBase; // size = 0x8 +typedef union { + struct { + /* 0x0 */ u16 type; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; + }; + s32 _words[2]; +} CsCmdMisc; // size = 0x30 -typedef struct { - /* 0x0 */ u16 unk0; - /* 0x2 */ u16 startFrame; - /* 0x4 */ u16 endFrame; - /* 0x6 */ u8 hour; - /* 0x7 */ u8 minute; - /* 0x8 */ UNK_TYPE1 unk_08[0x04]; -} CsCmdDayTime; // size = 0xC +typedef union { + struct { + /* 0x0 */ u16 unused0; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; // unused + /* 0x6 */ u8 hour; + /* 0x7 */ u8 minute; + }; + s32 _words[3]; +} CsCmdTime; // size = 0xC -typedef struct { - /* 0x0 */ u16 setting; - /* 0x2 */ u16 startFrame; - /* 0x4 */ u16 endFrame; - /* 0x6 */ u16 unk_06; -} CsCmdEnvLighting; // size = 0x8 +typedef union { + struct { + /* 0x0 */ u16 settingPlusOne; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; // unused + }; + s32 _words[2]; +} CsCmdLightSetting; // size = 0x8 -typedef struct { - /* 0x0 */ u16 sequence; - /* 0x2 */ u16 startFrame; - /* 0x4 */ u16 endFrame; - /* 0x6 */ u16 unk_06; -} CsCmdSequenceChange; // size = 0x8 +typedef union { + struct { + /* 0x0 */ u16 seqIdPlusOne; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; + }; + s32 _words[2]; +} CsCmdStartSeq; // size = 0x8 -typedef struct { - /* 0x0 */ u16 type; - /* 0x2 */ u16 startFrame; - /* 0x4 */ u16 endFrame; - /* 0x6 */ u16 unk_06; - /* 0x8 */ u32 unk_08; -} CsCmdSequenceFade; // size = 0xC +typedef union { + struct { + /* 0x0 */ u16 seqIdPlusOne; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; + }; + s32 _words[2]; +} CsCmdStopSeq; // size = 0x8 -typedef struct { - /* 0x0 */ u16 base; - /* 0x2 */ u16 startFrame; - /* 0x4 */ u16 endFrame; - /* 0x6 */ u16 type; - /* 0x8 */ u16 textId1; - /* 0xA */ u16 textId2; -} CsCmdTextbox; // size = 0xC +typedef union { + struct { + /* 0x0 */ u16 seqPlayer; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; + }; + s32 _words[3]; +} CsCmdFadeOutSeq; // size = 0xC typedef enum { - /* -1 */ CS_TEXTBOX_TYPE_NONE = -1, - /* 0 */ CS_TEXTBOX_TYPE_DEFAULT, - /* 1 */ CS_TEXTBOX_TYPE_1, - /* 2 */ CS_TEXTBOX_TYPE_LEARN_SONG, - /* 3 */ CS_TEXTBOX_TYPE_3, - /* 4 */ CS_TEXTBOX_TYPE_BOSSES_REMAINS, - /* 5 */ CS_TEXTBOX_TYPE_ALL_NORMAL_MASKS -} CutsceneTextboxType; + /* 1 */ CS_FADE_OUT_BGM_MAIN = 1, + /* 2 */ CS_FADE_OUT_FANFARE +} CutsceneFadeOutSeqPlayer; -typedef struct { - /* 0x0 */ u16 type; - /* 0x2 */ u16 startFrame; - /* 0x4 */ u16 endFrame; - /* 0x6 */ u8 intensity; - /* 0x7 */ u8 decayTimer; - /* 0x8 */ u8 decayStep; - /* 0x9 */ UNK_TYPE1 pad9[0x3]; +typedef union { + struct { + /* 0x0 */ u16 unused0; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; // unused + }; + s32 _words[2]; +} CsCmdStartAmbience; // size = 0x8 + +typedef union { + struct { + /* 0x0 */ u16 unused0; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; + }; + s32 _words[2]; +} CsCmdFadeOutAmbience; // size = 0x8 + +typedef union { + struct { + /* 0x0 */ u16 type; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; // unused + }; + s32 _words[2]; +} CsCmdModifySeq; // size = 0x8 + +typedef enum { + /* 1 */ CS_MOD_SEQ_0 = 1, + /* 2 */ CS_MOD_SEQ_1, + /* 3 */ CS_MOD_SEQ_2, + /* 4 */ CS_MOD_AMBIENCE_0, + /* 5 */ CS_MOD_AMBIENCE_1, + /* 6 */ CS_MOD_AMBIENCE_2, + /* 7 */ CS_MOD_SEQ_STORE, + /* 8 */ CS_MOD_SEQ_RESTORE +} CsModifySeqType; + +typedef union { + struct { + /* 0x0 */ u16 type; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; // unused + }; + s32 _words[2]; +} CsCmdDestination; // size = 0x8 + +typedef enum { + /* 1 */ CS_DESTINATION_DEFAULT = 1, + /* 2 */ CS_DESTINATION_BOSS_WARP +} CsDestinationType; + +typedef union { + struct { + /* 0x0 */ u16 type; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; // unused + }; + s32 _words[2]; +} CsCmdChooseCreditsScene; // size = 0x8 + +typedef enum { + /* 1 */ CS_CREDITS_DESTINATION = CS_DESTINATION_DEFAULT, + /* 2 */ CS_CREDITS_MASK_KAMARO, + /* 3 */ CS_CREDITS_MASK_GREAT_FAIRY, + /* 4 */ CS_CREDITS_MASK_ROMANI, + /* 5 */ CS_CREDITS_MASK_BLAST, + /* 6 */ CS_CREDITS_MASK_CIRCUS_LEADER, + /* 7 */ CS_CREDITS_MASK_BREMEN, + /* 8 */ CS_CREDITS_IKANA, + /* 9 */ CS_CREDITS_MASK_COUPLE, + /* 10 */ CS_CREDITS_MASK_BUNNY, + /* 11 */ CS_CREDITS_MASK_POSTMAN +} CsChooseCreditsSceneType; + +typedef union { + struct { + /* 0x0 */ u16 type; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; + }; + s32 _words[2]; +} CsCmdMotionBlur; // size = 0x8 + +typedef enum { + /* 1 */ CS_MOTION_BLUR_ENABLE = 1, // enable instantly + /* 2 */ CS_MOTION_BLUR_DISABLE // disable gradually +} CsMotionBlurType; + +typedef union { + struct { + /* 0x0 */ u16 unused0; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; // unused + }; + s32 _words[2]; +} CsCmdSfxReverbIndexTo2; // size = 0x8 + +typedef union { + struct { + /* 0x0 */ u16 unused0; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; // unused + }; + s32 _words[2]; +} CsCmdSfxReverbIndexTo1; // size = 0x8 + +typedef union { + struct { + /* 0x0 */ u16 type; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; + }; + s32 _words[2]; +} CsCmdTransition; // size = 0x8 + +typedef enum { + /* 1 */ CS_TRANS_GRAY_FILL_IN = 1, // has hardcoded sounds for some scenes + /* 2 */ CS_TRANS_BLUE_FILL_IN, + /* 3 */ CS_TRANS_RED_FILL_OUT, + /* 4 */ CS_TRANS_GREEN_FILL_OUT, + /* 5 */ CS_TRANS_GRAY_FILL_OUT, + /* 6 */ CS_TRANS_BLUE_FILL_OUT, + /* 7 */ CS_TRANS_RED_FILL_IN, + /* 8 */ CS_TRANS_GREEN_FILL_IN, + /* 9 */ CS_TRANS_TRIGGER_INSTANCE, // used with `TRANS_MODE_INSTANCE_WAIT` + /* 10 */ CS_TRANS_BLACK_FILL_OUT, + /* 11 */ CS_TRANS_BLACK_FILL_IN, + /* 12 */ CS_TRANS_GRAY_TO_BLACK, + /* 13 */ CS_TRANS_BLACK_TO_GRAY +} CutsceneTransitionType; + +typedef union { + struct { + /* 0x0 */ u16 textId; // can also be an ocarina action for `CS_TEXT_OCARINA_ACTION` + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; + /* 0x6 */ u16 type; + /* 0x8 */ u16 altTextId1; + /* 0xA */ u16 altTextId2; + }; + s32 _words[3]; +} CsCmdText; // size = 0xC + +typedef enum { + /* -1 */ CS_TEXT_TYPE_NONE = -1, + /* 0 */ CS_TEXT_TYPE_DEFAULT, + /* 1 */ CS_TEXT_TYPE_1, + /* 2 */ CS_TEXT_OCARINA_ACTION, + /* 3 */ CS_TEXT_TYPE_3, + /* 4 */ CS_TEXT_TYPE_BOSSES_REMAINS, // use `altText1` in the Giant Cutscene if all remains are already obtained + /* 5 */ CS_TEXT_TYPE_ALL_NORMAL_MASKS +} CutsceneTextType; + +typedef union { + struct { + /* 0x0 */ u16 type; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; + /* 0x6 */ u8 intensity; + /* 0x7 */ u8 decayTimer; + /* 0x8 */ u8 decayStep; + }; + s32 _words[3]; } CsCmdRumble; // size = 0xC -typedef struct { - /* 0x0 */ u16 unk0; - /* 0x2 */ u16 startFrame; - /* 0x4 */ u16 endFrame; - /* 0x6 */ Color_RGB8 color; - /* 0x9 */ UNK_TYPE1 pad9[0x3]; -} CsCmdFadeScreen; // size = 0xC +typedef enum { + /* 1 */ CS_RUMBLE_ONCE = 1, // rumble once when startFrame is reached + /* 2 */ CS_RUMBLE_PULSE // rumble every 64 frames between startFrame and endFrame +} CutsceneRumbleType; + +typedef union { + struct { + /* 0x0 */ u16 type; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; + /* 0x6 */ Color_RGB8 color; + }; + s32 _words[3]; +} CsCmdTransitionGeneral; // size = 0xC typedef enum { - /* 0 */ CS_STATE_0, - /* 1 */ CS_STATE_1, - /* 2 */ CS_STATE_2, - /* 3 */ CS_STATE_3, - /* 4 */ CS_STATE_4 + /* 1 */ CS_TRANS_GENERAL_FILL_IN = 1, + /* 2 */ CS_TRANS_GENERAL_FILL_OUT +} CsTransitionGeneralType; + +typedef union { + struct { + /* 0x0 */ u16 giveTatl; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; // unused + }; + s32 _words[2]; +} CsCmdGiveTatl; // size = 0x8 + +typedef enum { + /* 0 */ CS_STATE_IDLE, + /* 1 */ CS_STATE_START, + /* 2 */ CS_STATE_RUN, + /* 3 */ CS_STATE_STOP, + /* 4 */ CS_STATE_RUN_UNSTOPPABLE } CutsceneState; +typedef union { + struct { + /* 0x0 */ u16 unused0; + /* 0x2 */ u16 startFrame; + /* 0x4 */ u16 endFrame; // unused + }; + s32 _words[2]; +} CsCmdUnimplemented; // size = 0x8 + typedef enum { - /* 0x00A */ CS_CMD_TEXTBOX = 0xA, - /* 0x05A */ CS_CMD_CAMERA = 0x5A, - /* 0x096 */ CS_CMD_MISC = 0x96, - /* 0x097 */ CS_CMD_SET_LIGHTING, - /* 0x098 */ CS_CMD_SCENE_TRANS_FX, - /* 0x099 */ CS_CMD_MOTIONBLUR, - /* 0x09A */ CS_CMD_GIVETATL, - /* 0x09B */ CS_CMD_FADESCREEN, - /* 0x09C */ CS_CMD_FADESEQ, - /* 0x09D */ CS_CMD_SETTIME, - /* 0x0C8 */ CS_CMD_SET_PLAYER_ACTION = 0xC8, - /* 0x0FA */ CS_CMD_UNK_FA = 0xFA, - /* 0x0FE */ CS_CMD_UNK_FE = 0xFE, - /* 0x0FF */ CS_CMD_UNK_FF, - /* 0x100 */ CS_CMD_UNK_100, - /* 0x101 */ CS_CMD_UNK_101, - /* 0x102 */ CS_CMD_UNK_102, - /* 0x103 */ CS_CMD_UNK_103, - /* 0x104 */ CS_CMD_UNK_104, - /* 0x105 */ CS_CMD_UNK_105, - /* 0x108 */ CS_CMD_UNK_108 = 0x108, - /* 0x109 */ CS_CMD_UNK_109, - /* 0x12C */ CS_CMD_PLAYSEQ = 0x12C, - /* 0x12D */ CS_CMD_STOPSEQ, - /* 0x12E */ CS_CMD_PLAYAMBIENCE, - /* 0x12F */ CS_CMD_FADEAMBIENCE, - /* 0x130 */ CS_CMD_130, - /* 0x131 */ CS_CMD_131, - /* 0x132 */ CS_CMD_132, - /* 0x15E */ CS_CMD_TERMINATOR = 0x15E, + /* 0x00A */ CS_CMD_TEXT = 10, + /* 0x05A */ CS_CMD_CAMERA_SPLINE = 90, + /* 0x064 */ CS_CMD_ACTOR_CUE_100 = 100, + /* 0x065 */ CS_CMD_ACTOR_CUE_101, + /* 0x066 */ CS_CMD_ACTOR_CUE_102, + /* 0x067 */ CS_CMD_ACTOR_CUE_103, + /* 0x068 */ CS_CMD_ACTOR_CUE_104, + /* 0x069 */ CS_CMD_ACTOR_CUE_105, + /* 0x06A */ CS_CMD_ACTOR_CUE_106, + /* 0x06B */ CS_CMD_ACTOR_CUE_107, + /* 0x06C */ CS_CMD_ACTOR_CUE_108, + /* 0x06D */ CS_CMD_ACTOR_CUE_109, + /* 0x06E */ CS_CMD_ACTOR_CUE_110, + /* 0x06F */ CS_CMD_ACTOR_CUE_111, + /* 0x070 */ CS_CMD_ACTOR_CUE_112, + /* 0x071 */ CS_CMD_ACTOR_CUE_113, + /* 0x072 */ CS_CMD_ACTOR_CUE_114, + /* 0x073 */ CS_CMD_ACTOR_CUE_115, + /* 0x074 */ CS_CMD_ACTOR_CUE_116, + /* 0x075 */ CS_CMD_ACTOR_CUE_117, + /* 0x076 */ CS_CMD_ACTOR_CUE_118, + /* 0x077 */ CS_CMD_ACTOR_CUE_119, + /* 0x078 */ CS_CMD_ACTOR_CUE_120, + /* 0x079 */ CS_CMD_ACTOR_CUE_121, + /* 0x07A */ CS_CMD_ACTOR_CUE_122, + /* 0x07B */ CS_CMD_ACTOR_CUE_123, + /* 0x07C */ CS_CMD_ACTOR_CUE_124, + /* 0x07D */ CS_CMD_ACTOR_CUE_125, + /* 0x07E */ CS_CMD_ACTOR_CUE_126, + /* 0x07F */ CS_CMD_ACTOR_CUE_127, + /* 0x080 */ CS_CMD_ACTOR_CUE_128, + /* 0x081 */ CS_CMD_ACTOR_CUE_129, + /* 0x082 */ CS_CMD_ACTOR_CUE_130, + /* 0x083 */ CS_CMD_ACTOR_CUE_131, + /* 0x084 */ CS_CMD_ACTOR_CUE_132, + /* 0x085 */ CS_CMD_ACTOR_CUE_133, + /* 0x086 */ CS_CMD_ACTOR_CUE_134, + /* 0x087 */ CS_CMD_ACTOR_CUE_135, + /* 0x088 */ CS_CMD_ACTOR_CUE_136, + /* 0x089 */ CS_CMD_ACTOR_CUE_137, + /* 0x08A */ CS_CMD_ACTOR_CUE_138, + /* 0x08B */ CS_CMD_ACTOR_CUE_139, + /* 0x08C */ CS_CMD_ACTOR_CUE_140, + /* 0x08D */ CS_CMD_ACTOR_CUE_141, + /* 0x08E */ CS_CMD_ACTOR_CUE_142, + /* 0x08F */ CS_CMD_ACTOR_CUE_143, + /* 0x090 */ CS_CMD_ACTOR_CUE_144, + /* 0x091 */ CS_CMD_ACTOR_CUE_145, + /* 0x092 */ CS_CMD_ACTOR_CUE_146, + /* 0x093 */ CS_CMD_ACTOR_CUE_147, + /* 0x094 */ CS_CMD_ACTOR_CUE_148, + /* 0x095 */ CS_CMD_ACTOR_CUE_149, + /* 0x096 */ CS_CMD_MISC, + /* 0x097 */ CS_CMD_LIGHT_SETTING, + /* 0x098 */ CS_CMD_TRANSITION, + /* 0x099 */ CS_CMD_MOTION_BLUR, + /* 0x09A */ CS_CMD_GIVE_TATL, + /* 0x09B */ CS_CMD_TRANSITION_GENERAL, + /* 0x09C */ CS_CMD_FADE_OUT_SEQ, + /* 0x09D */ CS_CMD_TIME, + /* 0x0C8 */ CS_CMD_PLAYER_CUE = 200, + /* 0x0C9 */ CS_CMD_ACTOR_CUE_201, + /* 0x0FA */ CS_CMD_UNK_DATA_FA = 0xFA, + /* 0x0FE */ CS_CMD_UNK_DATA_FE = 0xFE, + /* 0x0FF */ CS_CMD_UNK_DATA_FF, + /* 0x100 */ CS_CMD_UNK_DATA_100, + /* 0x101 */ CS_CMD_UNK_DATA_101, + /* 0x102 */ CS_CMD_UNK_DATA_102, + /* 0x103 */ CS_CMD_UNK_DATA_103, + /* 0x104 */ CS_CMD_UNK_DATA_104, + /* 0x105 */ CS_CMD_UNK_DATA_105, + /* 0x108 */ CS_CMD_UNK_DATA_108 = 0x108, + /* 0x109 */ CS_CMD_UNK_DATA_109, + /* 0x12C */ CS_CMD_START_SEQ = 300, + /* 0x12D */ CS_CMD_STOP_SEQ, + /* 0x12E */ CS_CMD_START_AMBIENCE, + /* 0x12F */ CS_CMD_FADE_OUT_AMBIENCE, + /* 0x130 */ CS_CMD_SFX_REVERB_INDEX_2, + /* 0x131 */ CS_CMD_SFX_REVERB_INDEX_1, + /* 0x132 */ CS_CMD_MODIFY_SEQ, + /* 0x15E */ CS_CMD_DESTINATION = 350, /* 0x15F */ CS_CMD_CHOOSE_CREDITS_SCENES, - /* 0x190 */ CS_CMD_RUMBLE = 0x190 + /* 0x190 */ CS_CMD_RUMBLE = 400, + /* 0x1C2 */ CS_CMD_ACTOR_CUE_450 = 450, + /* 0x1C3 */ CS_CMD_ACTOR_CUE_451, + /* 0x1C4 */ CS_CMD_ACTOR_CUE_452, + /* 0x1C5 */ CS_CMD_ACTOR_CUE_453, + /* 0x1C6 */ CS_CMD_ACTOR_CUE_454, + /* 0x1C7 */ CS_CMD_ACTOR_CUE_455, + /* 0x1C8 */ CS_CMD_ACTOR_CUE_456, + /* 0x1C9 */ CS_CMD_ACTOR_CUE_457, + /* 0x1CA */ CS_CMD_ACTOR_CUE_458, + /* 0x1CB */ CS_CMD_ACTOR_CUE_459, + /* 0x1CC */ CS_CMD_ACTOR_CUE_460, + /* 0x1CD */ CS_CMD_ACTOR_CUE_461, + /* 0x1CE */ CS_CMD_ACTOR_CUE_462, + /* 0x1CF */ CS_CMD_ACTOR_CUE_463, + /* 0x1D0 */ CS_CMD_ACTOR_CUE_464, + /* 0x1D1 */ CS_CMD_ACTOR_CUE_465, + /* 0x1D2 */ CS_CMD_ACTOR_CUE_466, + /* 0x1D3 */ CS_CMD_ACTOR_CUE_467, + /* 0x1D4 */ CS_CMD_ACTOR_CUE_468, + /* 0x1D5 */ CS_CMD_ACTOR_CUE_469, + /* 0x1D6 */ CS_CMD_ACTOR_CUE_470, + /* 0x1D7 */ CS_CMD_ACTOR_CUE_471, + /* 0x1D8 */ CS_CMD_ACTOR_CUE_472, + /* 0x1D9 */ CS_CMD_ACTOR_CUE_473, + /* 0x1DA */ CS_CMD_ACTOR_CUE_474, + /* 0x1DB */ CS_CMD_ACTOR_CUE_475, + /* 0x1DC */ CS_CMD_ACTOR_CUE_476, + /* 0x1DD */ CS_CMD_ACTOR_CUE_477, + /* 0x1DE */ CS_CMD_ACTOR_CUE_478, + /* 0x1DF */ CS_CMD_ACTOR_CUE_479, + /* 0x1E0 */ CS_CMD_ACTOR_CUE_480, + /* 0x1E1 */ CS_CMD_ACTOR_CUE_481, + /* 0x1E2 */ CS_CMD_ACTOR_CUE_482, + /* 0x1E3 */ CS_CMD_ACTOR_CUE_483, + /* 0x1E4 */ CS_CMD_ACTOR_CUE_484, + /* 0x1E5 */ CS_CMD_ACTOR_CUE_485, + /* 0x1E6 */ CS_CMD_ACTOR_CUE_486, + /* 0x1E7 */ CS_CMD_ACTOR_CUE_487, + /* 0x1E8 */ CS_CMD_ACTOR_CUE_488, + /* 0x1E9 */ CS_CMD_ACTOR_CUE_489, + /* 0x1EA */ CS_CMD_ACTOR_CUE_490, + /* 0x1EB */ CS_CMD_ACTOR_CUE_491, + /* 0x1EC */ CS_CMD_ACTOR_CUE_492, + /* 0x1ED */ CS_CMD_ACTOR_CUE_493, + /* 0x1EE */ CS_CMD_ACTOR_CUE_494, + /* 0x1EF */ CS_CMD_ACTOR_CUE_495, + /* 0x1F0 */ CS_CMD_ACTOR_CUE_496, + /* 0x1F1 */ CS_CMD_ACTOR_CUE_497, + /* 0x1F2 */ CS_CMD_ACTOR_CUE_498, + /* 0x1F3 */ CS_CMD_ACTOR_CUE_499, + /* 0x1F4 */ CS_CMD_ACTOR_CUE_500, + /* 0x1F5 */ CS_CMD_ACTOR_CUE_501, + /* 0x1F6 */ CS_CMD_ACTOR_CUE_502, + /* 0x1F7 */ CS_CMD_ACTOR_CUE_503, + /* 0x1F8 */ CS_CMD_ACTOR_CUE_504, + /* 0x1F9 */ CS_CMD_ACTOR_CUE_505, + /* 0x1FA */ CS_CMD_ACTOR_CUE_506, + /* 0x1FB */ CS_CMD_ACTOR_CUE_507, + /* 0x1FC */ CS_CMD_ACTOR_CUE_508, + /* 0x1FD */ CS_CMD_ACTOR_CUE_509, + /* 0x1FE */ CS_CMD_ACTOR_CUE_510, + /* 0x1FF */ CS_CMD_ACTOR_CUE_511, + /* 0x200 */ CS_CMD_ACTOR_CUE_512, + /* 0x201 */ CS_CMD_ACTOR_CUE_513, + /* 0x202 */ CS_CMD_ACTOR_CUE_514, + /* 0x203 */ CS_CMD_ACTOR_CUE_515, + /* 0x204 */ CS_CMD_ACTOR_CUE_516, + /* 0x205 */ CS_CMD_ACTOR_CUE_517, + /* 0x206 */ CS_CMD_ACTOR_CUE_518, + /* 0x207 */ CS_CMD_ACTOR_CUE_519, + /* 0x208 */ CS_CMD_ACTOR_CUE_520, + /* 0x209 */ CS_CMD_ACTOR_CUE_521, + /* 0x20A */ CS_CMD_ACTOR_CUE_522, + /* 0x20B */ CS_CMD_ACTOR_CUE_523, + /* 0x20C */ CS_CMD_ACTOR_CUE_524, + /* 0x20D */ CS_CMD_ACTOR_CUE_525, + /* 0x20E */ CS_CMD_ACTOR_CUE_526, + /* 0x20F */ CS_CMD_ACTOR_CUE_527, + /* 0x210 */ CS_CMD_ACTOR_CUE_528, + /* 0x211 */ CS_CMD_ACTOR_CUE_529, + /* 0x212 */ CS_CMD_ACTOR_CUE_530, + /* 0x213 */ CS_CMD_ACTOR_CUE_531, + /* 0x214 */ CS_CMD_ACTOR_CUE_532, + /* 0x215 */ CS_CMD_ACTOR_CUE_533, + /* 0x216 */ CS_CMD_ACTOR_CUE_534, + /* 0x217 */ CS_CMD_ACTOR_CUE_535, + /* 0x218 */ CS_CMD_ACTOR_CUE_536, + /* 0x219 */ CS_CMD_ACTOR_CUE_537, + /* 0x21A */ CS_CMD_ACTOR_CUE_538, + /* 0x21B */ CS_CMD_ACTOR_CUE_539, + /* 0x21C */ CS_CMD_ACTOR_CUE_540, + /* 0x21D */ CS_CMD_ACTOR_CUE_541, + /* 0x21E */ CS_CMD_ACTOR_CUE_542, + /* 0x21F */ CS_CMD_ACTOR_CUE_543, + /* 0x220 */ CS_CMD_ACTOR_CUE_544, + /* 0x221 */ CS_CMD_ACTOR_CUE_545, + /* 0x222 */ CS_CMD_ACTOR_CUE_546, + /* 0x223 */ CS_CMD_ACTOR_CUE_547, + /* 0x224 */ CS_CMD_ACTOR_CUE_548, + /* 0x225 */ CS_CMD_ACTOR_CUE_549, + /* 0x226 */ CS_CMD_ACTOR_CUE_550, + /* 0x227 */ CS_CMD_ACTOR_CUE_551, + /* 0x228 */ CS_CMD_ACTOR_CUE_552, + /* 0x229 */ CS_CMD_ACTOR_CUE_553, + /* 0x22A */ CS_CMD_ACTOR_CUE_554, + /* 0x22B */ CS_CMD_ACTOR_CUE_555, + /* 0x22C */ CS_CMD_ACTOR_CUE_556, + /* 0x22D */ CS_CMD_ACTOR_CUE_557, + /* 0x22E */ CS_CMD_ACTOR_CUE_558, + /* 0x22F */ CS_CMD_ACTOR_CUE_559, + /* 0x230 */ CS_CMD_ACTOR_CUE_560, + /* 0x231 */ CS_CMD_ACTOR_CUE_561, + /* 0x232 */ CS_CMD_ACTOR_CUE_562, + /* 0x233 */ CS_CMD_ACTOR_CUE_563, + /* 0x234 */ CS_CMD_ACTOR_CUE_564, + /* 0x235 */ CS_CMD_ACTOR_CUE_565, + /* 0x236 */ CS_CMD_ACTOR_CUE_566, + /* 0x237 */ CS_CMD_ACTOR_CUE_567, + /* 0x238 */ CS_CMD_ACTOR_CUE_568, + /* 0x239 */ CS_CMD_ACTOR_CUE_569, + /* 0x23A */ CS_CMD_ACTOR_CUE_570, + /* 0x23B */ CS_CMD_ACTOR_CUE_571, + /* 0x23C */ CS_CMD_ACTOR_CUE_572, + /* 0x23D */ CS_CMD_ACTOR_CUE_573, + /* 0x23E */ CS_CMD_ACTOR_CUE_574, + /* 0x23F */ CS_CMD_ACTOR_CUE_575, + /* 0x240 */ CS_CMD_ACTOR_CUE_576, + /* 0x241 */ CS_CMD_ACTOR_CUE_577, + /* 0x242 */ CS_CMD_ACTOR_CUE_578, + /* 0x243 */ CS_CMD_ACTOR_CUE_579, + /* 0x244 */ CS_CMD_ACTOR_CUE_580, + /* 0x245 */ CS_CMD_ACTOR_CUE_581, + /* 0x246 */ CS_CMD_ACTOR_CUE_582, + /* 0x247 */ CS_CMD_ACTOR_CUE_583, + /* 0x248 */ CS_CMD_ACTOR_CUE_584, + /* 0x249 */ CS_CMD_ACTOR_CUE_585, + /* 0x24A */ CS_CMD_ACTOR_CUE_586, + /* 0x24B */ CS_CMD_ACTOR_CUE_587, + /* 0x24C */ CS_CMD_ACTOR_CUE_588, + /* 0x24D */ CS_CMD_ACTOR_CUE_589, + /* 0x24E */ CS_CMD_ACTOR_CUE_590, + /* 0x24F */ CS_CMD_ACTOR_CUE_591, + /* 0x250 */ CS_CMD_ACTOR_CUE_592, + /* 0x251 */ CS_CMD_ACTOR_CUE_593, + /* 0x252 */ CS_CMD_ACTOR_CUE_594, + /* 0x253 */ CS_CMD_ACTOR_CUE_595, + /* 0x254 */ CS_CMD_ACTOR_CUE_596, + /* 0x255 */ CS_CMD_ACTOR_CUE_597, + /* 0x256 */ CS_CMD_ACTOR_CUE_598, + /* 0x257 */ CS_CMD_ACTOR_CUE_599, + /* -2 */ CS_CMD_ACTOR_CUE_POST_PROCESS = 0xFFFFFFFE, + /* -1 */ CS_CAM_STOP // OoT Remnant } CutsceneCmd; +typedef enum { + /* 0x00 */ CS_MISC_UNIMPLEMENTED_0, + /* 0x01 */ CS_MISC_RAIN, + /* 0x02 */ CS_MISC_LIGHTNING, + /* 0x03 */ CS_MISC_LIFT_FOG, + /* 0x04 */ CS_MISC_CLOUDY_SKY, + /* 0x05 */ CS_MISC_STOP_CUTSCENE, + /* 0x06 */ CS_MISC_UNIMPLEMENTED_6, + /* 0x07 */ CS_MISC_SHOW_TITLE_CARD, + /* 0x08 */ CS_MISC_EARTHQUAKE_MEDIUM, + /* 0x09 */ CS_MISC_EARTHQUAKE_STOP, + /* 0x0A */ CS_MISC_VISMONO_BLACK_AND_WHITE, + /* 0x0B */ CS_MISC_VISMONO_SEPIA, + /* 0x0C */ CS_MISC_HIDE_ROOM, + /* 0x0D */ CS_MISC_RED_PULSATING_LIGHTS, + /* 0x0E */ CS_MISC_HALT_ALL_ACTORS, + /* 0x0F */ CS_MISC_RESUME_ALL_ACTORS, + /* 0x10 */ CS_MISC_SANDSTORM_FILL, + /* 0x11 */ CS_MISC_SUNSSONG_START, + /* 0x12 */ CS_MISC_FREEZE_TIME, + /* 0x13 */ CS_MISC_LONG_SCARECROW_SONG, + /* 0x14 */ CS_MISC_SET_CSFLAG_3, + /* 0x15 */ CS_MISC_SET_CSFLAG_4, + /* 0x16 */ CS_MISC_PLAYER_FORM_DEKU, + /* 0x17 */ CS_MISC_ENABLE_PLAYER_REFLECTION, + /* 0x18 */ CS_MISC_DISABLE_PLAYER_REFLECTION, + /* 0x19 */ CS_MISC_PLAYER_FORM_HUMAN, + /* 0x1A */ CS_MISC_EARTHQUAKE_STRONG, + /* 0x1B */ CS_MISC_DEST_MOON_CRASH_FIRE_WALL, + /* 0x1C */ CS_MISC_MOON_CRASH_SKYBOX, + /* 0x1D */ CS_MISC_PLAYER_FORM_RESTORED, + /* 0x1E */ CS_MISC_DISABLE_PLAYER_CSMODE_START_POS, + /* 0x1F */ CS_MISC_ENABLE_PLAYER_CSMODE_START_POS, + /* 0x20 */ CS_MISC_UNIMPLEMENTED_20, + /* 0x21 */ CS_MISC_SAVE_ENTER_CLOCK_TOWN, + /* 0x22 */ CS_MISC_RESET_SAVE_FROM_MOON_CRASH, + /* 0x23 */ CS_MISC_TIME_ADVANCE, + /* 0x24 */ CS_MISC_EARTHQUAKE_WEAK, + /* 0x25 */ CS_MISC_UNIMPLEMENTED_25, + /* 0x26 */ CS_MISC_DAWN_OF_A_NEW_DAY, + /* 0x27 */ CS_MISC_PLAYER_FORM_ZORA, + /* 0x28 */ CS_MISC_FINALE +} CutsceneMiscType; + typedef union CutsceneData { s32 i; f32 f; @@ -163,29 +580,291 @@ typedef union CutsceneData { s8 b[4]; } CutsceneData; -typedef struct { - /* 0x0 */ CutsceneData* segmentedData; - /* 0x4 */ s16 nextEntrance; - /* 0x6 */ u8 unk6; - /* 0x7 */ u8 unk7; // a weekEventReg bitpack? -} CutsceneEntry; // size = 0x8 +#define BIT_FLAG_TO_SHIFT(flag) \ + ((flag & 0x80) ? 7 : \ + (flag & 0x40) ? 6 : \ + (flag & 0x20) ? 5 : \ + (flag & 0x10) ? 4 : \ + (flag & 0x8) ? 3 : \ + (flag & 0x4) ? 2 : \ + (flag & 0x2) ? 1 : \ + (flag & 0x1) ? 0 : \ + 0) + +// Do not trigger the scripted cutscene upon any spawn +#define CS_SPAWN_FLAG_NONE 0xFF +// Always trigger the scripted cutscene upon the specified spawn +#define CS_SPAWN_FLAG_ALWAYS 0xFE +// Trigger the scripted cutscene once upon the specified spawn if `weekEventFlags` is not set. Set `weekEventFlags` after the cutscene. +//! @note Despite there being more than `0x1F` indices for weekEventFlags, this u8 flag entry can only check weekEventFlags with indices [0 - 0x1F] +#define CS_SPAWN_FLAG_ONCE(weekEventFlag) ((((weekEventFlag) & 0x1F00) >> 5) | BIT_FLAG_TO_SHIFT((weekEventFlag) & 0xFF)) + +#define CHECK_CS_SPAWN_FLAG_WEEKEVENTREG(spawnFlags) (GET_WEEKEVENTREG((spawnFlags) / 8) & (1 << ((spawnFlags) % 8))) +#define SET_CS_SPAWN_FLAG_WEEKEVENTREG(spawnFlags) (WEEKEVENTREG((spawnFlags) / 8) = GET_WEEKEVENTREG((spawnFlags) / 8) | (1 << ((spawnFlags) % 8))) + typedef struct { - /* 0x00 */ u8 sceneCsCount; - /* 0x04 */ CutsceneData* csData; - /* 0x08 */ u8 state; - /* 0x0C */ f32 unk_0C; - /* 0x10 */ u16 frames; - /* 0x12 */ u16 currentCsIndex; - /* 0x14 */ s32 subCamId; - /* 0x18 */ u16 unk_18; - /* 0x1A */ u8 unk_1A; - /* 0x1B */ u8 unk_1B; - /* 0x1C */ CutsceneCameraPoint* atPoints; - /* 0x20 */ CutsceneCameraPoint* eyePoints; - /* 0x24 */ CsCmdActorAction* playerAction; - /* 0x28 */ CsCmdActorAction* actorActions[10]; // "npcdemopnt" - /* 0x50 */ CutsceneEntry* sceneCsList; + /* 0x0 */ CutsceneData* script; + /* 0x4 */ s16 nextEntrance; + /* 0x6 */ u8 spawn; + /* 0x7 */ u8 spawnFlags; // See `CS_SPAWN_FLAG_` +} CutsceneScriptEntry; // size = 0x8 + +// ZAPD compatibility typedefs +// TODO: Remove when ZAPD adds support for them +typedef CutsceneScriptEntry CutsceneEntry; + +typedef struct { + /* 0x00 */ u8 scriptListCount; + /* 0x04 */ CutsceneData* script; + /* 0x08 */ u8 state; + /* 0x0C */ f32 timer; + /* 0x10 */ u16 curFrame; + /* 0x12 */ u16 scriptIndex; + /* 0x14 */ s32 subCamId; + /* 0x18 */ u16 camEyeSplinePointsAppliedFrame; // Remnant of OoT. Set but never used. + /* 0x1C */ UNK_TYPE1 unk_1C[0xA]; // Remnant of cam data from OoT + /* 0x24 */ CsCmdActorCue* playerCue; + /* 0x28 */ CsCmdActorCue* actorCues[10]; // "npcdemopnt" + /* 0x50 */ CutsceneScriptEntry* scriptList; } CutsceneContext; // size = 0x54 +/* Actor Cutscenes, which encompasses all cutscenes */ + +typedef struct { + /* 0x00 */ s16 priority; // Lower means higher priority. -1 means it ignores priority + /* 0x02 */ s16 length; + /* 0x04 */ s16 csCamId; // Index of CsCameraEntry to use. Negative indices use sGlobalCamDataSettings. Indices 0 and above use CsCameraEntry from a sceneLayer + /* 0x06 */ s16 scriptIndex; + /* 0x08 */ s16 additionalCsId; + /* 0x0A */ u8 endSfx; + /* 0x0B */ u8 customValue; // 0 - 99: actor-specific custom value. 100+: spawn. 255: none + /* 0x0C */ s16 hudVisibility; + /* 0x0E */ u8 endCam; + /* 0x0F */ u8 letterboxSize; +} ActorCutscene; // size = 0x10 +// TODO: rename `ActorCutscene` to `CutsceneEntry` once ZAPD uses `CutsceneScriptEntry` +// typedef CutsceneEntry ActorCutscene; + +typedef enum { + /* -1 */ CS_ID_NONE = -1, + // CsId's 0 - 119 are sceneLayer-specific and index `ActorCutscene` + /* 0x78 */ CS_ID_GLOBAL_78 = 120, + /* 0x79 */ CS_ID_GLOBAL_79, + /* 0x7A */ CS_ID_GLOBAL_7A, + /* 0x7B */ CS_ID_GLOBAL_ELEGY, + /* 0x7C */ CS_ID_GLOBAL_TALK, + /* 0x7D */ CS_ID_GLOBAL_DOOR, + /* 0x7E */ CS_ID_GLOBAL_RETURN_TO_CAM, // smoothly return to the previous camera + /* 0x7F */ CS_ID_GLOBAL_END +} CutsceneId; + +typedef enum { + /* 0 */ PLAYER_CS_ID_ITEM_OCARINA, + /* 1 */ PLAYER_CS_ID_ITEM_GET, + /* 2 */ PLAYER_CS_ID_ITEM_BOTTLE, + /* 3 */ PLAYER_CS_ID_ITEM_SHOW, + /* 4 */ PLAYER_CS_ID_WARP_PAD_MOON, + /* 5 */ PLAYER_CS_ID_MASK_TRANSFORMATION, + /* 6 */ PLAYER_CS_ID_DEATH, + /* 7 */ PLAYER_CS_ID_REVIVE, + /* 8 */ PLAYER_CS_ID_SONG_WARP, // Song of Time and Song of Soaring + /* 9 */ PLAYER_CS_ID_WARP_PAD_ENTRANCE, + /* 10 */ PLAYER_CS_ID_MAX +} PlayerCsId; + +#define CS_SCRIPT_ID_NONE -1 + +typedef enum { + // global (see sGlobalCamDataSettings) + /* -25 */ CS_CAM_ID_GLOBAL_ELEGY = -25, // CAM_SET_ELEGY_SHELL + /* -24 */ CS_CAM_ID_GLOBAL_SIDED, // CAM_SET_SIDED + /* -23 */ CS_CAM_ID_GLOBAL_BOAT_CRUISE, // CAM_SET_BOAT_CRUISE + /* -22 */ CS_CAM_ID_GLOBAL_N16, // CAM_SET_NONE + /* -21 */ CS_CAM_ID_GLOBAL_SUBJECTD, // CAM_SET_SUBJECTD + /* -20 */ CS_CAM_ID_GLOBAL_NORMALD, // CAM_SET_NORMALD + /* -19 */ CS_CAM_ID_GLOBAL_N13, // CAM_SET_NONE + /* -18 */ CS_CAM_ID_GLOBAL_N12, // CAM_SET_NONE + /* -17 */ CS_CAM_ID_GLOBAL_N11, // CAM_SET_NONE + /* -16 */ CS_CAM_ID_GLOBAL_WARP_PAD_ENTRANCE, // CAM_SET_WARP_PAD_ENTRANCE + /* -15 */ CS_CAM_ID_GLOBAL_ATTENTION, // CAM_SET_ATTENTION + /* -14 */ CS_CAM_ID_GLOBAL_CONNECT, // CAM_SET_CONNECT0 + /* -13 */ CS_CAM_ID_GLOBAL_REMOTE_BOMB, // CAM_SET_REMOTEBOMB + /* -12 */ CS_CAM_ID_GLOBAL_N0C, // CAM_SET_NONE + /* -11 */ CS_CAM_ID_GLOBAL_MASK_TRANSFORMATION, // CAM_SET_MASK_TRANSFORMATION + /* -10 */ CS_CAM_ID_GLOBAL_LONG_CHEST_OPENING, // CAM_SET_LONG_CHEST_OPENING + /* -9 */ CS_CAM_ID_GLOBAL_REVIVE, // CAM_SET_REBIRTH + /* -8 */ CS_CAM_ID_GLOBAL_DEATH, // CAM_SET_DEATH + /* -7 */ CS_CAM_ID_GLOBAL_WARP_PAD_MOON, // CAM_SET_WARP_PAD_MOON + /* -6 */ CS_CAM_ID_GLOBAL_SONG_WARP, // CAM_SET_NAVI + /* -5 */ CS_CAM_ID_GLOBAL_ITEM_SHOW, // CAM_SET_ITEM3 + /* -4 */ CS_CAM_ID_GLOBAL_ITEM_BOTTLE, // CAM_SET_ITEM2 + /* -3 */ CS_CAM_ID_GLOBAL_ITEM_OCARINA, // CAM_SET_ITEM1 + /* -2 */ CS_CAM_ID_GLOBAL_ITEM_GET, // CAM_SET_ITEM0 + /* -1 */ CS_CAM_ID_NONE + // CamCsId's 0+ are sceneLayer-specific and index `ActorCsCamInfo` +} CutsceneCamId; + +typedef enum { + /* -1 */ CS_HUD_VISIBILITY_ALL_ALT = -1, + /* 0 */ CS_HUD_VISIBILITY_NONE, + /* 1 */ CS_HUD_VISIBILITY_ALL, + /* 2 */ CS_HUD_VISIBILITY_A_HEARTS_MAGIC, + /* 3 */ CS_HUD_VISIBILITY_C_HEARTS_MAGIC, + /* 4 */ CS_HUD_VISIBILITY_ALL_NO_MINIMAP, + /* 5 */ CS_HUD_VISIBILITY_A_B_C, + /* 6 */ CS_HUD_VISIBILITY_B_MINIMAP, + /* 7 */ CS_HUD_VISIBILITY_A +} CutsceneHudVisibility; + +typedef enum { + /* 0 */ CS_END_SFX_NONE, + /* 1 */ CS_END_SFX_TRE_BOX_APPEAR, + /* 2 */ CS_END_SFX_CORRECT_CHIME, + /* 255 */ CS_END_SFX_NONE_ALT = 0xFF +} CutsceneEndSfx; + +typedef enum { + /* 0 */ CS_END_CAM_0, + /* 1 */ CS_END_CAM_1, + /* 2 */ CS_END_CAM_SMOOTH +} CutsceneEndCam; + +/* Cutscene Camera Spline Scripts */ + +typedef struct { + /* 0x0 */ s16 numEntries; + /* 0x2 */ s16 unk_02; // unused + /* 0x4 */ s16 unk_04; // unused + /* 0x6 */ s16 duration; // total duration +} CsCmdCamSpline; // size = 0x8 + +// Both camAt and camEye +typedef struct { + /* 0x0 */ u8 interpType; // see `CutsceneCamInterpType` + /* 0x1 */ u8 weight; // for certain types of interpTypes, shifts the weight to certain points. Default is 100. + /* 0x2 */ s16 duration; // duration of current point + /* 0x4 */ Vec3s pos; + /* 0xA */ s16 relativeTo; // see `CutsceneCamRelativeTo` +} CsCmdCamPoint; // size = 0xC + +typedef enum { + /* 0 */ CS_CAM_INTERP_0, + /* 1 */ CS_CAM_INTERP_1, + /* 2 */ CS_CAM_INTERP_2, + /* 3 */ CS_CAM_INTERP_3, + /* 4 */ CS_CAM_INTERP_4, + /* 5 */ CS_CAM_INTERP_5, + /* 6 */ CS_CAM_INTERP_6, + /* 7 */ CS_CAM_INTERP_7 +} CutsceneCamInterpType; + +typedef enum { + /* 0 */ CS_CAM_REL_0, + /* 1 */ CS_CAM_REL_1, + /* 2 */ CS_CAM_REL_2, + /* 3 */ CS_CAM_REL_3, + /* 4 */ CS_CAM_REL_4, + /* 5 */ CS_CAM_REL_5 +} CutsceneCamRelativeTo; + + +// Roll and Fov Data +typedef struct { + /* 0x0 */ s16 unused0; // unused + /* 0x2 */ s16 roll; + /* 0x4 */ s16 fov; + /* 0x6 */ s16 unused1; // unused +} CsCmdCamMisc; // size = 0x8 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x2A */ f32 unk_20; + /* 0x24 */ s16 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ s16 unk_28; + /* 0x2A */ s16 numEntries; + /* 0x1E */ u8 curPoint; + /* 0x2D */ u8 unk_2D; + /* 0x2E */ UNK_TYPE1 unk_2E[2]; +} CutsceneCameraInterp; // size = 0x30 + +typedef struct { + /* 0x00 */ s16 splineIndex; + /* 0x02 */ s16 cmdIndex; + /* 0x04 */ s16 splineNeedsInit; + /* 0x06 */ s16 state; + /* 0x08 */ s16 nextSplineTimer; + /* 0x0A */ s16 updateSplineTimer; + /* 0x0C */ s16 duration; // Duration of the current spline + /* 0x10 */ CutsceneCameraInterp eyeInterp; + /* 0x40 */ CutsceneCameraInterp atInterp; + /* 0x70 */ CsCmdCamPoint* atCmd; + /* 0x74 */ CsCmdCamPoint* eyeCmd; + /* 0x78 */ CsCmdCamMisc* miscCmd; + /* 0x7C */ Camera* camera; +} CutsceneCamera; // size = 0x80 + +typedef enum { + /* 0 */ CS_CAM_STATE_UPDATE_ALL, // Update spline and next spline timer + /* 0 */ CS_CAM_STATE_UPDATE_SPLINE, // Update spline, do not advance next spline timer + /* 0 */ CS_CAM_STATE_PAUSE, // No updates + /* 0 */ CS_CAM_STATE_DONE_SPLINE, // Finished the current spline, ready for the next one + /* 0 */ CS_CAM_STATE_DONE = 999 // Finished all the splines. +} CutsceneCameraState; + +// OoT Remnant +#define CS_CAM_DATA_NOT_APPLIED 0xFFFF + +void Cutscene_InitContext(struct PlayState* play, CutsceneContext* csCtx); +void Cutscene_StartManual(struct PlayState* play, CutsceneContext* csCtx); +void Cutscene_StopManual(struct PlayState* play, CutsceneContext* csCtx); +void Cutscene_UpdateManual(struct PlayState* play, CutsceneContext* csCtx); +void Cutscene_UpdateScripted(struct PlayState* play, CutsceneContext* csCtx); +void Cutscene_HandleEntranceTriggers(struct PlayState* play); +void func_800EDDB0(struct PlayState* play); +void Cutscene_StartScripted(struct PlayState* play, u8 scriptIndex); +void Cutscene_ActorTranslate(Actor* actor, struct PlayState* play, s32 cueChannel); +void Cutscene_ActorTranslateAndYaw(Actor* actor, struct PlayState* play, s32 cueChannel); +void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, struct PlayState* play, s32 cueChannel); +void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, struct PlayState* play, s32 cueChannel); +s32 Cutscene_GetSceneLayer(struct PlayState* play); +s32 Cutscene_GetCueChannel(struct PlayState* play, u16 cueType); +s32 Cutscene_IsCueInChannel(struct PlayState* play, u16 cueType); +u8 Cutscene_IsPlaying(struct PlayState* play); + +void CutsceneManager_Init(struct PlayState* play, ActorCutscene* cutsceneList, s16 numEntries); +void CutsceneManager_StoreCamera(Camera* camera); +void CutsceneManager_ClearWaiting(void); +s16 CutsceneManager_Update(void); +void CutsceneManager_Queue(s16 csId); +s16 CutsceneManager_IsNext(s16 csId); +s16 CutsceneManager_StartWithPlayerCs(s16 csId, Actor* actor); +s16 CutsceneManager_StartWithPlayerCsAndSetFlag(s16 csId, Actor* actor); +s16 CutsceneManager_Start(s16 csId, Actor* actor); +s16 CutsceneManager_Stop(s16 csId); +s16 CutsceneManager_GetCurrentCsId(void); +ActorCutscene* CutsceneManager_GetCutsceneEntry(s16 csId); +s16 CutsceneManager_GetAdditionalCsId(s16 csId); +s16 CutsceneManager_GetLength(s16 csId); +s16 CutsceneManager_GetCutsceneScriptIndex(s16 csId); +s16 CutsceneManager_GetCutsceneCustomValue(s16 csId); +s16 CutsceneManager_GetCurrentSubCamId(s16 csId); +s16 CutsceneManager_FindEntranceCsId(void); +s32 func_800F22C4(s16 csId, Actor* actor); +void CutsceneManager_SetReturnCamera(s16 camId); + +s32 CutsceneCamera_Init(Camera* camera, CutsceneCamera* csCamera); +s32 CutsceneCamera_UpdateSplines(u8* script, CutsceneCamera* csCamera); +void CutsceneCamera_SetState(s16 state); +void CutsceneCamera_Reset(void); + +void CutsceneFlags_UnsetAll(struct PlayState* play); +void CutsceneFlags_Set(struct PlayState* play, s16 flag); +void CutsceneFlags_Unset(struct PlayState* play, s16 flag); +s32 CutsceneFlags_Get(struct PlayState* play, s16 flag); + #endif diff --git a/include/z64cutscene_commands.h b/include/z64cutscene_commands.h index 1ab6533ac..50e1ce451 100644 --- a/include/z64cutscene_commands.h +++ b/include/z64cutscene_commands.h @@ -5,13 +5,19 @@ #include "z64cutscene.h" /** + * Cutscene scripts are arrays of `CutsceneData` words, including bit-packed integers and floats. + */ + +/** + * Marks the beginning of a cutscene script. + * * ARGS - * s32 totalEntries (e), s32 endFrame (n) + * s32 totalEntries (e), s32 frameCount (n) * FORMAT * eeeeeeee nnnnnnnn * size = 0x8 */ -#define CS_BEGIN_CUTSCENE(totalEntries, endFrame) { CMD_W(totalEntries) }, { CMD_W(endFrame) } +#define CS_BEGIN_CUTSCENE(totalEntries, frameCount) { CMD_W(totalEntries) }, { CMD_W(frameCount) } /** @@ -21,83 +27,83 @@ * 0000000A eeeeeeee * size = 0x8 */ -#define CS_TEXT_LIST(entries) { CS_CMD_TEXTBOX }, { CMD_W(entries) } +#define CS_TEXT_LIST(entries) { CS_CMD_TEXT }, { CMD_W(entries) } /** * ARGS - * s16 messageId (i), s16 startFrame (s), s16 endFrame (e), s16 type (o), + * s16 textId (i), s16 startFrame (s), s16 endFrame (e), s16 type (o), * s16 topOptionBranch (y), s16 bottomOptionBranch (n) * FORMAT * iiiissss eeeeoooo yyyynnnn * size = 0xC */ -#define CS_TEXT_DISPLAY_TEXTBOX(messageId, startFrame, endFrame, type, topOptionBranch, bottomOptionBranch) \ - { CMD_HH(messageId, startFrame) }, { CMD_HH(endFrame, type) }, { CMD_HH(topOptionBranch, bottomOptionBranch) } +#define CS_TEXT(textId, startFrame, endFrame, type, topOptionBranch, bottomOptionBranch) \ + { CMD_HH(textId, startFrame) }, { CMD_HH(endFrame, type) }, { CMD_HH(topOptionBranch, bottomOptionBranch) } /** * ARGS - * s16 messageId (i), s16 startFrame (s), s16 endFrame (e), + * s16 textId (i), s16 startFrame (s), s16 endFrame (e), * s16 topOptionBranch (y), s16 bottomOptionBranch (n) * FORMAT * iiiissss eeee0000 yyyynnnn * size = 0xC */ -#define CS_TEXT_DEFAULT(messageId, startFrame, endFrame, topOptionBranch, bottomOptionBranch) \ - CS_TEXT_DISPLAY_TEXTBOX(messageId, startFrame, endFrame, CS_TEXTBOX_TYPE_DEFAULT, topOptionBranch, bottomOptionBranch) +#define CS_TEXT_DEFAULT(textId, startFrame, endFrame, topOptionBranch, bottomOptionBranch) \ + CS_TEXT(textId, startFrame, endFrame, CS_TEXT_TYPE_DEFAULT, topOptionBranch, bottomOptionBranch) /** * ARGS - * s16 messageId (i), s16 startFrame (s), s16 endFrame (e), + * s16 textId (i), s16 startFrame (s), s16 endFrame (e), * s16 topOptionBranch (y), s16 bottomOptionBranch (n) * FORMAT * iiiissss eeee0001 yyyynnnn * size = 0xC */ -#define CS_TEXT_TYPE_1(messageId, startFrame, endFrame, topOptionBranch, bottomOptionBranch) \ - CS_TEXT_DISPLAY_TEXTBOX(messageId, startFrame, endFrame, CS_TEXTBOX_TYPE_1, topOptionBranch, bottomOptionBranch) +#define CS_TEXT_TYPE_1(textId, startFrame, endFrame, topOptionBranch, bottomOptionBranch) \ + CS_TEXT(textId, startFrame, endFrame, CS_TEXT_TYPE_1, topOptionBranch, bottomOptionBranch) /** * ARGS - * s16 ocarinaSongAction (o), s16 startFrame (s), s16 endFrame (e), s16 messageId (i) + * s16 ocarinaSongAction (o), s16 startFrame (s), s16 endFrame (e), s16 textId (i) * FORMAT * oooossss eeee0002 iiiiFFFF * size = 0xC */ -#define CS_TEXT_LEARN_SONG(ocarinaSongAction, startFrame, endFrame, messageId) \ - CS_TEXT_DISPLAY_TEXTBOX(ocarinaSongAction, startFrame, endFrame, CS_TEXTBOX_TYPE_LEARN_SONG, messageId, 0xFFFF) +#define CS_TEXT_OCARINA_ACTION(ocarinaSongAction, startFrame, endFrame, textId) \ + CS_TEXT(ocarinaSongAction, startFrame, endFrame, CS_TEXT_OCARINA_ACTION, textId, 0xFFFF) /** * ARGS - * s16 messageId (i), s16 startFrame (s), s16 endFrame (e), + * s16 textId (i), s16 startFrame (s), s16 endFrame (e), * s16 topOptionBranch (y), s16 bottomOptionBranch (n) * FORMAT * iiiissss eeee0003 yyyynnnn * size = 0xC */ -#define CS_TEXT_TYPE_3(messageId, startFrame, endFrame, topOptionBranch, bottomOptionBranch) \ - CS_TEXT_DISPLAY_TEXTBOX(messageId, startFrame, endFrame, CS_TEXTBOX_TYPE_3, topOptionBranch, bottomOptionBranch) +#define CS_TEXT_TYPE_3(textId, startFrame, endFrame, topOptionBranch, bottomOptionBranch) \ + CS_TEXT(textId, startFrame, endFrame, CS_TEXT_TYPE_3, topOptionBranch, bottomOptionBranch) /** - * If Player has all 4 bosses' remains then alternativeMessageId is used, otherwise defaultMessageId is used + * If Player has all 4 bosses' remains then alternativeTextId is used, otherwise defaultTextId is used * ARGS - * s16 defaultMessageId (d), s16 startFrame (s), s16 endFrame (e), s16 alternativeMessageId (a) + * s16 defaultTextId (d), s16 startFrame (s), s16 endFrame (e), s16 alternativeTextId (a) * FORMAT * ddddssss eeee0004 aaaaFFFF * size = 0xC */ -#define CS_TEXT_BOSSES_REMAINS(defaultMessageId, startFrame, endFrame, alternativeMessageId) \ - CS_TEXT_DISPLAY_TEXTBOX(defaultMessageId, startFrame, endFrame, CS_TEXTBOX_TYPE_BOSSES_REMAINS, alternativeMessageId, 0xFFFF) +#define CS_TEXT_BOSSES_REMAINS(defaultTextId, startFrame, endFrame, alternativeTextId) \ + CS_TEXT(defaultTextId, startFrame, endFrame, CS_TEXT_TYPE_BOSSES_REMAINS, alternativeTextId, 0xFFFF) /** - * If Player has every non-transformation mask then alternativeMessageId is used, otherwise defaultMessageId is used + * If Player has every non-transformation mask then alternativeTextId is used, otherwise defaultTextId is used * ARGS - * s16 defaultMessageId (d), s16 startFrame (s), s16 endFrame (e), s16 alternativeMessageId (a) + * s16 defaultTextId (d), s16 startFrame (s), s16 endFrame (e), s16 alternativeTextId (a) * FORMAT * ddddssss eeee0005 aaaaFFFF * size = 0xC */ -#define CS_TEXT_ALL_NORMAL_MASKS(defaultMessageId, startFrame, endFrame, alternativeMessageId) \ - CS_TEXT_DISPLAY_TEXTBOX(defaultMessageId, startFrame, endFrame, CS_TEXTBOX_TYPE_ALL_NORMAL_MASKS, alternativeMessageId, 0xFFFF) +#define CS_TEXT_ALL_NORMAL_MASKS(defaultTextId, startFrame, endFrame, alternativeTextId) \ + CS_TEXT(defaultTextId, startFrame, endFrame, CS_TEXT_TYPE_ALL_NORMAL_MASKS, alternativeTextId, 0xFFFF) /** * ARGS @@ -107,22 +113,57 @@ * size = 0xC */ #define CS_TEXT_NONE(startFrame, endFrame) \ - CS_TEXT_DISPLAY_TEXTBOX(0xFFFF, startFrame, endFrame, CS_TEXTBOX_TYPE_NONE, 0xFFFF, 0xFFFF) + CS_TEXT(0xFFFF, startFrame, endFrame, CS_TEXT_TYPE_NONE, 0xFFFF, 0xFFFF) /** * ARGS - * s32 entries (e) + * s32 numBytes (b) * FORMAT - * 0000005A eeeeeeee + * 0000005A bbbbbbbb * size = 0x8 */ -#define CS_CAMERA_LIST(entries) { CS_CMD_CAMERA }, { CMD_W(entries) } +#define CS_CAM_SPLINE_LIST(numBytes) { CS_CMD_CAMERA_SPLINE }, { CMD_W(numBytes) } -// TODO: Camera command macros. Requieres func_80161998 being decomped +/** + * ARGS + * s16 numEntries (e), s16 duration (d) + * FORMAT + * Capital U is Unused + * eeeeUUUU UUUUdddd + * size = 0x8 + */ +#define CS_CAM_SPLINE(numEntries, unused0, unused1, duration) \ + { CMD_HH(numEntries, unused0) }, { CMD_HH(unused1, duration) } + +/** + * ARGS + * u8 interpType (i), u8 weight (2), s16 duration (d), Vec3s pos (x/y/z), s16 relativeTo (r) + * FORMAT + * ii22dddd xxxxyyyy zzzzrrrr + * size = 0xC + */ +#define CS_CAM_POINT(interpType, weight, duration, posX, posY, posZ, relativeTo) \ + { CMD_BBH(interpType, weight, duration) }, { CMD_HH(posX, posY) }, { CMD_HH(posZ, relativeTo) } + +/** + * ARGS + * s16 roll (r), s16 fov (f) + * FORMAT + * Capital U is Unused + * UUUUrrrr ffffUUUU + * size = 0x8 + */ +#define CS_CAM_MISC(unused0, roll, fov, unused1) \ + { CMD_HH(unused0, roll) }, { CMD_HH(fov, unused1) } + +// First half-word is read from as `numEntries` in `CS_CAM_SPLINE()` +#define CS_CAM_END() { CMD_HH(0xFFFF, 4) } /** + * Declares a list of `CS_MISC` entries. + * * ARGS * s32 entries (e) * FORMAT @@ -132,36 +173,46 @@ #define CS_MISC_LIST(entries) { CS_CMD_MISC }, { CMD_W(entries) } /** + * Various miscellaneous commands. + * @see `CutsceneMiscType` enum for the different types of commands. + * @note setting `endFrame` to same value as `startFrame` will not behave as expected. + * For commands that only need to last one frame, set `endFrame` to `startFrame + 1`. + * * ARGS - * s16 unk (u), s16 startFrame (s), s16 endFrame (e) + * s16 type (t), s16 startFrame (s), s16 endFrame (e) * FORMAT * Capital U is Unused - * uuuussss eeeeUUUU - * size = 0x08 + * ttttssss eeeeUUUU + * size = 0x8 */ -#define CS_MISC(unk, startFrame, endFrame, unk_06) \ - { CMD_HH(unk, startFrame) }, { CMD_HH(endFrame, unk_06) } +#define CS_MISC(type, startFrame, endFrame, unused0) \ + { CMD_HH(type, startFrame) }, { CMD_HH(endFrame, unused0) } /** + * Declares a list of `CS_LIGHT_SETTING` entries. + * * ARGS * s32 entries (e) * FORMAT * 00000097 eeeeeeee * size = 0x8 */ -#define CS_LIGHTING_LIST(entries) { CS_CMD_SET_LIGHTING }, { CMD_W(entries) } +#define CS_LIGHT_SETTING_LIST(entries) { CS_CMD_LIGHT_SETTING }, { CMD_W(entries) } /** + * Changes the environment lights to the specified setting. + * The lighting change will take place immediately with no blending. + * * ARGS - * s16 setting (m), s16 startFrame (s), s16 endFrame (e) + * s16 setting (t), s16 startFrame (s), s16 endFrame (e) * FORMAT * Capital U is Unused - * mmmmssss eeeeUUUU - * size = 0x08 + * ttttssss eeeeUUUU + * size = 0x8 */ -#define CS_LIGHTING(setting, startFrame, endFrame) \ - { CMD_HH(setting, startFrame) }, { CMD_HH(endFrame, endFrame) } +#define CS_LIGHT_SETTING(lightSetting, startFrame, endFrame) \ + { CMD_BBH(0, (lightSetting + 1), startFrame) }, { CMD_HH(endFrame, endFrame) } /** @@ -171,18 +222,18 @@ * 00000098 eeeeeeee * size = 0x8 */ -#define CS_SCENE_TRANS_FX_LIST(entries) { CS_CMD_SCENE_TRANS_FX }, { CMD_W(entries) } +#define CS_TRANSITION_LIST(entries) { CS_CMD_TRANSITION }, { CMD_W(entries) } /** * ARGS - * s16 transitionType (m), s16 startFrame (s), s16 endFrame (e) + * s16 type (t), s16 startFrame (s), s16 endFrame (e) * FORMAT * Capital U is Unused - * mmmmssss eeeeUUUU - * size = 0x08 + * ttttssss eeeeUUUU + * size = 0x8 */ -#define CS_SCENE_TRANS_FX(transitionType, startFrame, endFrame) \ - { CMD_HH(transitionType, startFrame) }, { CMD_HH(endFrame, endFrame) } +#define CS_TRANSITION(type, startFrame, endFrame) \ + { CMD_HH(type, startFrame) }, { CMD_HH(endFrame, endFrame) } /** @@ -190,20 +241,20 @@ * s32 entries (e) * FORMAT * 00000099 eeeeeeee - * size = 0x08 + * size = 0x8 */ -#define CS_MOTIONBLUR_LIST(entries) { CS_CMD_MOTIONBLUR }, { CMD_W(entries) } +#define CS_MOTION_BLUR_LIST(entries) { CS_CMD_MOTION_BLUR }, { CMD_W(entries) } /** * ARGS - * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * s16 type (t), s16 startFrame (s), s16 endFrame (e) * FORMAT * Capital U is Unused - * mmmmssss eeeeUUUU - * size = 0x08 + * ttttssss eeeeUUUU + * size = 0x8 */ -#define CS_MOTIONBLUR(base, startFrame, endFrame) \ - { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } +#define CS_MOTION_BLUR(type, startFrame, endFrame) \ + { CMD_HH(type, startFrame) }, { CMD_HH(endFrame, endFrame) } /** @@ -213,18 +264,18 @@ * 0000009A eeeeeeee * size = 0x8 */ -#define CS_GIVETATL_LIST(entries) { CS_CMD_GIVETATL }, { CMD_W(entries) } +#define CS_GIVE_TATL_LIST(entries) { CS_CMD_GIVE_TATL }, { CMD_W(entries) } /** * ARGS - * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * s16 giveTatl (t), s16 startFrame (s), s16 endFrame (e) * FORMAT * Capital U is Unused - * mmmmssss eeeeUUUU - * size = 0x08 + * ttttssss eeeeUUUU + * size = 0x8 */ -#define CS_GIVETATL(base, startFrame, endFrame) \ - { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } +#define CS_GIVE_TATL(giveTatl, startFrame, endFrame) \ + { CMD_HH(giveTatl, startFrame) }, { CMD_HH(endFrame, endFrame) } /** @@ -234,75 +285,66 @@ * 0000009B eeeeeeee * size = 0x8 */ -#define CS_FADESCREEN_LIST(entries) { CS_CMD_FADESCREEN }, { CMD_W(entries) } +#define CS_TRANSITION_GENERAL_LIST(entries) { CS_CMD_TRANSITION_GENERAL }, { CMD_W(entries) } /** * ARGS - * s16 base (m), s16 startFrame (s), s16 endFrame (e), + * s16 type (t), s16 startFrame (s), s16 endFrame (e), * u8 red (r), u8 green (g), blue (b) * FORMAT * Capital U is Unused - * mmmmssss eeeerrgg bbUUUUUU + * ttttssss eeeerrgg bbUUUUUU * size = 0x0C */ -#define CS_FADESCREEN(base, startFrame, endFrame, red, green, blue) \ - { CMD_HH(base, startFrame) }, { CMD_HBB(endFrame, red, green) }, { CMD_BBBB(blue, 0, 0, 0) } - - -/** - * ARGS - * s32 entries (e) - * FORMAT - * 0000009C eeeeeeee - * size = 0x8 - */ -#define CS_FADESEQ_LIST(entries) { CS_CMD_FADESEQ }, { CMD_W(entries) } - -/** - * ARGS - * s16 base (m), s16 startFrame (s), s16 endFrame (e) - * FORMAT - * Capital U is Unused - * mmmmssss eeeeUUUU UUUUUUUU - * size = 0x0C - */ -#define CS_FADESEQ(base, startFrame, endFrame) \ - { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, 0) }, { CMD_W(0) } +#define CS_TRANSITION_GENERAL(type, startFrame, endFrame, red, green, blue) \ + { CMD_HH(type, startFrame) }, { CMD_HBB(endFrame, red, green) }, { CMD_BBBB(blue, 0, 0, 0) } /** + * Declares a list of `CS_TIME` entries. + * * ARGS * s32 entries (e) * FORMAT * 0000009D eeeeeeee * size = 0x8 */ -#define CS_TIME_LIST(entries) { CS_CMD_SETTIME }, { CMD_W(entries) } +#define CS_TIME_LIST(entries) { CS_CMD_TIME }, { CMD_W(entries) } /** + * Sets the time of day. + * Both the day time and skybox time are set by this command. + * @note `endFrame` is not used in the implementation of the command, so its value does not matter + * * ARGS - * s16 unk (u), s16 startFrame (s), s16 endFrame (e), s8 hour (h), s8 min (m) + * s16 startFrame (s), s16 endFrame (e), s8 hour (h), s8 min (m) * FORMAT * Capital U is Unused - * uuuussss eeeehhmm UUUUUUUU + * UUUUssss eeeehhmm UUUUUUUU * size = 0xC */ -#define CS_TIME(unk, startFrame, endFrame, hour, min, unused) \ - { CMD_HH(unk, startFrame) }, { CMD_HBB(endFrame, hour, min) }, { CMD_W(unused) } +#define CS_TIME(unused0, startFrame, endFrame, hour, min) \ + { CMD_HH(unused0, startFrame) }, { CMD_HBB(endFrame, hour, min) }, { CMD_W(0) } /** + * Declares a list of `CS_ACTOR_CUE` entries. + * * ARGS * s32 cmdType (c), s32 entries (e) * FORMAT * cccccccc eeeeeeee * size = 0x8 */ -#define CS_ACTOR_ACTION_LIST(cmdType, entries) { CMD_W(cmdType) }, { CMD_W(entries) } +#define CS_ACTOR_CUE_LIST(cmdType, entries) { CMD_W(cmdType) }, { CMD_W(entries) } /** + * Defines a cue that an actor can listen for. + * The actor can choose whether or not to use the position and rotation data supplied to it. + * The cue `id` is a number that has an actor-specific meaning. + * * ARGS - * s16 npcAction (a), s16 startFrame (s), s16 endFrame (e), + * s16 id (a), s16 startFrame (s), s16 endFrame (e), * s16 rotX (u), s16 rotY (v), s16 rotZ (w), * s32 startX (i), s32 startY (j), s32 startZ (k), * s32 endX (l), s32 endY (m), s32 endZ (n), @@ -311,25 +353,29 @@ * aaaassss eeeeuuuu vvvvwwww iiiiiiii jjjjjjjj kkkkkkkk llllllll mmmmmmmm nnnnnnnn xxxxxxxx yyyyyyyy zzzzzzzz * size = 0x30 */ -#define CS_ACTOR_ACTION(npcAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) \ - { CMD_HH(npcAction, startFrame) }, { CMD_HH(endFrame, rotX) }, { CMD_HH(rotY, rotZ) }, \ +#define CS_ACTOR_CUE(id, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) \ + { CMD_HH(id, startFrame) }, { CMD_HH(endFrame, rotX) }, { CMD_HH(rotY, rotZ) }, \ { CMD_W(startX) }, { CMD_W(startY) }, { CMD_W(startZ) }, \ { CMD_W(endX) }, { CMD_W(endY) }, { CMD_W(endZ) }, \ { CMD_F(normX) }, { CMD_F(normY) }, { CMD_F(normZ) } /** + * Declares a list of `CS_PLAYER_CUE` entries. + * * ARGS * s32 cmdType (c), s32 entries (e) * FORMAT * 000000C8 eeeeeeee * size = 0x8 */ -#define CS_PLAYER_ACTION_LIST(entries) { CS_CMD_SET_PLAYER_ACTION }, { CMD_W(entries) } +#define CS_PLAYER_CUE_LIST(entries) { CS_CMD_PLAYER_CUE }, { CMD_W(entries) } /** + * A player cue is the same as `CS_ACTOR_CUE` but is specifically for player. + * * ARGS - * s16 playerAction (a), s16 startFrame (s), s16 endFrame (e), + * s16 id (a), s16 startFrame (s), s16 endFrame (e), * s16 rotX (u), s16 rotY (v), s16 rotZ (w), * s32 startX (i), s32 startY (j), s32 startZ (k), * s32 endX (l), s32 endY (m), s32 endZ (n), @@ -338,113 +384,87 @@ * aaaassss eeeeuuuu vvvvwwww iiiiiiii jjjjjjjj kkkkkkkk llllllll mmmmmmmm nnnnnnnn xxxxxxxx yyyyyyyy zzzzzzzz * size = 0x30 */ -#define CS_PLAYER_ACTION(playerAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) \ - CS_ACTOR_ACTION(playerAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) +#define CS_PLAYER_CUE(id, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) \ + CS_ACTOR_CUE(id, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) /** + * Declares a list of `CS_START_SEQ` entries. + * * ARGS * s32 entries (e) * FORMAT * 0000012C eeeeeeee * size = 0x8 */ -#define CS_PLAYSEQ_LIST(entries) { CS_CMD_PLAYSEQ }, { CMD_W(entries) } +#define CS_START_SEQ_LIST(entries) \ + { CS_CMD_START_SEQ }, { CMD_W(entries) } /** + * Starts a sequence at the specified time. + * @note `endFrame` is not used in the implementation of the command, so its value does not matter + * * ARGS - * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * s16 seqId (i), s16 startFrame (s), s16 endFrame (e) * FORMAT * Capital U is Unused - * mmmmssss eeeeUUUU - * size = 0x08 - */ -#define CS_PLAYSEQ(sequence, startFrame, endFrame) \ - { CMD_HH(sequence, startFrame) }, { CMD_HH(endFrame, endFrame) } - - -/** - * ARGS - * s32 entries (e) - * FORMAT - * 00000130 eeeeeeee + * iiiissss eeeeUUUU * size = 0x8 */ -#define CS_SCENE_UNK_130_LIST(entries) { CS_CMD_130 }, { CMD_W(entries) } - -/** - * ARGS - * s16 base (m), s16 startFrame (s), s16 endFrame (e) - * FORMAT - * Capital U is Unused - * mmmmssss eeeeUUUU - * size = 0x30 - */ -#define CS_SCENE_UNK_130(base, startFrame, endFrame, unk_06) \ - { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } - - -/** - * ARGS - * s32 entries (e) - * FORMAT - * 00000131 eeeeeeee - * size = 0x8 - */ -#define CS_SCENE_UNK_131_LIST(entries) { CS_CMD_131 }, { CMD_W(entries) } - -/** - * ARGS - * s16 base (m), s16 startFrame (s), s16 endFrame (e) - * FORMAT - * Capital U is Unused - * mmmmssss eeeeUUUU - * size = 0x08 - */ -#define CS_SCENE_UNK_131(base, startFrame, endFrame, unk_06) \ - { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } - - -/** - * ARGS - * s32 entries (e) - * FORMAT - * 00000132 eeeeeeee - * size = 0x8 - */ -#define CS_SCENE_UNK_132_LIST(entries) { CS_CMD_132 }, { CMD_W(entries) } - -/** - * ARGS - * s16 base (m), s16 startFrame (s), s16 endFrame (e) - * FORMAT - * Capital U is Unused - * mmmmssss eeeeUUUU - * size = 0x08 - */ -#define CS_SCENE_UNK_132(base, startFrame, endFrame) \ - { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } +#define CS_START_SEQ(seqId, startFrame, endFrame) \ + { CMD_HH((seqId + 1), startFrame) }, { CMD_HH(endFrame, endFrame) } /** + * Declares a list of `CS_STOP_SEQ` entries. + * * ARGS * s32 entries (e) * FORMAT * 00000133 eeeeeeee * size = 0x8 */ -#define CS_STOPSEQ_LIST(entries) { CS_CMD_STOPSEQ }, { CMD_W(entries) } +#define CS_STOP_SEQ_LIST(entries) { CS_CMD_STOP_SEQ }, { CMD_W(entries) } /** + * Stops a sequence at the specified time. + * * ARGS - * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * s16 seqId (i), s16 startFrame (s), s16 endFrame (e) * FORMAT * Capital U is Unused - * mmmmssss eeeeUUUU - * size = 0x08 + * iiiissss eeeeUUUU + * size = 0x8 */ -#define CS_STOPSEQ(base, startFrame, endFrame, unk_06) \ - { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } +#define CS_STOP_SEQ(seqId, startFrame, endFrame, unk_06) \ + { CMD_HH((seqId + 1), startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * Stops a sequence at the specified time. + * @note `endFrame` is not used in the implementation of the command, so its value does not matter + * + * ARGS + * s32 entries (e) + * FORMAT + * 0000009C eeeeeeee + * size = 0x8 + */ +#define CS_FADE_OUT_SEQ_LIST(entries) { CS_CMD_FADE_OUT_SEQ }, { CMD_W(entries) } + +/** + * Fade out the sequence that is playing on the specified sequence player, over the specified frame range. + * @see `CutsceneFadeOutSeqPlayer` + * + * ARGS + * s16 seqPlayer (p), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * ppppssss eeeeUUUU UUUUUUUU + * size = 0x0C + */ +#define CS_FADE_OUT_SEQ(seqPlayer, startFrame, endFrame) \ + { CMD_HH(seqPlayer, startFrame) }, { CMD_HH(endFrame, 0) }, { CMD_W(0) } /** @@ -454,18 +474,18 @@ * 00000134 eeeeeeee * size = 0x8 */ -#define CS_PLAYAMBIENCE_LIST(entries) { CS_CMD_PLAYAMBIENCE }, { CMD_W(entries) } +#define CS_START_AMBIENCE_LIST(entries) { CS_CMD_START_AMBIENCE }, { CMD_W(entries) } /** * ARGS - * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * s16 startFrame (s), s16 endFrame (e) * FORMAT * Capital U is Unused - * mmmmssss eeeeUUUU - * size = 0x08 + * UUUUssss eeeeUUUU + * size = 0x8 */ -#define CS_PLAYAMBIENCE(base, startFrame, endFrame, unk_06) \ - { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } +#define CS_START_AMBIENCE(unused0, startFrame, endFrame) \ + { CMD_HH(unused0, startFrame) }, { CMD_HH(endFrame, 0) } /** @@ -475,39 +495,106 @@ * 00000135 eeeeeeee * size = 0x8 */ -#define CS_FADEAMBIENCE_LIST(entries) { CS_CMD_FADEAMBIENCE }, { CMD_W(entries) } +#define CS_FADE_OUT_AMBIENCE_LIST(entries) { CS_CMD_FADE_OUT_AMBIENCE }, { CMD_W(entries) } /** * ARGS - * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * s16 startFrame (s), s16 endFrame (e) * FORMAT * Capital U is Unused - * mmmmssss eeeeUUUU - * size = 0x08 + * UUUUssss eeeeUUUU + * size = 0x8 */ -#define CS_FADEAMBIENCE(base, startFrame, endFrame, unk_06) \ - { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } +#define CS_FADE_OUT_AMBIENCE(unused0, startFrame, endFrame) \ + { CMD_HH(unused0, startFrame) }, { CMD_HH(endFrame, 0) } /** * ARGS * s32 entries (e) * FORMAT - * 0000015E eeeeeeee + * 00000132 eeeeeeee * size = 0x8 */ -#define CS_TERMINATOR_LIST(entries) { CS_CMD_TERMINATOR }, { CMD_W(entries) } +#define CS_MODIFY_SEQ_LIST(entries) { CS_CMD_MODIFY_SEQ }, { CMD_W(entries) } /** * ARGS - * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * s16 type (t), s16 startFrame (s), s16 endFrame (e) * FORMAT * Capital U is Unused - * mmmmssss eeeeUUUU - * size = 0x08 + * ttttssss eeeeUUUU + * size = 0x8 */ -#define CS_TERMINATOR(base, startFrame, endFrame) \ - { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } +#define CS_MODIFY_SEQ(type, startFrame, endFrame) \ + { CMD_HH(type, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000130 eeeeeeee + * size = 0x8 + */ +#define CS_SFX_REVERB_INDEX_2_LIST(entries) { CS_CMD_SFX_REVERB_INDEX_2 }, { CMD_W(entries) } + +/** + * ARGS + * s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * UUUUssss eeeeUUUU + * size = 0x30 + */ +#define CS_SFX_REVERB_INDEX_2(unused0, startFrame, endFrame) \ + { CMD_HH(unused0, startFrame) }, { CMD_HH(endFrame, 0) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000131 eeeeeeee + * size = 0x8 + */ +#define CS_SFX_REVERB_INDEX_1_LIST(entries) { CS_CMD_SFX_REVERB_INDEX_1 }, { CMD_W(entries) } + +/** + * ARGS + * s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * UUUUssss eeeeUUUU + * size = 0x8 + */ +#define CS_SFX_REVERB_INDEX_1(unused0, startFrame, endFrame) \ + { CMD_HH(unused0, startFrame) }, { CMD_HH(endFrame, 0) } + + +/** + * Declares a list of `CS_DESTINATION` entries. + * + * ARGS + * s32 entries (e) + * FORMAT + * 0000015E eeeeeeee + * size = 0x8 + */ +#define CS_DESTINATION_LIST(entries) { CS_CMD_DESTINATION }, { CMD_W(entries) } + +/** + * Sends the player to a new destination using the entry defined in `CutsceneScriptEntry`. + * + * ARGS + * s16 type (t), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * ttttssss eeeeUUUU + * size = 0x8 + */ +#define CS_DESTINATION(type, startFrame, endFrame) \ + { CMD_HH(type, startFrame) }, { CMD_HH(endFrame, endFrame) } /** @@ -521,14 +608,14 @@ /** * ARGS - * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * s16 type (t), s16 startFrame (s), s16 endFrame (e) * FORMAT * Capital U is Unused - * mmmmssss eeeeUUUU - * size = 0x08 + * ttttssss eeeeUUUU + * size = 0x8 */ -#define CS_CHOOSE_CREDITS_SCENES(base, startFrame, endFrame) \ - { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } +#define CS_CHOOSE_CREDITS_SCENES(type, startFrame, endFrame) \ + { CMD_HH(type, startFrame) }, { CMD_HH(endFrame, endFrame) } /** @@ -542,14 +629,14 @@ /** * ARGS - * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * s16 type (t), s16 startFrame (s), s16 endFrame (e) * FORMAT * Capital U is Unused - * mmmmssss eeeeUUUU - * size = 0x08 + * ttttssss eeeeUUUU + * size = 0x8 */ -#define CS_RUMBLE(base, startFrame, endFrame, intensity, decayTimer, decayStep) \ - { CMD_HH(base, startFrame) }, { CMD_HBB(endFrame, intensity, decayTimer) }, { CMD_BBBB(decayStep, 0, 0, 0) } +#define CS_RUMBLE(type, startFrame, endFrame, intensity, decayTimer, decayStep) \ + { CMD_HH(type, startFrame) }, { CMD_HBB(endFrame, intensity, decayTimer) }, { CMD_BBBB(decayStep, 0, 0, 0) } /** @@ -563,14 +650,14 @@ /** * ARGS - * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * s16 startFrame (s), s16 endFrame (e) * FORMAT * Capital U is Unused - * mmmmssss eeeeUUUU - * size = 0x08 + * UUUUssss eeeeUUUU + * size = 0x8 */ -#define CS_UNK_DATA(base, startFrame, endFrame, unk_06) \ - { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } +#define CS_UNK_DATA(unused0, startFrame, endFrame, unk_06) \ + { CMD_HH(unused0, startFrame) }, { CMD_HH(endFrame, unk_06) } /** @@ -578,4 +665,47 @@ */ #define CS_END() { CMD_W(0xFFFFFFFF) } +// TODO: Fix ZAPD and delete these +#define CS_ACTOR_ACTION_LIST CS_ACTOR_CUE_LIST +#define CS_ACTOR_ACTION CS_ACTOR_CUE +#define CS_PLAYER_ACTION_LIST CS_PLAYER_CUE_LIST +#define CS_PLAYER_ACTION CS_PLAYER_CUE +#define CS_LIGHTING_LIST CS_LIGHT_SETTING_LIST +#define CS_CAMERA_LIST CS_CAM_SPLINE_LIST +#define CS_TEXT_DISPLAY_TEXTBOX CS_TEXT +#define CS_TEXT_LEARN_SONG CS_TEXT_OCARINA_ACTION +#define CS_SCENE_TRANS_FX_LIST CS_TRANSITION_LIST +#define CS_SCENE_TRANS_FX CS_TRANSITION +#define CS_GIVETATL_LIST CS_GIVE_TATL_LIST +#define CS_GIVETATL CS_GIVE_TATL +#define CS_PLAYSEQ_LIST CS_START_SEQ_LIST +#define CS_STOPSEQ_LIST CS_STOP_SEQ_LIST +#define CS_FADESEQ_LIST CS_FADE_OUT_SEQ_LIST +#define CS_FADESEQ CS_FADE_OUT_SEQ +#define CS_PLAYAMBIENCE_LIST CS_START_AMBIENCE_LIST +#define CS_PLAYAMBIENCE CS_START_AMBIENCE +#define CS_FADEAMBIENCE_LIST CS_FADE_OUT_AMBIENCE_LIST +#define CS_FADEAMBIENCE CS_FADE_OUT_AMBIENCE +#define CS_SCENE_UNK_130_LIST CS_SFX_REVERB_INDEX_2_LIST +#define CS_SCENE_UNK_130 CS_SFX_REVERB_INDEX_2 +#define CS_SCENE_UNK_131_LIST CS_SFX_REVERB_INDEX_1_LIST +#define CS_SCENE_UNK_131 CS_SFX_REVERB_INDEX_1 +#define CS_SCENE_UNK_132_LIST CS_MODIFY_SEQ_LIST +#define CS_SCENE_UNK_132 CS_MODIFY_SEQ +#define CS_MOTIONBLUR_LIST CS_MOTION_BLUR_LIST +#define CS_MOTIONBLUR CS_MOTION_BLUR +#define CS_FADESCREEN_LIST CS_TRANSITION_GENERAL_LIST +#define CS_FADESCREEN CS_TRANSITION_GENERAL +#define CS_TERMINATOR_LIST CS_DESTINATION_LIST +#define CS_TERMINATOR CS_DESTINATION + +#define CS_PLAYSEQ(seqId, startFrame, endFrame) \ +CS_START_SEQ((seqId)-1, startFrame, endFrame) + +#define CS_STOPSEQ(seqId, startFrame, endFrame, unk_06) \ +CS_STOP_SEQ((seqId)-1, startFrame, endFrame, unk_06) + +#define CS_LIGHTING(lightSetting, startFrame, endFrame) \ +CS_LIGHT_SETTING((lightSetting)-1, startFrame, endFrame) + #endif diff --git a/include/z64debug_display.h b/include/z64debug_display.h new file mode 100644 index 000000000..885a3839c --- /dev/null +++ b/include/z64debug_display.h @@ -0,0 +1,25 @@ +#ifndef Z64DEBUG_DISPLAY_H +#define Z64DEBUG_DISPLAY_H + +#include "color.h" +#include "ultra64.h" +#include "z64math.h" + +struct GraphicsContext; +struct PlayState; + +typedef struct DebugDispObject { + /* 0x00 */ Vec3f pos; + /* 0x0C */ Vec3s rot; + /* 0x14 */ Vec3f scale; + /* 0x20 */ Color_RGBA8 color; + /* 0x24 */ s16 type; + /* 0x28 */ struct DebugDispObject* next; + /* 0x2C */ s32 pad; // Padding is not in the OoT version +} DebugDispObject; // size = 0x30 + +DebugDispObject* DebugDisplay_Init(void); +void DebugDisplay_DrawObjects(struct PlayState* play); +DebugDispObject* DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, f32 scaleX, f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type, struct GraphicsContext* gfxCtx); + +#endif diff --git a/include/z64debug_text.h b/include/z64debug_text.h new file mode 100644 index 000000000..65595f99e --- /dev/null +++ b/include/z64debug_text.h @@ -0,0 +1,36 @@ +#ifndef Z64DEBUG_TEXT_H +#define Z64DEBUG_TEXT_H + +#include "ultra64.h" + +struct GraphicsContext; + +typedef enum { + /* 0 */ DEBUG_TEXT_BLACK, + /* 1 */ DEBUG_TEXT_BLUE, + /* 2 */ DEBUG_TEXT_RED, + /* 3 */ DEBUG_TEXT_PURPLE, + /* 4 */ DEBUG_TEXT_GREEN, + /* 5 */ DEBUG_TEXT_CYAN, + /* 6 */ DEBUG_TEXT_YELLOW, + /* 7 */ DEBUG_TEXT_WHITE +} DebugTextColor; + +typedef enum { + /* 0 */ DEBUG_CAM_TEXT_YELLOW, + /* 1 */ DEBUG_CAM_TEXT_PEACH, + /* 2 */ DEBUG_CAM_TEXT_BROWN, + /* 3 */ DEBUG_CAM_TEXT_ORANGE, + /* 4 */ DEBUG_CAM_TEXT_GOLD, + /* 5 */ DEBUG_CAM_TEXT_WHITE, + /* 6 */ DEBUG_CAM_TEXT_BLUE, + /* 7 */ DEBUG_CAM_TEXT_GREEN +} DebugCamTextColor; + +void Debug_ClearTextDrawFlags(void); +void Debug_ScreenText(s32 index, s32 colorIndex, const char* text); +void DebugCamera_ScreenText(u8 x, u8 y, u8 colorIndex, const char* text); +void Debug_DrawText(struct GraphicsContext* gfxCtx); + + +#endif diff --git a/include/z64dma.h b/include/z64dma.h index 92c0227f3..964be9c59 100644 --- a/include/z64dma.h +++ b/include/z64dma.h @@ -1,5 +1,5 @@ -#ifndef _Z64_DMA_H_ -#define _Z64_DMA_H_ +#ifndef Z64DMA_H +#define Z64DMA_H #include "ultra64.h" diff --git a/include/z64eff_footmark.h b/include/z64eff_footmark.h new file mode 100644 index 000000000..6d5fe3026 --- /dev/null +++ b/include/z64eff_footmark.h @@ -0,0 +1,33 @@ +#ifndef Z64EFF_FOOTMARK_H +#define Z64EFF_FOOTMARK_H + +#include "ultra64.h" +#include "z64math.h" + +struct PlayState; +struct Actor; + +typedef struct EffFootmark { + /* 0x00 */ MtxF mf; + /* 0x40 */ struct Actor* actor; + /* 0x44 */ Vec3f pos; + /* 0x50 */ u8 flags; // bit 0 - footmark fades out + /* 0x51 */ u8 id; + /* 0x52 */ u8 red; + /* 0x53 */ u8 blue; + /* 0x54 */ u8 green; + /* 0x56 */ u16 alpha; + /* 0x58 */ u16 alphaChange; + /* 0x5A */ u16 size; + /* 0x5C */ u16 fadeOutDelay; + /* 0x5E */ u16 age; +} EffFootmark; // size = 0x60 + +#define FOOTMARK_FLAG_1 (1 << 0) + +void EffFootmark_Init(struct PlayState* play); +void EffFootmark_Add(struct PlayState* play, MtxF* mf, struct Actor* actor, u8 id, Vec3f* pos, u16 size, u8 red, u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeOutDelay); +void EffFootmark_Update(struct PlayState* play); +void EffFootmark_Draw(struct PlayState* play); + +#endif diff --git a/include/z64effect.h b/include/z64effect.h index 727bf04d2..d6ab8b3b5 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -1,7 +1,8 @@ -#ifndef _Z64EFFECT_H_ -#define _Z64EFFECT_H_ +#ifndef Z64EFFECT_H +#define Z64EFFECT_H #include "PR/ultratypes.h" +#include "libc/stdint.h" #include "color.h" #include "z64light.h" #include "z64math.h" @@ -9,6 +10,8 @@ struct GraphicsContext; struct PlayState; +struct Actor; +struct CollisionPoly; #define SPARK_COUNT 3 #define BLURE_COUNT 25 @@ -181,7 +184,7 @@ typedef struct { /* 0x08 */ Vec3s p2; /* 0x0E */ s16 life; /* 0x10 */ UNK_TYPE1 pad10[0x4]; - /* 0x14 */ CollisionPoly* colPoly; + /* 0x14 */ struct CollisionPoly* colPoly; } EffectTireMarkElement; // size = 0x18 typedef struct { @@ -265,7 +268,7 @@ typedef struct EffectSs { /* 0x28 */ EffectSsDrawFunc draw; /* 0x2C */ Vec3f vec; /* 0x38 */ void* gfx; - /* 0x3C */ Actor* actor; + /* 0x3C */ struct Actor* actor; /* 0x40 */ s16 regs[13]; // These are particle-specific /* 0x5A */ u16 flags; // bit 0: set if this entry is not considered free on a priority tie bit 1: ? bit 2: ? /* 0x5C */ s16 life; // -1 means this entry is free @@ -279,47 +282,15 @@ typedef struct { /* 0x8 */ s32 size; } EffectSsInfo; // size = 0xC -typedef enum { - /* 0x00 */ EFFECT_SS_DUST, - /* 0x01 */ EFFECT_SS_KIRAKIRA, - /* 0x02 */ EFFECT_SS_UNSET_02, // Deleted - /* 0x03 */ EFFECT_SS_BOMB2, - /* 0x04 */ EFFECT_SS_BLAST, - /* 0x05 */ EFFECT_SS_G_SPK, - /* 0x06 */ EFFECT_SS_D_FIRE, - /* 0x07 */ EFFECT_SS_BUBBLE, - /* 0x08 */ EFFECT_SS_UNSET_08, // Deleted - /* 0x09 */ EFFECT_SS_G_RIPPLE, - /* 0x0A */ EFFECT_SS_G_SPLASH, - /* 0x0B */ EFFECT_SS_UNSET_0B, - /* 0x0C */ EFFECT_SS_G_FIRE, - /* 0x0D */ EFFECT_SS_LIGHTNING, - /* 0x0E */ EFFECT_SS_DT_BUBBLE, - /* 0x0F */ EFFECT_SS_HAHEN, - /* 0x10 */ EFFECT_SS_STICK, - /* 0x11 */ EFFECT_SS_SIBUKI, - /* 0x12 */ EFFECT_SS_UNSET_12, // Deleted - /* 0x13 */ EFFECT_SS_UNSET_13, // Deleted - /* 0x14 */ EFFECT_SS_STONE1, - /* 0x15 */ EFFECT_SS_HITMARK, - /* 0x16 */ EFFECT_SS_FHG_FLASH, - /* 0x17 */ EFFECT_SS_K_FIRE, - /* 0x18 */ EFFECT_SS_SOLDER_SRCH_BALL, - /* 0x19 */ EFFECT_SS_KAKERA, - /* 0x1A */ EFFECT_SS_ICE_PIECE, - /* 0x1B */ EFFECT_SS_EN_ICE, - /* 0x1C */ EFFECT_SS_FIRE_TAIL, - /* 0x1D */ EFFECT_SS_EN_FIRE, - /* 0x1E */ EFFECT_SS_EXTRA, - /* 0x1F */ EFFECT_SS_UNSET_1F, // Deleted - /* 0x20 */ EFFECT_SS_DEAD_DB, - /* 0x21 */ EFFECT_SS_DEAD_DD, - /* 0x22 */ EFFECT_SS_DEAD_DS, - /* 0x23 */ EFFECT_SS_UNSET_23, // Deleted - /* 0x24 */ EFFECT_SS_ICE_SMOKE, - /* 0x25 */ EFFECT_EN_ICE_BLOCK, - /* 0x26 */ EFFECT_SS_SBN, +#define DEFINE_EFFECT_SS(_name, enumValue) enumValue, +#define DEFINE_EFFECT_SS_UNSET(enumValue) enumValue, + +typedef enum EffectSsType { + #include "tables/effect_ss_table.h" /* 0x27 */ EFFECT_SS_MAX } EffectSsType; +#undef DEFINE_EFFECT_SS +#undef DEFINE_EFFECT_SS_UNSET + #endif diff --git a/include/z64frameadvance.h b/include/z64frameadvance.h new file mode 100644 index 000000000..179a1adba --- /dev/null +++ b/include/z64frameadvance.h @@ -0,0 +1,15 @@ +#ifndef Z64FRAMEADVANCE_H +#define Z64FRAMEADVANCE_H + +#include "padmgr.h" + +typedef struct FrameAdvanceContext { + /* 0x0 */ s32 enabled; + /* 0x4 */ s32 timer; +} FrameAdvanceContext; // size = 0x8 + + +void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx); +s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input); + +#endif diff --git a/include/z64game_over.h b/include/z64game_over.h new file mode 100644 index 000000000..240efdf41 --- /dev/null +++ b/include/z64game_over.h @@ -0,0 +1,30 @@ +#ifndef Z64GAME_OVER_H +#define Z64GAME_OVER_H + +#include "ultra64.h" + +struct PlayState; + + +typedef enum GameOverState { + /* 0 */ GAMEOVER_INACTIVE, + /* 1 */ GAMEOVER_DEATH_START, + /* 2 */ GAMEOVER_DEATH_WAIT_GROUND, // wait for player to fall and hit the ground + /* 3 */ GAMEOVER_DEATH_FADE_OUT, // wait before fading out + /* 20 */ GAMEOVER_REVIVE_START = 20, + /* 21 */ GAMEOVER_REVIVE_RUMBLE, + /* 22 */ GAMEOVER_REVIVE_WAIT_GROUND, // wait for player to fall and hit the ground + /* 23 */ GAMEOVER_REVIVE_WAIT_FAIRY, // wait for the fairy to rise all the way up out of player's body + /* 24 */ GAMEOVER_REVIVE_FADE_OUT // fade out the game over lights as player is revived and gets back up +} GameOverState; + +typedef struct GameOverContext { + /* 0x0 */ u16 state; +} GameOverContext; // size = 0x2 + + +void GameOver_Init(struct PlayState* play); +void GameOver_FadeLights(struct PlayState* play); +void GameOver_Update(struct PlayState* play); + +#endif diff --git a/include/z64interface.h b/include/z64interface.h index 385f80835..e01baa425 100644 --- a/include/z64interface.h +++ b/include/z64interface.h @@ -134,7 +134,7 @@ typedef struct { /* 0x218 */ f32 aButtonRoll; /* 0x21C */ s16 unk_21C; /* 0x21E */ s16 bButtonDoAction; - /* 0x220 */ s16 unk_220; + /* 0x220 */ s16 tatlCalling; /* 0x222 */ s16 unk_222; /* 0x224 */ s16 unk_224; /* 0x226 */ s16 lifeColorChange; diff --git a/include/z64jpeg.h b/include/z64jpeg.h index 38183bfa9..60797af98 100644 --- a/include/z64jpeg.h +++ b/include/z64jpeg.h @@ -1,5 +1,5 @@ -#ifndef Z64_JPEG_H -#define Z64_JPEG_H +#ifndef Z64JPEG_H +#define Z64JPEG_H #include "PR/ultratypes.h" #include "ultra64/message.h" diff --git a/include/z64light.h b/include/z64light.h index d9404ab4c..706df2f4d 100644 --- a/include/z64light.h +++ b/include/z64light.h @@ -4,6 +4,10 @@ #include "ultra64.h" #include "PR/gbi.h" #include "color.h" +#include "z64math.h" + +struct PlayState; + typedef struct { /* 0x00 */ u8 ambientColor[3]; @@ -13,7 +17,7 @@ typedef struct { /* 0x0C */ u8 diffuseColor[3]; /* 0x0F */ u8 fogColor[3]; /* 0x12 */ s16 fogNear; - /* 0x14 */ s16 fogFar; + /* 0x14 */ s16 zFar; } LightSettings; // size = 0x16 typedef struct { @@ -22,7 +26,7 @@ typedef struct { /* 0x0C */ s16 diffuseColor2[3]; /* 0x12 */ s16 fogColor[3]; /* 0x18 */ s16 fogNear; - /* 0x1A */ s16 fogFar; + /* 0x1A */ s16 zFar; } EnvLightSettings; // size = 0x1C typedef struct { @@ -74,11 +78,9 @@ typedef struct LightsBuffer { typedef struct LightContext { /* 0x0 */ LightNode* listHead; /* 0x4 */ Color_RGB8 ambient; - /* 0x7 */ u8 unk7; - /* 0x8 */ u8 unk8; - /* 0x9 */ u8 unk9; - /* 0xA */ s16 unkA; - /* 0xC */ s16 unkC; + /* 0x7 */ Color_RGB8 fogColor; + /* 0xA */ s16 fogNear; // how close until fog starts taking effect. range 0 - 996 + /* 0xC */ s16 zFar; // draw distance. range 0 - 12800 } LightContext; // size = 0x10 typedef enum LightType { diff --git a/include/z64math.h b/include/z64math.h index 323042b15..8df81454a 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -87,12 +87,32 @@ typedef struct { /* 0x0C */ Vec3f b; } LineSegment; // size = 0x18 -// Defines a point in the spherical coordinate system typedef struct { - /* 0x0 */ f32 r; // radius - /* 0x4 */ s16 pitch; // polar (zenith) angle - /* 0x6 */ s16 yaw; // azimuthal angle -} VecSph; // size = 0x8 + /* 0x0 */ f32 r; // radius + /* 0x4 */ s16 pitch; // depends on coordinate system. See below. + /* 0x6 */ s16 yaw; // azimuthal angle +} VecSphGeo; // size = 0x8 + +// Defines a point in the spherical coordinate system. +// Pitch is 0 along the positive y-axis (up) +typedef VecSphGeo VecSph; + +// Defines a point in the geographic coordinate system. +// Pitch is 0 along the xz-plane (horizon) +typedef VecSphGeo VecGeo; + +// To be used with OLib_Vec3fAdd() +typedef enum { + /* 0 */ OLIB_ADD_COPY, // Copy `b` to dest + /* 1 */ OLIB_ADD_OFFSET, // Add `a` and `b` to dest, and also add the yaw of `a` to the dest + /* 2 */ OLIB_ADD, // Add `a` and `b` to dest +} OlibVec3fAdd; + +typedef enum { + /* 0 */ OLIB_DIFF_COPY, // Copy `b` to dest + /* 1 */ OLIB_DIFF_OFFSET, // Sub `a` and `b` to dest, and also subs the yaw of `a` to the dest + /* 2 */ OLIB_DIFF, // Sub `a` and `b` to dest +} OlibVec3fDiff; #define LERPIMP(v0, v1, t) ((v0) + (((v1) - (v0)) * (t))) #define F32_LERP(v0, v1, t) ((1.0f - (t)) * (f32)(v0) + (t) * (f32)(v1)) @@ -104,20 +124,38 @@ typedef struct { #define LERPWEIGHT(val, prev, next) (((val) - (prev)) / ((next) - (prev))) #define F32_LERPWEIGHT(val, prev, next) (((f32)(val) - (f32)(prev)) / ((f32)(next) - (f32)(prev))) -#define VEC3F_LERPIMPDST(dst, v0, v1, t){ \ - (dst)->x = (v0)->x + (((v1)->x - (v0)->x) * t); \ - (dst)->y = (v0)->y + (((v1)->y - (v0)->y) * t); \ - (dst)->z = (v0)->z + (((v1)->z - (v0)->z) * t); \ -} +#define VEC3F_LERPIMPDST(dst, v0, v1, t) \ + { \ + (dst)->x = (v0)->x + (((v1)->x - (v0)->x) * t); \ + (dst)->y = (v0)->y + (((v1)->y - (v0)->y) * t); \ + (dst)->z = (v0)->z + (((v1)->z - (v0)->z) * t); \ + } \ + (void)0 #define IS_ZERO(f) (fabsf(f) < 0.008f) +// Casting a float to an integer, when the float value is larger than what the integer type can hold, +// leads to undefined behavior. For example (f32)0x8000 doesn't fit in a s16, so it cannot be cast to s16. +// This isn't an issue with IDO, but is one with for example GCC. +// A partial workaround is to cast to s32 then s16, hoping all binang values used will fit a s32. +#define TRUNCF_BINANG(f) (s16)(s32)(f) + // Angle conversion macros -#define DEG_TO_BINANG(degrees) (s16)((degrees) * (0x8000 / 180.0f)) -#define RADF_TO_BINANG(radf) (s16)((radf) * (0x8000 / M_PI)) -#define RADF_TO_DEGF(radf) ((radf) * (180.0f / M_PI)) -#define DEGF_TO_RADF(degf) ((degf) * (M_PI / 180.0f)) -#define BINANG_TO_RAD(binang) (((f32)binang / 0x8000) * M_PI) +#define DEG_TO_RAD(degrees) ((degrees) * (M_PI / 180.0f)) +#define DEG_TO_BINANG(degrees) TRUNCF_BINANG((degrees) * (0x8000 / 180.0f)) +#define DEG_TO_BINANG_ALT(degrees) TRUNCF_BINANG(((degrees) / 180.0f) * 0x8000) +#define DEG_TO_BINANG_ALT2(degrees) TRUNCF_BINANG(((degrees) * 0x10000) / 360.0f) +#define DEG_TO_BINANG_ALT3(degrees) ((degrees) * (0x8000 / 180.0f)) + +#define RAD_TO_DEG(radians) ((radians) * (180.0f / M_PI)) +#define RAD_TO_BINANG(radians) TRUNCF_BINANG((radians) * (0x8000 / M_PI)) +#define RAD_TO_BINANG_ALT(radians) TRUNCF_BINANG(((radians) / M_PI) * 0x8000) +#define RAD_TO_BINANG_ALT2(radians) TRUNCF_BINANG(((radians) * 0x8000) / M_PI) + +#define BINANG_TO_DEG(binang) ((f32)(binang) * (180.0f / 0x8000)) +#define BINANG_TO_RAD(binang) ((f32)(binang) * (M_PI / 0x8000)) +#define BINANG_TO_RAD_ALT(binang) (((f32)(binang) / 0x8000) * M_PI) +#define BINANG_TO_RAD_ALT2(binang) (((f32)(binang) * M_PI) / 0x8000) // Angle arithmetic macros #define BINANG_ROT180(angle) ((s16)(angle + 0x8000)) diff --git a/include/z64message.h b/include/z64message.h index 7d4723e7b..2b0387045 100644 --- a/include/z64message.h +++ b/include/z64message.h @@ -34,7 +34,7 @@ typedef enum TextState { #define FONT_CHAR_TEX_WIDTH 16 #define FONT_CHAR_TEX_HEIGHT 16 -//! @TODO: Make this use `sizeof(AnyFontTextureSymbol)` +//! TODO: Make this use `sizeof(AnyFontTextureSymbol)` #define FONT_CHAR_TEX_SIZE ((16 * 16) / 2) // 16x16 I4 texture // TODO: should Font be in its own header or is it fine to have it here? @@ -67,7 +67,7 @@ typedef struct MessageContext { /* 0x00168 */ Font font; /* 0x11EF8 */ UNK_PTR unk11EF8; /* 0x11EFC */ UNK_TYPE1 unk11EFC[0x4]; - /* 0x11F00 */ struct OcarinaStaff* unk11F00; + /* 0x11F00 */ struct OcarinaStaff* ocarinaStaff; /* 0x11F04 */ u16 currentTextId; /* 0x11F06 */ UNK_TYPE1 unk11F06[0x2]; /* 0x11F08 */ u16 unk11F08; diff --git a/include/z64object.h b/include/z64object.h index e800e9138..712826815 100644 --- a/include/z64object.h +++ b/include/z64object.h @@ -8,651 +8,17 @@ #define OBJECT_EXCHANGE_BANK_MAX 35 -typedef enum { - /* 0x000 */ OBJECT_UNSET_0, - /* 0x001 */ GAMEPLAY_KEEP, - /* 0x002 */ GAMEPLAY_FIELD_KEEP, - /* 0x003 */ GAMEPLAY_DANGEON_KEEP, - /* 0x004 */ OBJECT_NB, - /* 0x005 */ OBJECT_OKUTA, - /* 0x006 */ OBJECT_CROW, - /* 0x007 */ OBJECT_AH, - /* 0x008 */ OBJECT_DY_OBJ, - /* 0x009 */ OBJECT_WALLMASTER, - /* 0x00A */ OBJECT_DODONGO, - /* 0x00B */ OBJECT_FIREFLY, - /* 0x00C */ OBJECT_BOX, - /* 0x00D */ OBJECT_AL, - /* 0x00E */ OBJECT_BUBBLE, - /* 0x00F */ OBJECT_NIW, - /* 0x010 */ OBJECT_LINK_BOY, - /* 0x011 */ OBJECT_LINK_CHILD, - /* 0x012 */ OBJECT_TITE, - /* 0x013 */ OBJECT_TAB, - /* 0x014 */ OBJECT_PH, - /* 0x015 */ OBJECT_AND, - /* 0x016 */ OBJECT_MSMO, - /* 0x017 */ OBJECT_DINOFOS, - /* 0x018 */ OBJECT_DRS, - /* 0x019 */ OBJECT_ZL1, - /* 0x01A */ OBJECT_AN4, - /* 0x01B */ OBJECT_UNSET_1B, - /* 0x01C */ OBJECT_TEST3, - /* 0x01D */ OBJECT_FAMOS, - /* 0x01E */ OBJECT_UNSET_1E, - /* 0x01F */ OBJECT_UNSET_1F, - /* 0x020 */ OBJECT_ST, - /* 0x021 */ OBJECT_UNSET_21, - /* 0x022 */ OBJECT_THIEFBIRD, - /* 0x023 */ OBJECT_UNSET_23, - /* 0x024 */ OBJECT_UNSET_24, - /* 0x025 */ OBJECT_UNSET_25, - /* 0x026 */ OBJECT_UNSET_26, - /* 0x027 */ OBJECT_UNSET_27, - /* 0x028 */ OBJECT_UNSET_28, - /* 0x029 */ OBJECT_UNSET_29, - /* 0x02A */ OBJECT_BOMBF, - /* 0x02B */ OBJECT_UNSET_2B, - /* 0x02C */ OBJECT_UNSET_2C, - /* 0x02D */ OBJECT_UNSET_2D, - /* 0x02E */ OBJECT_UNSET_2E, - /* 0x02F */ OBJECT_UNSET_2F, - /* 0x030 */ OBJECT_AM, - /* 0x031 */ OBJECT_DEKUBABA, - /* 0x032 */ OBJECT_UNSET_32, - /* 0x033 */ OBJECT_UNSET_33, - /* 0x034 */ OBJECT_UNSET_34, - /* 0x035 */ OBJECT_UNSET_35, - /* 0x036 */ OBJECT_UNSET_36, - /* 0x037 */ OBJECT_UNSET_37, - /* 0x038 */ OBJECT_UNSET_38, - /* 0x039 */ OBJECT_UNSET_39, - /* 0x03A */ OBJECT_UNSET_3A, - /* 0x03B */ OBJECT_UNSET_3B, - /* 0x03C */ OBJECT_UNSET_3C, - /* 0x03D */ OBJECT_UNSET_3D, - /* 0x03E */ OBJECT_WARP1, - /* 0x03F */ OBJECT_B_HEART, - /* 0x040 */ OBJECT_DEKUNUTS, - /* 0x041 */ OBJECT_UNSET_41, - /* 0x042 */ OBJECT_UNSET_42, - /* 0x043 */ OBJECT_UNSET_43, - /* 0x044 */ OBJECT_UNSET_44, - /* 0x045 */ OBJECT_UNSET_45, - /* 0x046 */ OBJECT_UNSET_46, - /* 0x047 */ OBJECT_UNSET_47, - /* 0x048 */ OBJECT_UNSET_48, - /* 0x049 */ OBJECT_UNSET_49, - /* 0x04A */ OBJECT_UNSET_4A, - /* 0x04B */ OBJECT_UNSET_4B, - /* 0x04C */ OBJECT_UNSET_4C, - /* 0x04D */ OBJECT_UNSET_4D, - /* 0x04E */ OBJECT_UNSET_4E, - /* 0x04F */ OBJECT_UNSET_4F, - /* 0x050 */ OBJECT_UNSET_50, - /* 0x051 */ OBJECT_BB, - /* 0x052 */ OBJECT_DEATH, - /* 0x053 */ OBJECT_UNSET_53, - /* 0x054 */ OBJECT_UNSET_54, - /* 0x055 */ OBJECT_UNSET_55, - /* 0x056 */ OBJECT_UNSET_56, - /* 0x057 */ OBJECT_UNSET_57, - /* 0x058 */ OBJECT_UNSET_58, - /* 0x059 */ OBJECT_UNSET_59, - /* 0x05A */ OBJECT_UNSET_5A, - /* 0x05B */ OBJECT_UNSET_5B, - /* 0x05C */ OBJECT_F40_OBJ, - /* 0x05D */ OBJECT_PO_COMPOSER, - /* 0x05E */ OBJECT_UNSET_5E, - /* 0x05F */ OBJECT_HATA, - /* 0x060 */ OBJECT_UNSET_60, - /* 0x061 */ OBJECT_WOOD02, - /* 0x062 */ OBJECT_UNSET_62, - /* 0x063 */ OBJECT_UNSET_63, - /* 0x064 */ OBJECT_TRAP, - /* 0x065 */ OBJECT_UNSET_65, - /* 0x066 */ OBJECT_UNSET_66, - /* 0x067 */ OBJECT_UNSET_67, - /* 0x068 */ OBJECT_UNSET_68, - /* 0x069 */ OBJECT_UNSET_69, - /* 0x06A */ OBJECT_VM, - /* 0x06B */ OBJECT_UNSET_6B, - /* 0x06C */ OBJECT_UNSET_6C, - /* 0x06D */ OBJECT_UNSET_6D, - /* 0x06E */ OBJECT_UNSET_6E, - /* 0x06F */ OBJECT_UNSET_6F, - /* 0x070 */ OBJECT_EFC_STAR_FIELD, - /* 0x071 */ OBJECT_UNSET_71, - /* 0x072 */ OBJECT_UNSET_72, - /* 0x073 */ OBJECT_UNSET_73, - /* 0x074 */ OBJECT_UNSET_74, - /* 0x075 */ OBJECT_RD, - /* 0x076 */ OBJECT_YUKIMURA_OBJ, - /* 0x077 */ OBJECT_HEAVY_OBJECT, - /* 0x078 */ OBJECT_UNSET_78, - /* 0x079 */ OBJECT_UNSET_79, - /* 0x07A */ OBJECT_UNSET_7A, - /* 0x07B */ OBJECT_UNSET_7B, - /* 0x07C */ OBJECT_UNSET_7C, - /* 0x07D */ OBJECT_HORSE_LINK_CHILD, - /* 0x07E */ OBJECT_UNSET_7E, - /* 0x07F */ OBJECT_UNSET_7F, - /* 0x080 */ OBJECT_SYOKUDAI, - /* 0x081 */ OBJECT_UNSET_81, - /* 0x082 */ OBJECT_UNSET_82, - /* 0x083 */ OBJECT_UNSET_83, - /* 0x084 */ OBJECT_EFC_TW, - /* 0x085 */ OBJECT_UNSET_85, - /* 0x086 */ OBJECT_GI_KEY, - /* 0x087 */ OBJECT_MIR_RAY, - /* 0x088 */ OBJECT_CTOWER_ROT, - /* 0x089 */ OBJECT_UNSET_89, - /* 0x08A */ OBJECT_BDOOR, - /* 0x08B */ OBJECT_UNSET_8B, - /* 0x08C */ OBJECT_UNSET_8C, - /* 0x08D */ OBJECT_UNSET_8D, - /* 0x08E */ OBJECT_SB, - /* 0x08F */ OBJECT_GI_MELODY, - /* 0x090 */ OBJECT_GI_HEART, - /* 0x091 */ OBJECT_GI_COMPASS, - /* 0x092 */ OBJECT_GI_BOSSKEY, - /* 0x093 */ OBJECT_UNSET_93, - /* 0x094 */ OBJECT_GI_NUTS, - /* 0x095 */ OBJECT_UNSET_95, - /* 0x096 */ OBJECT_GI_HEARTS, - /* 0x097 */ OBJECT_GI_ARROWCASE, - /* 0x098 */ OBJECT_GI_BOMBPOUCH, - /* 0x099 */ OBJECT_IN, - /* 0x09A */ OBJECT_UNSET_9A, - /* 0x09B */ OBJECT_UNSET_9B, - /* 0x09C */ OBJECT_UNSET_9C, - /* 0x09D */ OBJECT_OS_ANIME, - /* 0x09E */ OBJECT_GI_BOTTLE, - /* 0x09F */ OBJECT_GI_STICK, - /* 0x0A0 */ OBJECT_GI_MAP, - /* 0x0A1 */ OBJECT_OF1D_MAP, - /* 0x0A2 */ OBJECT_RU2, - /* 0x0A3 */ OBJECT_UNSET_A3, - /* 0x0A4 */ OBJECT_GI_MAGICPOT, - /* 0x0A5 */ OBJECT_GI_BOMB_1, - /* 0x0A6 */ OBJECT_UNSET_A6, - /* 0x0A7 */ OBJECT_MA2, - /* 0x0A8 */ OBJECT_GI_PURSE, - /* 0x0A9 */ OBJECT_UNSET_A9, - /* 0x0AA */ OBJECT_UNSET_AA, - /* 0x0AB */ OBJECT_RR, - /* 0x0AC */ OBJECT_UNSET_AC, - /* 0x0AD */ OBJECT_UNSET_AD, - /* 0x0AE */ OBJECT_UNSET_AE, - /* 0x0AF */ OBJECT_GI_ARROW, - /* 0x0B0 */ OBJECT_GI_BOMB_2, - /* 0x0B1 */ OBJECT_UNSET_B1, - /* 0x0B2 */ OBJECT_UNSET_B2, - /* 0x0B3 */ OBJECT_GI_SHIELD_2, - /* 0x0B4 */ OBJECT_GI_HOOKSHOT, - /* 0x0B5 */ OBJECT_GI_OCARINA, - /* 0x0B6 */ OBJECT_GI_MILK, - /* 0x0B7 */ OBJECT_MA1, - /* 0x0B8 */ OBJECT_UNSET_B8, - /* 0x0B9 */ OBJECT_UNSET_B9, - /* 0x0BA */ OBJECT_UNSET_BA, - /* 0x0BB */ OBJECT_NY, - /* 0x0BC */ OBJECT_FR, - /* 0x0BD */ OBJECT_UNSET_BD, - /* 0x0BE */ OBJECT_UNSET_BE, - /* 0x0BF */ OBJECT_GI_BOW, - /* 0x0C0 */ OBJECT_GI_GLASSES, - /* 0x0C1 */ OBJECT_GI_LIQUID, - /* 0x0C2 */ OBJECT_ANI, - /* 0x0C3 */ OBJECT_GI_SHIELD_3, - /* 0x0C4 */ OBJECT_UNSET_C4, - /* 0x0C5 */ OBJECT_UNSET_C5, - /* 0x0C6 */ OBJECT_GI_BEAN, - /* 0x0C7 */ OBJECT_GI_FISH, - /* 0x0C8 */ OBJECT_UNSET_C8, - /* 0x0C9 */ OBJECT_UNSET_C9, - /* 0x0CA */ OBJECT_UNSET_CA, - /* 0x0CB */ OBJECT_GI_LONGSWORD, - /* 0x0CC */ OBJECT_UNSET_CC, - /* 0x0CD */ OBJECT_UNSET_CD, - /* 0x0CE */ OBJECT_UNSET_CE, - /* 0x0CF */ OBJECT_UNSET_CF, - /* 0x0D0 */ OBJECT_ZO, - /* 0x0D1 */ OBJECT_UNSET_D1, - /* 0x0D2 */ OBJECT_UMAJUMP, - /* 0x0D3 */ OBJECT_UNSET_D3, - /* 0x0D4 */ OBJECT_UNSET_D4, - /* 0x0D5 */ OBJECT_MASTERGOLON, - /* 0x0D6 */ OBJECT_MASTERZOORA, - /* 0x0D7 */ OBJECT_AOB, - /* 0x0D8 */ OBJECT_IK, - /* 0x0D9 */ OBJECT_AHG, - /* 0x0DA */ OBJECT_CNE, - /* 0x0DB */ OBJECT_UNSET_DB, - /* 0x0DC */ OBJECT_UNSET_DC, - /* 0x0DD */ OBJECT_AN3, - /* 0x0DE */ OBJECT_BJI, - /* 0x0DF */ OBJECT_BBA, - /* 0x0E0 */ OBJECT_AN2, - /* 0x0E1 */ OBJECT_UNSET_E1, - /* 0x0E2 */ OBJECT_AN1, - /* 0x0E3 */ OBJECT_BOJ, - /* 0x0E4 */ OBJECT_FZ, - /* 0x0E5 */ OBJECT_BOB, - /* 0x0E6 */ OBJECT_GE1, - /* 0x0E7 */ OBJECT_YABUSAME_POINT, - /* 0x0E8 */ OBJECT_UNSET_E8, - /* 0x0E9 */ OBJECT_UNSET_E9, - /* 0x0EA */ OBJECT_UNSET_EA, - /* 0x0EB */ OBJECT_UNSET_EB, - /* 0x0EC */ OBJECT_D_HSBLOCK, - /* 0x0ED */ OBJECT_D_LIFT, - /* 0x0EE */ OBJECT_MAMENOKI, - /* 0x0EF */ OBJECT_GOROIWA, - /* 0x0F0 */ OBJECT_TORYO, - /* 0x0F1 */ OBJECT_DAIKU, - /* 0x0F2 */ OBJECT_NWC, - /* 0x0F3 */ OBJECT_GM, - /* 0x0F4 */ OBJECT_MS, - /* 0x0F5 */ OBJECT_HS, - /* 0x0F6 */ OBJECT_UNSET_F6, - /* 0x0F7 */ OBJECT_LIGHTSWITCH, - /* 0x0F8 */ OBJECT_KUSA, - /* 0x0F9 */ OBJECT_TSUBO, - /* 0x0FA */ OBJECT_UNSET_FA, - /* 0x0FB */ OBJECT_UNSET_FB, - /* 0x0FC */ OBJECT_KANBAN, - /* 0x0FD */ OBJECT_OWL, - /* 0x0FE */ OBJECT_MK, - /* 0x0FF */ OBJECT_FU, - /* 0x100 */ OBJECT_GI_KI_TAN_MASK, - /* 0x101 */ OBJECT_UNSET_101, - /* 0x102 */ OBJECT_GI_MASK18, - /* 0x103 */ OBJECT_GI_RABIT_MASK, - /* 0x104 */ OBJECT_GI_TRUTH_MASK, - /* 0x105 */ OBJECT_UNSET_105, - /* 0x106 */ OBJECT_STREAM, - /* 0x107 */ OBJECT_MM, - /* 0x108 */ OBJECT_UNSET_108, - /* 0x109 */ OBJECT_UNSET_109, - /* 0x10A */ OBJECT_UNSET_10A, - /* 0x10B */ OBJECT_UNSET_10B, - /* 0x10C */ OBJECT_UNSET_10C, - /* 0x10D */ OBJECT_UNSET_10D, - /* 0x10E */ OBJECT_UNSET_10E, - /* 0x10F */ OBJECT_JS, - /* 0x110 */ OBJECT_CS, - /* 0x111 */ OBJECT_UNSET_111, - /* 0x112 */ OBJECT_UNSET_112, - /* 0x113 */ OBJECT_GI_SOLDOUT, - /* 0x114 */ OBJECT_UNSET_114, - /* 0x115 */ OBJECT_MAG, - /* 0x116 */ OBJECT_UNSET_116, - /* 0x117 */ OBJECT_UNSET_117, - /* 0x118 */ OBJECT_UNSET_118, - /* 0x119 */ OBJECT_GI_GOLONMASK, - /* 0x11A */ OBJECT_GI_ZORAMASK, - /* 0x11B */ OBJECT_UNSET_11B, - /* 0x11C */ OBJECT_UNSET_11C, - /* 0x11D */ OBJECT_KA, - /* 0x11E */ OBJECT_UNSET_11E, - /* 0x11F */ OBJECT_ZG, - /* 0x120 */ OBJECT_UNSET_120, - /* 0x121 */ OBJECT_GI_M_ARROW, - /* 0x122 */ OBJECT_DS2, - /* 0x123 */ OBJECT_UNSET_123, - /* 0x124 */ OBJECT_FISH, - /* 0x125 */ OBJECT_GI_SUTARU, - /* 0x126 */ OBJECT_UNSET_126, - /* 0x127 */ OBJECT_SSH, - /* 0x128 */ OBJECT_BIGSLIME, - /* 0x129 */ OBJECT_BG, - /* 0x12A */ OBJECT_BOMBIWA, - /* 0x12B */ OBJECT_HINTNUTS, - /* 0x12C */ OBJECT_RS, - /* 0x12D */ OBJECT_UNSET_12D, - /* 0x12E */ OBJECT_GLA, - /* 0x12F */ OBJECT_UNSET_12F, - /* 0x130 */ OBJECT_GELDB, - /* 0x131 */ OBJECT_UNSET_131, - /* 0x132 */ OBJECT_DOG, - /* 0x133 */ OBJECT_KIBAKO2, - /* 0x134 */ OBJECT_DNS, - /* 0x135 */ OBJECT_DNK, - /* 0x136 */ OBJECT_UNSET_136, - /* 0x137 */ OBJECT_GI_INSECT, - /* 0x138 */ OBJECT_UNSET_138, - /* 0x139 */ OBJECT_GI_GHOST, - /* 0x13A */ OBJECT_GI_SOUL, - /* 0x13B */ OBJECT_UNSET_13B, - /* 0x13C */ OBJECT_UNSET_13C, - /* 0x13D */ OBJECT_UNSET_13D, - /* 0x13E */ OBJECT_UNSET_13E, - /* 0x13F */ OBJECT_GI_RUPY, - /* 0x140 */ OBJECT_MU, - /* 0x141 */ OBJECT_WF, - /* 0x142 */ OBJECT_SKB, - /* 0x143 */ OBJECT_GS, - /* 0x144 */ OBJECT_PS, - /* 0x145 */ OBJECT_OMOYA_OBJ, - /* 0x146 */ OBJECT_COW, - /* 0x147 */ OBJECT_UNSET_147, - /* 0x148 */ OBJECT_GI_SWORD_1, - /* 0x149 */ OBJECT_UNSET_149, - /* 0x14A */ OBJECT_UNSET_14A, - /* 0x14B */ OBJECT_ZL4, - /* 0x14C */ OBJECT_LINK_GORON, - /* 0x14D */ OBJECT_LINK_ZORA, - /* 0x14E */ OBJECT_GRASSHOPPER, - /* 0x14F */ OBJECT_BOYO, - /* 0x150 */ OBJECT_UNSET_150, - /* 0x151 */ OBJECT_UNSET_151, - /* 0x152 */ OBJECT_UNSET_152, - /* 0x153 */ OBJECT_FWALL, - /* 0x154 */ OBJECT_LINK_NUTS, - /* 0x155 */ OBJECT_JSO, - /* 0x156 */ OBJECT_KNIGHT, - /* 0x157 */ OBJECT_ICICLE, - /* 0x158 */ OBJECT_SPDWEB, - /* 0x159 */ OBJECT_UNSET_159, - /* 0x15A */ OBJECT_BOSS01, - /* 0x15B */ OBJECT_BOSS02, - /* 0x15C */ OBJECT_BOSS03, - /* 0x15D */ OBJECT_BOSS04, - /* 0x15E */ OBJECT_BOSS05, - /* 0x15F */ OBJECT_BOSS06, - /* 0x160 */ OBJECT_BOSS07, - /* 0x161 */ OBJECT_RAF, - /* 0x162 */ OBJECT_FUNEN, - /* 0x163 */ OBJECT_RAILLIFT, - /* 0x164 */ OBJECT_NUMA_OBJ, - /* 0x165 */ OBJECT_FLOWERPOT, - /* 0x166 */ OBJECT_SPINYROLL, - /* 0x167 */ OBJECT_ICE_BLOCK, - /* 0x168 */ OBJECT_UNSET_168, - /* 0x169 */ OBJECT_KEIKOKU_DEMO, - /* 0x16A */ OBJECT_SLIME, - /* 0x16B */ OBJECT_PR, - /* 0x16C */ OBJECT_F52_OBJ, - /* 0x16D */ OBJECT_F53_OBJ, - /* 0x16E */ OBJECT_UNSET_16E, - /* 0x16F */ OBJECT_KIBAKO, - /* 0x170 */ OBJECT_SEK, - /* 0x171 */ OBJECT_GMO, - /* 0x172 */ OBJECT_BAT, - /* 0x173 */ OBJECT_SEKIHIL, - /* 0x174 */ OBJECT_SEKIHIG, - /* 0x175 */ OBJECT_SEKIHIN, - /* 0x176 */ OBJECT_SEKIHIZ, - /* 0x177 */ OBJECT_UNSET_177, - /* 0x178 */ OBJECT_WIZ, - /* 0x179 */ OBJECT_LADDER, - /* 0x17A */ OBJECT_MKK, - /* 0x17B */ OBJECT_UNSET_17B, - /* 0x17C */ OBJECT_UNSET_17C, - /* 0x17D */ OBJECT_UNSET_17D, - /* 0x17E */ OBJECT_KEIKOKU_OBJ, - /* 0x17F */ OBJECT_SICHITAI_OBJ, - /* 0x180 */ OBJECT_DEKUCITY_ANA_OBJ, - /* 0x181 */ OBJECT_RAT, - /* 0x182 */ OBJECT_WATER_EFFECT, - /* 0x183 */ OBJECT_UNSET_183, - /* 0x184 */ OBJECT_DBLUE_OBJECT, - /* 0x185 */ OBJECT_BAL, - /* 0x186 */ OBJECT_WARP_UZU, - /* 0x187 */ OBJECT_DRIFTICE, - /* 0x188 */ OBJECT_FALL, - /* 0x189 */ OBJECT_HANAREYAMA_OBJ, - /* 0x18A */ OBJECT_CRACE_OBJECT, - /* 0x18B */ OBJECT_DNO, - /* 0x18C */ OBJECT_OBJ_TOKEIDAI, - /* 0x18D */ OBJECT_EG, - /* 0x18E */ OBJECT_TRU, - /* 0x18F */ OBJECT_TRT, - /* 0x190 */ OBJECT_HAKUGIN_OBJ, - /* 0x191 */ OBJECT_HORSE_GAME_CHECK, - /* 0x192 */ OBJECT_STK, - /* 0x193 */ OBJECT_UNSET_193, - /* 0x194 */ OBJECT_UNSET_194, - /* 0x195 */ OBJECT_MNK, - /* 0x196 */ OBJECT_GI_BOTTLE_RED, - /* 0x197 */ OBJECT_TOKEI_TOBIRA, - /* 0x198 */ OBJECT_AZ, - /* 0x199 */ OBJECT_TWIG, - /* 0x19A */ OBJECT_DEKUCITY_OBJ, - /* 0x19B */ OBJECT_PO_FUSEN, - /* 0x19C */ OBJECT_RACETSUBO, - /* 0x19D */ OBJECT_HA, - /* 0x19E */ OBJECT_BIGOKUTA, - /* 0x19F */ OBJECT_OPEN_OBJ, - /* 0x1A0 */ OBJECT_FU_KAITEN, - /* 0x1A1 */ OBJECT_FU_MATO, - /* 0x1A2 */ OBJECT_MTORIDE, - /* 0x1A3 */ OBJECT_OSN, - /* 0x1A4 */ OBJECT_TOKEI_STEP, - /* 0x1A5 */ OBJECT_LOTUS, - /* 0x1A6 */ OBJECT_TL, - /* 0x1A7 */ OBJECT_DKJAIL_OBJ, - /* 0x1A8 */ OBJECT_VISIBLOCK, - /* 0x1A9 */ OBJECT_TSN, - /* 0x1AA */ OBJECT_DS2N, - /* 0x1AB */ OBJECT_FSN, - /* 0x1AC */ OBJECT_SHN, - /* 0x1AD */ OBJECT_BIGICICLE, - /* 0x1AE */ OBJECT_GI_BOTTLE_15, - /* 0x1AF */ OBJECT_TK, - /* 0x1B0 */ OBJECT_MARKET_OBJ, - /* 0x1B1 */ OBJECT_GI_RESERVE00, - /* 0x1B2 */ OBJECT_GI_RESERVE01, - /* 0x1B3 */ OBJECT_LIGHTBLOCK, - /* 0x1B4 */ OBJECT_TAKARAYA_OBJECTS, - /* 0x1B5 */ OBJECT_WDHAND, - /* 0x1B6 */ OBJECT_SDN, - /* 0x1B7 */ OBJECT_SNOWWD, - /* 0x1B8 */ OBJECT_GIANT, - /* 0x1B9 */ OBJECT_COMB, - /* 0x1BA */ OBJECT_HANA, - /* 0x1BB */ OBJECT_BOSS_HAKUGIN, - /* 0x1BC */ OBJECT_MEGANEANA_OBJ, - /* 0x1BD */ OBJECT_GI_NUTSMASK, - /* 0x1BE */ OBJECT_STK2, - /* 0x1BF */ OBJECT_SPOT11_OBJ, - /* 0x1C0 */ OBJECT_DANPEI_OBJECT, - /* 0x1C1 */ OBJECT_DHOUSE, - /* 0x1C2 */ OBJECT_HAKAISI, - /* 0x1C3 */ OBJECT_PO, - /* 0x1C4 */ OBJECT_SNOWMAN, - /* 0x1C5 */ OBJECT_PO_SISTERS, - /* 0x1C6 */ OBJECT_PP, - /* 0x1C7 */ OBJECT_GORONSWITCH, - /* 0x1C8 */ OBJECT_DELF, - /* 0x1C9 */ OBJECT_BOTIHASIRA, - /* 0x1CA */ OBJECT_GI_BIGBOMB, - /* 0x1CB */ OBJECT_PST, - /* 0x1CC */ OBJECT_BSMASK, - /* 0x1CD */ OBJECT_SPIDERTENT, - /* 0x1CE */ OBJECT_ZORAEGG, - /* 0x1CF */ OBJECT_KBT, - /* 0x1D0 */ OBJECT_GG, - /* 0x1D1 */ OBJECT_MARUTA, - /* 0x1D2 */ OBJECT_GHAKA, - /* 0x1D3 */ OBJECT_OYU, - /* 0x1D4 */ OBJECT_DNQ, - /* 0x1D5 */ OBJECT_DAI, - /* 0x1D6 */ OBJECT_KGY, - /* 0x1D7 */ OBJECT_FB, - /* 0x1D8 */ OBJECT_TAISOU, - /* 0x1D9 */ OBJECT_MASK_BU_SAN, - /* 0x1DA */ OBJECT_MASK_KI_TAN, - /* 0x1DB */ OBJECT_MASK_RABIT, - /* 0x1DC */ OBJECT_MASK_SKJ, - /* 0x1DD */ OBJECT_MASK_BAKURETU, - /* 0x1DE */ OBJECT_MASK_TRUTH, - /* 0x1DF */ OBJECT_GK, - /* 0x1E0 */ OBJECT_HAKA_OBJ, - /* 0x1E1 */ OBJECT_MASK_GORON, - /* 0x1E2 */ OBJECT_MASK_ZORA, - /* 0x1E3 */ OBJECT_MASK_NUTS, - /* 0x1E4 */ OBJECT_MASK_BOY, - /* 0x1E5 */ OBJECT_DNT, - /* 0x1E6 */ OBJECT_YUKIYAMA, - /* 0x1E7 */ OBJECT_ICEFLOE, - /* 0x1E8 */ OBJECT_GI_GOLD_DUST, - /* 0x1E9 */ OBJECT_GI_BOTTLE_16, - /* 0x1EA */ OBJECT_GI_BOTTLE_22, - /* 0x1EB */ OBJECT_BEE, - /* 0x1EC */ OBJECT_OT, - /* 0x1ED */ OBJECT_UTUBO, - /* 0x1EE */ OBJECT_DORA, - /* 0x1EF */ OBJECT_GI_LOACH, - /* 0x1F0 */ OBJECT_GI_SEAHORSE, - /* 0x1F1 */ OBJECT_BIGPO, - /* 0x1F2 */ OBJECT_HARIKO, - /* 0x1F3 */ OBJECT_DNJ, - /* 0x1F4 */ OBJECT_SINKAI_KABE, - /* 0x1F5 */ OBJECT_KIN2_OBJ, - /* 0x1F6 */ OBJECT_ISHI, - /* 0x1F7 */ OBJECT_HAKUGIN_DEMO, - /* 0x1F8 */ OBJECT_JG, - /* 0x1F9 */ OBJECT_GI_SWORD_2, - /* 0x1FA */ OBJECT_GI_SWORD_3, - /* 0x1FB */ OBJECT_GI_SWORD_4, - /* 0x1FC */ OBJECT_UM, - /* 0x1FD */ OBJECT_MASK_GIBUDO, - /* 0x1FE */ OBJECT_MASK_JSON, - /* 0x1FF */ OBJECT_MASK_KERFAY, - /* 0x200 */ OBJECT_MASK_BIGELF, - /* 0x201 */ OBJECT_RB, - /* 0x202 */ OBJECT_MBAR_OBJ, - /* 0x203 */ OBJECT_IKANA_OBJ, - /* 0x204 */ OBJECT_KZ, - /* 0x205 */ OBJECT_TOKEI_TURRET, - /* 0x206 */ OBJECT_ZOG, - /* 0x207 */ OBJECT_ROTLIFT, - /* 0x208 */ OBJECT_POSTHOUSE_OBJ, - /* 0x209 */ OBJECT_GI_MASK09, - /* 0x20A */ OBJECT_GI_MASK14, - /* 0x20B */ OBJECT_GI_MASK15, - /* 0x20C */ OBJECT_INIBS_OBJECT, - /* 0x20D */ OBJECT_TREE, - /* 0x20E */ OBJECT_KAIZOKU_OBJ, - /* 0x20F */ OBJECT_GI_RESERVE_B_00, - /* 0x210 */ OBJECT_GI_RESERVE_C_00, - /* 0x211 */ OBJECT_ZOB, - /* 0x212 */ OBJECT_MILKBAR, - /* 0x213 */ OBJECT_DMASK, - /* 0x214 */ OBJECT_MASK_KYOJIN, - /* 0x215 */ OBJECT_GI_RESERVE_C_01, - /* 0x216 */ OBJECT_ZOD, - /* 0x217 */ OBJECT_KUMO30, - /* 0x218 */ OBJECT_OBJ_YASI, - /* 0x219 */ OBJECT_MASK_ROMERNY, - /* 0x21A */ OBJECT_TANRON1, - /* 0x21B */ OBJECT_TANRON2, - /* 0x21C */ OBJECT_TANRON3, - /* 0x21D */ OBJECT_GI_MAGICMUSHROOM, - /* 0x21E */ OBJECT_OBJ_CHAN, - /* 0x21F */ OBJECT_GI_MASK10, - /* 0x220 */ OBJECT_ZOS, - /* 0x221 */ OBJECT_MASK_POSTHAT, - /* 0x222 */ OBJECT_F40_SWITCH, - /* 0x223 */ OBJECT_LODMOON, - /* 0x224 */ OBJECT_TRO, - /* 0x225 */ OBJECT_GI_MASK12, - /* 0x226 */ OBJECT_GI_MASK23, - /* 0x227 */ OBJECT_GI_BOTTLE_21, - /* 0x228 */ OBJECT_GI_CAMERA, - /* 0x229 */ OBJECT_KAMEJIMA, - /* 0x22A */ OBJECT_HARFGIBUD, - /* 0x22B */ OBJECT_ZOV, - /* 0x22C */ OBJECT_HGDOOR, - /* 0x22D */ OBJECT_UNSET_22D, - /* 0x22E */ OBJECT_UNSET_22E, - /* 0x22F */ OBJECT_UNSET_22F, - /* 0x230 */ OBJECT_DOR01, - /* 0x231 */ OBJECT_DOR02, - /* 0x232 */ OBJECT_DOR03, - /* 0x233 */ OBJECT_DOR04, - /* 0x234 */ OBJECT_LAST_OBJ, - /* 0x235 */ OBJECT_REDEAD_OBJ, - /* 0x236 */ OBJECT_IKNINSIDE_OBJ, - /* 0x237 */ OBJECT_IKNV_OBJ, - /* 0x238 */ OBJECT_PAMERA, - /* 0x239 */ OBJECT_HSSTUMP, - /* 0x23A */ OBJECT_ZM, - /* 0x23B */ OBJECT_BIG_FWALL, - /* 0x23C */ OBJECT_SECOM_OBJ, - /* 0x23D */ OBJECT_HUNSUI, - /* 0x23E */ OBJECT_UCH, - /* 0x23F */ OBJECT_TANRON4, - /* 0x240 */ OBJECT_TANRON5, - /* 0x241 */ OBJECT_DT, - /* 0x242 */ OBJECT_GI_MASK03, - /* 0x243 */ OBJECT_CHA, - /* 0x244 */ OBJECT_OBJ_DINNER, - /* 0x245 */ OBJECT_GI_RESERVE_B_01, - /* 0x246 */ OBJECT_LASTDAY, - /* 0x247 */ OBJECT_BAI, - /* 0x248 */ OBJECT_IN2, - /* 0x249 */ OBJECT_IKN_DEMO, - /* 0x24A */ OBJECT_YB, - /* 0x24B */ OBJECT_RZ, - /* 0x24C */ OBJECT_MASK_ZACHO, - /* 0x24D */ OBJECT_GI_FIELDMAP, - /* 0x24E */ OBJECT_MASK_STONE, - /* 0x24F */ OBJECT_BJT, - /* 0x250 */ OBJECT_TARU, - /* 0x251 */ OBJECT_MOONSTON, - /* 0x252 */ OBJECT_MASK_BREE, - /* 0x253 */ OBJECT_GI_SCHEDULE, - /* 0x254 */ OBJECT_GI_STONEMASK, - /* 0x255 */ OBJECT_ZORABAND, - /* 0x256 */ OBJECT_KEPN_KOYA, - /* 0x257 */ OBJECT_OBJ_USIYANE, - /* 0x258 */ OBJECT_GI_MASK05, - /* 0x259 */ OBJECT_GI_MASK11, - /* 0x25A */ OBJECT_GI_MASK20, - /* 0x25B */ OBJECT_NNH, - /* 0x25C */ OBJECT_MASK_GERO, - /* 0x25D */ OBJECT_MASK_YOFUKASI, - /* 0x25E */ OBJECT_MASK_MEOTO, - /* 0x25F */ OBJECT_MASK_DANCER, - /* 0x260 */ OBJECT_KZSAKU, - /* 0x261 */ OBJECT_OBJ_MILK_BIN, - /* 0x262 */ OBJECT_RANDOM_OBJ, - /* 0x263 */ OBJECT_KUJIYA, - /* 0x264 */ OBJECT_KITAN, - /* 0x265 */ OBJECT_GI_MASK06, - /* 0x266 */ OBJECT_GI_MASK16, - /* 0x267 */ OBJECT_ASTR_OBJ, - /* 0x268 */ OBJECT_BSB, - /* 0x269 */ OBJECT_FALL2, - /* 0x26A */ OBJECT_STH, - /* 0x26B */ OBJECT_GI_MSSA, - /* 0x26C */ OBJECT_SMTOWER, - /* 0x26D */ OBJECT_GI_MASK21, - /* 0x26E */ OBJECT_YADO_OBJ, - /* 0x26F */ OBJECT_SYOTEN, - /* 0x270 */ OBJECT_MOONEND, - /* 0x271 */ OBJECT_OB, - /* 0x272 */ OBJECT_GI_BOTTLE_04, - /* 0x273 */ OBJECT_OBJ_DANPEILIFT, - /* 0x274 */ OBJECT_WDOR01, - /* 0x275 */ OBJECT_WDOR02, - /* 0x276 */ OBJECT_WDOR03, - /* 0x277 */ OBJECT_STK3, - /* 0x278 */ OBJECT_KINSTA1_OBJ, - /* 0x279 */ OBJECT_KINSTA2_OBJ, - /* 0x27A */ OBJECT_BH, - /* 0x27B */ OBJECT_WDOR04, - /* 0x27C */ OBJECT_WDOR05, - /* 0x27D */ OBJECT_GI_MASK17, - /* 0x27E */ OBJECT_GI_MASK22, - /* 0x27F */ OBJECT_LBFSHOT, - /* 0x280 */ OBJECT_FUSEN, - /* 0x281 */ OBJECT_ENDING_OBJ, - /* 0x282 */ OBJECT_GI_MASK13, +#define DEFINE_OBJECT(_name, enumValue) enumValue, +#define DEFINE_OBJECT_UNSET(enumValue) enumValue, +#define DEFINE_OBJECT_SIZE_ZERO(_name, enumValue) enumValue, + +typedef enum ObjectId { + #include "tables/object_table.h" /* 0x283 */ OBJECT_ID_MAX -} ObjectID; +} ObjectId; + +#undef DEFINE_OBJECT +#undef DEFINE_OBJECT_UNSET +#undef DEFINE_OBJECT_SIZE_ZERO #endif diff --git a/include/z64player.h b/include/z64player.h index e99b261ce..3bcc53fde 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -22,7 +22,8 @@ typedef enum PlayerBoots { /* 4 */ PLAYER_BOOTS_ZORA_LAND, /* 5 */ PLAYER_BOOTS_ZORA_UNDERWATER, /* 6 */ PLAYER_BOOTS_GORON, - /* 7 */ PLAYER_BOOTS_MAX + /* 7 */ PLAYER_BOOTS_7, + /* 8 */ PLAYER_BOOTS_MAX } PlayerBoots; typedef enum PlayerStrength { @@ -84,7 +85,8 @@ typedef enum PlayerItemAction { /* 0x00 */ PLAYER_IA_NONE, /* 0x01 */ PLAYER_IA_LAST_USED, /* 0x02 */ PLAYER_IA_FISHING_ROD, - /* 0x03 */ PLAYER_IA_SWORD_KOKIRI, + /* 0x03 */ PLAYER_IA_SWORD_MIN, + /* 0x03 */ PLAYER_IA_SWORD_KOKIRI = PLAYER_IA_SWORD_MIN, /* 0x04 */ PLAYER_IA_SWORD_RAZOR, /* 0x05 */ PLAYER_IA_SWORD_GILDED, /* 0x06 */ PLAYER_IA_SWORD_GREAT_FAIRY, @@ -95,14 +97,16 @@ typedef enum PlayerItemAction { /* 0x0B */ PLAYER_IA_BOW_ICE, /* 0x0C */ PLAYER_IA_BOW_LIGHT, /* 0x0D */ PLAYER_IA_HOOKSHOT, - /* 0x0E */ PLAYER_IA_BOMB, + /* 0x0E */ PLAYER_IA_EXPLOSIVE_MIN, + /* 0x0E */ PLAYER_IA_BOMB = PLAYER_IA_EXPLOSIVE_MIN, /* 0x0F */ PLAYER_IA_POWDER_KEG, /* 0x10 */ PLAYER_IA_BOMBCHU, /* 0x11 */ PLAYER_IA_11, /* 0x12 */ PLAYER_IA_NUT, /* 0x13 */ PLAYER_IA_PICTO_BOX, /* 0x14 */ PLAYER_IA_OCARINA, - /* 0x15 */ PLAYER_IA_BOTTLE, + /* 0x15 */ PLAYER_IA_BOTTLE_MIN, + /* 0x15 */ PLAYER_IA_BOTTLE_EMPTY = PLAYER_IA_BOTTLE_MIN, /* 0x16 */ PLAYER_IA_BOTTLE_FISH, /* 0x17 */ PLAYER_IA_BOTTLE_SPRING_WATER, /* 0x18 */ PLAYER_IA_BOTTLE_HOT_SPRING_WATER, @@ -167,6 +171,83 @@ typedef enum PlayerItemAction { /* 0x53 */ PLAYER_IA_MAX } PlayerItemAction; +// Relies on B swords related item actions to be contiguous +#define GET_B_SWORD_FROM_IA(itemAction) ((itemAction) - PLAYER_IA_SWORD_MIN + 1) + +typedef enum PlayerBButtonSword { + /* 0 */ PLAYER_B_SWORD_NONE, + /* 1 */ PLAYER_B_SWORD_KOKIRI = GET_B_SWORD_FROM_IA(PLAYER_IA_SWORD_KOKIRI), + /* 2 */ PLAYER_B_SWORD_RAZOR = GET_B_SWORD_FROM_IA(PLAYER_IA_SWORD_RAZOR), + /* 3 */ PLAYER_B_SWORD_GILDED = GET_B_SWORD_FROM_IA(PLAYER_IA_SWORD_GILDED), + /* 4 */ PLAYER_B_SWORD_MAX +} PlayerBButtonSword; + +// Relies on melee weapon related item actions to be contiguous +#define GET_MELEE_WEAPON_FROM_IA(itemAction) ((itemAction) - PLAYER_IA_SWORD_MIN + 1) + +typedef enum PlayerMeleeWeapon { + /* 0 */ PLAYER_MELEEWEAPON_NONE, + /* 1 */ PLAYER_MELEEWEAPON_SWORD_KOKIRI = GET_MELEE_WEAPON_FROM_IA(PLAYER_IA_SWORD_KOKIRI), + /* 2 */ PLAYER_MELEEWEAPON_SWORD_RAZOR = GET_MELEE_WEAPON_FROM_IA(PLAYER_IA_SWORD_RAZOR), + /* 3 */ PLAYER_MELEEWEAPON_SWORD_GILDED = GET_MELEE_WEAPON_FROM_IA(PLAYER_IA_SWORD_GILDED), + /* 4 */ PLAYER_MELEEWEAPON_SWORD_GREAT_FAIRY = GET_MELEE_WEAPON_FROM_IA(PLAYER_IA_SWORD_GREAT_FAIRY), + /* 5 */ PLAYER_MELEEWEAPON_STICK = GET_MELEE_WEAPON_FROM_IA(PLAYER_IA_STICK), + /* 6 */ PLAYER_MELEEWEAPON_ZORA_FINS = GET_MELEE_WEAPON_FROM_IA(PLAYER_IA_ZORA_FINS), + /* 7 */ PLAYER_MELEEWEAPON_MAX +} PlayerMeleeWeapon; + +// Relies on bottle-related item actions to be contiguous +#define GET_BOTTLE_FROM_IA(itemAction) ((itemAction) - PLAYER_IA_BOTTLE_MIN) + +typedef enum PlayerBottle { + /* -1 */ PLAYER_BOTTLE_NONE = -1, + /* 0 */ PLAYER_BOTTLE_EMPTY = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_EMPTY), + /* 1 */ PLAYER_BOTTLE_FISH = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_FISH), + /* 2 */ PLAYER_BOTTLE_SPRING_WATER = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_SPRING_WATER), + /* 3 */ PLAYER_BOTTLE_HOT_SPRING_WATER = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_HOT_SPRING_WATER), + /* 4 */ PLAYER_BOTTLE_ZORA_EGG = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_ZORA_EGG), + /* 5 */ PLAYER_BOTTLE_DEKU_PRINCESS = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_DEKU_PRINCESS), + /* 6 */ PLAYER_BOTTLE_GOLD_DUST = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_GOLD_DUST), + /* 7 */ PLAYER_BOTTLE_1C = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_1C), + /* 8 */ PLAYER_BOTTLE_SEAHORSE = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_SEAHORSE), + /* 9 */ PLAYER_BOTTLE_MUSHROOM = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_MUSHROOM), + /* 10 */ PLAYER_BOTTLE_HYLIAN_LOACH = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_HYLIAN_LOACH), + /* 11 */ PLAYER_BOTTLE_BUG = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_BUG), + /* 12 */ PLAYER_BOTTLE_POE = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_POE), + /* 13 */ PLAYER_BOTTLE_BIG_POE = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_BIG_POE), + /* 14 */ PLAYER_BOTTLE_POTION_RED = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_POTION_RED), + /* 15 */ PLAYER_BOTTLE_POTION_BLUE = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_POTION_BLUE), + /* 16 */ PLAYER_BOTTLE_POTION_GREEN = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_POTION_GREEN), + /* 17 */ PLAYER_BOTTLE_MILK = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_MILK), + /* 18 */ PLAYER_BOTTLE_MILK_HALF = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_MILK_HALF), + /* 19 */ PLAYER_BOTTLE_CHATEAU = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_CHATEAU), + /* 20 */ PLAYER_BOTTLE_FAIRY = GET_BOTTLE_FROM_IA(PLAYER_IA_BOTTLE_FAIRY), + /* 21 */ PLAYER_BOTTLE_MAX +} PlayerBottle; + +// Relies on explosive-related item actions to be contiguous +#define GET_EXPLOSIVE_FROM_IA(itemAction) ((itemAction) - PLAYER_IA_EXPLOSIVE_MIN) + +typedef enum PlayerExplosive { + /* -1 */ PLAYER_EXPLOSIVE_NONE = -1, + /* 0 */ PLAYER_EXPLOSIVE_BOMB = GET_EXPLOSIVE_FROM_IA(PLAYER_IA_BOMB), + /* 1 */ PLAYER_EXPLOSIVE_POWDER_KEG = GET_EXPLOSIVE_FROM_IA(PLAYER_IA_POWDER_KEG), + /* 2 */ PLAYER_EXPLOSIVE_BOMBCHU = GET_EXPLOSIVE_FROM_IA(PLAYER_IA_BOMBCHU), + /* 3 */ PLAYER_EXPLOSIVE_MAX +} PlayerExplosive; + +// Relies on sword item actions to be contiguous +#define GET_SWORD_FROM_IA(itemAction) ((itemAction) - PLAYER_IA_SWORD_MIN) + +typedef enum PlayerSword { + /* -1 */ PLAYER_SWORD_NONE = -1, + /* 0 */ PLAYER_SWORD_KOKIRI = GET_SWORD_FROM_IA(PLAYER_IA_SWORD_KOKIRI), + /* 1 */ PLAYER_SWORD_RAZOR = GET_SWORD_FROM_IA(PLAYER_IA_SWORD_RAZOR), + /* 2 */ PLAYER_SWORD_GILDED = GET_SWORD_FROM_IA(PLAYER_IA_SWORD_GILDED), + /* 3 */ PLAYER_SWORD_GREAT_FAIRY = GET_SWORD_FROM_IA(PLAYER_IA_SWORD_GREAT_FAIRY), + /* 4 */ PLAYER_SWORD_MAX +} PlayerSword; + typedef enum PlayerMeleeWeaponAnimation { /* 0 */ PLAYER_MWA_FORWARD_SLASH_1H, // Vertical one-handed slash /* 1 */ PLAYER_MWA_FORWARD_SLASH_2H, // Vertical two-handed slash @@ -217,10 +298,10 @@ typedef enum PlayerDoorType { } PlayerDoorType; typedef enum PlayerAnimType { - /* 0 */ PLAYER_ANIMTYPE_0, + /* 0 */ PLAYER_ANIMTYPE_DEFAULT, // DEFAULT /* 1 */ PLAYER_ANIMTYPE_1, /* 2 */ PLAYER_ANIMTYPE_2, - /* 3 */ PLAYER_ANIMTYPE_3, + /* 3 */ PLAYER_ANIMTYPE_3, // Two hand weapon /* 4 */ PLAYER_ANIMTYPE_4, /* 5 */ PLAYER_ANIMTYPE_5, /* 6 */ PLAYER_ANIMTYPE_MAX @@ -228,28 +309,29 @@ typedef enum PlayerAnimType { typedef enum PlayerModelType { // left hand - /* 0 */ PLAYER_MODELTYPE_LH_OPEN, - /* 1 */ PLAYER_MODELTYPE_LH_CLOSED, - /* 2 */ PLAYER_MODELTYPE_LH_ONE_HAND_SWORD, - /* 3 */ PLAYER_MODELTYPE_LH_TWO_HAND_SWORD, - /* 4 */ PLAYER_MODELTYPE_LH_4, - /* 5 */ PLAYER_MODELTYPE_LH_BOTTLE, + /* 0 */ PLAYER_MODELTYPE_LH_OPEN, + /* 1 */ PLAYER_MODELTYPE_LH_CLOSED, + /* 2 */ PLAYER_MODELTYPE_LH_ONE_HAND_SWORD, + /* 3 */ PLAYER_MODELTYPE_LH_TWO_HAND_SWORD, + /* 4 */ PLAYER_MODELTYPE_LH_4, + /* 5 */ PLAYER_MODELTYPE_LH_BOTTLE, // right hand - /* 6 */ PLAYER_MODELTYPE_RH_OPEN, - /* 7 */ PLAYER_MODELTYPE_RH_CLOSED, - /* 8 */ PLAYER_MODELTYPE_RH_SHIELD, - /* 9 */ PLAYER_MODELTYPE_RH_BOW, - /* 10 */ PLAYER_MODELTYPE_RH_INSTRUMENT, - /* 11 */ PLAYER_MODELTYPE_RH_HOOKSHOT, + /* 6 */ PLAYER_MODELTYPE_RH_OPEN, + /* 7 */ PLAYER_MODELTYPE_RH_CLOSED, + /* 8 */ PLAYER_MODELTYPE_RH_SHIELD, + /* 9 */ PLAYER_MODELTYPE_RH_BOW, + /* 10 */ PLAYER_MODELTYPE_RH_INSTRUMENT, + /* 11 */ PLAYER_MODELTYPE_RH_HOOKSHOT, // sheath - /* 12 */ PLAYER_MODELTYPE_SHEATH_12, - /* 13 */ PLAYER_MODELTYPE_SHEATH_13, - /* 14 */ PLAYER_MODELTYPE_SHEATH_14, - /* 15 */ PLAYER_MODELTYPE_SHEATH_15, + /* 12 */ PLAYER_MODELTYPE_SHEATH_12, + /* 13 */ PLAYER_MODELTYPE_SHEATH_13, + /* 14 */ PLAYER_MODELTYPE_SHEATH_14, + /* 15 */ PLAYER_MODELTYPE_SHEATH_15, // waist - /* 16 */ PLAYER_MODELTYPE_WAIST, - /* 17 */ PLAYER_MODELTYPE_17, // NULL? - /* 18 */ PLAYER_MODELTYPE_MAX + /* 16 */ PLAYER_MODELTYPE_WAIST, + /* 17 */ PLAYER_MODELTYPE_17, // NULL? + /* 18 */ PLAYER_MODELTYPE_MAX, + /* 255 */ PLAYER_MODELTYPE_RH_FF = 0xFF // disable shield collider, cutscene-specific } PlayerModelType; typedef struct PlayerModelIndices { @@ -368,25 +450,33 @@ typedef enum PlayerBodyPart { typedef struct PlayerAnimationFrame { /* 0x000 */ Vec3s frameTable[PLAYER_LIMB_MAX]; - /* 0x108 */ s16 faceInfo; + /* 0x108 */ s16 appearanceInfo; // bitpack containing the face and hands info } PlayerAnimationFrame; // size = 0x10A #define PLAYER_LIMB_BUF_SIZE (ALIGN16(sizeof(PlayerAnimationFrame)) + 0xF) +#define GET_APPEARANCE_FROM_JOINT_TABLE(jointTable) (((PlayerAnimationFrame *)(jointTable))->appearanceInfo) +#define GET_EYE_INDEX_FROM_JOINT_TABLE(jointTable) ((GET_APPEARANCE_FROM_JOINT_TABLE(jointTable) & 0xF) - 1) +#define GET_MOUTH_INDEX_FROM_JOINT_TABLE(jointTable) (((GET_APPEARANCE_FROM_JOINT_TABLE(jointTable) >> 4) & 0xF) - 1) + +// Note the returned value from this macro needs to be shifted +#define GET_LEFT_HAND_INDEX_FROM_JOINT_TABLE(jointTable) (GET_APPEARANCE_FROM_JOINT_TABLE(jointTable) & 0xF000) +#define GET_RIGHT_HAND_INDEX_FROM_JOINT_TABLE(jointTable) (GET_APPEARANCE_FROM_JOINT_TABLE(jointTable) & 0x0F00) + typedef struct PlayerAgeProperties { /* 0x00 */ f32 unk_00; // ceilingCheckHeight? /* 0x04 */ f32 shadowScale; /* 0x08 */ f32 unk_08; /* 0x0C */ f32 unk_0C; /* 0x10 */ f32 unk_10; - /* 0x14 */ f32 unk_14; - /* 0x18 */ f32 unk_18; - /* 0x1C */ f32 unk_1C; - /* 0x20 */ f32 unk_20; - /* 0x24 */ f32 unk_24; - /* 0x28 */ f32 unk_28; - /* 0x2C */ f32 unk_2C; - /* 0x30 */ f32 unk_30; + /* 0x14 */ f32 unk_14; // compared to wallHeight + /* 0x18 */ f32 unk_18; // compared to wallHeight + /* 0x1C */ f32 unk_1C; // compared to wallHeight + /* 0x20 */ f32 unk_20; // unused? + /* 0x24 */ f32 unk_24; // water stuff // depthInWater + /* 0x28 */ f32 unk_28; // water stuff // depthInWater + /* 0x2C */ f32 unk_2C; // water stuff // depthInWater + /* 0x30 */ f32 unk_30; // water stuff // depthInWater /* 0x34 */ f32 unk_34; /* 0x38 */ f32 unk_38; // wallCheckHeight? /* 0x3C */ f32 unk_3C; @@ -399,15 +489,15 @@ typedef struct PlayerAgeProperties { /* 0x94 */ u16 surfaceSfxIdOffset; /* 0x98 */ f32 unk_98; /* 0x9C */ f32 unk_9C; - /* 0xA0 */ LinkAnimationHeader* unk_A0; - /* 0xA4 */ LinkAnimationHeader* unk_A4; - /* 0xA8 */ LinkAnimationHeader* unk_A8; - /* 0xAC */ LinkAnimationHeader* unk_AC; - /* 0xB0 */ LinkAnimationHeader* unk_B0; - /* 0xB4 */ LinkAnimationHeader* unk_B4[4]; - /* 0xC4 */ LinkAnimationHeader* unk_C4[2]; - /* 0xCC */ LinkAnimationHeader* unk_CC[2]; - /* 0xD4 */ LinkAnimationHeader* unk_D4[2]; + /* 0xA0 */ PlayerAnimationHeader* unk_A0; + /* 0xA4 */ PlayerAnimationHeader* unk_A4; + /* 0xA8 */ PlayerAnimationHeader* unk_A8; + /* 0xAC */ PlayerAnimationHeader* unk_AC; + /* 0xB0 */ PlayerAnimationHeader* unk_B0; + /* 0xB4 */ PlayerAnimationHeader* unk_B4[4]; + /* 0xC4 */ PlayerAnimationHeader* unk_C4[2]; + /* 0xCC */ PlayerAnimationHeader* unk_CC[2]; + /* 0xD4 */ PlayerAnimationHeader* unk_D4[2]; } PlayerAgeProperties; // size = 0xDC typedef struct { @@ -445,8 +535,8 @@ typedef enum PlayerCsMode { /* 0x03 */ PLAYER_CSMODE_3, /* 0x04 */ PLAYER_CSMODE_4, /* 0x05 */ PLAYER_CSMODE_5, - /* 0x06 */ PLAYER_CSMODE_6, - /* 0x07 */ PLAYER_CSMODE_7, + /* 0x06 */ PLAYER_CSMODE_END, + /* 0x07 */ PLAYER_CSMODE_WAIT, /* 0x08 */ PLAYER_CSMODE_8, /* 0x09 */ PLAYER_CSMODE_9, /* 0x0A */ PLAYER_CSMODE_10, @@ -587,7 +677,7 @@ typedef enum PlayerCsMode { #define PLAYER_STATE1_1 (1 << 0) // #define PLAYER_STATE1_2 (1 << 1) -// +// Climbing ledge #define PLAYER_STATE1_4 (1 << 2) // #define PLAYER_STATE1_8 (1 << 3) @@ -607,7 +697,7 @@ typedef enum PlayerCsMode { #define PLAYER_STATE1_400 (1 << 10) // #define PLAYER_STATE1_800 (1 << 11) -// +// charging spin attack #define PLAYER_STATE1_1000 (1 << 12) // #define PLAYER_STATE1_2000 (1 << 13) @@ -641,7 +731,7 @@ typedef enum PlayerCsMode { #define PLAYER_STATE1_8000000 (1 << 27) // #define PLAYER_STATE1_10000000 (1 << 28) -// +// Time is stopped but Link & NPC animations continue #define PLAYER_STATE1_20000000 (1 << 29) // #define PLAYER_STATE1_40000000 (1 << 30) @@ -671,7 +761,7 @@ typedef enum PlayerCsMode { #define PLAYER_STATE2_200 (1 << 9) // #define PLAYER_STATE2_400 (1 << 10) -// +// Diving #define PLAYER_STATE2_800 (1 << 11) // #define PLAYER_STATE2_1000 (1 << 12) @@ -683,7 +773,7 @@ typedef enum PlayerCsMode { #define PLAYER_STATE2_8000 (1 << 15) // #define PLAYER_STATE2_10000 (1 << 16) -// +// A non-magic spin attack #define PLAYER_STATE2_20000 (1 << 17) // #define PLAYER_STATE2_40000 (1 << 18) @@ -731,7 +821,7 @@ typedef enum PlayerCsMode { #define PLAYER_STATE3_40 (1 << 6) // #define PLAYER_STATE3_80 (1 << 7) -// Related to form Deku +// Deku flower dive #define PLAYER_STATE3_100 (1 << 8) // #define PLAYER_STATE3_200 (1 << 9) @@ -745,7 +835,7 @@ typedef enum PlayerCsMode { #define PLAYER_STATE3_2000 (1 << 13) // #define PLAYER_STATE3_4000 (1 << 14) -// +// Swimming Zora #define PLAYER_STATE3_8000 (1 << 15) // #define PLAYER_STATE3_10000 (1 << 16) @@ -928,7 +1018,7 @@ typedef struct Player { /* 0xA7C */ Actor* boomerangActor; /* 0xA80 */ Actor* tatlActor; /* 0xA84 */ s16 tatlTextId; - /* 0xA86 */ s8 unk_A86; // actorCutsceneIndex? + /* 0xA86 */ s8 csId; /* 0xA87 */ s8 exchangeItemId; // PlayerItemAction enum /* 0xA88 */ Actor* talkActor; /* 0xA8C */ f32 talkActorDistance; @@ -942,8 +1032,8 @@ typedef struct Player { /* 0xAA6 */ u16 unk_AA6; // flags of some kind /* 0xAA8 */ s16 unk_AA8; /* 0xAAA */ s16 unk_AAA; - /* 0xAAC */ Vec3s unk_AAC; - /* 0xAB2 */ Vec3s unk_AB2; + /* 0xAAC */ Vec3s headLimbRot; + /* 0xAB2 */ Vec3s upperLimbRot; /* 0xAB8 */ f32 unk_AB8; /* 0xABC */ f32 unk_ABC; /* 0xAC0 */ f32 unk_AC0; @@ -966,11 +1056,14 @@ typedef struct Player { /* 0xAE7 */ s8 unk_AE7; // a timer /* 0xAE8 */ s16 unk_AE8; // multipurpose timer /* 0xAEC */ f32 unk_AEC; - /* 0xAF0 */ Vec3f unk_AF0[2]; + /* 0xAF0 */ union { // TODO: this may be an union of two structs + Vec3f unk_AF0[2]; + f32 arr_AF0[6]; + }; /* 0xB08 */ f32 unk_B08[2]; // TODO: Investigate if this member actually is an array /* 0xB10 */ f32 unk_B10[6]; /* 0xB28 */ s16 unk_B28; //Burning stick timer? - /* 0xB2A */ s8 getItemDrawId; + /* 0xB2A */ s8 getItemDrawIdPlusOne; /* 0xB2B */ s8 unk_B2B; /* 0xB2C */ f32 windSpeed; /* 0xB30 */ s16 windAngleX; @@ -990,7 +1083,7 @@ typedef struct Player { /* 0xB5D */ u8 unk_B5D; /* 0xB5E */ u8 unk_B5E; /* 0xB5F */ u8 unk_B5F; - /* 0xB60 */ u16 unk_B60; // blast mask timer? + /* 0xB60 */ u16 blastMaskTimer; /* 0xB62 */ s16 unk_B62; /* 0xB64 */ u8 unk_B64; /* 0xB65 */ u8 shockTimer; @@ -1022,7 +1115,7 @@ typedef struct Player { /* 0xCC4 */ MtxF mf_CC4; /* 0xD04 */ MtxF shieldMf; /* 0xD44 */ u8 isBurning; - /* 0xD45 */ u8 flameTimers[PLAYER_BODYPART_MAX]; + /* 0xD45 */ u8 flameTimers[PLAYER_BODYPART_MAX]; // one flame per body part /* 0xD57 */ u8 unk_D57; /* 0xD58 */ PlayerFuncD58 unk_D58; /* 0xD5C */ s8 invincibilityTimer; // prevents damage when nonzero (positive = visible, counts towards zero each frame) diff --git a/include/z64quake.h b/include/z64quake.h index a1272941d..0150b5404 100644 --- a/include/z64quake.h +++ b/include/z64quake.h @@ -1,68 +1,64 @@ #ifndef Z64QUAKE_H #define Z64QUAKE_H +#include "z64camera.h" #include "z64math.h" struct PlayState; -struct Camera; typedef struct { /* 0x00 */ Vec3f atOffset; /* 0x0C */ Vec3f eyeOffset; - /* 0x18 */ s16 rollOffset; - /* 0x1A */ s16 zoom; - /* 0x1C */ f32 max; // Set to scaled max data of struct (mag for Vec3f), never used -} QuakeCamCalc; // size = 0x20 - -#define QUAKE_SPEED (1 << 0) -#define QUAKE_VERTICAL_MAG (1 << 1) -#define QUAKE_HORIZONTAL_MAG (1 << 2) -#define QUAKE_ZOOM (1 << 3) -#define QUAKE_ROLL_OFFSET (1 << 4) -#define QUAKE_SHAKE_PLANE_OFFSET_X (1 << 5) -#define QUAKE_SHAKE_PLANE_OFFSET_Y (1 << 6) -#define QUAKE_SHAKE_PLANE_OFFSET_Z (1 << 7) -#define QUAKE_COUNTDOWN (1 << 8) -#define QUAKE_IS_SHAKE_PERPENDICULAR (1 << 9) + /* 0x18 */ s16 upRollOffset; + /* 0x1A */ s16 fovOffset; + /* 0x1C */ f32 maxOffset; // Set to scaled max data of struct (mag for Vec3f), never used +} ShakeInfo; // size = 0x20 typedef enum { - /* 1 */ QUAKE_TYPE_1 = 1, - /* 2 */ QUAKE_TYPE_2, - /* 3 */ QUAKE_TYPE_3, - /* 4 */ QUAKE_TYPE_4, - /* 5 */ QUAKE_TYPE_5, - /* 6 */ QUAKE_TYPE_6 + /* 0 */ QUAKE_TYPE_NONE, + /* 1 */ QUAKE_TYPE_1, // Periodic, sustaining, random X perturbations + /* 2 */ QUAKE_TYPE_2, // Aperiodic, sustaining, random X perturbations + /* 3 */ QUAKE_TYPE_3, // Periodic, decaying + /* 4 */ QUAKE_TYPE_4, // Aperiodic, decaying, random X perturbations + /* 5 */ QUAKE_TYPE_5, // Periodic, sustaining + /* 6 */ QUAKE_TYPE_6 // See below } QuakeType; -u32 Quake_SetValue(s16 quakeIndex, s16 valueType, s16 value); -u32 Quake_SetSpeed(s16 quakeIndex, s16 speed); -u32 Quake_SetCountdown(s16 quakeIndex, s16 countdown); -s16 Quake_GetCountdown(s16 quakeIndex); -u32 Quake_SetQuakeValues(s16 quakeIndex, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset); -u32 Quake_SetQuakeValues2(s16 quakeIndex, s16 isShakePerpendicular, Vec3s shakePlaneOffset); -s16 Quake_Add(Camera* camera, u32 type); -s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData); -u32 Quake_Remove(s16 index); -s32 Quake_NumActiveQuakes(void); +s16 Quake_Request(Camera* camera, u32 type); + +u32 Quake_SetSpeed(s16 index, s16 speed); +u32 Quake_SetPerturbations(s16 index, s16 y, s16 x, s16 fov, s16 roll); +u32 Quake_SetDuration(s16 index, s16 duration); +u32 Quake_SetOrientation(s16 index, s16 isRelativeToScreen, Vec3s orientation); + +s16 Quake_GetTimeLeft(s16 index); +s32 Quake_GetNumActiveQuakes(void); +u32 Quake_RemoveRequest(s16 index); + void Quake_Init(void); +s16 Quake_Update(Camera* camera, ShakeInfo* camShake); -#define DISTORTION_TYPE_0 (1 << 0) -#define DISTORTION_TYPE_2 (1 << 2) -#define DISTORTION_TYPE_3 (1 << 3) -#define DISTORTION_TYPE_4 (1 << 4) -#define DISTORTION_TYPE_5 (1 << 5) -#define DISTORTION_TYPE_6 (1 << 6) -#define DISTORTION_TYPE_7 (1 << 7) -#define DISTORTION_TYPE_8 (1 << 8) -#define DISTORTION_TYPE_9 (1 << 9) -#define DISTORTION_TYPE_A (1 << 10) -#define DISTORTION_TYPE_B (1 << 11) +#define DISTORTION_TYPE_HOT_ROOM (1 << 0) // Hot Room +#define DISTORTION_TYPE_NON_ZORA_SWIMMING (1 << 2) // Non-Zora swimming +#define DISTORTION_TYPE_ZORA_SWIMMING (1 << 3) // Zora swimming, also used for boss warp pad part 1 -void Distortion_SetCountdown(s16 countdown); -s16 Distortion_GetCountdown(void); +#define DISTORTION_TYPE_UNDERWATER_ENTRY (1 << 4) // Entering water, also used for boss warp pad part 2 +#define DISTORTION_TYPE_SONG_OF_TIME (1 << 5) // Song of Time effects +#define DISTORTION_TYPE_ZORA_KICK (1 << 6) // PLAYER_MWA_ZORA_PUNCH_KICK +#define DISTORTION_TYPE_UNK_ATTACK (1 << 7) // Impossible to achieve, inferred to be another `PLAYER_MWA_`, + +#define DISTORTION_TYPE_GORON_BUTT (1 << 8) // PLAYER_MWA_GORON_PUNCH_BUTT +#define DISTORTION_TYPE_MASK_TRANSFORM_1 (1 << 9) // Mask transformation part 1 +#define DISTORTION_TYPE_BOSS_WARP (1 << 10) // Boss warp pad part 3 +#define DISTORTION_TYPE_MASK_TRANSFORM_2 (1 << 11) // Mask transformation part 2 + +void Distortion_Request(s32 type); +void Distortion_SetDuration(s16 duration); + +s16 Distortion_GetTimeLeft(void); s16 Distortion_GetType(void); -void Distortion_SetType(s32 type); -void Distortion_ClearType(s32 type); +void Distortion_RemoveRequest(s32 type); + void Distortion_Init(PlayState* play); void Distortion_Update(void); diff --git a/include/z64save.h b/include/z64save.h index 23b220dde..88b63c57f 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -211,7 +211,7 @@ typedef struct PermanentSceneFlags { /* 0x08 */ u32 switch1; /* 0x0C */ u32 clearedRoom; /* 0x10 */ u32 collectible; - /* 0x14 */ u32 unk_14; // varies based on scene. For dungeons, floors visited. + /* 0x14 */ u32 unk_14; // varies based on scene. For dungeons, floors visited. /* 0x18 */ u32 rooms; } PermanentSceneFlags; // size = 0x1C @@ -252,68 +252,72 @@ typedef struct SavePlayerData { /* 0x26 */ s16 savedSceneId; // "scene_data_ID" } SavePlayerData; // size = 0x28 +typedef struct SaveInfo { + /* 0x000 */ SavePlayerData playerData; + /* 0x028 */ ItemEquips equips; + /* 0x04C */ Inventory inventory; + /* 0x0D4 */ PermanentSceneFlags permanentSceneFlags[120]; + /* 0xDF4 */ UNK_TYPE1 unk_DF4[0x54]; + /* 0xE48 */ u32 dekuPlaygroundHighScores[3]; + /* 0xE54 */ u32 pictoFlags0; // Flags set by `PictoActor`s if pictograph is valid + /* 0xE58 */ u32 pictoFlags1; // Flags set by Snap_ValidatePictograph() to record errors; volatile since that function is run many times in succession + /* 0xE5C */ u32 unk_E5C; + /* 0xE60 */ u32 unk_E60; + /* 0xE64 */ u32 unk_E64[7]; // Invadepoh flags + /* 0xE80 */ u32 scenesVisible[7]; // tingle maps and clouded regions on pause map. Stores scenes bitwise for up to 224 scenes even though there are not that many scenes + /* 0xE9C */ u32 skullTokenCount; // upper 16 bits store Swamp skulls, lower 16 bits store Ocean skulls + /* 0xEA0 */ u32 unk_EA0; // Gossic stone heart piece flags + /* 0xEA4 */ u32 unk_EA4; + /* 0xEA8 */ u32 unk_EA8[2]; // Related to blue warps + /* 0xEB0 */ u32 stolenItems; // Items stolen by Takkuri and given to Curiosity Shop Man + /* 0xEB4 */ u32 unk_EB4; + /* 0xEB8 */ u32 bankRupees; + /* 0xEBC */ u32 unk_EBC; + /* 0xEC0 */ u32 unk_EC0; // Fishing flags + /* 0xEC4 */ u32 unk_EC4; + /* 0xEC8 */ u32 horseBackBalloonHighScore; + /* 0xECC */ u32 lotteryCodeGuess; // Lottery code chosen by player (only uses lower three hex digits) + /* 0xED0 */ u32 shootingGalleryHighScores; // High scores for both shooting galleries. Town uses lower 16 bits, Swamp uses higher 16 bits. + /* 0xED4 */ u8 weekEventReg[100]; // "week_event_reg" + /* 0xF38 */ u32 regionsVisited; // "area_arrival" + /* 0xF3C */ u32 worldMapCloudVisibility; // "cloud_clear" + /* 0xF40 */ u8 unk_F40; // "oca_rec_flag" has scarecrows song + /* 0xF41 */ u8 unk_F41; // "oca_rec_flag8" scarecrows song set? + /* 0xF42 */ u8 scarecrowSpawnSong[128]; + /* 0xFC2 */ s8 bombersCaughtNum; // "aikotoba_index" + /* 0xFC3 */ s8 bombersCaughtOrder[5]; // "aikotoba_table" + /* 0xFC8 */ s8 lotteryCodes[3][3]; // "numbers_table", Preset lottery codes + /* 0xFD1 */ s8 spiderHouseMaskOrder[6]; // "kinsta_color_table" + /* 0xFD7 */ s8 bomberCode[5]; // "bombers_aikotoba_table" + /* 0xFDC */ HorseData horseData; + /* 0xFE6 */ u16 checksum; // "check_sum" +} SaveInfo; // size = 0xFE8 + typedef struct Save { - /* 0x0000 */ u32 entrance; // "scene_no" - /* 0x0004 */ u8 equippedMask; // "player_mask" - /* 0x0005 */ u8 isFirstCycle; // "opening_flag" - /* 0x0006 */ u8 unk_06; - /* 0x0007 */ u8 linkAge; // "link_age" - /* 0x0008 */ s32 cutscene; // "day_time" - /* 0x000C */ u16 time; // "zelda_time" - /* 0x000E */ u16 owlSaveLocation; - /* 0x0010 */ s32 isNight; // "asahiru_fg" - /* 0x0014 */ s32 timeSpeedOffset; // "change_zelda_time" - /* 0x0018 */ s32 day; // "totalday" - /* 0x001C */ s32 daysElapsed; // "eventday" - /* 0x0020 */ u8 playerForm; // "player_character" - /* 0x0021 */ u8 snowheadCleared; // "spring_flag" - /* 0x0022 */ u8 hasTatl; // "bell_flag" - /* 0x0023 */ u8 isOwlSave; - /* 0x0024 */ SavePlayerData playerData; - /* 0x004C */ ItemEquips equips; - /* 0x0070 */ Inventory inventory; - /* 0x00F8 */ PermanentSceneFlags permanentSceneFlags[120]; - /* 0x0E18 */ u8 unk_E18[0x54]; - /* 0x0E6C */ u32 dekuPlaygroundHighScores[3]; - /* 0x0E78 */ u32 pictoFlags0; // Flags set by `PictoActor`s if pictograph is valid - /* 0x0E7C */ u32 pictoFlags1; // Flags set by Snap_ValidatePictograph() to record errors; volatile since that function is run many times in succession - /* 0x0E80 */ u32 unk_E80; - /* 0x0E84 */ u32 unk_E84; - /* 0x0E88 */ u32 unk_E88[7]; // Invadepoh flags - /* 0x0EA4 */ u32 scenesVisible[7]; // tingle maps and clouded regions on pause map. Stores scenes bitwise for up to 224 scenes even though there are not that many scenes - /* 0x0EC0 */ u32 skullTokenCount; // upper 16 bits store Swamp skulls, lower 16 bits store Ocean skulls - /* 0x0EC4 */ u32 unk_EC4; // Gossic stone heart piece flags - /* 0x0EC8 */ u32 unk_EC8; - /* 0x0ECC */ u32 unk_ECC[2]; // Related to blue warps - /* 0x0ED4 */ u32 stolenItems; // Items stolen by Takkuri and given to Curiosity Shop Man - /* 0x0ED8 */ u32 unk_DD8; - /* 0x0EDC */ u32 bankRupees; - /* 0x0EE0 */ u32 unk_EE0; - /* 0x0EE4 */ u32 unk_EE4; // Fishing flags - /* 0x0EE8 */ u32 unk_EE8; - /* 0x0EEC */ u32 horseBackBalloonHighScore; - /* 0x0EF0 */ u32 lotteryCodeGuess; // Lottery code chosen by player (only uses lower three hex digits) - /* 0x0EF4 */ u32 shootingGalleryHighScores; // High scores for both shooting galleries. Town uses lower 16 bits, Swamp uses higher 16 bits. - /* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg" - /* 0x0F5C */ u32 regionsVisited; // "area_arrival" - /* 0x0F60 */ u32 worldMapCloudVisibility; // "cloud_clear" - /* 0x0F64 */ u8 unk_F64; // "oca_rec_flag" has scarecrows song - /* 0x0F65 */ u8 unk_F65; // "oca_rec_flag8" scarecrows song set? - /* 0x0F66 */ u8 scarecrowSpawnSong[128]; - /* 0x0FE6 */ s8 bombersCaughtNum; // "aikotoba_index" - /* 0x0FE7 */ s8 bombersCaughtOrder[5]; // "aikotoba_table" - /* 0x0FEC */ s8 lotteryCodes[3][3]; // "numbers_table", Preset lottery codes - /* 0x0FF5 */ s8 spiderHouseMaskOrder[6]; // "kinsta_color_table" - /* 0x0FFB */ s8 bomberCode[5]; // "bombers_aikotoba_table" - /* 0x1000 */ HorseData horseData; - /* 0x100A */ u16 checksum; // "check_sum" + /* 0x00 */ s32 entrance; // "scene_no" + /* 0x04 */ u8 equippedMask; // "player_mask" + /* 0x05 */ u8 isFirstCycle; // "opening_flag" + /* 0x06 */ u8 unk_06; + /* 0x07 */ u8 linkAge; // "link_age" + /* 0x08 */ s32 cutsceneIndex; // "day_time" + /* 0x0C */ u16 time; // "zelda_time" + /* 0x0E */ u16 owlSaveLocation; + /* 0x10 */ s32 isNight; // "asahiru_fg" + /* 0x14 */ s32 timeSpeedOffset; // "change_zelda_time" + /* 0x18 */ s32 day; // "totalday" + /* 0x1C */ s32 daysElapsed; // "eventday" + /* 0x20 */ u8 playerForm; // "player_character" + /* 0x21 */ u8 snowheadCleared; // "spring_flag" + /* 0x22 */ u8 hasTatl; // "bell_flag" + /* 0x23 */ u8 isOwlSave; + /* 0x24 */ SaveInfo saveInfo; } Save; // size = 0x100C typedef struct SaveContext { /* 0x0000 */ Save save; /* 0x100C */ u8 eventInf[8]; // "event_inf" /* 0x1014 */ u8 unk_1014; // "stone_set_flag" - /* 0x1015 */ u8 unk_1015; + /* 0x1015 */ u8 bButtonStatus; /* 0x1016 */ u16 jinxTimer; /* 0x1018 */ s16 rupeeAccumulator; // "lupy_udct" /* 0x101A */ u8 bottleTimerStates[BOTTLE_MAX]; // See the `BottleTimerState` enum. "bottle_status" @@ -406,6 +410,14 @@ typedef enum SunsSongState { /* 3 */ SUNSSONG_SPECIAL // time does not advance, but signals the song was played. used for freezing redeads } SunsSongState; +typedef enum { + /* 0 */ GAMEMODE_NORMAL, + /* 1 */ GAMEMODE_TITLE_SCREEN, + /* 2 */ GAMEMODE_FILE_SELECT, + /* 3 */ GAMEMODE_END_CREDITS, + /* 4 */ GAMEMODE_OWL_SAVE +} GameMode; + // 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 #define LINK_IS_CHILD (gSaveContext.save.linkAge == 1) @@ -421,42 +433,42 @@ typedef enum SunsSongState { #define GET_PLAYER_FORM ((void)0, gSaveContext.save.playerForm) #define SLOT(item) gItemSlots[item] -#define AMMO(item) gSaveContext.save.inventory.ammo[SLOT(item)] -#define INV_CONTENT(item) gSaveContext.save.inventory.items[SLOT(item)] -#define GET_INV_CONTENT(item) ((void)0, gSaveContext.save.inventory.items)[SLOT(item)] +#define AMMO(item) gSaveContext.save.saveInfo.inventory.ammo[SLOT(item)] +#define INV_CONTENT(item) gSaveContext.save.saveInfo.inventory.items[SLOT(item)] +#define GET_INV_CONTENT(item) ((void)0, gSaveContext.save.saveInfo.inventory.items)[SLOT(item)] #define CUR_FORM ((gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) ? 0 : gSaveContext.save.playerForm) -#define GET_SAVE_EQUIPS_EQUIPMENT ((void)0, gSaveContext.save.equips.equipment) -#define GET_SAVE_INVENTORY_UPGRADES ((void)0, gSaveContext.save.inventory.upgrades) -#define GET_SAVE_INVENTORY_QUEST_ITEMS ((void)0, gSaveContext.save.inventory.questItems) +#define GET_SAVE_EQUIPS_EQUIPMENT ((void)0, gSaveContext.save.saveInfo.equips.equipment) +#define GET_SAVE_INVENTORY_UPGRADES ((void)0, gSaveContext.save.saveInfo.inventory.upgrades) +#define GET_SAVE_INVENTORY_QUEST_ITEMS ((void)0, gSaveContext.save.saveInfo.inventory.questItems) #define GET_CUR_EQUIP_VALUE(equip) ((GET_SAVE_EQUIPS_EQUIPMENT & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_UPG_VALUE(upg) ((gSaveContext.save.inventory.upgrades & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) +#define CUR_UPG_VALUE(upg) ((gSaveContext.save.saveInfo.inventory.upgrades & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) #define GET_CUR_UPG_VALUE(upg) ((GET_SAVE_INVENTORY_UPGRADES & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) -#define SET_EQUIP_VALUE(equip, value) (gSaveContext.save.equips.equipment = ((GET_SAVE_EQUIPS_EQUIPMENT & gEquipNegMasks[equip]) | (u16)((u16)(value) << gEquipShifts[equip]))) +#define SET_EQUIP_VALUE(equip, value) (gSaveContext.save.saveInfo.equips.equipment = ((GET_SAVE_EQUIPS_EQUIPMENT & gEquipNegMasks[equip]) | (u16)((u16)(value) << gEquipShifts[equip]))) -#define BUTTON_ITEM_EQUIP(form, button) (gSaveContext.save.equips.buttonItems[form][button]) +#define BUTTON_ITEM_EQUIP(form, button) (gSaveContext.save.saveInfo.equips.buttonItems[form][button]) #define CUR_FORM_EQUIP(button) BUTTON_ITEM_EQUIP(CUR_FORM, button) -#define C_SLOT_EQUIP(form, button) (gSaveContext.save.equips.cButtonSlots[form][button]) +#define C_SLOT_EQUIP(form, button) (gSaveContext.save.saveInfo.equips.cButtonSlots[form][button]) #define CHECK_QUEST_ITEM(item) (GET_SAVE_INVENTORY_QUEST_ITEMS & gBitFlags[item]) -#define SET_QUEST_ITEM(item) (gSaveContext.save.inventory.questItems = (GET_SAVE_INVENTORY_QUEST_ITEMS | gBitFlags[item])) -#define REMOVE_QUEST_ITEM(item) (gSaveContext.save.inventory.questItems = (GET_SAVE_INVENTORY_QUEST_ITEMS & (-1 - gBitFlags[item]))) +#define SET_QUEST_ITEM(item) (gSaveContext.save.saveInfo.inventory.questItems = (GET_SAVE_INVENTORY_QUEST_ITEMS | gBitFlags[item])) +#define REMOVE_QUEST_ITEM(item) (gSaveContext.save.saveInfo.inventory.questItems = (GET_SAVE_INVENTORY_QUEST_ITEMS & (-1 - gBitFlags[item]))) #define GET_QUEST_HEART_PIECE_COUNT ((GET_SAVE_INVENTORY_QUEST_ITEMS & 0xF0000000) >> QUEST_HEART_PIECE_COUNT) #define EQ_MAX_QUEST_HEART_PIECE_COUNT ((GET_SAVE_INVENTORY_QUEST_ITEMS & 0xF0000000) == (4 << QUEST_HEART_PIECE_COUNT)) #define LEQ_MAX_QUEST_HEART_PIECE_COUNT ((GET_SAVE_INVENTORY_QUEST_ITEMS & 0xF0000000) <= (4 << QUEST_HEART_PIECE_COUNT)) -#define INCREMENT_QUEST_HEART_PIECE_COUNT (gSaveContext.save.inventory.questItems += (1 << QUEST_HEART_PIECE_COUNT)) -#define DECREMENT_QUEST_HEART_PIECE_COUNT (gSaveContext.save.inventory.questItems -= (1 << QUEST_HEART_PIECE_COUNT)) -#define RESET_HEART_PIECE_COUNT (gSaveContext.save.inventory.questItems ^= (4 << QUEST_HEART_PIECE_COUNT)) +#define INCREMENT_QUEST_HEART_PIECE_COUNT (gSaveContext.save.saveInfo.inventory.questItems += (1 << QUEST_HEART_PIECE_COUNT)) +#define DECREMENT_QUEST_HEART_PIECE_COUNT (gSaveContext.save.saveInfo.inventory.questItems -= (1 << QUEST_HEART_PIECE_COUNT)) +#define RESET_HEART_PIECE_COUNT (gSaveContext.save.saveInfo.inventory.questItems ^= (4 << QUEST_HEART_PIECE_COUNT)) -#define CHECK_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.save.inventory.dungeonItems[(void)0, dungeonIndex] & gBitFlags[item]) -#define CHECK_DUNGEON_ITEM2(item, dungeonIndex) (gSaveContext.save.inventory.dungeonItems[dungeonIndex] & gBitFlags[item]) -#define SET_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.save.inventory.dungeonItems[(void)0, dungeonIndex] |= (u8)gBitFlags[item]) -#define DUNGEON_KEY_COUNT(dungeonIndex) (gSaveContext.save.inventory.dungeonKeys[(void)0, dungeonIndex]) +#define CHECK_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.save.saveInfo.inventory.dungeonItems[(void)0, dungeonIndex] & gBitFlags[item]) +#define CHECK_DUNGEON_ITEM2(item, dungeonIndex) (gSaveContext.save.saveInfo.inventory.dungeonItems[dungeonIndex] & gBitFlags[item]) +#define SET_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.save.saveInfo.inventory.dungeonItems[(void)0, dungeonIndex] |= (u8)gBitFlags[item]) +#define DUNGEON_KEY_COUNT(dungeonIndex) (gSaveContext.save.saveInfo.inventory.dungeonKeys[(void)0, dungeonIndex]) #define GET_CUR_FORM_BTN_ITEM(btn) ((u8)((btn) == EQUIP_SLOT_B ? BUTTON_ITEM_EQUIP(CUR_FORM, btn) : BUTTON_ITEM_EQUIP(0, btn))) #define GET_CUR_FORM_BTN_SLOT(btn) ((u8)((btn) == EQUIP_SLOT_B ? C_SLOT_EQUIP(CUR_FORM, btn) : C_SLOT_EQUIP(0, btn))) @@ -484,56 +496,63 @@ typedef enum SunsSongState { #define STOLEN_ITEM_NONE (0) -#define STOLEN_ITEM_1 ((gSaveContext.save.stolenItems & 0xFF000000) >> 0x18) -#define STOLEN_ITEM_2 ((gSaveContext.save.stolenItems & 0x00FF0000) >> 0x10) +#define STOLEN_ITEM_1 ((gSaveContext.save.saveInfo.stolenItems & 0xFF000000) >> 0x18) +#define STOLEN_ITEM_2 ((gSaveContext.save.saveInfo.stolenItems & 0x00FF0000) >> 0x10) #define SET_STOLEN_ITEM_1(itemId) \ - (gSaveContext.save.stolenItems = (gSaveContext.save.stolenItems & ~0xFF000000) | ((itemId & 0xFF) << 0x18)) + (gSaveContext.save.saveInfo.stolenItems = (gSaveContext.save.saveInfo.stolenItems & ~0xFF000000) | ((itemId & 0xFF) << 0x18)) #define SET_STOLEN_ITEM_2(itemId) \ - (gSaveContext.save.stolenItems = (gSaveContext.save.stolenItems & ~0x00FF0000) | ((itemId & 0xFF) << 0x10)) + (gSaveContext.save.saveInfo.stolenItems = (gSaveContext.save.saveInfo.stolenItems & ~0x00FF0000) | ((itemId & 0xFF) << 0x10)) -#define GET_TOWN_SHOOTING_GALLERY_HIGH_SCORE() ((s32)(gSaveContext.save.shootingGalleryHighScores & 0xFFFF)) -#define GET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE() ((s32)((gSaveContext.save.shootingGalleryHighScores & 0xFFFF0000) >> 0x10)) -#define SET_TOWN_SHOOTING_GALLERY_HIGH_SCORE(score) (gSaveContext.save.shootingGalleryHighScores = (gSaveContext.save.shootingGalleryHighScores & 0xFFFF0000) | ((u16)(score))) -#define SET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE(score) (gSaveContext.save.shootingGalleryHighScores = ((gSaveContext.save.shootingGalleryHighScores) & 0xFFFF) | ((u16)(score) << 0x10)) +#define GET_TOWN_SHOOTING_GALLERY_HIGH_SCORE() ((s32)(gSaveContext.save.saveInfo.shootingGalleryHighScores & 0xFFFF)) +#define GET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE() ((s32)((gSaveContext.save.saveInfo.shootingGalleryHighScores & 0xFFFF0000) >> 0x10)) +#define SET_TOWN_SHOOTING_GALLERY_HIGH_SCORE(score) (gSaveContext.save.saveInfo.shootingGalleryHighScores = (gSaveContext.save.saveInfo.shootingGalleryHighScores & 0xFFFF0000) | ((u16)(score))) +#define SET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE(score) (gSaveContext.save.saveInfo.shootingGalleryHighScores = ((gSaveContext.save.saveInfo.shootingGalleryHighScores) & 0xFFFF) | ((u16)(score) << 0x10)) /** - * gSaveContext.save.weekEventReg + * gSaveContext.save.saveInfo.weekEventReg */ #define PACK_WEEKEVENTREG_FLAG(index, mask) (((index) << 8) | (mask)) #define WEEKEVENTREG_00_01 PACK_WEEKEVENTREG_FLAG(0, 0x01) -#define WEEKEVENTREG_00_02 PACK_WEEKEVENTREG_FLAG(0, 0x02) -#define WEEKEVENTREG_00_04 PACK_WEEKEVENTREG_FLAG(0, 0x04) -#define WEEKEVENTREG_00_08 PACK_WEEKEVENTREG_FLAG(0, 0x08) -#define WEEKEVENTREG_00_10 PACK_WEEKEVENTREG_FLAG(0, 0x10) -#define WEEKEVENTREG_00_20 PACK_WEEKEVENTREG_FLAG(0, 0x20) -#define WEEKEVENTREG_00_40 PACK_WEEKEVENTREG_FLAG(0, 0x40) -#define WEEKEVENTREG_00_80 PACK_WEEKEVENTREG_FLAG(0, 0x80) -#define WEEKEVENTREG_01_01 PACK_WEEKEVENTREG_FLAG(1, 0x01) -#define WEEKEVENTREG_01_02 PACK_WEEKEVENTREG_FLAG(1, 0x02) -#define WEEKEVENTREG_01_04 PACK_WEEKEVENTREG_FLAG(1, 0x04) -#define WEEKEVENTREG_01_08 PACK_WEEKEVENTREG_FLAG(1, 0x08) -#define WEEKEVENTREG_01_10 PACK_WEEKEVENTREG_FLAG(1, 0x10) -#define WEEKEVENTREG_01_20 PACK_WEEKEVENTREG_FLAG(1, 0x20) -#define WEEKEVENTREG_01_40 PACK_WEEKEVENTREG_FLAG(1, 0x40) -#define WEEKEVENTREG_01_80 PACK_WEEKEVENTREG_FLAG(1, 0x80) -#define WEEKEVENTREG_02_01 PACK_WEEKEVENTREG_FLAG(2, 0x01) -#define WEEKEVENTREG_02_02 PACK_WEEKEVENTREG_FLAG(2, 0x02) -#define WEEKEVENTREG_02_04 PACK_WEEKEVENTREG_FLAG(2, 0x04) -#define WEEKEVENTREG_02_08 PACK_WEEKEVENTREG_FLAG(2, 0x08) -#define WEEKEVENTREG_02_10 PACK_WEEKEVENTREG_FLAG(2, 0x10) -#define WEEKEVENTREG_02_20 PACK_WEEKEVENTREG_FLAG(2, 0x20) -#define WEEKEVENTREG_02_40 PACK_WEEKEVENTREG_FLAG(2, 0x40) -#define WEEKEVENTREG_02_80 PACK_WEEKEVENTREG_FLAG(2, 0x80) -#define WEEKEVENTREG_03_01 PACK_WEEKEVENTREG_FLAG(3, 0x01) -#define WEEKEVENTREG_03_02 PACK_WEEKEVENTREG_FLAG(3, 0x02) -#define WEEKEVENTREG_03_04 PACK_WEEKEVENTREG_FLAG(3, 0x04) -#define WEEKEVENTREG_03_08 PACK_WEEKEVENTREG_FLAG(3, 0x08) -#define WEEKEVENTREG_03_10 PACK_WEEKEVENTREG_FLAG(3, 0x10) -#define WEEKEVENTREG_03_20 PACK_WEEKEVENTREG_FLAG(3, 0x20) -#define WEEKEVENTREG_03_40 PACK_WEEKEVENTREG_FLAG(3, 0x40) + +/* Entrance cutscenes watched */ + +#define WEEKEVENTREG_ENTERED_TERMINA_FIELD PACK_WEEKEVENTREG_FLAG(0, 0x02) +#define WEEKEVENTREG_ENTERED_IKANA_GRAVEYARD PACK_WEEKEVENTREG_FLAG(0, 0x04) +#define WEEKEVENTREG_ENTERED_ROMANI_RANCH PACK_WEEKEVENTREG_FLAG(0, 0x08) +#define WEEKEVENTREG_ENTERED_GORMAN_TRACK PACK_WEEKEVENTREG_FLAG(0, 0x10) +#define WEEKEVENTREG_ENTERED_MOUNTAIN_VILLAGE_WINTER PACK_WEEKEVENTREG_FLAG(0, 0x20) +#define WEEKEVENTREG_ENTERED_GORON_SHRINE PACK_WEEKEVENTREG_FLAG(0, 0x40) +#define WEEKEVENTREG_ENTERED_SNOWHEAD PACK_WEEKEVENTREG_FLAG(0, 0x80) +#define WEEKEVENTREG_ENTERED_SOUTHERN_SWAMP_POISONED PACK_WEEKEVENTREG_FLAG(1, 0x01) +#define WEEKEVENTREG_ENTERED_WOODFALL PACK_WEEKEVENTREG_FLAG(1, 0x02) +#define WEEKEVENTREG_ENTERED_DEKU_PALACE PACK_WEEKEVENTREG_FLAG(1, 0x04) +#define WEEKEVENTREG_ENTERED_GREAT_BAY_COAST PACK_WEEKEVENTREG_FLAG(1, 0x08) +#define WEEKEVENTREG_ENTERED_PIRATES_FORTRESS PACK_WEEKEVENTREG_FLAG(1, 0x10) +#define WEEKEVENTREG_ENTERED_ZORA_HALL PACK_WEEKEVENTREG_FLAG(1, 0x20) +#define WEEKEVENTREG_ENTERED_WATERFALL_RAPIDS PACK_WEEKEVENTREG_FLAG(1, 0x40) +#define WEEKEVENTREG_ENTERED_IKANA_CANYON PACK_WEEKEVENTREG_FLAG(1, 0x80) +// Attached to the scene but unused. Entrance cutscene is instead triggered by `ACTOR_OBJ_DEMO` +#define WEEKEVENTREG_ENTERED_IKANA_CASTLE PACK_WEEKEVENTREG_FLAG(2, 0x01) +#define WEEKEVENTREG_ENTERED_STONE_TOWER PACK_WEEKEVENTREG_FLAG(2, 0x02) +#define WEEKEVENTREG_ENTERED_STONE_TOWER_INVERTED PACK_WEEKEVENTREG_FLAG(2, 0x04) +#define WEEKEVENTREG_ENTERED_EAST_CLOCK_TOWN PACK_WEEKEVENTREG_FLAG(2, 0x08) +#define WEEKEVENTREG_ENTERED_WEST_CLOCK_TOWN PACK_WEEKEVENTREG_FLAG(2, 0x10) +#define WEEKEVENTREG_ENTERED_NORTH_CLOCK_TOWN PACK_WEEKEVENTREG_FLAG(2, 0x20) +#define WEEKEVENTREG_ENTERED_WOODFALL_TEMPLE PACK_WEEKEVENTREG_FLAG(2, 0x40) +#define WEEKEVENTREG_ENTERED_SNOWHEAD_TEMPLE PACK_WEEKEVENTREG_FLAG(2, 0x80) +// Attached to the scene but unused. Entrance cutscene is instead triggered by `ACTOR_OBJ_DEMO` +#define WEEKEVENTREG_ENTERED_PIRATES_FORTRESS_EXTERIOR PACK_WEEKEVENTREG_FLAG(3, 0x01) +#define WEEKEVENTREG_ENTERED_STONE_TOWER_TEMPLE PACK_WEEKEVENTREG_FLAG(3, 0x02) +#define WEEKEVENTREG_ENTERED_STONE_TOWER_TEMPLE_INVERTED PACK_WEEKEVENTREG_FLAG(3, 0x04) +// Unused as no cutscene is attached to this script +#define WEEKEVENTREG_ENTERED_THE_MOON PACK_WEEKEVENTREG_FLAG(3, 0x08) +#define WEEKEVENTREG_ENTERED_MOON_DEKU_TRIAL PACK_WEEKEVENTREG_FLAG(3, 0x10) +#define WEEKEVENTREG_ENTERED_MOON_GORON_TRIAL PACK_WEEKEVENTREG_FLAG(3, 0x20) +#define WEEKEVENTREG_ENTERED_MOON_ZORA_TRIAL PACK_WEEKEVENTREG_FLAG(3, 0x40) + #define WEEKEVENTREG_03_80 PACK_WEEKEVENTREG_FLAG(3, 0x80) #define WEEKEVENTREG_04_01 PACK_WEEKEVENTREG_FLAG(4, 0x01) #define WEEKEVENTREG_04_02 PACK_WEEKEVENTREG_FLAG(4, 0x02) @@ -566,14 +585,21 @@ typedef enum SunsSongState { #define WEEKEVENTREG_07_10 PACK_WEEKEVENTREG_FLAG(7, 0x10) #define WEEKEVENTREG_07_20 PACK_WEEKEVENTREG_FLAG(7, 0x20) #define WEEKEVENTREG_07_40 PACK_WEEKEVENTREG_FLAG(7, 0x40) -#define WEEKEVENTREG_07_80 PACK_WEEKEVENTREG_FLAG(7, 0x80) + +// Entrance cutscene watched to the prison where the deku princess is kept. Also set in door_warp1.c +#define WEEKEVENTREG_ENTERED_WOODFALL_TEMPLE_PRISON PACK_WEEKEVENTREG_FLAG(7, 0x80) + +// Related to Honey & Darling minigame #define WEEKEVENTREG_08_01 PACK_WEEKEVENTREG_FLAG(8, 0x01) #define WEEKEVENTREG_08_02 PACK_WEEKEVENTREG_FLAG(8, 0x02) #define WEEKEVENTREG_08_04 PACK_WEEKEVENTREG_FLAG(8, 0x04) #define WEEKEVENTREG_08_08 PACK_WEEKEVENTREG_FLAG(8, 0x08) #define WEEKEVENTREG_08_10 PACK_WEEKEVENTREG_FLAG(8, 0x10) -#define WEEKEVENTREG_08_20 PACK_WEEKEVENTREG_FLAG(8, 0x20) +#define WEEKEVENTREG_RECEIVED_DOGGY_RACETRACK_HEART_PIECE PACK_WEEKEVENTREG_FLAG(8, 0x20) + +// Related to final hours #define WEEKEVENTREG_08_40 PACK_WEEKEVENTREG_FLAG(8, 0x40) + #define WEEKEVENTREG_08_80 PACK_WEEKEVENTREG_FLAG(8, 0x80) #define WEEKEVENTREG_09_01 PACK_WEEKEVENTREG_FLAG(9, 0x01) #define WEEKEVENTREG_09_02 PACK_WEEKEVENTREG_FLAG(9, 0x02) @@ -615,9 +641,18 @@ typedef enum SunsSongState { #define WEEKEVENTREG_13_04 PACK_WEEKEVENTREG_FLAG(13, 0x04) #define WEEKEVENTREG_13_08 PACK_WEEKEVENTREG_FLAG(13, 0x08) #define WEEKEVENTREG_13_10 PACK_WEEKEVENTREG_FLAG(13, 0x10) -#define WEEKEVENTREG_13_20 PACK_WEEKEVENTREG_FLAG(13, 0x20) -#define WEEKEVENTREG_13_40 PACK_WEEKEVENTREG_FLAG(13, 0x40) -#define WEEKEVENTREG_13_80 PACK_WEEKEVENTREG_FLAG(13, 0x80) + +// This flag marks that the player has finished the Oceanside Spider House and has exited. +// Used to identify if EnSth should be moved deeper into the house. +// This does NOT flag: +// A) that the player has completed the house (Inventory_GetSkullTokenCount(play->sceneId)) +// B) that the player has collected a reward (WEEKEVENTREG_OCEANSIDE_SPIDER_HOUSE_COLLECTED_REWARD) +// C) that the player has collected the wallet (WEEKEVENTREG_RECEIVED_OCEANSIDE_WALLET_UPGRADE) +#define WEEKEVENTREG_OCEANSIDE_SPIDER_HOUSE_BUYER_MOVED_IN PACK_WEEKEVENTREG_FLAG(13, 0x20) + +#define WEEKEVENTREG_RECEIVED_OCEANSIDE_WALLET_UPGRADE PACK_WEEKEVENTREG_FLAG(13, 0x40) +// You only get a wallet if completed on Day 1: repeat gets silver rupee, other days get less +#define WEEKEVENTREG_OCEANSIDE_SPIDER_HOUSE_COLLECTED_REWARD PACK_WEEKEVENTREG_FLAG(13, 0x80) // PlayedMilkMinigame // Attempted Cremia Cart Ride @@ -673,7 +708,7 @@ typedef enum SunsSongState { #define WEEKEVENTREG_20_01 PACK_WEEKEVENTREG_FLAG(20, 0x01) // woodfall temple purification cutscene watched -#define WEEKEVENTREG_20_02 PACK_WEEKEVENTREG_FLAG(20, 0x02) +#define WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE PACK_WEEKEVENTREG_FLAG(20, 0x02) #define WEEKEVENTREG_20_04 PACK_WEEKEVENTREG_FLAG(20, 0x04) #define WEEKEVENTREG_20_08 PACK_WEEKEVENTREG_FLAG(20, 0x08) @@ -786,6 +821,9 @@ typedef enum SunsSongState { #define WEEKEVENTREG_31_10 PACK_WEEKEVENTREG_FLAG(31, 0x10) #define WEEKEVENTREG_31_20 PACK_WEEKEVENTREG_FLAG(31, 0x20) +//! @note: entrance cutscenes defined in `CutsceneEntry` can not use +//! any of the below weekEventFlags due to bitpacking + // Cremia asked the player to accompany her to town #define WEEKEVENTREG_31_40 PACK_WEEKEVENTREG_FLAG(31, 0x40) // Player is playing the Milk Run @@ -814,16 +852,16 @@ typedef enum SunsSongState { #define WEEKEVENTREG_33_40 PACK_WEEKEVENTREG_FLAG(33, 0x40) // Mountain village is unfrozen -#define WEEKEVENTREG_33_80 PACK_WEEKEVENTREG_FLAG(33, 0x80) +#define WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE PACK_WEEKEVENTREG_FLAG(33, 0x80) // Spoken to MINIFROG_YELLOW #define WEEKEVENTREG_34_01 PACK_WEEKEVENTREG_FLAG(34, 0x01) #define WEEKEVENTREG_34_02 PACK_WEEKEVENTREG_FLAG(34, 0x02) #define WEEKEVENTREG_34_04 PACK_WEEKEVENTREG_FLAG(34, 0x04) -#define WEEKEVENTREG_34_08 PACK_WEEKEVENTREG_FLAG(34, 0x08) +#define WEEKEVENTREG_TALKED_SWAMP_SPIDER_HOUSE_MAN PACK_WEEKEVENTREG_FLAG(34, 0x08) #define WEEKEVENTREG_34_10 PACK_WEEKEVENTREG_FLAG(34, 0x10) #define WEEKEVENTREG_34_20 PACK_WEEKEVENTREG_FLAG(34, 0x20) -#define WEEKEVENTREG_34_40 PACK_WEEKEVENTREG_FLAG(34, 0x40) +#define WEEKEVENTREG_RECEIVED_MASK_OF_TRUTH PACK_WEEKEVENTREG_FLAG(34, 0x40) // Cremia did Milk Run alone. Player didn't interact or didn't accept the ride #define WEEKEVENTREG_34_80 PACK_WEEKEVENTREG_FLAG(34, 0x80) @@ -887,62 +925,11 @@ typedef enum SunsSongState { #define WEEKEVENTREG_41_20 PACK_WEEKEVENTREG_FLAG(41, 0x20) #define WEEKEVENTREG_41_40 PACK_WEEKEVENTREG_FLAG(41, 0x40) #define WEEKEVENTREG_41_80 PACK_WEEKEVENTREG_FLAG(41, 0x80) -#define WEEKEVENTREG_42_01 PACK_WEEKEVENTREG_FLAG(42, 0x01) -#define WEEKEVENTREG_42_02 PACK_WEEKEVENTREG_FLAG(42, 0x02) -#define WEEKEVENTREG_42_04 PACK_WEEKEVENTREG_FLAG(42, 0x04) -#define WEEKEVENTREG_42_08 PACK_WEEKEVENTREG_FLAG(42, 0x08) -#define WEEKEVENTREG_42_10 PACK_WEEKEVENTREG_FLAG(42, 0x10) -#define WEEKEVENTREG_42_20 PACK_WEEKEVENTREG_FLAG(42, 0x20) -#define WEEKEVENTREG_42_40 PACK_WEEKEVENTREG_FLAG(42, 0x40) -#define WEEKEVENTREG_42_80 PACK_WEEKEVENTREG_FLAG(42, 0x80) -#define WEEKEVENTREG_43_01 PACK_WEEKEVENTREG_FLAG(43, 0x01) -#define WEEKEVENTREG_43_02 PACK_WEEKEVENTREG_FLAG(43, 0x02) -#define WEEKEVENTREG_43_04 PACK_WEEKEVENTREG_FLAG(43, 0x04) -#define WEEKEVENTREG_43_08 PACK_WEEKEVENTREG_FLAG(43, 0x08) -#define WEEKEVENTREG_43_10 PACK_WEEKEVENTREG_FLAG(43, 0x10) -#define WEEKEVENTREG_43_20 PACK_WEEKEVENTREG_FLAG(43, 0x20) -#define WEEKEVENTREG_43_40 PACK_WEEKEVENTREG_FLAG(43, 0x40) -#define WEEKEVENTREG_43_80 PACK_WEEKEVENTREG_FLAG(43, 0x80) -#define WEEKEVENTREG_44_01 PACK_WEEKEVENTREG_FLAG(44, 0x01) -#define WEEKEVENTREG_44_02 PACK_WEEKEVENTREG_FLAG(44, 0x02) -#define WEEKEVENTREG_44_04 PACK_WEEKEVENTREG_FLAG(44, 0x04) -#define WEEKEVENTREG_44_08 PACK_WEEKEVENTREG_FLAG(44, 0x08) -#define WEEKEVENTREG_44_10 PACK_WEEKEVENTREG_FLAG(44, 0x10) -#define WEEKEVENTREG_44_20 PACK_WEEKEVENTREG_FLAG(44, 0x20) -#define WEEKEVENTREG_44_40 PACK_WEEKEVENTREG_FLAG(44, 0x40) -#define WEEKEVENTREG_44_80 PACK_WEEKEVENTREG_FLAG(44, 0x80) -#define WEEKEVENTREG_45_01 PACK_WEEKEVENTREG_FLAG(45, 0x01) -#define WEEKEVENTREG_45_02 PACK_WEEKEVENTREG_FLAG(45, 0x02) -#define WEEKEVENTREG_45_04 PACK_WEEKEVENTREG_FLAG(45, 0x04) -#define WEEKEVENTREG_45_08 PACK_WEEKEVENTREG_FLAG(45, 0x08) -#define WEEKEVENTREG_45_10 PACK_WEEKEVENTREG_FLAG(45, 0x10) -#define WEEKEVENTREG_45_20 PACK_WEEKEVENTREG_FLAG(45, 0x20) -#define WEEKEVENTREG_45_40 PACK_WEEKEVENTREG_FLAG(45, 0x40) -#define WEEKEVENTREG_45_80 PACK_WEEKEVENTREG_FLAG(45, 0x80) -#define WEEKEVENTREG_46_01 PACK_WEEKEVENTREG_FLAG(46, 0x01) -#define WEEKEVENTREG_46_02 PACK_WEEKEVENTREG_FLAG(46, 0x02) -#define WEEKEVENTREG_46_04 PACK_WEEKEVENTREG_FLAG(46, 0x04) -#define WEEKEVENTREG_46_08 PACK_WEEKEVENTREG_FLAG(46, 0x08) -#define WEEKEVENTREG_46_10 PACK_WEEKEVENTREG_FLAG(46, 0x10) -#define WEEKEVENTREG_46_20 PACK_WEEKEVENTREG_FLAG(46, 0x20) -#define WEEKEVENTREG_46_40 PACK_WEEKEVENTREG_FLAG(46, 0x40) -#define WEEKEVENTREG_46_80 PACK_WEEKEVENTREG_FLAG(46, 0x80) -#define WEEKEVENTREG_47_01 PACK_WEEKEVENTREG_FLAG(47, 0x01) -#define WEEKEVENTREG_47_02 PACK_WEEKEVENTREG_FLAG(47, 0x02) -#define WEEKEVENTREG_47_04 PACK_WEEKEVENTREG_FLAG(47, 0x04) -#define WEEKEVENTREG_47_08 PACK_WEEKEVENTREG_FLAG(47, 0x08) -#define WEEKEVENTREG_47_10 PACK_WEEKEVENTREG_FLAG(47, 0x10) -#define WEEKEVENTREG_47_20 PACK_WEEKEVENTREG_FLAG(47, 0x20) -#define WEEKEVENTREG_47_40 PACK_WEEKEVENTREG_FLAG(47, 0x40) -#define WEEKEVENTREG_47_80 PACK_WEEKEVENTREG_FLAG(47, 0x80) -#define WEEKEVENTREG_48_01 PACK_WEEKEVENTREG_FLAG(48, 0x01) -#define WEEKEVENTREG_48_02 PACK_WEEKEVENTREG_FLAG(48, 0x02) -#define WEEKEVENTREG_48_04 PACK_WEEKEVENTREG_FLAG(48, 0x04) -#define WEEKEVENTREG_48_08 PACK_WEEKEVENTREG_FLAG(48, 0x08) -#define WEEKEVENTREG_48_10 PACK_WEEKEVENTREG_FLAG(48, 0x10) -#define WEEKEVENTREG_48_20 PACK_WEEKEVENTREG_FLAG(48, 0x20) -#define WEEKEVENTREG_48_40 PACK_WEEKEVENTREG_FLAG(48, 0x40) -#define WEEKEVENTREG_48_80 PACK_WEEKEVENTREG_FLAG(48, 0x80) + +// Used for storing the text ID offsets for the dogs in the Doggy Racetrack (56 entries) +// The number of weekEventRegs used needs to be kept in sync with RACEDOG_COUNT in z_en_aob_01.h +// PACK_WEEKEVENTREG_FLAG(42, 0x01) to PACK_WEEKEVENTREG_FLAG(48, 0x80) + #define WEEKEVENTREG_49_01 PACK_WEEKEVENTREG_FLAG(49, 0x01) #define WEEKEVENTREG_49_02 PACK_WEEKEVENTREG_FLAG(49, 0x02) #define WEEKEVENTREG_49_04 PACK_WEEKEVENTREG_FLAG(49, 0x04) @@ -976,10 +963,7 @@ typedef enum SunsSongState { #define WEEKEVENTREG_52_04 PACK_WEEKEVENTREG_FLAG(52, 0x04) #define WEEKEVENTREG_52_08 PACK_WEEKEVENTREG_FLAG(52, 0x08) #define WEEKEVENTREG_52_10 PACK_WEEKEVENTREG_FLAG(52, 0x10) - -// cleared Stone Tower Temple -#define WEEKEVENTREG_52_20 PACK_WEEKEVENTREG_FLAG(52, 0x20) - +#define WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE PACK_WEEKEVENTREG_FLAG(52, 0x20) #define WEEKEVENTREG_52_40 PACK_WEEKEVENTREG_FLAG(52, 0x40) #define WEEKEVENTREG_52_80 PACK_WEEKEVENTREG_FLAG(52, 0x80) #define WEEKEVENTREG_53_01 PACK_WEEKEVENTREG_FLAG(53, 0x01) @@ -1010,7 +994,7 @@ typedef enum SunsSongState { #define WEEKEVENTREG_55_40 PACK_WEEKEVENTREG_FLAG(55, 0x40) // Gyorg has been defeated -#define WEEKEVENTREG_55_80 PACK_WEEKEVENTREG_FLAG(55, 0x80) +#define WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE PACK_WEEKEVENTREG_FLAG(55, 0x80) #define WEEKEVENTREG_56_01 PACK_WEEKEVENTREG_FLAG(56, 0x01) #define WEEKEVENTREG_56_02 PACK_WEEKEVENTREG_FLAG(56, 0x02) @@ -1071,8 +1055,12 @@ typedef enum SunsSongState { #define WEEKEVENTREG_62_20 PACK_WEEKEVENTREG_FLAG(62, 0x20) #define WEEKEVENTREG_62_40 PACK_WEEKEVENTREG_FLAG(62, 0x40) #define WEEKEVENTREG_62_80 PACK_WEEKEVENTREG_FLAG(62, 0x80) -#define WEEKEVENTREG_63_01 PACK_WEEKEVENTREG_FLAG(63, 0x01) -#define WEEKEVENTREG_63_02 PACK_WEEKEVENTREG_FLAG(63, 0x02) + +// See `EnTimeTag_KickOut_WaitForTime` and `EnTimeTag_KickOut_WaitForTrigger` +#define WEEKEVENTREG_KICKOUT_WAIT PACK_WEEKEVENTREG_FLAG(63, 0x01) +// See `EnTimeTag_KickOut_WaitForTime` and `EnTimeTag_KickOut_WaitForTrigger` +#define WEEKEVENTREG_KICKOUT_TIME_PASSED PACK_WEEKEVENTREG_FLAG(63, 0x02) + #define WEEKEVENTREG_63_04 PACK_WEEKEVENTREG_FLAG(63, 0x04) #define WEEKEVENTREG_63_08 PACK_WEEKEVENTREG_FLAG(63, 0x08) #define WEEKEVENTREG_63_10 PACK_WEEKEVENTREG_FLAG(63, 0x10) @@ -1089,12 +1077,12 @@ typedef enum SunsSongState { #define WEEKEVENTREG_64_10 PACK_WEEKEVENTREG_FLAG(64, 0x10) #define WEEKEVENTREG_64_20 PACK_WEEKEVENTREG_FLAG(64, 0x20) #define WEEKEVENTREG_64_40 PACK_WEEKEVENTREG_FLAG(64, 0x40) -#define WEEKEVENTREG_64_80 PACK_WEEKEVENTREG_FLAG(64, 0x80) -#define WEEKEVENTREG_65_01 PACK_WEEKEVENTREG_FLAG(65, 0x01) -#define WEEKEVENTREG_65_02 PACK_WEEKEVENTREG_FLAG(65, 0x02) -#define WEEKEVENTREG_65_04 PACK_WEEKEVENTREG_FLAG(65, 0x04) -#define WEEKEVENTREG_65_08 PACK_WEEKEVENTREG_FLAG(65, 0x08) -#define WEEKEVENTREG_65_10 PACK_WEEKEVENTREG_FLAG(65, 0x10) +#define WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_DAY_1 PACK_WEEKEVENTREG_FLAG(64, 0x80) +#define WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_NIGHT_1 PACK_WEEKEVENTREG_FLAG(65, 0x01) +#define WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_DAY_2 PACK_WEEKEVENTREG_FLAG(65, 0x02) +#define WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_NIGHT_2 PACK_WEEKEVENTREG_FLAG(65, 0x04) +#define WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_DAY_3 PACK_WEEKEVENTREG_FLAG(65, 0x08) +#define WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_NIGHT_3 PACK_WEEKEVENTREG_FLAG(65, 0x10) #define WEEKEVENTREG_65_20 PACK_WEEKEVENTREG_FLAG(65, 0x20) #define WEEKEVENTREG_65_40 PACK_WEEKEVENTREG_FLAG(65, 0x40) #define WEEKEVENTREG_65_80 PACK_WEEKEVENTREG_FLAG(65, 0x80) @@ -1219,7 +1207,10 @@ typedef enum SunsSongState { #define WEEKEVENTREG_80_01 PACK_WEEKEVENTREG_FLAG(80, 0x01) #define WEEKEVENTREG_80_02 PACK_WEEKEVENTREG_FLAG(80, 0x02) #define WEEKEVENTREG_80_04 PACK_WEEKEVENTREG_FLAG(80, 0x04) + +// Aveil has spotted Player #define WEEKEVENTREG_80_08 PACK_WEEKEVENTREG_FLAG(80, 0x08) + #define WEEKEVENTREG_80_10 PACK_WEEKEVENTREG_FLAG(80, 0x10) #define WEEKEVENTREG_80_20 PACK_WEEKEVENTREG_FLAG(80, 0x20) #define WEEKEVENTREG_80_40 PACK_WEEKEVENTREG_FLAG(80, 0x40) @@ -1238,13 +1229,17 @@ typedef enum SunsSongState { // check if already healed Kamaro the Dancing Ghost #define WEEKEVENTREG_82_04 PACK_WEEKEVENTREG_FLAG(82, 0x04) +// Related to Swordsman's log minigame #define WEEKEVENTREG_82_08 PACK_WEEKEVENTREG_FLAG(82, 0x08) #define WEEKEVENTREG_82_10 PACK_WEEKEVENTREG_FLAG(82, 0x10) #define WEEKEVENTREG_82_20 PACK_WEEKEVENTREG_FLAG(82, 0x20) #define WEEKEVENTREG_82_40 PACK_WEEKEVENTREG_FLAG(82, 0x40) #define WEEKEVENTREG_82_80 PACK_WEEKEVENTREG_FLAG(82, 0x80) #define WEEKEVENTREG_83_01 PACK_WEEKEVENTREG_FLAG(83, 0x01) + +// Knocked the Gerudo beehive down #define WEEKEVENTREG_83_02 PACK_WEEKEVENTREG_FLAG(83, 0x02) + #define WEEKEVENTREG_83_04 PACK_WEEKEVENTREG_FLAG(83, 0x04) #define WEEKEVENTREG_83_08 PACK_WEEKEVENTREG_FLAG(83, 0x08) #define WEEKEVENTREG_83_10 PACK_WEEKEVENTREG_FLAG(83, 0x10) @@ -1258,6 +1253,7 @@ typedef enum SunsSongState { #define WEEKEVENTREG_84_10 PACK_WEEKEVENTREG_FLAG(84, 0x10) // Unconfirmed: "Obtained Fierce Deity's Mask?" +// Also related to moon child #define WEEKEVENTREG_84_20 PACK_WEEKEVENTREG_FLAG(84, 0x20) #define WEEKEVENTREG_84_40 PACK_WEEKEVENTREG_FLAG(84, 0x40) @@ -1322,6 +1318,8 @@ typedef enum SunsSongState { #define WEEKEVENTREG_90_04 PACK_WEEKEVENTREG_FLAG(90, 0x04) #define WEEKEVENTREG_90_08 PACK_WEEKEVENTREG_FLAG(90, 0x08) #define WEEKEVENTREG_90_10 PACK_WEEKEVENTREG_FLAG(90, 0x10) + +// Related to Fishermans's jumping minigame #define WEEKEVENTREG_90_20 PACK_WEEKEVENTREG_FLAG(90, 0x20) #define WEEKEVENTREG_90_40 PACK_WEEKEVENTREG_FLAG(90, 0x40) #define WEEKEVENTREG_90_80 PACK_WEEKEVENTREG_FLAG(90, 0x80) @@ -1334,10 +1332,8 @@ typedef enum SunsSongState { #define WEEKEVENTREG_91_40 PACK_WEEKEVENTREG_FLAG(91, 0x40) #define WEEKEVENTREG_91_80 PACK_WEEKEVENTREG_FLAG(91, 0x80) -// RACE_FLAGS -//#define WEEKEVENTREG_92_01 PACK_WEEKEVENTREG_FLAG(92, 0x01) -//#define WEEKEVENTREG_92_02 PACK_WEEKEVENTREG_FLAG(92, 0x02) -//#define WEEKEVENTREG_92_04 PACK_WEEKEVENTREG_FLAG(92, 0x04) +// HORSE_RACE_STATE (3 entries) +// WEEKEVENTREG_92_01 to WEEKEVENTREG_92_04 #define WEEKEVENTREG_92_08 PACK_WEEKEVENTREG_FLAG(92, 0x08) #define WEEKEVENTREG_92_10 PACK_WEEKEVENTREG_FLAG(92, 0x10) @@ -1401,7 +1397,7 @@ typedef enum SunsSongState { #define WEEKEVENTREG_99_40 PACK_WEEKEVENTREG_FLAG(99, 0x40) #define WEEKEVENTREG_99_80 PACK_WEEKEVENTREG_FLAG(99, 0x80) -#define WEEKEVENTREG(index) (gSaveContext.save.weekEventReg[(index)]) +#define WEEKEVENTREG(index) (gSaveContext.save.saveInfo.weekEventReg[(index)]) #define GET_WEEKEVENTREG(index) ((void)0, WEEKEVENTREG(index)) #define CHECK_WEEKEVENTREG(flag) (WEEKEVENTREG((flag) >> 8) & ((flag) & 0xFF)) @@ -1409,31 +1405,52 @@ typedef enum SunsSongState { #define SET_WEEKEVENTREG(flag) (WEEKEVENTREG((flag) >> 8) = GET_WEEKEVENTREG((flag) >> 8) | ((flag) & 0xFF)) #define CLEAR_WEEKEVENTREG(flag) (WEEKEVENTREG((flag) >> 8) = GET_WEEKEVENTREG((flag) >> 8) & (u8)~((flag) & 0xFF)) -#define WEEKEVENTREG_RACE_FLAG_END 0 -#define WEEKEVENTREG_RACE_FLAG_START 1 -#define WEEKEVENTREG_RACE_FLAG_2 2 -#define WEEKEVENTREG_RACE_FLAG_3 3 -#define WEEKEVENTREG_RACE_FLAG_4 4 -#define WEEKEVENTREG_RACE_FLAGS 7 +typedef enum { + /* 0 */ WEEKEVENTREG_HORSE_RACE_STATE_END, + /* 1 */ WEEKEVENTREG_HORSE_RACE_STATE_START, + /* 2 */ WEEKEVENTREG_HORSE_RACE_STATE_2, + /* 3 */ WEEKEVENTREG_HORSE_RACE_STATE_3, + /* 4 */ WEEKEVENTREG_HORSE_RACE_STATE_4, + /* 7 */ WEEKEVENTREG_HORSE_RACE_STATE_MAX = 7 +} WeekEventRegHorseRaceState; -#define GET_WEEKEVENTREG_RACE_FLAGS (WEEKEVENTREG(92) & WEEKEVENTREG_RACE_FLAGS) +#define GET_WEEKEVENTREG_HORSE_RACE_STATE (WEEKEVENTREG(92) & WEEKEVENTREG_HORSE_RACE_STATE_MAX) -#define SET_WEEKEVENTREG_RACE_FLAGS(flag) \ - WEEKEVENTREG(92) &= (u8)~WEEKEVENTREG_RACE_FLAGS; \ - WEEKEVENTREG(92) = WEEKEVENTREG(92) | (u8)((WEEKEVENTREG(92) & ~WEEKEVENTREG_RACE_FLAGS) | (flag)) +#define SET_WEEKEVENTREG_HORSE_RACE_STATE(state) \ + { \ + WEEKEVENTREG(92) &= (u8)~WEEKEVENTREG_HORSE_RACE_STATE_MAX; \ + WEEKEVENTREG(92) = WEEKEVENTREG(92) | (u8)((WEEKEVENTREG(92) & ~WEEKEVENTREG_HORSE_RACE_STATE_MAX) | (state)); \ + } \ + (void)0 + +#define GET_WEEKEVENTREG_DOG_RACE_TEXT(index, baseTextId) \ + (index % 2) ? (baseTextId + (((WEEKEVENTREG(42 + (index / 2))) & 0xF0) >> 4)) \ + : (baseTextId + ((WEEKEVENTREG(42 + (index / 2))) & 0x0F)); + +#define SET_WEEKEVENTREG_DOG_RACE_TEXT_OFFSETS(index, packedOffsets) \ + { \ + WEEKEVENTREG(42 + index) = ((void)0, WEEKEVENTREG(42 + index)) | packedOffsets; \ + } + +#define CLEAR_WEEKEVENTREG_DOG_RACE_TEXT_OFFSETS(index) \ + { \ + WEEKEVENTREG(42 + index) = 0; \ + } /** * gSaveContext.eventInf */ -#define EVENTINF_00 0x00 -#define EVENTINF_01 0x01 -#define EVENTINF_02 0x02 -#define EVENTINF_03 0x03 -#define EVENTINF_04 0x04 -#define EVENTINF_05 0x05 -#define EVENTINF_06 0x06 -#define EVENTINF_07 0x07 +// gSaveContext.eventInf[0] is used to dog race information +// #define EVENTINF_00 0x00 +// #define EVENTINF_01 0x01 +// #define EVENTINF_02 0x02 +// #define EVENTINF_03 0x03 +// #define EVENTINF_04 0x04 +// #define EVENTINF_05 0x05 +// #define EVENTINF_06 0x06 +// #define EVENTINF_07 0x07 + #define EVENTINF_10 0x10 #define EVENTINF_11 0x11 #define EVENTINF_12 0x12 @@ -1458,11 +1475,15 @@ typedef enum SunsSongState { #define EVENTINF_32 0x32 #define EVENTINF_33 0x33 + +// Related to Deku playground minigame #define EVENTINF_34 0x34 #define EVENTINF_35 0x35 #define EVENTINF_36 0x36 #define EVENTINF_37 0x37 #define EVENTINF_40 0x40 + +// Related to swamp boat (non-minigame)? #define EVENTINF_41 0x41 #define EVENTINF_42 0x42 #define EVENTINF_43 0x43 @@ -1503,6 +1524,25 @@ typedef enum SunsSongState { #define CLEAR_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] &= (u8)~(1 << ((flag) & 0xF))) #define CLEAR_EVENTINF_ALT(flag) (gSaveContext.eventInf[(flag) >> 4] &= ~(1 << ((flag) & 0xF))) +typedef enum { + /* 0 */ EVENTINF_DOG_RACE_STATE_NOT_STARTED, + /* 2 */ EVENTINF_DOG_RACE_STATE_STARTED = 2, + /* 3 */ EVENTINF_DOG_RACE_STATE_ENDED, + /* 7 */ EVENTINF_DOG_RACE_STATE_MAX = 7 +} EventInfDogRaceState; + +#define GET_EVENTINF_DOG_RACE_STATE (gSaveContext.eventInf[0] & EVENTINF_DOG_RACE_STATE_MAX) +#define SET_EVENTINF_DOG_RACE_STATE(state) \ + (gSaveContext.eventInf[0] = ((gSaveContext.eventInf[0] & (u8)~EVENTINF_DOG_RACE_STATE_MAX) | (state))) + +#define GET_EVENTINF_DOG_RACE_SELECTED_DOG_INDEX ((gSaveContext.eventInf[0] & (u8)~EVENTINF_DOG_RACE_STATE_MAX) >> 3) +#define SET_EVENTINF_DOG_RACE_SELECTED_DOG_INDEX(selectedDogIndex) \ + (gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & EVENTINF_DOG_RACE_STATE_MAX) | (selectedDogIndex << 3)) + +// This is exactly the same as the selected dog index; they never need both of them at the same time. +#define GET_EVENTINF_DOG_RACE_RACE_STANDING ((gSaveContext.eventInf[0] & (u8)~EVENTINF_DOG_RACE_STATE_MAX) >> 3) +#define SET_EVENTINF_DOG_RACE_RACE_STANDING(raceStanding) \ + (gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & EVENTINF_DOG_RACE_STATE_MAX) | (raceStanding << 3)) typedef enum { /* 0 */ DUNGEON_INDEX_WOODFALL_TEMPLE, @@ -1518,7 +1558,7 @@ void Sram_IncrementDay(void); u16 Sram_CalcChecksum(void* data, size_t count); void Sram_InitNewSave(void); void Sram_InitDebugSave(void); -void func_80144A94(SramContext* sramCtx); +void Sram_ResetSaveFromMoonCrash(SramContext* sramCtx); void Sram_OpenSave(struct FileSelectState* fileSelect, SramContext* sramCtx); void func_8014546C(SramContext* sramCtx); void func_801457CC(struct FileSelectState* fileSelect, SramContext* sramCtx); diff --git a/include/z64scene.h b/include/z64scene.h index b61a04609..f8313d2aa 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -13,6 +13,9 @@ typedef struct { /* 0x4 */ uintptr_t vromEnd; } RomFile; // size = 0x8 +#define ROOM_DRAW_OPA (1 << 0) +#define ROOM_DRAW_XLU (1 << 1) + typedef struct { /* 0x0 */ u8 code; /* 0x1 */ u8 data1; @@ -174,9 +177,9 @@ typedef struct { typedef struct { /* 0x0 */ u8 code; - /* 0x1 */ u8 sceneCsCount; + /* 0x1 */ u8 scriptListCount; /* 0x4 */ void* segment; -} SCmdCutsceneList; // size = 0x8 +} SCmdCsScriptList; // size = 0x8 typedef struct { /* 0x0 */ u8 code; @@ -199,7 +202,7 @@ typedef struct { /* 0x0 */ u8 code; /* 0x1 */ u8 num; /* 0x4 */ void* segment; -} SCmdCutsceneActorList; // size = 0x8 +} SCmdCutsceneList; // size = 0x8 typedef struct { /* 0x0 */ u8 code; @@ -213,58 +216,132 @@ typedef struct { /* 0x4 */ void* segment; } SCmdMinimapChests; // size = 0x8 -typedef struct { - /* 0x0 */ Gfx* opaqueDl; - /* 0x4 */ Gfx* translucentDl; -} RoomMeshType0Params; // size = 0x8 - -// Fields TODO -typedef struct { - /* 0x0 */ u8 type; - /* 0x1 */ u8 format; // 1 = single, 2 = multi -} RoomMeshType1; // size = 0x2 - -// Size TODO -typedef struct { - /* 0x0 */ UNK_TYPE1 pad0[0x10]; -} RoomMeshType1Params; // size = 0x10 - -typedef struct { - /* 0x0 */ UNK_TYPE1 pad0[0x10]; -} RoomMeshType2Params; // size = 0x10 +typedef enum { + /* 0 */ ROOM_SHAPE_TYPE_NORMAL, + /* 1 */ ROOM_SHAPE_TYPE_IMAGE, + /* 2 */ ROOM_SHAPE_TYPE_CULLABLE, + /* 3 */ ROOM_SHAPE_TYPE_NONE, + /* 4 */ ROOM_SHAPE_TYPE_MAX +} RoomShapeType; typedef struct { /* 0x0 */ u8 type; - /* 0x1 */ u8 count; - /* 0x2 */ UNK_TYPE1 pad2[0x2]; - /* 0x4 */ RoomMeshType0Params* paramsStart; - /* 0x8 */ RoomMeshType0Params* paramsEnd; -} RoomMeshType0; // size = 0xC +} RoomShapeBase; // size = 0x1 typedef struct { - /* 0x0 */ u8 type; - /* 0x1 */ u8 count; - /* 0x2 */ UNK_TYPE1 pad2[0x2]; - /* 0x4 */ RoomMeshType2Params* paramsStart; - /* 0x8 */ RoomMeshType2Params* paramsEnd; -} RoomMeshType2; // size = 0xC + /* 0x0 */ Gfx* opa; + /* 0x4 */ Gfx* xlu; +} RoomShapeDListsEntry; // size = 0x8 + +typedef struct { + /* 0x0 */ RoomShapeBase base; + /* 0x1 */ u8 numEntries; + /* 0x4 */ RoomShapeDListsEntry* entries; + /* 0x8 */ RoomShapeDListsEntry* entriesEnd; +} RoomShapeNormal; // size = 0xC + +typedef enum { + /* 1 */ ROOM_SHAPE_IMAGE_AMOUNT_SINGLE = 1, + /* 2 */ ROOM_SHAPE_IMAGE_AMOUNT_MULTI +} RoomShapeImageAmountType; + +typedef struct { + /* 0x0 */ RoomShapeBase base; + /* 0x1 */ u8 amountType; // uses `RoomShapeImageAmountType` + /* 0x4 */ RoomShapeDListsEntry* entry; +} RoomShapeImageBase; // size = 0x8 + +typedef struct { + /* 0x00 */ RoomShapeImageBase base; + /* 0x08 */ void* source; + /* 0x0C */ u32 unk_0C; + /* 0x10 */ void* tlut; + /* 0x14 */ u16 width; + /* 0x16 */ u16 height; + /* 0x18 */ u8 fmt; + /* 0x19 */ u8 siz; + /* 0x1A */ u16 tlutMode; + /* 0x1C */ u16 tlutCount; +} RoomShapeImageSingle; // size = 0x20 + +typedef struct { + /* 0x00 */ u16 unk_00; + /* 0x02 */ u8 bgCamIndex; // the bg cam index this entry is for + /* 0x04 */ void* source; + /* 0x08 */ u32 unk_0C; + /* 0x0C */ void* tlut; + /* 0x10 */ u16 width; + /* 0x12 */ u16 height; + /* 0x14 */ u8 fmt; + /* 0x15 */ u8 siz; + /* 0x16 */ u16 tlutMode; + /* 0x18 */ u16 tlutCount; +} RoomShapeImageMultiBgEntry; // size = 0x1C + +typedef struct { + /* 0x0 */ RoomShapeImageBase base; + /* 0x8 */ u8 numBackgrounds; + /* 0xC */ RoomShapeImageMultiBgEntry* backgrounds; +} RoomShapeImageMulti; // size = 0x10 + +typedef struct { + /* 0x0 */ Vec3s boundsSphereCenter; + /* 0x6 */ s16 boundsSphereRadius; + /* 0x8 */ Gfx* opa; + /* 0xC */ Gfx* xlu; +} RoomShapeCullableEntry; // size = 0x10 + +typedef struct { + /* 0x0 */ RoomShapeBase base; + /* 0x1 */ u8 numEntries; + /* 0x4 */ RoomShapeCullableEntry* entries; + /* 0x8 */ RoomShapeCullableEntry* entriesEnd; +} RoomShapeCullable; // size = 0xC typedef union { - RoomMeshType0 type0; - RoomMeshType1 type1; - RoomMeshType2 type2; -} RoomMesh; // size = 0xC + RoomShapeBase base; + RoomShapeNormal normal; + union { + RoomShapeImageBase base; + RoomShapeImageSingle single; + RoomShapeImageMulti multi; + } image; + RoomShapeCullable cullable; +} RoomShape; // "Ground Shape" + +// TODO: update ZAPD +#define SCENE_CMD_MESH SCENE_CMD_ROOM_SHAPE + +// TODO: Check which ones don't exist +typedef enum { + /* 0 */ ROOM_BEHAVIOR_TYPE1_0, + /* 1 */ ROOM_BEHAVIOR_TYPE1_1, + /* 2 */ ROOM_BEHAVIOR_TYPE1_2, + /* 3 */ ROOM_BEHAVIOR_TYPE1_3, // unused + /* 4 */ ROOM_BEHAVIOR_TYPE1_4, + /* 5 */ ROOM_BEHAVIOR_TYPE1_5 +} RoomBehaviorType1; + +typedef enum { + /* 0 */ ROOM_BEHAVIOR_TYPE2_0, + /* 1 */ ROOM_BEHAVIOR_TYPE2_1, + /* 2 */ ROOM_BEHAVIOR_TYPE2_2, + /* 3 */ ROOM_BEHAVIOR_TYPE2_HOT, + /* 4 */ ROOM_BEHAVIOR_TYPE2_4, + /* 5 */ ROOM_BEHAVIOR_TYPE2_5, + /* 6 */ ROOM_BEHAVIOR_TYPE2_6 +} RoomBehaviorType2; typedef struct { /* 0x00 */ s8 num; /* 0x01 */ u8 unk1; - /* 0x02 */ u8 unk2; // 3: Room is hot - /* 0x03 */ u8 unk3; + /* 0x02 */ u8 behaviorType2; + /* 0x03 */ u8 behaviorType1; /* 0x04 */ s8 echo; - /* 0x05 */ u8 unk5; + /* 0x05 */ u8 lensMode; /* 0x06 */ u8 enablePosLights; /* 0x07 */ UNK_TYPE1 pad7[0x1]; - /* 0x08 */ RoomMesh* mesh; + /* 0x08 */ RoomShape* roomShape; /* 0x0C */ void* segment; /* 0x10 */ UNK_TYPE1 pad10[0x4]; } Room; // size = 0x14 @@ -274,7 +351,7 @@ typedef struct { /* 0x14 */ Room prevRoom; /* 0x28 */ void* roomMemPages[2]; // In a scene with transitions, roomMemory is split between two pages that toggle each transition. This is one continuous range, as the second page allocates from the end /* 0x30 */ u8 activeMemPage; // 0 - First page in memory, 1 - Second page - /* 0x31 */ s8 unk31; + /* 0x31 */ s8 status; /* 0x32 */ UNK_TYPE1 pad32[0x2]; /* 0x34 */ void* activeRoomVram; /* 0x38 */ DmaRequest dmaRequest; @@ -286,15 +363,17 @@ typedef struct { /* 0x7A */ UNK_TYPE2 unk7A[3]; } RoomContext; // size = 0x80 -typedef struct { +typedef void(*RoomDrawHandler)(struct PlayState* play, Room* room, u32 flags); + +typedef struct TransitionActorEntry { struct { s8 room; // Room to switch to s8 bgCamIndex; // How the camera reacts during the transition. -2 for spiral staircase. -1 for generic door. 0+ will index scene CamData } /* 0x0 */ sides[2]; // 0 = front, 1 = back - /* 0x4 */ s16 id; + /* 0x4 */ s16 id; /* 0x6 */ Vec3s pos; - /* 0xC */ s16 rotY; - /* 0xE */ u16 params; + /* 0xC */ s16 rotY; + /* 0xE */ u16 params; } TransitionActorEntry; // size = 0x10 typedef struct { @@ -341,6 +420,7 @@ typedef struct { /* 0xA */ u8 unk_A; /* 0xB */ u8 drawConfig; /* 0xC */ u8 unk_C; + /* 0xD */ u8 unk_D; } SceneTableEntry; // size = 0x10 typedef struct { @@ -389,77 +469,6 @@ typedef struct { /* 0x00C */ ObjectStatus status[OBJECT_EXCHANGE_BANK_MAX]; } ObjectContext; // size = 0x958 -typedef struct { - /* 0x0 */ u8 headerType; -} MeshHeaderBase; // size = 0x1 - -typedef struct { - /* 0x0 */ MeshHeaderBase base; - /* 0x1 */ u8 numEntries; - /* 0x4 */ u32 dListStart; - /* 0x8 */ u32 dListEnd; -} MeshHeader0; // size = 0xC - -typedef struct { - /* 0x0 */ u32 opaqueDList; - /* 0x4 */ u32 translucentDList; -} MeshEntry0; // size = 0x8 - -typedef struct { - /* 0x0 */ MeshHeaderBase base; - /* 0x1 */ u8 format; - /* 0x4 */ u32 entryRecord; -} MeshHeader1Base; // size = 0x8 - -typedef struct { - /* 0x00 */ MeshHeader1Base base; - /* 0x08 */ u32 imagePtr; - /* 0x0C */ u32 unknown; - /* 0x10 */ u32 unknown2; - /* 0x14 */ u16 bgWidth; - /* 0x16 */ u16 bgHeight; - /* 0x18 */ u8 imageFormat; - /* 0x19 */ u8 imageSize; - /* 0x1A */ u16 imagePal; - /* 0x1C */ u16 imageFlip; -} MeshHeader1Single; // size = 0x20 - -typedef struct { - /* 0x0 */ MeshHeader1Base base; - /* 0x8 */ u8 bgCnt; - /* 0xC */ u32 bgRecordPtr; -} MeshHeader1Multi; // size = 0x10 - -typedef struct { - /* 0x00 */ u16 unknown; - /* 0x02 */ s8 bgID; - /* 0x04 */ u32 imagePtr; - /* 0x08 */ u32 unknown2; - /* 0x0C */ u32 unknown3; - /* 0x10 */ u16 bgWidth; - /* 0x12 */ u16 bgHeight; - /* 0x14 */ u8 imageFmt; - /* 0x15 */ u8 imageSize; - /* 0x16 */ u16 imagePal; - /* 0x18 */ u16 imageFlip; -} BackgroundRecord; // size = 0x1C - -typedef struct { - /* 0x0 */ s16 playerXMax; - /* 0x2 */ s16 playerZMax; - /* 0x4 */ s16 playerXMin; - /* 0x6 */ s16 playerZMin; - /* 0x8 */ u32 opaqueDList; - /* 0xC */ u32 translucentDList; -} MeshEntry2; // size = 0x10 - -typedef struct { - /* 0x0 */ MeshHeaderBase base; - /* 0x1 */ u8 numEntries; - /* 0x4 */ u32 dListStart; - /* 0x8 */ u32 dListEnd; -} MeshHeader2; // size = 0xC - typedef struct { /* 0x0 */ u8 count; // number of points in the path /* 0x1 */ u8 unk1; @@ -522,11 +531,11 @@ typedef union { /* Command: 0x14 */ SCmdEndMarker endMarker; /* Command: 0x15 */ SCmdSoundSettings soundSettings; /* Command: 0x16 */ SCmdEchoSettings echoSettings; - /* Command: 0x17 */ SCmdCutsceneList cutsceneList; + /* Command: 0x17 */ SCmdCsScriptList scriptList; /* Command: 0x18 */ SCmdAltHeaders altHeaders; /* Command: 0x19 */ SCmdRegionVisited regionVisited; /* Command: 0x1A */ SCmdTextureAnimations textureAnimations; - /* Command: 0x1B */ SCmdCutsceneActorList cutsceneActorList; + /* Command: 0x1B */ SCmdCutsceneList cutsceneList; /* Command: 0x1C */ SCmdMinimapSettings minimapSettings; /* Command: 0x1D */ // Unused /* Command: 0x1E */ SCmdMinimapChests minimapChests; @@ -813,6 +822,15 @@ typedef enum { */ #define ENTRANCE(scene, spawn) ((((ENTR_SCENE_##scene) & 0x7F) << 9) | (((spawn) & 0x1F) << 4)) +/* +* Entrances used in cutscene destination. Includes scene layer that's immediately applied to `nextCutsceneIndex` and removed. +* See `CutsceneScriptEntry.nextEntrance` +* 0xFE00: Index into sSceneEntranceTable (Scene) +* 0x01F0: Index into the scenes specific entrance table (Spawn) +* 0x000F: Index into the specific entrance table (Layer) +*/ +#define CS_ENTRANCE(scene, spawn, layer) ((((ENTR_SCENE_##scene) & 0x7F) << 9) | (((spawn) & 0x1F) << 4) | ((layer) & 0xF)) + // SceneTableEntry draw configs typedef enum { /* 0 */ SCENE_DRAW_CFG_DEFAULT, @@ -845,7 +863,7 @@ typedef enum { /* 0x07 */ SCENE_CMD_ID_SPECIAL_FILES, /* 0x08 */ SCENE_CMD_ID_ROOM_BEHAVIOR, /* 0x09 */ SCENE_CMD_ID_UNK_09, - /* 0x0A */ SCENE_CMD_ID_MESH, + /* 0x0A */ SCENE_CMD_ID_ROOM_SHAPE, /* 0x0B */ SCENE_CMD_ID_OBJECT_LIST, /* 0x0C */ SCENE_CMD_ID_LIGHT_LIST, /* 0x0D */ SCENE_CMD_ID_PATH_LIST, @@ -858,7 +876,7 @@ typedef enum { /* 0x14 */ SCENE_CMD_ID_END, /* 0x15 */ SCENE_CMD_ID_SOUND_SETTINGS, /* 0x16 */ SCENE_CMD_ID_ECHO_SETTINGS, - /* 0x17 */ SCENE_CMD_ID_CUTSCENE_LIST, + /* 0x17 */ SCENE_CMD_ID_CUTSCENE_SCRIPT_LIST, /* 0x18 */ SCENE_CMD_ID_ALTERNATE_HEADER_LIST, /* 0x19 */ SCENE_CMD_ID_SET_REGION_VISITED, /* 0x1A */ SCENE_CMD_ID_ANIMATED_MATERIAL_LIST, @@ -904,8 +922,8 @@ typedef enum { #define SCENE_CMD_UNK_09() \ { SCENE_CMD_ID_UNK_09, 0, CMD_W(0) } -#define SCENE_CMD_MESH(meshHeader) \ - { SCENE_CMD_ID_MESH, 0, CMD_PTR(meshHeader) } +#define SCENE_CMD_ROOM_SHAPE(roomShape) \ + { SCENE_CMD_ID_ROOM_SHAPE, 0, CMD_PTR(roomShape) } #define SCENE_CMD_OBJECT_LIST(numObjects, objectList) \ { SCENE_CMD_ID_OBJECT_LIST, numObjects, CMD_PTR(objectList) } @@ -943,21 +961,20 @@ typedef enum { #define SCENE_CMD_ECHO_SETTINGS(echo) \ { SCENE_CMD_ID_ECHO_SETTINGS, 0, CMD_BBBB(0, 0, 0, echo) } -#define SCENE_CMD_CUTSCENE_LIST(numCutscene, cutsceneList) \ - { SCENE_CMD_ID_CUTSCENE_LIST, numCutscene, CMD_PTR(cutsceneList) } +#define SCENE_CMD_CUTSCENE_SCRIPT_LIST(numEntries, scriptList) \ + { SCENE_CMD_ID_CUTSCENE_SCRIPT_LIST, numEntries, CMD_PTR(scriptList) } #define SCENE_CMD_ALTERNATE_HEADER_LIST(alternateHeaderList) \ { SCENE_CMD_ID_ALTERNATE_HEADER_LIST, 0, CMD_PTR(alternateHeaderList) } -#define SCENE_CMD_MISC_SETTINGS SCENE_CMD_SET_REGION_VISITED // TODO: ZAPD Capatability #define SCENE_CMD_SET_REGION_VISITED() \ { SCENE_CMD_ID_SET_REGION_VISITED, 0, CMD_W(0) } #define SCENE_CMD_ANIMATED_MATERIAL_LIST(matAnimList) \ { SCENE_CMD_ID_ANIMATED_MATERIAL_LIST, 0, CMD_PTR(matAnimList) } -#define SCENE_CMD_ACTOR_CUTSCENE_LIST(actorCutsceneCount, actorCutsceneList) \ - { SCENE_CMD_ID_ACTOR_CUTSCENE_LIST, actorCutsceneCount, CMD_PTR(actorCutsceneList) } +#define SCENE_CMD_ACTOR_CUTSCENE_LIST(numEntries, actorCutsceneList) \ + { SCENE_CMD_ID_ACTOR_CUTSCENE_LIST, numEntries, CMD_PTR(actorCutsceneList) } #define SCENE_CMD_MINIMAP_INFO(minimapInfo) \ { SCENE_CMD_ID_MINIMAP_INFO, 0, CMD_PTR(minimapInfo) } @@ -965,4 +982,8 @@ typedef enum { #define SCENE_CMD_MINIMAP_COMPASS_ICON_INFO(compassIconCount, compassIconInfo) \ { SCENE_CMD_ID_MINIMAP_COMPASS_ICON_INFO, compassIconCount, CMD_PTR(compassIconInfo) } + // TODO: ZAPD Capatability +#define SCENE_CMD_MISC_SETTINGS SCENE_CMD_SET_REGION_VISITED +#define SCENE_CMD_CUTSCENE_LIST SCENE_CMD_CUTSCENE_SCRIPT_LIST + #endif diff --git a/include/z64shrink_window.h b/include/z64shrink_window.h index 2742fb602..bff11b939 100644 --- a/include/z64shrink_window.h +++ b/include/z64shrink_window.h @@ -18,6 +18,6 @@ s32 ShrinkWindow_Pillarbox_GetSize(void); void ShrinkWindow_Init(void); void ShrinkWindow_Destroy(void); void ShrinkWindow_Update(s32 framerateDivisor); -void ShrinkWindow_Draw(GraphicsContext* gfxCtx); +void ShrinkWindow_Draw(struct GraphicsContext* gfxCtx); #endif diff --git a/include/z64skin.h b/include/z64skin.h index 360e265e6..a9e2ebc01 100644 --- a/include/z64skin.h +++ b/include/z64skin.h @@ -1,5 +1,5 @@ -#ifndef Z64_SKIN_H -#define Z64_SKIN_H +#ifndef Z64SKIN_H +#define Z64SKIN_H #include "z64animation.h" diff --git a/include/z64skybox.h b/include/z64skybox.h new file mode 100644 index 000000000..0a981d23e --- /dev/null +++ b/include/z64skybox.h @@ -0,0 +1,62 @@ +#ifndef Z64SKYBOX_H +#define Z64SKYBOX_H + +#include "PR/ultratypes.h" +#include "PR/gbi.h" +#include "color.h" + +#include "z64dma.h" +#include "z64math.h" +#include "z64view.h" + +struct GraphicsContext; +struct GameState; +struct PlayState; + +typedef enum SkyboxId { + /* 0 */ SKYBOX_NONE, + /* 1 */ SKYBOX_NORMAL_SKY, + /* 2 */ SKYBOX_2, + /* 3 */ SKYBOX_3, + /* 5 */ SKYBOX_CUTSCENE_MAP = 5 +} SkyboxId; + +typedef struct SkyboxContext { + /* 0x000 */ View view; + /* 0x168 */ void* staticSegments[4]; + /* 0x178 */ void* paletteStaticSegment; + /* 0x17C */ Gfx (*dListBuf)[150]; + /* 0x180 */ Gfx* roomDL; + /* 0x184 */ Vtx* roomVtx; + /* 0x188 */ DmaRequest unk188; + /* 0x1A8 */ DmaRequest unk1A8; + /* 0x1C8 */ DmaRequest unk1C8; + /* 0x1E8 */ OSMesgQueue loadQueue; + /* 0x200 */ OSMesg loadMsg; + /* 0x204 */ s16 skyboxShouldDraw; + /* 0x208 */ Vec3f rot; + /* 0x214 */ Vec3f eye; + /* 0x220 */ s16 angle; + /* 0x222 */ Color_RGB8 prim; + /* 0x225 */ Color_RGB8 env; +} SkyboxContext; // size = 0x228 + +typedef struct struct_801C5F44 { + /* 0x00 */ s32 unk0; + /* 0x04 */ s32 unk4; + /* 0x08 */ s32 unk8; + /* 0x0C */ s32 unkC; + /* 0x10 */ s32 unk10; +} struct_801C5F44; // size = 0x14 + +s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* roomVtx, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8); +void func_80143148(SkyboxContext* skyboxCtx, s32 arg1); +void Skybox_Setup(struct GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId); +void func_80143324(struct PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId); +void Skybox_Init(struct GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId); +Mtx* Skybox_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z); +void Skybox_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB); +void Skybox_Draw(SkyboxContext* skyboxCtx, struct GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z); +void Skybox_Update(SkyboxContext* skyboxCtx); + +#endif diff --git a/include/z64snap.h b/include/z64snap.h index fb3f86186..8bec78c3d 100644 --- a/include/z64snap.h +++ b/include/z64snap.h @@ -1,5 +1,5 @@ -#ifndef Z64_SNAP_H -#define Z64_SNAP_H +#ifndef Z64SNAP_H +#define Z64SNAP_H #include "PR/ultratypes.h" #include "z64actor.h" @@ -11,36 +11,36 @@ typedef struct { /* 0x144 */ PictoValidationFunc validationFunc; } PictoActor; -// Picto box flags +// Picto validation flags typedef enum { // Used externally, set and read by actors - /* 0x00 */ PICTOGRAPH_0, - /* 0x01 */ PICTOGRAPH_IN_SWAMP, - /* 0x02 */ PICTOGRAPH_MONKEY, - /* 0x03 */ PICTOGRAPH_BIG_OCTO, - /* 0x04 */ PICTOGRAPH_LULU_HEAD, - /* 0x05 */ PICTOGRAPH_LULU_RIGHT_ARM, - /* 0x06 */ PICTOGRAPH_LULU_LEFT_ARM, // Need all three of these to qualify as a good picture - /* 0x07 */ PICTOGRAPH_SCARECROW, - /* 0x08 */ PICTOGRAPH_TINGLE, - /* 0x09 */ PICTOGRAPH_PIRATE_GOOD, - /* 0x0A */ PICTOGRAPH_DEKU_KING, - /* 0x0B */ PICTOGRAPH_PIRATE_TOO_FAR, // overlaps with PICTOGRAPH_PIRATE_GOOD, but that is checked first + /* 0x00 */ PICTO_VALID_0, + /* 0x01 */ PICTO_VALID_IN_SWAMP, + /* 0x02 */ PICTO_VALID_MONKEY, + /* 0x03 */ PICTO_VALID_BIG_OCTO, + /* 0x04 */ PICTO_VALID_LULU_HEAD, + /* 0x05 */ PICTO_VALID_LULU_RIGHT_ARM, + /* 0x06 */ PICTO_VALID_LULU_LEFT_ARM, // Need all three of these to qualify as a good picture + /* 0x07 */ PICTO_VALID_SCARECROW, + /* 0x08 */ PICTO_VALID_TINGLE, + /* 0x09 */ PICTO_VALID_PIRATE_GOOD, + /* 0x0A */ PICTO_VALID_DEKU_KING, + /* 0x0B */ PICTO_VALID_PIRATE_TOO_FAR, // overlaps with PICTO_VALID_PIRATE_GOOD, but that is checked first // Used internally, test for failures of position, angle etc. - /* 0x3B */ PICTOGRAPH_BEHIND_COLLISION = 0x3B, - /* 0x3C */ PICTOGRAPH_BEHIND_BG, - /* 0x3D */ PICTOGRAPH_NOT_IN_VIEW, - /* 0x3E */ PICTOGRAPH_BAD_ANGLE, - /* 0x3F */ PICTOGRAPH_BAD_DISTANCE -} PictographFlag; + /* 0x3B */ PICTO_VALID_BEHIND_COLLISION = 0x3B, + /* 0x3C */ PICTO_VALID_BEHIND_BG, + /* 0x3D */ PICTO_VALID_NOT_IN_VIEW, + /* 0x3E */ PICTO_VALID_BAD_ANGLE, + /* 0x3F */ PICTO_VALID_BAD_DISTANCE +} PictoValidFlag; -// The following macros are subject to renaming once the capture system is better understood -#define PICTO_RESOLUTION_HORIZONTAL 150 -#define PICTO_RESOLUTION_VERTICAL 105 -#define PICTO_CAPTURE_REGION_TOPLEFT_X ((SCREEN_WIDTH - PICTO_RESOLUTION_HORIZONTAL) / 2) -#define PICTO_CAPTURE_REGION_TOPLEFT_Y ((SCREEN_HEIGHT - PICTO_RESOLUTION_VERTICAL) / 2) +// The subregion of the picto photo that will set the flag for an actor being in the photo +#define PICTO_VALID_WIDTH 150 +#define PICTO_VALID_HEIGHT 105 +#define PICTO_VALID_TOPLEFT_X ((SCREEN_WIDTH - PICTO_VALID_WIDTH) / 2) +#define PICTO_VALID_TOPLEFT_Y ((SCREEN_HEIGHT - PICTO_VALID_HEIGHT) / 2) s32 Snap_RecordPictographedActors(PlayState* play); void Snap_SetFlag(s32 flag); diff --git a/include/z64subs.h b/include/z64subs.h index ca90cb232..ad2b7044f 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -11,12 +11,12 @@ extern Vec3f gOneVec3f; #define SUBS_TIME_PATHING_ORDER 3 typedef enum { - /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, + /* 0 */ SUBS_CUTSCENE_WITH_PLAYER, /* 1 */ SUBS_CUTSCENE_NORMAL, - /* 2 */ SUBS_CUTSCENE_SET_FLAG + /* 2 */ SUBS_CUTSCENE_WITH_PLAYER_SET_FLAG } SubSCutsceneType; -//! @TODO: rename based on func_8013E748 and func_800B8500 +//! TODO: rename based on func_8013E748 and func_800B8500 typedef s32 (*func_8013E748_VerifyFunc)(struct PlayState*, Actor*, void*); typedef s32 (*VerifyActor)(struct PlayState*, Actor*, Actor*, void*); @@ -153,8 +153,8 @@ s32 SubS_ActorPathing_SetNextPoint(struct PlayState* play, ActorPathing* actorPa void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animationInfo, s32 nextAnimIndex, s32* curAnimIndex); -s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type); -s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes); +s32 SubS_StartCutscene(Actor* actor, s16 nextCsId, s16 curCsId, s32 type); +s32 SubS_FillCutscenesList(Actor* actor, s16 csIdList[], s16 numCutscenes); void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane); s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect); diff --git a/include/z64transition.h b/include/z64transition.h index 45178ba8e..e223d9b58 100644 --- a/include/z64transition.h +++ b/include/z64transition.h @@ -1,7 +1,40 @@ -#ifndef _Z64_TRANSITION_H_ -#define _Z64_TRANSITION_H_ +#ifndef Z64TRANSITION_H +#define Z64TRANSITION_H #include "ultra64.h" +#include "libc/stdint.h" +#include "overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h" +#include "overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h" +#include "overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h" +#include "overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h" +#include "overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h" + +typedef enum { + /* 0 */ TRANS_TILE_OFF, // Inactive, do nothing + /* 1 */ TRANS_TILE_SETUP, // Save the necessary buffers + /* 2 */ TRANS_TILE_PROCESS, // Initialize the transition + /* 3 */ TRANS_TILE_READY // The transition is ready, so will update and draw each frame +} TransitionTileState; + +typedef struct { + /* 0x0 */ f32 x; + /* 0x4 */ f32 y; +} TransitionTileVtxData; // size = 0x8 + +typedef struct { + /* 0x00 */ s32 cols; + /* 0x04 */ s32 rows; + /* 0x08 */ s32 frame; + /* 0x0C */ TransitionTileVtxData* vtxData; + /* 0x10 */ Vtx* vtxFrame1; + /* 0x14 */ Vtx* vtxFrame2; + /* 0x18 */ Mtx projection; + /* 0x58 */ Mtx modelView; + /* 0x98 */ Mtx unk_98; + /* 0xD8 */ Gfx* gfx; // "gfxtbl" + /* 0xDC */ u16* zBuffer; +} TransitionTile; // size = 0xE0 + #define TC_SET_PARAMS (1 << 7) @@ -32,31 +65,21 @@ typedef struct { /* 0x14 */ TransitionInit* initInfo; /* 0x18 */ size_t size; } TransitionOverlay; - -typedef struct { - /* 0x000 */ s16 transitionType; - /* 0x002 */ s8 fbdemoType; - /* 0x003 */ char unk_003[0x22B]; - /* 0x230 */ void* (*init)(void* transition); - /* 0x234 */ void (*destroy)(void* transition); - /* 0x238 */ void (*update)(void* transition, s32 updateRate); - /* 0x23C */ void (*draw)(void* transition, Gfx** gfxP); - /* 0x240 */ void (*start)(void* transition); - /* 0x244 */ void (*setType)(void* transition, s32 type); - /* 0x248 */ void (*setColor)(void* transition, u32 color); - /* 0x24C */ void (*setEnvColor)(void* transition, u32 color); - /* 0x250 */ s32 (*isDone)(void* transition); - /* 0x254 */ char unk_254[0x4]; -} TransitionContext; // size = 0x258 - -typedef struct { - /* 0x0 */ char unk_0[0xC]; -} TransitionFade; // size = 0xC typedef enum { - /* 0 */ TRANSITION_CIRCLE_IN, - /* 1 */ TRANSITION_CIRCLE_OUT, -} TransitionCircleDirection; + /* 1 */ TRANS_INSTANCE_TYPE_FILL_OUT = 1, + /* 2 */ TRANS_INSTANCE_TYPE_FILL_IN, +} TransitionInstanceType; + +#define TRANS_INSTANCE_TYPE_FADE_FLASH 3 + +typedef struct { + /* 0x0 */ u8 type; + /* 0x1 */ u8 isDone; + /* 0x2 */ u8 direction; + /* 0x4 */ Color_RGBA8_u32 color; + /* 0x8 */ u16 timer; +} TransitionFade; // size = 0xC #define FBDEMO_CIRCLE_GET_MASK_TYPE(type) (type & 1) @@ -76,4 +99,111 @@ typedef struct { /* 0x1F */ s8 unk_1F; // Set to 0 and never used } TransitionCircle; // size = 0x20 +#define TRANS_TRIGGER_OFF 0 // transition is not active +#define TRANS_TRIGGER_START 20 // start transition (exiting an area) +#define TRANS_TRIGGER_END -20 // transition is ending (arriving in a new area) + +typedef enum { + /* 0 */ TRANS_MODE_OFF, + /* 1 */ TRANS_MODE_SETUP, + /* 2 */ TRANS_MODE_INSTANCE_INIT, + /* 3 */ TRANS_MODE_INSTANCE_RUNNING, + /* 4 */ TRANS_MODE_FILL_WHITE_INIT, + /* 5 */ TRANS_MODE_FILL_IN, + /* 6 */ TRANS_MODE_FILL_OUT, + /* 7 */ TRANS_MODE_FILL_BROWN_INIT, + /* 8 */ TRANS_MODE_08, // unused + /* 9 */ TRANS_MODE_09, // unused + /* 10 */ TRANS_MODE_INSTANT, + /* 11 */ TRANS_MODE_INSTANCE_WAIT, + /* 12 */ TRANS_MODE_SANDSTORM_INIT, + /* 13 */ TRANS_MODE_SANDSTORM, + /* 14 */ TRANS_MODE_SANDSTORM_END_INIT, + /* 15 */ TRANS_MODE_SANDSTORM_END, + /* 16 */ TRANS_MODE_CS_BLACK_FILL_INIT, + /* 17 */ TRANS_MODE_CS_BLACK_FILL +} TransitionMode; + +#define TRANS_TYPE_WIPE4 (1 << 5) +#define TRANS_TYPE_WIPE3 (1 << 6) +#define TRANS_TYPE_SET_PARAMS (1 << 7) + +typedef enum { + /* 0 */ TRANS_TYPE_WIPE, + /* 1 */ TRANS_TYPE_TRIFORCE, + /* 2 */ TRANS_TYPE_FADE_BLACK, + /* 3 */ TRANS_TYPE_FADE_WHITE, + /* 4 */ TRANS_TYPE_FADE_BLACK_FAST, + /* 5 */ TRANS_TYPE_FADE_WHITE_FAST, + /* 6 */ TRANS_TYPE_FADE_BLACK_SLOW, + /* 7 */ TRANS_TYPE_FADE_WHITE_SLOW, + /* 8 */ TRANS_TYPE_WIPE_FAST, + /* 9 */ TRANS_TYPE_FILL_WHITE_FAST, // Not actually fast due to bug in Play_UpdateTransition + /* 10 */ TRANS_TYPE_FILL_WHITE, + /* 11 */ TRANS_TYPE_INSTANT, + /* 12 */ TRANS_TYPE_FILL_BROWN, + /* 13 */ TRANS_TYPE_FADE_WHITE_CS_DELAYED, + /* 14 */ TRANS_TYPE_SANDSTORM_PERSIST, + /* 15 */ TRANS_TYPE_SANDSTORM_END, + /* 16 */ TRANS_TYPE_CS_BLACK_FILL, + /* 17 */ TRANS_TYPE_FADE_WHITE_INSTANT, + /* 18 */ TRANS_TYPE_FADE_GREEN, + /* 19 */ TRANS_TYPE_FADE_BLUE, + /* 20 */ TRANS_TYPE_FADE_DYNAMIC, // Chooses Black or White based on time of day + /* 21 */ TRANS_TYPE_CIRCLE, + /* 22 */ TRANS_TYPE_WIPE5, + // transition types 23 - 31 are unused + // transition types 32 - 39 are Wipe4 TODO needs macro + /* 38 */ TRANS_TYPE_38 = 38, + // transition types 40 - 63 are unused + // transition types 64 - 127 are Wipe3 TODO needs macro + /* 64 */ TRANS_TYPE_64 = 64, + /* 70 */ TRANS_TYPE_70 = 70, + /* 72 */ TRANS_TYPE_72 = 72, + /* 73 */ TRANS_TYPE_73, + /* 80 */ TRANS_TYPE_80 = 80, + /* 86 */ TRANS_TYPE_86 = 86 +} TransitionType; + +#define DEFINE_TRANSITION(enumValue, _structName, _instanceName, _name) enumValue, +#define DEFINE_TRANSITION_INTERNAL(enumValue, _structName, _instanceName) enumValue, + +typedef enum FbDemoType { + #include "tables/transition_table.h" + /* 7 */ FBDEMO_MAX +} FbDemoType; + +#undef DEFINE_TRANSITION +#undef DEFINE_TRANSITION_INTERNAL + +#define TRANS_NEXT_TYPE_DEFAULT 0xFF + +#define DEFINE_TRANSITION(_enumValue, structName, instanceName, _name) structName instanceName; +#define DEFINE_TRANSITION_INTERNAL(_enumValue, structName, instanceName) structName instanceName; + +typedef union TransitionInstance { + #include "tables/transition_table.h" +} TransitionInstance; // size = 0x218 + +#undef DEFINE_TRANSITION +#undef DEFINE_TRANSITION_INTERNAL + +typedef struct { + /* 0x000 */ s16 transitionType; + /* 0x002 */ s8 fbdemoType; + /* 0x003 */ char unk_003[0x5]; + /* 0x008 */ TransitionInstance instanceData; + /* 0x220 */ char unk_220[0x10]; + /* 0x230 */ void* (*init)(void* transition); + /* 0x234 */ void (*destroy)(void* transition); + /* 0x238 */ void (*update)(void* transition, s32 updateRate); + /* 0x23C */ void (*draw)(void* transition, Gfx** gfxP); + /* 0x240 */ void (*start)(void* transition); + /* 0x244 */ void (*setType)(void* transition, s32 type); + /* 0x248 */ void (*setColor)(void* transition, u32 color); + /* 0x24C */ void (*setEnvColor)(void* transition, u32 color); + /* 0x250 */ s32 (*isDone)(void* transition); + /* 0x254 */ char unk_254[0x4]; +} TransitionContext; // size = 0x258 + #endif diff --git a/include/z_en_hy_code.h b/include/z_en_hy_code.h index 0620d35a0..1a2b7847e 100644 --- a/include/z_en_hy_code.h +++ b/include/z_en_hy_code.h @@ -1,5 +1,5 @@ -#ifndef Z_EN_HY_CODE_H -#define Z_EN_HY_CODE_H +#ifndef Z64ENHY_CODE_H +#define Z64ENHY_CODE_H #include "global.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" diff --git a/include/z_fireobj.h b/include/z_fireobj.h new file mode 100644 index 000000000..7bd58d80a --- /dev/null +++ b/include/z_fireobj.h @@ -0,0 +1,77 @@ +#ifndef Z_FIREOBJ_H +#define Z_FIREOBJ_H + +#include "ultra64.h" +#include "color.h" +#include "z64collision_check.h" +#include "z64light.h" +#include "z64math.h" + +struct PlayState; +struct Actor; + + +typedef struct FireObjInitParams { + /* 0x0 */ f32 size; + /* 0x4 */ f32 dynamicSizeStep; + /* 0x8 */ u8 state; + /* 0x9 */ u8 sizeGrowsCos2; + /* 0xA */ u8 colorsIndex; + /* 0xB */ u8 flags; + /* 0xC */ u8 lightParamsIndex; +} FireObjInitParams; // size = 0x10 + +typedef struct FireObjColors { + /* 0x0 */ Color_RGBA8 primColor; + /* 0x4 */ u8 lod; + /* 0x5 */ Color_RGB8 envColor; +} FireObjColors; // size = 0x8 + +typedef struct FireObjLightParams { + /* 0x0 */ s16 radius; + /* 0x2 */ Color_RGB8 color; + /* 0x5 */ Color_RGB8 maxColorAdj; +} FireObjLightParams; // size = 0x8 + +typedef struct FireObjLight { + /* 0x00 */ LightNode* light; + /* 0x04 */ LightInfo lightInfo; + /* 0x12 */ u8 lightParamsIndex; +} FireObjLight; // size = 0x14 + +typedef struct FireObj { + /* 0x00 */ Vec3f position; + /* 0x0C */ f32 size; + /* 0x10 */ f32 sizeInv; + /* 0x14 */ f32 xScale; + /* 0x18 */ f32 yScale; + /* 0x1C */ f32 dynamicSize; + /* 0x20 */ f32 dynamicSizeStep; + /* 0x24 */ u8 state; // @see FireState enum + /* 0x25 */ u8 sizeGrowsCos2; + /* 0x26 */ u8 timer; + /* 0x27 */ u8 colorsIndex; + /* 0x28 */ u8 flags; // @see FIRE_FLAG_ + /* 0x2A */ s16 ignitionDelay; + /* 0x2C */ ColliderCylinder collision; + /* 0x78 */ FireObjLight light; +} FireObj; // size = 0x8B + +typedef enum FireState { + /* 0 */ FIRE_STATE_GROWING, + /* 1 */ FIRE_STATE_SHRINKING, + /* 2 */ FIRE_STATE_FULLY_LIT, + /* 3 */ FIRE_STATE_NOT_LIT, +} FireState; + +#define FIRE_FLAG_WATER_EXTINGUISHABLE (1 << 0) +#define FIRE_FLAG_INTERACT_STICK (1 << 1) + +void FireObj_SetPosition(FireObj* fire, Vec3f* pos); +void FireObj_Draw(struct PlayState* play, FireObj* fire); +void FireObj_Init(struct PlayState* play, FireObj* fire, FireObjInitParams* init, struct Actor* actor); +void FireObj_Destroy(struct PlayState* play, FireObj* fire); +void FireObj_SetState2(FireObj* fire, f32 dynamicSizeStep, u8 newState); +void FireObj_Update(struct PlayState* play, FireObj* fire, struct Actor* actor); + +#endif diff --git a/include/z_prenmi.h b/include/z_prenmi.h index 1aa1e6f99..04c3f5f16 100644 --- a/include/z_prenmi.h +++ b/include/z_prenmi.h @@ -1,5 +1,5 @@ -#ifndef Z64_PRENMI_H -#define Z64_PRENMI_H +#ifndef Z64PRENMI_H +#define Z64PRENMI_H #include "global.h" diff --git a/include/z_title_setup.h b/include/z_title_setup.h index 41e3f52f8..3b299af97 100644 --- a/include/z_title_setup.h +++ b/include/z_title_setup.h @@ -1,5 +1,5 @@ -#ifndef Z64_TITLE_SETUP_H -#define Z64_TITLE_SETUP_H +#ifndef Z64TITLE_SETUP_H +#define Z64TITLE_SETUP_H #include "global.h" diff --git a/spec b/spec index ba217e15b..4b8481a73 100644 --- a/spec +++ b/spec @@ -458,12 +458,9 @@ beginseg include "build/src/code/z_debug.o" include "build/src/code/z_debug_display.o" include "build/src/code/z_debug_mode.o" - include "build/data/code/z_debug_mode.data.o" - include "build/data/code/z_debug_mode.bss.o" include "build/src/code/z_demo.o" include "build/src/code/z_draw.o" include "build/src/code/z_eff_footmark.o" - include "build/data/code/z_eff_footmark.data.o" include "build/src/code/z_sound_source.o" include "build/src/code/z_elf_message.o" include "build/src/code/z_en_hy_code.o" @@ -473,7 +470,6 @@ beginseg include "build/data/code/z_eventmgr.bss.o" include "build/src/code/z_fcurve_data.o" include "build/src/code/z_fcurve_data_skelanime.o" - include "build/data/code/code_801BD830.data.o" include "build/src/code/z_fireobj.o" include "build/src/code/z_game_dlftbls.o" include "build/src/code/z_horse.o" @@ -508,12 +504,11 @@ beginseg include "build/src/code/z_rcp.o" pad_text include "build/src/code/z_room.o" - include "build/data/code/z_room.data.o" include "build/src/code/code_8012EC80.o" pad_text include "build/data/code/code_801C2410.data.o" include "build/src/code/z_scene.o" - include "build/data/code/code_801C2730.data.o" + include "build/src/code/object_table.o" include "build/src/code/z_scene_proc.o" include "build/src/code/z_scene_table.o" include "build/src/code/z_schedule.o" @@ -531,7 +526,7 @@ beginseg include "build/data/code/code_80140CE0.data.o" include "build/src/code/code_80140E80.o" include "build/src/code/z_vismono.o" - include "build/src/code/code_801420C0.o" + include "build/src/code/z_viszbuf.o" include "build/src/code/z_vr_box.o" include "build/src/code/z_vr_box_draw.o" include "build/src/code/z_sram_NES.o" @@ -543,27 +538,24 @@ beginseg include "build/src/code/z_message_staff.o" include "build/src/code/z_player_call.o" include "build/src/code/z_shrink_window.o" - include "build/src/code/db_camera.o" - include "build/data/code/db_camera.bss.o" + include "build/src/code/cutscene_camera.o" + include "build/data/code/cutscene_camera.bss.o" include "build/src/code/z_kaleido_manager.o" include "build/src/code/z_kaleido_scope_call.o" include "build/src/code/z_fbdemo_dlftbls.o" include "build/src/code/z_fbdemo.o" - include "build/data/code/z_fbdemo.data.o" include "build/src/code/z_fbdemo_fade.o" include "build/src/code/z_fbdemo_circle.o" include "build/src/code/z_overlay.o" include "build/src/code/z_play.o" - include "build/data/code/z_play.data.o" - include "build/data/code/z_play.bss.o" include "build/src/code/z_play_hireso.o" include "build/data/code/z_play_hireso.data.o" include "build/src/code/PreRender.o" include "build/data/code/PreRender.bss.o" include "build/src/code/TwoHeadGfxArena.o" include "build/src/code/TwoHeadArena.o" - include "build/src/code/code_80172BC0.o" - include "build/src/code/audioMgr.o" + include "build/src/code/audio_stop_all_sfx.o" + include "build/src/code/audio_thread_manager.o" include "build/src/code/title_setup.o" include "build/src/code/game.o" include "build/data/code/game.bss.o" @@ -575,15 +567,14 @@ beginseg include "build/data/code/main.data.o" include "build/data/code/main.bss.o" include "build/src/code/padmgr.o" - include "build/data/code/padmgr.data.o" include "build/src/code/sched.o" include "build/src/code/speed_meter.o" include "build/data/code/speed_meter.data.o" include "build/data/code/speed_meter.bss.o" include "build/src/code/su_mtx.o" + include "build/src/code/sys_cfb.o" include "build/data/code/sys_cfb.bss.o" include "build/src/code/sys_cmpdma.o" - include "build/data/code/sys_cmpdma.bss.o" include "build/src/code/sys_initial_check.o" include "build/src/code/sys_math.o" include "build/src/code/sys_math3d.o" @@ -604,34 +595,33 @@ beginseg pad_text pad_text pad_text - include "build/src/code/audio/audio_data.o" - include "build/src/code/audio/audio_synthesis.o" - include "build/src/code/audio/audio_heap.o" + include "build/src/audio/lib/data.o" + include "build/src/audio/lib/synthesis.o" + include "build/src/audio/lib/heap.o" include "build/data/code/audio_heap.bss.o" - include "build/src/code/audio/audio_load.o" - include "build/src/code/audio/audio_thread.o" - include "build/src/code/audio/audio_dcache.o" - include "build/src/code/audio/aisetnextbuf.o" - include "build/src/code/audio/audio_playback.o" - include "build/src/code/audio/audio_effects.o" - include "build/src/code/audio/audio_seqplayer.o" + include "build/src/audio/lib/load.o" + include "build/src/audio/lib/thread.o" + include "build/src/audio/lib/dcache.o" + include "build/src/audio/lib/aisetnextbuf.o" + include "build/src/audio/lib/playback.o" + include "build/src/audio/lib/effects.o" + include "build/src/audio/lib/seqplayer.o" include "build/data/code/audio_dramStack.data.o" include "build/asm/code/code_8019AE40.text.o" // handwritten pad_text include "build/asm/code/code_8019AEC0.text.o" // handwritten - include "build/src/code/audio/code_8019AF00.o" - include "build/src/code/audio/code_801A4EB0.o" - include "build/data/code/code_801A4EB0.data.o" - include "build/src/code/audio/code_801A51F0.o" - include "build/data/code/code_801A51F0.data.o" - include "build/data/code/code_801A51F0.bss.o" + include "build/src/audio/code_8019AF00.o" + include "build/src/audio/voice_external.o" + include "build/data/code/voice_external.data.o" + include "build/src/audio/voice_internal.o" + include "build/data/code/voice_internal.data.o" + include "build/data/code/voice_internal.bss.o" pad_text - include "build/src/code/audio/audio_sfx_params.o" - include "build/src/code/audio/code_801A5BD0.o" - include "build/src/code/audio/code_801A7B10.o" - include "build/data/code/code_801A7B10.data.o" - include "build/data/code/code_801A7B10.bss.o" - include "build/src/code/audio/audio_init_params.o" + include "build/src/audio/sfx_params.o" + include "build/src/audio/sfx.o" + include "build/src/audio/sequence.o" + include "build/data/code/sequence.bss.o" + include "build/src/audio/session_config.o" include "build/src/code/jpegutils.o" include "build/src/code/jpegdecoder.o" include_data_with_rodata "build/src/code/z_game_over.o" @@ -965,8 +955,7 @@ beginseg name "ovl_En_Dekubaba" compress include "build/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.o" - include "build/data/ovl_En_Dekubaba/ovl_En_Dekubaba.data.o" - include "build/data/ovl_En_Dekubaba/ovl_En_Dekubaba.reloc.o" + include "build/src/overlays/actors/ovl_En_Dekubaba/ovl_En_Dekubaba_reloc.o" endseg beginseg @@ -1008,7 +997,8 @@ beginseg name "ovl_Item_B_Heart" compress include "build/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.o" - include "build/src/overlays/actors/ovl_Item_B_Heart/ovl_Item_B_Heart_reloc.o" + include "build/data/ovl_Item_B_Heart/ovl_Item_B_Heart.data.o" + include "build/data/ovl_Item_B_Heart/ovl_Item_B_Heart.reloc.o" endseg beginseg @@ -1043,7 +1033,8 @@ beginseg name "ovl_Bg_Keikoku_Spr" compress include "build/src/overlays/actors/ovl_Bg_Keikoku_Spr/z_bg_keikoku_spr.o" - include "build/src/overlays/actors/ovl_Bg_Keikoku_Spr/ovl_Bg_Keikoku_Spr_reloc.o" + include "build/data/ovl_Bg_Keikoku_Spr/ovl_Bg_Keikoku_Spr.data.o" + include "build/data/ovl_Bg_Keikoku_Spr/ovl_Bg_Keikoku_Spr.reloc.o" endseg beginseg @@ -1979,8 +1970,7 @@ beginseg name "ovl_En_Si" compress include "build/src/overlays/actors/ovl_En_Si/z_en_si.o" - include "build/data/ovl_En_Si/ovl_En_Si.data.o" - include "build/data/ovl_En_Si/ovl_En_Si.reloc.o" + include "build/src/overlays/actors/ovl_En_Si/ovl_En_Si_reloc.o" endseg beginseg @@ -2123,7 +2113,8 @@ beginseg name "ovl_Door_Spiral" compress include "build/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.o" - include "build/src/overlays/actors/ovl_Door_Spiral/ovl_Door_Spiral_reloc.o" + include "build/data/ovl_Door_Spiral/ovl_Door_Spiral.data.o" + include "build/data/ovl_Door_Spiral/ovl_Door_Spiral.reloc.o" endseg beginseg @@ -2151,7 +2142,8 @@ beginseg name "ovl_Obj_Boyo" compress include "build/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.o" - include "build/src/overlays/actors/ovl_Obj_Boyo/ovl_Obj_Boyo_reloc.o" + include "build/data/ovl_Obj_Boyo/ovl_Obj_Boyo.data.o" + include "build/data/ovl_Obj_Boyo/ovl_Obj_Boyo.reloc.o" endseg beginseg @@ -2564,9 +2556,7 @@ beginseg name "ovl_En_Slime" compress include "build/src/overlays/actors/ovl_En_Slime/z_en_slime.o" - include "build/data/ovl_En_Slime/ovl_En_Slime.data.o" - include "build/data/ovl_En_Slime/ovl_En_Slime.bss.o" - include "build/data/ovl_En_Slime/ovl_En_Slime.reloc.o" + include "build/src/overlays/actors/ovl_En_Slime/ovl_En_Slime_reloc.o" endseg beginseg @@ -2971,11 +2961,7 @@ beginseg name "ovl_En_Tru" compress include "build/src/overlays/actors/ovl_En_Tru/z_en_tru.o" - #ifdef NON_MATCHING - include "build/src/overlays/actors/ovl_En_Tru/ovl_En_Tru_reloc.o" - #else - include "build/data/ovl_En_Tru/ovl_En_Tru.reloc.o" - #endif + include "build/src/overlays/actors/ovl_En_Tru/ovl_En_Tru_reloc.o" endseg beginseg @@ -3208,8 +3194,7 @@ beginseg name "ovl_fbdemo_wipe1" compress include "build/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.o" - include "build/data/ovl_fbdemo_wipe1/ovl_fbdemo_wipe1.data.o" - include "build/data/ovl_fbdemo_wipe1/ovl_fbdemo_wipe1.reloc.o" + include "build/src/overlays/fbdemos/ovl_fbdemo_wipe1/ovl_fbdemo_wipe1_reloc.o" endseg beginseg @@ -3344,7 +3329,8 @@ beginseg name "ovl_Bg_Lotus" compress include "build/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.o" - include "build/src/overlays/actors/ovl_Bg_Lotus/ovl_Bg_Lotus_reloc.o" + include "build/data/ovl_Bg_Lotus/ovl_Bg_Lotus.data.o" + include "build/data/ovl_Bg_Lotus/ovl_Bg_Lotus.reloc.o" endseg beginseg @@ -3431,8 +3417,7 @@ beginseg name "ovl_En_Stop_heishi" compress include "build/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.o" - include "build/data/ovl_En_Stop_heishi/ovl_En_Stop_heishi.data.o" - include "build/data/ovl_En_Stop_heishi/ovl_En_Stop_heishi.reloc.o" + include "build/src/overlays/actors/ovl_En_Stop_heishi/ovl_En_Stop_heishi_reloc.o" endseg beginseg @@ -3604,7 +3589,8 @@ beginseg name "ovl_Bg_Tobira01" compress include "build/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.o" - include "build/src/overlays/actors/ovl_Bg_Tobira01/ovl_Bg_Tobira01_reloc.o" + include "build/data/ovl_Bg_Tobira01/ovl_Bg_Tobira01.data.o" + include "build/data/ovl_Bg_Tobira01/ovl_Bg_Tobira01.reloc.o" endseg beginseg @@ -3822,7 +3808,9 @@ beginseg name "ovl_En_Invadepoh" compress include "build/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.o" - include "build/src/overlays/actors/ovl_En_Invadepoh/ovl_En_Invadepoh_reloc.o" + include "build/data/ovl_En_Invadepoh/ovl_En_Invadepoh.data.o" + include "build/data/ovl_En_Invadepoh/ovl_En_Invadepoh.bss.o" + include "build/data/ovl_En_Invadepoh/ovl_En_Invadepoh.reloc.o" endseg beginseg @@ -4026,8 +4014,7 @@ beginseg name "ovl_En_Ge2" compress include "build/src/overlays/actors/ovl_En_Ge2/z_en_ge2.o" - include "build/data/ovl_En_Ge2/ovl_En_Ge2.data.o" - include "build/data/ovl_En_Ge2/ovl_En_Ge2.reloc.o" + include "build/src/overlays/actors/ovl_En_Ge2/ovl_En_Ge2_reloc.o" endseg beginseg @@ -4895,8 +4882,7 @@ beginseg name "ovl_En_And" compress include "build/src/overlays/actors/ovl_En_And/z_en_and.o" - include "build/data/ovl_En_And/ovl_En_And.data.o" - include "build/data/ovl_En_And/ovl_En_And.reloc.o" + include "build/src/overlays/actors/ovl_En_And/ovl_En_And_reloc.o" endseg beginseg diff --git a/src/code/audio/code_8019AF00.c b/src/audio/code_8019AF00.c similarity index 94% rename from src/code/audio/code_8019AF00.c rename to src/audio/code_8019AF00.c index 801e2b076..287149c91 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/audio/code_8019AF00.c @@ -70,7 +70,7 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume); void Audio_StartMorningSceneSequence(u16 seqId); void Audio_StartSceneSequence(u16 seqId); -void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData); +void Audio_PlaySequenceWithSeqPlayerIO(s8 seqPlayerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData); void func_801A4428(u8 reverbIndex); void func_801A3038(void); void Audio_PlayAmbience(u8 ambienceId); @@ -2058,11 +2058,11 @@ const char sAudioOcarinaUnusedText6[] = "last key step is too short !!! %d:%d %d const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n"; void AudioOcarina_ReadControllerInput(void) { - Input inputs[4]; + Input inputs[MAXCONTROLLERS]; Input* input = &inputs[0]; u32 ocarinaInputButtonPrev = sOcarinaInputButtonCur; - Padmgr_GetInput2(inputs, 0); + PadMgr_GetInput2(inputs, false); sOcarinaInputButtonCur = input->cur.button; sOcarinaInputButtonPrev = ocarinaInputButtonPrev; sOcarinaInputStickRel.x = input->rel.stick_x; @@ -2734,8 +2734,7 @@ void AudioOcarina_SetOcarinaDisableTimer(u8 unused, u8 timer) { void AudioOcarina_SetInstrument(u8 ocarinaInstrumentId) { if ((sOcarinaInstrumentId != ocarinaInstrumentId) || (ocarinaInstrumentId == OCARINA_INSTRUMENT_DEFAULT)) { - Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_SFX) << 24) | ((u32)(1) << 16) | - ((u32)(SFX_CHANNEL_OCARINA) << 8) | (u32)(ocarinaInstrumentId)); + SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 1, ocarinaInstrumentId); sOcarinaInstrumentId = ocarinaInstrumentId; if (ocarinaInstrumentId == OCARINA_INSTRUMENT_OFF) { @@ -3303,7 +3302,10 @@ s32 AudioOcarina_MemoryGameNextNote(void) { sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcarinaMemoryGameAppendPos].length = 0; sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcarinaMemoryGameAppendPos + 1].pitch = OCARINA_PITCH_NONE; sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcarinaMemoryGameAppendPos + 1].length = 0; + + //! FAKE: if (1) {} + return false; } #undef OCARINA_SONG_MEMORY_GAME @@ -3355,7 +3357,7 @@ void AudioOcarina_Update(void) { #define OCARINA_INSTRUMENT_OOT_MAX 7 -void AudioOcarina_PlayLongScarecrowAfterCredits(void) { +void AudioOcarina_PlayLongScarecrowSong(void) { static u8 sScarecrowAfterCreditsState = 0; static u8 sScarecrowAfterCreditsIntrumentId = OCARINA_INSTRUMENT_DEFAULT; static u16 sScarecrowAfterCreditsTimer = 1200; @@ -3407,8 +3409,7 @@ void AudioOcarina_SetCustomSequence(void) { // Called by unused function void AudioOcarina_PlayCustomSequence(void) { sRequestCustomSequence = true; - Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_FANFARE) << 24) | ((u32)(0) << 0x10) | - (u32)(NA_BGM_DUNGEON_APPEAR)); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_FANFARE, 0, NA_BGM_DUNGEON_APPEAR); } // Unused @@ -3586,8 +3587,7 @@ s32 AudioOcarina_CreateCustomSequence(void) { void AudioOcarina_ResetInstrument(void) { if (sOcarinaInstrumentId != OCARINA_INSTRUMENT_OFF) { - Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_SFX) << 24) | ((u32)(1) << 16) | - ((u32)(SFX_CHANNEL_OCARINA) << 8) | (u32)(0)); + SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 1, 0); sOcarinaInstrumentId = OCARINA_INSTRUMENT_OFF; AudioOcarina_ResetAndMute(); } @@ -3629,7 +3629,7 @@ void Audio_Noop3(void) { } void Audio_Update(void) { - if ((func_801A9768() == 0) && (func_801A982C() == 0)) { + if ((AudioSeq_UpdateAudioHeapReset() == 0) && !AudioSeq_ResetReverb()) { AudioOcarina_SetCustomSequence(); AudioOcarina_Update(); func_801A5118(); @@ -3646,9 +3646,9 @@ void Audio_Update(void) { func_801A1290(); Audio_ResetRequestedSceneSeqId(); AudioSfx_ProcessRequests(); - func_801A89D0(); + AudioSeq_ProcessSeqCmds(); AudioSfx_ProcessActiveSfx(); - func_801A8D5C(); + AudioSeq_UpdateActiveSequences(); AudioSfx_ProcessSfxSettings(); AudioThread_ScheduleProcessCmds(); } @@ -3660,7 +3660,14 @@ void Audio_Noop4(s32 arg0) { void Audio_Noop5(s32 arg0, s32 arg1) { } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E110.s") +/** + * Queues a bgm sequence directly to the internal audio queue system. + * Skips the external audio command process + * Unused + */ +void Audio_PlayMainBgm(s8 seqId) { + AUDIOCMD_GLOBAL_INIT_SEQPLAYER(SEQ_PLAYER_BGM_MAIN, (u8)seqId, 1); +} f32 AudioSfx_ComputeVolume(u8 bankId, u8 entryIndex) { SfxBankEntry* bankEntry = &gSfxBanks[bankId][entryIndex]; @@ -4290,13 +4297,23 @@ f32 sBigBellsVolume[8] = { }; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0124.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0184.s") +void Audio_SetBgmVolumeOff(void) { + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_FANFARE, 0, 10); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_FANFARE, 0, 10); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A01C4.s") +void Audio_SetBgmVolumeOn(void) { + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_FANFARE, 0x7F, 3); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_FANFARE, 0x7F, 3); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0204.s") +void func_801A0204(s8 seqId) { + AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_BGM_MAIN, 2, (u8)seqId); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0238.s") +void Audio_SetMainBgmVolume(u8 targetVolume, u8 volumeFadeTimer) { + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, targetVolume, volumeFadeTimer); +} /** * Unused remnant from OoT's EnRiverSound @@ -4338,7 +4355,7 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) { if (sGanonsTowerVol != targetVolume) { // Sets the volume - Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, targetVolume, 2); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, targetVolume, 2); // Sets the filter cutoff of the form (lowPassFilterCutoff << 4) | (highPassFilter & 0xF). highPassFilter is // always set to 0 @@ -4350,8 +4367,7 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) { lowPassFilterCutoff = (((targetVolume - 0x40) >> 2) + 1) << 4; } - Audio_QueueSeqCmd((8 << 28) | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u8)(4) << 16) | ((u8)(15) << 8) | - (u8)(lowPassFilterCutoff)); + SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_BGM_MAIN, 15, 4, lowPassFilterCutoff); // Sets the reverb for (channelIndex = 0; channelIndex < ARRAY_COUNT(gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels); @@ -4399,14 +4415,14 @@ void Audio_UpdateRiverSoundVolumes(void) { if (sRiverSoundMainBgmLower == true) { if (sRiverSoundMainBgmCurrentVol != sRiverSoundMainBgmVol) { // lowers the volume for 1 frame - Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, sRiverSoundMainBgmVol, 10); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, sRiverSoundMainBgmVol, 10); sRiverSoundMainBgmCurrentVol = sRiverSoundMainBgmVol; sRiverSoundMainBgmRestore = true; } sRiverSoundMainBgmLower = false; } else if ((sRiverSoundMainBgmRestore == true) && !sAudioIsWindowOpen) { // restores the volume every frame - Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, 0x7F, 10); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, 0x7F, 10); sRiverSoundMainBgmCurrentVol = 0x7F; sRiverSoundMainBgmRestore = false; } @@ -4488,10 +4504,9 @@ void func_801A09D4(Vec3f* pos, f32 xzDistToPlayer) { volumeRel = ((1.0f - ((sRiverSoundXZDistToPlayer - 120.0f) / 280.0f)) * 0.9f) + 0.1f; } - for (channelIndex = 0; channelIndex < 16; channelIndex++) { + for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) { if (channelIndex != 9) { - Audio_QueueSeqCmd(((u32)(6) << 28) | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(2) << 16) | - ((u32)(channelIndex) << 8) | ((u8)(127.0f * volumeRel))); + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, channelIndex, 2, (u8)(127.0f * volumeRel)); AUDIOCMD_CHANNEL_SET_PAN(SEQ_PLAYER_BGM_MAIN, channelIndex, pan); } } @@ -4527,8 +4542,8 @@ void Audio_SplitBgmChannels(s8 volumeSplit) { u8 i; u8 channelIndex; - if ((Audio_GetActiveSequence(SEQ_PLAYER_FANFARE) == NA_BGM_DISABLED) && - (Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) != NA_BGM_ROMANI_RANCH)) { + if ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_FANFARE) == NA_BGM_DISABLED) && + (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) != NA_BGM_ROMANI_RANCH)) { for (i = 0; i < ARRAY_COUNT(sBgmPlayers); i++) { if (i == 0) { // Main Bgm SeqPlayer @@ -4556,7 +4571,7 @@ void Audio_SplitBgmChannels(s8 volumeSplit) { } } - Audio_QueueSeqCmd(0xA0000000 | ((u32)(sBgmPlayers[i]) << 24) | ((u32)(channelBits))); + SEQCMD_SET_CHANNEL_DISABLE_MASK(sBgmPlayers[i], channelBits); } } } @@ -4635,8 +4650,8 @@ void Audio_PlaySariaBgm(Vec3f* pos, u16 seqId, u16 distMax) { Audio_SplitBgmChannels(targetVolume); } - Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, targetVolume, 0); - Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F - targetVolume, 0); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_BGM_SUB, targetVolume, 0); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F - targetVolume, 0); } /** @@ -4650,12 +4665,12 @@ void Audio_ClearSariaBgm2(void) { void Audio_PlayMorningSceneSequence(u16 seqId, u8 dayMinusOne) { Audio_StartMorningSceneSequence(seqId); - Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(4) << 0x10) | (u32)(dayMinusOne)); + SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_BGM_MAIN, 4, dayMinusOne); } void Audio_StartMorningSceneSequence(u16 seqId) { if (seqId != NA_BGM_AMBIENCE) { - Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_AMBIENCE) << 24) | ((0) << 16)); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_AMBIENCE, 0); Audio_StartSceneSequence(seqId); Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, 0, 0, 1); } else { @@ -4669,8 +4684,7 @@ void Audio_PlaySceneSequence(u16 seqId, u8 dayMinusOne) { Audio_PlayAmbience(AMBIENCE_ID_08); } else if ((seqId != NA_BGM_FINAL_HOURS) || (sPrevMainBgmSeqId == NA_BGM_DISABLED)) { Audio_StartSceneSequence(seqId); - Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(4) << 0x10) | - (u32)(dayMinusOne)); + SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_BGM_MAIN, 4, dayMinusOne); } sRequestedSceneSeqId = seqId; } @@ -4710,7 +4724,7 @@ void Audio_StartSceneSequence(u16 seqId) { } void Audio_UpdateSceneSequenceResumePoint(void) { - u16 seqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); + u16 seqId = AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN); if ((seqId != NA_BGM_DISABLED) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_RESUME)) { if (sSeqResumePoint != SEQ_RESUME_POINT_NONE) { @@ -4723,55 +4737,95 @@ void Audio_UpdateSceneSequenceResumePoint(void) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A27E8.s") +// Unused +void Audio_PlayBgmForSongOfStorms(void) { + if (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_SONG_OF_STORMS) { + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_SONG_OF_STORMS | SEQ_FLAG_ASYNC); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A281C.s") +/** + * Specifically for SEQ_PLAYER_BGM_MAIN + */ +void Audio_ScaleTempoAndFreqForMainBgm(f32 freqTempoScale, u8 duration) { + if (freqTempoScale == 1.0f) { + SEQCMD_RESET_TEMPO(SEQ_PLAYER_BGM_MAIN, duration); + } else { + SEQCMD_SCALE_TEMPO(SEQ_PLAYER_BGM_MAIN, duration, freqTempoScale * 100.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A29D4.s") + SEQCMD_SET_SEQPLAYER_FREQ(SEQ_PLAYER_BGM_MAIN, duration, freqTempoScale * 1000.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2BB8.s") +void Audio_SetSeqTempoAndFreq(u8 seqPlayerIndex, f32 freqTempoScale, u8 duration) { + if (freqTempoScale == 1.0f) { + SEQCMD_RESET_TEMPO(seqPlayerIndex, duration); + } else { + SEQCMD_SCALE_TEMPO(seqPlayerIndex, duration, freqTempoScale * 100.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2C20.s") + SEQCMD_SET_SEQPLAYER_FREQ(seqPlayerIndex, duration, freqTempoScale * 1000.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2C44.s") +void Audio_PlaySubBgm(u16 seqId) { + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_BGM_SUB, 0x7F, 0); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_SUB, 0, seqId); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0, 5); + + SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX(SEQ_PLAYER_BGM_SUB, SEQ_PLAYER_BGM_MAIN, 3, 10); + SEQCMD_SETUP_SET_CHANNEL_DISABLE_MASK(SEQ_PLAYER_BGM_SUB, SEQ_PLAYER_BGM_MAIN, 0); +} + +void Audio_StopSubBgm(void) { + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_SUB, 0); +} + +// Unused remnant of OoT +void Audio_IncreaseTempoForTimedMinigame(void) { + if ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_TIMED_MINI_GAME) && + AudioSeq_IsSeqCmdNotQueued(SEQCMD_OP_PLAY_SEQUENCE << 28, SEQCMD_OP_MASK)) { + // Set tempo to be higher than the default tempo for th timed mini-game sequence + SEQCMD_SET_TEMPO(SEQ_PLAYER_BGM_MAIN, 5, 210); + } +} void Audio_PlaySequenceInCutscene(u16 seqId) { if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE) { Audio_PlayFanfare(seqId); } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE_KAMARO) { - Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_FANFARE) << 24) | ((u32)(0) << 0x10) | (u32)(seqId)); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_FANFARE, 0, seqId); } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_NO_AMBIENCE) { - Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_SUB) << 24) | ((u32)(0) << 0x10) | (u32)(seqId)); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_SUB, 0, seqId); } else { Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, 0, 7, SEQ_IO_VAL_NONE); - Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 1, 0x7F, 0); - Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, 0); - Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_FANFARE) << 24) | ((0) << 16)); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_FANFARE, 0x7F, 0); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F, 0); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); } } void Audio_StopSequenceInCutscene(u16 seqId) { if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE) { - Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_FANFARE) << 24) | ((0) << 16)); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE_KAMARO) { - Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_FANFARE) << 24) | ((0) << 16)); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_NO_AMBIENCE) { - Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_SUB) << 24) | ((0) << 16)); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_SUB, 0); } else { - Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((0) << 16)); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); } } s32 Audio_IsSequencePlaying(u8 seqId) { - u8 playerIndex = SEQ_PLAYER_BGM_MAIN; + u8 seqPlayerIndex = SEQ_PLAYER_BGM_MAIN; if (sSeqFlags[seqId & 0xFF] & SEQ_FLAG_FANFARE) { - playerIndex = SEQ_PLAYER_FANFARE; + seqPlayerIndex = SEQ_PLAYER_FANFARE; } else if (sSeqFlags[seqId & 0xFF] & SEQ_FLAG_FANFARE_KAMARO) { - playerIndex = SEQ_PLAYER_FANFARE; + seqPlayerIndex = SEQ_PLAYER_FANFARE; } - if (seqId == (Audio_GetActiveSequence(playerIndex) & 0xFF)) { + if (seqId == (AudioSeq_GetActiveSeqId(seqPlayerIndex) & 0xFF)) { return true; } else { return false; @@ -4779,7 +4833,7 @@ s32 Audio_IsSequencePlaying(u8 seqId) { } void Audio_PlayBgm_StorePrevBgm(u16 seqId) { - u16 curSeqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); + u16 curSeqId = AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN); if (curSeqId == NA_BGM_DISABLED) { curSeqId = NA_BGM_GENERAL_SFX; @@ -4793,7 +4847,7 @@ void Audio_PlayBgm_StorePrevBgm(u16 seqId) { sPrevMainBgmSeqId = curSeqId; } - Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(0) << 0x10) | (u32)(seqId + 0x8000)); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, seqId + SEQ_FLAG_ASYNC); } } @@ -4801,16 +4855,15 @@ void Audio_PlayBgm_StorePrevBgm(u16 seqId) { * To be used in conjunction with Audio_PlayBgm_StorePrevBgm */ void Audio_RestorePrevBgm(void) { - if ((Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) != NA_BGM_DISABLED) && - (sSeqFlags[Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) & 0xFF] & SEQ_FLAG_RESTORE)) { + if ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_DISABLED) && + (sSeqFlags[AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) & 0xFF] & SEQ_FLAG_RESTORE)) { if ((sPrevMainBgmSeqId == NA_BGM_DISABLED) || (sPrevMainBgmSeqId == NA_BGM_GENERAL_SFX)) { - Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((0) << 16)); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); } else { if (sPrevMainBgmSeqId == NA_BGM_AMBIENCE) { sPrevMainBgmSeqId = sPrevAmbienceSeqId; } - Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(0) << 0x10) | - (u32)(sPrevMainBgmSeqId + 0x8000)); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, sPrevMainBgmSeqId + SEQ_FLAG_ASYNC); } sPrevMainBgmSeqId = NA_BGM_DISABLED; } @@ -4818,7 +4871,7 @@ void Audio_RestorePrevBgm(void) { // Unused void Audio_PlayAmbience_StorePrevBgm(u8 ambienceId) { - u16 seqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); + u16 seqId = AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN); if (seqId != NA_BGM_AMBIENCE) { sPrevMainBgmSeqId = seqId; @@ -4830,8 +4883,7 @@ void Audio_PlayAmbience_StorePrevBgm(u8 ambienceId) { // Unused void Audio_ForceRestorePreviousBgm(void) { if (sPrevMainBgmSeqId != NA_BGM_DISABLED) { - Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(0) << 0x10) | - (u32)(sPrevMainBgmSeqId + 0x8000)); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, sPrevMainBgmSeqId + SEQ_FLAG_ASYNC); } sPrevMainBgmSeqId = NA_BGM_DISABLED; @@ -4847,16 +4899,16 @@ void Audio_ForceRestorePreviousBgm(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A31EC.s") -void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData) { +void Audio_PlaySequenceWithSeqPlayerIO(s8 seqPlayerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData) { u16 flaggedSeqId; - Audio_QueueSeqCmd(0x70000000 | ((u32)(playerIndex) << 24) | ((u32)(ioPort) << 0x10) | (u32)(ioData)); + SEQCMD_SET_SEQPLAYER_IO(seqPlayerIndex, ioPort, ioData); if ((seqId & 0xFF) < 2) { flaggedSeqId = seqId; } else { flaggedSeqId = seqId | 0x8000; } - Audio_QueueSeqCmd(0x00000000 | ((u32)(playerIndex) << 24) | ((u32)(fadeInDuration) << 0x10) | (u32)(flaggedSeqId)); + SEQCMD_PLAY_SEQUENCE((u32)seqPlayerIndex, fadeInDuration, flaggedSeqId); } void Audio_SetSequenceMode(u8 seqMode) { @@ -4884,17 +4936,18 @@ void Audio_SetSequenceMode(u8 seqMode) { volumeFadeInTimer = gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[1] - sBgmEnemyVolume; } - Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, sBgmEnemyVolume, volumeFadeInTimer); - Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_SUB) << 24) | ((u32)(10) << 0x10) | - (u32)(NA_BGM_ENEMY | 0x800)); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_BGM_SUB, sBgmEnemyVolume, + volumeFadeInTimer); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_SUB, 10, NA_BGM_ENEMY | 0x800); if (seqId >= NA_BGM_TERMINA_FIELD) { - Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F - sBgmEnemyVolume, 10); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F - sBgmEnemyVolume, + 10); Audio_SplitBgmChannels(sBgmEnemyVolume); } } else if ((sPrevSeqMode & 0x7F) == SEQ_MODE_ENEMY) { // If only sPrevSeqMode = SEQ_MODE_ENEMY (End) - Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_SUB) << 24) | ((10) << 16)); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_SUB, 10); if (seqMode == SEQ_MODE_IGNORE) { volumeFadeOutTimer = 0; @@ -4902,7 +4955,7 @@ void Audio_SetSequenceMode(u8 seqMode) { volumeFadeOutTimer = 10; } - Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, volumeFadeOutTimer); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F, volumeFadeOutTimer); Audio_SplitBgmChannels(0); } @@ -4910,10 +4963,9 @@ void Audio_SetSequenceMode(u8 seqMode) { } else { if (seqMode == SEQ_MODE_ENEMY) { // If both seqMode = sPrevSeqMode = SEQ_MODE_ENEMY - if ((Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) == NA_BGM_DISABLED) && + if ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) == NA_BGM_DISABLED) && (seqId != NA_BGM_DISABLED) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_ENEMY)) { - Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_SUB) << 24) | ((u32)(10) << 0x10) | - (u32)(NA_BGM_ENEMY | 0x800)); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_SUB, 10, NA_BGM_ENEMY | 0x800); sPrevSeqMode = seqMode + 0x80; } } @@ -4935,7 +4987,7 @@ void Audio_SetSequenceMode(u8 seqMode) { } sPrevSeqMode = seqMode; - Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(2) << 0x10) | (u32)(seqMode)); + SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_BGM_MAIN, 2, seqMode); } } } @@ -4956,10 +5008,10 @@ void Audio_UpdateEnemyBgmVolume(f32 dist) { } sBgmEnemyVolume = ((350.0f - adjDist) * 127.0f) / 350.0f; - Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, sBgmEnemyVolume, 10); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_BGM_SUB, sBgmEnemyVolume, 10); if ((seqId >= NA_BGM_TERMINA_FIELD) && !(sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE_KAMARO)) { - Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, (0x7F - sBgmEnemyVolume), 10); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, (0x7F - sBgmEnemyVolume), 10); } } @@ -5032,7 +5084,8 @@ void Audio_ResetRequestedSceneSeqId(void) { sRequestedSceneSeqId = NA_BGM_DISABLED; } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A44D4.s") +void Audio_ResetData(void); +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_ResetData.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A46F8.s") @@ -5046,13 +5099,15 @@ void Audio_SetAmbienceChannelIO(u8 channelIndexRange, u8 ioPort, u8 ioData) { u8 lastChannelIndex; u8 channelIndex; - if ((gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId != NA_BGM_AMBIENCE) && func_801A8ABC(NA_BGM_AMBIENCE, 0xF00000FF)) { + if ((gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId != NA_BGM_AMBIENCE) && + AudioSeq_IsSeqCmdNotQueued((SEQCMD_OP_PLAY_SEQUENCE << 28) | NA_BGM_AMBIENCE, + SEQCMD_OP_MASK | SEQCMD_SEQID_MASK)) { return; } // channelIndexRange = 01 on ioPort 1 if ((((channelIndexRange << 8) + (u32)ioPort) == ((1 << 8) | (u32)1)) && - (Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) != NA_BGM_ROMANI_RANCH)) { + (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) != NA_BGM_ROMANI_RANCH)) { D_801FD3A8 = 0; } @@ -5064,38 +5119,33 @@ void Audio_SetAmbienceChannelIO(u8 channelIndexRange, u8 ioPort, u8 ioData) { } for (channelIndex = firstChannelIndex; channelIndex <= lastChannelIndex; channelIndex++) { - Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(ioPort) << 16) | - ((u32)(channelIndex) << 8) | (u32)(ioData)); + SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_AMBIENCE, channelIndex, ioPort, ioData); } } void Audio_StartAmbience(u16 initChannelMask, u16 initMuteChannelMask) { u8 channelIndex; - Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(SEQ_PLAYER_IO_PORT_0) << 0x10) | - (u32)(1)); - Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(SEQ_PLAYER_IO_PORT_4) << 0x10) | - (u32)((u8)(initChannelMask >> 8))); - Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(SEQ_PLAYER_IO_PORT_5) << 0x10) | - (u32)((u8)(initChannelMask & 0xFF))); - Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, 0x7F, 1); + SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_AMBIENCE, SEQ_PLAYER_IO_PORT_0, 1); + SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_AMBIENCE, SEQ_PLAYER_IO_PORT_4, (u8)(initChannelMask >> 8)); + SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_AMBIENCE, SEQ_PLAYER_IO_PORT_5, (u8)(initChannelMask & 0xFF)); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, 0x7F, 1); - if ((Audio_GetActiveSequence(SEQ_PLAYER_AMBIENCE) != NA_BGM_DISABLED) && - (Audio_GetActiveSequence(SEQ_PLAYER_AMBIENCE) != NA_BGM_AMBIENCE)) { - Audio_StopSequence(SEQ_PLAYER_AMBIENCE, 0); + if ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_AMBIENCE) != NA_BGM_DISABLED) && + (AudioSeq_GetActiveSeqId(SEQ_PLAYER_AMBIENCE) != NA_BGM_AMBIENCE)) { + AudioSeq_StopSequence(SEQ_PLAYER_AMBIENCE, 0); AUDIOCMD_GLOBAL_STOP_AUDIOCMDS(); } - if (Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) == (NA_BGM_ENEMY | 0x800)) { - Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, 1); + if (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) == (NA_BGM_ENEMY | 0x800)) { + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F, 1); } - Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(0) << 0x10) | (u32)(NA_BGM_AMBIENCE)); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_AMBIENCE, 0, NA_BGM_AMBIENCE); - for (channelIndex = 0; channelIndex < 16; channelIndex++) { + for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) { if (!(initMuteChannelMask & (1 << channelIndex)) && (initChannelMask & (1 << channelIndex))) { - Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(CHANNEL_IO_PORT_1) << 16) | - ((u32)(channelIndex) << 8) | (u32)(1)); + SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_AMBIENCE, channelIndex, CHANNEL_IO_PORT_1, 1); } } } @@ -5119,12 +5169,10 @@ void Audio_PlayAmbience(u8 ambienceId) { channelIndex = sAmbienceData[ambienceId].channelProperties[i++]; ioPort = sAmbienceData[ambienceId].channelProperties[i++]; ioData = sAmbienceData[ambienceId].channelProperties[i++]; - Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(ioPort) << 16) | - ((u32)(channelIndex) << 8) | (u32)(ioData)); + SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_AMBIENCE, channelIndex, ioPort, ioData); } - Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(CHANNEL_IO_PORT_7) << 16) | - ((u32)(AMBIENCE_CHANNEL_SOUND_MODE) << 8) | (u32)(sSoundMode)); + SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_AMBIENCE, AMBIENCE_CHANNEL_SOUND_MODE, CHANNEL_IO_PORT_7, sSoundMode); } } @@ -5155,7 +5203,7 @@ void AudioSfx_Init(u16 fadeTimer) { u8 channelIndex; AudioThread_ScheduleProcessCmds(); - Audio_StartSequence(SEQ_PLAYER_SFX, NA_BGM_GENERAL_SFX, 0x70, fadeTimer); + AudioSeq_StartSequence(SEQ_PLAYER_SFX, NA_BGM_GENERAL_SFX, 0x70, fadeTimer); for (channelIndex = 0; channelIndex < ARRAY_COUNT(sSfxChannelState); channelIndex++) { AUDIOCMD_CHANNEL_SET_SFX_STATE(SEQ_PLAYER_SFX, channelIndex, &sSfxChannelState[channelIndex]); @@ -5165,12 +5213,52 @@ void AudioSfx_Init(u16 fadeTimer) { AUDIOCMD_GLOBAL_SET_CUSTOM_FUNCTION(AUDIO_CUSTOM_FUNCTION_SEQ_1, Audio_SetAmbienceRandomBend); } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4D00.s") +void Audio_InitSound(void) { + Audio_ResetData(); + AudioOcarina_ResetStaffs(); + AudioSfx_ResetSfxChannelState(); + AudioSeq_ResetActiveSequencesAndVolume(); + AudioSfx_Reset(); + AudioVoice_ResetData(); + AudioSfx_Init(10); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4D50.s") +void Audio_ResetForAudioHeapStep3(void) { + AudioSfx_Init(1); + AUDIOCMD_GLOBAL_UNMUTE(AUDIOCMD_ALL_SEQPLAYERS, true); + AudioThread_ScheduleProcessCmds(); + AUDIOCMD_GLOBAL_STOP_AUDIOCMDS(); + sIsFinalHoursOrSoaring = false; + sObjSoundMainBgmSeqId = NA_BGM_GENERAL_SFX; + sMuteOnlySfxAndAmbienceSeq = false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4DA4.s") +void Audio_ResetForAudioHeapStep2(void) { + Audio_ResetForAudioHeapStep3(); + if (gAudioSpecId < ARRAY_COUNT(gReverbSettingsTable)) { + AUDIOCMD_GLOBAL_SET_REVERB_DATA(1, REVERB_DATA_TYPE_SETTINGS, &gReverbSettingsTable[gAudioSpecId][1]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4DF4.s") +void Audio_ResetForAudioHeapStep1(s32 specId) { + gAudioHeapResetState = AUDIO_HEAP_RESET_STATE_RESETTING; + Audio_ResetData(); + AudioOcarina_ResetStaffs(); + AudioSfx_ResetSfxChannelState(); + AudioSeq_ResetActiveSequences(); + AudioSfx_Reset(); + func_801A4FD8(); + if (gAudioSpecId == 0xB) { + AudioSfx_MuteBanks((1 << BANK_PLAYER) | (1 << BANK_ITEM) | (1 << BANK_ENV) | (1 << BANK_ENEMY) | + (1 << BANK_OCARINA) | (1 << BANK_VOICE)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4E64.s") +void Audio_UnusedReset(void) { + AudioSeq_ResetActiveSequences(); + AUDIOCMD_GLOBAL_UNMUTE(AUDIOCMD_ALL_SEQPLAYERS, true); + Audio_ResetData(); + AudioSfx_ResetSfxChannelState(); + AudioSfx_Init(1); + func_801A4FD8(); +} diff --git a/src/code/audio/aisetnextbuf.c b/src/audio/lib/aisetnextbuf.c similarity index 100% rename from src/code/audio/aisetnextbuf.c rename to src/audio/lib/aisetnextbuf.c diff --git a/src/code/audio/audio_data.c b/src/audio/lib/data.c similarity index 100% rename from src/code/audio/audio_data.c rename to src/audio/lib/data.c diff --git a/src/code/audio/audio_dcache.c b/src/audio/lib/dcache.c similarity index 100% rename from src/code/audio/audio_dcache.c rename to src/audio/lib/dcache.c diff --git a/src/code/audio/audio_effects.c b/src/audio/lib/effects.c similarity index 99% rename from src/code/audio/audio_effects.c rename to src/audio/lib/effects.c index 0dcdcda88..feddf73ca 100644 --- a/src/code/audio/audio_effects.c +++ b/src/audio/lib/effects.c @@ -64,7 +64,7 @@ void AudioEffects_SequencePlayerProcessSound(SequencePlayer* seqPlayer) { seqPlayer->fadeTimer--; if ((seqPlayer->fadeTimer == 0) && (seqPlayer->state == SEQPLAYER_STATE_FADE_OUT)) { - AudioSeq_SequencePlayerDisable(seqPlayer); + AudioScript_SequencePlayerDisable(seqPlayer); return; } } diff --git a/src/code/audio/audio_heap.c b/src/audio/lib/heap.c similarity index 99% rename from src/code/audio/audio_heap.c rename to src/audio/lib/heap.c index d767f7de3..0a64c0d1b 100644 --- a/src/code/audio/audio_heap.c +++ b/src/audio/lib/heap.c @@ -86,7 +86,7 @@ void AudioHeap_DiscardFont(s32 fontId) { AudioPlayback_NoteDisable(note); AudioPlayback_AudioListRemove(¬e->listItem); - AudioSeq_AudioListPushBack(&gAudioCtx.noteFreeLists.disabled, ¬e->listItem); + AudioScript_AudioListPushBack(&gAudioCtx.noteFreeLists.disabled, ¬e->listItem); } } } @@ -113,7 +113,7 @@ void AudioHeap_DiscardSequence(s32 seqId) { for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) { if (gAudioCtx.seqPlayers[i].enabled && gAudioCtx.seqPlayers[i].seqId == seqId) { - AudioSeq_SequencePlayerDisable(&gAudioCtx.seqPlayers[i]); + AudioScript_SequencePlayerDisable(&gAudioCtx.seqPlayers[i]); } } } @@ -857,7 +857,7 @@ s32 AudioHeap_ResetStep(void) { switch (gAudioCtx.resetStatus) { case 5: for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) { - AudioSeq_SequencePlayerDisableAsFinished(&gAudioCtx.seqPlayers[i]); + AudioScript_SequencePlayerDisableAsFinished(&gAudioCtx.seqPlayers[i]); } gAudioCtx.audioResetFadeOutFramesLeft = 2 / count; gAudioCtx.resetStatus--; @@ -1059,10 +1059,10 @@ void AudioHeap_Init(void) { } // Initialize sequence players - AudioSeq_InitSequencePlayers(); + AudioScript_InitSequencePlayers(); for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) { - AudioSeq_InitSequencePlayerChannels(i); - AudioSeq_ResetSequencePlayer(&gAudioCtx.seqPlayers[i]); + AudioScript_InitSequencePlayerChannels(i); + AudioScript_ResetSequencePlayer(&gAudioCtx.seqPlayers[i]); } // Initialize two additional caches on the audio heap to store individual audio samples diff --git a/src/code/audio/audio_load.c b/src/audio/lib/load.c similarity index 99% rename from src/code/audio/audio_load.c rename to src/audio/lib/load.c index 28c27d2cc..3a4f1c1e0 100644 --- a/src/code/audio/audio_load.c +++ b/src/audio/lib/load.c @@ -11,6 +11,7 @@ */ #include "global.h" +#include "buffers.h" /** * SoundFont Notes: @@ -583,7 +584,7 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIndex, s32 seqId, s32 arg2) { return 0; } - AudioSeq_SequencePlayerDisable(seqPlayer); + AudioScript_SequencePlayerDisable(seqPlayer); if (1) {} fontId = 0xFF; @@ -601,7 +602,7 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIndex, s32 seqId, s32 arg2) { return 0; } - AudioSeq_ResetSequencePlayer(seqPlayer); + AudioScript_ResetSequencePlayer(seqPlayer); seqPlayer->seqId = seqId; if (fontId != 0xFF) { diff --git a/src/code/audio/audio_playback.c b/src/audio/lib/playback.c similarity index 97% rename from src/code/audio/audio_playback.c rename to src/audio/lib/playback.c index 9f3c6f8ed..deb6e82b9 100644 --- a/src/code/audio/audio_playback.c +++ b/src/audio/lib/playback.c @@ -189,7 +189,7 @@ void AudioPlayback_ProcessNotes(void) { (playbackState->priority >= 1)) { // do nothing } else if (playbackState->parentLayer->channel->seqPlayer == NULL) { - AudioSeq_SequenceChannelDisable(playbackState->parentLayer->channel); + AudioScript_SequenceChannelDisable(playbackState->parentLayer->channel); playbackState->priority = 1; playbackState->status = PLAYBACK_STATUS_1; continue; @@ -224,13 +224,13 @@ void AudioPlayback_ProcessNotes(void) { AudioEffects_NoteVibratoInit(note); AudioEffects_NotePortamentoInit(note); AudioPlayback_AudioListRemove(¬e->listItem); - AudioSeq_AudioListPushBack(¬e->listItem.pool->active, ¬e->listItem); + AudioScript_AudioListPushBack(¬e->listItem.pool->active, ¬e->listItem); playbackState->wantedParentLayer = NO_LAYER; // don't skip } else { AudioPlayback_NoteDisable(note); AudioPlayback_AudioListRemove(¬e->listItem); - AudioSeq_AudioListPushBack(¬e->listItem.pool->disabled, ¬e->listItem); + AudioScript_AudioListPushBack(¬e->listItem.pool->disabled, ¬e->listItem); playbackState->wantedParentLayer = NO_LAYER; goto skip; } @@ -240,7 +240,7 @@ void AudioPlayback_ProcessNotes(void) { } AudioPlayback_NoteDisable(note); AudioPlayback_AudioListRemove(¬e->listItem); - AudioSeq_AudioListPushBack(¬e->listItem.pool->disabled, ¬e->listItem); + AudioScript_AudioListPushBack(¬e->listItem.pool->disabled, ¬e->listItem); continue; } } @@ -250,7 +250,7 @@ void AudioPlayback_ProcessNotes(void) { } AudioPlayback_NoteDisable(note); AudioPlayback_AudioListRemove(¬e->listItem); - AudioSeq_AudioListPushBack(¬e->listItem.pool->disabled, ¬e->listItem); + AudioScript_AudioListPushBack(¬e->listItem.pool->disabled, ¬e->listItem); continue; } @@ -669,7 +669,7 @@ void AudioPlayback_InitNoteFreeList(void) { for (i = 0; i < gAudioCtx.numNotes; i++) { gAudioCtx.notes[i].listItem.u.value = &gAudioCtx.notes[i]; gAudioCtx.notes[i].listItem.prev = NULL; - AudioSeq_AudioListPushBack(&gAudioCtx.noteFreeLists.disabled, &gAudioCtx.notes[i].listItem); + AudioScript_AudioListPushBack(&gAudioCtx.noteFreeLists.disabled, &gAudioCtx.notes[i].listItem); } } @@ -708,7 +708,7 @@ void AudioPlayback_NotePoolClear(NotePool* pool) { break; } AudioPlayback_AudioListRemove(cur); - AudioSeq_AudioListPushBack(dest, cur); + AudioScript_AudioListPushBack(dest, cur); } } } @@ -750,11 +750,11 @@ void AudioPlayback_NotePoolFill(NotePool* pool, s32 count) { } while (j < count) { - note = AudioSeq_AudioListPopBack(source); + note = AudioScript_AudioListPopBack(source); if (note == NULL) { break; } - AudioSeq_AudioListPushBack(dest, ¬e->listItem); + AudioScript_AudioListPushBack(dest, ¬e->listItem); j++; } } @@ -867,7 +867,8 @@ void AudioPlayback_NoteReleaseAndTakeOwnership(Note* note, SequenceLayer* layer) } Note* AudioPlayback_AllocNoteFromDisabled(NotePool* pool, SequenceLayer* layer) { - Note* note = AudioSeq_AudioListPopBack(&pool->disabled); + Note* note = AudioScript_AudioListPopBack(&pool->disabled); + if (note != NULL) { AudioPlayback_NoteInitForLayer(note, layer); AudioPlayback_AudioListPushFront(&pool->active, ¬e->listItem); @@ -881,7 +882,7 @@ Note* AudioPlayback_AllocNoteFromDecaying(NotePool* pool, SequenceLayer* layer) if (note != NULL) { AudioPlayback_NoteReleaseAndTakeOwnership(note, layer); AudioPlayback_AudioListRemove(¬e->listItem); - AudioSeq_AudioListPushBack(&pool->releasing, ¬e->listItem); + AudioScript_AudioListPushBack(&pool->releasing, ¬e->listItem); } return note; } @@ -912,7 +913,7 @@ Note* AudioPlayback_AllocNoteFromActive(NotePool* pool, SequenceLayer* layer) { if (aPriority < rPriority) { AudioPlayback_AudioListRemove(&aNote->listItem); func_801963E8(aNote, layer); - AudioSeq_AudioListPushBack(&pool->releasing, &aNote->listItem); + AudioScript_AudioListPushBack(&pool->releasing, &aNote->listItem); aNote->playbackState.priority = layer->channel->notePriority; return aNote; } @@ -931,7 +932,7 @@ Note* AudioPlayback_AllocNote(SequenceLayer* layer) { note->playbackState.wantedParentLayer == NO_LAYER) { AudioPlayback_NoteReleaseAndTakeOwnership(note, layer); AudioPlayback_AudioListRemove(¬e->listItem); - AudioSeq_AudioListPushBack(¬e->listItem.pool->releasing, ¬e->listItem); + AudioScript_AudioListPushBack(¬e->listItem.pool->releasing, ¬e->listItem); return note; } } diff --git a/src/code/audio/audio_seqplayer.c b/src/audio/lib/seqplayer.c similarity index 86% rename from src/code/audio/audio_seqplayer.c rename to src/audio/lib/seqplayer.c index a8c54420a..270164972 100644 --- a/src/code/audio/audio_seqplayer.c +++ b/src/audio/lib/seqplayer.c @@ -29,15 +29,15 @@ typedef enum { /* 5 */ PORTAMENTO_MODE_5 } PortamentoMode; -u8 AudioSeq_ScriptReadU8(SeqScriptState* state); -s16 AudioSeq_ScriptReadS16(SeqScriptState* state); -u16 AudioSeq_ScriptReadCompressedU16(SeqScriptState* state); -void AudioSeq_SeqLayerProcessScriptStep1(SequenceLayer* layer); -s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameTunedSample); -s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer); -s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd); -s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd); -u8 AudioSeq_GetInstrument(SequenceChannel* channel, u8 instId, Instrument** instOut, AdsrSettings* adsr); +u8 AudioScript_ScriptReadU8(SeqScriptState* state); +s16 AudioScript_ScriptReadS16(SeqScriptState* state); +u16 AudioScript_ScriptReadCompressedU16(SeqScriptState* state); +void AudioScript_SeqLayerProcessScriptStep1(SequenceLayer* layer); +s32 AudioScript_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameTunedSample); +s32 AudioScript_SeqLayerProcessScriptStep2(SequenceLayer* layer); +s32 AudioScript_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd); +s32 AudioScript_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd); +u8 AudioScript_GetInstrument(SequenceChannel* channel, u8 instId, Instrument** instOut, AdsrSettings* adsr); /** * sSeqInstructionArgsTable is a table for each sequence instruction @@ -172,7 +172,7 @@ u8 sSeqInstructionArgsTable[] = { * * @return the argument value for a control flow instruction, or 0 if there is no argument */ -u16 AudioSeq_GetScriptControlFlowArgument(SeqScriptState* state, u8 cmd) { +u16 AudioScript_GetScriptControlFlowArgument(SeqScriptState* state, u8 cmd) { u8 highBits = sSeqInstructionArgsTable[cmd - 0xA0]; u8 lowBits = highBits & 3; u16 cmdArg = 0; @@ -180,9 +180,9 @@ u16 AudioSeq_GetScriptControlFlowArgument(SeqScriptState* state, u8 cmd) { // only 1 argument if (lowBits == 1) { if (!(highBits & 0x80)) { - cmdArg = AudioSeq_ScriptReadU8(state); + cmdArg = AudioScript_ScriptReadU8(state); } else { - cmdArg = AudioSeq_ScriptReadS16(state); + cmdArg = AudioScript_ScriptReadS16(state); } } @@ -194,7 +194,7 @@ u16 AudioSeq_GetScriptControlFlowArgument(SeqScriptState* state, u8 cmd) { * * @return number of frames until next instruction. -1 signals termination */ -s32 AudioSeq_HandleScriptFlowControl(SequencePlayer* seqPlayer, SeqScriptState* state, s32 cmd, s32 cmdArg) { +s32 AudioScript_HandleScriptFlowControl(SequencePlayer* seqPlayer, SeqScriptState* state, s32 cmd, s32 cmdArg) { u32 depth; switch (cmd) { @@ -206,7 +206,7 @@ s32 AudioSeq_HandleScriptFlowControl(SequencePlayer* seqPlayer, SeqScriptState* break; case 0xFD: // delay n frames - return AudioSeq_ScriptReadCompressedU16(state); + return AudioScript_ScriptReadCompressedU16(state); case 0xFE: // delay 1 frame return 1; @@ -266,7 +266,7 @@ s32 AudioSeq_HandleScriptFlowControl(SequencePlayer* seqPlayer, SeqScriptState* return 0; } -void AudioSeq_InitSequenceChannel(SequenceChannel* channel) { +void AudioScript_InitSequenceChannel(SequenceChannel* channel) { s32 i; if (channel == &gAudioCtx.sequenceChannelNone) { @@ -325,12 +325,12 @@ void AudioSeq_InitSequenceChannel(SequenceChannel* channel) { channel->sfxState = NULL; } -s32 AudioSeq_SeqChannelSetLayer(SequenceChannel* channel, s32 layerIndex) { +s32 AudioScript_SeqChannelSetLayer(SequenceChannel* channel, s32 layerIndex) { SequenceLayer* layer; s32 pad; if (channel->layers[layerIndex] == NULL) { - layer = AudioSeq_AudioListPopBack(&gAudioCtx.layerFreeList); + layer = AudioScript_AudioListPopBack(&gAudioCtx.layerFreeList); channel->layers[layerIndex] = layer; if (layer == NULL) { channel->layers[layerIndex] = NULL; @@ -382,7 +382,7 @@ s32 AudioSeq_SeqChannelSetLayer(SequenceChannel* channel, s32 layerIndex) { return 0; } -void AudioSeq_SeqLayerDisable(SequenceLayer* layer) { +void AudioScript_SeqLayerDisable(SequenceLayer* layer) { if (layer != NULL) { if ((layer->channel != &gAudioCtx.sequenceChannelNone) && (layer->channel->seqPlayer->finished == true)) { AudioPlayback_SeqLayerNoteRelease(layer); @@ -394,30 +394,30 @@ void AudioSeq_SeqLayerDisable(SequenceLayer* layer) { } } -void AudioSeq_SeqLayerFree(SequenceChannel* channel, s32 layerIndex) { +void AudioScript_SeqLayerFree(SequenceChannel* channel, s32 layerIndex) { SequenceLayer* layer = channel->layers[layerIndex]; if (layer != NULL) { - AudioSeq_AudioListPushBack(&gAudioCtx.layerFreeList, &layer->listItem); - AudioSeq_SeqLayerDisable(layer); + AudioScript_AudioListPushBack(&gAudioCtx.layerFreeList, &layer->listItem); + AudioScript_SeqLayerDisable(layer); channel->layers[layerIndex] = NULL; } } -void AudioSeq_SequenceChannelDisable(SequenceChannel* channel) { +void AudioScript_SequenceChannelDisable(SequenceChannel* channel) { s32 i; channel->finished = true; for (i = 0; i < 4; i++) { - AudioSeq_SeqLayerFree(channel, i); + AudioScript_SeqLayerFree(channel, i); } AudioPlayback_NotePoolClear(&channel->notePool); channel->enabled = false; } -void AudioSeq_SequencePlayerSetupChannels(SequencePlayer* seqPlayer, u16 channelBits) { +void AudioScript_SequencePlayerSetupChannels(SequencePlayer* seqPlayer, u16 channelBits) { SequenceChannel* channel; s32 i; @@ -432,19 +432,19 @@ void AudioSeq_SequencePlayerSetupChannels(SequencePlayer* seqPlayer, u16 channel } } -void AudioSeq_SequencePlayerDisableChannels(SequencePlayer* seqPlayer, u16 channelBitsUnused) { +void AudioScript_SequencePlayerDisableChannels(SequencePlayer* seqPlayer, u16 channelBitsUnused) { SequenceChannel* channel; s32 i; for (i = 0; i < SEQ_NUM_CHANNELS; i++) { channel = seqPlayer->channels[i]; if (IS_SEQUENCE_CHANNEL_VALID(channel) == 1) { - AudioSeq_SequenceChannelDisable(channel); + AudioScript_SequenceChannelDisable(channel); } } } -void AudioSeq_SequenceChannelEnable(SequencePlayer* seqPlayer, u8 channelIndex, void* script) { +void AudioScript_SequenceChannelEnable(SequencePlayer* seqPlayer, u8 channelIndex, void* script) { SequenceChannel* channel = seqPlayer->channels[channelIndex]; s32 i; @@ -456,18 +456,18 @@ void AudioSeq_SequenceChannelEnable(SequencePlayer* seqPlayer, u8 channelIndex, for (i = 0; i < ARRAY_COUNT(channel->layers); i++) { if (channel->layers[i] != NULL) { - AudioSeq_SeqLayerFree(channel, i); + AudioScript_SeqLayerFree(channel, i); } } } -void AudioSeq_SequencePlayerDisableAsFinished(SequencePlayer* seqPlayer) { +void AudioScript_SequencePlayerDisableAsFinished(SequencePlayer* seqPlayer) { seqPlayer->finished = true; - AudioSeq_SequencePlayerDisable(seqPlayer); + AudioScript_SequencePlayerDisable(seqPlayer); } -void AudioSeq_SequencePlayerDisable(SequencePlayer* seqPlayer) { - AudioSeq_SequencePlayerDisableChannels(seqPlayer, 0xFFFF); +void AudioScript_SequencePlayerDisable(SequencePlayer* seqPlayer) { + AudioScript_SequencePlayerDisableChannels(seqPlayer, 0xFFFF); AudioPlayback_NotePoolClear(&seqPlayer->notePool); if (!seqPlayer->enabled) { return; @@ -491,7 +491,7 @@ void AudioSeq_SequencePlayerDisable(SequencePlayer* seqPlayer) { } } -void AudioSeq_AudioListPushBack(AudioListItem* list, AudioListItem* item) { +void AudioScript_AudioListPushBack(AudioListItem* list, AudioListItem* item) { if (item->prev == NULL) { list->prev->next = item; item->prev = list->prev; @@ -502,7 +502,7 @@ void AudioSeq_AudioListPushBack(AudioListItem* list, AudioListItem* item) { } } -void* AudioSeq_AudioListPopBack(AudioListItem* list) { +void* AudioScript_AudioListPopBack(AudioListItem* list) { AudioListItem* item = list->prev; if (item == list) { @@ -517,7 +517,7 @@ void* AudioSeq_AudioListPopBack(AudioListItem* list) { return item->u.value; } -void AudioSeq_InitLayerFreelist(void) { +void AudioScript_InitLayerFreelist(void) { s32 i; gAudioCtx.layerFreeList.prev = &gAudioCtx.layerFreeList; @@ -528,22 +528,22 @@ void AudioSeq_InitLayerFreelist(void) { for (i = 0; i < ARRAY_COUNT(gAudioCtx.sequenceLayers); i++) { gAudioCtx.sequenceLayers[i].listItem.u.value = &gAudioCtx.sequenceLayers[i]; gAudioCtx.sequenceLayers[i].listItem.prev = NULL; - AudioSeq_AudioListPushBack(&gAudioCtx.layerFreeList, &gAudioCtx.sequenceLayers[i].listItem); + AudioScript_AudioListPushBack(&gAudioCtx.layerFreeList, &gAudioCtx.sequenceLayers[i].listItem); } } -u8 AudioSeq_ScriptReadU8(SeqScriptState* state) { +u8 AudioScript_ScriptReadU8(SeqScriptState* state) { return *(state->pc++); } -s16 AudioSeq_ScriptReadS16(SeqScriptState* state) { +s16 AudioScript_ScriptReadS16(SeqScriptState* state) { s16 ret = *(state->pc++) << 8; ret = *(state->pc++) | ret; return ret; } -u16 AudioSeq_ScriptReadCompressedU16(SeqScriptState* state) { +u16 AudioScript_ScriptReadCompressedU16(SeqScriptState* state) { u16 ret = *(state->pc++); if (ret & 0x80) { @@ -553,7 +553,7 @@ u16 AudioSeq_ScriptReadCompressedU16(SeqScriptState* state) { return ret; } -void AudioSeq_SeqLayerProcessScript(SequenceLayer* layer) { +void AudioScript_SeqLayerProcessScript(SequenceLayer* layer) { s32 cmd; if (!layer->enabled) { @@ -569,25 +569,25 @@ void AudioSeq_SeqLayerProcessScript(SequenceLayer* layer) { return; } - AudioSeq_SeqLayerProcessScriptStep1(layer); + AudioScript_SeqLayerProcessScriptStep1(layer); do { - cmd = AudioSeq_SeqLayerProcessScriptStep2(layer); + cmd = AudioScript_SeqLayerProcessScriptStep2(layer); if (cmd == PROCESS_SCRIPT_END) { return; } - cmd = AudioSeq_SeqLayerProcessScriptStep3(layer, cmd); + cmd = AudioScript_SeqLayerProcessScriptStep3(layer, cmd); } while ((cmd == -1) && (layer->delay == 0)); if (cmd != PROCESS_SCRIPT_END) { // returns `sameTunedSample` instead of a command - cmd = AudioSeq_SeqLayerProcessScriptStep4(layer, cmd); + cmd = AudioScript_SeqLayerProcessScriptStep4(layer, cmd); } if (cmd != PROCESS_SCRIPT_END) { - AudioSeq_SeqLayerProcessScriptStep5(layer, cmd); + AudioScript_SeqLayerProcessScriptStep5(layer, cmd); } if (layer->muted == true) { @@ -597,7 +597,7 @@ void AudioSeq_SeqLayerProcessScript(SequenceLayer* layer) { } } -void AudioSeq_SeqLayerProcessScriptStep1(SequenceLayer* layer) { +void AudioScript_SeqLayerProcessScriptStep1(SequenceLayer* layer) { if (!layer->continuousNotes) { AudioPlayback_SeqLayerNoteDecay(layer); } else if ((layer->note != NULL) && (layer->note->playbackState.wantedParentLayer == layer)) { @@ -611,7 +611,7 @@ void AudioSeq_SeqLayerProcessScriptStep1(SequenceLayer* layer) { layer->notePropertiesNeedInit = true; } -s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameTunedSample) { +s32 AudioScript_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameTunedSample) { Note* note; if ((layer->continuousNotes == true) && (layer->bit1 == true)) { @@ -648,7 +648,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameTunedSampl return 0; } -s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) { +s32 AudioScript_SeqLayerProcessScriptStep2(SequenceLayer* layer) { SequenceChannel* channel = layer->channel; SeqScriptState* state = &layer->scriptState; SequencePlayer* seqPlayer = channel->seqPlayer; @@ -658,22 +658,22 @@ s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) { u16 velocity; while (true) { - cmd = AudioSeq_ScriptReadU8(state); + cmd = AudioScript_ScriptReadU8(state); // Note Commands - // To be processed in AudioSeq_SeqLayerProcessScriptStep3 + // To be processed in AudioScript_SeqLayerProcessScriptStep3 if (cmd <= 0xC0) { return cmd; } // Control Flow Commands if (cmd >= 0xF2) { - cmdArg16 = AudioSeq_GetScriptControlFlowArgument(state, cmd); + cmdArg16 = AudioScript_GetScriptControlFlowArgument(state, cmd); - if (AudioSeq_HandleScriptFlowControl(seqPlayer, state, cmd, cmdArg16) == 0) { + if (AudioScript_HandleScriptFlowControl(seqPlayer, state, cmd, cmdArg16) == 0) { continue; } - AudioSeq_SeqLayerDisable(layer); + AudioScript_SeqLayerDisable(layer); return PROCESS_SCRIPT_END; } @@ -710,12 +710,12 @@ s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) { break; case 0xC3: // layer: set short note default delay - cmdArg16 = AudioSeq_ScriptReadCompressedU16(state); + cmdArg16 = AudioScript_ScriptReadCompressedU16(state); layer->shortNoteDefaultDelay = cmdArg16; break; case 0xC6: // layer: set instrument - cmd = AudioSeq_ScriptReadU8(state); + cmd = AudioScript_ScriptReadU8(state); if (cmd >= 0x7E) { if (cmd == 0x7E) { // Sfxs @@ -734,17 +734,17 @@ s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) { } } else { // Instrument - if ((layer->instOrWave = AudioSeq_GetInstrument(channel, cmd, &layer->instrument, &layer->adsr)) == - 0) { + if ((layer->instOrWave = + AudioScript_GetInstrument(channel, cmd, &layer->instrument, &layer->adsr)) == 0) { layer->instOrWave = 0xFF; } } break; case 0xC7: // layer: enable portamento - layer->portamento.mode = AudioSeq_ScriptReadU8(state); + layer->portamento.mode = AudioScript_ScriptReadU8(state); - cmd = AudioSeq_ScriptReadU8(state); + cmd = AudioScript_ScriptReadU8(state); cmd += channel->transposition; cmd += layer->transposition; cmd += seqPlayer->transposition; @@ -761,7 +761,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) { break; } - cmdArg16 = AudioSeq_ScriptReadCompressedU16(state); + cmdArg16 = AudioScript_ScriptReadCompressedU16(state); layer->portamentoTime = cmdArg16; break; @@ -770,11 +770,11 @@ s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) { break; case 0xCB: // layer: set envelope and decay index - cmdArg16 = AudioSeq_ScriptReadS16(state); + cmdArg16 = AudioScript_ScriptReadS16(state); layer->adsr.envelope = (EnvelopePoint*)(seqPlayer->seqData + cmdArg16); // fallthrough case 0xCF: // layer: set decay index - layer->adsr.decayIndex = AudioSeq_ScriptReadU8(state); + layer->adsr.decayIndex = AudioScript_ScriptReadU8(state); break; case 0xCC: // layer: ignore drum pan @@ -782,21 +782,21 @@ s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) { break; case 0xCD: // layer: stereo effects - layer->stereoData.asByte = AudioSeq_ScriptReadU8(state); + layer->stereoData.asByte = AudioScript_ScriptReadU8(state); break; case 0xCE: // layer: bend pitch - cmdArg8 = AudioSeq_ScriptReadU8(state); + cmdArg8 = AudioScript_ScriptReadU8(state); layer->bend = gBendPitchTwoSemitonesFrequencies[(u8)(cmdArg8 + 0x80)]; break; case 0xF0: // layer: - cmdArg16 = AudioSeq_ScriptReadS16(state); + cmdArg16 = AudioScript_ScriptReadS16(state); layer->unk_0A.asByte &= (cmdArg16 ^ 0xFFFF); break; case 0xF1: // layer: - layer->surroundEffectIndex = AudioSeq_ScriptReadU8(state); + layer->surroundEffectIndex = AudioScript_ScriptReadU8(state); break; default: @@ -814,7 +814,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) { } } -s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) { +s32 AudioScript_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) { s32 sameTunedSample = true; s32 instOrWave; s32 speed; @@ -1025,7 +1025,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) { return sameTunedSample; } -s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd) { +s32 AudioScript_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd) { SeqScriptState* state = &layer->scriptState; u16 delay; s32 velocity; @@ -1035,7 +1035,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd) { f32 floatDelta; if (cmd == 0xC0) { // layer: delay - layer->delay = AudioSeq_ScriptReadCompressedU16(state); + layer->delay = AudioScript_ScriptReadCompressedU16(state); layer->muted = true; layer->bit1 = false; return PROCESS_SCRIPT_END; @@ -1046,14 +1046,14 @@ s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd) { if (channel->largeNotes == true) { switch (cmd & 0xC0) { case 0x00: // layer: large note 0 - delay = AudioSeq_ScriptReadCompressedU16(state); + delay = AudioScript_ScriptReadCompressedU16(state); velocity = *(state->pc++); layer->gateTime = *(state->pc++); layer->lastDelay = delay; break; case 0x40: // layer: large note 1 - delay = AudioSeq_ScriptReadCompressedU16(state); + delay = AudioScript_ScriptReadCompressedU16(state); velocity = *(state->pc++); layer->gateTime = 0; layer->lastDelay = delay; @@ -1074,7 +1074,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd) { } else { switch (cmd & 0xC0) { case 0x00: // layer: small note 0 - delay = AudioSeq_ScriptReadCompressedU16(state); + delay = AudioScript_ScriptReadCompressedU16(state); layer->lastDelay = delay; break; @@ -1138,7 +1138,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd) { return cmd; } -void AudioSeq_SetChannelPriorities(SequenceChannel* channel, u8 priority) { +void AudioScript_SetChannelPriorities(SequenceChannel* channel, u8 priority) { if ((priority & 0xF) != 0) { channel->notePriority = priority & 0xF; } @@ -1149,7 +1149,7 @@ void AudioSeq_SetChannelPriorities(SequenceChannel* channel, u8 priority) { } } -u8 AudioSeq_GetInstrument(SequenceChannel* channel, u8 instId, Instrument** instOut, AdsrSettings* adsr) { +u8 AudioScript_GetInstrument(SequenceChannel* channel, u8 instId, Instrument** instOut, AdsrSettings* adsr) { Instrument* inst = AudioPlayback_GetInstrumentInner(channel->fontId, instId); if (inst == NULL) { @@ -1169,7 +1169,7 @@ u8 AudioSeq_GetInstrument(SequenceChannel* channel, u8 instId, Instrument** inst return instId; } -void AudioSeq_SetInstrument(SequenceChannel* channel, u8 instId) { +void AudioScript_SetInstrument(SequenceChannel* channel, u8 instId) { if (instId >= 0x80) { // Synthetic Waves channel->instOrWave = instId; @@ -1184,7 +1184,7 @@ void AudioSeq_SetInstrument(SequenceChannel* channel, u8 instId) { channel->instrument = (Instrument*)2; // invalid pointer, never dereferenced } else { // Instruments - if ((channel->instOrWave = AudioSeq_GetInstrument(channel, instId, &channel->instrument, &channel->adsr)) == + if ((channel->instOrWave = AudioScript_GetInstrument(channel, instId, &channel->instrument, &channel->adsr)) == 0) { channel->hasInstrument = false; return; @@ -1194,11 +1194,11 @@ void AudioSeq_SetInstrument(SequenceChannel* channel, u8 instId) { channel->hasInstrument = true; } -void AudioSeq_SequenceChannelSetVolume(SequenceChannel* channel, u8 volume) { +void AudioScript_SequenceChannelSetVolume(SequenceChannel* channel, u8 volume) { channel->volume = (s32)volume / 127.0f; } -void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { +void AudioScript_SequenceChannelProcessScript(SequenceChannel* channel) { s32 i; u8* data; u32 rand; @@ -1225,7 +1225,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { u16 cmdArgU16; u32 cmdArgs[3]; s8 cmdArgS8; - u8 cmd = AudioSeq_ScriptReadU8(scriptState); + u8 cmd = AudioScript_ScriptReadU8(scriptState); u8 lowBits; u8 highBits; s32 delay; @@ -1244,19 +1244,19 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { // read in arguments for the instruction for (i = 0; i < lowBits; i++, highBits <<= 1) { if (!(highBits & 0x80)) { - cmdArgs[i] = AudioSeq_ScriptReadU8(scriptState); + cmdArgs[i] = AudioScript_ScriptReadU8(scriptState); } else { - cmdArgs[i] = AudioSeq_ScriptReadS16(scriptState); + cmdArgs[i] = AudioScript_ScriptReadS16(scriptState); } } // Control Flow Commands if (cmd >= 0xF2) { - delay = AudioSeq_HandleScriptFlowControl(seqPlayer, scriptState, cmd, cmdArgs[0]); + delay = AudioScript_HandleScriptFlowControl(seqPlayer, scriptState, cmd, cmdArgs[0]); if (delay != 0) { if (delay == PROCESS_SCRIPT_END) { - AudioSeq_SequenceChannelDisable(channel); + AudioScript_SequenceChannelDisable(channel); } else { channel->delay = delay; } @@ -1310,7 +1310,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { // fallthrough case 0xC1: // channel: set instrument cmd = (u8)cmdArgs[0]; - AudioSeq_SetInstrument(channel, cmd); + AudioScript_SetInstrument(channel, cmd); break; case 0xC3: // channel: large notes off @@ -1323,7 +1323,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { case 0xDF: // channel: set volume cmd = (u8)cmdArgs[0]; - AudioSeq_SequenceChannelSetVolume(channel, cmd); + AudioScript_SequenceChannelSetVolume(channel, cmd); channel->changes.s.volume = true; break; @@ -1459,7 +1459,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { case 0xCD: // channel: disable channel cmd = (u8)cmdArgs[0]; - AudioSeq_SequenceChannelDisable(seqPlayer->channels[cmd]); + AudioScript_SequenceChannelDisable(seqPlayer->channels[cmd]); break; case 0xCA: // channel: set mute behavior @@ -1533,7 +1533,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { channel->muteFlags = data[0]; data += 3; channel->noteAllocPolicy = data[-2]; - AudioSeq_SetChannelPriorities(channel, data[-1]); + AudioScript_SetChannelPriorities(channel, data[-1]); channel->transposition = (s8)data[0]; data += 4; channel->newPan = data[-3]; @@ -1548,12 +1548,12 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { channel->muteFlags = cmdArgs[0]; channel->noteAllocPolicy = cmdArgs[1]; cmd = (u8)cmdArgs[2]; - AudioSeq_SetChannelPriorities(channel, cmd); - channel->transposition = (s8)AudioSeq_ScriptReadU8(scriptState); - channel->newPan = AudioSeq_ScriptReadU8(scriptState); - channel->panChannelWeight = AudioSeq_ScriptReadU8(scriptState); - channel->targetReverbVol = AudioSeq_ScriptReadU8(scriptState); - channel->reverbIndex = AudioSeq_ScriptReadU8(scriptState); + AudioScript_SetChannelPriorities(channel, cmd); + channel->transposition = (s8)AudioScript_ScriptReadU8(scriptState); + channel->newPan = AudioScript_ScriptReadU8(scriptState); + channel->panChannelWeight = AudioScript_ScriptReadU8(scriptState); + channel->targetReverbVol = AudioScript_ScriptReadU8(scriptState); + channel->reverbIndex = AudioScript_ScriptReadU8(scriptState); //! @bug: Not marking reverb state as changed channel->changes.s.pan = true; break; @@ -1579,7 +1579,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { break; case 0xE9: // channel: set note priority - AudioSeq_SetChannelPriorities(channel, (u8)cmdArgs[0]); + AudioScript_SetChannelPriorities(channel, (u8)cmdArgs[0]); break; case 0xED: // channel: set hilo gain @@ -1747,18 +1747,18 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { break; case 0x88: // channel: set layer - cmdArgU16 = AudioSeq_ScriptReadS16(scriptState); - if (!AudioSeq_SeqChannelSetLayer(channel, lowBits)) { + cmdArgU16 = AudioScript_ScriptReadS16(scriptState); + if (!AudioScript_SeqChannelSetLayer(channel, lowBits)) { channel->layers[lowBits]->scriptState.pc = &seqPlayer->seqData[cmdArgU16]; } break; case 0x90: // channel: free layer - AudioSeq_SeqLayerFree(channel, lowBits); + AudioScript_SeqLayerFree(channel, lowBits); break; case 0x98: // channel: dynset layer - if ((scriptState->value != -1) && (AudioSeq_SeqChannelSetLayer(channel, lowBits) != -1)) { + if ((scriptState->value != -1) && (AudioScript_SeqChannelSetLayer(channel, lowBits) != -1)) { data = (*channel->dynTable)[scriptState->value]; cmdArgU16 = (data[0] << 8) + data[1]; channel->layers[lowBits]->scriptState.pc = &seqPlayer->seqData[cmdArgU16]; @@ -1770,8 +1770,8 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { break; case 0x78: // channel: set layer relative - temp1 = AudioSeq_ScriptReadS16(scriptState); - if (!AudioSeq_SeqChannelSetLayer(channel, lowBits)) { + temp1 = AudioScript_ScriptReadS16(scriptState); + if (!AudioScript_SeqChannelSetLayer(channel, lowBits)) { channel->layers[lowBits]->scriptState.pc = &scriptState->pc[temp1]; } break; @@ -1815,17 +1815,17 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { break; case 0x20: // channel: start channel - cmdArgU16 = AudioSeq_ScriptReadS16(scriptState); - AudioSeq_SequenceChannelEnable(seqPlayer, lowBits, &seqPlayer->seqData[cmdArgU16]); + cmdArgU16 = AudioScript_ScriptReadS16(scriptState); + AudioScript_SequenceChannelEnable(seqPlayer, lowBits, &seqPlayer->seqData[cmdArgU16]); break; case 0x30: // channel: io write value 2 - cmd = AudioSeq_ScriptReadU8(scriptState); + cmd = AudioScript_ScriptReadU8(scriptState); seqPlayer->channels[lowBits]->seqScriptIO[cmd] = scriptState->value; break; case 0x40: // channel: io read value 2 - cmd = AudioSeq_ScriptReadU8(scriptState); + cmd = AudioScript_ScriptReadU8(scriptState); scriptState->value = seqPlayer->channels[lowBits]->seqScriptIO[cmd]; break; } @@ -1834,12 +1834,12 @@ exit_loop: for (i = 0; i < ARRAY_COUNT(channel->layers); i++) { if (channel->layers[i] != NULL) { - AudioSeq_SeqLayerProcessScript(channel->layers[i]); + AudioScript_SeqLayerProcessScript(channel->layers[i]); } } } -void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { +void AudioScript_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { u8 cmd; u8 cmdLowBits; SeqScriptState* seqScript = &seqPlayer->scriptState; @@ -1866,7 +1866,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { if (AudioLoad_IsSeqLoadComplete(seqPlayer->seqId)) {} if (AudioLoad_IsSeqLoadComplete(seqPlayer->defaultFont)) {} - AudioSeq_SequencePlayerDisable(seqPlayer); + AudioScript_SequencePlayerDisable(seqPlayer); return; } @@ -1903,16 +1903,16 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { seqPlayer->recalculateVolume = true; while (true) { - cmd = AudioSeq_ScriptReadU8(seqScript); + cmd = AudioScript_ScriptReadU8(seqScript); // 0xF2 and above are "flow control" commands, including termination. if (cmd >= 0xF2) { - delay = AudioSeq_HandleScriptFlowControl( - seqPlayer, seqScript, cmd, AudioSeq_GetScriptControlFlowArgument(&seqPlayer->scriptState, cmd)); + delay = AudioScript_HandleScriptFlowControl( + seqPlayer, seqScript, cmd, AudioScript_GetScriptControlFlowArgument(&seqPlayer->scriptState, cmd)); if (delay != 0) { if (delay == -1) { - AudioSeq_SequencePlayerDisable(seqPlayer); + AudioScript_SequencePlayerDisable(seqPlayer); } else { seqPlayer->delay = delay; } @@ -1926,7 +1926,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { switch (cmd) { case 0xF1: // seqPlayer: reserve notes AudioPlayback_NotePoolClear(&seqPlayer->notePool); - cmd = AudioSeq_ScriptReadU8(seqScript); + cmd = AudioScript_ScriptReadU8(seqScript); AudioPlayback_NotePoolFill(&seqPlayer->notePool, cmd); break; @@ -1938,11 +1938,11 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { seqPlayer->transposition = 0; // fallthrough case 0xDE: // seqPlayer: transpose relative - seqPlayer->transposition += (s8)AudioSeq_ScriptReadU8(seqScript); + seqPlayer->transposition += (s8)AudioScript_ScriptReadU8(seqScript); break; case 0xDD: // seqPlayer: set tempo - seqPlayer->tempo = AudioSeq_ScriptReadU8(seqScript) * TATUMS_PER_BEAT; + seqPlayer->tempo = AudioScript_ScriptReadU8(seqScript) * TATUMS_PER_BEAT; if (seqPlayer->tempo > gAudioCtx.maxTempo) { seqPlayer->tempo = gAudioCtx.maxTempo; } @@ -1953,12 +1953,12 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { break; case 0xDC: // seqPlayer: add tempo - seqPlayer->tempoChange = (s8)AudioSeq_ScriptReadU8(seqScript) * TATUMS_PER_BEAT; + seqPlayer->tempoChange = (s8)AudioScript_ScriptReadU8(seqScript) * TATUMS_PER_BEAT; break; case 0xDA: // seqPlayer: change volume - cmd = AudioSeq_ScriptReadU8(seqScript); - temp = AudioSeq_ScriptReadS16(seqScript); + cmd = AudioScript_ScriptReadU8(seqScript); + temp = AudioScript_ScriptReadS16(seqScript); switch (cmd) { case SEQPLAYER_STATE_0: case SEQPLAYER_STATE_FADE_IN: @@ -1977,7 +1977,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { break; case 0xDB: // seqPlayer: set volume - value = AudioSeq_ScriptReadU8(seqScript); + value = AudioScript_ScriptReadU8(seqScript); switch (seqPlayer->state) { case SEQPLAYER_STATE_FADE_IN: seqPlayer->state = SEQPLAYER_STATE_0; @@ -1999,20 +1999,20 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { break; case 0xD9: // seqPlayer: set volume scale - seqPlayer->fadeVolumeScale = (s8)AudioSeq_ScriptReadU8(seqScript) / 127.0f; + seqPlayer->fadeVolumeScale = (s8)AudioScript_ScriptReadU8(seqScript) / 127.0f; break; case 0xD7: // seqPlayer: initialize channels - temp = AudioSeq_ScriptReadS16(seqScript); - AudioSeq_SequencePlayerSetupChannels(seqPlayer, temp); + temp = AudioScript_ScriptReadS16(seqScript); + AudioScript_SequencePlayerSetupChannels(seqPlayer, temp); break; case 0xD6: // seqPlayer: disable channels - AudioSeq_ScriptReadS16(seqScript); + AudioScript_ScriptReadS16(seqScript); break; case 0xD5: // seqPlayer: set mute scale - seqPlayer->muteVolumeScale = (s8)AudioSeq_ScriptReadU8(seqScript) / 127.0f; + seqPlayer->muteVolumeScale = (s8)AudioScript_ScriptReadU8(seqScript) / 127.0f; break; case 0xD4: // seqPlayer: mute @@ -2020,12 +2020,12 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { break; case 0xD3: // seqPlayer: set mute behavior - seqPlayer->muteFlags = AudioSeq_ScriptReadU8(seqScript); + seqPlayer->muteFlags = AudioScript_ScriptReadU8(seqScript); break; case 0xD1: // seqPlayer: set short note gatetime table case 0xD2: // seqPlayer: set short note velocity table - temp = AudioSeq_ScriptReadS16(seqScript); + temp = AudioScript_ScriptReadS16(seqScript); data3 = &seqPlayer->seqData[temp]; if (cmd == 0xD2) { seqPlayer->shortNoteVelocityTable = data3; @@ -2035,11 +2035,11 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { break; case 0xD0: // seqPlayer: set note allocation policy - seqPlayer->noteAllocPolicy = AudioSeq_ScriptReadU8(seqScript); + seqPlayer->noteAllocPolicy = AudioScript_ScriptReadU8(seqScript); break; case 0xCE: // seqPlayer: random value - cmd = AudioSeq_ScriptReadU8(seqScript); + cmd = AudioScript_ScriptReadU8(seqScript); if (cmd == 0) { seqScript->value = (gAudioCtx.audioRandom >> 2) & 0xFF; } else { @@ -2048,7 +2048,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { break; case 0xCD: // seqPlayer: dyncall - temp = AudioSeq_ScriptReadS16(seqScript); + temp = AudioScript_ScriptReadS16(seqScript); if ((seqScript->value != -1) && (seqScript->depth != 3)) { data1 = seqPlayer->seqData + (u32)(temp + (seqScript->value << 1)); seqScript->stack[seqScript->depth] = seqScript->pc; @@ -2059,26 +2059,26 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { break; case 0xCC: // seqPlayer: set value - seqScript->value = AudioSeq_ScriptReadU8(seqScript); + seqScript->value = AudioScript_ScriptReadU8(seqScript); break; case 0xC9: // seqPlayer: `bit and` -> set value - seqScript->value &= AudioSeq_ScriptReadU8(seqScript); + seqScript->value &= AudioScript_ScriptReadU8(seqScript); break; case 0xC8: // seqPlayer: subtract -> set value - seqScript->value -= AudioSeq_ScriptReadU8(seqScript); + seqScript->value -= AudioScript_ScriptReadU8(seqScript); break; case 0xC7: // seqPlayer: write into sequence script - cmd = AudioSeq_ScriptReadU8(seqScript); - temp = AudioSeq_ScriptReadS16(seqScript); + cmd = AudioScript_ScriptReadU8(seqScript); + temp = AudioScript_ScriptReadS16(seqScript); data2 = &seqPlayer->seqData[temp]; *data2 = (u8)seqScript->value + cmd; break; case 0xC2: // seqPlayer: - temp = AudioSeq_ScriptReadS16(seqScript); + temp = AudioScript_ScriptReadS16(seqScript); if (seqScript->value != -1) { data4 = seqPlayer->seqData + (u32)(temp + (seqScript->value << 1)); @@ -2092,16 +2092,16 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { return; case 0xC5: // seqPlayer: - seqPlayer->unk_16 = AudioSeq_ScriptReadS16(seqScript); + seqPlayer->unk_16 = AudioScript_ScriptReadS16(seqScript); break; case 0xEF: // seqPlayer: - AudioSeq_ScriptReadS16(seqScript); - AudioSeq_ScriptReadU8(seqScript); + AudioScript_ScriptReadS16(seqScript); + AudioScript_ScriptReadU8(seqScript); break; case 0xC4: // seqPlayer: start sequence - cmd = AudioSeq_ScriptReadU8(seqScript); + cmd = AudioScript_ScriptReadU8(seqScript); if (cmd == 0xFF) { cmd = seqPlayer->playerIndex; if (seqPlayer->state == SEQPLAYER_STATE_FADE_OUT) { @@ -2109,7 +2109,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { } } - cmdLowBits = AudioSeq_ScriptReadU8(seqScript); + cmdLowBits = AudioScript_ScriptReadU8(seqScript); AudioLoad_SyncInitSeqPlayer(cmd, cmdLowBits, 0); if (cmd == (u8)seqPlayer->playerIndex) { return; @@ -2117,7 +2117,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { break; case 0xC3: // seqPlayer: - temp = AudioSeq_ScriptReadS16(seqScript); + temp = AudioScript_ScriptReadS16(seqScript); if (seqScript->value != -1) { new_var = (u16*)(seqPlayer->seqData + (u32)(temp + seqScript->value * 2)); temp = *new_var; @@ -2156,30 +2156,30 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { break; case 0x40: // seqPlayer: disable channel - AudioSeq_SequenceChannelDisable(seqPlayer->channels[cmdLowBits]); + AudioScript_SequenceChannelDisable(seqPlayer->channels[cmdLowBits]); break; case 0x90: // seqPlayer: start channel - temp = AudioSeq_ScriptReadS16(seqScript); - AudioSeq_SequenceChannelEnable(seqPlayer, cmdLowBits, (void*)&seqPlayer->seqData[temp]); + temp = AudioScript_ScriptReadS16(seqScript); + AudioScript_SequenceChannelEnable(seqPlayer, cmdLowBits, (void*)&seqPlayer->seqData[temp]); break; case 0xA0: // seqPlayer: start channel relative - tempS = AudioSeq_ScriptReadS16(seqScript); - AudioSeq_SequenceChannelEnable(seqPlayer, cmdLowBits, (void*)&seqScript->pc[tempS]); + tempS = AudioScript_ScriptReadS16(seqScript); + AudioScript_SequenceChannelEnable(seqPlayer, cmdLowBits, (void*)&seqScript->pc[tempS]); break; case 0xB0: // seqPlayer: load sequence - cmd = AudioSeq_ScriptReadU8(seqScript); - temp = AudioSeq_ScriptReadS16(seqScript); + cmd = AudioScript_ScriptReadU8(seqScript); + temp = AudioScript_ScriptReadS16(seqScript); data2 = &seqPlayer->seqData[temp]; AudioLoad_SlowLoadSeq(cmd, data2, &seqPlayer->seqScriptIO[cmdLowBits]); break; case 0x60: // seqPlayer: async load - cmd = AudioSeq_ScriptReadU8(seqScript); + cmd = AudioScript_ScriptReadU8(seqScript); value = cmd; - temp = AudioSeq_ScriptReadU8(seqScript); + temp = AudioScript_ScriptReadU8(seqScript); AudioLoad_ScriptLoad(value, temp, &seqPlayer->seqScriptIO[cmdLowBits]); break; } @@ -2189,12 +2189,12 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) { for (j = 0; j < SEQ_NUM_CHANNELS; j++) { channel = seqPlayer->channels[j]; if (channel->enabled) { - AudioSeq_SequenceChannelProcessScript(channel); + AudioScript_SequenceChannelProcessScript(channel); } } } -void AudioSeq_ProcessSequences(s32 arg0) { +void AudioScript_ProcessSequences(s32 arg0) { SequencePlayer* seqPlayer; u32 i; @@ -2203,7 +2203,7 @@ void AudioSeq_ProcessSequences(s32 arg0) { for (i = 0; i < (u32)gAudioCtx.audioBufferParameters.numSequencePlayers; i++) { seqPlayer = &gAudioCtx.seqPlayers[i]; if (seqPlayer->enabled == true) { - AudioSeq_SequencePlayerProcessSequence(seqPlayer); + AudioScript_SequencePlayerProcessSequence(seqPlayer); AudioEffects_SequencePlayerProcessSound(seqPlayer); } } @@ -2211,18 +2211,18 @@ void AudioSeq_ProcessSequences(s32 arg0) { AudioPlayback_ProcessNotes(); } -void AudioSeq_SkipForwardSequence(SequencePlayer* seqPlayer) { +void AudioScript_SkipForwardSequence(SequencePlayer* seqPlayer) { while (seqPlayer->skipTicks > 0) { - AudioSeq_SequencePlayerProcessSequence(seqPlayer); + AudioScript_SequencePlayerProcessSequence(seqPlayer); AudioEffects_SequencePlayerProcessSound(seqPlayer); seqPlayer->skipTicks--; } } -void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer) { +void AudioScript_ResetSequencePlayer(SequencePlayer* seqPlayer) { s32 channelIndex; - AudioSeq_SequencePlayerDisable(seqPlayer); + AudioScript_SequencePlayerDisable(seqPlayer); seqPlayer->stopScript = false; seqPlayer->delay = 0; seqPlayer->state = SEQPLAYER_STATE_FADE_IN; @@ -2243,11 +2243,11 @@ void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer) { seqPlayer->muteVolumeScale = 0.5f; for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) { - AudioSeq_InitSequenceChannel(seqPlayer->channels[channelIndex]); + AudioScript_InitSequenceChannel(seqPlayer->channels[channelIndex]); } } -void AudioSeq_InitSequencePlayerChannels(s32 seqPlayerIndex) { +void AudioScript_InitSequencePlayerChannels(s32 seqPlayerIndex) { SequenceChannel* channel; SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[seqPlayerIndex]; s32 channelIndex; @@ -2267,11 +2267,11 @@ void AudioSeq_InitSequencePlayerChannels(s32 seqPlayerIndex) { } } - AudioSeq_InitSequenceChannel(seqPlayer->channels[channelIndex]); + AudioScript_InitSequenceChannel(seqPlayer->channels[channelIndex]); } } -void AudioSeq_InitSequencePlayer(SequencePlayer* seqPlayer) { +void AudioScript_InitSequencePlayer(SequencePlayer* seqPlayer) { s32 i; s32 j; @@ -2294,13 +2294,13 @@ void AudioSeq_InitSequencePlayer(SequencePlayer* seqPlayer) { seqPlayer->bend = 1.0f; AudioPlayback_InitNoteLists(&seqPlayer->notePool); - AudioSeq_ResetSequencePlayer(seqPlayer); + AudioScript_ResetSequencePlayer(seqPlayer); } -void AudioSeq_InitSequencePlayers(void) { +void AudioScript_InitSequencePlayers(void) { s32 i; - AudioSeq_InitLayerFreelist(); + AudioScript_InitLayerFreelist(); for (i = 0; i < ARRAY_COUNT(gAudioCtx.sequenceLayers); i++) { gAudioCtx.sequenceLayers[i].channel = NULL; @@ -2308,6 +2308,6 @@ void AudioSeq_InitSequencePlayers(void) { } for (i = 0; i < ARRAY_COUNT(gAudioCtx.seqPlayers); i++) { - AudioSeq_InitSequencePlayer(&gAudioCtx.seqPlayers[i]); + AudioScript_InitSequencePlayer(&gAudioCtx.seqPlayers[i]); } } diff --git a/src/code/audio/audio_synthesis.c b/src/audio/lib/synthesis.c similarity index 99% rename from src/code/audio/audio_synthesis.c rename to src/audio/lib/synthesis.c index 057668f37..71b6a2212 100644 --- a/src/code/audio/audio_synthesis.c +++ b/src/audio/lib/synthesis.c @@ -223,7 +223,7 @@ Acmd* AudioSynth_Update(Acmd* abiCmdStart, s32* numAbiCmds, s16* aiBufStart, s32 for (reverseUpdateIndex = gAudioCtx.audioBufferParameters.updatesPerFrame; reverseUpdateIndex > 0; reverseUpdateIndex--) { - AudioSeq_ProcessSequences(reverseUpdateIndex - 1); + AudioScript_ProcessSequences(reverseUpdateIndex - 1); AudioSynth_SyncSampleStates(gAudioCtx.audioBufferParameters.updatesPerFrame - reverseUpdateIndex); } diff --git a/src/code/audio/audio_thread.c b/src/audio/lib/thread.c similarity index 99% rename from src/code/audio/audio_thread.c rename to src/audio/lib/thread.c index 2b06281cc..082e77a67 100644 --- a/src/code/audio/audio_thread.c +++ b/src/audio/lib/thread.c @@ -212,13 +212,13 @@ void AudioThread_ProcessGlobalCmd(AudioCmd* cmd) { case AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER_SKIP_TICKS: AudioLoad_SyncInitSeqPlayerSkipTicks(cmd->arg0, cmd->arg1, cmd->asInt); AudioThread_SetFadeInTimer(cmd->arg0, 500); - AudioSeq_SkipForwardSequence(&gAudioCtx.seqPlayers[cmd->arg0]); + AudioScript_SkipForwardSequence(&gAudioCtx.seqPlayers[cmd->arg0]); break; case AUDIOCMD_OP_GLOBAL_DISABLE_SEQPLAYER: if (gAudioCtx.seqPlayers[cmd->arg0].enabled) { if (cmd->asInt == 0) { - AudioSeq_SequencePlayerDisableAsFinished(&gAudioCtx.seqPlayers[cmd->arg0]); + AudioScript_SequencePlayerDisableAsFinished(&gAudioCtx.seqPlayers[cmd->arg0]); } else { AudioThread_SetFadeOutTimer(cmd->arg0, cmd->asInt); } @@ -322,7 +322,7 @@ void AudioThread_ProcessGlobalCmd(AudioCmd* cmd) { if (flags == AUDIO_NOTE_RELEASE) { for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) { if (gAudioCtx.seqPlayers[i].enabled) { - AudioSeq_SequencePlayerDisableAsFinished(&gAudioCtx.seqPlayers[i]); + AudioScript_SequencePlayerDisableAsFinished(&gAudioCtx.seqPlayers[i]); } } } diff --git a/src/audio/sequence.c b/src/audio/sequence.c new file mode 100644 index 000000000..7d37a0ae9 --- /dev/null +++ b/src/audio/sequence.c @@ -0,0 +1,922 @@ +/** + * @file sequence.c + * + * This file implements a set of high-level audio sequence commands that allow sequences to be modified in real-time. + * These commands are intended to interface external to the audio library. + * + * These commands are generated using `AudioSeq_QueueSeqCmd`, and a user-friendly interface for this function + * can be found in `seqcmd.h` + * + * These commands change sequences by generating internal audio commands `AudioThread_QueueCmd` which allows these + * sequence requests to be passed onto the audio thread. It is worth noting all functions in this file are + * called from the graph thread. + * + * These commands are not to be confused with the sequence instructions used by the sequences themselves + * which are a midi-based scripting language. + * + * Nor are these commands to be confused with the internal audio commands used to transfer requests from + * the graph thread to the audio thread. + */ +#include "global.h" + +// Direct audio command (skips the queueing system) +#define SEQCMD_SET_SEQPLAYER_VOLUME_NOW(seqPlayerIndex, duration, volume) \ + AudioSeq_ProcessSeqCmd((SEQCMD_OP_SET_SEQPLAYER_VOLUME << 28) | ((u8)(seqPlayerIndex) << 24) | \ + ((u8)(duration) << 16) | ((u8)((volume)*127.0f))); + +u8 sSeqCmdWritePos = 0; +u8 sSeqCmdReadPos = 0; +u8 sStartSeqDisabled = 0; +u8 sSoundModeList[] = { + SOUNDMODE_STEREO, SOUNDMODE_HEADSET, SOUNDMODE_SURROUND_EXTERNAL, SOUNDMODE_MONO, SOUNDMODE_SURROUND, +}; +u8 gAudioSpecId = 0; +u8 gAudioHeapResetState = AUDIO_HEAP_RESET_STATE_NONE; +u32 sResetAudioHeapSeqCmd = 0; + +void AudioSeq_StartSequence(u8 seqPlayerIndex, u8 seqId, u8 seqArgs, u16 fadeInDuration) { + u8 channelIndex; + u16 skipTicks; + s32 pad; + + if (!sStartSeqDisabled || (seqPlayerIndex == SEQ_PLAYER_SFX)) { + seqArgs &= 0x7F; + if (seqArgs == 0x7F) { + // `fadeInDuration` interpreted as seconds, 60 is refresh rate and does not account for PAL + skipTicks = (fadeInDuration >> 3) * 60 * gAudioCtx.audioBufferParameters.updatesPerFrame; + AUDIOCMD_GLOBAL_INIT_SEQPLAYER_SKIP_TICKS(seqPlayerIndex, seqId, skipTicks); + } else { + // `fadeInDuration` interpreted as 1/30th of a second, does not account for change in refresh rate for PAL + AUDIOCMD_GLOBAL_INIT_SEQPLAYER(seqPlayerIndex, seqId, + (fadeInDuration * (u16)gAudioCtx.audioBufferParameters.updatesPerFrame) / 4); + } + + gActiveSeqs[seqPlayerIndex].seqId = seqId | (seqArgs << 8); + gActiveSeqs[seqPlayerIndex].prevSeqId = seqId | (seqArgs << 8); + gActiveSeqs[seqPlayerIndex].isSeqPlayerInit = true; + + if (gActiveSeqs[seqPlayerIndex].volCur != 1.0f) { + AUDIOCMD_SEQPLAYER_FADE_VOLUME_SCALE(seqPlayerIndex, gActiveSeqs[seqPlayerIndex].volCur); + } + + gActiveSeqs[seqPlayerIndex].tempoTimer = 0; + gActiveSeqs[seqPlayerIndex].tempoOriginal = 0; + gActiveSeqs[seqPlayerIndex].tempoCmd = 0; + + for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) { + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur = 1.0f; + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTimer = 0; + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleCur = 1.0f; + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTimer = 0; + } + + gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags = 0; + gActiveSeqs[seqPlayerIndex].volChannelFlags = 0; + } +} + +void AudioSeq_StopSequence(u8 seqPlayerIndex, u16 fadeOutDuration) { + AUDIOCMD_GLOBAL_DISABLE_SEQPLAYER(seqPlayerIndex, + (fadeOutDuration * (u16)gAudioCtx.audioBufferParameters.updatesPerFrame) / 4); + gActiveSeqs[seqPlayerIndex].seqId = NA_BGM_DISABLED; +} + +void AudioSeq_ProcessSeqCmd(u32 cmd) { + s32 priority; + s32 channelMaskEnable; + u16 channelMaskDisable; + u16 fadeTimer; + u16 val; + u8 oldSpecId; + u8 specId; + u8 fadeReverb; + u8 op; + u8 subOp; + u8 seqPlayerIndex; + u8 seqId; + u8 seqArgs; + u8 found; + u8 ioPort; + u8 duration; + u8 channelIndex; + u8 i; + f32 freqScaleTarget; + u32 outNumFonts; + + op = cmd >> 28; + seqPlayerIndex = (cmd & SEQCMD_SEQPLAYER_MASK) >> 24; + + switch (op) { + case SEQCMD_OP_PLAY_SEQUENCE: + // Play a new sequence + seqId = cmd & SEQCMD_SEQID_MASK; + seqArgs = (cmd & 0xFF00) >> 8; + // `fadeTimer` is only shifted 13 bits instead of 16 bits. + // `fadeTimer` continues to be scaled in `AudioSeq_StartSequence` + fadeTimer = (cmd & 0xFF0000) >> 13; + if (!gActiveSeqs[seqPlayerIndex].isWaitingForFonts && !sStartSeqDisabled) { + if (seqArgs < 0x80) { + AudioSeq_StartSequence(seqPlayerIndex, seqId, seqArgs, fadeTimer); + } else { + // Store the cmd to be called again once the fonts are loaded + // but changes the command so that next time, the (seqArgs < 0x80) case is taken + gActiveSeqs[seqPlayerIndex].startAsyncSeqCmd = + (cmd & ~(SEQ_FLAG_ASYNC | SEQCMD_ASYNC_ACTIVE)) + SEQCMD_ASYNC_ACTIVE; + gActiveSeqs[seqPlayerIndex].isWaitingForFonts = true; + gActiveSeqs[seqPlayerIndex].fontId = *AudioThread_GetFontsForSequence(seqId, &outNumFonts); + AudioSeq_StopSequence(seqPlayerIndex, 1); + + if (gActiveSeqs[seqPlayerIndex].prevSeqId != NA_BGM_DISABLED) { + if (*AudioThread_GetFontsForSequence(seqId, &outNumFonts) != + *AudioThread_GetFontsForSequence(gActiveSeqs[seqPlayerIndex].prevSeqId & 0xFF, + &outNumFonts)) { + // Discard Seq Fonts + AUDIOCMD_GLOBAL_DISCARD_SEQ_FONTS((s32)seqId); + } + } + + AUDIOCMD_GLOBAL_ASYNC_LOAD_FONT(*AudioThread_GetFontsForSequence(seqId, &outNumFonts), + (u8)((seqPlayerIndex + 1) & 0xFF)); + } + } + break; + + case SEQCMD_OP_STOP_SEQUENCE: + // Stop a sequence and disable the sequence player + fadeTimer = (cmd & 0xFF0000) >> 13; + AudioSeq_StopSequence(seqPlayerIndex, fadeTimer); + break; + + case SEQCMD_OP_QUEUE_SEQUENCE: + // Queue a sequence into `sSeqRequests` + seqId = cmd & SEQCMD_SEQID_MASK; + seqArgs = (cmd & 0xFF00) >> 8; + fadeTimer = (cmd & 0xFF0000) >> 13; + priority = seqArgs; + + // Checks if the requested sequence is first in the list of requests + // If it is already queued and first in the list, then play the sequence immediately + for (i = 0; i < sNumSeqRequests[seqPlayerIndex]; i++) { + if (sSeqRequests[seqPlayerIndex][i].seqId == seqId) { + if (i == 0) { + AudioSeq_StartSequence(seqPlayerIndex, seqId, seqArgs, fadeTimer); + } + return; + } + } + + // Searches the sequence requests for the first request that does not have a higher priority + // than the current incoming request + found = sNumSeqRequests[seqPlayerIndex]; + for (i = 0; i < sNumSeqRequests[seqPlayerIndex]; i++) { + if (priority >= sSeqRequests[seqPlayerIndex][i].priority) { + found = i; + i = sNumSeqRequests[seqPlayerIndex]; // "break;" + } + } + + // Check if the queue is full + if (sNumSeqRequests[seqPlayerIndex] < ARRAY_COUNT(sSeqRequests[seqPlayerIndex])) { + sNumSeqRequests[seqPlayerIndex]++; + } + + for (i = sNumSeqRequests[seqPlayerIndex] - 1; i != found; i--) { + // Move all requests of lower priority backwards 1 place in the queue + // If the queue is full, overwrite the entry with the lowest priority + sSeqRequests[seqPlayerIndex][i].priority = sSeqRequests[seqPlayerIndex][i - 1].priority; + sSeqRequests[seqPlayerIndex][i].seqId = sSeqRequests[seqPlayerIndex][i - 1].seqId; + } + + // Fill the newly freed space in the queue with the new request + sSeqRequests[seqPlayerIndex][found].priority = seqArgs; + sSeqRequests[seqPlayerIndex][found].seqId = seqId; + + // The sequence is first in queue, so start playing. + if (found == 0) { + AudioSeq_StartSequence(seqPlayerIndex, seqId, seqArgs, fadeTimer); + } + break; + + case SEQCMD_OP_UNQUEUE_SEQUENCE: + // Unqueue sequence + fadeTimer = (cmd & 0xFF0000) >> 13; + + found = sNumSeqRequests[seqPlayerIndex]; + for (i = 0; i < sNumSeqRequests[seqPlayerIndex]; i++) { + seqId = cmd & SEQCMD_SEQID_MASK; + if (sSeqRequests[seqPlayerIndex][i].seqId == seqId) { + found = i; + i = sNumSeqRequests[seqPlayerIndex]; // "break;" + } + } + + if (found != sNumSeqRequests[seqPlayerIndex]) { + // Move all requests of lower priority forward 1 place in the queue + for (i = found; i < sNumSeqRequests[seqPlayerIndex] - 1; i++) { + sSeqRequests[seqPlayerIndex][i].priority = sSeqRequests[seqPlayerIndex][i + 1].priority; + sSeqRequests[seqPlayerIndex][i].seqId = sSeqRequests[seqPlayerIndex][i + 1].seqId; + } + sNumSeqRequests[seqPlayerIndex]--; + } + + // If the sequence was first in queue (it is currently playing), + // Then stop the sequence and play the next sequence in the queue. + if (found == 0) { + AudioSeq_StopSequence(seqPlayerIndex, fadeTimer); + if (sNumSeqRequests[seqPlayerIndex] != 0) { + AudioSeq_StartSequence(seqPlayerIndex, sSeqRequests[seqPlayerIndex][0].seqId, + sSeqRequests[seqPlayerIndex][0].priority, fadeTimer); + } + } + break; + + case SEQCMD_OP_SET_SEQPLAYER_VOLUME: + // Transition volume to a target volume for an entire player + duration = (cmd & 0xFF0000) >> 15; + val = cmd & 0xFF; + if (duration == 0) { + duration++; + } + // Volume is scaled relative to 127 + gActiveSeqs[seqPlayerIndex].volTarget = (f32)val / 127.0f; + if (gActiveSeqs[seqPlayerIndex].volCur != gActiveSeqs[seqPlayerIndex].volTarget) { + gActiveSeqs[seqPlayerIndex].volStep = + (gActiveSeqs[seqPlayerIndex].volCur - gActiveSeqs[seqPlayerIndex].volTarget) / (f32)duration; + gActiveSeqs[seqPlayerIndex].volTimer = duration; + } + break; + + case SEQCMD_OP_SET_SEQPLAYER_FREQ: + // Transition freq scale to a target freq for all channels + duration = (cmd & 0xFF0000) >> 15; + val = cmd & 0xFFFF; + if (duration == 0) { + duration++; + } + // Frequency is scaled relative to 1000 + freqScaleTarget = (f32)val / 1000.0f; + for (i = 0; i < SEQ_NUM_CHANNELS; i++) { + gActiveSeqs[seqPlayerIndex].channelData[i].freqScaleTarget = freqScaleTarget; + gActiveSeqs[seqPlayerIndex].channelData[i].freqScaleTimer = duration; + gActiveSeqs[seqPlayerIndex].channelData[i].freqScaleStep = + (gActiveSeqs[seqPlayerIndex].channelData[i].freqScaleCur - freqScaleTarget) / (f32)duration; + } + gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags = 0xFFFF; + break; + + case SEQCMD_OP_SET_CHANNEL_FREQ: + // Transition freq scale to a target for a specific channel + duration = (cmd & 0xFF0000) >> 15; + channelIndex = (cmd & 0xF000) >> 12; + val = cmd & 0xFFF; + if (duration == 0) { + duration++; + } + // Frequency is scaled relative to 1000 + freqScaleTarget = (f32)val / 1000.0f; + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTarget = freqScaleTarget; + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleStep = + (gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleCur - freqScaleTarget) / (f32)duration; + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTimer = duration; + gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags |= 1 << channelIndex; + break; + + case SEQCMD_OP_SET_CHANNEL_VOLUME: + // Transition volume to a target volume for a specific channel + duration = (cmd & 0xFF0000) >> 15; + channelIndex = (cmd & 0xF00) >> 8; + val = cmd & 0xFF; + if (duration == 0) { + duration++; + } + // Volume is scaled relative to 127 + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTarget = (f32)val / 127.0f; + if (gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur != + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTarget) { + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volStep = + (gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur - + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTarget) / + (f32)duration; + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTimer = duration; + gActiveSeqs[seqPlayerIndex].volChannelFlags |= 1 << channelIndex; + } + break; + + case SEQCMD_OP_SET_SEQPLAYER_IO: + // Set global io port + ioPort = (cmd & 0xFF0000) >> 16; + val = cmd & 0xFF; + AUDIOCMD_SEQPLAYER_SET_IO(seqPlayerIndex, ioPort, val); + break; + + case SEQCMD_OP_SET_CHANNEL_IO: + // Set io port if channel masked + channelIndex = (cmd & 0xF00) >> 8; + ioPort = (cmd & 0xFF0000) >> 16; + val = cmd & 0xFF; + if (!(gActiveSeqs[seqPlayerIndex].channelPortMask & (1 << channelIndex))) { + AUDIOCMD_CHANNEL_SET_IO(seqPlayerIndex, channelIndex, ioPort, val); + } + break; + + case SEQCMD_OP_SET_CHANNEL_IO_DISABLE_MASK: + // Disable channel io specifically for `SEQCMD_OP_SET_CHANNEL_IO`. + // This can be bypassed by setting channel io through using `AUDIOCMD_CHANNEL_SET_IO` directly. + // This is accomplished by setting a channel mask. + gActiveSeqs[seqPlayerIndex].channelPortMask = cmd & 0xFFFF; + break; + + case SEQCMD_OP_SET_CHANNEL_DISABLE_MASK: + // Disable or Reenable channels + + // Disable channels + channelMaskDisable = cmd & 0xFFFF; + if (channelMaskDisable != 0) { + // Apply channel mask `channelMaskDisable` + AUDIOCMD_GLOBAL_SET_CHANNEL_MASK(seqPlayerIndex, channelMaskDisable); + // Disable channels + AUDIOCMD_CHANNEL_SET_MUTE(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, true); + } + + // Reenable channels + channelMaskEnable = channelMaskDisable ^ 0xFFFF; + if (channelMaskEnable != 0) { + // Apply channel mask `channelMaskEnable` + AUDIOCMD_GLOBAL_SET_CHANNEL_MASK(seqPlayerIndex, channelMaskEnable); + // Enable channels + AUDIOCMD_CHANNEL_SET_MUTE(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, false); + } + break; + + case SEQCMD_OP_TEMPO_CMD: + // Update a tempo using a sub-command system. + // Stores the cmd for processing elsewhere. + gActiveSeqs[seqPlayerIndex].tempoCmd = cmd; + break; + + case SEQCMD_OP_SETUP_CMD: + // Queue a sub-command to execute once the sequence is finished playing + subOp = (cmd & 0xF00000) >> 20; + if (subOp != SEQCMD_SUB_OP_SETUP_RESET_SETUP_CMDS) { + // Ensure the maximum number of setup commands is not exceeded + if (gActiveSeqs[seqPlayerIndex].setupCmdNum < (ARRAY_COUNT(gActiveSeqs[seqPlayerIndex].setupCmd) - 1)) { + found = gActiveSeqs[seqPlayerIndex].setupCmdNum++; + if (found < ARRAY_COUNT(gActiveSeqs[seqPlayerIndex].setupCmd)) { + gActiveSeqs[seqPlayerIndex].setupCmd[found] = cmd; + // Adds a delay of 2 frames before executing any setup commands. + // This allows setup commands to be requested along with a new sequence on a seqPlayerIndex. + // This 2 frame delay ensures the player is enabled before its state is checked for + // the purpose of deciding if the setup commands should be run. + // Otherwise, the setup commands will be executed before the sequence starts, + // when the player is still disabled, instead of when the newly played sequence ends. + gActiveSeqs[seqPlayerIndex].setupCmdTimer = 2; + } + } + } else { + // `SEQCMD_SUB_OP_SETUP_RESET_SETUP_CMDS` + // Discard all setup command requests on `seqPlayerIndex` + gActiveSeqs[seqPlayerIndex].setupCmdNum = 0; + } + break; + + case SEQCMD_OP_GLOBAL_CMD: + // Apply a command that applies to all sequence players + subOp = (cmd & 0xF00) >> 8; + val = cmd & 0xFF; + switch (subOp) { + case SEQCMD_SUB_OP_GLOBAL_SET_SOUND_MODE: + // Set sound mode + AUDIOCMD_GLOBAL_SET_SOUND_MODE(sSoundModeList[val]); + break; + + case SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES: + // Set sequence disabled in (sStartSeqDisabled & 1) bit + sStartSeqDisabled = (sStartSeqDisabled & (u8)~1) | (u8)(val & 1); + break; + + case SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES_2: + // Set sequence disabled in (sStartSeqDisabled & 2) bit + sStartSeqDisabled = (sStartSeqDisabled & (u8)~2) | (u8)((val & 1) << 1); + break; + } + break; + + case SEQCMD_OP_RESET_AUDIO_HEAP: + // Resets the audio heap based on the audio specifications, audio mode, and sfx channel layout + specId = cmd & 0xFF; + fadeReverb = (cmd & 0xFF0000) >> 16; + if (fadeReverb == 0) { + gSfxChannelLayout = (cmd & 0xFF00) >> 8; + oldSpecId = gAudioSpecId; + gAudioSpecId = specId; + AudioThread_ResetAudioHeap(specId); + Audio_ResetForAudioHeapStep1(oldSpecId); + AUDIOCMD_GLOBAL_STOP_AUDIOCMDS(); + } else { + sResetAudioHeapSeqCmd = cmd; + sResetAudioHeapFadeReverbVolume = 0x7FFF; + sResetAudioHeapTimer = 20; + sResetAudioHeapFadeReverbVolumeStep = 0x666; + } + break; + } +} + +/** + * Add the sequence cmd to the `sAudioSeqCmds` queue + */ +void AudioSeq_QueueSeqCmd(u32 cmd) { + sAudioSeqCmds[sSeqCmdWritePos++] = cmd; +} + +void AudioSeq_ProcessSeqCmds(void) { + while (sSeqCmdWritePos != sSeqCmdReadPos) { + AudioSeq_ProcessSeqCmd(sAudioSeqCmds[sSeqCmdReadPos++]); + } +} + +u16 AudioSeq_GetActiveSeqId(u8 seqPlayerIndex) { + if (gActiveSeqs[seqPlayerIndex].isWaitingForFonts == true) { + return gActiveSeqs[seqPlayerIndex].startAsyncSeqCmd & SEQCMD_SEQID_MASK; + } + + if (gActiveSeqs[seqPlayerIndex].seqId != NA_BGM_DISABLED) { + return gActiveSeqs[seqPlayerIndex].seqId; + } + + return NA_BGM_DISABLED; +} + +s32 AudioSeq_IsSeqCmdNotQueued(u32 cmdVal, u32 cmdMask) { + u8 i; + + for (i = sSeqCmdReadPos; i != sSeqCmdWritePos; i++) { + if ((sAudioSeqCmds[i] & cmdMask) == cmdVal) { + return false; + } + } + + return true; +} + +// Unused +void AudioSeq_ResetSequenceRequests(u8 seqPlayerIndex) { + sNumSeqRequests[seqPlayerIndex] = 0; +} + +/** + * Check if the setup command is queued. If it is, then replace the command + * with `SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME`. + * Unused + */ +void AudioSeq_ReplaceSeqCmdSetupOpVolRestore(u8 seqPlayerIndex, u8 setupOpDisabled) { + u8 i; + + for (i = 0; i < gActiveSeqs[seqPlayerIndex].setupCmdNum; i++) { + u8 setupOp = (gActiveSeqs[seqPlayerIndex].setupCmd[i] & 0xF00000) >> 20; + + if (setupOp == setupOpDisabled) { + gActiveSeqs[seqPlayerIndex].setupCmd[i] = 0xFF000000; + } + } +} + +void AudioSeq_SetVolumeScale(u8 seqPlayerIndex, u8 scaleIndex, u8 targetVol, u8 volFadeTimer) { + f32 volScale; + u8 i; + + gActiveSeqs[seqPlayerIndex].volScales[scaleIndex] = targetVol & 0x7F; + + if (volFadeTimer != 0) { + gActiveSeqs[seqPlayerIndex].fadeVolUpdate = true; + gActiveSeqs[seqPlayerIndex].volFadeTimer = volFadeTimer; + } else { + for (i = 0, volScale = 1.0f; i < VOL_SCALE_INDEX_MAX; i++) { + volScale *= gActiveSeqs[seqPlayerIndex].volScales[i] / 127.0f; + } + + SEQCMD_SET_SEQPLAYER_VOLUME_NOW(seqPlayerIndex, volFadeTimer, volScale); + } +} + +/** + * Update different commands and requests for active sequences + */ +void AudioSeq_UpdateActiveSequences(void) { + u32 tempoCmd; + u16 tempoPrev; + u16 seqId; + u16 channelMask; + u16 tempoTarget; + u8 setupOp; + u8 targetSeqPlayerIndex; + u8 setupVal2; + u8 setupVal1; + u8 tempoOp; + s32 pad[2]; + u32 retMsg; + f32 volume; + u8 tempoTimer; + u8 seqPlayerIndex; + u8 j; + u8 channelIndex; + + for (seqPlayerIndex = 0; seqPlayerIndex < SEQ_PLAYER_MAX; seqPlayerIndex++) { + + // The seqPlayer has finished initializing and is currently playing the active sequences + if (gActiveSeqs[seqPlayerIndex].isSeqPlayerInit && gAudioCtx.seqPlayers[seqPlayerIndex].enabled) { + gActiveSeqs[seqPlayerIndex].isSeqPlayerInit = false; + } + + // The seqPlayer is no longer playing the active sequences + if ((AudioSeq_GetActiveSeqId(seqPlayerIndex) != NA_BGM_DISABLED) && + !gAudioCtx.seqPlayers[seqPlayerIndex].enabled && (!gActiveSeqs[seqPlayerIndex].isSeqPlayerInit)) { + gActiveSeqs[seqPlayerIndex].seqId = NA_BGM_DISABLED; + } + + // Check if the requested sequences is waiting for fonts to load + if (gActiveSeqs[seqPlayerIndex].isWaitingForFonts) { + switch ((s32)AudioThread_GetExternalLoadQueueMsg(&retMsg)) { + case SEQ_PLAYER_BGM_MAIN + 1: + case SEQ_PLAYER_FANFARE + 1: + case SEQ_PLAYER_SFX + 1: + case SEQ_PLAYER_BGM_SUB + 1: + case SEQ_PLAYER_AMBIENCE + 1: + // The fonts have been loaded successfully. + gActiveSeqs[seqPlayerIndex].isWaitingForFonts = false; + // Queue the same command that was stored previously, but without the 0x8000 + AudioSeq_ProcessSeqCmd(gActiveSeqs[seqPlayerIndex].startAsyncSeqCmd); + break; + case 0xFF: + // There was an error in loading the fonts + gActiveSeqs[seqPlayerIndex].isWaitingForFonts = false; + break; + } + } + + // Update global volume + if (gActiveSeqs[seqPlayerIndex].fadeVolUpdate) { + volume = 1.0f; + for (j = 0; j < VOL_SCALE_INDEX_MAX; j++) { + volume *= (gActiveSeqs[seqPlayerIndex].volScales[j] / 127.0f); + } + + SEQCMD_SET_SEQPLAYER_VOLUME((u8)(seqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)), + gActiveSeqs[seqPlayerIndex].volFadeTimer, (u8)(volume * 127.0f)); + gActiveSeqs[seqPlayerIndex].fadeVolUpdate = false; + } + + if (gActiveSeqs[seqPlayerIndex].volTimer != 0) { + gActiveSeqs[seqPlayerIndex].volTimer--; + + if (gActiveSeqs[seqPlayerIndex].volTimer != 0) { + gActiveSeqs[seqPlayerIndex].volCur -= gActiveSeqs[seqPlayerIndex].volStep; + } else { + gActiveSeqs[seqPlayerIndex].volCur = gActiveSeqs[seqPlayerIndex].volTarget; + } + + AUDIOCMD_SEQPLAYER_FADE_VOLUME_SCALE(seqPlayerIndex, gActiveSeqs[seqPlayerIndex].volCur); + } + + // Process tempo + if (gActiveSeqs[seqPlayerIndex].tempoCmd != 0) { + tempoCmd = gActiveSeqs[seqPlayerIndex].tempoCmd; + tempoTimer = (tempoCmd & 0xFF0000) >> 15; + tempoTarget = tempoCmd & 0xFFF; + if (tempoTimer == 0) { + tempoTimer++; + } + + // Process tempo commands + if (gAudioCtx.seqPlayers[seqPlayerIndex].enabled) { + tempoPrev = gAudioCtx.seqPlayers[seqPlayerIndex].tempo / TATUMS_PER_BEAT; + tempoOp = (tempoCmd & 0xF000) >> 12; + switch (tempoOp) { + case SEQCMD_SUB_OP_TEMPO_SPEED_UP: + // Speed up tempo by `tempoTarget` amount + tempoTarget += tempoPrev; + break; + + case SEQCMD_SUB_OP_TEMPO_SLOW_DOWN: + // Slow down tempo by `tempoTarget` amount + if (tempoTarget < tempoPrev) { + tempoTarget = tempoPrev - tempoTarget; + } + break; + + case SEQCMD_SUB_OP_TEMPO_SCALE: + // Scale tempo by a multiplicative factor + tempoTarget = tempoPrev * (tempoTarget / 100.0f); + break; + + case SEQCMD_SUB_OP_TEMPO_RESET: + // Reset tempo to original tempo + tempoTarget = (gActiveSeqs[seqPlayerIndex].tempoOriginal != 0) + ? gActiveSeqs[seqPlayerIndex].tempoOriginal + : tempoPrev; + break; + + default: // `SEQCMD_SUB_OP_TEMPO_SET` + // `tempoTarget` is the new tempo + break; + } + + if (gActiveSeqs[seqPlayerIndex].tempoOriginal == 0) { + gActiveSeqs[seqPlayerIndex].tempoOriginal = tempoPrev; + } + + gActiveSeqs[seqPlayerIndex].tempoTarget = tempoTarget; + gActiveSeqs[seqPlayerIndex].tempoCur = gAudioCtx.seqPlayers[seqPlayerIndex].tempo / 0x30; + gActiveSeqs[seqPlayerIndex].tempoStep = + (gActiveSeqs[seqPlayerIndex].tempoCur - gActiveSeqs[seqPlayerIndex].tempoTarget) / tempoTimer; + gActiveSeqs[seqPlayerIndex].tempoTimer = tempoTimer; + gActiveSeqs[seqPlayerIndex].tempoCmd = 0; + } + } + + // Step tempo to target + if (gActiveSeqs[seqPlayerIndex].tempoTimer != 0) { + gActiveSeqs[seqPlayerIndex].tempoTimer--; + if (gActiveSeqs[seqPlayerIndex].tempoTimer != 0) { + gActiveSeqs[seqPlayerIndex].tempoCur -= gActiveSeqs[seqPlayerIndex].tempoStep; + } else { + gActiveSeqs[seqPlayerIndex].tempoCur = gActiveSeqs[seqPlayerIndex].tempoTarget; + } + + AUDIOCMD_SEQPLAYER_SET_TEMPO(seqPlayerIndex, gActiveSeqs[seqPlayerIndex].tempoCur); + } + + // Update channel volumes + if (gActiveSeqs[seqPlayerIndex].volChannelFlags != 0) { + for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) { + if (gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTimer != 0) { + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTimer--; + if (gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTimer != 0) { + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur -= + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volStep; + } else { + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur = + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTarget; + gActiveSeqs[seqPlayerIndex].volChannelFlags ^= (1 << channelIndex); + } + + AUDIOCMD_CHANNEL_SET_VOL_SCALE(seqPlayerIndex, channelIndex, + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur); + } + } + } + + // Update frequencies + if (gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags != 0) { + for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) { + if (gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTimer != 0) { + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTimer--; + if (gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTimer != 0) { + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleCur -= + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleStep; + } else { + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleCur = + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTarget; + gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags ^= (1 << channelIndex); + } + + AUDIOCMD_CHANNEL_SET_FREQ_SCALE(seqPlayerIndex, channelIndex, + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleCur); + } + } + } + + // Process setup commands + if (gActiveSeqs[seqPlayerIndex].setupCmdNum != 0) { + // If there is a SeqCmd to reset the audio heap queued, then drop all setup commands + if (!AudioSeq_IsSeqCmdNotQueued(SEQCMD_OP_RESET_AUDIO_HEAP << 28, SEQCMD_OP_MASK)) { + gActiveSeqs[seqPlayerIndex].setupCmdNum = 0; + break; + } + + // Only process setup commands once the timer reaches zero + if (gActiveSeqs[seqPlayerIndex].setupCmdTimer != 0) { + gActiveSeqs[seqPlayerIndex].setupCmdTimer--; + continue; + } + + // Only process setup commands if `seqPlayerIndex` if no longer playing + // i.e. the `seqPlayer` is no longer enabled + if (gAudioCtx.seqPlayers[seqPlayerIndex].enabled) { + continue; + } + + for (j = 0; j < gActiveSeqs[seqPlayerIndex].setupCmdNum; j++) { + setupOp = (gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0xF00000) >> 20; + targetSeqPlayerIndex = (gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0xF0000) >> 16; + setupVal2 = (gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0xFF00) >> 8; + setupVal1 = gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0xFF; + + switch (setupOp) { + case SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME: + // Restore `targetSeqPlayerIndex` volume back to normal levels + AudioSeq_SetVolumeScale(targetSeqPlayerIndex, VOL_SCALE_INDEX_FANFARE, 0x7F, setupVal1); + break; + + case SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_IF_QUEUED: + // Restore `targetSeqPlayerIndex` volume back to normal levels, + // but only if the number of sequence queue requests from `sSeqRequests` + // exactly matches the argument to the command + if (setupVal1 == sNumSeqRequests[seqPlayerIndex]) { + AudioSeq_SetVolumeScale(targetSeqPlayerIndex, VOL_SCALE_INDEX_FANFARE, 0x7F, setupVal2); + } + break; + + case SEQCMD_SUB_OP_SETUP_SEQ_UNQUEUE: + // Unqueue `seqPlayerIndex` from sSeqRequests + //! @bug this command does not work as intended as unqueueing + //! the sequence relies on `gActiveSeqs[seqPlayerIndex].seqId` + //! However, `gActiveSeqs[seqPlayerIndex].seqId` is reset before the sequence on + //! `seqPlayerIndex` is requested to stop, i.e. before the sequence is disabled and setup + //! commands (including this command) can run. A simple fix would have been to unqueue based on + //! `gActiveSeqs[seqPlayerIndex].prevSeqId` instead + SEQCMD_UNQUEUE_SEQUENCE((u8)(seqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)), 0, + gActiveSeqs[seqPlayerIndex].seqId); + break; + + case SEQCMD_SUB_OP_SETUP_RESTART_SEQ: + // Restart the currently active sequence on `targetSeqPlayerIndex` with full volume. + // Sequence on `targetSeqPlayerIndex` must still be active to play (can be muted) + SEQCMD_PLAY_SEQUENCE((u8)(targetSeqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)), 1, + gActiveSeqs[targetSeqPlayerIndex].seqId); + gActiveSeqs[targetSeqPlayerIndex].fadeVolUpdate = true; + gActiveSeqs[targetSeqPlayerIndex].volScales[1] = 0x7F; + break; + + case SEQCMD_SUB_OP_SETUP_TEMPO_SCALE: + // Scale tempo by a multiplicative factor + SEQCMD_SCALE_TEMPO((u8)(targetSeqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)), setupVal2, + setupVal1); + break; + + case SEQCMD_SUB_OP_SETUP_TEMPO_RESET: + // Reset tempo to previous tempo + SEQCMD_RESET_TEMPO((u8)(targetSeqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)), setupVal1); + break; + + case SEQCMD_SUB_OP_SETUP_PLAY_SEQ: + // Play the requested sequence + // Uses the fade timer set by `SEQCMD_SUB_OP_SETUP_SET_FADE_TIMER` + seqId = gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0xFFFF; + SEQCMD_PLAY_SEQUENCE((u8)(targetSeqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)), + gActiveSeqs[targetSeqPlayerIndex].setupFadeTimer, seqId); + AudioSeq_SetVolumeScale(targetSeqPlayerIndex, VOL_SCALE_INDEX_FANFARE, 0x7F, 0); + gActiveSeqs[targetSeqPlayerIndex].setupFadeTimer = 0; + break; + + case SEQCMD_SUB_OP_SETUP_SET_FADE_TIMER: + // A command specifically to support `SEQCMD_SUB_OP_SETUP_PLAY_SEQ` + // Sets the fade timer for the sequence requested in `SEQCMD_SUB_OP_SETUP_PLAY_SEQ` + gActiveSeqs[seqPlayerIndex].setupFadeTimer = setupVal2; + break; + + case SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX: + // Restore the volume back to default levels + // Allows a `scaleIndex` to be specified. + AudioSeq_SetVolumeScale(targetSeqPlayerIndex, setupVal2, 0x7F, setupVal1); + break; + + case SEQCMD_SUB_OP_SETUP_POP_PERSISTENT_CACHE: + // Discard audio data by popping one more audio caches from the audio heap + if (setupVal1 & (1 << SEQUENCE_TABLE)) { + AUDIOCMD_GLOBAL_POP_PERSISTENT_CACHE(SEQUENCE_TABLE); + } + if (setupVal1 & (1 << FONT_TABLE)) { + AUDIOCMD_GLOBAL_POP_PERSISTENT_CACHE(FONT_TABLE); + } + if (setupVal1 & (1 << SAMPLE_TABLE)) { + AUDIOCMD_GLOBAL_POP_PERSISTENT_CACHE(SAMPLE_TABLE); + } + break; + + case SEQCMD_SUB_OP_SETUP_SET_CHANNEL_DISABLE_MASK: + // Disable (or reenable) specific channels of `targetSeqPlayerIndex` + channelMask = gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0xFFFF; + SEQCMD_SET_CHANNEL_DISABLE_MASK((u8)(targetSeqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)), + channelMask); + break; + + case SEQCMD_SUB_OP_SETUP_SET_SEQPLAYER_FREQ: + // Scale all channels of `targetSeqPlayerIndex` + SEQCMD_SET_SEQPLAYER_FREQ((u8)(targetSeqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)), setupVal2, + setupVal1 * 10); + break; + + default: + break; + } + } + + gActiveSeqs[seqPlayerIndex].setupCmdNum = 0; + } + } +} + +u8 AudioSeq_UpdateAudioHeapReset(void) { + if (gAudioHeapResetState != AUDIO_HEAP_RESET_STATE_NONE) { + if (gAudioHeapResetState == AUDIO_HEAP_RESET_STATE_RESETTING) { + if (func_80193C5C() == 1) { + gAudioHeapResetState = AUDIO_HEAP_RESET_STATE_NONE; + AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_SFX, 0, gSfxChannelLayout); + Audio_ResetForAudioHeapStep2(); + } + } else if (gAudioHeapResetState == AUDIO_HEAP_RESET_STATE_RESETTING_ALT) { + while (func_80193C5C() != 1) {} + gAudioHeapResetState = AUDIO_HEAP_RESET_STATE_NONE; + AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_SFX, 0, gSfxChannelLayout); + Audio_ResetForAudioHeapStep2(); + } + } + + return gAudioHeapResetState; +} + +u8 AudioSeq_ResetReverb(void) { + u8 isReverbFading = false; + u8 fadeReverb = ((sResetAudioHeapSeqCmd & 0xFF0000) >> 16); + u8 reverbIndex = 0; + u8 specId; + + if (sResetAudioHeapSeqCmd != 0) { + if (sResetAudioHeapTimer--) { + while (fadeReverb != 0) { + if (fadeReverb & 1) { + AUDIOCMD_GLOBAL_SET_REVERB_DATA(reverbIndex, REVERB_DATA_TYPE_VOLUME, + sResetAudioHeapFadeReverbVolume); + AudioThread_ScheduleProcessCmds(); + } + reverbIndex++; + fadeReverb = fadeReverb >> 1; + } + + sResetAudioHeapFadeReverbVolume -= sResetAudioHeapFadeReverbVolumeStep; + isReverbFading = true; + } else { + while (fadeReverb != 0) { + if (fadeReverb & 1) { + AUDIOCMD_GLOBAL_SET_REVERB_DATA( + reverbIndex, REVERB_DATA_TYPE_SETTINGS, + (s32)(gReverbSettingsTable[(u8)(sResetAudioHeapSeqCmd & 0xFF)] + reverbIndex)); + AudioThread_ScheduleProcessCmds(); + } + reverbIndex++; + fadeReverb = fadeReverb >> 1; + } + + sResetAudioHeapSeqCmd = 0; + AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_SFX, 0, gSfxChannelLayout); + Audio_ResetForAudioHeapStep3(); + } + } + + return isReverbFading; +} + +void AudioSeq_ResetActiveSequences(void) { + u8 seqPlayerIndex; + u8 scaleIndex; + + for (seqPlayerIndex = 0; seqPlayerIndex < SEQ_PLAYER_MAX; seqPlayerIndex++) { + sNumSeqRequests[seqPlayerIndex] = 0; + + gActiveSeqs[seqPlayerIndex].seqId = NA_BGM_DISABLED; + gActiveSeqs[seqPlayerIndex].prevSeqId = NA_BGM_DISABLED; + gActiveSeqs[seqPlayerIndex].tempoTimer = 0; + gActiveSeqs[seqPlayerIndex].tempoOriginal = 0; + gActiveSeqs[seqPlayerIndex].tempoCmd = 0; + gActiveSeqs[seqPlayerIndex].channelPortMask = 0; + gActiveSeqs[seqPlayerIndex].setupCmdNum = 0; + gActiveSeqs[seqPlayerIndex].setupFadeTimer = 0; + gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags = 0; + gActiveSeqs[seqPlayerIndex].volChannelFlags = 0; + gActiveSeqs[seqPlayerIndex].isWaitingForFonts = false; + gActiveSeqs[seqPlayerIndex].isSeqPlayerInit = false; + + for (scaleIndex = 0; scaleIndex < VOL_SCALE_INDEX_MAX; scaleIndex++) { + gActiveSeqs[seqPlayerIndex].volScales[scaleIndex] = 0x7F; + } + + gActiveSeqs[seqPlayerIndex].volFadeTimer = 1; + gActiveSeqs[seqPlayerIndex].fadeVolUpdate = true; + } +} + +void AudioSeq_ResetActiveSequencesAndVolume(void) { + u8 seqPlayerIndex; + u8 scaleIndex; + + for (seqPlayerIndex = 0; seqPlayerIndex < SEQ_PLAYER_MAX; seqPlayerIndex++) { + gActiveSeqs[seqPlayerIndex].volCur = 1.0f; + gActiveSeqs[seqPlayerIndex].volTimer = 0; + gActiveSeqs[seqPlayerIndex].fadeVolUpdate = false; + for (scaleIndex = 0; scaleIndex < VOL_SCALE_INDEX_MAX; scaleIndex++) { + gActiveSeqs[seqPlayerIndex].volScales[scaleIndex] = 0x7F; + } + } + AudioSeq_ResetActiveSequences(); +} diff --git a/src/code/audio/audio_init_params.c b/src/audio/session_config.c similarity index 99% rename from src/code/audio/audio_init_params.c rename to src/audio/session_config.c index 6bba865e9..e0881913b 100644 --- a/src/code/audio/audio_init_params.c +++ b/src/audio/session_config.c @@ -1,4 +1,5 @@ #include "global.h" +#include "buffers.h" const s16 gAudioTatumInit[] = { 0x1C00, // unused diff --git a/src/code/audio/code_801A5BD0.c b/src/audio/sfx.c similarity index 99% rename from src/code/audio/code_801A5BD0.c rename to src/audio/sfx.c index 76597f5f3..537a9f394 100644 --- a/src/code/audio/code_801A5BD0.c +++ b/src/audio/sfx.c @@ -102,8 +102,8 @@ void AudioSfx_MuteBanks(u16 muteMask) { void AudioSfx_LowerBgmVolume(u8 channelIndex) { sSfxChannelLowVolumeFlag |= (1 << channelIndex); - Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 2, 0x40, 0xF); - Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 2, 0x40, 0xF); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_SFX, 0x40, 0xF); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_SFX, 0x40, 0xF); } /** @@ -114,8 +114,8 @@ void AudioSfx_RestoreBgmVolume(u8 channelIndex) { sSfxChannelLowVolumeFlag &= ((1 << channelIndex) ^ 0xFFFF); if (sSfxChannelLowVolumeFlag == 0) { - Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 2, 0x7F, 0xF); - Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 2, 0x7F, 0xF); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_SFX, 0x7F, 0xF); + AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_SFX, 0x7F, 0xF); } } diff --git a/src/code/audio/audio_sfx_params.c b/src/audio/sfx_params.c similarity index 100% rename from src/code/audio/audio_sfx_params.c rename to src/audio/sfx_params.c diff --git a/src/audio/voice_external.c b/src/audio/voice_external.c new file mode 100644 index 000000000..eba2069d8 --- /dev/null +++ b/src/audio/voice_external.c @@ -0,0 +1,17 @@ +#include "global.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_external/func_801A4EB0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_external/func_801A4EB8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_external/func_801A4FD8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_external/func_801A5080.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_external/func_801A50C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_external/func_801A5100.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_external/func_801A510C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_external/func_801A5118.s") diff --git a/src/audio/voice_internal.c b/src/audio/voice_internal.c new file mode 100644 index 000000000..055b66ed1 --- /dev/null +++ b/src/audio/voice_internal.c @@ -0,0 +1,42 @@ +#include "global.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/D_801E0EC0.s") + +UNK_TYPE func_801A51F0(UNK_TYPE arg0) { + switch (arg0) { + case 1: + case 4: + case 5: + case 11: + case 13: + case 14: + case 15: + return -1; + default: + return 0; + } +} + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/func_801A5228.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/func_801A5390.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/func_801A53DC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/func_801A53E8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/func_801A541C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/func_801A5488.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/func_801A54C4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/func_801A54D0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/func_801A5680.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/func_801A5808.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/AudioVoice_ResetData.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/func_801A5A1C.s") diff --git a/src/boot_O2/stackcheck.c b/src/boot_O2/stackcheck.c index 20e56f480..edd1e3a30 100644 --- a/src/boot_O2/stackcheck.c +++ b/src/boot_O2/stackcheck.c @@ -1,18 +1,19 @@ -#include "global.h" +#include "stackcheck.h" +#include "libc/stdbool.h" +#include "libc/stdint.h" StackEntry* sStackInfoListStart = NULL; StackEntry* sStackInfoListEnd = NULL; -void StackCheck_Init(StackEntry* entry, void* stackTop, void* stackBottom, u32 initValue, s32 minSpace, +void StackCheck_Init(StackEntry* entry, void* stackBottom, void* stackTop, u32 initValue, s32 minSpace, const char* name) { - StackEntry* iter; - u32* addr; - - if (!entry) { + if (entry == NULL) { sStackInfoListStart = NULL; } else { - entry->head = (u32)stackTop; - entry->tail = (u32)stackBottom; + StackEntry* iter; + + entry->head = stackBottom; + entry->tail = stackTop; entry->initValue = initValue; entry->minSpace = minSpace; entry->name = name; @@ -32,13 +33,14 @@ void StackCheck_Init(StackEntry* entry, void* stackTop, void* stackBottom, u32 i } sStackInfoListEnd = entry; - if (!sStackInfoListStart) { + if (sStackInfoListStart == NULL) { sStackInfoListStart = entry; } if (entry->minSpace != -1) { - addr = (u32*)entry->head; - while ((u32)addr < entry->tail) { + u32* addr = entry->head; + + while (addr < (u32*)entry->tail) { *addr++ = entry->initValue; } } @@ -46,13 +48,13 @@ void StackCheck_Init(StackEntry* entry, void* stackTop, void* stackBottom, u32 i } void StackCheck_Cleanup(StackEntry* entry) { - u32 inconsistency = 0; // unused variable needed to match + u32 inconsistency = false; - if (!entry->prev) { + if (entry->prev == NULL) { if (entry == sStackInfoListStart) { sStackInfoListStart = entry->next; } else { - inconsistency = 1; + inconsistency = true; } } else { entry->prev->next = entry->next; @@ -62,7 +64,7 @@ void StackCheck_Cleanup(StackEntry* entry) { if (entry == sStackInfoListEnd) { sStackInfoListEnd = entry->prev; } else { - inconsistency = 1; + inconsistency = true; } } @@ -71,22 +73,22 @@ void StackCheck_Cleanup(StackEntry* entry) { StackStatus StackCheck_GetState(StackEntry* entry) { u32* last; - u32 used; - u32 free; - s32 status; + size_t used; + size_t free; + StackStatus status; - for (last = (u32*)entry->head; (u32)last < entry->tail; last++) { + for (last = entry->head; last < (u32*)entry->tail; last++) { if (entry->initValue != *last) { break; } } - used = entry->tail - (u32)last; - free = (u32)last - entry->head; + used = (uintptr_t)entry->tail - (uintptr_t)last; + free = (uintptr_t)last - (uintptr_t)entry->head; if (free == 0) { status = STACK_STATUS_OVERFLOW; - } else if (free < (u32)entry->minSpace && entry->minSpace != -1) { + } else if ((free < (size_t)entry->minSpace) && (entry->minSpace != -1)) { status = STACK_STATUS_WARNING; } else { status = STACK_STATUS_OK; @@ -95,13 +97,14 @@ StackStatus StackCheck_GetState(StackEntry* entry) { return status; } -u32 StackCheck_CheckAll() { +u32 StackCheck_CheckAll(void) { u32 ret = 0; StackEntry* iter = sStackInfoListStart; - while (iter) { - u32 state = StackCheck_GetState(iter); - if (state) { + while (iter != NULL) { + StackStatus state = StackCheck_GetState(iter); + + if (state != STACK_STATUS_OK) { ret = 1; } iter = iter->next; @@ -111,7 +114,7 @@ u32 StackCheck_CheckAll() { } u32 StackCheck_Check(StackEntry* entry) { - if (!entry) { + if (entry == NULL) { return StackCheck_CheckAll(); } else { return StackCheck_GetState(entry); diff --git a/src/boot_O2_g3/CIC6105.c b/src/boot_O2_g3/CIC6105.c index 78eed1a77..4745ad5c8 100644 --- a/src/boot_O2_g3/CIC6105.c +++ b/src/boot_O2_g3/CIC6105.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" UNK_TYPE4 D_8009BE30; diff --git a/src/boot_O2_g3/boot_main.c b/src/boot_O2_g3/boot_main.c index 04bb9a33a..7b8d7126b 100644 --- a/src/boot_O2_g3/boot_main.c +++ b/src/boot_O2_g3/boot_main.c @@ -1,20 +1,21 @@ #include "global.h" +#include "stack.h" +#include "stackcheck.h" -StackEntry sBootThreadInfo; +StackEntry sBootStackInfo; OSThread sIdleThread; -u8 sIdleThreadStack[0x400]; -StackEntry sIdleThreadInfo; -u8 sBootThreadStack[0x400]; +STACK(sIdleStack, 0x400); +StackEntry sIdleStackInfo; +STACK(sBootStack, 0x400); void bootproc(void) { - StackCheck_Init(&sBootThreadInfo, sBootThreadStack, sBootThreadStack + sizeof(sBootThreadStack), 0, -1, "boot"); + StackCheck_Init(&sBootStackInfo, sBootStack, STACK_TOP(sBootStack), 0, -1, "boot"); osMemSize = osGetMemSize(); func_800818F4(); osInitialize(); osUnmapTLBAll(); gCartHandle = osCartRomInit(); - StackCheck_Init(&sIdleThreadInfo, sIdleThreadStack, sIdleThreadStack + sizeof(sIdleThreadStack), 0, 256, "idle"); - osCreateThread(&sIdleThread, Z_THREAD_ID_IDLE, Idle_ThreadEntry, NULL, sIdleThreadStack + sizeof(sIdleThreadStack), - Z_PRIORITY_IDLE); + StackCheck_Init(&sIdleStackInfo, sIdleStack, STACK_TOP(sIdleStack), 0, 0x100, "idle"); + osCreateThread(&sIdleThread, Z_THREAD_ID_IDLE, Idle_ThreadEntry, NULL, STACK_TOP(sIdleStack), Z_PRIORITY_IDLE); osStartThread(&sIdleThread); } diff --git a/src/boot_O2_g3/fault.c b/src/boot_O2_g3/fault.c index e648275b6..6e1656170 100644 --- a/src/boot_O2_g3/fault.c +++ b/src/boot_O2_g3/fault.c @@ -1,6 +1,15 @@ #include "ultra64.h" #include "global.h" +#include "stack.h" #include "vt.h" +#include "stackcheck.h" + +extern FaultThreadStruct* sFaultContext; +extern f32 D_8009BE54; +extern u32 faultCustomOptions; +extern u32 faultCopyToLog; +extern STACK(sFaultStack, 0x600); +extern StackEntry sFaultStackInfo; // data const char* sCpuExceptions[] = { @@ -195,7 +204,7 @@ void Fault_Sleep(u32 duration) { } void Fault_PadCallback(Input* input) { - Padmgr_GetInput2(input, 0); + PadMgr_GetInput2(input, false); } void Fault_UpdatePadImpl() { @@ -465,7 +474,7 @@ void Fault_WaitForButtonCombo(void) { do { Fault_Sleep(0x10); Fault_UpdatePadImpl(); - } while (!CHECK_BTN_ALL(input->press.button, 0x80)); + } while (!CHECK_BTN_ALL(input->press.button, BTN_RESET)); } while (!CHECK_BTN_ALL(input->cur.button, BTN_DLEFT | BTN_L | BTN_R | BTN_CRIGHT)); } @@ -754,14 +763,14 @@ void Fault_SetOptionsFromController3(void) { u32 graphRA; u32 graphSP; - if (CHECK_BTN_ALL(input3->press.button, 0x80)) { + if (CHECK_BTN_ALL(input3->press.button, BTN_RESET)) { faultCustomOptions = !faultCustomOptions; } if (faultCustomOptions) { - graphPC = sGraphThread.context.pc; - graphRA = sGraphThread.context.ra; - graphSP = sGraphThread.context.sp; + graphPC = gGraphThread.context.pc; + graphRA = gGraphThread.context.ra; + graphSP = gGraphThread.context.sp; if (CHECK_BTN_ALL(input3->cur.button, BTN_R)) { static u32 faultCopyToLog; @@ -793,8 +802,8 @@ void Fault_ThreadEntry(void* arg) { u32 pad; OSThread* faultedThread; - osSetEventMesg(10, &sFaultContext->queue, (OSMesg)1); - osSetEventMesg(12, &sFaultContext->queue, (OSMesg)2); + osSetEventMesg(OS_EVENT_CPU_BREAK, &sFaultContext->queue, (OSMesg)1); + osSetEventMesg(OS_EVENT_FAULT, &sFaultContext->queue, (OSMesg)2); while (1) { do { osRecvMesg(&sFaultContext->queue, &msg, OS_MESG_BLOCK); @@ -889,8 +898,8 @@ void Fault_Start(void) { sFaultContext->faultActive = 0; gFaultStruct.faultHandlerEnabled = 1; osCreateMesgQueue(&sFaultContext->queue, sFaultContext->msg, ARRAY_COUNT(sFaultContext->msg)); - StackCheck_Init(&sFaultThreadInfo, sFaultStack, sFaultStack + sizeof(sFaultStack), 0, 0x100, "fault"); - osCreateThread(&sFaultContext->thread, 2, Fault_ThreadEntry, NULL, sFaultStack + sizeof(sFaultStack), 0x7F); + StackCheck_Init(&sFaultStackInfo, sFaultStack, STACK_TOP(sFaultStack), 0, 0x100, "fault"); + osCreateThread(&sFaultContext->thread, 2, Fault_ThreadEntry, NULL, STACK_TOP(sFaultStack), 0x7F); osStartThread(&sFaultContext->thread); } diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index 942435fa7..6c63e2a70 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -1,4 +1,8 @@ +#include "prevent_bss_reordering.h" #include "global.h" +#include "stack.h" +#include "buffers.h" +#include "stackcheck.h" u8 D_80096B20 = 1; vu8 gViConfigUseDefault = 1; @@ -8,10 +12,10 @@ f32 gViConfigXScale = 1.0f; f32 gViConfigYScale = 1.0f; IrqMgr gIrqMgr; -u8 sIrqMgrStack[0x500]; +STACK(sIrqMgrStack, 0x500); StackEntry sIrqMgrStackInfo; -OSThread gMainThread; -u8 sMainStack[0x900]; +OSThread sMainThread; +STACK(sMainStack, 0x900); StackEntry sMainStackInfo; OSMesg sPiMgrCmdBuff[50]; OSMesgQueue gPiMgrCmdQ; @@ -70,8 +74,8 @@ void Idle_InitCodeAndMemory(void) { } void Main_ThreadEntry(void* arg) { - StackCheck_Init(&sIrqMgrStackInfo, sIrqMgrStack, sIrqMgrStack + sizeof(sIrqMgrStack), 0, 0x100, "irqmgr"); - IrqMgr_Init(&gIrqMgr, &sIrqMgrStackInfo, Z_PRIORITY_IRQMGR, 1); + StackCheck_Init(&sIrqMgrStackInfo, sIrqMgrStack, STACK_TOP(sIrqMgrStack), 0, 0x100, "irqmgr"); + IrqMgr_Init(&gIrqMgr, STACK_TOP(sIrqMgrStack), Z_PRIORITY_IRQMGR, 1); DmaMgr_Start(); Idle_InitCodeAndMemory(); Main(arg); @@ -107,10 +111,9 @@ void Idle_InitVideo(void) { void Idle_ThreadEntry(void* arg) { Idle_InitVideo(); osCreatePiManager(150, &gPiMgrCmdQ, sPiMgrCmdBuff, ARRAY_COUNT(sPiMgrCmdBuff)); - StackCheck_Init(&sMainStackInfo, sMainStack, sMainStack + sizeof(sMainStack), 0, 0x400, "main"); - osCreateThread(&gMainThread, Z_THREAD_ID_MAIN, Main_ThreadEntry, arg, sMainStack + sizeof(sMainStack), - Z_PRIORITY_MAIN); - osStartThread(&gMainThread); + StackCheck_Init(&sMainStackInfo, sMainStack, STACK_TOP(sMainStack), 0, 0x400, "main"); + osCreateThread(&sMainThread, Z_THREAD_ID_MAIN, Main_ThreadEntry, arg, STACK_TOP(sMainStack), Z_PRIORITY_MAIN); + osStartThread(&sMainThread); osSetThreadPri(NULL, 0); do { } while (true); } diff --git a/src/boot_O2_g3/irqmgr.c b/src/boot_O2_g3/irqmgr.c index b100f209d..1f1e94ab4 100644 --- a/src/boot_O2_g3/irqmgr.c +++ b/src/boot_O2_g3/irqmgr.c @@ -1,4 +1,5 @@ #include "global.h" +#include "stackcheck.h" vs32 gIrqMgrResetStatus = 0; volatile OSTime sIrqMgrResetTime = 0; @@ -160,9 +161,9 @@ void IrqMgr_Init(IrqMgr* irqmgr, void* stack, OSPri pri, u8 retraceCount) { irqmgr->lastPrenmiTime = 0; osCreateMesgQueue(&irqmgr->irqQueue, (OSMesg*)irqmgr->irqBuffer, ARRAY_COUNT(irqmgr->irqBuffer)); - osSetEventMesg(0xE, &irqmgr->irqQueue, (OSMesg)0x29D); + osSetEventMesg(OS_EVENT_PRENMI, &irqmgr->irqQueue, (OSMesg)0x29D); osViSetEvent(&irqmgr->irqQueue, (OSMesg)0x29A, retraceCount); - osCreateThread(&irqmgr->thread, Z_THREAD_ID_IRQMGR, (osCreateThread_func)IrqMgr_ThreadEntry, irqmgr, stack, pri); + osCreateThread(&irqmgr->thread, Z_THREAD_ID_IRQMGR, IrqMgr_ThreadEntry, irqmgr, stack, pri); osStartThread(&irqmgr->thread); } diff --git a/src/boot_O2_g3/yaz0.c b/src/boot_O2_g3/yaz0.c index 63260e885..3517b97ae 100644 --- a/src/boot_O2_g3/yaz0.c +++ b/src/boot_O2_g3/yaz0.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" u8 sYaz0DataBuffer[0x400]; @@ -6,7 +5,7 @@ u8* sYaz0CurDataEnd; uintptr_t sYaz0CurRomStart; u32 sYaz0CurSize; u8* sYaz0MaxPtr; -u8* D_8009BE20; +void* gYaz0DecompressDstEnd; void* Yaz0_FirstDMA() { u32 pad0; @@ -118,7 +117,7 @@ s32 Yaz0_DecompressImpl(u8* src, u8* dst) { bitIdx--; } while (dst != dstEnd); - D_8009BE20 = dstEnd; + gYaz0DecompressDstEnd = dstEnd; return 0; } diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index f4003de8f..bbf8e4bed 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -1,4 +1,6 @@ #include "global.h" +#include "stack.h" +#include "stackcheck.h" u32 sDmaMgrDmaBuffSize = 0x2000; @@ -7,7 +9,7 @@ u16 numDmaEntries; OSMesgQueue sDmaMgrMsgQueue; OSMesg sDmaMgrMsgs[32]; OSThread sDmaMgrThread; -u8 sDmaMgrStack[0x500]; +STACK(sDmaMgrStack, 0x500); s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size) { OSIoMesg ioMsg; @@ -225,8 +227,8 @@ void DmaMgr_Start(void) { } osCreateMesgQueue(&sDmaMgrMsgQueue, sDmaMgrMsgs, ARRAY_COUNT(sDmaMgrMsgs)); - StackCheck_Init(&sDmaMgrStackInfo, sDmaMgrStack, sDmaMgrStack + sizeof(sDmaMgrStack), 0, 0x100, "dmamgr"); - osCreateThread(&sDmaMgrThread, Z_THREAD_ID_DMAMGR, DmaMgr_ThreadEntry, NULL, sDmaMgrStack + sizeof(sDmaMgrStack), + StackCheck_Init(&sDmaMgrStackInfo, sDmaMgrStack, STACK_TOP(sDmaMgrStack), 0, 0x100, "dmamgr"); + osCreateThread(&sDmaMgrThread, Z_THREAD_ID_DMAMGR, DmaMgr_ThreadEntry, NULL, STACK_TOP(sDmaMgrStack), Z_PRIORITY_DMAMGR); osStartThread(&sDmaMgrThread); diff --git a/src/buffers/gfxpools.c b/src/buffers/gfxpools.c index a91c87bed..ff4934f11 100644 --- a/src/buffers/gfxpools.c +++ b/src/buffers/gfxpools.c @@ -1,3 +1,3 @@ -#include "global.h" +#include "buffers.h" GfxPool gGfxPools[2]; diff --git a/src/buffers/gfxstack.c b/src/buffers/gfxstack.c index 2b158d141..8864d58ef 100644 --- a/src/buffers/gfxstack.c +++ b/src/buffers/gfxstack.c @@ -1,3 +1,3 @@ -#include "global.h" +#include "buffers.h" -u8 gGfxSPTaskStack[0x400]; +STACK(gGfxSPTaskStack, 0x400); diff --git a/src/buffers/gfxyield.c b/src/buffers/gfxyield.c index 94a5f55c9..576cfc0bb 100644 --- a/src/buffers/gfxyield.c +++ b/src/buffers/gfxyield.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" -#include "global.h" +#include "buffers.h" u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; diff --git a/src/buffers/heaps.c b/src/buffers/heaps.c index 866d51c16..477eca03e 100644 --- a/src/buffers/heaps.c +++ b/src/buffers/heaps.c @@ -1,4 +1,4 @@ -#include "global.h" +#include "buffers.h" u8 gAudioHeap[0x138000]; diff --git a/src/code/PreRender.c b/src/code/PreRender.c index 599f4c8d3..172659cf7 100644 --- a/src/code/PreRender.c +++ b/src/code/PreRender.c @@ -1,4 +1,7 @@ #include "global.h" +#include "slowly.h" +#include "stack.h" +#include "stackcheck.h" /** * Assigns the "save" values in PreRender @@ -51,8 +54,8 @@ void func_8016FDB8(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, u32 ar flags = 0x1C; } - func_80172758(&gfx, buf, NULL, this->width, this->height, G_IM_FMT_RGBA, G_IM_SIZ_16b, G_TT_NONE, 0, 0.0f, 0.0f, - 1.0f, 1.0f, flags); + Prerender_DrawBackground2D(&gfx, buf, NULL, this->width, this->height, G_IM_FMT_RGBA, G_IM_SIZ_16b, G_TT_NONE, 0, + 0.0f, 0.0f, 1.0f, 1.0f, flags); gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); @@ -87,8 +90,8 @@ void func_8016FF90(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, s32 en gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, this->width, this->height); - func_80172758(&gfx, buf, 0, this->width, this->height, G_IM_FMT_RGBA, G_IM_SIZ_16b, G_TT_NONE, 0, 0.0f, 0.0f, 1.0f, - 1.0f, 0xB); + Prerender_DrawBackground2D(&gfx, buf, 0, this->width, this->height, G_IM_FMT_RGBA, G_IM_SIZ_16b, G_TT_NONE, 0, 0.0f, + 0.0f, 1.0f, 1.0f, 0xB); gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); @@ -410,19 +413,24 @@ void PreRender_ApplyFilters(PreRender* this) { } } +extern SlowlyMgr sSlowlyMgr; +extern s32 D_801F6FC0; +extern StackEntry sSlowlyStackInfo; +extern STACK(sSlowlyStack, 0x1000); + /** * Initializes `PreRender_ApplyFilters` onto a new "slowly" thread */ void PreRender_ApplyFiltersSlowlyInit(PreRender* this) { if ((this->cvgSave != NULL) && (this->fbufSave != NULL)) { if (D_801F6FC0) { - StackCheck_Cleanup(&slowlyStackEntry); - Slowly_Stop(&D_801F6E00); + StackCheck_Cleanup(&sSlowlyStackInfo); + Slowly_Destroy(&sSlowlyMgr); } this->unk_4D = 1; - StackCheck_Init(&slowlyStackEntry, slowlyStack, &slowlyStack[4096], 0, 0x100, "slowly"); - Slowly_Start(&D_801F6E00, &D_801F7FE8, PreRender_ApplyFilters, this, NULL); + StackCheck_Init(&sSlowlyStackInfo, sSlowlyStack, STACK_TOP(sSlowlyStack), 0, 0x100, "slowly"); + Slowly_Init(&sSlowlyMgr, STACK_TOP(sSlowlyStack), (void*)PreRender_ApplyFilters, this, NULL); D_801F6FC0 = true; } } @@ -432,8 +440,8 @@ void PreRender_ApplyFiltersSlowlyInit(PreRender* this) { */ void PreRender_ApplyFiltersSlowlyDestroy(PreRender* this) { if (D_801F6FC0) { - StackCheck_Cleanup(&slowlyStackEntry); - Slowly_Stop(&D_801F6E00); + StackCheck_Cleanup(&sSlowlyStackInfo); + Slowly_Destroy(&sSlowlyMgr); D_801F6FC0 = false; } } @@ -447,8 +455,8 @@ void func_801720C4(PreRender* this) { #pragma GLOBAL_ASM("asm/non_matchings/code/PreRender/func_801720FC.s") -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 Prerender_DrawBackground2D(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) { PreRenderParams params; PreRenderParams* paramsp = ¶ms; diff --git a/src/code/TwoHeadArena.c b/src/code/TwoHeadArena.c index 83d5be3d1..a476c3d74 100644 --- a/src/code/TwoHeadArena.c +++ b/src/code/TwoHeadArena.c @@ -1,79 +1,136 @@ -#include "global.h" +/** + * @file TwoHeadArena.c + * + * This file implements a simple general purpose double-ended stack allocator. + * + * A double-ended stack allocator accepts allocations at either the "head" or "tail" of its allotted memory region. + * While in general this type of allocator could accept deallocations on the most recently allocated block at either + * end, this implementation does not support any individual deallocations; the only provided way to deallocate anything + * is to reset the entire arena, deallocating everything. This scheme is most applicable to allocating similar data + * with identical lifetime. + */ + +#include "tha.h" +#include "alignment.h" +#include "functions.h" void* THA_GetHead(TwoHeadArena* tha) { return tha->head; } -void THA_SetHead(TwoHeadArena* tha, void* start) { - tha->head = start; +void THA_SetHead(TwoHeadArena* tha, void* newHead) { + tha->head = newHead; } void* THA_GetTail(TwoHeadArena* tha) { return tha->tail; } -void* THA_AllocStart(TwoHeadArena* tha, size_t size) { +/** + * Allocates to the head of the Two Head Arena. The allocation will not have any alignment guarantees. + */ +void* THA_AllocHead(TwoHeadArena* tha, size_t size) { void* start = tha->head; - tha->head = (u32)tha->head + size; + tha->head = (u8*)tha->head + size; return start; } -void* THA_AllocStart1(TwoHeadArena* tha) { - return THA_AllocStart(tha, 1); +void* THA_AllocHeadByte(TwoHeadArena* tha) { + return THA_AllocHead(tha, 1); } -void* THA_AllocEnd(TwoHeadArena* tha, size_t size) { - u32 mask; +/** + * Allocates to the tail end of the Two Head Arena. The allocation will be aligned based on the size of the allocation. + * All allocations of 16 bytes or more will be aligned to 16-bytes. Otherwise, the alignment will be the largest power + * of 2 for which the size is a multiple, in order to accommodate the alignment requirements of any data types that can + * fit within the allocation. + */ +void* THA_AllocTail(TwoHeadArena* tha, size_t size) { + uintptr_t mask; if (size >= 0x10) { - mask = ~0xF; + // Align 0x10 for allocations greater than 0x10 + mask = ALIGN_MASK(0x10); } else if (size & 1) { - mask = -1; + // No alignment for odd sizes + mask = ALIGN_MASK(1); } else if (size & 2) { - mask = ~0x1; + // Align 2 for multiples of 2 + mask = ALIGN_MASK(2); } else if (size & 4) { - mask = ~0x3; + // Align 4 for multiples of 4 + mask = ALIGN_MASK(4); + } else if (size & 8) { + // Align 8 for multiples of 8 + mask = ALIGN_MASK(8); } else { - mask = (size & 8) ? ~0x7 : -1; + mask = ALIGN_MASK(1); } - tha->tail = (((u32)tha->tail & mask) - size) & mask; + tha->tail = (void*)((((uintptr_t)tha->tail & mask) - size) & mask); return tha->tail; } -void* THA_AllocEndAlign16(TwoHeadArena* tha, size_t size) { - u32 mask = ~0xF; +/** + * Allocates to the tail end of the Two Head Arena with guaranteed 16-byte alignment. + */ +void* THA_AllocTailAlign16(TwoHeadArena* tha, size_t size) { + uintptr_t mask = ALIGN_MASK(0x10); - tha->tail = (((u32)tha->tail & mask) - size) & mask; + tha->tail = (void*)((((uintptr_t)tha->tail & mask) - size) & mask); return tha->tail; } -void* THA_AllocEndAlign(TwoHeadArena* tha, size_t size, u32 mask) { - tha->tail = (((u32)tha->tail & mask) - size) & mask; +/** + * Allocates to the tail end of the Two Head Arena using the provided mask to align the allocated region. + * + * @param tha Arena to allocate to + * @param size Size of the allocation + * @param mask Mask to use to align the allocated region. To align to n-bytes where n is a power of 2, use the + * ALIGN_MASK(n) macro + * + * @return Pointer to the start of the allocated block + */ +void* THA_AllocTailAlign(TwoHeadArena* tha, size_t size, uintptr_t mask) { + tha->tail = (void*)((((uintptr_t)tha->tail & mask) - size) & mask); return tha->tail; } -s32 THA_GetSize(TwoHeadArena* tha) { - return (u32)tha->tail - (u32)tha->head; +/** + * Gets the remaining size of the Two Head Arena + * + * @return Remaining size. A negative number indicates an overflow. + */ +s32 THA_GetRemaining(TwoHeadArena* tha) { + return (s32)((u8*)tha->tail - (u8*)tha->head); } +/** + * @return true if the Two Head Arena has overflowed, false otherwise + */ u32 THA_IsCrash(TwoHeadArena* tha) { - return THA_GetSize(tha) < 0; + return THA_GetRemaining(tha) < 0; } -void THA_Init(TwoHeadArena* tha) { - tha->head = tha->bufp; - tha->tail = (u32)tha->bufp + tha->size; +void THA_Reset(TwoHeadArena* tha) { + tha->head = tha->start; + tha->tail = (u8*)tha->start + tha->size; } -void THA_Ct(TwoHeadArena* tha, void* ptr, size_t size) { +/** + * Creates a new Two Head Arena at `start` with available size `size` + */ +void THA_Init(TwoHeadArena* tha, void* start, size_t size) { bzero(tha, sizeof(TwoHeadArena)); - tha->bufp = ptr; + tha->start = start; tha->size = size; - THA_Init(tha); + THA_Reset(tha); } -void THA_Dt(TwoHeadArena* tha) { +/** + * Destroys the Two Head Arena, no further allocations are possible + */ +void THA_Destroy(TwoHeadArena* tha) { bzero(tha, sizeof(TwoHeadArena)); } diff --git a/src/code/TwoHeadGfxArena.c b/src/code/TwoHeadGfxArena.c index 2f1629765..d40512efd 100644 --- a/src/code/TwoHeadGfxArena.c +++ b/src/code/TwoHeadGfxArena.c @@ -1,65 +1,105 @@ -#include "global.h" +/** + * @file TwoHeadGfxArena.c + * + * This file implements a particular use of the double-ended stack allocator from TwoHeadArena.c for graphics data. + * + * Display list commands are allocated from the head while other graphics data such as matrices and vertices are + * allocated from the tail end. + * + * @see TwoHeadArena.c + */ -void THGA_Ct(TwoHeadGfxArena* thga, Gfx* start, size_t size) { - THA_Ct((TwoHeadArena*)thga, start, size); +#include "thga.h" +#include "alignment.h" +#include "functions.h" + +void THGA_Init(TwoHeadGfxArena* thga, void* start, size_t size) { + THA_Init(&thga->tha, start, size); } -void THGA_Dt(TwoHeadGfxArena* thga) { - THA_Dt((TwoHeadArena*)thga); +void THGA_Destroy(TwoHeadGfxArena* thga) { + THA_Destroy(&thga->tha); } u32 THGA_IsCrash(TwoHeadGfxArena* thga) { - return THA_IsCrash((TwoHeadArena*)thga); + return THA_IsCrash(&thga->tha); } -void THGA_Init(TwoHeadGfxArena* thga) { - THA_Init((TwoHeadArena*)thga); +void THGA_Reset(TwoHeadGfxArena* thga) { + THA_Reset(&thga->tha); } -s32 THGA_GetSize(TwoHeadGfxArena* thga) { - return THA_GetSize((TwoHeadArena*)thga); +s32 THGA_GetRemaining(TwoHeadGfxArena* thga) { + return THA_GetRemaining(&thga->tha); } Gfx* THGA_GetHead(TwoHeadGfxArena* thga) { - return THA_GetHead((TwoHeadArena*)thga); + return THA_GetHead(&thga->tha); } -void THGA_SetHead(TwoHeadGfxArena* thga, Gfx* start) { - THA_SetHead((TwoHeadArena*)thga, start); +void THGA_SetHead(TwoHeadGfxArena* thga, Gfx* newHead) { + THA_SetHead(&thga->tha, newHead); } -Gfx* THGA_GetTail(TwoHeadGfxArena* thga) { - return THA_GetTail((TwoHeadArena*)thga); +void* THGA_GetTail(TwoHeadGfxArena* thga) { + return THA_GetTail(&thga->tha); } -Gfx* THGA_AllocStartArray8(TwoHeadGfxArena* thga, u32 count) { - return THA_AllocStart((TwoHeadArena*)thga, count * 8); +/** + * Allocates a display list of `num` Gfx commands to the head of the Two Head Gfx Arena. + */ +Gfx* THGA_AllocDisplayList(TwoHeadGfxArena* thga, size_t num) { + return THA_AllocHead(&thga->tha, num * sizeof(Gfx)); } -Gfx* THGA_AllocStart8(TwoHeadGfxArena* thga) { - return THGA_AllocStartArray8(thga, 1); +/** + * Allocates a single Gfx command to the head of the Two Head Gfx Arena. + */ +Gfx* THGA_AllocGfx(TwoHeadGfxArena* thga) { + return THGA_AllocDisplayList(thga, 1); } -Gfx* THGA_AllocStart8Wrapper(TwoHeadGfxArena* thga) { - return THGA_AllocStart8(thga); +/** + * Identical to `THGA_AllocGfx` + * + * @see THGA_AllocGfx + */ +Gfx* THGA_AllocGfx2(TwoHeadGfxArena* thga) { + return THGA_AllocGfx(thga); } -Gfx* THGA_AllocEnd(TwoHeadGfxArena* thga, size_t size) { - return THA_AllocEnd((TwoHeadArena*)thga, size); +/** + * Allocates to the end of the Two Head Gfx Arena. Intended for data complementary to the display lists such as + * matrices and vertices that are only needed for a single graphics task. + */ +void* THGA_AllocTail(TwoHeadGfxArena* thga, size_t size) { + return THA_AllocTail(&thga->tha, size); } -Gfx* THGA_AllocEndArray64(TwoHeadGfxArena* thga, u32 count) { - return THGA_AllocEnd(thga, count * 0x40); +/** + * Allocates `num` matrices to the tail end of the Two Head Gfx Arena. + */ +Mtx* THGA_AllocMtxArray(TwoHeadGfxArena* thga, size_t num) { + return THGA_AllocTail(thga, num * sizeof(Mtx)); } -Gfx* THGA_AllocEnd64(TwoHeadGfxArena* thga) { - return THGA_AllocEnd(thga, 0x40); +/** + * Allocates a matrix to the tail end of the Two Head Gfx Arena. + */ +Mtx* THGA_AllocMtx(TwoHeadGfxArena* thga) { + return THGA_AllocTail(thga, sizeof(Mtx)); } -Gfx* THGA_AllocEndArray16(TwoHeadGfxArena* thga, u32 count) { - return THGA_AllocEnd(thga, count * 0x10); +/** + * Allocates `num` vertices to the tail end of the Two Head Gfx Arena. + */ +Vtx* THGA_AllocVtxArray(TwoHeadGfxArena* thga, u32 num) { + return THGA_AllocTail(thga, num * sizeof(Vtx)); } -Gfx* THGA_AllocEnd16(TwoHeadGfxArena* thga) { - return THGA_AllocEnd(thga, 0x10); +/** + * Allocates a vertex to the tail end of the Two Head Gfx Arena. + */ +Vtx* THGA_AllocVtx(TwoHeadGfxArena* thga) { + return THGA_AllocTail(thga, sizeof(Vtx)); } diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c deleted file mode 100644 index d3461c8f5..000000000 --- a/src/code/audio/code_801A4EB0.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4FD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5080.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A50C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5100.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A510C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5118.s") diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c deleted file mode 100644 index 6a40bf23a..000000000 --- a/src/code/audio/code_801A51F0.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/D_801E0EC0.s") - -UNK_TYPE func_801A51F0(UNK_TYPE arg0) { - switch (arg0) { - case 1: - case 4: - case 5: - case 11: - case 13: - case 14: - case 15: - return -1; - default: - return 0; - } -} - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5228.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5390.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A53DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A53E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A541C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5488.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A54C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A54D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5680.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5808.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5A10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5A1C.s") diff --git a/src/code/audio/code_801A7B10.c b/src/code/audio/code_801A7B10.c deleted file mode 100644 index 3f8446036..000000000 --- a/src/code/audio/code_801A7B10.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_StartSequence.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_StopSequence.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A7D84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_QueueSeqCmd.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A89D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_GetActiveSequence.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8ABC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8B14.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8B2C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_SetVolumeScale.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8D5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9768.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A982C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A99B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9A74.s") diff --git a/src/code/code_80172BC0.c b/src/code/audio_stop_all_sfx.c similarity index 100% rename from src/code/code_80172BC0.c rename to src/code/audio_stop_all_sfx.c diff --git a/src/code/audioMgr.c b/src/code/audio_thread_manager.c similarity index 99% rename from src/code/audioMgr.c rename to src/code/audio_thread_manager.c index eca7ddd83..45fbcb87e 100644 --- a/src/code/audioMgr.c +++ b/src/code/audio_thread_manager.c @@ -80,7 +80,7 @@ void AudioMgr_ThreadEntry(void* arg) { Audio_Init(); AudioLoad_SetDmaHandler(DmaMgr_DmaHandler); - func_801A4D00(); + Audio_InitSound(); osSendMesg(&audioMgr->lockMsgQ, NULL, OS_MESG_BLOCK); IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->interruptMsgQ); diff --git a/src/code/code_800E8EA0.c b/src/code/code_800E8EA0.c index 7485f2d3a..4ab38fcba 100644 --- a/src/code/code_800E8EA0.c +++ b/src/code/code_800E8EA0.c @@ -1,7 +1,7 @@ #include "global.h" void Actor_ContinueText(PlayState* play, Actor* actor, u16 textId) { - func_80151938(play, textId); + Message_ContinueTextbox(play, textId); actor->textId = textId; } @@ -85,7 +85,7 @@ s32 Actor_TrackPlayerSetFocusHeight(PlayState* play, Actor* actor, Vec3s* headRo actor->focus.pos = actor->world.pos; actor->focus.pos.y += focusHeight; - if (!((play->csCtx.state != 0) || gDbgCamEnabled)) { + if (!((play->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled)) { yaw = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); if (yaw >= 0x4300) { Actor_TrackNone(headRot, torsoRot); @@ -93,7 +93,7 @@ s32 Actor_TrackPlayerSetFocusHeight(PlayState* play, Actor* actor, Vec3s* headRo } } - if ((play->csCtx.state != 0) || gDbgCamEnabled) { + if ((play->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) { target = play->view.eye; } else { target = player->actor.focus.pos; @@ -127,7 +127,7 @@ s32 Actor_TrackPlayer(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* tors actor->focus.pos = focusPos; - if (!((play->csCtx.state != 0) || gDbgCamEnabled)) { + if (!((play->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled)) { yaw = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); if (yaw >= 0x4300) { Actor_TrackNone(headRot, torsoRot); @@ -135,7 +135,7 @@ s32 Actor_TrackPlayer(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* tors } } - if ((play->csCtx.state != 0) || gDbgCamEnabled) { + if ((play->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) { target = play->view.eye; } else { target = player->actor.focus.pos; diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c index fb6f0743d..e10290356 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -472,9 +472,9 @@ u16 gSceneIdsPerRegion[REGION_MAX][27] = { }; s32 Inventory_GetBtnBItem(PlayState* play) { - if (gSaveContext.buttonStatus[0] == BTN_DISABLED) { + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) { return ITEM_NONE; - } else if (gSaveContext.unk_1015 == ITEM_NONE) { + } else if (gSaveContext.bButtonStatus == BTN_DISABLED) { return ITEM_NONE; } else if (CUR_FORM_EQUIP(EQUIP_SLOT_B) == ITEM_NONE) { if (play->interfaceCtx.unk_21C != 0) { @@ -511,12 +511,12 @@ u8 Inventory_DeleteEquipment(PlayState* play, s16 equipment) { } void Inventory_ChangeUpgrade(s16 upgrade, u32 value) { - u32 upgrades = gSaveContext.save.inventory.upgrades; + u32 upgrades = gSaveContext.save.saveInfo.inventory.upgrades; upgrades &= gUpgradeNegMasks[upgrade]; upgrades |= value << gUpgradeShifts[upgrade]; - gSaveContext.save.inventory.upgrades = upgrades; + gSaveContext.save.saveInfo.inventory.upgrades = upgrades; } s32 Inventory_IsMapVisible(s16 sceneId) { @@ -543,7 +543,7 @@ s32 Inventory_IsMapVisible(s16 sceneId) { } } - if (gSaveContext.save.scenesVisible[index] & gBitFlags[sceneId - (index << 5)]) { + if (gSaveContext.save.saveInfo.scenesVisible[index] & gBitFlags[sceneId - (index << 5)]) { return true; } @@ -656,23 +656,23 @@ void Inventory_SetWorldMapCloudVisibility(s16 tingleIndex) { index = 6; } - gSaveContext.save.scenesVisible[index] = - gSaveContext.save.scenesVisible[index] | gBitFlags[(s16)(*tingleMapSceneIds)[i] - (index << 5)]; + gSaveContext.save.saveInfo.scenesVisible[index] = gSaveContext.save.saveInfo.scenesVisible[index] | + gBitFlags[(s16)(*tingleMapSceneIds)[i] - (index << 5)]; i++; } if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_CLOCK_TOWN]) { - gSaveContext.save.worldMapCloudVisibility |= 3; + gSaveContext.save.saveInfo.worldMapCloudVisibility |= 3; } else if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_WOODFALL]) { - gSaveContext.save.worldMapCloudVisibility |= 0x1C; + gSaveContext.save.saveInfo.worldMapCloudVisibility |= 0x1C; } else if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_SNOWHEAD]) { - gSaveContext.save.worldMapCloudVisibility |= 0xE0; + gSaveContext.save.saveInfo.worldMapCloudVisibility |= 0xE0; } else if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_ROMANI_RANCH]) { - gSaveContext.save.worldMapCloudVisibility |= 0x100; + gSaveContext.save.saveInfo.worldMapCloudVisibility |= 0x100; } else if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_GREAT_BAY]) { - gSaveContext.save.worldMapCloudVisibility |= 0x1E00; + gSaveContext.save.saveInfo.worldMapCloudVisibility |= 0x1E00; } else if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_STONE_TOWER]) { - gSaveContext.save.worldMapCloudVisibility |= 0x6000; + gSaveContext.save.saveInfo.worldMapCloudVisibility |= 0x6000; } } @@ -685,34 +685,34 @@ void Inventory_SetWorldMapCloudVisibility(s16 tingleIndex) { void Inventory_SaveDekuPlaygroundHighScore(s16 timerId) { s16 i; - gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] = gSaveContext.timerCurTimes[timerId]; + gSaveContext.save.saveInfo.dekuPlaygroundHighScores[CURRENT_DAY - 1] = gSaveContext.timerCurTimes[timerId]; for (i = 0; i < 8; i++) { - gSaveContext.save.inventory.dekuPlaygroundPlayerName[CURRENT_DAY - 1][i] = - gSaveContext.save.playerData.playerName[i]; + gSaveContext.save.saveInfo.inventory.dekuPlaygroundPlayerName[CURRENT_DAY - 1][i] = + gSaveContext.save.saveInfo.playerData.playerName[i]; } } void Inventory_IncrementSkullTokenCount(s16 sceneIndex) { if (sceneIndex == SCENE_KINSTA1) { // Swamp Spider House (increment high bits of skullTokenCount) - gSaveContext.save.skullTokenCount = - ((u16)(((gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10) + 1) << 0x10) | - (gSaveContext.save.skullTokenCount & 0xFFFF); + gSaveContext.save.saveInfo.skullTokenCount = + ((u16)(((gSaveContext.save.saveInfo.skullTokenCount & 0xFFFF0000) >> 0x10) + 1) << 0x10) | + (gSaveContext.save.saveInfo.skullTokenCount & 0xFFFF); } else { // Ocean Spider House (increment low bits of skullTokenCount) - gSaveContext.save.skullTokenCount = - (((u16)gSaveContext.save.skullTokenCount + 1) & 0xFFFF) | (gSaveContext.save.skullTokenCount & 0xFFFF0000); + gSaveContext.save.saveInfo.skullTokenCount = (((u16)gSaveContext.save.saveInfo.skullTokenCount + 1) & 0xFFFF) | + (gSaveContext.save.saveInfo.skullTokenCount & 0xFFFF0000); } } s16 Inventory_GetSkullTokenCount(s16 sceneIndex) { if (sceneIndex == SCENE_KINSTA1) { // Swamp Spider House - return (gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10; + return (gSaveContext.save.saveInfo.skullTokenCount & 0xFFFF0000) >> 0x10; } else { // Ocean Spider House - return gSaveContext.save.skullTokenCount & 0xFFFF; + return gSaveContext.save.saveInfo.skullTokenCount & 0xFFFF; } } @@ -722,6 +722,6 @@ void Inventory_SaveLotteryCodeGuess(PlayState* play) { lotteryCodeGuess = ((play->msgCtx.unk12054[0] & 0xF) << 8); // First Digit lotteryCodeGuess |= ((play->msgCtx.unk12054[1] & 0xF) << 4); // Second Digit lotteryCodeGuess |= (play->msgCtx.unk12054[2] & 0xF); // Third Digit - gSaveContext.save.lotteryCodeGuess = - (gSaveContext.save.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF); + gSaveContext.save.saveInfo.lotteryCodeGuess = + (gSaveContext.save.saveInfo.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF); } diff --git a/src/code/code_801420C0.c b/src/code/code_801420C0.c deleted file mode 100644 index 63c96571e..000000000 --- a/src/code/code_801420C0.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801420C0/func_801420C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801420C0/func_801420F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801420C0/func_80142100.s") diff --git a/src/code/cutscene_camera.c b/src/code/cutscene_camera.c new file mode 100644 index 000000000..d92d119dd --- /dev/null +++ b/src/code/cutscene_camera.c @@ -0,0 +1,380 @@ +#include "global.h" + +extern CutsceneCamera* sCurCsCamera; + +typedef s16 (*CsCamInterpolateCallback)(Vec3f*, f32*, s16*, CsCmdCamPoint*, CsCmdCamMisc*, CutsceneCameraInterp*); + +// function declarations +s16 func_80161180(Vec3f* pos, f32* fov, s16* roll, CsCmdCamPoint* point, CsCmdCamMisc* misc, + CutsceneCameraInterp* interp); +s16 func_8016237C(Vec3f* pos, f32* fov, s16* roll, CsCmdCamPoint* point, CsCmdCamMisc* misc, + CutsceneCameraInterp* interp); +s16 func_8016253C(Vec3f* pos, f32* fov, s16* roll, CsCmdCamPoint* point, CsCmdCamMisc* misc, + CutsceneCameraInterp* interp); +s16 func_80162A50(Vec3f* pos, f32* fov, s16* roll, CsCmdCamPoint* point, CsCmdCamMisc* misc, + CutsceneCameraInterp* interp); +s16 func_801623E4(Vec3f* pos, f32* fov, s16* roll, CsCmdCamPoint* point, CsCmdCamMisc* misc, + CutsceneCameraInterp* interp); +s16 func_80161C20(Vec3f* pos, f32* fov, s16* roll, CsCmdCamPoint* point, CsCmdCamMisc* misc, + CutsceneCameraInterp* interp); +s16 func_80161E4C(Vec3f* pos, f32* fov, s16* roll, CsCmdCamPoint* point, CsCmdCamMisc* misc, + CutsceneCameraInterp* interp); +s16 func_801620CC(Vec3f* pos, f32* fov, s16* roll, CsCmdCamPoint* point, CsCmdCamMisc* misc, + CutsceneCameraInterp* interp); +s16 func_80163334(Vec3f* pos, f32* fov, s16* roll, CsCmdCamPoint* point, CsCmdCamMisc* misc, + CutsceneCameraInterp* interp); +f32 func_80163660(Actor* actor); + +#pragma GLOBAL_ASM("asm/non_matchings/code/cutscene_camera/func_80161180.s") + +/** + * Initializes Cutscene Camera Info + */ +s32 CutsceneCamera_Init(Camera* camera, CutsceneCamera* csCamera) { + csCamera->camera = camera; + + csCamera->nextSplineTimer = csCamera->updateSplineTimer = 0; + csCamera->cmdIndex = 0; + csCamera->splineIndex = 0xFFFF; + csCamera->splineNeedsInit = true; + csCamera->state = CS_CAM_STATE_UPDATE_ALL; + + sCurCsCamera = csCamera; + + __osMemset(&csCamera->eyeInterp, 0, sizeof(CutsceneCameraInterp)); + __osMemset(&csCamera->atInterp, 0, sizeof(CutsceneCameraInterp)); + + csCamera->eyeInterp.unk_2D = csCamera->atInterp.unk_2D = 7; + + return 1; +} + +CsCamInterpolateCallback CutsceneCamera_Interpolate(u8 interpType) { + switch (interpType) { + case CS_CAM_INTERP_7: + default: + return func_80161180; + + case CS_CAM_INTERP_0: + return func_8016237C; + + case CS_CAM_INTERP_5: + return func_8016253C; + + case CS_CAM_INTERP_4: + return func_80162A50; + + case CS_CAM_INTERP_1: + return func_801623E4; + + case CS_CAM_INTERP_2: + return func_80161C20; + + case CS_CAM_INTERP_3: + return func_80161E4C; + + case CS_CAM_INTERP_6: + return func_801620CC; + } +} + +u8 CutsceneCamera_ProcessSpline(CutsceneCamera* csCamera) { + s32 sp5C; + f32* fov; + s16* roll; + CsCamInterpolateCallback interpHandler; + Player* player; + Actor* target; + s16 numPoints; + + sp5C = true; + if (csCamera->state == CS_CAM_STATE_DONE_SPLINE) { + return false; + } + + player = GET_PLAYER(csCamera->camera->play); + target = csCamera->camera->target; + + if (csCamera->eyeCmd[csCamera->atInterp.curPoint].interpType < + csCamera->atCmd[csCamera->eyeInterp.curPoint].interpType) { + sp5C = false; + } + + csCamera->eyeInterp.unk_00 = csCamera->camera->eye; + csCamera->atInterp.unk_00 = csCamera->camera->at; + + if (sp5C) { + fov = NULL; + } else { + fov = &csCamera->camera->fov; + } + + if (sp5C) { + roll = NULL; + } else { + roll = &csCamera->camera->roll; + } + + interpHandler = CutsceneCamera_Interpolate(csCamera->atCmd[csCamera->eyeInterp.curPoint].interpType); + + switch (csCamera->atCmd[csCamera->eyeInterp.curPoint].relativeTo) { + case CS_CAM_REL_2: + OLib_Vec3fDiff(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, OLIB_DIFF); + break; + + case CS_CAM_REL_3: + OLib_Vec3fDiff(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, OLIB_DIFF_OFFSET); + break; + + case CS_CAM_REL_1: + OLib_Vec3fDiff(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, OLIB_DIFF_OFFSET); + break; + + case CS_CAM_REL_4: + OLib_Vec3fDiff(&target->world, &csCamera->camera->at, &csCamera->camera->at, OLIB_DIFF_OFFSET); + break; + + case CS_CAM_REL_5: + OLib_Vec3fDiff(&target->world, &csCamera->camera->at, &csCamera->camera->at, OLIB_DIFF); + break; + + default: // CS_CAM_REL_0 + break; + } + + numPoints = interpHandler(&csCamera->camera->at, fov, roll, &csCamera->atCmd[csCamera->eyeInterp.curPoint], + &csCamera->miscCmd[csCamera->eyeInterp.curPoint], &csCamera->eyeInterp); + + switch (csCamera->atCmd[csCamera->eyeInterp.curPoint].relativeTo) { + case CS_CAM_REL_2: + OLib_Vec3fAdd(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, OLIB_ADD); + break; + + case CS_CAM_REL_3: + OLib_Vec3fAdd(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, OLIB_ADD_OFFSET); + csCamera->camera->at.y += func_80163660(&player->actor); + break; + + case CS_CAM_REL_1: + OLib_Vec3fAdd(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, OLIB_ADD_OFFSET); + break; + + case CS_CAM_REL_4: + OLib_Vec3fAdd(&target->world, &csCamera->camera->at, &csCamera->camera->at, OLIB_ADD_OFFSET); + break; + + case CS_CAM_REL_5: + OLib_Vec3fAdd(&target->world, &csCamera->camera->at, &csCamera->camera->at, OLIB_ADD); + break; + + default: // CS_CAM_REL_0 + break; + } + + csCamera->eyeInterp.curPoint += numPoints; + + if (sp5C) { + fov = &csCamera->camera->fov; + } else { + fov = NULL; + } + + if (sp5C) { + roll = &csCamera->camera->roll; + } else { + roll = NULL; + } + + interpHandler = CutsceneCamera_Interpolate(csCamera->eyeCmd[csCamera->atInterp.curPoint].interpType); + + switch (csCamera->eyeCmd[csCamera->atInterp.curPoint].relativeTo) { + case CS_CAM_REL_2: + OLib_Vec3fDiff(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_DIFF); + break; + + case CS_CAM_REL_3: + OLib_Vec3fDiff(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_DIFF_OFFSET); + break; + + case CS_CAM_REL_1: + OLib_Vec3fDiff(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_DIFF_OFFSET); + break; + + case CS_CAM_REL_4: + OLib_Vec3fDiff(&target->world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_DIFF_OFFSET); + break; + + case CS_CAM_REL_5: + OLib_Vec3fDiff(&target->world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_DIFF); + break; + + default: // CS_CAM_REL_0 + break; + } + + numPoints = interpHandler(&csCamera->camera->eye, fov, roll, &csCamera->eyeCmd[csCamera->atInterp.curPoint], + &csCamera->miscCmd[csCamera->atInterp.curPoint], &csCamera->atInterp); + + switch (csCamera->eyeCmd[csCamera->atInterp.curPoint].relativeTo) { + case CS_CAM_REL_2: + OLib_Vec3fAdd(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_ADD); + break; + + case CS_CAM_REL_3: + OLib_Vec3fAdd(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_ADD_OFFSET); + csCamera->camera->eye.y += func_80163660(&player->actor); + break; + + case CS_CAM_REL_1: + OLib_Vec3fAdd(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_ADD_OFFSET); + break; + + case CS_CAM_REL_4: + OLib_Vec3fAdd(&target->world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_ADD_OFFSET); + break; + + case CS_CAM_REL_5: + OLib_Vec3fAdd(&target->world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_ADD); + break; + + default: // CS_CAM_REL_0 + break; + } + + csCamera->atInterp.curPoint += numPoints; + + if ((csCamera->eyeInterp.curPoint >= csCamera->eyeInterp.numEntries) || + (csCamera->atInterp.curPoint >= csCamera->atInterp.numEntries)) { + return false; + } + + return true; +} + +/** + * Processes camera cutscene commands + */ +s32 CutsceneCamera_UpdateSplines(u8* script, CutsceneCamera* csCamera) { + CsCmdCamSpline* spline; + + switch (csCamera->state) { + case CS_CAM_STATE_DONE: + return 0; + + case CS_CAM_STATE_PAUSE: + return csCamera->nextSplineTimer; + + case CS_CAM_STATE_UPDATE_SPLINE: + if (csCamera->updateSplineTimer <= csCamera->duration) { + csCamera->updateSplineTimer++; + if (csCamera->updateSplineTimer <= csCamera->duration) { + // Process Spline + if (!CutsceneCamera_ProcessSpline(csCamera)) { + csCamera->state = CS_CAM_STATE_DONE_SPLINE; + } + } + } + break; + + case CS_CAM_STATE_DONE_SPLINE: + break; + + default: // CS_CAM_STATE_UPDATE_ALL + if (csCamera->splineNeedsInit == true) { + // Spline Header + spline = (CsCmdCamSpline*)&script[csCamera->cmdIndex]; + csCamera->atInterp.numEntries = csCamera->eyeInterp.numEntries = spline->numEntries; + csCamera->duration = spline->duration; + csCamera->cmdIndex += sizeof(CsCmdCamSpline); + + // At Point + csCamera->atCmd = (CsCmdCamPoint*)&script[csCamera->cmdIndex]; + csCamera->cmdIndex += (s16)(csCamera->eyeInterp.numEntries * sizeof(CsCmdCamPoint)); + + // Misc Point + csCamera->eyeCmd = (CsCmdCamPoint*)&script[csCamera->cmdIndex]; + csCamera->cmdIndex += (s16)(csCamera->eyeInterp.numEntries * sizeof(CsCmdCamPoint)); + + // Misc + csCamera->miscCmd = (CsCmdCamMisc*)&script[csCamera->cmdIndex]; + csCamera->cmdIndex += (s16)(csCamera->eyeInterp.numEntries * sizeof(CsCmdCamMisc)); + + // Other Params + csCamera->eyeInterp.curPoint = 0; + csCamera->atInterp.curPoint = 0; + + csCamera->splineNeedsInit = false; + //! FAKE: csCamera->splineIndex++; + csCamera->splineIndex = (csCamera->splineIndex & 0xFFFF) + 1; + csCamera->state = CS_CAM_STATE_UPDATE_ALL; + csCamera->nextSplineTimer = csCamera->updateSplineTimer = 0; + csCamera->eyeInterp.unk_2D = csCamera->atInterp.unk_2D = 7; + } + + csCamera->nextSplineTimer++; + + if (csCamera->updateSplineTimer <= csCamera->duration) { + csCamera->updateSplineTimer++; + if (csCamera->updateSplineTimer <= csCamera->duration) { + // Process SubCommands + if (!CutsceneCamera_ProcessSpline(csCamera)) { + csCamera->state = CS_CAM_STATE_DONE_SPLINE; + } + } + } + break; + } + + if (csCamera->nextSplineTimer > csCamera->duration) { + // Next Spline + csCamera->splineNeedsInit = true; + spline = (CsCmdCamSpline*)&script[csCamera->cmdIndex]; + if (spline->numEntries == -1) { + csCamera->state = CS_CAM_STATE_DONE; + return 0; + } + } + + return csCamera->nextSplineTimer; +} + +// Unused +s16 func_80161BAC(void) { + return (sCurCsCamera->state == CS_CAM_STATE_PAUSE) || (sCurCsCamera->state == CS_CAM_STATE_UPDATE_SPLINE); +} + +void CutsceneCamera_SetState(s16 state) { + if (sCurCsCamera->state == CS_CAM_STATE_UPDATE_ALL) { + sCurCsCamera->state = state; + } +} + +void CutsceneCamera_Reset(void) { + sCurCsCamera->state = CS_CAM_STATE_UPDATE_ALL; +} + +#pragma GLOBAL_ASM("asm/non_matchings/code/cutscene_camera/func_80161C20.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/cutscene_camera/func_80161E4C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/cutscene_camera/func_801620CC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/cutscene_camera/func_8016237C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/cutscene_camera/func_801623E4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/cutscene_camera/func_801624EC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/cutscene_camera/func_8016253C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/cutscene_camera/func_801629BC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/cutscene_camera/func_80162A50.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/cutscene_camera/func_80162FF8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/cutscene_camera/func_801631DC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/cutscene_camera/func_80163334.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/cutscene_camera/func_80163660.s") diff --git a/src/code/db_camera.c b/src/code/db_camera.c deleted file mode 100644 index 92b6d87f9..000000000 --- a/src/code/db_camera.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_80161180.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_8016119C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_8016122C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_801612B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_80161998.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_80161BAC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_80161BE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_80161C0C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_80161C20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_80161E4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_801620CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_8016237C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_801623E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_801624EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_8016253C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_801629BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_80162A50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_80162FF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_801631DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_80163334.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_80163660.s") diff --git a/src/code/flg_set.c b/src/code/flg_set.c index a22b62a0e..bb25818a6 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -13,106 +13,106 @@ #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" static FlagSetEntry sFlagEntries[] = { - { &gSaveContext.save.weekEventReg[0], "week_event_reg[0]" }, - { &gSaveContext.save.weekEventReg[1], "week_event_reg[1]" }, - { &gSaveContext.save.weekEventReg[2], "week_event_reg[2]" }, - { &gSaveContext.save.weekEventReg[3], "week_event_reg[3]" }, - { &gSaveContext.save.weekEventReg[4], "week_event_reg[4]" }, - { &gSaveContext.save.weekEventReg[5], "week_event_reg[5]" }, - { &gSaveContext.save.weekEventReg[6], "week_event_reg[6]" }, - { &gSaveContext.save.weekEventReg[7], "week_event_reg[7]" }, - { &gSaveContext.save.weekEventReg[8], "week_event_reg[8]" }, - { &gSaveContext.save.weekEventReg[9], "week_event_reg[9]" }, - { &gSaveContext.save.weekEventReg[10], "week_event_reg[10]" }, - { &gSaveContext.save.weekEventReg[11], "week_event_reg[11]" }, - { &gSaveContext.save.weekEventReg[12], "week_event_reg[12]" }, - { &gSaveContext.save.weekEventReg[13], "week_event_reg[13]" }, - { &gSaveContext.save.weekEventReg[14], "week_event_reg[14]" }, - { &gSaveContext.save.weekEventReg[15], "week_event_reg[15]" }, - { &gSaveContext.save.weekEventReg[16], "week_event_reg[16]" }, - { &gSaveContext.save.weekEventReg[17], "week_event_reg[17]" }, - { &gSaveContext.save.weekEventReg[18], "week_event_reg[18]" }, - { &gSaveContext.save.weekEventReg[19], "week_event_reg[19]" }, - { &gSaveContext.save.weekEventReg[20], "week_event_reg[20]" }, - { &gSaveContext.save.weekEventReg[21], "week_event_reg[21]" }, - { &gSaveContext.save.weekEventReg[22], "week_event_reg[22]" }, - { &gSaveContext.save.weekEventReg[23], "week_event_reg[23]" }, - { &gSaveContext.save.weekEventReg[24], "week_event_reg[24]" }, - { &gSaveContext.save.weekEventReg[25], "week_event_reg[25]" }, - { &gSaveContext.save.weekEventReg[26], "week_event_reg[26]" }, - { &gSaveContext.save.weekEventReg[27], "week_event_reg[27]" }, - { &gSaveContext.save.weekEventReg[28], "week_event_reg[28]" }, - { &gSaveContext.save.weekEventReg[29], "week_event_reg[29]" }, - { &gSaveContext.save.weekEventReg[30], "week_event_reg[30]" }, - { &gSaveContext.save.weekEventReg[31], "week_event_reg[31]" }, - { &gSaveContext.save.weekEventReg[32], "week_event_reg[32]" }, - { &gSaveContext.save.weekEventReg[33], "week_event_reg[33]" }, - { &gSaveContext.save.weekEventReg[34], "week_event_reg[34]" }, - { &gSaveContext.save.weekEventReg[35], "week_event_reg[35]" }, - { &gSaveContext.save.weekEventReg[36], "week_event_reg[36]" }, - { &gSaveContext.save.weekEventReg[37], "week_event_reg[37]" }, - { &gSaveContext.save.weekEventReg[38], "week_event_reg[38]" }, - { &gSaveContext.save.weekEventReg[39], "week_event_reg[39]" }, - { &gSaveContext.save.weekEventReg[40], "week_event_reg[40]" }, - { &gSaveContext.save.weekEventReg[41], "week_event_reg[41]" }, - { &gSaveContext.save.weekEventReg[42], "week_event_reg[42]" }, - { &gSaveContext.save.weekEventReg[43], "week_event_reg[43]" }, - { &gSaveContext.save.weekEventReg[44], "week_event_reg[44]" }, - { &gSaveContext.save.weekEventReg[45], "week_event_reg[45]" }, - { &gSaveContext.save.weekEventReg[46], "week_event_reg[46]" }, - { &gSaveContext.save.weekEventReg[47], "week_event_reg[47]" }, - { &gSaveContext.save.weekEventReg[48], "week_event_reg[48]" }, - { &gSaveContext.save.weekEventReg[49], "week_event_reg[49]" }, - { &gSaveContext.save.weekEventReg[50], "week_event_reg[50]" }, - { &gSaveContext.save.weekEventReg[51], "week_event_reg[51]" }, - { &gSaveContext.save.weekEventReg[52], "week_event_reg[52]" }, - { &gSaveContext.save.weekEventReg[53], "week_event_reg[53]" }, - { &gSaveContext.save.weekEventReg[54], "week_event_reg[54]" }, - { &gSaveContext.save.weekEventReg[55], "week_event_reg[55]" }, - { &gSaveContext.save.weekEventReg[56], "week_event_reg[56]" }, - { &gSaveContext.save.weekEventReg[57], "week_event_reg[57]" }, - { &gSaveContext.save.weekEventReg[58], "week_event_reg[58]" }, - { &gSaveContext.save.weekEventReg[59], "week_event_reg[59]" }, - { &gSaveContext.save.weekEventReg[60], "week_event_reg[60]" }, - { &gSaveContext.save.weekEventReg[61], "week_event_reg[61]" }, - { &gSaveContext.save.weekEventReg[62], "week_event_reg[62]" }, - { &gSaveContext.save.weekEventReg[63], "week_event_reg[63]" }, - { &gSaveContext.save.weekEventReg[64], "week_event_reg[64]" }, - { &gSaveContext.save.weekEventReg[65], "week_event_reg[65]" }, - { &gSaveContext.save.weekEventReg[66], "week_event_reg[66]" }, - { &gSaveContext.save.weekEventReg[67], "week_event_reg[67]" }, - { &gSaveContext.save.weekEventReg[68], "week_event_reg[68]" }, - { &gSaveContext.save.weekEventReg[69], "week_event_reg[69]" }, - { &gSaveContext.save.weekEventReg[70], "week_event_reg[70]" }, - { &gSaveContext.save.weekEventReg[71], "week_event_reg[71]" }, - { &gSaveContext.save.weekEventReg[72], "week_event_reg[72]" }, - { &gSaveContext.save.weekEventReg[73], "week_event_reg[73]" }, - { &gSaveContext.save.weekEventReg[74], "week_event_reg[74]" }, - { &gSaveContext.save.weekEventReg[75], "week_event_reg[75]" }, - { &gSaveContext.save.weekEventReg[76], "week_event_reg[76]" }, - { &gSaveContext.save.weekEventReg[77], "week_event_reg[77]" }, - { &gSaveContext.save.weekEventReg[78], "week_event_reg[78]" }, - { &gSaveContext.save.weekEventReg[79], "week_event_reg[79]" }, - { &gSaveContext.save.weekEventReg[80], "week_event_reg[80]" }, - { &gSaveContext.save.weekEventReg[81], "week_event_reg[81]" }, - { &gSaveContext.save.weekEventReg[82], "week_event_reg[82]" }, - { &gSaveContext.save.weekEventReg[83], "week_event_reg[83]" }, - { &gSaveContext.save.weekEventReg[84], "week_event_reg[84]" }, - { &gSaveContext.save.weekEventReg[85], "week_event_reg[85]" }, - { &gSaveContext.save.weekEventReg[86], "week_event_reg[86]" }, - { &gSaveContext.save.weekEventReg[87], "week_event_reg[87]" }, - { &gSaveContext.save.weekEventReg[88], "week_event_reg[88]" }, - { &gSaveContext.save.weekEventReg[89], "week_event_reg[89]" }, - { &gSaveContext.save.weekEventReg[90], "week_event_reg[90]" }, - { &gSaveContext.save.weekEventReg[91], "week_event_reg[91]" }, - { &gSaveContext.save.weekEventReg[92], "week_event_reg[92]" }, - { &gSaveContext.save.weekEventReg[93], "week_event_reg[93]" }, - { &gSaveContext.save.weekEventReg[94], "week_event_reg[94]" }, - { &gSaveContext.save.weekEventReg[95], "week_event_reg[95]" }, - { &gSaveContext.save.weekEventReg[96], "week_event_reg[96]" }, - { &gSaveContext.save.weekEventReg[97], "week_event_reg[97]" }, - { &gSaveContext.save.weekEventReg[98], "week_event_reg[98]" }, - { &gSaveContext.save.weekEventReg[99], "week_event_reg[99]" }, + { &gSaveContext.save.saveInfo.weekEventReg[0], "week_event_reg[0]" }, + { &gSaveContext.save.saveInfo.weekEventReg[1], "week_event_reg[1]" }, + { &gSaveContext.save.saveInfo.weekEventReg[2], "week_event_reg[2]" }, + { &gSaveContext.save.saveInfo.weekEventReg[3], "week_event_reg[3]" }, + { &gSaveContext.save.saveInfo.weekEventReg[4], "week_event_reg[4]" }, + { &gSaveContext.save.saveInfo.weekEventReg[5], "week_event_reg[5]" }, + { &gSaveContext.save.saveInfo.weekEventReg[6], "week_event_reg[6]" }, + { &gSaveContext.save.saveInfo.weekEventReg[7], "week_event_reg[7]" }, + { &gSaveContext.save.saveInfo.weekEventReg[8], "week_event_reg[8]" }, + { &gSaveContext.save.saveInfo.weekEventReg[9], "week_event_reg[9]" }, + { &gSaveContext.save.saveInfo.weekEventReg[10], "week_event_reg[10]" }, + { &gSaveContext.save.saveInfo.weekEventReg[11], "week_event_reg[11]" }, + { &gSaveContext.save.saveInfo.weekEventReg[12], "week_event_reg[12]" }, + { &gSaveContext.save.saveInfo.weekEventReg[13], "week_event_reg[13]" }, + { &gSaveContext.save.saveInfo.weekEventReg[14], "week_event_reg[14]" }, + { &gSaveContext.save.saveInfo.weekEventReg[15], "week_event_reg[15]" }, + { &gSaveContext.save.saveInfo.weekEventReg[16], "week_event_reg[16]" }, + { &gSaveContext.save.saveInfo.weekEventReg[17], "week_event_reg[17]" }, + { &gSaveContext.save.saveInfo.weekEventReg[18], "week_event_reg[18]" }, + { &gSaveContext.save.saveInfo.weekEventReg[19], "week_event_reg[19]" }, + { &gSaveContext.save.saveInfo.weekEventReg[20], "week_event_reg[20]" }, + { &gSaveContext.save.saveInfo.weekEventReg[21], "week_event_reg[21]" }, + { &gSaveContext.save.saveInfo.weekEventReg[22], "week_event_reg[22]" }, + { &gSaveContext.save.saveInfo.weekEventReg[23], "week_event_reg[23]" }, + { &gSaveContext.save.saveInfo.weekEventReg[24], "week_event_reg[24]" }, + { &gSaveContext.save.saveInfo.weekEventReg[25], "week_event_reg[25]" }, + { &gSaveContext.save.saveInfo.weekEventReg[26], "week_event_reg[26]" }, + { &gSaveContext.save.saveInfo.weekEventReg[27], "week_event_reg[27]" }, + { &gSaveContext.save.saveInfo.weekEventReg[28], "week_event_reg[28]" }, + { &gSaveContext.save.saveInfo.weekEventReg[29], "week_event_reg[29]" }, + { &gSaveContext.save.saveInfo.weekEventReg[30], "week_event_reg[30]" }, + { &gSaveContext.save.saveInfo.weekEventReg[31], "week_event_reg[31]" }, + { &gSaveContext.save.saveInfo.weekEventReg[32], "week_event_reg[32]" }, + { &gSaveContext.save.saveInfo.weekEventReg[33], "week_event_reg[33]" }, + { &gSaveContext.save.saveInfo.weekEventReg[34], "week_event_reg[34]" }, + { &gSaveContext.save.saveInfo.weekEventReg[35], "week_event_reg[35]" }, + { &gSaveContext.save.saveInfo.weekEventReg[36], "week_event_reg[36]" }, + { &gSaveContext.save.saveInfo.weekEventReg[37], "week_event_reg[37]" }, + { &gSaveContext.save.saveInfo.weekEventReg[38], "week_event_reg[38]" }, + { &gSaveContext.save.saveInfo.weekEventReg[39], "week_event_reg[39]" }, + { &gSaveContext.save.saveInfo.weekEventReg[40], "week_event_reg[40]" }, + { &gSaveContext.save.saveInfo.weekEventReg[41], "week_event_reg[41]" }, + { &gSaveContext.save.saveInfo.weekEventReg[42], "week_event_reg[42]" }, + { &gSaveContext.save.saveInfo.weekEventReg[43], "week_event_reg[43]" }, + { &gSaveContext.save.saveInfo.weekEventReg[44], "week_event_reg[44]" }, + { &gSaveContext.save.saveInfo.weekEventReg[45], "week_event_reg[45]" }, + { &gSaveContext.save.saveInfo.weekEventReg[46], "week_event_reg[46]" }, + { &gSaveContext.save.saveInfo.weekEventReg[47], "week_event_reg[47]" }, + { &gSaveContext.save.saveInfo.weekEventReg[48], "week_event_reg[48]" }, + { &gSaveContext.save.saveInfo.weekEventReg[49], "week_event_reg[49]" }, + { &gSaveContext.save.saveInfo.weekEventReg[50], "week_event_reg[50]" }, + { &gSaveContext.save.saveInfo.weekEventReg[51], "week_event_reg[51]" }, + { &gSaveContext.save.saveInfo.weekEventReg[52], "week_event_reg[52]" }, + { &gSaveContext.save.saveInfo.weekEventReg[53], "week_event_reg[53]" }, + { &gSaveContext.save.saveInfo.weekEventReg[54], "week_event_reg[54]" }, + { &gSaveContext.save.saveInfo.weekEventReg[55], "week_event_reg[55]" }, + { &gSaveContext.save.saveInfo.weekEventReg[56], "week_event_reg[56]" }, + { &gSaveContext.save.saveInfo.weekEventReg[57], "week_event_reg[57]" }, + { &gSaveContext.save.saveInfo.weekEventReg[58], "week_event_reg[58]" }, + { &gSaveContext.save.saveInfo.weekEventReg[59], "week_event_reg[59]" }, + { &gSaveContext.save.saveInfo.weekEventReg[60], "week_event_reg[60]" }, + { &gSaveContext.save.saveInfo.weekEventReg[61], "week_event_reg[61]" }, + { &gSaveContext.save.saveInfo.weekEventReg[62], "week_event_reg[62]" }, + { &gSaveContext.save.saveInfo.weekEventReg[63], "week_event_reg[63]" }, + { &gSaveContext.save.saveInfo.weekEventReg[64], "week_event_reg[64]" }, + { &gSaveContext.save.saveInfo.weekEventReg[65], "week_event_reg[65]" }, + { &gSaveContext.save.saveInfo.weekEventReg[66], "week_event_reg[66]" }, + { &gSaveContext.save.saveInfo.weekEventReg[67], "week_event_reg[67]" }, + { &gSaveContext.save.saveInfo.weekEventReg[68], "week_event_reg[68]" }, + { &gSaveContext.save.saveInfo.weekEventReg[69], "week_event_reg[69]" }, + { &gSaveContext.save.saveInfo.weekEventReg[70], "week_event_reg[70]" }, + { &gSaveContext.save.saveInfo.weekEventReg[71], "week_event_reg[71]" }, + { &gSaveContext.save.saveInfo.weekEventReg[72], "week_event_reg[72]" }, + { &gSaveContext.save.saveInfo.weekEventReg[73], "week_event_reg[73]" }, + { &gSaveContext.save.saveInfo.weekEventReg[74], "week_event_reg[74]" }, + { &gSaveContext.save.saveInfo.weekEventReg[75], "week_event_reg[75]" }, + { &gSaveContext.save.saveInfo.weekEventReg[76], "week_event_reg[76]" }, + { &gSaveContext.save.saveInfo.weekEventReg[77], "week_event_reg[77]" }, + { &gSaveContext.save.saveInfo.weekEventReg[78], "week_event_reg[78]" }, + { &gSaveContext.save.saveInfo.weekEventReg[79], "week_event_reg[79]" }, + { &gSaveContext.save.saveInfo.weekEventReg[80], "week_event_reg[80]" }, + { &gSaveContext.save.saveInfo.weekEventReg[81], "week_event_reg[81]" }, + { &gSaveContext.save.saveInfo.weekEventReg[82], "week_event_reg[82]" }, + { &gSaveContext.save.saveInfo.weekEventReg[83], "week_event_reg[83]" }, + { &gSaveContext.save.saveInfo.weekEventReg[84], "week_event_reg[84]" }, + { &gSaveContext.save.saveInfo.weekEventReg[85], "week_event_reg[85]" }, + { &gSaveContext.save.saveInfo.weekEventReg[86], "week_event_reg[86]" }, + { &gSaveContext.save.saveInfo.weekEventReg[87], "week_event_reg[87]" }, + { &gSaveContext.save.saveInfo.weekEventReg[88], "week_event_reg[88]" }, + { &gSaveContext.save.saveInfo.weekEventReg[89], "week_event_reg[89]" }, + { &gSaveContext.save.saveInfo.weekEventReg[90], "week_event_reg[90]" }, + { &gSaveContext.save.saveInfo.weekEventReg[91], "week_event_reg[91]" }, + { &gSaveContext.save.saveInfo.weekEventReg[92], "week_event_reg[92]" }, + { &gSaveContext.save.saveInfo.weekEventReg[93], "week_event_reg[93]" }, + { &gSaveContext.save.saveInfo.weekEventReg[94], "week_event_reg[94]" }, + { &gSaveContext.save.saveInfo.weekEventReg[95], "week_event_reg[95]" }, + { &gSaveContext.save.saveInfo.weekEventReg[96], "week_event_reg[96]" }, + { &gSaveContext.save.saveInfo.weekEventReg[97], "week_event_reg[97]" }, + { &gSaveContext.save.saveInfo.weekEventReg[98], "week_event_reg[98]" }, + { &gSaveContext.save.saveInfo.weekEventReg[99], "week_event_reg[99]" }, { &gSaveContext.eventInf[0], "event_inf[0]" }, { &gSaveContext.eventInf[1], "event_inf[1]" }, @@ -246,8 +246,8 @@ void FlagSet_Update(GameState* gameState) { if (CHECK_BTN_ALL(input->cur.button, BTN_START)) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { s16 i; - for (i = 0; i < ARRAY_COUNT(gSaveContext.save.weekEventReg); i++) { - gSaveContext.save.weekEventReg[i] = 0; + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.saveInfo.weekEventReg); i++) { + gSaveContext.save.saveInfo.weekEventReg[i] = 0; } for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { gSaveContext.eventInf[i] = 0; diff --git a/src/code/game.c b/src/code/game.c index b7069d312..bc8b9e39f 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -1,5 +1,6 @@ #include "global.h" #include "system_malloc.h" +#include "z64debug_text.h" #include "z64rumble.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" @@ -21,7 +22,7 @@ void Game_SetFramerateDivisor(GameState* gameState, s32 divisor) { Game_UpdateFramerateVariables(divisor); } -void GameState_SetFBFilter(Gfx** gfx, u32 arg1) { +void GameState_SetFBFilter(Gfx** gfx, void* zbuffer) { Gfx* dlist = *gfx; if ((R_FB_FILTER_TYPE > 0) && (R_FB_FILTER_TYPE < 5)) { @@ -30,33 +31,29 @@ void GameState_SetFBFilter(Gfx** gfx, u32 arg1) { D_801F8010.color.g = R_FB_FILTER_PRIM_COLOR(1); D_801F8010.color.b = R_FB_FILTER_PRIM_COLOR(2); D_801F8010.color.a = R_FB_FILTER_A; - func_80140D10(&D_801F8010, &dlist, arg1); - } else { - if ((R_FB_FILTER_TYPE == 5) || (R_FB_FILTER_TYPE == 6)) { - D_801F8020.useRgba = (R_FB_FILTER_TYPE == 6); - D_801F8020.primColor.r = R_FB_FILTER_PRIM_COLOR(0); - D_801F8020.primColor.g = R_FB_FILTER_PRIM_COLOR(1); - D_801F8020.primColor.b = R_FB_FILTER_PRIM_COLOR(2); - D_801F8020.primColor.a = R_FB_FILTER_A; - D_801F8020.envColor.r = R_FB_FILTER_ENV_COLOR(0); - D_801F8020.envColor.g = R_FB_FILTER_ENV_COLOR(1); - D_801F8020.envColor.b = R_FB_FILTER_ENV_COLOR(2); - D_801F8020.envColor.a = R_FB_FILTER_A; - func_80142100(&D_801F8020, &dlist, arg1); - } else { - if (R_FB_FILTER_TYPE == 7) { - sMonoColors.unk_00 = 0; - sMonoColors.primColor.r = R_FB_FILTER_PRIM_COLOR(0); - sMonoColors.primColor.g = R_FB_FILTER_PRIM_COLOR(1); - sMonoColors.primColor.b = R_FB_FILTER_PRIM_COLOR(2); - sMonoColors.primColor.a = R_FB_FILTER_A; - sMonoColors.envColor.r = R_FB_FILTER_ENV_COLOR(0); - sMonoColors.envColor.g = R_FB_FILTER_ENV_COLOR(1); - sMonoColors.envColor.b = R_FB_FILTER_ENV_COLOR(2); - sMonoColors.envColor.a = R_FB_FILTER_A; - VisMono_Draw(&sMonoColors, &dlist); - } - } + func_80140D10(&D_801F8010, &dlist, zbuffer); + } else if ((R_FB_FILTER_TYPE == 5) || (R_FB_FILTER_TYPE == 6)) { + sVisZbuf.useRgba = (R_FB_FILTER_TYPE == 6); + sVisZbuf.primColor.r = R_FB_FILTER_PRIM_COLOR(0); + sVisZbuf.primColor.g = R_FB_FILTER_PRIM_COLOR(1); + sVisZbuf.primColor.b = R_FB_FILTER_PRIM_COLOR(2); + sVisZbuf.primColor.a = R_FB_FILTER_A; + sVisZbuf.envColor.r = R_FB_FILTER_ENV_COLOR(0); + sVisZbuf.envColor.g = R_FB_FILTER_ENV_COLOR(1); + sVisZbuf.envColor.b = R_FB_FILTER_ENV_COLOR(2); + sVisZbuf.envColor.a = R_FB_FILTER_A; + VisZbuf_Draw(&sVisZbuf, &dlist, zbuffer); + } else if (R_FB_FILTER_TYPE == 7) { + sMonoColors.unk_00 = 0; + sMonoColors.primColor.r = R_FB_FILTER_PRIM_COLOR(0); + sMonoColors.primColor.g = R_FB_FILTER_PRIM_COLOR(1); + sMonoColors.primColor.b = R_FB_FILTER_PRIM_COLOR(2); + sMonoColors.primColor.a = R_FB_FILTER_A; + sMonoColors.envColor.r = R_FB_FILTER_ENV_COLOR(0); + sMonoColors.envColor.g = R_FB_FILTER_ENV_COLOR(1); + sMonoColors.envColor.b = R_FB_FILTER_ENV_COLOR(2); + sMonoColors.envColor.a = R_FB_FILTER_A; + VisMono_Draw(&sMonoColors, &dlist); } *gfx = dlist; @@ -75,7 +72,7 @@ void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) { gSPDisplayList(OVERLAY_DISP++, nextDisplayList); if (R_FB_FILTER_TYPE && R_FB_FILTER_ENV_COLOR(3) == 0) { - GameState_SetFBFilter(&nextDisplayList, (u32)gfxCtx->zbuffer); + GameState_SetFBFilter(&nextDisplayList, gfxCtx->zbuffer); } if (R_ENABLE_ARENA_DBG < 0) { @@ -90,7 +87,7 @@ void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) { { s32 requiredScopeTemp; - func_800E9F78(gfxCtx); + Debug_DrawText(gfxCtx); } if (R_ENABLE_ARENA_DBG != 0) { @@ -131,7 +128,7 @@ void func_801736DC(GraphicsContext* gfxCtx) { } void Game_UpdateInput(GameState* gameState) { - Padmgr_GetInput(gameState->input, 1); + PadMgr_GetInput(gameState->input, true); } void Game_Update(GameState* gameState) { @@ -157,11 +154,11 @@ void GameState_InitArena(GameState* gameState, size_t size) { void* buf = GameAlloc_Malloc(alloc, size); if (buf) { - THA_Ct(&gameState->heap, buf, size); + THA_Init(&gameState->heap, buf, size); return; } - THA_Ct(&gameState->heap, NULL, 0); + THA_Init(&gameState->heap, NULL, 0); __assert("../game.c", 1035); } @@ -173,9 +170,9 @@ void GameState_Realloc(GameState* gameState, size_t size) { size_t bytesAllocated; void* heapStart; - heapStart = gameState->heap.bufp; + heapStart = gameState->heap.start; alloc = &gameState->alloc; - THA_Dt(&gameState->heap); + THA_Destroy(&gameState->heap); GameAlloc_Free(alloc, heapStart); SystemArena_GetSizes(&systemMaxFree, &bytesFree, &bytesAllocated); size = ((systemMaxFree - (sizeof(ArenaNode))) < size) ? (0) : (size); @@ -184,9 +181,9 @@ void GameState_Realloc(GameState* gameState, size_t size) { } if ((gameArena = GameAlloc_Malloc(alloc, size)) != NULL) { - THA_Ct(&gameState->heap, gameArena, size); + THA_Init(&gameState->heap, gameArena, size); } else { - THA_Ct(&gameState->heap, 0, 0); + THA_Init(&gameState->heap, 0, 0); __assert("../game.c", 1074); } } @@ -214,7 +211,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g init(gameState); func_80140CE0(&D_801F8010); - func_801420C0(&D_801F8020); + VisZbuf_Init(&sVisZbuf); VisMono_Init(&sMonoColors); func_80140898(&D_801F8048); func_801773A0(&D_801F7FF0); @@ -236,10 +233,10 @@ void GameState_Destroy(GameState* gameState) { Rumble_Destroy(); func_801773C4(&D_801F7FF0); func_80140D04(&D_801F8010); - func_801420F4(&D_801F8020); + VisZbuf_Destroy(&sVisZbuf); VisMono_Destroy(&sMonoColors); func_80140900(&D_801F8048); - THA_Dt(&gameState->heap); + THA_Destroy(&gameState->heap); GameAlloc_Cleanup(&gameState->alloc); } @@ -256,7 +253,7 @@ u32 GameState_IsRunning(GameState* gameState) { } s32 GameState_GetArenaSize(GameState* gameState) { - return THA_GetSize(&gameState->heap); + return THA_GetRemaining(&gameState->heap); } s32 func_80173B48(GameState* gameState) { diff --git a/src/code/graph.c b/src/code/graph.c index 8edc979d4..558f7d563 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -1,5 +1,5 @@ -#include "prevent_bss_reordering.h" #include "global.h" +#include "buffers.h" #include "system_malloc.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" #include "overlays/gamestates/ovl_file_choose/z_file_choose.h" @@ -26,7 +26,7 @@ void Graph_FaultClient(void) { } void Graph_InitTHGA(TwoHeadGfxArena* arena, Gfx* buffer, s32 size) { - THGA_Ct(arena, buffer, size); + THGA_Init(arena, buffer, size); } void Graph_SetNextGfxPool(GraphicsContext* gfxCtx) { @@ -50,7 +50,7 @@ void Graph_SetNextGfxPool(GraphicsContext* gfxCtx) { gfxCtx->workBuffer = pool->workBuffer; gfxCtx->debugBuffer = pool->debugBuffer; - gfxCtx->curFrameBuffer = (u16*)SysCfb_GetFbPtr(gfxCtx->framebufferIdx % 2); + gfxCtx->curFrameBuffer = SysCfb_GetFbPtr(gfxCtx->framebufferIndex % 2); gSegments[0x0F] = gfxCtx->curFrameBuffer; gfxCtx->zbuffer = SysCfb_GetZBuffer(); @@ -91,21 +91,21 @@ GameStateOverlay* Graph_GetNextGameState(GameState* gameState) { return NULL; } -void* Graph_FaultAddrConvFunc(void* address, void* param) { +void* Graph_FaultAddrConv(void* address, void* param) { uintptr_t addr = address; GameStateOverlay* gameStateOvl = &gGameStateOverlayTable[0]; - uintptr_t ramConv; + size_t ramConv; void* ramStart; - uintptr_t diff; + size_t diff; s32 i; - for (i = 0; i < graphNumGameStates; i++, gameStateOvl++) { + for (i = 0; i < gGraphNumGameStates; i++, gameStateOvl++) { diff = VRAM_PTR_SIZE(gameStateOvl); ramStart = gameStateOvl->loadedRamAddr; ramConv = (uintptr_t)gameStateOvl->vramStart - (uintptr_t)ramStart; if (ramStart != NULL) { - if (addr >= (uintptr_t)ramStart && addr < (uintptr_t)ramStart + diff) { + if ((addr >= (uintptr_t)ramStart) && (addr < (uintptr_t)ramStart + diff)) { return addr + ramConv; } } @@ -116,14 +116,14 @@ void* Graph_FaultAddrConvFunc(void* address, void* param) { void Graph_Init(GraphicsContext* gfxCtx) { bzero(gfxCtx, sizeof(GraphicsContext)); gfxCtx->gfxPoolIdx = 0; - gfxCtx->framebufferIdx = 0; + gfxCtx->framebufferIndex = 0; gfxCtx->viMode = NULL; gfxCtx->viConfigFeatures = gViConfigFeatures; gfxCtx->xScale = gViConfigXScale; gfxCtx->yScale = gViConfigYScale; osCreateMesgQueue(&gfxCtx->queue, gfxCtx->msgBuff, ARRAY_COUNT(gfxCtx->msgBuff)); Fault_AddClient(&sGraphFaultClient, Graph_FaultClient, NULL, NULL); - Fault_AddAddrConvClient(&sGraphFaultAddrConvClient, Graph_FaultAddrConvFunc, NULL); + Fault_AddAddrConvClient(&sGraphFaultAddrConvClient, Graph_FaultAddrConv, NULL); } void Graph_Destroy(GraphicsContext* gfxCtx) { @@ -165,7 +165,7 @@ retry: gfxCtx->masterList = gGfxMasterDL; if (gfxCtx->callback != NULL) { - gfxCtx->callback(gfxCtx, gfxCtx->callbackParam); + gfxCtx->callback(gfxCtx, gfxCtx->callbackArg); } task->type = M_GFXTASK; @@ -191,7 +191,7 @@ retry: if (SREG(33) & 1) { SREG(33) &= ~1; scTask->flags &= ~OS_SC_SWAPBUFFER; - gfxCtx->framebufferIdx--; + gfxCtx->framebufferIndex--; } scTask->msgQ = &gfxCtx->queue; @@ -305,7 +305,7 @@ void Graph_ExecuteAndDraw(GraphicsContext* gfxCtx, GameState* gameState) { if (!problem) { Graph_TaskSet00(gfxCtx, gameState); gfxCtx->gfxPoolIdx++; - gfxCtx->framebufferIdx++; + gfxCtx->framebufferIndex++; } { diff --git a/src/code/main.c b/src/code/main.c index 59ffb6a32..6eadd591a 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -3,7 +3,29 @@ * reordering than just prevent_bss_reordering.h: there is too much of it to control, and it cannot be split into * separate files since most of it is at addresses ending in 8. */ + #include "global.h" +#include "buffers.h" +#include "stack.h" +#include "stackcheck.h" + +extern OSMesgQueue sSiIntMsgQ; +extern OSMesg sSiIntMsgBuf[1]; +extern u32 gSegments[NUM_SEGMENTS]; +extern SchedContext gSchedContext; +extern IrqMgrClient irqClient; +extern OSMesgQueue irqMgrMsgQ; +extern OSMesg irqMgrMsgBuf[60]; +extern OSThread gGraphThread; +extern STACK(sGraphStack, 0x1800); +extern STACK(sSchedStack, 0x600); +extern STACK(sAudioStack, 0x800); +extern STACK(sPadMgrStack, 0x500); +extern StackEntry sGraphStackInfo; +extern StackEntry sSchedStackInfo; +extern StackEntry sAudioStackInfo; +extern StackEntry sPadMgrStackInfo; +extern AudioMgr sAudioMgr; void Main(void* arg) { intptr_t fb; @@ -24,7 +46,7 @@ void Main(void* arg) { startHeapSize = fb - sysHeap; SystemArena_Init(sysHeap, startHeapSize); - GameInfo_Init(); + Regs_Init(); R_ENABLE_ARENA_DBG = 0; @@ -33,25 +55,24 @@ void Main(void* arg) { osCreateMesgQueue(&irqMgrMsgQ, irqMgrMsgBuf, ARRAY_COUNT(irqMgrMsgBuf)); - StackCheck_Init(&schedStackEntry, schedStack, schedStack + sizeof(schedStack), 0, 0x100, "sched"); - Sched_Init(&gSchedContext, schedStack + sizeof(schedStack), Z_PRIORITY_SCHED, D_8009B290, 1, &gIrqMgr); + StackCheck_Init(&sSchedStackInfo, sSchedStack, STACK_TOP(sSchedStack), 0, 0x100, "sched"); + Sched_Init(&gSchedContext, STACK_TOP(sSchedStack), Z_PRIORITY_SCHED, D_8009B290, 1, &gIrqMgr); CIC6105_AddRomInfoFaultPage(); IrqMgr_AddClient(&gIrqMgr, &irqClient, &irqMgrMsgQ); - StackCheck_Init(&audioStackEntry, audioStack, audioStack + sizeof(audioStack), 0, 0x100, "audio"); - AudioMgr_Init(&audioContext, audioStack + sizeof(audioStack), Z_PRIORITY_AUDIOMGR, 0xA, &gSchedContext, &gIrqMgr); + StackCheck_Init(&sAudioStackInfo, sAudioStack, STACK_TOP(sAudioStack), 0, 0x100, "audio"); + AudioMgr_Init(&sAudioMgr, STACK_TOP(sAudioStack), Z_PRIORITY_AUDIOMGR, 0xA, &gSchedContext, &gIrqMgr); - StackCheck_Init(&padmgrStackEntry, padmgrStack, padmgrStack + sizeof(padmgrStack), 0, 0x100, "padmgr"); - PadMgr_Init(&sSiIntMsgQ, &gIrqMgr, 7, Z_PRIORITY_PADMGR, padmgrStack + sizeof(padmgrStack)); + StackCheck_Init(&sPadMgrStackInfo, sPadMgrStack, STACK_TOP(sPadMgrStack), 0, 0x100, "padmgr"); + PadMgr_Init(&sSiIntMsgQ, &gIrqMgr, 7, Z_PRIORITY_PADMGR, STACK_TOP(sPadMgrStack)); - AudioMgr_Unlock(&audioContext); + AudioMgr_Unlock(&sAudioMgr); - StackCheck_Init(&sGraphStackInfo, sGraphStack, sGraphStack + sizeof(sGraphStack), 0, 0x100, "graph"); - osCreateThread(&sGraphThread, Z_THREAD_ID_GRAPH, Graph_ThreadEntry, arg, sGraphStack + sizeof(sGraphStack), - Z_PRIORITY_GRAPH); - osStartThread(&sGraphThread); + StackCheck_Init(&sGraphStackInfo, sGraphStack, STACK_TOP(sGraphStack), 0, 0x100, "graph"); + osCreateThread(&gGraphThread, Z_THREAD_ID_GRAPH, Graph_ThreadEntry, arg, STACK_TOP(sGraphStack), Z_PRIORITY_GRAPH); + osStartThread(&gGraphThread); exit = false; @@ -73,5 +94,5 @@ void Main(void* arg) { } IrqMgr_RemoveClient(&gIrqMgr, &irqClient); - osDestroyThread(&sGraphThread); + osDestroyThread(&gGraphThread); } diff --git a/src/code/object_table.c b/src/code/object_table.c new file mode 100644 index 000000000..aa73199b8 --- /dev/null +++ b/src/code/object_table.c @@ -0,0 +1,24 @@ +#include "global.h" + +s16 gPlayerFormObjectIndices[PLAYER_FORM_MAX] = { + OBJECT_LINK_BOY, // PLAYER_FORM_FIERCE_DEITY + OBJECT_LINK_GORON, // PLAYER_FORM_GORON + OBJECT_LINK_ZORA, // PLAYER_FORM_ZORA + OBJECT_LINK_NUTS, // PLAYER_FORM_DEKU + OBJECT_LINK_CHILD, // PLAYER_FORM_HUMAN +}; + +ObjectId gObjectTableSize = OBJECT_ID_MAX; + +// Object Table definition +#define DEFINE_OBJECT(name, _enumValue) { SEGMENT_ROM_START(name), SEGMENT_ROM_END(name) }, +#define DEFINE_OBJECT_UNSET(_enumValue) { 0, 0 }, +#define DEFINE_OBJECT_SIZE_ZERO(name, _enumValue) { SEGMENT_ROM_START(name), SEGMENT_ROM_START(name) }, + +RomFile gObjectTable[] = { +#include "tables/object_table.h" +}; + +#undef DEFINE_OBJECT +#undef DEFINE_OBJECT_UNSET +#undef DEFINE_OBJECT_SIZE_ZERO diff --git a/src/code/padmgr.c b/src/code/padmgr.c index 077ef1b2b..a04a14f57 100644 --- a/src/code/padmgr.c +++ b/src/code/padmgr.c @@ -1,58 +1,797 @@ +/** + * @file padmgr.c + * + * This file implements communicating with joybus devices at a high level and serving the results to other threads. + * + * Any device that can be plugged into one of the four controller ports such as a standard N64 controller is a joybus + * device. Some joybus devices are also located inside the cartridge such as EEPROM for save data or the Real-Time + * Clock, however neither of these are used in Zelda64 and so this type of communication is unimplemented. Unlike the + * padmgr implementation in OoT, there are three controller types supported: + * - Standard N64 Controller + * - N64 Mouse + * - Voice Recognition Unit + * + * Communicating with these devices is broken down into various layers: + * + * Other threads : The rest of the program that will use the polled data + * | + * PadMgr : Manages devices, submits polling commands at vertical retrace + * | + * Libultra osCont* routines : Interface for building commands and safely using the Serial Interface + * | + * Serial Interface : Hardware unit for sending joybus commands and receiving data via DMA + * | + * PIF : Forwards joybus commands and receives response data from the devices + * |---¬---¬---¬-------¬ + * 1 2 3 4 5 : The joybus devices plugged into the four controller ports or on the cartridge + * + * Joybus communication is handled on another thread as polling and receiving controller data is a slow process; the + * N64 programming manual section 26.2.4.1 quotes 2 milliseconds as the expected delay from calling + * `osContStartReadData` to receiving the data. By running this on a separate thread to the game state, work can be + * done while waiting for this operation to complete. + */ #include "global.h" +#include "io/controller.h" #include "ultra64/motor.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_GetControllerBitmask.s") +#define PADMGR_RETRACE_MSG (1 << 0) +#define PADMGR_PRE_NMI_MSG (1 << 1) +#define PADMGR_NMI_MSG (1 << 2) -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_80174F24.s") +typedef enum { + /* 0 */ VOICE_INIT_FAILED, // voice initialization failed + /* 1 */ VOICE_INIT_TRY, // try to initialize voice + /* 2 */ VOICE_INIT_SUCCESS // voice initialized +} VoiceInitStatus; -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_80174F44.s") +PadMgr* sPadMgrInstance = &gPadMgr; -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_80174F7C.s") +s32 sPadMgrRetraceCount = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_80174F9C.s") +s32 sVoiceInitStatus = VOICE_INIT_TRY; -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_GetEventCallback.s") +/** + * Returns the bitmask of valid controllers. + * + * bit n set = controller (n+1) available. + */ +u8 PadMgr_GetValidControllersMask(void) { + return sPadMgrInstance->validCtrlrsMask; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_80175008.s") +/** + * Sets the callback function intended to be used to modify the rumble pak state on each VI with + * calls to `PadMgr_RumbleSetSingle`. The callback may be passed a single user-provided argument. + * + * @param callback callback to run before rumble state is updated for the current VI + * @param arg the argument to pass to the callback + * + * @see PadMgr_RumbleSetSingle + * @see PadMgr_UnsetRumbleRetraceCallback + */ +void PadMgr_SetRumbleRetraceCallback(void (*callback)(void*), void* arg) { + sPadMgrInstance->rumbleRetraceCallback = callback; + sPadMgrInstance->rumbleRetraceArg = arg; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_SetEventCallback.s") +/** + * Unsets the rumble retrace callback if the provided function and argument are the same as those already registered. + * + * @param callback the callback to test against + * @param arg the argument to test against + * + * @see PadMgr_SetRumbleRetraceCallback + */ +void PadMgr_UnsetRumbleRetraceCallback(void (*callback)(void*), void* arg) { + if ((sPadMgrInstance->rumbleRetraceCallback == callback) && (sPadMgrInstance->rumbleRetraceArg == arg)) { + sPadMgrInstance->rumbleRetraceCallback = NULL; + sPadMgrInstance->rumbleRetraceArg = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_8017506C.s") +/** + * Sets the callback function intended to be used to test for particular inputs on each VI, immediately after new + * inputs have been polled. + * + * This is useful for the rare cases where additional resolution is needed in the timings of player inputs, + * while the game is still updating comparatively slower. + * + * @param callback callback to run as soon as new inputs are obtained + * @param arg the argument to pass to the callback + * + * @see PadMgr_UnsetInputRetraceCallback + */ +void PadMgr_SetInputRetraceCallback(void (*callback)(void*), void* arg) { + sPadMgrInstance->inputRetraceCallback = callback; + sPadMgrInstance->inputRetraceArg = arg; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_Lock.s") +/** + * Unsets the input retrace callback if the provided function and argument are the same as those already registered. + * + * @param callback the callback to test against + * @param arg the argument to test against + * + * @see PadMgr_SetInputRetraceCallback + */ +void PadMgr_UnsetInputRetraceCallback(void (*callback)(void*), void* arg) { + if ((sPadMgrInstance->inputRetraceCallback == callback) && (sPadMgrInstance->inputRetraceArg == arg)) { + sPadMgrInstance->inputRetraceCallback = NULL; + sPadMgrInstance->inputRetraceArg = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_Unlock.s") +/** + * Acquires exclusive access to the serial event queue. + * + * When a DMA to/from PIF RAM completes, an SI interrupt is generated to notify the process that the DMA has completed + * and a message is posted to the serial event queue. If multiple processes are trying to use the SI at the same time + * it becomes ambiguous as to which DMA has completed, so a locking system is required to arbitrate access to the SI. + * + * Once the task requiring the serial event queue is complete, it should be released with a call to + * `PadMgr_ReleaseSerialEventQueue()`. + * + * If another process tries to acquire the event queue, the current thread will be blocked until the event queue is + * released. Note the possibility for a deadlock, if the thread that already holds the serial event queue attempts to + * acquire it again it will block forever. + * + * @return The message queue to which SI interrupt events are posted. + * + * @see PadMgr_ReleaseSerialEventQueue + */ +OSMesgQueue* PadMgr_AcquireSerialEventQueue(void) { + OSMesgQueue* serialEventQueue; -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_801750FC.s") + osRecvMesg(&sPadMgrInstance->serialLockQueue, (OSMesg*)&serialEventQueue, OS_MESG_BLOCK); + return serialEventQueue; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_80175364.s") +/** + * Like `PadMgr_AcquireSerialEventQueue` but for Voice access. + * + * @see PadMgr_AcquireSerialEventQueue + * @see PadMgr_VoiceReleaseSerialEventQueue + */ +OSMesgQueue* PadMgr_VoiceAcquireSerialEventQueue(void) { + OSMesgQueue* serialEventQueue; -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_80175434.s") + osRecvMesg(&sPadMgrInstance->serialLockQueue, (OSMesg*)&serialEventQueue, OS_MESG_BLOCK); + return serialEventQueue; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_8017544C.s") +/** + * Relinquishes access to the serial message queue, allowing another process to acquire and use it. + * + * @param serialEventQueue The serial message queue acquired by `PadMgr_AcquireSerialEventQueue` + * + * @see PadMgr_AcquireSerialEventQueue + */ +void PadMgr_ReleaseSerialEventQueue(OSMesgQueue* serialEventQueue) { + osSendMesg(&sPadMgrInstance->serialLockQueue, (OSMesg)serialEventQueue, OS_MESG_BLOCK); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_RumbleSet.s") +/** + * Like `PadMgr_ReleaseSerialEventQueue` but for Voice access. + * + * @see PadMgr_VoiceAcquireSerialEventQueue + */ +void PadMgr_VoiceReleaseSerialEventQueue(OSMesgQueue* serialEventQueue) { + osSendMesg(&sPadMgrInstance->serialLockQueue, (OSMesg)serialEventQueue, OS_MESG_BLOCK); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_ControllerHasRumblePak.s") +/** + * Locks controller input data while padmgr is reading new inputs or another thread is using the current inputs. + * This prevents new inputs overwriting the current inputs while they are in use. + * + * @see PadMgr_UnlockPadData + */ +void PadMgr_LockPadData(void) { + osRecvMesg(&sPadMgrInstance->lockQueue, NULL, OS_MESG_BLOCK); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_CalcStickEdges.s") +/** + * Unlocks controller input data, allowing padmgr to read new inputs or another thread to access the most recently + * polled inputs. + * + * @see PadMgr_LockPadData + */ +void PadMgr_UnlockPadData(void) { + osSendMesg(&sPadMgrInstance->lockQueue, NULL, OS_MESG_BLOCK); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_ParseState.s") +/** + * Activates the rumble pak for all controllers it is enabled on, stops it for all controllers it is disabled on and + * attempts to initialize it for a controller if it is not already initialized. + */ +void PadMgr_UpdateRumble(void) { + s32 i; + s32 ret; + OSMesgQueue* serialEventQueue = PadMgr_AcquireSerialEventQueue(); + s32 triedRumbleComm = false; -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_801759BC.s") + for (i = 0; i < MAXCONTROLLERS; i++) { + if (sPadMgrInstance->ctrlrType[i] == PADMGR_CONT_NORMAL) { + // Check status for whether a controller pak is connected + if (sPadMgrInstance->padStatus[i].status & CONT_CARD_ON) { + if (sPadMgrInstance->pakType[i] == CONT_PAK_RUMBLE) { + if (sPadMgrInstance->rumbleEnable[i]) { + if (sPadMgrInstance->rumbleTimer[i] < 3) { + // Rumble pak start -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_80175AE0.s") + if (osMotorStart(&sPadMgrInstance->rumblePfs[i]) != 0) { + // error + sPadMgrInstance->pakType[i] = CONT_PAK_NONE; + } else { + sPadMgrInstance->rumbleTimer[i] = 3; + } + triedRumbleComm = true; + } + } else { + if (sPadMgrInstance->rumbleTimer[i] != 0) { + // Rumble Pak stop -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_Update.s") + if (osMotorStop(&sPadMgrInstance->rumblePfs[i]) != 0) { + // error + sPadMgrInstance->pakType[i] = CONT_PAK_NONE; + } else { + sPadMgrInstance->rumbleTimer[i]--; + } + triedRumbleComm = true; + } + } + } + } else if (sPadMgrInstance->pakType[i] != CONT_PAK_NONE) { + sPadMgrInstance->pakType[i] = CONT_PAK_NONE; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_Stop.s") + if (!triedRumbleComm) { + // Try to initialize the rumble pak for controller port `i` if a controller pak is connected and not already + // known to be an initialized a rumble pak + i = sPadMgrRetraceCount % MAXCONTROLLERS; -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_80175E68.s") + if ((sPadMgrInstance->ctrlrType[i] == PADMGR_CONT_NORMAL) && + (sPadMgrInstance->padStatus[i].status & CONT_CARD_ON) && (sPadMgrInstance->pakType[i] != CONT_PAK_RUMBLE)) { + ret = osMotorInit(serialEventQueue, &sPadMgrInstance->rumblePfs[i], i); -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_GetInput.s") + if (ret == 0) { + // Got rumble pak + sPadMgrInstance->pakType[i] = CONT_PAK_RUMBLE; + sPadMgrInstance->rumbleTimer[i] = 2; + } else if (ret == PFS_ERR_DEVICE) { + // Not a rumble pak + if (sPadMgrInstance->pakType[i] != CONT_PAK_OTHER) { + sPadMgrInstance->pakType[i] = CONT_PAK_OTHER; + } + } else if (ret == PFS_ERR_CONTRFAIL) { + // Pak communication error + } else if (ret == PFS_ERR_NOPACK) { + // No controller pak + } else { + // Unrecognized return code + Fault_AddHungupAndCrash("../padmgr.c", 594); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_GetInput2.s") + PadMgr_ReleaseSerialEventQueue(serialEventQueue); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_ThreadEntry.s") +/** + * Immediately stops rumble on all controllers + */ +void PadMgr_RumbleStop(void) { + OSMesgQueue* serialEventQueue = PadMgr_AcquireSerialEventQueue(); + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_Init.s") + for (i = 0; i < MAXCONTROLLERS; i++) { + if ((sPadMgrInstance->ctrlrType[i] == PADMGR_CONT_NORMAL) && + (osMotorInit(serialEventQueue, &sPadMgrInstance->rumblePfs[i], i) == 0)) { + // If there is a rumble pak attached to this controller, stop it + osMotorStop(&sPadMgrInstance->rumblePfs[i]); + } + } + PadMgr_ReleaseSerialEventQueue(serialEventQueue); +} + +/** + * Prevents rumble for 12 VI, ~0.2 seconds at 60 VI/sec + */ +void PadMgr_RumblePause(void) { + sPadMgrInstance->rumbleOffTimer = 12; +} + +/** + * Enables or disables rumble on controller port `port` for 24 VI, + * ~0.4 seconds at 60 VI/sec and ~0.48 seconds at 50 VI/sec + */ +void PadMgr_RumbleSetSingle(s32 port, s32 enable) { + sPadMgrInstance->rumbleEnable[port] = enable; + sPadMgrInstance->rumbleOnTimer = 24; +} + +/** + * Enables or disables rumble on all controller ports for 24 VI, + * ~0.4 seconds at 60 VI/sec and ~0.48 seconds at 50 VI/sec + * + * @param enable Array of u8 of length MAXCONTROLLERS containing either true or false to enable or disable rumble + * for that controller + */ +void PadMgr_RumbleSet(u8 enable[MAXCONTROLLERS]) { + s32 i; + + for (i = 0; i < MAXCONTROLLERS; i++) { + sPadMgrInstance->rumbleEnable[i] = enable[i]; + } + sPadMgrInstance->rumbleOnTimer = 24; +} + +s32 PadMgr_ControllerHasRumblePak(s32 port) { + return sPadMgrInstance->pakType[port] == CONT_PAK_RUMBLE; +} + +void PadMgr_AdjustInput(Input* input) { + s32 plus; + s32 minus; + s32 pressX; + s32 pressX2; + s32 pressY; + s32 pressY2; + s32 pad1; + s32 pad2; + s32 pad3; + f32 pad4; + f32 newX; + f32 newY; + f32 magnitude; + f32 angle; + s8 curX = input->cur.stick_x; + s8 curY = input->cur.stick_y; + + if (CHECK_BTN_ANY(input->press.button, BTN_RESET) || (input->press.stick_x == 0)) { + input->press.stick_x = 61; + input->press.errno = -61; + input->press.stick_y = 63; + input->rel.errno = -63; + } + pressX = input->press.stick_x; + pressX2 = (s8)input->press.errno; + pressY = input->press.stick_y; + pressY2 = (s8)input->rel.errno; + + if (CHECK_BTN_ANY(input->cur.button, BTN_RESET)) { + minus = curX - 7; + plus = curX + 7; + + if (minus > 0) { + if (pressX < minus - 3) { + pressX = minus - 3; + input->press.stick_x = minus - 3; + } + } else if (plus < 0) { + if (pressX2 > plus + 3) { + pressX2 = plus + 3; + input->press.errno = plus + 3; + } + } + + minus = curY - 7; + plus = curY + 7; + + if (minus > 0) { + if (pressY < minus - 3) { + pressY = minus - 3; + input->press.stick_y = minus - 3; + } + } else if (plus < 0) { + if (pressY2 > plus + 3) { + pressY2 = plus + 3; + input->rel.errno = plus + 3; + } + } + } + + minus = curX - 7; + plus = curX + 7; + + if (minus > 0) { + newX = (pressX < minus) ? 1.0f : (f32)minus / pressX; + } else if (plus < 0) { + newX = (pressX2 > plus) ? -1.0f : -(f32)plus / pressX2; + } else { + newX = 0.0f; + } + + minus = curY - 7; + plus = curY + 7; + + if (minus > 0) { + newY = (pressY < minus) ? 1.0f : (f32)minus / pressY; + } else if (plus < 0) { + newY = (pressY2 > plus) ? -1.0f : -(f32)plus / pressY2; + } else { + newY = 0.0f; + } + + if (1) { + s32 pad; + + magnitude = sqrtf(SQ(newX) + SQ(newY)); + if (magnitude > 1.0f) { + magnitude = 1.0f; + } + angle = Math_Atan2F_XY(curY, -curX); + newX = -sinf(angle) * magnitude; + newY = cosf(angle) * magnitude; + } + input->rel.stick_x = newX * 60.5f; + input->rel.stick_y = newY * 60.5f; +} + +/** + * Updates `sPadMgrInstance->inputs` based on the error response of each controller + */ +void PadMgr_UpdateInputs(void) { + s32 diff; + Input* input = &sPadMgrInstance->inputs[0]; + s32 i; + OSContPad* pad = &sPadMgrInstance->pads[0]; + + for (i = 0; i < sPadMgrInstance->nControllers; i++, input++, pad++) { + s32 isStandardController; + + input->prev = input->cur; + isStandardController = sPadMgrInstance->ctrlrType[i] == PADMGR_CONT_NORMAL; + if (isStandardController) { + switch (pad->errno) { + case 0: + // No error, copy inputs + input->cur = *pad; + break; + + case CHNL_ERR_OVERRUN >> 4: + // Overrun error, reuse previous inputs + input->cur = input->prev; + break; + + case CHNL_ERR_NORESP >> 4: + // No response error, take inputs as 0 + input->cur.button = 0; + input->cur.stick_x = 0; + input->cur.stick_y = 0; + input->cur.errno = pad->errno; + if (sPadMgrInstance->ctrlrType[i] != PADMGR_CONT_NONE) { + // If we get no response, consider the controller disconnected + sPadMgrInstance->ctrlrType[i] = PADMGR_CONT_NONE; + sPadMgrInstance->pakType[i] = CONT_PAK_NONE; + sPadMgrInstance->rumbleTimer[i] = 0xFF; + } + break; + + default: + // Unknown error response + Fault_AddHungupAndCrash("../padmgr.c", 1098); + break; + } + } else { + input->cur.button = 0; + input->cur.stick_x = 0; + input->cur.stick_y = 0; + input->cur.errno = pad->errno; + } + + // If opposed directions on the D-Pad are pressed at the same time, mask both out + if ((input->cur.button & (BTN_DDOWN | BTN_DUP)) == (BTN_DDOWN | BTN_DUP)) { + input->cur.button &= ~(BTN_DDOWN | BTN_DUP); + } + if ((input->cur.button & (BTN_DRIGHT | BTN_DLEFT)) == (BTN_DRIGHT | BTN_DLEFT)) { + input->cur.button &= ~(BTN_DRIGHT | BTN_DLEFT); + } + + // Calculate pressed and relative inputs + diff = input->prev.button ^ input->cur.button; + input->press.button |= (u16)(diff & input->cur.button); + input->rel.button |= (u16)(diff & input->prev.button); + + if (1) {} + PadMgr_AdjustInput(input); + } +} + +/** + * Looks for plugged in voice recognition units and initializes them. + * + * This runs only on startup, there will be no attempts to initialize + * a VRU other than on the first VI retrace. + */ +void PadMgr_InitVoice(void) { + s32 i; + OSMesgQueue* serialEventQueue; + s32 ret; + + for (i = 0; i < sPadMgrInstance->nControllers; i++) { + if (sPadMgrInstance->ctrlrType[i] == PADMGR_CONT_VOICE_PLUGGED) { + serialEventQueue = PadMgr_AcquireSerialEventQueue(); + + ret = osVoiceInit(serialEventQueue, &gVoiceHandle, i); + + PadMgr_ReleaseSerialEventQueue(serialEventQueue); + + if (ret != 0) { + // error + } else { + sPadMgrInstance->ctrlrType[i] = PADMGR_CONT_VOICE; + sVoiceInitStatus = VOICE_INIT_SUCCESS; + func_801A4EB0(); + } + } + } + // If sVoiceInitStatus is still VOICE_INIT_TRY after the first attempt to initialize a VRU, don't try again + if (sVoiceInitStatus == VOICE_INIT_TRY) { + sVoiceInitStatus = VOICE_INIT_FAILED; + } +} + +/** + * Update the state of connected controllers + */ +void PadMgr_UpdateConnections(void) { + s32 ctrlrMask = 0; + s32 i; + char msg[50]; + + for (i = 0; i < MAXCONTROLLERS; i++) { + if (sPadMgrInstance->padStatus[i].errno == 0) { + switch (sPadMgrInstance->padStatus[i].type & CONT_TYPE_MASK) { + case CONT_TYPE_NORMAL: + // Standard N64 Controller + ctrlrMask |= (1 << i); + if (sPadMgrInstance->ctrlrType[i] == PADMGR_CONT_NONE) { + sPadMgrInstance->ctrlrType[i] = PADMGR_CONT_NORMAL; + } + break; + + case CONT_TYPE_MOUSE: + // N64 Mouse + if (sPadMgrInstance->ctrlrType[i] == PADMGR_CONT_NONE) { + sPadMgrInstance->ctrlrType[i] = PADMGR_CONT_MOUSE; + } + break; + + case CONT_TYPE_VOICE: + // Voice Recognition Unit + if (sPadMgrInstance->ctrlrType[i] == PADMGR_CONT_NONE) { + sPadMgrInstance->ctrlrType[i] = PADMGR_CONT_VOICE_PLUGGED; + sPadMgrInstance->pakType[i] = CONT_PAK_NONE; + } + break; + + default: + // Other/Unrecognized + if (sPadMgrInstance->ctrlrType[i] == PADMGR_CONT_NONE) { + sPadMgrInstance->ctrlrType[i] = PADMGR_CONT_UNK; + // "Recognized an unknown type of controller (%04x)" + sprintf(msg, "知らない種類のコントローラ(%04x)を認識しました", + sPadMgrInstance->padStatus[i].type); + } + // Missing break required for matching + } + } else if (sPadMgrInstance->ctrlrType[i] != PADMGR_CONT_NONE) { + // Plugged controller errored + sPadMgrInstance->ctrlrType[i] = PADMGR_CONT_NONE; + sPadMgrInstance->pakType[i] = CONT_PAK_NONE; + sPadMgrInstance->rumbleTimer[i] = 0xFF; + } + } + sPadMgrInstance->validCtrlrsMask = ctrlrMask; +} + +void PadMgr_HandleRetrace(void) { + OSMesgQueue* serialEventQueue = PadMgr_AcquireSerialEventQueue(); + + // Begin reading controller data + osContStartReadData(serialEventQueue); + + // Execute rumble callback + if (sPadMgrInstance->rumbleRetraceCallback != NULL) { + sPadMgrInstance->rumbleRetraceCallback(sPadMgrInstance->rumbleRetraceArg); + } + + // Wait for controller data + osRecvMesg(serialEventQueue, NULL, OS_MESG_BLOCK); + osContGetReadData(sPadMgrInstance->pads); + + // Clear all but controller 1 + bzero(&sPadMgrInstance->pads[1], sizeof(*sPadMgrInstance->pads) * (MAXCONTROLLERS - 1)); + + // If in PreNMI, clear all controllers + if (sPadMgrInstance->isResetting) { + bzero(sPadMgrInstance->pads, sizeof(sPadMgrInstance->pads)); + } + + // Query controller statuses + osContStartQuery(serialEventQueue); + osRecvMesg(serialEventQueue, NULL, OS_MESG_BLOCK); + osContGetQuery(sPadMgrInstance->padStatus); + + // Lock serial message queue + PadMgr_ReleaseSerialEventQueue(serialEventQueue); + + // Update connections + PadMgr_UpdateConnections(); + + // Lock input data + PadMgr_LockPadData(); + + // Update input data + PadMgr_UpdateInputs(); + + // Execute input callback + if (sPadMgrInstance->inputRetraceCallback != NULL) { + sPadMgrInstance->inputRetraceCallback(sPadMgrInstance->inputRetraceArg); + } + + // Unlock input data + PadMgr_UnlockPadData(); + + // Try and initialize a Voice Recognition Unit if not already attempted + if (sVoiceInitStatus != VOICE_INIT_FAILED) { + PadMgr_InitVoice(); + } + + // Rumble Pak + if (gFaultStruct.msgId != 0) { + // If fault is active, no rumble + PadMgr_RumbleStop(); + } else if (sPadMgrInstance->rumbleOffTimer > 0) { + // If the rumble off timer is active, no rumble + --sPadMgrInstance->rumbleOffTimer; + PadMgr_RumbleStop(); + } else if (sPadMgrInstance->rumbleOnTimer == 0) { + // If the rumble on timer is inactive, no rumble + PadMgr_RumbleStop(); + } else if (!sPadMgrInstance->isResetting) { + // If not resetting, update rumble + PadMgr_UpdateRumble(); + --sPadMgrInstance->rumbleOnTimer; + } + + sPadMgrRetraceCount++; +} + +void PadMgr_HandlePreNMI(void) { + sPadMgrInstance->isResetting = true; + PadMgr_RumblePause(); +} + +/** + * Fetches the most recently polled inputs from padmgr. + * + * NOTE: This function does not lock the inputs while reading them. + * The padmgr thread may interrupt this function and poll new inputs while the thread running this function is + * currently copying the old inputs potentially resulting in a mix of newly polled and old inputs being used. + * It is preferable to use `PadMgr_GetInput` or `PadMgr_GetInput2`. + * + * @param inputs Array of Input of length MAXCONTROLLERS to copy inputs into + * @param gameRequest True if polling inputs for updating the game state + */ +void PadMgr_GetInputNoLock(Input* inputs, s32 gameRequest) { + s32 i; + Input* input = &sPadMgrInstance->inputs[0]; + Input* inputOut = &inputs[0]; + s32 buttonDiff; + + for (i = 0; i < MAXCONTROLLERS; i++) { + if (gameRequest) { + // Copy inputs as-is, press and rel are calculated prior in `PadMgr_UpdateInputs` + *inputOut = *input; + // Zero parts of the press and rel inputs in the polled inputs so they are not read more than once + input->press.button = 0; + input->rel.button = 0; + } else { + // Take as the previous inputs the inputs that are currently in the destination array + inputOut->prev = inputOut->cur; + // Copy current inputs from the polled inputs + inputOut->cur = input->cur; + // Calculate press and rel from these + buttonDiff = inputOut->prev.button ^ inputOut->cur.button; + inputOut->press.button = inputOut->cur.button & buttonDiff; + inputOut->rel.button = inputOut->prev.button & buttonDiff; + PadUtils_UpdateRelXY(inputOut); + } + input++; + inputOut++; + } +} + +/** + * Fetches the most recently polled inputs from padmgr. + * + * @param inputs Array of Input of length MAXCONTROLLERS to copy inputs into + * @param gameRequest True if polling inputs for updating the game state + */ +void PadMgr_GetInput(Input* inputs, s32 gameRequest) { + PadMgr_LockPadData(); + PadMgr_GetInputNoLock(inputs, gameRequest); + PadMgr_UnlockPadData(); +} + +/** + * Copy of `PadMgr_GetInput` + * + * @see PadMgr_GetInput + */ +void PadMgr_GetInput2(Input* inputs, s32 gameRequest) { + PadMgr_LockPadData(); + PadMgr_GetInputNoLock(inputs, gameRequest); + PadMgr_UnlockPadData(); +} + +void PadMgr_ThreadEntry() { + s16* interruptMsg = NULL; + s32 actionBits; + s32 exit; + + osCreateMesgQueue(&sPadMgrInstance->interruptQueue, sPadMgrInstance->interruptMsgBuf, + ARRAY_COUNT(sPadMgrInstance->interruptMsgBuf)); + IrqMgr_AddClient(sPadMgrInstance->irqMgr, &sPadMgrInstance->irqClient, &sPadMgrInstance->interruptQueue); + + actionBits = 0; + exit = false; + + while (!exit) { + // Process all messages currently in the queue, instead of only a single mssage. + // Deduplicates the same message. + do { + osRecvMesg(&sPadMgrInstance->interruptQueue, (OSMesg*)&interruptMsg, OS_MESG_BLOCK); + switch (*interruptMsg) { + case OS_SC_RETRACE_MSG: + actionBits |= PADMGR_RETRACE_MSG; + break; + + case OS_SC_PRE_NMI_MSG: + actionBits |= PADMGR_PRE_NMI_MSG; + break; + + case OS_SC_NMI_MSG: + actionBits |= PADMGR_NMI_MSG; + break; + } + } while (!MQ_IS_EMPTY(&sPadMgrInstance->interruptQueue)); + + // Act on received messages + while (actionBits != 0) { + if (actionBits & PADMGR_NMI_MSG) { + actionBits &= ~PADMGR_NMI_MSG; + exit = true; + } else if (actionBits & PADMGR_PRE_NMI_MSG) { + actionBits &= ~PADMGR_PRE_NMI_MSG; + PadMgr_HandlePreNMI(); + } else if (actionBits & PADMGR_RETRACE_MSG) { + actionBits &= ~PADMGR_RETRACE_MSG; + PadMgr_HandleRetrace(); + } + } + } + + IrqMgr_RemoveClient(sPadMgrInstance->irqMgr, &sPadMgrInstance->irqClient); +} + +void PadMgr_Init(OSMesgQueue* siEvtQ, IrqMgr* irqMgr, OSId threadId, OSPri pri, void* stack) { + bzero(sPadMgrInstance, sizeof(PadMgr)); + sPadMgrInstance->irqMgr = irqMgr; + + // These are unique access tokens, there should only ever be room for one OSMesg in these queues + osCreateMesgQueue(&sPadMgrInstance->serialLockQueue, &sPadMgrInstance->serialMsg, 1); + osCreateMesgQueue(&sPadMgrInstance->lockQueue, &sPadMgrInstance->lockMsg, 1); + + PadMgr_UnlockPadData(); + PadSetup_Init(siEvtQ, &sPadMgrInstance->validCtrlrsMask, sPadMgrInstance->padStatus); + sPadMgrInstance->nControllers = MAXCONTROLLERS; + osContSetCh(sPadMgrInstance->nControllers); + PadMgr_ReleaseSerialEventQueue(siEvtQ); + + osCreateThread(&sPadMgrInstance->thread, threadId, PadMgr_ThreadEntry, sPadMgrInstance, stack, pri); + osStartThread(&sPadMgrInstance->thread); +} diff --git a/src/code/sched.c b/src/code/sched.c index 5f9cdf236..c2630677c 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -1,5 +1,6 @@ #include "prevent_bss_reordering.h" #include "global.h" +#include "stackcheck.h" #define RSP_DONE_MSG 667 #define RDP_DONE_MSG 668 diff --git a/src/code/sys_cfb.c b/src/code/sys_cfb.c new file mode 100644 index 000000000..25d92227c --- /dev/null +++ b/src/code/sys_cfb.c @@ -0,0 +1,21 @@ +#include "global.h" +#include "buffers.h" +#include "system_malloc.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cfb/func_80178750.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cfb/func_80178818.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cfb/func_80178978.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cfb/func_801789D4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cfb/SysCfb_GetFbPtr.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cfb/SysCfb_GetZBuffer.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cfb/func_80178A24.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cfb/func_80178A34.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cfb/func_80178A94.s") diff --git a/src/code/sys_cmpdma.c b/src/code/sys_cmpdma.c index 2533c44f5..b2a17d547 100644 --- a/src/code/sys_cmpdma.c +++ b/src/code/sys_cmpdma.c @@ -1,32 +1,117 @@ #include "global.h" #include "system_malloc.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_80178750.s") +typedef struct { + union { + u32 dmaWord[2]; + u32 dataStart; + u32 dataSize; + struct { + u32 start; + u32 end; + } offset; + }; +} CmpDmaBuffer; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_80178818.s") +CmpDmaBuffer sDmaBuffer; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_80178978.s") +void func_80178AC0(u16* src, void* dst, size_t size) { + Color_RGBA8_u32 spC; + Color_RGBA16_2 tc; + Color_RGBA14 tc2; + u32* dstCur = dst; + u16* src16 = src; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_801789D4.s") + while (((uintptr_t)dstCur) - size < ((uintptr_t)dst)) { + tc.rgba = *(src16++); + if (tc.a == 1) { + spC.r = (tc.r * 255) / 31; + spC.g = (tc.g * 255) / 31; + spC.b = (tc.b * 255) / 31; + spC.a = 255; + } else if (tc.rgba == 0) { + spC.rgba = 0; + } else { + tc2.rgba = tc.rgba; + tc.rgba = *(src16++); + spC.r = (tc.r << 3) | tc2.r; + spC.g = (tc.g << 3) | tc2.g; + spC.b = (tc.b << 3) | tc2.b; + spC.a = ((tc.rgba & 1) << 7) | ((tc2.a * 127) / 63); + } + *(dstCur++) = spC.rgba; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/SysCfb_GetFbPtr.s") +void CmpDma_GetFileInfo(u8* segmentRom, s32 id, uintptr_t* outFileRom, size_t* size, s32* flag) { + u32 dataStart; + u32 refOff; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/SysCfb_GetZBuffer.s") + DmaMgr_DmaRomToRam(segmentRom, &sDmaBuffer.dataStart, sizeof(sDmaBuffer.dataStart)); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_80178A24.s") + dataStart = sDmaBuffer.dataStart; + refOff = id * sizeof(u32); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_80178A34.s") + // if id is >= idMax + if (refOff > (dataStart - 4)) { + *outFileRom = segmentRom; + *size = 0; + } else if (refOff == 0) { + // get offset start of next file, i.e. size of first file + DmaMgr_DmaRomToRam(segmentRom + 4, &sDmaBuffer.dataSize, sizeof(sDmaBuffer.dataSize)); + *outFileRom = segmentRom + dataStart; + *size = sDmaBuffer.dataSize; + } else { + // get offset start, end from dataStart + DmaMgr_DmaRomToRam(refOff + segmentRom, &sDmaBuffer.offset, sizeof(sDmaBuffer.offset)); + *outFileRom = sDmaBuffer.offset.start + segmentRom + dataStart; + *size = sDmaBuffer.offset.end - sDmaBuffer.offset.start; + } + *flag = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_80178A94.s") +void CmpDma_Decompress(uintptr_t romStart, size_t size, void* dst) { + if (size != 0) { + Yaz0_Decompress(romStart, dst, size); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_80178AC0.s") +void CmpDma_LoadFileImpl(uintptr_t segmentRom, s32 id, void* dst, size_t size) { + uintptr_t romStart; + size_t compressedSize; + s32 flag; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_80178C80.s") + CmpDma_GetFileInfo(segmentRom, id, &romStart, &compressedSize, &flag); + if (flag & 1) { + void* tempBuf = SystemArena_Malloc(0x1000); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_80178D7C.s") + CmpDma_Decompress(romStart, compressedSize, tempBuf); + func_80178AC0(tempBuf, dst, size); + SystemArena_Free(tempBuf); + } else { + CmpDma_Decompress(romStart, compressedSize, dst); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_80178DAC.s") +void CmpDma_LoadFile(uintptr_t segmentVrom, s32 id, void* dst, size_t size) { + CmpDma_LoadFileImpl(DmaMgr_TranslateVromToRom(segmentVrom), id, dst, size); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_80178E3C.s") +void CmpDma_LoadAllFiles(uintptr_t segmentVrom, void* dst, size_t size) { + uintptr_t rom = DmaMgr_TranslateVromToRom(segmentVrom); + u32 i; + u32 end; + void* nextDst; + u32 dataStart; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_80178E7C.s") + DmaMgr_DmaRomToRam(rom, &sDmaBuffer.dataStart, sizeof(sDmaBuffer.dataStart)); + + dataStart = sDmaBuffer.dataStart; + nextDst = dst; + end = (dataStart / sizeof(u32)) - 1; + + for (i = 0; i < end; i++) { + CmpDma_LoadFileImpl(rom, i, nextDst, 0); + nextDst = gYaz0DecompressDstEnd; + } +} diff --git a/src/code/sys_flashrom.c b/src/code/sys_flashrom.c index 8b6c2fa5c..0db0b8744 100644 --- a/src/code/sys_flashrom.c +++ b/src/code/sys_flashrom.c @@ -1,6 +1,18 @@ #include "global.h" +#include "stack.h" +#include "stackcheck.h" #include "system_malloc.h" +// extern UNK_TYPE1 D_801FBE10; +// extern UNK_TYPE1 D_801FBE28; +// extern UNK_TYPE1 D_801FBE2C; +// extern UNK_TYPE4 D_801FBE30; +extern STACK(sSysFlashromStack, 0x1000); +extern StackEntry sSysFlashromStackInfo; +extern OSThread sSysFlashromThread; +extern s80185D40 D_801FD008; +extern OSMesg D_801FD034[1]; + #pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_801857C0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_801857D0.s") diff --git a/src/code/sys_math.c b/src/code/sys_math.c index da4ccc9d2..7fd7e9dea 100644 --- a/src/code/sys_math.c +++ b/src/code/sys_math.c @@ -66,7 +66,7 @@ f32 pow_int(f32 base, s32 exp) { * Takes an angle in radians and returns the sine. */ f32 sin_rad(f32 rad) { - return sins(RADF_TO_BINANG(rad)) * SHT_MINV; + return sins(RAD_TO_BINANG(rad)) * SHT_MINV; } // Rename to Math_CosF @@ -74,7 +74,7 @@ f32 sin_rad(f32 rad) { * Takes an angle in radians and returns the cosine. */ f32 cos_rad(f32 rad) { - return coss(RADF_TO_BINANG(rad)) * SHT_MINV; + return coss(RAD_TO_BINANG(rad)) * SHT_MINV; } /** diff --git a/src/code/sys_math_atan.c b/src/code/sys_math_atan.c index 72383b6b9..ef05676f5 100644 --- a/src/code/sys_math_atan.c +++ b/src/code/sys_math_atan.c @@ -127,7 +127,7 @@ s16 Math_Atan2S(f32 y, f32 x) { } f32 Math_Atan2F(f32 y, f32 x) { - return Math_Atan2S(y, x) * (M_PI / 0x8000); + return BINANG_TO_RAD(Math_Atan2S(y, x)); } // Match the OoT implementation of Math_Atan2S diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index f2ed19c38..de8da3def 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -74,7 +74,7 @@ MtxF* sCurrentMatrix; //!< original name: "Matrix_now" * @remark original name: "new_Matrix" */ void Matrix_Init(GameState* gameState) { - sMatrixStack = THA_AllocEndAlign16(&gameState->heap, MATRIX_STACK_SIZE * sizeof(MtxF)); + sMatrixStack = THA_AllocTailAlign16(&gameState->heap, MATRIX_STACK_SIZE * sizeof(MtxF)); sCurrentMatrix = sMatrixStack; } @@ -444,8 +444,8 @@ void Matrix_RotateXFApply(f32 x) { if (x != 0.0f) { cmf = sCurrentMatrix; - sin = sins(RADF_TO_BINANG(x)) * SHT_MINV; - cos = coss(RADF_TO_BINANG(x)) * SHT_MINV; + sin = sins(RAD_TO_BINANG(x)) * SHT_MINV; + cos = coss(RAD_TO_BINANG(x)) * SHT_MINV; tempY = cmf->xy; tempZ = cmf->xz; diff --git a/src/code/sys_rumble.c b/src/code/sys_rumble.c index 4101758be..06bef6e34 100644 --- a/src/code/sys_rumble.c +++ b/src/code/sys_rumble.c @@ -24,12 +24,12 @@ void RumbleManager_Update(RumbleManager* rumbleMgr) { if (D_801D1E70) { for (i = 0; i < MAXCONTROLLERS; i++) { - func_8017544C(i, false); + PadMgr_RumbleSetSingle(i, false); } } D_801D1E70 = rumbleMgr->updateEnabled; - func_80175434(); + PadMgr_RumblePause(); return; } @@ -39,7 +39,7 @@ void RumbleManager_Update(RumbleManager* rumbleMgr) { // Start up the manager by wiping old requests if (rumbleMgr->state == RUMBLEMANAGER_STATE_INITIAL) { for (i = 0; i < MAXCONTROLLERS; i++) { - func_8017544C(i, false); + PadMgr_RumbleSetSingle(i, false); } for (i = 0; i < RUMBLE_REQUEST_BUFFER_SIZE; i++) { @@ -59,7 +59,7 @@ void RumbleManager_Update(RumbleManager* rumbleMgr) { rumbleMgr->state = RUMBLEMANAGER_STATE_RUNNING; - func_80175434(); + PadMgr_RumblePause(); } if (rumbleMgr->state != RUMBLEMANAGER_STATE_WIPE) { @@ -146,7 +146,7 @@ void RumbleManager_Update(RumbleManager* rumbleMgr) { rumbleMgr->overrideDecayStep = 0; rumbleMgr->overrideAccumulator = 0; - func_80175434(); + PadMgr_RumblePause(); } } diff --git a/src/code/sys_slowly.c b/src/code/sys_slowly.c index 415d5f297..754c5d472 100644 --- a/src/code/sys_slowly.c +++ b/src/code/sys_slowly.c @@ -1,43 +1,59 @@ +/** + * @file sys_slowly.c + * + * This file implements a manager for running an asynchronous task on a thread with the lowest priority. + * + * The task callback is expected to have up to 2 void* arguments and have a void return. Setting `argCount` will adjust + * how many args the callback gets called with, but defaults to 2 and using the 2 argument callback. + * + * @note: `argCount` must be set manually, as this file implements no way to configure it. + */ +#include "slowly.h" #include "global.h" +#include "stackcheck.h" -#define SLOWLY_STATUS_DONE (1 << 0) -#define SLOWLY_STATUS_STARTED (1 << 1) - -void Slowly_Main(SlowlyTask* slowly) { +void Slowly_Main(SlowlyMgr* slowly) { slowly->status |= SLOWLY_STATUS_STARTED; - switch (slowly->callbackArgCount) { - case SLOWLY_CALLBACK_NO_ARGS: - slowly->callback0(); + switch (slowly->argCount) { + case 0: + slowly->callback.zero(); break; - case SLOWLY_CALLBACK_ONE_ARG: - slowly->callback1(slowly->callbackArg0); + + case 1: + slowly->callback.one(slowly->arg0); break; - case SLOWLY_CALLBACK_TWO_ARGS: - slowly->callback2(slowly->callbackArg0, slowly->callbackArg1); + + case 2: + slowly->callback.two(slowly->arg0, slowly->arg1); + break; + + default: break; } slowly->status |= SLOWLY_STATUS_DONE; } -void Slowly_ThreadEntry(SlowlyTask* slowly) { +void Slowly_ThreadEntry(void* arg) { + SlowlyMgr* slowly = (SlowlyMgr*)arg; + Slowly_Main(slowly); } -void Slowly_Start(SlowlyTask* slowly, void* stack, void (*callback)(), void* callbackArg0, void* callbackArg1) { - bzero(slowly, sizeof(SlowlyTask)); +void Slowly_Init(SlowlyMgr* slowly, void* stack, SlowlyCallbackTwo callback, void* arg0, void* arg1) { + bzero(slowly, sizeof(SlowlyMgr)); - slowly->callbackArgCount = SLOWLY_CALLBACK_TWO_ARGS; + slowly->argCount = 2; slowly->status = 0; - slowly->callback0 = callback; - slowly->callbackArg0 = callbackArg0; - slowly->callbackArg1 = callbackArg1; + slowly->callback.two = callback; + slowly->arg0 = arg0; + slowly->arg1 = arg1; osCreateThread(&slowly->thread, Z_THREAD_ID_SLOWLY, Slowly_ThreadEntry, slowly, stack, Z_PRIORITY_SLOWLY); osStartThread(&slowly->thread); } -void Slowly_Stop(SlowlyTask* slowly) { +void Slowly_Destroy(SlowlyMgr* slowly) { osDestroyThread(&slowly->thread); } diff --git a/src/code/z_actor.c b/src/code/z_actor.c index a8a5f4cfe..b09477198 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -32,7 +32,7 @@ extern Mtx D_801ED8E0; // 1 func extern Actor* D_801ED920; // 2 funcs. 1 out of z_actor // Internal forward declarations -void func_800BA8B8(PlayState* play, ActorContext* actorCtx); +void Actor_KillAllOnHalfDayChange(PlayState* play, ActorContext* actorCtx); Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, PlayState* play); Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play); void func_800BB8EC(GameState* gameState, ActorContext* actorCtx, Actor** arg2, Actor** arg3, Player* player); @@ -113,7 +113,7 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, PlayState* play, Gfx* dlist, } void ActorShadow_DrawCircle(Actor* actor, Lights* lights, PlayState* play) { - if (actor->bgCheckFlags & 0x400) { + if (actor->bgCheckFlags & BGCHECKFLAG_PLAYER_400) { func_800B4AEC(play, actor, 50.0f); } @@ -121,7 +121,7 @@ void ActorShadow_DrawCircle(Actor* actor, Lights* lights, PlayState* play) { } void ActorShadow_DrawSquare(Actor* actor, Lights* lights, PlayState* play) { - if (actor->bgCheckFlags & 0x400) { + if (actor->bgCheckFlags & BGCHECKFLAG_PLAYER_400) { func_800B4AEC(play, actor, 50.0f); } @@ -129,9 +129,9 @@ void ActorShadow_DrawSquare(Actor* actor, Lights* lights, PlayState* play) { } void ActorShadow_DrawWhiteCircle(Actor* actor, Lights* lights, PlayState* play) { - static Color_RGBA8 color = { 255, 255, 255, 255 }; + static Color_RGBA8 sColor = { 255, 255, 255, 255 }; - ActorShadow_Draw(actor, lights, play, gCircleShadowDL, &color); + ActorShadow_Draw(actor, lights, play, gCircleShadowDL, &sColor); } void ActorShadow_DrawHorse(Actor* actor, Lights* lights, PlayState* play) { @@ -195,7 +195,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, PlayState* play) { if (distToFloor < 200.0f) { MtxF sp13C; MtxF spFC; - CollisionPoly* spF8; + CollisionPoly* poly; s32 bgId; f32 floorHeight[2]; Light* firstLight = &mapper->l.l[0]; @@ -224,7 +224,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, PlayState* play) { for (i = 0; i < ARRAY_COUNT(floorHeight); i++, spB8 >>= 1) { feetPosPtr->y += 50.0f; - *floorHeightPtr = func_80169100(play, &sp13C, &spF8, &bgId, feetPosPtr); + *floorHeightPtr = Play_GetFloorSurfaceImpl(play, &sp13C, &poly, &bgId, feetPosPtr); feetPosPtr->y -= 50.0f; distToFloor = feetPosPtr->y - *floorHeightPtr; @@ -234,8 +234,9 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, PlayState* play) { if (distToFloor <= 10.0f) { actor->shape.feetFloorFlags |= spB8; - if ((actor->depthInWater < 0.0f) && (bgId == 0x32) && ((actor->shape.unk_17 & spB8) != 0)) { - if (func_800C9C24(&play->colCtx, spF8, bgId, 1) != 0) { + if ((actor->depthInWater < 0.0f) && (bgId == BGCHECK_SCENE) && (actor->shape.unk_17 & spB8)) { + if (SurfaceType_HasMaterialProperty(&play->colCtx, poly, bgId, + MATERIAL_PROPERTY_SOFT_IMPRINT)) { SkinMatrix_MtxFCopy(&sp13C, &spFC); SkinMatrix_MulYRotation(&spFC, actor->shape.rot.y); EffFootmark_Add(play, &spFC, actor, i, feetPosPtr, (actor->shape.shadowScale * 0.3f), @@ -285,7 +286,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, PlayState* play) { floorHeightPtr++; } - if (!(actor->bgCheckFlags & 1)) { + if (!(actor->bgCheckFlags & BGCHECKFLAG_GROUND)) { actor->shape.feetFloorFlags = 0; } else if (actor->shape.feetFloorFlags == 3) { f32 footDistY = actor->shape.feetPos[FOOT_LEFT].y - actor->shape.feetPos[FOOT_RIGHT].y; @@ -336,7 +337,7 @@ void func_800B4B50(Actor* actor, Lights* mapper, PlayState* play) { Light* phi_s0; s32 lightNumMax; - if (actor->bgCheckFlags & 0x400) { + if (actor->bgCheckFlags & BGCHECKFLAG_PLAYER_400) { func_800B4AEC(play, actor, 50.0f); } @@ -560,7 +561,7 @@ void Actor_DrawZTarget(TargetContext* targetCtx, PlayState* play) { } actor = targetCtx->unk_94; - if ((actor != NULL) && !(actor->flags & ACTOR_FLAG_8000000)) { + if ((actor != NULL) && !(actor->flags & ACTOR_FLAG_CANT_LOCK_ON)) { TatlColor* color = &sTatlColorList[actor->category]; POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x07); @@ -907,39 +908,38 @@ s32 func_800B6434(PlayState* play, TitleCardContext* titleCtx) { return true; } -void func_800B6468(PlayState* play) { - play->actorCtx.unk1F5 = 0; +void Actor_InitPlayerImpact(PlayState* play) { + play->actorCtx.playerImpact.timer = 0; } -void func_800B6474(PlayState* play) { - if (play->actorCtx.unk1F5 != 0) { - play->actorCtx.unk1F5--; - } +void Actor_UpdatePlayerImpact(PlayState* play) { + DECR(play->actorCtx.playerImpact.timer); } -s32 func_800B648C(PlayState* play, s32 arg1, s32 arg2, f32 arg3, Vec3f* arg4) { - if ((play->actorCtx.unk1F5 != 0) && (arg3 < play->actorCtx.unk1F8)) { +s32 Actor_SetPlayerImpact(PlayState* play, PlayerImpactType type, s32 timer, f32 dist, Vec3f* pos) { + if ((play->actorCtx.playerImpact.timer != 0) && (dist < play->actorCtx.playerImpact.dist)) { return false; } - play->actorCtx.unk1F4 = arg1; - play->actorCtx.unk1F5 = arg2; - play->actorCtx.unk1F8 = arg3; - Math_Vec3f_Copy(&play->actorCtx.unk1FC, arg4); + play->actorCtx.playerImpact.type = type; + play->actorCtx.playerImpact.timer = timer; + play->actorCtx.playerImpact.dist = dist; + Math_Vec3f_Copy(&play->actorCtx.playerImpact.pos, pos); return true; } -f32 func_800B64FC(PlayState* play, f32 arg1, Vec3f* arg2, u32* arg3) { - f32 temp_f8; +f32 Actor_GetPlayerImpact(PlayState* play, f32 range, Vec3f* pos, PlayerImpactType* type) { + f32 dist; - if ((play->actorCtx.unk1F5 == 0) || (arg1 == 0.0f)) { + if ((play->actorCtx.playerImpact.timer == 0) || (range == 0.0f)) { return -1.0f; } - temp_f8 = Math_Vec3f_DistXYZ(&play->actorCtx.unk1FC, arg2) / arg1; - *arg3 = play->actorCtx.unk1F4; - return play->actorCtx.unk1F8 - temp_f8; + dist = Math_Vec3f_DistXYZ(&play->actorCtx.playerImpact.pos, pos) / range; + *type = play->actorCtx.playerImpact.type; + + return play->actorCtx.playerImpact.dist - dist; } /** @@ -1010,7 +1010,7 @@ void* func_800B6608(PlayState* play, s16 id) { * 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. + * Used only by EnGamelupy. */ void* func_800B6680(PlayState* play, s16 id) { ActorContext_unk_20C* entry = play->actorCtx.unk_20C; @@ -1101,17 +1101,17 @@ void Actor_Destroy(Actor* actor, PlayState* play) { } } -f32 actorMovementScale = 1.0f; +f32 sActorMovementScale = 1.0f; void Actor_SetMovementScale(s32 scale) { - actorMovementScale = scale * 0.5f; + sActorMovementScale = scale * 0.5f; } /** * Update actor position using velocity and any push from z_collision_check. */ void Actor_UpdatePos(Actor* actor) { - f32 speedRate = actorMovementScale; + f32 speedRate = sActorMovementScale; actor->world.pos.x += (actor->velocity.x * speedRate) + actor->colChkInfo.displacement.x; actor->world.pos.y += (actor->velocity.y * speedRate) + actor->colChkInfo.displacement.y; @@ -1125,8 +1125,8 @@ void Actor_UpdatePos(Actor* actor) { * 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.x = actor->speed * Math_SinS(actor->world.rot.y); + actor->velocity.z = actor->speed * Math_CosS(actor->world.rot.y); actor->velocity.y += actor->gravity; if (actor->velocity.y < actor->terminalVelocity) { @@ -1150,11 +1150,11 @@ void Actor_MoveWithGravity(Actor* actor) { * 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; + f32 speedXZ = Math_CosS(actor->world.rot.x) * actor->speed; - 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) * horizontalSpeed; + actor->velocity.x = Math_SinS(actor->world.rot.y) * speedXZ; + actor->velocity.y = Math_SinS(actor->world.rot.x) * actor->speed; + actor->velocity.z = Math_CosS(actor->world.rot.y) * speedXZ; } /** @@ -1174,11 +1174,11 @@ void Actor_MoveWithoutGravity(Actor* actor) { * 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; + f32 speedXZ = Math_CosS(-actor->world.rot.x) * actor->speed; - 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) * horizontalSpeed; + actor->velocity.x = Math_SinS(actor->world.rot.y) * speedXZ; + actor->velocity.y = Math_SinS(-actor->world.rot.x) * actor->speed; + actor->velocity.z = Math_CosS(actor->world.rot.y) * speedXZ; } /** @@ -1193,7 +1193,7 @@ void Actor_MoveWithoutGravityReverse(Actor* actor) { * 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->speed = Math_CosS(actor->world.rot.x) * speed; actor->velocity.y = -Math_SinS(actor->world.rot.x) * speed; } @@ -1207,44 +1207,44 @@ void Actor_UpdatePosFromSkelAnime(Actor* actor, SkelAnime* skelAnime) { 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); +s16 Actor_WorldYawTowardActor(Actor* actorA, Actor* actorB) { + return Math_Vec3f_Yaw(&actorA->world.pos, &actorB->world.pos); } -s16 Actor_YawBetweenActorsTop(Actor* from, Actor* to) { - return Math_Vec3f_Yaw(&from->focus.pos, &to->focus.pos); +s16 Actor_FocusYawTowardActor(Actor* actorA, Actor* actorB) { + return Math_Vec3f_Yaw(&actorA->focus.pos, &actorB->focus.pos); } -s16 Actor_YawToPoint(Actor* actor, Vec3f* point) { - return Math_Vec3f_Yaw(&actor->world.pos, point); +s16 Actor_WorldYawTowardPoint(Actor* actor, Vec3f* refPoint) { + return Math_Vec3f_Yaw(&actor->world.pos, refPoint); } -s16 Actor_PitchBetweenActors(Actor* from, Actor* to) { - return Math_Vec3f_Pitch(&from->world.pos, &to->world.pos); +s16 Actor_WorldPitchTowardActor(Actor* actorA, Actor* actorB) { + return Math_Vec3f_Pitch(&actorA->world.pos, &actorB->world.pos); } -s16 Actor_PitchBetweenActorsTop(Actor* from, Actor* to) { - return Math_Vec3f_Pitch(&from->focus.pos, &to->focus.pos); +s16 Actor_FocusPitchTowardActor(Actor* actorA, Actor* actorB) { + return Math_Vec3f_Pitch(&actorA->focus.pos, &actorB->focus.pos); } -s16 Actor_PitchToPoint(Actor* actor, Vec3f* point) { - return Math_Vec3f_Pitch(&actor->world.pos, point); +s16 Actor_WorldPitchTowardPoint(Actor* actor, Vec3f* refPoint) { + return Math_Vec3f_Pitch(&actor->world.pos, refPoint); } -f32 Actor_DistanceBetweenActors(Actor* actor1, Actor* actor2) { - return Math_Vec3f_DistXYZ(&actor1->world.pos, &actor2->world.pos); +f32 Actor_WorldDistXYZToActor(Actor* actorA, Actor* actorB) { + return Math_Vec3f_DistXYZ(&actorA->world.pos, &actorB->world.pos); } -f32 Actor_DistanceToPoint(Actor* actor, Vec3f* point) { - return Math_Vec3f_DistXYZ(&actor->world.pos, point); +f32 Actor_WorldDistXYZToPoint(Actor* actor, Vec3f* refPoint) { + return Math_Vec3f_DistXYZ(&actor->world.pos, refPoint); } -f32 Actor_XZDistanceBetweenActors(Actor* actor1, Actor* actor2) { - return Math_Vec3f_DistXZ(&actor1->world.pos, &actor2->world.pos); +f32 Actor_WorldDistXZToActor(Actor* actorA, Actor* actorB) { + return Math_Vec3f_DistXZ(&actorA->world.pos, &actorB->world.pos); } -f32 Actor_XZDistanceToPoint(Actor* actor, Vec3f* point) { - return Math_Vec3f_DistXZ(&actor->world.pos, point); +f32 Actor_WorldDistXZToPoint(Actor* actor, Vec3f* refPoint) { + return Math_Vec3f_DistXZ(&actor->world.pos, refPoint); } /** @@ -1302,12 +1302,16 @@ f32 Player_GetHeight(Player* player) { default: case PLAYER_FORM_FIERCE_DEITY: return extraHeight + 124.0f; + case PLAYER_FORM_GORON: return extraHeight + ((player->stateFlags3 & PLAYER_STATE3_1000) ? 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; } @@ -1338,7 +1342,7 @@ s32 func_800B715C(PlayState* play) { } void Actor_SetCameraHorseSetting(PlayState* play, Player* player) { - if ((play->roomCtx.curRoom.unk3 != 4) && (player->actor.id == ACTOR_PLAYER)) { + if ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_4) && (player->actor.id == ACTOR_PLAYER)) { EnHorse* rideActor = (EnHorse*)player->rideActor; if ((rideActor != NULL) && !(rideActor->unk_1EC & 0x10)) { @@ -1364,7 +1368,7 @@ void func_800B722C(GameState* gameState, Player* player) { s32 func_800B724C(PlayState* play, Actor* actor, u8 csMode) { Player* player = GET_PLAYER(play); - if ((player->csMode == PLAYER_CSMODE_5) || ((csMode == PLAYER_CSMODE_6) && (player->csMode == PLAYER_CSMODE_0))) { + if ((player->csMode == PLAYER_CSMODE_5) || ((csMode == PLAYER_CSMODE_END) && (player->csMode == PLAYER_CSMODE_0))) { return false; } @@ -1416,7 +1420,7 @@ s32 Player_IsFacingActor(Actor* actor, s16 maxAngleDiff, PlayState* play) { * 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 angle = BINANG_ROT180(Actor_WorldYawTowardActor(actorA, actorB)); s16 dist = angle - actorB->shape.rot.y; if (ABS_ALT(dist) < maxAngleDiff) { @@ -1444,7 +1448,7 @@ s32 Actor_IsFacingPlayer(Actor* actor, s16 angle) { * 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; + s16 dist = Actor_WorldYawTowardActor(actorA, actorB) - actorA->shape.rot.y; if (ABS_ALT(dist) < maxAngleDiff) { return true; @@ -1477,8 +1481,8 @@ s32 Actor_IsFacingAndNearPlayer(Actor* actor, f32 range, s16 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; + if (Actor_WorldDistXYZToActor(actorA, actorB) < range) { + s16 dist = Actor_WorldYawTowardActor(actorA, actorB) - actorA->shape.rot.y; if (ABS_ALT(dist) < maxAngleDiff) { return true; @@ -1496,12 +1500,12 @@ void Actor_GetSlopeDirection(CollisionPoly* floorPoly, Vec3f* slopeNormal, s16* *downwardSlopeYaw = Math_Atan2S_XY(slopeNormal->z, slopeNormal->x); } -s32 func_800B761C(Actor* actor, f32 arg1, s32 arg2) { - if (actor->bgCheckFlags & 1) { - actor->bgCheckFlags &= ~1; - actor->bgCheckFlags |= 4; +s32 func_800B761C(Actor* actor, f32 arg1, s32 updBgCheckInfoFlags) { + if (actor->bgCheckFlags & BGCHECKFLAG_GROUND) { + actor->bgCheckFlags &= ~BGCHECKFLAG_GROUND; + actor->bgCheckFlags |= BGCHECKFLAG_GROUND_LEAVE; - if ((actor->velocity.y < 0.0f) && (arg2 & 0x10)) { + if ((actor->velocity.y < 0.0f) && (updBgCheckInfoFlags & UPDBGCHECKINFO_FLAG_10)) { actor->velocity.y = 0.0f; } return false; @@ -1510,28 +1514,29 @@ s32 func_800B761C(Actor* actor, f32 arg1, s32 arg2) { return true; } -s32 func_800B7678(PlayState* play, Actor* actor, Vec3f* pos, s32 flags) { +s32 func_800B7678(PlayState* play, Actor* actor, Vec3f* pos, s32 updBgCheckInfoFlags) { f32 distToFloor; s32 bgId; - pos->y += (flags & 0x800) ? 10.0f : 50.0f; + pos->y += (updBgCheckInfoFlags & UPDBGCHECKINFO_FLAG_800) ? 10.0f : 50.0f; actor->floorHeight = BgCheck_EntityRaycastFloor5_2(play, &play->colCtx, &actor->floorPoly, &bgId, actor, pos); - actor->bgCheckFlags &= ~(0x80 | 0x04 | 0x02); + actor->bgCheckFlags &= ~(BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_GROUND_LEAVE | BGCHECKFLAG_GROUND_STRICT); if (actor->floorHeight <= BGCHECK_Y_MIN) { - return func_800B761C(actor, BGCHECK_Y_MIN, flags); + return func_800B761C(actor, BGCHECK_Y_MIN, updBgCheckInfoFlags); } 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 ((distToFloor >= 0.0f) || + (((actor->bgCheckFlags & BGCHECKFLAG_GROUND)) && !(actor->bgCheckFlags & BGCHECKFLAG_PLAYER_800) && + (distToFloor >= -11.0f) && (actor->velocity.y < 0.0f))) { + actor->bgCheckFlags |= BGCHECKFLAG_GROUND_STRICT; - if (actor->bgCheckFlags & 0x10) { + if (actor->bgCheckFlags & BGCHECKFLAG_CEILING) { if (bgId != D_801ED8B4) { if (distToFloor > 15.0f) { - actor->bgCheckFlags |= 0x100; + actor->bgCheckFlags |= BGCHECKFLAG_CRUSHED; } } else { actor->world.pos.x = actor->prevPos.x; @@ -1542,90 +1547,90 @@ s32 func_800B7678(PlayState* play, Actor* actor, Vec3f* pos, s32 flags) { 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)) { + if (!(actor->bgCheckFlags & BGCHECKFLAG_GROUND)) { + actor->bgCheckFlags |= BGCHECKFLAG_GROUND_TOUCH; + } else if ((updBgCheckInfoFlags & UPDBGCHECKINFO_FLAG_8) && (actor->gravity < 0.0f)) { actor->velocity.y = -4.0f; - } else if (!(flags & 0x100)) { + } else if (!(updBgCheckInfoFlags & UPDBGCHECKINFO_FLAG_100)) { actor->velocity.y = 0.0f; } - actor->bgCheckFlags |= 1; - BgCheck2_AttachToMesh(&play->colCtx, actor, (s32)actor->floorBgId); + actor->bgCheckFlags |= BGCHECKFLAG_GROUND; + DynaPolyActor_AttachCarriedActor(&play->colCtx, actor, actor->floorBgId); } } else { - return func_800B761C(actor, distToFloor, flags); + return func_800B761C(actor, distToFloor, updBgCheckInfoFlags); } return true; } void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight, f32 wallCheckRadius, - f32 ceilingCheckHeight, u32 flags) { + f32 ceilingCheckHeight, u32 updBgCheckInfoFlags) { f32 sp94 = actor->world.pos.y - actor->prevPos.y; s32 pad; Vec3f pos; - if ((actor->floorBgId != BGCHECK_SCENE) && (actor->bgCheckFlags & 1)) { - BgCheck2_UpdateActorAttachedToMesh(&play->colCtx, actor->floorBgId, actor); + if ((actor->floorBgId != BGCHECK_SCENE) && (actor->bgCheckFlags & BGCHECKFLAG_GROUND)) { + DynaPolyActor_TransformCarriedActor(&play->colCtx, actor->floorBgId, actor); } - if (flags & 1) { + if (updBgCheckInfoFlags & UPDBGCHECKINFO_FLAG_1) { s32 bgId; - actor->bgCheckFlags &= ~0x1000; - if ((!(flags & 0x80) && + actor->bgCheckFlags &= ~BGCHECKFLAG_PLAYER_1000; + if ((!(updBgCheckInfoFlags & UPDBGCHECKINFO_FLAG_80) && (BgCheck_EntitySphVsWall3(&play->colCtx, &pos, &actor->world.pos, &actor->prevPos, wallCheckRadius, &actor->wallPoly, &bgId, actor, wallCheckHeight))) || - ((flags & 0x80) && + ((updBgCheckInfoFlags & UPDBGCHECKINFO_FLAG_80) && (BgCheck_EntitySphVsWall4(&play->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) { + actor->bgCheckFlags |= BGCHECKFLAG_WALL; + if ((updBgCheckInfoFlags & UPDBGCHECKINFO_FLAG_200) && (actor->bgCheckFlags & BGCHECKFLAG_PLAYER_1000) && + ((s32)sp7C->normal.y > 0) && (sqrtf(SQXYZ(actor->colChkInfo.displacement)) < 10.0f)) { + actor->bgCheckFlags &= ~BGCHECKFLAG_WALL; + } else if (actor->bgCheckFlags & BGCHECKFLAG_WALL) { Math_Vec3f_Copy(&actor->world.pos, &pos); } actor->wallYaw = Math_Atan2S_XY(sp7C->normal.z, sp7C->normal.x); actor->wallBgId = bgId; } else { - actor->bgCheckFlags &= ~8; + actor->bgCheckFlags &= ~BGCHECKFLAG_WALL; } } pos.x = actor->world.pos.x; pos.z = actor->world.pos.z; - if (flags & 2) { + if (updBgCheckInfoFlags & UPDBGCHECKINFO_FLAG_2) { f32 y; pos.y = actor->prevPos.y + 4.0f; if (BgCheck_EntityCheckCeiling(&play->colCtx, &y, &pos, (ceilingCheckHeight + sp94) - 4.0f, &D_801ED8B0, &D_801ED8B4, actor)) { - actor->bgCheckFlags |= 0x10; + actor->bgCheckFlags |= BGCHECKFLAG_CEILING; actor->world.pos.y = (y + sp94) - 4.0f; } else { - actor->bgCheckFlags &= ~0x10; + actor->bgCheckFlags &= ~BGCHECKFLAG_CEILING; } } - if (flags & 4) { + if (updBgCheckInfoFlags & UPDBGCHECKINFO_FLAG_4) { WaterBox* waterbox; f32 y; pos.y = actor->prevPos.y; - func_800B7678(play, actor, &pos, flags); + func_800B7678(play, actor, &pos, updBgCheckInfoFlags); y = actor->world.pos.y; if (WaterBox_GetSurface1(play, &play->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)) { + actor->bgCheckFlags &= ~(BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH); + } else if (!(actor->bgCheckFlags & BGCHECKFLAG_WATER)) { + actor->bgCheckFlags |= (BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH); + if (!(updBgCheckInfoFlags & UPDBGCHECKINFO_FLAG_40)) { Vec3f sp64; sp64.x = actor->world.pos.x; @@ -1637,15 +1642,15 @@ void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight, EffectSsGRipple_Spawn(play, &sp64, 100, 500, 8); } } else { - actor->bgCheckFlags &= ~0x40; + actor->bgCheckFlags &= ~BGCHECKFLAG_WATER_TOUCH; } } else { - actor->bgCheckFlags &= ~(0x40 | 0x20); + actor->bgCheckFlags &= ~(BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH); actor->depthInWater = BGCHECK_Y_MIN; } } - if (flags & 0x400) { + if (updBgCheckInfoFlags & UPDBGCHECKINFO_FLAG_400) { WaterBox* waterbox; f32 y = actor->world.pos.y; @@ -1653,10 +1658,10 @@ void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight, 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)) { + actor->bgCheckFlags &= ~(BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH); + } else if (!(actor->bgCheckFlags & BGCHECKFLAG_WATER)) { + actor->bgCheckFlags |= (BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH); + if (!(updBgCheckInfoFlags & UPDBGCHECKINFO_FLAG_40)) { Vec3f sp50; sp50.x = actor->world.pos.x; @@ -1668,10 +1673,10 @@ void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight, EffectSsGRipple_Spawn(play, &sp50, 100, 500, 8); } } else { - actor->bgCheckFlags &= ~0x40; + actor->bgCheckFlags &= ~BGCHECKFLAG_WATER_TOUCH; } } else { - actor->bgCheckFlags &= ~(0x40 | 0x20); + actor->bgCheckFlags &= ~(BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH); actor->depthInWater = BGCHECK_Y_MIN; } } @@ -1784,7 +1789,7 @@ f32 func_800B82EC(Actor* actor, Player* player, s16 angle) { s16 yaw = ABS_ALT(temp_v0); if (player->targetedActor != NULL) { - if ((yaw > 0x4000) || ((actor->flags & ACTOR_FLAG_8000000))) { + if ((yaw > 0x4000) || ((actor->flags & ACTOR_FLAG_CANT_LOCK_ON))) { return FLT_MAX; } @@ -1812,7 +1817,7 @@ s32 func_800B83BC(Actor* actor, f32 arg1) { } s32 func_800B83F8(Actor* actor, Player* player, s32 flag) { - if ((actor->update == NULL) || !(actor->flags & ACTOR_FLAG_1) || (actor->flags & ACTOR_FLAG_8000000)) { + if ((actor->update == NULL) || !(actor->flags & ACTOR_FLAG_1) || (actor->flags & ACTOR_FLAG_CANT_LOCK_ON)) { return true; } @@ -1834,24 +1839,34 @@ s32 func_800B83F8(Actor* actor, Player* player, s32 flag) { } s16 D_801AED48[] = { - 0x101, 0x141, 0x111, 0x151, 0x105, 0x145, 0x115, 0x155, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY4_NIGHT, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY1_NIGHT | HALFDAYBIT_DAY4_NIGHT, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY2_NIGHT | HALFDAYBIT_DAY4_NIGHT, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY1_NIGHT | HALFDAYBIT_DAY2_NIGHT | HALFDAYBIT_DAY4_NIGHT, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY3_NIGHT | HALFDAYBIT_DAY4_NIGHT, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY1_NIGHT | HALFDAYBIT_DAY3_NIGHT | HALFDAYBIT_DAY4_NIGHT, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY2_NIGHT | HALFDAYBIT_DAY3_NIGHT | HALFDAYBIT_DAY4_NIGHT, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY1_NIGHT | HALFDAYBIT_DAY2_NIGHT | HALFDAYBIT_DAY3_NIGHT | + HALFDAYBIT_DAY4_NIGHT, }; s32 Actor_ProcessTalkRequest(Actor* actor, GameState* gameState) { - if (actor->flags & ACTOR_FLAG_100) { - actor->flags &= ~ACTOR_FLAG_100; + if (actor->flags & ACTOR_FLAG_TALK_REQUESTED) { + actor->flags &= ~ACTOR_FLAG_TALK_REQUESTED; return true; } return false; } -// Actor_PickUpExchange? Seems to be called with exchangeItemId -1 if the same actor used Actor_PickUp +// Actor_OfferTalk / Actor_OfferGetItemExchange? Seems to be called with PLAYER_IA_MINUS1 if the same actor used +// Actor_OfferGetItem. // This function is also used to toggle the "Speak" action on the A button s32 func_800B8500(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, PlayerItemAction exchangeItemId) { Player* player = GET_PLAYER(play); - if ((player->actor.flags & ACTOR_FLAG_100) || ((exchangeItemId > PLAYER_IA_NONE) && Player_InCsMode(play)) || + if ((player->actor.flags & ACTOR_FLAG_TALK_REQUESTED) || + ((exchangeItemId > PLAYER_IA_NONE) && Player_InCsMode(play)) || (!actor->isTargeted && ((fabsf(actor->playerHeightRel) > fabsf(yRange)) || (actor->xzDistToPlayer > player->talkActorDistance) || (xzRange < actor->xzDistToPlayer)))) { @@ -1862,7 +1877,7 @@ s32 func_800B8500(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, Player player->talkActorDistance = actor->xzDistToPlayer; player->exchangeItemId = exchangeItemId; - ActorCutscene_SetIntentToPlay(0x7C); + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); return true; } @@ -1882,7 +1897,7 @@ s32 func_800B863C(Actor* actor, PlayState* play) { s32 Actor_TextboxIsClosing(Actor* actor, PlayState* play) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { - actor->flags &= ~ACTOR_FLAG_100; + actor->flags &= ~ACTOR_FLAG_TALK_REQUESTED; return true; } @@ -1899,7 +1914,7 @@ s32 Actor_ChangeFocus(Actor* actor1, PlayState* play, Actor* actor2) { talkActor = player->talkActor; - if ((player->actor.flags & ACTOR_FLAG_100) && (talkActor != NULL)) { + if ((player->actor.flags & ACTOR_FLAG_TALK_REQUESTED) && (talkActor != NULL)) { player->talkActor = actor2; player->targetedActor = actor2; return true; @@ -1986,19 +2001,35 @@ s32 Actor_HasParent(Actor* actor, PlayState* play) { } /** - * Allows to pick up an item (GetItem or GI), lift an actor or catch various actors in bottles - * within the specified range. + * This function covers various interactions with the player actor, using Get Item IDs (see `GetItemID` enum). + * It is typically used to give items to the player, but also has other purposes. * - * 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 + * This function carries a get item request to the player actor if context allows it (e.g. the player is in range and + * not busy with certain things). The player actor performs the requested action itself. + * + * The following description of what the `getItemId` values can do is provided here for completeness, but these + * behaviors are entirely out of the scope of this function. All behavior is defined by the player actor. + * + * - Positive values (`GI_NONE < getItemId < GI_MAX`): + * Give an item to the player. The player may not get it immediately (for example if diving), but is expected to + * in the near future. + * - Negative values (`-GI_MAX < getItemId < GI_NONE`): + * Used by treasure chests to indicate the chest can be opened (by pressing A). + * The item gotten corresponds to the positive Get Item ID `abs(getItemId)`. + * - `GI_NONE`: + * Allows the player to pick up the actor (by pressing A), to carry it around. + * - `GI_MAX`: + * Allows the player to catch specific actors in a bottle. + * + * @return true If the player actor is capable of accepting the offer. */ -s32 Actor_PickUp(Actor* actor, PlayState* play, GetItemId getItemId, f32 xzRange, f32 yRange) { +s32 Actor_OfferGetItem(Actor* actor, PlayState* play, GetItemId getItemId, f32 xzRange, f32 yRange) { Player* player = GET_PLAYER(play); if (!(player->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_1000 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_40000 | PLAYER_STATE1_80000 | PLAYER_STATE1_100000 | PLAYER_STATE1_200000)) && - Player_GetExplosiveHeld(player) < 0) { + (Player_GetExplosiveHeld(player) <= PLAYER_EXPLOSIVE_NONE)) { if ((actor->xzDistToPlayer <= xzRange) && (fabsf(actor->playerHeightRel) <= fabsf(yRange))) { if ((getItemId == GI_MASK_CIRCUS_LEADER || getItemId == GI_PENDANT_OF_MEMORIES || getItemId == GI_DEED_LAND || @@ -2014,7 +2045,7 @@ s32 Actor_PickUp(Actor* actor, PlayState* play, GetItemId getItemId, f32 xzRange player->getItemDirection = absYawDiff; if ((getItemId > GI_NONE) && (getItemId < GI_MAX)) { - ActorCutscene_SetIntentToPlay(play->playerActorCsIds[1]); + CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_ITEM_GET]); } return true; @@ -2026,16 +2057,16 @@ s32 Actor_PickUp(Actor* actor, PlayState* play, GetItemId getItemId, f32 xzRange return false; } -s32 Actor_PickUpNearby(Actor* actor, PlayState* play, GetItemId getItemId) { - return Actor_PickUp(actor, play, getItemId, 50.0f, 10.0f); +s32 Actor_OfferGetItemNearby(Actor* actor, PlayState* play, GetItemId getItemId) { + return Actor_OfferGetItem(actor, play, getItemId, 50.0f, 10.0f); } -s32 Actor_LiftActor(Actor* actor, PlayState* play) { - return Actor_PickUpNearby(actor, play, GI_NONE); +s32 Actor_OfferCarry(Actor* actor, PlayState* play) { + return Actor_OfferGetItemNearby(actor, play, GI_NONE); } -s32 Actor_PickUpFar(Actor* actor, PlayState* play, GetItemId getItemId) { - return Actor_PickUp(actor, play, getItemId, 9999.9f, 9999.9f); +s32 Actor_OfferGetItemFar(Actor* actor, PlayState* play, GetItemId getItemId) { + return Actor_OfferGetItem(actor, play, getItemId, 9999.9f, 9999.9f); } s32 Actor_HasNoParent(Actor* actor, PlayState* play) { @@ -2065,7 +2096,7 @@ void func_800B8C20(Actor* actorA, Actor* actorB, PlayState* play) { * Sets closest secret distance to the distance to the actor. Calling this function on `actor` is the way to make it a * 'secret' for that update cycle, i.e. something that the controller will rumble for. */ -void func_800B8C50(Actor* actor, PlayState* play) { +void Actor_SetClosestSecretDistance(Actor* actor, PlayState* play) { Player* player = GET_PLAYER(play); if (actor->xyzDistToPlayerSq < player->closestSecretDistSq) { @@ -2089,7 +2120,7 @@ s32 Actor_SetRideActor(PlayState* play, Actor* horse, s32 mountSide) { PLAYER_STATE1_40000 | PLAYER_STATE1_80000 | PLAYER_STATE1_100000 | PLAYER_STATE1_200000))) { player->rideActor = horse; player->mountSide = mountSide; - ActorCutscene_SetIntentToPlay(0x7C); + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); return true; } @@ -2130,7 +2161,10 @@ void func_800B8E1C(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4) func_800B8DD4(play, actor, arg2, arg3, arg4, 0); } -void func_800B8E58(Player* player, u16 sfxId) { +/** + * Play a sound effect at the player's position + */ +void Player_PlaySfx(Player* player, u16 sfxId) { if (player->currentMask == PLAYER_MASK_GIANT) { func_8019F170(&player->actor.projectedPos, sfxId); } else { @@ -2140,27 +2174,27 @@ void func_800B8E58(Player* player, u16 sfxId) { } /** - * Plays the sound effect at the actor's position + * Play a sound effect at the actor's position */ -void Actor_PlaySfxAtPos(Actor* actor, u16 sfxId) { +void Actor_PlaySfx(Actor* actor, u16 sfxId) { Audio_PlaySfxAtPos(&actor->projectedPos, sfxId); } void func_800B8EF4(PlayState* play, Actor* actor) { - u32 sfxId; + SurfaceSfxOffset surfaceSfxOffset; - if (actor->bgCheckFlags & 0x20) { + if (actor->bgCheckFlags & BGCHECKFLAG_WATER) { if (actor->depthInWater < 20.0f) { - sfxId = NA_SE_PL_WALK_WATER0 - SFX_FLAG; + surfaceSfxOffset = SURFACE_SFX_OFFSET_WATER_SHALLOW; } else { - sfxId = NA_SE_PL_WALK_WATER1 - SFX_FLAG; + surfaceSfxOffset = SURFACE_SFX_OFFSET_WATER_DEEP; } } else { - sfxId = SurfaceType_GetSfx(&play->colCtx, actor->floorPoly, actor->floorBgId); + surfaceSfxOffset = SurfaceType_GetSfxOffset(&play->colCtx, actor->floorPoly, actor->floorBgId); } Audio_PlaySfxAtPos(&actor->projectedPos, NA_SE_EV_BOMB_BOUND); - Audio_PlaySfxAtPos(&actor->projectedPos, sfxId + SFX_FLAG); + Audio_PlaySfxAtPos(&actor->projectedPos, NA_SE_PL_WALK_GROUND + surfaceSfxOffset); } void func_800B8F98(Actor* actor, u16 sfxId) { @@ -2212,7 +2246,7 @@ void func_800B9098(Actor* actor) { } s32 func_800B90AC(PlayState* play, Actor* actor, CollisionPoly* polygon, s32 bgId, Vec3f* arg4) { - if (func_800C99D4(&play->colCtx, polygon, bgId) == 8) { + if (SurfaceType_GetFloorType(&play->colCtx, polygon, bgId) == FLOOR_TYPE_8) { return true; } @@ -2226,14 +2260,14 @@ void Actor_DeactivateLens(PlayState* play) { } } -void func_800B9120(ActorContext* actorCtx) { - s32 phi_v0 = CURRENT_DAY * 2; +void Actor_InitHalfDaysBit(ActorContext* actorCtx) { + s32 halfDayCount = CURRENT_DAY * 2; - if (gSaveContext.save.time < CLOCK_TIME(6, 0) || gSaveContext.save.time > CLOCK_TIME(18, 0)) { - phi_v0++; + if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) || (gSaveContext.save.time > CLOCK_TIME(18, 0))) { + halfDayCount++; } - actorCtx->unkC = 0x200 >> phi_v0; + actorCtx->halfDaysBit = HALFDAYBIT_DAY0_DAWN >> halfDayCount; } void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* actorEntry) { @@ -2266,13 +2300,13 @@ void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* acto actorCtx->sceneFlags.clearedRoom = cycleFlags->clearedRoom; TitleCard_ContextInit(&play->state, &actorCtx->titleCtxt); - func_800B6468(play); + Actor_InitPlayerImpact(play); actorCtx->absoluteSpace = NULL; Actor_SpawnEntry(actorCtx, actorEntry, play); Actor_TargetContextInit(&actorCtx->targetContext, actorCtx->actorLists[ACTORCAT_PLAYER].first, play); - func_800B9120(actorCtx); + Actor_InitHalfDaysBit(actorCtx); Fault_AddClient(&sActorFaultClient, (void*)Actor_PrintLists, actorCtx, NULL); func_800B722C(&play->state, (Player*)actorCtx->actorLists[ACTORCAT_PLAYER].first); } @@ -2284,24 +2318,27 @@ void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* acto void Actor_SpawnSetupActors(PlayState* play, ActorContext* actorCtx) { if (play->numSetupActors > 0) { ActorEntry* actorEntry = play->setupActorList; - s32 temp_fp = actorCtx->unkC; - s32 temp_s1; - s32 phi_v0; + s32 prevHalfDaysBitValue = actorCtx->halfDaysBit; + s32 shiftedHalfDaysBit; + s32 actorEntryHalfDayBit; s32 i; - func_800B9120(actorCtx); - func_800BA8B8(play, &play->actorCtx); + Actor_InitHalfDaysBit(actorCtx); + Actor_KillAllOnHalfDayChange(play, &play->actorCtx); - temp_s1 = (actorCtx->unkC * 2) & 0x2FF; + // Shift to previous halfDay bit, but ignoring DAY0_NIGHT. + // In other words, if the current halfDay is DAY1_DAY then this logic is ignored and this variable is zero + shiftedHalfDaysBit = (actorCtx->halfDaysBit << 1) & (HALFDAYBIT_ALL & ~HALFDAYBIT_DAY0_NIGHT); for (i = 0; i < play->numSetupActors; i++) { - phi_v0 = ((actorEntry->rot.x & 7) << 7) | (actorEntry->rot.z & 0x7F); - if (phi_v0 == 0) { - phi_v0 = 0x3FF; + actorEntryHalfDayBit = ((actorEntry->rot.x & 7) << 7) | (actorEntry->rot.z & 0x7F); + if (actorEntryHalfDayBit == 0) { + actorEntryHalfDayBit = HALFDAYBIT_ALL; } - if (!(phi_v0 & temp_fp) && (phi_v0 & actorCtx->unkC) && - (!CHECK_EVENTINF(EVENTINF_17) || !(phi_v0 & temp_s1) || !(actorEntry->id & 0x800))) { + if (!(actorEntryHalfDayBit & prevHalfDaysBitValue) && (actorEntryHalfDayBit & actorCtx->halfDaysBit) && + (!CHECK_EVENTINF(EVENTINF_17) || !(actorEntryHalfDayBit & shiftedHalfDaysBit) || + !(actorEntry->id & 0x800))) { Actor_SpawnEntry(&play->actorCtx, actorEntry, play); } actorEntry++; @@ -2315,9 +2352,9 @@ void Actor_SpawnSetupActors(PlayState* play, ActorContext* actorCtx) { typedef struct { /* 0x00 */ PlayState* play; /* 0x04 */ Actor* actor; - /* 0x08 */ u32 unk_08; - /* 0x0C */ u32 unkC; - /* 0x10 */ Actor* unk10; + /* 0x08 */ u32 requiredActorFlag; + /* 0x0C */ u32 canFreezeCategory; + /* 0x10 */ Actor* talkActor; /* 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 @@ -2352,53 +2389,51 @@ Actor* Actor_UpdateActor(UpdateActor_Params* params) { } else { if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { Actor_Kill(actor); + } else if (((params->requiredActorFlag) && !(actor->flags & params->requiredActorFlag)) || + ((((!params->requiredActorFlag) != 0)) && + (!(actor->flags & ACTOR_FLAG_100000) || + ((actor->category == ACTORCAT_EXPLOSIVES) && (params->player->stateFlags1 & PLAYER_STATE1_200))) && + params->canFreezeCategory && (actor != params->talkActor) && + ((actor != params->player->heldActor)) && (actor->parent != ¶ms->player->actor))) { + CollisionCheck_ResetDamage(&actor->colChkInfo); } else { - if (((params->unk_08) && !(actor->flags & params->unk_08)) || - ((((!params->unk_08) != 0)) && - (!(actor->flags & ACTOR_FLAG_100000) || - ((actor->category == ACTORCAT_EXPLOSIVES) && (params->player->stateFlags1 & PLAYER_STATE1_200))) && - (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); + Math_Vec3f_Copy(&actor->prevPos, &actor->world.pos); + actor->xzDistToPlayer = Actor_WorldDistXZToActor(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; + actor->yawTowardsPlayer = Actor_WorldYawTowardActor(actor, ¶ms->player->actor); + actor->flags &= ~ACTOR_FLAG_1000000; - if ((DECR(actor->freezeTimer) == 0) && (actor->flags & params->unk_18)) { - if (actor == params->player->targetedActor) { - actor->isTargeted = true; - } else { - actor->isTargeted = false; - } - - if ((actor->targetPriority != 0) && (params->player->targetedActor == NULL)) { - actor->targetPriority = 0; - } - - Actor_SetObjectDependency(play, actor); - - if (actor->colorFilterTimer != 0) { - actor->colorFilterTimer--; - } - - actor->update(actor, play); - BgCheck_ResetFlagsIfLoadedActor(play, &play->colCtx.dyna, actor); + if ((DECR(actor->freezeTimer) == 0) && (actor->flags & params->unk_18)) { + if (actor == params->player->targetedActor) { + actor->isTargeted = true; + } else { + actor->isTargeted = false; } - CollisionCheck_ResetDamage(&actor->colChkInfo); + if ((actor->targetPriority != 0) && (params->player->targetedActor == NULL)) { + actor->targetPriority = 0; + } + + Actor_SetObjectDependency(play, actor); + + if (actor->colorFilterTimer != 0) { + actor->colorFilterTimer--; + } + + actor->update(actor, play); + DynaPoly_UnsetAllInteractFlags(play, &play->colCtx.dyna, actor); } + + CollisionCheck_ResetDamage(&actor->colChkInfo); } nextActor = actor->next; } return nextActor; } -u32 D_801AED58[ACTORCAT_MAX] = { +u32 sCategoryFreezeMasks[ACTORCAT_MAX] = { /* ACTORCAT_SWITCH */ PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_10000000, /* ACTORCAT_BG */ @@ -2433,7 +2468,7 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { s32 i; Actor* actor; Player* player = GET_PLAYER(play); - u32* tmp; + u32* categoryFreezeMaskP; s32 cat; Actor* next; ActorListEntry* entry; @@ -2442,7 +2477,7 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { params.player = player; params.play = play; - if (play->unk_18844 != 0) { + if (play->unk_18844) { params.unk_18 = ACTOR_FLAG_200000; } else { params.unk_18 = ACTOR_FLAG_200000 | ACTOR_FLAG_40 | ACTOR_FLAG_10; @@ -2454,22 +2489,23 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { actorCtx->unk2--; } - tmp = D_801AED58; + categoryFreezeMaskP = sCategoryFreezeMasks; if (player->stateFlags2 & PLAYER_STATE2_8000000) { - params.unk_08 = 0x2000000; + params.requiredActorFlag = ACTOR_FLAG_2000000; } else { - params.unk_08 = 0; + params.requiredActorFlag = 0; } if ((player->stateFlags1 & PLAYER_STATE1_40) && ((player->actor.textId & 0xFF00) != 0x1900)) { - params.unk10 = player->talkActor; + params.talkActor = player->talkActor; } else { - params.unk10 = NULL; + params.talkActor = NULL; } - for (i = 0, entry = actorCtx->actorLists; i < ARRAY_COUNT(actorCtx->actorLists); entry++, tmp++, i++) { - params.unkC = *tmp & player->stateFlags1; + for (i = 0, entry = actorCtx->actorLists; i < ARRAY_COUNT(actorCtx->actorLists); + entry++, categoryFreezeMaskP++, i++) { + params.canFreezeCategory = *categoryFreezeMaskP & player->stateFlags1; params.actor = entry->first; while (params.actor != NULL) { @@ -2477,7 +2513,7 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { } if (i == ACTORCAT_BG) { - DynaPoly_Setup(play, &play->colCtx.dyna); + DynaPoly_UpdateContext(play, &play->colCtx.dyna); } } @@ -2520,7 +2556,7 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { } TitleCard_Update(&play->state, &actorCtx->titleCtxt); - func_800B6474(play); + Actor_UpdatePlayerImpact(play); DynaPoly_UpdateBgActorTransforms(play, &play->colCtx.dyna); } @@ -2538,7 +2574,7 @@ void Actor_Draw(PlayState* play, Actor* actor) { (actor->flags & (ACTOR_FLAG_10000000 | ACTOR_FLAG_400000)) ? NULL : &actor->world.pos, play); Lights_Draw(light, play->state.gfxCtx); - if (actor->flags & ACTOR_FLAG_1000) { + if (actor->flags & ACTOR_FLAG_IGNORE_QUAKE) { Matrix_SetTranslateRotateYXZ(actor->world.pos.x + play->mainCamera.quakeOffset.x, actor->world.pos.y + ((actor->shape.yOffset * actor->scale.y) + play->mainCamera.quakeOffset.y), @@ -2555,31 +2591,33 @@ void Actor_Draw(PlayState* play, Actor* actor) { gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[actor->objBankIndex].segment); if (actor->colorFilterTimer != 0) { - s32 temp_v0_2 = actor->colorFilterParams & 0xC000; + s32 colorFlag = COLORFILTER_GET_COLORFLAG(actor->colorFilterParams); Color_RGBA8 actorDefaultHitColor = { 0, 0, 0, 255 }; - if (temp_v0_2 == 0x8000) { + if (colorFlag == COLORFILTER_COLORFLAG_GRAY) { 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) { + COLORFILTER_GET_COLORINTENSITY(actor->colorFilterParams) | 7; + } else if (colorFlag == COLORFILTER_COLORFLAG_RED) { + actorDefaultHitColor.r = COLORFILTER_GET_COLORINTENSITY(actor->colorFilterParams) | 7; + } else if (colorFlag == COLORFILTER_COLORFLAG_NONE) { actorDefaultHitColor.b = actorDefaultHitColor.g = actorDefaultHitColor.r = 0; } else { - actorDefaultHitColor.b = ((actor->colorFilterParams & 0x1F00) >> 5) | 7; + actorDefaultHitColor.b = COLORFILTER_GET_COLORINTENSITY(actor->colorFilterParams) | 7; } - if (actor->colorFilterParams & 0x2000) { - func_800AE778(play, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); + if (actor->colorFilterParams & COLORFILTER_BUFFLAG_XLU) { + func_800AE778(play, &actorDefaultHitColor, actor->colorFilterTimer, + COLORFILTER_GET_DURATION(actor->colorFilterParams)); } else { - func_800AE434(play, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); + func_800AE434(play, &actorDefaultHitColor, actor->colorFilterTimer, + COLORFILTER_GET_DURATION(actor->colorFilterParams)); } } actor->draw(actor, play); if (actor->colorFilterTimer != 0) { - if (actor->colorFilterParams & 0x2000) { + if (actor->colorFilterParams & COLORFILTER_BUFFLAG_XLU) { func_800AE8EC(play); } else { func_800AE5A0(play); @@ -2615,26 +2653,26 @@ void func_800B9D1C(Actor* actor) { if (sfxId) {} if (actor->audioFlags & 0x40) { - func_801A1FB4(3, &actor->projectedPos, NA_BGM_MUSIC_BOX_HOUSE, 1500.0f); + func_801A1FB4(SEQ_PLAYER_BGM_SUB, &actor->projectedPos, NA_BGM_MUSIC_BOX_HOUSE, 1500.0f); } if (actor->audioFlags & 0x20) { - func_801A1FB4(0, &actor->projectedPos, NA_BGM_KAMARO_DANCE, 900.0f); + func_801A1FB4(SEQ_PLAYER_BGM_MAIN, &actor->projectedPos, NA_BGM_KAMARO_DANCE, 900.0f); } } -void Actor_DrawAllSetup(PlayState* play) { - play->actorCtx.undrawnActorCount = 0; +void Actor_ResetLensActors(PlayState* play) { + play->actorCtx.numLensActors = 0; play->actorCtx.lensActorsDrawn = false; } -s32 Actor_RecordUndrawnActor(PlayState* play, Actor* actor) { - if (play->actorCtx.undrawnActorCount >= 32) { +s32 Actor_AddToLensActors(PlayState* play, Actor* actor) { + if (play->actorCtx.numLensActors >= LENS_ACTOR_MAX) { return false; } - play->actorCtx.undrawnActors[play->actorCtx.undrawnActorCount] = actor; - play->actorCtx.undrawnActorCount++; + play->actorCtx.lensActors[play->actorCtx.numLensActors] = actor; + play->actorCtx.numLensActors++; return true; } @@ -2643,125 +2681,126 @@ void Actor_DrawLensOverlay(Gfx** gfxP, s32 lensMaskSize) { ((LENS_MASK_ACTIVE_SIZE - lensMaskSize) * 0.003f) + 1.0f); } -void Actor_DrawLensActors(PlayState* play, s32 numInvisibleActors, Actor** invisibleActors) { +void Actor_DrawLensActors(PlayState* play, s32 numLensActors, Actor** lensActors) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + Actor** lensActor; + s32 i; + Gfx* gfx; + Gfx* gfxTemp; + void* zbuffer; + void* spA4; s32 dbgVar1; s32 dbgVar2; - s32 spB4; - Actor** invisibleActor; - Gfx* spAC; - void* spA8; - void* spA4; - GraphicsContext* gfxCtx = play->state.gfxCtx; - Gfx* tmp; s32 pad[2]; + // Remnant of debug dbgVar1 = true; dbgVar2 = true; if (dbgVar1) { - dbgVar1 = numInvisibleActors > 0; + dbgVar1 = (numLensActors > 0); } OPEN_DISPS(gfxCtx); if (dbgVar1) { - tmp = POLY_XLU_DISP; - spA8 = gfxCtx->zbuffer; + gfx = POLY_XLU_DISP; + zbuffer = gfxCtx->zbuffer; spA4 = play->unk_18E68; if (dbgVar2) { - PreRender_SetValues(&play->pauseBgPreRender, D_801FBBCC, D_801FBBCE, gfxCtx->curFrameBuffer, spA8); + PreRender_SetValues(&play->pauseBgPreRender, D_801FBBCC, D_801FBBCE, gfxCtx->curFrameBuffer, zbuffer); - spAC = tmp; - func_80170200(&play->pauseBgPreRender, &spAC, spA8, spA4); - tmp = spAC; + gfxTemp = gfx; + func_80170200(&play->pauseBgPreRender, &gfxTemp, zbuffer, spA4); + gfx = gfxTemp; } - gDPPipeSync(tmp++); - gDPSetPrimDepth(tmp++, 0, 0); + gDPPipeSync(gfx++); + gDPSetPrimDepth(gfx++, 0, 0); - gDPSetOtherMode(tmp++, + gDPSetOtherMode(gfx++, 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)); - gDPSetPrimColor(tmp++, 0, 0, 0, 0, 0, 255); + gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 255); - if (play->roomCtx.curRoom.unk5 == 0) { - gDPSetCombineLERP(tmp++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, + if (play->roomCtx.curRoom.lensMode == LENS_MODE_HIDE_ACTORS) { + gDPSetCombineLERP(gfx++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0); } else { - gDPSetCombineMode(tmp++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetCombineMode(gfx++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); } - spAC = tmp; - Actor_DrawLensOverlay(&spAC, play->actorCtx.lensMaskSize); - tmp = func_801660B8(play, spAC); + gfxTemp = gfx; + Actor_DrawLensOverlay(&gfxTemp, play->actorCtx.lensMaskSize); + gfx = Play_SetFog(play, gfxTemp); - for (spB4 = 0, invisibleActor = invisibleActors; spB4 < numInvisibleActors; spB4++, invisibleActor++) { - POLY_XLU_DISP = tmp; - Actor_Draw(play, *invisibleActor); - tmp = POLY_XLU_DISP; + for (i = 0, lensActor = lensActors; i < numLensActors; i++, lensActor++) { + POLY_XLU_DISP = gfx; + Actor_Draw(play, *lensActor); + gfx = POLY_XLU_DISP; } if (dbgVar2) { - gDPPipeSync(tmp++); + gDPPipeSync(gfx++); - gDPSetOtherMode(tmp++, + gDPSetOtherMode(gfx++, 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)); - gDPSetBlendColor(tmp++, 255, 255, 255, 0); - gDPSetPrimColor(tmp++, 0, 0xFF, 0, 0, 0, 32); + gDPSetBlendColor(gfx++, 255, 255, 255, 0); + gDPSetPrimColor(gfx++, 0, 0xFF, 0, 0, 0, 32); - if (play->roomCtx.curRoom.unk5 == 0) { - gDPSetCombineMode(tmp++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + if (play->roomCtx.curRoom.lensMode == LENS_MODE_HIDE_ACTORS) { + gDPSetCombineMode(gfx++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); } else { - gDPSetCombineLERP(tmp++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, + gDPSetCombineLERP(gfx++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0); } - gDPSetColorImage(tmp++, G_IM_FMT_RGBA, G_IM_SIZ_16b, play->pauseBgPreRender.width, spA4); + gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, play->pauseBgPreRender.width, spA4); - spAC = tmp; - Actor_DrawLensOverlay(&spAC, play->actorCtx.lensMaskSize); - tmp = spAC; + gfxTemp = gfx; + Actor_DrawLensOverlay(&gfxTemp, play->actorCtx.lensMaskSize); + gfx = gfxTemp; - gDPPipeSync(tmp++); - gDPSetBlendColor(tmp++, 255, 255, 255, 8); + gDPPipeSync(gfx++); + gDPSetBlendColor(gfx++, 255, 255, 255, 8); - gDPSetColorImage(tmp++, G_IM_FMT_RGBA, G_IM_SIZ_16b, play->pauseBgPreRender.width, + gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, play->pauseBgPreRender.width, play->pauseBgPreRender.fbuf); - spAC = tmp; - func_8016FDB8(&play->pauseBgPreRender, &spAC, (void*)spA4, spA8, 1); - tmp = spAC; + gfxTemp = gfx; + func_8016FDB8(&play->pauseBgPreRender, &gfxTemp, spA4, zbuffer, 1); + gfx = gfxTemp; } - POLY_XLU_DISP = tmp; + POLY_XLU_DISP = gfx; } - tmp = OVERLAY_DISP; + gfx = OVERLAY_DISP; - gDPPipeSync(tmp++); + gDPPipeSync(gfx++); - gDPSetOtherMode(tmp++, + gDPSetOtherMode(gfx++, 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); - gDPSetCombineLERP(tmp++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, + gDPSetCombineLERP(gfx++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0); - gDPSetPrimColor(tmp++, 0, 0, 74, 0, 0, 74); + gDPSetPrimColor(gfx++, 0, 0, 74, 0, 0, 74); - spAC = tmp; - Actor_DrawLensOverlay(&spAC, play->actorCtx.lensMaskSize); - OVERLAY_DISP = spAC; + gfxTemp = gfx; + Actor_DrawLensOverlay(&gfxTemp, play->actorCtx.lensMaskSize); + OVERLAY_DISP = gfxTemp; CLOSE_DISPS(gfxCtx); } @@ -2779,9 +2818,9 @@ s32 func_800BA2FC(PlayState* play, Actor* actor, Vec3f* projectedPos, f32 projec f32 phi_f16; if (play->view.fovy != 60.0f) { - phi_f12 = actor->uncullZoneScale * play->unk_187F0.x * 0.76980036f; // sqrt(16/27) + phi_f12 = actor->uncullZoneScale * play->projectionMtxFDiagonal.x * 0.76980036f; // sqrt(16/27) - phi_f14 = play->unk_187F0.y * 0.57735026f; // 1 / sqrt(3) + phi_f14 = play->projectionMtxFDiagonal.y * 0.57735026f; // 1 / sqrt(3) phi_f16 = actor->uncullZoneScale * phi_f14; phi_f14 *= actor->uncullZoneDownward; } else { @@ -2809,7 +2848,7 @@ void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) { s32 actorFlags; s32 i; - if (play->unk_18844 != 0) { + if (play->unk_18844) { actorFlags = ACTOR_FLAG_200000; } else { actorFlags = ACTOR_FLAG_200000 | ACTOR_FLAG_40 | ACTOR_FLAG_20; @@ -2817,7 +2856,7 @@ void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) { OPEN_DISPS(play->state.gfxCtx); - Actor_DrawAllSetup(play); + Actor_ResetLensActors(play); sp58 = POLY_XLU_DISP; POLY_XLU_DISP = &sp58[1]; @@ -2841,10 +2880,11 @@ void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) { actor->isDrawn = false; if ((actor->init == NULL) && (actor->draw != NULL) && (actor->flags & actorFlags)) { - if ((actor->flags & ACTOR_FLAG_80) && - ((play->roomCtx.curRoom.unk5 == 0) || (play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) || + if ((actor->flags & ACTOR_FLAG_REACT_TO_LENS) && + ((play->roomCtx.curRoom.lensMode == LENS_MODE_HIDE_ACTORS) || + (play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) || (actor->room != play->roomCtx.curRoom.num))) { - if (Actor_RecordUndrawnActor(play, actor)) {} + if (Actor_AddToLensActors(play, actor)) {} } else { Actor_Draw(play, actor); } @@ -2870,9 +2910,10 @@ void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) { } else { Math_StepToC(&play->actorCtx.lensMaskSize, 0, 10); } + if (play->actorCtx.lensMaskSize != 0) { play->actorCtx.lensActorsDrawn = true; - Actor_DrawLensActors(play, play->actorCtx.undrawnActorCount, play->actorCtx.undrawnActors); + Actor_DrawLensActors(play, play->actorCtx.numLensActors, play->actorCtx.lensActors); } tmp2 = POLY_XLU_DISP; @@ -2880,7 +2921,7 @@ void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) { gSPBranchList(ref2, &tmp2[1]); POLY_XLU_DISP = &tmp2[1]; - if (play->unk_18844 == 0) { + if (!play->unk_18844) { Lights_DrawGlow(play); } @@ -2890,9 +2931,9 @@ void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) { } /** - * Kills every actor which its object is not loaded + * Kill every actor which depends on an object that is not loaded. */ -void func_800BA6FC(PlayState* play, ActorContext* actorCtx) { +void Actor_KillAllWithMissingObject(PlayState* play, ActorContext* actorCtx) { Actor* actor; s32 i; @@ -2942,15 +2983,19 @@ void func_800BA798(PlayState* play, ActorContext* actorCtx) { play->msgCtx.unk_12030 = 0; } -void func_800BA8B8(PlayState* play, ActorContext* actorCtx) { +/** + * Kill every actor which does not have the current halfDayBit enabled + */ +void Actor_KillAllOnHalfDayChange(PlayState* play, 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)) { + if (!(actor->halfDaysBits & actorCtx->halfDaysBit)) { func_80123590(play, actor); + if (!actor->isDrawn) { actor = Actor_Delete(actorCtx, actor, play); } else { @@ -3078,8 +3123,8 @@ void Actor_FreeOverlay(ActorOverlay* entry) { Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params) { - return Actor_SpawnAsChildAndCutscene(actorCtx, play, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1, 0x3FF, - NULL); + return Actor_SpawnAsChildAndCutscene(actorCtx, play, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, + CS_ID_NONE, HALFDAYBIT_ALL, NULL); } ActorInit* Actor_LoadOverlay(ActorContext* actorCtx, s16 index) { @@ -3123,7 +3168,7 @@ ActorInit* Actor_LoadOverlay(ActorContext* actorCtx, s16 index) { } Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s16 index, f32 x, f32 y, f32 z, s16 rotX, - s16 rotY, s16 rotZ, s32 params, u32 cutscene, s32 arg11, Actor* parent) { + s16 rotY, s16 rotZ, s32 params, u32 csId, u32 halfDaysBits, Actor* parent) { s32 pad; Actor* actor; ActorInit* actorInit; @@ -3189,16 +3234,16 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s1 actor->home.rot.y = rotY; actor->home.rot.z = rotZ; actor->params = params & 0xFFFF; - actor->cutscene = (cutscene & 0x7F); + actor->csId = csId & 0x7F; - if (actor->cutscene == 0x7F) { - actor->cutscene = -1; + if (actor->csId == 0x7F) { + actor->csId = CS_ID_NONE; } - if (arg11 != 0) { - actor->unk20 = arg11; + if (halfDaysBits != 0) { + actor->halfDaysBits = halfDaysBits; } else { - actor->unk20 = 0x3FF; + actor->halfDaysBits = HALFDAYBIT_ALL; } Actor_AddToCategory(actorCtx, actor, actorInit->type); @@ -3215,8 +3260,8 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s1 Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, PlayState* play, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params) { - return Actor_SpawnAsChildAndCutscene(actorCtx, play, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1, - parent->unk20, parent); + return Actor_SpawnAsChildAndCutscene(actorCtx, play, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, + CS_ID_NONE, parent->halfDaysBits, parent); } void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx) { @@ -3232,13 +3277,13 @@ void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx) { (transitionActorList->sides[1].room >= 0 && (play->roomCtx.curRoom.num == transitionActorList->sides[1].room || play->roomCtx.prevRoom.num == transitionActorList->sides[1].room))) { - s16 rotY = ((transitionActorList->rotY >> 7) & 0x1FF) * (0x10000 / 360.0f); + s16 rotY = DEG_TO_BINANG((transitionActorList->rotY >> 7) & 0x1FF); if (Actor_SpawnAsChildAndCutscene(actorCtx, play, 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->rotY & 0x7F, HALFDAYBIT_ALL, 0) != NULL) { transitionActorList->id = -transitionActorList->id; } numTransitionActors = play->transitionActors.count; @@ -3253,19 +3298,19 @@ Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, PlayStat s16 rotZ = (actorEntry->rot.z >> 7) & 0x1FF; if (!(actorEntry->id & 0x8000)) { - rotY *= 0x10000 / 360.0f; + rotY = DEG_TO_BINANG(rotY); } else if (rotY > 180) { rotY -= 360; } if (!(actorEntry->id & 0x4000)) { - rotX *= 0x10000 / 360.0f; + rotX = DEG_TO_BINANG(rotX); } else if (rotX > 180) { rotX -= 360; } if (!(actorEntry->id & 0x2000)) { - rotZ *= 0x10000 / 360.0f; + rotZ = DEG_TO_BINANG(rotZ); } else if (rotZ > 180) { rotZ -= 360; } @@ -3347,7 +3392,7 @@ void func_800BB604(GameState* gameState, ActorContext* actorCtx, Player* player, if ((actor != targetedActor) || (actor->flags & ACTOR_FLAG_80000)) { temp_f0_2 = func_800B82EC(actor, player, D_801ED8DC); - phi_s2_2 = (actor->flags & 1) != 0; + phi_s2_2 = (actor->flags & ACTOR_FLAG_1) != 0; if (phi_s2_2) { phi_s2_2 = temp_f0_2 < D_801ED8C8; } @@ -3490,16 +3535,16 @@ s16 func_800BBC20(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3) { return arg0[0]; } -void Actor_SpawnBodyParts(Actor* actor, PlayState* play, s32 arg2, Gfx** dList) { - EnPart* part; - Actor* spawnedPart; - MtxF* currentMatrix; - +void Actor_SpawnBodyParts(Actor* actor, PlayState* play, s32 partParams, Gfx** dList) { if (*dList != NULL) { - currentMatrix = Matrix_GetCurrent(); + EnPart* part; + Actor* spawnedPart; + MtxF* currentMatrix = Matrix_GetCurrent(); + spawnedPart = Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_EN_PART, currentMatrix->mf[3][0], - currentMatrix->mf[3][1], currentMatrix->mf[3][2], 0, 0, actor->objBankIndex, arg2); + currentMatrix->mf[3][1], currentMatrix->mf[3][2], 0, 0, actor->objBankIndex, partParams); + if (spawnedPart != NULL) { part = (EnPart*)spawnedPart; @@ -3568,21 +3613,29 @@ void func_800BC154(PlayState* play, ActorContext* actorCtx, Actor* actor, u8 act } // Damage flags for EnArrow -s32 D_801AEDB0[] = { - 0x800, 0x20, 0x20, 0x800, 0x1000, 0x2000, 0x1, 0x10000, 0x1, +u32 sArrowDmgFlags[] = { + DMG_FIRE_ARROW, // ENARROW_0 + DMG_NORMAL_ARROW, // ENARROW_1 + DMG_NORMAL_ARROW, // ENARROW_2 + DMG_FIRE_ARROW, // ENARROW_3 + DMG_ICE_ARROW, // ENARROW_4 + DMG_LIGHT_ARROW, // ENARROW_5 + DMG_DEKU_NUT, // ENARROW_6 + DMG_DEKU_BUBBLE, // ENARROW_7 + DMG_DEKU_NUT, // ENARROW_8 }; -s32 func_800BC188(s32 index) { - if ((index < 0) || (index >= ARRAY_COUNT(D_801AEDB0))) { +u32 Actor_GetArrowDmgFlags(s32 params) { + if ((params < 0) || (params >= ARRAY_COUNT(sArrowDmgFlags))) { return 0; } - return D_801AEDB0[index]; + return sArrowDmgFlags[params]; } -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); +s32 func_800BC1B4(Actor* actor, Actor* projectile, f32 distance, f32 speed) { + if ((speed > 0.0f) && (Actor_WorldDistXYZToActor(projectile, actor) < ((speed * 2.5f) + distance))) { + s16 temp_v1 = BINANG_SUB(Actor_WorldYawTowardActor(projectile, actor), projectile->world.rot.y); if (ABS_ALT(temp_v1) < 0x1400) { return true; @@ -3592,36 +3645,36 @@ s32 func_800BC1B4(Actor* actor, Actor* arg1, f32 arg2, f32 arg3) { return false; } -Actor* func_800BC270(PlayState* play, Actor* actor, f32 arg2, s32 arg3) { +Actor* func_800BC270(PlayState* play, Actor* actor, f32 distance, u32 dmgFlags) { Actor* itemAction = play->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->id == ACTOR_ARMS_HOOK) && (dmgFlags & DMG_HOOKSHOT)) || + ((itemAction->id == ACTOR_EN_BOOM) && (dmgFlags & DMG_ZORA_BOOMERANG)) || + ((itemAction->id == ACTOR_EN_ARROW) && (Actor_GetArrowDmgFlags(itemAction->params) & dmgFlags))) { + f32 speed; - if ((itemAction->speedXZ <= 0.0f) && (GET_PLAYER(play)->unk_D57 != 0)) { + if ((itemAction->speed <= 0.0f) && (GET_PLAYER(play)->unk_D57 != 0)) { if (itemAction->id == ACTOR_ARMS_HOOK) { - speedXZ = 20.0f; + speed = 20.0f; } else if (itemAction->id == ACTOR_EN_BOOM) { - speedXZ = 12.0f; + speed = 12.0f; } else { - s32 temp_v0_3 = func_800BC188(itemAction->params); + u32 arrowDmgFlags = Actor_GetArrowDmgFlags(itemAction->params); - if (temp_v0_3 == 1) { - speedXZ = 80.0f; - } else if (temp_v0_3 == 0x10000) { - speedXZ = 60.0f; + if (arrowDmgFlags == DMG_DEKU_NUT) { + speed = 80.0f; + } else if (arrowDmgFlags == DMG_DEKU_BUBBLE) { + speed = 60.0f; } else { - speedXZ = 150.0f; + speed = 150.0f; } } } else { - speedXZ = itemAction->speedXZ; + speed = itemAction->speed; } - if (func_800BC1B4(actor, itemAction, arg2, speedXZ)) { + if (func_800BC1B4(actor, itemAction, distance, speed)) { break; } } @@ -3632,13 +3685,13 @@ Actor* func_800BC270(PlayState* play, Actor* actor, f32 arg2, s32 arg3) { return itemAction; } -Actor* func_800BC444(PlayState* play, Actor* actor, f32 arg2) { +Actor* func_800BC444(PlayState* play, Actor* actor, f32 distance) { Actor* explosive = play->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)) { + if (func_800BC1B4(actor, explosive, distance, explosive->speed)) { break; } } @@ -3671,10 +3724,10 @@ s16 Actor_TestFloorInDirection(Actor* actor, PlayState* play, f32 distance, s16 actor->world.pos.x += dx; actor->world.pos.z += dz; - Actor_UpdateBgCheckInfo(play, actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); Math_Vec3f_Copy(&actor->world.pos, &actorPos); - ret = actor->bgCheckFlags & 1; + ret = actor->bgCheckFlags & BGCHECKFLAG_GROUND; actor->bgCheckFlags = bgCheckFlags; @@ -3707,29 +3760,30 @@ s32 Actor_OtherIsTargeted(PlayState* play, Actor* actor) { return false; } -void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play) { - MtxF sp58; - f32 sp54; - Vec3f sp48; - CollisionPoly* sp44; +void func_800BC620(Vec3f* pos, Vec3f* scale, u8 alpha, PlayState* play) { + MtxF mf; + f32 yIntersect; + Vec3f adjustedPos; + CollisionPoly* poly; OPEN_DISPS(play->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; + adjustedPos.x = pos->x; + adjustedPos.y = pos->y + 1.0f; + adjustedPos.z = pos->z; - sp54 = BgCheck_EntityRaycastFloor2(play, &play->colCtx, &sp44, &sp48); - if (sp44 != NULL) { - func_800C0094(sp44, arg0->x, sp54, arg0->z, &sp58); - Matrix_Put(&sp58); + yIntersect = BgCheck_EntityRaycastFloor2(play, &play->colCtx, &poly, &adjustedPos); + if (poly != NULL) { + func_800C0094(poly, pos->x, yIntersect, pos->z, &mf); + Matrix_Put(&mf); } else { - Matrix_Translate(arg0->x, arg0->y, arg0->z, MTXMODE_NEW); + Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_NEW); } - Matrix_Scale(arg1->x, 1.0f, arg1->z, MTXMODE_APPLY); + + Matrix_Scale(scale->x, 1.0f, scale->z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gCircleShadowDL); @@ -3737,30 +3791,29 @@ void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -void Actor_AddQuake(PlayState* play, s16 verticalMag, s16 countdown) { - s16 quakeIndex = Quake_Add(&play->mainCamera, QUAKE_TYPE_3); +void Actor_RequestQuake(PlayState* play, s16 y, s16 duration) { + s16 quakeIndex = Quake_Request(&play->mainCamera, QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 20000); - Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0); - Quake_SetCountdown(quakeIndex, countdown); + Quake_SetPerturbations(quakeIndex, y, 0, 0, 0); + Quake_SetDuration(quakeIndex, duration); } -void Actor_AddQuakeWithSpeed(PlayState* play, s16 verticalMag, s16 countdown, s16 speed) { - s16 quakeIndex = Quake_Add(&play->mainCamera, QUAKE_TYPE_3); +void Actor_RequestQuakeWithSpeed(PlayState* play, s16 y, s16 duration, s16 speed) { + s16 quakeIndex = Quake_Request(&play->mainCamera, QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, speed); - Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0); - Quake_SetCountdown(quakeIndex, countdown); + Quake_SetPerturbations(quakeIndex, y, 0, 0, 0); + Quake_SetDuration(quakeIndex, duration); } -// Actor_RequestRumble? -void func_800BC848(Actor* actor, PlayState* play, s16 y, s16 countdown) { - if (y >= 5) { +void Actor_RequestQuakeAndRumble(Actor* actor, PlayState* play, s16 quakeY, s16 quakeDuration) { + if (quakeY >= 5) { Rumble_Request(actor->xyzDistToPlayerSq, 255, 20, 150); } else { Rumble_Request(actor->xyzDistToPlayerSq, 180, 20, 100); } - Actor_AddQuake(play, y, countdown); + Actor_RequestQuake(play, quakeY, quakeDuration); } typedef struct { @@ -3834,12 +3887,12 @@ void Actor_SpawnShieldParticlesMetal(PlayState* play, Vec3f* pos) { CollisionCheck_SpawnShieldParticlesMetal(play, 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); +void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 bufFlag, u16 duration) { + if ((colorFlag == COLORFILTER_COLORFLAG_GRAY) && !(colorIntensityMax & COLORFILTER_INTENSITY_FLAG)) { + Actor_PlaySfx(actor, NA_SE_EN_LIGHT_ARROW_HIT); } - actor->colorFilterParams = colorFlag | xluFlag | ((colorIntensityMax & 0xF8) << 5) | duration; + actor->colorFilterParams = colorFlag | bufFlag | ((colorIntensityMax & 0xF8) << 5) | duration; actor->colorFilterTimer = duration; } @@ -4008,170 +4061,285 @@ void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3 } } -// unused -s32 func_800BD2B4(PlayState* play, Actor* actor, s16* arg2, f32 arg3, u16 (*textIdCallback)(PlayState*, Actor*), - s16 (*arg5)(PlayState*, Actor*)) { +/** + * Updates NPC talking state. Checks for a talk request and updates + * the talkState parameter when a dialog is ongoing. Otherwise checks if + * the actor is onscreen, advertises the interaction in a range and sets + * the current text id if necessary. + * + * The talk state values are defined in the NpcTalkState enum. + * + * @see NpcTalkState + * + * @param[in,out] talkState Talk state + * @param interactRange The interact (talking) range for the actor + * @param getTextId Callback for getting the next text id + * @param updateTalkState Callback for getting the next talkState value + * @return True if a new dialog was started (player talked to the actor). False otherwise. + */ +s32 Npc_UpdateTalking(PlayState* play, Actor* actor, s16* talkState, f32 interactRange, NpcGetTextIdFunc getTextId, + NpcUpdateTalkStateFunc updateTalkState) { if (Actor_ProcessTalkRequest(actor, &play->state)) { - *arg2 = true; + *talkState = NPC_TALK_STATE_TALKING; return true; - } else if (*arg2) { - *arg2 = arg5(play, actor); - return false; - } else if (!Actor_OnScreen(play, actor)) { - return false; - } else if (!func_800B8614(actor, play, arg3)) { - return false; - } else { - actor->textId = textIdCallback(play, actor); + } + + if (*talkState != NPC_TALK_STATE_IDLE) { + *talkState = updateTalkState(play, actor); return false; } + + if (!Actor_OnScreen(play, actor)) { + return false; + } + + if (!func_800B8614(actor, play, interactRange)) { + return false; + } + + actor->textId = getTextId(play, 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 + /* 0x0 */ s16 maxHeadYaw; + /* 0x2 */ s16 minHeadPitch; + /* 0x4 */ s16 maxHeadPitch; + /* 0x6 */ s16 maxTorsoYaw; + /* 0x8 */ s16 minTorsoPitch; + /* 0xA */ s16 maxTorsoPitch; + /* 0xC */ u8 rotateYaw; +} NpcTrackingRotLimits; // size = 0x10 typedef struct { - /* 0x00 */ struct_801AEE38_0 sub_00; - /* 0x10 */ f32 unk_10; - /* 0x14 */ s16 unk_14; -} struct_801AEE38; // size = 0x18 + /* 0x00 */ NpcTrackingRotLimits rotLimits; + // Fields specific to NPC_TRACKING_PLAYER_AUTO_TURN mode + /* 0x10 */ f32 autoTurnDistanceRange; // Max distance to player to enable tracking and auto-turn + /* 0x14 */ s16 maxYawForPlayerTracking; // Player is tracked if within this yaw +} NpcTrackingParams; // 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 }, +/** + * Npc tracking angle limit presets to use with Npc_TrackPoint. + * + * @see Npc_TrackPoint + */ +NpcTrackingParams sNpcTrackingPresets[] = { + { { 0x1C20, 0xE390, 0x1C70, 0x1554, 0x0000, 0x0000, false }, 170.0f, 0x3FFC }, + { { 0x2AA8, 0xEAAC, 0x1554, 0x1554, 0xF8E4, 0x0E38, true }, 170.0f, 0x3FFC }, + { { 0x31C4, 0xE390, 0x0E38, 0x0E38, 0xF1C8, 0x071C, true }, 170.0f, 0x3FFC }, + { { 0x1554, 0xF1C8, 0x0000, 0x071C, 0xF8E4, 0x0000, true }, 170.0f, 0x3FFC }, + { { 0x2AA8, 0xF8E4, 0x071C, 0x0E38, 0xD558, 0x2AA8, true }, 170.0f, 0x3FFC }, + { { 0x0000, 0xE390, 0x2AA8, 0x3FFC, 0xF1C8, 0x0E38, true }, 170.0f, 0x3FFC }, + { { 0x2AA8, 0xF1C8, 0x0E38, 0x0E38, 0x0000, 0x0000, true }, 0.0f, 0x0000 }, + { { 0x2AA8, 0xF1C8, 0x0000, 0x0E38, 0x0000, 0x1C70, true }, 0.0f, 0x0000 }, + { { 0x2AA8, 0xF1C8, 0xF1C8, 0x0000, 0x0000, 0x0000, true }, 0.0f, 0x0000 }, + { { 0x071C, 0xF1C8, 0x0E38, 0x1C70, 0x0000, 0x0000, true }, 0.0f, 0x0000 }, + { { 0x0E38, 0xF1C8, 0x0000, 0x1C70, 0x0000, 0x0E38, true }, 0.0f, 0x0000 }, + { { 0x2AA8, 0xE390, 0x1C70, 0x0E38, 0xF1C8, 0x0E38, true }, 0.0f, 0x0000 }, + { { 0x18E2, 0xF1C8, 0x0E38, 0x0E38, 0x0000, 0x0000, true }, 0.0f, 0x0000 }, + { { 0x2A6C, 0xE390, 0x1C70, 0x1554, 0x0000, 0x0000, false }, 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; +/** + * Smoothly turns the actor's whole body and updates torso and head rotations in + * NpcInteractInfo so that the actor tracks the point specified in NpcInteractInfo.trackPos. + * Rotations are limited to specified angles. + * + * Head and torso rotation angles are determined by calculating the pitch and yaw + * from the actor position to the given target position. + * + * The y position of the actor is offset by NpcInteractInfo.yOffset + * before calculating the angles. It can be used to configure the height difference + * between the actor and the target. + * + * @param maxHeadYaw maximum head yaw difference from neutral position + * @param maxHeadPitch maximum head pitch angle + * @param minHeadPitch minimum head pitch angle + * @param maxTorsoYaw maximum torso yaw difference from neutral position + * @param maxTorsoPitch maximum torso pitch angle + * @param minTorsoPitch minimum torso pitch angle + * @param rotateYaw if true, the actor's yaw (shape.rot.y) is updated to turn the actor's whole body + */ +void Npc_TrackPointWithLimits(Actor* actor, NpcInteractInfo* interactInfo, s16 maxHeadYaw, s16 maxHeadPitch, + s16 minHeadPitch, s16 maxTorsoYaw, s16 maxTorsoPitch, s16 minTorsoPitch, u8 rotateYaw) { + s16 pitchTowardsTarget; + s16 yawTowardsTarget; + s16 torsoPitch; + s16 bodyYawDiff; + s16 temp; + Vec3f offsetActorPos; - sp30.x = actor->world.pos.x; - sp30.y = actor->world.pos.y + arg1->unk_14; - sp30.z = actor->world.pos.z; + offsetActorPos.x = actor->world.pos.x; + offsetActorPos.y = actor->world.pos.y + interactInfo->yOffset; + offsetActorPos.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; + pitchTowardsTarget = Math_Vec3f_Pitch(&offsetActorPos, &interactInfo->trackPos); + yawTowardsTarget = Math_Vec3f_Yaw(&offsetActorPos, &interactInfo->trackPos); + bodyYawDiff = Math_Vec3f_Yaw(&actor->world.pos, &interactInfo->trackPos) - actor->shape.rot.y; - temp1 = CLAMP(sp40, -arg2, arg2); - Math_SmoothStepToS(&arg1->unk_08.y, temp1, 6, 2000, 1); + temp = CLAMP(bodyYawDiff, -maxHeadYaw, maxHeadYaw); + Math_SmoothStepToS(&interactInfo->headRot.y, temp, 6, 0x7D0, 1); - temp1 = (ABS_ALT(sp40) >= 0x8000) ? 0 : ABS_ALT(sp40); - arg1->unk_08.y = CLAMP(arg1->unk_08.y, -temp1, temp1); + temp = (ABS_ALT(bodyYawDiff) >= 0x8000) ? 0 : ABS_ALT(bodyYawDiff); + interactInfo->headRot.y = CLAMP(interactInfo->headRot.y, -temp, temp); - sp40 -= arg1->unk_08.y; + bodyYawDiff -= interactInfo->headRot.y; - temp1 = CLAMP(sp40, -arg5, arg5); - Math_SmoothStepToS(&arg1->unk_0E.y, temp1, 6, 2000, 1); + temp = CLAMP(bodyYawDiff, -maxTorsoYaw, maxTorsoYaw); + Math_SmoothStepToS(&interactInfo->torsoRot.y, temp, 6, 0x7D0, 1); - temp1 = (ABS_ALT(sp40) >= 0x8000) ? 0 : ABS_ALT(sp40); - arg1->unk_0E.y = CLAMP(arg1->unk_0E.y, -temp1, temp1); + temp = (ABS_ALT(bodyYawDiff) >= 0x8000) ? 0 : ABS_ALT(bodyYawDiff); + interactInfo->torsoRot.y = CLAMP(interactInfo->torsoRot.y, -temp, temp); - if (arg8) { - Math_SmoothStepToS(&actor->shape.rot.y, sp44, 6, 2000, 1); + if (rotateYaw) { + Math_SmoothStepToS(&actor->shape.rot.y, yawTowardsTarget, 6, 0x7D0, 1); } - temp1 = CLAMP(sp46, arg4, (s16)(u16)arg3); - Math_SmoothStepToS(&arg1->unk_08.x, temp1, 6, 2000, 1); + temp = CLAMP(pitchTowardsTarget, minHeadPitch, (s16)(u16)maxHeadPitch); + Math_SmoothStepToS(&interactInfo->headRot.x, temp, 6, 2000, 1); - temp2 = sp46 - arg1->unk_08.x; + torsoPitch = pitchTowardsTarget - interactInfo->headRot.x; - temp1 = CLAMP(temp2, arg7, arg6); - Math_SmoothStepToS(&arg1->unk_0E.x, temp1, 6, 2000, 1); + temp = CLAMP(torsoPitch, minTorsoPitch, maxTorsoPitch); + Math_SmoothStepToS(&interactInfo->torsoRot.x, temp, 6, 0x7D0, 1); } // unused -s16 func_800BD6B8(s16 arg0) { - return D_801AEE38[arg0].unk_14; +s16 Npc_GetTrackingPresetMaxPlayerYaw(s16 presetIndex) { + return sNpcTrackingPresets[presetIndex].maxYawForPlayerTracking; } -s16 func_800BD6E4(Actor* actor, struct_800BD888_arg1* arg1, f32 arg2, s16 arg3, s16 flag) { +/** + * Handles NPC tracking modes and auto-turning towards the player when + * NPC_TRACKING_PLAYER_AUTO_TURN tracking mode is used. + * + * Returns a tracking mode that will determine which actor limbs + * will be rotated towards the target. + * + * When the player is behind the actor (i.e. not in the yaw range in front of the actor + * defined by maxYawForPlayerTracking), the actor will start an auto-turn sequence: + * - look forward for 30-60 frames + * - turn head to look at the player for 10-20 frames + * - look forward for 30-60 frames + * - turn the entire body to face the player + * + * @param distanceRange Max distance to player that tracking and auto-turning will be active for + * @param maxYawForPlayerTracking Maximum angle for tracking the player. + * @param trackingMode The tracking mode selected by the actor. If this is not + * NPC_TRACKING_PLAYER_AUTO_TURN this function does nothing + * + * @return The tracking mode (NpcTrackingMode) to use for the current frame. + */ +s16 Npc_UpdateAutoTurn(Actor* actor, NpcInteractInfo* interactInfo, f32 distanceRange, s16 maxYawForPlayerTracking, + s16 trackingMode) { s32 pad; + s16 yaw; + s16 yawDiff; - 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 (trackingMode != NPC_TRACKING_PLAYER_AUTO_TURN) { + return trackingMode; + } - 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; + if (interactInfo->talkState != NPC_TALK_STATE_IDLE) { + // When talking, always fully turn to face the player + return NPC_TRACKING_FULL_BODY; + } - case 1: - arg1->unk_04 = Rand_S16Offset(10, 10); - arg1->unk_06++; - return 3; + if (distanceRange < Math_Vec3f_DistXYZ(&actor->world.pos, &interactInfo->trackPos)) { + // Player is too far away, do not track + interactInfo->autoTurnTimer = 0; + interactInfo->autoTurnState = 0; + return NPC_TRACKING_NONE; + } - default: - return 4; - } - } + yaw = Math_Vec3f_Yaw(&actor->world.pos, &interactInfo->trackPos); + yawDiff = ABS_ALT(BINANG_SUB(yaw, actor->shape.rot.y)); + + if (maxYawForPlayerTracking >= yawDiff) { + // Player is in front of the actor, track with the head and the torso + interactInfo->autoTurnTimer = 0; + interactInfo->autoTurnState = 0; + return NPC_TRACKING_HEAD_AND_TORSO; + } + + // Player is behind the actor, run the auto-turn sequence. + + if (DECR(interactInfo->autoTurnTimer) != 0) { + // While the timer is still running, return the previous tracking mode + return interactInfo->trackingMode; + } + + switch (interactInfo->autoTurnState) { + case 0: + case 2: + // Just stand still, not tracking the player + interactInfo->autoTurnTimer = Rand_S16Offset(30, 30); + interactInfo->autoTurnState++; + return NPC_TRACKING_NONE; + + case 1: + // Glance at the player by only turning the head + interactInfo->autoTurnTimer = Rand_S16Offset(10, 10); + interactInfo->autoTurnState++; + return NPC_TRACKING_HEAD; + + default: + // Auto-turn sequence complete, turn towards the player + return NPC_TRACKING_FULL_BODY; } } -// This function is very similar to OoT's func_80034A14 -void func_800BD888(Actor* actor, struct_800BD888_arg1* arg1, s16 arg2, s16 arg3) { - struct_801AEE38_0 sp38; +/** + * Rotates the actor's whole body, torso and head tracking the point specified in NpcInteractInfo.trackPos. + * Uses angle limits from a preset selected from from sNpcTrackingPresets. + * + * The trackingMode parameter controls whether the head and torso are turned towards the target. + * If not, they are smoothly turned towards zero. Setting the parameter to NPC_TRACKING_FULL_BODY + * causes the actor's whole body to be rotated to face the target. + * + * If NPC_TRACKING_PLAYER_AUTO_TURN is used, the actor will track the player with its head and torso as long + * as the player is in front of the actor (within a yaw angle specified in the option preset). + * If the player is outside of this angle, the actor will turn to face the player after a while. + * + * @see Npc_UpdateAutoTurn + * @see sNpcTrackingPresets + * @see NpcTrackingMode + * + * @param presetIndex The index to a preset in sNpcTrackingPresets + * @param trackingMode A value from NpcTrackingMode enum + */ +void Npc_TrackPoint(Actor* actor, NpcInteractInfo* interactInfo, s16 presetIndex, s16 trackingMode) { + NpcTrackingRotLimits rotLimits; - arg1->unk_02 = func_800BD6E4(actor, arg1, D_801AEE38[arg2].unk_10, D_801AEE38[arg2].unk_14, arg3); - sp38 = D_801AEE38[arg2].sub_00; + interactInfo->trackingMode = + Npc_UpdateAutoTurn(actor, interactInfo, sNpcTrackingPresets[presetIndex].autoTurnDistanceRange, + sNpcTrackingPresets[presetIndex].maxYawForPlayerTracking, trackingMode); - 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; + rotLimits = sNpcTrackingPresets[presetIndex].rotLimits; + + switch (interactInfo->trackingMode) { + case NPC_TRACKING_NONE: + rotLimits.maxHeadYaw = 0; + rotLimits.maxHeadPitch = 0; + rotLimits.minHeadPitch = 0; + // fallthrough + case NPC_TRACKING_HEAD: + rotLimits.maxTorsoYaw = 0; + rotLimits.maxTorsoPitch = 0; + rotLimits.minTorsoPitch = 0; + // fallthrough + case NPC_TRACKING_HEAD_AND_TORSO: + rotLimits.rotateYaw = false; + break; + + default: + break; } - 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); + Npc_TrackPointWithLimits(actor, interactInfo, rotLimits.maxHeadYaw, rotLimits.maxHeadPitch, rotLimits.minHeadPitch, + rotLimits.maxTorsoYaw, rotLimits.maxTorsoPitch, rotLimits.minTorsoPitch, + rotLimits.rotateYaw); } Gfx D_801AEF88[] = { @@ -4232,7 +4400,7 @@ s16 func_800BDB6C(Actor* actor, PlayState* play, s16 arg2, f32 arg3) { Player* player = GET_PLAYER(play); f32 phi_f2; - if ((play->csCtx.state != CS_STATE_0) || gDbgCamEnabled) { + if ((play->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) { phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &play->view.eye) * 0.25f; } else { phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &player->actor.world.pos); @@ -4293,7 +4461,7 @@ Actor* Actor_FindNearby(PlayState* play, Actor* inActor, s16 actorId, u8 actorCa continue; } - if (Actor_DistanceBetweenActors(inActor, actor) <= distance) { + if (Actor_WorldDistXYZToActor(inActor, actor) <= distance) { return actor; } @@ -4330,15 +4498,15 @@ void Actor_SetDropFlag(Actor* actor, ColliderInfo* colInfo) { ColliderInfo* acHitInfo = colInfo->acHitInfo; 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; + actor->dropFlag = DROPFLAG_NONE; + } else if (acHitInfo->toucher.dmgFlags & DMG_FIRE_ARROW) { + actor->dropFlag = DROPFLAG_1; + } else if (acHitInfo->toucher.dmgFlags & DMG_ICE_ARROW) { + actor->dropFlag = DROPFLAG_2; + } else if (acHitInfo->toucher.dmgFlags & DMG_LIGHT_ARROW) { + actor->dropFlag = DROPFLAG_20; } else { - actor->dropFlag = 0; + actor->dropFlag = DROPFLAG_NONE; } } @@ -4348,23 +4516,23 @@ void Actor_SetDropFlagJntSph(Actor* actor, ColliderJntSph* jntSphere) { ColliderInfo* acHitInfo; s32 flag; - actor->dropFlag = 0; + actor->dropFlag = DROPFLAG_NONE; for (i = jntSphere->count - 1; i >= 0; i--) { jntElement = &jntSphere->elements[i]; acHitInfo = jntElement->info.acHitInfo; if (acHitInfo == NULL) { - flag = 0; + flag = DROPFLAG_NONE; } else { s32 dmgFlags = acHitInfo->toucher.dmgFlags; - if (dmgFlags & 0x800) { - flag = 1; - } else if (dmgFlags & 0x1000) { - flag = 2; + if (dmgFlags & DMG_FIRE_ARROW) { + flag = DROPFLAG_1; + } else if (dmgFlags & DMG_ICE_ARROW) { + flag = DROPFLAG_2; } else { - flag = (dmgFlags & 0x2000) ? 0x20 : 0; + flag = (dmgFlags & DMG_LIGHT_ARROW) ? DROPFLAG_20 : DROPFLAG_NONE; } } @@ -4372,19 +4540,19 @@ void Actor_SetDropFlagJntSph(Actor* actor, ColliderJntSph* jntSphere) { } } -void func_800BE33C(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3) { +void func_800BE33C(Vec3f* arg0, Vec3f* arg1, Vec3s* dst, 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_Atan2S_XY(zDiff, xDiff); - arg2->x = Math_Atan2S_XY(sqrtf(SQ(xDiff) + SQ(zDiff)), yDiff); + dst->y = Math_Atan2S_XY(zDiff, xDiff); + dst->x = Math_Atan2S_XY(sqrtf(SQ(xDiff) + SQ(zDiff)), yDiff); } void func_800BE3D0(Actor* actor, s16 angle, Vec3s* arg2) { - f32 sp44; - f32 sp40; - f32 sp3C; + f32 floorPolyNormalX; + f32 floorPolyNormalY; + f32 floorPolyNormalZ; f32 sp38; f32 sp34; f32 sp30; @@ -4394,17 +4562,17 @@ void func_800BE3D0(Actor* actor, s16 angle, Vec3s* arg2) { 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); + floorPolyNormalX = COLPOLY_GET_NORMAL(floorPoly->normal.x); + floorPolyNormalY = COLPOLY_GET_NORMAL(floorPoly->normal.y); + floorPolyNormalZ = 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); + arg2->x = (s16)-Math_Atan2S((-(floorPolyNormalX * sp38) - (floorPolyNormalZ * sp34)) * floorPolyNormalY, 1.0f); sp2C = Math_SinS(angle - 0x3FF7); sp30 = Math_CosS(angle - 0x3FF7); - arg2->z = (s16)-Math_Atan2S((-(sp44 * sp2C) - (sp3C * sp30)) * sp40, 1.0f); + arg2->z = (s16)-Math_Atan2S((-(floorPolyNormalX * sp2C) - (floorPolyNormalZ * sp30)) * floorPolyNormalY, 1.0f); } } @@ -4413,7 +4581,7 @@ void func_800BE504(Actor* actor, ColliderCylinder* 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); + actor->world.rot.y = Actor_WorldYawTowardActor(collider->base.ac, actor); } } @@ -4421,7 +4589,7 @@ 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); + actor->world.rot.y = Actor_WorldYawTowardActor(collider->base.ac, actor); } } @@ -4430,7 +4598,7 @@ void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 colliderIndex) { (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); + actor->world.rot.y = Actor_WorldYawTowardActor(collider->base.ac, actor); } } @@ -4473,13 +4641,13 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 // Apply sfx along with damage effect if ((actor != NULL) && (effectAlpha > 0.05f) && (play->gameOverCtx.state == GAMEOVER_INACTIVE)) { if (type == ACTOR_DRAW_DMGEFF_FIRE) { - Actor_PlaySfxAtPos(actor, NA_SE_EV_BURN_OUT - SFX_FLAG); + Actor_PlaySfx(actor, NA_SE_EV_BURN_OUT - SFX_FLAG); } else if (type == ACTOR_DRAW_DMGEFF_BLUE_FIRE) { - Actor_PlaySfxAtPos(actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + Actor_PlaySfx(actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); } else if (type == ACTOR_DRAW_DMGEFF_FROZEN_SFX) { - Actor_PlaySfxAtPos(actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + Actor_PlaySfx(actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } else if ((type == ACTOR_DRAW_DMGEFF_LIGHT_ORBS) || (type == ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS)) { - Actor_PlaySfxAtPos(actor, NA_SE_EN_COMMON_DEADLIGHT - SFX_FLAG); + Actor_PlaySfx(actor, NA_SE_EN_COMMON_DEADLIGHT - SFX_FLAG); } } @@ -4730,7 +4898,7 @@ void Actor_SpawnIceEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s32 l SoundSource_PlaySfxAtFixedWorldPos(play, &actor->world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < limbPosCount; i++) { - yaw = Actor_YawToPoint(actor, limbPos); + yaw = Actor_WorldYawTowardPoint(actor, limbPos); for (j = 0; j < effectsPerLimb; j++) { randomYaw = ((s32)Rand_Next() >> 0x13) + yaw; diff --git a/src/code/z_actor_dlftbls.c b/src/code/z_actor_dlftbls.c index 5d7f30ea8..1008cceab 100644 --- a/src/code/z_actor_dlftbls.c +++ b/src/code/z_actor_dlftbls.c @@ -38,45 +38,44 @@ ActorOverlay gActorOverlayTable[] = { ActorId gMaxActorId = 0; -FaultClient D_801ED930; -FaultAddrConvClient D_801ED940; +FaultClient sActorOverlayTableFaultClient; +FaultAddrConvClient sActorOverlayTableFaultAddrConvClient; -void ActorOverlayTable_FaultPrint(void* arg0, void* arg1) { +void ActorOverlayTable_FaultClient(void* arg0, void* arg1) { ActorOverlay* overlayEntry; u32 overlaySize; - ActorId i; + ActorId actorId; FaultDrawer_SetCharPad(-2, 0); FaultDrawer_Printf("actor_dlftbls %u\n", gMaxActorId); FaultDrawer_Printf("No. RamStart- RamEnd cn Name\n"); - for (i = 0, overlayEntry = &gActorOverlayTable[0]; i < gMaxActorId; i++, overlayEntry++) { + for (actorId = 0, overlayEntry = &gActorOverlayTable[0]; actorId < gMaxActorId; actorId++, overlayEntry++) { overlaySize = VRAM_PTR_SIZE(overlayEntry); if (overlayEntry->loadedRamAddr != NULL) { - FaultDrawer_Printf("%3d %08x-%08x %3d %s\n", i, overlayEntry->loadedRamAddr, + FaultDrawer_Printf("%3d %08x-%08x %3d %s\n", actorId, overlayEntry->loadedRamAddr, (u32)overlayEntry->loadedRamAddr + overlaySize, overlayEntry->numLoaded, ""); } } } -void* ActorOverlayTable_FaultAddrConv(void* arg0, void* arg1) { - u8* ptr = arg0; - ActorOverlay* overlayEntry = &gActorOverlayTable[0]; - ActorId i; - u8* ramStart; - u8* ramEnd; - size_t size; - u32 offset; +void* ActorOverlayTable_FaultAddrConv(void* address, void* param) { + uintptr_t addr = address; + ActorOverlay* actorOvl = &gActorOverlayTable[0]; + size_t ramConv; + void* ramStart; + size_t diff; + ActorId actorId; + + for (actorId = 0; actorId < gMaxActorId; actorId++, actorOvl++) { + diff = VRAM_PTR_SIZE(actorOvl); + ramStart = actorOvl->loadedRamAddr; + ramConv = (uintptr_t)actorOvl->vramStart - (uintptr_t)ramStart; - for (i = 0; i < gMaxActorId; i++, overlayEntry++) { - size = VRAM_PTR_SIZE(overlayEntry); - ramStart = overlayEntry->loadedRamAddr; - ramEnd = ramStart + size; - offset = (u8*)overlayEntry->vramStart - ramStart; if (ramStart != NULL) { - if (ptr >= ramStart && ptr < ramEnd) { - return ptr + offset; + if ((addr >= (uintptr_t)ramStart) && (addr < (uintptr_t)ramStart + diff)) { + return addr + ramConv; } } } @@ -85,12 +84,12 @@ void* ActorOverlayTable_FaultAddrConv(void* arg0, void* arg1) { void ActorOverlayTable_Init(void) { gMaxActorId = ACTOR_ID_MAX; - Fault_AddClient(&D_801ED930, &ActorOverlayTable_FaultPrint, NULL, NULL); - Fault_AddAddrConvClient(&D_801ED940, &ActorOverlayTable_FaultAddrConv, NULL); + Fault_AddClient(&sActorOverlayTableFaultClient, ActorOverlayTable_FaultClient, NULL, NULL); + Fault_AddAddrConvClient(&sActorOverlayTableFaultAddrConvClient, ActorOverlayTable_FaultAddrConv, NULL); } void ActorOverlayTable_Cleanup(void) { - Fault_RemoveClient(&D_801ED930); - Fault_RemoveAddrConvClient(&D_801ED940); + Fault_RemoveClient(&sActorOverlayTableFaultClient); + Fault_RemoveAddrConvClient(&sActorOverlayTableFaultAddrConvClient); gMaxActorId = 0; } diff --git a/src/code/z_bg_collect.c b/src/code/z_bg_collect.c index 0d4f4a21f..b0c0971ea 100644 --- a/src/code/z_bg_collect.c +++ b/src/code/z_bg_collect.c @@ -1,103 +1,116 @@ #include "global.h" -void BgCheck2_UpdateActorPosition(CollisionContext* colCtx, s32 bgId, Actor* actor) { - MtxF prevMatrix; - MtxF prevMatrixInv; - MtxF currMatrix; - Vec3f newPos; - Vec3f posWithInv; +/** + * Update the `carriedActor`'s position based on the dynapoly actor identified by `bgId`. + */ +void DynaPolyActor_UpdateCarriedActorPos(CollisionContext* colCtx, s32 bgId, Actor* carriedActor) { + MtxF prevTransform; + MtxF prevTransformInv; + MtxF curTransform; + Vec3f pos; + Vec3f tempPos; if (!DynaPoly_IsBgIdBgActor(bgId)) { return; } SkinMatrix_SetScaleRotateYRPTranslate( - &prevMatrix, colCtx->dyna.bgActors[bgId].prevTransform.scale.x, + &prevTransform, colCtx->dyna.bgActors[bgId].prevTransform.scale.x, colCtx->dyna.bgActors[bgId].prevTransform.scale.y, colCtx->dyna.bgActors[bgId].prevTransform.scale.z, colCtx->dyna.bgActors[bgId].prevTransform.rot.x, colCtx->dyna.bgActors[bgId].prevTransform.rot.y, colCtx->dyna.bgActors[bgId].prevTransform.rot.z, colCtx->dyna.bgActors[bgId].prevTransform.pos.x, colCtx->dyna.bgActors[bgId].prevTransform.pos.y, colCtx->dyna.bgActors[bgId].prevTransform.pos.z); - if (SkinMatrix_Invert(&prevMatrix, &prevMatrixInv) == 2) { + if (SkinMatrix_Invert(&prevTransform, &prevTransformInv) == 2) { return; } SkinMatrix_SetScaleRotateYRPTranslate( - &currMatrix, colCtx->dyna.bgActors[bgId].curTransform.scale.x, colCtx->dyna.bgActors[bgId].curTransform.scale.y, - colCtx->dyna.bgActors[bgId].curTransform.scale.z, colCtx->dyna.bgActors[bgId].curTransform.rot.x, - colCtx->dyna.bgActors[bgId].curTransform.rot.y, colCtx->dyna.bgActors[bgId].curTransform.rot.z, - colCtx->dyna.bgActors[bgId].curTransform.pos.x, colCtx->dyna.bgActors[bgId].curTransform.pos.y, - colCtx->dyna.bgActors[bgId].curTransform.pos.z); + &curTransform, colCtx->dyna.bgActors[bgId].curTransform.scale.x, + colCtx->dyna.bgActors[bgId].curTransform.scale.y, colCtx->dyna.bgActors[bgId].curTransform.scale.z, + colCtx->dyna.bgActors[bgId].curTransform.rot.x, colCtx->dyna.bgActors[bgId].curTransform.rot.y, + colCtx->dyna.bgActors[bgId].curTransform.rot.z, colCtx->dyna.bgActors[bgId].curTransform.pos.x, + colCtx->dyna.bgActors[bgId].curTransform.pos.y, colCtx->dyna.bgActors[bgId].curTransform.pos.z); - SkinMatrix_Vec3fMtxFMultXYZ(&prevMatrixInv, &actor->world.pos, &posWithInv); - SkinMatrix_Vec3fMtxFMultXYZ(&currMatrix, &posWithInv, &newPos); + // Apply the movement of the dynapoly actor `bgId` over the last frame to the `carriedActor` position + // pos = curTransform * prevTransformInv * pos + // Note (curTransform * prevTransformInv) represents the transform relative to the previous frame + SkinMatrix_Vec3fMtxFMultXYZ(&prevTransformInv, &carriedActor->world.pos, &tempPos); + SkinMatrix_Vec3fMtxFMultXYZ(&curTransform, &tempPos, &pos); - actor->world.pos = newPos; + carriedActor->world.pos = pos; } -void BgCheck2_UpdateActorYRotation(CollisionContext* colCtx, s32 bgId, Actor* actor) { - s16 angleChange; +/** + * Update the `carriedActor`'s Y rotation based on the dynapoly actor identified by `bgId`. + */ +void DynaPolyActor_UpdateCarriedActorRotY(CollisionContext* colCtx, s32 bgId, Actor* carriedActor) { + s16 rotY; if (!DynaPoly_IsBgIdBgActor(bgId)) { return; } - angleChange = colCtx->dyna.bgActors[bgId].curTransform.rot.y - colCtx->dyna.bgActors[bgId].prevTransform.rot.y; + rotY = colCtx->dyna.bgActors[bgId].curTransform.rot.y - colCtx->dyna.bgActors[bgId].prevTransform.rot.y; - if (actor->id == 0) { - ((Player*)actor)->currentYaw += angleChange; + if (carriedActor->id == ACTOR_PLAYER) { + ((Player*)carriedActor)->currentYaw += rotY; } - actor->shape.rot.y += angleChange; - actor->world.rot.y += angleChange; + carriedActor->shape.rot.y += rotY; + carriedActor->world.rot.y += rotY; } -void BgCheck2_AttachToMesh(CollisionContext* colCtx, Actor* actor, s32 bgId) { - DynaPolyActor* meshActor; +void DynaPolyActor_AttachCarriedActor(CollisionContext* colCtx, Actor* carriedActor, s32 bgId) { + DynaPolyActor* dynaActor; if (!DynaPoly_IsBgIdBgActor(bgId)) { return; } - meshActor = DynaPoly_GetActor(colCtx, bgId); - if (meshActor != NULL) { - DynaPolyActor_SetRidingFallingState(meshActor); + dynaActor = DynaPoly_GetActor(colCtx, bgId); + if (dynaActor != NULL) { + DynaPolyActor_SetActorOnTop(dynaActor); - if ((actor->flags & 0x4000000) == 0x4000000) { - DynaPolyActor_SetSwitchPressedState(meshActor); + if (CHECK_FLAG_ALL(carriedActor->flags, ACTOR_FLAG_CAN_PRESS_SWITCH)) { + DynaPolyActor_SetActorOnSwitch(dynaActor); } - if ((actor->flags & 0x20000) == 0x20000) { - DynaPolyActor_SetHeavySwitchPressedState(meshActor); + if (CHECK_FLAG_ALL(carriedActor->flags, ACTOR_FLAG_CAN_PRESS_HEAVY_SWITCH)) { + DynaPolyActor_SetActorOnHeavySwitch(dynaActor); } } } -u32 BgCheck2_UpdateActorAttachedToMesh(CollisionContext* colCtx, s32 bgId, Actor* actor) { - u32 wasUpdated = 0; - DynaPolyActor* meshActor; +/** + * Update the `carriedActor`'s position and Y rotation based on the dynapoly actor identified by `bgId`, according to + * the dynapoly actor's move flags (see `DYNA_TRANSFORM_POS` and `DYNA_TRANSFORM_ROT_Y`). + */ +u32 DynaPolyActor_TransformCarriedActor(CollisionContext* colCtx, s32 bgId, Actor* carriedActor) { + u32 wasUpdated = false; + DynaPolyActor* dynaActor; if (!DynaPoly_IsBgIdBgActor(bgId)) { - return 0; + return false; } - if (colCtx->dyna.bgActorFlags[bgId] & 2 || !(colCtx->dyna.bgActorFlags[bgId] & 1)) { - return 0; + if ((colCtx->dyna.bgActorFlags[bgId] & BGACTOR_1) || !(colCtx->dyna.bgActorFlags[bgId] & BGACTOR_IN_USE)) { + return false; } - meshActor = DynaPoly_GetActor(colCtx, bgId); + dynaActor = DynaPoly_GetActor(colCtx, bgId); - if (meshActor == NULL) { - return 0; + if (dynaActor == NULL) { + return false; } - if (meshActor->flags & 1) { - BgCheck2_UpdateActorPosition(colCtx, bgId, actor); - wasUpdated = 1; + if (dynaActor->transformFlags & DYNA_TRANSFORM_POS) { + DynaPolyActor_UpdateCarriedActorPos(colCtx, bgId, carriedActor); + wasUpdated = true; } - if (meshActor->flags & 2) { - BgCheck2_UpdateActorYRotation(colCtx, bgId, actor); - wasUpdated = 1; + if (dynaActor->transformFlags & DYNA_TRANSFORM_ROT_Y) { + DynaPolyActor_UpdateCarriedActorRotY(colCtx, bgId, carriedActor); + wasUpdated = true; } return wasUpdated; diff --git a/src/code/z_bg_item.c b/src/code/z_bg_item.c index 79bdf2b82..cedd77194 100644 --- a/src/code/z_bg_item.c +++ b/src/code/z_bg_item.c @@ -1,18 +1,15 @@ #include "global.h" -#define DYNAPOLY_STATE_NONE 0 -#define DYNAPOLY_STATE_RIDING_FALLING (1 << 0) -#define DYNAPOLY_STATE_RIDING_MOVING (1 << 1) -#define DYNAPOLY_STATE_RIDING_ROTATING (1 << 2) -#define DYNAPOLY_STATE_SWITCH_PRESSED (1 << 3) -#define DYNAPOLY_STATE_HEAVY_SWITCH_PRESSED (1 << 4) - -void DynaPolyActor_Init(DynaPolyActor* dynaActor, s32 flags) { +/** + * @param transformFlags How other actors standing on the dynapoly actor's collision move when the dynapoly actor moves. + * See `DYNA_TRANSFORM_POS`, `DYNA_TRANSFORM_ROT_Y`. + */ +void DynaPolyActor_Init(DynaPolyActor* dynaActor, s32 transformFlags) { dynaActor->bgId = -1; dynaActor->pushForce = 0.0f; dynaActor->unk14C = 0.0f; - dynaActor->flags = flags; - dynaActor->stateFlags = DYNAPOLY_STATE_NONE; + dynaActor->transformFlags = transformFlags; + dynaActor->interactFlags = 0; } void DynaPolyActor_LoadMesh(PlayState* play, DynaPolyActor* dynaActor, CollisionHeader* meshHeader) { @@ -22,80 +19,80 @@ void DynaPolyActor_LoadMesh(PlayState* play, DynaPolyActor* dynaActor, Collision dynaActor->bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &dynaActor->actor, header); } -void DynaPolyActor_ResetState(DynaPolyActor* dynaActor) { - dynaActor->stateFlags = DYNAPOLY_STATE_NONE; +void DynaPolyActor_UnsetAllInteractFlags(DynaPolyActor* dynaActor) { + dynaActor->interactFlags = 0; } -void DynaPolyActor_SetRidingFallingState(DynaPolyActor* dynaActor) { - dynaActor->stateFlags |= DYNAPOLY_STATE_RIDING_FALLING; +void DynaPolyActor_SetActorOnTop(DynaPolyActor* dynaActor) { + dynaActor->interactFlags |= DYNA_INTERACT_ACTOR_ON_TOP; } -void DynaPolyActor_SetRidingMovingState(DynaPolyActor* dynaActor) { - dynaActor->stateFlags |= DYNAPOLY_STATE_RIDING_MOVING; +void DynaPolyActor_SetPlayerOnTop(DynaPolyActor* dynaActor) { + dynaActor->interactFlags |= DYNA_INTERACT_PLAYER_ON_TOP; } -void DynaPolyActor_SetRidingMovingStateByIndex(CollisionContext* colCtx, s32 bgId) { +void DynaPoly_SetPlayerOnTop(CollisionContext* colCtx, s32 bgId) { DynaPolyActor* dynaActor = DynaPoly_GetActor(colCtx, bgId); if (dynaActor != NULL) { - DynaPolyActor_SetRidingMovingState(dynaActor); + DynaPolyActor_SetPlayerOnTop(dynaActor); } } -void DynaPolyActor_SetRidingRotatingState(DynaPolyActor* dynaActor) { - dynaActor->stateFlags |= DYNAPOLY_STATE_RIDING_ROTATING; +void DynaPolyActor_SetPlayerAbove(DynaPolyActor* dynaActor) { + dynaActor->interactFlags |= DYNA_INTERACT_PLAYER_ABOVE; } -void DynaPolyActor_SetRidingRotatingStateByIndex(CollisionContext* colCtx, s32 bgId) { +void DynaPoly_SetPlayerAbove(CollisionContext* colCtx, s32 bgId) { DynaPolyActor* dynaActor = DynaPoly_GetActor(colCtx, bgId); if (dynaActor != NULL) { - DynaPolyActor_SetRidingRotatingState(dynaActor); + DynaPolyActor_SetPlayerAbove(dynaActor); } } -void DynaPolyActor_SetSwitchPressedState(DynaPolyActor* dynaActor) { - dynaActor->stateFlags |= DYNAPOLY_STATE_SWITCH_PRESSED; +void DynaPolyActor_SetActorOnSwitch(DynaPolyActor* dynaActor) { + dynaActor->interactFlags |= DYNA_INTERACT_ACTOR_ON_SWITCH; } -void DynaPolyActor_SetHeavySwitchPressedState(DynaPolyActor* dynaActor) { - dynaActor->stateFlags |= DYNAPOLY_STATE_HEAVY_SWITCH_PRESSED; +void DynaPolyActor_SetActorOnHeavySwitch(DynaPolyActor* dynaActor) { + dynaActor->interactFlags |= DYNA_INTERACT_ACTOR_ON_HEAVY_SWITCH; } -s32 DynaPolyActor_IsInRidingFallingState(DynaPolyActor* dynaActor) { - if (dynaActor->stateFlags & DYNAPOLY_STATE_RIDING_FALLING) { +s32 DynaPolyActor_IsActorOnTop(DynaPolyActor* dynaActor) { + if (dynaActor->interactFlags & DYNA_INTERACT_ACTOR_ON_TOP) { return true; } else { return false; } } -s32 DynaPolyActor_IsInRidingMovingState(DynaPolyActor* dynaActor) { - if (dynaActor->stateFlags & DYNAPOLY_STATE_RIDING_MOVING) { +s32 DynaPolyActor_IsPlayerOnTop(DynaPolyActor* dynaActor) { + if (dynaActor->interactFlags & DYNA_INTERACT_PLAYER_ON_TOP) { return true; } else { return false; } } -s32 DynaPolyActor_IsInRidingRotatingState(DynaPolyActor* dynaActor) { - if (dynaActor->stateFlags & DYNAPOLY_STATE_RIDING_ROTATING) { +s32 DynaPolyActor_IsPlayerAbove(DynaPolyActor* dynaActor) { + if (dynaActor->interactFlags & DYNA_INTERACT_PLAYER_ABOVE) { return true; } else { return false; } } -s32 DynaPolyActor_IsInSwitchPressedState(DynaPolyActor* dynaActor) { - if (dynaActor->stateFlags & DYNAPOLY_STATE_SWITCH_PRESSED) { +s32 DynaPolyActor_IsSwitchPressed(DynaPolyActor* dynaActor) { + if (dynaActor->interactFlags & DYNA_INTERACT_ACTOR_ON_SWITCH) { return true; } else { return false; } } -s32 DynaPolyActor_IsInHeavySwitchPressedState(DynaPolyActor* dynaActor) { - if (dynaActor->stateFlags & DYNAPOLY_STATE_HEAVY_SWITCH_PRESSED) { +s32 DynaPolyActor_IsHeavySwitchPressed(DynaPolyActor* dynaActor) { + if (dynaActor->interactFlags & DYNA_INTERACT_ACTOR_ON_HEAVY_SWITCH) { return true; } else { return false; @@ -129,13 +126,16 @@ s32 DynaPolyActor_ValidateMove(PlayState* play, DynaPolyActor* dynaActor, s16 st &bgId, &dynaActor->actor, 0.0f)) { return false; } + startPos.x = (dynaActor->actor.world.pos.x * 2.0f) - startPos.x; startPos.z = (dynaActor->actor.world.pos.z * 2.0f) - startPos.z; endPos.x = sign * adjustedEndRadius * sin + startPos.x; endPos.z = sign * adjustedEndRadius * cos + startPos.z; + if (BgCheck_EntityLineTest3(&play->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false, true, &bgId, &dynaActor->actor, 0.0f)) { return false; } + return true; } diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index eda6437af..2fc1852ab 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #include "vt.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" @@ -7,44 +6,51 @@ #define DYNA_RAYCAST_WALLS 2 #define DYNA_RAYCAST_CEILINGS 4 -u32 sWallFlags[32] = { - 0, 1, 3, 5, 8, 16, 32, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +u32 sWallFlags[WALL_TYPE_MAX] = { + 0, // WALL_TYPE_0 + WALL_FLAG_0, // WALL_TYPE_1 + WALL_FLAG_0 | WALL_FLAG_1, // WALL_TYPE_2 + WALL_FLAG_0 | WALL_FLAG_2, // WALL_TYPE_3 + WALL_FLAG_3, // WALL_TYPE_4 + WALL_FLAG_4, // WALL_TYPE_5 + WALL_FLAG_5, // WALL_TYPE_6 + WALL_FLAG_6, // WALL_TYPE_7 }; -u16 sSurfaceTypeSfx[] = { - /* 0x00 */ NA_SE_PL_WALK_GROUND - SFX_FLAG, - /* 0x01 */ NA_SE_PL_WALK_SAND - SFX_FLAG, - /* 0x02 */ NA_SE_PL_WALK_CONCRETE - SFX_FLAG, - /* 0x03 */ NA_SE_PL_WALK_DIRT - SFX_FLAG, - /* 0x04 */ NA_SE_PL_WALK_WATER0 - SFX_FLAG, - /* 0x05 */ NA_SE_PL_WALK_WATER1 - SFX_FLAG, - /* 0x06 */ NA_SE_PL_WALK_WATER2 - SFX_FLAG, - /* 0x07 */ NA_SE_PL_WALK_MAGMA - SFX_FLAG, - /* 0x08 */ NA_SE_PL_WALK_GRASS - SFX_FLAG, - /* 0x09 */ NA_SE_PL_WALK_GLASS - SFX_FLAG, - /* 0x0A */ NA_SE_PL_WALK_LADDER - SFX_FLAG, - /* 0x0B */ NA_SE_PL_WALK_GROUND - SFX_FLAG, - /* 0x0C */ NA_SE_PL_WALK_ICE - SFX_FLAG, - /* 0x0D */ NA_SE_PL_WALK_IRON - SFX_FLAG, - /* 0x0E */ NA_SE_PL_WALK_SNOW - SFX_FLAG +u16 sSurfaceSfxOffsets[SURFACE_MATERIAL_MAX] = { + SURFACE_SFX_OFFSET_DIRT, // SURFACE_MATERIAL_DIRT + SURFACE_SFX_OFFSET_SAND, // SURFACE_MATERIAL_SAND + SURFACE_SFX_OFFSET_STONE, // SURFACE_MATERIAL_STONE + SURFACE_SFX_OFFSET_DIRT_SHALLOW, // SURFACE_MATERIAL_DIRT_SHALLOW + SURFACE_SFX_OFFSET_WATER_SHALLOW, // SURFACE_MATERIAL_WATER_SHALLOW + SURFACE_SFX_OFFSET_WATER_DEEP, // SURFACE_MATERIAL_WATER_DEEP + SURFACE_SFX_OFFSET_TALL_GRASS, // SURFACE_MATERIAL_TALL_GRASS + SURFACE_SFX_OFFSET_LAVA, // SURFACE_MATERIAL_LAVA + SURFACE_SFX_OFFSET_GRASS, // SURFACE_MATERIAL_GRASS + SURFACE_SFX_OFFSET_BRIDGE, // SURFACE_MATERIAL_BRIDGE + SURFACE_SFX_OFFSET_WOOD, // SURFACE_MATERIAL_WOOD + SURFACE_SFX_OFFSET_DIRT, // SURFACE_MATERIAL_DIRT_SOFT + SURFACE_SFX_OFFSET_ICE, // SURFACE_MATERIAL_ICE + SURFACE_SFX_OFFSET_CARPET, // SURFACE_MATERIAL_CARPET + SURFACE_SFX_OFFSET_SNOW, // SURFACE_MATERIAL_SNOW }; -u8 D_801B46C0[] = { - /* 0x00 */ 1, - /* 0x01 */ 1, - /* 0x02 */ 0, - /* 0x03 */ 1, - /* 0x04 */ 0, - /* 0x05 */ 0, - /* 0x06 */ 0, - /* 0x07 */ 0, - /* 0x08 */ 0, - /* 0x09 */ 0, - /* 0x0A */ 0, - /* 0x0B */ 0, - /* 0x0C */ 0, - /* 0x0D */ 0, - /* 0x0E */ 1 +u8 sSurfaceMaterialProperties[SURFACE_MATERIAL_MAX] = { + MATERIAL_PROPERTY_SOFT_IMPRINT, // SURFACE_MATERIAL_DIRT + MATERIAL_PROPERTY_SOFT_IMPRINT, // SURFACE_MATERIAL_SAND + 0, // SURFACE_MATERIAL_STONE + MATERIAL_PROPERTY_SOFT_IMPRINT, // SURFACE_MATERIAL_DIRT_SHALLOW + 0, // SURFACE_MATERIAL_WATER_SHALLOW + 0, // SURFACE_MATERIAL_WATER_DEEP + 0, // SURFACE_MATERIAL_TALL_GRASS + 0, // SURFACE_MATERIAL_LAVA + 0, // SURFACE_MATERIAL_GRASS + 0, // SURFACE_MATERIAL_BRIDGE + 0, // SURFACE_MATERIAL_WOOD + 0, // SURFACE_MATERIAL_DIRT_SOFT + 0, // SURFACE_MATERIAL_ICE + 0, // SURFACE_MATERIAL_CARPET + MATERIAL_PROPERTY_SOFT_IMPRINT, // SURFACE_MATERIAL_SNOW }; s16 sSmallMemSceneIds[] = { @@ -52,9 +58,9 @@ s16 sSmallMemSceneIds[] = { }; typedef struct { - s16 sceneId; - u32 memSize; -} BgCheckSceneMemEntry; + /* 0x0 */ s16 sceneId; + /* 0x4 */ u32 memSize; +} BgCheckSceneMemEntry; // size = 0x8 BgCheckSceneMemEntry sSceneMemList[] = { { SCENE_00KEIKOKU, 0xC800 }, @@ -90,7 +96,7 @@ char D_801ED9A0[80]; char D_801EDAA8[80]; char D_801EDAF8[80]; -MtxF D_801EDA40; +MtxF sModelToWorldMtxF; void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector); f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast); @@ -140,7 +146,7 @@ void DynaSSNodeList_Init(PlayState* play, DynaSSNodeList* list) { } void DynaSSNodeList_Alloc(PlayState* play, DynaSSNodeList* list, u32 numNodes) { - list->tbl = (SSNode*)THA_AllocEndAlign(&play->state.heap, numNodes * sizeof(SSNode), -2); + list->tbl = (SSNode*)THA_AllocTailAlign(&play->state.heap, numNodes * sizeof(SSNode), -2); list->maxNodes = numNodes; list->count = 0; } @@ -955,12 +961,12 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0) { CollisionPoly* polyList; s32 result; - Vec3f polyIntersect; // sp7C + Vec3f polyIntersect; SSNode* curNode; u8* checkedPoly; f32 minY; f32 distSq; - BgLineVsPolyTest test; // sp50 + BgLineVsPolyTest test; s16 polyId; result = false; @@ -1591,7 +1597,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader colCtx->subdivAmount.z = 16; } } - colCtx->lookupTbl = THA_AllocEndAlign( + colCtx->lookupTbl = THA_AllocTailAlign( &play->state.heap, colCtx->subdivAmount.x * sizeof(StaticLookup) * colCtx->subdivAmount.y * colCtx->subdivAmount.z, ~1); if (colCtx->lookupTbl == NULL) { @@ -1659,7 +1665,7 @@ CollisionHeader* BgCheck_GetCollisionHeader(CollisionContext* colCtx, s32 bgId) if ((bgId < 0) || (bgId > BG_ACTOR_MAX)) { return NULL; } - if (!(colCtx->dyna.bgActorFlags[bgId] & 1)) { + if (!(colCtx->dyna.bgActorFlags[bgId] & BGACTOR_IN_USE)) { return NULL; } return colCtx->dyna.bgActors[bgId].colHeader; @@ -1735,7 +1741,7 @@ f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFl } } - if ((yIntersect != BGCHECK_Y_MIN) && func_800C9B68(colCtx, *outPoly, *outBgId)) { + if ((yIntersect != BGCHECK_Y_MIN) && SurfaceType_IsSoft(colCtx, *outPoly, *outBgId)) { yIntersect -= 1.0f; } return yIntersect; @@ -1955,7 +1961,7 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul } posResult->z = posIntersect.z; if (actor != NULL) { - actor->bgCheckFlags |= 0x1000; + actor->bgCheckFlags |= BGCHECKFLAG_PLAYER_1000; } } // poly is wall @@ -2001,7 +2007,7 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul result = true; if (poly->normal.y * COLPOLY_NORMAL_FRAC > 0.5f) { if (actor != NULL) { - actor->bgCheckFlags |= 0x1000; + actor->bgCheckFlags |= BGCHECKFLAG_PLAYER_1000; } } } else { @@ -2478,8 +2484,8 @@ void SSNodeList_Init(SSNodeList* this) { void SSNodeList_Alloc(PlayState* play, SSNodeList* this, s32 tblMax, s32 numPolys) { this->max = tblMax; this->count = 0; - this->tbl = THA_AllocEndAlign(&play->state.heap, tblMax * sizeof(SSNode), -2); - this->polyCheckTbl = THA_AllocEndAlign16(&play->state.heap, numPolys * sizeof(u8)); + this->tbl = THA_AllocTailAlign(&play->state.heap, tblMax * sizeof(SSNode), -2); + this->polyCheckTbl = THA_AllocTailAlign16(&play->state.heap, numPolys * sizeof(u8)); if (this->polyCheckTbl == NULL) { sprintf(D_801ED950, "this->polygon_check == NULL(game_alloc() MemoryAllocationError.)\n"); @@ -2621,7 +2627,7 @@ void DynaPoly_NullPolyList(CollisionPoly** polyList) { * Allocate dyna.polyList */ void DynaPoly_AllocPolyList(PlayState* play, CollisionPoly** polyList, s32 numPolys) { - *polyList = THA_AllocEndAlign(&play->state.heap, numPolys * sizeof(CollisionPoly), -2); + *polyList = THA_AllocTailAlign(&play->state.heap, numPolys * sizeof(CollisionPoly), -2); } /** @@ -2635,7 +2641,7 @@ void DynaPoly_NullVtxList(Vec3s** vtxList) { * Allocate dyna.vtxList */ void DynaPoly_AllocVtxList(PlayState* play, Vec3s** vtxList, s32 numVtx) { - *vtxList = THA_AllocEndAlign(&play->state.heap, numVtx * sizeof(Vec3s), -2); + *vtxList = THA_AllocTailAlign(&play->state.heap, numVtx * sizeof(Vec3s), -2); } /** @@ -2650,7 +2656,7 @@ void DynaPoly_InitWaterBoxList(DynaWaterBoxList* waterBoxList) { * Allocate dyna.waterBoxList */ void DynaPoly_AllocWaterBoxList(PlayState* play, DynaWaterBoxList* waterBoxList, s32 numWaterBoxes) { - waterBoxList->boxes = THA_AllocEndAlign(&play->state.heap, numWaterBoxes * sizeof(WaterBox), -2); + waterBoxList->boxes = THA_AllocTailAlign(&play->state.heap, numWaterBoxes * sizeof(WaterBox), -2); } /** @@ -2713,8 +2719,8 @@ s32 DynaPoly_SetBgActor(PlayState* play, DynaCollisionContext* dyna, Actor* acto s32 foundSlot = false; for (bgId = 0; bgId < BG_ACTOR_MAX; bgId++) { - if (!(dyna->bgActorFlags[bgId] & 1)) { - dyna->bgActorFlags[bgId] |= 1; + if (!(dyna->bgActorFlags[bgId] & BGACTOR_IN_USE)) { + dyna->bgActorFlags[bgId] |= BGACTOR_IN_USE; foundSlot = true; break; } @@ -2727,7 +2733,7 @@ s32 DynaPoly_SetBgActor(PlayState* play, DynaCollisionContext* dyna, Actor* acto BgActor_SetActor(&dyna->bgActors[bgId], actor, colHeader); dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; - dyna->bgActorFlags[bgId] &= ~2; + dyna->bgActorFlags[bgId] &= ~BGACTOR_1; return bgId; } @@ -2735,51 +2741,51 @@ s32 DynaPoly_SetBgActor(PlayState* play, DynaCollisionContext* dyna, Actor* acto * Gets the actor assigned to `bgId` */ DynaPolyActor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId) { - if (!DynaPoly_IsBgIdBgActor(bgId) || !(colCtx->dyna.bgActorFlags[bgId] & 1) || - (colCtx->dyna.bgActorFlags[bgId] & 2)) { + if (!DynaPoly_IsBgIdBgActor(bgId) || !(colCtx->dyna.bgActorFlags[bgId] & BGACTOR_IN_USE) || + (colCtx->dyna.bgActorFlags[bgId] & BGACTOR_1)) { return NULL; } return (DynaPolyActor*)colCtx->dyna.bgActors[bgId].actor; } -void func_800C62BC(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { +void DynaPoly_DisableCollision(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { - dyna->bgActorFlags[bgId] |= 4; + dyna->bgActorFlags[bgId] |= BGACTOR_COLLISION_DISABLED; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } -void func_800C6314(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { +void DynaPoly_EnableCollision(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { - dyna->bgActorFlags[bgId] &= ~4; + dyna->bgActorFlags[bgId] &= ~BGACTOR_COLLISION_DISABLED; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } -void func_800C636C(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { +void DynaPoly_DisableCeilingCollision(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { - dyna->bgActorFlags[bgId] |= 8; + dyna->bgActorFlags[bgId] |= BGACTOR_CEILING_COLLISION_DISABLED; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } -void func_800C63C4(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { +void DynaPoly_EnableCeilingCollision(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { - dyna->bgActorFlags[bgId] &= ~8; + dyna->bgActorFlags[bgId] &= ~BGACTOR_CEILING_COLLISION_DISABLED; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } -void func_800C641C(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { +void DynaPoly_DisableFloorCollision(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { - dyna->bgActorFlags[bgId] |= 0x20; + dyna->bgActorFlags[bgId] |= BGACTOR_FLOOR_COLLISION_DISABLED; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } -void func_800C6474(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { +void DynaPoly_EnableFloorCollision(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { - dyna->bgActorFlags[bgId] &= ~0x20; + dyna->bgActorFlags[bgId] &= ~BGACTOR_FLOOR_COLLISION_DISABLED; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } @@ -2798,11 +2804,11 @@ void DynaPoly_DeleteBgActor(PlayState* play, DynaCollisionContext* dyna, s32 bgI actor->bgId = BGACTOR_NEG_ONE; dyna->bgActors[bgId].actor = NULL; - dyna->bgActorFlags[bgId] |= 2; + dyna->bgActorFlags[bgId] |= BGACTOR_1; } } -void func_800C6554(PlayState* play, DynaCollisionContext* dyna) { +void DynaPoly_InvalidateLookup(PlayState* play, DynaCollisionContext* dyna) { dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } @@ -2856,38 +2862,28 @@ void BgCheck_CalcWaterboxDimensions(Vec3f* minPos, Vec3f* maxXPos, Vec3f* maxZPo } } -#ifdef NON_MATCHING /** * original name: DynaPolyInfo_expandSRT */ -void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s32* vtxStartIndex, s32* polyStartIndex, - s32* waterBoxStartIndex) { +void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s32* vtxStartIndex, + s32* polyStartIndex, s32* waterBoxStartIndex) { Actor* actor; - s32 pad; - s32 pad2; - f32 numVtxInverse; s32 i; - Vec3f pos; // sp170 + s32 j; + s32 wi; + f32 numVtxInverse; + Vec3f pos; Sphere16* sphere; Vec3s* dVtxList; Vec3s* point; - Vec3f newCenterPoint; // sp158 - + Vec3f newCenterPoint; f32 newRadiusSq; CollisionHeader* pbgdata; - Vec3f newVtx; // sp144 - Vec3f vtxA; // sp138 - Vec3f vtxB; // sp12C - Vec3f vtxC; // sp120 + Vec3f newVtx; + Vec3f vtxA; + Vec3f vtxB; + Vec3f vtxC; Vec3f newNormal; - s32 wi; - Vec3f spB8; // waterbox ? - Vec3f spAC; - Vec3f spA0; // waterbox ? - Vec3f sp94; - Vec3f sp88; // waterbox ? - Vec3f sp7C; - WaterBox* waterBox; pbgdata = dyna->bgActors[bgId].colHeader; sphere = &dyna->bgActors[bgId].boundingSphere; @@ -2898,12 +2894,15 @@ void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s pos = actor->world.pos; pos.y += actor->shape.yOffset * actor->scale.y; + //! FAKE: + if (pbgdata && pbgdata) {} + ScaleRotPos_SetValue(&dyna->bgActors[bgId].curTransform, &actor->scale, &actor->shape.rot, &pos); - if (dyna->bgActorFlags[bgId] & 4) { + if (dyna->bgActorFlags[bgId] & BGACTOR_COLLISION_DISABLED) { return; } - // if(&pos){} // fake but considerably improves match. commented out to stop warnings + if (*waterBoxStartIndex + pbgdata->numWaterBoxes > DYNA_WATERBOX_MAX) { sprintf(D_801EDAA8, "water_poly Error:[MoveBG OSUGI!!!]"); sprintf(D_801EDAF8, "num = %d > %d\n", *waterBoxStartIndex + pbgdata->numWaterBoxes, DYNA_WATERBOX_MAX); @@ -2930,13 +2929,13 @@ void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s s16 normalY = poly->normal.y; if (normalY > COLPOLY_SNORMAL(0.5f)) { - if (!(dyna->bgActorFlags[bgId] & 0x20)) { + if (!(dyna->bgActorFlags[bgId] & BGACTOR_FLOOR_COLLISION_DISABLED)) { s16 polyIndex = pi; DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.floor, &polyIndex); } } else if (normalY < COLPOLY_SNORMAL(-0.8f)) { - if (!(dyna->bgActorFlags[bgId] & 8)) { + if (!(dyna->bgActorFlags[bgId] & BGACTOR_CEILING_COLLISION_DISABLED)) { s16 polyIndex = pi; DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.ceiling, @@ -2952,150 +2951,156 @@ void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s *polyStartIndex += pbgdata->numPolygons; *vtxStartIndex += pbgdata->numVertices; *waterBoxStartIndex += pbgdata->numWaterBoxes; - } else { - SkinMatrix_SetScaleRotateYRPTranslate( - &D_801EDA40, dyna->bgActors[bgId].curTransform.scale.x, dyna->bgActors[bgId].curTransform.scale.y, - dyna->bgActors[bgId].curTransform.scale.z, dyna->bgActors[bgId].curTransform.rot.x, - dyna->bgActors[bgId].curTransform.rot.y, dyna->bgActors[bgId].curTransform.rot.z, - dyna->bgActors[bgId].curTransform.pos.x, dyna->bgActors[bgId].curTransform.pos.y, - dyna->bgActors[bgId].curTransform.pos.z); - - if ((pbgdata->numVertices != 0) && (pbgdata->numPolygons != 0)) { - s32 j; - numVtxInverse = 1.0f / pbgdata->numVertices; - newCenterPoint.x = newCenterPoint.y = newCenterPoint.z = 0.0f; - for (i = 0; i < pbgdata->numVertices; i++) { - Vec3f vtx; // spF4 - Vec3f vtxT; // spE8 Vtx after mtx transform - - Math_Vec3s_ToVec3f(&vtx, &pbgdata->vtxList[i]); - SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &vtx, &vtxT); - BgCheck_Vec3fToVec3s(&dyna->vtxList[*vtxStartIndex + i], &vtxT); - - if (i == 0) { - dyna->bgActors[bgId].minY = dyna->bgActors[bgId].maxY = vtxT.y; - } else if (vtxT.y < dyna->bgActors[bgId].minY) { - dyna->bgActors[bgId].minY = vtxT.y; - } else if (dyna->bgActors[bgId].maxY < vtxT.y) { - dyna->bgActors[bgId].maxY = vtxT.y; - } - newCenterPoint.x += vtxT.x; - newCenterPoint.y += vtxT.y; - newCenterPoint.z += vtxT.z; - } - - newCenterPoint.x *= numVtxInverse; - newCenterPoint.y *= numVtxInverse; - newCenterPoint.z *= numVtxInverse; - sphere->center.x = newCenterPoint.x; - sphere->center.y = newCenterPoint.y; - sphere->center.z = newCenterPoint.z; - newRadiusSq = -100.0f; - - for (i = 0, j = *vtxStartIndex; i < pbgdata->numVertices; i++, j++) { - f32 radiusSq; - - newVtx.x = dyna->vtxList[j].x; - newVtx.y = dyna->vtxList[j].y; - newVtx.z = dyna->vtxList[j].z; - radiusSq = Math3D_Vec3fDistSq(&newVtx, &newCenterPoint); - if (newRadiusSq < radiusSq) { - newRadiusSq = radiusSq; - } - } - - sphere->radius = sqrtf(newRadiusSq) * 1.1f; - - for (i = 0; i < pbgdata->numPolygons; i++) { - CollisionPoly* newPoly = &dyna->polyList[*polyStartIndex + i]; - f32 newNormMagnitude; - u32 vIA; - u32 vIB; - u32 vIC; - - *newPoly = pbgdata->polyList[i]; - - vIA = (COLPOLY_VTX_INDEX(newPoly->flags_vIA) + *vtxStartIndex); - vIB = (COLPOLY_VTX_INDEX(newPoly->flags_vIB) + *vtxStartIndex); - vIC = newPoly->vIC + *vtxStartIndex; - - newPoly->flags_vIA = vIA | ((*newPoly).flags_vIA & 0xE000); - newPoly->flags_vIB = vIB | ((*newPoly).flags_vIB & 0xE000); - newPoly->vIC = vIC; - dVtxList = dyna->vtxList; - vtxA.x = dVtxList[vIA].x; - vtxA.y = dVtxList[vIA].y; - vtxA.z = dVtxList[vIA].z; - vtxB.x = dVtxList[vIB].x; - vtxB.y = dVtxList[vIB].y; - vtxB.z = dVtxList[vIB].z; - vtxC.x = dVtxList[vIC].x; - vtxC.y = dVtxList[vIC].y; - vtxC.z = dVtxList[vIC].z; - Math3D_SurfaceNorm(&vtxA, &vtxB, &vtxC, &newNormal); - newNormMagnitude = Math3D_Vec3fMagnitude(&newNormal); - - if (!IS_ZERO(newNormMagnitude)) { - newNormal.x *= (1.0f / newNormMagnitude); - newNormal.y *= (1.0f / newNormMagnitude); - newNormal.z *= (1.0f / newNormMagnitude); - newPoly->normal.x = COLPOLY_SNORMAL(newNormal.x); - newPoly->normal.y = COLPOLY_SNORMAL(newNormal.y); - newPoly->normal.z = COLPOLY_SNORMAL(newNormal.z); - } - - newPoly->dist = func_80086D24(-DOTXYZ(newNormal, vtxA)); - if (newNormal.y > 0.5f) { - s16 polyId = *polyStartIndex + i; - - DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.floor, &polyId); - } else if (newNormal.y < -0.8f) { - s16 polyId = *polyStartIndex + i; - - DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.ceiling, &polyId); - } else { - s16 polyId = *polyStartIndex + i; - - DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.wall, &polyId); - } - } - } - - if (pbgdata->numWaterBoxes > 0) { - for (wi = 0; wi < pbgdata->numWaterBoxes; wi++) { - Math_Vec3s_ToVec3f(&spB8, &pbgdata->waterBoxes[wi].minPos); - Math_Vec3f_Copy(&spA0, &spB8); - spA0.x += pbgdata->waterBoxes[wi].xLength; - Math_Vec3f_Copy(&sp88, &spB8); - sp88.z += pbgdata->waterBoxes[wi].zLength; - SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spB8, &spAC); - SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spA0, &sp94); - SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &sp88, &sp7C); - waterBox = &dyna->waterBoxList.boxes[*waterBoxStartIndex + wi]; - BgCheck_CalcWaterboxDimensions(&spAC, &sp94, &sp7C, &waterBox->minPos, &waterBox->xLength, - &waterBox->zLength); - waterBox->properties = pbgdata->waterBoxes[wi].properties; - } - } - *polyStartIndex += pbgdata->numPolygons; - *vtxStartIndex += pbgdata->numVertices; - *waterBoxStartIndex += pbgdata->numWaterBoxes; + return; } -} -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/DynaPoly_ExpandSRT.s") -#endif -void BgCheck_ResetFlagsIfLoadedActor(PlayState* play, DynaCollisionContext* dyna, Actor* actor) { + SkinMatrix_SetScaleRotateYRPTranslate( + &sModelToWorldMtxF, dyna->bgActors[bgId].curTransform.scale.x, dyna->bgActors[bgId].curTransform.scale.y, + dyna->bgActors[bgId].curTransform.scale.z, dyna->bgActors[bgId].curTransform.rot.x, + dyna->bgActors[bgId].curTransform.rot.y, dyna->bgActors[bgId].curTransform.rot.z, + dyna->bgActors[bgId].curTransform.pos.x, dyna->bgActors[bgId].curTransform.pos.y, + dyna->bgActors[bgId].curTransform.pos.z); + + if ((pbgdata->numVertices != 0) && (pbgdata->numPolygons != 0)) { + f32 radiusSq; + + numVtxInverse = 1.0f / pbgdata->numVertices; + newCenterPoint.x = newCenterPoint.y = newCenterPoint.z = 0.0f; + for (i = 0; i < pbgdata->numVertices; i++) { + Vec3f vtx; + Vec3f vtxT; // Vtx after mtx transform + s32 pad; + + Math_Vec3s_ToVec3f(&vtx, &pbgdata->vtxList[i]); + SkinMatrix_Vec3fMtxFMultXYZ(&sModelToWorldMtxF, &vtx, &vtxT); + BgCheck_Vec3fToVec3s(&dyna->vtxList[*vtxStartIndex + (u32)i], &vtxT); + + if (i == 0) { + dyna->bgActors[bgId].minY = dyna->bgActors[bgId].maxY = vtxT.y; + } else if (vtxT.y < dyna->bgActors[bgId].minY) { + dyna->bgActors[bgId].minY = vtxT.y; + } else if (dyna->bgActors[bgId].maxY < vtxT.y) { + dyna->bgActors[bgId].maxY = vtxT.y; + } + newCenterPoint.x += vtxT.x; + newCenterPoint.y += vtxT.y; + newCenterPoint.z += vtxT.z; + } + + newCenterPoint.x *= numVtxInverse; + newCenterPoint.y *= numVtxInverse; + newCenterPoint.z *= numVtxInverse; + sphere->center.x = newCenterPoint.x; + sphere->center.y = newCenterPoint.y; + sphere->center.z = newCenterPoint.z; + newRadiusSq = -100.0f; + + for (i = 0, j = *vtxStartIndex; i < pbgdata->numVertices; i++, j++) { + newVtx.x = dyna->vtxList[j].x; + newVtx.y = dyna->vtxList[j].y; + newVtx.z = dyna->vtxList[j].z; + radiusSq = Math3D_Vec3fDistSq(&newVtx, &newCenterPoint); + if (newRadiusSq < radiusSq) { + newRadiusSq = radiusSq; + } + } + + sphere->radius = sqrtf(newRadiusSq) * 1.1f; + + for (i = 0; i < pbgdata->numPolygons; i++) { + CollisionPoly* newPoly = &dyna->polyList[*polyStartIndex + i]; + f32 newNormMagnitude; + u32 vIA; + u32 vIB; + u32 vIC; + + *newPoly = pbgdata->polyList[i]; + + vIA = (COLPOLY_VTX_INDEX(newPoly->flags_vIA) + *vtxStartIndex); + vIB = (COLPOLY_VTX_INDEX(newPoly->flags_vIB) + *vtxStartIndex); + vIC = newPoly->vIC + *vtxStartIndex; + + newPoly->flags_vIA = vIA | (newPoly->flags_vIA & 0xE000); + newPoly->flags_vIB = vIB | (newPoly->flags_vIB & 0xE000); + newPoly->vIC = vIC; + dVtxList = dyna->vtxList; + vtxA.x = dVtxList[vIA].x; + vtxA.y = dVtxList[vIA].y; + vtxA.z = dVtxList[vIA].z; + vtxB.x = dVtxList[vIB].x; + vtxB.y = dVtxList[vIB].y; + vtxB.z = dVtxList[vIB].z; + vtxC.x = dVtxList[vIC].x; + vtxC.y = dVtxList[vIC].y; + vtxC.z = dVtxList[vIC].z; + Math3D_SurfaceNorm(&vtxA, &vtxB, &vtxC, &newNormal); + newNormMagnitude = Math3D_Vec3fMagnitude(&newNormal); + + if (!IS_ZERO(newNormMagnitude)) { + newNormal.x *= 1.0f / newNormMagnitude; + newNormal.y *= 1.0f / newNormMagnitude; + newNormal.z *= 1.0f / newNormMagnitude; + newPoly->normal.x = COLPOLY_SNORMAL(newNormal.x); + newPoly->normal.y = COLPOLY_SNORMAL(newNormal.y); + newPoly->normal.z = COLPOLY_SNORMAL(newNormal.z); + } + + newPoly->dist = func_80086D24(-DOTXYZ(newNormal, vtxA)); + if (newNormal.y > 0.5f) { + s16 polyId = *polyStartIndex + i; + + DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.floor, &polyId); + } else if (newNormal.y < -0.8f) { + s16 polyId = *polyStartIndex + i; + + DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.ceiling, &polyId); + } else { + s16 polyId = *polyStartIndex + i; + + DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.wall, &polyId); + } + } + } + + if (pbgdata->numWaterBoxes > 0) { + for (wi = 0; wi < pbgdata->numWaterBoxes; wi++) { + WaterBox* waterBox; + Vec3f modelMinPos; + Vec3f worldMinPos; + Vec3f modelMinPosXOffset; + Vec3f worldMinPosXOffset; + Vec3f modelMinPosZOffset; + Vec3f worldMinPosZOffset; + + Math_Vec3s_ToVec3f(&modelMinPos, &pbgdata->waterBoxes[wi].minPos); + Math_Vec3f_Copy(&modelMinPosXOffset, &modelMinPos); + modelMinPosXOffset.x += pbgdata->waterBoxes[wi].xLength; + Math_Vec3f_Copy(&modelMinPosZOffset, &modelMinPos); + modelMinPosZOffset.z += pbgdata->waterBoxes[wi].zLength; + SkinMatrix_Vec3fMtxFMultXYZ(&sModelToWorldMtxF, &modelMinPos, &worldMinPos); + SkinMatrix_Vec3fMtxFMultXYZ(&sModelToWorldMtxF, &modelMinPosXOffset, &worldMinPosXOffset); + SkinMatrix_Vec3fMtxFMultXYZ(&sModelToWorldMtxF, &modelMinPosZOffset, &worldMinPosZOffset); + waterBox = &dyna->waterBoxList.boxes[*waterBoxStartIndex + wi]; + BgCheck_CalcWaterboxDimensions(&worldMinPos, &worldMinPosXOffset, &worldMinPosZOffset, &waterBox->minPos, + &waterBox->xLength, &waterBox->zLength); + waterBox->properties = pbgdata->waterBoxes[wi].properties; + } + } + *polyStartIndex += pbgdata->numPolygons; + *vtxStartIndex += pbgdata->numVertices; + *waterBoxStartIndex += pbgdata->numWaterBoxes; +} + +void DynaPoly_UnsetAllInteractFlags(PlayState* play, DynaCollisionContext* dyna, Actor* actor) { DynaPolyActor* dynaActor; s32 i; for (i = 0; i < BG_ACTOR_MAX; i++) { - if ((dyna->bgActorFlags[i] & 1)) { + if ((dyna->bgActorFlags[i] & BGACTOR_IN_USE)) { dynaActor = DynaPoly_GetActor(&play->colCtx, i); if ((dynaActor != NULL) && (&dynaActor->actor == actor)) { - DynaPolyActor_ResetState((DynaPolyActor*)actor); - return; + DynaPolyActor_UnsetAllInteractFlags((DynaPolyActor*)actor); + break; } } } @@ -3104,7 +3109,7 @@ void BgCheck_ResetFlagsIfLoadedActor(PlayState* play, DynaCollisionContext* dyna /** * original name: DynaPolyInfo_setup */ -void DynaPoly_Setup(PlayState* play, DynaCollisionContext* dyna) { +void DynaPoly_UpdateContext(PlayState* play, DynaCollisionContext* dyna) { DynaPolyActor* actor; s32 vtxStartIndex; s32 polyStartIndex; @@ -3118,7 +3123,7 @@ void DynaPoly_Setup(PlayState* play, DynaCollisionContext* dyna) { } for (i = 0; i < BG_ACTOR_MAX; i++) { - if (dyna->bgActorFlags[i] & 2) { + if (dyna->bgActorFlags[i] & BGACTOR_1) { // Initialize BgActor dyna->bgActorFlags[i] = 0; BgActor_Init(play, &dyna->bgActors[i]); @@ -3141,8 +3146,8 @@ void DynaPoly_Setup(PlayState* play, DynaCollisionContext* dyna) { polyStartIndex = 0; waterBoxStartIndex = 0; for (i = 0; i < BG_ACTOR_MAX; i++) { - if ((dyna->bgActorFlags[i] & 1) && !(dyna->bgActorFlags[i] & 2)) { - DynaPoly_ExpandSRT(play, dyna, i, &vtxStartIndex, &polyStartIndex, &waterBoxStartIndex); + if ((dyna->bgActorFlags[i] & BGACTOR_IN_USE) && !(dyna->bgActorFlags[i] & BGACTOR_1)) { + DynaPoly_AddBgActorToLookup(play, dyna, i, &vtxStartIndex, &polyStartIndex, &waterBoxStartIndex); } } dyna->bitFlag &= ~DYNAPOLY_INVALIDATE_LOOKUP; @@ -3160,7 +3165,8 @@ void func_800C756C(DynaCollisionContext* dyna, s32* numPolygons, s32* numVertice *numWaterBoxes = 0; for (i = 0; i < BG_ACTOR_MAX; i++) { - if ((dyna->bgActorFlags[i] & 1) && !(dyna->bgActorFlags[i] & 2) && !(dyna->bgActorFlags[i] & 4)) { + if ((dyna->bgActorFlags[i] & BGACTOR_IN_USE) && !(dyna->bgActorFlags[i] & BGACTOR_1) && + !(dyna->bgActorFlags[i] & BGACTOR_COLLISION_DISABLED)) { colHeader = dyna->bgActors[i].colHeader; *numPolygons += colHeader->numPolygons; *numVertices += colHeader->numVertices; @@ -3176,7 +3182,7 @@ void DynaPoly_UpdateBgActorTransforms(PlayState* play, DynaCollisionContext* dyn s32 i; for (i = 0; i < BG_ACTOR_MAX; i++) { - if (dyna->bgActorFlags[i] & 1) { + if (dyna->bgActorFlags[i] & BGACTOR_IN_USE) { DynaPoly_SetBgActorPrevTransform(play, &dyna->bgActors[i]); } } @@ -3206,7 +3212,8 @@ f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) { (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIB, 4) && (((dynaRaycast->actor != NULL) && (dynaRaycast->actor->category != ACTORCAT_PLAYER)) || ((dynaRaycast->actor == NULL) && (dynaRaycast->xpFlags != COLPOLY_IGNORE_CAMERA)))) || - ((dynaRaycast->unk_24 & 0x20) && func_800C9B68(dynaRaycast->colCtx, &polyList[id], dynaRaycast->unk1C))) { + ((dynaRaycast->unk_24 & 0x20) && + SurfaceType_IsSoft(dynaRaycast->colCtx, &polyList[id], dynaRaycast->unk1C))) { if (curNode->next == SS_NULL) { break; } else { @@ -3269,7 +3276,8 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) { *dynaRaycast->bgId = BGCHECK_SCENE; for (i = 0; i < BG_ACTOR_MAX; i++) { - if (!(dynaRaycast->colCtx->dyna.bgActorFlags[i] & 1) || (dynaRaycast->colCtx->dyna.bgActorFlags[i] & 2)) { + if (!(dynaRaycast->colCtx->dyna.bgActorFlags[i] & BGACTOR_IN_USE) || + (dynaRaycast->colCtx->dyna.bgActorFlags[i] & BGACTOR_1)) { continue; } @@ -3322,7 +3330,7 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) { if (!pauseState) { pauseState = dynaRaycast->play->pauseCtx.debugEditor != DEBUG_EDITOR_NONE; } - if (!pauseState && (dynaRaycast->colCtx->dyna.bgActorFlags[*dynaRaycast->bgId] & 2)) { + if (!pauseState && (dynaRaycast->colCtx->dyna.bgActorFlags[*dynaRaycast->bgId] & BGACTOR_1)) { curTransform = &dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].curTransform; polyMin = &dynaRaycast->dyna ->polyList[(u16)dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].dynaLookup.polyStartIndex]; @@ -3581,7 +3589,7 @@ s32 BgCheck_SphVsDynaWall(CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* resultPos = *pos; for (i = 0; i < BG_ACTOR_MAX; i++) { - if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 2)) { + if (!(colCtx->dyna.bgActorFlags[i] & BGACTOR_IN_USE) || (colCtx->dyna.bgActorFlags[i] & BGACTOR_1)) { continue; } if ((colCtx->dyna.bgActors + i)->actor == actor) { @@ -3703,7 +3711,7 @@ s32 BgCheck_CheckDynaCeiling(CollisionContext* colCtx, u16 xpFlags, f32* outY, V resultY = tempY; for (i = 0; i < BG_ACTOR_MAX; i++) { - if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 2)) { + if (!(colCtx->dyna.bgActorFlags[i] & BGACTOR_IN_USE) || (colCtx->dyna.bgActorFlags[i] & BGACTOR_1)) { continue; } if (actor == colCtx->dyna.bgActors[i].actor) { @@ -3849,7 +3857,7 @@ s32 BgCheck_CheckLineAgainstDyna(CollisionContext* colCtx, u16 xpFlags, Vec3f* p f32 by; for (i = 0; i < BG_ACTOR_MAX; i++) { - if ((colCtx->dyna.bgActorFlags[i] & 1) && !(colCtx->dyna.bgActorFlags[i] & 2)) { + if ((colCtx->dyna.bgActorFlags[i] & BGACTOR_IN_USE) && !(colCtx->dyna.bgActorFlags[i] & BGACTOR_1)) { if (actor != colCtx->dyna.bgActors[i].actor) { ay = posA->y; by = posB->y; @@ -3958,7 +3966,7 @@ s32 BgCheck_SphVsFirstDynaPoly(CollisionContext* colCtx, u16 xpFlags, CollisionP Sphere16 testSphere; for (i = 0; i < BG_ACTOR_MAX; i++) { - if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 2)) { + if (!(colCtx->dyna.bgActorFlags[i] & BGACTOR_IN_USE) || (colCtx->dyna.bgActorFlags[i] & BGACTOR_1)) { continue; } if (colCtx->dyna.bgActors[i].actor == actor) { @@ -4013,7 +4021,7 @@ void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, PlayState* play) { for (i = 0; i < BG_ACTOR_MAX; i++) { flag = dyna->bgActorFlags[i]; - if ((flag & 1) && !(flag & 2)) { + if ((flag & BGACTOR_IN_USE) && !(flag & BGACTOR_1)) { Actor_SetObjectDependency(play, dyna->bgActors[i].actor); CollisionHeader_SegmentedToVirtual(dyna->bgActors[i].colHeader); } @@ -4189,17 +4197,11 @@ Vec3s* BgCheck_GetBgCamFuncData(CollisionContext* colCtx, CollisionPoly* poly, s return BgCheck_GetBgCamFuncDataImpl(colCtx, SurfaceType_GetBgCamIndex(colCtx, poly, bgId), bgId); } -/** - * SurfaceType Get Scene Exit Index - */ u32 SurfaceType_GetSceneExitIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 8 & 0x1F; } -/** - * SurfaceType Get ? Property (& 0x0003_E000) - */ -u32 func_800C99D4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +FloorType SurfaceType_GetFloorType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 13 & 0x1F; } @@ -4210,126 +4212,85 @@ u32 func_800C99FC(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 18 & 7; } -/** - * SurfaceType Get Wall Property (Internal) - */ -u32 func_800C9A24(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +WallType SurfaceType_GetWallType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 21 & 0x1F; } -/** - * SurfaceType Get Wall Flags - */ -s32 func_800C9A4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { - return sWallFlags[func_800C9A24(colCtx, poly, bgId)]; +s32 SurfaceType_GetWallFlags(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return sWallFlags[SurfaceType_GetWallType(colCtx, poly, bgId)]; } -/** - * SurfaceType Is Wall Flag (1 << 0) Set - */ -s32 func_800C9A7C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { - return (func_800C9A4C(colCtx, poly, bgId) & 1) ? true : false; +s32 SurfaceType_CheckWallFlag0(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return (SurfaceType_GetWallFlags(colCtx, poly, bgId) & WALL_FLAG_0) ? true : false; } -/** - * SurfaceType Is Wall Flag (1 << 1) Set - */ -s32 func_800C9AB0(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { - return (func_800C9A4C(colCtx, poly, bgId) & 2) ? true : false; +s32 SurfaceType_CheckWallFlag1(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return (SurfaceType_GetWallFlags(colCtx, poly, bgId) & WALL_FLAG_1) ? true : false; } -/** - * SurfaceType Is Wall Flag (1 << 2) Set - */ -s32 func_800C9AE4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { - return (func_800C9A4C(colCtx, poly, bgId) & 4) ? true : false; +s32 SurfaceType_CheckWallFlag2(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return (SurfaceType_GetWallFlags(colCtx, poly, bgId) & WALL_FLAG_2) ? true : false; } -u32 func_800C9B18(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +FloorProperty SurfaceType_GetFloorProperty2(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 26 & 0xF; } -/** - * SurfaceType Get Floor Property - */ -u32 func_800C9B40(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +FloorProperty SurfaceType_GetFloorProperty(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 26 & 0xF; } -/** - * SurfaceType Is Floor Minus 1 - */ -u32 func_800C9B68(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +u32 SurfaceType_IsSoft(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 30 & 1; } -/** - * SurfaceType Is Horse Blocked - */ u32 SurfaceType_IsHorseBlocked(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 31 & 1; } -u32 func_800C9BB8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +SurfaceMaterial SurfaceType_GetMaterial(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 1) & 0xF; } -/** - * SurfaceType Get Poly Sfx - */ -u16 SurfaceType_GetSfx(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { - s32 id = func_800C9BB8(colCtx, poly, bgId); +u16 SurfaceType_GetSfxOffset(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + SurfaceMaterial surfaceMaterial = SurfaceType_GetMaterial(colCtx, poly, bgId); - if ((id < 0) || (id > 14)) { - return NA_SE_PL_WALK_GROUND - SFX_FLAG; + if ((surfaceMaterial < 0) || (surfaceMaterial >= ARRAY_COUNT(sSurfaceSfxOffsets))) { + return SURFACE_SFX_OFFSET_DIRT; } - return sSurfaceTypeSfx[id]; + + return sSurfaceSfxOffsets[surfaceMaterial]; } /** - * SurfaceType Get ? (same indexer as Get Poly Sfx) + * Checks if the material has the bitwise propertyType */ -s32 func_800C9C24(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, s32 arg3) { - s32 id = func_800C9BB8(colCtx, poly, bgId); +s32 SurfaceType_HasMaterialProperty(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, s32 propertyType) { + SurfaceMaterial surfaceMaterial = SurfaceType_GetMaterial(colCtx, poly, bgId); - if ((id < 0) || (id > 14)) { + if ((surfaceMaterial < 0) || (surfaceMaterial >= ARRAY_COUNT(sSurfaceMaterialProperties))) { return 0; } - return D_801B46C0[id] & arg3; + + return sSurfaceMaterialProperties[surfaceMaterial] & propertyType; } -/** - * SurfaceType get terrain slope surface - */ -u32 SurfaceType_GetSlope(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +FloorEffect SurfaceType_GetFloorEffect(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 4 & 3; } -/** - * SurfaceType get surface lighting setting - */ u32 SurfaceType_GetLightSettingIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 6 & 0x1F; } -/** - * SurfaceType get echo - */ u32 SurfaceType_GetEcho(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 11 & 0x3F; } -/** - * SurfaceType Is Hookshot Surface - */ u32 SurfaceType_IsHookshotSurface(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 17 & 1; } -/** - * CollisionPoly is ignored by entities - * Returns true if poly is ignored by entities, else false - */ s32 SurfaceType_IsIgnoredByEntities(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { u32 flags; @@ -4340,10 +4301,6 @@ s32 SurfaceType_IsIgnoredByEntities(CollisionContext* colCtx, CollisionPoly* pol return !!flags; } -/** - * CollisionPoly is ignored by projectiles - * Returns true if poly is ignored by projectiles, else false - */ s32 SurfaceType_IsIgnoredByProjectiles(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { u32 flags; @@ -4386,10 +4343,7 @@ s32 func_800C9DDC(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return !!flags; } -/** - * SurfaceType Get Conveyor Surface Speed - */ -u32 SurfaceType_GetConveyorSpeed(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +ConveyorSpeed SurfaceType_GetConveyorSpeed(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 18 & 7; } @@ -4407,9 +4361,6 @@ u32 SurfaceType_GetConveyorDirection(CollisionContext* colCtx, CollisionPoly* po return data & 0x3F; } -/** - * SurfaceType is Wall Damage - */ u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return (SurfaceType_GetData(colCtx, poly, bgId, 1) & 0x8000000) ? true : false; } @@ -4450,7 +4401,8 @@ s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f3 } for (i = 0; i < BG_ACTOR_MAX; i++) { - if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 4)) { + if (!(colCtx->dyna.bgActorFlags[i] & BGACTOR_IN_USE) || + (colCtx->dyna.bgActorFlags[i] & BGACTOR_COLLISION_DISABLED)) { continue; } bgActor = &colCtx->dyna.bgActors[i]; @@ -4535,8 +4487,8 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, for (i = 0; i < BG_ACTOR_MAX; i++) { - if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 4) || - (colCtx->dyna.bgActorFlags[i] & 2)) { + if (!(colCtx->dyna.bgActorFlags[i] & BGACTOR_IN_USE) || + (colCtx->dyna.bgActorFlags[i] & BGACTOR_COLLISION_DISABLED) || (colCtx->dyna.bgActorFlags[i] & BGACTOR_1)) { continue; } bgActor = &colCtx->dyna.bgActors[i]; @@ -4669,7 +4621,7 @@ s32 func_800CA6F0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* } } for (i = 0; i < BG_ACTOR_MAX; i++) { - if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 2)) { + if (!(colCtx->dyna.bgActorFlags[i] & BGACTOR_IN_USE) || (colCtx->dyna.bgActorFlags[i] & BGACTOR_1)) { continue; } bgActor = &colCtx->dyna.bgActors[i]; diff --git a/src/code/z_camera.c b/src/code/z_camera.c index f54fc93da..ea600b30e 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -1,22 +1,96 @@ +/** + * @file camera.c + * Implements the camera system. Camera functionality depends on the current combination of + * setting and mode. + * + * When working with the camera, you should be familiar with MM's coordinate system. + * Relative to the camera, the coordinate system follows the right hand rule: + * +X points right. + * +Y points up. + * +Z points out of the screen. + * + * You should also be familiar with Euler angles: 'pitch', 'yaw', and 'roll'. + * pitch: rotation about the X-axis, measured from +Y. + * Unlike yaw and roll, pitch is bounded in +-0x4000 (90 degrees). + * Pitch is 0 when the camera points parallel to the xz-plane (+Y points straight up). + * + * yaw: rotation about the Y-axis, measured from (absolute) +Z. + * Positive yaw rotates clockwise, towards +X. + * + * roll: rotation about the Z-axis, measured from the camera's right direction. + * Unfortunately, it's weird: For some reason, roll is flipped. Positive roll makes the camera + * rotate counterclockwise, which means the WORLD rotates clockwise. Luckily roll is rarely + * used. + * + * Remember the right hand rule: make a thumbs-up with your right hand, stick your thumb in the + * +direction (except for roll), and the angle follows the rotation of your curled fingers. + * + * Illustrations: + * Following the right hand rule, each hidden axis's positive direction points out of the screen. + * + * YZ-Plane (pitch) XZ-Plane (yaw) XY-Plane (roll -- Note flipped) + * +Y -Z +Y + * ^ ^ (into the ^ + * --|-- | screen) |<- + * +pitch / | \ -pitch | | \ -roll + * v | v | | | + * +Z <------O------> -Z -X <------O------> +X -X <------O------> +X + * | ^ | ^ | | + * | \ | / | / +roll + * | -yaw --|-- +yaw |<- + * v v v + * -Y +Z -Y + * + */ #include "global.h" #include "z64quake.h" #include "z64shrink_window.h" #include "z64view.h" +#include "overlays/actors/ovl_En_Horse/z_en_horse.h" + +void func_800DDFE0(Camera* camera); +s32 Camera_ChangeMode(Camera* camera, s16 mode); +s16 Camera_ChangeSettingFlags(Camera* camera, s16 setting, s16 flags); +s16 Camera_UnsetStateFlag(Camera* camera, s16 flags); #include "z_camera_data.inc.c" -// BSS -s16 D_801EDBF0; -f32 D_801EDBF4; -f32 D_801EDBF8; -CameraCollision D_801EDC00; - PlayState* sCamPlayState; SwingAnimation D_801EDC30[4]; Vec3f D_801EDDD0; Vec3f D_801EDDE0; Vec3f D_801EDDF0; +// Camera will reload its paramData. Usually that means setting the read-only data from what is stored in +// CameraModeValue arrays. Although sometimes some read-write data is reset as well +#define RELOAD_PARAMS(camera) ((camera->animState == 0) || (camera->animState == 10) || (camera->animState == 20)) + +/** + * Camera data is stored in both read-only data and OREG as s16, and then converted to the appropriate type during + * runtime. If a small f32 is being stored as an s16, it is common to store that value 100 times larger than the + * original value. This is then scaled back down during runtime with the CAM_RODATA_UNSCALE macro. + */ +#define CAM_RODATA_SCALE(x) ((x)*100.0f) +#define CAM_RODATA_UNSCALE(x) ((x)*0.01f) + +// Load the next value from camera read-only data stored in CameraModeValue +#define GET_NEXT_RO_DATA(values) ((values++)->val) +// Load the next value and scale down from camera read-only data stored in CameraModeValue +#define GET_NEXT_SCALED_RO_DATA(values) CAM_RODATA_UNSCALE(GET_NEXT_RO_DATA(values)) + +// Camera bg surface flags +#define FLG_ADJSLOPE (1 << 0) +#define FLG_OFFGROUND (1 << 7) + +#define CAM_CHANGE_SETTING_0 (1 << 0) +#define CAM_CHANGE_SETTING_1 (1 << 1) +#define CAM_CHANGE_SETTING_2 (1 << 2) +#define CAM_CHANGE_SETTING_3 (1 << 3) + +/*===============================================================*/ +/* Camera Internal Functions */ +/*===============================================================*/ + /** * Returns the absolute value for floats */ @@ -81,47 +155,63 @@ f32 Camera_QuadraticAttenuation(f32 xRange, f32 x) { return y; } -/* - * Performs linear interpoloation between `cur` and `target`. If `cur` is within - * `minDiff` units, the result is rounded up to `target` +/** + * @param[in] target target value + * @param[in] cur current value + * @param[in] stepScale fraction of (target - cur) to step towards target + * @param[in] minDiff minimum value of (target - cur) perform a step. Otherwise, return `target` + * + * @return new current value */ -f32 Camera_LerpCeilF(f32 target, f32 cur, f32 stepScale, f32 minDiff) { +f32 Camera_ScaledStepToCeilF(f32 target, f32 cur, f32 stepScale, f32 minDiff) { f32 diff = target - cur; f32 step = diff * stepScale; return (Camera_fabsf(diff) >= minDiff) ? cur + step : target; } -/* - * Performs linear interpoloation between `cur` and `target`. If `cur` is within - * `minDiff` units, the result is rounded up to `target` +/** + * @param[in] target target value + * @param[in] cur current value + * @param[in] stepScale fraction of (target - cur) to step towards target + * @param[in] minDiff minimum value of (target - cur) perform a step. Otherwise, return `target` + * + * @return new current value */ -s16 Camera_LerpCeilS(s16 target, s16 cur, f32 stepScale, s16 minDiff) { +s16 Camera_ScaledStepToCeilS(s16 target, s16 cur, f32 stepScale, s16 minDiff) { s16 diff = target - cur; s16 step = diff * stepScale + 0.5f; return (ABS(diff) >= minDiff) ? cur + step : target; } -/* - * Performs linear interpoloation between `cur` and `target`. If `cur` is within - * `minDiff` units, the result is rounded down to `cur` +/** + * @param[in] target target value + * @param[in] cur current value + * @param[in] stepScale fraction of (target - cur) to step towards target + * @param[in] minDiff minimum value of (target - cur) perform a step. Otherwise, return `current` + * + * @return new current value */ -s16 Camera_LerpFloorS(s16 target, s16 cur, f32 stepScale, s16 minDiff) { +s16 Camera_ScaledStepToFloorS(s16 target, s16 cur, f32 stepScale, s16 minDiff) { s16 diff = target - cur; s16 step = diff * stepScale + 0.5f; return (ABS(diff) >= minDiff) ? cur + step : cur; } -/* - * Performs linear interpoloation between `cur` and `target`. If `cur` is within - * `minDiff` units, the result is rounded up to `target`. Output is written to `cur` +/** + * @param[in] target target value + * @param[in] cur current value + * @param[in] stepScale fraction of (target - cur) to step towards target + * @param[in] minDiff minimum value of (target - cur) perform a step. Otherwise, return `target` + * + * @return new current value */ -void Camera_LerpCeilVec3f(Vec3f* target, Vec3f* cur, f32 xzStepScale, f32 yStepScale, f32 minDiff) { - cur->x = Camera_LerpCeilF(target->x, cur->x, xzStepScale, minDiff); - cur->y = Camera_LerpCeilF(target->y, cur->y, yStepScale, minDiff); - cur->z = Camera_LerpCeilF(target->z, cur->z, xzStepScale, minDiff); +void Camera_ScaledStepToCeilVec3f(Vec3f* target, Vec3f* cur, f32 xzStepScale, f32 yStepScale, f32 minDiff) { + cur->x = Camera_ScaledStepToCeilF(target->x, cur->x, xzStepScale, minDiff); + cur->y = Camera_ScaledStepToCeilF(target->y, cur->y, yStepScale, minDiff); + cur->z = Camera_ScaledStepToCeilF(target->z, cur->z, xzStepScale, minDiff); } void Camera_SetUpdateRatesFastPitch(Camera* camera) { @@ -149,14 +239,11 @@ void Camera_SetUpdateRatesSlow(Camera* camera) { camera->rUpdateRateInv = 1800.0f; camera->yawUpdateRateInv = 1800.0f; camera->pitchUpdateRateInv = 1800.0f; - camera->yOffsetUpdateRate = 0.01; - camera->xzOffsetUpdateRate = 0.01; - camera->fovUpdateRate = 0.01; + camera->yOffsetUpdateRate = 0.01f; + camera->xzOffsetUpdateRate = 0.01f; + camera->fovUpdateRate = 0.01f; } -/** - * Converts a 3D s16 vector into a 3D f32 vector - */ Vec3f* Camera_Vec3sToVec3f(Vec3f* dest, Vec3s* src) { Vec3f copy; @@ -176,29 +263,29 @@ s16 Camera_AngleDiffAndScale(s16 angle1, s16 angle2, f32 scale) { } /** - * Calculates the current offset between the camera's at-coordinates and the centered actor's coordinates + * Calculates the current offset between the camera's at-coordinates and the focal actors coordinates */ -void Camera_UpdateAtActorOffset(Camera* camera, Vec3f* actorOffset) { - camera->atActorOffset.x = camera->at.x - actorOffset->x; - camera->atActorOffset.y = camera->at.y - actorOffset->y; - camera->atActorOffset.z = camera->at.z - actorOffset->z; +void Camera_SetFocalActorAtOffset(Camera* camera, Vec3f* focalActorPos) { + camera->focalActorAtOffset.x = camera->at.x - focalActorPos->x; + camera->focalActorAtOffset.y = camera->at.y - focalActorPos->y; + camera->focalActorAtOffset.z = camera->at.z - focalActorPos->z; } f32 Camera_GetFocalActorHeight(Camera* camera) { - PosRot actorFocus; + PosRot focalActorFocus; Actor* focalActor = camera->focalActor; - f32 focalHeight; + f32 focalActorHeight; if (focalActor == &GET_PLAYER(camera->play)->actor) { - focalHeight = Player_GetHeight((Player*)focalActor); + focalActorHeight = Player_GetHeight((Player*)focalActor); } else { - Actor_GetFocus(&actorFocus, focalActor); - focalHeight = actorFocus.pos.y - camera->focalActorPosRot.pos.y; - if (focalHeight == 0.0f) { - focalHeight = 10.0f; + Actor_GetFocus(&focalActorFocus, focalActor); + focalActorHeight = focalActorFocus.pos.y - camera->focalActorPosRot.pos.y; + if (focalActorHeight == 0.0f) { + focalActorHeight = 10.0f; } } - return focalHeight; + return focalActorHeight; } f32 Camera_GetRunSpeedLimit(Camera* camera) { @@ -223,6 +310,7 @@ s32 func_800CB7CC(Camera* camera) { return 0; } } + s32 Camera_IsMountedOnHorse(Camera* camera) { Actor* focalActor = camera->focalActor; @@ -310,7 +398,7 @@ s32 func_800CB950(Camera* camera) { f32 yDiff; if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { - yDiff = Camera_fabsf(camera->focalActorPosRot.pos.y - camera->playerFloorHeight); + yDiff = Camera_fabsf(camera->focalActorPosRot.pos.y - camera->focalActorFloorHeight); phi_v0 = false; if (yDiff < 11.0f) { @@ -444,7 +532,7 @@ s32 Camera_IsUsingZoraFins(Camera* camera) { } s32 func_800CBC30(Camera* camera, f32 waterYMax, f32 waterYMin) { - if ((camera->playerFloorHeight != camera->waterYPos) && (camera->waterYPos < waterYMax) && + if ((camera->focalActorFloorHeight != camera->waterYPos) && (camera->waterYPos < waterYMax) && (camera->waterYPos > waterYMin)) { return true; } else { @@ -452,23 +540,258 @@ s32 func_800CBC30(Camera* camera, f32 waterYMax, f32 waterYMin) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBC84.s") +s32 func_800CBC84(Camera* camera, Vec3f* from, CameraCollision* to, s32 arg3) { + CollisionContext* colCtx = &camera->play->colCtx; + Vec3f toNewPos; + Vec3f toPoint; + Vec3f fromToNorm; + f32 floorPolyY; + CollisionPoly** floorPoly; + s32 floorBgId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBFA4.s") + OLib_Vec3fDistNormalize(&fromToNorm, from, &to->pos); + toPoint.x = to->pos.x + fromToNorm.x; + toPoint.y = to->pos.y + fromToNorm.y; + toPoint.z = to->pos.z + fromToNorm.z; + floorPoly = &to->poly; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC000.s") + if (!BgCheck_CameraLineTest1(colCtx, from, &toPoint, &toNewPos, floorPoly, (arg3 & 1) ? 0 : 1, 1, + (arg3 & 2) ? 0 : 1, -1, &floorBgId)) { + toNewPos = to->pos; + //! FAKE + if (1) {} + if (1) {} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC128.s") + toNewPos.y += 5.0f; + if ((arg3 != 0) && func_800CB7CC(camera)) { + to->poly = camera->focalActor->floorPoly; + floorBgId = camera->focalActor->floorBgId; + to->norm.x = COLPOLY_GET_NORMAL(to->poly->normal.x); + to->norm.y = COLPOLY_GET_NORMAL(to->poly->normal.y); + to->norm.z = COLPOLY_GET_NORMAL(to->poly->normal.z); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC1C4.s") + if (!Math3D_LineSegVsPlane(to->norm.x, to->norm.y, to->norm.z, to->poly->dist, from, &toPoint, &toNewPos, + 1)) { + floorPolyY = to->pos.y - 20.0f; + } else { + toNewPos.y += 5.0f; + floorPolyY = to->pos.y; + } + } else { + floorPolyY = BgCheck_CameraRaycastFloor2(colCtx, floorPoly, &floorBgId, &toNewPos); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC260.s") + if ((to->pos.y - floorPolyY) > 5.0f) { + to->norm.x = -fromToNorm.x; + to->norm.y = -fromToNorm.y; + to->norm.z = -fromToNorm.z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC488.s") + return 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC56C.s") + to->bgId = floorBgId; + to->norm.x = COLPOLY_GET_NORMAL(to->poly->normal.x); + to->norm.y = COLPOLY_GET_NORMAL(to->poly->normal.y); + to->norm.z = COLPOLY_GET_NORMAL(to->poly->normal.z); + to->pos.x = to->norm.x + toNewPos.x; + to->pos.y = to->norm.y + toNewPos.y; + to->pos.z = to->norm.z + toNewPos.z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC5C8.s") + return floorBgId + 1; +} + +void func_800CBFA4(Camera* camera, Vec3f* arg1, Vec3f* arg2, s32 arg3) { + CameraCollision sp20; + s32 pad; + + sp20.pos = *arg2; + func_800CBC84(camera, arg1, &sp20, arg3); + *arg2 = sp20.pos; +} + +/** + * Detects the collision poly between `from` and `to`, places collision info in `to` + */ +s32 Camera_BgCheckInfo(Camera* camera, Vec3f* from, CameraCollision* to) { + CollisionPoly* floorPoly; + Vec3f toNewPos; + Vec3f fromToNorm; + + if (BgCheck_CameraLineTest1(&camera->play->colCtx, from, &to->pos, &toNewPos, &to->poly, 1, 1, 1, -1, &to->bgId)) { + floorPoly = to->poly; + to->norm.x = COLPOLY_GET_NORMAL(floorPoly->normal.x); + to->norm.y = COLPOLY_GET_NORMAL(floorPoly->normal.y); + to->norm.z = COLPOLY_GET_NORMAL(floorPoly->normal.z); + to->pos = toNewPos; + + return to->bgId + 1; + } + + OLib_Vec3fDistNormalize(&fromToNorm, from, &to->pos); + to->norm.x = -fromToNorm.x; + to->norm.y = -fromToNorm.y; + to->norm.z = -fromToNorm.z; + + return 0; +} + +/** + * Detects if there is collision between `from` and `to` + */ +s32 Camera_BgCheck(Camera* camera, Vec3f* from, Vec3f* to) { + CollisionContext* colCtx = &camera->play->colCtx; + Vec3f intersect; + s32 bgId; + CollisionPoly* poly = NULL; + + if (BgCheck_CameraLineTest1(colCtx, from, to, &intersect, &poly, 1, 1, 1, -1, &bgId)) { + *to = intersect; + return true; + } + + return false; +} + +/** + * Checks if `from` to `to` is looking from the outside of a poly towards the front + */ +s32 Camera_CheckOOB(Camera* camera, Vec3f* from, Vec3f* to) { + s32 pad; + Vec3f intersect; + s32 pad2; + s32 bgId; + CollisionPoly* poly; + CollisionContext* colCtx = &camera->play->colCtx; + + poly = NULL; + if ((BgCheck_CameraLineTest1(colCtx, from, to, &intersect, &poly, 1, 1, 1, 0, &bgId)) && + (CollisionPoly_GetPointDistanceFromPlane(poly, from) < 0.0f)) { + return true; + } + + return false; +} + +s16 func_800CC260(Camera* camera, Vec3f* arg1, Vec3f* arg2, VecGeo* arg3, Actor** exclusions, s16 numExclusions) { + VecGeo sp90; + s32 ret; + s32 angleCount; + f32 rand; + PosRot playerFocus; + Vec3f sp64; + Player* player = GET_PLAYER(camera->play); + s32 i; + + sp64 = *arg2; + Actor_GetFocus(&playerFocus, &player->actor); // playerFocus unused + sp90 = *arg3; + + angleCount = ARRAY_COUNT(D_801B9E18); + + for (i = 0; i < angleCount; i++) { + OLib_AddVecGeoToVec3f(arg1, arg2, &sp90); + + if (!Camera_CheckOOB(camera, arg1, &sp64) && !func_800CBC30(camera, arg2->y, arg1->y) && + !CollisionCheck_LineOCCheck(camera->play, &camera->play->colChkCtx, arg2, arg1, exclusions, + numExclusions)) { + break; + } + + sp90.yaw = D_801B9E18[i] + arg3->yaw; + rand = Rand_ZeroOne(); + sp90.pitch = D_801B9E34[i] + (s16)(arg3->pitch * rand); + + if (sp90.pitch > 0x36B0) { // 76.9 degrees + sp90.pitch -= 0x3E80; // -87.9 degrees + } + if (sp90.pitch < -0x36B0) { // -76.9 degrees + sp90.pitch += 0x3A98; // 82.4 degrees + } + + sp90.r *= 0.9f; + sp64 = *arg2; + } + + *arg3 = sp90; + + if (i == angleCount) { + ret = -1; + } else { + ret = i; + } + + return ret; +} + +/** + * Gets the floor position underneath `chkPos`, and returns the normal of the floor to `floorNorm`, + * and bgId to `bgId`. If no floor is found, then the normal is a flat surface pointing upwards. + */ +f32 Camera_GetFloorYNorm(Camera* camera, Vec3f* floorNorm, Vec3f* chkPos, s32* bgId) { + CollisionContext* colCtx = &camera->play->colCtx; + CollisionPoly* floorPoly; + f32 floorY = BgCheck_EntityRaycastFloor3(colCtx, &floorPoly, bgId, chkPos); + + if (floorY == BGCHECK_Y_MIN) { + // no floor + floorNorm->x = 0.0f; + floorNorm->y = 1.0f; + floorNorm->z = 0.0f; + } else { + floorNorm->x = COLPOLY_GET_NORMAL(floorPoly->normal.x); + floorNorm->y = COLPOLY_GET_NORMAL(floorPoly->normal.y); + floorNorm->z = COLPOLY_GET_NORMAL(floorPoly->normal.z); + } + + return floorY; +} + +/** + * Gets the position of the floor from `pos` + */ +f32 Camera_GetFloorY(Camera* camera, Vec3f* pos) { + Vec3f posCheck; + Vec3f floorNorm; + s32 bgId; + + posCheck = *pos; + posCheck.y += 80.0f; + + return Camera_GetFloorYNorm(camera, &floorNorm, &posCheck, &bgId); +} + +/** + * Gets the position of the floor from `pos`, and if the floor is considered not solid, + * it checks the next floor below that. Returns the normal of the floor into `norm` + */ +f32 Camera_GetFloorYLayer(Camera* camera, Vec3f* norm, Vec3f* pos, s32* bgId) { + CollisionPoly* floorPoly; + CollisionContext* colCtx = &camera->play->colCtx; + f32 floorY; + + if (camera->focalActor != NULL) { + floorY = BgCheck_EntityRaycastFloor5_3(camera->play, &camera->play->colCtx, &floorPoly, bgId, + camera->focalActor, pos); + } else { + floorY = BgCheck_CameraRaycastFloor2(colCtx, &floorPoly, bgId, pos); + } + + if ((floorY == BGCHECK_Y_MIN) || + ((camera->focalActorFloorHeight < floorY) && !(COLPOLY_GET_NORMAL(floorPoly->normal.y) > 0.5f))) { + // no floor, or player is below the floor and floor is not considered steep + norm->x = 0.0f; + norm->y = 1.0f; + norm->z = 0.0f; + floorY = BGCHECK_Y_MIN; + } else { + norm->x = COLPOLY_GET_NORMAL(floorPoly->normal.x); + norm->y = COLPOLY_GET_NORMAL(floorPoly->normal.y); + norm->z = COLPOLY_GET_NORMAL(floorPoly->normal.z); + } + + return floorY; +} #define CAM_DATA_IS_BG (1 << 12) // if not set, then cam data is for actor cutscenes @@ -543,163 +866,5087 @@ s32 Camera_GetWaterBoxBgCamSetting(Camera* camera, f32* waterY) { return (camSetting == CAM_SET_NONE) ? -2 : camSetting; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC938.s") +void func_800CC938(Camera* camera) { + func_800DDFE0(camera); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC958.s") +/** + * Calculates the angle between points `from` and `to` + */ +s16 Camera_CalcXZAngle(Vec3f* to, Vec3f* from) { + return CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(from->x - to->x, from->z - to->z))); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC9C0.s") +// BSS +s16 D_801EDBF0; -s32 D_801B9E5C = 0; -f32 D_801B9E60 = 0.0f; +/** + * Calculates a pitch adjustment by sampling a position in front of the focal actor and testing the floor height. + * Used to detect if the focal actor is near a slope, edge, or cliff. + * + * @param camera + * @param viewYaw The yaw the camera is facing, gives a direction to sample a position + * @param shouldInit + * + * @return pitchOffset resulting pitch adjustment + */ +s16 Camera_GetPitchAdjFromFloorHeightDiffs(Camera* camera, s16 viewYaw, s16 shouldInit) { + static f32 sFloorYNear; + static f32 sFloorYFar; + static CameraCollision sFarColChk; + Vec3f focalActorPos; + Vec3f nearPos; + Vec3f floorNorm; + f32 checkOffsetY; + s16 pitchNear; + s16 pitchFar; + f32 floorYDiffFar; + f32 viewForwardsUnitX; + f32 viewForwardsUnitZ; + s32 bgId; + f32 nearDist; + f32 farDist; + f32 floorYDiffNear; + f32 focalActorHeight; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CCCEC.s") + viewForwardsUnitX = Math_SinS(viewYaw); + viewForwardsUnitZ = Math_CosS(viewYaw); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CD04C.s") + focalActorHeight = Camera_GetFocalActorHeight(camera); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CD288.s") + checkOffsetY = focalActorHeight * 1.2f; + nearDist = focalActorHeight * 1.0f; + farDist = focalActorHeight * 2.5f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CD2E0.s") + focalActorPos.x = camera->focalActorPosRot.pos.x; + focalActorPos.y = camera->focalActorFloorHeight + checkOffsetY; + focalActorPos.z = camera->focalActorPosRot.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CD2F0.s") + nearPos.x = focalActorPos.x + (nearDist * viewForwardsUnitX); + nearPos.y = focalActorPos.y; + nearPos.z = focalActorPos.z + (nearDist * viewForwardsUnitZ); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CD3E4.s") + if (shouldInit || ((camera->play->state.frames % 2) == 0)) { + sFarColChk.pos.x = focalActorPos.x + (farDist * viewForwardsUnitX); + sFarColChk.pos.y = focalActorPos.y; + sFarColChk.pos.z = focalActorPos.z + (farDist * viewForwardsUnitZ); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CD44C.s") + Camera_BgCheckInfo(camera, &focalActorPos, &sFarColChk); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CD634.s") + if (shouldInit) { + sFloorYNear = sFloorYFar = camera->focalActorFloorHeight; + } + } else { + farDist = OLib_Vec3fDistXZ(&focalActorPos, &sFarColChk.pos); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CD6CC.s") + sFarColChk.pos.x += sFarColChk.norm.x * 5.0f; + sFarColChk.pos.y += sFarColChk.norm.y * 5.0f; + sFarColChk.pos.z += sFarColChk.norm.z * 5.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CD6F8.s") + if (nearDist > farDist) { + nearDist = farDist; + sFloorYNear = sFloorYFar = Camera_GetFloorYLayer(camera, &floorNorm, &sFarColChk.pos, &bgId); + } else { + sFloorYNear = Camera_GetFloorYLayer(camera, &floorNorm, &nearPos, &bgId); + sFloorYFar = Camera_GetFloorYLayer(camera, &floorNorm, &sFarColChk.pos, &bgId); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CD834.s") + if (sFloorYNear == BGCHECK_Y_MIN) { + sFloorYNear = camera->focalActorFloorHeight; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CDA14.s") + if (sFloorYFar == BGCHECK_Y_MIN) { + sFloorYFar = sFloorYNear; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CDB6C.s") + floorYDiffNear = (sFloorYNear - camera->focalActorFloorHeight) * 0.8f; + floorYDiffFar = (sFloorYFar - camera->focalActorFloorHeight) * (20.0f * 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CDE6C.s") + pitchNear = CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(floorYDiffNear, nearDist))); + pitchFar = CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(floorYDiffFar, farDist))); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CE2B8.s") + return pitchNear + pitchFar; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CE5E0.s") +f32 func_800CCCEC(Camera* camera, s16 reset) { + static s32 D_801B9E5C = 0; + static f32 D_801B9E60 = 0.0f; + Vec3f offsetForwards; + Vec3f angledOffsetForwards; + PosRot focalActorPosRot; + CameraCollision camCollision; + f32 forwardsUnitZ; + f32 focalActorHeight; + f32 forwardsUnitX; + f32 distResult; + s16 yawForwardsOffset; + f32 distResultAdj; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CE79C.s") + focalActorHeight = Camera_GetFocalActorHeight(camera); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CE930.s") + if (reset) { + D_801B9E5C = 0; + D_801B9E60 = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CEAD8.s") + focalActorPosRot = camera->focalActorPosRot; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CEC38.s") + forwardsUnitX = Math_SinS(focalActorPosRot.rot.y); + forwardsUnitZ = Math_CosS(focalActorPosRot.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CED90.s") + offsetForwards.x = focalActorPosRot.pos.x + (30.0f * forwardsUnitX); + offsetForwards.y = focalActorPosRot.pos.y + focalActorHeight; + offsetForwards.z = focalActorPosRot.pos.z + (30.0f * forwardsUnitZ); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Noop.s") + camCollision.pos.x = focalActorPosRot.pos.x + (12.0f * forwardsUnitX); + camCollision.pos.y = offsetForwards.y; + camCollision.pos.z = focalActorPosRot.pos.z + (12.0f * forwardsUnitZ); + if ((camera->play->state.frames % 2) != 0) { + // Turn and project 65.92 degrees left + yawForwardsOffset = focalActorPosRot.rot.y + DEG_TO_BINANG(65.92f); + + angledOffsetForwards.x = (Math_SinS(yawForwardsOffset) * 50.0f) + offsetForwards.x; + angledOffsetForwards.y = offsetForwards.y; + angledOffsetForwards.z = (Math_CosS(yawForwardsOffset) * 50.0f) + offsetForwards.z; + + if ((Camera_BgCheckInfo(camera, &angledOffsetForwards, &camCollision) != 0) && + Camera_CheckOOB(camera, &offsetForwards, &angledOffsetForwards)) { + // Always going to result in 28.0f? + distResult = OLib_Vec3fDistXZ(&offsetForwards, &camCollision.pos); + + // (-D_801B9E60 < (50.0f - distResult)) + if (!((D_801B9E5C == 2) && (-D_801B9E60 >= (50.0f - distResult)))) { + D_801B9E5C = 1; + distResult = 50.0f - distResult; // 22.0f + D_801B9E60 = distResult; + + // if (distResult == 0.0f) + if (distResult == -distResult) { + distResultAdj = 0.0f; + } else { + distResultAdj = distResult; + } + + return distResultAdj; + } + } + } else { + // Turn and project 90 degrees right + yawForwardsOffset = focalActorPosRot.rot.y - DEG_TO_BINANG(90); + + angledOffsetForwards.x = (Math_SinS(yawForwardsOffset) * 50.0f) + offsetForwards.x; + angledOffsetForwards.y = offsetForwards.y; + angledOffsetForwards.z = (Math_CosS(yawForwardsOffset) * 50.0f) + offsetForwards.z; + + if ((Camera_BgCheckInfo(camera, &angledOffsetForwards, &camCollision) != 0) && + Camera_CheckOOB(camera, &offsetForwards, &angledOffsetForwards)) { + // Always going to result in 28.0f? + distResult = OLib_Vec3fDistXZ(&offsetForwards, &camCollision.pos); + + if (!((D_801B9E5C == 1) && (D_801B9E60 >= -(distResult - 50.0f)))) { + D_801B9E5C = 2; + distResult = distResult - 50.0f; + D_801B9E60 = distResult; + if (distResult == -distResult) { + distResultAdj = 0.0f; + } else { + distResultAdj = distResult; + } + return distResultAdj; + } + } + } + + if (D_801B9E5C != 0) { + distResult = D_801B9E60; + } else { + distResult = 0.0f; + } + + D_801B9E5C = 0; + D_801B9E60 = 0.0f; + + return distResult; +} + +/** + * Calculates a new Up vector from the pitch, yaw, roll + */ +Vec3f* Camera_CalcUpVec(Vec3f* viewUp, s16 pitch, s16 yaw, s16 roll) { + f32 sinP = Math_SinS(pitch); + f32 cosP = Math_CosS(pitch); + f32 sinY = Math_SinS(yaw); + f32 cosY = Math_CosS(yaw); + f32 sinR = Math_SinS(-roll); + f32 cosR = Math_CosS(-roll); + Vec3f up; + Vec3f baseUp; + Vec3f u; + Vec3f rollMtxRow1; + Vec3f rollMtxRow2; + Vec3f rollMtxRow3; + f32 pad; + + // Axis to roll around + u.x = cosP * sinY; + u.y = sinP; + u.z = cosP * cosY; + + // Matrix to apply the roll to the Up vector without roll + rollMtxRow1.x = ((1.0f - SQ(u.x)) * cosR) + SQ(u.x); + rollMtxRow1.y = ((u.x * u.y) * (1.0f - cosR)) - (u.z * sinR); + rollMtxRow1.z = ((u.z * u.x) * (1.0f - cosR)) + (u.y * sinR); + + rollMtxRow2.x = ((u.x * u.y) * (1.0f - cosR)) + (u.z * sinR); + rollMtxRow2.y = ((1.0f - SQ(u.y)) * cosR) + SQ(u.y); + rollMtxRow2.z = ((u.y * u.z) * (1.0f - cosR)) - (u.x * sinR); + + rollMtxRow3.x = ((u.z * u.x) * (1.0f - cosR)) - (u.y * sinR); + rollMtxRow3.y = ((u.y * u.z) * (1.0f - cosR)) + (u.x * sinR); + rollMtxRow3.z = ((1.0f - SQ(u.z)) * cosR) + SQ(u.z); + + // Up without roll + baseUp.x = -sinP * sinY; + baseUp.y = cosP; + baseUp.z = -sinP * cosY; + + // rollMtx * baseUp + up.x = DOTXYZ(baseUp, rollMtxRow1); + up.y = DOTXYZ(baseUp, rollMtxRow2); + up.z = DOTXYZ(baseUp, rollMtxRow3); + + *viewUp = up; + + return viewUp; +} + +f32 Camera_ClampLerpScale(Camera* camera, f32 maxLerpScale) { + f32 ret; + + if (camera->atLerpStepScale < 0.12f) { + ret = 0.12f; + } else if (camera->atLerpStepScale >= maxLerpScale) { + ret = maxLerpScale; + } else { + ret = 1.1f * camera->atLerpStepScale; + } + + return ret; +} + +void Camera_ResetActionFuncState(Camera* camera, s32 mode) { + camera->animState = 0; +} + +void Camera_UpdateInterface(s32 interfaceFlags) { + s32 hudVisibility; + + if ((interfaceFlags & CAM_LETTERBOX_MASK) != CAM_LETTERBOX_IGNORE) { + switch (interfaceFlags & CAM_LETTERBOX_SIZE_MASK) { + case CAM_LETTERBOX_SMALL: + sCameraLetterboxSize = 26; + break; + + case CAM_LETTERBOX_MEDIUM: + sCameraLetterboxSize = 27; + break; + + case CAM_LETTERBOX_LARGE: + sCameraLetterboxSize = 32; + break; + + default: + sCameraLetterboxSize = 0; + break; + } + + if (interfaceFlags & CAM_LETTERBOX_INSTANT) { + ShrinkWindow_Letterbox_SetSize(sCameraLetterboxSize); + } else { + ShrinkWindow_Letterbox_SetSizeTarget(sCameraLetterboxSize); + } + } + + if ((interfaceFlags & CAM_HUD_VISIBILITY_MASK) != CAM_HUD_VISIBILITY_IGNORE) { + hudVisibility = (interfaceFlags & CAM_HUD_VISIBILITY_MASK) >> CAM_HUD_VISIBILITY_SHIFT; + if (hudVisibility == (CAM_HUD_VISIBILITY_ALL >> CAM_HUD_VISIBILITY_SHIFT)) { + hudVisibility = 50; + } + if (hudVisibility != sCameraHudVisibility) { + sCameraHudVisibility = hudVisibility; + Interface_SetHudVisibility(sCameraHudVisibility); + } + } +} + +Vec3f* Camera_BgCheckCorner(Vec3f* dst, Vec3f* linePointA, Vec3f* linePointB, CameraCollision* pointAColChk, + CameraCollision* pointBColChk) { + Vec3f closestPoint; + + func_800CAA14(pointAColChk->poly, pointBColChk->poly, linePointA, linePointB, &closestPoint); + *dst = closestPoint; + + return dst; +} + +/** + * Checks collision between at and eyeNext, if `checkEye` is set, if there is no collsion between + * eyeNext->at, then eye->at is also checked. + * Returns: + * 0 if no collsion is found between at->eyeNext + * 1 if the angle between the polys is between 60 degrees and 120 degrees + * 3 ? + * 6 if the angle between the polys is greater than 120 degrees + */ +s32 func_800CD44C(Camera* camera, VecGeo* diffGeo, CameraCollision* camEyeCollision, CameraCollision* camAtCollision, + s16 checkEye) { + Vec3f* at = &camera->at; + s32 pad[2]; + s32 atEyeBgId; + s32 eyeAtBgId; + s32 ret; + f32 cosEyeAt; + CameraCollision camCollision; + + camEyeCollision->pos = camera->eyeNext; + + ret = 0; + + atEyeBgId = func_800CBC84(camera, at, camEyeCollision, 0); + if (atEyeBgId != 0) { + // collision found between at->ey + camAtCollision->pos = *at; + + OLib_Vec3fToVecGeo(&camEyeCollision->geoNorm, &camEyeCollision->norm); + + if (camEyeCollision->geoNorm.pitch > 0x2EE0) { // 65.9 degrees + camEyeCollision->geoNorm.yaw = diffGeo->yaw; + } + + if (checkEye & 1) { + memcpy(&camCollision, camAtCollision, sizeof(CameraCollision)); + } + + eyeAtBgId = Camera_BgCheckInfo(camera, &camera->eye, camAtCollision); + + if (eyeAtBgId == 0) { + // no collision from eyeNext->at + if (checkEye & 1) { + memcpy(camAtCollision, &camCollision, sizeof(CameraCollision)); + } else { + return 3; + } + } + + if (camEyeCollision->poly == camAtCollision->poly) { + // at->eyeNext and eyeNext->at is the same poly + return 3; + } + + OLib_Vec3fToVecGeo(&camAtCollision->geoNorm, &camAtCollision->norm); + + if (camAtCollision->geoNorm.pitch > 0x2EE0) { // 65.9 degrees + camAtCollision->geoNorm.yaw = BINANG_ROT180(diffGeo->yaw); + } + + if (atEyeBgId != eyeAtBgId) { + // different bgIds for at->eye[Next] and eye[Next]->at + ret = 3; + } else { + cosEyeAt = Math3D_Parallel(&camEyeCollision->norm, &camAtCollision->norm); + if (cosEyeAt < -0.5f) { + ret = 6; + } else if ((cosEyeAt > 0.5f) || (checkEye & 2)) { + ret = 3; + } else { + ret = 1; + } + } + } + return ret; +} + +/** + * Calculates how much to adjust the camera at's y value when on a slope. + */ +f32 Camera_CalcSlopeYAdj(Vec3f* floorNorm, s16 playerYRot, s16 eyeAtYaw, f32 adjAmt) { + f32 tmp; + VecGeo floorNormGeo; + + OLib_Vec3fToVecGeo(&floorNormGeo, floorNorm); + + tmp = Math_CosS(floorNormGeo.pitch) * Math_CosS(playerYRot - floorNormGeo.yaw); + + return (Camera_fabsf(tmp) * adjAmt) * Math_CosS(playerYRot - eyeAtYaw); +} + +f32 func_800CD6CC(Actor* actor) { + return sqrtf(gTargetRanges[actor->targetMode].rangeSq / gTargetRanges[actor->targetMode].leashScale); +} + +/** + * Calculates new at vector for the camera pointing in `eyeAtDir` + */ +s32 Camera_CalcAtDefault(Camera* camera, VecGeo* eyeAtDir, f32 yOffset, s16 calcSlope) { + Vec3f* at = &camera->at; + Vec3f focalActorAtOffsetTarget; + Vec3f atTarget; + s32 pad; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + f32 focalActorHeight = Camera_GetFocalActorHeight(camera); + + focalActorAtOffsetTarget.y = focalActorHeight + yOffset; + focalActorAtOffsetTarget.x = 0.0f; + focalActorAtOffsetTarget.z = 0.0f; + + if (calcSlope) { + focalActorAtOffsetTarget.y -= OLib_ClampMaxDist( + Camera_CalcSlopeYAdj(&camera->floorNorm, focalActorPosRot->rot.y, eyeAtDir->yaw, 25.0f), focalActorHeight); + } + + Camera_ScaledStepToCeilVec3f(&focalActorAtOffsetTarget, &camera->focalActorAtOffset, camera->xzOffsetUpdateRate, + camera->yOffsetUpdateRate, 0.1f); + + atTarget.x = focalActorPosRot->pos.x + camera->focalActorAtOffset.x; + atTarget.y = focalActorPosRot->pos.y + camera->focalActorAtOffset.y; + atTarget.z = focalActorPosRot->pos.z + camera->focalActorAtOffset.z; + + if (atTarget.y < (camera->focalActorFloorHeight + 10.0f)) { + atTarget.y = camera->focalActorFloorHeight + 10.0f; + } + + Camera_ScaledStepToCeilVec3f(&atTarget, at, camera->atLerpStepScale, camera->atLerpStepScale, 0.2f); + + return 1; +} + +s32 Camera_CalcAtForScreen(Camera* camera, VecGeo* eyeAtDir, f32 yOffset, f32* focalActorPosY, f32 deltaYMax) { + f32 deltaY; + Vec3f focalActorAtOffsetTarget; + Vec3f atTarget; + s32 pad; + f32 clampedDeltaY; + f32 clampedAbsScreenY; + s16 absScreenY; + s16 screenY; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + f32 focalActorHeight = Camera_GetFocalActorHeight(camera); + + focalActorAtOffsetTarget.y = focalActorHeight + yOffset; + focalActorAtOffsetTarget.x = 0.0f; + focalActorAtOffsetTarget.z = 0.0f; + + Actor_GetScreenPos(camera->play, camera->focalActor, &absScreenY, &screenY); + screenY -= SCREEN_HEIGHT / 2; + absScreenY = ABS(screenY); + + // result unused + clampedAbsScreenY = OLib_ClampMaxDist(absScreenY / (f32)(SCREEN_HEIGHT / 2), 1.0f); + + deltaY = focalActorPosRot->pos.y - *focalActorPosY; + clampedDeltaY = OLib_ClampMaxDist(deltaY, deltaYMax); + + if (absScreenY > (SCREEN_HEIGHT / 4)) { + absScreenY = SCREEN_HEIGHT / 4; + } + + clampedAbsScreenY = OLib_ClampMaxDist(absScreenY / (f32)(SCREEN_HEIGHT / 4), 1.0f); + + focalActorAtOffsetTarget.y -= clampedDeltaY * clampedAbsScreenY * clampedAbsScreenY; + Camera_ScaledStepToCeilVec3f(&focalActorAtOffsetTarget, &camera->focalActorAtOffset, camera->xzOffsetUpdateRate, + camera->yOffsetUpdateRate, 0.1f); + + atTarget.x = focalActorPosRot->pos.x + camera->focalActorAtOffset.x; + atTarget.y = focalActorPosRot->pos.y + camera->focalActorAtOffset.y; + atTarget.z = focalActorPosRot->pos.z + camera->focalActorAtOffset.z; + atTarget.y = CLAMP_MIN(atTarget.y, camera->focalActorFloorHeight + 10.0f); + + Camera_ScaledStepToCeilVec3f(&atTarget, &camera->at, camera->atLerpStepScale, camera->atLerpStepScale, 0.1f); + + return 1; +} + +s32 Camera_CalcAtForNormal1(Camera* camera, VecGeo* arg1, f32 yOffset, f32 forwardDist) { + PosRot* focalActorPosRot = &camera->focalActorPosRot; + Vec3f focalActorAtOffsetTarget; + Vec3f atTarget; + Vec3f collisionFromPos; + s32 pad; + f32 focalActorHeight = Camera_GetFocalActorHeight(camera); + + focalActorAtOffsetTarget.x = Math_SinS(focalActorPosRot->rot.y) * forwardDist; + focalActorAtOffsetTarget.z = Math_CosS(focalActorPosRot->rot.y) * forwardDist; + focalActorAtOffsetTarget.y = focalActorHeight + yOffset; + + Camera_ScaledStepToCeilVec3f(&focalActorAtOffsetTarget, &camera->focalActorAtOffset, camera->xzOffsetUpdateRate, + camera->yOffsetUpdateRate, 0.1f); + + atTarget.x = focalActorPosRot->pos.x + camera->focalActorAtOffset.x; + atTarget.y = focalActorPosRot->pos.y + camera->focalActorAtOffset.y; + atTarget.z = focalActorPosRot->pos.z + camera->focalActorAtOffset.z; + + collisionFromPos.x = focalActorPosRot->pos.x; + collisionFromPos.y = atTarget.y; + collisionFromPos.z = focalActorPosRot->pos.z; + + if (Camera_BgCheck(camera, &collisionFromPos, &atTarget)) { + atTarget.x -= camera->focalActorAtOffset.x - (atTarget.x - collisionFromPos.x); + atTarget.z -= camera->focalActorAtOffset.z - (atTarget.z - collisionFromPos.z); + } + + Camera_ScaledStepToCeilVec3f(&atTarget, &camera->at, camera->atLerpStepScale, camera->atLerpStepScale, 0.2f); + + return 1; +} + +/** + * Adjusts the camera's at position for Camera_Parallel1 + */ +s32 Camera_CalcAtForParallel(Camera* camera, VecGeo* arg1, f32 yOffset, f32 xzOffsetMax, f32* focalActorPosY, + s16 flags) { + f32 pad; + Vec3f focalActorAtOffsetTarget; + Vec3f atTarget; + f32 fovHeight; + Vec3f* at = &camera->at; + f32 deltaY; + f32 eyeAtDistXZ; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + f32 focalActorHeight = Camera_GetFocalActorHeight(camera); + VecGeo focalActorAtOffsetTargetGeo; + + // Calculate the `focalActorAtOffsetTarget` + // @TODO: Only uses `PARALLEL1_FLAG_` flags, but may need separate flags for `CalcAt` system + if (flags & 0x40) { + focalActorAtOffsetTargetGeo.r = func_800CCCEC(camera, flags & 0x10); + focalActorAtOffsetTargetGeo.yaw = focalActorPosRot->rot.y + 0x4000; + focalActorAtOffsetTargetGeo.pitch = 0; + OLib_VecGeoToVec3f(&focalActorAtOffsetTarget, &focalActorAtOffsetTargetGeo); + } else { + f32 xOffset = camera->focalActorAtOffset.x + camera->unk_0F0.x; + f32 zOffset = camera->focalActorAtOffset.z + camera->unk_0F0.z; + + if (sqrtf(SQ(xOffset) + SQ(zOffset)) < xzOffsetMax) { + focalActorAtOffsetTarget.x = xOffset; + focalActorAtOffsetTarget.z = zOffset; + } else { + focalActorAtOffsetTarget.x = camera->focalActorAtOffset.x; + focalActorAtOffsetTarget.z = camera->focalActorAtOffset.z; + } + } + + focalActorAtOffsetTarget.y = focalActorHeight + yOffset; + + // focalActorAtOffsetTarget.y based on slope + if (PREG(76) && flags) { + focalActorAtOffsetTarget.y -= + Camera_CalcSlopeYAdj(&camera->floorNorm, focalActorPosRot->rot.y, arg1->yaw, 25.0f); + } + + // Adjust posOffsetTarget.y based on something + if (func_800CB950(camera)) { + *focalActorPosY = Camera_ScaledStepToCeilF(focalActorPosRot->pos.y, *focalActorPosY, 0.4f, 0.1f); + deltaY = focalActorPosRot->pos.y - *focalActorPosY; + focalActorAtOffsetTarget.y -= deltaY; + Camera_ScaledStepToCeilVec3f(&focalActorAtOffsetTarget, &camera->focalActorAtOffset, camera->xzOffsetUpdateRate, + camera->yOffsetUpdateRate, 0.1f); + } else { + deltaY = focalActorPosRot->pos.y - *focalActorPosY; + eyeAtDistXZ = OLib_Vec3fDistXZ(at, &camera->eye); + + // Math_FTanF + // Get the height based on 80% of the fov + fovHeight = func_80086760(DEG_TO_RAD(camera->fov * (0.8f * 0.5f))) * eyeAtDistXZ; + + if (deltaY > fovHeight) { + //! FAKE + if (1) {} + *focalActorPosY += deltaY - fovHeight; + deltaY = fovHeight; + } else if (deltaY < -fovHeight) { + *focalActorPosY += deltaY + fovHeight; + deltaY = -fovHeight; + } + + focalActorAtOffsetTarget.y -= deltaY; + Camera_ScaledStepToCeilVec3f(&focalActorAtOffsetTarget, &camera->focalActorAtOffset, 0.3f, 0.2f, 0.1f); + camera->xzOffsetUpdateRate = 0.3f; + camera->yOffsetUpdateRate = 0.2f; + } + + atTarget.x = focalActorPosRot->pos.x + camera->focalActorAtOffset.x; + atTarget.y = focalActorPosRot->pos.y + camera->focalActorAtOffset.y; + atTarget.z = focalActorPosRot->pos.z + camera->focalActorAtOffset.z; + Camera_ScaledStepToCeilVec3f(&atTarget, at, camera->atLerpStepScale, camera->atLerpStepScale, 0.2f); + + return 1; +} + +s32 Camera_CalcAtForFriendlyLockOn(Camera* camera, VecGeo* eyeAtDir, Vec3f* targetPos, f32 yOffset, f32 distance, + f32* yPosOffset, VecGeo* outPlayerToTargetDir, s16 flags) { + Vec3f* at = &camera->at; + Vec3f focalActorAtOffsetTarget; + Vec3f atTarget; + Vec3f sp68; + f32 temp_f0_6; + VecGeo sp5C; + f32 deltaY; + f32 fovHeight; + f32 phi_f16; + f32 focalActorHeight = Camera_GetFocalActorHeight(camera); + f32 sp50; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + + focalActorAtOffsetTarget.y = focalActorHeight + yOffset; + focalActorAtOffsetTarget.x = 0.0f; + focalActorAtOffsetTarget.z = 0.0f; + + if (PREG(76) && (flags & FLG_ADJSLOPE)) { + focalActorAtOffsetTarget.y -= + Camera_CalcSlopeYAdj(&camera->floorNorm, camera->focalActorPosRot.rot.y, eyeAtDir->yaw, 25.0f); + } + + atTarget = focalActorPosRot->pos; + atTarget.y += focalActorHeight; + + OLib_Vec3fDiffToVecGeo(outPlayerToTargetDir, &atTarget, targetPos); + + sp5C = *outPlayerToTargetDir; + sp5C.r = (distance < sp5C.r) ? (sp5C.r * 0.2f) : ((sp5C.r * 0.9f) - (sp5C.r * 0.7f * (sp5C.r / distance))); + + if (flags & FLG_OFFGROUND) { + sp5C.r *= 0.2f; + camera->yOffsetUpdateRate = camera->xzOffsetUpdateRate = 0.01f; + } + + OLib_VecGeoToVec3f(&sp68, &sp5C); + + focalActorAtOffsetTarget.x += sp68.x; + focalActorAtOffsetTarget.y += sp68.y; + focalActorAtOffsetTarget.z += sp68.z; + + if (func_800CB950(camera)) { + *yPosOffset = Camera_ScaledStepToCeilF(focalActorPosRot->pos.y, *yPosOffset, 0.4f, 0.1f); + deltaY = focalActorPosRot->pos.y - *yPosOffset; + focalActorAtOffsetTarget.y -= deltaY; + Camera_ScaledStepToCeilVec3f(&focalActorAtOffsetTarget, &camera->focalActorAtOffset, camera->xzOffsetUpdateRate, + camera->yOffsetUpdateRate, 0.1f); + } else { + if (!(flags & 0x80)) { + deltaY = focalActorPosRot->pos.y - *yPosOffset; + sp50 = OLib_Vec3fDistXZ(at, &camera->eye); + phi_f16 = sp50; + func_80086B30(deltaY, sp50); + fovHeight = func_80086760(DEG_TO_RAD(camera->fov * 0.4f)) * phi_f16; + + if (fovHeight < deltaY) { + *yPosOffset += deltaY - fovHeight; + deltaY = fovHeight; + } else if (deltaY < -fovHeight) { + *yPosOffset += deltaY + fovHeight; + deltaY = -fovHeight; + } + focalActorAtOffsetTarget.y -= deltaY; + } else { + deltaY = focalActorPosRot->pos.y - *yPosOffset; + temp_f0_6 = func_80086B30(deltaY, OLib_Vec3fDistXZ(at, &camera->eye)); + + if (temp_f0_6 > 0.34906584f) { // (M_PI / 9) + phi_f16 = 1.0f - sin_rad(temp_f0_6 - 0.34906584f); + } else if (temp_f0_6 < -0.17453292f) { // (M_PI / 18) + phi_f16 = 1.0f - sin_rad(-0.17453292f - temp_f0_6); + } else { + phi_f16 = 1.0f; + } + + focalActorAtOffsetTarget.y -= deltaY * phi_f16; + } + + Camera_ScaledStepToCeilVec3f(&focalActorAtOffsetTarget, &camera->focalActorAtOffset, 0.5f, 0.5f, 0.1f); + camera->xzOffsetUpdateRate = 0.5f; + camera->yOffsetUpdateRate = 0.5f; + } + + atTarget.x = focalActorPosRot->pos.x + camera->focalActorAtOffset.x; + atTarget.y = focalActorPosRot->pos.y + camera->focalActorAtOffset.y; + atTarget.z = focalActorPosRot->pos.z + camera->focalActorAtOffset.z; + Camera_ScaledStepToCeilVec3f(&atTarget, at, camera->atLerpStepScale, camera->atLerpStepScale, 0.2f); + + return 1; +} + +s32 Camera_CalcAtForEnemyLockOn(Camera* camera, f32* arg1, s32 arg2, f32 yOffset, f32 arg4, f32 arg5, f32* arg6, + VecGeo* arg7, s16 flags) { + PosRot* focalActorPosRot = &camera->focalActorPosRot; + Vec3f focalActorAtOffsetTarget; + Vec3f atTarget; + Vec3f sp60; + VecGeo sp58; + f32 temp_f0_3; + f32 deltaY; + f32 new_var2; + f32 sp4C; + f32 phi_f14; + f32 fovHeight; + + focalActorAtOffsetTarget.y = Camera_GetFocalActorHeight(camera) + yOffset; + focalActorAtOffsetTarget.x = 0.0f; + focalActorAtOffsetTarget.z = 0.0f; + + sp58 = *arg7; + sp58.r = arg7->r * (arg5 * arg4); + + if (flags & 0x80) { + camera->yOffsetUpdateRate = 0.01f; + camera->xzOffsetUpdateRate = 0.01f; + } + + OLib_VecGeoToVec3f(&sp60, &sp58); + + focalActorAtOffsetTarget.x += sp60.x; + focalActorAtOffsetTarget.y += sp60.y; + focalActorAtOffsetTarget.z += sp60.z; + + if (func_800CB950(camera)) { + phi_f14 = *arg6; + *arg6 = Camera_ScaledStepToCeilF(focalActorPosRot->pos.y, phi_f14, 0.4f, 0.1f); + deltaY = focalActorPosRot->pos.y - *arg6; + focalActorAtOffsetTarget.y -= deltaY; + Camera_ScaledStepToCeilVec3f(&focalActorAtOffsetTarget, &camera->focalActorAtOffset, camera->xzOffsetUpdateRate, + camera->yOffsetUpdateRate, 0.1f); + } else { + //! FAKE: + if (focalActorPosRot->pos.x) {} + + //! FAKE: unnecessary temp? + new_var2 = *arg1; + sp4C = new_var2; + deltaY = focalActorPosRot->pos.y - *arg6; + temp_f0_3 = func_80086B30(deltaY, sp4C); + + if (!(flags & 0x80)) { + fovHeight = func_80086760(DEG_TO_RAD(camera->fov * 0.4f)) * sp4C; + + if (fovHeight < deltaY) { + *arg6 += deltaY - fovHeight; + deltaY = fovHeight; + } else if (deltaY < -fovHeight) { + *arg6 += deltaY + fovHeight; + deltaY = -fovHeight; + } + + focalActorAtOffsetTarget.y -= deltaY; + } else { + if (temp_f0_3 > 0.34906584f) { // (M_PI / 9) + phi_f14 = 1.0f - sin_rad(temp_f0_3 - 0.34906584f); + } else if (temp_f0_3 < -0.17453292f) { // (M_PI / 18) + phi_f14 = 1.0f - sin_rad(-0.17453292f - temp_f0_3); + } else { + phi_f14 = 1.0f; + } + + focalActorAtOffsetTarget.y -= deltaY * phi_f14; + } + Camera_ScaledStepToCeilVec3f(&focalActorAtOffsetTarget, &camera->focalActorAtOffset, 0.5f, 0.5f, 0.1f); + camera->xzOffsetUpdateRate = 0.5f; + camera->yOffsetUpdateRate = 0.5f; + } + + atTarget.x = focalActorPosRot->pos.x + camera->focalActorAtOffset.x; + atTarget.y = focalActorPosRot->pos.y + camera->focalActorAtOffset.y; + atTarget.z = focalActorPosRot->pos.z + camera->focalActorAtOffset.z; + Camera_ScaledStepToCeilVec3f(&atTarget, &camera->at, camera->atLerpStepScale, camera->atLerpStepScale, 0.2f); + + return true; +} + +s32 Camera_CalcAtForHorse(Camera* camera, VecGeo* eyeAtDir, f32 yOffset, f32* yPosOffset, s16 calcSlope) { + Vec3f* at = &camera->at; + Vec3f posOffsetTarget; + Vec3f atTarget; + s32 pad[2]; + f32 focalActorHeight = Camera_GetFocalActorHeight(camera); + Player* player = (Player*)camera->focalActor; + PosRot horsePosRot; + + Actor_GetWorld(&horsePosRot, player->rideActor); + + if (EN_HORSE_CHECK_JUMPING((EnHorse*)player->rideActor)) { + horsePosRot.pos.y -= 49.0f; + *yPosOffset = Camera_ScaledStepToCeilF(horsePosRot.pos.y, *yPosOffset, 0.1f, 0.1f); + camera->atLerpStepScale = Camera_ScaledStepToCeilF(0.4f, camera->atLerpStepScale, 0.2f, 0.02f); + } else { + *yPosOffset = Camera_ScaledStepToCeilF(horsePosRot.pos.y, *yPosOffset, 0.5f, 0.1f); + } + + posOffsetTarget.x = 0.0f; + posOffsetTarget.y = focalActorHeight + yOffset; + posOffsetTarget.z = 0.0f; + + if (calcSlope) { + posOffsetTarget.y -= + Camera_CalcSlopeYAdj(&camera->floorNorm, camera->focalActorPosRot.rot.y, eyeAtDir->yaw, 25.0f); + } + + Camera_ScaledStepToCeilVec3f(&posOffsetTarget, &camera->focalActorAtOffset, camera->xzOffsetUpdateRate, + camera->yOffsetUpdateRate, 0.1f); + + atTarget.x = camera->focalActorAtOffset.x + horsePosRot.pos.x; + atTarget.y = camera->focalActorAtOffset.y + horsePosRot.pos.y; + atTarget.z = camera->focalActorAtOffset.z + horsePosRot.pos.z; + Camera_ScaledStepToCeilVec3f(&atTarget, at, camera->atLerpStepScale, camera->atLerpStepScale, 0.2f); + + return true; +} + +f32 Camera_ClampDist1(Camera* camera, f32 dist, f32 minDist, f32 maxDist, s16 timer) { + f32 distTarget; + + if ((dist / maxDist) > 1.2f) { + distTarget = maxDist; + + camera->rUpdateRateInv = 20.0f / (dist / maxDist); + if ((20.0f / (dist / maxDist)) < 10) { + camera->rUpdateRateInv = 10; + } + } else if (dist < minDist) { + distTarget = minDist; + + camera->rUpdateRateInv = + Camera_ScaledStepToCeilF((timer != 0) ? 10.0f : 20.0f, camera->rUpdateRateInv, 0.5f, 0.1f); + } else if (maxDist < dist) { + distTarget = maxDist; + + camera->rUpdateRateInv = + Camera_ScaledStepToCeilF((timer != 0) ? 10.0f : 20.0f, camera->rUpdateRateInv, 0.5f, 0.1f); + } else { + distTarget = dist; + + camera->rUpdateRateInv = + Camera_ScaledStepToCeilF((timer != 0) ? 20.0f : 1.0f, camera->rUpdateRateInv, 0.5f, 0.1f); + } + + return Camera_ScaledStepToCeilF(distTarget, camera->dist, 1.0f / camera->rUpdateRateInv, 0.1f); +} + +f32 Camera_ClampDist2(Camera* camera, f32 dist, f32 minDist, f32 maxDist, s16 timer) { + f32 distTarget; + + if (timer == 0) { + distTarget = ((maxDist * 0.25f) > 80.0f) ? maxDist * 0.25f : 80.0f; + + camera->rUpdateRateInv = Camera_ScaledStepToCeilF(1000.0f, camera->rUpdateRateInv, 0.5f, 0.1f); + } else if ((dist / maxDist) > 1.2f) { + distTarget = maxDist; + + camera->rUpdateRateInv = 20.0f / (dist / maxDist); + if ((20.0f / (dist / maxDist)) < 10.0f) { + camera->rUpdateRateInv = 10.0f; + } + } else if (dist < minDist) { + distTarget = minDist; + + camera->rUpdateRateInv = Camera_ScaledStepToCeilF(20.0f, camera->rUpdateRateInv, 0.5f, 0.1f); + } else if (maxDist < dist) { + distTarget = maxDist; + + camera->rUpdateRateInv = Camera_ScaledStepToCeilF(20.0f, camera->rUpdateRateInv, 0.5f, 0.1f); + } else { + distTarget = dist; + + camera->rUpdateRateInv = Camera_ScaledStepToCeilF(1.0f, camera->rUpdateRateInv, 0.5f, 0.1f); + } + + return Camera_ScaledStepToCeilF(distTarget, camera->dist, 1.0f / camera->rUpdateRateInv, 0.1f); +} + +/** + * Calculates the camera pitch to update to as player moves around + * The pitch target starts with a default value on a flat surface, then standing on a sloped surface will create an + * offset in default pitch Camera "AI" for pitch + */ +s16 Camera_CalcDefaultPitch(Camera* camera, s16 pitch, s16 flatSurfacePitchTarget, s16 slopePitchAdj) { + f32 attenuation; + f32 pitchStepScale; + f32 t; + s16 slopePitchAdjAttenuated; + s16 pitchMag = ABS(pitch); + s16 pitchTarget; + + // if slopePitchAdj is positive, then it is attenuated by a factor of Math_CosS(slopePitchAdj) + slopePitchAdjAttenuated = (slopePitchAdj > 0) ? (s16)(Math_CosS(slopePitchAdj) * slopePitchAdj) : slopePitchAdj; + pitchTarget = flatSurfacePitchTarget - slopePitchAdjAttenuated; + + if (ABS(pitchTarget) < pitchMag) { + // pitch is decreasing + pitchStepScale = (1.0f / camera->pitchUpdateRateInv) * 3.0f; + } else { + // pitch is increasing + t = pitchMag * (1.0f / DEG_TO_BINANG(79.655f)); + attenuation = + Camera_QuadraticAttenuation(0.8f, 1.0f - t); // attenuation starts above pitch = 0xB54 (16 degrees) + pitchStepScale = (1.0f / camera->pitchUpdateRateInv) * attenuation; + } + + return Camera_ScaledStepToCeilS(pitchTarget, pitch, pitchStepScale, 5); +} + +/** + * Calculates the camera pitch to update to as player moves around + * The yaw target starts with a default value, but will only update to that target yaw in proportion to players velocity + * No velocity means yaw does not update + * Camera "AI" for yaw + */ +s16 Camera_CalcDefaultYaw(Camera* camera, s16 yaw, s16 target, f32 attenuationYawDiffRange, + f32 attenuationYawDiffInterpParam) { + f32 attenuationYawDiffAdj; + f32 attenuationYawDiff; + f32 attenuationYawDiffParam; + f32 attenuationSpeedRatio; + f32 yawUpdRate; + s16 yawDiffToTarget; + + if (camera->xzSpeed > 0.001f) { + yawDiffToTarget = target - BINANG_ROT180(yaw); + attenuationYawDiffParam = BINANG_ROT180(yawDiffToTarget) / (f32)0x8000; + } else { + yawDiffToTarget = target - BINANG_ROT180(yaw); + attenuationYawDiffParam = 0.3f; + } + + // Attenuation 1 based on YawDiffToTarget. + attenuationYawDiff = Camera_QuadraticAttenuation(attenuationYawDiffRange, attenuationYawDiffParam); + attenuationYawDiffAdj = LERPIMP(attenuationYawDiff, 1.0f, attenuationYawDiffInterpParam); + attenuationYawDiffAdj = CLAMP_MIN(attenuationYawDiffAdj, 0.0f); + + // attenuation 2 based on SpeedRatio + attenuationSpeedRatio = Camera_QuadraticAttenuation(0.5f, camera->speedRatio); + + yawUpdRate = 1.0f / camera->yawUpdateRateInv; + return yaw + (s16)(yawDiffToTarget * attenuationYawDiffAdj * attenuationSpeedRatio * yawUpdRate); +} + +void Camera_CalcDefaultSwing(Camera* camera, VecGeo* arg1, VecGeo* arg2, f32 arg3, f32 arg4, SwingAnimation* swing2, + s16* flags) { + SwingAnimation* swing = swing2; + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + Vec3f peekAroundPoint; + s32 sp8C = 0; + f32 sp88; + s32 checkEyeBit1; + s32 checkEyeBit2; + CameraCollision sp58; + VecGeo sp50; + Vec3f* sp30; + + if (swing->unk_64 == 1) { + if (arg3 < (sp88 = OLib_Vec3fDist(at, &swing->collisionClosePoint))) { + //! FAKE: + dummy:; + swing->unk_64 = 0; + } else if ((sp88 = Math3D_SignedDistanceFromPlane(swing->eyeAtColChk.norm.x, swing->eyeAtColChk.norm.y, + swing->eyeAtColChk.norm.z, swing->eyeAtColChk.poly->dist, + at)) > 0.0f) { + swing->unk_64 = 0; + } else if ((sp88 = OLib_Vec3fDist(eye, &swing->eyeAtColChk.pos)) < 10.0f) { + swing->unk_64 = 0; + } else if ((sp88 = Math3D_SignedDistanceFromPlane(swing->atEyeColChk.norm.x, swing->atEyeColChk.norm.y, + swing->atEyeColChk.norm.z, swing->atEyeColChk.poly->dist, + eye)) > 0.0f) { + swing->unk_64 = 0; + } else if (swing->atEyeColChk.norm.y > 0.50f) { + swing->unk_64 = 0; + } else { + Math3D_AngleBetweenVectors(&camera->unk_0F0, &swing->eyeAtColChk.norm, &sp88); + if (sp88 > 0.0f) { + swing->unk_64 = 0; + } + } + + if (swing->unk_64 == 1) { + sp8C = 2; + } + } else if (swing->unk_64 == 2) { + swing->unk_64 = 0; + } + + if (sp8C == 0) { + if (*flags & 2) { + checkEyeBit1 = 1 << 1; + } else { + checkEyeBit1 = 0; + } + + if (swing->unk_64 != 1) { + checkEyeBit2 = 1 << 0; + } else { + checkEyeBit2 = 0; + } + + sp8C = + func_800CD44C(camera, arg1, &swing->atEyeColChk, &swing->eyeAtColChk, ((s16)checkEyeBit2 | checkEyeBit1)); + } + + switch (sp8C) { + case 1: + Camera_BgCheckCorner(&swing->collisionClosePoint, &camera->at, &camera->eyeNext, &swing->atEyeColChk, + &swing->eyeAtColChk); + // fallthrough + case 2: + peekAroundPoint.x = swing->collisionClosePoint.x + (swing->atEyeColChk.norm.x + swing->eyeAtColChk.norm.x); + peekAroundPoint.y = swing->collisionClosePoint.y + (swing->atEyeColChk.norm.y + swing->eyeAtColChk.norm.y); + peekAroundPoint.z = swing->collisionClosePoint.z + (swing->atEyeColChk.norm.z + swing->eyeAtColChk.norm.z); + + sp30 = &camera->eyeNext; + OLib_Vec3fDiffToVecGeo(&sp50, at, &peekAroundPoint); + sp50.r = arg1->r; + swing->unk_64 = 1; + swing->swingUpdateRate = 1.5f; + OLib_AddVecGeoToVec3f(&sp58.pos, at, &sp50); + + if (func_800CBC84(camera, &swing->eyeAtColChk.pos, &sp58, 0) == 0) { + sp50.yaw = + Camera_AngleDiffAndScale(arg1->yaw, arg2->yaw, (camera->speedRatio * 0.5f) + 0.5f) + arg2->yaw; + sp50.pitch = Camera_AngleDiffAndScale(arg1->pitch, arg2->pitch, (camera->speedRatio * 0.5f) + 0.5f) + + arg2->pitch; + if (swing->atEyeColChk.geoNorm.pitch < 0x2AA8) { // 60 degrees + swing->yaw = sp50.yaw; + swing->pitch = sp50.pitch; + } else { + swing->yaw = arg1->yaw; + swing->pitch = arg1->pitch; + } + } + *eye = *sp30 = sp58.pos; + break; + + case 3: + case 6: + sp30 = &swing->atEyeColChk.pos; + sp88 = OLib_Vec3fDist(at, sp30); + if (sp88 < 60.0f) { + sp50.yaw = Camera_AngleDiffAndScale(arg1->yaw, arg2->yaw, camera->speedRatio) + arg2->yaw; + if (*flags & 0x1000) { + sp50.pitch = arg2->pitch; + } else { + sp50.pitch = Math_CosS(swing->atEyeColChk.geoNorm.pitch) * 0x3FFC; + } + sp50.r = 60.0f - sp88; + OLib_AddVecGeoToVec3f(&sp58.pos, sp30, &sp50); + } else { + sp50.yaw = Camera_AngleDiffAndScale(arg1->yaw, arg2->yaw, camera->speedRatio) + arg2->yaw; + sp50.pitch = Camera_AngleDiffAndScale(arg1->pitch, arg2->pitch, camera->speedRatio) + arg2->pitch; + sp50.r = arg1->r; + OLib_AddVecGeoToVec3f(&sp58.pos, at, &sp50); + } + func_800CBC84(camera, at, &sp58, 0); + *eye = sp58.pos; + break; + + default: + sp30 = &swing->atEyeColChk.pos; + *flags &= ~0x1000; + swing->swingUpdateRate = arg4; + *eye = *sp30; + break; + } +} + +/*===============================================================*/ +/* Camera Update Functions (Chosen by Settings & Modes) */ +/*===============================================================*/ + +s32 Camera_Noop(Camera* camera) { + return 1; +} + +// SP, FLOATS - Many temps reused to get the stack pointer down, even though it doesn't seem logical +// https://decomp.me/scratch/zVOSG +#ifdef NON_EQUIVALENT +s32 Camera_Normal1(Camera* camera) { + CameraModeValue* values; + f32 phi_f16_2; + Vec3f spD8; // D8-DC-E0 + f32 spD4; + f32 spD0; + f32 spC8; + f32 spC4; + f32 spC0; + VecGeo spB4; // B4-B8-BA + VecGeo spAC; // AC-B0-B2 + VecGeo spA4; // A4-A8-AA + VecGeo sp9C; // 9C-A0-A2 + VecGeo sp74; // 74-78-7A + s16 sp72; + f32 sp6C; + VecGeo sp64; // 64-68-6A + CollisionPoly* sp60; + f32 sp88 = Camera_GetFocalActorHeight(camera); + s32 sp5C; // BgID + f32 sp58; + f32 phi_f2; + // Vec3f *sp48; + // Vec3f *sp44; + + // f32 phi_f0; + f32 phi_f2_2; + f32 phi_f0_4; + s32 phi_v1_2; + Vec3f* sp4C = &camera->eye; + PosRot* sp40 = &camera->focalActorPosRot; + // f32 phi_f16_5; + + s16 phi_a0; + s16 temp_a0_3; // May be fake + Vec3f* new_var3; + + Normal1ReadOnlyData* roData = &camera->paramData.norm1.roData; + Normal1ReadWriteData* rwData = &camera->paramData.norm1.rwData; + + // sp48 = &camera->at; + // sp4C;/ + // sp44 = &camera->eyeNext; + // sp40; + // sp88; + + values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->unk_00 = GET_NEXT_RO_DATA(values) * (sp88 * 0.01f * (0.8f - ((68.0f / sp88) * -0.2f))); + roData->unk_04 = GET_NEXT_RO_DATA(values) * (sp88 * 0.01f * (0.8f - ((68.0f / sp88) * -0.2f))); + roData->unk_08 = GET_NEXT_RO_DATA(values) * (sp88 * 0.01f * (0.8f - ((68.0f / sp88) * -0.2f))); + roData->unk_04 = roData->unk_08 - (roData->unk_08 - roData->unk_04); + + if (RELOAD_PARAMS(camera)) { + roData->unk_20 = (s16)((GET_NEXT_RO_DATA(values) * 182.04167f) + .5f); + roData->unk_0C = GET_NEXT_RO_DATA(values); + roData->unk_0C = 40.0f - (40.0f - roData->unk_0C); + roData->unk_10 = GET_NEXT_RO_DATA(values); + roData->unk_14 = GET_NEXT_RO_DATA(values) * 0.01f; + roData->unk_14 = 1.0f - (1.0f - roData->unk_14); + roData->unk_18 = GET_NEXT_RO_DATA(values); + roData->unk_1C = GET_NEXT_RO_DATA(values) * 0.01f; + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + } + + sCameraInterfaceFlags = roData->interfaceFlags; + OLib_Vec3fDiffToVecGeo(&spA4, &camera->at, sp4C); + OLib_Vec3fDiffToVecGeo(&sp9C, &camera->at, &camera->eyeNext); + + switch (camera->animState) { + case 20: + Camera_SetUpdateRatesFastYaw(camera); + // fallthrough? + case 0: + rwData->unk_0C = 1; + if (!(roData->interfaceFlags & NORMAL1_FLAG_3) && (camera->animState != 20)) { + rwData->unk_0C |= 0x1000; + } + // fallthrough? + case 10: + if (camera->animState == 10) { + rwData->unk_0C = 0; + } + rwData->unk_08 = 0; + D_801EDC30[camera->camId].yaw = D_801EDC30[camera->camId].pitch = D_801EDC30[camera->camId].unk_64 = 0; + rwData->unk_0A = 0x514; + D_801EDC30[camera->camId].swingUpdateRate = roData->unk_0C; + rwData->unk_00 = camera->focalActorPosRot.pos.y; + rwData->unk_04 = camera->xzSpeed; + D_801EDC30[camera->camId].timer = 0; + sUpdateCameraDirection = false; + rwData->unk_10 = 120.0f; + break; + } + + camera->animState = 1; + sUpdateCameraDirection = true; + + if ((camera->speedRatio < 0.01f) || (rwData->unk_0A > 0x4B0)) { + if (rwData->unk_0A > -0x4B0) { + rwData->unk_0A--; + } + } else { + rwData->unk_0A = 0x4B0; + } + + if (func_800CB950(camera)) { + rwData->unk_00 = camera->focalActorPosRot.pos.y; + } + + if (rwData->unk_0C & 0x1000) { + spC8 = camera->speedRatio; + } else { + spC8 = ((camera->speedRatio * 3.0f) + 1.0f) * 0.25f; + } + + spD8 = camera->focalActorAtOffset; + spD8.y -= sp88 + roData->unk_00; + spC4 = Camera_Vec3fMagnitude(&spD8); + + if ((roData->unk_04 + roData->unk_08) < spC4) { + spC4 = 1.0f; + } else { + spC4 = spC4 / (roData->unk_04 + roData->unk_08); + } + + // Everything above matches except stack pointers + // PERM_RANDOMIZE( + + phi_f16_2 = 0.2f; + + phi_f2 = (camera->xzSpeed - rwData->unk_04) * 0.2f; + phi_f0_4 = phi_f2; + if (phi_f2 < 0.0f) { + phi_f0_4 = 0.0f; + } + + spC0 = OLib_ClampMaxDist(SQ(phi_f0_4), 1.0f); + camera->yOffsetUpdateRate = + Camera_ScaledStepToCeilF(0.05f, camera->yOffsetUpdateRate, (0.5f * spC8) + (0.5f * spC4), 0.0001f); + camera->xzOffsetUpdateRate = + Camera_ScaledStepToCeilF(0.05f, camera->xzOffsetUpdateRate, (0.5f * spC8) + (0.5f * spC4), 0.0001f); + camera->fovUpdateRate = + Camera_ScaledStepToCeilF(0.05f, camera->fovUpdateRate, (0.5f * spC8) + (0.5f * spC4), 0.0001f); + + if (D_801EDC30[camera->camId].unk_64 == 1) { + phi_f2 = 0.5f; + } else { + phi_f2 = (0.5f * spC8) + (0.5f * spC4); + } + + rwData->unk_04 = camera->xzSpeed; + + if (D_801EDC30[camera->camId].timer != 0) { + camera->yawUpdateRateInv = + Camera_ScaledStepToCeilF((D_801EDC30[camera->camId].timer * 2) + D_801EDC30[camera->camId].swingUpdateRate, + camera->yawUpdateRateInv, phi_f2, 0.1f); + if (roData->interfaceFlags & NORMAL1_FLAG_3) { + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF(100.0f, camera->pitchUpdateRateInv, 0.5f, 0.1f); + } else { + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF((D_801EDC30[camera->camId].timer * 2) + 16.0f, + camera->pitchUpdateRateInv, 0.2f, 0.1f); + } + D_801EDC30[camera->camId].timer--; + } else { + camera->yawUpdateRateInv = Camera_ScaledStepToCeilF( + D_801EDC30[camera->camId].swingUpdateRate - (D_801EDC30[camera->camId].swingUpdateRate * 0.7f * spC0), + camera->yawUpdateRateInv, phi_f2, 0.1f); + if ((roData->interfaceFlags & NORMAL1_FLAG_3) && (camera->speedRatio > 0.01f)) { + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF(100.0f, camera->pitchUpdateRateInv, 0.5f, 0.1f); + } else if (D_801ED920 != NULL) { + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF(32.0f, camera->pitchUpdateRateInv, 0.5f, 0.1f); + } else { + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF(16.0f, camera->pitchUpdateRateInv, 0.2f, 0.1f); + } + } + + if (roData->interfaceFlags & NORMAL1_FLAG_0) { + //! FAKE + if (!spC8) {} + temp_a0_3 = Camera_GetPitchAdjFromFloorHeightDiffs(camera, spA4.yaw + 0x8000, rwData->unk_0C & 1); + phi_f2 = (1.0f / roData->unk_10) * 0.7f; + phi_f16_2 = (1.0f / roData->unk_10) * 0.3f * (1.0f - camera->speedRatio); + spD0 = phi_f16_2; + rwData->unk_08 = Camera_ScaledStepToCeilS(temp_a0_3, rwData->unk_08, phi_f2 + phi_f16_2, 5); + } else { + rwData->unk_08 = 0; + } + + if ((D_801EDC30[camera->camId].unk_64 == 1) && (roData->unk_00 > -40.0f)) { + phi_f0_4 = Math_SinS(D_801EDC30[camera->camId].pitch); + phi_f2 = roData->unk_00; + phi_f2 = phi_f2 * (1.0f - phi_f0_4); // TODO: phi_f2 should not be on the LHS and RHS + // phi_f2 = roData->unk_00 * (1.0f - phi_f0_4); + camera->yawUpdateRateInv = 80.0f; + camera->pitchUpdateRateInv = 80.0f; + phi_f2_2 = ((-40.0f) * phi_f0_4) + phi_f2; + phi_f16_2 = phi_f0_4; + } else { + phi_f2_2 = roData->unk_00; + } + + if (roData->interfaceFlags & (NORMAL1_FLAG_6 | NORMAL1_FLAG_5)) { + if (camera->dist < roData->unk_04) { + phi_f16_2 = 0.0f; + } else if (roData->unk_08 < camera->dist) { + phi_f16_2 = 1.0f; + } else if (roData->unk_08 == roData->unk_04) { + phi_f16_2 = 1.0f; + } else { + // phi_f16_2 = camera->dist - roData->unk_04; + spD4 = (camera->dist - roData->unk_04) / (roData->unk_08 - roData->unk_04); + phi_f16_2 = spD4; + } + + Camera_CalcAtForNormal1(camera, &sp9C, phi_f2_2, 25.0f * phi_f16_2 * camera->speedRatio); + rwData->unk_10 = 120.0f; + spD0 = phi_f16_2; + } else if ((roData->interfaceFlags & NORMAL1_FLAG_7) && (rwData->unk_0A < 0)) { + phi_f0_4 = rwData->unk_0A / -1200.0f; // May be used to swap $f registers + Camera_CalcAtForNormal1( + camera, &sp9C, + phi_f2_2 - ((phi_f2_2 - ((0.8f - ((68.0f / sp88) * -0.2f)) * sp88 * -0.45f)) * phi_f0_4 * 0.75f), + 10.0f * phi_f0_4); + rwData->unk_10 = 120.0f; + spD0 = phi_f16_2; + //! FAKE + if (0) {} + } else if (roData->interfaceFlags & NORMAL1_FLAG_3) { + spD0 = phi_f16_2; + Camera_CalcAtForScreen(camera, &sp9C, roData->unk_00, &rwData->unk_00, rwData->unk_10); + if (rwData->unk_10 > 20.0f) { + rwData->unk_10 -= 0.2f; + } + } else { + spD0 = phi_f16_2; + Camera_CalcAtDefault(camera, &sp9C, phi_f2_2, roData->interfaceFlags & NORMAL1_FLAG_0); + rwData->unk_10 = 120.0f; + } + + phi_f16_2 = spD0; + OLib_Vec3fDiffToVecGeo(&spB4, &camera->at, &camera->eyeNext); + if ((roData->interfaceFlags & NORMAL1_FLAG_7) && (rwData->unk_0A < 0)) { + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + switch (((Player*)camera->focalActor)->transformation) { + case PLAYER_FORM_HUMAN: + phi_f16_2 = 66.0f; + break; + + case PLAYER_FORM_DEKU: + phi_f16_2 = 66.0f; + break; + + case PLAYER_FORM_ZORA: + phi_f16_2 = 115.0f; + break; + + case PLAYER_FORM_GORON: + phi_f16_2 = 115.0f; + break; + + case PLAYER_FORM_FIERCE_DEITY: + phi_f16_2 = roData->unk_04; + break; + + default: + phi_f16_2 = roData->unk_04; + break; + } + } + phi_f0_4 = Camera_ClampDist2(camera, spB4.r, phi_f16_2, phi_f16_2, 0); + } else if (roData->interfaceFlags & NORMAL1_FLAG_7) { + phi_f0_4 = Camera_ClampDist2(camera, spB4.r, roData->unk_04, roData->unk_08, 1); + } else { + phi_f0_4 = Camera_ClampDist1(camera, spB4.r, roData->unk_04, roData->unk_08, rwData->unk_0A > 0); + } + + camera->dist = spB4.r = phi_f0_4; + + if (D_801EDC30[camera->camId].unk_64 != 0) { + //! FAKE + if (phi_v1_2) {} + spB4.pitch = + Camera_ScaledStepToCeilS(D_801EDC30[camera->camId].pitch, sp9C.pitch, 1.0f / camera->yawUpdateRateInv, 5); + spB4.yaw = + Camera_ScaledStepToCeilS(D_801EDC30[camera->camId].yaw, sp9C.yaw, 1.0f / camera->yawUpdateRateInv, 5); + } else { + if (roData->interfaceFlags & NORMAL1_FLAG_5) { + spB4.yaw = sp9C.yaw; + spB4.pitch = sp9C.pitch; + camera->animState = 20; + } else { + if (D_801ED920 != NULL) { + //! FAKE + if (sp40) {} + new_var3 = &D_801ED920->world.pos; + OLib_Vec3fDiffToVecGeo(&sp74, &sp40->pos, new_var3); // TODO: arg0 & arg1 swapped + sp72 = sp40->rot.y - sp74.yaw; + // Interface and shrink-window flags + if ((roData->interfaceFlags & 0xFF00) == 0xFF00) { + sp6C = 1.0f; + } else { + sp6C = 1.0f - (ABS(sp72) / 10922.0f); + } + + if (ABS((s16)(sp9C.yaw - sp74.yaw)) < 0x4000) { + sp74.yaw += 0x8000; + } + + if (!(roData->interfaceFlags & NORMAL1_FLAG_3) || !func_800CB924(camera)) { + spB4.yaw = Camera_CalcDefaultYaw(camera, sp9C.yaw, (s16)(sp40->rot.y - (s16)(sp72 * sp6C)), + roData->unk_14, spC0); + } + + if (!(roData->interfaceFlags & NORMAL1_FLAG_3) || (camera->speedRatio < 0.01f)) { + spB4.pitch = Camera_CalcDefaultPitch( + camera, sp9C.pitch, roData->unk_20 + (s16)((roData->unk_20 - sp74.pitch) * sp6C * 0.75f), + rwData->unk_08); + } + dummy:; // TODO: Will this be needed? + } else if (roData->interfaceFlags & NORMAL1_FLAG_1) { + if ((camera->speedRatio > 0.1f) || (rwData->unk_0A > 0x4B0)) { + OLib_Vec3fToVecGeo(&sp64, &camera->unk_0F0); + if (!(roData->interfaceFlags & NORMAL1_FLAG_3) || !func_800CB924(camera)) { + spB4.yaw = Camera_CalcDefaultYaw(camera, sp9C.yaw, sp64.yaw, roData->unk_14, spC0); + } + if (!(roData->interfaceFlags & NORMAL1_FLAG_3)) { + spB4.pitch = Camera_CalcDefaultPitch(camera, sp9C.pitch, roData->unk_20, rwData->unk_08); + } else if ((camera->unk_0F0.y > 0.0f) && func_800CB924(camera)) { + spB4.pitch = Camera_CalcDefaultPitch(camera, sp9C.pitch, roData->unk_20, rwData->unk_08); + } + } else { + spB4.yaw = sp9C.yaw; + spB4.pitch = sp9C.pitch; + dummy4:; // TODO: Will this be needed? + } + } else { + spB4.yaw = Camera_CalcDefaultYaw(camera, sp9C.yaw, sp40->rot.y, roData->unk_14, spC0); + if (!(roData->interfaceFlags & NORMAL1_FLAG_3) || (camera->speedRatio < 0.1f)) { + spB4.pitch = Camera_CalcDefaultPitch(camera, sp9C.pitch, roData->unk_20, rwData->unk_08); + } + } + } + } + + // 76.9 degrees + if (spB4.pitch > 0x36B0) { + spB4.pitch = 0x36B0; + } + + // -76.9 degrees + if (spB4.pitch < -0x36B0) { + spB4.pitch = -0x36B0; + } + + OLib_AddVecGeoToVec3f(&camera->eyeNext, &camera->at, &spB4); + if ((camera->status == CAM_STATUS_ACTIVE) && !(roData->interfaceFlags & NORMAL1_FLAG_4) && (spC4 <= 0.9f)) { + + if (func_800CBA7C(camera) == 0) { + Camera_CalcDefaultSwing(camera, &spB4, &sp9C, roData->unk_04, roData->unk_0C, &D_801EDC30[camera->camId], + &rwData->unk_0C); + sp58 = BgCheck_CameraRaycastFloor2(&camera->play->colCtx, &sp60, &sp5C, sp4C); + if ((roData->interfaceFlags & NORMAL1_FLAG_3) && func_800CB924(camera)) { + phi_f16_2 = 25.0f; + } else { + phi_f16_2 = 5.0f; + } + spD0 = sp4C->y; // TODO: another fake reuse of temp + phi_f0_4 = sp4C->y; + phi_f0_4 -= sp58; + // new_var2 = sp4C->y; + if ((sp58 != BGCHECK_Y_MIN) && (phi_f0_4 < phi_f16_2)) { + sp4C->y = sp58 + phi_f16_2; + } else if ((camera->waterYPos != camera->focalActorFloorHeight) && ((spD0 - camera->waterYPos) < 5.0f) && + ((spD0 - camera->waterYPos) > -5.0f)) { + sp4C->y = camera->waterYPos + 5.0f; + } + } + + OLib_Vec3fDiffToVecGeo(&spAC, sp4C, &camera->at); + camera->inputDir.x = spAC.pitch; + camera->inputDir.y = spAC.yaw; + camera->inputDir.z = 0; + if (gSaveContext.save.saveInfo.playerData.health < 17) { + phi_v1_2 = (camera->play->state.frames << 0x18); + phi_v1_2 = (s16)((phi_v1_2 >> 0x15) & 0xFD68); + camera->inputDir.y += phi_v1_2; + } + } else { + D_801EDC30[camera->camId].swingUpdateRate = roData->unk_0C; + D_801EDC30[camera->camId].unk_64 = 0; + sUpdateCameraDirection = false; + *sp4C = camera->eyeNext; + } + + // Everything below OLib_Vec3fDiffToVecGeo matches except stack pointers + // ) + + phi_f2 = (gSaveContext.save.saveInfo.playerData.health <= 16) ? 0.8f : 1.0f; + camera->fov = Camera_ScaledStepToCeilF(roData->unk_18 * phi_f2, camera->fov, camera->fovUpdateRate, 0.1f); + + if (roData->interfaceFlags & NORMAL1_FLAG_2) { + spD4 = Math_SinS((s16)(spA4.yaw - spB4.yaw)); + camera->roll = Camera_ScaledStepToCeilS(((Rand_ZeroOne() - 0.5f) * 500.0f * camera->speedRatio) + + (spD4 * spD4 * spD4 * 10000.0f), + camera->roll, 0.1f, 5); + } else { + if (gSaveContext.save.saveInfo.playerData.health <= 16) { + phi_a0 = (Rand_ZeroOne() - 0.5f) * 100.0f * camera->speedRatio; + } else { + phi_a0 = 0.0f; + } + camera->roll = Camera_ScaledStepToCeilS(phi_a0, camera->roll, 0.2f, 5); + } + + camera->atLerpStepScale = Camera_ClampLerpScale(camera, roData->unk_1C); + rwData->unk_0C &= ~1; + + return true; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Normal1.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Normal2.s") +/** + * Unused Camera RemoteBomb Setting + */ +s32 Camera_Normal2(Camera* camera) { + return Camera_Noop(camera); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Normal3.s") +#define NORMAL3_RW_FLAG (1 << 0) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Normal4.s") +/** + * Riding Epona and Zora + */ +s32 Camera_Normal3(Camera* camera) { + Normal3ReadOnlyData* roData = &camera->paramData.norm3.roData; + Normal3ReadWriteData* rwData = &camera->paramData.norm3.rwData; + f32 sp8C; + f32 sp90; + f32 temp_f2; // multi-use temp + f32 sp88; + VecGeo sp80; + VecGeo sp78; + VecGeo sp70; + VecGeo sp68; + f32 phi_f2; + s16 sp62; + s16 phi_v1_2; + Player* player = (Player*)camera->focalActor; + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + Vec3f* eyeNext = &camera->eyeNext; + PosRot* focalActorPosRot = &camera->focalActorPosRot; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Normal0.s") + temp_f2 = Camera_GetFocalActorHeight(camera); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Parallel1.s") + if ((camera->setting == CAM_SET_HORSE) && (player->rideActor == NULL)) { + Camera_ChangeSettingFlags(camera, camera->prevSetting, CAM_CHANGE_SETTING_1); + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Parallel2.s") + if (RELOAD_PARAMS(camera)) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Parallel3.s") + temp_f2 = CAM_RODATA_UNSCALE(temp_f2); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Parallel4.s") + roData->yOffset = GET_NEXT_RO_DATA(values) * temp_f2; + roData->distMin = GET_NEXT_RO_DATA(values) * temp_f2; + roData->distMax = GET_NEXT_RO_DATA(values) * temp_f2; + roData->pitchTarget = CAM_DEG_TO_BINANG(GET_NEXT_RO_DATA(values)); + roData->yawUpdateRateInv = GET_NEXT_RO_DATA(values); + roData->pitchUpdateRateInv = GET_NEXT_RO_DATA(values); + roData->fovTarget = GET_NEXT_RO_DATA(values); + roData->maxAtLERPScale = GET_NEXT_SCALED_RO_DATA(values); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Parallel0.s") + OLib_Vec3fDiffToVecGeo(&sp70, at, eye); + OLib_Vec3fDiffToVecGeo(&sp68, at, eyeNext); + sUpdateCameraDirection = true; + sCameraInterfaceFlags = roData->interfaceFlags; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Jump1.s") + //! FAKE: fake temp + phi_v1_2 = camera->animState; + if (!(((phi_v1_2 == 0) || (phi_v1_2 == 10)) || (phi_v1_2 == 20))) { + } else { + rwData->isZero = 0; + rwData->curPitch = 0; + rwData->yPosOffset = camera->focalActorFloorHeight; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Jump2.s") + D_801EDC30[camera->camId].yaw = D_801EDC30[camera->camId].pitch = D_801EDC30[camera->camId].unk_64 = 0; + D_801EDC30[camera->camId].swingUpdateRate = roData->yawUpdateRateInv; + rwData->yawUpdateRate = BINANG_SUB(BINANG_ROT180(camera->focalActorPosRot.rot.y), sp70.yaw) * (1.0f / 6.0f); + rwData->distTimer = 0; + rwData->is1200 = 1200; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Jump3.s") + if (roData->interfaceFlags & NORMAL3_FLAG_1) { + rwData->yawTimer = 6; + Camera_SetStateFlag(camera, CAM_STATE_DISABLE_MODE_CHANGE); + } else { + rwData->yawTimer = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Jump4.s") + camera->animState = 1; + D_801EDC30[camera->camId].timer = 0; + rwData->flag = NORMAL3_RW_FLAG; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Jump0.s") + if (rwData->distTimer != 0) { + rwData->distTimer--; + } + sp90 = ((camera->speedRatio * 3.0f) + 1.0f) * 0.25f * 0.5f; + sp8C = temp_f2 = camera->speedRatio * 0.2f; + + if (D_801EDC30[camera->camId].timer != 0) { + camera->yawUpdateRateInv = Camera_ScaledStepToCeilF( + (D_801EDC30[camera->camId].timer * 2) + roData->yawUpdateRateInv, camera->yawUpdateRateInv, sp90, 0.1f); + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF((D_801EDC30[camera->camId].timer * 2) + 16.0f, + camera->pitchUpdateRateInv, sp8C, 0.1f); + D_801EDC30[camera->camId].timer--; + } else { + camera->yawUpdateRateInv = + Camera_ScaledStepToCeilF(roData->yawUpdateRateInv, camera->yawUpdateRateInv, sp90, 0.1f); + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF(16.0f, camera->pitchUpdateRateInv, sp8C, 0.1f); + } + + camera->yOffsetUpdateRate = Camera_ScaledStepToCeilF(0.05f, camera->yOffsetUpdateRate, sp90, 0.001f); + camera->xzOffsetUpdateRate = Camera_ScaledStepToCeilF(0.05f, camera->xzOffsetUpdateRate, sp8C, 0.0001f); + camera->fovUpdateRate = Camera_ScaledStepToCeilF(0.05f, camera->fovUpdateRate, sp8C, 0.0001f); + + phi_v1_2 = Camera_GetPitchAdjFromFloorHeightDiffs(camera, BINANG_ROT180(sp70.yaw), rwData->flag & NORMAL3_RW_FLAG); + temp_f2 = ((1.0f / roData->pitchUpdateRateInv) * 0.5f) * (1.0f - camera->speedRatio); + rwData->curPitch = + Camera_ScaledStepToCeilS(phi_v1_2, rwData->curPitch, ((1.0f / roData->pitchUpdateRateInv) * 0.5f) + temp_f2, 5); + + if ((roData->interfaceFlags & NORMAL3_FLAG_6) || (player->rideActor == NULL)) { + Camera_CalcAtDefault(camera, &sp68, roData->yOffset, 1); + } else { + Camera_CalcAtForHorse(camera, &sp68, roData->yOffset, &rwData->yPosOffset, 1); + } + + sp88 = (roData->distMax + roData->distMin) * 0.5f; + OLib_Vec3fDiffToVecGeo(&sp80, at, eyeNext); + temp_f2 = Camera_ClampDist1(camera, sp80.r, roData->distMin, roData->distMax, rwData->distTimer); + + phi_f2 = sp88 - temp_f2; + phi_f2 *= 0.002f; + camera->dist = sp80.r = temp_f2 + phi_f2; + + if (roData->interfaceFlags & NORMAL3_FLAG_7) { + sp80.pitch = Camera_ScaledStepToCeilS(camera->focalActor->focus.rot.x - rwData->curPitch, sp68.pitch, 0.25f, 5); + } else { + sp62 = roData->pitchTarget - rwData->curPitch; + sp80.pitch = Camera_ScaledStepToCeilS(sp62, sp68.pitch, 1.0f / camera->pitchUpdateRateInv, 5); + } + + sp80.pitch = CLAMP_MAX(sp80.pitch, DEG_TO_BINANG(79.655f)); + + if (sp80.pitch < -DEG_TO_BINANG(29.995f)) { + sp80.pitch = -DEG_TO_BINANG(29.995f); + } + + if (roData->interfaceFlags & NORMAL3_FLAG_7) { + sp62 = BINANG_SUB(camera->focalActor->focus.rot.y, BINANG_ROT180(sp68.yaw)); + temp_f2 = 1.0f; + } else { + sp62 = BINANG_SUB(focalActorPosRot->rot.y, BINANG_ROT180(sp68.yaw)); + OLib_Vec3fToVecGeo(&sp78, &camera->unk_0F0); + phi_v1_2 = focalActorPosRot->rot.y - sp78.yaw; + if (phi_v1_2 < 0) { + phi_v1_2 *= -1; + } + + if (phi_v1_2 < 0x555A) { + temp_f2 = 1.0f; + } else { + temp_f2 = ((f32)0x8000 - phi_v1_2) / (f32)0x2AA6; + } + } + + sp90 = (sp62 * ((SQ(camera->speedRatio) * 0.8f) + 0.2f) * temp_f2) / camera->yawUpdateRateInv; + if ((Camera_fabsf(sp90) > 150.0f) && (camera->speedRatio > 0.05f)) { + sp80.yaw = sp68.yaw + sp90; + } + + if (rwData->yawTimer > 0) { + sp80.yaw += rwData->yawUpdateRate; + rwData->yawTimer--; + if (rwData->yawTimer == 0) { + Camera_UnsetStateFlag(camera, CAM_STATE_DISABLE_MODE_CHANGE); + } + } + + OLib_AddVecGeoToVec3f(eyeNext, at, &sp80); + + if (camera->status == CAM_STATUS_ACTIVE) { + *eye = *eyeNext; + func_800CBFA4(camera, at, eye, 0); + } else { + *eye = *eyeNext; + } + + camera->fov = Camera_ScaledStepToCeilF(roData->fovTarget, camera->fov, camera->fovUpdateRate, 0.1f); + + if (roData->interfaceFlags & NORMAL3_FLAG_5) { + camera->roll = Camera_ScaledStepToCeilS(0, camera->roll, 0.05f, 5); + } else { + camera->roll = Camera_ScaledStepToCeilS(0, camera->roll, 0.1f, 5); + } + + camera->atLerpStepScale = Camera_ClampLerpScale(camera, roData->maxAtLERPScale); + rwData->flag &= ~NORMAL3_RW_FLAG; + + return 1; +} + +/** + * Used for the unknown Naname setting. + * Identical to Normal1 except reads camera scene data to apply a camera roll + */ +s32 Camera_Normal4(Camera* camera) { + BgCamFuncData* bgCamFuncData; + s16 roll; + + if (RELOAD_PARAMS(camera)) { + bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamOrActorCsCamFuncData(camera, camera->bgCamIndex); + D_801EDBF0 = bgCamFuncData->rot.z; + } + + roll = camera->roll; + Camera_Normal1(camera); + camera->roll = Camera_ScaledStepToCeilS(D_801EDBF0, roll, 0.05f, 5); + + return 1; +} + +s32 Camera_Normal0(Camera* camera) { + f32 phi_f0; + f32 yNormal; + s32 pad; + f32 playerHeight; + f32 spA4; + f32 spA0; + VecGeo sp98; + VecGeo sp90; + VecGeo sp88; + VecGeo sp80; + VecGeo sp78; + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + Vec3f* eyeNext = &camera->eyeNext; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + s16 temp_v1_2; + s16 phi_a1; + s16 phi_a0; + BgCamFuncData* bgCamFuncData; + f32 new_var; + Normal0ReadOnlyData* roData = &camera->paramData.norm0.roData; + Normal0ReadWriteData* rwData = &camera->paramData.norm0.rwData; + + playerHeight = Player_GetHeight((Player*)camera->focalActor); + yNormal = 0.8f - ((68.0f / playerHeight) * -0.2f); + + if (!RELOAD_PARAMS(camera)) { + } else { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + + roData->unk_00 = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; + roData->unk_04 = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; + roData->unk_08 = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; + roData->unk_1C = CAM_DEG_TO_BINANG(GET_NEXT_RO_DATA(values)); + roData->unk_0C = GET_NEXT_RO_DATA(values); + roData->unk_10 = GET_NEXT_SCALED_RO_DATA(values); + roData->unk_14 = GET_NEXT_RO_DATA(values); + roData->unk_18 = GET_NEXT_SCALED_RO_DATA(values); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + } + + sCameraInterfaceFlags = roData->interfaceFlags; + + if (RELOAD_PARAMS(camera)) { + bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamOrActorCsCamFuncData(camera, camera->bgCamIndex); + Camera_Vec3sToVec3f(&rwData->unk_00, &bgCamFuncData->pos); + rwData->unk_20 = bgCamFuncData->rot.x; + rwData->unk_22 = bgCamFuncData->rot.y; + rwData->unk_24 = focalActorPosRot->pos.y; + if (bgCamFuncData->fov == -1) { + rwData->unk_1C = roData->unk_14; + } else { + if (bgCamFuncData->fov > 360) { + phi_f0 = CAM_RODATA_UNSCALE(bgCamFuncData->fov); + } else { + phi_f0 = bgCamFuncData->fov; + } + rwData->unk_1C = phi_f0; + } + + if (bgCamFuncData->unk_0E == -1) { + rwData->unk_2C = 0; + } else { + rwData->unk_2C = bgCamFuncData->unk_0E; + } + + rwData->unk_18 = 0.0f; + rwData->unk_28 = 120.0f; + + if (roData->interfaceFlags & NORMAL0_FLAG_2) { + sp88.pitch = rwData->unk_20; + sp88.yaw = rwData->unk_22; + sp88.r = 100.0f; + OLib_VecGeoToVec3f(&rwData->unk_0C, &sp88); + } + camera->animState = 1; + camera->yawUpdateRateInv = 50.0f; + } else { + if (func_800CB950(camera)) { + rwData->unk_24 = focalActorPosRot->pos.y; + } + //! FAKE: + if (1) {} + } + + OLib_Vec3fDiffToVecGeo(&sp80, at, eye); + OLib_Vec3fDiffToVecGeo(&sp78, at, eyeNext); + + camera->speedRatio *= 0.50f; + spA4 = camera->speedRatio * 0.5f; + spA0 = camera->speedRatio * 0.2f; + + camera->yawUpdateRateInv = + Camera_ScaledStepToCeilF(roData->unk_0C, camera->yawUpdateRateInv * camera->speedRatio, 0.5f, 0.1f); + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF(16.0f, camera->pitchUpdateRateInv, spA0, 0.1f); + camera->yOffsetUpdateRate = Camera_ScaledStepToCeilF(0.05f, camera->yOffsetUpdateRate, spA4, 0.0001f); + camera->xzOffsetUpdateRate = Camera_ScaledStepToCeilF(0.05f, camera->xzOffsetUpdateRate, spA0, 0.0001f); + camera->fovUpdateRate = Camera_ScaledStepToCeilF(0.05, camera->fovUpdateRate, camera->speedRatio * 0.05f, 0.0001f); + + if (!(roData->interfaceFlags & NORMAL0_FLAG_7)) { + Camera_CalcAtDefault(camera, &sp78, roData->unk_00, roData->interfaceFlags & NORMAL0_FLAG_0); + rwData->unk_28 = 120.0f; + } else { + Camera_CalcAtForScreen(camera, &sp78, roData->unk_00, &rwData->unk_24, rwData->unk_28); + if (rwData->unk_28 > 20.0f) { + rwData->unk_28 -= 0.2f; + } + } + + if (roData->interfaceFlags & NORMAL0_FLAG_2) { + rwData->unk_00.x = focalActorPosRot->pos.x + rwData->unk_0C.x; + rwData->unk_00.z = focalActorPosRot->pos.z + rwData->unk_0C.z; + } + + rwData->unk_00.y = focalActorPosRot->pos.y; + OLib_Vec3fDiffToVecGeo(&sp88, &rwData->unk_00, at); + OLib_Vec3fDiffToVecGeo(&sp90, at, eyeNext); + + if (rwData->unk_2C & 2) { + phi_a1 = rwData->unk_22; + } else { + phi_a1 = roData->unk_1C; + } + + temp_v1_2 = sp90.yaw - sp88.yaw; + if (((phi_a1 <= 0x4000) && (phi_a1 < ABS(temp_v1_2))) || ((phi_a1 > 0x4000) && (ABS(temp_v1_2) < phi_a1))) { + //! FAKE: Needed to swap v0/v1 + if (1) {} + if (1) {} + if (1) {} + if (1) {} + + //! FAKE: Needed because the *1.0f isn't being multiplied + new_var = 1.0f; + + if (temp_v1_2 < 0) { + phi_a0 = -phi_a1; + } else { + phi_a0 = phi_a1; + } + + phi_a0 += sp88.yaw; + sp98.yaw = Camera_ScaledStepToCeilS(phi_a0, sp80.yaw, + (1.0f / camera->yawUpdateRateInv) * new_var * camera->speedRatio, 5); + if (rwData->unk_2C & 1) { + sp98.pitch = Camera_CalcDefaultPitch(camera, sp78.pitch, rwData->unk_20, 0); + } else { + sp98.pitch = sp80.pitch; + } + } else { + sp98 = sp90; + } + + camera->dist = sp98.r = Camera_ClampDist1(camera, sp90.r, roData->unk_04, roData->unk_08, 0); + if (!(rwData->unk_2C & 1)) { + if (sp98.pitch > 0xE38) { // 20 degrees + sp98.pitch += ((s16)(0xE38 - sp98.pitch) >> 2); + } + if (sp98.pitch < 0) { + sp98.pitch += ((s16)(-0x38E - sp98.pitch) >> 2); + } + } + OLib_AddVecGeoToVec3f(eyeNext, at, &sp98); + + *eye = *eyeNext; + + if (camera->status == CAM_STATUS_ACTIVE) { + if ((camera->play->envCtx.skyboxDisabled == 0) || (roData->interfaceFlags & NORMAL0_FLAG_4)) { + Camera_BgCheck(camera, at, eye); + } else { + func_800CBFA4(camera, at, eye, 3); + OLib_Vec3fDiffToVecGeo(&sp98, eye, at); + camera->inputDir.x = sp98.pitch; + camera->inputDir.y = sp98.yaw; + camera->inputDir.z = 0; + } + } + + camera->fov = Camera_ScaledStepToCeilF(rwData->unk_1C, camera->fov, camera->fovUpdateRate, 0.1f); + camera->roll = Camera_ScaledStepToCeilS(0, camera->roll, 0.5f, 5); + camera->atLerpStepScale = Camera_ClampLerpScale(camera, roData->unk_18); + + return 1; +} + +/** + * Used for targeting + */ +s32 Camera_Parallel1(Camera* camera) { + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + Vec3f* eyeNext = &camera->eyeNext; + Vec3f spB0; + Vec3f spA4; + f32 spA0; + f32 sp9C; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + VecGeo sp90; + VecGeo sp88; + VecGeo sp80; + VecGeo sp78; + BgCamFuncData* bgCamFuncData; + s16 sp72; + s16 tangle; + Parallel1ReadOnlyData* roData = &camera->paramData.para1.roData; + Parallel1ReadWriteData* rwData = &camera->paramData.para1.rwData; + s32 parallelFlagCond; + f32 focalActorHeight = Camera_GetFocalActorHeight(camera); + s16 new_var2; + s16 phi_a0; + s32 phi_a0_2; + CameraModeValue* values; + f32 yNormal; + + if (!RELOAD_PARAMS(camera)) { + } else { + values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->unk_00 = + GET_NEXT_SCALED_RO_DATA(values) * focalActorHeight * (0.8f - ((68.0f / focalActorHeight) * -0.2f)); + roData->unk_04 = + GET_NEXT_SCALED_RO_DATA(values) * focalActorHeight * (0.8f - ((68.0f / focalActorHeight) * -0.2f)); + roData->unk_08 = + GET_NEXT_SCALED_RO_DATA(values) * focalActorHeight * (0.8f - ((68.0f / focalActorHeight) * -0.2f)); + roData->unk_20 = CAM_DEG_TO_BINANG(GET_NEXT_RO_DATA(values)); + roData->unk_22 = CAM_DEG_TO_BINANG(GET_NEXT_RO_DATA(values)); + roData->unk_0C = GET_NEXT_RO_DATA(values); + roData->unk_10 = GET_NEXT_RO_DATA(values); + roData->unk_14 = GET_NEXT_RO_DATA(values); + roData->unk_18 = GET_NEXT_SCALED_RO_DATA(values); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + roData->unk_1C = GET_NEXT_SCALED_RO_DATA(values); + roData->unk_24 = GET_NEXT_RO_DATA(values); + rwData->unk_00 = roData->unk_04; + } + + OLib_Vec3fDiffToVecGeo(&sp80, at, eye); + OLib_Vec3fDiffToVecGeo(&sp78, at, eyeNext); + Camera_GetFocalActorPos(&spA4, camera); + + switch (camera->animState) { + case 20: + if ((roData->interfaceFlags & (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) == 0) { + Camera_SetUpdateRatesFastYaw(camera); + } + // fallthrough + case 0: + case 10: + if ((roData->interfaceFlags & (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) == + (PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) { + rwData->unk_10 = focalActorPosRot->pos; + } else { + camera->xzOffsetUpdateRate = 0.5f; + camera->yOffsetUpdateRate = 0.5f; + } + + if ((roData->interfaceFlags & (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) == + PARALLEL1_FLAG_3) { + rwData->unk_10 = camera->focalActorPosRot.pos; + } + + rwData->timer1 = 200.0f; + + if ((2.0f * roData->unk_04) < camera->dist) { + camera->dist = 2.0f * roData->unk_04; + sp78.r = camera->dist; + sp80.r = sp78.r; + OLib_AddVecGeoToVec3f(eye, at, &sp80); + *eyeNext = *eye; + } + + rwData->unk_1C = 0; + + if (roData->interfaceFlags & PARALLEL1_FLAG_2) { + rwData->timer2 = 20; + } else { + rwData->timer2 = 6; + } + + if ((camera->focalActor == &GET_PLAYER(camera->play)->actor) && (camera->mode == CAM_MODE_CHARGE)) { + rwData->timer2 = 30; + if (((Player*)camera->focalActor)->transformation == PLAYER_FORM_DEKU) { + roData->unk_24 = -1; + } + } + + if ((roData->interfaceFlags & (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) == + (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_1)) { + rwData->timer2 = 1; + yNormal = 0.8f - ((68.0f / focalActorHeight) * -0.2f); + + bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamOrActorCsCamFuncData(camera, camera->bgCamIndex); + + rwData->unk_20 = bgCamFuncData->rot.x; + rwData->unk_1E = bgCamFuncData->rot.y; + rwData->unk_08 = (bgCamFuncData->fov == -1) ? roData->unk_14 + : (bgCamFuncData->fov > 360) ? CAM_RODATA_UNSCALE(bgCamFuncData->fov) + : bgCamFuncData->fov; + rwData->unk_00 = (bgCamFuncData->unk_0E == -1) + ? roData->unk_04 + : CAM_RODATA_UNSCALE(bgCamFuncData->unk_0E) * focalActorHeight * yNormal; + //! FAKE + dummy:; + } else { + rwData->unk_08 = roData->unk_14; + rwData->unk_00 = roData->unk_04; + } + + rwData->timer3 = roData->unk_24; + rwData->unk_04 = focalActorPosRot->pos.y - camera->unk_0F0.y; + rwData->unk_26 = 1; + camera->animState = 1; + sCameraInterfaceFlags = roData->interfaceFlags; + break; + } + + if (rwData->timer2 != 0) { + switch (roData->interfaceFlags & (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) { + case PARALLEL1_FLAG_1: + case (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1): + rwData->unk_1E = BINANG_ROT180(camera->focalActorPosRot.rot.y) + roData->unk_22; + rwData->unk_20 = roData->unk_20; + break; + + case PARALLEL1_FLAG_2: + rwData->unk_1E = roData->unk_22; + rwData->unk_20 = roData->unk_20; + break; + + case (PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1): + if (rwData->timer3 == 1) { + OLib_Vec3fDiffToVecGeo(&sp88, &rwData->unk_10, &spA4); + rwData->unk_1E = ((ABS(BINANG_SUB(sp88.yaw, sp80.yaw)) < 0x3A98) || Camera_IsClimbingLedge(camera)) + ? sp80.yaw + : sp80.yaw + (s16)((BINANG_SUB(sp88.yaw, sp80.yaw) >> 2) * 3); + } + rwData->unk_20 = roData->unk_20; + break; + + case PARALLEL1_FLAG_3: + rwData->unk_1E = sp80.yaw; + rwData->unk_20 = roData->unk_20; + break; + + case (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_1): + break; + + default: + rwData->unk_1E = sp78.yaw + roData->unk_22; + rwData->unk_20 = roData->unk_20; + break; + } + } else if (roData->interfaceFlags & PARALLEL1_FLAG_5) { + rwData->unk_1E = BINANG_ROT180(camera->focalActorPosRot.rot.y) + roData->unk_22; + } + + if (camera->animState == 21) { + camera->animState = 1; + } else if (camera->animState == 11) { + camera->animState = 1; + } + + spA0 = camera->speedRatio * 0.5f; + sp9C = camera->speedRatio * 0.2f; + + if (((roData->interfaceFlags & (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) == + (PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) || + ((roData->interfaceFlags & (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) == PARALLEL1_FLAG_3) || + (roData->interfaceFlags & PARALLEL1_FLAG_5)) { + camera->rUpdateRateInv = Camera_ScaledStepToCeilF(20.0f, camera->rUpdateRateInv, 0.5f, 0.1f); + camera->yawUpdateRateInv = Camera_ScaledStepToCeilF(roData->unk_0C, camera->yawUpdateRateInv, 0.5f, 0.1f); + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF(20.0f, camera->pitchUpdateRateInv, 0.5f, 0.1f); + } else { + camera->rUpdateRateInv = Camera_ScaledStepToCeilF(20.0f, camera->rUpdateRateInv, spA0, 0.1f); + camera->yawUpdateRateInv = Camera_ScaledStepToCeilF(roData->unk_0C, camera->yawUpdateRateInv, spA0, 0.1f); + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF(2.0f, camera->pitchUpdateRateInv, sp9C, 0.1f); + } + + if ((roData->interfaceFlags & (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) == + (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) { + camera->yOffsetUpdateRate = Camera_ScaledStepToCeilF(0.1f, camera->yOffsetUpdateRate, spA0, 0.0001f); + camera->xzOffsetUpdateRate = Camera_ScaledStepToCeilF(0.1f, camera->xzOffsetUpdateRate, sp9C, 0.0001f); + } else if (roData->interfaceFlags & PARALLEL1_FLAG_7) { + camera->yOffsetUpdateRate = Camera_ScaledStepToCeilF(0.5f, camera->yOffsetUpdateRate, spA0, 0.0001f); + camera->xzOffsetUpdateRate = Camera_ScaledStepToCeilF(0.5f, camera->xzOffsetUpdateRate, sp9C, 0.0001f); + } else { + camera->yOffsetUpdateRate = Camera_ScaledStepToCeilF(0.05f, camera->yOffsetUpdateRate, spA0, 0.0001f); + camera->xzOffsetUpdateRate = Camera_ScaledStepToCeilF(0.05f, camera->xzOffsetUpdateRate, sp9C, 0.0001f); + } + + // TODO: Extra trailing 0 in 0.050f needed? + camera->fovUpdateRate = + Camera_ScaledStepToCeilF(0.050f, camera->fovUpdateRate, camera->speedRatio * 0.05f, 0.0001f); + + if (roData->interfaceFlags & PARALLEL1_FLAG_0) { + tangle = Camera_GetPitchAdjFromFloorHeightDiffs(camera, BINANG_ROT180(sp80.yaw), rwData->unk_26 = 1); + spA0 = ((1.0f / roData->unk_10)); + spA0 *= 0.6f; + sp9C = ((1.0f / roData->unk_10) * 0.4f) * (1.0f - camera->speedRatio); + rwData->unk_1C = Camera_ScaledStepToCeilS(tangle, rwData->unk_1C, spA0 + sp9C, 5); + } else { + rwData->unk_1C = 0; + } + + if (func_800CB950(camera) || (((Player*)camera->focalActor)->stateFlags1 & PLAYER_STATE1_1000) || + (((Player*)camera->focalActor)->stateFlags3 & PLAYER_STATE3_100)) { + rwData->unk_04 = camera->focalActorPosRot.pos.y; + sp72 = false; + } else { + sp72 = true; + } + + if ((((Player*)camera->focalActor)->stateFlags1 & PLAYER_STATE1_4000) || + (((Player*)camera->focalActor)->stateFlags1 & PLAYER_STATE1_4) || + ((roData->interfaceFlags & (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) == + (PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1))) { + spB0 = spA4; + spB0.y += ((focalActorHeight * 0.6f) + roData->unk_00); + Camera_ScaledStepToCeilVec3f(&spB0, at, camera->xzOffsetUpdateRate, camera->yOffsetUpdateRate, 0.0001f); + Camera_SetFocalActorAtOffset(camera, &focalActorPosRot->pos); + } else if ((roData->interfaceFlags & (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) == + (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) { + spB0 = focalActorPosRot->pos; + spB0.y += focalActorHeight + roData->unk_00; + Camera_ScaledStepToCeilVec3f(&spB0, at, camera->xzOffsetUpdateRate, camera->yOffsetUpdateRate, 0.0001f); + Camera_SetFocalActorAtOffset(camera, &focalActorPosRot->pos); + } else if (rwData->timer2 != 0) { + Camera_CalcAtDefault(camera, &sp78, roData->unk_00, 0); + rwData->timer1 = 200.0f; + } else if (!(roData->interfaceFlags & PARALLEL1_FLAG_7) && !sp72) { + Camera_CalcAtForParallel(camera, &sp78, roData->unk_00, roData->unk_08, &rwData->unk_04, + roData->interfaceFlags & (PARALLEL1_FLAG_6 | PARALLEL1_FLAG_0)); + rwData->timer1 = 200.0f; + } else { + Camera_CalcAtForScreen(camera, &sp78, roData->unk_00, &rwData->unk_04, rwData->timer1); + if (rwData->timer1 > 10.0f) { + rwData->timer1--; + } + } + + camera->dist = Camera_ScaledStepToCeilF(rwData->unk_00, camera->dist, 1.0f / camera->rUpdateRateInv, 0.1f); + + if (rwData->timer2 != 0) { + if (rwData->timer3 <= 0) { + if (rwData->timer3 == 0) { + Camera_SetStateFlag(camera, CAM_STATE_DISABLE_MODE_CHANGE); + } + + tangle = ((rwData->timer2 + 1) * rwData->timer2) >> 1; + sp90.yaw = sp80.yaw + ((BINANG_SUB(rwData->unk_1E, sp80.yaw) / tangle) * rwData->timer2); + phi_a0 = ((roData->interfaceFlags & PARALLEL1_FLAG_0) ? BINANG_SUB(rwData->unk_20, rwData->unk_1C) + : rwData->unk_20); + new_var2 = BINANG_SUB(phi_a0, sp80.pitch); + sp90.pitch = sp80.pitch + ((new_var2 / tangle) * rwData->timer2); + sp90.r = camera->dist; + rwData->timer2--; + } else { + sp90 = sp80; + sp90.r = camera->dist; + } + } else { + OLib_Vec3fDiffToVecGeo(&sp90, at, eyeNext); + sp90.r = camera->dist; + + if (roData->interfaceFlags & PARALLEL1_FLAG_1) { + sp90.yaw = Camera_ScaledStepToCeilS(rwData->unk_1E, sp78.yaw, 1.0f / camera->yawUpdateRateInv, 0xC8); + } + + parallelFlagCond = (roData->interfaceFlags & (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)); + + if (roData->interfaceFlags & PARALLEL1_FLAG_0) { + phi_a0 = (rwData->unk_20 - rwData->unk_1C); + } else { + phi_a0 = rwData->unk_20; + } + + if (parallelFlagCond == (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) { + spA0 = CLAMP_MAX(camera->speedRatio, 1.0f); + phi_a0 = (sp90.pitch * spA0) + (phi_a0 * (1.0f - spA0)); + sp90.pitch = Camera_ScaledStepToCeilS(phi_a0, sp78.pitch, 1.0f / camera->pitchUpdateRateInv, 5); + } else if (parallelFlagCond != PARALLEL1_FLAG_3) { + sp90.pitch = Camera_ScaledStepToCeilS(phi_a0, sp78.pitch, 1.0f / camera->pitchUpdateRateInv, 5); + } + + if (sp90.pitch > DEG_TO_BINANG(79.655f)) { + sp90.pitch = DEG_TO_BINANG(79.655f); + } + + if (sp90.pitch < -DEG_TO_BINANG(29.995f)) { + sp90.pitch = -DEG_TO_BINANG(29.995f); + } + } + + if (rwData->timer3 > 0) { + rwData->timer3--; + } + + OLib_AddVecGeoToVec3f(eyeNext, at, &sp90); + + if (camera->status == CAM_STATUS_ACTIVE) { + if ((camera->play->envCtx.skyboxDisabled == 0) || (roData->interfaceFlags & PARALLEL1_FLAG_4)) { + spB0 = *at; + if ((((Player*)camera->focalActor)->stateFlags1 & PLAYER_STATE1_4000) || + (((Player*)camera->focalActor)->stateFlags1 & PLAYER_STATE1_4) || + ((roData->interfaceFlags & (PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1)) == + (PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1))) { + spB0.y += focalActorHeight; + } + *eye = *eyeNext; + func_800CBFA4(camera, &spB0, eye, 0); + } else { + *eye = *eyeNext; + func_800CBFA4(camera, at, eye, 3); + } + + if (rwData->timer2 != 0) { + sUpdateCameraDirection = true; + } else { + sUpdateCameraDirection = false; + } + } + + camera->fov = Camera_ScaledStepToCeilF(rwData->unk_08, camera->fov, camera->fovUpdateRate, 0.1f); + camera->roll = Camera_ScaledStepToCeilS(0, camera->roll, 0.5f, 5); + camera->atLerpStepScale = Camera_ClampLerpScale(camera, sp72 ? roData->unk_1C : roData->unk_18); + rwData->unk_26 &= ~1; + + return 1; +} + +/** + * Unused Camera Maze Setting + */ +s32 Camera_Parallel2(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Parallel3(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Parallel4(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Parallel0(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Jump1(Camera* camera) { + return Camera_Noop(camera); +} + +/** + * Camera for climbing structures + */ +s32 Camera_Jump2(Camera* camera) { + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + Vec3f* eyeNext = &camera->eyeNext; + Vec3f spC8; + Vec3f spBC; + VecGeo spB4; + VecGeo spAC; + VecGeo spA4; + VecGeo sp9C; + s16 temp_t2; + s16 yawDiff; + s32 pad; + f32 sp90; + f32 sp8C; + s32 sp88; + CameraCollision sp60; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + Jump2ReadOnlyData* roData = &camera->paramData.jump2.roData; + Jump2ReadWriteData* rwData = &camera->paramData.jump2.rwData; + f32 phi_f2; + f32 yNormal; // used twice + f32 focalActorHeight = Camera_GetFocalActorHeight(camera); + f32 temp_f16; + + if (RELOAD_PARAMS(camera)) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + + yNormal = 0.8f - (-0.2f * (68.0f / focalActorHeight)); + + if (camera->unk_0F0.y > 0.0f) { + phi_f2 = -10.0f; + } else { + phi_f2 = 10.0f; + } + + roData->unk_00 = CAM_RODATA_UNSCALE(phi_f2 + GET_NEXT_RO_DATA(values)) * focalActorHeight * yNormal; + roData->unk_04 = GET_NEXT_SCALED_RO_DATA(values) * focalActorHeight * yNormal; + roData->unk_08 = GET_NEXT_SCALED_RO_DATA(values) * focalActorHeight * yNormal; + roData->unk_0C = GET_NEXT_SCALED_RO_DATA(values); + roData->unk_10 = GET_NEXT_RO_DATA(values); + roData->unk_14 = GET_NEXT_SCALED_RO_DATA(values); + roData->unk_18 = GET_NEXT_RO_DATA(values); + roData->unk_1C = GET_NEXT_SCALED_RO_DATA(values); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + } + + OLib_Vec3fDiffToVecGeo(&sp9C, at, eye); + OLib_Vec3fDiffToVecGeo(&spA4, at, eyeNext); + + sCameraInterfaceFlags = roData->interfaceFlags; + + if (RELOAD_PARAMS(camera)) { + spC8 = focalActorPosRot->pos; + rwData->unk_00 = Camera_GetFloorY(camera, &spC8); + rwData->unk_04 = spA4.yaw; + rwData->unk_06 = 0; + + if (rwData->unk_00 == BGCHECK_Y_MIN) { + rwData->unk_0A = -1; + rwData->unk_00 = focalActorPosRot->pos.y - 1000.0f; + } else if ((focalActorPosRot->pos.y - rwData->unk_00) < focalActorHeight) { + rwData->unk_0A = 1; + } else { + rwData->unk_0A = -1; + } + + yawDiff = BINANG_SUB(BINANG_ROT180(focalActorPosRot->rot.y), spA4.yaw); + rwData->unk_06 = ((yawDiff / 6) / 4) * 3; + + if (roData->interfaceFlags & JUMP2_FLAG_1) { + rwData->unk_08 = 10; + } else { + rwData->unk_08 = 10000; + } + + focalActorPosRot->pos.x -= camera->unk_0F0.x; + focalActorPosRot->pos.y -= camera->unk_0F0.y; + focalActorPosRot->pos.z -= camera->unk_0F0.z; + + rwData->timer = 6; + camera->animState++; + camera->atLerpStepScale = roData->unk_1C; + } + + sp90 = camera->speedRatio * 0.5f; + sp8C = camera->speedRatio * 0.2f; + + camera->yawUpdateRateInv = Camera_ScaledStepToCeilF(roData->unk_10, camera->yawUpdateRateInv, sp90, 0.1f); + camera->yOffsetUpdateRate = Camera_ScaledStepToCeilF(roData->unk_14, camera->yOffsetUpdateRate, sp90, 0.0001f); + camera->xzOffsetUpdateRate = Camera_ScaledStepToCeilF(0.05f, camera->xzOffsetUpdateRate, sp8C, 0.0001f); + camera->fovUpdateRate = Camera_ScaledStepToCeilF(0.05f, camera->fovUpdateRate, camera->speedRatio * .05f, 0.0001f); + camera->rUpdateRateInv = 1800.0f; + + Camera_CalcAtDefault(camera, &spA4, roData->unk_00, 0); + OLib_Vec3fDiffToVecGeo(&spB4, at, eye); + + //! FAKE: Unused + yNormal = roData->unk_04; + + phi_f2 = roData->unk_08 + (roData->unk_08 * roData->unk_0C); + temp_f16 = roData->unk_04 - (roData->unk_04 * roData->unk_0C); + + if (spB4.r > phi_f2) { + spB4.r = phi_f2; + } else if (spB4.r < temp_f16) { + spB4.r = temp_f16; + } + + yawDiff = BINANG_SUB(BINANG_ROT180(focalActorPosRot->rot.y), spB4.yaw); + if (rwData->timer != 0) { + rwData->unk_04 = BINANG_ROT180(focalActorPosRot->rot.y); + rwData->timer--; + spB4.yaw = Camera_ScaledStepToCeilS(rwData->unk_04, spA4.yaw, 0.5f, 5); + } else if (rwData->unk_08 < ABS(yawDiff)) { + temp_t2 = BINANG_ROT180(focalActorPosRot->rot.y); + spB4.yaw = Camera_ScaledStepToFloorS((yawDiff < 0) ? (temp_t2 + rwData->unk_08) : (temp_t2 - rwData->unk_08), + spA4.yaw, 0.1f, 1); + } else { + spB4.yaw = Camera_ScaledStepToCeilS(spB4.yaw, spA4.yaw, 0.25f, 5); + } + + spC8.x = focalActorPosRot->pos.x + (Math_SinS(focalActorPosRot->rot.y) * 25.0f); + spC8.y = focalActorPosRot->pos.y + (focalActorHeight * 2.2f); + spC8.z = focalActorPosRot->pos.z + (Math_CosS(focalActorPosRot->rot.y) * 25.0f); + + yNormal = Camera_GetFloorYNorm(camera, &spBC, &spC8, &sp88); + if (camera->focalActor->bgCheckFlags & 0x10) { + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF(20.0f, camera->pitchUpdateRateInv, 0.2f, 0.1f); + camera->rUpdateRateInv = Camera_ScaledStepToCeilF(20.0f, camera->rUpdateRateInv, 0.2f, 0.1f); + spB4.pitch = Camera_ScaledStepToCeilS(-DEG_TO_BINANG(27.47f), spA4.pitch, 0.2f, 5); + } else if ((yNormal != BGCHECK_Y_MIN) && (focalActorPosRot->pos.y < yNormal)) { + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF(20.0f, camera->pitchUpdateRateInv, 0.2f, 0.1f); + camera->rUpdateRateInv = Camera_ScaledStepToCeilF(20.0f, camera->rUpdateRateInv, 0.2f, 0.1f); + if (camera->unk_0F0.y > 1.0f) { + spB4.pitch = Camera_ScaledStepToCeilS(0x1F4, spA4.pitch, 1.0f / camera->pitchUpdateRateInv, 5); + } + } else if ((focalActorPosRot->pos.y - rwData->unk_00) < focalActorHeight) { + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF(20.0f, camera->pitchUpdateRateInv, 0.2f, 0.1f); + camera->rUpdateRateInv = Camera_ScaledStepToCeilF(20.0f, camera->rUpdateRateInv, 0.2f, 0.1f); + if (camera->unk_0F0.y > 1.0f) { + spB4.pitch = Camera_ScaledStepToCeilS(0x1F4, spA4.pitch, 1.0f / camera->pitchUpdateRateInv, 5); + } + } else { + camera->pitchUpdateRateInv = 100.0f; + camera->rUpdateRateInv = 100.0f; + } + + spB4.pitch = CLAMP_MAX(spB4.pitch, DEG_TO_BINANG(60.43f)); + spB4.pitch = CLAMP_MIN(spB4.pitch, -DEG_TO_BINANG(60.43f)); + + OLib_AddVecGeoToVec3f(eyeNext, at, &spB4); + sp60.pos = *eyeNext; + + if (func_800CBC84(camera, at, &sp60, 0) != 0) { + spC8 = sp60.pos; + spAC.pitch = 0; + spAC.r = spB4.r; + spAC.yaw = spB4.yaw; + OLib_AddVecGeoToVec3f(&sp60.pos, at, &spAC); + if (func_800CBC84(camera, at, &sp60, 0) != 0) { + *eye = spC8; + } else { + spB4.pitch = Camera_ScaledStepToCeilS(0, spB4.pitch, 0.2f, 5); + OLib_AddVecGeoToVec3f(eye, at, &spB4); + func_800CBFA4(camera, at, eye, 0); + } + } else { + *eye = *eyeNext; + } + + camera->dist = spB4.r; + camera->fov = Camera_ScaledStepToCeilF(roData->unk_18, camera->fov, camera->fovUpdateRate, 0.1f); + camera->roll = Camera_ScaledStepToCeilS(0, camera->roll, 0.5f, 5); + + return true; +} + +/** + * Used for water-based camera settings + * e.g. Gyorg, Pinnacle Rock, whirlpool, water + */ +s32 Camera_Jump3(Camera* camera) { + Vec3f* sp48 = &camera->eye; + Vec3f* sp44 = &camera->at; + Vec3f* sp40 = &camera->eyeNext; + f32 spD0; + f32 spCC; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + f32 phi_f0; + f32 spC0; + Vec3f spB4; + VecGeo spAC; + CameraModeValue* values; + f32 phi_f14; + VecGeo sp9C; + VecGeo sp94; + f32 phi_f2_2; + f32 temp_f0; + f32 temp1; + f32 pad; + Jump3ReadOnlyData* roData = &camera->paramData.jump3.roData; + Jump3ReadWriteData* rwData = &camera->paramData.jump3.rwData; + f32 focalActorHeight; + PosRot focalActorFocus; + f32 sp60; + f32 sp5C; + s32 sp58; + + focalActorHeight = Camera_GetFocalActorHeight(camera); + Actor_GetFocus(&focalActorFocus, camera->focalActor); + sp60 = camera->waterYPos - sp48->y; + + sp58 = false; + + if (RELOAD_PARAMS(camera)) { + rwData->unk_0A = camera->mode; + rwData->timer2 = 0; + } + + if (camera->mode == CAM_MODE_NORMAL) { + if ((camera->focalActor->bgCheckFlags & 0x10) || (rwData->timer2 != 0)) { + if (rwData->unk_0A != 0xF) { + rwData->unk_0A = 0xF; + sp58 = true; + rwData->timer2 = 10; + } + } else if (sp60 < 50.0f) { + if (rwData->unk_0A != 0) { + rwData->unk_0A = 0; + sp58 = true; + } + } else if (Camera_fabsf(camera->focalActorPosRot.pos.y - camera->focalActorFloorHeight) < 11.0f) { + if (rwData->unk_0A != 5) { + rwData->unk_0A = 5; + sp58 = true; + } + } else if ((sp60 > 250.0f) && (rwData->unk_0A != 0x1A)) { + rwData->unk_0A = 0x1A; + sp58 = true; + } + } + + if (rwData->timer2 != 0) { + rwData->timer2--; + } + + OLib_Vec3fDiffToVecGeo(&sp9C, sp44, sp48); + OLib_Vec3fDiffToVecGeo(&sp94, sp44, sp40); + + if (!RELOAD_PARAMS(camera) && !sp58) { + } else { + values = sCameraSettings[camera->setting].cameraModes[rwData->unk_0A].values; + + sp5C = 0.8f - (-0.2f * (68.0f / focalActorHeight)); + spD0 = focalActorHeight * 0.01f * sp5C; + + roData->unk_00 = GET_NEXT_RO_DATA(values) * spD0; + roData->unk_04 = GET_NEXT_RO_DATA(values) * spD0; + roData->unk_08 = GET_NEXT_RO_DATA(values) * spD0; + roData->unk_20 = CAM_DEG_TO_BINANG(GET_NEXT_RO_DATA(values)); + roData->unk_0C = GET_NEXT_RO_DATA(values); + roData->unk_10 = GET_NEXT_RO_DATA(values); + roData->unk_14 = GET_NEXT_SCALED_RO_DATA(values); + roData->unk_18 = GET_NEXT_RO_DATA(values); + roData->unk_1C = GET_NEXT_SCALED_RO_DATA(values); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + } + + sCameraInterfaceFlags = roData->interfaceFlags; + + switch (camera->animState) { + case 0: + rwData->unk_10 = 0x1000; + // fallthrough + case 10: + case 20: + rwData->unk_00 = camera->focalActorFloorHeight; + D_801EDC30[camera->camId].yaw = D_801EDC30[camera->camId].pitch = D_801EDC30[camera->camId].unk_64 = 0; + rwData->timer1 = 10; + D_801EDC30[camera->camId].swingUpdateRate = roData->unk_0C; + camera->animState++; + D_801EDC30[camera->camId].timer = 0; + break; + + default: + if (rwData->timer1 != 0) { + rwData->timer1--; + } + break; + } + + spC0 = focalActorFocus.pos.y - focalActorPosRot->pos.y; + spB4 = *sp48; + + spD0 = camera->speedRatio * 0.5f; + spCC = camera->speedRatio * 0.2f; + + temp_f0 = (D_801EDC30[camera->camId].unk_64 == 1) ? 0.5f : spD0; + + if (D_801EDC30[camera->camId].timer != 0) { + camera->yawUpdateRateInv = + Camera_ScaledStepToCeilF((D_801EDC30[camera->camId].swingUpdateRate + D_801EDC30[camera->camId].timer * 2), + camera->yawUpdateRateInv, spD0, 0.1f); + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF((40.0f + D_801EDC30[camera->camId].timer * 2), + camera->pitchUpdateRateInv, spCC, 0.1f); + D_801EDC30[camera->camId].timer--; + } else { + camera->yawUpdateRateInv = Camera_ScaledStepToCeilF(D_801EDC30[camera->camId].swingUpdateRate, + camera->yawUpdateRateInv, temp_f0, 0.1f); + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF(40.0f, camera->pitchUpdateRateInv, spCC, 0.1f); + } + + if (roData->interfaceFlags & JUMP3_FLAG_7) { + camera->yOffsetUpdateRate = Camera_ScaledStepToCeilF(0.01f, camera->yOffsetUpdateRate, spD0, 0.0001f); + sp5C = sqrtf((camera->unk_0F0.x * camera->unk_0F0.x) + (camera->unk_0F0.z * camera->unk_0F0.z)) / + Camera_GetRunSpeedLimit(camera); + camera->speedRatio = OLib_ClampMaxDist(sp5C / Camera_GetRunSpeedLimit(camera), 1.8f); + spCC = camera->speedRatio * 0.2f; + } else { + camera->yOffsetUpdateRate = Camera_ScaledStepToCeilF(0.05f, camera->yOffsetUpdateRate, spD0, 0.0001f); + } + + camera->xzOffsetUpdateRate = Camera_ScaledStepToCeilF(0.05f, camera->xzOffsetUpdateRate, spCC, 0.0001f); + camera->fovUpdateRate = + Camera_ScaledStepToCeilF(0.050f, camera->fovUpdateRate, camera->speedRatio * 0.05f, 0.0001f); + + if (sp60 < 50.0f) { + sp5C = camera->waterYPos - spC0; + + Camera_CalcAtForScreen(camera, &sp94, roData->unk_00, &sp5C, + ((sp60 < 0.0f) ? 1.0f : 1.0f - (sp60 / 50.0f)) * 50.0f); + } else { + Camera_CalcAtDefault(camera, &sp94, roData->unk_00, roData->interfaceFlags); + } + + OLib_Vec3fDiffToVecGeo(&spAC, sp44, sp40); + spAC.r = Camera_ClampDist1(camera, spAC.r, roData->unk_04, roData->unk_08, rwData->timer1); + camera->dist = spAC.r; + + if (!(Camera_fabsf(focalActorPosRot->pos.y - camera->focalActorFloorHeight) < 10.0f) && + !(Camera_fabsf(focalActorFocus.pos.y - camera->waterYPos) < 50.f)) { + camera->pitchUpdateRateInv = 100.0f; + } + + if (roData->interfaceFlags & JUMP3_FLAG_5) { + spD0 = CLAMP_MAX(camera->speedRatio * 1.3f, 0.6f); + + //! FAKE: spCC = + spAC.pitch = Camera_ScaledStepToCeilS( + (spAC.pitch * spD0) + (roData->unk_20 * (1.0f - spD0)), sp94.pitch, + 1.0f / (spCC = ((camera->pitchUpdateRateInv + 1.0f) - (camera->pitchUpdateRateInv * spD0))), 5); + } else if (D_801EDC30[camera->camId].unk_64 == 1) { + spAC.yaw = + Camera_ScaledStepToCeilS(D_801EDC30[camera->camId].yaw, sp94.yaw, 1.0f / camera->yawUpdateRateInv, 5); + + // Bug? Should be pitchUpdateRateInv + spAC.pitch = + Camera_ScaledStepToCeilS(D_801EDC30[camera->camId].pitch, sp94.pitch, 1.0f / camera->yawUpdateRateInv, 5); + } else if (roData->interfaceFlags & (JUMP3_FLAG_7 | JUMP3_FLAG_3)) { + spAC.yaw = Camera_CalcDefaultYaw(camera, sp94.yaw, focalActorPosRot->rot.y, roData->unk_14, 0.0f); + + spD0 = CLAMP_MAX(camera->speedRatio * 1.3f, 1.0f); + + //! FAKE: spCC = + spAC.pitch = Camera_ScaledStepToCeilS( + (spAC.pitch * spD0) + (roData->unk_20 * (1.0f - spD0)), sp94.pitch, + 1.0f / (spCC = (camera->pitchUpdateRateInv + 1.0f) - (camera->pitchUpdateRateInv * spD0)), 5); + } else { + spAC.yaw = Camera_CalcDefaultYaw(camera, sp94.yaw, focalActorPosRot->rot.y, roData->unk_14, 0.0f); + spAC.pitch = Camera_CalcDefaultPitch(camera, sp94.pitch, roData->unk_20, 0); + } + + if (spAC.pitch > DEG_TO_BINANG(79.655f)) { + spAC.pitch = DEG_TO_BINANG(79.655f); + } + + if (spAC.pitch < -DEG_TO_BINANG(29.995f)) { + spAC.pitch = -DEG_TO_BINANG(29.995f); + } + + OLib_AddVecGeoToVec3f(sp40, sp44, &spAC); + + if ((camera->status == CAM_STATUS_ACTIVE) && !(roData->interfaceFlags & JUMP3_FLAG_6)) { + if (func_800CBA7C(camera) == 0) { + Camera_CalcDefaultSwing(camera, &spAC, &sp9C, roData->unk_04, roData->unk_0C, &D_801EDC30[camera->camId], + &rwData->unk_10); + } + + if (roData->interfaceFlags & JUMP3_FLAG_2) { + camera->inputDir.x = -sp9C.pitch; + camera->inputDir.y = sp9C.yaw + 0x8000; + camera->inputDir.z = 0; + } else { + OLib_Vec3fDiffToVecGeo(&spAC, sp48, sp44); + camera->inputDir.x = spAC.pitch; + camera->inputDir.y = spAC.yaw; + camera->inputDir.z = 0; + } + } else { + D_801EDC30[camera->camId].swingUpdateRate = roData->unk_0C; + D_801EDC30[camera->camId].unk_64 = 0; + sUpdateCameraDirection = false; + *sp48 = *sp40; + } + + camera->fov = Camera_ScaledStepToCeilF(roData->unk_18, camera->fov, camera->fovUpdateRate, 0.1f); + camera->roll = Camera_ScaledStepToCeilS(0, camera->roll, .5f, 5); + camera->atLerpStepScale = Camera_ClampLerpScale(camera, roData->unk_1C); + + return 1; +} + +s32 Camera_Jump4(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Jump0(Camera* camera) { + return Camera_Noop(camera); +} + +#ifdef NON_EQUIVALENT +s32 Camera_Battle1(Camera* camera) { + Battle1ReadOnlyData* roData = &camera->paramData.batt1.roData; + Battle1ReadWriteData* rwData = &camera->paramData.batt1.rwData; + Vec3f sp120; + Vec3f sp114; + f32 sp104; + f32 spFC; + f32 spF8; + f32 spF8_2; + f32 spF4; + s32 spF0; // bool + f32 spEC; + Vec3f spC4; + VecGeo spBC; + VecGeo spB4; + VecGeo spAC; + VecGeo spA4; + VecGeo sp9C; + VecGeo sp94; + PosRot* sp8C; + s16 sp8A; + s16 sp88; + s16 sp86; + s16 sp84; + f32 sp80; + f32 sp7C; + f32 sp78; + f32 sp68; + s16 sp5E; + s16 sp5C; + Vec3f* sp50; + Vec3f* sp4C; + Vec3f* sp48; + PosRot* sp40; + + f32 temp_f12; + f32 temp_f14; + f32 temp_f2_3; + s16 temp_v0_5; + s16 temp_v0_6; + s32 temp_f4; + f32 phi_f0_3; + f32 phi_f12; + + f32 new_var; + f32 new_var2; + f32 new_var3; + f32 new_var5; + f32 new_var4; + + sp50 = &camera->eye; + sp4C = &camera->at; + sp48 = &camera->eyeNext; + sp40 = &camera->targetPosRot; + + spF0 = false; + sp8C = &camera->focalActor->focus; + sp68 = Camera_GetFocalActorHeight(camera); + + if ((camera->animState != 0) && (camera->animState != 0xA) && (camera->animState != 0x14)) { + } else { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + + roData->unk_00 = GET_NEXT_RO_DATA(values) * 0.01f * sp68 * (0.8f - ((68.0f / sp68) * -0.2f)); + roData->unk_04 = GET_NEXT_RO_DATA(values); + roData->unk_08 = GET_NEXT_RO_DATA(values); + roData->unk_0C = GET_NEXT_RO_DATA(values); + roData->unk_0C = 80.0f - (80.0f - roData->unk_0C); + roData->unk_10 = GET_NEXT_RO_DATA(values); + roData->unk_10 = 0.0f - (0.0f - roData->unk_10); + roData->unk_14 = GET_NEXT_RO_DATA(values); + roData->unk_14 = 40.0f - (40.0f - roData->unk_14); + roData->unk_18 = GET_NEXT_RO_DATA(values); + roData->unk_18 = 20.0f - (20.0f - roData->unk_18); + roData->unk_1C = GET_NEXT_RO_DATA(values) * 0.01f; + roData->unk_1C = 1.0f - (1.0f - roData->unk_1C); + roData->unk_20 = GET_NEXT_RO_DATA(values); + roData->unk_24 = GET_NEXT_RO_DATA(values) * 0.01f; + roData->unk_24 = 1.0f - (1.0f - roData->unk_24); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + roData->unk_28 = GET_NEXT_RO_DATA(values) * 0.01f; + roData->unk_28 = 0.2f - (0.2f - roData->unk_28); + roData->unk_2C = GET_NEXT_RO_DATA(values) * 0.01f; + if ((camera->animState != 0) && (camera->animState != 0xA) && (camera->animState != 0x14)) { + } else { + rwData->unk_18 = 0x28; + camera->pitchUpdateRateInv = 9.0f; + } + } + + sp80 = roData->unk_14; + sp7C = roData->unk_18; + sp78 = roData->unk_20; + + if (Camera_IsChargingSwordOrDekuFlowerDive(camera)) { + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF(18.0f, camera->pitchUpdateRateInv, 0.5f, 0.1f); + camera->yOffsetUpdateRate = Camera_ScaledStepToCeilF(0.2f, camera->yOffsetUpdateRate, 0.5f, 0.0001f); + camera->xzOffsetUpdateRate = Camera_ScaledStepToCeilF(0.2f, camera->xzOffsetUpdateRate, 0.5f, 0.0001f); + if (rwData->unk_18 >= -0x13) { + rwData->unk_18--; + } else { + sp80 = 50.0f; + sp7C = 40.0f; + sp78 = 60.0f; + } + } else { + if (rwData->unk_18 < 0) { + sp80 = 50.0f; + sp7C = 40.0f; + sp78 = 60.0f; + rwData->unk_18++; + } else { + rwData->unk_18 = 0x28; + camera->pitchUpdateRateInv = Camera_ScaledStepToCeilF(9.0f, camera->pitchUpdateRateInv, 0.5f, 0.1f); + camera->yOffsetUpdateRate = + Camera_ScaledStepToCeilF(0.6f, camera->yOffsetUpdateRate, camera->speedRatio * 0.5f, 0.0001f); + camera->xzOffsetUpdateRate = + Camera_ScaledStepToCeilF(0.6f, camera->xzOffsetUpdateRate, camera->speedRatio * 0.2f, 0.0001f); + } + } + + camera->fovUpdateRate = + Camera_ScaledStepToCeilF(0.050f, camera->fovUpdateRate, camera->speedRatio * 0.05f, 0.0001f); + sp68 += roData->unk_00; + OLib_Vec3fDiffToVecGeo(&sp9C, sp4C, sp50); + OLib_Vec3fDiffToVecGeo(&sp94, sp4C, sp48); + if ((camera->target == NULL) || (camera->target->update == NULL)) { + camera->target = NULL; + Camera_ChangeMode(camera, CAM_MODE_TARGET); + return true; + } + + sCameraInterfaceFlags = roData->interfaceFlags; + + if ((camera->animState == 0) || (camera->animState == 0xA) || (camera->animState == 0x14)) { + rwData->unk_10 = 0; + rwData->unk_1A = 0; + rwData->unk_08 = camera->target; + camera->animState++; + rwData->unk_16 = 7; + rwData->unk_12 = sp9C.yaw; + rwData->unk_14 = sp9C.pitch; + rwData->unk_00 = sp9C.r; + rwData->unk_04 = camera->focalActorPosRot.pos.y - camera->unk_0F0.y; + if ((2.0f * roData->unk_04) < camera->dist) { + camera->dist = 2.0f * roData->unk_04; + sp94.r = camera->dist; + sp9C.r = sp94.r; + OLib_AddVecGeoToVec3f(sp50, sp4C, &sp9C); + *sp48 = *sp50; + } + } + + if (camera->status == CAM_STATUS_ACTIVE) { + sUpdateCameraDirection = true; + camera->inputDir.x = -sp9C.pitch; + camera->inputDir.y = sp9C.yaw + 0x8000; + camera->inputDir.z = 0; + } + + if (func_800CB950(camera)) { + rwData->unk_04 = camera->focalActorPosRot.pos.y; + sp84 = 0; + } else { + sp84 = 1; + } + + if (rwData->unk_16 == 0) { + camera->atLerpStepScale = Camera_ClampLerpScale(camera, sp84 ? roData->unk_28 : roData->unk_24); + } + + Actor_GetFocus(&sp40->pos, camera->target); + + if (rwData->unk_08 != camera->target) { + camera->animState = 0; + return true; + } + + sp120 = camera->focalActorPosRot.pos; + sp120.y += sp68; + OLib_Vec3fDiffToVecGeo(&spA4, &sp120, &sp40->pos); + sp104 = func_800CD6CC(camera->target); + if (PREG(86) + 800.0f < sp104) { + sp104 = PREG(86) + 800.0f; + } + + // new_var5 = sp104; // TODO: Fake temp but helps when used? + // sp104 = new_var5; + + // Above is down to SP and Floats + + if ((sp104 < spA4.r) || Camera_IsChargingSwordOrDekuFlowerDive(camera)) { + spEC = 1.0f; + spF8 = 10.0f; + // dummy:; // Helps? + // sp80 = roData->unk_14; // Fake & Non-equivalent but helps? + } else { + spEC = spA4.r / sp104; + spF8 = 2.0f; + } + // spF8 should be set with swc1 twice, not once + + // sp94 is loading in too early + Camera_CalcAtForEnemyLockOn(camera, &sp94.r, sp40, roData->unk_00, roData->unk_2C, 1.0f - spEC, &rwData->unk_04, + &spA4, + (sp84 ? (BATTLE1_FLAG_7 | BATTLE1_FLAG_0) : BATTLE1_FLAG_0) | roData->interfaceFlags); + + sp88 = spA4.yaw; + OLib_Vec3fDiffToVecGeo(&spBC, sp4C, sp48); + spF4 = roData->unk_04 + ((roData->unk_08 - roData->unk_04) * spEC); + camera->rUpdateRateInv = Camera_ScaledStepToCeilF(spF8, camera->rUpdateRateInv, 0.5f, 0.1f); + spBC.r = camera->dist = Camera_ScaledStepToCeilF(spF4, camera->dist, 1.0f / camera->rUpdateRateInv, 0.1f); + OLib_Vec3fDiffToVecGeo(&spAC, sp4C, &sp40->pos); + + spAC.r = spBC.r - (((spAC.r >= spBC.r) ? spBC.r : spAC.r) * 0.5f); + + if (rwData->unk_1A & 0x1000) { + spFC = 15.0f; + } else { + spFC = roData->unk_0C + ((roData->unk_10 - roData->unk_0C) * (1.1f - spEC)); + } + spBC.yaw = sp94.yaw; + temp_v0_5 = (sp94.yaw + 0x8000); + temp_v0_5 = spAC.yaw - temp_v0_5; + if (rwData->unk_16 != 0) { + if (rwData->unk_16 > 0) { + sp86 = rwData->unk_16 - 1; + OLib_Vec3fDiffToVecGeo(&spB4, sp4C, sp50); + spB4.yaw = sp88 + 0x8000; + new_var = (rwData->unk_00 - spB4.r) * 0.16666667f; + sp8A = (s16)(rwData->unk_12 - spB4.yaw) * 0.16666667f; + sp88 = (s16)(rwData->unk_14 - spB4.pitch) * 0.16666667f; + spBC.r = Camera_ScaledStepToCeilF((sp86 * new_var) + spB4.r, sp9C.r, 0.5f, + 1.0f); // TODO: extra float calcs going on here + spBC.yaw = Camera_ScaledStepToCeilS(spB4.yaw + (sp8A * sp86), sp9C.yaw, 0.5f, 5); + spBC.pitch = Camera_ScaledStepToCeilS(spB4.pitch + (sp88 * sp86), sp9C.pitch, 0.5f, 5); + } else { + spF0 = true; + } + rwData->unk_16--; + } else { + // s32 phi_v0_2 = ABS(temp_v0_5); + temp_f4 = (s16)((spFC * 182.04167f) + .5f); + if ((temp_f4 < ABS(temp_v0_5)) && (sp84 == 0)) { + + sp8A = temp_v0_5; + sp104 = temp_v0_5 * 0.00549325f; + + temp_f2_3 = ((OLib_ClampMaxDist(spAC.r, spBC.r) / spBC.r) * ((spFC + 10.0f) - spFC)) + spFC; + temp_f12 = (SQ(temp_f2_3) - 2.0f) / (temp_f2_3 - 360.0f); + new_var3 = temp_f12 * sp104; + temp_f14 = SQ(sp104) / (new_var3 + (2.0f - (360.0f * temp_f12))); + + if (sp8A >= 0) { + sp88 = CAM_DEG_TO_BINANG(temp_f14); + } else { + sp88 = -CAM_DEG_TO_BINANG(temp_f14); + } + + spBC.yaw = (s16)(sp94.yaw + 0x8000) + (s16)(sp88 + 0x8000); + } else { + new_var2 = (1.0f - camera->speedRatio) * 0.05f; + if (temp_v0_5 >= 0) { + sp88 = temp_f4 & 0xFFFFu; // TODO: Is this needed? + } else { + sp88 = -temp_f4; + } + spBC.yaw = sp94.yaw - (s16)((sp88 - temp_v0_5) * new_var2); + } + } + + if (spF0 == false) { + new_var4 = spAC.pitch * roData->unk_1C; + temp_v0_6 = ((s16)(((((sp7C - sp80) * spEC) + sp80) * 182.04167f) + .5f) - + (s16)((spA4.pitch * (0.5f + (spEC * 0.5f))) + 0.5f)); + temp_v0_6 += (s16)new_var4; + + if (temp_v0_6 < -0x2AA8) { + temp_v0_6 = -0x2AA8; + } else if (temp_v0_6 > 0x2AA8) { + temp_v0_6 = 0x2AA8; + } + + spBC.pitch = Camera_ScaledStepToCeilS(temp_v0_6, sp94.pitch, 1.0f / camera->pitchUpdateRateInv, 5); + OLib_AddVecGeoToVec3f(sp48, sp4C, &spBC); + spC4 = *sp48; + if (camera->status == CAM_STATUS_ACTIVE) { + if (!(roData->interfaceFlags & BATTLE1_FLAG_4)) { + if ((camera->play->envCtx.skyboxDisabled == 0) || (roData->interfaceFlags & BATTLE1_FLAG_0)) { + if (func_800CBC84(camera, sp4C, &spC4, 0) != 0) { + rwData->unk_1A |= 0x1000; + } else { + rwData->unk_1A &= ~0x1000; + } + } else if (roData->interfaceFlags & BATTLE1_FLAG_1) { + func_800CBC84(camera, sp4C, &spC4, 3); + } else { + OLib_Vec3fDistNormalize(&sp114, sp4C, &spC4); + spC4.x -= sp114.x; + spC4.y -= sp114.y; + spC4.z -= sp114.z; + } + *sp50 = spC4; + ; + rwData->unk_1A &= ~0x10; + } else if ((camera->play->envCtx.skyboxDisabled == 0) || (roData->interfaceFlags & BATTLE1_FLAG_0)) { + if (func_800CBC84(camera, sp4C, &spC4, 0) != 0) { + rwData->unk_1A |= 0x1000; + spF8 = OLib_Vec3fDist(sp4C, sp8C); + spF4 = OLib_Vec3fDist(sp4C, &spC4); + phi_f0_3 = (rwData->unk_1A & 0x10) ? 40.0f : 0.0f; + spF8 = spF8 + phi_f0_3; + Actor_GetScreenPos(camera->play, camera->focalActor, &sp5E, &sp5C); + if ((spF4 < spF8) || ((sp5E >= 0) && (sp5E < 0x141) && (sp5C >= 0) && (sp5C < 0xF1))) { + rwData->unk_1A |= 0x10; + spB4.yaw = spA4.yaw + 0x8000; + spB4.pitch = -spA4.pitch; + spB4.r = 40.0f; + sp114 = sp8C->pos; + sp114.y += 40.0f; + OLib_AddVecGeoToVec3f(&sp120, &sp114, &spB4); + Camera_ScaledStepToCeilVec3f(&sp120, sp50, 0.15f, 0.15f, 0.2f); + } else if (rwData->unk_1A & 0x10) { + if (OLib_Vec3fDist(&spC4, sp50) < 20.0f) { + rwData->unk_1A &= ~0x10; + *sp50 = spC4; + } else { + Camera_ScaledStepToCeilVec3f(&spC4, sp50, 0.15f, 0.15f, 0.2f); + } + } else { + rwData->unk_1A &= ~0x10; + *sp50 = spC4; + } + dummy:; // TODO: Is Needed? + } else { + if (rwData->unk_1A & 0x10) { + if (OLib_Vec3fDist(&spC4, sp50) < 20.0f) { + rwData->unk_1A &= ~0x10; + *sp50 = spC4; + } else { + Camera_ScaledStepToCeilVec3f(&spC4, sp50, 0.15f, 0.15f, 0.2f); + } + } else { + rwData->unk_1A &= ~0x10; + *sp50 = spC4; + } + rwData->unk_1A &= ~0x1000; + } + } else if (roData->interfaceFlags & BATTLE1_FLAG_1) { + rwData->unk_1A &= ~0x10; + if (func_800CBC84(camera, sp4C, &spC4, 3) != 0) { + *sp50 = spC4; + } else { + *sp50 = spC4; + } + } else { + rwData->unk_1A &= ~0x10; + OLib_Vec3fDistNormalize(&sp114, sp4C, &spC4); + spC4.x -= sp114.x; + spC4.y -= sp114.y; + spC4.z -= sp114.z; + *sp50 = spC4; + } + } else { + rwData->unk_1A &= ~0x10; + *sp50 = *sp48; + } + } + + if (rwData->unk_16 != 0) { + sp88 = 0; + } else { + sp88 = (s16)(sp94.yaw - spBC.yaw) * 0.50f; + } + + camera->roll = Camera_ScaledStepToCeilS(sp88, camera->roll, 0.06f, 5); + if (func_800CBAAC(camera) != 0) { + phi_f12 = ((camera->play->state.frames & 8) != 0) ? roData->unk_20 - (roData->unk_20 * 0.5f) : roData->unk_20; + } else { + phi_f12 = ((gSaveContext.save.saveInfo.playerData.health <= 16) ? 0.8f : 1.0f) * (sp78 - (sp78 * 0.05f * spEC)); + } + camera->fov = Camera_ScaledStepToCeilF(phi_f12, camera->fov, camera->fovUpdateRate, 0.1f); + + return true; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Battle1.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Battle2.s") +s32 Camera_Battle2(Camera* camera) { + return Camera_Noop(camera); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Battle3.s") +s32 Camera_Battle3(Camera* camera) { + return Camera_Noop(camera); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Battle4.s") +s32 Camera_Battle4(Camera* camera) { + return Camera_Noop(camera); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Battle0.s") +s32 Camera_Battle0(Camera* camera) { + return Camera_Noop(camera); +} +/** + * Used for following a secondary target such as zora fins or a z-target + */ +// Very non-equivalent, many fakes. May need to restart from scratch (mips2c) +#ifdef NON_EQUIVALENT +s32 Camera_KeepOn1(Camera* camera) { + f32 pad1; + f32* pad2; + Vec3f* sp48 = &camera->eye; + Vec3f* sp44 = &camera->at; + Vec3f* sp40 = &camera->eyeNext; + Vec3f sp130; + Vec3f sp124; + Vec3f sp118; + f32 sp114; + PosRot* sp3C = &camera->focalActorPosRot; + PosRot* sp30 = &camera->targetPosRot; + f32 sp104; + f32 temp_f2_3; + f32 new_var; + f32 spFC; + f32 spF8; + f32 spF4; + s16 spF2; + s16 spF0; + VecGeo spE8; + VecGeo spE0; + VecGeo spD8; + VecGeo spD0; + VecGeo spC8; + VecGeo spC0; + f32 new_var2; + s32 new_var3; + f32 temp_f0; + Vec3f spA8; + PosRot* spA4; + CameraCollision sp7C; + + s32 sp78; + f32 sp74; + s16 sp72; + s16 sp70; + f32 sp60; + s16 sp56; + s16 sp54; + + s16 phi_v1_3; + s16 phi_a0; + KeepOn1ReadOnlyData* roData = &camera->paramData.keep1.roData; + KeepOn1ReadWriteData* rwData = &camera->paramData.keep1.rwData; + s16 temp_v0_3; + s16 new_var4; + + spA4 = &camera->focalActor->focus; + //! FAKE + if (temp_v0_3) {} + sp78 = 0; + temp_f0 = Camera_GetFocalActorHeight(camera); + // temp_a1 = camera->target; + + if ((camera->target == NULL) || (camera->target->update == NULL)) { + camera->target = NULL; + Camera_ChangeMode(camera, CAM_MODE_TARGET); + return 1; + } + + if (RELOAD_PARAMS(camera)) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + + roData->unk_00 = GET_NEXT_SCALED_RO_DATA(values) * temp_f0 * (0.8f - ((68.0f / temp_f0) * -0.2f)); + roData->unk_04 = GET_NEXT_RO_DATA(values); + roData->unk_08 = GET_NEXT_RO_DATA(values); + roData->unk_0C = GET_NEXT_RO_DATA(values); + roData->unk_10 = GET_NEXT_RO_DATA(values); + roData->unk_14 = GET_NEXT_RO_DATA(values); + roData->unk_14 = 40.0f - (40.0f - roData->unk_14); + roData->unk_18 = GET_NEXT_RO_DATA(values); + roData->unk_18 = 20.0f - (20.0f - roData->unk_18); + // roData->unk_18 = roData->unk_18; // TODO: Fake + // if (!roData->unk_08) {} + roData->unk_1C = GET_NEXT_SCALED_RO_DATA(values); + roData->unk_1C = 1.000f - (1.00f - roData->unk_1C); // TODO: Necessary? + roData->unk_20 = GET_NEXT_RO_DATA(values); + roData->unk_24 = GET_NEXT_SCALED_RO_DATA(values); + roData->unk_24 = 1.0f - (1.0f - roData->unk_24); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + roData->unk_28 = GET_NEXT_SCALED_RO_DATA(values); + roData->unk_28 = 0.2f - (0.2f - roData->unk_28); + } + + sp60 = temp_f0; + sp114 = roData->unk_00; // TODO: likely fake temp + sp60 += sp114; + OLib_Vec3fDiffToVecGeo(&spC8, sp44, sp48); + OLib_Vec3fDiffToVecGeo(&spC0, sp44, sp40); + sCameraInterfaceFlags = roData->interfaceFlags; + + if (RELOAD_PARAMS(camera)) { + camera->animState++; + rwData->unk_18 = 0; + rwData->unk_10 = 0; + rwData->unk_04 = 0.0f; + rwData->unk_0C = camera->target; + rwData->unk_16 = 7; + rwData->unk_12 = spC8.yaw; + rwData->unk_14 = spC8.pitch; + rwData->unk_00 = spC8.r; + rwData->unk_08 = sp3C->pos.y - camera->unk_0F0.y; + if ((2.0f * roData->unk_04) < camera->dist) { + camera->dist = 2.0f * roData->unk_04; + spC0.r = camera->dist; + spC8.r = spC0.r; + OLib_AddVecGeoToVec3f(sp48, sp44, &spC8); + *sp40 = *sp48; + } + } + + if (camera->status == CAM_STATUS_ACTIVE) { + sUpdateCameraDirection = true; + camera->inputDir.x = -spC8.pitch; + camera->inputDir.y = spC8.yaw + 0x8000; + camera->inputDir.z = 0; + } + + if (func_800CB950(camera)) { + rwData->unk_08 = sp3C->pos.y; + } + + sp114 = roData->unk_04; + + if (camera->target->id != ACTOR_EN_BOOM) { + Actor_GetWorldPosShapeRot(sp30, camera->target); + Actor_GetFocus(&spA8, camera->target); + camera->targetPosRot.pos.y = spA8.y; + } else { + Actor_GetFocus(sp30, camera->target); + } + if (rwData->unk_0C != camera->target) { + rwData->unk_0C = camera->target; + camera->atLerpStepScale = 0.0f; + } + + camera->yOffsetUpdateRate = + Camera_ScaledStepToCeilF(1.0f, camera->yOffsetUpdateRate, camera->speedRatio * 0.5f, 0.0001f); + camera->xzOffsetUpdateRate = + Camera_ScaledStepToCeilF(1.0f, camera->xzOffsetUpdateRate, camera->speedRatio * 0.2f, 0.0001f); + // TODO: No f on 0.05? + camera->fovUpdateRate = Camera_ScaledStepToCeilF(0.05, camera->fovUpdateRate, camera->speedRatio * 0.05f, 0.0001f); + + if (func_800CB950(camera)) { + rwData->unk_08 = sp3C->pos.y; + sp70 = false; + } else { + sp70 = true; + } + + Camera_CalcAtForFriendlyLockOn(camera, &spC0, sp30, roData->unk_00, roData->unk_08, &rwData->unk_08, &spD0, + roData->interfaceFlags | (sp70 ? KEEPON1_FLAG_7 : 0)); + sp124 = sp3C->pos; + sp124.y += sp60; + OLib_Vec3fDiffToVecGeo(&spD0, &sp124, sp30); + + if (sp114 < spD0.r) { + sp74 = 1.0f; + } else { + sp74 = spD0.r / sp114; + } + + OLib_Vec3fDiffToVecGeo(&spE8, sp44, sp40); + + if (spE8.r < roData->unk_04) { + sp114 = roData->unk_04; + spF8 = 20.0f; + } else if (roData->unk_08 < spE8.r) { + sp114 = roData->unk_08; + spF8 = 20.0f; + } else { + sp114 = spE8.r; + spF8 = 1.0f; + } + + camera->rUpdateRateInv = Camera_ScaledStepToCeilF(spF8, camera->rUpdateRateInv, 0.5f, 0.1f); + camera->dist = Camera_ScaledStepToCeilF(sp114, camera->dist, 1.0f / camera->rUpdateRateInv, 0.1f); + spF8 = camera->dist; + spE8.r = camera->dist; + sp118 = sp30->pos; + OLib_Vec3fDiffToVecGeo(&spD8, sp44, &sp118); + //! FAKE + if (1) {} + if (1) {} + if (1) {} // TODO: Is needed? + pad1 = spD8.r; // TODO: Fake temp? + spD8.r = spF8 - (((pad1 <= spF8) ? spD8.r : spF8) * .5f); + camera->dist = Camera_ScaledStepToCeilF(pad1, camera->dist, 0.06f, 0.1f); + spE8.r = camera->dist; + spFC = roData->unk_0C + ((roData->unk_10 - roData->unk_0C) * (1.1f - sp74)); + spE8.yaw = spC0.yaw; + temp_v0_3 = (s16)(spD8.yaw - (s16)(spC0.yaw + 0x8000)); + if (rwData->unk_16 != 0) { + if (rwData->unk_16 > 0) { + sp72 = rwData->unk_16 - 1; + spF2 = spD0.yaw; + OLib_Vec3fDiffToVecGeo(&spD0, sp44, sp48); + spD0.yaw = (s16)(spF2 + 0x8000); + sp60 = (rwData->unk_00 - spD0.r) * 0.16666667f; + spF2 = (s16)(rwData->unk_12 - (s16)(spF2 + 0x8000)) * 0.16666667f; + spF0 = ((s16)(rwData->unk_14 - (s64)spD0.pitch)); // TODO: s16 cast on F0 + spF0 = (s16)(spF0 * 0.16666667f); + spE8.r = Camera_ScaledStepToCeilF(spD0.r + (sp60 * sp72), spC8.r, .5f, 0.1f); + spE8.yaw = Camera_ScaledStepToCeilS(spD0.yaw + (spF2 * sp72), spC8.yaw, .5f, 5); + spE8.pitch = Camera_ScaledStepToCeilS(spD0.pitch + (spF0 * sp72), spC8.pitch, .5f, 5); + } + sp78 = 1; + rwData->unk_16--; + } else { + new_var3 = ABS(temp_v0_3); // TODO: Fake temp? + if ((s16)((spFC * 182.04167f) + .5f) < new_var3) { + spF2 = temp_v0_3; + sp104 = temp_v0_3 * 0.00549325f; + temp_f2_3 = ((OLib_ClampMaxDist(spD8.r, spE8.r) / spE8.r) * ((spFC + 10.0f) - spFC)) + spFC; + pad2 = &sp104; // TODO: Fake temp + temp_f2_3 = ((temp_f2_3 * temp_f2_3) - 2.0f) / (temp_f2_3 - 360.0f); + temp_f2_3 = (sp104 * (*pad2)) / ((temp_f2_3 * (*pad2)) + (2.0f - (360.0f * temp_f2_3))); + + if (spF2 >= 0) { + phi_v1_3 = (s16)((temp_f2_3 * 182.04167f) + .5f); + } else { + phi_v1_3 = -(s16)((temp_f2_3 * 182.04167f) + .5f); + } + spE8.yaw = (s16)(spC0.yaw + 0x8000) + (s16)(phi_v1_3 + 0x8000); + } else { + new_var = (1.0f - camera->speedRatio) * 0.05f; // TODO: Fake temp? + phi_v1_3 = (temp_v0_3 >= 0) ? CAM_DEG_TO_BINANG(spFC) : -CAM_DEG_TO_BINANG(spFC); + //! FAKE + if (phi_a0) {} // TODO: Fake to shaft a registers + spE8.yaw = (s16)(spC0.yaw - (s16)((phi_v1_3 - temp_v0_3) * new_var)); + } + } + + //! FAKE + if (!spF0) {} // TODO: Is needed? + if (sp78 == 0) { + // TODO: extra 0 on 0.050f needed? + phi_a0 = (s16)(((roData->unk_14 + ((roData->unk_18 - roData->unk_14) * sp74)) * 182.04167f) + .5f); + phi_a0 -= (s16)((spD0.pitch * (0.5f + (sp74 * 0.5f))) + 0.5f); + //! FAKE + if (1) {} // TODO: Needed? + sp60 = spD8.pitch * roData->unk_1C; // TODO: Fake sp60 temp? + phi_a0 += (s16)sp60; + + if (phi_a0 < -0x3200) { + phi_a0 = -0x3200; + } else if (phi_a0 > 0x3200) { + phi_a0 = 0x3200; + } + + spE8.pitch = Camera_ScaledStepToCeilS(phi_a0, spC0.pitch, 0.11111111f, 5); + OLib_AddVecGeoToVec3f(sp40, sp44, &spE8); + sp7C.pos = *sp40; + if (camera->status == CAM_STATUS_ACTIVE) { + if (!(roData->interfaceFlags & KEEPON1_FLAG_4)) { + if ((camera->play->envCtx.skyboxDisabled == 0) || (roData->interfaceFlags & KEEPON1_FLAG_0)) { + if (func_800CBC84(camera, sp44, &sp7C, 0) != 0) { + rwData->unk_18 |= 0x1000; + } else { + rwData->unk_18 &= ~0x1000; + } + } else if (roData->interfaceFlags & KEEPON1_FLAG_1) { + func_800CBC84(camera, sp44, &sp7C, 3); + } else { + OLib_Vec3fDistNormalize(&sp130, sp44, &sp7C.pos); + sp7C.pos.x -= sp130.x; + sp7C.pos.y -= sp130.y; + sp7C.pos.z -= sp130.z; + } + *sp48 = sp7C.pos; + rwData->unk_18 &= ~0x10; + } else if ((camera->play->envCtx.skyboxDisabled == 0) || (roData->interfaceFlags & KEEPON1_FLAG_0)) { + if (func_800CBC84(camera, sp44, &sp7C, 0) != 0) { + rwData->unk_18 |= 0x1000; + spF8 = OLib_Vec3fDist(sp44, spA4); + spF4 = OLib_Vec3fDist(sp44, &sp7C.pos); + spF8 += (rwData->unk_18 & 0x10) ? 40 : 0.0f; // TODO: 40.0f? + Actor_GetScreenPos(camera->play, camera->focalActor, &sp56, &sp54); + if ((spF4 < spF8) || ((sp56 >= 0) && (sp56 <= 320) && (sp54 >= 0) && (sp54 <= 240))) { + rwData->unk_18 |= 0x10; + spE0.yaw = (s16)(spD0.yaw + 0x8000); + spE0.pitch = -spD0.pitch; + spE0.r = 40.0f; + sp130 = spA4->pos; + sp130.y += 40.0f; + OLib_AddVecGeoToVec3f(&sp124, &sp130, &spE0); + Camera_ScaledStepToCeilVec3f(&sp124, sp48, 0.15f, 0.15f, 0.2f); + } else if (rwData->unk_18 & 0x10) { + if (OLib_Vec3fDist(&sp7C.pos, sp48) < 20.0f) { + rwData->unk_18 &= ~0x10; + *sp48 = sp7C.pos; + } else { + Camera_ScaledStepToCeilVec3f(&sp7C.pos, sp48, 0.15f, 0.15f, 0.2f); + } + } else { + rwData->unk_18 &= ~0x10; + *sp48 = sp7C.pos; + } + dummy:; // TODO: Is this needed? + } else { + if (rwData->unk_18 & 0x10) { + if (OLib_Vec3fDist(&sp7C.pos, sp48) < 20.0f) { + rwData->unk_18 &= ~0x10; + *sp48 = sp7C.pos; + } else { + Camera_ScaledStepToCeilVec3f(&sp7C.pos, sp48, 0.15f, 0.15f, 0.2f); + } + } else { + rwData->unk_18 &= ~0x10; + *sp48 = sp7C.pos; + // if (sp104) {} // TODO: Is this needed? + } + rwData->unk_18 &= ~0x1000; + } + } else if (roData->interfaceFlags & KEEPON1_FLAG_1) { + rwData->unk_18 &= ~0x10; + if (func_800CBC84(camera, sp44, &sp7C, 3) != 0) { + *sp48 = sp7C.pos; + } else { + *sp48 = sp7C.pos; + ; + } + } else { + rwData->unk_18 &= ~0x10; + OLib_Vec3fDistNormalize(&sp130, sp44, &sp7C.pos); + sp7C.pos.x -= sp130.x; + sp7C.pos.y -= sp130.y; + sp7C.pos.z -= sp130.z; + *sp48 = sp7C.pos; + } + } else { + rwData->unk_18 &= ~0x10; + *sp48 = *sp40; + } + } + + // TODO: spF8 temp needed? + camera->fov = Camera_ScaledStepToCeilF(spF8 = roData->unk_20, camera->fov, camera->fovUpdateRate, 0.1f); + camera->roll = Camera_ScaledStepToCeilS(0, camera->roll, 0.2f, 5); + camera->atLerpStepScale = Camera_ClampLerpScale(camera, sp70 ? roData->unk_28 : roData->unk_24); + + return true; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_KeepOn1.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_KeepOn2.s") +s32 Camera_KeepOn2(Camera* camera) { + return Camera_Noop(camera); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_KeepOn3.s") +/** + * Talking to an NPC + */ +s32 Camera_KeepOn3(Camera* camera) { + Vec3f* eye = &camera->eye; + s32 temp_f0; + Vec3f* eyeNext = &camera->eyeNext; + Vec3f spD8; + Vec3f spCC; + Vec3f spC0; + f32 timer; + f32 spB8; + f32 spB4; + f32 swingAngle; + Actor* spA8[2]; + VecGeo spA0; + VecGeo sp98; + VecGeo sp90; + VecGeo sp88; + VecGeo sp80; + Vec3f* at = &camera->at; + s32 sp78; + f32 phi_f14; + PosRot* sp70; + s16 sp6E; + s16 sp6C; + s16 sp6A; + s16 phi_a3; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + KeepOn3ReadOnlyData* roData = &camera->paramData.keep3.roData; + KeepOn3ReadWriteData* rwData = &camera->paramData.keep3.rwData; + f32 focalActorHeight; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_KeepOn4.s") + sp70 = &camera->focalActor->focus; // TODO: Move above? + sp6A = 0; + focalActorHeight = Camera_GetFocalActorHeight(camera); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_KeepOn0.s") + if ((camera->target == NULL) || (camera->target->update == NULL)) { + camera->target = NULL; + Camera_ChangeMode(camera, CAM_MODE_TARGET); + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Fixed1.s") + if (RELOAD_PARAMS(camera)) { + if (camera->play->view.unk164 == 0) { + Camera_SetStateFlag(camera, CAM_STATE_DISABLE_MODE_CHANGE); + camera->play->view.unk164 = camera->camId | 0x50; + return 1; + } + Camera_UnsetStateFlag(camera, CAM_STATE_DISABLE_MODE_CHANGE); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Fixed2.s") + Camera_UnsetStateFlag(camera, CAM_STATE_4); + if (RELOAD_PARAMS(camera)) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Fixed3.s") + roData->unk_00 = + GET_NEXT_SCALED_RO_DATA(values) * focalActorHeight * (0.8f - ((68.0f / focalActorHeight) * -0.2f)); + roData->unk_04 = GET_NEXT_RO_DATA(values); + roData->unk_08 = GET_NEXT_RO_DATA(values); + roData->unk_0C = GET_NEXT_RO_DATA(values); + roData->unk_10 = GET_NEXT_RO_DATA(values); + roData->unk_14 = GET_NEXT_RO_DATA(values); + roData->unk_18 = GET_NEXT_RO_DATA(values); + roData->unk_1C = GET_NEXT_SCALED_RO_DATA(values); + roData->unk_20 = GET_NEXT_RO_DATA(values); + roData->unk_24 = GET_NEXT_SCALED_RO_DATA(values); + roData->timer = GET_NEXT_RO_DATA(values); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + roData->unk_28 = GET_NEXT_SCALED_RO_DATA(values); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Fixed4.s") + if (camera->animState == 10) { + roData->timer >>= 1; + if (roData->timer < 20) { + roData->timer = 20; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Fixed0.s") + OLib_Vec3fDiffToVecGeo(&sp88, at, eye); + OLib_Vec3fDiffToVecGeo(&sp80, at, eyeNext); + Actor_GetFocus(&camera->targetPosRot, camera->target); + spD8 = focalActorPosRot->pos; + spD8.y += focalActorHeight; + OLib_Vec3fDiffToVecGeo(&spA0, &spD8, &camera->targetPosRot.pos); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Subject1.s") + if (RELOAD_PARAMS(camera)) { + camera->animState++; + spA8[0] = camera->target; + spA8[1] = camera->focalActor; + rwData->unk_0C = camera->target; + phi_f14 = (roData->unk_08 < spA0.r) ? 1.0f : (spA0.r / roData->unk_08); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Subject2.s") + rwData->timer = roData->timer; + spB8 = ((1.0f - phi_f14) * spA0.r) / rwData->timer; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Subject3.s") + if (roData->interfaceFlags & KEEPON3_FLAG_6) { + spA0.pitch = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Subject4.s") + swingAngle = LERPIMP(roData->unk_14, roData->unk_18, phi_f14); + sp98.pitch = CAM_DEG_TO_BINANG(swingAngle) + ((s16) - (spA0.pitch * roData->unk_1C)); + swingAngle = LERPIMP(roData->unk_0C, roData->unk_10, phi_f14); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Subject0.s") + phi_a3 = CAM_DEG_TO_BINANG(swingAngle); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Data0.s") + sp78 = 1; + if ((camera->target->category == ACTORCAT_DOOR) || (camera->target->id == ACTOR_EN_TALK)) { + if ((s16)(camera->targetPosRot.rot.y - sp80.yaw) > 0) { + phi_a3 = -phi_a3; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Data1.s") + if (ABS(spA0.pitch) < 0x157C) { // 30.2 degrees + sp98.yaw = BINANG_ROT180(spA0.yaw) + phi_a3; + sp6A = (s16)(BINANG_ROT180(spA0.yaw) - phi_a3); + } else { + sp78 = 0; + sp90.r = 30.0f; + sp90.yaw = BINANG_ROT180(spA0.yaw) + (phi_a3 >> 2); + sp90.pitch = -spA0.pitch; + spCC = sp70->pos; + spCC.y += 30.0f; + OLib_AddVecGeoToVec3f(&spC0, &spCC, &sp90); + spCC.x = (camera->targetPosRot.pos.x + spD8.x) * 0.5f; + spCC.y = (camera->targetPosRot.pos.y + spD8.y) * 0.5f; + spCC.z = (camera->targetPosRot.pos.z + spD8.z) * 0.5f; + OLib_Vec3fDiffToVecGeo(&sp98, &spCC, &spC0); + if (sp98.pitch < -0x2328) { // 49.4 degrees + sp98.pitch = -0x2328; + } + } + } else if (!(roData->interfaceFlags & KEEPON3_FLAG_5) && (ABS((s16)(spA0.yaw - sp80.yaw)) < 0x4000)) { + if ((s16)(spA0.yaw - sp80.yaw) > 0) { + phi_a3 = -phi_a3; + } + sp98.yaw = (s16)(spA0.yaw + phi_a3); + sp6A = (s16)(spA0.yaw - phi_a3); + } else { + if ((s16)(BINANG_ROT180(spA0.yaw) - sp80.yaw) < 0) { + phi_a3 = -phi_a3; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Data2.s") + sp98.yaw = BINANG_ROT180(spA0.yaw) + phi_a3; + sp6A = BINANG_ROT180(spA0.yaw) - phi_a3; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Data3.s") + sp6C = sp98.yaw; + sp6E = sp98.pitch; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Data4.s") + //! FAKE + if (roData->unk_28) {} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique1.s") + spB4 = spA0.r; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique2.s") + phi_f14 = roData->unk_28; + spA0.r = spB8 * phi_f14 + (spB4 * (1.0f - phi_f14)); + spD8 = focalActorPosRot->pos; + spD8.y += focalActorHeight; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique3.s") + OLib_AddVecGeoToVec3f(&rwData->unk_10, &spD8, &spA0); + rwData->unk_10.y += roData->unk_00; + spA0.r = spB4; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique4.s") + if (sp78 != 0) { + sp98.r = ((roData->unk_04 + (spA0.r * 0.5f)) - sp80.r) + sp80.r; + i = 0; + sp78 = 14; + OLib_AddVecGeoToVec3f(&spCC, &rwData->unk_10, &sp98); + if (!(roData->interfaceFlags & KEEPON3_FLAG_7)) { + if (CollisionCheck_LineOCCheck(camera->play, &camera->play->colChkCtx, &rwData->unk_10, &spCC, spA8, + 2) || + Camera_BgCheck(camera, &rwData->unk_10, &spCC)) { + sp98.yaw = sp6A; + OLib_AddVecGeoToVec3f(&spCC, &rwData->unk_10, &sp98); + } + while (i < sp78) { + if (!CollisionCheck_LineOCCheck(camera->play, &camera->play->colChkCtx, &rwData->unk_10, &spCC, + spA8, 2) && + !Camera_BgCheck(camera, &rwData->unk_10, &spCC)) { + break; + } + sp98.yaw = sp6C + D_801B9E18[i]; + sp98.pitch = sp6E + D_801B9E34[i]; + OLib_AddVecGeoToVec3f(&spCC, &rwData->unk_10, &sp98); + i++; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique5.s") + Camera_UnsetStateFlag(camera, CAM_STATE_3 | CAM_STATE_2); + temp_f0 = ((rwData->timer + 1) * rwData->timer) >> 1; + rwData->unk_04 = (f32)(s16)(sp98.yaw - sp80.yaw) / temp_f0; + rwData->unk_08 = (f32)(s16)(sp98.pitch - sp80.pitch) / temp_f0; + rwData->unk_00 = (sp98.r - sp80.r) / temp_f0; + sCameraInterfaceFlags = CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, 0); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique0.s") + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique6.s") + sCameraInterfaceFlags = roData->interfaceFlags; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique7.s") + if (rwData->timer != 0) { + timer = rwData->timer; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique8.s") + at->x += (rwData->unk_10.x - at->x) / timer; + at->y += (rwData->unk_10.y - at->y) / timer; + at->z += (rwData->unk_10.z - at->z) / timer; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique9.s") + sp98.r = (rwData->unk_00 * timer) + sp80.r + 1.0f; + sp98.yaw = sp80.yaw + (s16)(rwData->unk_04 * timer); + sp98.pitch = sp80.pitch + (s16)(rwData->unk_08 * timer); + OLib_AddVecGeoToVec3f(eyeNext, at, &sp98); + *eye = *eyeNext; + camera->fov = Camera_ScaledStepToCeilF(roData->unk_20, camera->fov, 0.5f, 0.1f); + camera->roll = Camera_ScaledStepToCeilS(0, camera->roll, 0.5f, 5); + camera->atLerpStepScale = Camera_ClampLerpScale(camera, roData->unk_24); + func_800CBFA4(camera, at, eye, 3); + rwData->timer--; + } else { + Camera_SetStateFlag(camera, CAM_STATE_10 | CAM_STATE_4); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo1.s") + Camera_SetFocalActorAtOffset(camera, &focalActorPosRot->pos); + camera->dist = OLib_Vec3fDist(at, eye); + if (camera->stateFlags & CAM_STATE_3) { + sCameraInterfaceFlags = CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0); + Camera_SetUpdateRatesSlow(camera); + camera->atLerpStepScale = 0.0f; + + if ((camera->xzSpeed > 0.001f) || CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CUP) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CLEFT) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CRIGHT) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_Z) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_L) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_R)) { + Camera_SetStateFlag(camera, CAM_STATE_2); + Camera_UnsetStateFlag(camera, CAM_STATE_3); + } + } + + if (rwData->unk_0C != camera->target) { + rwData->unk_0C = camera->target; + camera->animState = 10; + } + + return 1; +} + +/** + * Used for settings where camera turns around and faces player + * eg. all item-based settings, elegy shell cutscene, death cutscene, ... + */ +s32 Camera_KeepOn4(Camera* camera) { + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + Vec3f* eyeNext = &camera->eyeNext; + Actor* spCC[2]; + f32 temp_f0_2; + f32 new_var; + CollisionPoly* spC0; + VecGeo spB8; + VecGeo spB0; + VecGeo spA8; + s16* sp44 = &camera->data2; + s16 spA2; + s16 spA0; + s16 sp9E; + s16 sp9C; + s16 pad1; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + KeepOn4ReadOnlyData* roData = &camera->paramData.keep4.roData; + KeepOn4ReadWriteData* rwData = &camera->paramData.keep4.rwData; + f32 focalActorHeight; + s32 bgId; + s16 camMode; + Player* player; + Vec3f* data; + CameraModeValue* values; + PosRot sp60; + PosRot sp4C; + + if (RELOAD_PARAMS(camera)) { + if (camera->play->view.unk164 == 0) { + Camera_SetStateFlag(camera, CAM_STATE_DISABLE_MODE_CHANGE); + Camera_UnsetStateFlag(camera, CAM_STATE_2 | CAM_STATE_CHECK_WATER); + camera->play->view.unk164 = camera->camId | 0x50; + return true; + } + rwData->unk_18 = *sp44; + Camera_UnsetStateFlag(camera, CAM_STATE_DISABLE_MODE_CHANGE); + } + + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + player = (Player*)camera->focalActor; + + switch (((Player*)camera->focalActor)->transformation) { + case PLAYER_FORM_DEKU: + camMode = CAM_MODE_DEKUSHOOT; + break; + + case PLAYER_FORM_GORON: + camMode = CAM_MODE_GORONDASH; + break; + + case PLAYER_FORM_ZORA: + camMode = CAM_MODE_DEKUFLY; + break; + + case PLAYER_FORM_FIERCE_DEITY: + camMode = CAM_MODE_JUMP; + break; + + default: + camMode = CAM_MODE_NORMAL; + break; + } + + focalActorHeight = Camera_GetFocalActorHeight(camera) - (player->unk_AB8 * camera->focalActor->scale.y); + } else { + camMode = CAM_MODE_NORMAL; + focalActorHeight = Camera_GetFocalActorHeight(camera); + } + + if (rwData->unk_18 != *sp44) { + camera->animState = 20; + Camera_SetStateFlag(camera, CAM_STATE_DISABLE_MODE_CHANGE); + Camera_UnsetStateFlag(camera, CAM_STATE_2 | CAM_STATE_CHECK_WATER); + camera->play->view.unk164 = camera->camId | 0x50; + return true; + } + + Camera_UnsetStateFlag(camera, CAM_STATE_4); + if (RELOAD_PARAMS(camera)) { + values = sCameraSettings[camera->setting].cameraModes[camMode].values; + new_var = -0.5f; + roData->unk_00 = GET_NEXT_SCALED_RO_DATA(values) * focalActorHeight * + ((1.0f + new_var) - ((68.0f / focalActorHeight) * new_var)); + roData->unk_04 = GET_NEXT_SCALED_RO_DATA(values) * focalActorHeight * + ((1.0f + new_var) - ((68.0f / focalActorHeight) * new_var)); + roData->unk_08 = GET_NEXT_RO_DATA(values); + roData->unk_0C = GET_NEXT_RO_DATA(values); + roData->unk_10 = GET_NEXT_RO_DATA(values); + roData->unk_18 = GET_NEXT_RO_DATA(values); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + roData->unk_14 = GET_NEXT_SCALED_RO_DATA(values); + roData->timer = GET_NEXT_RO_DATA(values); + } + + sUpdateCameraDirection = true; + sCameraInterfaceFlags = roData->interfaceFlags; + + OLib_Vec3fDiffToVecGeo(&spB0, at, eye); + data = &D_801EDDD0; + OLib_Vec3fDiffToVecGeo(&spA8, at, eyeNext); + D_801EDDD0 = focalActorPosRot->pos; + D_801EDDD0.y = data->y + focalActorHeight; + temp_f0_2 = BgCheck_CameraRaycastFloor2(&camera->play->colCtx, &spC0, &bgId, &D_801EDDD0); + + if ((roData->unk_00 + data->y) < temp_f0_2) { + D_801EDDD0.y = temp_f0_2 + 10.0f; + } else { + D_801EDDD0.y = roData->unk_00 + data->y; + } + + if (roData->unk_10 != 0.0f) { + D_801EDDE0 = (*data); + spB8.r = roData->unk_10; + spB8.pitch = 0; + spB8.yaw = focalActorPosRot->rot.y; + OLib_AddVecGeoToVec3f(&D_801EDDD0, &D_801EDDD0, &spB8); + } + + sp9C = 0; + + switch (camera->animState) { + case 0: + case 20: + spCC[sp9C] = camera->focalActor; + sp9C++; + Camera_SetUpdateRatesFastPitch(camera); + Camera_UnsetStateFlag(camera, CAM_STATE_2 | CAM_STATE_CHECK_WATER); + rwData->timer = roData->timer; + rwData->unk_08 = focalActorPosRot->pos.y - camera->unk_0F0.y; + + switch (roData->interfaceFlags & (KEEPON4_FLAG_3 | KEEPON4_FLAG_2 | KEEPON4_FLAG_1)) { + case KEEPON4_FLAG_1: + spA2 = CAM_DEG_TO_BINANG(roData->unk_08); + spA0 = BINANG_SUB(BINANG_ROT180(focalActorPosRot->rot.y), spA8.yaw) < 0 + ? BINANG_ROT180(focalActorPosRot->rot.y) + CAM_DEG_TO_BINANG(roData->unk_0C) + : BINANG_ROT180(focalActorPosRot->rot.y) - CAM_DEG_TO_BINANG(roData->unk_0C); + break; + + case (KEEPON4_FLAG_3 | KEEPON4_FLAG_2): + spA2 = CAM_DEG_TO_BINANG(roData->unk_08); + pad1 = BINANG_ROT180(focalActorPosRot->rot.y); + spA0 = pad1 + CAM_DEG_TO_BINANG(roData->unk_0C); + break; + + case KEEPON4_FLAG_2: + spA2 = CAM_DEG_TO_BINANG(roData->unk_08); + spA0 = CAM_DEG_TO_BINANG(roData->unk_0C); + break; + + case (KEEPON4_FLAG_2 | KEEPON4_FLAG_1): + spA2 = spA8.pitch + CAM_DEG_TO_BINANG(roData->unk_08); + spA0 = spA8.yaw + CAM_DEG_TO_BINANG(roData->unk_0C); + break; + + case KEEPON4_FLAG_3: + if (camera->target != NULL) { + Actor_GetWorldPosShapeRot(&sp60, camera->target); + spA2 = CAM_DEG_TO_BINANG(roData->unk_08) - sp60.rot.x; + spA0 = (BINANG_SUB(BINANG_ROT180(sp60.rot.y), spA8.yaw) > 0) + ? BINANG_ROT180(sp60.rot.y) + CAM_DEG_TO_BINANG(roData->unk_0C) + : BINANG_ROT180(sp60.rot.y) - CAM_DEG_TO_BINANG(roData->unk_0C); + + spCC[1] = camera->target; + sp9C++; + break; + } + // fallthrough + case (KEEPON4_FLAG_3 | KEEPON4_FLAG_1): + if (camera->target != 0) { + Actor_GetWorld(&sp4C, camera->target); + spA2 = CAM_DEG_TO_BINANG(roData->unk_08); + sp9E = Camera_CalcXZAngle(&sp4C.pos, &focalActorPosRot->pos); + spA0 = (BINANG_SUB(sp9E, spA8.yaw) > 0) ? sp9E + CAM_DEG_TO_BINANG(roData->unk_0C) + : sp9E - CAM_DEG_TO_BINANG(roData->unk_0C); + spCC[1] = camera->target; + sp9C++; + break; + } + // fallthrough + case (KEEPON4_FLAG_3 | KEEPON4_FLAG_2 | KEEPON4_FLAG_1): + spA2 = CAM_DEG_TO_BINANG(roData->unk_08); + spA0 = spA8.yaw; + break; + + default: + spA2 = spA8.pitch; + spA0 = spA8.yaw; + break; + } + + spB8.pitch = spA2; + spB8.yaw = spA0; + spB8.r = roData->unk_04; + // Odd that the return is set to bgId and remains unused + bgId = func_800CC260(camera, &D_801EDDF0, &D_801EDDD0, &spB8, spCC, sp9C); + rwData->unk_04 = (f32)(s16)(spB8.pitch - spA8.pitch) / rwData->timer; + rwData->unk_00 = (f32)(s16)(spB8.yaw - spA8.yaw) / rwData->timer; + rwData->unk_10 = spA8.yaw; + rwData->unk_12 = spA8.pitch; + camera->animState++; + rwData->unk_16 = 1; + break; + + case 10: + rwData->unk_08 = focalActorPosRot->pos.y - camera->unk_0F0.y; + break; + } + + if (roData->interfaceFlags & KEEPON4_FLAG_6) { + if (rwData->timer != 0) { + at->x += ((data->x - at->x) / rwData->timer); + at->y += ((data->y - at->y) / rwData->timer); + at->z += ((data->z - at->z) / rwData->timer); + Camera_SetFocalActorAtOffset(camera, &focalActorPosRot->pos); + } + camera->yOffsetUpdateRate = 0.25f; + camera->xzOffsetUpdateRate = 0.25f; + camera->atLerpStepScale = 0.0f; + } else { + camera->yOffsetUpdateRate = 0.25f; + camera->xzOffsetUpdateRate = 0.25f; + camera->atLerpStepScale = 0.75f; + Camera_ScaledStepToCeilVec3f(data, at, 0.2f, 0.2f, 0.2f); + camera->atLerpStepScale = 0.0f; + Camera_SetFocalActorAtOffset(camera, &focalActorPosRot->pos); + } + + camera->dist = Camera_ScaledStepToCeilF(roData->unk_04, camera->dist, 0.25f, 1.0f); + spB8.r = camera->dist; + + if (rwData->timer != 0) { + Camera_SetStateFlag(camera, CAM_STATE_DISABLE_MODE_CHANGE); + rwData->unk_10 += (s16)rwData->unk_00; + rwData->unk_12 += (s16)rwData->unk_04; + rwData->timer--; + } else { + Camera_SetStateFlag(camera, CAM_STATE_10 | CAM_STATE_4); + } + + spB8.yaw = Camera_ScaledStepToCeilS(rwData->unk_10, spA8.yaw, roData->unk_14, 5); + spB8.pitch = Camera_ScaledStepToCeilS(rwData->unk_12, spA8.pitch, roData->unk_14, 5); + OLib_AddVecGeoToVec3f(eyeNext, at, &spB8); + *eye = *eyeNext; + func_800CBFA4(camera, at, eye, 3); + + camera->fov = Camera_ScaledStepToCeilF(roData->unk_18, camera->fov, camera->fovUpdateRate, 0.1f); + camera->roll = Camera_ScaledStepToCeilS(0, camera->roll, 0.5f, 5); + + return 1; +} + +s32 Camera_KeepOn0(Camera* camera) { + return Camera_Noop(camera); +} + +/** + * Used for many fixed-based camera settings i.e. camera is fixed in rotation, and often position (but not always) + */ +s32 Camera_Fixed1(Camera* camera) { + s32 pad[2]; + s32 yawDiff; + VecGeo eyeOffset; + VecGeo eyeAtOffset; + VecGeo sp7C; + u32 negOne; + Vec3f adjustedPos; + BgCamFuncData* bgCamFuncData; + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + f32 focalActorHeight = Camera_GetFocalActorHeight(camera); + CameraModeValue* values; + PosRot* targetHome; + PosRot* targetWorld; + VecGeo sp44; + Fixed1ReadOnlyData* roData = &camera->paramData.fixd1.roData; + Fixed1ReadWriteData* rwData = &camera->paramData.fixd1.rwData; + + OLib_Vec3fDiffToVecGeo(&sp7C, at, eye); + + if (!RELOAD_PARAMS(camera)) { + } else { + values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamOrActorCsCamFuncData(camera, camera->bgCamIndex); + Camera_Vec3sToVec3f(&rwData->eyePosRotTarget.pos, &bgCamFuncData->pos); + + rwData->eyePosRotTarget.rot = bgCamFuncData->rot; + rwData->fov = bgCamFuncData->fov; + rwData->focalActor = camera->focalActor; + + roData->unk_00 = GET_NEXT_SCALED_RO_DATA(values) * focalActorHeight; + roData->unk_04 = GET_NEXT_SCALED_RO_DATA(values); + roData->fov = GET_NEXT_RO_DATA(values); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + + if (roData->interfaceFlags & FIXED1_FLAG_4) { + if (camera->target == NULL) { + return false; + } + + targetHome = &camera->target->home; + targetWorld = &camera->target->world; + + OLib_Vec3fDiffToVecGeo(&sp44, &targetHome->pos, &rwData->eyePosRotTarget.pos); + sp44.yaw = targetWorld->rot.y + (s16)(sp44.yaw - targetHome->rot.y); + OLib_AddVecGeoToVec3f(&rwData->eyePosRotTarget.pos, &targetWorld->pos, &sp44); + yawDiff = (s16)(rwData->eyePosRotTarget.rot.y - targetHome->rot.y); + rwData->eyePosRotTarget.rot.y = targetWorld->rot.y + yawDiff; + } + } + + negOne = -1; + + if (rwData->focalActor != camera->focalActor) { + camera->animState = 20; + } + + if (rwData->fov == (s32)negOne) { + rwData->fov = roData->fov * 100; + } else if (rwData->fov <= 360) { + rwData->fov *= 100; + } + + sCameraInterfaceFlags = roData->interfaceFlags; + + if (camera->animState == 0) { + camera->animState++; + Camera_SetUpdateRatesSlow(camera); + if (rwData->fov != (s32)negOne) { + roData->fov = CAM_RODATA_UNSCALE(rwData->fov); + } + + if (bgCamFuncData->unk_0E != (s32)negOne) { + roData->unk_04 = CAM_RODATA_UNSCALE(bgCamFuncData->unk_0E); + } + } + + OLib_Vec3fDiffToVecGeo(&eyeAtOffset, eye, at); + Camera_ScaledStepToCeilVec3f(&rwData->eyePosRotTarget.pos, eye, roData->unk_04, roData->unk_04, 0.2f); + adjustedPos = focalActorPosRot->pos; + adjustedPos.y += focalActorHeight; + camera->dist = OLib_Vec3fDist(&adjustedPos, eye); + eyeOffset.r = camera->dist; + eyeOffset.pitch = + Camera_ScaledStepToCeilS(rwData->eyePosRotTarget.rot.x * -1, eyeAtOffset.pitch, roData->unk_04, 5); + eyeOffset.yaw = Camera_ScaledStepToCeilS(rwData->eyePosRotTarget.rot.y, eyeAtOffset.yaw, roData->unk_04, 5); + OLib_AddVecGeoToVec3f(at, eye, &eyeOffset); + camera->eyeNext = *eye; + Camera_BgCheck(camera, eye, at); + + camera->fov = Camera_ScaledStepToCeilF(roData->fov, camera->fov, roData->unk_04, 0.1f); + camera->roll = 0; + camera->atLerpStepScale = 0.0f; + Camera_SetFocalActorAtOffset(camera, &focalActorPosRot->pos); + camera->roll = Camera_ScaledStepToCeilS(rwData->eyePosRotTarget.rot.z, camera->roll, roData->unk_04, 5); + + return 1; +} + +/** + * Used for many pivot-based camera settings i.e. camera fixed in position but free to rotate + */ +s32 Camera_Fixed2(Camera* camera) { + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + Vec3f* eyeNext = &camera->eyeNext; + Vec3f spB0; + Vec3f spA4; + Vec3f sp98; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + f32 temp_f0_3; + f32 new_var; + BgCamFuncData* bgCamFuncData; + VecGeo sp80; + PosRot* sp7C; + PosRot* sp78; + VecGeo sp70; + Vec3f* new_var1; + Vec3f* new_var2; + Player* player; + f32 focalActorHeight = Camera_GetFocalActorHeight(camera); + Actor* actor; + Fixed2ReadOnlyData* roData = &camera->paramData.fixd2.roData; + Fixed2ReadWriteData* rwData = &camera->paramData.fixd2.rwData; + CameraModeValue* values; + Vec3f sp44; + + if (!RELOAD_PARAMS(camera)) { + } else { + //! FAKE + if (new_var2) {} + + values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->unk_00 = + GET_NEXT_SCALED_RO_DATA(values) * focalActorHeight * (0.8f - ((68.0f / focalActorHeight) * -0.2f)); + roData->unk_04 = GET_NEXT_RO_DATA(values); + roData->unk_08 = GET_NEXT_RO_DATA(values); + roData->unk_0C = GET_NEXT_SCALED_RO_DATA(values); + roData->unk_10 = GET_NEXT_SCALED_RO_DATA(values); + roData->unk_14 = GET_NEXT_RO_DATA(values); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + rwData->unk_1C = roData->unk_14 * 100.0f; + bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamOrActorCsCamFuncData(camera, camera->bgCamIndex); + if (bgCamFuncData != NULL) { + if (!(roData->interfaceFlags & FIXED2_FLAG_1)) { + Camera_Vec3sToVec3f(&rwData->unk_00, &bgCamFuncData->pos); + } else { + if (camera->focalActor != &GET_PLAYER(camera->play)->actor) { + player = GET_PLAYER(camera->play); + OLib_Vec3fDiffToVecGeo(&sp70, &player->actor.focus.pos, eye); + if (sp70.r < roData->unk_04) { + sp70.r = roData->unk_04; + if (sp70.pitch < 0xBB8) { // 16.5 degrees + sp70.pitch = 0xBB8; + } + + new_var1 = &player->actor.focus.pos; + + OLib_AddVecGeoToVec3f(&rwData->unk_00, new_var1, &sp70); + } else { + rwData->unk_00 = *eye; + //! FAKE: + dummy:; + } + } else { + rwData->unk_00 = camera->eye; + } + } + + if (bgCamFuncData->fov != -1) { + if (roData->interfaceFlags & FIXED2_FLAG_7) { + rwData->unk_1C = (bgCamFuncData->fov >> 1) + (bgCamFuncData->fov >> 2); + if (rwData->unk_1C < 0x1E) { + rwData->unk_1C = 0x1E; + } + } else { + rwData->unk_1C = bgCamFuncData->fov; + } + } + + if (bgCamFuncData->unk_0E != -1) { + rwData->unk_0C = bgCamFuncData->unk_0E; + } else { + rwData->unk_0C = roData->unk_08; + } + + if (bgCamFuncData->unk_10 != -1) { + if (roData->interfaceFlags & FIXED2_FLAG_2) { + rwData->unk_14 = bgCamFuncData->unk_10 * 0.01f; + rwData->unk_18 = roData->unk_0C; + } else { + temp_f0_3 = bgCamFuncData->unk_10 * 0.01f; + rwData->unk_18 = temp_f0_3; + rwData->unk_14 = temp_f0_3; + } + } else { + rwData->unk_14 = roData->unk_10; + rwData->unk_18 = roData->unk_0C; + } + if (roData->interfaceFlags & FIXED2_FLAG_4) { + if (camera->target == 0) { + return 0; + } + sp7C = &camera->target->home; + sp78 = &camera->target->world; + OLib_Vec3fDiffToVecGeo(&sp70, &sp7C->pos, &rwData->unk_00); + sp70.yaw = sp78->rot.y + (s16)(sp70.yaw - sp7C->rot.y); + OLib_AddVecGeoToVec3f(&rwData->unk_00, &sp78->pos, &sp70); + } + } else { + rwData->unk_00 = camera->eye; + rwData->unk_0C = roData->unk_08; + rwData->unk_14 = roData->unk_10; + rwData->unk_18 = roData->unk_0C; + } + if (rwData->unk_1C <= 360) { + rwData->unk_1C *= 100; + } + if (camera->animState == 20) { + rwData->unk_14 = 0.2f; + } + //! FAKE: + if (1) {} + } + + sCameraInterfaceFlags = roData->interfaceFlags; + //! FAKE: + new_var = 0.0f; + + if (roData->interfaceFlags & FIXED2_FLAG_3) { + if (camera->target == NULL) { + return false; + } + + spB0.x = camera->target->focus.pos.x; + spB0.y = camera->target->focus.pos.y; + spB0.z = camera->target->focus.pos.z; + + camera->focalActorAtOffset.x = spB0.x - focalActorPosRot->pos.x; + camera->focalActorAtOffset.y = spB0.y - focalActorPosRot->pos.y; + camera->focalActorAtOffset.z = spB0.z - focalActorPosRot->pos.z; + } else if (roData->interfaceFlags & FIXED2_FLAG_6) { + sp98.x = new_var; + sp98.y = roData->unk_00 + focalActorHeight; + sp98.z = new_var; + + if (camera->target != NULL) { + new_var1 = &camera->focalActor->focus.pos; + new_var2 = &camera->target->focus.pos; + //! FAKE: + sp98.x = ((void)0, new_var) + ((new_var2->x - new_var1->x) * 0.4f); + sp98.y += (new_var2->y - new_var1->y) * 0.4f; + sp98.z = ((void)0, new_var) + ((new_var2->z - new_var1->z) * 0.4f); + } + + Camera_ScaledStepToCeilVec3f(&sp98, &camera->focalActorAtOffset, 0.25f, 0.25f, 0.1f); + spB0.x = focalActorPosRot->pos.x + camera->focalActorAtOffset.x; + spB0.y = focalActorPosRot->pos.y + camera->focalActorAtOffset.y; + spB0.z = focalActorPosRot->pos.z + camera->focalActorAtOffset.z; + } else if (roData->interfaceFlags & FIXED2_FLAG_7) { + sp98.x = new_var; + sp98.y = roData->unk_00 + focalActorHeight; + sp98.z = new_var; + + if (camera->target != NULL) { + new_var1 = &camera->focalActor->focus.pos; + new_var2 = &camera->target->focus.pos; + //! FAKE: + sp98.x = ((void)0, new_var) + ((new_var2->x - new_var1->x) * 0.7f); + sp98.y += (new_var2->y - new_var1->y) * 0.7f; + sp98.z = ((void)0, new_var) + ((new_var2->z - new_var1->z) * 0.7f); + } + + Camera_ScaledStepToCeilVec3f(&sp98, &camera->focalActorAtOffset, 0.25f, 0.25f, 0.1f); + spB0.x = focalActorPosRot->pos.x + camera->focalActorAtOffset.x; + spB0.y = focalActorPosRot->pos.y + camera->focalActorAtOffset.y; + spB0.z = focalActorPosRot->pos.z + camera->focalActorAtOffset.z; + } else { + sp98.x = new_var; + sp98.z = new_var; + + if ((((Player*)camera->focalActor)->stateFlags1 & PLAYER_STATE1_4000) || + (((Player*)camera->focalActor)->stateFlags1 & PLAYER_STATE1_4)) { + sp98.y = roData->unk_00; + } else { + sp98.y = roData->unk_00 + focalActorHeight; + } + + Camera_ScaledStepToCeilVec3f(&sp98, &camera->focalActorAtOffset, rwData->unk_14, rwData->unk_14, 0.1f); + spB0.x = focalActorPosRot->pos.x + camera->focalActorAtOffset.x; + spB0.y = focalActorPosRot->pos.y + camera->focalActorAtOffset.y; + spB0.z = focalActorPosRot->pos.z + camera->focalActorAtOffset.z; + } + + if (camera->animState == 0) { + Camera_SetUpdateRatesSlow(camera); + if (!(roData->interfaceFlags & FIXED2_FLAG_0)) { + *at = spB0; + OLib_Vec3fDiffToVecGeo(&sp80, at, &rwData->unk_00); + if ((rwData->unk_0C < sp80.r) || (roData->interfaceFlags & FIXED2_FLAG_5)) { + sp80.r = rwData->unk_0C; + OLib_AddVecGeoToVec3f(&spA4, at, &sp80); + } else { + if (sp80.r < roData->unk_04) { + sp80.r = roData->unk_04; + OLib_AddVecGeoToVec3f(&spA4, at, &sp80); + } else { + spA4 = rwData->unk_00; + } + } + sp44 = spA4; + camera->eyeNext = sp44; + *eye = sp44; + camera->fov = rwData->unk_1C * 0.01f; + } + } + + Camera_ScaledStepToCeilVec3f(&spB0, at, rwData->unk_14, rwData->unk_14, 1.0f); + OLib_Vec3fDiffToVecGeo(&sp80, at, &rwData->unk_00); + if ((rwData->unk_0C < sp80.r) || (roData->interfaceFlags & FIXED2_FLAG_5)) { + sp80.r = rwData->unk_0C; + OLib_AddVecGeoToVec3f(&spA4, at, &sp80); + } else if (sp80.r < roData->unk_04) { + sp80.r = roData->unk_04; + OLib_AddVecGeoToVec3f(&spA4, at, &sp80); + } else { + spA4 = rwData->unk_00; + } + + Camera_ScaledStepToCeilVec3f(&spA4, eyeNext, rwData->unk_18, rwData->unk_18, 0.1f); + *eye = *eyeNext; + camera->dist = OLib_Vec3fDist(at, eye); + camera->roll = 0; + camera->xzSpeed = 0; + rwData->unk_10 = rwData->unk_1C * 0.01f; + camera->fov = Camera_ScaledStepToCeilF(rwData->unk_10, camera->fov, rwData->unk_14, 0.1f); + camera->atLerpStepScale = Camera_ClampLerpScale(camera, 1.0f); + Camera_SetFocalActorAtOffset(camera, &focalActorPosRot->pos); + camera->animState = 1; + + return true; +} + +/** + * Used by the unused PREREND_FIXED Camera Setting. Remnant of OoT + */ +s32 Camera_Fixed3(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Fixed4(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Fixed0(Camera* camera) { + return Camera_Noop(camera); +} + +/** + * First person view + */ +s32 Camera_Subject1(Camera* camera) { + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + Vec3f* eyeNext = &camera->eyeNext; + Vec3f sp90; + Vec3f sp84; + VecGeo sp7C; + VecGeo sp74; + VecGeo tgeo; + PosRot sp58; + f32 sp54; + f32 temp_f0_2; + s16 sp4E; + s16 sp4C; + Subject1ReadOnlyData* roData = &camera->paramData.subj1.roData; + Subject1ReadWriteData* rwData = &camera->paramData.subj1.rwData; + CameraModeValue* values; + f32 temp_f0; + f32 focalActorHeight; + + Actor_GetFocus(&sp58, camera->focalActor); + focalActorHeight = Camera_GetFocalActorHeight(camera); + Camera_SetUpdateRatesFastPitch(camera); + + values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->unk_00 = GET_NEXT_SCALED_RO_DATA(values) * focalActorHeight; + roData->unk_04 = GET_NEXT_RO_DATA(values); + roData->unk_08 = GET_NEXT_RO_DATA(values); + roData->unk_0C = GET_NEXT_RO_DATA(values); + roData->unk_10 = GET_NEXT_RO_DATA(values) * 0.1f; + roData->unk_14 = GET_NEXT_RO_DATA(values) * 0.1f; + roData->unk_18 = GET_NEXT_RO_DATA(values) * 0.1f; + roData->unk_1C = GET_NEXT_RO_DATA(values); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + + sp7C.r = roData->unk_08; + sp7C.yaw = BINANG_ROT180(sp58.rot.y); + sp7C.pitch = sp58.rot.x; + sp90 = sp58.pos; + sp90.y += roData->unk_00; + + OLib_AddVecGeoToVec3f(&sp84, &sp90, &sp7C); + OLib_Vec3fDiffToVecGeo(&sp74, &camera->at, eye); + sCameraInterfaceFlags = roData->interfaceFlags; + + if (camera->play->view.unk164 == 0) { + camera->play->view.unk164 = camera->camId | 0x50; + return true; + } + + if (RELOAD_PARAMS(camera)) { + rwData->unk_00 = sp74.r; + rwData->unk_04 = sp74.yaw; + rwData->unk_06 = sp74.pitch; + + if (roData->interfaceFlags & SUBJECT1_FLAG_4) { + camera->fov = roData->unk_1C; + rwData->timer = 0; + } else { + rwData->timer = 6; + } + camera->dist = roData->unk_08; + camera->rUpdateRateInv = 1.0f; + camera->animState++; + camera->dist = roData->unk_08; + } + + tgeo.r = rwData->unk_00; + tgeo.pitch = rwData->unk_04; + tgeo.yaw = rwData->unk_06; + + if (rwData->timer != 0) { + temp_f0 = (1.0f / rwData->timer); + + VEC3F_LERPIMPDST(at, at, &sp90, temp_f0); + + sp54 = ((tgeo.r - sp7C.r) * (1.0f / 6.0f)); + sp4E = BINANG_SUB(tgeo.pitch, sp7C.yaw) * (1.0f / 6.0f); + sp4C = BINANG_SUB(tgeo.yaw, sp7C.pitch) * (1.0f / 6.0f); + + sp74.r = Camera_ScaledStepToCeilF((rwData->timer * sp54) + sp7C.r, sp74.r, 0.5f, 1.0f); + sp74.yaw = Camera_ScaledStepToCeilS(sp7C.yaw + (sp4E * rwData->timer), sp74.yaw, 0.5f, 5); + sp74.pitch = Camera_ScaledStepToCeilS(sp7C.pitch + (sp4C * rwData->timer), sp74.pitch, 0.5f, 5); + + OLib_AddVecGeoToVec3f(eyeNext, at, &sp74); + *eye = *eyeNext; + rwData->timer--; + } else { + sp54 = Math_SinS(-sp58.rot.x); + temp_f0_2 = Math_CosS(-sp58.rot.x); + + sp90.x = roData->unk_10; + sp90.y = (roData->unk_14 * temp_f0_2) - (roData->unk_18 * sp54); + sp90.z = (roData->unk_14 * sp54) + (roData->unk_18 * temp_f0_2); + + sp54 = Math_SinS(BINANG_ROT180(sp58.rot.y)); + temp_f0_2 = Math_CosS(BINANG_ROT180(sp58.rot.y)); + + roData->unk_10 = (sp90.z * sp54) + (sp90.x * temp_f0_2); + roData->unk_14 = sp90.y; + roData->unk_18 = (sp90.z * temp_f0_2) - (sp90.x * sp54); + + at->x = roData->unk_10 + sp58.pos.x; + at->y = roData->unk_14 + sp58.pos.y; + at->z = roData->unk_18 + sp58.pos.z; + + sp74.r = roData->unk_08; + sp74.yaw = BINANG_ROT180(sp58.rot.y); + sp74.pitch = sp58.rot.x; + + OLib_AddVecGeoToVec3f(&camera->eyeNext, at, &sp74); + sp74.r = roData->unk_04; + OLib_AddVecGeoToVec3f(eye, at, &sp74); + } + + // TODO: is skyboxDisabled accurate here? + if (camera->play->envCtx.skyboxDisabled == 0) { + Camera_BgCheck(camera, at, eye); + } else { + func_800CBFA4(camera, at, eye, 3); + } + + camera->fov = Camera_ScaledStepToCeilF(roData->unk_1C, camera->fov, 0.25f, 0.1f); + camera->roll = 0; + camera->atLerpStepScale = 0.0f; + + return true; +} + +s32 Camera_Subject2(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Subject3(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Subject4(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Subject0(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Data0(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Data1(Camera* camera) { + return Camera_Normal1(camera); +} + +s32 Camera_Data2(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Data3(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Data4(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Unique1(Camera* camera) { + return Camera_Noop(camera); +} + +/** + * Player diving from the surface of the water to underwater not as zora + * Also used when using a door to leave a scene + */ +s32 Camera_Unique2(Camera* camera) { + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + f32 phi_f16; + Vec3f sp70; + VecGeo sp68; + VecGeo sp60; + s32 pad[3]; + Unique2ReadOnlyData* roData = &camera->paramData.uniq2.roData; + Unique2ReadWriteData* rwData = &camera->paramData.uniq2.rwData; + f32 focalActorHeight = Camera_GetFocalActorHeight(camera); + Vec3f* eyeNext = &camera->eyeNext; + CameraModeValue* values; + + OLib_Vec3fDiffToVecGeo(&sp60, at, eye); + + if (RELOAD_PARAMS(camera)) { + values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->unk_00 = + GET_NEXT_SCALED_RO_DATA(values) * focalActorHeight * (0.8f - ((68.0f / focalActorHeight) * -0.2f)); + roData->unk_04 = GET_NEXT_RO_DATA(values); + roData->unk_08 = 0.25f; + roData->unk_0C = GET_NEXT_RO_DATA(values); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + } + + sCameraInterfaceFlags = roData->interfaceFlags; + + if ((camera->animState == 0) || (rwData->unk_04 != roData->interfaceFlags)) { + rwData->unk_04 = roData->interfaceFlags; + } + + if (camera->animState == 0) { + camera->animState = 1; + Camera_SetUpdateRatesSlow(camera); + rwData->unk_00 = 200.0f; + } + + if (roData->interfaceFlags & UNIQUE2_FLAG_4) { + *eyeNext = *eye; + Camera_UnsetStateFlag(camera, CAM_STATE_2); + } + + sp70 = camera->focalActorPosRot.pos; + + if (roData->interfaceFlags & UNIQUE2_FLAG_0) { + phi_f16 = 1.0f; + } else { + phi_f16 = camera->speedRatio; + } + + at->x += (sp70.x - at->x) * phi_f16 * 0.3f; + at->y += ((sp70.y + focalActorHeight + roData->unk_00) - at->y) * 0.2f; + at->z += (sp70.z - at->z) * phi_f16 * 0.3f; + + rwData->unk_00 = rwData->unk_00 + ((2.0f - rwData->unk_00) * 0.05f); + + if (roData->interfaceFlags & UNIQUE2_FLAG_0) { + OLib_Vec3fDiffToVecGeo(&sp68, at, eyeNext); + sp68.r = roData->unk_04; + OLib_AddVecGeoToVec3f(&sp70, at, &sp68); + Camera_ScaledStepToCeilVec3f(&sp70, eye, roData->unk_08, roData->unk_08, 0.2f); + } else if (roData->interfaceFlags & UNIQUE2_FLAG_1) { + if (OLib_Vec3fDistXZ(at, eyeNext) < roData->unk_04) { + OLib_Vec3fDiffToVecGeo(&sp68, at, eyeNext); + sp68.yaw = Camera_ScaledStepToCeilS(sp68.yaw, sp60.yaw, 0.1f, 5); + sp68.r = roData->unk_04; + sp68.pitch = 0; + OLib_AddVecGeoToVec3f(eye, at, &sp68); + eye->y = eyeNext->y; + } else { + Camera_ScaledStepToCeilVec3f(eyeNext, eye, roData->unk_08, roData->unk_08, 0.2f); + } + } + + if (!(roData->interfaceFlags & UNIQUE2_FLAG_5)) { + Camera_BgCheck(camera, at, eye); + } + + camera->dist = OLib_Vec3fDist(at, eye); + camera->roll = 0; + camera->fov = Camera_ScaledStepToCeilF(roData->unk_0C, camera->fov, 0.2f, 0.1f); + camera->atLerpStepScale = Camera_ClampLerpScale(camera, 1.0f); + + return true; +} + +/** + * Woodfall inside the Swamp, used for normal camModes and derivative modes + */ +s32 Camera_Unique3(Camera* camera) { + s32 ret = Camera_Normal1(camera); + + if ((camera->play->sceneId == SCENE_21MITURINMAE) && (camera->eye.y < 5.0f)) { + camera->eye.y = 5.0f; + } + return ret; +} + +/** + * Woodfall inside the Swamp, used for parallel camModes and derivative modes + */ +s32 Camera_Unique4(Camera* camera) { + s32 ret = Camera_Parallel1(camera); + + if ((camera->play->sceneId == SCENE_21MITURINMAE) && (camera->eye.y < 5.0f)) { + camera->eye.y = 5.0f; + } + return ret; +} + +/** + * Woodfall inside the Swamp, used for battle camMode + */ +s32 Camera_Unique5(Camera* camera) { + s32 ret = Camera_Battle1(camera); + + if ((camera->play->sceneId == SCENE_21MITURINMAE) && (camera->eye.y < 5.0f)) { + camera->eye.y = 5.0f; + } + return ret; +} + +/** + * Entering a room or scene (camera settings START0/START1/START2) + */ +s32 Camera_Unique0(Camera* camera) { + f32 playerHeight; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + PosRot sp9C; + Player* player; + Vec3f sp8C; + VecGeo sp84; + VecGeo sp7C; + BgCamFuncData* bgCamFuncData; + f32 sp74; + s32 pad; + s16 temp_v1; + Unique0ReadOnlyData* roData = &camera->paramData.uniq0.roData; + Unique0ReadWriteData* rwData = &camera->paramData.uniq0.rwData; + CameraModeValue* values; + Vec3f sp54; + + playerHeight = Player_GetHeight((Player*)camera->focalActor); + player = (Player*)camera->focalActor; + + if (RELOAD_PARAMS(camera)) { + values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->unk_00 = GET_NEXT_RO_DATA(values); + roData->unk_04 = GET_NEXT_RO_DATA(values); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + } + + OLib_Vec3fDiffToVecGeo(&sp7C, &camera->at, &camera->eye); + + if (player->rideActor != NULL) { + Actor_GetWorld(&sp9C, player->rideActor); + sp8C = sp9C.pos; + sp8C.y += playerHeight + 20.0f; + } else { + sp8C = camera->focalActorPosRot.pos; + sp8C.y += playerHeight; + } + + sCameraInterfaceFlags = roData->interfaceFlags; + + switch (camera->animState) { + case 0: + bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamOrActorCsCamFuncData(camera, camera->bgCamIndex); + Camera_Vec3sToVec3f(&rwData->unk_1C, &bgCamFuncData->pos); + camera->eye = camera->eyeNext = rwData->unk_1C; + rwData->unk_34 = bgCamFuncData->rot; + + temp_v1 = bgCamFuncData->fov; + if (temp_v1 != -1) { + if (temp_v1 <= 360) { + camera->fov = temp_v1; + } else { + camera->fov = temp_v1 * 0.01f; + } + } + + rwData->timer = bgCamFuncData->unk_0E; + if (rwData->timer == -1) { + rwData->timer = 60; + } + + if (bgCamFuncData->unk_10 != -1) { + rwData->unk_18 = bgCamFuncData->unk_10 * 0.01f; + } else { + rwData->unk_18 = roData->unk_04 * 0.01f; + } + + rwData->unk_00 = focalActorPosRot->pos; + if (roData->interfaceFlags & UNIQUE0_FLAG_4) { + rwData->unk_0C.x = focalActorPosRot->pos.x; + rwData->unk_0C.y = focalActorPosRot->pos.y + playerHeight + roData->unk_00; + rwData->unk_0C.z = focalActorPosRot->pos.z; + } + rwData->unk_3A = camera->focalActor->world.rot.y; + rwData->unk_3E = 0; + camera->eye = camera->eyeNext = rwData->unk_1C; + Camera_UnsetStateFlag(camera, CAM_STATE_2); + camera->animState++; + // fallthrough + case 1: + sp84.r = OLib_Vec3fDist(&sp8C, &camera->eye); + sp84.yaw = rwData->unk_34.y; + sp84.pitch = -rwData->unk_34.x; + OLib_VecGeoToVec3f(&rwData->unk_28, &sp84); + func_80179A44(&rwData->unk_1C, focalActorPosRot, &rwData->unk_0C); + camera->at = rwData->unk_0C; + + if (player->stateFlags1 & PLAYER_STATE1_20000000) { + rwData->unk_00 = focalActorPosRot->pos; + } + + if (roData->interfaceFlags & UNIQUE0_FLAG_4) { + sp54.x = focalActorPosRot->pos.x; + sp54.y = focalActorPosRot->pos.y + playerHeight + roData->unk_00; + sp54.z = focalActorPosRot->pos.z; + Camera_ScaledStepToCeilVec3f(&sp54, &camera->at, camera->xzOffsetUpdateRate, camera->yOffsetUpdateRate, + 0.1f); + camera->yOffsetUpdateRate = + Camera_ScaledStepToCeilF(rwData->unk_18, camera->yOffsetUpdateRate, 0.1f, 0.0001f); + camera->xzOffsetUpdateRate = + Camera_ScaledStepToCeilF(rwData->unk_18, camera->xzOffsetUpdateRate, 0.1f, 0.0001f); + } + + if ((camera->animState == 999) || (camera->animState == 666)) { + rwData->unk_3E = 2; + } + + if (roData->interfaceFlags & UNIQUE0_FLAG_0) { + if (rwData->timer > 0) { + rwData->timer--; + rwData->unk_00 = focalActorPosRot->pos; + } else if (!(player->stateFlags1 & PLAYER_STATE1_20000000) && + ((OLib_Vec3fDistXZ(&focalActorPosRot->pos, &rwData->unk_00) >= 10.0f) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CUP) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CLEFT) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CRIGHT) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_Z) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_L) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_R) || + (roData->interfaceFlags & UNIQUE0_FLAG_1))) { + rwData->unk_3E = 1; + } + } else { + if (rwData->timer > 0) { + rwData->timer--; + if (rwData->timer == 0) { + sCameraInterfaceFlags = CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0); + } + } else { + rwData->unk_00 = focalActorPosRot->pos; + } + + if (!(player->stateFlags1 & PLAYER_STATE1_20000000)) { // TODO: Merge into 1 if-statement + if ((rwData->unk_3A != camera->focalActor->world.rot.y) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CUP) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CLEFT) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CRIGHT) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_Z) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_L) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_R) || + (roData->interfaceFlags & UNIQUE0_FLAG_1)) { + rwData->unk_3E = 1; + } + } + } + break; + + case 3: + sp74 = 1.0f / rwData->timer; + sp8C.y -= playerHeight * 0.2f; + + Camera_ScaledStepToCeilVec3f(&sp8C, &camera->at, sp74, sp74, 0.001f); + + sp84.r = OLib_Vec3fDist(&camera->at, &camera->eye); + sp84.pitch = sp7C.pitch; + sp84.yaw = sp7C.yaw; + sp84.r = Camera_ScaledStepToCeilF(100.0f, sp84.r, sp74, 1.0f); + + OLib_AddVecGeoToVec3f(&sp8C, &camera->at, &sp84); + + sp74 = (QREG(64) * 0.01f) + 0.2f; + + Camera_ScaledStepToCeilVec3f(&sp8C, &camera->eye, sp74, sp74, 0.001f); + + rwData->timer--; + if (rwData->timer == 0) { + rwData->unk_3E = 9; + } + break; + } + + if ((rwData->unk_3E == 1) || (rwData->unk_3E == 2) || (rwData->unk_3E == 9)) { + camera->dist = OLib_Vec3fDist(&camera->at, &camera->eye); + camera->atLerpStepScale = Camera_ClampLerpScale(camera, 1.0f); + + Camera_SetFocalActorAtOffset(camera, &focalActorPosRot->pos); + + camera->atLerpStepScale = 0.0f; + + Camera_ChangeSettingFlags(camera, camera->prevSetting, CAM_CHANGE_SETTING_1); + Camera_SetStateFlag(camera, CAM_STATE_2); + + camera->yawUpdateRateInv = 1200.0f; + camera->pitchUpdateRateInv = 1200.0f; + camera->yOffsetUpdateRate = 0.001f; + camera->xzOffsetUpdateRate = 0.001f; + camera->fovUpdateRate = 0.01f; + } + + return true; +} + +/** + * Does the minimal amount of camera update. + * Allows for manual control of camera parameters without interference from update + */ +s32 Camera_Unique6(Camera* camera) { + f32 focalActorHeight; + CameraModeValue* values; + Vec3f playerPosDisp; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + Unique6ReadOnlyData* roData = &camera->paramData.uniq6.roData; + + if (RELOAD_PARAMS(camera)) { + values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + } + + sCameraInterfaceFlags = roData->interfaceFlags; + + if (camera->animState == 0) { + camera->animState++; + Camera_SetUpdateRatesFastPitch(camera); + } + + if (camera->focalActor != NULL) { + focalActorHeight = Camera_GetFocalActorHeight(camera); + playerPosDisp = focalActorPosRot->pos; + playerPosDisp.y += focalActorHeight; + camera->dist = OLib_Vec3fDist(&playerPosDisp, &camera->eye); + Camera_SetFocalActorAtOffset(camera, &focalActorPosRot->pos); + } else { + camera->dist = OLib_Vec3fDist(&camera->at, &camera->eye); + } + + if (roData->interfaceFlags & UNIQUE6_FLAG_0) { + if (camera->timer > 0) { + camera->timer--; + } + } + + return true; +} + +/** + * Used by the unused PREREND_PIVOT Camera Setting. Remnant of OoT + */ +s32 Camera_Unique7(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Unique8(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Unique9(Camera* camera) { + return Camera_Noop(camera); +} + +/** + * Used by unknown settings DEMO0 and ATTENTION + */ +s32 Camera_Demo1(Camera* camera) { + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + Vec3f* eyeNext = &camera->eyeNext; + PosRot* targetPosRot = &camera->targetPosRot; + f32 temp_f0; + Actor* sp98[1]; + s16 screenX; + s16 screenY; + s32 phi_v0; + VecGeo sp88; + PosRot sp74; + PosRot targetHead; + Demo1ReadOnlyData* roData = &camera->paramData.demo1.roData; + Demo1ReadWriteData* rwData = &camera->paramData.demo1.rwData; + s32 pad; + + if (camera->animState == 0) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + } + + if (camera->animState == 0) { + rwData->unk_1C = 0; + OLib_Vec3fDiffToVecGeo(&rwData->unk_0C, &camera->targetPosRot.pos, eye); + OLib_Vec3fDiffToVecGeo(&rwData->unk_14, &camera->at, eye); + Actor_GetFocus(&targetHead, camera->target); + Actor_GetWorld(&sp74, camera->target); + camera->targetPosRot.pos.x = (sp74.pos.x + targetHead.pos.x) * 0.5f; + camera->targetPosRot.pos.y = (sp74.pos.y + targetHead.pos.y) * 0.5f; + camera->targetPosRot.pos.z = (sp74.pos.z + targetHead.pos.z) * 0.5f; + camera->targetPosRot.rot = targetHead.rot; + camera->animState++; + } + + Actor_GetScreenPos(camera->play, camera->target, &screenX, &screenY); + + temp_f0 = rwData->unk_0C.r; + if ((screenX > 20) && (screenX < (SCREEN_WIDTH - 20)) && (screenY > 40) && (screenY < (SCREEN_HEIGHT - 40))) { + if (temp_f0 < 700.0f) { + phi_v0 = 0; + } else { + phi_v0 = 1; + } + } else if (temp_f0 < 50.0f) { + phi_v0 = 2; + } else if (temp_f0 < 300.0f) { + phi_v0 = 3; + } else if (temp_f0 < 700.0f) { + phi_v0 = 4; + } else { + phi_v0 = 5; + } + + if (camera->target->category == ACTORCAT_DOOR) { + if ((phi_v0 > 0) && (phi_v0 < 5)) { + phi_v0 = 6; + } else if (phi_v0 >= 5) { + phi_v0 = 7; + } + } + + if (camera->target->category == ACTORCAT_CHEST) { + if ((phi_v0 > 1) && (phi_v0 < 5)) { + phi_v0 = 8; + } + } + + switch (phi_v0) { + Vec3f sp44; + + case 1: + Camera_ScaledStepToCeilVec3f(&camera->targetPosRot.pos, at, 0.1f, 0.1f, 0.1f); + OLib_Vec3fDiffToVecGeo(&sp88, at, eye); + sp88.r = rwData->unk_0C.r; + OLib_AddVecGeoToVec3f(eyeNext, at, &sp88); + *eye = *eyeNext; + Camera_BgCheck(camera, at, eye); + break; + + case 2: + Camera_ScaledStepToCeilVec3f(&camera->targetPosRot.pos, &camera->at, 0.1f, 0.1f, 0.1f); + break; + + case 3: + eyeNext = &targetPosRot->pos; + if (rwData->unk_1C == 0) { + sp98[0] = camera->target; + func_800CC260(camera, &rwData->unk_00, &targetPosRot->pos, &rwData->unk_14, sp98, 1); + } + Camera_ScaledStepToCeilVec3f(eyeNext, at, 0.1f, 0.1f, 0.1f); + eyeNext = &camera->eyeNext; + Camera_ScaledStepToCeilVec3f(&rwData->unk_00, eyeNext, 0.1f, 0.1f, 0.1f); + *eye = *eyeNext; + Camera_BgCheck(camera, at, eye); + break; + + case 4: + if (rwData->unk_1C == 0) { + sp98[0] = camera->target; + rwData->unk_14.r = rwData->unk_0C.r; + func_800CC260(camera, &rwData->unk_00, &targetPosRot->pos, &rwData->unk_14, sp98, 1); + } + Camera_ScaledStepToCeilVec3f(&targetPosRot->pos, at, 0.1f, 0.1f, 0.1f); + Camera_ScaledStepToCeilVec3f(&rwData->unk_00, eyeNext, 0.1f, 0.1f, 0.1f); + *eye = *eyeNext; + Camera_BgCheck(camera, at, eye); + break; + + case 5: + eyeNext = &targetPosRot->pos; + if (rwData->unk_1C == 0) { + sp98[0] = camera->target; + func_800CC260(camera, &rwData->unk_00, &targetPosRot->pos, &rwData->unk_0C, sp98, 1); + } + *at = *eyeNext; + sp44 = rwData->unk_00; + camera->eyeNext = sp44; + *eye = sp44; + break; + + case 6: + if (rwData->unk_1C == 0) { + rwData->unk_0C.yaw = camera->target->shape.rot.y; + sp98[0] = camera->target; + rwData->unk_0C.r = rwData->unk_14.r; + func_800CC260(camera, &rwData->unk_00, &targetPosRot->pos, &rwData->unk_0C, sp98, 1); + } + Camera_ScaledStepToCeilVec3f(&targetPosRot->pos, at, 0.1f, 0.1f, 0.1f); + Camera_ScaledStepToCeilVec3f(&rwData->unk_00, eyeNext, 0.1f, 0.1f, 0.1f); + *eye = *eyeNext; + Camera_BgCheck(camera, at, eye); + break; + + case 7: + if (rwData->unk_1C == 0) { + rwData->unk_0C.yaw = camera->target->shape.rot.y; + sp98[0] = camera->target; + func_800CC260(camera, &rwData->unk_00, &targetPosRot->pos, &rwData->unk_0C, sp98, 1); + } + *at = targetPosRot->pos; + sp44 = rwData->unk_00; + camera->eyeNext = sp44; + *eye = sp44; + break; + + case 8: + if (rwData->unk_1C == 0) { + rwData->unk_0C.yaw = camera->target->shape.rot.y; + sp98[0] = camera->target; + func_800CC260(camera, &rwData->unk_00, &targetPosRot->pos, &rwData->unk_0C, sp98, 1); + } + Camera_ScaledStepToCeilVec3f(&targetPosRot->pos, at, 0.1f, 0.1f, 0.1f); + Camera_ScaledStepToCeilVec3f(&rwData->unk_00, eyeNext, 0.1f, 0.1f, 0.1f); + *eye = *eyeNext; + Camera_BgCheck(camera, at, eye); + break; + } + + rwData->unk_1C++; + + return true; +} // Data for opening chests (default) -VecSph D_801B9E64[] = { +VecGeo D_801B9E64[] = { { 50.0f, 0xEE3A, 0xD558 }, { 75.0f, 0x0000, 0x8008 }, { 80.0f, 0xEE3A, 0x8008 }, @@ -713,7 +5960,7 @@ Vec3f D_801B9E84[] = { }; // Data for opening chests (goron) -VecSph D_801B9EB4[] = { +VecGeo D_801B9EB4[] = { { 60.0f, 0xEE3A, 0xD558 }, { 95.0f, 0x0000, 0x8008 }, { 90.0f, 0xEE3A, 0x8008 }, @@ -726,140 +5973,2308 @@ Vec3f D_801B9ED4[] = { { 0.0f, 3.0f, -3.0f }, }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo2.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo3.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo5.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo6.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo7.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo9.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special1.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special2.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special3.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special5.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special6.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special7.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special9.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Alloc.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Free.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DDFE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DE0E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_InitPlayerSettings.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ChangeStatus.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DE324.s") - -s16 sEarthquakeFreq[] = { - 0xFFC, // 1 Large Earthquake between CLOCK_TIME(0, 00) to CLOCK_TIME(1, 30) - 0x7FC, // 2 Large Earthquakes between CLOCK_TIME(1, 30) to CLOCK_TIME(3, 00) - 0x3FC, // 4 Large Earthquakes between CLOCK_TIME(3, 00) to CLOCK_TIME(4, 30) - 0x1FC, // 8 Large Earthquakes between CLOCK_TIME(4, 30) to CLOCK_TIME(6, 00) -}; -s16 sEarthquakeTimer = 0; - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DE62C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DE840.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DE890.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DE954.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Update.s") - -s32 sModeChangeFlags = 0; - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DF498.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_SetMode.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") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DF8EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ChangeSetting.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ChangeDataIdx.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFC1C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFC40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetInputDirYaw.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetCamDir.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetCamDirPitch.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetCamDirYaw.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_AddQuake.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_SetViewParam.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFEF0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFF18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFF34.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFF44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_SetFlags.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ClearFlags.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ChangeDoorCam.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Copy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E01AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetQuakeOffset.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E01DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E0228.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E0238.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_SetToTrackActor.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_SetTargetActor.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetWaterYPos.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E0348.s") +/** + * Opening large chests. + * The camera position will be at a fixed point, and rotate around at different intervals. + * The direction, and initial position is dependent on when the camera was started. + */ +s32 Camera_Demo2(Camera* camera) { + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + Vec3f* eyeNext = &camera->eyeNext; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + VecGeo atToEye; + VecGeo eyeOffset; + VecGeo atOffset; + Vec3f sp7C; + Vec3f sp70; + Vec3f sp64; + f32 sp60; + s32 pad; + u8 skipUpdateEye = false; + f32 playerHeight = Player_GetHeight((Player*)camera->focalActor); + s16 angle; + VecGeo* sp4C = D_801B9E64; + Vec3f* sp48 = D_801B9E84; + Actor* focalActor = camera->focalActor; + Demo2ReadOnlyData* roData = &camera->paramData.demo2.roData; + Demo2ReadWriteData* rwData = &camera->paramData.demo2.rwData; + + if (((focalActor == &GET_PLAYER(camera->play)->actor) && + (((Player*)focalActor)->transformation == PLAYER_FORM_GORON))) { + sp4C = D_801B9EB4; + sp48 = D_801B9ED4; + } + + Camera_UnsetStateFlag(camera, CAM_STATE_4); + + if (RELOAD_PARAMS(camera)) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + + roData->fov = GET_NEXT_RO_DATA(values); + roData->unk_04 = GET_NEXT_RO_DATA(values); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + } + + OLib_Vec3fDiffToVecGeo(&atToEye, at, eye); + + sCameraInterfaceFlags = roData->interfaceFlags; + + switch (camera->animState) { + case 0: + Camera_UnsetStateFlag(camera, CAM_STATE_3 | CAM_STATE_2); + Camera_SetUpdateRatesSlow(camera); + camera->fov = roData->fov; + camera->roll = rwData->animFrame = 0; + rwData->initialAt = focalActorPosRot->pos; + if (camera->focalActorFloorHeight != BGCHECK_Y_MIN) { + rwData->initialAt.y = camera->focalActorFloorHeight; + } + angle = focalActorPosRot->rot.y; + sp70.x = rwData->initialAt.x + (Math_SinS(angle) * 40.0f); + sp70.y = rwData->initialAt.y + 40.0f; + sp70.z = rwData->initialAt.z + (Math_CosS(angle) * 40.0f); + if (camera->play->state.frames & 2) { + angle -= 0x4000; + rwData->yawDir = 1; + } else { + angle += 0x4000; + rwData->yawDir = -1; + } + + sp7C.x = sp70.x + (sp4C[1].r * Math_SinS(angle)); + sp7C.y = rwData->initialAt.y + 5.0f; + sp7C.z = sp70.z + (sp4C[1].r * Math_CosS(angle)); + if (Camera_BgCheck(camera, &sp70, &sp7C)) { + rwData->yawDir = -rwData->yawDir; + } + + OLib_Vec3fToVecGeo(&atOffset, &sp48[0]); + atOffset.yaw += focalActorPosRot->rot.y; + OLib_AddVecGeoToVec3f(at, &rwData->initialAt, &atOffset); + + eyeOffset.r = sp4C[0].r; + eyeOffset.pitch = sp4C[0].pitch; + eyeOffset.yaw = (sp4C[0].yaw * rwData->yawDir) + focalActorPosRot->rot.y; + + rwData->unk_0C = 1.0f; + break; + + case 1: + // This is the case taken for nearly the entire cutscene + sp60 = (rwData->animFrame - 2) * (1.0f / 146.0f); + + VEC3F_LERPIMPDST(&sp64, &sp48[0], &sp48[1], sp60); + + OLib_Vec3fToVecGeo(&atOffset, &sp64); + atOffset.yaw = (atOffset.yaw * rwData->yawDir) + focalActorPosRot->rot.y; + OLib_AddVecGeoToVec3f(at, &rwData->initialAt, &atOffset); + + atOffset.r = LERPIMP(sp4C[0].r, sp4C[1].r, sp60); + atOffset.pitch = BINANG_LERPIMP(sp4C[0].pitch, sp4C[1].pitch, sp60); + atOffset.yaw = BINANG_LERPIMP(sp4C[0].yaw, sp4C[1].yaw, sp60); + + eyeOffset.r = atOffset.r; + eyeOffset.pitch = atOffset.pitch; + eyeOffset.yaw = (atOffset.yaw * rwData->yawDir) + focalActorPosRot->rot.y; + + rwData->unk_0C -= (1.0f / 365.0f); + break; + + case 2: + sp60 = (rwData->animFrame - 148) * 0.1f; + + sp64.x = LERPIMP(sp48[1].x, sp48[2].x, sp60); + sp64.y = LERPIMP((sp48[1].y - playerHeight), sp48[2].y, sp60); + sp64.y += playerHeight; + sp64.z = LERPIMP(sp48[1].z, sp48[2].z, sp60); + + OLib_Vec3fToVecGeo(&atOffset, &sp64); + atOffset.yaw = (atOffset.yaw * rwData->yawDir) + focalActorPosRot->rot.y; + OLib_AddVecGeoToVec3f(at, &rwData->initialAt, &atOffset); + + atOffset.r = LERPIMP(sp4C[1].r, sp4C[2].r, sp60); + atOffset.pitch = BINANG_LERPIMP(sp4C[1].pitch, sp4C[2].pitch, sp60); + atOffset.yaw = BINANG_LERPIMP(sp4C[1].yaw, sp4C[2].yaw, sp60); + + eyeOffset.r = atOffset.r; + eyeOffset.pitch = atOffset.pitch; + eyeOffset.yaw = (atOffset.yaw * rwData->yawDir) + focalActorPosRot->rot.y; + + rwData->unk_0C -= 0.04f; + break; + + case 3: + sp60 = (rwData->animFrame - 159) * (1.0f / 9.0f); + + sp64.x = LERPIMP(sp48[2].x, sp48[3].x, sp60); + sp64.y = LERPIMP(sp48[2].y, sp48[3].y, sp60); + sp64.y += playerHeight; + sp64.z = LERPIMP(sp48[2].z, sp48[3].z, sp60); + + OLib_Vec3fToVecGeo(&atOffset, &sp64); + atOffset.yaw = (atOffset.yaw * rwData->yawDir) + focalActorPosRot->rot.y; + OLib_AddVecGeoToVec3f(at, &rwData->initialAt, &atOffset); + + atOffset.r = LERPIMP(sp4C[2].r, sp4C[3].r, sp60); + atOffset.pitch = BINANG_LERPIMP(sp4C[2].pitch, sp4C[3].pitch, sp60); + atOffset.yaw = BINANG_LERPIMP(sp4C[2].yaw, sp4C[3].yaw, sp60); + + eyeOffset.r = atOffset.r; + eyeOffset.pitch = atOffset.pitch; + eyeOffset.yaw = (atOffset.yaw * rwData->yawDir) + focalActorPosRot->rot.y; + + rwData->unk_0C += (4.0f / 45.0f); + break; + + case 30: + Camera_SetStateFlag(camera, CAM_STATE_10); + if (camera->stateFlags & CAM_STATE_3) { + camera->animState = 4; + } + // fallthrough + case 10: + case 20: + // Taken on the 1st and 158th animation frame + skipUpdateEye = true; + break; + case 4: + eyeOffset.r = 80.0f; + eyeOffset.pitch = 0; + eyeOffset.yaw = atToEye.yaw; + rwData->unk_0C = 0.1f; + sCameraInterfaceFlags = CAM_INTERFACE_FLAGS(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_A, 0); + + if (!(((rwData->animFrame < 0) || (camera->xzSpeed > 0.001f) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CUP) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CLEFT) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CRIGHT) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_Z) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_L) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_R)) && + (camera->stateFlags & CAM_STATE_3))) { + goto skipeyeUpdate; + } + // fallthrough + default: + Camera_SetStateFlag(camera, CAM_STATE_4 | CAM_STATE_2); + Camera_UnsetStateFlag(camera, CAM_STATE_3); + func_800CC938(camera); + sCameraInterfaceFlags = CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0); + skipeyeUpdate: + skipUpdateEye = true; + break; + } + + rwData->animFrame++; + + /** + * Opening a large chest only lasts 135 frames + * + * So for one frame, the animState is set to 10, + * allowing the static data to be loaded into the subCamera mini-heap + * + * For the remainder of the cutscene, animState is set to 1 + */ + if (rwData->animFrame == 1) { + camera->animState = 10; + } else if (rwData->animFrame == 2) { + camera->animState = 1; + } else if (rwData->animFrame == 148) { + camera->animState = 2; + } else if (rwData->animFrame == 158) { + camera->animState = 20; + } else if (rwData->animFrame == 159) { + camera->animState = 3; + } else if (rwData->animFrame == 168) { + camera->animState = 30; + } else if (rwData->animFrame == 228) { + camera->animState = 4; + } + + if (!skipUpdateEye) { + eyeOffset.r = Camera_ScaledStepToCeilF(eyeOffset.r, atToEye.r, rwData->unk_0C, 1.0f); + eyeOffset.pitch = Camera_ScaledStepToCeilS(eyeOffset.pitch, atToEye.pitch, rwData->unk_0C, 5); + eyeOffset.yaw = Camera_ScaledStepToCeilS(eyeOffset.yaw, atToEye.yaw, rwData->unk_0C, 5); + OLib_AddVecGeoToVec3f(eyeNext, at, &eyeOffset); + *eye = *eyeNext; + } + + camera->dist = OLib_Vec3fDist(at, eye); + camera->atLerpStepScale = 0.1f; + Camera_SetFocalActorAtOffset(camera, &focalActorPosRot->pos); + + return true; +} + +/** + * Taking the warp pad from the start of a dungeon to the boss-room + */ +s32 Camera_Demo3(Camera* camera) { + s32 pad2; + f32 temp; + CameraModeValue* values; + VecGeo atToEye; + PosRot focalActorFocus; + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + Vec3f* eyeNext = &camera->eyeNext; + Demo3ReadOnlyData* roData = &camera->paramData.demo3.roData; + Demo3ReadWriteData* rwData = &camera->paramData.demo3.rwData; + + OLib_Vec3fDiffToVecGeo(&atToEye, at, eye); + Actor_GetFocus(&focalActorFocus, camera->focalActor); + focalActorFocus.pos.x = camera->focalActorPosRot.pos.x; + focalActorFocus.pos.z = camera->focalActorPosRot.pos.z; + focalActorFocus.pos.y -= (focalActorFocus.pos.y - camera->focalActorPosRot.pos.y) * 0.4f; + Camera_ScaledStepToCeilVec3f(&focalActorFocus.pos, at, 0.1f, 0.1f, 0.1f); + + if (RELOAD_PARAMS(camera)) { + values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + camera->animState = 0; + } + + sCameraInterfaceFlags = roData->interfaceFlags; + + switch (camera->animState) { + case 0: + // Init Data + camera->animState++; + rwData->timer = 125; + Distortion_Request(DISTORTION_TYPE_ZORA_SWIMMING); + Distortion_SetDuration(60); + break; + + case 1: + // Zoom into player, start to rise + temp = 1.0f / rwData->timer; + atToEye.r = Camera_ScaledStepToCeilF(140.0f, atToEye.r, temp, 0.1f); + rwData->timer--; + camera->fov = Camera_ScaledStepToCeilF(50.0f, camera->fov, 0.1f, 0.1f); + if (rwData->timer <= 0) { + rwData->timer = 20; + camera->animState++; + Distortion_Request(DISTORTION_TYPE_UNDERWATER_ENTRY); + Distortion_SetDuration(80); + } + break; + + case 2: + // continue rising + rwData->timer--; + if (rwData->timer <= 0) { + rwData->unk_04 = 120; + rwData->timer = 0; + rwData->unk_00 = (175.0f - camera->fov) / rwData->unk_04; + camera->animState++; + Distortion_Request(DISTORTION_TYPE_BOSS_WARP); + Distortion_SetDuration(15); + } + break; + + case 3: + rwData->timer++; + camera->fov += rwData->unk_00 * rwData->timer; + if (rwData->timer >= 15) { + Distortion_RemoveRequest(DISTORTION_TYPE_BOSS_WARP); + Distortion_RemoveRequest(DISTORTION_TYPE_UNDERWATER_ENTRY); + Distortion_RemoveRequest(DISTORTION_TYPE_ZORA_SWIMMING); + camera->animState++; + } + break; + } + + OLib_AddVecGeoToVec3f(eyeNext, at, &atToEye); + *eye = *eyeNext; + return true; +} + +/** + * Mask Transformation Cutscene 0: + * starting as a human and transforming into anything else + */ +s32 Camera_Demo4(Camera* camera) { + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + VecGeo atToEye; + CameraModeValue* values; + PosRot focalActorFocus; + f32 sp58; + f32 sin; + Demo4ReadOnlyData* roData = &camera->paramData.demo4.roData; + Demo4ReadWriteData* rwData = &camera->paramData.demo4.rwData; + s32 pad[2]; + + OLib_Vec3fDiffToVecGeo(&atToEye, at, eye); + + if (RELOAD_PARAMS(camera)) { + values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + camera->animState = 0; + rwData->unk_00 = *at; + rwData->unk_18 = atToEye; + rwData->unk_14 = camera->fov; + } + + Actor_GetFocus(&focalActorFocus, camera->focalActor); + sCameraInterfaceFlags = roData->interfaceFlags; + + switch (camera->animState) { + //! FAKE: + if (1) {} + case 0: + camera->animState++; + rwData->timer = 0; + + if (!(atToEye.r < 40.0f)) { + atToEye.r = 40.0f; + } + + camera->fov = 80.0f; + rwData->unk_10 = (Rand_ZeroOne() - 0.5f) * 40.0f; + // fallthrough + case 1: + // Camera fixed on human player as the mask moves from the pocket to the face + // Camera rolls left and right + if (rwData->timer >= 12) { + rwData->unk_0C = (rwData->timer - 12) * 10.384615f; + sin = sin_rad(DEG_TO_RAD(rwData->unk_0C)); + rwData->unk_0C = ((rwData->unk_10 < 0.0f) ? -1.0f : 1.0f) * sin; + if (rwData->timer == 12) { + Distortion_Request(DISTORTION_TYPE_MASK_TRANSFORM_1); + Distortion_SetDuration(26); + } + } else { + rwData->unk_0C = 0.0f; + } + + sp58 = rwData->timer * (6.0f / 19.0f); + rwData->unk_20 = focalActorPosRot->rot.y + 0x4000; + focalActorFocus.pos.x = (Math_SinS(rwData->unk_20) * sp58 * rwData->unk_0C) + focalActorPosRot->pos.x; + focalActorFocus.pos.z = (Math_CosS(rwData->unk_20) * sp58 * rwData->unk_0C) + focalActorPosRot->pos.z; + focalActorFocus.pos.y -= (focalActorFocus.pos.y - focalActorPosRot->pos.y) * 0.099999994f; + Camera_ScaledStepToCeilVec3f(&focalActorFocus.pos, at, 0.2f, 0.2f, 0.1f); + + sp58 = (rwData->timer * (30.0f / 19.0f)); + camera->roll = CAM_DEG_TO_BINANG(sp58 * rwData->unk_0C); + + sp58 = 1.0f / (38 - rwData->timer); + rwData->timer++; + atToEye.r = Camera_ScaledStepToCeilF(30.0f, atToEye.r, sp58, 0.1f); + atToEye.pitch = 0; + + if (rwData->timer >= 38) { + rwData->timer = 24; + camera->animState++; + rwData->unk_0C = (32.0f - camera->fov) / 24.0f; + Distortion_Request(DISTORTION_TYPE_MASK_TRANSFORM_2); + } + break; + + case 2: + // Camera steadies as human player is fully croutched down and hiding face + if (rwData->timer == 24) { + at->x = (Math_SinS(focalActorPosRot->rot.y) * -7.0f) + focalActorPosRot->pos.x; + at->y = focalActorFocus.pos.y - ((focalActorFocus.pos.y - focalActorPosRot->pos.y) * 0.1f); + at->z = (Math_CosS(focalActorPosRot->rot.y) * -7.0f) + focalActorPosRot->pos.z; + } else { + focalActorFocus.pos.x = (Math_SinS(focalActorPosRot->rot.y) * -7.0f) + focalActorPosRot->pos.x; + focalActorFocus.pos.y -= (focalActorFocus.pos.y - camera->focalActorPosRot.pos.y) * 0.1f; + focalActorFocus.pos.z = (Math_CosS(focalActorPosRot->rot.y) * -7.0f) + focalActorPosRot->pos.z; + Camera_ScaledStepToCeilVec3f(&focalActorFocus.pos, at, 0.25f, 0.25f, 0.1f); + } + + if (rwData->timer > 0) { + camera->fov += rwData->unk_0C; + } + + rwData->timer--; + + atToEye.r = 35.0f; + atToEye.pitch = 0x2000; + camera->roll = Camera_ScaledStepToCeilS(0, camera->roll, 0.1f, 5); + + if (rwData->timer <= 0) { + rwData->unk_20 = 630; + rwData->timer = 0; + rwData->unk_0C = (60.0f - camera->fov) / rwData->unk_20; + camera->animState = 3; + } + break; + + case 3: + // Camera zooms into human players face with bulging eyes + focalActorFocus.pos.x = focalActorPosRot->pos.x; + focalActorFocus.pos.y -= (focalActorFocus.pos.y - camera->focalActorPosRot.pos.y) * 0.1f; + focalActorFocus.pos.z = focalActorPosRot->pos.z; + + Camera_ScaledStepToCeilVec3f(&focalActorFocus.pos, at, 0.25f, 0.25f, 0.1f); + + camera->roll = Camera_ScaledStepToCeilS(0, camera->roll, 0.1f, 5); + rwData->timer++; + camera->fov += rwData->unk_0C * rwData->timer; + atToEye.pitch = 0x2000; + atToEye.r = 35.0f; + + if (rwData->timer >= 35) { + Distortion_RemoveRequest(DISTORTION_TYPE_MASK_TRANSFORM_1); + Distortion_RemoveRequest(DISTORTION_TYPE_MASK_TRANSFORM_2); + camera->animState = 4; + } + break; + + case 999: + Actor_GetFocus(&focalActorFocus, camera->focalActor); + Distortion_RemoveRequest(DISTORTION_TYPE_MASK_TRANSFORM_1); + Distortion_RemoveRequest(DISTORTION_TYPE_MASK_TRANSFORM_2); + camera->animState = 4; + break; + + case 4: + // Camera backs up as player is now in a transformed state + focalActorFocus.pos.y -= (focalActorFocus.pos.y - camera->focalActorPosRot.pos.y) * 0.1f; + Camera_ScaledStepToCeilVec3f(&focalActorFocus.pos, at, 0.1f, 0.1f, 0.1f); + atToEye = rwData->unk_18; + camera->fov = rwData->unk_14; + camera->roll = 0; + break; + } + + OLib_AddVecGeoToVec3f(&camera->eyeNext, at, &atToEye); + *eye = camera->eyeNext; + + return true; +} + +/** + * Mask Transformation Cutscene 1: + * starting as non-human/fierce diety and transforming into anything else + */ +s32 Camera_Demo5(Camera* camera) { + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + Vec3f* eyeNext = &camera->eyeNext; + VecGeo atToEye; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + PosRot focalActorFocus; + f32 new_var; + f32 sp58; + f32 sin; + Demo5ReadOnlyData* roData = &camera->paramData.demo5.roData; + Demo5ReadWriteData* rwData = &camera->paramData.demo5.rwData; + CameraModeValue* values; + + OLib_Vec3fDiffToVecGeo(&atToEye, at, eye); + + if (RELOAD_PARAMS(camera)) { + values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + camera->animState = 0; + rwData->unk_00 = *at; + rwData->unk_1C = atToEye; + rwData->unk_18 = camera->fov; + } + + Actor_GetFocus(&focalActorFocus, camera->focalActor); + + sCameraInterfaceFlags = roData->interfaceFlags; + + switch (camera->animState) { + case 0: + camera->animState++; + atToEye.pitch = 0; + rwData->timer = 0x12; + rwData->unk_14 = 80.0f; + atToEye.r = 30.0f; + camera->fov = 80.0f; + rwData->unk_10 = (Rand_ZeroOne() - 0.5f) * 40.0f; + camera->roll = 0; + focalActorFocus.pos.x = focalActorPosRot->pos.x; + focalActorFocus.pos.z = focalActorPosRot->pos.z; + *at = focalActorFocus.pos; + // fallthrough + case 1: + // Camera remains still as player moves hands to face + rwData->timer--; + if (rwData->timer <= 0) { + rwData->timer = 0; + camera->animState = 2; + rwData->unk_24 = camera->focalActorPosRot.rot.y + 0x4000; + rwData->timer = 46; + Distortion_Request(DISTORTION_TYPE_MASK_TRANSFORM_1); + Distortion_SetDuration(46); + } + break; + + case 2: + // Camera zooms out while rolling back and forth + rwData->unk_0C = rwData->timer * (180.0f / 23.0f); + sp58 = DEG_TO_RAD(rwData->unk_0C); + sin = sin_rad(sp58); + rwData->unk_0C = ((rwData->unk_10 < 0.0f) ? -1.0f : 1.0f) * sin; + new_var = (46 - rwData->timer) * (5.0f / 46.0f); + focalActorFocus.pos.x = (Math_SinS(rwData->unk_24) * new_var * rwData->unk_0C) + focalActorPosRot->pos.x; + focalActorFocus.pos.z = (Math_CosS(rwData->unk_24) * new_var * rwData->unk_0C) + focalActorPosRot->pos.z; + focalActorFocus.pos.y -= (focalActorFocus.pos.y - camera->focalActorPosRot.pos.y) * 0.2f; + Camera_ScaledStepToCeilVec3f(&focalActorFocus.pos, at, 0.1f, 0.1f, 0.1f); + new_var = rwData->timer * (10.0f / 23.0f); + camera->roll = CAM_DEG_TO_BINANG(rwData->unk_0C * new_var); + new_var = 1.0f / rwData->timer; + atToEye.r = Camera_ScaledStepToCeilF(rwData->unk_14, atToEye.r, new_var, 0.1f); + rwData->timer--; + atToEye.pitch = 0; + if (rwData->timer <= 0) { + camera->animState = 3; + Distortion_RemoveRequest(DISTORTION_TYPE_MASK_TRANSFORM_1); + } + break; + + case 999: + Actor_GetFocus(&focalActorFocus, camera->focalActor); + camera->animState = 3; + Distortion_RemoveRequest(DISTORTION_TYPE_MASK_TRANSFORM_1); + break; + + case 3: + // Player is in new form + focalActorFocus.pos.y -= (focalActorFocus.pos.y - camera->focalActorPosRot.pos.y) * 0.1f; + Camera_ScaledStepToCeilVec3f(&focalActorFocus.pos, at, 0.1f, 0.1f, 0.1f); + camera->roll = 0; + atToEye = rwData->unk_1C; + camera->fov = rwData->unk_18; + break; + } + + OLib_AddVecGeoToVec3f(eyeNext, at, &atToEye); + *eye = *eyeNext; + + return true; +} + +s32 Camera_Demo6(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Demo7(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Demo8(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Demo9(Camera* camera) { + return Camera_Noop(camera); +} + +/** + * Smoothly and gradually return camera to Player after a cutscene + * Used for global actorCsId = 0x7E (Connect Camera Setting) + */ +s32 Camera_Demo0(Camera* camera) { + s32 pad; + f32 timer; + s16 phi_v1; + Camera* subCam = &camera->play->subCameras[2]; + Vec3f* eye = &camera->eye; + Vec3f* subEye = &subCam->eye; + Vec3f* at = &camera->at; + Demo0ReadOnlyData* roData = &camera->paramData.demo0.roData; + Demo0ReadWriteData* rwData = &camera->paramData.demo0.rwData; + + // Initialize + if (camera->animState == 0) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + } + + // Initialize + if (camera->animState == 0) { + OLib_Vec3fDiffToVecGeo(&rwData->subAtToEye, &subCam->at, subEye); + OLib_Vec3fDiffToVecGeo(&rwData->atToEye, &camera->at, eye); + if (rwData->subAtToEye.r < 50.0f) { + rwData->subAtToEye.r = 50.0f; + if (rwData->subAtToEye.pitch < 0x7D0) { // 11 degrees + rwData->subAtToEye.pitch = 0x7D0; + } + } + + rwData->unk_00 = OLib_Vec3fDist(eye, subEye); + if (rwData->unk_00 < 300.0f) { + rwData->timer = 0; + } else { + rwData->timer = sqrtf(rwData->unk_00 - 200.0f); + } + + rwData->unk_14 = subCam->inputDir.x - camera->inputDir.x; + if (rwData->unk_14 >= 0) { + phi_v1 = rwData->unk_14; + } else { + phi_v1 = -rwData->unk_14; + } + + if (phi_v1 > 10000) { + phi_v1 /= 1000; + if (rwData->timer < phi_v1) { + rwData->timer = phi_v1; + } + } + + rwData->unk_16 = subCam->inputDir.y - camera->inputDir.y; + if (rwData->unk_16 >= 0) { + phi_v1 = rwData->unk_16; + } else { + phi_v1 = -rwData->unk_16; + } + + if (phi_v1 > 10000) { + phi_v1 /= 1000; + if (rwData->timer < phi_v1) { + rwData->timer = phi_v1; + } + } + + rwData->unk_18 = subCam->inputDir.z - camera->inputDir.z; + if (rwData->unk_18 >= 0) { + phi_v1 = rwData->unk_18; + } else { + phi_v1 = -rwData->unk_18; + } + + if (phi_v1 > 10000) { + phi_v1 /= 1000; + if (rwData->timer < phi_v1) { + rwData->timer = phi_v1; + } + } + + if (rwData->timer != 0) { + rwData->unk_00 = (rwData->subAtToEye.r - rwData->atToEye.r) / rwData->timer; + rwData->unk_14 = (s16)(rwData->subAtToEye.pitch - rwData->atToEye.pitch) / rwData->timer; + rwData->unk_16 = (s16)(rwData->subAtToEye.yaw - rwData->atToEye.yaw) / rwData->timer; + rwData->unk_18 = (s16)(subCam->roll - camera->roll) / rwData->timer; + } + camera->animState++; + } + + if (rwData->timer != 0) { + timer = rwData->timer; + + // Update At (Inverse Interpolation) + at->x += (subCam->at.x - camera->at.x) / timer; + at->y += (subCam->at.y - camera->at.y) / timer; + at->z += (subCam->at.z - camera->at.z) / timer; + + rwData->atToEye.r += rwData->unk_00; + rwData->atToEye.pitch += rwData->unk_14; + rwData->atToEye.yaw += rwData->unk_16; + + camera->roll += rwData->unk_18; + + // Update Eye + OLib_AddVecGeoToVec3f(eye, at, &rwData->atToEye); + camera->eyeNext = *eye; + + rwData->timer--; + } + + if (rwData->timer == 0) { + CutsceneManager_Stop(0x7E); + } + + return true; +} + +s32 Camera_Special0(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Special1(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Special2(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Special3(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Special4(Camera* camera) { + return Camera_Noop(camera); +} + +/** + * Flying with hookshot + */ +s32 Camera_Special5(Camera* camera) { + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + Vec3f* eyeNext = &camera->eyeNext; + PosRot spA8; + s16 pad1; + s16 spA4; + CameraCollision sp7C; + VecGeo sp74; + VecGeo sp6C; + VecGeo atToEye; + VecGeo atToEyeNext; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + Special5ReadOnlyData* roData = &camera->paramData.spec5.roData; + Special5ReadWriteData* rwData = &camera->paramData.spec5.rwData; + f32 rand; + f32 focalActorHeight = Camera_GetFocalActorHeight(camera); + + if (RELOAD_PARAMS(camera)) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + f32 yNormal = (0.8f - ((68.0f / focalActorHeight) * -0.2f)); + + roData->yOffset = (GET_NEXT_SCALED_RO_DATA(values) * focalActorHeight) * yNormal; + roData->eyeDist = GET_NEXT_RO_DATA(values); + roData->minDistForRot = GET_NEXT_RO_DATA(values); + roData->pitch = CAM_DEG_TO_BINANG(GET_NEXT_RO_DATA(values)); + roData->fovTarget = GET_NEXT_RO_DATA(values); + roData->atMaxLERPScale = GET_NEXT_SCALED_RO_DATA(values); + roData->timerInit = GET_NEXT_RO_DATA(values); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + } + + OLib_Vec3fDiffToVecGeo(&atToEye, at, eye); + OLib_Vec3fDiffToVecGeo(&atToEyeNext, at, eyeNext); + Actor_GetWorld(&spA8, camera->target); + + sCameraInterfaceFlags = roData->interfaceFlags; + + if (camera->animState == 0) { + camera->animState++; + rwData->animTimer = roData->timerInit; + } + + if (rwData->animTimer > 0) { + rwData->animTimer--; + } else if (rwData->animTimer == 0) { + if ((camera->target == NULL) || (camera->target->update == NULL)) { + camera->target = NULL; + return true; + } + + rwData->animTimer--; + if (roData->minDistForRot < OLib_Vec3fDist(&spA8.pos, &focalActorPosRot->pos)) { + sp6C.yaw = focalActorPosRot->rot.y; + sp6C.pitch = -focalActorPosRot->rot.x; + sp6C.r = 20.0f; + OLib_AddVecGeoToVec3f(&sp7C.pos, &spA8.pos, &sp6C); + func_800CBC84(camera, at, &sp7C, 0); + OLib_Vec3fToVecGeo(&sp6C, &sp7C.norm); + spA4 = BINANG_SUB(focalActorPosRot->rot.y, sp6C.yaw); + sp74.r = roData->eyeDist; + rand = Rand_ZeroOne(); + sp74.yaw = BINANG_ROT180(focalActorPosRot->rot.y) + + (s16)(spA4 < 0 ? -(s16)(0x1553 + (s16)(rand * 2730.0f)) : (s16)(0x1553 + (s16)(rand * 2730.0f))); + sp74.pitch = roData->pitch; + OLib_AddVecGeoToVec3f(eyeNext, &spA8.pos, &sp74); + *eye = *eyeNext; + Camera_BgCheck(camera, &spA8.pos, eye); + } + } + + Camera_CalcAtDefault(camera, &atToEyeNext, roData->yOffset, 0); + camera->fov = Camera_ScaledStepToCeilF(roData->fovTarget, camera->fov, camera->atLerpStepScale * 0.05f, 0.1f); + camera->roll = Camera_ScaledStepToCeilS(0, camera->roll, 0.5f, 5); + camera->atLerpStepScale = Camera_ClampLerpScale(camera, roData->atMaxLERPScale); + + return true; +} + +s32 Camera_Special6(Camera* camera) { + return Camera_Noop(camera); +} + +s32 Camera_Special7(Camera* camera) { + return Camera_Noop(camera); +} + +/** + * Exiting a spiral staircase cutscene. + * Camera remains fixed at given position, and tracks player for the duration of the cutscene + */ +s32 Camera_Special8(Camera* camera) { + Vec3f* at = &camera->at; + Vec3f* eyeNext = &camera->eyeNext; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + Vec3f atTarget; + Vec3f posOffsetTarget; + f32 yNormal; + f32 focalActorHeight = Camera_GetFocalActorHeight(camera); + DoorParams* doorParams = &camera->paramData.doorParams; + Special8ReadOnlyData* roData = &camera->paramData.spec8.roData; + Special8ReadWriteData* rwData = &camera->paramData.spec8.rwData; + s32 pad[2]; + + Camera_UnsetStateFlag(camera, CAM_STATE_4); + yNormal = (0.8f - ((68.0f / focalActorHeight) * -0.2f)); + + if (!RELOAD_PARAMS(camera)) { + } else { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + + // Initialize data + roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * focalActorHeight * yNormal; + roData->eyeStepScale = GET_NEXT_SCALED_RO_DATA(values); + roData->posStepScale = GET_NEXT_SCALED_RO_DATA(values); + roData->fov = GET_NEXT_RO_DATA(values); + roData->spiralDoorCsLength = GET_NEXT_RO_DATA(values) * 5; + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + rwData->fov = roData->fov * 100.0f; + rwData->spiralDoorCsFrame = 0; + Camera_UnsetStateFlag(camera, CAM_STATE_2 | CAM_STATE_CHECK_WATER); + rwData->eye.x = doorParams->eye.x; + rwData->eye.y = doorParams->eye.y; + rwData->eye.z = doorParams->eye.z; + } + + // Check if cutscene is still playing + if (rwData->spiralDoorCsFrame < roData->spiralDoorCsLength) { + rwData->spiralDoorCsFrame++; + sCameraInterfaceFlags = roData->interfaceFlags; + posOffsetTarget.x = 0.0f; + posOffsetTarget.y = roData->yOffset + focalActorHeight; + posOffsetTarget.z = 0.0f; + Camera_ScaledStepToCeilVec3f(&posOffsetTarget, &camera->focalActorAtOffset, roData->posStepScale, + roData->posStepScale, 0.1f); + + // Camera follows player as they exit the stairwell + atTarget.x = focalActorPosRot->pos.x + camera->focalActorAtOffset.x; + atTarget.y = focalActorPosRot->pos.y + camera->focalActorAtOffset.y; + atTarget.z = focalActorPosRot->pos.z + camera->focalActorAtOffset.z; + if (camera->animState == 0) { + camera->animState++; + if (!(roData->interfaceFlags & SPECIAL8_FLAG_0)) { + camera->eyeNext = rwData->eye; + camera->at = atTarget; + } + } + + // Update at to look at player + Camera_ScaledStepToCeilVec3f(&atTarget, at, roData->posStepScale, roData->posStepScale, 10.0f); + + // Move camera position &rwData->eye and remain there for the entire cutscen + Camera_ScaledStepToCeilVec3f(&rwData->eye, eyeNext, roData->eyeStepScale, roData->eyeStepScale, 0.1f); + camera->eye = *eyeNext; + camera->dist = OLib_Vec3fDist(at, &camera->eye); + camera->roll = 0; + camera->xzSpeed = 0.0f; + camera->fov = CAM_RODATA_UNSCALE(rwData->fov); + camera->atLerpStepScale = Camera_ClampLerpScale(camera, 1.0f); + Camera_SetFocalActorAtOffset(camera, &focalActorPosRot->pos); + } else { + // Cutscene is finished + Camera_SetStateFlag(camera, CAM_STATE_10 | CAM_STATE_4); + sCameraInterfaceFlags = CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0); + + // Wait for user input to move to the next camera update function + if ((camera->xzSpeed > 0.001f) || CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CUP) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CLEFT) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CRIGHT) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_Z) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_L) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_R) || + (roData->interfaceFlags & SPECIAL8_FLAG_3)) { + func_800CC938(camera); + Camera_SetStateFlag(camera, CAM_STATE_2 | CAM_STATE_CHECK_WATER); + Camera_UnsetStateFlag(camera, CAM_STATE_10); + } + } + return true; +} + +/** + * Entering and exiting a door between rooms (eg. sliding doors) + * Camera closely follows player on both the front and the back room + */ +s32 Camera_Special9(Camera* camera) { + Vec3f* eye = &camera->eye; + Vec3f* at = &camera->at; + s32 rand1; + Vec3f spB8; + VecGeo spB0; + VecGeo spA8; + f32 focalActorHeight; + s32 phi_v1_2; + s16 actorCsId; + f32 yNormal; + PosRot sp84; + Vec3f* eyeNext = &camera->eyeNext; + PosRot* focalActorPosRot = &camera->focalActorPosRot; + DoorParams* doorParams = &camera->paramData.doorParams; + Special9ReadOnlyData* roData = &camera->paramData.spec9.roData; + Special9ReadWriteData* rwData = &camera->paramData.spec9.rwData; + s32 sp50[1]; + BgCamFuncData* bgCamFuncData; + + focalActorHeight = Camera_GetFocalActorHeight(camera); + actorCsId = CutsceneManager_GetCurrentCsId(); + + if ((actorCsId != -1) && (actorCsId != 0x7D)) { + func_800E0348(camera); + } + + Camera_UnsetStateFlag(camera, CAM_STATE_4); + yNormal = 0.8f - ((68.0f / focalActorHeight) * -0.2f); + + if (!RELOAD_PARAMS(camera)) { + } else { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + + roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * focalActorHeight * yNormal; + roData->fov = GET_NEXT_RO_DATA(values); + roData->interfaceFlags = GET_NEXT_RO_DATA(values); + } + + if (doorParams->doorActor != NULL) { + Actor_GetWorldPosShapeRot(&sp84, doorParams->doorActor); + } else { + sp84 = *focalActorPosRot; + sp84.pos.y += focalActorHeight + roData->yOffset; + sp84.rot.x = 0; + } + + OLib_Vec3fDiffToVecGeo(&spA8, at, eye); + + sCameraInterfaceFlags = roData->interfaceFlags; + + switch (camera->animState) { + case 0: + // Init + Camera_UnsetStateFlag(camera, CAM_STATE_2 | CAM_STATE_CHECK_WATER); + camera->animState++; + if (ABS((s16)(focalActorPosRot->rot.y - sp84.rot.y)) > 0x4000) { + rwData->unk_00 = BINANG_ROT180(sp84.rot.y); + } else { + rwData->unk_00 = sp84.rot.y; + } + // fallthrough + case 1: + // Camera is fixed in front of the door + doorParams->timer1--; + if (doorParams->timer1 > 0) { + break; + } + + camera->animState++; + + // Setup for the camera moving behind the door + if (roData->interfaceFlags & SPECIAL9_FLAG_0) { + bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamOrActorCsCamFuncData(camera, camera->bgCamIndex); + Camera_Vec3sToVec3f(eyeNext, &bgCamFuncData->pos); + spB8 = *eye = *eyeNext; + } else { + s16 camEyeSide; + s16 randFloat; + + spB0.pitch = ((s16)(Rand_ZeroOne() * 0x280) + 0xBB8); + randFloat = ((s16)(Rand_ZeroOne() * 0x4CE) + 0x5DC); + + // The camera will either position itself either to the left or to the right + // of the door when it jumps behind it. It's effectively 50/50 percent chance + camEyeSide = (s16)(randFloat * ((camera->play->state.frames % 2) ? 1 : -1)); + + spB0.yaw = rwData->unk_00 + camEyeSide; + spB0.r = 200.0f * yNormal; + OLib_AddVecGeoToVec3f(eyeNext, at, &spB0); + spB8 = *eye = *eyeNext; + + // If the side chosen moves the camera out-of-bounds, move to the other side + if (Camera_CheckOOB(camera, &spB8, &focalActorPosRot->pos)) { + camEyeSide = (s16)-camEyeSide; + spB0.yaw = rwData->unk_00 + camEyeSide; + OLib_AddVecGeoToVec3f(eyeNext, at, &spB0); + *eye = *eyeNext; + } + } + // fallthrough + case 2: + // Camera is behind the door looking at player + spB8 = focalActorPosRot->pos; + spB8.y += focalActorHeight + roData->yOffset; + // Update camera at to follow the player + Camera_ScaledStepToCeilVec3f(&spB8, at, 0.25f, 0.25f, 0.1f); + + doorParams->timer2--; + if (doorParams->timer2 > 0) { + break; + } + + // Setup for the camera turning around to look in front of player + camera->animState++; + rwData->unk_00 = BINANG_ROT180(rwData->unk_00); + // fallthrough + case 3: + // Camera turns around to look in front of player + spB8 = focalActorPosRot->pos; + spB8.y += focalActorHeight + roData->yOffset; + Camera_ScaledStepToCeilVec3f(&spB8, at, 0.5f, 0.5f, 0.1f); + spB0.pitch = Camera_ScaledStepToCeilS(0xAAA, spA8.pitch, 0.3f, 5); + spB0.yaw = Camera_ScaledStepToCeilS(rwData->unk_00, spA8.yaw, 0.3f, 5); + spB0.r = Camera_ScaledStepToCeilF(60.0f, spA8.r, 0.3f, 1.0f); + OLib_AddVecGeoToVec3f(eyeNext, at, &spB0); + + *eye = *eyeNext; + + doorParams->timer3--; + if (doorParams->timer3 > 0) { + break; + } + + camera->animState++; + // fallthrough + case 4: + camera->animState++; + // fallthrough + case 999: + default: + // Door is closed and is waiting for user input to toggle to a new setting + Camera_SetStateFlag(camera, CAM_STATE_10 | CAM_STATE_4); + sCameraInterfaceFlags = CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0); + + if ((camera->xzSpeed > 0.001f) || CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CUP) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CDOWN) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CLEFT) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CRIGHT) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_Z) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_L) || + CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_R) || + (roData->interfaceFlags & SPECIAL9_FLAG_3)) { + + func_800CC938(camera); + Camera_SetStateFlag(camera, CAM_STATE_2 | CAM_STATE_CHECK_WATER); + Camera_UnsetStateFlag(camera, CAM_STATE_10); + } + break; + } + + spB8 = focalActorPosRot->pos; + spB8.y += focalActorHeight; + camera->dist = OLib_Vec3fDist(&spB8, eye); + Camera_SetFocalActorAtOffset(camera, &focalActorPosRot->pos); + + return true; +} + +/*===============================================================*/ +/* Camera Public Functions */ +/*===============================================================*/ + +Camera* Camera_Create(View* view, CollisionContext* colCtx, PlayState* play) { + Camera* newCamera = ZeldaArena_Malloc(sizeof(Camera)); + + if (newCamera != NULL) { + Camera_Init(newCamera, view, colCtx, play); + } + return newCamera; +} + +void Camera_Destroy(Camera* camera) { + if (camera != NULL) { + ZeldaArena_Free(camera); + } +} + +void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState* play) { + Camera* cameraPtr; + s32 i; + s16 curUID; + s16 j; + + __osMemset(camera, 0, sizeof(Camera)); + + camera->play = sCamPlayState = play; + curUID = sCameraNextUID; + sCameraNextUID++; + while (curUID != 0) { + if (curUID == 0) { + sCameraNextUID++; + } + + for (j = 0; j < NUM_CAMS; j++) { + cameraPtr = camera->play->cameraPtrs[j]; + if ((cameraPtr != NULL) && (curUID == cameraPtr->uid)) { + break; + } + } + + if (j == NUM_CAMS) { + break; + } + + curUID = sCameraNextUID++; + } + + camera->inputDir.y = 0x4000; + camera->uid = curUID; + camera->camDir = camera->inputDir; + camera->nextCamSceneDataId = -1; + camera->up.z = camera->up.x = 0.0f; + camera->up.y = 1.0f; + camera->fov = 60.0f; + camera->yOffsetUpdateRate = 0.05f; + camera->xzOffsetUpdateRate = 0.05f; + camera->fovUpdateRate = 0.05f; + camera->rUpdateRateInv = 10.0f; + camera->yawUpdateRateInv = 10.0f; + camera->pitchUpdateRateInv = 16.0f; + + sCameraLetterboxSize = 32; + sCameraHudVisibility = 0; + + camera->setting = camera->prevSetting = CAM_SET_FREE0; + camera->bgCamIndex = camera->prevBgCamDataId = -1; + camera->stateFlags = 0; + camera->mode = CAM_MODE_NORMAL; + camera->bgId = BGCHECK_SCENE; + camera->unk168 = 0xF; + camera->timer = -1; + camera->focalActor = NULL; + camera->target = NULL; + Camera_SetStateFlag(camera, CAM_STATE_INITIALIZED); + camera->quakeOffset.z = camera->quakeOffset.y = camera->quakeOffset.x = 0; + camera->up.z = camera->up.x = 0.0f; + camera->atLerpStepScale = 1; + camera->up.y = 1.0f; + sCameraInterfaceFlags = CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, 0); + sCameraInitSceneTimer = 3; +} + +void func_800DDFE0(Camera* camera) { + if (camera != &camera->play->mainCamera) { + camera->prevSetting = camera->setting = CAM_SET_FREE0; + Camera_UnsetStateFlag(camera, CAM_STATE_2); + } else { + switch (camera->play->roomCtx.curRoom.behaviorType1) { + case ROOM_BEHAVIOR_TYPE1_1: + camera->prevSetting = CAM_SET_DUNGEON0; + Camera_ChangeSettingFlags(camera, CAM_SET_DUNGEON0, CAM_CHANGE_SETTING_1); + break; + + case ROOM_BEHAVIOR_TYPE1_0: + camera->prevSetting = CAM_SET_NORMAL0; + Camera_ChangeSettingFlags(camera, CAM_SET_NORMAL0, CAM_CHANGE_SETTING_1); + break; + + case ROOM_BEHAVIOR_TYPE1_2: + camera->prevSetting = CAM_SET_ROOM0; + Camera_ChangeSettingFlags(camera, CAM_SET_ROOM0, CAM_CHANGE_SETTING_1); + break; + + default: + camera->prevSetting = CAM_SET_NORMAL0; + Camera_ChangeSettingFlags(camera, CAM_SET_NORMAL0, CAM_CHANGE_SETTING_1); + break; + } + Camera_SetStateFlag(camera, CAM_STATE_2); + } +} + +/** + * Unused empty function + */ +void Camera_Stub800DE0E0(Camera* camera) { +} + +void Camera_InitFocalActorSettings(Camera* camera, Actor* focalActor) { + PosRot focalActorPosRot; + VecGeo eyeNextAtOffset; + s32 bgId; + Vec3f floorPos; + s32 upXZ; + f32 focalActorHeight; + Vec3f* eye = &camera->eye; + + Actor_GetWorldPosShapeRot(&focalActorPosRot, focalActor); + + camera->focalActor = focalActor; + focalActorHeight = Camera_GetFocalActorHeight(camera); + camera->focalActorPosRot = focalActorPosRot; + camera->dist = eyeNextAtOffset.r = 180.0f; + camera->inputDir.y = focalActorPosRot.rot.y; + eyeNextAtOffset.yaw = BINANG_ROT180(camera->inputDir.y); + camera->inputDir.x = eyeNextAtOffset.pitch = 0x71C; + camera->inputDir.z = 0; + camera->camDir = camera->inputDir; + camera->xzSpeed = 0.0f; + camera->unk_0F0.y = 0.0f; + camera->at = focalActorPosRot.pos; + camera->at.y += focalActorHeight; + + camera->focalActorAtOffset.x = 0; + camera->focalActorAtOffset.y = focalActorHeight; + camera->focalActorAtOffset.z = 0; + + OLib_AddVecGeoToVec3f(&camera->eyeNext, &camera->at, &eyeNextAtOffset); + *eye = camera->eyeNext; + camera->roll = 0; + + upXZ = 0; + camera->up.z = upXZ; + camera->up.y = 1.0f; + camera->up.x = upXZ; + + { + s32 pad; + + if (Camera_GetFloorYNorm(camera, &floorPos, &camera->at, &bgId) != BGCHECK_Y_MIN) { + camera->bgId = bgId; + } + } + + camera->waterPrevBgCamDataId = -1; + camera->waterPrevCamSetting = -1; + camera->waterQuakeId = -1; + + { + s32 pad; + + func_800DDFE0(camera); + } + + Camera_SetStateFlag(camera, CAM_STATE_2); + + camera->viewFlags = 0; + camera->nextCamSceneDataId = -1; + camera->yOffsetUpdateRate = 0.01f; + camera->xzOffsetUpdateRate = 0.01f; + camera->fovUpdateRate = 0.01f; + camera->atLerpStepScale = 1; + Camera_ResetActionFuncState(camera, camera->mode); + + if (camera == &camera->play->mainCamera) { + sCameraInterfaceFlags = + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_LARGE | CAM_LETTERBOX_INSTANT, CAM_HUD_VISIBILITY_NONE_ALT, 0); + CutsceneManager_StoreCamera(camera); + } else { + sCameraInterfaceFlags = CAM_INTERFACE_FLAGS(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_NONE_ALT, 0); + } + Camera_UpdateWater(camera); +} + +/** + * Updates the camera status + */ +s32 Camera_ChangeStatus(Camera* camera, s16 status) { + camera->status = status; + return camera->status; +} + +s32 Camera_UpdateWater(Camera* camera) { + f32 waterY; + s16 camSetting; + s32 pad[2]; + s32* waterPrevCamSetting = &camera->waterPrevCamSetting; + s16 prevBgId; + + if (!(camera->stateFlags & CAM_STATE_CHECK_WATER) || (sCameraSettings[camera->setting].flags & 0x40000000)) { + return false; + } + + if (camera->stateFlags & CAM_STATE_9) { + if (Camera_IsDiving(camera)) { + if (!Camera_IsPlayerFormZora(camera)) { + Camera_ChangeSettingFlags(camera, CAM_SET_PIVOT_DIVING, CAM_CHANGE_SETTING_2 | CAM_CHANGE_SETTING_1); + } else { + Camera_ChangeSettingFlags(camera, CAM_SET_ZORA_DIVING, CAM_CHANGE_SETTING_2 | CAM_CHANGE_SETTING_1); + } + Camera_SetStateFlag(camera, CAM_STATE_15); + } else if (camera->stateFlags & CAM_STATE_15) { + Camera_ChangeSettingFlags(camera, *waterPrevCamSetting, CAM_CHANGE_SETTING_2 | CAM_CHANGE_SETTING_1); + Camera_UnsetStateFlag(camera, CAM_STATE_15); + } + } + + if (!(camera->stateFlags & CAM_STATE_15)) { + camSetting = Camera_GetWaterBoxBgCamSetting(camera, &waterY); + if (camSetting == -2) { + // CAM_SET_NONE + if (!(camera->stateFlags & CAM_STATE_9)) { + Camera_SetStateFlag(camera, CAM_STATE_9); + camera->waterPrevBgCamDataId = camera->bgCamIndex; + camera->waterQuakeId = -1; + } + + if (!(Camera_fabsf(camera->focalActorPosRot.pos.y - camera->focalActorFloorHeight) < 11.0f) || + (Camera_IsSwimming(camera) && !Camera_IsUnderwaterAsZora(camera))) { + prevBgId = camera->bgId; + camera->bgId = BGCHECK_SCENE; + waterPrevCamSetting = &camera->waterPrevCamSetting; + Camera_ChangeSettingFlags(camera, CAM_SET_NORMAL3, CAM_CHANGE_SETTING_1); + *waterPrevCamSetting = camera->setting; + camera->bgId = prevBgId; + camera->bgCamIndex = -2; + } + + } else if (camSetting != -1) { + // player is in a water box + if (!(camera->stateFlags & CAM_STATE_9)) { + Camera_SetStateFlag(camera, CAM_STATE_9); + camera->waterPrevBgCamDataId = camera->bgCamIndex; + camera->waterQuakeId = -1; + } + + if (!(Camera_fabsf(camera->focalActorPosRot.pos.y - camera->focalActorFloorHeight) < 11.0f) || + (Camera_IsSwimming(camera) && !Camera_IsUnderwaterAsZora(camera))) { + prevBgId = camera->bgId; + camera->bgId = BGCHECK_SCENE; + waterPrevCamSetting = &camera->waterPrevCamSetting; + Camera_ChangeSettingFlags(camera, camSetting, CAM_CHANGE_SETTING_1); + *waterPrevCamSetting = camera->setting; + camera->bgId = prevBgId; + } + + } else if (camera->stateFlags & CAM_STATE_9) { + // player is out of a water box. + Camera_UnsetStateFlag(camera, CAM_STATE_9); + prevBgId = camera->bgId; + camera->bgId = BGCHECK_SCENE; + if (camera->waterPrevBgCamDataId < 0) { + func_800DDFE0(camera); + camera->bgCamIndex = -1; + } else { + Camera_ChangeActorCsCamIndex(camera, camera->waterPrevBgCamDataId); + } + camera->bgId = prevBgId; + } + camera->waterYPos = waterY; + } + return true; +} + +void Camera_EarthquakeDay3(Camera* camera) { + static s16 sEarthquakeTimer = 0; + u16 time; + s16 quakeIndex; + s32 timeSpeedOffset; + s16 sEarthquakeFreq[] = { + 0xFFC, // 1 Large Earthquake between CLOCK_TIME(0, 00) to CLOCK_TIME(1, 30) + 0x7FC, // 2 Large Earthquakes between CLOCK_TIME(1, 30) to CLOCK_TIME(3, 00) + 0x3FC, // 4 Large Earthquakes between CLOCK_TIME(3, 00) to CLOCK_TIME(4, 30) + 0x1FC, // 8 Large Earthquakes between CLOCK_TIME(4, 30) to CLOCK_TIME(6, 00) + }; + + if ((CURRENT_DAY == 3) && (CutsceneManager_GetCurrentCsId() == -1)) { + time = gSaveContext.save.time; + timeSpeedOffset = gSaveContext.save.timeSpeedOffset; + + // Large earthquake created + // Times based on sEarthquakeFreq + if ((time > CLOCK_TIME(0, 0)) && (time < CLOCK_TIME(6, 0)) && ((sEarthquakeFreq[time >> 12] & time) == 0) && + (Quake_GetNumActiveQuakes() < 2)) { + quakeIndex = Quake_Request(camera, QUAKE_TYPE_4); + if (quakeIndex != 0) { + Quake_SetSpeed(quakeIndex, 30000); + Quake_SetPerturbations(quakeIndex, (time >> 12) + 2, 1, 5, 60); + sEarthquakeTimer = ((time >> 10) - timeSpeedOffset) + 80; + Quake_SetDuration(quakeIndex, sEarthquakeTimer); + } + } + + // Small earthquake created + // Around CLOCK_TIME(17, 33) || Around CLOCK_TIME(20, 33) || Every 1024 frames (around every 51s) + if (((((time + 0x4D2) & 0xDFFC) == 0xC000) || ((camera->play->state.frames % 1024) == 0)) && + (Quake_GetNumActiveQuakes() < 2)) { + quakeIndex = Quake_Request(camera, QUAKE_TYPE_3); + if (quakeIndex != 0) { + Quake_SetSpeed(quakeIndex, 16000); + Quake_SetPerturbations(quakeIndex, 1, 0, 0, time & 0x3F); // %64 + sEarthquakeTimer = 120 - timeSpeedOffset; + Quake_SetDuration(quakeIndex, sEarthquakeTimer); + } + } + + if (sEarthquakeTimer != 0) { + sEarthquakeTimer--; + func_8019F128(NA_SE_SY_EARTHQUAKE_OUTDOOR - SFX_FLAG); + } + } +} + +/** + * Sets the distortion to type 1 for a hot room + * Remnant of OoT as no room in any MM scene is set to a hot-room + */ +s32 Camera_UpdateHotRoom(Camera* camera) { + Distortion_RemoveRequest(DISTORTION_TYPE_HOT_ROOM); + if (camera->play->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_HOT) { + Distortion_Request(DISTORTION_TYPE_HOT_ROOM); + } + return true; +} + +s32 Camera_SetSwordDistortion(Camera* camera) { + switch (func_800CBB88(camera)) { + case 1: + // non-magic spin attack + if (Distortion_GetType() != DISTORTION_TYPE_ZORA_KICK) { + Distortion_Request(DISTORTION_TYPE_ZORA_KICK); + Distortion_SetDuration(12); + } + break; + + case 2: + // Unused: case 2 is impossible to achieve + if (Distortion_GetType() != DISTORTION_TYPE_UNK_ATTACK) { + Distortion_Request(DISTORTION_TYPE_UNK_ATTACK); + Distortion_SetDuration(5); + } + break; + + case 3: + if (Distortion_GetType() != DISTORTION_TYPE_GORON_BUTT) { + Distortion_Request(DISTORTION_TYPE_GORON_BUTT); + Distortion_SetDuration(15); + } + break; + } + return true; +} + +s32 Camera_RequestGiantsMaskSetting(Camera* camera) { + Player* player = GET_PLAYER(camera->play); + + if ((camera->camId == CAM_ID_MAIN) && (camera->focalActor == &GET_PLAYER(camera->play)->actor) && + (player->currentMask == PLAYER_MASK_GIANT)) { + Camera_ChangeSettingFlags(camera, CAM_SET_GIANT, CAM_CHANGE_SETTING_1); + return true; + } else { + return false; + } +} + +Vec3s* Camera_Update(Vec3s* inputDir, Camera* camera) { + Vec3f viewAt; + Vec3f viewEye; + Vec3f viewUp; + Vec3f focalActorPos; + s32 bgId; + s32 sp98; + s32 changeCamSceneDataType; + CollisionPoly* sp90; + CollisionPoly* sp8C; + f32 runSpeedLimit; + f32 speed; + f32 viewFov; + DynaPolyActor* meshActor; + PosRot focalActorPosRot; + ShakeInfo camShake; + Actor* focalActor = camera->focalActor; + VecGeo sp3C; + s16 bgCamIndex; + s16 numQuakesApplied; + f32 focalActorFloorHeight; + + // Camera of status CUT only updates to this point + if (camera->status == CAM_STATUS_CUT) { + *inputDir = camera->inputDir; + return inputDir; + } + + sUpdateCameraDirection = false; + sIsFalse = false; + + if (camera->play->view.unk164 == 0) { + if (camera->focalActor != NULL) { + // Updates camera info on the actor it's tracking + + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + Actor_GetWorldPosShapeRot(&focalActorPosRot, camera->focalActor); + } else { + Actor_GetWorld(&focalActorPosRot, camera->focalActor); + } + camera->unk_0F0.x = focalActorPosRot.pos.x - camera->focalActorPosRot.pos.x; + camera->unk_0F0.y = focalActorPosRot.pos.y - camera->focalActorPosRot.pos.y; + camera->unk_0F0.z = focalActorPosRot.pos.z - camera->focalActorPosRot.pos.z; + + // bg related to tracked actor + sp98 = 0; + if (Camera_IsMountedOnHorse(camera)) { + if (((Player*)focalActor)->rideActor->floorPoly != NULL) { + sp90 = ((Player*)focalActor)->rideActor->floorPoly; + camera->bgId = ((Player*)focalActor)->rideActor->floorBgId; + camera->focalActorFloorHeight = ((Player*)focalActor)->rideActor->floorHeight; + sp98 = 3; + } + } else if (func_800CB7CC(camera)) { + if (camera->focalActor->floorPoly != NULL) { + sp90 = camera->focalActor->floorPoly; + camera->bgId = camera->focalActor->floorBgId; + camera->focalActorFloorHeight = camera->focalActor->floorHeight; + sp98 = 1; + } + } else { + focalActorPos = focalActorPosRot.pos; + focalActorPos.y += Camera_GetFocalActorHeight(camera); + focalActorFloorHeight = BgCheck_EntityRaycastFloor5_3(camera->play, &camera->play->colCtx, &sp90, &bgId, + camera->focalActor, &focalActorPos); + if (focalActorFloorHeight != BGCHECK_Y_MIN) { + camera->bgId = bgId; + camera->focalActorFloorHeight = focalActorFloorHeight; + sp98 = 2; + } + } + + if ((sp98 != 0) && (Camera_fabsf(camera->focalActorPosRot.pos.y - camera->focalActorFloorHeight) < 11.0f)) { + meshActor = DynaPoly_GetActor(&camera->play->colCtx, camera->bgId); + if (meshActor != NULL) { + camera->floorNorm.x = COLPOLY_GET_NORMAL(sp90->normal.x); + camera->floorNorm.y = COLPOLY_GET_NORMAL(sp90->normal.y); + camera->floorNorm.z = COLPOLY_GET_NORMAL(sp90->normal.z); + camera->unk_0F0.x -= meshActor->actor.world.pos.x - camera->meshActorPos.x; + camera->unk_0F0.y -= meshActor->actor.world.pos.y - camera->meshActorPos.y; + camera->unk_0F0.z -= meshActor->actor.world.pos.z - camera->meshActorPos.z; + camera->meshActorPos = meshActor->actor.world.pos; + } + } + + // Set camera speed + runSpeedLimit = Camera_GetRunSpeedLimit(camera) * 1.5f; + speed = Camera_Vec3fMagnitude(&camera->unk_0F0); + camera->xzSpeed = OLib_ClampMaxDist(speed, runSpeedLimit); + camera->speedRatio = OLib_ClampMaxDist(speed / runSpeedLimit, 1.8f); + camera->focalActorPosRot = focalActorPosRot; + + if (camera->camId == CAM_ID_MAIN) { + Camera_UpdateWater(camera); + Camera_UpdateHotRoom(camera); + Camera_EarthquakeDay3(camera); + Camera_SetSwordDistortion(camera); + } + + /** + * This section is about updating the camera setting based on the camera scene data + * + */ + + // If doorTimer1 is active, set CAM_STATE_10 which suppresses bg camera scene data from being read + if (camera->doorTimer1 != 0) { + Camera_SetStateFlag(camera, CAM_STATE_10); + } else if (!(camera->stateFlags & CAM_STATE_2)) { + camera->nextCamSceneDataId = -1; + } + + changeCamSceneDataType = 0; // default to no change in the cam scene data + bgId = camera->bgId; + + // Sets the next cam scene data Index based on the bg surface + if ((camera->stateFlags & CAM_STATE_0) && (camera->stateFlags & CAM_STATE_2) && + !(camera->stateFlags & CAM_STATE_10) && + (!(camera->stateFlags & CAM_STATE_9) || Camera_IsUnderwaterAsZora(camera)) && + !(camera->stateFlags & CAM_STATE_15) && !Camera_IsMountedOnHorse(camera) && + !Camera_RequestGiantsMaskSetting(camera) && !Camera_IsDekuHovering(camera) && (sp98 != 0)) { + + bgCamIndex = Camera_GetBgCamIndex(camera, &bgId, sp90); + if ((bgCamIndex != -1) && (camera->bgId == BGCHECK_SCENE)) { + if (Camera_IsUsingZoraFins(camera) == 0) { + camera->nextCamSceneDataId = bgCamIndex | CAM_DATA_IS_BG; + } + } + + focalActorPos = focalActorPosRot.pos; + focalActorPos.y += Camera_GetFocalActorHeight(camera); + focalActorFloorHeight = + BgCheck_CameraRaycastFloor2(&camera->play->colCtx, &sp8C, &bgId, &focalActorPos); + + if ((focalActorFloorHeight != BGCHECK_Y_MIN) && (sp8C != sp90) && (bgId == BGCHECK_SCENE) && + ((camera->focalActorFloorHeight - 2.0f) < focalActorFloorHeight)) { + bgCamIndex = Camera_GetBgCamIndex(camera, &bgId, sp8C); + if ((bgCamIndex != -1) && (bgId == BGCHECK_SCENE)) { + camera->nextCamSceneDataId = bgCamIndex | CAM_DATA_IS_BG; + changeCamSceneDataType = 1; // change cam scene data based on the bg cam data + } + } + } + + if (camera->doorTimer1 != 0) { + camera->doorTimer1--; + if (camera->doorTimer1 == 0) { + Camera_UnsetStateFlag(camera, CAM_STATE_10); + changeCamSceneDataType = 5; // change cam scene data based on the cutscene cam data + } + } + + if (((camera->camId == CAM_ID_MAIN) || (camera->stateFlags & CAM_STATE_6)) && + ((camera->bgId == BGCHECK_SCENE) || ((bgId == BGCHECK_SCENE) && (changeCamSceneDataType != 0))) && + (camera->nextCamSceneDataId != -1) && (camera->doorTimer1 == 0) && + ((Camera_fabsf(camera->focalActorPosRot.pos.y - camera->focalActorFloorHeight) < 11.0f) || + (changeCamSceneDataType != 0)) && + (!(camera->stateFlags & CAM_STATE_9) || Camera_IsUnderwaterAsZora(camera))) { + + Camera_ChangeActorCsCamIndex(camera, camera->nextCamSceneDataId); + camera->nextCamSceneDataId = -1; + if (camera->doorTimer2 != 0) { + camera->doorTimer1 = camera->doorTimer2; + camera->doorTimer2 = 0; + } + } + } + + // Camera of status WAIT only updates to this point + if (camera->status == CAM_STATUS_WAIT) { + *inputDir = camera->inputDir; + return inputDir; + } + + camera->behaviorFlags = 0; + Camera_UnsetStateFlag(camera, CAM_STATE_10 | CAM_STATE_DISABLE_MODE_CHANGE); + Camera_SetStateFlag(camera, CAM_STATE_4); + } + + // Call the camera update function + sCameraUpdateHandlers[sCameraSettings[camera->setting].cameraModes[camera->mode].funcId](camera); + + // Update the interface + if (sCameraInitSceneTimer != 0) { + sCameraInitSceneTimer--; + } + if (camera->status == CAM_STATUS_ACTIVE) { + if (((sCameraInitSceneTimer != 0) || func_800CB854(camera)) && (camera->camId == CAM_ID_MAIN)) { + // Surpresses the interface for the first few frames of a scene + sCameraInterfaceFlags = CAM_INTERFACE_FLAGS(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_NONE_ALT, 0); + Camera_UpdateInterface(sCameraInterfaceFlags); + } else if ((camera->play->transitionMode != TRANS_MODE_OFF) && (camera->camId != CAM_ID_MAIN)) { + sCameraInterfaceFlags = CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, 0); + Camera_UpdateInterface(sCameraInterfaceFlags); + } else { + Camera_UpdateInterface(sCameraInterfaceFlags); + } + } + + // Camera of status UNK3 only updates to this point + if (camera->status == CAM_STATUS_UNK3) { + *inputDir = camera->inputDir; + return inputDir; + } + + /** + * This section is about updating view structs from the active camera, + * which view uses to calculate the viewing/projection matrices + */ + numQuakesApplied = Quake_Update(camera, &camShake); + + bgId = numQuakesApplied; // required to match + + if (numQuakesApplied != 0) { + viewAt.x = camera->at.x + camShake.atOffset.x; + viewAt.y = camera->at.y + camShake.atOffset.y; + viewAt.z = camera->at.z + camShake.atOffset.z; + viewEye.x = camera->eye.x + camShake.eyeOffset.x; + viewEye.y = camera->eye.y + camShake.eyeOffset.y; + viewEye.z = camera->eye.z + camShake.eyeOffset.z; + OLib_Vec3fDiffToVecGeo(&sp3C, &viewEye, &viewAt); + Camera_CalcUpVec(&viewUp, sp3C.pitch, sp3C.yaw, camera->roll + camShake.upRollOffset); + viewFov = camera->fov + CAM_BINANG_TO_DEG(camShake.fovOffset); + } else if (sIsFalse) { + //! condition is impossible to achieve + viewAt = camera->at; + viewEye = camera->eye; + OLib_Vec3fDiffToVecGeo(&sp3C, &viewEye, &viewAt); + viewUp = camera->up; + viewFov = camera->fov; + } else { + viewAt = camera->at; + viewEye = camera->eye; + OLib_Vec3fDiffToVecGeo(&sp3C, &viewEye, &viewAt); + Camera_CalcUpVec(&viewUp, sp3C.pitch, sp3C.yaw, camera->roll); + viewFov = camera->fov; + } + + // set view up + if (camera->viewFlags & CAM_VIEW_UP) { + camera->viewFlags &= ~CAM_VIEW_UP; + viewUp = camera->up; + } else { + camera->up = viewUp; + } + + camera->quakeOffset = camShake.eyeOffset; + View_SetScale(&camera->play->view, (OREG(67) * 0.01f) + 1.0f); + camera->play->view.fovy = viewFov; + View_LookAt(&camera->play->view, &viewEye, &viewAt, &viewUp); + camera->camDir.x = sp3C.pitch; + camera->camDir.y = sp3C.yaw; + camera->camDir.z = 0; + + if (!sUpdateCameraDirection) { + camera->inputDir.x = sp3C.pitch; + camera->inputDir.y = sp3C.yaw; + camera->inputDir.z = 0; + } + + *inputDir = camera->inputDir; + + return inputDir; +} + +s32 func_800DF498(Camera* camera) { + Camera_SetStateFlag(camera, CAM_STATE_3 | CAM_STATE_2); // CAM_STATE_3 is set only immediately to be unset + Camera_UnsetStateFlag(camera, CAM_STATE_12 | CAM_STATE_3); + return true; +} + +#define CAM_CHANGE_MODE_0 (1 << 0) +#define CAM_CHANGE_MODE_1 (1 << 1) +#define CAM_CHANGE_MODE_BATTLE (1 << 2) +#define CAM_CHANGE_MODE_FOLLOW_TARGET (1 << 3) +#define CAM_CHANGE_MODE_4 (1 << 4) +#define CAM_CHANGE_MODE_FIRST_PERSON (1 << 5) + +s32 Camera_ChangeModeFlags(Camera* camera, s16 mode, u8 forceChange) { + static s32 sModeChangeFlags = 0; + + if ((camera->setting == CAM_SET_TELESCOPE) && ((mode == CAM_MODE_FIRSTPERSON) || (mode == CAM_MODE_DEKUHIDE))) { + forceChange = true; + } + + // Mode change rejected by flag + if ((camera->stateFlags & CAM_STATE_DISABLE_MODE_CHANGE) && !forceChange) { + camera->behaviorFlags |= CAM_BEHAVIOR_MODE_VALID; + return -1; + } + + // Mode change rejected by validModes + if (!(sCameraSettings[camera->setting].validModes & (1 << mode))) { + if (camera->mode != CAM_MODE_NORMAL) { + camera->mode = CAM_MODE_NORMAL; + Camera_ResetActionFuncState(camera, camera->mode); + func_800DF498(camera); + return mode | 0xC0000000; + } else { + camera->behaviorFlags |= CAM_BEHAVIOR_MODE_VALID; + camera->behaviorFlags |= CAM_BEHAVIOR_MODE_1; + return 0; + } + } + + // Mode change rejected due to mode already being set. (otherwise, reset mode) + if ((mode == camera->mode) && !forceChange) { + camera->behaviorFlags |= CAM_BEHAVIOR_MODE_VALID; + return -1; + } + + camera->behaviorFlags |= CAM_BEHAVIOR_MODE_VALID; + camera->behaviorFlags |= CAM_BEHAVIOR_MODE_1; + + Camera_ResetActionFuncState(camera, mode); + + sModeChangeFlags = 0; + + // Process Requested Camera Mode + switch (mode) { + case CAM_MODE_FIRSTPERSON: + sModeChangeFlags = CAM_CHANGE_MODE_FIRST_PERSON; + break; + + case CAM_MODE_BATTLE: + sModeChangeFlags = CAM_CHANGE_MODE_BATTLE; + break; + + case CAM_MODE_FOLLOWTARGET: + if (camera->target != NULL && camera->target->id != ACTOR_EN_BOOM) { + sModeChangeFlags = CAM_CHANGE_MODE_FOLLOW_TARGET; + } + break; + + case CAM_MODE_BOWARROWZ: + case CAM_MODE_TARGET: + case CAM_MODE_TALK: + case CAM_MODE_HANGZ: + case CAM_MODE_PUSHPULL: + sModeChangeFlags = CAM_CHANGE_MODE_1; + break; + + case CAM_MODE_NORMAL: + case CAM_MODE_HANG: + sModeChangeFlags = CAM_CHANGE_MODE_4; + break; + } + + // Process Current Camera Mode + switch (camera->mode) { + case CAM_MODE_FIRSTPERSON: + if (sModeChangeFlags & CAM_CHANGE_MODE_FIRST_PERSON) { + camera->animState = 10; + } + break; + + case CAM_MODE_JUMP: + case CAM_MODE_HANG: + if (sModeChangeFlags & CAM_CHANGE_MODE_4) { + camera->animState = 20; + } + sModeChangeFlags |= CAM_CHANGE_MODE_0; + break; + + case CAM_MODE_CHARGE: + if (sModeChangeFlags & CAM_CHANGE_MODE_4) { + camera->animState = 20; + } + sModeChangeFlags |= CAM_CHANGE_MODE_0; + break; + + case CAM_MODE_FOLLOWTARGET: + if (sModeChangeFlags & CAM_CHANGE_MODE_FOLLOW_TARGET) { + camera->animState = 10; + } + sModeChangeFlags |= CAM_CHANGE_MODE_0; + break; + + case CAM_MODE_BATTLE: + if (sModeChangeFlags & CAM_CHANGE_MODE_BATTLE) { + camera->animState = 10; + } + sModeChangeFlags |= 1; + break; + + case CAM_MODE_BOWARROWZ: + case CAM_MODE_HANGZ: + case CAM_MODE_PUSHPULL: + sModeChangeFlags |= CAM_CHANGE_MODE_0; + break; + + case CAM_MODE_NORMAL: + if (sModeChangeFlags & CAM_CHANGE_MODE_4) { + camera->animState = 20; + } + break; + + default: + break; + } + + sModeChangeFlags &= ~CAM_CHANGE_MODE_4; + + // Z-Pressing Sfx + if (camera->status == CAM_STATUS_ACTIVE) { + switch (sModeChangeFlags) { + case CAM_CHANGE_MODE_0: + play_sound(0); + break; + + case CAM_CHANGE_MODE_1: + if (camera->play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_1) { + play_sound(NA_SE_SY_ATTENTION_URGENCY); + } else { + + play_sound(NA_SE_SY_ATTENTION_ON); + } + break; + + case CAM_CHANGE_MODE_BATTLE: + play_sound(NA_SE_SY_ATTENTION_URGENCY); + break; + + case CAM_CHANGE_MODE_FOLLOW_TARGET: + play_sound(NA_SE_SY_ATTENTION_ON); + break; + + default: + break; + } + } + + func_800DF498(camera); + camera->mode = mode; + + return mode | 0x80000000; +} + +s32 Camera_ChangeMode(Camera* camera, s16 mode) { + return Camera_ChangeModeFlags(camera, mode, false); +} + +s32 Camera_CheckValidMode(Camera* camera, s16 mode) { + if (camera->stateFlags & CAM_STATE_DISABLE_MODE_CHANGE) { + return 0; + } else if (!(sCameraSettings[camera->setting].validModes & (1 << mode))) { + return 0; + } else if (mode == camera->mode) { + return -1; + } else { + return mode | 0x80000000; + } +} + +s16 Camera_ChangeSettingFlags(Camera* camera, s16 setting, s16 flags) { + // Reject settings change based on priority + if ((camera->behaviorFlags & CAM_BEHAVIOR_SETTING_USE_PRIORITY) && + ((sCameraSettings[camera->setting].flags & 0xF) >= (sCameraSettings[setting].flags & 0xF))) { + camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_2; + if (!(flags & CAM_CHANGE_SETTING_1)) { + camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_USE_PRIORITY; + } + return -2; + } + + // Reject settings change based on NONE setting + if (setting == CAM_SET_NONE) { + return 0; + } + + // Reject settings change based on an invalid setting + if (setting >= CAM_SET_MAX) { + return -99; + } + + // Reject settings change based on setting already set (and flags) + if ((setting == camera->setting) && !(flags & CAM_CHANGE_SETTING_0)) { + camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_2; + if (!(flags & CAM_CHANGE_SETTING_1)) { + camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_USE_PRIORITY; + } + return -1; + } + + camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_2; + + if (!(flags & CAM_CHANGE_SETTING_1)) { + camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_USE_PRIORITY; + } + + func_800DF498(camera); + + if (!(sCameraSettings[camera->setting].flags & 0x40000000)) { + camera->prevSetting = camera->setting; + } + + if (flags & CAM_CHANGE_SETTING_3) { + camera->bgCamIndex = camera->prevBgCamDataId; + camera->prevBgCamDataId = -1; + } else if (!(flags & CAM_CHANGE_SETTING_2)) { + if (!(sCameraSettings[camera->setting].flags & 0x40000000)) { + camera->prevBgCamDataId = camera->bgCamIndex; + } + camera->bgCamIndex = -1; + } + + camera->setting = setting; + + if (Camera_ChangeModeFlags(camera, camera->mode, true) >= 0) { + Camera_ResetActionFuncState(camera, camera->mode); + } + + return setting; +} + +s32 Camera_ChangeSetting(Camera* camera, s16 setting) { + s32 settingChangeSuccessful = Camera_ChangeSettingFlags(camera, setting, 0); + + if (settingChangeSuccessful >= 0) { + camera->bgCamIndex = -1; + } + return settingChangeSuccessful; +} + +s32 Camera_ChangeActorCsCamIndex(Camera* camera, s32 bgCamIndex) { + s16 setting; + + if ((bgCamIndex == -1) || (bgCamIndex == camera->bgCamIndex)) { + camera->behaviorFlags |= CAM_BEHAVIOR_BGCAM_2; + return -1; + } + + if (bgCamIndex < 0) { + setting = sGlobalCamDataSettingsPtr[bgCamIndex]; + } else if (!(camera->behaviorFlags & CAM_BEHAVIOR_BGCAM_2)) { + setting = Camera_GetBgCamOrActorCsCamSetting(camera, bgCamIndex); + } else { + return -1; + } + + camera->behaviorFlags |= CAM_BEHAVIOR_BGCAM_2; + + // Sets camera setting based on bg/scene data + if ((Camera_ChangeSettingFlags(camera, setting, CAM_CHANGE_SETTING_2 | CAM_CHANGE_SETTING_0) >= 0) || + (sCameraSettings[camera->setting].flags & 0x80000000)) { + camera->bgCamIndex = bgCamIndex; + camera->behaviorFlags |= CAM_BEHAVIOR_BGCAM_1; + Camera_ResetActionFuncState(camera, camera->mode); + } + + return bgCamIndex | 0x80000000; +} + +Vec3s* Camera_GetInputDir(Vec3s* dst, Camera* camera) { + *dst = camera->inputDir; + return dst; +} + +s16 Camera_GetInputDirPitch(Camera* camera) { + Vec3s dir; + + Camera_GetInputDir(&dir, camera); + return dir.x; +} + +s16 Camera_GetInputDirYaw(Camera* camera) { + Vec3s dir; + + Camera_GetInputDir(&dir, camera); + return dir.y; +} + +Vec3s* Camera_GetCamDir(Vec3s* dst, Camera* camera) { + *dst = camera->camDir; + return dst; +} + +s16 Camera_GetCamDirPitch(Camera* camera) { + Vec3s camDir; + + Camera_GetCamDir(&camDir, camera); + return camDir.x; +} + +s16 Camera_GetCamDirYaw(Camera* camera) { + Vec3s camDir; + + Camera_GetCamDir(&camDir, camera); + return camDir.y; +} + +s32 Camera_AddQuake(Camera* camera, s32 arg1, s16 y, s32 countdown) { + s16 quakeIndex = Quake_Request(camera, QUAKE_TYPE_3); + + if (quakeIndex == 0) { + return false; + } + + Quake_SetSpeed(quakeIndex, 25000); + Quake_SetPerturbations(quakeIndex, y, 0, 0, 0); + Quake_SetDuration(quakeIndex, countdown); + return true; +} + +s32 Camera_SetViewParam(Camera* camera, s32 viewFlag, void* param) { + s32 pad[3]; + + if (param != NULL) { + switch (viewFlag) { + case CAM_VIEW_AT: + camera->viewFlags &= ~(CAM_VIEW_TARGET_POS | CAM_VIEW_TARGET | CAM_VIEW_AT); + camera->at = *(Vec3f*)param; + break; + + case CAM_VIEW_TARGET_POS: + camera->viewFlags &= ~(CAM_VIEW_TARGET_POS | CAM_VIEW_TARGET | CAM_VIEW_AT); + camera->targetPosRot.pos = *(Vec3f*)param; + break; + + case CAM_VIEW_TARGET: + camera->target = (Actor*)param; + camera->viewFlags &= ~(CAM_VIEW_TARGET_POS | CAM_VIEW_TARGET | CAM_VIEW_AT); + break; + + case CAM_VIEW_EYE: + camera->eye = camera->eyeNext = *(Vec3f*)param; + break; + + case CAM_VIEW_UP: + camera->up = *(Vec3f*)param; + break; + + case CAM_VIEW_ROLL: + camera->roll = CAM_DEG_TO_BINANG(*(f32*)param); + break; + + case CAM_VIEW_FOV: + camera->fov = *(f32*)param; + break; + + default: + return false; + } + camera->viewFlags |= viewFlag; + } else { + return false; + } + return true; +} + +s32 Camera_UnsetViewFlag(Camera* camera, s16 viewFlag) { + camera->viewFlags &= ~viewFlag; + return true; +} + +s32 Camera_OverwriteStateFlags(Camera* camera, s16 stateFlags) { + camera->stateFlags = stateFlags; + return true; +} + +s32 Camera_ResetActionFuncStateUnused(Camera* camera) { + camera->animState = 0; + return true; +} + +/** + * Unused Remnant of OoT. `CutsceneCameraPoint` struct no longer exists. + */ +s32 Camera_SetCsParams(Camera* camera, void* atPoints, void* eyePoints, Player* player, s16 relativeToPlayer) { + return true; +} + +s16 Camera_SetStateFlag(Camera* camera, s16 flags) { + camera->stateFlags |= flags; + return camera->stateFlags; +} + +s16 Camera_UnsetStateFlag(Camera* camera, s16 flags) { + camera->stateFlags &= ~flags; + return camera->stateFlags; +} + +s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 bgCamIndex, f32 arg3, s16 timer1, s16 timer2, + s16 timer3) { + DoorParams* doorParams = &camera->paramData.doorParams; + + if (camera->setting == CAM_SET_DOORC) { + return 0; + } + + doorParams->doorActor = doorActor; + doorParams->timer1 = timer1; + doorParams->timer2 = timer2; + doorParams->timer3 = timer3; + doorParams->bgCamIndex = bgCamIndex; + + if (bgCamIndex == -99) { + Camera_ResetActionFuncState(camera, camera->mode); + return -99; + } + + if (bgCamIndex == -1) { + Camera_ChangeSettingFlags(camera, CAM_SET_DOORC, 0); + } else if (bgCamIndex == -2) { + Camera_ChangeSettingFlags(camera, CAM_SET_SPIRAL_DOOR, 0); + } else { + camera->nextCamSceneDataId = bgCamIndex; + camera->doorTimer1 = timer1; + camera->doorTimer2 = timer2 + timer3; + } + + Camera_ResetActionFuncState(camera, camera->mode); + return -1; +} + +s32 Camera_Copy(Camera* dstCam, Camera* srcCam) { + s32 pad; + + dstCam->focalActorAtOffset.z = 0.0f; + dstCam->focalActorAtOffset.y = 0.0f; + dstCam->focalActorAtOffset.x = 0.0f; + dstCam->atLerpStepScale = 0.1f; + dstCam->at = srcCam->at; + + dstCam->eye = dstCam->eyeNext = srcCam->eye; + + dstCam->dist = OLib_Vec3fDist(&dstCam->at, &dstCam->eye); + dstCam->fov = srcCam->fov; + dstCam->roll = srcCam->roll; + Camera_SetUpdateRatesSlow(dstCam); + + if (dstCam->focalActor != NULL) { + if (dstCam->focalActor == &GET_PLAYER(dstCam->play)->actor) { + Actor_GetWorldPosShapeRot(&dstCam->focalActorPosRot, dstCam->focalActor); + } else { + Actor_GetWorld(&dstCam->focalActorPosRot, dstCam->focalActor); + } + Camera_SetFocalActorAtOffset(dstCam, &dstCam->focalActorPosRot.pos); + } + return true; +} + +/** + * Unused Remnant of OoT/Debug + */ +s32 Camera_IsDbgCamEnabled(void) { + return false; +} + +Vec3f* Camera_GetQuakeOffset(Vec3f* quakeOffset, Camera* camera) { + *quakeOffset = camera->quakeOffset; + + return quakeOffset; +} + +void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* data1, s16 data2, s16 data3) { + if (setDataFlags & 1) { + camera->data0 = data0; + } + + if (setDataFlags & 2) { + camera->data1 = data1; + } + + if (setDataFlags & 4) { + camera->data2 = data2; + } + + if (setDataFlags & 8) { + camera->data3 = data3; + } +} + +s32 Camera_GetNegOne(void) { + return sCameraNegOne; +} + +s16 func_800E0238(Camera* camera) { + Camera_SetStateFlag(camera, CAM_STATE_3); + if ((camera->camId == CAM_ID_MAIN) && (camera->play->activeCamId != CAM_ID_MAIN)) { + Camera_SetStateFlag(GET_ACTIVE_CAM(camera->play), CAM_STATE_3); + return camera->play->activeCamId; + } else { + return camera->camId; + } +} + +void Camera_SetFocalActor(Camera* camera, Actor* actor) { + camera->focalActor = actor; + if (actor == &GET_PLAYER(camera->play)->actor) { + Actor_GetWorldPosShapeRot(&camera->focalActorPosRot, actor); + } else { + Actor_GetWorld(&camera->focalActorPosRot, camera->focalActor); + } + + camera->animState = 0; +} + +void Camera_SetTargetActor(Camera* camera, Actor* actor) { + camera->target = actor; + camera->animState = 20; +} + +f32 Camera_GetWaterYPos(Camera* camera) { + if (camera->stateFlags & CAM_STATE_UNDERWATER) { + return camera->waterYPos; + } else { + return BGCHECK_Y_MIN; + } +} + +void func_800E0348(Camera* camera) { + if (!RELOAD_PARAMS(camera)) { + camera->animState = 999; + Camera_SetStateFlag(camera, CAM_STATE_10 | CAM_STATE_4 | CAM_STATE_2 | CAM_STATE_CHECK_WATER); + } else { + camera->animState = 666; + } +} diff --git a/src/code/z_camera_data.inc.c b/src/code/z_camera_data.inc.c index a8e9fbb80..6e1501fd8 100644 --- a/src/code/z_camera_data.inc.c +++ b/src/code/z_camera_data.inc.c @@ -3613,31 +3613,31 @@ CameraSetting sCameraSettings[] = { }; s16 sGlobalCamDataSettings[] = { - /* -25 */ CAM_SET_ELEGY_SHELL, - /* -24 */ CAM_SET_SIDED, - /* -23 */ CAM_SET_BOAT_CRUISE, - /* -22 */ CAM_SET_NONE, - /* -21 */ CAM_SET_SUBJECTD, - /* -20 */ CAM_SET_NORMALD, - /* -19 */ CAM_SET_NONE, - /* -18 */ CAM_SET_NONE, - /* -17 */ CAM_SET_NONE, - /* -16 */ CAM_SET_WARP_PAD_ENTRANCE, - /* -15 */ CAM_SET_ATTENTION, - /* -14 */ CAM_SET_CONNECT0, - /* -13 */ CAM_SET_REMOTEBOMB, - /* -12 */ CAM_SET_NONE, - /* -11 */ CAM_SET_MASK_TRANSFORMATION, - /* -10 */ CAM_SET_LONG_CHEST_OPENING, - /* -9 */ CAM_SET_REBIRTH, - /* -8 */ CAM_SET_DEATH, - /* -7 */ CAM_SET_WARP_PAD_MOON, - /* -6 */ CAM_SET_NAVI, - /* -5 */ CAM_SET_ITEM3, - /* -4 */ CAM_SET_ITEM2, - /* -3 */ CAM_SET_ITEM1, - /* -2 */ CAM_SET_ITEM0, - /* -1 */ CAM_SET_STOP0, + /* -25 */ CAM_SET_ELEGY_SHELL, // CS_CAM_ID_GLOBAL_ELEGY + /* -24 */ CAM_SET_SIDED, // CS_CAM_ID_GLOBAL_SIDED + /* -23 */ CAM_SET_BOAT_CRUISE, // CS_CAM_ID_GLOBAL_BOAT_CRUISE + /* -22 */ CAM_SET_NONE, // CS_CAM_ID_GLOBAL_N16 + /* -21 */ CAM_SET_SUBJECTD, // CS_CAM_ID_GLOBAL_SUBJECTD + /* -20 */ CAM_SET_NORMALD, // CS_CAM_ID_GLOBAL_NORMALD + /* -19 */ CAM_SET_NONE, // CS_CAM_ID_GLOBAL_N13 + /* -18 */ CAM_SET_NONE, // CS_CAM_ID_GLOBAL_N12 + /* -17 */ CAM_SET_NONE, // CS_CAM_ID_GLOBAL_N11 + /* -16 */ CAM_SET_WARP_PAD_ENTRANCE, // CS_CAM_ID_GLOBAL_WARP_PAD_ENTRANCE + /* -15 */ CAM_SET_ATTENTION, // CS_CAM_ID_GLOBAL_ATTENTION + /* -14 */ CAM_SET_CONNECT0, // CS_CAM_ID_GLOBAL_CONNECT + /* -13 */ CAM_SET_REMOTEBOMB, // CS_CAM_ID_GLOBAL_REMOTE_BOMB + /* -12 */ CAM_SET_NONE, // CS_CAM_ID_GLOBAL_N0C + /* -11 */ CAM_SET_MASK_TRANSFORMATION, // CS_CAM_ID_GLOBAL_MASK_TRANSFORMATION + /* -10 */ CAM_SET_LONG_CHEST_OPENING, // CS_CAM_ID_GLOBAL_LONG_CHEST_OPENING + /* -9 */ CAM_SET_REBIRTH, // CS_CAM_ID_GLOBAL_REVIVE + /* -8 */ CAM_SET_DEATH, // CS_CAM_ID_GLOBAL_DEATH + /* -7 */ CAM_SET_WARP_PAD_MOON, // CS_CAM_ID_GLOBAL_WARP_PAD_MOON + /* -6 */ CAM_SET_NAVI, // CS_CAM_ID_GLOBAL_SONG_WARP + /* -5 */ CAM_SET_ITEM3, // CS_CAM_ID_GLOBAL_ITEM_SHOW + /* -4 */ CAM_SET_ITEM2, // CS_CAM_ID_GLOBAL_ITEM_BOTTLE + /* -3 */ CAM_SET_ITEM1, // CS_CAM_ID_GLOBAL_ITEM_OCARINA + /* -2 */ CAM_SET_ITEM0, // CS_CAM_ID_GLOBAL_ITEM_GET + /* -1 */ CAM_SET_STOP0, // CS_CAM_ID_NONE /* 0 */ CAM_SET_NONE, }; @@ -3795,12 +3795,12 @@ s32 sCameraHudVisibility = 2; s32 sCameraLetterboxSize = 32; s32 sCameraNegOne = -1; -// VecSph yaw data +// VecGeo yaw data s16 D_801B9E18[] = { 0x0AAA, 0xF556, 0x1555, 0xEAAB, 0x2AAA, 0xD556, 0x3FFF, 0xC001, 0x5555, 0xAAAB, 0x6AAA, 0x9556, 0x7FFF, 0x0000, }; -// VecSph pitch data +// VecGeo pitch data s16 D_801B9E34[] = { 0x0000, 0x02C6, 0x058C, 0x0000, 0x0000, 0xFD3A, 0x0000, 0x0852, 0x0000, 0x0000, 0x0B18, 0x02C6, 0xFA74, 0x0000, }; diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 0e36f1c54..8bcd244bd 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" Vec3f D_801EDE00; @@ -24,16 +23,24 @@ Vec3f D_801EE0D8; TriNorm D_801EE0E8[2]; TriNorm D_801EE150; TriNorm D_801EE188; + +#ifndef NON_MATCHING Vec3f D_801EE1C0; Vec3f D_801EE1D0; Vec3f D_801EE1E0; Vec3f D_801EE1F0; EffectSparkInit D_801EE200; +#endif + TriNorm D_801EE6C8; TriNorm D_801EE700; + +#ifndef NON_MATCHING EffectSparkInit D_801EE738; EffectSparkInit D_801EEC00; EffectSparkInit D_801EF0C8; +#endif + TriNorm D_801EF590; TriNorm D_801EF5C8; TriNorm D_801EF600; @@ -3837,7 +3844,7 @@ void CollisionCheck_SpawnShieldParticles(PlayState* play, Vec3f* v) { 35.0f, 30.0f, 8, - { 0, 0, 0, 0, 128, 255, 0, 300 }, + { 0, 0, 0, { 0, 128, 255 }, 0, 300 }, 1, }; s32 effectIndex; @@ -3892,7 +3899,7 @@ void CollisionCheck_SpawnShieldParticlesWood(PlayState* play, Vec3f* v, Vec3f* p 35.0f, 30.0f, 8, - { 0, 0, 0, 0, 128, 255, 0, 300 }, + { 0, 0, 0, { 0, 128, 255 }, 0, 300 }, 0, }; s32 effectIndex; diff --git a/src/code/z_construct.c b/src/code/z_construct.c index 5e92d4958..3d2621c9c 100644 --- a/src/code/z_construct.c +++ b/src/code/z_construct.c @@ -1,4 +1,5 @@ #include "global.h" -void func_801AAAA0(PlayState* play) { +// Remnant from OoT +void Regs_InitData(PlayState* play) { } diff --git a/src/code/z_debug.c b/src/code/z_debug.c index 46649a4ce..058d896a4 100644 --- a/src/code/z_debug.c +++ b/src/code/z_debug.c @@ -1,20 +1,21 @@ -#include "global.h" +#include "regs.h" #include "system_malloc.h" +#include "macros.h" -GameInfo* gGameInfo; +RegEditor* gRegEditor; -void GameInfo_Init(void) { +void Regs_Init(void) { s32 i; - gGameInfo = SystemArena_Malloc(sizeof(GameInfo)); + gRegEditor = SystemArena_Malloc(sizeof(RegEditor)); if (1) {} - gGameInfo->unk_00 = 0; - gGameInfo->unk_01 = 0; - gGameInfo->unk_02 = 0; - gGameInfo->unk_04 = 0; - gGameInfo->unk_03 = 0; + gRegEditor->regPage = 0; + gRegEditor->regGroup = 0; + gRegEditor->regCur = 0; + gRegEditor->inputRepeatTimer = 0; + gRegEditor->dPadInputPrev = 0; - for (i = 0; i < ARRAY_COUNT(gGameInfo->data); i++) { - gGameInfo->data[i] = 0; + for (i = 0; i < ARRAY_COUNT(gRegEditor->data); i++) { + gRegEditor->data[i] = 0; } } diff --git a/src/code/z_debug_display.c b/src/code/z_debug_display.c index f98b8636e..d9f20d72b 100644 --- a/src/code/z_debug_display.c +++ b/src/code/z_debug_display.c @@ -1,13 +1,14 @@ +#include "z64debug_display.h" #include "global.h" DebugDispObject* sDebugObjectListHead; typedef struct { - /* 0x00 */ s16 drawType; // indicates which draw function to use when displaying the object - /* 0x04 */ void* drawArg; // segment address (display list or texture) passed to the draw funciton when called -} DebugDispObjectInfo; // size = 0x8 + /* 0x0 */ s16 drawType; // indicates which draw function to use when displaying the object + /* 0x4 */ void* drawArg; // segment address (display list or texture) passed to the draw funciton when called +} DebugDispObjectInfo; // size = 0x8 -typedef void (*DebugDispObject_DrawFunc)(DebugDispObject*, void*, PlayState*); +typedef void (*DebugDispObjectDrawFunc)(DebugDispObject*, void*, PlayState*); void DebugDisplay_DrawSpriteI8(DebugDispObject*, void*, PlayState*); void DebugDisplay_DrawPolygon(DebugDispObject*, void*, PlayState*); @@ -44,12 +45,12 @@ DebugDispObject* DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, #include "code/debug_display/debug_display.c" -DebugDispObject_DrawFunc sDebugObjectDrawFuncTable[] = { DebugDisplay_DrawSpriteI8, DebugDisplay_DrawPolygon }; +DebugDispObjectDrawFunc sDebugObjectDrawFuncTable[] = { DebugDisplay_DrawSpriteI8, DebugDisplay_DrawPolygon }; DebugDispObjectInfo sDebugObjectInfoTable[] = { { 0, sDebugDisplayCircleTex }, { 0, sDebugDisplayCrossTex }, { 0, sDebugDisplayBallTex }, - { 0, sDebugDisplayCursorTex }, { 1, &sDebugDisplay1DL }, { 1, &sDebugDisplay3DL }, - { 1, &sDebugDisplay2DL }, + { 0, sDebugDisplayCursorTex }, { 1, sDebugDisplay1DL }, { 1, sDebugDisplay3DL }, + { 1, sDebugDisplay2DL }, }; void DebugDisplay_DrawObjects(PlayState* play) { @@ -86,7 +87,7 @@ void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, PlayStat Lights1 sDebugDisplayLight1 = gdSPDefLights1(128, 128, 128, 255, 255, 255, 73, 73, 73); -void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, PlayState* play) { +void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* dList, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); func_8012C588(play->state.gfxCtx); @@ -99,7 +100,7 @@ void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, PlayState* p Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, arg1); + gSPDisplayList(POLY_XLU_DISP++, dList); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/code/z_debug_mode.c b/src/code/z_debug_mode.c index 0682b3693..a40bd29bd 100644 --- a/src/code/z_debug_mode.c +++ b/src/code/z_debug_mode.c @@ -1,13 +1,160 @@ +#include "z64debug_text.h" #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_mode/func_800E9C90.s") +typedef struct { + /* 0x0 */ u8 colorIndex; + /* 0x1 */ char text[11]; +} DebugTextBufferEntry; // size = 0xC -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_mode/func_800E9CA0.s") +typedef struct { + /* 0x0 */ u8 x; + /* 0x1 */ u8 y; + /* 0x2 */ u8 colorIndex; + /* 0x3 */ char text[41]; +} DebugCamTextBufferEntry; // size = 0x2C -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_mode/func_800E9CFC.s") +#define DEBUG_TEXT_DRAW_TEXT (1 << 0) +#define DEBUG_TEXT_DRAW_CAM_TEXT (1 << 1) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_mode/func_800E9DBC.s") +s32 sDebugTextDrawFlags = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_mode/func_800E9E94.s") +DebugTextBufferEntry sDebugTextBuffer[] = { + { DEBUG_TEXT_BLACK, " " }, { DEBUG_TEXT_BLACK, " " }, { DEBUG_TEXT_BLACK, " " }, + { DEBUG_TEXT_BLACK, " " }, { DEBUG_TEXT_BLACK, " " }, { DEBUG_TEXT_BLACK, " " }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_mode/func_800E9F78.s") +Color_RGBA8 sDebugTextColors[] = { + { 0, 0, 0, 64 }, // DEBUG_TEXT_BLACK + { 0, 0, 255, 64 }, // DEBUG_TEXT_BLUE + { 255, 0, 0, 64 }, // DEBUG_TEXT_RED + { 255, 0, 255, 64 }, // DEBUG_TEXT_PURPLE + { 0, 255, 0, 64 }, // DEBUG_TEXT_GREEN + { 0, 255, 255, 64 }, // DEBUG_TEXT_CYAN + { 255, 255, 0, 64 }, // DEBUG_TEXT_YELLOW + { 255, 255, 255, 64 }, // DEBUG_TEXT_WHITE +}; + +DebugCamTextBufferEntry sDebugCamTextBuffer[80]; + +s16 sDebugCamTextEntryCount = 0; + +Color_RGBA8 sDebugCamTextColors[] = { + { 255, 255, 32, 192 }, // DEBUG_CAM_TEXT_YELLOW + { 255, 150, 128, 192 }, // DEBUG_CAM_TEXT_PEACH + { 128, 96, 0, 64 }, // DEBUG_CAM_TEXT_BROWN + { 192, 128, 16, 128 }, // DEBUG_CAM_TEXT_ORANGE + { 255, 192, 32, 128 }, // DEBUG_CAM_TEXT_GOLD + { 230, 230, 220, 64 }, // DEBUG_CAM_TEXT_WHITE + { 128, 150, 255, 128 }, // DEBUG_CAM_TEXT_BLUE + { 128, 255, 32, 128 }, // DEBUG_CAM_TEXT_GREEN +}; + +void Debug_ClearTextDrawFlags(void) { + sDebugTextDrawFlags = 0; +} + +void Debug_ScreenText(s32 index, s32 colorIndex, const char* text) { + DebugTextBufferEntry* entry = &sDebugTextBuffer[index]; + char* textDest = entry->text; + + sDebugTextDrawFlags |= DEBUG_TEXT_DRAW_TEXT; + entry->colorIndex = colorIndex; + + do { + *textDest++ = *text; + } while (*text++ != '\0'); +} + +void Debug_DrawScreenText(GfxPrint* printer) { + DebugTextBufferEntry* entry; + Color_RGBA8* color; + s32 y; + + entry = sDebugTextBuffer; + for (y = 20; y < 20 + ARRAY_COUNT(sDebugTextBuffer); y++) { + GfxPrint_SetPos(printer, 26, y); + color = &sDebugTextColors[entry->colorIndex]; + GfxPrint_SetColor(printer, color->r, color->g, color->b, color->a); + GfxPrint_Printf(printer, "%s", entry->text); + *entry->text = '\0'; + entry++; + } +} + +void DebugCamera_ScreenText(u8 x, u8 y, u8 colorIndex, const char* text) { + DebugCamTextBufferEntry* entry = &sDebugCamTextBuffer[sDebugCamTextEntryCount]; + char* textDest; + s16 charCount; + + sDebugTextDrawFlags |= DEBUG_TEXT_DRAW_CAM_TEXT; + if (sDebugCamTextEntryCount < ARRAY_COUNT(sDebugCamTextBuffer)) { + entry->x = x; + entry->y = y; + entry->colorIndex = colorIndex; + + // Copy text into the entry, truncating if needed + charCount = 0; + textDest = entry->text; + + while ((*textDest++ = *text++) != '\0') { + if (charCount++ >= ARRAY_COUNT(entry->text)) { + break; + } + } + + *textDest = '\0'; + + sDebugCamTextEntryCount++; + } +} + +void DebugCamera_DrawScreenText(GfxPrint* printer) { + DebugCamTextBufferEntry* entry; + Color_RGBA8* color; + s32 i; + + for (i = 0; i < sDebugCamTextEntryCount; i++) { + entry = &sDebugCamTextBuffer[i]; + color = &sDebugCamTextColors[entry->colorIndex]; + + GfxPrint_SetColor(printer, color->r, color->g, color->b, color->a); + GfxPrint_SetPos(printer, entry->x, entry->y); + GfxPrint_Printf(printer, "%s", entry->text); + } +} + +void Debug_DrawText(GraphicsContext* gfxCtx) { + Gfx* gfx; + Gfx* gfxHead; + GfxPrint printer; + + if (THGA_GetRemaining(&gfxCtx->polyOpa) >= 0x2800) { + GfxPrint_Init(&printer); + + OPEN_DISPS(gfxCtx); + + gfxHead = POLY_OPA_DISP; + gfx = Graph_GfxPlusOne(gfxHead); + gSPDisplayList(DEBUG_DISP++, gfx); + + GfxPrint_Open(&printer, gfx); + + if (sDebugTextDrawFlags & DEBUG_TEXT_DRAW_CAM_TEXT) { + DebugCamera_DrawScreenText(&printer); + } + sDebugCamTextEntryCount = 0; + + if (sDebugTextDrawFlags & DEBUG_TEXT_DRAW_TEXT) { + Debug_DrawScreenText(&printer); + } + + gfx = GfxPrint_Close(&printer); + gSPEndDisplayList(gfx++); + Graph_BranchDlist(gfxHead, gfx); + POLY_OPA_DISP = gfx; + + CLOSE_DISPS(gfxCtx); + + GfxPrint_Destroy(&printer); + } +} diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 7d665e208..733ec4bc1 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,172 +1,176 @@ -#include "prevent_bss_reordering.h" #include "global.h" #include "z64quake.h" #include "z64rumble.h" #include "z64shrink_window.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" -void Cutscene_DoNothing(PlayState* play, CutsceneContext* csCtx); -void func_800EA258(PlayState* play, CutsceneContext* csCtx); -void func_800ED9C4(PlayState* play, CutsceneContext* csCtx); -void func_800EA2B8(PlayState* play, CutsceneContext* csCtx); -void func_800ED980(PlayState* play, CutsceneContext* csCtx); -void func_800EDA04(PlayState* play, CutsceneContext* csCtx); -void func_800EDA84(PlayState* play, CutsceneContext* csCtx); +void CutsceneHandler_DoNothing(PlayState* play, CutsceneContext* csCtx); +void CutsceneHandler_StartManual(PlayState* play, CutsceneContext* csCtx); +void CutsceneHandler_StopManual(PlayState* play, CutsceneContext* csCtx); +void CutsceneHandler_StartScript(PlayState* play, CutsceneContext* csCtx); +void CutsceneHandler_RunScript(PlayState* play, CutsceneContext* csCtx); +void CutsceneHandler_StopScript(PlayState* play, CutsceneContext* csCtx); +void Cutscene_SetupScripted(PlayState* play, CutsceneContext* csCtx); // Unused UNK_TYPE4 D_801BB120 = 0; -u16 D_801BB124 = 0; -u16 D_801BB128 = 0; -u8 D_801BB12C = 0; +u16 sCurTextId = 0; +u16 sCurOcarinaAction = 0; +u8 gOpeningEntranceIndex = 0; u8 sCutsceneStoredPlayerForm = 0; // bss #ifndef NON_MATCHING -static u16 seqId; +static u16 sSeqId; #endif s16 sCutsceneQuakeIndex; -DbCameraUnkStruct sCutsceneCameraInfo; -u16 D_801F4DC8[10]; +CutsceneCamera sCutsceneCameraInfo; +u16 sCueTypeList[10]; UNK_TYPE D_801F4DDC; -u8 D_801F4DE0; -s16 D_801F4DE2; +u8 gDisablePlayerCsModeStartPos; +s16 gDungeonBossWarpSceneId; -void Cutscene_Init(PlayState* play, CutsceneContext* csCtx) { +void Cutscene_InitContext(PlayState* play, CutsceneContext* csCtx) { s32 i; - csCtx->state = CS_STATE_0; - csCtx->frames = 0; - csCtx->unk_0C = 0.0f; - play->csCtx.sceneCsCount = 0; - play->csCtx.currentCsIndex = 0; + csCtx->state = CS_STATE_IDLE; + csCtx->curFrame = 0; + csCtx->timer = 0.0f; + play->csCtx.scriptListCount = 0; + play->csCtx.scriptIndex = 0; - for (i = 0; i < ARRAY_COUNT(D_801F4DC8); i++) { - D_801F4DC8[i] = 0; + for (i = 0; i < ARRAY_COUNT(sCueTypeList); i++) { + sCueTypeList[i] = 0; } - D_801F4DE0 = 0; + gDisablePlayerCsModeStartPos = 0; Audio_SetCutsceneFlag(false); } -void Cutscene_Start(PlayState* play, CutsceneContext* csCtx) { - csCtx->state = CS_STATE_1; - csCtx->playerAction = NULL; +void Cutscene_StartManual(PlayState* play, CutsceneContext* csCtx) { + csCtx->state = CS_STATE_START; + csCtx->playerCue = NULL; } -void Cutscene_End(PlayState* play, CutsceneContext* csCtx) { - if (csCtx->state != CS_STATE_4) { - csCtx->state = CS_STATE_3; +void Cutscene_StopManual(PlayState* play, CutsceneContext* csCtx) { + if (csCtx->state != CS_STATE_RUN_UNSTOPPABLE) { + csCtx->state = CS_STATE_STOP; } } -typedef void (*CutsceneStateHandler)(PlayState* play, CutsceneContext* csCtx); +typedef void (*CutsceneHandler)(PlayState* play, CutsceneContext* csCtx); -CutsceneStateHandler sCsStateHandlers1[] = { - Cutscene_DoNothing, // CS_STATE_0 - func_800EA258, // CS_STATE_1 - Cutscene_DoNothing, // CS_STATE_2 - func_800ED9C4, // CS_STATE_3 - Cutscene_DoNothing, // CS_STATE_4 +CutsceneHandler sManualCutsceneHandlers[] = { + CutsceneHandler_DoNothing, // CS_STATE_IDLE + CutsceneHandler_StartManual, // CS_STATE_START + CutsceneHandler_DoNothing, // CS_STATE_RUN + CutsceneHandler_StopManual, // CS_STATE_STOP + CutsceneHandler_DoNothing, // CS_STATE_RUN_UNSTOPPABLE }; -void Cutscene_Update1(PlayState* play, CutsceneContext* csCtx) { - if (gSaveContext.save.cutscene < 0xFFF0) { - sCsStateHandlers1[csCtx->state](play, csCtx); +void Cutscene_UpdateManual(PlayState* play, CutsceneContext* csCtx) { + if (gSaveContext.save.cutsceneIndex < 0xFFF0) { + sManualCutsceneHandlers[csCtx->state](play, csCtx); } } -CutsceneStateHandler sCsStateHandlers2[] = { - Cutscene_DoNothing, // CS_STATE_0 - func_800EA2B8, // CS_STATE_1 - func_800ED980, // CS_STATE_2 - func_800EDA04, // CS_STATE_3 - func_800ED980, // CS_STATE_4 +CutsceneHandler sScriptedCutsceneHandlers[] = { + CutsceneHandler_DoNothing, // CS_STATE_IDLE + CutsceneHandler_StartScript, // CS_STATE_START + CutsceneHandler_RunScript, // CS_STATE_RUN + CutsceneHandler_StopScript, // CS_STATE_STOP + CutsceneHandler_RunScript, // CS_STATE_RUN_UNSTOPPABLE }; -void Cutscene_Update2(PlayState* play, CutsceneContext* csCtx) { +void Cutscene_UpdateScripted(PlayState* play, CutsceneContext* csCtx) { if ((gSaveContext.cutsceneTrigger != 0) && (play->transitionTrigger == TRANS_TRIGGER_START)) { gSaveContext.cutsceneTrigger = 0; } - if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0)) { - gSaveContext.save.cutscene = 0xFFFD; + if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_IDLE)) { + gSaveContext.save.cutsceneIndex = 0xFFFD; gSaveContext.cutsceneTrigger = 1; } - if (gSaveContext.save.cutscene >= 0xFFF0) { - func_800EDA84(play, csCtx); - sCsStateHandlers2[csCtx->state](play, csCtx); + if (gSaveContext.save.cutsceneIndex >= 0xFFF0) { + Cutscene_SetupScripted(play, csCtx); + sScriptedCutsceneHandlers[csCtx->state](play, csCtx); } } -void Cutscene_DoNothing(PlayState* play, CutsceneContext* csCtx) { +void CutsceneHandler_DoNothing(PlayState* play, CutsceneContext* csCtx) { } -s32 func_800EA220(PlayState* play, CutsceneContext* csCtx, f32 target) { - return Math_StepToF(&csCtx->unk_0C, target, 0.1f); +s32 Cutscene_StepTimer(PlayState* play, CutsceneContext* csCtx, f32 target) { + return Math_StepToF(&csCtx->timer, target, 0.1f); } -void func_800EA258(PlayState* play, CutsceneContext* csCtx) { +void CutsceneHandler_StartManual(PlayState* play, CutsceneContext* csCtx) { Interface_SetHudVisibility(HUD_VISIBILITY_NONE); ShrinkWindow_Letterbox_SetSizeTarget(32); - if (func_800EA220(play, csCtx, 1.0f)) { + + if (Cutscene_StepTimer(play, csCtx, 1.0f)) { Audio_SetCutsceneFlag(true); - csCtx->state++; + csCtx->state++; // CS_STATE_RUN } } -void func_800EA2B8(PlayState* play, CutsceneContext* csCtx) { - func_800ED980(play, csCtx); +void CutsceneHandler_StartScript(PlayState* play, CutsceneContext* csCtx) { + CutsceneHandler_RunScript(play, csCtx); Interface_SetHudVisibility(HUD_VISIBILITY_NONE); ShrinkWindow_Letterbox_SetSizeTarget(32); - if (func_800EA220(play, csCtx, 1.0f)) { + + if (Cutscene_StepTimer(play, csCtx, 1.0f)) { Audio_SetCutsceneFlag(true); - csCtx->state++; + csCtx->state++; // CS_STATE_RUN } } /* Start of command handling section */ -// Command 0x96: Miscellaneous commands. -void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { +void CutsceneCmd_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdMisc* cmd) { static u16 D_801BB15C = 0xFFFF; Player* player = GET_PLAYER(play); - f32 progress; - u8 isStartFrame = false; + f32 lerp; + u8 isFirstFrame = false; SceneTableEntry* loadedScene; - if ((csCtx->frames < cmd->startFrame) || ((csCtx->frames >= cmd->endFrame) && (cmd->endFrame != cmd->startFrame))) { + if (!((csCtx->curFrame >= cmd->startFrame) && + ((csCtx->curFrame < cmd->endFrame) || (cmd->endFrame == cmd->startFrame)))) { return; } - progress = Environment_LerpWeight(cmd->endFrame - 1, cmd->startFrame, csCtx->frames); - if (csCtx->frames == cmd->startFrame) { - isStartFrame = true; + lerp = Environment_LerpWeight(cmd->endFrame - 1, cmd->startFrame, csCtx->curFrame); + + if (csCtx->curFrame == cmd->startFrame) { + isFirstFrame = true; } - // TODO: consider creating an enum for this when we understand what each value does - switch (cmd->base) { - case 0x1: - if (isStartFrame) { + switch (cmd->type) { + case CS_MISC_RAIN: + if (isFirstFrame) { func_800FD78C(play); - play->envCtx.unk_F2[0] = 0x3C; + play->envCtx.unk_F2[0] = 60; } break; - case 0x2: - if (isStartFrame) { + + case CS_MISC_LIGHTNING: + if (isFirstFrame) { Audio_SetAmbienceChannelIO(AMBIENCE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_0, 0); Environment_AddLightningBolts(play, 3); D_801F4E68 = 1; } break; - case 0x3: - if (play->envCtx.lightSettings.fogFar < 12800) { - play->envCtx.lightSettings.fogFar += 35; + + case CS_MISC_LIFT_FOG: + if (play->envCtx.lightSettings.zFar < 12800) { + play->envCtx.lightSettings.zFar += 35; } break; - case 0x4: - if (isStartFrame) { + + case CS_MISC_CLOUDY_SKY: + if (isFirstFrame) { play->envCtx.unk_19 = 1; play->envCtx.unk_17 = 1; play->envCtx.unk_18 = 0; @@ -178,49 +182,57 @@ void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* c play->envCtx.unk_22 = play->envCtx.unk_24; } break; - case 0x5: - if (isStartFrame && (csCtx->state != CS_STATE_4)) { - csCtx->state = CS_STATE_3; + + case CS_MISC_STOP_CUTSCENE: + if (isFirstFrame && (csCtx->state != CS_STATE_RUN_UNSTOPPABLE)) { + csCtx->state = CS_STATE_STOP; } break; - case 0x7: - if (isStartFrame) { + + case CS_MISC_SHOW_TITLE_CARD: + if (isFirstFrame) { loadedScene = play->loadedScene; if (loadedScene->titleTextId != 0) { func_80151A68(play, loadedScene->titleTextId); } } break; - case 0x8: + + case CS_MISC_EARTHQUAKE_MEDIUM: func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); - if (isStartFrame) { - sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); + if (isFirstFrame) { + sCutsceneQuakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); Quake_SetSpeed(sCutsceneQuakeIndex, 22000); - Quake_SetQuakeValues(sCutsceneQuakeIndex, 6, 4, 0, 0); - Quake_SetCountdown(sCutsceneQuakeIndex, 800); + Quake_SetPerturbations(sCutsceneQuakeIndex, 6, 4, 0, 0); + Quake_SetDuration(sCutsceneQuakeIndex, 800); } break; - case 0x9: - if (isStartFrame) { + + case CS_MISC_EARTHQUAKE_STOP: + if (isFirstFrame) { Quake_Init(); } break; - case 0xA: - D_801F6D30.r = 255; - D_801F6D30.g = 255; - D_801F6D30.b = 255; - D_801F6D30.a = 255 * progress; + + case CS_MISC_VISMONO_BLACK_AND_WHITE: + gVisMonoColor.r = 255; + gVisMonoColor.g = 255; + gVisMonoColor.b = 255; + gVisMonoColor.a = 255 * lerp; break; - case 0xB: - D_801F6D30.r = 255; - D_801F6D30.g = 180; - D_801F6D30.b = 100; - D_801F6D30.a = 255 * progress; + + case CS_MISC_VISMONO_SEPIA: + gVisMonoColor.r = 255; + gVisMonoColor.g = 180; + gVisMonoColor.b = 100; + gVisMonoColor.a = 255 * lerp; break; - case 0xC: + + case CS_MISC_HIDE_ROOM: play->roomCtx.curRoom.segment = NULL; break; - case 0xD: + + case CS_MISC_RED_PULSATING_LIGHTS: if (play->state.frames & 8) { if (play->envCtx.lightSettings.ambientColor[0] < 40) { play->envCtx.lightSettings.ambientColor[0] += 2; @@ -235,96 +247,118 @@ void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* c } } break; - case 0xE: - play->unk_18845 = 1; + + case CS_MISC_HALT_ALL_ACTORS: + play->haltAllActors = true; break; - case 0xF: - play->unk_18845 = 0; + + case CS_MISC_RESUME_ALL_ACTORS: + play->haltAllActors = false; break; - case 0x10: - if (isStartFrame) { + + case CS_MISC_SANDSTORM_FILL: + if (isFirstFrame) { play->envCtx.sandstormState = 1; } func_8019F128(NA_SE_EV_SAND_STORM - SFX_FLAG); break; - case 0x11: + + case CS_MISC_SUNSSONG_START: gSaveContext.sunsSongState = SUNSSONG_START; break; - case 0x12: + + case CS_MISC_FREEZE_TIME: if (!gSaveContext.save.isNight) { gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)R_TIME_SPEED; } else { gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)(2 * R_TIME_SPEED); } break; - case 0x13: - AudioOcarina_PlayLongScarecrowAfterCredits(); - csCtx->frames = cmd->startFrame - 1; + + case CS_MISC_LONG_SCARECROW_SONG: + AudioOcarina_PlayLongScarecrowSong(); + csCtx->curFrame = cmd->startFrame - 1; // the cutscene runs forever break; - case 0x14: - EnvFlags_Set(play, 3); + + case CS_MISC_SET_CSFLAG_3: + CutsceneFlags_Set(play, 3); break; - case 0x15: - EnvFlags_Set(play, 4); + + case CS_MISC_SET_CSFLAG_4: + CutsceneFlags_Set(play, 4); break; - case 0x16: + + case CS_MISC_PLAYER_FORM_DEKU: gSaveContext.save.playerForm = PLAYER_FORM_DEKU; break; - case 0x17: + + case CS_MISC_ENABLE_PLAYER_REFLECTION: player->stateFlags2 |= PLAYER_STATE2_4000000; break; - case 0x18: + + case CS_MISC_DISABLE_PLAYER_REFLECTION: player->stateFlags2 &= ~PLAYER_STATE2_4000000; break; - case 0x19: + + case CS_MISC_PLAYER_FORM_HUMAN: sCutsceneStoredPlayerForm = gSaveContext.save.playerForm; gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; gSaveContext.save.equippedMask = PLAYER_MASK_NONE; break; - case 0x1A: + + case CS_MISC_EARTHQUAKE_STRONG: func_8019F128(NA_SE_EV_EARTHQUAKE_LAST2 - SFX_FLAG); - if (isStartFrame) { - sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); + if (isFirstFrame) { + sCutsceneQuakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); Quake_SetSpeed(sCutsceneQuakeIndex, 30000); - Quake_SetQuakeValues(sCutsceneQuakeIndex, 20, 10, 0, 0); - Quake_SetCountdown(sCutsceneQuakeIndex, 800); + Quake_SetPerturbations(sCutsceneQuakeIndex, 20, 10, 0, 0); + Quake_SetDuration(sCutsceneQuakeIndex, 800); } break; - case 0x1B: - if (isStartFrame) { + + case CS_MISC_DEST_MOON_CRASH_FIRE_WALL: + if (isFirstFrame) { play->nextEntrance = ENTRANCE(CUTSCENE, 0); gSaveContext.nextCutsceneIndex = 0xFFF8; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; } break; - case 0x1C: - if (isStartFrame) { + + case CS_MISC_MOON_CRASH_SKYBOX: + if (isFirstFrame) { + // skyboxConfig play->envCtx.unk_17 = 0xD; } break; - case 0x1D: + + case CS_MISC_PLAYER_FORM_RESTORED: gSaveContext.save.playerForm = sCutsceneStoredPlayerForm; break; - case 0x1E: - D_801F4DE0 = true; + + case CS_MISC_DISABLE_PLAYER_CSMODE_START_POS: + gDisablePlayerCsModeStartPos = true; break; - case 0x1F: - D_801F4DE0 = false; + + case CS_MISC_ENABLE_PLAYER_CSMODE_START_POS: + gDisablePlayerCsModeStartPos = false; break; - case 0x21: - if (isStartFrame) { + + case CS_MISC_SAVE_ENTER_CLOCK_TOWN: + if (isFirstFrame) { Sram_SaveSpecialEnterClockTown(play); } break; - case 0x22: - if (isStartFrame) { - func_80144A94(&play->sramCtx); + + case CS_MISC_RESET_SAVE_FROM_MOON_CRASH: + if (isFirstFrame) { + Sram_ResetSaveFromMoonCrash(&play->sramCtx); } break; - case 0x23: - if (csCtx->frames != D_801BB15C) { - D_801BB15C = csCtx->frames; + + case CS_MISC_TIME_ADVANCE: + if (csCtx->curFrame != D_801BB15C) { + D_801BB15C = csCtx->curFrame; if (R_TIME_SPEED != 0) { gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)R_TIME_SPEED; @@ -333,20 +367,19 @@ void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* c } } break; - case 0x24: + + case CS_MISC_EARTHQUAKE_WEAK: func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); - if (isStartFrame) { - sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); + if (isFirstFrame) { + sCutsceneQuakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); Quake_SetSpeed(sCutsceneQuakeIndex, 22000); - Quake_SetQuakeValues(sCutsceneQuakeIndex, 2, 1, 0, 0); - Quake_SetCountdown(sCutsceneQuakeIndex, 800); + Quake_SetPerturbations(sCutsceneQuakeIndex, 2, 1, 0, 0); + Quake_SetDuration(sCutsceneQuakeIndex, 800); } break; - case 0x26: - // Seems to be used to trigger "Dawn of A New Day" - - gSaveContext.save.day = 9; + case CS_MISC_DAWN_OF_A_NEW_DAY: + gSaveContext.save.day = 9; // 9 % 5 is day number 4, see `CURRENT_DAY` STOP_GAMESTATE(&play->state); SET_NEXT_GAMESTATE(&play->state, DayTelop_Init, sizeof(DayTelopState)); @@ -354,21 +387,23 @@ void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* c Sram_SaveSpecialNewDay(play); break; - case 0x27: + case CS_MISC_PLAYER_FORM_ZORA: gSaveContext.save.playerForm = PLAYER_FORM_ZORA; break; - case 0x28: - csCtx->frames = cmd->startFrame - 1; + case CS_MISC_FINALE: + csCtx->curFrame = cmd->startFrame - 1; // the cutscene runs forever + break; + + default: break; } } -// Command 0x97: Set Environment Lighting -void Cutscene_Command_SetLighting(PlayState* play, CutsceneContext* csCtx, CsCmdEnvLighting* cmd) { - if (csCtx->frames == cmd->startFrame) { - if (cmd->setting != 0x20) { - play->envCtx.lightSettingOverride = cmd->setting - 1; +void CutsceneCmd_SetLightSetting(PlayState* play, CutsceneContext* csCtx, CsCmdLightSetting* cmd) { + if (csCtx->curFrame == cmd->startFrame) { + if (cmd->settingPlusOne != 32) { + play->envCtx.lightSettingOverride = cmd->settingPlusOne - 1; play->envCtx.lightBlend = 1.0f; } else { play->envCtx.lightSettingOverride = 0xFF; @@ -376,51 +411,45 @@ void Cutscene_Command_SetLighting(PlayState* play, CutsceneContext* csCtx, CsCmd } } -// Command 0x12C: Plays a sequence (Background music or Fanfare) -void Cutscene_Command_PlaySequence(PlayState* play, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) { - if (csCtx->frames == cmd->startFrame) { - Audio_PlaySequenceInCutscene(cmd->sequence - 1); +void CutsceneCmd_StartSequence(PlayState* play, CutsceneContext* csCtx, CsCmdStartSeq* cmd) { + if (csCtx->curFrame == cmd->startFrame) { + Audio_PlaySequenceInCutscene(cmd->seqIdPlusOne - 1); } } -// Command 0x12D: Stops a sequence (Background music or Fanfare) -void Cutscene_Command_StopSequence(PlayState* play, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) { - if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { - Audio_StopSequenceInCutscene(cmd->sequence - 1); +void CutsceneCmd_StopSequence(PlayState* play, CutsceneContext* csCtx, CsCmdStopSeq* cmd) { + if ((csCtx->curFrame >= cmd->startFrame) && (csCtx->curFrame <= cmd->endFrame)) { + Audio_StopSequenceInCutscene(cmd->seqIdPlusOne - 1); } } -// Command 0x9C: Fade a sequence (Background music or Fanfare) over duration -void Cutscene_Command_FadeSequence(PlayState* play, CutsceneContext* csCtx, CsCmdSequenceFade* cmd) { - if ((csCtx->frames == cmd->startFrame) && (csCtx->frames < cmd->endFrame)) { - u8 fadeTimer = cmd->endFrame - cmd->startFrame; +void CutsceneCmd_FadeOutSequence(PlayState* play, CutsceneContext* csCtx, CsCmdFadeOutSeq* cmd) { + if ((csCtx->curFrame == cmd->startFrame) && (csCtx->curFrame < cmd->endFrame)) { + u8 fadeOutDuration = cmd->endFrame - cmd->startFrame; - if (cmd->type == 2) { - Audio_QueueSeqCmd((fadeTimer << 0x10) | 0x110000FF); - } else { - Audio_QueueSeqCmd((fadeTimer << 0x10) | NA_BGM_STOP); + if (cmd->seqPlayer == CS_FADE_OUT_FANFARE) { + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, fadeOutDuration); + } else { // CS_FADE_OUT_BGM_MAIN + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, fadeOutDuration); } } } -// Command 0x12E: Play Ambience sequence -void Cutscene_Command_PlayAmbienceSequence(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { - if (csCtx->frames == cmd->startFrame) { +void CutsceneCmd_StartAmbience(PlayState* play, CutsceneContext* csCtx, CsCmdStartAmbience* cmd) { + if (csCtx->curFrame == cmd->startFrame) { Audio_PlayAmbience(play->sequenceCtx.ambienceId); } } -// Command 0x130: -void func_800EAD48(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { - if (csCtx->frames == cmd->startFrame) { +void Cutscene_SetSfxReverbIndexTo2(PlayState* play, CutsceneContext* csCtx, CsCmdSfxReverbIndexTo2* cmd) { + if (csCtx->curFrame == cmd->startFrame) { // Audio_SetSfxReverbIndexExceptOcarinaBank func_801A4428(2); } } -// Command 0x131: -void func_800EAD7C(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { - if (csCtx->frames == cmd->startFrame) { +void Cutscene_SetSfxReverbIndexTo1(PlayState* play, CutsceneContext* csCtx, CsCmdSfxReverbIndexTo1* cmd) { + if (csCtx->curFrame == cmd->startFrame) { // Audio_SetSfxReverbIndexExceptOcarinaBank func_801A4428(1); } @@ -428,107 +457,103 @@ void func_800EAD7C(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { #ifdef NON_MATCHING // needs in-function static bss -// audio related -void func_800EADB0(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { - static u16 seqId; +void CutsceneCmd_ModifySequence(PlayState* play, CutsceneContext* csCtx, CsCmdModifySeq* cmd) { + static u16 sSeqId; u8 dayMinusOne; - if (csCtx->frames == cmd->startFrame) { - dayMinusOne = (gSaveContext.save.day - 1); + if (csCtx->curFrame == cmd->startFrame) { + dayMinusOne = gSaveContext.save.day - 1; if (dayMinusOne >= 3) { dayMinusOne = 0; } - switch (cmd->base) { - case 1: - // func_801A246C(SEQ_PLAYER_BGM_MAIN, TYPE_1); + switch (cmd->type) { + case CS_MOD_SEQ_0: func_801A246C(SEQ_PLAYER_BGM_MAIN, 1); break; - case 2: - // func_801A246C(SEQ_PLAYER_BGM_MAIN, TYPE_0); + case CS_MOD_SEQ_1: func_801A246C(SEQ_PLAYER_BGM_MAIN, 0); break; - case 3: - // func_801A246C(SEQ_PLAYER_BGM_MAIN, TYPE_2); + case CS_MOD_SEQ_2: func_801A246C(SEQ_PLAYER_BGM_MAIN, 2); break; - case 4: - // func_801A246C(SEQ_PLAYER_AMBIENCE, TYPE_1); + case CS_MOD_AMBIENCE_0: func_801A246C(SEQ_PLAYER_AMBIENCE, 1); break; - case 5: - // func_801A246C(SEQ_PLAYER_AMBIENCE, TYPE_0); + case CS_MOD_AMBIENCE_1: func_801A246C(SEQ_PLAYER_AMBIENCE, 0); break; - case 6: - // func_801A246C(SEQ_PLAYER_AMBIENCE, TYPE_2); + case CS_MOD_AMBIENCE_2: func_801A246C(SEQ_PLAYER_AMBIENCE, 2); break; - case 7: - seqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); + case CS_MOD_SEQ_STORE: + sSeqId = AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN); break; - case 8: - if (seqId != NA_BGM_DISABLED) { - Audio_PlaySceneSequence(seqId, dayMinusOne); + case CS_MOD_SEQ_RESTORE: + if (sSeqId != NA_BGM_DISABLED) { + Audio_PlaySceneSequence(sSeqId, dayMinusOne); } break; + + default: + break; } } } #else -void func_800EADB0(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EADB0.s") +void CutsceneCmd_ModifySequence(PlayState* play, CutsceneContext* csCtx, CsCmdModifySeq* cmd); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/CutsceneCmd_ModifySequence.s") #endif -// Command 0x12F: Fade Ambience sequence -void Cutscene_Command_FadeAmbienceSequence(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { - if (csCtx->frames == cmd->startFrame && csCtx->frames < cmd->endFrame) { - u8 fadeTimer = cmd->endFrame - cmd->startFrame; +void CutsceneCmd_FadeOutAmbience(PlayState* play, CutsceneContext* csCtx, CsCmdFadeOutAmbience* cmd) { + if ((csCtx->curFrame == cmd->startFrame) && (csCtx->curFrame < cmd->endFrame)) { + u8 fadeOutDuration = cmd->endFrame - cmd->startFrame; - Audio_QueueSeqCmd((fadeTimer << 0x10) | 0x140000FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_AMBIENCE, fadeOutDuration); } } -// Command 0x190: Rumble -void Cutscene_Command_Rumble(PlayState* play, CutsceneContext* csCtx, CsCmdRumble* cmd) { +void CutsceneCmd_RumbleController(PlayState* play, CutsceneContext* csCtx, CsCmdRumble* cmd) { switch (cmd->type) { - case 1: - if (csCtx->frames == cmd->startFrame) { + case CS_RUMBLE_ONCE: + if (csCtx->curFrame == cmd->startFrame) { Rumble_Request(0.0f, cmd->intensity, cmd->decayTimer, cmd->decayStep); } break; - case 2: - if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { - if ((csCtx->frames == cmd->startFrame) || (play->state.frames % 64 == 0)) { + case CS_RUMBLE_PULSE: + if ((csCtx->curFrame >= cmd->startFrame) && (csCtx->curFrame <= cmd->endFrame)) { + if ((csCtx->curFrame == cmd->startFrame) || (play->state.frames % 64 == 0)) { Rumble_Request(0.0f, cmd->intensity, cmd->decayTimer, cmd->decayStep); } } break; + + default: + break; } } -// Command 0x9B: -void Cutscene_Command_FadeColorScreen(PlayState* play, CutsceneContext* csCtx, CsCmdFadeScreen* cmd) { - if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { +void CutsceneCmd_TransitionGeneral(PlayState* play, CutsceneContext* csCtx, CsCmdTransitionGeneral* cmd) { + if ((csCtx->curFrame >= cmd->startFrame) && (cmd->endFrame >= csCtx->curFrame)) { f32 alpha; play->envCtx.fillScreen = true; - alpha = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->frames); + alpha = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->curFrame); - if (((cmd->unk0 == 1)) || (cmd->unk0 == 2)) { + if (((cmd->type == CS_TRANS_GENERAL_FILL_IN)) || (cmd->type == CS_TRANS_GENERAL_FILL_OUT)) { play->envCtx.screenFillColor[0] = cmd->color.r; play->envCtx.screenFillColor[1] = cmd->color.g; play->envCtx.screenFillColor[2] = cmd->color.b; - if (cmd->unk0 == 2) { + if (cmd->type == CS_TRANS_GENERAL_FILL_OUT) { play->envCtx.screenFillColor[3] = (1.0f - alpha) * 255.0f; } else { play->envCtx.screenFillColor[3] = 255.0f * alpha; @@ -537,45 +562,47 @@ void Cutscene_Command_FadeColorScreen(PlayState* play, CutsceneContext* csCtx, C } } -// Command 0x9D: Set Time of Day & Environment Time -void Cutscene_Command_SetTime(PlayState* play, CutsceneContext* csCtx, CsCmdDayTime* cmd) { - u16 nextTime; +void CutsceneCmd_SetTime(PlayState* play, CutsceneContext* csCtx, CsCmdTime* cmd) { u16 hourAsMinutes; u16 minutes; - if (csCtx->frames == cmd->startFrame) { + if (csCtx->curFrame == cmd->startFrame) { hourAsMinutes = CLOCK_TIME_ALT_F(cmd->hour, 0); minutes = CLOCK_TIME_ALT_F(0, cmd->minute + 1); - nextTime = hourAsMinutes + minutes; - gSaveContext.save.time = nextTime; - gSaveContext.skyboxTime = nextTime; + gSaveContext.save.time = hourAsMinutes + minutes; + gSaveContext.skyboxTime = hourAsMinutes + minutes; } } -void Cutscene_TerminatorImpl(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { - csCtx->state = CS_STATE_4; - func_80165690(); +void CutsceneCmd_DestinationDefault(PlayState* play, CutsceneContext* csCtx, CsCmdDestination* cmd) { + csCtx->state = CS_STATE_RUN_UNSTOPPABLE; + Play_DisableMotionBlur(); Audio_SetCutsceneFlag(false); gSaveContext.cutsceneTransitionControl = 1; - if ((gSaveContext.gameMode != 0) && (csCtx->frames != cmd->startFrame)) { + // `hudVisibilityForceButtonAlphasByStatus` has a secondary purpose, which is to signal to the title + // screen actor that it should display immediately. This occurs when a title screen cutscene that + // is not the main clock town scene is skipped. + if ((gSaveContext.gameMode != GAMEMODE_NORMAL) && (csCtx->curFrame != cmd->startFrame)) { gSaveContext.hudVisibilityForceButtonAlphasByStatus = true; } - gSaveContext.save.cutscene = 0; - if (cmd->base == 1) { - play->nextEntrance = play->csCtx.sceneCsList[play->csCtx.currentCsIndex].nextEntrance; + gSaveContext.save.cutsceneIndex = 0; + + if (cmd->type == CS_DESTINATION_DEFAULT) { + play->nextEntrance = play->csCtx.scriptList[play->csCtx.scriptIndex].nextEntrance; gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; - if (gSaveContext.gameMode != 1) { + + if (gSaveContext.gameMode != GAMEMODE_TITLE_SCREEN) { Scene_SetExitFade(play); } else { - D_801BB12C++; - if (D_801BB12C >= 2) { - D_801BB12C = 0; + gOpeningEntranceIndex++; + if (gOpeningEntranceIndex >= 2) { + gOpeningEntranceIndex = 0; } - play->transitionType = TRANS_TYPE_04; + play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; } if ((play->nextEntrance & 0xF) > 0) { @@ -586,73 +613,74 @@ void Cutscene_TerminatorImpl(PlayState* play, CutsceneContext* csCtx, CsCmdBase* } } -// Command 0x15E -void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { - if (cmd->base == 1) { - if (csCtx->frames == cmd->startFrame) { - Cutscene_TerminatorImpl(play, csCtx, cmd); +void CutsceneCmd_Destination(PlayState* play, CutsceneContext* csCtx, CsCmdDestination* cmd) { + if (cmd->type == CS_DESTINATION_DEFAULT) { + if (csCtx->curFrame == cmd->startFrame) { + CutsceneCmd_DestinationDefault(play, csCtx, cmd); } - } else if (cmd->base == 2) { - if (csCtx->frames == cmd->startFrame) { - func_80165690(); + } else if (cmd->type == CS_DESTINATION_BOSS_WARP) { + if (csCtx->curFrame == cmd->startFrame) { + Play_DisableMotionBlur(); - switch (D_801F4DE2) { - case 0x1F: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { + switch (gDungeonBossWarpSceneId) { + case SCENE_MITURIN_BS: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE)) { play->nextEntrance = ENTRANCE(WOODFALL_TEMPLE, 1); play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; } else { play->nextEntrance = ENTRANCE(WOODFALL, 0); gSaveContext.nextCutsceneIndex = 0xFFF0; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; } break; - case 0x44: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { + case SCENE_HAKUGIN_BS: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE)) { play->nextEntrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 7); play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; } else { play->nextEntrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 0); gSaveContext.nextCutsceneIndex = 0xFFF0; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; } break; - case 0x5F: - SET_WEEKEVENTREG(WEEKEVENTREG_55_80); + case SCENE_SEA_BS: + SET_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE); play->nextEntrance = ENTRANCE(ZORA_CAPE, 8); gSaveContext.nextCutsceneIndex = 0xFFF0; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; - case 0x36: - SET_WEEKEVENTREG(WEEKEVENTREG_52_20); + case SCENE_INISIE_BS: + SET_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE); play->nextEntrance = ENTRANCE(IKANA_CANYON, 0); gSaveContext.nextCutsceneIndex = 0xFFF1; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; + break; + + default: break; } } } } -// Command 0x15F: Chooses between a cutscene or a rotating mask depending on whether the player has the corresponding -// mask -void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { - if ((csCtx->frames >= cmd->startFrame) && (func_801A3950(SEQ_PLAYER_BGM_MAIN, true) != 0xFF)) { - switch (cmd->base) { - case 1: - Cutscene_TerminatorImpl(play, csCtx, cmd); +// Chooses between a cutscene or a rotating mask depending on whether the player has the corresponding mask +void CutsceneCmd_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCtx, CsCmdChooseCreditsScene* cmd) { + if ((csCtx->curFrame >= cmd->startFrame) && (func_801A3950(SEQ_PLAYER_BGM_MAIN, true) != 0xFF)) { + switch (cmd->type) { + case CS_CREDITS_DESTINATION: + CutsceneCmd_DestinationDefault(play, csCtx, (CsCmdDestination*)cmd); break; - case 2: + case CS_CREDITS_MASK_KAMARO: if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { play->nextEntrance = ENTRANCE(MILK_BAR, 0); gSaveContext.nextCutsceneIndex = 0xFFF0; @@ -663,7 +691,7 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->transitionTrigger = TRANS_TRIGGER_START; break; - case 3: + case CS_CREDITS_MASK_GREAT_FAIRY: if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { play->nextEntrance = ENTRANCE(FAIRY_FOUNTAIN, 0); gSaveContext.nextCutsceneIndex = 0xFFF0; @@ -674,7 +702,7 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->transitionTrigger = TRANS_TRIGGER_START; break; - case 4: + case CS_CREDITS_MASK_ROMANI: if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) { play->nextEntrance = ENTRANCE(ROMANI_RANCH, 0); gSaveContext.nextCutsceneIndex = 0xFFF1; @@ -685,7 +713,7 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->transitionTrigger = TRANS_TRIGGER_START; break; - case 5: + case CS_CREDITS_MASK_BLAST: if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) { play->nextEntrance = ENTRANCE(WEST_CLOCK_TOWN, 0); gSaveContext.nextCutsceneIndex = 0xFFF0; @@ -696,7 +724,7 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->transitionTrigger = TRANS_TRIGGER_START; break; - case 6: + case CS_CREDITS_MASK_CIRCUS_LEADER: if (INV_CONTENT(ITEM_MASK_CIRCUS_LEADER) == ITEM_MASK_CIRCUS_LEADER) { play->nextEntrance = ENTRANCE(MILK_BAR, 0); gSaveContext.nextCutsceneIndex = 0xFFF1; @@ -707,7 +735,7 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->transitionTrigger = TRANS_TRIGGER_START; break; - case 7: + case CS_CREDITS_MASK_BREMEN: if (INV_CONTENT(ITEM_MASK_BREMEN) == ITEM_MASK_BREMEN) { play->nextEntrance = ENTRANCE(MILK_BAR, 0); gSaveContext.nextCutsceneIndex = 0xFFF3; @@ -718,13 +746,13 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->transitionTrigger = TRANS_TRIGGER_START; break; - case 8: + case CS_CREDITS_IKANA: play->nextEntrance = ENTRANCE(IKANA_CANYON, 0); gSaveContext.nextCutsceneIndex = 0xFFF3; play->transitionTrigger = TRANS_TRIGGER_START; break; - case 9: + case CS_CREDITS_MASK_COUPLE: if (INV_CONTENT(ITEM_MASK_COUPLE) == ITEM_MASK_COUPLE) { play->nextEntrance = ENTRANCE(TERMINA_FIELD, 0); gSaveContext.nextCutsceneIndex = 0xFFF8; @@ -735,7 +763,7 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->transitionTrigger = TRANS_TRIGGER_START; break; - case 10: + case CS_CREDITS_MASK_BUNNY: if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { play->nextEntrance = ENTRANCE(CUCCO_SHACK, 0); gSaveContext.nextCutsceneIndex = 0xFFF0; @@ -746,7 +774,7 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt play->transitionTrigger = TRANS_TRIGGER_START; break; - case 11: + case CS_CREDITS_MASK_POSTMAN: if (INV_CONTENT(ITEM_MASK_POSTMAN) == ITEM_MASK_POSTMAN) { play->nextEntrance = ENTRANCE(TERMINA_FIELD, 1); gSaveContext.nextCutsceneIndex = 0xFFF8; @@ -756,35 +784,36 @@ void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCt } play->transitionTrigger = TRANS_TRIGGER_START; break; + + default: + break; } } } -// Command 0x99: Motion blur -void Cutscene_Command_MotionBlur(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { - if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { - if ((csCtx->frames == cmd->startFrame) && (cmd->base == 1)) { - func_8016566C(180); +void CutsceneCmd_MotionBlur(PlayState* play, CutsceneContext* csCtx, CsCmdMotionBlur* cmd) { + if ((csCtx->curFrame >= cmd->startFrame) && (cmd->endFrame >= csCtx->curFrame)) { + if ((csCtx->curFrame == cmd->startFrame) && (cmd->type == CS_MOTION_BLUR_ENABLE)) { + Play_EnableMotionBlur(180); } - if (cmd->base == 2) { - f32 progress = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->frames); + if (cmd->type == CS_MOTION_BLUR_DISABLE) { + f32 lerp = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->curFrame); - if (progress >= 0.9f) { - func_80165690(); + if (lerp >= 0.9f) { + Play_DisableMotionBlur(); } else { - func_80165658((1.0f - progress) * 180.0f); + Play_SetMotionBlurAlpha((1.0f - lerp) * 180.0f); } } } } -// Command 0x9A: Gives Tatl to the player -void Cutscene_Command_GiveTatlToPlayer(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { +void CutsceneCmd_GiveTatlToPlayer(PlayState* play, CutsceneContext* csCtx, CsCmdGiveTatl* cmd) { Player* player = GET_PLAYER(play); - if (csCtx->frames == cmd->startFrame) { - if (cmd->base == 1) { + if (csCtx->curFrame == cmd->startFrame) { + if (cmd->giveTatl == true) { gSaveContext.save.hasTatl = true; if (player->tatlActor != NULL) { return; @@ -795,109 +824,112 @@ void Cutscene_Command_GiveTatlToPlayer(PlayState* play, CutsceneContext* csCtx, } } -// Command 0x98 -void Cutscene_Command_TransitionFX(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { - if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { - f32 temp_f0; +void CutsceneCmd_Transition(PlayState* play, CutsceneContext* csCtx, CsCmdTransition* cmd) { + if ((csCtx->curFrame >= cmd->startFrame) && (cmd->endFrame >= csCtx->curFrame)) { + f32 lerp; play->envCtx.fillScreen = true; - temp_f0 = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->frames); + lerp = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->curFrame); - switch (cmd->base) { - case 1: - case 5: + switch (cmd->type) { + case CS_TRANS_GRAY_FILL_IN: + case CS_TRANS_GRAY_FILL_OUT: play->envCtx.screenFillColor[0] = 160; play->envCtx.screenFillColor[1] = 160; play->envCtx.screenFillColor[2] = 160; - if (cmd->base == 1) { - play->envCtx.screenFillColor[3] = 255.0f * temp_f0; - if (temp_f0 == 0.0f) { + + if (cmd->type == CS_TRANS_GRAY_FILL_IN) { + play->envCtx.screenFillColor[3] = 255.0f * lerp; + if (lerp == 0.0f) { func_8019F128(NA_SE_EV_S_STONE_FLASH); } } else { - play->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + play->envCtx.screenFillColor[3] = (1.0f - lerp) * 255.0f; } break; - case 2: - case 6: + case CS_TRANS_BLUE_FILL_IN: + case CS_TRANS_BLUE_FILL_OUT: play->envCtx.screenFillColor[0] = 0; play->envCtx.screenFillColor[1] = 0; play->envCtx.screenFillColor[2] = 255; - if (cmd->base == 2) { - play->envCtx.screenFillColor[3] = 255.0f * temp_f0; + if (cmd->type == CS_TRANS_BLUE_FILL_IN) { + play->envCtx.screenFillColor[3] = 255.0f * lerp; } else { - play->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + play->envCtx.screenFillColor[3] = (1.0f - lerp) * 255.0f; } break; - case 3: - case 7: + case CS_TRANS_RED_FILL_OUT: + case CS_TRANS_RED_FILL_IN: play->envCtx.screenFillColor[0] = 255; play->envCtx.screenFillColor[1] = 0; play->envCtx.screenFillColor[2] = 0; - if (cmd->base == 3) { - play->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + if (cmd->type == CS_TRANS_RED_FILL_OUT) { + play->envCtx.screenFillColor[3] = (1.0f - lerp) * 255.0f; } else { - play->envCtx.screenFillColor[3] = 255.0f * temp_f0; + play->envCtx.screenFillColor[3] = 255.0f * lerp; } break; - case 4: - case 8: + case CS_TRANS_GREEN_FILL_OUT: + case CS_TRANS_GREEN_FILL_IN: play->envCtx.screenFillColor[0] = 0; play->envCtx.screenFillColor[1] = 255; play->envCtx.screenFillColor[2] = 0; - if (cmd->base == 4) { - play->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + if (cmd->type == CS_TRANS_GREEN_FILL_OUT) { + play->envCtx.screenFillColor[3] = (1.0f - lerp) * 255.0f; } else { - play->envCtx.screenFillColor[3] = 255.0f * temp_f0; + play->envCtx.screenFillColor[3] = 255.0f * lerp; } break; - case 9: + case CS_TRANS_TRIGGER_INSTANCE: gSaveContext.cutsceneTransitionControl = 1; break; - case 10: - case 11: + case CS_TRANS_BLACK_FILL_OUT: + case CS_TRANS_BLACK_FILL_IN: play->envCtx.screenFillColor[0] = 0; play->envCtx.screenFillColor[1] = 0; play->envCtx.screenFillColor[2] = 0; - if (cmd->base == 10) { - play->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + if (cmd->type == CS_TRANS_BLACK_FILL_OUT) { + play->envCtx.screenFillColor[3] = (1.0f - lerp) * 255.0f; } else { - play->envCtx.screenFillColor[3] = 255.0f * temp_f0; + play->envCtx.screenFillColor[3] = 255.0f * lerp; } break; - case 12: - play->envCtx.screenFillColor[0] = (160.0f * (1.0f - temp_f0)); + case CS_TRANS_GRAY_TO_BLACK: + play->envCtx.screenFillColor[0] = (1.0f - lerp) * 160.0f; play->envCtx.screenFillColor[1] = play->envCtx.screenFillColor[0]; play->envCtx.screenFillColor[2] = play->envCtx.screenFillColor[0]; play->envCtx.screenFillColor[3] = 255; break; - case 13: - play->envCtx.screenFillColor[0] = (160.0f * temp_f0); + case CS_TRANS_BLACK_TO_GRAY: + play->envCtx.screenFillColor[0] = 160.0f * lerp; play->envCtx.screenFillColor[1] = play->envCtx.screenFillColor[0]; play->envCtx.screenFillColor[2] = play->envCtx.screenFillColor[0]; play->envCtx.screenFillColor[3] = 255; break; + + default: + break; } } } -// Command 0x5A: Camera -s32 Cutscene_Command_Camera(PlayState* play, u8* cmd) { - s32 sp1C = 0; +s32 CutsceneCmd_UpdateCamSpline(PlayState* play, u8* script) { + s32 cmdBytes = 0; + + bcopy(script, &cmdBytes, sizeof(cmdBytes)); + script += sizeof(cmdBytes); - bcopy(cmd, &sp1C, sizeof(s32)); - cmd += sizeof(s32); if (!Play_IsDebugCamEnabled()) { - func_80161998(cmd, &sCutsceneCameraInfo); + CutsceneCamera_UpdateSplines(script, &sCutsceneCameraInfo); } - return sp1C + sizeof(s32); + return cmdBytes + sizeof(cmdBytes); } /** @@ -971,144 +1003,146 @@ s32 Cutscene_CountNormalMasks(void) { return count; } -// Command 0xA: Textbox -void Cutscene_Command_Textbox(PlayState* play, CutsceneContext* csCtx, CsCmdTextbox* cmd) { - static s32 D_801BB160 = CS_TEXTBOX_TYPE_DEFAULT; +void CutsceneCmd_Text(PlayState* play, CutsceneContext* csCtx, CsCmdText* cmd) { + static s32 sCutsceneTextboxType = CS_TEXT_TYPE_DEFAULT; u8 talkState; s32 pad; - u16 originalCsFrames; - s32 pad2; + u16 endFrame; - if ((cmd->startFrame >= csCtx->frames) || ((cmd->endFrame < csCtx->frames))) { + if ((csCtx->curFrame <= cmd->startFrame) || (csCtx->curFrame > cmd->endFrame)) { return; } - if (cmd->type != CS_TEXTBOX_TYPE_LEARN_SONG) { - if (D_801BB124 != cmd->base) { - if (D_801BB160 == CS_TEXTBOX_TYPE_3) { - csCtx->frames--; + if (cmd->type != CS_TEXT_OCARINA_ACTION) { + if (sCurTextId != cmd->textId) { + if (sCutsceneTextboxType == CS_TEXT_TYPE_3) { + csCtx->curFrame--; } - D_801BB160 = CS_TEXTBOX_TYPE_1; - D_801BB124 = cmd->base; - if (cmd->type == CS_TEXTBOX_TYPE_BOSSES_REMAINS) { + sCutsceneTextboxType = CS_TEXT_TYPE_1; + sCurTextId = cmd->textId; + if (cmd->type == CS_TEXT_TYPE_BOSSES_REMAINS) { if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { - if (cmd->textId1 != 0xFFFF) { - Message_StartTextbox(play, cmd->textId1, NULL); + if (cmd->altTextId1 != 0xFFFF) { + Message_StartTextbox(play, cmd->altTextId1, NULL); } } else { - Message_StartTextbox(play, cmd->base, NULL); + Message_StartTextbox(play, cmd->textId, NULL); } - } else if (cmd->type == CS_TEXTBOX_TYPE_ALL_NORMAL_MASKS) { + } else if (cmd->type == CS_TEXT_TYPE_ALL_NORMAL_MASKS) { if (Cutscene_CountNormalMasks() == 20) { - if (cmd->textId1 != 0xFFFF) { - Message_StartTextbox(play, cmd->textId1, NULL); + if (cmd->altTextId1 != 0xFFFF) { + Message_StartTextbox(play, cmd->altTextId1, NULL); } } else { - Message_StartTextbox(play, cmd->base, NULL); + Message_StartTextbox(play, cmd->textId, NULL); } } else { - Message_StartTextbox(play, cmd->base, NULL); + Message_StartTextbox(play, cmd->textId, NULL); } - } else { - goto else_label; + //! FAKE: return; + goto end; } - } else if (D_801BB128 != cmd->base) { - D_801BB160 = CS_TEXTBOX_TYPE_LEARN_SONG; - D_801BB128 = cmd->base; - func_80152434(play, cmd->base); } else { - else_label: - if (csCtx->frames >= cmd->endFrame) { - // The Textbox command can change the current cutscene frame, mainly to prevent advancing the cutscene when - // a textbox that is expected to be closed by the user is still open. - - originalCsFrames = csCtx->frames; - talkState = Message_GetState(&play->msgCtx); - if ((talkState != TEXT_STATE_CLOSING) && (talkState != TEXT_STATE_NONE) && (talkState != TEXT_STATE_7) && - (talkState != TEXT_STATE_8)) { - csCtx->frames--; - if ((talkState == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { - if (play->msgCtx.choiceIndex == 0) { - if (cmd->base == 0x33BD) { - func_8019F230(); - } - - if (cmd->textId1 != 0xFFFF) { - func_80151938(play, cmd->textId1); - if (cmd->type == CS_TEXTBOX_TYPE_3) { - D_801BB160 = CS_TEXTBOX_TYPE_3; - if (cmd->textId2 != 0xFFFF) { - csCtx->frames++; - } - } - } else { - func_801477B4(play); - csCtx->frames++; - } - } else { - if (cmd->base == 0x33BD) { - func_8019F208(); - } - - if (cmd->textId2 != 0xFFFF) { - func_80151938(play, cmd->textId2); - if (cmd->type == CS_TEXTBOX_TYPE_3) { - D_801BB160 = CS_TEXTBOX_TYPE_3; - if (cmd->textId1 != 0xFFFF) { - csCtx->frames++; - } - } - } else { - func_801477B4(play); - csCtx->frames++; - } - } - } - - if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_80152434(play, cmd->base); - } - } - - if ((talkState == TEXT_STATE_CLOSING) && (D_801BB160 == CS_TEXTBOX_TYPE_3)) { - csCtx->frames--; - D_801BB124++; - } - - if (originalCsFrames == csCtx->frames) { - Interface_SetHudVisibility(HUD_VISIBILITY_NONE); - D_801BB124 = 0; - D_801BB128 = 0; - func_80161C0C(); - } else { - func_80161BE0(1); - } + if (sCurOcarinaAction != cmd->textId) { + sCutsceneTextboxType = CS_TEXT_OCARINA_ACTION; + sCurOcarinaAction = cmd->textId; + func_80152434(play, cmd->textId); + return; } } -} -// Related to actorActions. Maybe a generic actorAction setter? -void func_800ECD7C(CutsceneContext* csCtx, u8** cutscenePtr, s16 index) { - s32 i; - s32 count; + if (csCtx->curFrame >= cmd->endFrame) { + // The Textbox command can change the current cutscene frame, mainly to prevent advancing the cutscene when + // a textbox that is expected to be closed by the user is still open. + endFrame = csCtx->curFrame; + talkState = Message_GetState(&play->msgCtx); + if ((talkState != TEXT_STATE_CLOSING) && (talkState != TEXT_STATE_NONE) && (talkState != TEXT_STATE_7) && + (talkState != TEXT_STATE_8)) { + csCtx->curFrame--; - bcopy(*cutscenePtr, &count, sizeof(s32)); - *cutscenePtr += sizeof(s32); + if ((talkState == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + if (play->msgCtx.choiceIndex == 0) { + if (cmd->textId == 0x33BD) { + // Gorman Track: do you understand? + func_8019F230(); + } - for (i = 0; i < count; i++) { - CsCmdActorAction* actorAction = *(CsCmdActorAction**)cutscenePtr; + if (cmd->altTextId1 != 0xFFFF) { + Message_ContinueTextbox(play, cmd->altTextId1); + if (cmd->type == CS_TEXT_TYPE_3) { + sCutsceneTextboxType = CS_TEXT_TYPE_3; + if (cmd->altTextId2 != 0xFFFF) { + csCtx->curFrame++; + } + } + } else { + Message_CloseTextbox(play); + csCtx->curFrame++; + } + } else { + if (cmd->textId == 0x33BD) { + // Gorman Track: do you understand? + func_8019F208(); + } - if ((csCtx->frames >= actorAction->startFrame) && (csCtx->frames < actorAction->endFrame)) { - csCtx->actorActions[index] = actorAction; + if (cmd->altTextId2 != 0xFFFF) { + Message_ContinueTextbox(play, cmd->altTextId2); + if (cmd->type == CS_TEXT_TYPE_3) { + sCutsceneTextboxType = CS_TEXT_TYPE_3; + if (cmd->altTextId1 != 0xFFFF) { + csCtx->curFrame++; + } + } + } else { + Message_CloseTextbox(play); + csCtx->curFrame++; + } + } + } + + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_80152434(play, cmd->textId); + } } - *cutscenePtr += sizeof(CsCmdActorAction); + if ((talkState == TEXT_STATE_CLOSING) && (sCutsceneTextboxType == CS_TEXT_TYPE_3)) { + csCtx->curFrame--; + sCurTextId++; + } + + if (endFrame == csCtx->curFrame) { + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); + sCurTextId = 0; + sCurOcarinaAction = 0; + CutsceneCamera_Reset(); + } else { + CutsceneCamera_SetState(CS_CAM_STATE_UPDATE_SPLINE); + } + } +end:; +} + +void Cutscene_SetActorCue(CutsceneContext* csCtx, u8** script, s16 cueChannel) { + s32 i; + s32 numCues; + + bcopy(*script, &numCues, sizeof(numCues)); + *script += sizeof(numCues); + + for (i = 0; i < numCues; i++) { + CsCmdActorCue* cue = *(CsCmdActorCue**)script; + + if ((csCtx->curFrame >= cue->startFrame) && (csCtx->curFrame < cue->endFrame)) { + csCtx->actorCues[cueChannel] = cue; + } + + *script += sizeof(CsCmdActorCue); } } /** - * Loops over the cutscene data itself (`cutscenePtr`), applying the effects of each command instantaneously (for most + * Loops over the cutscene data itself (`script`), applying the effects of each command instantaneously (for most * commands). * * The cutscene data is an irregularly-structured array of words, which is made up of @@ -1125,15 +1159,15 @@ void func_800ECD7C(CutsceneContext* csCtx, u8** cutscenePtr, s16 index) { * has (N). This is followed by N commands of the said category. (The exception is Camera, which has the length of the * list in bytes instead of the number of commands). * - * For most command lists categories (all but the actorActions and Camera commands): + * For most command lists categories (all but the actorCues and Camera commands): * - For each command list found, read the number of commands and loop over them, passing each one to the corresponding * function which handles the command, applying its effects and checking the frame range stored in the command. * * This function is invoked once per frame that a cutscene is active. * - * TODO: consider changing the type of `cutscenePtr` to `uintptr_t` when this function matches. + * TODO: consider changing the type of `script` to `uintptr_t` when this function matches. */ -void Cutscene_ProcessCommands(PlayState* play, CutsceneContext* csCtx, u8* cutscenePtr) { +void Cutscene_ProcessScript(PlayState* play, CutsceneContext* csCtx, u8* script) { s32 i; s32 j; s32 pad; @@ -1141,44 +1175,46 @@ void Cutscene_ProcessCommands(PlayState* play, CutsceneContext* csCtx, u8* cutsc u32 cmdType; s32 cmdEntries; s32 pad2; - s32 cutsceneEndFrame; - CsCmdBase* cmd; + s32 csFrameCount; + void* cmd; // Read the command list count and the ending frame for this cutscene - bcopy(cutscenePtr, &totalEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); - bcopy(cutscenePtr, &cutsceneEndFrame, sizeof(s32)); - cutscenePtr += sizeof(s32); + bcopy(script, &totalEntries, sizeof(totalEntries)); + script += sizeof(totalEntries); - if (((u16)cutsceneEndFrame < csCtx->frames) && (play->transitionTrigger != TRANS_TRIGGER_START) && - (csCtx->state != CS_STATE_4)) { - csCtx->state = CS_STATE_3; + bcopy(script, &csFrameCount, sizeof(csFrameCount)); + script += sizeof(csFrameCount); + + if ((csCtx->curFrame > (u16)csFrameCount) && (play->transitionTrigger != TRANS_TRIGGER_START) && + (csCtx->state != CS_STATE_RUN_UNSTOPPABLE)) { + csCtx->state = CS_STATE_STOP; return; } // Loop over every command list for (i = 0; i < totalEntries; i++) { // Read the command type of the current command list. - bcopy(cutscenePtr, &cmdType, sizeof(u32)); - cutscenePtr += sizeof(u32); + bcopy(script, &cmdType, sizeof(cmdType)); + script += sizeof(cmdType); - // TODO: This should probably be added to the CutsceneCmd enum. Consider doing it when this function matches. - if (cmdType == 0xFFFFFFFF) { + if (cmdType == CS_CAM_STOP) { break; } - // Check special cases of command types. This are generic ActorActions - // Ranges: [0x64, 0x96), 0xC9, [0x1C2, 0x258) - if (((cmdType >= 100) && (cmdType < 150)) || (cmdType == 201) || ((cmdType >= 450) && (cmdType < 600))) { - for (j = 0; j < ARRAY_COUNT(D_801F4DC8); j = (s16)(j + 1)) { - if (D_801F4DC8[j] == (u16)cmdType) { - func_800ECD7C(csCtx, &cutscenePtr, j); - cmdType = -2; + if (((cmdType >= CS_CMD_ACTOR_CUE_100) && (cmdType <= CS_CMD_ACTOR_CUE_149)) || + (cmdType == CS_CMD_ACTOR_CUE_201) || + ((cmdType >= CS_CMD_ACTOR_CUE_450) && (cmdType <= CS_CMD_ACTOR_CUE_599))) { + for (j = 0; j < ARRAY_COUNT(sCueTypeList); j = (s16)(j + 1)) { + if (sCueTypeList[j] == (u16)cmdType) { + Cutscene_SetActorCue(csCtx, &script, j); + cmdType = CS_CMD_ACTOR_CUE_POST_PROCESS; break; - } else if (D_801F4DC8[j] == 0) { - D_801F4DC8[j] = cmdType; - func_800ECD7C(csCtx, &cutscenePtr, j); - cmdType = -2; + } + + if (sCueTypeList[j] == 0) { + sCueTypeList[j] = cmdType; + Cutscene_SetActorCue(csCtx, &script, j); + cmdType = CS_CMD_ACTOR_CUE_POST_PROCESS; break; } } @@ -1186,203 +1222,227 @@ void Cutscene_ProcessCommands(PlayState* play, CutsceneContext* csCtx, u8* cutsc switch (cmdType) { case CS_CMD_MISC: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_Misc(play, csCtx, (CsCmdBase*)cutscenePtr); - cutscenePtr += sizeof(CsCmdBase); + CutsceneCmd_Misc(play, csCtx, (CsCmdMisc*)script); + script += sizeof(CsCmdMisc); } break; - case CS_CMD_SET_LIGHTING: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_LIGHT_SETTING: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_SetLighting(play, csCtx, (CsCmdEnvLighting*)cutscenePtr); - cutscenePtr += sizeof(CsCmdEnvLighting); + CutsceneCmd_SetLightSetting(play, csCtx, (CsCmdLightSetting*)script); + script += sizeof(CsCmdLightSetting); } break; - case CS_CMD_PLAYSEQ: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_START_SEQ: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_PlaySequence(play, csCtx, (CsCmdSequenceChange*)cutscenePtr); - cutscenePtr += sizeof(CsCmdSequenceChange); + CutsceneCmd_StartSequence(play, csCtx, (CsCmdStartSeq*)script); + script += sizeof(CsCmdStartSeq); } break; - case CS_CMD_STOPSEQ: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_STOP_SEQ: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_StopSequence(play, csCtx, (CsCmdSequenceChange*)cutscenePtr); - cutscenePtr += sizeof(CsCmdSequenceChange); + CutsceneCmd_StopSequence(play, csCtx, (CsCmdStopSeq*)script); + script += sizeof(CsCmdStartSeq); } break; - case CS_CMD_FADESEQ: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_FADE_OUT_SEQ: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_FadeSequence(play, csCtx, (CsCmdSequenceFade*)cutscenePtr); - cutscenePtr += sizeof(CsCmdSequenceFade); + CutsceneCmd_FadeOutSequence(play, csCtx, (CsCmdFadeOutSeq*)script); + script += sizeof(CsCmdFadeOutSeq); } break; - case CS_CMD_PLAYAMBIENCE: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_START_AMBIENCE: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_PlayAmbienceSequence(play, csCtx, (CsCmdBase*)cutscenePtr); - cutscenePtr += sizeof(CsCmdBase); + CutsceneCmd_StartAmbience(play, csCtx, (CsCmdStartAmbience*)script); + script += sizeof(CsCmdStartAmbience); } break; - case CS_CMD_FADEAMBIENCE: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_FADE_OUT_AMBIENCE: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_FadeAmbienceSequence(play, csCtx, (CsCmdBase*)cutscenePtr); - cutscenePtr += sizeof(CsCmdBase); + CutsceneCmd_FadeOutAmbience(play, csCtx, (CsCmdFadeOutAmbience*)script); + script += sizeof(CsCmdFadeOutAmbience); } break; - case CS_CMD_130: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_SFX_REVERB_INDEX_2: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - func_800EAD48(play, csCtx, (CsCmdBase*)cutscenePtr); - cutscenePtr += sizeof(CsCmdBase); + Cutscene_SetSfxReverbIndexTo2(play, csCtx, (CsCmdSfxReverbIndexTo2*)script); + script += sizeof(CsCmdSfxReverbIndexTo2); } break; - case CS_CMD_131: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_SFX_REVERB_INDEX_1: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - func_800EAD7C(play, csCtx, (CsCmdBase*)cutscenePtr); - cutscenePtr += sizeof(CsCmdBase); + Cutscene_SetSfxReverbIndexTo1(play, csCtx, (CsCmdSfxReverbIndexTo1*)script); + script += sizeof(CsCmdSfxReverbIndexTo1); } break; - case CS_CMD_132: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_MODIFY_SEQ: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - func_800EADB0(play, csCtx, (CsCmdBase*)cutscenePtr); - cutscenePtr += sizeof(CsCmdBase); + CutsceneCmd_ModifySequence(play, csCtx, (CsCmdModifySeq*)script); + script += sizeof(CsCmdModifySeq); } break; case CS_CMD_RUMBLE: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_Rumble(play, csCtx, (CsCmdRumble*)cutscenePtr); - cutscenePtr += sizeof(CsCmdRumble); + CutsceneCmd_RumbleController(play, csCtx, (CsCmdRumble*)script); + script += sizeof(CsCmdRumble); } break; - case CS_CMD_FADESCREEN: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_TRANSITION_GENERAL: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_FadeColorScreen(play, csCtx, (CsCmdFadeScreen*)cutscenePtr); - cutscenePtr += sizeof(CsCmdFadeScreen); + CutsceneCmd_TransitionGeneral(play, csCtx, (CsCmdTransitionGeneral*)script); + script += sizeof(CsCmdTransitionGeneral); } break; - case CS_CMD_SETTIME: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_TIME: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_SetTime(play, csCtx, (CsCmdDayTime*)cutscenePtr); - cutscenePtr += sizeof(CsCmdDayTime); + CutsceneCmd_SetTime(play, csCtx, (CsCmdTime*)script); + script += sizeof(CsCmdTime); } break; - case CS_CMD_SET_PLAYER_ACTION: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_PLAYER_CUE: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - cmd = (CsCmdBase*)cutscenePtr; - if ((cmd->startFrame <= csCtx->frames) && (csCtx->frames < cmd->endFrame)) { - csCtx->playerAction = (CsCmdActorAction*)cmd; + cmd = script; + + if ((((CsCmdActorCue*)cmd)->startFrame <= csCtx->curFrame) && + (csCtx->curFrame < ((CsCmdActorCue*)cmd)->endFrame)) { + csCtx->playerCue = (CsCmdActorCue*)cmd; } - cutscenePtr += sizeof(CsCmdActorAction); + script += sizeof(CsCmdActorCue); } break; - case CS_CMD_CAMERA: - cutscenePtr += Cutscene_Command_Camera(play, cutscenePtr); + case CS_CMD_CAMERA_SPLINE: + script += CutsceneCmd_UpdateCamSpline(play, script); break; - case CS_CMD_TERMINATOR: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_DESTINATION: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_Terminator(play, csCtx, (CsCmdBase*)cutscenePtr); - cutscenePtr += sizeof(CsCmdBase); + CutsceneCmd_Destination(play, csCtx, (CsCmdDestination*)script); + script += sizeof(CsCmdDestination); } break; case CS_CMD_CHOOSE_CREDITS_SCENES: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_ChooseCreditsScenes(play, csCtx, (CsCmdBase*)cutscenePtr); - cutscenePtr += sizeof(CsCmdBase); + CutsceneCmd_ChooseCreditsScenes(play, csCtx, (CsCmdChooseCreditsScene*)script); + script += sizeof(CsCmdChooseCreditsScene); } break; - case CS_CMD_TEXTBOX: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_TEXT: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - cmd = (CsCmdBase*)cutscenePtr; - if (cmd->base != 0xFFFF) { - Cutscene_Command_Textbox(play, csCtx, (CsCmdTextbox*)cmd); + cmd = script; + + if (((CsCmdText*)cmd)->textId != 0xFFFF) { + CutsceneCmd_Text(play, csCtx, (CsCmdText*)cmd); } - cutscenePtr += sizeof(CsCmdTextbox); + script += sizeof(CsCmdText); } break; - case CS_CMD_SCENE_TRANS_FX: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_TRANSITION: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_TransitionFX(play, csCtx, (CsCmdBase*)cutscenePtr); - cutscenePtr += sizeof(CsCmdBase); + CutsceneCmd_Transition(play, csCtx, (CsCmdTransition*)script); + script += sizeof(CsCmdTransition); } break; - case CS_CMD_MOTIONBLUR: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_MOTION_BLUR: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_MotionBlur(play, csCtx, (CsCmdBase*)cutscenePtr); - cutscenePtr += sizeof(CsCmdBase); + CutsceneCmd_MotionBlur(play, csCtx, (CsCmdMotionBlur*)script); + script += sizeof(CsCmdMotionBlur); } break; - case CS_CMD_GIVETATL: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + case CS_CMD_GIVE_TATL: + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_GiveTatlToPlayer(play, csCtx, (CsCmdBase*)cutscenePtr); - cutscenePtr += sizeof(CsCmdBase); + CutsceneCmd_GiveTatlToPlayer(play, csCtx, (CsCmdGiveTatl*)script); + script += sizeof(CsCmdGiveTatl); } break; - case -2: + case CS_CMD_ACTOR_CUE_POST_PROCESS: break; default: - bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); - cutscenePtr += sizeof(s32); + bcopy(script, &cmdEntries, sizeof(cmdEntries)); + script += sizeof(cmdEntries); + for (j = 0; j < cmdEntries; j++) { - cutscenePtr += sizeof(CsCmdBase); + script += sizeof(CsCmdUnimplemented); } break; } @@ -1391,118 +1451,125 @@ void Cutscene_ProcessCommands(PlayState* play, CutsceneContext* csCtx, u8* cutsc /* End of command handling section */ -void func_800ED980(PlayState* play, CutsceneContext* csCtx) { - if (gSaveContext.save.cutscene >= 0xFFF0) { - csCtx->frames++; - Cutscene_ProcessCommands(play, csCtx, (u8*)play->csCtx.csData); +void CutsceneHandler_RunScript(PlayState* play, CutsceneContext* csCtx) { + if (gSaveContext.save.cutsceneIndex >= 0xFFF0) { + csCtx->curFrame++; + Cutscene_ProcessScript(play, csCtx, (u8*)play->csCtx.script); } } -void func_800ED9C4(PlayState* play, CutsceneContext* csCtx) { - if (func_800EA220(play, csCtx, 0.0f)) { +void CutsceneHandler_StopManual(PlayState* play, CutsceneContext* csCtx) { + if (Cutscene_StepTimer(play, csCtx, 0.0f)) { Audio_SetCutsceneFlag(false); - csCtx->state = CS_STATE_0; + csCtx->state = CS_STATE_IDLE; } } -// unused -void func_800EDA04(PlayState* play, CutsceneContext* csCtx) { - if (func_800EA220(play, csCtx, 0.0f)) { +void CutsceneHandler_StopScript(PlayState* play, CutsceneContext* csCtx) { + if (Cutscene_StepTimer(play, csCtx, 0.0f)) { s16 i; - csCtx->playerAction = NULL; + csCtx->playerCue = NULL; - for (i = 0; i < ARRAY_COUNT(csCtx->actorActions); i++) { - csCtx->actorActions[i] = NULL; + for (i = 0; i < ARRAY_COUNT(csCtx->actorCues); i++) { + csCtx->actorCues[i] = NULL; } - gSaveContext.save.cutscene = 0; - gSaveContext.gameMode = 0; - ActorCutscene_Stop(0x7F); + gSaveContext.save.cutsceneIndex = 0; + gSaveContext.gameMode = GAMEMODE_NORMAL; + + CutsceneManager_Stop(CS_ID_GLOBAL_END); Audio_SetCutsceneFlag(false); - csCtx->state = CS_STATE_0; + csCtx->state = CS_STATE_IDLE; } } -void func_800EDA84(PlayState* play, CutsceneContext* csCtx) { - if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0) && !Player_InCsMode(play)) { - gSaveContext.save.cutscene = 0xFFFD; +void Cutscene_SetupScripted(PlayState* play, CutsceneContext* csCtx) { + if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_IDLE) && !Player_InCsMode(play)) { + gSaveContext.save.cutsceneIndex = 0xFFFD; } - if ((gSaveContext.save.cutscene >= 0xFFF0) && (csCtx->state == CS_STATE_0)) { + if ((gSaveContext.save.cutsceneIndex >= 0xFFF0) && (csCtx->state == CS_STATE_IDLE)) { s16 i; - D_801BB124 = 0; - D_801BB128 = 0; - csCtx->playerAction = NULL; + sCurTextId = 0; + sCurOcarinaAction = 0; + csCtx->playerCue = NULL; - for (i = 0; i < ARRAY_COUNT(csCtx->actorActions); i++) { - csCtx->actorActions[i] = NULL; + for (i = 0; i < ARRAY_COUNT(csCtx->actorCues); i++) { + csCtx->actorCues[i] = NULL; } - csCtx->state++; - if (csCtx->state == CS_STATE_1) { + csCtx->state++; // CS_STATE_START + + if (csCtx->state == CS_STATE_START) { Audio_SetCutsceneFlag(true); - csCtx->frames = 0xFFFF; - csCtx->subCamId = ActorCutscene_GetCurrentSubCamId(0x7F); - func_8016119C(Play_GetCamera(play, csCtx->subCamId), &sCutsceneCameraInfo); - csCtx->unk_18 = 0xFFFF; + csCtx->curFrame = 0xFFFF; + + csCtx->subCamId = CutsceneManager_GetCurrentSubCamId(CS_ID_GLOBAL_END); + CutsceneCamera_Init(Play_GetCamera(play, csCtx->subCamId), &sCutsceneCameraInfo); + + // OoT Remnant + csCtx->camEyeSplinePointsAppliedFrame = CS_CAM_DATA_NOT_APPLIED; if (gSaveContext.cutsceneTrigger == 0) { Interface_SetHudVisibility(HUD_VISIBILITY_NONE); ShrinkWindow_Letterbox_SetSizeTarget(32); ShrinkWindow_Letterbox_SetSize(32); - csCtx->state++; + csCtx->state++; // CS_STATE_RUN } - func_800ED980(play, csCtx); + CutsceneHandler_RunScript(play, csCtx); } gSaveContext.cutsceneTrigger = 0; } } -// HandleFlags? -void func_800EDBE0(PlayState* play) { +void Cutscene_HandleEntranceTriggers(PlayState* play) { s32 pad; - s16 sp2A; - SceneTableEntry* sp24; - s32 temp_v0_3; + s16 csId; + SceneTableEntry* scene; + s32 scriptIndex; - if (((gSaveContext.gameMode == 0) || (gSaveContext.gameMode == 1)) && (gSaveContext.respawnFlag <= 0)) { - sp2A = func_800F21CC(); - if (sp2A != -1) { - temp_v0_3 = func_800F2138(sp2A); - if (temp_v0_3 != -1) { - if ((play->csCtx.sceneCsList[temp_v0_3].unk7 != 0xFF) && (gSaveContext.respawnFlag == 0)) { - if (play->csCtx.sceneCsList[temp_v0_3].unk7 == 0xFE) { - ActorCutscene_Start(sp2A, NULL); + if (((gSaveContext.gameMode == GAMEMODE_NORMAL) || (gSaveContext.gameMode == GAMEMODE_TITLE_SCREEN)) && + (gSaveContext.respawnFlag <= 0)) { + // Try to find an actor cutscene that's triggered by the current spawn + csId = CutsceneManager_FindEntranceCsId(); + if (csId != CS_ID_NONE) { + scriptIndex = CutsceneManager_GetCutsceneScriptIndex(csId); + if (scriptIndex != CS_SCRIPT_ID_NONE) { + // A scripted cutscene is triggered by a spawn + if ((play->csCtx.scriptList[scriptIndex].spawnFlags != CS_SPAWN_FLAG_NONE) && + (gSaveContext.respawnFlag == 0)) { + if (play->csCtx.scriptList[scriptIndex].spawnFlags == CS_SPAWN_FLAG_ALWAYS) { + // Entrance cutscenes that always run + CutsceneManager_Start(csId, NULL); gSaveContext.showTitleCard = false; - } else if (!(((void)0, - gSaveContext.save.weekEventReg[(play->csCtx.sceneCsList[temp_v0_3].unk7 / 8)]) & - (1 << (play->csCtx.sceneCsList[temp_v0_3].unk7 % 8)))) { - // TODO: macros for this kind of weekEventReg access - gSaveContext.save.weekEventReg[(play->csCtx.sceneCsList[temp_v0_3].unk7 / 8)] = - ((void)0, gSaveContext.save.weekEventReg[(play->csCtx.sceneCsList[temp_v0_3].unk7 / 8)]) | - (1 << (play->csCtx.sceneCsList[temp_v0_3].unk7 % 8)); - ActorCutscene_Start(sp2A, NULL); + + } else if (!CHECK_CS_SPAWN_FLAG_WEEKEVENTREG(play->csCtx.scriptList[scriptIndex].spawnFlags)) { + // Entrance cutscenes that only run once + SET_CS_SPAWN_FLAG_WEEKEVENTREG(play->csCtx.scriptList[scriptIndex].spawnFlags); + CutsceneManager_Start(csId, NULL); + // The title card will be used by the cs misc command if necessary. gSaveContext.showTitleCard = false; } } } else { - ActorCutscene_StartAndSetUnkLinkFields(sp2A, NULL); + // A non-scripted cutscene is triggered by a spawn + CutsceneManager_StartWithPlayerCs(csId, NULL); } } } if ((gSaveContext.respawnFlag == 0) || (gSaveContext.respawnFlag == -2)) { - sp24 = play->loadedScene; - if ((sp24->titleTextId != 0) && gSaveContext.showTitleCard) { + scene = play->loadedScene; + if ((scene->titleTextId != 0) && gSaveContext.showTitleCard) { if ((Entrance_GetTransitionFlags(((void)0, gSaveContext.save.entrance) + ((void)0, gSaveContext.sceneLayer)) & 0x4000) != 0) { - func_80151A68(play, sp24->titleTextId); + func_80151A68(play, scene->titleTextId); } } @@ -1516,10 +1583,10 @@ void func_800EDDB0(PlayState* play) { void func_800EDDBC(UNK_TYPE arg0, UNK_TYPE arg1) { } -void Cutscene_LoadCutsceneData(PlayState* play, u8 csIndex) { - if (dREG(95) == 0) { - play->csCtx.currentCsIndex = csIndex; - play->csCtx.csData = Lib_SegmentedToVirtual(play->csCtx.sceneCsList[csIndex].segmentedData); +void Cutscene_StartScripted(PlayState* play, u8 scriptIndex) { + if (!R_USE_DEBUG_CUTSCENE) { + play->csCtx.scriptIndex = scriptIndex; + play->csCtx.script = Lib_SegmentedToVirtual(play->csCtx.scriptList[scriptIndex].script); } gSaveContext.cutsceneTrigger = 1; @@ -1531,32 +1598,32 @@ void Cutscene_LoadCutsceneData(PlayState* play, u8 csIndex) { * Interpolates the actor's position based on the corresponding actor action's position * and the current cutscene frame */ -void Cutscene_ActorTranslate(Actor* actor, PlayState* play, s32 actorActionIndex) { - Vec3f start; - Vec3f end; - CsCmdActorAction* entry = play->csCtx.actorActions[actorActionIndex]; - f32 progress; +void Cutscene_ActorTranslate(Actor* actor, PlayState* play, s32 cueChannel) { + Vec3f startPos; + Vec3f endPos; + CsCmdActorCue* cue = play->csCtx.actorCues[cueChannel]; + f32 lerp; - start.x = entry->startPos.x; - start.y = entry->startPos.y; - start.z = entry->startPos.z; - end.x = entry->endPos.x; - end.y = entry->endPos.y; - end.z = entry->endPos.z; + startPos.x = cue->startPos.x; + startPos.y = cue->startPos.y; + startPos.z = cue->startPos.z; + endPos.x = cue->endPos.x; + endPos.y = cue->endPos.y; + endPos.z = cue->endPos.z; - progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, play->csCtx.frames); + lerp = Environment_LerpWeight(cue->endFrame, cue->startFrame, play->csCtx.curFrame); - VEC3F_LERPIMPDST(&actor->world.pos, &start, &end, progress); + VEC3F_LERPIMPDST(&actor->world.pos, &startPos, &endPos, lerp); } /** * Interpolates the actor's position based on the corresponding actor action's position * and the current cutscene frame, and sets the actor's yaw using the actor action yaw */ -void Cutscene_ActorTranslateAndYaw(Actor* actor, PlayState* play, s32 actorActionIndex) { - Cutscene_ActorTranslate(actor, play, actorActionIndex); +void Cutscene_ActorTranslateAndYaw(Actor* actor, PlayState* play, s32 cueChannel) { + Cutscene_ActorTranslate(actor, play, cueChannel); - actor->world.rot.y = play->csCtx.actorActions[actorActionIndex]->urot.y; + actor->world.rot.y = play->csCtx.actorCues[cueChannel]->rot.y; actor->shape.rot.y = actor->world.rot.y; } @@ -1564,25 +1631,25 @@ void Cutscene_ActorTranslateAndYaw(Actor* actor, PlayState* play, s32 actorActio * Interpolates the actor's position and yaw based on the corresponding actor action's * position and the current cutscene frame */ -void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, PlayState* play, s32 actorActionIndex) { - Vec3f start; - Vec3f end; - CsCmdActorAction* entry; - f32 progress; +void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, PlayState* play, s32 cueChannel) { + Vec3f startPos; + Vec3f endPos; + CsCmdActorCue* cue; + f32 lerp; - start.x = play->csCtx.actorActions[actorActionIndex]->startPos.x; - start.y = play->csCtx.actorActions[actorActionIndex]->startPos.y; - start.z = play->csCtx.actorActions[actorActionIndex]->startPos.z; - end.x = play->csCtx.actorActions[actorActionIndex]->endPos.x; - end.y = play->csCtx.actorActions[actorActionIndex]->endPos.y; - end.z = play->csCtx.actorActions[actorActionIndex]->endPos.z; + startPos.x = play->csCtx.actorCues[cueChannel]->startPos.x; + startPos.y = play->csCtx.actorCues[cueChannel]->startPos.y; + startPos.z = play->csCtx.actorCues[cueChannel]->startPos.z; + endPos.x = play->csCtx.actorCues[cueChannel]->endPos.x; + endPos.y = play->csCtx.actorCues[cueChannel]->endPos.y; + endPos.z = play->csCtx.actorCues[cueChannel]->endPos.z; - entry = play->csCtx.actorActions[actorActionIndex]; - progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, play->csCtx.frames); + cue = play->csCtx.actorCues[cueChannel]; + lerp = Environment_LerpWeight(cue->endFrame, cue->startFrame, play->csCtx.curFrame); - VEC3F_LERPIMPDST(&actor->world.pos, &start, &end, progress); + VEC3F_LERPIMPDST(&actor->world.pos, &startPos, &endPos, lerp); - Math_SmoothStepToS(&actor->world.rot.y, Math_Vec3f_Yaw(&start, &end), 10, 1000, 1); + Math_SmoothStepToS(&actor->world.rot.y, Math_Vec3f_Yaw(&startPos, &endPos), 10, 1000, 1); actor->shape.rot.y = actor->world.rot.y; } @@ -1590,24 +1657,24 @@ void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, PlayState* play, s32 acto * Interpolates the actor's XZ position and yaw based on the corresponding actor action's * position and the current cutscene frame */ -void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, PlayState* play, s32 actorActionIndex) { - Vec3f start; - Vec3f end; - CsCmdActorAction* entry; - f32 progress; +void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, PlayState* play, s32 cueChannel) { + Vec3f startPos; + Vec3f endPos; + CsCmdActorCue* cue; + f32 lerp; - start.x = play->csCtx.actorActions[actorActionIndex]->startPos.x; - start.z = play->csCtx.actorActions[actorActionIndex]->startPos.z; - end.x = play->csCtx.actorActions[actorActionIndex]->endPos.x; - end.z = play->csCtx.actorActions[actorActionIndex]->endPos.z; + startPos.x = play->csCtx.actorCues[cueChannel]->startPos.x; + startPos.z = play->csCtx.actorCues[cueChannel]->startPos.z; + endPos.x = play->csCtx.actorCues[cueChannel]->endPos.x; + endPos.z = play->csCtx.actorCues[cueChannel]->endPos.z; - entry = play->csCtx.actorActions[actorActionIndex]; - progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, play->csCtx.frames); + cue = play->csCtx.actorCues[cueChannel]; + lerp = Environment_LerpWeight(cue->endFrame, cue->startFrame, play->csCtx.curFrame); - actor->world.pos.x = start.x + (end.x - start.x) * progress; - actor->world.pos.z = start.z + (end.z - start.z) * progress; + actor->world.pos.x = startPos.x + (endPos.x - startPos.x) * lerp; + actor->world.pos.z = startPos.z + (endPos.z - startPos.z) * lerp; - Math_SmoothStepToS(&actor->world.rot.y, Math_Vec3f_Yaw(&start, &end), 10, 1000, 1); + Math_SmoothStepToS(&actor->world.rot.y, Math_Vec3f_Yaw(&startPos, &endPos), 10, 1000, 1); actor->shape.rot.y = actor->world.rot.y; } @@ -1620,25 +1687,35 @@ s32 Cutscene_GetSceneLayer(PlayState* play) { return sceneLayer; } -s32 Cutscene_GetActorActionIndex(PlayState* play, u16 actorActionCmd) { +/** + * @param play See `PlayState` + * @param cueType See `cmdType` + * @return cue channel + */ +s32 Cutscene_GetCueChannel(PlayState* play, u16 cueType) { s32 i; - s32 index = -1; + s32 cueChannel = -1; - for (i = 0; i < ARRAY_COUNT(D_801F4DC8); i++) { - if (actorActionCmd == D_801F4DC8[i]) { - index = i; + for (i = 0; i < ARRAY_COUNT(sCueTypeList); i++) { + if (cueType == sCueTypeList[i]) { + cueChannel = i; } } - return index; + return cueChannel; } -s32 Cutscene_CheckActorAction(PlayState* play, u16 actorActionCmd) { - if (play->csCtx.state != CS_STATE_0) { - s32 index = Cutscene_GetActorActionIndex(play, actorActionCmd); +/** + * @param play See `PlayState` + * @param cueType See `cmdType` + * @return is cuetype in a channel + */ +s32 Cutscene_IsCueInChannel(PlayState* play, u16 cueType) { + if (play->csCtx.state != CS_STATE_IDLE) { + s32 cueChannel = Cutscene_GetCueChannel(play, cueType); - if (index != -1) { - return play->csCtx.actorActions[index] != NULL; + if (cueChannel != -1) { + return play->csCtx.actorCues[cueChannel] != NULL; } } @@ -1646,7 +1723,7 @@ s32 Cutscene_CheckActorAction(PlayState* play, u16 actorActionCmd) { } u8 Cutscene_IsPlaying(PlayState* play) { - return (gSaveContext.cutsceneTrigger != 0) || (play->csCtx.state != CS_STATE_0); + return (gSaveContext.cutsceneTrigger != 0) || (play->csCtx.state != CS_STATE_IDLE); } /* End of actor utilities section */ diff --git a/src/code/z_draw.c b/src/code/z_draw.c index 4167b4cea..a2686be8e 100644 --- a/src/code/z_draw.c +++ b/src/code/z_draw.c @@ -837,7 +837,7 @@ void GetItem_DrawRemains(PlayState* play, s16 drawId) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/code/z_eff_footmark.c b/src/code/z_eff_footmark.c index 1dc3d7237..bcf6ff824 100644 --- a/src/code/z_eff_footmark.c +++ b/src/code/z_eff_footmark.c @@ -1,14 +1,19 @@ -#include "global.h" +#include "z64eff_footmark.h" +#include "z64.h" +#include "macros.h" +#include "functions.h" + +#include "assets/code/eff_footmark/eff_footmark.c" void EffFootmark_Init(PlayState* play) { EffFootmark* footmark; s32 i; - for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) { + for (footmark = play->footprintInfo, i = 0; i < ARRAY_COUNT(play->footprintInfo); i++, footmark++) { footmark->actor = NULL; - footmark->location.x = 0; - footmark->location.y = 0; - footmark->location.z = 0; + footmark->pos.x = 0; + footmark->pos.y = 0; + footmark->pos.z = 0; footmark->flags = 0; footmark->id = 0; footmark->alpha = 0; @@ -16,47 +21,45 @@ void EffFootmark_Init(PlayState* play) { } } -void EffFootmark_Add(PlayState* play, MtxF* displayMatrix, Actor* actor, u8 id, Vec3f* location, u16 size, u8 red, - u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay) { +void EffFootmark_Add(PlayState* play, MtxF* mf, Actor* actor, u8 id, Vec3f* pos, u16 size, u8 red, u8 green, u8 blue, + u16 alpha, u16 alphaChange, u16 fadeOutDelay) { s32 i; EffFootmark* footmark; EffFootmark* destination = NULL; EffFootmark* oldest = NULL; - s32 isNew = 1; + s32 isNew = true; - for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) { - if (((actor == footmark->actor) && (footmark->id == id)) && ((footmark->flags & 1) == 0)) { - if (fabsf((footmark->location).x - location->x) <= 1) { - if (fabsf((footmark->location).z - location->z) <= 1) { - isNew = 0; + for (footmark = play->footprintInfo, i = 0; i < ARRAY_COUNT(play->footprintInfo); i++, footmark++) { + if (((actor == footmark->actor) && (footmark->id == id)) && !(footmark->flags & FOOTMARK_FLAG_1)) { + if (fabsf(footmark->pos.x - pos->x) <= 1) { + if (fabsf(footmark->pos.z - pos->z) <= 1) { + isNew = false; break; } } - // This footmark is being re-added at a new location. Let's mark this one to start fading out. - footmark->flags = 1; + // This footmark is being re-added at a new pos. Let's mark this one to start fading out. + footmark->flags = FOOTMARK_FLAG_1; } if (footmark->actor == NULL) { destination = footmark; - } else { - if (destination == NULL) { - if ((oldest != NULL && footmark->age > oldest->age) || (oldest == NULL)) { - oldest = footmark; - } + } else if (destination == NULL) { + if (((oldest != NULL) && (footmark->age > oldest->age)) || (oldest == NULL)) { + oldest = footmark; } } } - if ((isNew) && ((destination != NULL || (oldest != NULL)))) { + if (isNew && ((destination != NULL) || (oldest != NULL))) { if (destination == NULL) { destination = oldest; } - Matrix_MtxFCopy(&destination->displayMatrix, displayMatrix); + Matrix_MtxFCopy(&destination->mf, mf); destination->actor = actor; - destination->location.x = location->x; - destination->location.y = location->y; - destination->location.z = location->z; + destination->pos.x = pos->x; + destination->pos.y = pos->y; + destination->pos.z = pos->z; destination->flags = 0; destination->id = id; destination->red = red; @@ -65,7 +68,7 @@ void EffFootmark_Add(PlayState* play, MtxF* displayMatrix, Actor* actor, u8 id, destination->alpha = alpha; destination->alphaChange = alphaChange; destination->size = size; - destination->fadeoutDelay = fadeoutDelay; + destination->fadeOutDelay = fadeOutDelay; destination->age = 0; } } @@ -74,22 +77,24 @@ void EffFootmark_Update(PlayState* play) { EffFootmark* footmark; s32 i; - for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) { - if (footmark->actor != NULL) { - if ((footmark->flags & 1) == 1) { - if ((u32)footmark->age < UINT16_MAX) { - footmark->age++; - } + for (footmark = play->footprintInfo, i = 0; i < ARRAY_COUNT(play->footprintInfo); i++, footmark++) { + if (footmark->actor == NULL) { + continue; + } - if (footmark->fadeoutDelay == 0) { - if (footmark->alpha >= footmark->alphaChange + 0x1000) { - footmark->alpha -= footmark->alphaChange; - } else { - footmark->actor = NULL; - } - } else if (footmark->fadeoutDelay > 0) { - footmark->fadeoutDelay--; + if (CHECK_FLAG_ALL(footmark->flags, FOOTMARK_FLAG_1)) { + if ((u32)footmark->age < UINT16_MAX) { + footmark->age++; + } + + if (footmark->fadeOutDelay == 0) { + if (footmark->alpha >= footmark->alphaChange + 0x1000) { + footmark->alpha -= footmark->alphaChange; + } else { + footmark->actor = NULL; } + } else if (footmark->fadeOutDelay > 0) { + footmark->fadeOutDelay--; } } } @@ -102,11 +107,11 @@ void EffFootmark_Draw(PlayState* play) { func_8012C448(play->state.gfxCtx); - gSPDisplayList(gfxCtx->polyXlu.p++, D_801BC240); + gSPDisplayList(gfxCtx->polyXlu.p++, gEffFootprintMaterialDL); - for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) { + for (footmark = play->footprintInfo, i = 0; i < ARRAY_COUNT(play->footprintInfo); i++, footmark++) { if (footmark->actor != NULL) { - Matrix_Put(&footmark->displayMatrix); + Matrix_Put(&footmark->mf); Matrix_Scale(footmark->size * (1.0f / 0x100) * 0.7f, 1, footmark->size * (1.0f / 0x100), MTXMODE_APPLY); gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD); @@ -114,7 +119,7 @@ void EffFootmark_Draw(PlayState* play) { gDPSetPrimColor(gfxCtx->polyXlu.p++, 0, 0, footmark->red, footmark->green, footmark->blue, footmark->alpha >> 8); - gSPDisplayList(gfxCtx->polyXlu.p++, D_801BC288); + gSPDisplayList(gfxCtx->polyXlu.p++, gEffFootprintModelDL); } } } diff --git a/src/code/z_eff_ss_dead.c b/src/code/z_eff_ss_dead.c index b7c6af97e..6c416e3c8 100644 --- a/src/code/z_eff_ss_dead.c +++ b/src/code/z_eff_ss_dead.c @@ -50,7 +50,7 @@ void func_800AE5A0(PlayState* play) { OPEN_DISPS(play->state.gfxCtx); gDPPipeSync(POLY_OPA_DISP++); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); CLOSE_DISPS(play->state.gfxCtx); } @@ -105,7 +105,7 @@ void func_800AE8EC(PlayState* play) { OPEN_DISPS(play->state.gfxCtx); gDPPipeSync(POLY_XLU_DISP++); - POLY_XLU_DISP = func_801660B8(play, POLY_XLU_DISP); + POLY_XLU_DISP = Play_SetFog(play, POLY_XLU_DISP); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/code/z_eff_tire_mark.c b/src/code/z_eff_tire_mark.c index f19eb1289..d7754c5a7 100644 --- a/src/code/z_eff_tire_mark.c +++ b/src/code/z_eff_tire_mark.c @@ -11,7 +11,7 @@ void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f u32 spA0; Vec3s* vtxList = colCtx->colHeader->vtxList; - if ((bgId != 50) || (this->numElements >= (ARRAY_COUNT(this->elements) - 1)) || (colPoly == NULL)) { + if ((bgId != BGCHECK_SCENE) || (this->numElements >= (ARRAY_COUNT(this->elements) - 1)) || (colPoly == NULL)) { func_800AEF44(this); return; } diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index ea8a546d6..775b68f01 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -8,7 +8,7 @@ void EffectSS_Init(PlayState* play, s32 numEntries) { EffectSs* effectsSs; EffectSsOverlay* overlay; - sEffectSsInfo.data_table = (EffectSs*)THA_AllocEndAlign16(&play->state.heap, numEntries * sizeof(EffectSs)); + sEffectSsInfo.data_table = (EffectSs*)THA_AllocTailAlign16(&play->state.heap, numEntries * sizeof(EffectSs)); sEffectSsInfo.searchIndex = 0; sEffectSsInfo.size = numEntries; diff --git a/src/code/z_effect_soft_sprite_dlftbls.c b/src/code/z_effect_soft_sprite_dlftbls.c index e215cdee9..fff77feff 100644 --- a/src/code/z_effect_soft_sprite_dlftbls.c +++ b/src/code/z_effect_soft_sprite_dlftbls.c @@ -1,56 +1,34 @@ -#include "global.h" -#include "initvars.h" +#include "z64effect.h" +#include "segment_symbols.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, \ - } +// Init Vars and linker symbol declarations (used in the table below) +#define DEFINE_EFFECT_SS(name, _enumValue) \ + extern EffectSsInit name##_InitVars; \ + DECLARE_OVERLAY_SEGMENT(name) -#define EFFECT_SS_OVERLAY_INTERNAL(name) \ - { 0, 0, NULL, NULL, NULL, &name##_InitVars, 1 } +#define DEFINE_EFFECT_SS_UNSET(_enumValue) -#define EFFECT_SS_OVERLAY_UNSET \ - { 0 } +#include "tables/effect_ss_table.h" + +#undef DEFINE_EFFECT_SS +#undef DEFINE_EFFECT_SS_UNSET + +#define DEFINE_EFFECT_SS(name, _enumValue) \ + { \ + SEGMENT_ROM_START(ovl_##name), \ + SEGMENT_ROM_END(ovl_##name), \ + SEGMENT_START(ovl_##name), \ + SEGMENT_END(ovl_##name), \ + NULL, \ + &name##_InitVars, \ + 1, \ + }, + +#define DEFINE_EFFECT_SS_UNSET(_enumValue) { 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), +#include "tables/effect_ss_table.h" }; + +#undef DEFINE_EFFECT_SS +#undef DEFINE_EFFECT_SS_UNSET diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index 4f24651d1..0b08f4dd0 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -805,7 +805,7 @@ void EffectSsEnIce_SpawnFlying(PlayState* play, Actor* actor, Vec3f* pos, Color_ initParams.scale = scale; if (actor != NULL) { - Actor_PlaySfxAtPos(actor, NA_SE_PL_FREEZE_S); + Actor_PlaySfx(actor, NA_SE_PL_FREEZE_S); } EffectSs_Spawn(play, EFFECT_SS_EN_ICE, 80, &initParams); @@ -897,7 +897,7 @@ void EffectSsEnFire_SpawnVec3f(PlayState* play, Actor* actor, Vec3f* pos, s16 sc initParams.bodyPart = bodyPart; if (actor != NULL) { - Actor_PlaySfxAtPos(actor, NA_SE_EV_FLAME_IGNITION); + Actor_PlaySfx(actor, NA_SE_EV_FLAME_IGNITION); } EffectSs_Spawn(play, EFFECT_SS_EN_FIRE, 128, &initParams); @@ -917,7 +917,7 @@ void EffectSsEnFire_SpawnVec3s(PlayState* play, Actor* actor, Vec3s* pos, s16 sc initParams.bodyPart = bodyPart; if (actor != NULL) { - Actor_PlaySfxAtPos(actor, NA_SE_EV_FLAME_IGNITION); + Actor_PlaySfx(actor, NA_SE_EV_FLAME_IGNITION); } EffectSs_Spawn(play, EFFECT_SS_EN_FIRE, 128, &initParams); diff --git a/src/code/z_elf_message.c b/src/code/z_elf_message.c index 830824024..1b005443d 100644 --- a/src/code/z_elf_message.c +++ b/src/code/z_elf_message.c @@ -45,7 +45,7 @@ u16 QuestHint_GetTatlTextId(PlayState* play) { return 0x21D; } - if (gSaveContext.save.playerData.isMagicAcquired != true) { + if (gSaveContext.save.saveInfo.playerData.isMagicAcquired != true) { return 0x21F; } diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c index 01ec9eca3..674f4bfa4 100644 --- a/src/code/z_en_hy_code.c +++ b/src/code/z_en_hy_code.c @@ -69,7 +69,7 @@ EnDoor* EnHy_FindNearestDoor(Actor* actor, PlayState* play) { do { doorIter = SubS_FindActor(play, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); door = (EnDoor*)doorIter; - dist = Actor_DistanceBetweenActors(actor, &door->dyna.actor); + dist = Actor_WorldDistXYZToActor(actor, &door->dyna.actor); if (!isSetup || (dist < minDist)) { nearestDoor = door; minDist = dist; @@ -207,8 +207,8 @@ s32 EnHy_MoveForwards(EnHy* enHy, f32 speedTarget) { s32 reachedEnd = false; Vec3f curPointPos; - Math_SmoothStepToF(&enHy->actor.speedXZ, speedTarget, 0.4f, 1000.0f, 0.0f); - rotStep = enHy->actor.speedXZ * 400.0f; + Math_SmoothStepToF(&enHy->actor.speed, speedTarget, 0.4f, 1000.0f, 0.0f); + rotStep = enHy->actor.speed * 400.0f; if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &curPointPos) && SubS_MoveActorToPoint(&enHy->actor, &curPointPos, rotStep)) { enHy->curPoint++; @@ -225,8 +225,8 @@ s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget) { s32 reachedEnd = false; Vec3f curPointPos; - Math_SmoothStepToF(&enHy->actor.speedXZ, speedTarget, 0.4f, 1000.0f, 0.0f); - rotStep = enHy->actor.speedXZ * 400.0f; + Math_SmoothStepToF(&enHy->actor.speed, speedTarget, 0.4f, 1000.0f, 0.0f); + rotStep = enHy->actor.speed * 400.0f; if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &curPointPos) && SubS_MoveActorToPoint(&enHy->actor, &curPointPos, rotStep)) { enHy->curPoint--; @@ -250,29 +250,30 @@ void EnHy_UpdateCollider(EnHy* enHy, PlayState* play) { s32 EnHy_PlayWalkingSound(EnHy* enHy, PlayState* play, f32 distAboveThreshold) { u8 wasLeftFootOnGround = enHy->isLeftFootOnGround; u8 wasRightFootOnGround = enHy->isRightFootOnGround; - s32 waterSfxId; + SurfaceSfxOffset surfaceSfxOffset; u16 sfxId; u8 isFootOnGround; - if (enHy->actor.bgCheckFlags & 0x20) { + if (enHy->actor.bgCheckFlags & BGCHECKFLAG_WATER) { if (enHy->actor.depthInWater < 20.0f) { - waterSfxId = NA_SE_PL_WALK_WATER0 - SFX_FLAG; + surfaceSfxOffset = SURFACE_SFX_OFFSET_WATER_SHALLOW; } else { - waterSfxId = NA_SE_PL_WALK_WATER1 - SFX_FLAG; + surfaceSfxOffset = SURFACE_SFX_OFFSET_WATER_DEEP; } - sfxId = waterSfxId + SFX_FLAG; + sfxId = NA_SE_PL_WALK_GROUND + surfaceSfxOffset; } else { - sfxId = SurfaceType_GetSfx(&play->colCtx, enHy->actor.floorPoly, enHy->actor.floorBgId) + SFX_FLAG; + sfxId = NA_SE_PL_WALK_GROUND + + SurfaceType_GetSfxOffset(&play->colCtx, enHy->actor.floorPoly, enHy->actor.floorBgId); } enHy->isLeftFootOnGround = isFootOnGround = SubS_IsFloorAbove(play, &enHy->leftFootPos, distAboveThreshold); if (enHy->isLeftFootOnGround && !wasLeftFootOnGround && isFootOnGround) { - Actor_PlaySfxAtPos(&enHy->actor, sfxId); + Actor_PlaySfx(&enHy->actor, sfxId); } enHy->isRightFootOnGround = isFootOnGround = SubS_IsFloorAbove(play, &enHy->rightFootPos, distAboveThreshold); if (enHy->isRightFootOnGround && !wasRightFootOnGround && isFootOnGround) { - Actor_PlaySfxAtPos(&enHy->actor, sfxId); + Actor_PlaySfx(&enHy->actor, sfxId); } return false; diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 944e650a0..44e8703a2 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -219,7 +219,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { this->unk152 = 15; this->unk14C = 35; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; @@ -299,7 +299,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { } if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, play)) { - Actor_PickUp(&this->actor, play, getItemId, 50.0f, 20.0f); + Actor_OfferGetItem(&this->actor, play, getItemId, 50.0f, 20.0f); } this->actionFunc = func_800A6A40; @@ -346,7 +346,7 @@ void func_800A640C(EnItem00* this, PlayState* play) { this->actor.shape.yOffset = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + 850.0f; } - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + Math_SmoothStepToF(&this->actor.speed, 0.0f, 1.0f, 0.5f, 0.0f); if (this->unk14C == 0) { if ((this->actor.params != ITEM00_SMALL_KEY) && (this->actor.params != ITEM00_HEART_PIECE) && @@ -362,7 +362,7 @@ void func_800A640C(EnItem00* this, PlayState* play) { } } - if ((this->actor.gravity != 0.0f) && !(this->actor.bgCheckFlags & 1)) { + if ((this->actor.gravity != 0.0f) && !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->actionFunc = func_800A6650; } } @@ -387,12 +387,12 @@ void func_800A6650(EnItem00* this, PlayState* play) { EffectSsKirakira_SpawnSmall(play, &pos, &sEffectVelocity, &sEffectAccel, &sEffectPrimColor, &sEffectEnvColor); } - if (this->actor.bgCheckFlags & 3) { + if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) { if (this->actor.velocity.y > -2.0f) { this->actionFunc = func_800A640C; } else { this->actor.velocity.y = this->actor.velocity.y * -0.8f; - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; } } } @@ -406,7 +406,7 @@ void func_800A6780(EnItem00* this, PlayState* play) { if (this->actor.params == ITEM00_RECOVERY_HEART) { if (this->actor.velocity.y < 0.0f) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.gravity = -0.4f; if (this->actor.velocity.y < -1.5f) { this->actor.velocity.y = -1.5f; @@ -444,10 +444,10 @@ void func_800A6780(EnItem00* this, PlayState* play) { EffectSsKirakira_SpawnSmall(play, &pos, &sEffectVelocity, &sEffectAccel, &sEffectPrimColor, &sEffectEnvColor); } - if (this->actor.bgCheckFlags & 3) { + if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) { this->actionFunc = func_800A640C; this->actor.shape.rot.z = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } } @@ -456,7 +456,7 @@ void func_800A6A40(EnItem00* this, PlayState* play) { if (this->getItemId != GI_NONE) { if (!Actor_HasParent(&this->actor, play)) { - Actor_PickUp(&this->actor, play, this->getItemId, 50.0f, 80.0f); + Actor_OfferGetItem(&this->actor, play, this->getItemId, 50.0f, 80.0f); this->unk152++; } else { this->getItemId = GI_NONE; @@ -507,7 +507,9 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { if (this->actor.gravity != 0.0f) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 15.0f, 15.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 15.0f, 15.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); if (this->actor.floorHeight <= BGCHECK_Y_MIN) { Actor_Kill(&this->actor); @@ -646,7 +648,7 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { if (getItemId != GI_NONE) { if (!Actor_HasParent(&this->actor, play)) { - Actor_PickUp(&this->actor, play, getItemId, 50.0f, 20.0f); + Actor_OfferGetItem(&this->actor, play, getItemId, 50.0f, 20.0f); } } @@ -684,7 +686,7 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { this->unk152 = 15; this->unk14C = 35; this->actor.shape.rot.z = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; @@ -819,7 +821,7 @@ void EnItem00_DrawSprite(EnItem00* this, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); if (this->actor.params == ITEM00_NUTS_10) { texIndex = 6; @@ -883,12 +885,13 @@ s16 func_800A7650(s16 dropId) { (dropId == ITEM00_ARROWS_50)) && (INV_CONTENT(ITEM_BOW) == ITEM_NONE)) || (((dropId == ITEM00_MAGIC_LARGE) || (dropId == ITEM00_MAGIC_SMALL)) && - (gSaveContext.save.playerData.magicLevel == 0))) { + (gSaveContext.save.saveInfo.playerData.magicLevel == 0))) { return ITEM00_NO_DROP; } if (dropId == ITEM00_RECOVERY_HEART) { - if (((void)0, gSaveContext.save.playerData.healthCapacity) == ((void)0, gSaveContext.save.playerData.health)) { + if (((void)0, gSaveContext.save.saveInfo.playerData.healthCapacity) == + ((void)0, gSaveContext.save.saveInfo.playerData.health)) { return ITEM00_RUPEE_GREEN; } } @@ -951,7 +954,7 @@ Actor* Item_DropCollectible(PlayState* play, Vec3f* spawnPos, u32 params) { } else { spawnedActor->velocity.y = -2.0f; } - spawnedActor->speedXZ = 2.0f; + spawnedActor->speed = 2.0f; spawnedActor->gravity = -0.9f; spawnedActor->world.rot.y = randPlusMinusPoint5Scaled(0x10000); Actor_SetScale(spawnedActor, 0.0f); @@ -1002,7 +1005,7 @@ Actor* Item_DropCollectible2(PlayState* play, Vec3f* spawnPos, s32 params) { if (spawnedActor != NULL) { if (param8000 == 0) { spawnedActor->velocity.y = 0.0f; - spawnedActor->speedXZ = 0.0f; + spawnedActor->speed = 0.0f; if (param10000 != 0) { spawnedActor->gravity = 0.0f; } else { @@ -1128,16 +1131,17 @@ void Item_DropCollectibleRandom(PlayState* play, Actor* fromActor, Vec3f* spawnP if (fromActor != NULL) { dropFlag = fromActor->dropFlag; - if (dropFlag != 0) { - if (fromActor->dropFlag & 1) { + + if (dropFlag != DROPFLAG_NONE) { + if (fromActor->dropFlag & DROPFLAG_1) { params = 0x10; dropId = ITEM00_ARROWS_30; dropQuantity = 1; - } else if (fromActor->dropFlag & 2) { + } else if (fromActor->dropFlag & DROPFLAG_2) { params = 0x10; dropId = ITEM00_RECOVERY_HEART; dropQuantity = 1; - } else if (fromActor->dropFlag & 0x20) { + } else if (fromActor->dropFlag & DROPFLAG_20) { dropId = ITEM00_RUPEE_PURPLE; dropQuantity = 1; } @@ -1145,27 +1149,29 @@ void Item_DropCollectibleRandom(PlayState* play, Actor* fromActor, Vec3f* spawnP } if (dropId == ITEM00_FLEXIBLE) { - if (gSaveContext.save.playerData.health <= 0x10) { + if (gSaveContext.save.saveInfo.playerData.health <= 0x10) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, 2); SoundSource_PlaySfxAtFixedWorldPos(play, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); return; } - if (gSaveContext.save.playerData.health <= 0x30) { + if (gSaveContext.save.saveInfo.playerData.health <= 0x30) { params = 0x10; dropId = ITEM00_RECOVERY_HEART; dropQuantity = 3; - } else if (gSaveContext.save.playerData.health <= 0x50) { + } else if (gSaveContext.save.saveInfo.playerData.health <= 0x50) { params = 0x10; dropId = ITEM00_RECOVERY_HEART; dropQuantity = 1; - } else if ((gSaveContext.save.playerData.magicLevel != 0) && (gSaveContext.save.playerData.magic == 0)) { + } else if ((gSaveContext.save.saveInfo.playerData.magicLevel != 0) && + (gSaveContext.save.saveInfo.playerData.magic == 0)) { params = 0xD0; dropId = ITEM00_MAGIC_LARGE; dropQuantity = 1; - } else if ((gSaveContext.save.playerData.magicLevel != 0) && - ((gSaveContext.save.playerData.magicLevel >> 1) >= gSaveContext.save.playerData.magic)) { + } else if ((gSaveContext.save.saveInfo.playerData.magicLevel != 0) && + ((gSaveContext.save.saveInfo.playerData.magicLevel >> 1) >= + gSaveContext.save.saveInfo.playerData.magic)) { params = 0xD0; dropId = ITEM00_MAGIC_LARGE; dropQuantity = 1; @@ -1177,7 +1183,7 @@ void Item_DropCollectibleRandom(PlayState* play, Actor* fromActor, Vec3f* spawnP params = 0xB0; dropId = ITEM00_BOMBS_A; dropQuantity = 1; - } else if (gSaveContext.save.playerData.rupees < 11) { + } else if (gSaveContext.save.saveInfo.playerData.rupees < 11) { params = 0xA0; dropId = ITEM00_RUPEE_RED; dropQuantity = 1; @@ -1195,7 +1201,7 @@ void Item_DropCollectibleRandom(PlayState* play, Actor* fromActor, Vec3f* spawnP spawnPos->y, spawnPos->z, 0, 0, 0, dropId); if ((spawnedActor != 0) && (dropId != (u8)ITEM00_NO_DROP)) { spawnedActor->actor.velocity.y = 8.0f; - spawnedActor->actor.speedXZ = 2.0f; + spawnedActor->actor.speed = 2.0f; spawnedActor->actor.gravity = -0.9f; spawnedActor->actor.world.rot.y = Rand_ZeroOne() * 40000.0f; Actor_SetScale(&spawnedActor->actor, 0.0f); diff --git a/src/code/z_env_flags.c b/src/code/z_env_flags.c index 06e216cd3..0057128e2 100644 --- a/src/code/z_env_flags.c +++ b/src/code/z_env_flags.c @@ -1,33 +1,33 @@ #include "global.h" -void EnvFlags_UnsetAll(PlayState* play) { +void CutsceneFlags_UnsetAll(PlayState* play) { u8 i; - for (i = 0; i < ARRAY_COUNT(play->envFlags); i++) { - play->envFlags[i] = 0; + for (i = 0; i < ARRAY_COUNT(play->cutsceneFlags); i++) { + play->cutsceneFlags[i] = 0; } } -void EnvFlags_Set(PlayState* play, s16 flag) { +void CutsceneFlags_Set(PlayState* play, s16 flag) { s16 index = flag / 16; s16 bit = flag % 16; s16 mask = 1 << bit; - play->envFlags[index] |= mask; + play->cutsceneFlags[index] |= mask; } -void EnvFlags_Unset(PlayState* play, s16 flag) { +void CutsceneFlags_Unset(PlayState* play, s16 flag) { s16 index = flag / 16; s16 bit = flag % 16; s16 mask = (1 << bit) ^ 0xFFFF; - play->envFlags[index] &= mask; + play->cutsceneFlags[index] &= mask; } -s32 EnvFlags_Get(PlayState* play, s16 flag) { +s32 CutsceneFlags_Get(PlayState* play, s16 flag) { s16 index = flag / 16; s16 bit = flag % 16; s16 mask = 1 << bit; - return play->envFlags[index] & mask; + return play->cutsceneFlags[index] & mask; } diff --git a/src/code/z_eventmgr.c b/src/code/z_eventmgr.c index 5b8b8dce3..aec6fdbb0 100644 --- a/src/code/z_eventmgr.c +++ b/src/code/z_eventmgr.c @@ -1,52 +1,554 @@ +/** + * @file z_eventmgr.c + * + * Manages all cutscenes except for manual + */ #include "global.h" #include "z64shrink_window.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/func_800F1460.s") +ActorCutscene sGlobalCutsceneList[] = { + // CS_ID_GLOBAL_78 + { -100, -1, CS_CAM_ID_NONE, CS_SCRIPT_ID_NONE, CS_ID_NONE, CS_END_SFX_NONE_ALT, 255, CS_HUD_VISIBILITY_ALL_ALT, 255, + 255 }, + // CS_ID_GLOBAL_79 + { -100, -1, CS_CAM_ID_NONE, CS_SCRIPT_ID_NONE, CS_ID_NONE, CS_END_SFX_NONE_ALT, 255, CS_HUD_VISIBILITY_ALL_ALT, 255, + 255 }, + // CS_ID_GLOBAL_7A + { -100, -1, CS_CAM_ID_NONE, CS_SCRIPT_ID_NONE, CS_ID_NONE, CS_END_SFX_NONE_ALT, 255, CS_HUD_VISIBILITY_ALL_ALT, 255, + 255 }, + // CS_ID_GLOBAL_ELEGY + { 2, -1, CS_CAM_ID_GLOBAL_ELEGY, CS_SCRIPT_ID_NONE, CS_ID_NONE, CS_END_SFX_NONE_ALT, 255, CS_HUD_VISIBILITY_NONE, + CS_END_CAM_0, 32 }, + // CS_ID_GLOBAL_TALK + { 32765, -1, CS_CAM_ID_NONE, CS_SCRIPT_ID_NONE, CS_ID_NONE, CS_END_SFX_NONE_ALT, 255, CS_HUD_VISIBILITY_ALL_ALT, + CS_END_CAM_0, 255 }, + // CS_ID_GLOBAL_DOOR + { 32764, -1, CS_CAM_ID_NONE, CS_SCRIPT_ID_NONE, CS_ID_NONE, CS_END_SFX_NONE_ALT, 255, CS_HUD_VISIBILITY_ALL_ALT, + CS_END_CAM_0, 255 }, + // CS_ID_GLOBAL_RETURN_TO_CAM + { 32766, -2, CS_CAM_ID_GLOBAL_CONNECT, CS_SCRIPT_ID_NONE, CS_ID_NONE, CS_END_SFX_NONE, 255, + CS_HUD_VISIBILITY_ALL_ALT, CS_END_CAM_0, 32 }, + // CS_ID_GLOBAL_END + { 0, -1, CS_CAM_ID_NONE, CS_SCRIPT_ID_NONE, CS_ID_NONE, CS_END_SFX_NONE, 255, CS_HUD_VISIBILITY_ALL_ALT, + CS_END_CAM_0, 32 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCutsceneImpl.s") +typedef enum { + /* 0 */ CS_START_0, + /* 1 */ CS_START_1, + /* 2 */ CS_START_2, +} ActorCutsceneStartMethod; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_Init.s") +typedef struct { + /* 0x00 */ s16 csId; + /* 0x02 */ s16 length; + /* 0x04 */ s16 endCsId; + /* 0x06 */ s16 subCamId; + /* 0x08 */ Actor* targetActor; + /* 0x0C */ s32 startMethod; + /* 0x10 */ PlayState* play; + /* 0x14 */ s16 retCamId; + /* 0x16 */ s16 isCameraStored; +} CutsceneManager; // size = 0x18 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/func_800F15D8.s") +CutsceneManager sCutsceneMgr = { + CS_ID_NONE, 0, CS_ID_NONE, SUB_CAM_ID_DONE, NULL, CS_START_0, NULL, CAM_ID_MAIN, false, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_ClearWaiting.s") +s16 CutsceneManager_SetHudVisibility(s16 csHudVisibility) { + u16 hudVisibility; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_ClearNextCutscenes.s") + switch (csHudVisibility) { + case CS_HUD_VISIBILITY_NONE: + hudVisibility = HUD_VISIBILITY_NONE_ALT; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_MarkNextCutscenes.s") + case CS_HUD_VISIBILITY_ALL: + hudVisibility = HUD_VISIBILITY_ALL; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_End.s") + case CS_HUD_VISIBILITY_A_HEARTS_MAGIC: + hudVisibility = HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_Update.s") + case CS_HUD_VISIBILITY_C_HEARTS_MAGIC: + hudVisibility = HUD_VISIBILITY_HEARTS_MAGIC_C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_SetIntentToPlay.s") + case CS_HUD_VISIBILITY_ALL_NO_MINIMAP: + hudVisibility = HUD_VISIBILITY_ALL_NO_MINIMAP; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCanPlayNext.s") + case CS_HUD_VISIBILITY_A_B_C: + hudVisibility = HUD_VISIBILITY_A_B_C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_StartAndSetUnkLinkFields.s") + case CS_HUD_VISIBILITY_B_MINIMAP: + hudVisibility = HUD_VISIBILITY_B_MINIMAP; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_StartAndSetFlag.s") + case CS_HUD_VISIBILITY_A: + hudVisibility = HUD_VISIBILITY_A; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_Start.s") + default: + hudVisibility = HUD_VISIBILITY_ALL; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_Stop.s") + Interface_SetHudVisibility(hudVisibility); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCurrentIndex.s") + return hudVisibility; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCutscene.s") +ActorCutscene* CutsceneManager_GetCutsceneEntryImpl(s16 csId) { + if (csId < CS_ID_GLOBAL_78) { + return &sSceneCutsceneList[csId]; + } else { + csId -= CS_ID_GLOBAL_78; + return &sGlobalCutsceneList[csId]; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_GetAdditionalCutscene.s") +void CutsceneManager_Init(PlayState* play, ActorCutscene* cutsceneList, s16 numEntries) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_GetLength.s") + sSceneCutsceneList = cutsceneList; + sSceneCutsceneCount = numEntries; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/func_800F2138.s") + for (i = 0; i < ARRAY_COUNT(sWaitingCutsceneList); i++) { + sWaitingCutsceneList[i] = 0; + sNextCutsceneList[i] = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/func_800F2178.s") + sCutsceneMgr.endCsId = CS_ID_NONE; + sCutsceneMgr.play = play; + sCutsceneMgr.length = -1; + sCutsceneMgr.targetActor = NULL; + sCutsceneMgr.subCamId = SUB_CAM_ID_DONE; + sCutsceneMgr.isCameraStored = false; + sCutsceneMgr.csId = sCutsceneMgr.endCsId; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCurrentSubCamId.s") +/** + * Store camera into subCam 2, and keep subCam 2 INACTIVE to preserve the struct. + */ +void CutsceneManager_StoreCamera(Camera* camera) { + if (camera != NULL) { + memcpy(&sCutsceneMgr.play->subCameras[2], camera, sizeof(Camera)); + sCutsceneMgr.play->subCameras[2].camId = camera->camId; + Camera_ChangeStatus(&sCutsceneMgr.play->subCameras[2], CAM_STATUS_INACTIVE); + sCutsceneMgr.isCameraStored = true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/func_800F21CC.s") +void CutsceneManager_ClearWaiting(void) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/func_800F22C4.s") + for (i = 0; i < ARRAY_COUNT(sWaitingCutsceneList); i++) { + sWaitingCutsceneList[i] = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/ActorCutscene_SetReturnCamera.s") +void CutsceneManager_ClearNextCutscenes(void) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(sNextCutsceneList); i++) { + sNextCutsceneList[i] = 0; + } +} + +s16 CutsceneManager_MarkNextCutscenes(void) { + s16 bit; + s32 i; + s32 j; + s32 count = 0; + s16 csIdMax = CS_ID_NONE; + s16 priorityMax = SHT_MAX; // lower number means higher priority + s16 csId; + s16 priority; + + for (i = 0; i < ARRAY_COUNT(sNextCutsceneList); i++) { + for (bit = 1, j = 0; j < 8; j++) { + if (sWaitingCutsceneList[i] & bit) { + csId = (i << 3) | j; + priority = CutsceneManager_GetCutsceneEntryImpl(csId)->priority; + + if ((priority ^ 0) == -1) { + sNextCutsceneList[i] |= bit; + } else if ((priority < priorityMax) && (priority > 0)) { + csIdMax = csId; + priorityMax = priority; + } + count++; + } + bit <<= 1; + } + } + if (csIdMax != CS_ID_NONE) { + sNextCutsceneList[csIdMax >> 3] |= 1 << (csIdMax & 7); + } + return count; +} + +#define RET_CAM sCutsceneMgr.play->cameraPtrs[sCutsceneMgr.retCamId] +#define CUR_CAM sCutsceneMgr.play->cameraPtrs[sCutsceneMgr.subCamId] + +void CutsceneManager_End(void) { + ActorCutscene* csEntry; + s16 oldCamId; + s16 oldStateFlags; + + switch (sCutsceneMgr.startMethod) { + case CS_START_2: + sCutsceneMgr.targetActor->flags &= ~ACTOR_FLAG_100000; + // fallthrough + case CS_START_1: + func_800B7298(sCutsceneMgr.play, 0, PLAYER_CSMODE_END); + sCutsceneMgr.startMethod = CS_START_0; + break; + + default: + break; + } + + csEntry = CutsceneManager_GetCutsceneEntryImpl(sCutsceneMgr.csId); + + switch (csEntry->endSfx) { + case CS_END_SFX_TRE_BOX_APPEAR: + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + break; + + case CS_END_SFX_CORRECT_CHIME: + play_sound(NA_SE_SY_CORRECT_CHIME); + break; + + default: // CS_END_SFX_NONE + break; + } + + switch (csEntry->endCam) { + case CS_END_CAM_SMOOTH: + Play_CopyCamera(sCutsceneMgr.play, sCutsceneMgr.retCamId, sCutsceneMgr.subCamId); + RET_CAM->stateFlags = + (RET_CAM->stateFlags & ~CAM_STATE_UNDERWATER) | (CUR_CAM->stateFlags & CAM_STATE_UNDERWATER); + CutsceneManager_Queue(CS_ID_GLOBAL_RETURN_TO_CAM); + break; + + case CS_END_CAM_0: + default: + Play_CopyCamera(sCutsceneMgr.play, sCutsceneMgr.retCamId, sCutsceneMgr.subCamId); + RET_CAM->stateFlags = + (RET_CAM->stateFlags & ~CAM_STATE_UNDERWATER) | (CUR_CAM->stateFlags & CAM_STATE_UNDERWATER); + break; + + case CS_END_CAM_1: + oldCamId = RET_CAM->camId; + oldStateFlags = RET_CAM->stateFlags; + + if (sCutsceneMgr.isCameraStored) { + // Restore the camera that was stored in subCam 2 + memcpy(RET_CAM, &sCutsceneMgr.play->subCameras[2], sizeof(Camera)); + + RET_CAM->stateFlags = + (RET_CAM->stateFlags & ~CAM_STATE_UNDERWATER) | (CUR_CAM->stateFlags & CAM_STATE_UNDERWATER); + + RET_CAM->stateFlags = (RET_CAM->stateFlags & ~CAM_STATE_2) | (oldStateFlags & CAM_STATE_2); + sCutsceneMgr.isCameraStored = false; + } + RET_CAM->camId = oldCamId; + break; + } + + if (sCutsceneMgr.subCamId != SUB_CAM_ID_DONE) { + Play_ClearCamera(sCutsceneMgr.play, sCutsceneMgr.subCamId); + Play_ChangeCameraStatus(sCutsceneMgr.play, sCutsceneMgr.retCamId, CAM_STATUS_ACTIVE); + } + + sCutsceneMgr.csId = CS_ID_NONE; + sCutsceneMgr.endCsId = CS_ID_NONE; + sCutsceneMgr.length = -1; + sCutsceneMgr.targetActor = NULL; + sCutsceneMgr.subCamId = SUB_CAM_ID_DONE; +} + +s16 CutsceneManager_Update(void) { + s16 sp1E = 0; + + if (CutsceneManager_IsNext(CS_ID_GLOBAL_RETURN_TO_CAM)) { + CutsceneManager_StartWithPlayerCs(CS_ID_GLOBAL_RETURN_TO_CAM, &GET_PLAYER(sCutsceneMgr.play)->actor); + } + + if (sCutsceneMgr.endCsId == CS_ID_NONE) { + if (sCutsceneMgr.csId != CS_ID_NONE) { + if (sCutsceneMgr.length > 0) { + sCutsceneMgr.length--; + } + sp1E = 1; + if (sCutsceneMgr.length == 0) { + CutsceneManager_Stop(sCutsceneMgr.csId); + } + } + } + + if (sCutsceneMgr.endCsId != CS_ID_NONE) { + CutsceneManager_End(); + sp1E = 2; + } + + CutsceneManager_ClearNextCutscenes(); + + if (sCutsceneMgr.csId == CS_ID_NONE) { + if ((CutsceneManager_MarkNextCutscenes() == 0) && (sp1E != 0)) { + ShrinkWindow_Letterbox_SetSizeTarget(0); + } else if (sp1E == 0) { + CutsceneManager_StoreCamera(Play_GetCamera(sCutsceneMgr.play, sCutsceneMgr.retCamId)); + } + } + return sp1E; +} + +void CutsceneManager_Queue(s16 csId) { + if (csId >= 0) { + sWaitingCutsceneList[csId >> 3] |= 1 << (csId & 7); + } +} + +s16 CutsceneManager_IsNext(s16 csId) { + if (csId == CS_ID_GLOBAL_END) { + if (sCutsceneMgr.csId == CS_ID_NONE) { + return 0x7F; + } else { + return 0; + } + } + if (csId <= CS_ID_NONE) { + return -1; + } + return (sNextCutsceneList[csId >> 3] & (1 << (csId & 7))) ? 1 : 0; +} + +/** + * Start an actor cutscene, activate Player Cutscene Mode "Wait" + */ +s16 CutsceneManager_StartWithPlayerCs(s16 csId, Actor* actor) { + s16 startCsId = CutsceneManager_Start(csId, actor); + + if (startCsId >= 0) { + func_800B7298(sCutsceneMgr.play, 0, PLAYER_CSMODE_WAIT); + if (sCutsceneMgr.length == 0) { + CutsceneManager_Stop(sCutsceneMgr.csId); + } + sCutsceneMgr.startMethod = CS_START_1; + } + return startCsId; +} + +/** + * Start an actor cutscene, activate Player Cutscene Mode "Wait", turn on ACTOR_FLAG_100000 + */ +s16 CutsceneManager_StartWithPlayerCsAndSetFlag(s16 csId, Actor* actor) { + s16 startCsId = CutsceneManager_Start(csId, actor); + + if (startCsId >= 0) { + func_800B7298(sCutsceneMgr.play, 0, PLAYER_CSMODE_WAIT); + if (sCutsceneMgr.length == 0) { + CutsceneManager_Stop(sCutsceneMgr.csId); + } + if (actor != NULL) { + actor->flags |= ACTOR_FLAG_100000; + sCutsceneMgr.startMethod = CS_START_2; + } else { + sCutsceneMgr.startMethod = CS_START_1; + } + } + return startCsId; +} + +s16 CutsceneManager_Start(s16 csId, Actor* actor) { + ActorCutscene* csEntry; + Camera* subCam; + Camera* retCam; + s32 csType = 0; + + if ((csId < 0) || (sCutsceneMgr.csId != CS_ID_NONE)) { + return csId; + } + + sCutsceneMgr.startMethod = CS_START_0; + csEntry = CutsceneManager_GetCutsceneEntryImpl(csId); + + ShrinkWindow_Letterbox_SetSizeTarget(csEntry->letterboxSize); + CutsceneManager_SetHudVisibility(csEntry->hudVisibility); + + if (csId == CS_ID_GLOBAL_END) { + csType = 1; + } else if (csEntry->scriptIndex != CS_SCRIPT_ID_NONE) { + // scripted cutscene + csType = 1; + } else if ((csId != CS_ID_GLOBAL_DOOR) && (csId != CS_ID_GLOBAL_TALK)) { + csType = 2; + } + + if (csType != 0) { + sCutsceneMgr.retCamId = Play_GetActiveCamId(sCutsceneMgr.play); + sCutsceneMgr.subCamId = Play_CreateSubCamera(sCutsceneMgr.play); + + subCam = Play_GetCamera(sCutsceneMgr.play, sCutsceneMgr.subCamId); + retCam = Play_GetCamera(sCutsceneMgr.play, sCutsceneMgr.retCamId); + + if ((retCam->setting == CAM_SET_START0) || (retCam->setting == CAM_SET_START2) || + (retCam->setting == CAM_SET_START1)) { + if (CutsceneManager_FindEntranceCsId() != csId) { + func_800E0348(retCam); + } else { + Camera_UnsetStateFlag(retCam, CAM_STATE_2); + } + } + + memcpy(subCam, retCam, sizeof(Camera)); + subCam->camId = sCutsceneMgr.subCamId; + Camera_UnsetStateFlag(subCam, CAM_STATE_6 | CAM_STATE_0); + + Play_ChangeCameraStatus(sCutsceneMgr.play, sCutsceneMgr.retCamId, CAM_STATUS_WAIT); + Play_ChangeCameraStatus(sCutsceneMgr.play, sCutsceneMgr.subCamId, CAM_STATUS_ACTIVE); + + subCam->target = sCutsceneMgr.targetActor = actor; + subCam->behaviorFlags = 0; + + if (csType == 1) { + Camera_ChangeSetting(subCam, CAM_SET_FREE0); + Cutscene_StartScripted(sCutsceneMgr.play, csEntry->scriptIndex); + sCutsceneMgr.length = csEntry->length; + } else { + if (csEntry->csCamId != CS_CAM_ID_NONE) { + Camera_ChangeActorCsCamIndex(subCam, csEntry->csCamId); + } else { + Camera_ChangeSetting(subCam, CAM_SET_FREE0); + } + sCutsceneMgr.length = csEntry->length; + } + } + sCutsceneMgr.csId = csId; + + return csId; +} + +s16 CutsceneManager_Stop(s16 csId) { + ActorCutscene* csEntry; + + if (csId < 0) { + return csId; + } + + csEntry = CutsceneManager_GetCutsceneEntryImpl(sCutsceneMgr.csId); + if ((sCutsceneMgr.length > 0) && (csEntry->scriptIndex == CS_SCRIPT_ID_NONE)) { + return -2; + } + if ((csId != CS_ID_GLOBAL_END) && (csEntry->scriptIndex != CS_SCRIPT_ID_NONE)) { + return -3; + } + + if (csId == CS_ID_GLOBAL_END) { + csId = sCutsceneMgr.csId; + } + if (csId == sCutsceneMgr.csId) { + sCutsceneMgr.endCsId = sCutsceneMgr.csId; + return sCutsceneMgr.endCsId; + } + return -1; +} + +s16 CutsceneManager_GetCurrentCsId(void) { + return sCutsceneMgr.csId; +} + +ActorCutscene* CutsceneManager_GetCutsceneEntry(s16 csId) { + return CutsceneManager_GetCutsceneEntryImpl(csId); +} + +s16 CutsceneManager_GetAdditionalCsId(s16 csId) { + if (csId < 0) { + return CS_ID_NONE; + } + return CutsceneManager_GetCutsceneEntryImpl(csId)->additionalCsId; +} + +s16 CutsceneManager_GetLength(s16 csId) { + if (csId < 0) { + return -1; + } + return CutsceneManager_GetCutsceneEntryImpl(csId)->length; +} + +s16 CutsceneManager_GetCutsceneScriptIndex(s16 csId) { + if (csId < 0) { + return -1; + } + return CutsceneManager_GetCutsceneEntryImpl(csId)->scriptIndex; +} + +s16 CutsceneManager_GetCutsceneCustomValue(s16 csId) { + if (csId < 0) { + return -1; + } + return CutsceneManager_GetCutsceneEntryImpl(csId)->customValue; +} + +s16 CutsceneManager_GetCurrentSubCamId(s16 csId) { + return sCutsceneMgr.subCamId; +} + +s16 CutsceneManager_FindEntranceCsId(void) { + PlayState* play; + s32 csId; + + for (csId = 0; csId < sSceneCutsceneCount; csId++) { + //! FAKE: + if ((sSceneCutsceneList[csId].scriptIndex != CS_SCRIPT_ID_NONE) && + (sSceneCutsceneList[csId].scriptIndex < (play = sCutsceneMgr.play)->csCtx.scriptListCount) && + (sCutsceneMgr.play->curSpawn == + sCutsceneMgr.play->csCtx.scriptList[sSceneCutsceneList[csId].scriptIndex].spawn)) { + return csId; + } + } + + for (csId = 0; csId < sSceneCutsceneCount; csId++) { + if ((sSceneCutsceneList[csId].customValue >= 100) && + (sSceneCutsceneList[csId].customValue == (sCutsceneMgr.play->curSpawn + 100))) { + return csId; + } + } + + return -1; +} + +s32 func_800F22C4(s16 csId, Actor* actor) { + f32 dist; + s16 screenPosX; + s16 screenPosY; + + if ((sCutsceneMgr.csId == CS_ID_NONE) || (csId == CS_ID_NONE)) { + return 4; + } + + Actor_GetScreenPos(sCutsceneMgr.play, actor, &screenPosX, &screenPosY); + + dist = OLib_Vec3fDist(&actor->focus.pos, &Play_GetCamera(sCutsceneMgr.play, sCutsceneMgr.subCamId)->eye); + + if ((screenPosX > 40) && (screenPosX < SCREEN_WIDTH - 40) && (screenPosY > 40) && + (screenPosY < SCREEN_HEIGHT - 40) && (dist < 700.0f)) { + return 1; + } + if (sCutsceneMgr.length < 6) { + return 2; + } + if (csId == sCutsceneMgr.csId) { + return 0; + } + return 3; +} + +void CutsceneManager_SetReturnCamera(s16 camId) { + sCutsceneMgr.retCamId = camId; +} diff --git a/src/code/z_fbdemo.c b/src/code/z_fbdemo.c index 3d33399e5..441af901e 100644 --- a/src/code/z_fbdemo.c +++ b/src/code/z_fbdemo.c @@ -1,20 +1,223 @@ +/** + * @file z_fbdemo.c + * + * This file implements an unused transition system that takes the current screen, partitions it into large tiles, and + * can apply an effect to them. + * + * The screen is divided into 7 rows and 10 columns of tiles. (`gScreenWidth`/ 10 = `gScreenHeight` / 7 = 0x20) + * + * @note The only coded effect has a visual effect to blend the tiles to a single point, which looks like the screen + * gets sucked into. + */ #include "global.h" #include "system_malloc.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/func_80163DC0.s") +Gfx sTransTileSetupDL[] = { + gsDPPipeSync(), + gsSPTexture(0x8000, 0x8000, 0, G_TX_RENDERTILE, G_ON), + gsSPLoadGeometryMode(G_TEXTURE_ENABLE), + gsDPSetCombineMode(G_CC_DECALRGB, G_CC_DECALRGB), + gsDPSetOtherMode(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_PERSP | G_CYC_1CYCLE | G_PM_1PRIMITIVE, + G_AC_NONE | G_ZS_PIXEL | G_RM_AA_OPA_SURF | G_RM_AA_OPA_SURF2), + gsSPEndDisplayList(), +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/func_8016418C.s") +void TransitionTile_InitGraphics(TransitionTile* this) { + s32 frame; + s32 col; + s32 col2; + s32 colTex; + Vtx* vtx; + s32 row; + s32 rowTex; + Gfx* gfx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/func_8016424C.s") + guMtxIdent(&this->modelView); + guMtxIdent(&this->unk_98); + guOrtho(&this->projection, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, -1000.0f, 1000.0f, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/func_801642D8.s") + for (frame = 0; frame < 2; frame++) { + this->frame = frame; + vtx = (this->frame == 0) ? this->vtxFrame1 : this->vtxFrame2; + for (rowTex = 0, row = 0; row < (this->rows + 1); row++, rowTex += 0x20) { + for (colTex = 0, col = 0; col < (this->cols + 1); col++, colTex += 0x20) { + Vtx_tn* vtxn = &vtx->n; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/func_80164438.s") + // clang-format off + vtx++; \ + vtxn->tc[0] = colTex << 6; \ + vtxn->ob[0] = col * 0x20; \ + vtxn->ob[1] = row * 0x20; \ + vtxn->ob[2] = -5; \ + vtxn->flag = 0; \ + vtxn->tc[1] = rowTex << 6; \ + vtxn->n[0] = 0; \ + vtxn->n[1] = 0; \ + vtxn->n[2] = 120; \ + vtxn->a = 255; + // clang-format on + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/func_8016454C.s") + gfx = this->gfx; + for (rowTex = 0, row = 0; row < this->rows; row++, rowTex += 0x20) { + gSPVertex(gfx++, SEGMENT_ADDR(0xA, (u32)row * (this->cols + 1) * sizeof(Vtx)), 2 * (this->cols + 1), 0); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/func_80164678.s") + colTex = 0; + col2 = 0; + col = 0; + while (col < this->cols) { + gDPPipeSync(gfx++); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/func_801647AC.s") + gDPLoadTextureTile(gfx++, SEGMENT_ADDR(0xB, 0), G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, SCREEN_HEIGHT, + colTex, rowTex, colTex + 0x20, rowTex + 0x20, 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); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/func_801647B8.s") + gSP1Quadrangle(gfx++, col, col + 1, col2 + this->cols + 2, this->cols + col2 + 1, 0); + + colTex += 0x20; + col2++; + col++; + } + } + + gDPPipeSync(gfx++); + gSPEndDisplayList(gfx++); +} + +void TransitionTile_InitVtxData(TransitionTile* this) { + s32 row; + s32 col; + + for (row = 0; row < this->rows + 1; row++) { + for (col = 0; col < this->cols + 1; col++) { + (this->vtxData + col + row * (this->cols + 1))->x = col * 0x20; + (this->vtxData + col + row * (this->cols + 1))->y = row * 0x20; + } + } +} + +void TransitionTile_Destroy(TransitionTile* this) { + Sleep_Msec(100); + + if (this->vtxData != NULL) { + SystemArena_Free(this->vtxData); + this->vtxData = NULL; + } + if (this->vtxFrame1 != NULL) { + SystemArena_Free(this->vtxFrame1); + this->vtxFrame1 = NULL; + } + if (this->vtxFrame2 != NULL) { + SystemArena_Free(this->vtxFrame2); + this->vtxFrame2 = NULL; + } + if (this->gfx != NULL) { + SystemArena_Free(this->gfx); + this->gfx = NULL; + } +} + +TransitionTile* TransitionTile_Init(TransitionTile* this, s32 cols, s32 rows) { + s32 gridSize; + + bzero(this, sizeof(TransitionTile)); + this->frame = 0; + this->cols = cols; + this->rows = rows; + gridSize = (cols + 1) * (rows + 1); + this->vtxData = SystemArena_Malloc(gridSize * sizeof(TransitionTileVtxData)); + this->vtxFrame1 = SystemArena_Malloc(gridSize * sizeof(Vtx)); + this->vtxFrame2 = SystemArena_Malloc(gridSize * sizeof(Vtx)); + this->gfx = SystemArena_Malloc(((cols * 9 + 1) * rows + 2) * sizeof(Gfx)); + + if ((this->vtxData == NULL) || (this->vtxFrame1 == NULL) || (this->vtxFrame2 == NULL) || (this->gfx == NULL)) { + if (this->vtxData != NULL) { + SystemArena_Free(this->vtxData); + this->vtxData = NULL; + } + if (this->vtxFrame1 != NULL) { + SystemArena_Free(this->vtxFrame1); + this->vtxFrame1 = NULL; + } + if (this->vtxFrame2 != NULL) { + SystemArena_Free(this->vtxFrame2); + this->vtxFrame2 = NULL; + } + if (this->gfx != NULL) { + SystemArena_Free(this->gfx); + this->gfx = NULL; + } + return NULL; + } + + TransitionTile_InitGraphics(this); + TransitionTile_InitVtxData(this); + this->frame = 0; + + return this; +} + +void TransitionTile_SetVtx(TransitionTile* this) { + s32 row; + s32 col; + Vtx* vtx; + + for (row = 0; row < this->rows + 1; row++) { + for (col = 0; col < this->cols + 1; col++) { + vtx = (this->frame == 0) ? this->vtxFrame1 : this->vtxFrame2; + (vtx + col + row * (this->cols + 1))->n.ob[0] = (this->vtxData + col + row * (this->cols + 1))->x; + + vtx = (this->frame == 0) ? this->vtxFrame1 : this->vtxFrame2; + (vtx + col + row * (this->cols + 1))->n.ob[1] = (this->vtxData + col + row * (this->cols + 1))->y; + } + } +} + +void TransitionTile_Draw(TransitionTile* this, Gfx** gfxP) { + Gfx* gfx = *gfxP; + + gSPDisplayList(gfx++, sTransTileSetupDL); + TransitionTile_SetVtx(this); + gSPMatrix(gfx++, &this->projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gfx++, &this->modelView, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(gfx++, 0xA, this->frame == 0 ? this->vtxFrame1 : this->vtxFrame2); + gSPSegment(gfx++, 0xB, this->zBuffer); + gSPDisplayList(gfx++, sTransTileSetupDL); + gSPDisplayList(gfx++, this->gfx); + gDPPipeSync(gfx++); + this->frame ^= 1; + *gfxP = gfx; +} + +void TransitionTile_Suck(TransitionTile* this) { + s32 row; + s32 col; + f32 diffX; + f32 diffY; + f32 scale; + + for (row = 0; row < this->rows + 1; row++) { + for (col = 0; col < this->cols + 1; col++) { + diffX = (this->vtxData + col + row * (this->cols + 1))->x - (this->vtxData + 5 + 4 * (this->cols + 1))->x; + diffY = (this->vtxData + col + row * (this->cols + 1))->y - (this->vtxData + 5 + 4 * (this->cols + 1))->y; + scale = (SQ(diffX) + SQ(diffY)) / SQ(10.0f); + if (scale != 0.0f) { + if (scale < 1.0f) { + scale = 1.0f; + } + (this->vtxData + col + row * (this->cols + 1))->x -= diffX / scale; + (this->vtxData + col + row * (this->cols + 1))->y -= diffY / scale; + } + } + } +} + +void TransitionTile_Update(TransitionTile* this) { +} + +s32 func_801647B8(TransitionTile* this) { + return 0; +} diff --git a/src/code/z_fbdemo_circle.c b/src/code/z_fbdemo_circle.c index 2a8144ea4..bc07df883 100644 --- a/src/code/z_fbdemo_circle.c +++ b/src/code/z_fbdemo_circle.c @@ -1,6 +1,11 @@ #include "global.h" -Gfx D_801D0D00[] = { +typedef enum { + /* 0 */ TRANS_CIRCLE_DIR_IN, + /* 1 */ TRANS_CIRCLE_DIR_OUT, +} TransitionCircleDirection; + +Gfx sTransCircleSetupDL[] = { gsDPPipeSync(), gsDPSetOtherMode(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, @@ -23,7 +28,7 @@ void TransitionCircle_Start(void* thisx) { TransitionCircle* this = (TransitionCircle*)thisx; this->stepValue = 0.1f; - if (this->direction == TRANSITION_CIRCLE_IN) { + if (this->direction == TRANS_CIRCLE_DIR_IN) { this->targetRadius = 0.0f; this->startingRadius = 1.0f; } else { @@ -67,10 +72,10 @@ void TransitionCircle_SetType(void* thisx, s32 type) { if (type & TC_SET_PARAMS) { this->maskType = FBDEMO_CIRCLE_GET_MASK_TYPE(type); - } else if (type == 1) { - this->direction = TRANSITION_CIRCLE_OUT; + } else if (type == TRANS_INSTANCE_TYPE_FILL_OUT) { + this->direction = TRANS_CIRCLE_DIR_OUT; } else { - this->direction = TRANSITION_CIRCLE_IN; + this->direction = TRANS_CIRCLE_DIR_IN; } } @@ -121,7 +126,7 @@ void TransitionCircle_Draw(void* thisx, Gfx** gfxp) { TransitionCircle* this = (TransitionCircle*)thisx; gDPPipeSync(gfx++); - gSPDisplayList(gfx++, &D_801D0D00); + gSPDisplayList(gfx++, sTransCircleSetupDL); gDPSetPrimColor(gfx++, 0, this->color.a, this->color.r, this->color.g, this->color.b, 1); if (this->maskType == 0) { gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIM_LOD_FRAC, PRIMITIVE, 0, 0, 0, PRIMITIVE, TEXEL0, 0, diff --git a/src/code/z_fbdemo_dlftbls.c b/src/code/z_fbdemo_dlftbls.c index 9d3685a45..48d424813 100644 --- a/src/code/z_fbdemo_dlftbls.c +++ b/src/code/z_fbdemo_dlftbls.c @@ -1,30 +1,38 @@ #include "global.h" -#include "initvars.h" -#include "overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h" -#include "overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h" -#include "overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h" -#include "overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h" -#include "overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h" -#define TRANSITION_OVERLAY(name, filename) \ - { \ - { 0, 0 }, SEGMENT_START(ovl_##filename), SEGMENT_END(ovl_##filename), SEGMENT_ROM_START(ovl_##filename), \ - SEGMENT_ROM_END(ovl_##filename), &name##_InitVars, sizeof(name) \ - } +// InitVars and Linker symbol declarations (used in the table below) +#define DEFINE_TRANSITION(_enumValue, structName, _instanceName, name) \ + extern TransitionInit structName##_InitVars; \ + DECLARE_OVERLAY_SEGMENT(name) -#define TRANSITION_OVERLAY_INTERNAL(name) \ - { { 0, 0 }, NULL, NULL, 0, 0, &name##_InitVars, sizeof(name) } +#define DEFINE_TRANSITION_INTERNAL(_enumValue, structName, _instanceName) extern TransitionInit structName##_InitVars; -#define TRANSITION_OVERLAY_UNSET \ - { 0 } +#include "tables/transition_table.h" + +#undef DEFINE_TRANSITION +#undef DEFINE_TRANSITION_INTERNAL + +#define DEFINE_TRANSITION(_enumValue, structName, _instanceName, name) \ + { \ + { 0, 0 }, \ + SEGMENT_START(ovl_##name), \ + SEGMENT_END(ovl_##name), \ + SEGMENT_ROM_START(ovl_##name), \ + SEGMENT_ROM_END(ovl_##name), \ + &structName##_InitVars, \ + sizeof(structName), \ + }, + +#define DEFINE_TRANSITION_INTERNAL(_enumValue, structName, _instanceName) \ + { { 0, 0 }, NULL, NULL, 0, 0, &structName##_InitVars, sizeof(structName) }, TransitionOverlay gTransitionOverlayTable[] = { - TRANSITION_OVERLAY_INTERNAL(TransitionFade), TRANSITION_OVERLAY(TransitionTriforce, fbdemo_triforce), - TRANSITION_OVERLAY(TransitionWipe1, fbdemo_wipe1), TRANSITION_OVERLAY(TransitionWipe3, fbdemo_wipe3), - TRANSITION_OVERLAY(TransitionWipe4, fbdemo_wipe4), TRANSITION_OVERLAY_INTERNAL(TransitionCircle), - TRANSITION_OVERLAY(TransitionWipe5, fbdemo_wipe5), +#include "tables/transition_table.h" }; +#undef DEFINE_TRANSITION +#undef DEFINE_TRANSITION_INTERNAL + void Transition_Init(TransitionContext* transitionCtx) { TransitionOverlay* overlayEntry; ptrdiff_t relocOffset; diff --git a/src/code/z_fbdemo_fade.c b/src/code/z_fbdemo_fade.c index a0d9f1eae..a9ab37d48 100644 --- a/src/code/z_fbdemo_fade.c +++ b/src/code/z_fbdemo_fade.c @@ -1,17 +1,150 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_Start.s") +#define THIS ((TransitionFade*)thisx) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_Init.s") +typedef enum { + /* 0 */ TRANS_FADE_DIR_IN, + /* 1 */ TRANS_FADE_DIR_OUT +} TransitionFadeDirection; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_Destroy.s") +typedef enum { + /* 0 */ TRANS_FADE_TYPE_NONE, + /* 1 */ TRANS_FADE_TYPE_ONE_WAY, + /* 2 */ TRANS_FADE_TYPE_FLASH +} TransitionFadeType; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_Update.s") +static Gfx sTransFadeSetupDL[] = { + gsDPPipeSync(), + gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | + G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH), + gsDPSetOtherMode(G_AD_NOTPATTERN | G_CD_BAYER | 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_1PRIMITIVE, + G_AC_NONE | G_ZS_PIXEL | G_RM_CLD_SURF | G_RM_CLD_SURF2), + gsDPSetCombineLERP(0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE), + gsSPEndDisplayList(), +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_Draw.s") +TransitionInit TransitionFade_InitVars = { + TransitionFade_Init, TransitionFade_Destroy, TransitionFade_Update, TransitionFade_Draw, + TransitionFade_Start, TransitionFade_SetType, TransitionFade_SetColor, NULL, + TransitionFade_IsDone, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_IsDone.s") +void TransitionFade_Start(void* thisx) { + TransitionFade* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_SetColor.s") + switch (this->type) { + case TRANS_FADE_TYPE_NONE: + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_fade/TransitionFade_SetType.s") + case TRANS_FADE_TYPE_ONE_WAY: + this->timer = 0; + this->color.a = (this->direction != TRANS_FADE_DIR_IN) ? 255 : 0; + break; + + case TRANS_FADE_TYPE_FLASH: + this->color.a = 0; + break; + + default: + break; + } + this->isDone = false; +} + +void* TransitionFade_Init(void* thisx) { + TransitionFade* this = THIS; + + bzero(this, sizeof(TransitionFade)); + return this; +} + +void TransitionFade_Destroy(void* thisx) { +} + +void TransitionFade_Update(void* thisx, s32 updateRate) { + s32 alpha; + s16 newAlpha; + TransitionFade* this = THIS; + + switch (this->type) { + case TRANS_FADE_TYPE_NONE: + break; + + case TRANS_FADE_TYPE_ONE_WAY: + //! FAKE: + THIS->timer += updateRate; + + if (this->timer >= ((void)0, gSaveContext.transFadeDuration)) { + this->timer = ((void)0, gSaveContext.transFadeDuration); + this->isDone = true; + } + + alpha = (255.0f * this->timer) / ((void)0, gSaveContext.transFadeDuration); + this->color.a = (this->direction != TRANS_FADE_DIR_IN) ? 255 - alpha : alpha; + break; + + case TRANS_FADE_TYPE_FLASH: + newAlpha = this->color.a; + if (R_TRANS_FADE_FLASH_ALPHA_STEP != 0) { + if (R_TRANS_FADE_FLASH_ALPHA_STEP < 0) { + if (Math_StepToS(&newAlpha, 255, 255)) { + R_TRANS_FADE_FLASH_ALPHA_STEP = 150; + } + } else { + Math_StepToS(&R_TRANS_FADE_FLASH_ALPHA_STEP, 20, 60); + if (Math_StepToS(&newAlpha, 0, R_TRANS_FADE_FLASH_ALPHA_STEP)) { + R_TRANS_FADE_FLASH_ALPHA_STEP = 0; + this->isDone = true; + } + } + } + this->color.a = newAlpha; + break; + + default: + break; + } +} + +void TransitionFade_Draw(void* thisx, Gfx** gfxP) { + TransitionFade* this = THIS; + Gfx* gfx; + Color_RGBA8_u32* color = &this->color; + + if (color->a != 0) { + gfx = *gfxP; + gSPDisplayList(gfx++, sTransFadeSetupDL); + gDPSetPrimColor(gfx++, 0, 0, color->r, color->g, color->b, color->a); + gSPDisplayList(gfx++, D_0E000000.fillRect); + *gfxP = gfx; + } +} + +s32 TransitionFade_IsDone(void* thisx) { + TransitionFade* this = THIS; + + return this->isDone; +} + +void TransitionFade_SetColor(void* thisx, u32 color) { + TransitionFade* this = THIS; + + this->color.rgba = color; +} + +void TransitionFade_SetType(void* thisx, s32 type) { + TransitionFade* this = THIS; + + if (type == TRANS_INSTANCE_TYPE_FILL_OUT) { + this->type = TRANS_FADE_TYPE_ONE_WAY; + this->direction = TRANS_FADE_DIR_OUT; + } else if (type == TRANS_INSTANCE_TYPE_FILL_IN) { + this->type = TRANS_FADE_TYPE_ONE_WAY; + this->direction = TRANS_FADE_DIR_IN; + } else if (type == TRANS_INSTANCE_TYPE_FADE_FLASH) { + this->type = TRANS_FADE_TYPE_FLASH; + } else { + this->type = TRANS_FADE_TYPE_NONE; + } +} diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index e4f014ffa..114e62cc7 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -1,14 +1,7 @@ -#include "global.h" +#include "z_fireobj.h" #include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" #include "objects/gameplay_keep/gameplay_keep.h" -typedef enum { - FIRE_STATE_0, - FIRE_STATE_1, - FIRE_STATE_2, - FIRE_STATE_3, -} FireState; - ColliderCylinderInit sFireObjCollisionInit = { { COLTYPE_NONE, @@ -48,17 +41,17 @@ void FireObj_InitWithParams(PlayState* play, FireObj* fire, FireObjInitParams* i fire->xScale = 0.0f; fire->yScale = 0.0f; fire->dynamicSize = 0.0f; - fire->unk26 = Rand_ZeroOne() * 20.0f; + fire->timer = Rand_ZeroOne() * 20.0f; fire->ignitionDelay = -1; } void FireObj_SetState(FireObj* fire, f32 dynamicSizeStep, u8 newState) { fire->state = newState; - if (fire->state == FIRE_STATE_3) { + if (fire->state == FIRE_STATE_NOT_LIT) { fire->yScale = 0.0f; fire->xScale = 0.0f; fire->dynamicSize = 0.0f; - } else if (fire->state == FIRE_STATE_2) { + } else if (fire->state == FIRE_STATE_FULLY_LIT) { fire->xScale = fire->yScale = fire->size; fire->dynamicSize = 1.0f; } @@ -70,15 +63,16 @@ void FireObj_SetPosition(FireObj* fire, Vec3f* pos) { } void FireObj_StepSize(FireObj* fire) { - if (fire->state == FIRE_STATE_0) { - if (Math_StepToF(&fire->dynamicSize, 1.0f, fire->dynamicSizeStep) != 0) { - FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_2); + if (fire->state == FIRE_STATE_GROWING) { + if (Math_StepToF(&fire->dynamicSize, 1.0f, fire->dynamicSizeStep)) { + FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_FULLY_LIT); } - } else if ((fire->state == FIRE_STATE_1) && (Math_StepToF(&fire->dynamicSize, 0.0f, fire->dynamicSizeStep) != 0)) { - FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3); + } else if ((fire->state == FIRE_STATE_SHRINKING) && + (Math_StepToF(&fire->dynamicSize, 0.0f, fire->dynamicSizeStep))) { + FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_NOT_LIT); } if (fire->sizeGrowsCos2 == 1) { - if ((fire->state == FIRE_STATE_0) || (fire->state == FIRE_STATE_1)) { + if ((fire->state == FIRE_STATE_GROWING) || (fire->state == FIRE_STATE_SHRINKING)) { fire->xScale = (1.0f - Math_CosS(SQ(fire->dynamicSize) * 0x4000)) * fire->size; fire->yScale = fire->dynamicSize * fire->size; } else { @@ -101,39 +95,41 @@ void FireObj_UpdateStateTransitions(PlayState* play, FireObj* fire) { Vec3f dist; FireObj_StepSize(fire); - fire->unk26++; + fire->timer++; if (fire->ignitionDelay > 0) { fire->ignitionDelay--; } else if (fire->ignitionDelay == 0) { fire->ignitionDelay = -1; - if ((fire->state == FIRE_STATE_3) || (fire->state == FIRE_STATE_1)) { - nextState = FIRE_STATE_0; + if ((fire->state == FIRE_STATE_NOT_LIT) || (fire->state == FIRE_STATE_SHRINKING)) { + nextState = FIRE_STATE_GROWING; } else { - nextState = FIRE_STATE_1; + nextState = FIRE_STATE_SHRINKING; } FireObj_SetState(fire, fire->dynamicSizeStep, nextState); } - if ((fire->flags & 1) && (fire->state != FIRE_STATE_3) && + + if ((fire->flags & FIRE_FLAG_WATER_EXTINGUISHABLE) && (fire->state != FIRE_STATE_NOT_LIT) && WaterBox_GetSurface1_2(play, &play->colCtx, fire->position.x, fire->position.z, &waterY, &waterBox) && (waterY - fire->position.y > 6500.0f * fire->yScale)) { - FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3); + FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_NOT_LIT); } - if ((fire->flags & 2) && (player->heldItemAction == PLAYER_IA_STICK)) { + if ((fire->flags & FIRE_FLAG_INTERACT_STICK) && (player->heldItemAction == PLAYER_IA_STICK)) { Math_Vec3f_Diff(&player->meleeWeaponInfo[0].tip, &fire->position, &dist); - if (Math3D_LengthSquared(&dist) < 400.0f) { + if (Math3D_LengthSquared(&dist) < SQ(20.0f)) { sp40 = true; } } + if (sp40) { - if (fire->state == FIRE_STATE_3) { + if (fire->state == FIRE_STATE_NOT_LIT) { if (player->unk_B28 > 0) { - FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_0); + FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_GROWING); } } else if (player->unk_B28 == 0) { - player->unk_B28 = 0xD2; + player->unk_B28 = 210; SoundSource_PlaySfxAtFixedWorldPos(play, &fire->position, 20, NA_SE_EV_FLAME_IGNITION); - } else if (player->unk_B28 < 0xC8) { - player->unk_B28 = 0xC8; + } else if (player->unk_B28 < 200) { + player->unk_B28 = 200; } } } @@ -142,13 +138,13 @@ void FireObj_Draw(PlayState* play, FireObj* fire) { s32 pad; FireObjColors* fireColors = &sFireObjColors[fire->colorsIndex]; - if (fire->state != FIRE_STATE_3) { + if (fire->state != FIRE_STATE_NOT_LIT) { Vec3s vec; OPEN_DISPS(play->state.gfxCtx); func_8012C2DC(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (fire->unk26 * -20) & 511, 32, 128)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (fire->timer * -20) % 512U, 32, 128)); gDPSetPrimColor(POLY_XLU_DISP++, 0, fireColors->lod, fireColors->primColor.r, fireColors->primColor.g, fireColors->primColor.b, fireColors->primColor.a); @@ -185,7 +181,7 @@ void FireObj_UpdateLight(PlayState* play, FireObjLight* light, FireObj* fire) { FireObjLightParams* lightParams = &sFireObjLightParams[light->lightParamsIndex]; s16 radius; - if (fire->state == FIRE_STATE_3) { + if (fire->state == FIRE_STATE_NOT_LIT) { Lights_PointSetColorAndRadius(&light->lightInfo, 0, 0, 0, -1); } else { radius = (fire->yScale * 140.0f * fire->sizeInv) + 60.0f; @@ -225,14 +221,15 @@ void FireObj_Update(PlayState* play, FireObj* fire, Actor* actor) { EnArrow* arrow = (EnArrow*)fire->collision.base.ac; FireObj_UpdateStateTransitions(play, fire); - if (fire->state == FIRE_STATE_3) { - if ((fire->collision.base.acFlags & AC_HIT) && (fire->collision.info.acHitInfo->toucher.dmgFlags & 0x800)) { - FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_0); + if (fire->state == FIRE_STATE_NOT_LIT) { + if ((fire->collision.base.acFlags & AC_HIT) && + (fire->collision.info.acHitInfo->toucher.dmgFlags & DMG_FIRE_ARROW)) { + FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_GROWING); } } else if ((fire->collision.base.acFlags & AC_HIT) && (arrow->actor.update != NULL) && (arrow->actor.id == ACTOR_EN_ARROW)) { arrow->actor.params = 0; - arrow->collider.info.toucher.dmgFlags = 0x800; + arrow->collider.info.toucher.dmgFlags = DMG_FIRE_ARROW; } fire->collision.dim.pos.x = fire->position.x; fire->collision.dim.pos.y = fire->position.y; diff --git a/src/code/z_game_dlftbls.c b/src/code/z_game_dlftbls.c index 11d390a28..1b82705f5 100644 --- a/src/code/z_game_dlftbls.c +++ b/src/code/z_game_dlftbls.c @@ -24,4 +24,4 @@ GameStateOverlay gGameStateOverlayTable[] = { GAMESTATE_OVERLAY(daytelop, DayTelop_Init, DayTelop_Destroy, sizeof(DayTelopState)), }; -s32 graphNumGameStates = ARRAY_COUNT(gGameStateOverlayTable); +s32 gGraphNumGameStates = ARRAY_COUNT(gGameStateOverlayTable); diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 5609a4727..d0e5e45f2 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -1,6 +1,10 @@ -#include "global.h" +#include "z64game_over.h" #include "z64rumble.h" #include "z64shrink_window.h" +#include "z64.h" +#include "functions.h" +#include "variables.h" +#include "macros.h" void GameOver_Init(PlayState* play) { play->gameOverCtx.state = GAMEOVER_INACTIVE; @@ -23,7 +27,7 @@ void GameOver_Update(PlayState* play) { switch (gameOverCtx->state) { case GAMEOVER_DEATH_START: - func_801477B4(play); + Message_CloseTextbox(play); for (timerId = 0; timerId < TIMER_ID_MAX; timerId++) { gSaveContext.timerStates[timerId] = TIMER_STATE_OFF; @@ -46,7 +50,7 @@ void GameOver_Update(PlayState* play) { } gSaveContext.unk_3DC0 = 2000; - gSaveContext.save.playerData.tatlTimer = 0; + gSaveContext.save.saveInfo.playerData.tatlTimer = 0; gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; gSaveContext.eventInf[0] = 0; @@ -67,14 +71,15 @@ void GameOver_Update(PlayState* play) { Rumble_Request(0.0f, 126, 124, 63); gameOverCtx->state = GAMEOVER_DEATH_WAIT_GROUND; break; + case GAMEOVER_DEATH_FADE_OUT: - if (Audio_GetActiveSequence(SEQ_PLAYER_FANFARE) != NA_BGM_GAME_OVER) { + if (AudioSeq_GetActiveSeqId(SEQ_PLAYER_FANFARE) != NA_BGM_GAME_OVER) { func_80169F78(&play->state); if (gSaveContext.respawnFlag != -7) { gSaveContext.respawnFlag = -6; } - gSaveContext.nextTransitionType = TRANS_TYPE_02; - gSaveContext.save.playerData.health = 0x30; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; + gSaveContext.save.saveInfo.playerData.health = 0x30; gameOverCtx->state++; if (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU) { gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; @@ -83,31 +88,36 @@ void GameOver_Update(PlayState* play) { Rumble_StateReset(); } break; + case GAMEOVER_REVIVE_START: - gameOverCtx->state++; + gameOverCtx->state++; // GAMEOVER_REVIVE_RUMBLE sGameOverTimer = 0; Kankyo_InitGameOverLights(play); ShrinkWindow_Letterbox_SetSizeTarget(32); break; + case GAMEOVER_REVIVE_RUMBLE: sGameOverTimer = 50; - gameOverCtx->state++; + gameOverCtx->state++; // GAMEOVER_REVIVE_WAIT_GROUND Rumble_Request(0.0f, 126, 124, 63); break; + case GAMEOVER_REVIVE_WAIT_GROUND: sGameOverTimer--; if (sGameOverTimer == 0) { sGameOverTimer = 64; - gameOverCtx->state++; + gameOverCtx->state++; // GAMEOVER_REVIVE_WAIT_FAIRY } break; + case GAMEOVER_REVIVE_WAIT_FAIRY: sGameOverTimer--; if (sGameOverTimer == 0) { sGameOverTimer = 50; - gameOverCtx->state++; + gameOverCtx->state++; // GAMEOVER_REVIVE_FADE_OUT } break; + case GAMEOVER_REVIVE_FADE_OUT: Kankyo_FadeOutGameOverLights(play); sGameOverTimer--; diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.c index 48e8e2ad6..0d9f30a08 100644 --- a/src/code/z_kaleido_manager.c +++ b/src/code/z_kaleido_manager.c @@ -14,24 +14,23 @@ KaleidoMgrOverlay gKaleidoMgrOverlayTable[] = { void* sKaleidoAreaPtr = NULL; KaleidoMgrOverlay* gKaleidoMgrCurOvl = NULL; -FaultAddrConvClient sKaleidoAreaFaultClient; +FaultAddrConvClient sKaleidoMgrFaultAddrConvClient; -void* KaleidoManager_FaultAddrConvFunc(void* address, void* param) { - u8* ptr = address; - KaleidoMgrOverlay* ovl = &gKaleidoMgrCurOvl[0]; - u8* ramStart; - u8* ramEnd; - size_t size; - uintptr_t offset; +void* KaleidoManager_FaultAddrConv(void* address, void* param) { + uintptr_t addr = address; + KaleidoMgrOverlay* kaleidoMgrOvl = gKaleidoMgrCurOvl; + size_t ramConv; + void* ramStart; + size_t diff; + + if (kaleidoMgrOvl != NULL) { + diff = VRAM_PTR_SIZE(kaleidoMgrOvl); + ramStart = kaleidoMgrOvl->loadedRamAddr; + ramConv = (uintptr_t)kaleidoMgrOvl->vramStart - (uintptr_t)ramStart; - if (ovl != NULL) { - size = VRAM_PTR_SIZE(ovl); - ramStart = ovl->loadedRamAddr; - ramEnd = ramStart + size; - offset = (u8*)ovl->vramStart - ramStart; if (ramStart != NULL) { - if (ptr >= ramStart && ptr < ramEnd) { - return ptr + offset; + if ((addr >= (uintptr_t)ramStart) && (addr < (uintptr_t)ramStart + diff)) { + return addr + ramConv; } } } @@ -66,13 +65,13 @@ void KaleidoManager_Init(PlayState* play) { } } - sKaleidoAreaPtr = THA_AllocEndAlign16(&play->state.heap, largestSize); + sKaleidoAreaPtr = THA_AllocTailAlign16(&play->state.heap, largestSize); gKaleidoMgrCurOvl = NULL; - Fault_AddAddrConvClient(&sKaleidoAreaFaultClient, KaleidoManager_FaultAddrConvFunc, NULL); + Fault_AddAddrConvClient(&sKaleidoMgrFaultAddrConvClient, KaleidoManager_FaultAddrConv, NULL); } void KaleidoManager_Destroy() { - Fault_RemoveAddrConvClient(&sKaleidoAreaFaultClient); + Fault_RemoveAddrConvClient(&sKaleidoMgrFaultAddrConvClient); if (gKaleidoMgrCurOvl != NULL) { KaleidoManager_ClearOvl(gKaleidoMgrCurOvl); diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index 5ab466ddc..59fde2f2d 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -50,7 +50,7 @@ void KaleidoScopeCall_Update(PlayState* play) { pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; } else if ((pauseCtx->state == PAUSE_STATE_OPENING_1) || (pauseCtx->state == PAUSE_STATE_GAMEOVER_1) || (pauseCtx->state == PAUSE_STATE_OWLWARP_1)) { - if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_DONE) { + if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_READY) { pauseCtx->state++; } } else if (pauseCtx->state != PAUSE_STATE_OFF) { @@ -77,7 +77,7 @@ void KaleidoScopeCall_Update(PlayState* play) { void KaleidoScopeCall_Draw(PlayState* play) { KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; - if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_DONE) { + if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_READY) { if (((play->pauseCtx.state >= PAUSE_STATE_OPENING_3) && (play->pauseCtx.state <= PAUSE_STATE_SAVEPROMPT)) || ((play->pauseCtx.state >= PAUSE_STATE_GAMEOVER_3) && (play->pauseCtx.state <= PAUSE_STATE_UNPAUSE_SETUP))) { if (gKaleidoMgrCurOvl == kaleidoScopeOvl) { diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index dac0d8300..148aad84e 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -44,19 +44,19 @@ void func_800F4A10(PlayState* play) { if (pauseCtx->state == PAUSE_STATE_OPENING_0) { for (i = 0; i < REGION_MAX; i++) { - if ((gSaveContext.save.regionsVisited >> i) & 1) { + if ((gSaveContext.save.saveInfo.regionsVisited >> i) & 1) { pauseCtx->worldMapPoints[i] = true; } } } else { for (i = OWL_WARP_STONE_TOWER; i >= OWL_WARP_GREAT_BAY_COAST; i--) { - if ((gSaveContext.save.playerData.owlActivationFlags >> i) & 1) { + if ((gSaveContext.save.saveInfo.playerData.owlActivationFlags >> i) & 1) { pauseCtx->worldMapPoints[i] = true; pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = i; } } - if ((gSaveContext.save.playerData.owlActivationFlags >> 4) & 1) { + if ((gSaveContext.save.saveInfo.playerData.owlActivationFlags >> 4) & 1) { pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = 4; } } @@ -92,7 +92,7 @@ void KaleidoSetup_Update(PlayState* play) { if ((pauseCtx->state == PAUSE_STATE_OFF) && (pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && (play->gameOverCtx.state == GAMEOVER_INACTIVE)) { if ((play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF)) { - if ((gSaveContext.save.cutscene < 0xFFF0) && (gSaveContext.nextCutsceneIndex < 0xFFF0)) { + if ((gSaveContext.save.cutsceneIndex < 0xFFF0) && (gSaveContext.nextCutsceneIndex < 0xFFF0)) { if (!Play_InCsMode(play) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) { if ((play->unk_1887C < 2) && (gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY) && (gSaveContext.magicState != MAGIC_STATE_FILL)) { diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 919abbb1d..d6d38f9d6 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -4,7 +4,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F50D4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Kankyo_Init.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_Init.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F5954.s") @@ -12,7 +12,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F5B10.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F5CD0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_UpdateSkybox.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F6834.s") @@ -42,11 +42,11 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F8A9C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F8CD4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_Update.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F8D84.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F9728.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_DrawSunLensFlare.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F9824.s") @@ -54,7 +54,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FA3C4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FA9FC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_DrawRain.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FAAB4.s") @@ -72,7 +72,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FB9B4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FBCBC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_DrawCustomLensFlare.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Kankyo_InitGameOverLights.s") @@ -82,9 +82,9 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FC3DC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FC444.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_FillScreen.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FC64C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_DrawSandstorm.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FD2B4.s") diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index b123baab6..d6f2edf2a 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" #include "interface/parameter_static/parameter_static.h" @@ -38,7 +37,7 @@ void LifeMeter_Init(PlayState* play) { interfaceCtx->healthTimer = 320; - interfaceCtx->health = gSaveContext.save.playerData.health; + interfaceCtx->health = gSaveContext.save.saveInfo.playerData.health; interfaceCtx->lifeColorChange = 0; interfaceCtx->lifeColorChangeDirection = 0; @@ -171,7 +170,7 @@ void LifeMeter_UpdateColors(PlayState* play) { s32 LifeMeter_SaveInterfaceHealth(PlayState* play) { InterfaceContext* interfaceCtx = &play->interfaceCtx; - gSaveContext.save.playerData.health = interfaceCtx->health; + gSaveContext.save.saveInfo.playerData.health = interfaceCtx->health; return 1; } @@ -182,8 +181,8 @@ s32 LifeMeter_IncreaseInterfaceHealth(PlayState* play) { interfaceCtx->healthTimer = 320; interfaceCtx->health += 0x10; - if (play->interfaceCtx.health >= gSaveContext.save.playerData.health) { - play->interfaceCtx.health = gSaveContext.save.playerData.health; + if (play->interfaceCtx.health >= gSaveContext.save.saveInfo.playerData.health) { + play->interfaceCtx.health = gSaveContext.save.saveInfo.playerData.health; return true; } return false; @@ -200,7 +199,7 @@ s32 LifeMeter_DecreaseInterfaceHealth(PlayState* play) { interfaceCtx->health -= 0x10; if (interfaceCtx->health <= 0) { interfaceCtx->health = 0; - play->damagePlayer(play, -(((void)0, gSaveContext.save.playerData.health) + 1)); + play->damagePlayer(play, -(((void)0, gSaveContext.save.saveInfo.playerData.health) + 1)); return true; } } @@ -221,18 +220,18 @@ void LifeMeter_Draw(PlayState* play) { GraphicsContext* gfxCtx = play->state.gfxCtx; InterfaceContext* interfaceCtx = &play->interfaceCtx; Vtx* beatingHeartVtx = interfaceCtx->beatingHeartVtx; - s32 fractionHeartCount = gSaveContext.save.playerData.health % 0x10; - s16 healthCapacity = gSaveContext.save.playerData.healthCapacity / 0x10; - s16 fullHeartCount = gSaveContext.save.playerData.health / 0x10; + s32 fractionHeartCount = gSaveContext.save.saveInfo.playerData.health % 0x10; + s16 healthCapacity = gSaveContext.save.saveInfo.playerData.healthCapacity / 0x10; + s16 fullHeartCount = gSaveContext.save.saveInfo.playerData.health / 0x10; s32 pad2; f32 lifesize = interfaceCtx->lifeSizeChange * 0.1f; u32 curCombineModeSet = 0; TexturePtr temp = NULL; - s32 ddCount = gSaveContext.save.inventory.defenseHearts - 1; + s32 ddCount = gSaveContext.save.saveInfo.inventory.defenseHearts - 1; OPEN_DISPS(gfxCtx); - if ((gSaveContext.save.playerData.health % 0x10) == 0) { + if ((gSaveContext.save.saveInfo.playerData.health % 0x10) == 0) { fullHeartCount--; } @@ -423,17 +422,18 @@ void LifeMeter_UpdateSizeAndBeep(PlayState* play) { u32 LifeMeter_IsCritical(void) { s16 criticalThreshold; - if (gSaveContext.save.playerData.healthCapacity <= 0x50) { + if (gSaveContext.save.saveInfo.playerData.healthCapacity <= 0x50) { criticalThreshold = 0x10; - } else if (gSaveContext.save.playerData.healthCapacity <= 0xA0) { + } else if (gSaveContext.save.saveInfo.playerData.healthCapacity <= 0xA0) { criticalThreshold = 0x18; - } else if (gSaveContext.save.playerData.healthCapacity <= 0xF0) { + } else if (gSaveContext.save.saveInfo.playerData.healthCapacity <= 0xF0) { criticalThreshold = 0x20; } else { criticalThreshold = 0x2C; } - if ((criticalThreshold >= gSaveContext.save.playerData.health) && (gSaveContext.save.playerData.health > 0)) { + if ((criticalThreshold >= gSaveContext.save.saveInfo.playerData.health) && + (gSaveContext.save.saveInfo.playerData.health > 0)) { return true; } return false; diff --git a/src/code/z_lights.c b/src/code/z_lights.c index e3e732eb3..6a31c7e94 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -251,7 +251,7 @@ void Lights_FreeNode(LightNode* light) { void LightContext_Init(PlayState* play, LightContext* lightCtx) { LightContext_InitList(play, lightCtx); LightContext_SetAmbientColor(lightCtx, 80, 80, 80); - func_80102544(lightCtx, 0, 0, 0, 0x3E4, 0x3200); + LightContext_SetFog(lightCtx, 0, 0, 0, 996, 12800); bzero(&sLightsBuffer, sizeof(LightsBuffer)); } @@ -261,12 +261,12 @@ void LightContext_SetAmbientColor(LightContext* lightCtx, u8 r, u8 g, u8 b) { lightCtx->ambient.b = b; } -void func_80102544(LightContext* lightCtx, u8 a1, u8 a2, u8 a3, s16 numLights, s16 sp16) { - lightCtx->unk7 = a1; - lightCtx->unk8 = a2; - lightCtx->unk9 = a3; - lightCtx->unkA = numLights; - lightCtx->unkC = sp16; +void LightContext_SetFog(LightContext* lightCtx, u8 r, u8 g, u8 b, s16 near, s16 far) { + lightCtx->fogColor.r = r; + lightCtx->fogColor.g = g; + lightCtx->fogColor.b = b; + lightCtx->fogNear = near; + lightCtx->zFar = far; } /** diff --git a/src/code/z_map_disp.c b/src/code/z_map_disp.c index f8ec448e0..73bcdf693 100644 --- a/src/code/z_map_disp.c +++ b/src/code/z_map_disp.c @@ -38,7 +38,7 @@ extern TexturePtr D_0C000000; void MapDisp_GetIMapTexture(void* dst, s32 iMapId) { if (func_80109A98(iMapId) != 0) { - func_80178E3C(SEGMENT_ROM_START(map_i_static), iMapId, dst, func_80109A98(iMapId)); + CmpDma_LoadFile(SEGMENT_ROM_START(map_i_static), iMapId, dst, func_80109A98(iMapId)); } } @@ -527,8 +527,8 @@ void MapDisp_Init(PlayState* play) { if (!Map_IsInBossArea(play)) { D_801BEC1C = play->numRooms; } - D_801BEBB8.unk28 = THA_AllocEndAlign16(&play->state.heap, 0x4000); - D_801BEBB8.unk2C = THA_AllocEndAlign16(&play->state.heap, 0x4000); + D_801BEBB8.unk28 = THA_AllocTailAlign16(&play->state.heap, 0x4000); + D_801BEBB8.unk2C = THA_AllocTailAlign16(&play->state.heap, 0x4000); func_80104C80(play); if (!Map_IsInBossArea(play)) { D_801BEBB8.unk30 = 0; @@ -538,12 +538,12 @@ void MapDisp_Init(PlayState* play) { D_801BEBB8.unk38 = (s16)(s32)((f32)D_801BEBB8.unk30 + ((f32)D_801BEBB8.unk34 * 0.5f)); D_801BEBB8.unk3A = (s16)(s32)((f32)D_801BEBB8.unk32 + ((f32)D_801BEBB8.unk36 * 0.5f)); } - D_801BEBB8.unk3C = THA_AllocEndAlign16(&play->state.heap, D_801BEC1C * sizeof(s16)); + D_801BEBB8.unk3C = THA_AllocTailAlign16(&play->state.heap, D_801BEC1C * sizeof(s16)); for (i = 0; i < D_801BEC1C; i++) { func_80102E90(play, &D_801BEBB8.unk3C[i]); } - D_801BEBB8.unk48 = THA_AllocEndAlign16(&play->state.heap, 32 * sizeof(s16)); + D_801BEBB8.unk48 = THA_AllocTailAlign16(&play->state.heap, 32 * sizeof(s16)); for (i = 0; i < 32; i++) { D_801BEBB8.unk48[i] = -0x7FFF; @@ -886,7 +886,7 @@ void func_80105C40(s16 room) { D_801BEBB8.unk10 = D_801BEBB8.unk28; } if (func_801096D4(temp_s0->mapId) != 0) { - func_80178E3C(SEGMENT_ROM_START(map_grand_static), temp_s0->mapId - 0x100, + CmpDma_LoadFile(SEGMENT_ROM_START(map_grand_static), temp_s0->mapId - 0x100, (s32)D_801BEBB8.unk10, func_801096D4(temp_s0->mapId)); } break; @@ -1262,7 +1262,7 @@ void func_80106D5C(PlayState* play, s32 arg1, s32 arg2, s32 arg3, s32 arg4, f32 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); } - } else if (gSaveContext.save + } else if (gSaveContext.save.saveInfo .permanentSceneFlags[Play_GetOriginalSceneId(func_80106D08(play->sceneId))] .rooms & (1 << var_s2)) { @@ -1481,11 +1481,11 @@ void func_80108124(PlayState* play, s32 arg1, s32 arg2, s32 arg3, s32 arg4, f32 roomA = D_801F53B0[i].sides[0].room; roomB = D_801F53B0[i].sides[1].room; if (CHECK_DUNGEON_ITEM(2, gSaveContext.mapIndex) || (roomA < 0) || - (gSaveContext.save.permanentSceneFlags[Play_GetOriginalSceneId(func_80106D08(play->sceneId))] + (gSaveContext.save.saveInfo.permanentSceneFlags[Play_GetOriginalSceneId(func_80106D08(play->sceneId))] .rooms & (1 << roomA)) || (roomB < 0) || - (gSaveContext.save.permanentSceneFlags[Play_GetOriginalSceneId(func_80106D08(play->sceneId))] + (gSaveContext.save.saveInfo.permanentSceneFlags[Play_GetOriginalSceneId(func_80106D08(play->sceneId))] .rooms & (1 << roomB))) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); @@ -1607,7 +1607,7 @@ void func_80108AF8(PlayState* play) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 200, pauseCtx->alpha); for (var_s1 = 0; var_s1 < D_801BEBB8.unk40; var_s1++) { - if ((gSaveContext.save.permanentSceneFlags[Play_GetOriginalSceneId(func_80106D08(play->sceneId))].unk_14 & + if ((gSaveContext.save.saveInfo.permanentSceneFlags[Play_GetOriginalSceneId(func_80106D08(play->sceneId))].unk_14 & gBitFlags[4 - var_s1]) || CHECK_DUNGEON_ITEM2(2, spB4)) { gDPLoadTextureBlock(POLY_OPA_DISP++, func_80108A10(D_801BEBB8.unk44 + var_s1), G_IM_FMT_IA, G_IM_SIZ_8b, diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index 73ad47e60..534f9b2c3 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -156,7 +156,8 @@ void Map_InitRoomData(PlayState* play, s16 room) { if (room >= 0) { if (Map_IsInDungeonOrBossArea(play)) { - gSaveContext.save.permanentSceneFlags[Play_GetOriginalSceneId(play->sceneId)].rooms |= gBitFlags[room]; + gSaveContext.save.saveInfo.permanentSceneFlags[Play_GetOriginalSceneId(play->sceneId)].rooms |= + gBitFlags[room]; interfaceCtx->mapRoomNum = room; interfaceCtx->dungeonOrBossAreaMapIndex = mapIndex; } @@ -180,7 +181,7 @@ void Map_Init(PlayState* play) { func_80105C40(play->roomCtx.curRoom.num); interfaceCtx->unk_278 = -1; interfaceCtx->dungeonOrBossAreaMapIndex = -1; - interfaceCtx->mapSegment = THA_AllocEndAlign16(&play->state.heap, 0x1000); + interfaceCtx->mapSegment = THA_AllocTailAlign16(&play->state.heap, 0x1000); if (func_8010A2AC(play)) { gSaveContext.mapIndex = func_8010A238(play); return; @@ -243,7 +244,7 @@ void Map_Update(PlayState* play) { if (Map_IsInDungeonArea(play)) { floor = func_80109124(player->actor.world.pos.y); if (floor != -1) { - gSaveContext.save.permanentSceneFlags[Play_GetOriginalSceneId(play->sceneId)].unk_14 |= + gSaveContext.save.saveInfo.permanentSceneFlags[Play_GetOriginalSceneId(play->sceneId)].unk_14 |= gBitFlags[FLOOR_INDEX_MAX - floor]; R_REVERSE_FLOOR_INDEX = FLOOR_INDEX_MAX - floor; if (interfaceCtx->mapRoomNum != sLastRoomNum) { diff --git a/src/code/z_message.c b/src/code/z_message.c index e3eb9839d..8681967e6 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -99,14 +99,14 @@ s32 Message_ShouldAdvanceSilent(PlayState* play) { } } -void func_801477B4(PlayState* play) { +void Message_CloseTextbox(PlayState* play) { MessageContext* msgCtx = &play->msgCtx; if (play->msgCtx.msgLength != 0) { msgCtx->stateTimer = 2; msgCtx->msgMode = 0x43; msgCtx->unk12020 = 0; - play_sound(NA_SE_PL_WALK_GROUND - SFX_FLAG); + play_sound(NA_SE_NONE); } } @@ -309,7 +309,7 @@ void Message_StartTextbox(PlayState* play, u16 textId, Actor* Actor) { play->msgCtx.ocarinaMode = 0; } -void func_80151938(PlayState* play, u16 textId) { +void Message_ContinueTextbox(PlayState* play, u16 textId) { MessageContext* msgCtx = &play->msgCtx; InterfaceContext* interfaceCtx = &play->interfaceCtx; @@ -395,7 +395,7 @@ u32 func_80151C9C(PlayState* play) { SET_WEEKEVENTREG(D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]); if ((D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]] != 0) && CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { - func_80151938(play, D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]]); + Message_ContinueTextbox(play, D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]]); play_sound(NA_SE_SY_SCHEDULE_WRITE); return true; } @@ -531,7 +531,7 @@ void func_80153E7C(PlayState* play, void* arg1) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801541D4.s") -void func_80156758(PlayState* play) { +void Message_Draw(PlayState* play) { Gfx* nextDisplayList; Gfx* polyOpa; GraphicsContext* gfxCtx = play->state.gfxCtx; @@ -551,7 +551,7 @@ void func_80156758(PlayState* play) { CLOSE_DISPS(gfxCtx); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015680C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_Update.s") void func_801586A4(PlayState* play) { play->msgCtx.messageEntryTableNes = D_801C6B98; @@ -572,7 +572,7 @@ void Message_Init(PlayState* play) { messageCtx->ocarinaAction = messageCtx->unk11FF2 = 0; messageCtx->unk1201E = 0xFF; View_Init(&messageCtx->view, play->state.gfxCtx); - messageCtx->unk11EF8 = THA_AllocEndAlign16(&play->state.heap, 0x13C00); + messageCtx->unk11EF8 = THA_AllocTailAlign16(&play->state.heap, 0x13C00); font = &play->msgCtx.font; Font_LoadOrderedFont(&play->msgCtx.font); font->unk_11D88 = 0; diff --git a/src/code/z_olib.c b/src/code/z_olib.c index 2b6b8d139..754857014 100644 --- a/src/code/z_olib.c +++ b/src/code/z_olib.c @@ -100,16 +100,16 @@ Vec3f* OLib_VecSphToVec3f(Vec3f* dest, VecSph* sph) { } /** - * Takes the geographic point `sph` and converts it into a x,y,z position + * Takes the geographic point `geo` and converts it into a x,y,z position */ -Vec3f* OLib_VecSphGeoToVec3f(Vec3f* dest, VecSph* sph) { - VecSph geo; +Vec3f* OLib_VecGeoToVec3f(Vec3f* dest, VecGeo* geo) { + VecSph sph; - geo.r = sph->r; - geo.pitch = 0x4000 - sph->pitch; - geo.yaw = sph->yaw; + sph.r = geo->r; + sph.pitch = 0x4000 - geo->pitch; + sph.yaw = geo->yaw; - return OLib_VecSphToVec3f(dest, &geo); + return OLib_VecSphToVec3f(dest, &sph); } /** @@ -117,20 +117,20 @@ Vec3f* OLib_VecSphGeoToVec3f(Vec3f* dest, VecSph* sph) { */ VecSph* OLib_Vec3fToVecSph(VecSph* dest, Vec3f* vec) { VecSph sph; - f32 distSquared = SQ(vec->x) + SQ(vec->z); - f32 dist = sqrtf(distSquared); + f32 distXZSq = SQ(vec->x) + SQ(vec->z); + f32 distXZ = sqrtf(distXZSq); - if ((dist == 0.0f) && (vec->y == 0.0f)) { + if ((distXZ == 0.0f) && (vec->y == 0.0f)) { sph.pitch = 0; } else { - sph.pitch = CAM_DEG_TO_BINANG(RADF_TO_DEGF(func_80086B30(dist, vec->y))); + sph.pitch = CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(distXZ, vec->y))); } - sph.r = sqrtf(SQ(vec->y) + distSquared); + sph.r = sqrtf(SQ(vec->y) + distXZSq); if ((vec->x == 0.0f) && (vec->z == 0.0f)) { sph.yaw = 0; } else { - sph.yaw = CAM_DEG_TO_BINANG(RADF_TO_DEGF(func_80086B30(vec->x, vec->z))); + sph.yaw = CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(vec->x, vec->z))); } *dest = sph; @@ -141,7 +141,7 @@ VecSph* OLib_Vec3fToVecSph(VecSph* dest, Vec3f* vec) { /** * Takes the point `vec`, and converts it to a geographic coordinate */ -VecSph* OLib_Vec3fToVecSphGeo(VecSph* dest, Vec3f* vec) { +VecGeo* OLib_Vec3fToVecGeo(VecGeo* dest, Vec3f* vec) { VecSph sph; OLib_Vec3fToVecSph(&sph, vec); @@ -156,42 +156,42 @@ VecSph* OLib_Vec3fToVecSphGeo(VecSph* dest, Vec3f* vec) { * Takes the differences of positions `a` and `b`, and converts them to spherical coordinates */ VecSph* OLib_Vec3fDiffToVecSph(VecSph* dest, Vec3f* a, Vec3f* b) { - Vec3f sph; + Vec3f diff; - sph.x = b->x - a->x; - sph.y = b->y - a->y; - sph.z = b->z - a->z; + diff.x = b->x - a->x; + diff.y = b->y - a->y; + diff.z = b->z - a->z; - return OLib_Vec3fToVecSph(dest, &sph); + return OLib_Vec3fToVecSph(dest, &diff); } /** * Takes the difference of positions `a` and `b`, and converts them to geographic coordinates */ -VecSph* OLib_Vec3fDiffToVecSphGeo(VecSph* dest, Vec3f* a, Vec3f* b) { - Vec3f sph; +VecGeo* OLib_Vec3fDiffToVecGeo(VecGeo* dest, Vec3f* a, Vec3f* b) { + Vec3f diff; - sph.x = b->x - a->x; - sph.y = b->y - a->y; - sph.z = b->z - a->z; + diff.x = b->x - a->x; + diff.y = b->y - a->y; + diff.z = b->z - a->z; - return OLib_Vec3fToVecSphGeo(dest, &sph); + return OLib_Vec3fToVecGeo(dest, &diff); } /** - * Takes the sum of positions `a` (x,y,z coordinates) and `sph` (geographic coordinates), result is in x,y,z position + * Takes the sum of positions `a` (x,y,z coordinates) and `geo` (geographic coordinates), result is in x,y,z position * Identical to Quake_AddVec from OoT */ -Vec3f* OLib_VecSphAddToVec3f(Vec3f* dest, Vec3f* a, VecSph* sph) { - Vec3f vec; +Vec3f* OLib_AddVecGeoToVec3f(Vec3f* dest, Vec3f* a, VecGeo* geo) { + Vec3f sum; Vec3f b; - OLib_VecSphGeoToVec3f(&b, sph); - vec.x = a->x + b.x; - vec.y = a->y + b.y; - vec.z = a->z + b.z; + OLib_VecGeoToVec3f(&b, geo); + sum.x = a->x + b.x; + sum.y = a->y + b.y; + sum.z = a->z + b.z; - *dest = vec; + *dest = sum; return dest; } @@ -220,8 +220,8 @@ Vec3f* OLib_Vec3fDiffDegF(Vec3f* dest, Vec3f* a, Vec3f* b) { OLib_Vec3fDiffRad(&anglesRad, a, b); - anglesDegrees.x = RADF_TO_DEGF(anglesRad.x); - anglesDegrees.y = RADF_TO_DEGF(anglesRad.y); + anglesDegrees.x = RAD_TO_DEG(anglesRad.x); + anglesDegrees.y = RAD_TO_DEG(anglesRad.y); anglesDegrees.z = 0.0f; *dest = anglesDegrees; @@ -238,8 +238,8 @@ Vec3s* OLib_Vec3fDiffBinAng(Vec3s* dest, Vec3f* a, Vec3f* b) { OLib_Vec3fDiffRad(&anglesRad, a, b); - anglesBinAng.x = CAM_DEG_TO_BINANG(RADF_TO_DEGF(anglesRad.x)); - anglesBinAng.y = CAM_DEG_TO_BINANG(RADF_TO_DEGF(anglesRad.y)); + anglesBinAng.x = CAM_DEG_TO_BINANG(RAD_TO_DEG(anglesRad.x)); + anglesBinAng.y = CAM_DEG_TO_BINANG(RAD_TO_DEG(anglesRad.y)); anglesBinAng.z = 0.0f; *dest = anglesBinAng; @@ -248,46 +248,50 @@ Vec3s* OLib_Vec3fDiffBinAng(Vec3s* dest, Vec3f* a, Vec3f* b) { } /** - * Gets a x,y,z position diff depending on the dbCamera mode + * Gets a x,y,z position diff depending on the mode */ -void OLib_DbCameraVec3fDiff(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode) { - VecSph sph; +void OLib_Vec3fDiff(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode) { + VecGeo geo; switch (mode) { - case 1: - OLib_Vec3fDiffToVecSphGeo(&sph, &a->pos, b); - sph.yaw -= a->rot.y; - OLib_VecSphGeoToVec3f(dest, &sph); + case OLIB_DIFF_OFFSET: + OLib_Vec3fDiffToVecGeo(&geo, &a->pos, b); + geo.yaw -= a->rot.y; + OLib_VecGeoToVec3f(dest, &geo); break; - case 2: + + case OLIB_DIFF: dest->x = b->x - a->pos.x; dest->y = b->y - a->pos.y; dest->z = b->z - a->pos.z; break; - default: + + default: // OLIB_DIFF_COPY *dest = *b; break; } } /** - * Gets a x,y,z position sum depending on the dbCamera mode + * Gets a x,y,z position sum depending on the mode */ -void OLib_DbCameraVec3fSum(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode) { - VecSph sph; +void OLib_Vec3fAdd(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode) { + VecGeo geo; switch (mode) { - case 1: - OLib_Vec3fToVecSphGeo(&sph, b); - sph.yaw += a->rot.y; - OLib_VecSphAddToVec3f(dest, &a->pos, &sph); + case OLIB_ADD_OFFSET: + OLib_Vec3fToVecGeo(&geo, b); + geo.yaw += a->rot.y; + OLib_AddVecGeoToVec3f(dest, &a->pos, &geo); break; - case 2: + + case OLIB_ADD: dest->x = a->pos.x + b->x; dest->y = a->pos.y + b->y; dest->z = a->pos.z + b->z; break; - default: + + default: // OLIB_ADD_COPY *dest = *b; break; } diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index cd4ffa67f..fe4ca5ef8 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64snap.h" #include "z64view.h" #include "interface/parameter_static/parameter_static.h" #include "interface/do_action_static/do_action_static.h" @@ -7,6 +8,8 @@ #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" #include "overlays/actors/ovl_En_Mm3/z_en_mm3.h" +extern TexturePtr D_08095AC0; // gMagicArrowEquipEffectTex + typedef enum { /* 0 */ PICTO_BOX_STATE_OFF, // Not using the pictograph /* 1 */ PICTO_BOX_STATE_LENS, // Looking through the lens of the pictograph @@ -14,6 +17,11 @@ typedef enum { /* 3 */ PICTO_BOX_STATE_PHOTO } PictoBoxState; +// TODO extract this information from the texture definitions themselves +#define DO_ACTION_TEX_WIDTH 48 +#define DO_ACTION_TEX_HEIGHT 16 +#define DO_ACTION_TEX_SIZE ((DO_ACTION_TEX_WIDTH * DO_ACTION_TEX_HEIGHT) / 2) // (sizeof(gCheckDoActionENGTex)) + typedef struct { /* 0x00 */ u8 scene; /* 0x01 */ u8 flags1; @@ -21,7 +29,7 @@ typedef struct { /* 0x03 */ u8 flags3; } RestrictionFlags; -Input sPostmanTimerInput[4]; +Input sPostmanTimerInput[MAXCONTROLLERS]; #define RESTRICTIONS_TABLE_END 0xFF @@ -879,10 +887,10 @@ void Interface_SetVertices(PlayState* play) { s32 sPostmanTimerInputBtnAPressed = false; -void Interface_PostmanTimerCallback(s32 arg0) { +void Interface_PostmanTimerCallback(void* arg) { s32 btnAPressed; - func_80175E68(&sPostmanTimerInput[0], 0); + PadMgr_GetInputNoLock(sPostmanTimerInput, false); btnAPressed = CHECK_BTN_ALL(sPostmanTimerInput[0].cur.button, BTN_A); if ((btnAPressed != sPostmanTimerInputBtnAPressed) && btnAPressed) { gSaveContext.postmanTimerStopOsTime = osGetTime(); @@ -998,12 +1006,12 @@ void Interface_NewDay(PlayState* play, s32 day) { (u32)SEGMENT_ROM_START(week_static) + i * 0x510, 0x510); // i is used to store sceneId - for (i = 0; i < ARRAY_COUNT(gSaveContext.save.permanentSceneFlags); i++) { - gSaveContext.save.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; - gSaveContext.save.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; - gSaveContext.save.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; - gSaveContext.save.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; - gSaveContext.save.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.saveInfo.permanentSceneFlags); i++) { + gSaveContext.save.saveInfo.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; + gSaveContext.save.saveInfo.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; + gSaveContext.save.saveInfo.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; + gSaveContext.save.saveInfo.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; + gSaveContext.save.saveInfo.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; } } @@ -1021,7 +1029,7 @@ void Interface_SetHudVisibility(u16 hudVisibility) { void Interface_UpdateButtonAlphasByStatus(PlayState* play, s16 risingAlpha) { InterfaceContext* interfaceCtx = &play->interfaceCtx; - if ((gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) || (gSaveContext.unk_1015 == ITEM_NONE)) { + if ((gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) || (gSaveContext.bButtonStatus == BTN_DISABLED)) { if (interfaceCtx->bAlpha != 70) { interfaceCtx->bAlpha = 70; } @@ -1393,7 +1401,8 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { interfaceCtx->aAlpha = risingAlpha; } - if ((gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) || (gSaveContext.unk_1015 == ITEM_NONE)) { + if ((gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) || + (gSaveContext.bButtonStatus == ITEM_NONE)) { if (interfaceCtx->bAlpha != 70) { interfaceCtx->bAlpha = 70; } @@ -1767,15 +1776,741 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { break; } - if ((play->roomCtx.curRoom.unk3 == 1) && (interfaceCtx->minimapAlpha >= 255)) { + if ((play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_1) && (interfaceCtx->minimapAlpha >= 255)) { interfaceCtx->minimapAlpha = 255; } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80110038.s") +/** + * A continuation of the if-else chain from Interface_UpdateButtonsPart1 + * Also used directly when opening the pause menu i.e. skips part 1 + */ +void Interface_UpdateButtonsPart2(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + Player* player = GET_PLAYER(play); + s16 i; + s16 restoreHudVisibility = false; -void func_80111CB4(PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80111CB4.s") + if (CHECK_EVENTINF(EVENTINF_41)) { + // Related to swamp boat (non-minigame)? + for (i = EQUIP_SLOT_C_LEFT; i <= EQUIP_SLOT_C_RIGHT; i++) { + if ((GET_CUR_FORM_BTN_ITEM(i) != ITEM_PICTO_BOX) || (msgCtx->msgMode != 0)) { + if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_DISABLED; + } else { + if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_ENABLED; + } + } + + if (sPictoState == PICTO_BOX_STATE_OFF) { + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] != BTN_DISABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_DISABLED; + } else { + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + } + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_90_20)) { + // Fishermans's jumping minigame + for (i = EQUIP_SLOT_C_LEFT; i <= EQUIP_SLOT_C_RIGHT; i++) { + if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + gSaveContext.buttonStatus[i] = BTN_DISABLED; + } + } + + Interface_SetHudVisibility(HUD_VISIBILITY_B); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_82_08)) { + // Swordsman's log minigame + for (i = EQUIP_SLOT_C_LEFT; i <= EQUIP_SLOT_C_RIGHT; i++) { + if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + gSaveContext.buttonStatus[i] = BTN_DISABLED; + } + } + + Interface_SetHudVisibility(HUD_VISIBILITY_A_B_HEARTS_MAGIC_MINIMAP); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_84_20)) { + // Related to moon child + if (player->currentMask == PLAYER_MASK_FIERCE_DEITY) { + for (i = EQUIP_SLOT_C_LEFT; i <= EQUIP_SLOT_C_RIGHT; i++) { + if ((GET_CUR_FORM_BTN_ITEM(i) == ITEM_MASK_FIERCE_DEITY) || + ((GET_CUR_FORM_BTN_ITEM(i) >= ITEM_BOTTLE) && (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_OBABA_DRINK))) { + if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + restoreHudVisibility = true; + gSaveContext.buttonStatus[i] = BTN_ENABLED; + } + } else { + if (gSaveContext.buttonStatus[i] != BTN_DISABLED) { + gSaveContext.buttonStatus[i] = BTN_DISABLED; + restoreHudVisibility = true; + } + } + } + } else { + for (i = EQUIP_SLOT_C_LEFT; i <= EQUIP_SLOT_C_RIGHT; i++) { + if ((GET_CUR_FORM_BTN_ITEM(i) >= ITEM_MASK_DEKU) && (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_MASK_ZORA)) { + if (gSaveContext.buttonStatus[i] != BTN_DISABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_DISABLED; + } else { + if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_ENABLED; + } + } + } + } else if ((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 6)) { + // Unknown cutscene + for (i = EQUIP_SLOT_C_LEFT; i <= EQUIP_SLOT_C_RIGHT; i++) { + if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_DISABLED; + } + } else if (CHECK_EVENTINF(EVENTINF_34)) { + // Deku playground minigame + if (player->stateFlags3 & PLAYER_STATE3_1000000) { + if (gSaveContext.save.saveInfo.inventory.items[SLOT_NUT] == ITEM_NUT) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_NUT; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + } else { + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_DISABLED; + restoreHudVisibility = true; + } + } else { + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + restoreHudVisibility = true; + } + + for (i = EQUIP_SLOT_C_LEFT; i <= EQUIP_SLOT_C_RIGHT; i++) { + if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_DISABLED; + } + } + + if (restoreHudVisibility || (gSaveContext.hudVisibility != HUD_VISIBILITY_A_B_MINIMAP)) { + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_A_B_MINIMAP); + restoreHudVisibility = false; + } + } else if (player->stateFlags3 & PLAYER_STATE3_1000000) { + // Nuts on B (from flying as Deku Link) + if (gSaveContext.save.saveInfo.inventory.items[SLOT_NUT] == ITEM_NUT) { + if (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) != ITEM_NUT) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_NUT; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + restoreHudVisibility = true; + } + } else if (gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_ENABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_DISABLED; + restoreHudVisibility = true; + } + + if (restoreHudVisibility) { + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_DISABLED; + } + } else if (!gSaveContext.save.saveInfo.playerData.isMagicAcquired && (CUR_FORM == PLAYER_FORM_DEKU) && + (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_NUT)) { + // Nuts on B (as Deku Link) + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_FD; + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_DISABLED; + } else if ((Player_GetEnvironmentalHazard(play) >= PLAYER_ENV_HAZARD_UNDERWATER_FLOOR) && + (Player_GetEnvironmentalHazard(play) <= PLAYER_ENV_HAZARD_UNDERWATER_FREE)) { + // Swimming underwater + if (CUR_FORM != PLAYER_FORM_ZORA) { + if ((player->currentMask == PLAYER_MASK_BLAST) && (player->blastMaskTimer == 0)) { + if (gSaveContext.bButtonStatus == BTN_DISABLED) { + restoreHudVisibility = true; + } + gSaveContext.bButtonStatus = BTN_ENABLED; + } else if ((interfaceCtx->bButtonDoAction == DO_ACTION_EXPLODE) && + (player->currentMask == PLAYER_MASK_BLAST)) { + if (gSaveContext.bButtonStatus != BTN_DISABLED) { + gSaveContext.bButtonStatus = BTN_DISABLED; + restoreHudVisibility = true; + } + } else { + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] != BTN_DISABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_DISABLED; + } + } else { + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + } + + for (i = EQUIP_SLOT_C_LEFT; i <= EQUIP_SLOT_C_RIGHT; i++) { + if (GET_CUR_FORM_BTN_ITEM(i) != ITEM_MASK_ZORA) { + if (Player_GetEnvironmentalHazard(play) == PLAYER_ENV_HAZARD_UNDERWATER_FLOOR) { + if (!((GET_CUR_FORM_BTN_ITEM(i) >= ITEM_BOTTLE) && + (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_OBABA_DRINK))) { + if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_DISABLED; + } else { + if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_ENABLED; + } + } else { + if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_DISABLED; + } + } else if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + gSaveContext.buttonStatus[i] = BTN_ENABLED; + restoreHudVisibility = true; + } + } + + if (restoreHudVisibility) { + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + } + + if ((play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF)) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_NONE) { + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + } + } else if (player->stateFlags1 & PLAYER_STATE1_200000) { + // First person view + for (i = EQUIP_SLOT_C_LEFT; i <= EQUIP_SLOT_C_RIGHT; i++) { + if (GET_CUR_FORM_BTN_ITEM(i) != ITEM_LENS) { + if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_DISABLED; + } else { + if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_ENABLED; + } + } + + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] != BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_DISABLED; + restoreHudVisibility = true; + } + } else if (player->stateFlags1 & PLAYER_STATE1_2000) { + // Hanging from a ledge + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] != BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_DISABLED; + restoreHudVisibility = true; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + } else { + // End of special event cases + + // B button + if ((interfaceCtx->bButtonDoAction == DO_ACTION_EXPLODE) && (player->currentMask == PLAYER_MASK_BLAST) && + (player->blastMaskTimer != 0)) { + // Cooldown period for blast mask + if (gSaveContext.bButtonStatus != BTN_DISABLED) { + gSaveContext.bButtonStatus = BTN_DISABLED; + restoreHudVisibility = true; + } + } else { + // default to enabled + if (gSaveContext.bButtonStatus == BTN_DISABLED) { + gSaveContext.bButtonStatus = BTN_ENABLED; + restoreHudVisibility = true; + } + + // Apply B button restriction + if (interfaceCtx->restrictions.bButton == 0) { + if ((BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_BOW) || + (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_BOMB) || + (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_BOMBCHU)) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_NONE) { + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_DISABLED; + } + + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_ENABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_B] = + ITEM_SWORD_KOKIRI + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) - EQUIP_VALUE_SWORD_KOKIRI; + } + + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = gSaveContext.buttonStatus[EQUIP_SLOT_B]; + + if (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) != ITEM_NONE) { + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + } + restoreHudVisibility = true; + } else if (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_NONE) { + if (interfaceCtx->bButtonDoAction != 0) { + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) { + restoreHudVisibility = true; + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + } + } else { + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] != BTN_DISABLED) { + restoreHudVisibility = true; + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_DISABLED; + } + } + } else if (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_NONE) { + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] != BTN_DISABLED) { + restoreHudVisibility = true; + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_DISABLED; + } + } else { + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) { + restoreHudVisibility = true; + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + } + } + } else if (interfaceCtx->restrictions.bButton != 0) { + if ((BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_BOW) || + (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_BOMB) || + (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_BOMBCHU)) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_NONE) { + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_DISABLED; + } + + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = gSaveContext.buttonStatus[EQUIP_SLOT_B]; + + if (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) != ITEM_NONE) { + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + } + restoreHudVisibility = true; + } + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] != BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_DISABLED; + restoreHudVisibility = true; + } + } + } + + // C buttons + if (gSaveContext.save.playerForm == player->transformation) { + for (i = EQUIP_SLOT_C_LEFT; i <= EQUIP_SLOT_C_RIGHT; i++) { + // Individual C button + if (!gPlayerFormItemRestrictions[(void)0, gSaveContext.save.playerForm][GET_CUR_FORM_BTN_ITEM(i)]) { + // Item not usable in current playerForm + if (gSaveContext.buttonStatus[i] != BTN_DISABLED) { + gSaveContext.buttonStatus[i] = BTN_DISABLED; + restoreHudVisibility = true; + } + } else if (player->actor.id != ACTOR_PLAYER) { + // Currently not playing as the main player + if (gSaveContext.buttonStatus[i] != BTN_DISABLED) { + gSaveContext.buttonStatus[i] = BTN_DISABLED; + restoreHudVisibility = true; + } + } else if (player->currentMask == PLAYER_MASK_GIANT) { + // Currently wearing Giant's Mask + if (GET_CUR_FORM_BTN_ITEM(i) != ITEM_MASK_GIANT) { + if (gSaveContext.buttonStatus[i] != BTN_DISABLED) { + gSaveContext.buttonStatus[i] = BTN_DISABLED; + restoreHudVisibility = true; + } + } else if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + restoreHudVisibility = true; + gSaveContext.buttonStatus[i] = BTN_ENABLED; + } + } else if (GET_CUR_FORM_BTN_ITEM(i) == ITEM_MASK_GIANT) { + // Giant's Mask is equipped + if (play->sceneId != SCENE_INISIE_BS) { + if (gSaveContext.buttonStatus[i] != BTN_DISABLED) { + gSaveContext.buttonStatus[i] = BTN_DISABLED; + restoreHudVisibility = true; + } + } else if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + restoreHudVisibility = true; + gSaveContext.buttonStatus[i] = BTN_ENABLED; + } + } else if (GET_CUR_FORM_BTN_ITEM(i) == ITEM_MASK_FIERCE_DEITY) { + // Fierce Deity's Mask is equipped + if ((play->sceneId != SCENE_MITURIN_BS) && (play->sceneId != SCENE_HAKUGIN_BS) && + (play->sceneId != SCENE_SEA_BS) && (play->sceneId != SCENE_INISIE_BS) && + (play->sceneId != SCENE_LAST_BS)) { + if (gSaveContext.buttonStatus[i] != BTN_DISABLED) { + gSaveContext.buttonStatus[i] = BTN_DISABLED; + restoreHudVisibility = true; + } + } else if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + restoreHudVisibility = true; + gSaveContext.buttonStatus[i] = BTN_ENABLED; + } + } else { + // End of special item cases. Apply restrictions to buttons + if (interfaceCtx->restrictions.tradeItems != 0) { + if (((GET_CUR_FORM_BTN_ITEM(i) >= ITEM_MOON_TEAR) && + (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_PENDANT_OF_MEMORIES)) || + ((GET_CUR_FORM_BTN_ITEM(i) >= ITEM_BOTTLE) && + (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_OBABA_DRINK)) || + (GET_CUR_FORM_BTN_ITEM(i) == ITEM_OCARINA)) { + if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_DISABLED; + } + } else if (interfaceCtx->restrictions.tradeItems == 0) { + if (((GET_CUR_FORM_BTN_ITEM(i) >= ITEM_MOON_TEAR) && + (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_PENDANT_OF_MEMORIES)) || + ((GET_CUR_FORM_BTN_ITEM(i) >= ITEM_BOTTLE) && + (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_OBABA_DRINK)) || + (GET_CUR_FORM_BTN_ITEM(i) == ITEM_OCARINA)) { + if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_ENABLED; + } + } + + if (interfaceCtx->restrictions.masks != 0) { + if ((GET_CUR_FORM_BTN_ITEM(i) >= ITEM_MASK_DEKU) && + (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_MASK_GIANT)) { + if (!gSaveContext.buttonStatus[i]) { // == BTN_ENABLED + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_DISABLED; + } + } else if (interfaceCtx->restrictions.masks == 0) { + if ((GET_CUR_FORM_BTN_ITEM(i) >= ITEM_MASK_DEKU) && + (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_MASK_GIANT)) { + if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_ENABLED; + } + } + + if (interfaceCtx->restrictions.pictoBox != 0) { + if (GET_CUR_FORM_BTN_ITEM(i) == ITEM_PICTO_BOX) { + if (!gSaveContext.buttonStatus[i]) { // == BTN_ENABLED + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_DISABLED; + } + } else if (interfaceCtx->restrictions.pictoBox == 0) { + if (GET_CUR_FORM_BTN_ITEM(i) == ITEM_PICTO_BOX) { + if (gSaveContext.buttonStatus[i] == BTN_DISABLED) { + restoreHudVisibility = true; + } + gSaveContext.buttonStatus[i] = BTN_ENABLED; + } + } + + if (interfaceCtx->restrictions.all != 0) { + if (!((GET_CUR_FORM_BTN_ITEM(i) >= ITEM_MOON_TEAR) && + (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_PENDANT_OF_MEMORIES)) && + !((GET_CUR_FORM_BTN_ITEM(i) >= ITEM_BOTTLE) && + (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_OBABA_DRINK)) && + (GET_CUR_FORM_BTN_ITEM(i) != ITEM_OCARINA) && + !((GET_CUR_FORM_BTN_ITEM(i) >= ITEM_MASK_DEKU) && + (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_MASK_GIANT)) && + (GET_CUR_FORM_BTN_ITEM(i) != ITEM_PICTO_BOX)) { + + if ((gSaveContext.buttonStatus[i] == BTN_ENABLED)) { + restoreHudVisibility = true; + gSaveContext.buttonStatus[i] = BTN_DISABLED; + } + } + } else if (interfaceCtx->restrictions.all == 0) { + if (!((GET_CUR_FORM_BTN_ITEM(i) >= ITEM_MOON_TEAR) && + (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_PENDANT_OF_MEMORIES)) && + !((GET_CUR_FORM_BTN_ITEM(i) >= ITEM_BOTTLE) && + (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_OBABA_DRINK)) && + (GET_CUR_FORM_BTN_ITEM(i) != ITEM_OCARINA) && + !((GET_CUR_FORM_BTN_ITEM(i) >= ITEM_MASK_DEKU) && + (GET_CUR_FORM_BTN_ITEM(i) <= ITEM_MASK_GIANT)) && + (GET_CUR_FORM_BTN_ITEM(i) != ITEM_PICTO_BOX)) { + + if ((gSaveContext.buttonStatus[i] == BTN_DISABLED)) { + restoreHudVisibility = true; + gSaveContext.buttonStatus[i] = BTN_ENABLED; + } + } + } + } + } + } + } + + if (restoreHudVisibility && (play->activeCamId == CAM_ID_MAIN) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && + (play->transitionMode == TRANS_MODE_OFF)) { + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } +} + +void Interface_UpdateButtonsPart1(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + Player* player = GET_PLAYER(play); + s32 pad; + s32 restoreHudVisibility = false; + + if (gSaveContext.save.cutsceneIndex < 0xFFF0) { + gSaveContext.hudVisibilityForceButtonAlphasByStatus = false; + if ((player->stateFlags1 & PLAYER_STATE1_800000) || CHECK_WEEKEVENTREG(WEEKEVENTREG_08_01) || + (!(CHECK_EVENTINF(EVENTINF_41)) && (play->unk_1887C >= 2))) { + // Riding Epona OR Honey & Darling minigame OR Horseback balloon minigame OR related to swamp boat + // (non-minigame?) + if ((player->stateFlags1 & PLAYER_STATE1_800000) && (player->currentMask == PLAYER_MASK_BLAST) && + (gSaveContext.bButtonStatus == BTN_DISABLED)) { + // Riding Epona with blast mask? + restoreHudVisibility = true; + gSaveContext.bButtonStatus = BTN_ENABLED; + } + + if (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) != ITEM_NONE) { + if ((player->transformation == PLAYER_FORM_DEKU) && CHECK_WEEKEVENTREG(WEEKEVENTREG_08_01)) { + gSaveContext.hudVisibilityForceButtonAlphasByStatus = true; + if (play->sceneId == SCENE_BOWLING) { + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_DISABLED; + } + } else if (gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_ENABLED; + } + + Interface_SetHudVisibility(HUD_VISIBILITY_B_MAGIC); + } else { + if ((BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) != ITEM_BOW) && + (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) != ITEM_BOMB) && + (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) != ITEM_BOMBCHU)) { + gSaveContext.hudVisibilityForceButtonAlphasByStatus = true; + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B); + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_ENABLED; + if (play->sceneId == SCENE_BOWLING) { + if (CURRENT_DAY == 1) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_BOMBCHU; + } else if (CURRENT_DAY == 2) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_BOMB; + } else { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_BOW; + } + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_DISABLED; + } else { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_BOW; + + if (play->unk_1887C >= 2) { + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + } else if (gSaveContext.save.saveInfo.inventory.items[SLOT_BOW] == ITEM_NONE) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_NONE; + } else { + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + } + + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_DISABLED; + Interface_SetHudVisibility(HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_WITH_OVERWRITE); + } + } + + if (play->transitionMode != TRANS_MODE_OFF) { + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); + } else if ((gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) && + (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0)) && + (Cutscene_GetSceneLayer(play) != 0) && (play->transitionTrigger == TRANS_TRIGGER_OFF)) { + Interface_SetHudVisibility(HUD_VISIBILITY_A_B_MINIMAP); + } else if ((gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) && + (CHECK_EVENTINF(EVENTINF_35))) { + Interface_SetHudVisibility(HUD_VISIBILITY_B_MINIMAP); + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_82_08) && + (gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE)) { + Interface_SetHudVisibility(HUD_VISIBILITY_B); + } else if (play->unk_1887C >= 2) { + Interface_SetHudVisibility(HUD_VISIBILITY_B); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_01)) { + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_DISABLED; + Interface_SetHudVisibility(HUD_VISIBILITY_A_B_MINIMAP); + } else if (player->stateFlags1 & PLAYER_STATE1_800000) { + Interface_SetHudVisibility(HUD_VISIBILITY_A_B_MINIMAP); + } + } + } else { + if (player->stateFlags1 & PLAYER_STATE1_800000) { + Interface_SetHudVisibility(HUD_VISIBILITY_A_B_MINIMAP); + } + + if (play->sceneId == SCENE_BOWLING) { + if (CURRENT_DAY == 1) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_BOMBCHU; + } else if (CURRENT_DAY == 2) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_BOMB; + } else { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_BOW; + } + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_DISABLED; + } else { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_BOW; + } + + if (play->unk_1887C >= 2) { + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + } else if (gSaveContext.save.saveInfo.inventory.items[SLOT_BOW] == ITEM_NONE) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_NONE; + } else { + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + } + + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + restoreHudVisibility = true; + } + + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_DISABLED; + Interface_SetHudVisibility(HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_WITH_OVERWRITE); + + if (play->transitionMode != TRANS_MODE_OFF) { + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); + } else if ((gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) && + (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0)) && + (Cutscene_GetSceneLayer(play) != 0) && (play->transitionTrigger == TRANS_TRIGGER_OFF)) { + Interface_SetHudVisibility(HUD_VISIBILITY_A_B_MINIMAP); + } else if (gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) { + Interface_SetHudVisibility(HUD_VISIBILITY_B); + } else if (play->unk_1887C >= 2) { + Interface_SetHudVisibility(HUD_VISIBILITY_B); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_01)) { + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_DISABLED; + Interface_SetHudVisibility(HUD_VISIBILITY_A_B_MINIMAP); + } else if (player->stateFlags1 & PLAYER_STATE1_800000) { + Interface_SetHudVisibility(HUD_VISIBILITY_A_B_MINIMAP); + } + } + } else if (sPictoState != PICTO_BOX_STATE_OFF) { + // Related to pictograph + if (sPictoState == PICTO_BOX_STATE_LENS) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_PICTO_BOX_ON)) { + Play_CompressI8ToI5((play->pictoPhotoI8 != NULL) ? play->pictoPhotoI8 : D_801FBB90, + (u8*)((void)0, gSaveContext.pictoPhotoI5), + PICTO_PHOTO_WIDTH * PICTO_PHOTO_HEIGHT); + interfaceCtx->unk_222 = interfaceCtx->unk_224 = 0; + restoreHudVisibility = true; + sPictoState = PICTO_BOX_STATE_OFF; + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_B)) { + play->actorCtx.flags &= ~ACTORCTX_FLAG_PICTO_BOX_ON; + interfaceCtx->unk_222 = interfaceCtx->unk_224 = 0; + restoreHudVisibility = true; + sPictoState = PICTO_BOX_STATE_OFF; + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) || (func_801A5100() == 1)) { + if (!(CHECK_EVENTINF(EVENTINF_41)) || + ((CHECK_EVENTINF(EVENTINF_41)) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE))) { + play_sound(NA_SE_SY_CAMERA_SHUTTER); + SREG(89) = 1; + play->haltAllActors = true; + sPictoState = PICTO_BOX_STATE_SETUP_PHOTO; + sPictoPhotoBeingTaken = true; + } + } + } else if ((sPictoState >= PICTO_BOX_STATE_SETUP_PHOTO) && (Message_GetState(&play->msgCtx) == 4) && + Message_ShouldAdvance(play)) { + play->haltAllActors = false; + player->stateFlags1 &= ~PLAYER_STATE1_200; + Message_CloseTextbox(play); + if (play->msgCtx.choiceIndex != 0) { + func_8019F230(); + func_80115844(play, DO_ACTION_STOP); + Interface_SetHudVisibility(HUD_VISIBILITY_A_B); + sPictoState = PICTO_BOX_STATE_LENS; + REMOVE_QUEST_ITEM(QUEST_PICTOGRAPH); + } else { + func_8019F208(); + interfaceCtx->unk_222 = interfaceCtx->unk_224 = 0; + restoreHudVisibility = true; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + sPictoState = PICTO_BOX_STATE_OFF; + if (sPictoPhotoBeingTaken) { + Play_CompressI8ToI5((play->pictoPhotoI8 != NULL) ? play->pictoPhotoI8 : D_801FBB90, + (u8*)((void)0, gSaveContext.pictoPhotoI5), + PICTO_PHOTO_WIDTH * PICTO_PHOTO_HEIGHT); + Snap_RecordPictographedActors(play); + } + play->actorCtx.flags &= ~ACTORCTX_FLAG_PICTO_BOX_ON; + SET_QUEST_ITEM(QUEST_PICTOGRAPH); + sPictoPhotoBeingTaken = false; + } + } + } else if ((gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) && + (gSaveContext.save.entrance == ENTRANCE(WATERFALL_RAPIDS, 1)) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF)) { + // Beaver race minigame + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_DISABLED; + Interface_SetHudVisibility(HUD_VISIBILITY_A_B_MINIMAP); + } else if ((gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 1)) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF)) { + // Goron race minigame + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_DISABLED; + Interface_SetHudVisibility(HUD_VISIBILITY_A_B_HEARTS_MAGIC_MINIMAP); + } else if (play->actorCtx.flags & ACTORCTX_FLAG_PICTO_BOX_ON) { + // Related to pictograph + if (!CHECK_QUEST_ITEM(QUEST_PICTOGRAPH)) { + func_80115844(play, DO_ACTION_STOP); + Interface_SetHudVisibility(HUD_VISIBILITY_A_B); + sPictoState = PICTO_BOX_STATE_LENS; + } else { + Play_DecompressI5ToI8((u8*)((void)0, gSaveContext.pictoPhotoI5), + (play->pictoPhotoI8 != NULL) ? play->pictoPhotoI8 : D_801FBB90, + PICTO_PHOTO_WIDTH * PICTO_PHOTO_HEIGHT); + play->haltAllActors = true; + sPictoState = PICTO_BOX_STATE_SETUP_PHOTO; + } + } else { + // Continue processing the remaining cases + Interface_UpdateButtonsPart2(play); + } + } + + if (restoreHudVisibility) { + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + if ((play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF)) { + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + } +} void Interface_SetSceneRestrictions(PlayState* play) { InterfaceContext* interfaceCtx = &play->interfaceCtx; @@ -1823,7 +2558,40 @@ void Interface_InitMinigame(PlayState* play) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_LoadItemIcon.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80112C0C.s") +/** + * @param play PlayState + * @param flag 0 for default update, 1 for simplified update + */ +void Interface_UpdateButtonsAlt(PlayState* play, u16 flag) { + if (flag) { + if ((BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_BOW) || + (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_BOMB) || + (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_BOMBCHU) || + (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_FISHING_ROD) || + (gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED)) { + if ((BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_BOW) || + (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_BOMB) || + (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_BOMBCHU) || + (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_FISHING_ROD)) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = gSaveContext.buttonStatus[EQUIP_SLOT_B]; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + } + } else if (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) == ITEM_NONE) { + if (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = gSaveContext.buttonStatus[EQUIP_SLOT_B]; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + } + } + + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL_NO_MINIMAP_W_DISABLED); + } else { + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + Interface_UpdateButtonsPart1(play); + } +} s16 sAmmoRefillCounts[] = { 5, 10, 20, 30 }; // Sticks, nuts, bombs s16 sArrowRefillCounts[] = { 10, 30, 40, 50 }; @@ -1859,14 +2627,14 @@ u8 Item_Give(PlayState* play, u8 item) { INCREMENT_QUEST_HEART_PIECE_COUNT; if (EQ_MAX_QUEST_HEART_PIECE_COUNT) { RESET_HEART_PIECE_COUNT; - gSaveContext.save.playerData.healthCapacity += 0x10; - gSaveContext.save.playerData.health += 0x10; + gSaveContext.save.saveInfo.playerData.healthCapacity += 0x10; + gSaveContext.save.saveInfo.playerData.health += 0x10; } return ITEM_NONE; } else if (item == ITEM_HEART_CONTAINER) { - gSaveContext.save.playerData.healthCapacity += 0x10; - gSaveContext.save.playerData.health += 0x10; + gSaveContext.save.saveInfo.playerData.healthCapacity += 0x10; + gSaveContext.save.saveInfo.playerData.health += 0x10; return ITEM_NONE; } else if ((item >= ITEM_SONG_SONATA) && (item <= ITEM_SONG_LULLABY_INTRO)) { @@ -1878,7 +2646,7 @@ u8 Item_Give(PlayState* play, u8 item) { CUR_FORM_EQUIP(EQUIP_SLOT_B) = item; Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); if (item == ITEM_SWORD_RAZOR) { - gSaveContext.save.playerData.swordHealth = 100; + gSaveContext.save.saveInfo.playerData.swordHealth = 100; } return ITEM_NONE; @@ -2056,7 +2824,7 @@ u8 Item_Give(PlayState* play, u8 item) { return ITEM_NONE; } else if ((item >= ITEM_BOMBS_5) && (item <= ITEM_BOMBS_30)) { - if (gSaveContext.save.inventory.items[SLOT_BOMB] != ITEM_BOMB) { + if (gSaveContext.save.saveInfo.inventory.items[SLOT_BOMB] != ITEM_BOMB) { INV_CONTENT(ITEM_BOMB) = ITEM_BOMB; AMMO(ITEM_BOMB) += sAmmoRefillCounts[item - ITEM_BOMBS_5]; return ITEM_NONE; @@ -2079,7 +2847,7 @@ u8 Item_Give(PlayState* play, u8 item) { return ITEM_NONE; } else if ((item >= ITEM_BOMBCHUS_20) && (item <= ITEM_BOMBCHUS_5)) { - if (gSaveContext.save.inventory.items[SLOT_BOMBCHU] != ITEM_BOMBCHU) { + if (gSaveContext.save.saveInfo.inventory.items[SLOT_BOMBCHU] != ITEM_BOMBCHU) { INV_CONTENT(ITEM_BOMBCHU) = ITEM_BOMBCHU; AMMO(ITEM_BOMBCHU) += sBombchuRefillCounts[item - ITEM_BOMBCHUS_20]; @@ -2149,8 +2917,8 @@ u8 Item_Give(PlayState* play, u8 item) { slot = SLOT(item); for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { - if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { - gSaveContext.save.inventory.items[slot + i] = ITEM_POTION_RED; + if (gSaveContext.save.saveInfo.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.saveInfo.inventory.items[slot + i] = ITEM_POTION_RED; return ITEM_NONE; } } @@ -2161,8 +2929,8 @@ u8 Item_Give(PlayState* play, u8 item) { slot = SLOT(item); for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { - if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { - gSaveContext.save.inventory.items[slot + i] = item; + if (gSaveContext.save.saveInfo.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.saveInfo.inventory.items[slot + i] = item; return ITEM_NONE; } } @@ -2172,8 +2940,8 @@ u8 Item_Give(PlayState* play, u8 item) { slot = SLOT(item); for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { - if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { - gSaveContext.save.inventory.items[slot + i] = item; + if (gSaveContext.save.saveInfo.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.saveInfo.inventory.items[slot + i] = item; return ITEM_NONE; } } @@ -2203,7 +2971,7 @@ u8 Item_Give(PlayState* play, u8 item) { slot = SLOT(item); for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { - if (gSaveContext.save.inventory.items[slot + i] == ITEM_BOTTLE) { + if (gSaveContext.save.saveInfo.inventory.items[slot + i] == ITEM_BOTTLE) { if (item == ITEM_HOT_SPRING_WATER) { Interface_StartBottleTimer(60, i); } @@ -2222,14 +2990,14 @@ u8 Item_Give(PlayState* play, u8 item) { gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_ENABLED; } - gSaveContext.save.inventory.items[slot + i] = item; + gSaveContext.save.saveInfo.inventory.items[slot + i] = item; return ITEM_NONE; } } } else { for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { - if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { - gSaveContext.save.inventory.items[slot + i] = item; + if (gSaveContext.save.saveInfo.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.saveInfo.inventory.items[slot + i] = item; return ITEM_NONE; } } @@ -2250,7 +3018,7 @@ u8 Item_Give(PlayState* play, u8 item) { return ITEM_NONE; } - temp = gSaveContext.save.inventory.items[slot]; + temp = gSaveContext.save.saveInfo.inventory.items[slot]; INV_CONTENT(item) = item; return temp; } @@ -2391,13 +3159,13 @@ u8 Item_CheckObtainabilityImpl(u8 item) { bottleSlot = SLOT(item); for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { - if (gSaveContext.save.inventory.items[bottleSlot + i] == ITEM_BOTTLE) { + if (gSaveContext.save.saveInfo.inventory.items[bottleSlot + i] == ITEM_BOTTLE) { return ITEM_NONE; } } } else { for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { - if (gSaveContext.save.inventory.items[bottleSlot + i] == ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[bottleSlot + i] == ITEM_NONE) { return ITEM_NONE; } } @@ -2406,7 +3174,7 @@ u8 Item_CheckObtainabilityImpl(u8 item) { return ITEM_NONE; } - return gSaveContext.save.inventory.items[slot]; + return gSaveContext.save.saveInfo.inventory.items[slot]; } u8 Item_CheckObtainability(u8 item) { @@ -2416,7 +3184,7 @@ u8 Item_CheckObtainability(u8 item) { void Inventory_DeleteItem(s16 item, s16 slot) { s16 btn; - gSaveContext.save.inventory.items[slot] = ITEM_NONE; + gSaveContext.save.saveInfo.inventory.items[slot] = ITEM_NONE; for (btn = EQUIP_SLOT_C_LEFT; btn <= EQUIP_SLOT_C_RIGHT; btn++) { if (GET_CUR_FORM_BTN_ITEM(btn) == item) { @@ -2441,8 +3209,8 @@ s32 Inventory_ReplaceItem(PlayState* play, u8 oldItem, u8 newItem) { u8 i; for (i = 0; i < 24; i++) { - if (gSaveContext.save.inventory.items[i] == oldItem) { - gSaveContext.save.inventory.items[i] = newItem; + if (gSaveContext.save.saveInfo.inventory.items[i] == oldItem) { + gSaveContext.save.saveInfo.inventory.items[i] = newItem; for (i = EQUIP_SLOT_C_LEFT; i <= EQUIP_SLOT_C_RIGHT; i++) { if (GET_CUR_FORM_BTN_ITEM(i) == oldItem) { @@ -2491,7 +3259,7 @@ s32 Inventory_HasEmptyBottle(void) { s32 slot; for (slot = SLOT_BOTTLE_1; slot <= SLOT_BOTTLE_6; slot++) { - if (gSaveContext.save.inventory.items[slot] == ITEM_BOTTLE) { + if (gSaveContext.save.saveInfo.inventory.items[slot] == ITEM_BOTTLE) { return true; } } @@ -2502,7 +3270,7 @@ s32 Inventory_HasItemInBottle(u8 item) { s32 slot; for (slot = SLOT_BOTTLE_1; slot <= SLOT_BOTTLE_6; slot++) { - if (gSaveContext.save.inventory.items[slot] == item) { + if (gSaveContext.save.saveInfo.inventory.items[slot] == item) { return true; } } @@ -2510,7 +3278,7 @@ s32 Inventory_HasItemInBottle(u8 item) { } void Inventory_UpdateBottleItem(PlayState* play, u8 item, u8 btn) { - gSaveContext.save.inventory.items[GET_CUR_FORM_BTN_SLOT(btn)] = item; + gSaveContext.save.saveInfo.inventory.items[GET_CUR_FORM_BTN_SLOT(btn)] = item; SET_CUR_FORM_BTN_ITEM(btn, item); Interface_LoadItemIconImpl(play, btn); @@ -2529,7 +3297,7 @@ s32 Inventory_ConsumeFairy(PlayState* play) { u8 i; for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { - if (gSaveContext.save.inventory.items[bottleSlot + i] == ITEM_FAIRY) { + if (gSaveContext.save.saveInfo.inventory.items[bottleSlot + i] == ITEM_FAIRY) { for (btn = EQUIP_SLOT_C_LEFT; btn <= EQUIP_SLOT_C_RIGHT; btn++) { if (GET_CUR_FORM_BTN_ITEM(btn) == ITEM_FAIRY) { SET_CUR_FORM_BTN_ITEM(btn, ITEM_BOTTLE); @@ -2539,7 +3307,7 @@ s32 Inventory_ConsumeFairy(PlayState* play) { break; } } - gSaveContext.save.inventory.items[bottleSlot + i] = ITEM_BOTTLE; + gSaveContext.save.saveInfo.inventory.items[bottleSlot + i] = ITEM_BOTTLE; return true; } } @@ -2553,7 +3321,7 @@ s32 Inventory_ConsumeFairy(PlayState* play) { void Inventory_UpdateItem(PlayState* play, s16 slot, s16 item) { s16 btn; - gSaveContext.save.inventory.items[slot] = item; + gSaveContext.save.saveInfo.inventory.items[slot] = item; for (btn = EQUIP_SLOT_C_LEFT; btn <= EQUIP_SLOT_C_RIGHT; btn++) { if (GET_CUR_FORM_BTN_SLOT(btn) == slot) { @@ -2587,18 +3355,19 @@ void func_80115428(InterfaceContext* interfaceCtx, u16 doAction, s16 loadOffset) s32 Health_ChangeBy(PlayState* play, s16 healthChange) { if (healthChange > 0) { play_sound(NA_SE_SY_HP_RECOVER); - } else if (gSaveContext.save.playerData.doubleDefense && (healthChange < 0)) { + } else if (gSaveContext.save.saveInfo.playerData.doubleDefense && (healthChange < 0)) { healthChange >>= 1; } - gSaveContext.save.playerData.health += healthChange; + gSaveContext.save.saveInfo.playerData.health += healthChange; - if (((void)0, gSaveContext.save.playerData.health) > ((void)0, gSaveContext.save.playerData.healthCapacity)) { - gSaveContext.save.playerData.health = gSaveContext.save.playerData.healthCapacity; + if (((void)0, gSaveContext.save.saveInfo.playerData.health) > + ((void)0, gSaveContext.save.saveInfo.playerData.healthCapacity)) { + gSaveContext.save.saveInfo.playerData.health = gSaveContext.save.saveInfo.playerData.healthCapacity; } - if (gSaveContext.save.playerData.health <= 0) { - gSaveContext.save.playerData.health = 0; + if (gSaveContext.save.saveInfo.playerData.health <= 0) { + gSaveContext.save.saveInfo.playerData.health = 0; return false; } else { return true; @@ -2606,7 +3375,7 @@ s32 Health_ChangeBy(PlayState* play, s16 healthChange) { } void Health_GiveHearts(s16 hearts) { - gSaveContext.save.playerData.healthCapacity += hearts * 0x10; + gSaveContext.save.saveInfo.playerData.healthCapacity += hearts * 0x10; } void Rupees_ChangeBy(s16 rupeeChange) { @@ -2673,7 +3442,7 @@ void Inventory_ChangeAmmo(s16 item, s16 ammoChange) { } void Magic_Add(PlayState* play, s16 magicToAdd) { - if (((void)0, gSaveContext.save.playerData.magic) < ((void)0, gSaveContext.magicCapacity)) { + if (((void)0, gSaveContext.save.saveInfo.playerData.magic) < ((void)0, gSaveContext.magicCapacity)) { gSaveContext.magicToAdd += magicToAdd; gSaveContext.isMagicRequested = true; } @@ -2697,12 +3466,12 @@ s32 Magic_Consume(PlayState* play, s16 magicToConsume, s16 type) { InterfaceContext* interfaceCtx = &play->interfaceCtx; // Magic is not acquired yet - if (!gSaveContext.save.playerData.isMagicAcquired) { + if (!gSaveContext.save.saveInfo.playerData.isMagicAcquired) { return false; } // Not enough magic available to consume - if ((gSaveContext.save.playerData.magic - magicToConsume) < 0) { + if ((gSaveContext.save.saveInfo.playerData.magic - magicToConsume) < 0) { if (gSaveContext.magicCapacity != 0) { play_sound(NA_SE_SY_ERROR); } @@ -2750,7 +3519,7 @@ s32 Magic_Consume(PlayState* play, s16 magicToConsume, s16 type) { case MAGIC_CONSUME_LENS: if (gSaveContext.magicState == MAGIC_STATE_IDLE) { - if (gSaveContext.save.playerData.magic != 0) { + if (gSaveContext.save.saveInfo.playerData.magic != 0) { interfaceCtx->magicConsumptionTimer = 80; gSaveContext.magicState = MAGIC_STATE_CONSUME_LENS; return true; @@ -2781,7 +3550,7 @@ s32 Magic_Consume(PlayState* play, s16 magicToConsume, s16 type) { case MAGIC_CONSUME_GORON_ZORA: // Goron spiked rolling or Zora electric barrier - if (gSaveContext.save.playerData.magic != 0) { + if (gSaveContext.save.saveInfo.playerData.magic != 0) { interfaceCtx->magicConsumptionTimer = 10; gSaveContext.magicState = MAGIC_STATE_CONSUME_GORON_ZORA_SETUP; return true; @@ -2792,7 +3561,7 @@ s32 Magic_Consume(PlayState* play, s16 magicToConsume, s16 type) { case MAGIC_CONSUME_GIANTS_MASK: // Wearing Giant's Mask if (gSaveContext.magicState == MAGIC_STATE_IDLE) { - if (gSaveContext.save.playerData.magic != 0) { + if (gSaveContext.save.saveInfo.playerData.magic != 0) { interfaceCtx->magicConsumptionTimer = R_MAGIC_CONSUME_TIMER_GIANTS_MASK; gSaveContext.magicState = MAGIC_STATE_CONSUME_GIANTS_MASK; return true; @@ -2816,7 +3585,7 @@ s32 Magic_Consume(PlayState* play, s16 magicToConsume, s16 type) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { magicToConsume = 0; } - gSaveContext.save.playerData.magic -= magicToConsume; + gSaveContext.save.saveInfo.playerData.magic -= magicToConsume; return true; } else { play_sound(NA_SE_SY_ERROR); @@ -2829,11 +3598,11 @@ s32 Magic_Consume(PlayState* play, s16 magicToConsume, s16 type) { void Magic_UpdateAddRequest(void) { if (gSaveContext.isMagicRequested) { - gSaveContext.save.playerData.magic += 4; + gSaveContext.save.saveInfo.playerData.magic += 4; play_sound(NA_SE_SY_GAUGE_UP - SFX_FLAG); - if (((void)0, gSaveContext.save.playerData.magic) >= ((void)0, gSaveContext.magicCapacity)) { - gSaveContext.save.playerData.magic = gSaveContext.magicCapacity; + if (((void)0, gSaveContext.save.saveInfo.playerData.magic) >= ((void)0, gSaveContext.magicCapacity)) { + gSaveContext.save.saveInfo.playerData.magic = gSaveContext.magicCapacity; gSaveContext.magicToAdd = 0; gSaveContext.isMagicRequested = false; } else { @@ -2909,7 +3678,7 @@ void Magic_Update(PlayState* play) { case MAGIC_STATE_STEP_CAPACITY: // Step magicCapacity to the capacity determined by magicLevel // This changes the width of the magic meter drawn - magicCapacityTarget = gSaveContext.save.playerData.magicLevel * MAGIC_NORMAL_METER; + magicCapacityTarget = gSaveContext.save.saveInfo.playerData.magicLevel * MAGIC_NORMAL_METER; if (gSaveContext.magicCapacity != magicCapacityTarget) { if (gSaveContext.magicCapacity < magicCapacityTarget) { gSaveContext.magicCapacity += 0x10; @@ -2931,14 +3700,14 @@ void Magic_Update(PlayState* play) { case MAGIC_STATE_FILL: // Add magic until magicFillTarget is reached - gSaveContext.save.playerData.magic += 0x10; + gSaveContext.save.saveInfo.playerData.magic += 0x10; - if ((gSaveContext.gameMode == 0) && (gSaveContext.sceneLayer < 4)) { + if ((gSaveContext.gameMode == GAMEMODE_NORMAL) && (gSaveContext.sceneLayer < 4)) { play_sound(NA_SE_SY_GAUGE_UP - SFX_FLAG); } - if (((void)0, gSaveContext.save.playerData.magic) >= ((void)0, gSaveContext.magicFillTarget)) { - gSaveContext.save.playerData.magic = gSaveContext.magicFillTarget; + if (((void)0, gSaveContext.save.saveInfo.playerData.magic) >= ((void)0, gSaveContext.magicFillTarget)) { + gSaveContext.save.saveInfo.playerData.magic = gSaveContext.magicFillTarget; gSaveContext.magicState = MAGIC_STATE_IDLE; } break; @@ -2952,10 +3721,10 @@ void Magic_Update(PlayState* play) { case MAGIC_STATE_CONSUME: // Consume magic until target is reached or no more magic is available if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { - gSaveContext.save.playerData.magic = - ((void)0, gSaveContext.save.playerData.magic) - ((void)0, gSaveContext.magicToConsume); - if (gSaveContext.save.playerData.magic <= 0) { - gSaveContext.save.playerData.magic = 0; + gSaveContext.save.saveInfo.playerData.magic = + ((void)0, gSaveContext.save.saveInfo.playerData.magic) - ((void)0, gSaveContext.magicToConsume); + if (gSaveContext.save.saveInfo.playerData.magic <= 0) { + gSaveContext.save.saveInfo.playerData.magic = 0; } gSaveContext.magicState = MAGIC_STATE_METER_FLASH_1; sMagicMeterOutlinePrimRed = sMagicMeterOutlinePrimGreen = sMagicMeterOutlinePrimBlue = 255; @@ -2981,7 +3750,7 @@ void Magic_Update(PlayState* play) { (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play)) { - if ((gSaveContext.save.playerData.magic == 0) || + if ((gSaveContext.save.saveInfo.playerData.magic == 0) || ((Player_GetEnvironmentalHazard(play) >= PLAYER_ENV_HAZARD_UNDERWATER_FLOOR) && (Player_GetEnvironmentalHazard(play) <= PLAYER_ENV_HAZARD_UNDERWATER_FREE)) || ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) != ITEM_LENS) && @@ -2999,7 +3768,7 @@ void Magic_Update(PlayState* play) { interfaceCtx->magicConsumptionTimer--; if (interfaceCtx->magicConsumptionTimer == 0) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { - gSaveContext.save.playerData.magic--; + gSaveContext.save.saveInfo.playerData.magic--; } interfaceCtx->magicConsumptionTimer = 80; } @@ -3011,10 +3780,10 @@ void Magic_Update(PlayState* play) { case MAGIC_STATE_CONSUME_GORON_ZORA_SETUP: if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { - gSaveContext.save.playerData.magic -= 2; + gSaveContext.save.saveInfo.playerData.magic -= 2; } - if (gSaveContext.save.playerData.magic <= 0) { - gSaveContext.save.playerData.magic = 0; + if (gSaveContext.save.saveInfo.playerData.magic <= 0) { + gSaveContext.save.saveInfo.playerData.magic = 0; } gSaveContext.magicState = MAGIC_STATE_CONSUME_GORON_ZORA; // fallthrough @@ -3026,10 +3795,10 @@ void Magic_Update(PlayState* play) { interfaceCtx->magicConsumptionTimer--; if (interfaceCtx->magicConsumptionTimer == 0) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { - gSaveContext.save.playerData.magic--; + gSaveContext.save.saveInfo.playerData.magic--; } - if (gSaveContext.save.playerData.magic <= 0) { - gSaveContext.save.playerData.magic = 0; + if (gSaveContext.save.saveInfo.playerData.magic <= 0) { + gSaveContext.save.saveInfo.playerData.magic = 0; } interfaceCtx->magicConsumptionTimer = 10; } @@ -3048,10 +3817,10 @@ void Magic_Update(PlayState* play) { interfaceCtx->magicConsumptionTimer--; if (interfaceCtx->magicConsumptionTimer == 0) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { - gSaveContext.save.playerData.magic--; + gSaveContext.save.saveInfo.playerData.magic--; } - if (gSaveContext.save.playerData.magic <= 0) { - gSaveContext.save.playerData.magic = 0; + if (gSaveContext.save.saveInfo.playerData.magic <= 0) { + gSaveContext.save.saveInfo.playerData.magic = 0; } interfaceCtx->magicConsumptionTimer = R_MAGIC_CONSUME_TIMER_GIANTS_MASK; } @@ -3074,8 +3843,8 @@ void Magic_DrawMeter(PlayState* play) { OPEN_DISPS(play->state.gfxCtx); - if (gSaveContext.save.playerData.magicLevel != 0) { - if (gSaveContext.save.playerData.healthCapacity > 0xA0) { + if (gSaveContext.save.saveInfo.playerData.magicLevel != 0) { + if (gSaveContext.save.saveInfo.playerData.healthCapacity > 0xA0) { magicBarY = 42; // two rows of hearts } else { magicBarY = 34; // one row of hearts @@ -3108,8 +3877,8 @@ void Magic_DrawMeter(PlayState* play) { gDPLoadTextureBlock_4b(OVERLAY_DISP++, gMagicMeterFillTex, G_IM_FMT_I, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); gSPTextureRectangle(OVERLAY_DISP++, 104, (magicBarY + 3) << 2, - (((void)0, gSaveContext.save.playerData.magic) + 26) << 2, (magicBarY + 10) << 2, - G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + (((void)0, gSaveContext.save.saveInfo.playerData.magic) + 26) << 2, + (magicBarY + 10) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); // Fill the rest of the meter with the normal magic color gDPPipeSync(OVERLAY_DISP++); @@ -3123,7 +3892,8 @@ void Magic_DrawMeter(PlayState* play) { gSPTextureRectangle( OVERLAY_DISP++, 104, (magicBarY + 3) << 2, - ((((void)0, gSaveContext.save.playerData.magic) - ((void)0, gSaveContext.magicToConsume)) + 26) << 2, + ((((void)0, gSaveContext.save.saveInfo.playerData.magic) - ((void)0, gSaveContext.magicToConsume)) + 26) + << 2, (magicBarY + 10) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); } else { // Fill the whole meter with the normal magic color @@ -3138,57 +3908,508 @@ void Magic_DrawMeter(PlayState* play) { gDPLoadTextureBlock_4b(OVERLAY_DISP++, gMagicMeterFillTex, G_IM_FMT_I, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); gSPTextureRectangle(OVERLAY_DISP++, 104, (magicBarY + 3) << 2, - (((void)0, gSaveContext.save.playerData.magic) + 26) << 2, (magicBarY + 10) << 2, - G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + (((void)0, gSaveContext.save.saveInfo.playerData.magic) + 26) << 2, + (magicBarY + 10) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); } } CLOSE_DISPS(play->state.gfxCtx); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116FD8.s") +void Interface_SetPerspectiveView(PlayState* play, s32 topY, s32 bottomY, s32 leftX, s32 rightX) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + Vec3f eye; + Vec3f at; + Vec3f up; -void func_801170B8(InterfaceContext* interfaceCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801170B8.s") + eye.x = eye.y = eye.z = 0.0f; + at.x = at.y = 0.0f; + at.z = -1.0f; + up.x = up.z = 0.0f; + up.y = 1.0f; -TexturePtr cUpLabelTextures[] = { - gTatlCUpENGTex, gTatlCUpENGTex, gTatlCUpGERTex, gTatlCUpFRATex, gTatlCUpESPTex, -}; -s16 startButtonLeftPos[] = { - // Remnant of OoT - 130, 136, 136, 136, 136, -}; -s16 D_801BFAF4[] = { 0x1D, 0x1B }; -s16 D_801BFAF8[] = { 0x1B, 0x1B }; + View_LookAt(&interfaceCtx->view, &eye, &at, &up); -void func_80117100(PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80117100.s") + interfaceCtx->viewport.topY = topY; + interfaceCtx->viewport.bottomY = bottomY; + interfaceCtx->viewport.leftX = leftX; + interfaceCtx->viewport.rightX = rightX; + View_SetViewport(&interfaceCtx->view, &interfaceCtx->viewport); -s16 D_801BFAFC[] = { 30, 24, 24, 24 }; + View_SetPerspective(&interfaceCtx->view, 60.0f, 10.0f, 60.0f); + View_ApplyPerspectiveToOverlay(&interfaceCtx->view); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80117A20.s") +void Interface_SetOrthoView(InterfaceContext* interfaceCtx) { + SET_FULLSCREEN_VIEWPORT(&interfaceCtx->view); + View_ApplyOrthoToOverlay(&interfaceCtx->view); +} + +void Interface_DrawItemButtons(PlayState* play) { + static TexturePtr cUpLabelTextures[] = { + gTatlCUpENGTex, gTatlCUpENGTex, gTatlCUpGERTex, gTatlCUpFRATex, gTatlCUpESPTex, + }; + static s16 startButtonLeftPos[] = { + // Remnant of OoT + 130, 136, 136, 136, 136, + }; + static s16 D_801BFAF4[] = { 0x1D, 0x1B }; + static s16 D_801BFAF8[] = { 0x1B, 0x1B }; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + Player* player = GET_PLAYER(play); + PauseContext* pauseCtx = &play->pauseCtx; + MessageContext* msgCtx = &play->msgCtx; + s16 temp; // Used as both an alpha value and a button index + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + // B Button Color & Texture + OVERLAY_DISP = Gfx_DrawTexRectIA8_DropShadow(OVERLAY_DISP, gButtonBackgroundTex, 0x20, 0x20, D_801BF9D4[0], + D_801BF9DC[0], D_801BFAF4[0], D_801BFAF4[0], D_801BF9E4[0] * 2, + D_801BF9E4[0] * 2, 100, 255, 120, interfaceCtx->bAlpha); + if (1) {} + gDPPipeSync(OVERLAY_DISP++); + + // C-Left Button Color & Texture + OVERLAY_DISP = Gfx_DrawRect_DropShadow(OVERLAY_DISP, D_801BF9D4[1], D_801BF9DC[1], D_801BFAF4[1], D_801BFAF4[1], + D_801BF9E4[1] * 2, D_801BF9E4[1] * 2, 255, 240, 0, interfaceCtx->cLeftAlpha); + // C-Down Button Color & Texture + OVERLAY_DISP = Gfx_DrawRect_DropShadow(OVERLAY_DISP, D_801BF9D8[0], D_801BF9E0[0], D_801BFAF8[0], D_801BFAF8[0], + D_801BF9E4[2] * 2, D_801BF9E4[2] * 2, 255, 240, 0, interfaceCtx->cDownAlpha); + // C-Right Button Color & Texture + OVERLAY_DISP = + Gfx_DrawRect_DropShadow(OVERLAY_DISP, D_801BF9D8[1], D_801BF9E0[1], D_801BFAF8[1], D_801BFAF8[1], + D_801BF9E4[3] * 2, D_801BF9E4[3] * 2, 255, 240, 0, interfaceCtx->cRightAlpha); + + if (!IS_PAUSE_STATE_GAMEOVER) { + if ((play->pauseCtx.state != PAUSE_STATE_OFF) || (play->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { + OVERLAY_DISP = Gfx_DrawRect_DropShadow(OVERLAY_DISP, 0x88, 0x11, 0x16, 0x16, 0x5B6, 0x5B6, 0xFF, 0x82, 0x3C, + interfaceCtx->startAlpha); + // Start Button Texture, Color & Label + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->startAlpha); + gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 0); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, interfaceCtx->doActionSegment + DO_ACTION_TEX_SIZE * 2, G_IM_FMT_IA, + DO_ACTION_TEX_WIDTH, DO_ACTION_TEX_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++, 0x01F8, 0x0054, 0x02D4, 0x009C, G_TX_RENDERTILE, 0, 0, 0x04A6, 0x04A6); + } + } + + if (interfaceCtx->tatlCalling && (play->pauseCtx.state == PAUSE_STATE_OFF) && + (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && (play->csCtx.state == CS_STATE_IDLE) && + (sPictoState == PICTO_BOX_STATE_OFF)) { + if (sCUpInvisible == 0) { + // C-Up Button Texture, Color & Label (Tatl Text) + gDPPipeSync(OVERLAY_DISP++); + + if ((gSaveContext.hudVisibility == HUD_VISIBILITY_NONE) || + (gSaveContext.hudVisibility == HUD_VISIBILITY_NONE_ALT) || + (gSaveContext.hudVisibility == HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE) || + (msgCtx->msgMode != 0)) { + temp = 0; + } else if (player->stateFlags1 & PLAYER_STATE1_200000) { + temp = 70; + } else { + temp = interfaceCtx->aAlpha; + } + + OVERLAY_DISP = + Gfx_DrawRect_DropShadow(OVERLAY_DISP, 0xFE, 0x10, 0x10, 0x10, 0x800, 0x800, 0xFF, 0xF0, 0, temp); + + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, temp); + gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 0); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, cUpLabelTextures[gSaveContext.options.language], G_IM_FMT_IA, 32, 12, + 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++, 0x03DC, 0x0048, 0x045C, 0x0078, G_TX_RENDERTILE, 0, 0, 1 << 10, + 1 << 10); + } + + sCUpTimer--; + if (sCUpTimer == 0) { + sCUpInvisible ^= 1; + sCUpTimer = 10; + } + } + + gDPPipeSync(OVERLAY_DISP++); + + // Empty C Button Arrows + for (temp = EQUIP_SLOT_C_LEFT; temp <= EQUIP_SLOT_C_RIGHT; temp++) { + if (GET_CUR_FORM_BTN_ITEM(temp) > 0xF0) { + if (temp == EQUIP_SLOT_C_LEFT) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 240, 0, interfaceCtx->cLeftAlpha); + } else if (temp == EQUIP_SLOT_C_DOWN) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 240, 0, interfaceCtx->cDownAlpha); + } else { // EQUIP_SLOT_C_RIGHT + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 240, 0, interfaceCtx->cRightAlpha); + } + OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, ((u8*)gButtonBackgroundTex + ((32 * 32) * (temp + 1))), + 0x20, 0x20, D_801BF9D4[temp], D_801BF9DC[temp], D_801BFAF4[temp], + D_801BFAF4[temp], D_801BF9E4[temp] * 2, D_801BF9E4[temp] * 2); + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +void Interface_DrawItemIconTexture(PlayState* play, TexturePtr texture, s16 button) { + static s16 D_801BFAFC[] = { 30, 24, 24, 24 }; + + OPEN_DISPS(play->state.gfxCtx); + + gDPLoadTextureBlock(OVERLAY_DISP++, texture, G_IM_FMT_RGBA, G_IM_SIZ_32b, 32, 32, 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++, D_801BF9D4[button] << 2, D_801BF9DC[button] << 2, + (D_801BF9D4[button] + D_801BFAFC[button]) << 2, (D_801BF9DC[button] + D_801BFAFC[button]) << 2, + G_TX_RENDERTILE, 0, 0, D_801BF9BC[button] << 1, D_801BF9BC[button] << 1); + + CLOSE_DISPS(play->state.gfxCtx); +} s16 D_801BFB04[] = { 0xA2, 0xE4, 0xFA, 0x110 }; s16 D_801BFB0C[] = { 0x23, 0x23, 0x33, 0x23 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80117BD0.s") +void Interface_DrawAmmoCount(PlayState* play, s16 button, s16 alpha) { + u8 i; + u16 ammo; -void func_80118084(PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80118084.s") + OPEN_DISPS(play->state.gfxCtx); -void func_80118890(PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80118890.s") + i = ((void)0, GET_CUR_FORM_BTN_ITEM(button)); -void func_80118BA4(PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80118BA4.s") + if ((i == ITEM_STICK) || (i == ITEM_NUT) || (i == ITEM_BOMB) || (i == ITEM_BOW) || + ((i >= ITEM_BOW_ARROW_FIRE) && (i <= ITEM_BOW_ARROW_LIGHT)) || (i == ITEM_BOMBCHU) || (i == ITEM_POWDER_KEG) || + (i == ITEM_MAGIC_BEANS) || (i == ITEM_PICTO_BOX)) { -extern TexturePtr D_08095AC0; // gMagicArrowEquipEffectTex -s16 D_801BFB14[] = { 255, 100, 255, 0 }; // magicArrowEffectsR -s16 D_801BFB1C[] = { 0, 100, 255, 0 }; // magicArrowEffectsG -s16 D_801BFB24[] = { 0, 255, 100, 0 }; // magicArrowEffectsB + if ((i >= ITEM_BOW_ARROW_FIRE) && (i <= ITEM_BOW_ARROW_LIGHT)) { + i = ITEM_BOW; + } -void func_80119030(PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80119030.s") + ammo = AMMO(i); + + if (i == ITEM_PICTO_BOX) { + if (!CHECK_QUEST_ITEM(QUEST_PICTOGRAPH)) { + ammo = 0; + } else { + ammo = 1; + } + } + + gDPPipeSync(OVERLAY_DISP++); + + if ((button == EQUIP_SLOT_B) && (gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE)) { + ammo = play->interfaceCtx.minigameAmmo; + } else if ((button == EQUIP_SLOT_B) && (play->unk_1887C > 1)) { + ammo = play->unk_1887C - 1; + } else if (((i == ITEM_BOW) && (AMMO(i) == CUR_CAPACITY(UPG_QUIVER))) || + ((i == ITEM_BOMB) && (AMMO(i) == CUR_CAPACITY(UPG_BOMB_BAG))) || + ((i == ITEM_STICK) && (AMMO(i) == CUR_CAPACITY(UPG_STICKS))) || + ((i == ITEM_NUT) && (AMMO(i) == CUR_CAPACITY(UPG_NUTS))) || + ((i == ITEM_BOMBCHU) && (AMMO(i) == CUR_CAPACITY(UPG_BOMB_BAG))) || + ((i == ITEM_POWDER_KEG) && (ammo == 1)) || ((i == ITEM_PICTO_BOX) && (ammo == 1)) || + ((i == ITEM_MAGIC_BEANS) && (ammo == 20))) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 120, 255, 0, alpha); + } + + if ((u32)ammo == 0) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 100, 100, 100, alpha); + } + + for (i = 0; ammo >= 10; i++) { + ammo -= 10; + } + + // Draw upper digit (tens) + if ((u32)i != 0) { + OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, ((u8*)gAmmoDigit0Tex + ((8 * 8) * i)), 8, 8, + D_801BFB04[button], D_801BFB0C[button], 8, 8, 1 << 10, 1 << 10); + } + + // Draw lower digit (ones) + OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, ((u8*)gAmmoDigit0Tex + ((8 * 8) * ammo)), 8, 8, + D_801BFB04[button] + 6, D_801BFB0C[button], 8, 8, 1 << 10, 1 << 10); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +void Interface_DrawBButtonIcons(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + Player* player = GET_PLAYER(play); + + OPEN_DISPS(play->state.gfxCtx); + + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->bAlpha); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + if ((interfaceCtx->unk_222 == 0) && (player->stateFlags3 & PLAYER_STATE3_1000000)) { + if (gSaveContext.buttonStatus[EQUIP_SLOT_B] != BTN_DISABLED) { + Interface_DrawItemIconTexture(play, interfaceCtx->iconItemSegment, EQUIP_SLOT_B); + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + + Interface_DrawAmmoCount(play, EQUIP_SLOT_B, interfaceCtx->bAlpha); + } + } else if ((!interfaceCtx->unk_21C && (interfaceCtx->unk_222 == 0)) || + ((interfaceCtx->unk_21C && + ((BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) < ITEM_SWORD_KOKIRI) || + (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) > ITEM_SWORD_GILDED)) && + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) != ITEM_NONE) && + (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) != ITEM_NUT))) { + if ((player->transformation == PLAYER_FORM_FIERCE_DEITY) || (player->transformation == PLAYER_FORM_HUMAN)) { + if (BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) != ITEM_NONE) { + Interface_DrawItemIconTexture(play, interfaceCtx->iconItemSegment, EQUIP_SLOT_B); + if ((player->stateFlags1 & PLAYER_STATE1_800000) || CHECK_WEEKEVENTREG(WEEKEVENTREG_08_01) || + (play->unk_1887C >= 2)) { + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, + 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + + if ((play->sceneId != SCENE_SYATEKI_MIZU) && (play->sceneId != SCENE_SYATEKI_MORI) && + (play->sceneId != SCENE_BOWLING) && + ((gSaveContext.minigameStatus != MINIGAME_STATUS_ACTIVE) || + (gSaveContext.save.entrance != ENTRANCE(ROMANI_RANCH, 0))) && + ((gSaveContext.minigameStatus != MINIGAME_STATUS_ACTIVE) || !(CHECK_EVENTINF(EVENTINF_35))) && + (!CHECK_WEEKEVENTREG(WEEKEVENTREG_31_80) || (play->unk_1887C != 100))) { + Interface_DrawAmmoCount(play, EQUIP_SLOT_B, interfaceCtx->bAlpha); + } + } + } + } + } else if (interfaceCtx->unk_222 != 0) { + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->bAlpha); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, interfaceCtx->doActionSegment + 0x480, G_IM_FMT_IA, 48, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + + D_801BF9B0 = 1024.0f / (D_801BF9B4[gSaveContext.options.language] / 100.0f); + + gSPTextureRectangle( + OVERLAY_DISP++, (D_801BF9C4[gSaveContext.options.language] * 4), + (D_801BF9C8[gSaveContext.options.language] * 4), ((D_801BF9C4[gSaveContext.options.language] + 0x30) << 2), + ((D_801BF9C8[gSaveContext.options.language] + 0x10) << 2), G_TX_RENDERTILE, 0, 0, D_801BF9B0, D_801BF9B0); + } else if (interfaceCtx->bButtonDoAction != DO_ACTION_NONE) { + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->bAlpha); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, interfaceCtx->doActionSegment + 0x600, G_IM_FMT_IA, 48, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + + D_801BF9B0 = 1024.0f / (D_801BF9B4[gSaveContext.options.language] / 100.0f); + + gSPTextureRectangle( + OVERLAY_DISP++, (D_801BF9C4[gSaveContext.options.language] * 4), + (D_801BF9C8[gSaveContext.options.language] * 4), ((D_801BF9C4[gSaveContext.options.language] + 0x30) << 2), + ((D_801BF9C8[gSaveContext.options.language] + 0x10) << 2), G_TX_RENDERTILE, 0, 0, D_801BF9B0, D_801BF9B0); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +/** + * Draws the icons and ammo for each of the C buttons + */ +void Interface_DrawCButtonIcons(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + + OPEN_DISPS(play->state.gfxCtx); + + gDPPipeSync(OVERLAY_DISP++); + + // C-Left Button Icon & Ammo Count + if (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) < ITEM_F0) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->cLeftAlpha); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + Interface_DrawItemIconTexture(play, interfaceCtx->iconItemSegment + 0x1000, EQUIP_SLOT_C_LEFT); + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + Interface_DrawAmmoCount(play, EQUIP_SLOT_C_LEFT, interfaceCtx->cLeftAlpha); + } + + gDPPipeSync(OVERLAY_DISP++); + + // C-Down Button Icon & Ammo Count + if (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) < ITEM_F0) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->cDownAlpha); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + Interface_DrawItemIconTexture(play, interfaceCtx->iconItemSegment + 0x2000, EQUIP_SLOT_C_DOWN); + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + Interface_DrawAmmoCount(play, EQUIP_SLOT_C_DOWN, interfaceCtx->cDownAlpha); + } + + gDPPipeSync(OVERLAY_DISP++); + + // C-Right Button Icon & Ammo Count + if (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) < ITEM_F0) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->cRightAlpha); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + Interface_DrawItemIconTexture(play, interfaceCtx->iconItemSegment + 0x3000, EQUIP_SLOT_C_RIGHT); + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + Interface_DrawAmmoCount(play, EQUIP_SLOT_C_RIGHT, interfaceCtx->cRightAlpha); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +void Interface_DrawAButton(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 aAlpha; + + OPEN_DISPS(play->state.gfxCtx); + + aAlpha = interfaceCtx->aAlpha; + + if (aAlpha > 100) { + aAlpha = 100; + } + + func_8012C8D4(play->state.gfxCtx); + + Interface_SetPerspectiveView(play, 25 + R_A_BTN_Y_OFFSET, 70 + R_A_BTN_Y_OFFSET, 192, 237); + + gSPClearGeometryMode(OVERLAY_DISP++, G_CULL_BOTH); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetAlphaCompare(OVERLAY_DISP++, G_AC_THRESHOLD); + + Matrix_Translate(0.0f, 0.0f, -38.0f, MTXMODE_NEW); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateXFApply(interfaceCtx->aButtonRoll / 10000.0f); + + // Draw A button Shadow + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPPipeSync(OVERLAY_DISP++); + gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[4], 4, 0); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, aAlpha); + + OVERLAY_DISP = Gfx_DrawTexQuadIA8(OVERLAY_DISP, gButtonBackgroundTex, 32, 32, 0); + + // Draw A Button Colored + gDPPipeSync(OVERLAY_DISP++); + Interface_SetPerspectiveView(play, 23 + R_A_BTN_Y_OFFSET, 68 + R_A_BTN_Y_OFFSET, 190, 235); + gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[0], 4, 0); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 100, 200, 255, interfaceCtx->aAlpha); + gSP1Quadrangle(OVERLAY_DISP++, 0, 2, 3, 1, 0); + + // Draw A Button Do-Action + gDPPipeSync(OVERLAY_DISP++); + Interface_SetPerspectiveView(play, 23 + R_A_BTN_Y_OFFSET, 68 + R_A_BTN_Y_OFFSET, 190, 235); + gSPSetGeometryMode(OVERLAY_DISP++, G_CULL_BACK); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, + ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->aAlpha); + gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 0); + + Matrix_Translate(0.0f, 0.0f, D_801BF9CC[gSaveContext.options.language] / 10.0f, MTXMODE_NEW); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateXFApply(interfaceCtx->aButtonRoll / 10000.0f); + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[8], 4, 0); + + // Draw Action Label + if (((interfaceCtx->aButtonState <= A_BTN_STATE_1) || (interfaceCtx->aButtonState == A_BTN_STATE_3))) { + OVERLAY_DISP = Gfx_DrawTexQuad4b(OVERLAY_DISP, interfaceCtx->doActionSegment, 3, DO_ACTION_TEX_WIDTH, + DO_ACTION_TEX_HEIGHT, 0); + } else { + OVERLAY_DISP = Gfx_DrawTexQuad4b(OVERLAY_DISP, interfaceCtx->doActionSegment + DO_ACTION_TEX_SIZE, 3, + DO_ACTION_TEX_WIDTH, DO_ACTION_TEX_HEIGHT, 0); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +static s16 sMagicArrowEffectsR[] = { 255, 100, 255 }; +static s16 sMagicArrowEffectsG[] = { 0, 100, 255 }; +static s16 sMagicArrowEffectsB[] = { 0, 255, 100 }; + +void Interface_DrawPauseMenuEquippingIcons(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + PauseContext* pauseCtx = &play->pauseCtx; + s16 temp; + + OPEN_DISPS(play->state.gfxCtx); + + gDPPipeSync(OVERLAY_DISP++); + + // This is needed as `Interface_DrawPauseMenuEquippingIcons` is call immediately + // after `Interface_DrawAButton`, which sets the view to perspective mode + Interface_SetOrthoView(interfaceCtx); + + if ((pauseCtx->state == PAUSE_STATE_MAIN) && ((pauseCtx->mainState == PAUSE_MAIN_STATE_EQUIP_ITEM) || + (pauseCtx->mainState == PAUSE_MAIN_STATE_EQUIP_MASK))) { + // Inventory Equip Effects + gSPSegment(OVERLAY_DISP++, 0x08, pauseCtx->iconItemSegment); + func_8012C8D4(play->state.gfxCtx); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetAlphaCompare(OVERLAY_DISP++, G_AC_THRESHOLD); + gSPMatrix(OVERLAY_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + pauseCtx->cursorVtx[16].v.ob[0] = pauseCtx->cursorVtx[18].v.ob[0] = pauseCtx->equipAnimX / 10; + pauseCtx->cursorVtx[17].v.ob[0] = pauseCtx->cursorVtx[19].v.ob[0] = + pauseCtx->cursorVtx[16].v.ob[0] + (pauseCtx->equipAnimScale / 10); + pauseCtx->cursorVtx[16].v.ob[1] = pauseCtx->cursorVtx[17].v.ob[1] = pauseCtx->equipAnimY / 10; + pauseCtx->cursorVtx[18].v.ob[1] = pauseCtx->cursorVtx[19].v.ob[1] = + pauseCtx->cursorVtx[16].v.ob[1] - (pauseCtx->equipAnimScale / 10); + + if (pauseCtx->equipTargetItem < 0xB5) { + // Normal Equip (icon goes from the inventory slot to the C button when equipping it) + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, pauseCtx->equipAnimAlpha); + gSPVertex(OVERLAY_DISP++, &pauseCtx->cursorVtx[16], 4, 0); + gDPLoadTextureBlock(OVERLAY_DISP++, gItemIcons[pauseCtx->equipTargetItem], G_IM_FMT_RGBA, G_IM_SIZ_32b, 32, + 32, 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); + } else { + // Magic Arrow Equip Effect + temp = pauseCtx->equipTargetItem - 0xB5; + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sMagicArrowEffectsR[temp], sMagicArrowEffectsG[temp], + sMagicArrowEffectsB[temp], pauseCtx->equipAnimAlpha); + + if ((pauseCtx->equipAnimAlpha > 0) && (pauseCtx->equipAnimAlpha < 255)) { + temp = (pauseCtx->equipAnimAlpha / 8) / 2; + pauseCtx->cursorVtx[16].v.ob[0] = pauseCtx->cursorVtx[18].v.ob[0] = + pauseCtx->cursorVtx[16].v.ob[0] - temp; + pauseCtx->cursorVtx[17].v.ob[0] = pauseCtx->cursorVtx[19].v.ob[0] = + pauseCtx->cursorVtx[16].v.ob[0] + temp * 2 + 32; + pauseCtx->cursorVtx[16].v.ob[1] = pauseCtx->cursorVtx[17].v.ob[1] = + pauseCtx->cursorVtx[16].v.ob[1] + temp; + pauseCtx->cursorVtx[18].v.ob[1] = pauseCtx->cursorVtx[19].v.ob[1] = + pauseCtx->cursorVtx[16].v.ob[1] - temp * 2 - 32; + } + + gSPVertex(OVERLAY_DISP++, &pauseCtx->cursorVtx[16], 4, 0); + gDPLoadTextureBlock(OVERLAY_DISP++, &D_08095AC0, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 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); + } + + gSP1Quadrangle(OVERLAY_DISP++, 0, 2, 3, 1, 0); + } + + CLOSE_DISPS(play->state.gfxCtx); +} /** * Draws either the analog three-day clock or the digital final-hours clock @@ -3263,7 +4484,7 @@ void Interface_DrawClock(PlayState* play) { if (R_TIME_SPEED != 0) { if ((msgCtx->msgMode == 0) || ((play->actorCtx.flags & ACTORCTX_FLAG_1) && !Play_InCsMode(play)) || (msgCtx->msgMode == 0) || ((msgCtx->currentTextId >= 0x100) && (msgCtx->currentTextId <= 0x200)) || - (gSaveContext.gameMode == 3)) { + (gSaveContext.gameMode == GAMEMODE_END_CREDITS)) { if (!FrameAdvance_IsEnabled(&play->state) && !Environment_IsTimeStopped() && (gSaveContext.save.day < 4)) { /** * Changes Clock's transparancy depending if Player is moving or not and possibly other things @@ -4324,7 +5545,7 @@ void Interface_DrawPerfectLetters(PlayState* play) { void Interface_StartMoonCrash(PlayState* play) { if (play->actorCtx.flags & ACTORCTX_FLAG_1) { - Audio_QueueSeqCmd(0xE0000100); + SEQCMD_DISABLE_PLAY_SEQUENCES(false); } gSaveContext.save.day = 4; @@ -4333,7 +5554,7 @@ void Interface_StartMoonCrash(PlayState* play) { play->nextEntrance = ENTRANCE(TERMINA_FIELD, 12); gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; } void Interface_GetTimerDigits(u64 timer, s16* timerArr) { @@ -4433,7 +5654,7 @@ void Interface_DrawTimers(PlayState* play) { } gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_POSTMAN_COUNTING; sPostmanTimerInputBtnAPressed = true; - func_80174F7C(Interface_PostmanTimerCallback, NULL); + PadMgr_SetInputRetraceCallback(Interface_PostmanTimerCallback, NULL); break; case TIMER_STATE_POSTMAN_STOP: @@ -4442,7 +5663,7 @@ void Interface_DrawTimers(PlayState* play) { postmanTimerStopOsTime - ((void)0, gSaveContext.timerStartOsTimes[TIMER_ID_POSTMAN]) - ((void)0, gSaveContext.timerPausedOsTimes[TIMER_ID_POSTMAN])); gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_POSTMAN_END; - func_80174F9C(Interface_PostmanTimerCallback, NULL); + PadMgr_UnsetInputRetraceCallback(Interface_PostmanTimerCallback, NULL); break; case TIMER_STATE_POSTMAN_COUNTING: @@ -4464,7 +5685,7 @@ void Interface_DrawTimers(PlayState* play) { if (interfaceCtx->magicAlpha != 255) { gSaveContext.timerY[sTimerId] = 22; - } else if (gSaveContext.save.playerData.healthCapacity > 0xA0) { + } else if (gSaveContext.save.saveInfo.playerData.healthCapacity > 0xA0) { gSaveContext.timerY[sTimerId] = 54; } else { gSaveContext.timerY[sTimerId] = 46; @@ -4508,7 +5729,7 @@ void Interface_DrawTimers(PlayState* play) { j = ((((void)0, gSaveContext.timerX[sTimerId]) - 26) / sTimerStateTimer); gSaveContext.timerX[sTimerId] = ((void)0, gSaveContext.timerX[sTimerId]) - j; - j = (gSaveContext.save.playerData.healthCapacity > 0xA0) + j = (gSaveContext.save.saveInfo.playerData.healthCapacity > 0xA0) ? ((((void)0, gSaveContext.timerY[sTimerId]) - 54) / sTimerStateTimer) : ((((void)0, gSaveContext.timerY[sTimerId]) - 46) / sTimerStateTimer); gSaveContext.timerY[sTimerId] = ((void)0, gSaveContext.timerY[sTimerId]) - j; @@ -4522,7 +5743,7 @@ void Interface_DrawTimers(PlayState* play) { gSaveContext.timerY[sTimerId] = R_MOON_CRASH_TIMER_Y; } else { gSaveContext.timerX[sTimerId] = 26; - if (gSaveContext.save.playerData.healthCapacity > 0xA0) { + if (gSaveContext.save.saveInfo.playerData.healthCapacity > 0xA0) { gSaveContext.timerY[sTimerId] = 54; } else { gSaveContext.timerY[sTimerId] = 46; @@ -4562,7 +5783,8 @@ void Interface_DrawTimers(PlayState* play) { break; case TIMER_STATE_ENV_HAZARD_START: - gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(gSaveContext.save.playerData.health >> 1); + gSaveContext.timerCurTimes[sTimerId] = + SECONDS_TO_TIMER(gSaveContext.save.saveInfo.playerData.health >> 1); gSaveContext.timerDirections[sTimerId] = TIMER_COUNT_DOWN; gSaveContext.timerTimeLimits[sTimerId] = gSaveContext.timerCurTimes[sTimerId]; sTimerStateTimer = 20; @@ -4670,8 +5892,8 @@ void Interface_DrawTimers(PlayState* play) { gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(0); gSaveContext.timerStates[sTimerId] = TIMER_STATE_STOP; if (sEnvTimerActive) { - gSaveContext.save.playerData.health = 0; - play->damagePlayer(play, -(((void)0, gSaveContext.save.playerData.health) + 2)); + gSaveContext.save.saveInfo.playerData.health = 0; + play->damagePlayer(play, -(((void)0, gSaveContext.save.saveInfo.playerData.health) + 2)); } sEnvTimerActive = false; } @@ -4739,7 +5961,8 @@ void Interface_DrawTimers(PlayState* play) { } } else if (CHECK_EVENTINF(EVENTINF_34) && (play->sceneId == SCENE_DEKUTES)) { if ((((void)0, gSaveContext.timerCurTimes[sTimerId]) > - (gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] - SECONDS_TO_TIMER(9))) && + (gSaveContext.save.saveInfo.dekuPlaygroundHighScores[CURRENT_DAY - 1] - + SECONDS_TO_TIMER(9))) && (sTimerBeepSfxSeconds != sTimerDigits[4])) { play_sound(NA_SE_SY_WARNING_COUNT_E); sTimerBeepSfxSeconds = sTimerDigits[4]; @@ -4777,10 +6000,10 @@ void Interface_DrawTimers(PlayState* play) { } } else if (CHECK_EVENTINF(EVENTINF_34) && (play->sceneId == SCENE_DEKUTES)) { if (((void)0, gSaveContext.timerCurTimes[sTimerId]) >= - gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { + gSaveContext.save.saveInfo.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 50, 0, 255); } else if (((void)0, gSaveContext.timerCurTimes[sTimerId]) >= - (gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] - + (gSaveContext.save.saveInfo.dekuPlaygroundHighScores[CURRENT_DAY - 1] - SECONDS_TO_TIMER(9))) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 0, 255); } else { @@ -4888,7 +6111,7 @@ void Interface_UpdateBottleTimers(PlayState* play) { // Time has passed, and the time limit has been exceeded. gSaveContext.bottleTimerCurTimes[i] = SECONDS_TO_TIMER(0); - if (gSaveContext.save.inventory.items[i + SLOT_BOTTLE_1] == ITEM_HOT_SPRING_WATER) { + if (gSaveContext.save.saveInfo.inventory.items[i + SLOT_BOTTLE_1] == ITEM_HOT_SPRING_WATER) { Inventory_UpdateItem(play, i + SLOT_BOTTLE_1, ITEM_SPRING_WATER); Message_StartTextbox(play, 0xFA, NULL); } @@ -4947,7 +6170,7 @@ void Interface_DrawMinigameIcons(PlayState* play) { width = 24; height = 16; rectX = 20; - if (gSaveContext.save.playerData.healthCapacity > 0xA0) { + if (gSaveContext.save.saveInfo.playerData.healthCapacity > 0xA0) { rectY = 75; // two rows of hearts } else { rectY = 67; // one row of hearts @@ -4991,7 +6214,7 @@ void Interface_DrawMinigameIcons(PlayState* play) { if (play->sceneId == SCENE_30GYOSON) { rectX += 20; - if (gSaveContext.save.playerData.healthCapacity > 0xA0) { + if (gSaveContext.save.saveInfo.playerData.healthCapacity > 0xA0) { rectY = 87; // two rows of hearts } else { rectY = 79; // one row of hearts @@ -5083,7 +6306,7 @@ void Interface_Draw(PlayState* play) { if (pauseCtx->debugEditor == DEBUG_EDITOR_NONE) { Interface_SetVertices(play); - func_801170B8(interfaceCtx); + Interface_SetOrthoView(interfaceCtx); // Draw Grandma's Story if (interfaceCtx->storyDmaStatus == STORY_DMA_DONE) { @@ -5096,8 +6319,9 @@ void Interface_Draw(PlayState* play) { // Load in Grandma's Story gSPLoadUcodeL(OVERLAY_DISP++, gspS2DEX2_fifo); gfx = OVERLAY_DISP; - func_80172758(&gfx, sStoryTextures[interfaceCtx->storyType], sStoryTLUTs[interfaceCtx->storyType], - SCREEN_WIDTH, SCREEN_HEIGHT, 2, 1, 0x8000, 0x100, 0.0f, 0.0f, 1.0f, 1.0f, 0); + Prerender_DrawBackground2D(&gfx, sStoryTextures[interfaceCtx->storyType], + sStoryTLUTs[interfaceCtx->storyType], SCREEN_WIDTH, SCREEN_HEIGHT, 2, 1, 0x8000, + 0x100, 0.0f, 0.0f, 1.0f, 1.0f, 0); OVERLAY_DISP = gfx; gSPLoadUcode(OVERLAY_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData()); @@ -5245,7 +6469,7 @@ void Interface_Draw(PlayState* play) { PRIMITIVE, 0); counterDigits[0] = counterDigits[1] = 0; - counterDigits[2] = gSaveContext.save.playerData.rupees; + counterDigits[2] = gSaveContext.save.saveInfo.playerData.rupees; if ((counterDigits[2] > 9999) || (counterDigits[2] < 0)) { counterDigits[2] &= 0xDDD; @@ -5278,9 +6502,9 @@ void Interface_Draw(PlayState* play) { gDPPipeSync(OVERLAY_DISP++); - if (gSaveContext.save.playerData.rupees == CUR_CAPACITY(UPG_WALLET)) { + if (gSaveContext.save.saveInfo.playerData.rupees == CUR_CAPACITY(UPG_WALLET)) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 120, 255, 0, interfaceCtx->magicAlpha); - } else if (gSaveContext.save.playerData.rupees != 0) { + } else if (gSaveContext.save.saveInfo.playerData.rupees != 0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); } else { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 100, 100, 100, interfaceCtx->magicAlpha); @@ -5299,16 +6523,16 @@ void Interface_Draw(PlayState* play) { func_8012C654(play->state.gfxCtx); - func_80117100(play); + Interface_DrawItemButtons(play); if (player->transformation == ((void)0, gSaveContext.save.playerForm)) { - func_80118084(play); + Interface_DrawBButtonIcons(play); } - func_80118890(play); + Interface_DrawCButtonIcons(play); - func_80118BA4(play); + Interface_DrawAButton(play); - func_80119030(play); + Interface_DrawPauseMenuEquippingIcons(play); // Draw either the minigame countdown or the three-day clock if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { @@ -5515,7 +6739,7 @@ void Interface_Update(PlayState* play) { // Update buttons if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { if (play->gameOverCtx.state == GAMEOVER_INACTIVE) { - func_80111CB4(play); + Interface_UpdateButtonsPart1(play); } } @@ -5631,14 +6855,15 @@ void Interface_Update(PlayState* play) { // Update health if (gSaveContext.healthAccumulator != 0) { gSaveContext.healthAccumulator -= 4; - gSaveContext.save.playerData.health += 4; + gSaveContext.save.saveInfo.playerData.health += 4; - if ((gSaveContext.save.playerData.health & 0xF) < 4) { + if ((gSaveContext.save.saveInfo.playerData.health & 0xF) < 4) { play_sound(NA_SE_SY_HP_RECOVER); } - if (((void)0, gSaveContext.save.playerData.health) >= ((void)0, gSaveContext.save.playerData.healthCapacity)) { - gSaveContext.save.playerData.health = gSaveContext.save.playerData.healthCapacity; + if (((void)0, gSaveContext.save.saveInfo.playerData.health) >= + ((void)0, gSaveContext.save.saveInfo.playerData.healthCapacity)) { + gSaveContext.save.saveInfo.playerData.health = gSaveContext.save.saveInfo.playerData.healthCapacity; gSaveContext.healthAccumulator = 0; } } @@ -5663,26 +6888,26 @@ void Interface_Update(PlayState* play) { // Update rupees if (gSaveContext.rupeeAccumulator != 0) { if (gSaveContext.rupeeAccumulator > 0) { - if (gSaveContext.save.playerData.rupees < CUR_CAPACITY(UPG_WALLET)) { + if (gSaveContext.save.saveInfo.playerData.rupees < CUR_CAPACITY(UPG_WALLET)) { gSaveContext.rupeeAccumulator--; - gSaveContext.save.playerData.rupees++; + gSaveContext.save.saveInfo.playerData.rupees++; play_sound(NA_SE_SY_RUPY_COUNT); } else { // Max rupees - gSaveContext.save.playerData.rupees = CUR_CAPACITY(UPG_WALLET); + gSaveContext.save.saveInfo.playerData.rupees = CUR_CAPACITY(UPG_WALLET); gSaveContext.rupeeAccumulator = 0; } - } else if (gSaveContext.save.playerData.rupees != 0) { + } else if (gSaveContext.save.saveInfo.playerData.rupees != 0) { if (gSaveContext.rupeeAccumulator <= -50) { gSaveContext.rupeeAccumulator += 10; - gSaveContext.save.playerData.rupees -= 10; - if (gSaveContext.save.playerData.rupees < 0) { - gSaveContext.save.playerData.rupees = 0; + gSaveContext.save.saveInfo.playerData.rupees -= 10; + if (gSaveContext.save.saveInfo.playerData.rupees < 0) { + gSaveContext.save.saveInfo.playerData.rupees = 0; } play_sound(NA_SE_SY_RUPY_COUNT); } else { gSaveContext.rupeeAccumulator++; - gSaveContext.save.playerData.rupees--; + gSaveContext.save.saveInfo.playerData.rupees--; play_sound(NA_SE_SY_RUPY_COUNT); } } else { @@ -5815,29 +7040,31 @@ void Interface_Update(PlayState* play) { if (!(player->stateFlags1 & PLAYER_STATE1_200)) { if (R_MAGIC_DBG_SET_UPGRADE == MAGIC_DBG_SET_UPGRADE_DOUBLE_METER) { // Upgrade to double magic - if (!gSaveContext.save.playerData.isMagicAcquired) { - gSaveContext.save.playerData.isMagicAcquired = true; + if (!gSaveContext.save.saveInfo.playerData.isMagicAcquired) { + gSaveContext.save.saveInfo.playerData.isMagicAcquired = true; } - gSaveContext.save.playerData.isDoubleMagicAcquired = true; - gSaveContext.save.playerData.magic = MAGIC_DOUBLE_METER; - gSaveContext.save.playerData.magicLevel = 0; + gSaveContext.save.saveInfo.playerData.isDoubleMagicAcquired = true; + gSaveContext.save.saveInfo.playerData.magic = MAGIC_DOUBLE_METER; + gSaveContext.save.saveInfo.playerData.magicLevel = 0; R_MAGIC_DBG_SET_UPGRADE = MAGIC_DBG_SET_UPGRADE_NO_ACTION; } else if (R_MAGIC_DBG_SET_UPGRADE == MAGIC_DBG_SET_UPGRADE_NORMAL_METER) { // Upgrade to normal magic - if (!gSaveContext.save.playerData.isMagicAcquired) { - gSaveContext.save.playerData.isMagicAcquired = true; + if (!gSaveContext.save.saveInfo.playerData.isMagicAcquired) { + gSaveContext.save.saveInfo.playerData.isMagicAcquired = true; } - gSaveContext.save.playerData.isDoubleMagicAcquired = false; - gSaveContext.save.playerData.magic = MAGIC_NORMAL_METER; - gSaveContext.save.playerData.magicLevel = 0; + gSaveContext.save.saveInfo.playerData.isDoubleMagicAcquired = false; + gSaveContext.save.saveInfo.playerData.magic = MAGIC_NORMAL_METER; + gSaveContext.save.saveInfo.playerData.magicLevel = 0; R_MAGIC_DBG_SET_UPGRADE = MAGIC_DBG_SET_UPGRADE_NO_ACTION; } - if ((gSaveContext.save.playerData.isMagicAcquired) && (gSaveContext.save.playerData.magicLevel == 0)) { + if ((gSaveContext.save.saveInfo.playerData.isMagicAcquired) && + (gSaveContext.save.saveInfo.playerData.magicLevel == 0)) { // Prepare to step `magicCapacity` to full capacity - gSaveContext.save.playerData.magicLevel = gSaveContext.save.playerData.isDoubleMagicAcquired + 1; - gSaveContext.magicFillTarget = gSaveContext.save.playerData.magic; - gSaveContext.save.playerData.magic = 0; + gSaveContext.save.saveInfo.playerData.magicLevel = + gSaveContext.save.saveInfo.playerData.isDoubleMagicAcquired + 1; + gSaveContext.magicFillTarget = gSaveContext.save.saveInfo.playerData.magic; + gSaveContext.save.saveInfo.playerData.magic = 0; gSaveContext.magicState = MAGIC_STATE_STEP_CAPACITY; BUTTON_ITEM_EQUIP(PLAYER_FORM_DEKU, EQUIP_SLOT_B) = ITEM_NUT; } @@ -5851,7 +7078,7 @@ void Interface_Update(PlayState* play) { if ((sEnvHazard == PLAYER_ENV_HAZARD_HOTROOM) || (sEnvHazard == PLAYER_ENV_HAZARD_UNDERWATER_FREE)) { if (CUR_FORM != PLAYER_FORM_ZORA) { if (play->gameOverCtx.state == GAMEOVER_INACTIVE) { - if ((gSaveContext.save.playerData.health >> 1) != 0) { + if ((gSaveContext.save.saveInfo.playerData.health >> 1) != 0) { gSaveContext.timerStates[TIMER_ID_ENV_HAZARD] = TIMER_STATE_ENV_HAZARD_START; gSaveContext.timerX[TIMER_ID_ENV_HAZARD] = 115; gSaveContext.timerY[TIMER_ID_ENV_HAZARD] = 80; @@ -5984,7 +7211,7 @@ void Interface_Update(PlayState* play) { void Interface_Destroy(PlayState* play) { Map_Destroy(play); - func_80174F9C(Interface_PostmanTimerCallback, NULL); + PadMgr_UnsetInputRetraceCallback(Interface_PostmanTimerCallback, NULL); } void Interface_Init(PlayState* play) { @@ -6005,16 +7232,16 @@ void Interface_Init(PlayState* play) { interfaceCtx->healthTimer = 200; parameterStaticSize = SEGMENT_ROM_SIZE(parameter_static); - interfaceCtx->parameterSegment = THA_AllocEndAlign16(&play->state.heap, parameterStaticSize); + interfaceCtx->parameterSegment = THA_AllocTailAlign16(&play->state.heap, parameterStaticSize); DmaMgr_SendRequest0(interfaceCtx->parameterSegment, SEGMENT_ROM_START(parameter_static), parameterStaticSize); - interfaceCtx->doActionSegment = THA_AllocEndAlign16(&play->state.heap, 0xC90); + interfaceCtx->doActionSegment = THA_AllocTailAlign16(&play->state.heap, 0xC90); DmaMgr_SendRequest0(interfaceCtx->doActionSegment, SEGMENT_ROM_START(do_action_static), 0x300); DmaMgr_SendRequest0(interfaceCtx->doActionSegment + 0x300, SEGMENT_ROM_START(do_action_static) + 0x480, 0x180); Interface_NewDay(play, CURRENT_DAY); - interfaceCtx->iconItemSegment = THA_AllocEndAlign16(&play->state.heap, 0x4000); + interfaceCtx->iconItemSegment = THA_AllocTailAlign16(&play->state.heap, 0x4000); if (CUR_FORM_EQUIP(EQUIP_SLOT_B) < ITEM_F0) { Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); diff --git a/src/code/z_pause.c b/src/code/z_pause.c index bb5b33cf2..5f212b7ae 100644 --- a/src/code/z_pause.c +++ b/src/code/z_pause.c @@ -18,7 +18,9 @@ * * Note2: Controllers 2-4's inputs are normally zeroed out, so this would also need to be fixed to use frame advance */ -#include "global.h" + +#include "z64frameadvance.h" +#include "macros.h" void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx) { frameAdvCtx->timer = 0; diff --git a/src/code/z_play.c b/src/code/z_play.c index 8f27a0bed..abf2be57c 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1,81 +1,1598 @@ #include "global.h" +#include "buffers.h" +#include "z64debug_display.h" #include "z64quake.h" +#include "z64rumble.h" #include "z64shrink_window.h" #include "z64view.h" +#include "overlays/gamestates/ovl_daytelop/z_daytelop.h" +#include "overlays/gamestates/ovl_opening/z_opening.h" +#include "overlays/gamestates/ovl_file_choose/z_file_choose.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165460.s") +s32 gDbgCamEnabled = false; +u8 D_801D0D54 = false; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165608.s") +s16 sTransitionFillTimer; +Input D_801F6C18; +TransitionTile sTransitionTile; +s32 gTransitionTileState; +VisMono sVisMono; +Color_RGBA8_u32 gVisMonoColor; +Struct_80140E80 D_801F6D38; +Struct_80140E80* D_801F6D4C; +BombersNotebook sBombersNotebook; +u8 sBombersNotebookOpen; +u8 sMotionBlurStatus; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165630.s") +typedef enum { + /* 0 */ MOTION_BLUR_OFF, + /* 1 */ MOTION_BLUR_SETUP, + /* 2 */ MOTION_BLUR_PROCESS +} MotionBlurStatus; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165658.s") +void Play_DrawMotionBlur(PlayState* this) { + GraphicsContext* gfxCtx = this->state.gfxCtx; + s32 alpha; + Gfx* gfx; + Gfx* gfxHead; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016566C.s") + if (R_MOTION_BLUR_PRIORITY_ENABLED) { + alpha = R_MOTION_BLUR_PRIORITY_ALPHA; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165690.s") + if (sMotionBlurStatus == MOTION_BLUR_OFF) { + sMotionBlurStatus = MOTION_BLUR_SETUP; + } + } else if (R_MOTION_BLUR_ENABLED) { + alpha = R_MOTION_BLUR_ALPHA; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801656A4.s") + if (sMotionBlurStatus == MOTION_BLUR_OFF) { + sMotionBlurStatus = MOTION_BLUR_SETUP; + } + } else { + alpha = 0; + sMotionBlurStatus = MOTION_BLUR_OFF; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165DB8.s") + if (sMotionBlurStatus != MOTION_BLUR_OFF) { + OPEN_DISPS(gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165DCC.s") + gfxHead = POLY_OPA_DISP; + gfx = Graph_GfxPlusOne(gfxHead); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165DF0.s") + gSPDisplayList(OVERLAY_DISP++, gfx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165E04.s") + this->pauseBgPreRender.fbuf = gfxCtx->curFrameBuffer; + this->pauseBgPreRender.fbufSave = this->unk_18E64; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165E1C.s") + if (sMotionBlurStatus == MOTION_BLUR_PROCESS) { + func_80170AE0(&this->pauseBgPreRender, &gfx, alpha); + } else { + sMotionBlurStatus = MOTION_BLUR_PROCESS; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165E7C.s") + func_801705B4(&this->pauseBgPreRender, &gfx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165EC0.s") + gSPEndDisplayList(gfx++); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/D_801DFA18.s") + Graph_BranchDlist(gfxHead, gfx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80166060.s") + POLY_OPA_DISP = gfx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801660B8.s") + CLOSE_DISPS(gfxCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Destroy.s") +void Play_InitMotionBlur(void) { + R_MOTION_BLUR_ENABLED = false; + R_MOTION_BLUR_PRIORITY_ENABLED = false; + sMotionBlurStatus = MOTION_BLUR_OFF; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CompressI8ToI5.s") +void Play_DestroyMotionBlur(void) { + R_MOTION_BLUR_ENABLED = false; + R_MOTION_BLUR_PRIORITY_ENABLED = false; + sMotionBlurStatus = MOTION_BLUR_OFF; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_DecompressI5ToI8.s") +void Play_SetMotionBlurAlpha(u32 alpha) { + R_MOTION_BLUR_ALPHA = alpha; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801668B4.s") +void Play_EnableMotionBlur(u32 alpha) { + R_MOTION_BLUR_ALPHA = alpha; + R_MOTION_BLUR_ENABLED = true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80166968.s") +void Play_DisableMotionBlur(void) { + R_MOTION_BLUR_ENABLED = false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80166B30.s") +// How much each color component contributes to the intensity image. +// These coefficients are close to what the YUV color space defines Y (luminance) as: +// https://en.wikipedia.org/wiki/YUV#Conversion_to/from_RGB +#define PLAY_INTENSITY_RED 2 +#define PLAY_INTENSITY_GREEN 4 +#define PLAY_INTENSITY_BLUE 1 +#define PLAY_INTENSITY_NORM (0x1F * PLAY_INTENSITY_RED + 0x1F * PLAY_INTENSITY_GREEN + 0x1F * PLAY_INTENSITY_BLUE) +#define PLAY_INTENSITY_MIX(r, g, b, m) \ + ((((r)*PLAY_INTENSITY_RED + (g)*PLAY_INTENSITY_GREEN + (b)*PLAY_INTENSITY_BLUE) * (m)) / PLAY_INTENSITY_NORM) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Update.s") +/** + * Converts an RGBA16 buffer to an Intensity Image + * + * @param[out] destI destination buffer + * @param[in] srcRgba16 source buffer + * @param[in] rgba16Width width of a full row for the RGBA16 + * @param[in] pixelLeft X coordinate of the top-left RGBA16 pixel to start with + * @param[in] pixelTop Y coordinate of the top-left RGBA16 pixel to start with + * @param[in] pixelRight X coordinate of the bottom-right RGBA16 pixel to end with + * @param[in] pixelBottom Y coordinate of the bottom-right RGBA16 pixel to end with + * @param[in] bitDepth bit depth for the intensity image + */ +void Play_ConvertRgba16ToIntensityImage(void* destI, u16* srcRgba16, s32 rgba16Width, s32 pixelLeft, s32 pixelTop, + s32 pixelRight, s32 pixelBottom, s32 bitDepth) { + s32 i; + s32 j; + u32 pixel; + u32 r; + u32 g; + u32 b; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80167DE4.s") + switch (bitDepth) { + case 4: { + u8* destI4 = destI; + u32 upper; + u32 lower; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80167F0C.s") + for (i = pixelTop; i <= pixelBottom; i++) { + for (j = pixelLeft; j <= pixelRight; j += 2) { + pixel = srcRgba16[i * rgba16Width + j]; + r = RGBA16_GET_R(pixel); + g = RGBA16_GET_G(pixel); + b = RGBA16_GET_B(pixel); + upper = PLAY_INTENSITY_MIX(r, g, b, 15); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Draw.s") + pixel = srcRgba16[i * rgba16Width + j + 1]; + r = RGBA16_GET_R(pixel); + g = RGBA16_GET_G(pixel); + b = RGBA16_GET_B(pixel); + lower = PLAY_INTENSITY_MIX(r, g, b, 15); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80168DAC.s") + *(destI4++) = (upper << 4) | lower; + } + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Main.s") + case 5: { + u8* destI5 = destI; + + for (i = pixelTop; i <= pixelBottom; i++) { + for (j = pixelLeft; j <= pixelRight; j++) { + pixel = srcRgba16[i * rgba16Width + j]; + r = RGBA16_GET_R(pixel); + g = RGBA16_GET_G(pixel); + b = RGBA16_GET_B(pixel); + + pixel = 0; + + *(destI5++) = PLAY_INTENSITY_MIX(r, g, b, 255) & 0xF8; + } + } + break; + } + + case 8: { + u8* destI8 = destI; + + for (i = pixelTop; i <= pixelBottom; i++) { + for (j = pixelLeft; j <= pixelRight; j++) { + pixel = srcRgba16[i * rgba16Width + j]; + + r = RGBA16_GET_R(pixel); + g = RGBA16_GET_G(pixel); + b = RGBA16_GET_B(pixel); + + *(destI8++) = PLAY_INTENSITY_MIX(r, g, b, 255); + } + } + break; + } + + case 16: { + u16* destI16 = destI; + + for (i = pixelTop; i <= pixelBottom; i++) { + for (j = pixelLeft; j <= pixelRight; j++) { + *(destI16++) = srcRgba16[i * rgba16Width + j]; + } + } + break; + } + } +} + +void Play_SetMotionBlurPriorityAlpha(u32 alpha) { + R_MOTION_BLUR_PRIORITY_ALPHA = alpha; +} + +void Play_EnableMotionBlurPriority(u32 alpha) { + R_MOTION_BLUR_PRIORITY_ALPHA = alpha; + R_MOTION_BLUR_PRIORITY_ENABLED = true; +} + +void Play_DisableMotionBlurPriority(void) { + R_MOTION_BLUR_PRIORITY_ENABLED = false; +} + +// Will take the photograph, but doesn't compress and save it +void Play_TriggerPictoPhoto(void) { + R_PICTO_PHOTO_STATE = PICTO_PHOTO_STATE_SETUP; +} + +void Play_TakePictoPhoto(PreRender* prerender) { + PreRender_ApplyFilters(prerender); + Play_ConvertRgba16ToIntensityImage(gPictoPhotoI8, prerender->fbufSave, SCREEN_WIDTH, PICTO_PHOTO_TOPLEFT_X, + PICTO_PHOTO_TOPLEFT_Y, (PICTO_PHOTO_TOPLEFT_X + PICTO_PHOTO_WIDTH) - 1, + (PICTO_PHOTO_TOPLEFT_Y + PICTO_PHOTO_HEIGHT) - 1, 8); +} + +s32 Play_ChooseDynamicTransition(PlayState* this, s32 transitionType) { + s32 nextTransitionType = transitionType; + + if (transitionType == TRANS_TYPE_FADE_DYNAMIC) { + if (!gSaveContext.save.isNight) { + nextTransitionType = TRANS_TYPE_FADE_WHITE; + } else { + nextTransitionType = TRANS_TYPE_FADE_BLACK; + } + } + if (nextTransitionType != transitionType) { + this->transitionType = nextTransitionType; + } + return nextTransitionType; +} + +void Play_SetupTransition(PlayState* this, s32 transitionType) { + TransitionContext* transitionCtx = &this->transitionCtx; + s32 fbdemoType; + + bzero(transitionCtx, sizeof(TransitionContext)); + + fbdemoType = -1; + if (transitionType & TRANS_TYPE_WIPE3) { + fbdemoType = FBDEMO_WIPE3; + } else if ((transitionType & 0x78) == TRANS_TYPE_WIPE4) { // Checks not only type, but also a max value of 39 + fbdemoType = FBDEMO_WIPE4; + } else if (!(transitionType & (TRANS_TYPE_WIPE3 | TRANS_TYPE_WIPE4))) { + switch (transitionType) { + case TRANS_TYPE_TRIFORCE: + fbdemoType = FBDEMO_TRIFORCE; + break; + + case TRANS_TYPE_WIPE: + case TRANS_TYPE_WIPE_FAST: + fbdemoType = FBDEMO_WIPE1; + break; + + case TRANS_TYPE_FADE_BLACK: + case TRANS_TYPE_FADE_WHITE: + case TRANS_TYPE_FADE_BLACK_FAST: + case TRANS_TYPE_FADE_WHITE_FAST: + case TRANS_TYPE_FADE_BLACK_SLOW: + case TRANS_TYPE_FADE_WHITE_SLOW: + case TRANS_TYPE_FADE_WHITE_CS_DELAYED: + case TRANS_TYPE_FADE_WHITE_INSTANT: + case TRANS_TYPE_FADE_GREEN: + case TRANS_TYPE_FADE_BLUE: + fbdemoType = FBDEMO_FADE; + break; + + case TRANS_TYPE_FILL_WHITE_FAST: + case TRANS_TYPE_FILL_WHITE: + this->transitionMode = TRANS_MODE_FILL_WHITE_INIT; + break; + + case TRANS_TYPE_INSTANT: + this->transitionMode = TRANS_MODE_INSTANT; + break; + + case TRANS_TYPE_FILL_BROWN: + this->transitionMode = TRANS_MODE_FILL_BROWN_INIT; + break; + + case TRANS_TYPE_SANDSTORM_PERSIST: + this->transitionMode = TRANS_MODE_SANDSTORM_INIT; + break; + + case TRANS_TYPE_SANDSTORM_END: + this->transitionMode = TRANS_MODE_SANDSTORM_END_INIT; + break; + + case TRANS_TYPE_CS_BLACK_FILL: + this->transitionMode = TRANS_MODE_CS_BLACK_FILL_INIT; + break; + + case TRANS_TYPE_CIRCLE: + fbdemoType = FBDEMO_CIRCLE; + break; + + case TRANS_TYPE_WIPE5: + fbdemoType = FBDEMO_WIPE5; + break; + + default: + fbdemoType = -1; + __assert("../z_play.c", 1420); + } + } else { + fbdemoType = -1; + __assert("../z_play.c", 1423); + } + + transitionCtx->transitionType = transitionType; + transitionCtx->fbdemoType = fbdemoType; + if (fbdemoType != -1) { + Transition_Init(transitionCtx); + } +} + +void Play_ClearTransition(PlayState* this) { + if (this->transitionCtx.fbdemoType != -1) { + Transition_Destroy(&this->transitionCtx); + } + this->transitionCtx.transitionType = -1; +} + +Gfx* Play_SetFog(PlayState* this, Gfx* gfx) { + s32 fogFar = this->lightCtx.zFar * (5.0f / 64.0f); + + return Gfx_SetFogWithSync(gfx, this->lightCtx.fogColor.r, this->lightCtx.fogColor.g, this->lightCtx.fogColor.b, 0, + this->lightCtx.fogNear, ((fogFar <= 1000) ? 1000 : fogFar)); +} + +void Play_Destroy(GameState* thisx) { + PlayState* this = (PlayState*)thisx; + GraphicsContext* gfxCtx = this->state.gfxCtx; + + if (sBombersNotebookOpen) { + MsgEvent_SendNullTask(); + func_80178750(); + gfxCtx->curFrameBuffer = SysCfb_GetFbPtr(gfxCtx->framebufferIndex % 2); + gfxCtx->zbuffer = SysCfb_GetZBuffer(); + gfxCtx->viMode = D_801FBB88; + gfxCtx->viConfigFeatures = gViConfigFeatures; + gfxCtx->xScale = gViConfigXScale; + gfxCtx->yScale = gViConfigYScale; + gfxCtx->updateViMode = true; + sBombersNotebookOpen = false; + } + + BombersNotebook_Destroy(&sBombersNotebook); + this->state.gfxCtx->callback = NULL; + this->state.gfxCtx->callbackArg = 0; + Play_DestroyMotionBlur(); + + if (R_PAUSE_BG_PRERENDER_STATE != PAUSE_BG_PRERENDER_OFF) { + PreRender_ApplyFiltersSlowlyDestroy(&this->pauseBgPreRender); + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_OFF; + } + + R_PICTO_PHOTO_STATE = PICTO_PHOTO_STATE_OFF; + PreRender_Destroy(&this->pauseBgPreRender); + this->unk_18E58 = NULL; + this->pictoPhotoI8 = NULL; + this->unk_18E60 = NULL; + this->unk_18E64 = NULL; + this->unk_18E68 = NULL; + Effect_DestroyAll(this); + EffectSS_Clear(this); + CollisionCheck_DestroyContext(this, &this->colChkCtx); + + if (gTransitionTileState == TRANS_TILE_READY) { + TransitionTile_Destroy(&sTransitionTile); + gTransitionTileState = TRANS_TILE_OFF; + } + + if ((this->transitionMode == TRANS_MODE_INSTANCE_RUNNING) || D_801D0D54) { + this->transitionCtx.destroy(&this->transitionCtx.instanceData); + Play_ClearTransition(this); + this->transitionMode = TRANS_MODE_OFF; + } + + ShrinkWindow_Destroy(); + TransitionFade_Destroy(&this->unk_18E48); + VisMono_Destroy(&sVisMono); + func_80140EA0(D_801F6D4C); + D_801F6D4C = NULL; + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_92_80)) { + Actor_CleanupContext(&this->actorCtx, this); + } + CLEAR_WEEKEVENTREG(WEEKEVENTREG_92_80); + + Interface_Destroy(this); + KaleidoScopeCall_Destroy(this); + KaleidoManager_Destroy(); + ZeldaArena_Cleanup(); +} + +#define PLAY_COMPRESS_BITS 5 +#define PLAY_DECOMPRESS_BITS 8 + +void Play_CompressI8ToI5(void* srcI8, void* destI5, size_t size) { + u32 i; + u8* src = srcI8; + s8* dest = destI5; + s32 bitsLeft = PLAY_DECOMPRESS_BITS; // Bits left in the current dest pixel left to compress into + u32 destPixel = 0; + s32 shift; + u32 srcPixel; + + for (i = 0; i < size; i++) { + srcPixel = *src++; + srcPixel = (srcPixel * 0x1F + 0x80) / 0xFF; + shift = bitsLeft - PLAY_COMPRESS_BITS; + if (shift > 0) { + destPixel |= srcPixel << shift; + } else { + destPixel |= srcPixel >> -shift; + *dest++ = destPixel; + shift += PLAY_DECOMPRESS_BITS; + destPixel = srcPixel << shift; + } + bitsLeft = shift; + } + + if (bitsLeft < PLAY_DECOMPRESS_BITS) { + *dest = destPixel; + } +} + +void Play_DecompressI5ToI8(void* srcI5, void* destI8, size_t size) { + u32 i; + u8* src = srcI5; + s8* dest = destI8; + s32 bitsLeft = PLAY_DECOMPRESS_BITS; // Bits left in the current src pixel left to decompress + u32 destPixel; + s32 shift; + u32 srcPixel = *src++; + + for (i = 0; i < size; i++) { + shift = bitsLeft - PLAY_COMPRESS_BITS; + if (shift > 0) { + destPixel = 0; + destPixel |= srcPixel >> shift; + } else { + destPixel = 0; + destPixel |= srcPixel << -shift; + srcPixel = *src++; + shift += PLAY_DECOMPRESS_BITS; + destPixel |= srcPixel >> shift; + } + destPixel = (destPixel & 0x1F) * 0xFF / 0x1F; + *dest++ = destPixel; + bitsLeft = shift; + } +} + +f32 Play_GetWaterSurface(PlayState* this, Vec3f* pos, s32* lightIndex) { + Player* player = GET_PLAYER(this); + f32 waterSurfaceY = player->actor.world.pos.y; + WaterBox* waterBox; + s32 bgId; + + if (!WaterBox_GetSurfaceImpl(this, &this->colCtx, pos->x, pos->z, &waterSurfaceY, &waterBox, &bgId)) { + return BGCHECK_Y_MIN; + } + + if (waterSurfaceY < pos->y) { + return BGCHECK_Y_MIN; + } + + *lightIndex = WaterBox_GetLightSettingIndex(&this->colCtx, waterBox); + return waterSurfaceY; +} + +void Play_UpdateWaterCamera(PlayState* this, Camera* camera) { + static s16 sQuakeIndex = -1; + static s16 sIsCameraUnderwater = false; + s32 pad; + s32 lightIndex; + Player* player = GET_PLAYER(this); + + sIsCameraUnderwater = camera->stateFlags & CAM_STATE_UNDERWATER; + if (Play_GetWaterSurface(this, &camera->eye, &lightIndex) != BGCHECK_Y_MIN) { + if (!sIsCameraUnderwater) { + Camera_SetStateFlag(camera, CAM_STATE_UNDERWATER); + sQuakeIndex = -1; + Distortion_Request(DISTORTION_TYPE_UNDERWATER_ENTRY); + Distortion_SetDuration(80); + } + + func_801A3EC0(0x20); + func_800F6834(this, lightIndex); + + if ((sQuakeIndex == -1) || (Quake_GetTimeLeft(sQuakeIndex) == 10)) { + s16 quakeIndex = Quake_Request(camera, QUAKE_TYPE_5); + + sQuakeIndex = quakeIndex; + if (quakeIndex != 0) { + Quake_SetSpeed(sQuakeIndex, 550); + Quake_SetPerturbations(sQuakeIndex, 1, 1, 180, 0); + Quake_SetDuration(sQuakeIndex, 1000); + } + } + if (player->stateFlags3 & PLAYER_STATE3_8000) { + Distortion_Request(DISTORTION_TYPE_ZORA_SWIMMING); + Distortion_RemoveRequest(DISTORTION_TYPE_NON_ZORA_SWIMMING); + } else { + Distortion_Request(DISTORTION_TYPE_NON_ZORA_SWIMMING); + Distortion_RemoveRequest(DISTORTION_TYPE_ZORA_SWIMMING); + } + } else { + if (sIsCameraUnderwater) { + Camera_UnsetStateFlag(camera, CAM_STATE_UNDERWATER); + } + Distortion_RemoveRequest(DISTORTION_TYPE_NON_ZORA_SWIMMING); + Distortion_RemoveRequest(DISTORTION_TYPE_UNDERWATER_ENTRY); + Distortion_RemoveRequest(DISTORTION_TYPE_ZORA_SWIMMING); + if (sQuakeIndex != 0) { + Quake_RemoveRequest(sQuakeIndex); + } + func_800F694C(this); + func_801A3EC0(0); + } +} + +void Play_UpdateTransition(PlayState* this) { + s32 pad; + + if (this->transitionMode == TRANS_MODE_OFF) { + return; + } + + switch (this->transitionMode) { + case TRANS_MODE_SETUP: + if (this->transitionTrigger != TRANS_TRIGGER_END) { + s16 sceneLayer = 0; + + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); + + if (gSaveContext.nextCutsceneIndex >= 0xFFF0) { + sceneLayer = (gSaveContext.nextCutsceneIndex & 0xF) + 1; + } + + if ((!(Entrance_GetTransitionFlags(this->nextEntrance + sceneLayer) & 0x8000) || + ((this->nextEntrance == ENTRANCE(PATH_TO_MOUNTAIN_VILLAGE, 1)) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE)) || + ((this->nextEntrance == ENTRANCE(ROAD_TO_SOUTHERN_SWAMP, 1)) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE)) || + ((this->nextEntrance == ENTRANCE(TERMINA_FIELD, 2)) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) || + ((this->nextEntrance == ENTRANCE(ROAD_TO_IKANA, 1)) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE))) && + (!func_800FE590(this) || (Entrance_GetSceneId(this->nextEntrance + sceneLayer) < 0) || + (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_FINAL_HOURS))) { + func_801A4058(20); + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; + } + + if (func_800FD768()) { + func_801A4058(20); + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; + } + + if (func_800FE590(this) && (Entrance_GetSceneId(this->nextEntrance + sceneLayer) >= 0) && + (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_FINAL_HOURS)) { + func_801A41C8(20); + } + } + + if (!D_801D0D54) { + Play_SetupTransition(this, Play_ChooseDynamicTransition(this, this->transitionType)); + } + + if (this->transitionMode >= TRANS_MODE_FILL_WHITE_INIT) { + // non-instance modes break out of this switch + break; + } + // fallthrough + case TRANS_MODE_INSTANCE_INIT: { + s32 transWipeSpeed; + s32 transFadeDuration; + u32 color; + + this->transitionCtx.init(&this->transitionCtx.instanceData); + + if (this->transitionCtx.transitionType & (TRANS_TYPE_WIPE3 | TRANS_TYPE_WIPE4)) { + this->transitionCtx.setType(&this->transitionCtx.instanceData, + this->transitionCtx.transitionType | TRANS_TYPE_SET_PARAMS); + } + + if ((this->transitionCtx.transitionType == TRANS_TYPE_WIPE_FAST) || + (this->transitionCtx.transitionType == TRANS_TYPE_FILL_WHITE_FAST)) { + //! @bug TRANS_TYPE_FILL_WHITE_FAST will never reach this code. + //! It is a non-instance type transition which doesn't run this case. + transWipeSpeed = 28; + } else { + transWipeSpeed = 14; + } + gSaveContext.transWipeSpeed = transWipeSpeed; + + switch (this->transitionCtx.transitionType) { + case TRANS_TYPE_FADE_BLACK_FAST: + case TRANS_TYPE_FADE_WHITE_FAST: + transFadeDuration = 20; + break; + + case TRANS_TYPE_FADE_BLACK_SLOW: + case TRANS_TYPE_FADE_WHITE_SLOW: + transFadeDuration = 150; + break; + + case TRANS_TYPE_FADE_WHITE_INSTANT: + transFadeDuration = 2; + break; + + default: + transFadeDuration = 60; + break; + } + gSaveContext.transFadeDuration = transFadeDuration; + + switch (this->transitionCtx.transitionType) { + case TRANS_TYPE_FADE_WHITE: + case TRANS_TYPE_FADE_WHITE_FAST: + case TRANS_TYPE_FADE_WHITE_SLOW: + case TRANS_TYPE_FADE_WHITE_CS_DELAYED: + case TRANS_TYPE_FADE_WHITE_INSTANT: + color = RGBA8(160, 160, 160, 255); + break; + + case TRANS_TYPE_FADE_GREEN: + color = RGBA8(140, 140, 100, 255); + break; + + case TRANS_TYPE_FADE_BLUE: + color = RGBA8(70, 100, 110, 255); + break; + + default: + color = RGBA8(0, 0, 0, 255); + break; + } + + this->transitionCtx.setColor(&this->transitionCtx.instanceData, color); + if (this->transitionCtx.setEnvColor != NULL) { + this->transitionCtx.setEnvColor(&this->transitionCtx.instanceData, color); + } + + this->transitionCtx.setType(&this->transitionCtx.instanceData, + (this->transitionTrigger == TRANS_TRIGGER_END) ? TRANS_INSTANCE_TYPE_FILL_OUT + : TRANS_INSTANCE_TYPE_FILL_IN); + this->transitionCtx.start(&this->transitionCtx.instanceData); + + if (this->transitionCtx.transitionType == TRANS_TYPE_FADE_WHITE_CS_DELAYED) { + this->transitionMode = TRANS_MODE_INSTANCE_WAIT; + } else { + this->transitionMode = TRANS_MODE_INSTANCE_RUNNING; + } + break; + } + + case TRANS_MODE_INSTANCE_RUNNING: + if (this->transitionCtx.isDone(&this->transitionCtx.instanceData)) { + if (this->transitionTrigger != TRANS_TRIGGER_END) { + if (this->transitionCtx.transitionType == TRANS_TYPE_CIRCLE) { + D_801D0D54 = false; + } + + if (gSaveContext.gameMode == GAMEMODE_OWL_SAVE) { + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, TitleSetup_Init, sizeof(TitleSetupState)); + } else if (gSaveContext.gameMode != GAMEMODE_FILE_SELECT) { + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, Play_Init, sizeof(PlayState)); + gSaveContext.save.entrance = this->nextEntrance; + + if (gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) { + gSaveContext.minigameStatus = MINIGAME_STATUS_END; + } + } else { // GAMEMODE_FILE_SELECT + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, FileSelect_Init, sizeof(FileSelectState)); + } + } else { + if (this->transitionCtx.transitionType == TRANS_TYPE_CIRCLE) { + D_801D0D54 = true; + } else { + this->transitionCtx.destroy(&this->transitionCtx.instanceData); + Play_ClearTransition(this); + } + this->transitionMode = TRANS_MODE_OFF; + if (gTransitionTileState == TRANS_TILE_READY) { + TransitionTile_Destroy(&sTransitionTile); + gTransitionTileState = TRANS_TILE_OFF; + Game_SetFramerateDivisor(&this->state, 3); + } + } + this->transitionTrigger = TRANS_TRIGGER_OFF; + } else { + this->transitionCtx.update(&this->transitionCtx.instanceData, this->state.framerateDivisor); + } + break; + } + + // update non-instance transitions + switch (this->transitionMode) { + case TRANS_MODE_FILL_WHITE_INIT: + sTransitionFillTimer = 0; + this->envCtx.fillScreen = true; + this->envCtx.screenFillColor[0] = 160; + this->envCtx.screenFillColor[1] = 160; + this->envCtx.screenFillColor[2] = 160; + + if (this->transitionTrigger != TRANS_TRIGGER_END) { + this->envCtx.screenFillColor[3] = 0; + this->transitionMode = TRANS_MODE_FILL_IN; + } else { + this->envCtx.screenFillColor[3] = 255; + this->transitionMode = TRANS_MODE_FILL_OUT; + } + break; + + case TRANS_MODE_FILL_IN: + this->envCtx.screenFillColor[3] = (sTransitionFillTimer / 20.0f) * 255.0f; + + if (sTransitionFillTimer >= 20) { + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, Play_Init, sizeof(PlayState)); + gSaveContext.save.entrance = this->nextEntrance; + this->transitionTrigger = TRANS_TRIGGER_OFF; + this->transitionMode = TRANS_MODE_OFF; + } else { + sTransitionFillTimer++; + } + break; + + case TRANS_MODE_FILL_OUT: + this->envCtx.screenFillColor[3] = (1.0f - (sTransitionFillTimer / 20.0f)) * 255.0f; + + if (sTransitionFillTimer >= 20) { + gTransitionTileState = TRANS_TILE_OFF; + Game_SetFramerateDivisor(&this->state, 3); + this->transitionTrigger = TRANS_TRIGGER_OFF; + this->transitionMode = TRANS_MODE_OFF; + this->envCtx.fillScreen = false; + } else { + sTransitionFillTimer++; + } + break; + + case TRANS_MODE_FILL_BROWN_INIT: + sTransitionFillTimer = 0; + this->envCtx.fillScreen = true; + this->envCtx.screenFillColor[0] = 170; + this->envCtx.screenFillColor[1] = 160; + this->envCtx.screenFillColor[2] = 150; + + if (this->transitionTrigger != TRANS_TRIGGER_END) { + this->envCtx.screenFillColor[3] = 0; + this->transitionMode = TRANS_MODE_FILL_IN; + } else { + this->envCtx.screenFillColor[3] = 255; + this->transitionMode = TRANS_MODE_FILL_OUT; + } + break; + + case TRANS_MODE_INSTANT: + if (this->transitionTrigger != TRANS_TRIGGER_END) { + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, Play_Init, sizeof(PlayState)); + gSaveContext.save.entrance = this->nextEntrance; + this->transitionTrigger = TRANS_TRIGGER_OFF; + this->transitionMode = TRANS_MODE_OFF; + } else { + gTransitionTileState = TRANS_TILE_OFF; + Game_SetFramerateDivisor(&this->state, 3); + this->transitionTrigger = TRANS_TRIGGER_OFF; + this->transitionMode = TRANS_MODE_OFF; + } + break; + + case TRANS_MODE_INSTANCE_WAIT: + if (gSaveContext.cutsceneTransitionControl != 0) { + this->transitionMode = TRANS_MODE_INSTANCE_RUNNING; + } + break; + + case TRANS_MODE_SANDSTORM_INIT: + if (this->transitionTrigger != TRANS_TRIGGER_END) { + this->envCtx.sandstormState = 1; + this->transitionMode = TRANS_MODE_SANDSTORM; + } else { + this->envCtx.sandstormState = 2; + this->envCtx.sandstormPrimA = 255; + this->envCtx.sandstormEnvA = 255; + this->transitionMode = TRANS_MODE_SANDSTORM; + } + break; + + case TRANS_MODE_SANDSTORM: + func_8019F128(NA_SE_EV_SAND_STORM - SFX_FLAG); + if (this->transitionTrigger == TRANS_TRIGGER_END) { + if (this->envCtx.sandstormPrimA < 110) { + gTransitionTileState = TRANS_TILE_OFF; + Game_SetFramerateDivisor(&this->state, 3); + this->transitionTrigger = TRANS_TRIGGER_OFF; + this->transitionMode = TRANS_MODE_OFF; + } + } else { + if (this->envCtx.sandstormEnvA == 255) { + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, Play_Init, sizeof(PlayState)); + gSaveContext.save.entrance = this->nextEntrance; + this->transitionTrigger = TRANS_TRIGGER_OFF; + this->transitionMode = TRANS_MODE_OFF; + } + } + break; + + case TRANS_MODE_SANDSTORM_END_INIT: + if (this->transitionTrigger == TRANS_TRIGGER_END) { + this->envCtx.sandstormState = 4; + this->envCtx.sandstormPrimA = 255; + this->envCtx.sandstormEnvA = 255; + + // "It's here!!!!!!!!!" + (void)"来た!!!!!!!!!!!!!!!!!!!!!"; + + this->transitionMode = TRANS_MODE_SANDSTORM_END; + } else { + this->transitionMode = TRANS_MODE_SANDSTORM_INIT; + } + break; + + case TRANS_MODE_SANDSTORM_END: + func_8019F128(NA_SE_EV_SAND_STORM - SFX_FLAG); + + if (this->transitionTrigger == TRANS_TRIGGER_END) { + if (this->envCtx.sandstormPrimA <= 0) { + gTransitionTileState = TRANS_TILE_OFF; + Game_SetFramerateDivisor(&this->state, 3); + this->transitionTrigger = TRANS_TRIGGER_OFF; + this->transitionMode = TRANS_MODE_OFF; + } + } + break; + + case TRANS_MODE_CS_BLACK_FILL_INIT: + sTransitionFillTimer = 0; + this->envCtx.fillScreen = true; + this->envCtx.screenFillColor[0] = 0; + this->envCtx.screenFillColor[1] = 0; + this->envCtx.screenFillColor[2] = 0; + this->envCtx.screenFillColor[3] = 255; + this->transitionMode = TRANS_MODE_CS_BLACK_FILL; + break; + + case TRANS_MODE_CS_BLACK_FILL: + if (gSaveContext.cutsceneTransitionControl != 0) { + this->envCtx.screenFillColor[3] = gSaveContext.cutsceneTransitionControl; + + if (gSaveContext.cutsceneTransitionControl <= 100) { + gTransitionTileState = TRANS_TILE_OFF; + Game_SetFramerateDivisor(&this->state, 3); + this->transitionTrigger = TRANS_TRIGGER_OFF; + this->transitionMode = TRANS_MODE_OFF; + } + } + break; + } +} + +const char D_801DFA34[][4] = { + "all", "a", "a", "b", "b", "c", "c", "d", "d", "e", "e", "f", "fa", "fa", "fb", "fb", + "fc", "fc", "fd", "fd", "fe", "fe", "fg", "fg", "fh", "fh", "fi", "fi", "fj", "fj", "fk", "fk", + "f", "g", "g", "h", "h", "i", "i", "all", "all", "a", "b", "c", "d", "e", "f", "g", + "h", "i", "f", "fa", "fb", "fc", "fd", "fe", "ff", "fg", "fh", "fi", "fj", "fk", +}; + +#ifdef NON_MATCHING +// Stack issues +void Play_UpdateMain(PlayState* this) { + Input* input = this->state.input; + u8 freezeFlashTimer; + s32 sp5C = false; + + gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.mainKeepIndex].segment); + gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.subKeepIndex].segment); + gSegments[2] = VIRTUAL_TO_PHYSICAL(this->sceneSegment); + + if (R_PICTO_PHOTO_STATE == PICTO_PHOTO_STATE_PROCESS) { + R_PICTO_PHOTO_STATE = PICTO_PHOTO_STATE_READY; + MsgEvent_SendNullTask(); + Play_TakePictoPhoto(&this->pauseBgPreRender); + R_PICTO_PHOTO_STATE = PICTO_PHOTO_STATE_OFF; + } + Actor_SetMovementScale(this->state.framerateDivisor); + + if (FrameAdvance_Update(&this->frameAdvCtx, &input[1])) { + if ((this->transitionMode == TRANS_MODE_OFF) && (this->transitionTrigger != TRANS_TRIGGER_OFF)) { + this->transitionMode = TRANS_MODE_SETUP; + } + + if (gTransitionTileState != TRANS_TILE_OFF) { + switch (gTransitionTileState) { + case TRANS_TILE_PROCESS: + if (TransitionTile_Init(&sTransitionTile, 10, 7) == NULL) { + gTransitionTileState = TRANS_TILE_OFF; + } else { + sTransitionTile.zBuffer = gZBufferPtr; + gTransitionTileState = TRANS_TILE_READY; + Game_SetFramerateDivisor(&this->state, 1); + } + break; + + case TRANS_TILE_READY: + TransitionTile_Update(&sTransitionTile); + break; + + default: + break; + } + } + Play_UpdateTransition(this); + if (gTransitionTileState != TRANS_TILE_READY) { + if ((gSaveContext.gameMode == GAMEMODE_NORMAL) && + (((this->msgCtx.msgMode == 0)) || + ((this->msgCtx.currentTextId == 0xFF) && (this->msgCtx.msgMode == 0x42) && + (this->msgCtx.unk12020 == 0x41)) || + ((this->msgCtx.currentTextId >= 0x100) && (this->msgCtx.currentTextId <= 0x200))) && + (this->gameOverCtx.state == GAMEOVER_INACTIVE)) { + KaleidoSetup_Update(this); + } + + sp5C = (this->pauseCtx.state != 0) || (this->pauseCtx.debugEditor != DEBUG_EDITOR_NONE); + + AnimationContext_Reset(&this->animationCtx); + Object_UpdateBank(&this->objectCtx); + + if (!sp5C && (IREG(72) == 0)) { + this->gameplayFrames++; + Rumble_SetUpdateEnabled(true); + if ((this->actorCtx.freezeFlashTimer != 0) && (this->actorCtx.freezeFlashTimer-- < 5)) { + freezeFlashTimer = this->actorCtx.freezeFlashTimer; + if ((freezeFlashTimer > 0) && ((freezeFlashTimer % 2) != 0)) { + this->envCtx.fillScreen = true; + this->envCtx.screenFillColor[0] = this->envCtx.screenFillColor[1] = + this->envCtx.screenFillColor[2] = 150; + this->envCtx.screenFillColor[3] = 80; + } else { + this->envCtx.fillScreen = false; + } + } else { + Room_HandleLoadCallbacks(this, &this->roomCtx); + CollisionCheck_AT(this, &this->colChkCtx); + CollisionCheck_OC(this, &this->colChkCtx); + CollisionCheck_Damage(this, &this->colChkCtx); + CollisionCheck_ClearContext(this, &this->colChkCtx); + if (!this->haltAllActors) { + Actor_UpdateAll(this, &this->actorCtx); + } + Cutscene_UpdateManual(this, &this->csCtx); + Cutscene_UpdateScripted(this, &this->csCtx); + Effect_UpdateAll(this); + EffectSS_UpdateAllParticles(this); + EffFootmark_Update(this); + } + } else { + Rumble_SetUpdateEnabled(false); + } + + Room_Noop(this, &this->roomCtx.curRoom, &input[1], 0); + Room_Noop(this, &this->roomCtx.prevRoom, &input[1], 1); + Skybox_Update(&this->skyboxCtx); + + if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { + KaleidoScopeCall_Update(this); + } else if (this->gameOverCtx.state != GAMEOVER_INACTIVE) { + GameOver_Update(this); + } + + Message_Update(this); + Interface_Update(this); + AnimationContext_Update(this, &this->animationCtx); + SoundSource_UpdateAll(this); + ShrinkWindow_Update(this->state.framerateDivisor); + TransitionFade_Update(&this->unk_18E48, this->state.framerateDivisor); + } + } + + if (!sp5C || gDbgCamEnabled) { + s32 sp54; // camId + Vec3s sp48; // InputDir + + this->nextCamera = this->activeCamId; + for (sp54 = 0; sp54 < 4; sp54++) { + if ((sp54 != this->nextCamera) && (this->cameraPtrs[sp54] != NULL)) { + Camera_Update(&sp48, this->cameraPtrs[sp54]); + } + } + Camera_Update(&sp48, this->cameraPtrs[this->nextCamera]); + } + + if (!sp5C) { + Play_UpdateWaterCamera(this, this->cameraPtrs[this->nextCamera]); + Distortion_Update(); + } + + Environment_Update(this, &this->envCtx, &this->lightCtx, &this->pauseCtx, &this->msgCtx, &this->gameOverCtx, + this->state.gfxCtx); + + if (this->sramCtx.status != 0) { + if (gSaveContext.save.isOwlSave) { + func_80147198(&this->sramCtx); + } else { + func_80147068(&this->sramCtx); + } + } +} +#else +void Play_UpdateMain(PlayState* this); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_UpdateMain.s") +#endif + +void Play_Update(PlayState* this) { + if (!sBombersNotebookOpen) { + if (this->pauseCtx.bombersNotebookOpen) { + sBombersNotebookOpen = true; + sBombersNotebook.unk_00 = 0; + } + } else if (CHECK_BTN_ALL(CONTROLLER1(&this->state)->press.button, BTN_L) || + CHECK_BTN_ALL(CONTROLLER1(&this->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&this->state)->press.button, BTN_START) || (gIrqMgrResetStatus != 0)) { + sBombersNotebookOpen = false; + this->pauseCtx.bombersNotebookOpen = false; + sBombersNotebook.unk_00 = 0; + this->msgCtx.msgLength = 0; + this->msgCtx.msgMode = 0; + this->msgCtx.currentTextId = 0; + this->msgCtx.stateTimer = 0; + play_sound(NA_SE_SY_CANCEL); + } + if (sBombersNotebookOpen) { + BombersNotebook_Update(this, &sBombersNotebook, this->state.input); + Message_Update(this); + } else { + Play_UpdateMain(this); + } +} + +void Play_PostWorldDraw(PlayState* this) { + if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { + KaleidoScopeCall_Draw(this); + } + + if (gSaveContext.gameMode == GAMEMODE_NORMAL) { + Interface_Draw(this); + } + + if (((this->pauseCtx.state == 0) && (this->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) || + (this->msgCtx.currentTextId != 0xFF)) { + Message_Draw(this); + } + + if (this->gameOverCtx.state != GAMEOVER_INACTIVE) { + GameOver_FadeLights(this); + } + + // Shrink the whole screen display (at the end of First and Second Day by default) + if (gSaveContext.screenScaleFlag) { + Gfx* nextOpa; + Gfx* opa; + GraphicsContext* gfxCtx = this->state.gfxCtx; + + D_801F6D4C->scale = gSaveContext.screenScale / 1000.0f; + + OPEN_DISPS(gfxCtx); + + opa = POLY_OPA_DISP; + nextOpa = Graph_GfxPlusOne(opa); + gSPDisplayList(OVERLAY_DISP++, nextOpa); + + func_80141778(D_801F6D4C, &nextOpa, this->unk_18E60, gfxCtx); + + gSPEndDisplayList(nextOpa++); + Graph_BranchDlist(opa, nextOpa); + POLY_OPA_DISP = nextOpa; + + CLOSE_DISPS(gfxCtx); + } +} + +#ifdef NON_MATCHING +// Stack issues and 1 small issue around Play_PostWorldDraw +void Play_DrawMain(PlayState* this) { + GraphicsContext* gfxCtx = this->state.gfxCtx; + Lights* sp268; + Vec3f sp25C; + u8 sp25B = false; + + if (R_PAUSE_BG_PRERENDER_STATE >= PAUSE_BG_PRERENDER_UNK4) { + PreRender_ApplyFiltersSlowlyDestroy(&this->pauseBgPreRender); + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_OFF; + } + + if ((R_PAUSE_BG_PRERENDER_STATE <= PAUSE_BG_PRERENDER_SETUP) && (gTransitionTileState <= TRANS_TILE_SETUP)) { + if (this->skyboxCtx.skyboxShouldDraw || (this->roomCtx.curRoom.roomShape->base.type == ROOM_SHAPE_TYPE_IMAGE)) { + func_8012CF0C(gfxCtx, false, true, 0, 0, 0); + } else { + func_8012CF0C(gfxCtx, true, true, this->lightCtx.fogColor.r, this->lightCtx.fogColor.g, + this->lightCtx.fogColor.b); + } + } else { + func_8012CF0C(gfxCtx, false, false, 0, 0, 0); + } + + OPEN_DISPS(gfxCtx); + + gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.mainKeepIndex].segment); + gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.subKeepIndex].segment); + gSegments[2] = VIRTUAL_TO_PHYSICAL(this->sceneSegment); + + gSPSegment(POLY_OPA_DISP++, 0x04, this->objectCtx.status[this->objectCtx.mainKeepIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x04, this->objectCtx.status[this->objectCtx.mainKeepIndex].segment); + gSPSegment(OVERLAY_DISP++, 0x04, this->objectCtx.status[this->objectCtx.mainKeepIndex].segment); + + gSPSegment(POLY_OPA_DISP++, 0x05, this->objectCtx.status[this->objectCtx.subKeepIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x05, this->objectCtx.status[this->objectCtx.subKeepIndex].segment); + gSPSegment(OVERLAY_DISP++, 0x05, this->objectCtx.status[this->objectCtx.subKeepIndex].segment); + + gSPSegment(POLY_OPA_DISP++, 0x02, this->sceneSegment); + gSPSegment(POLY_XLU_DISP++, 0x02, this->sceneSegment); + gSPSegment(OVERLAY_DISP++, 0x02, this->sceneSegment); + + if (1) { + f32 var_fv0; // zFar + + ShrinkWindow_Draw(gfxCtx); + + POLY_OPA_DISP = Play_SetFog(this, POLY_OPA_DISP); + POLY_XLU_DISP = Play_SetFog(this, POLY_XLU_DISP); + + // zFar + var_fv0 = this->lightCtx.zFar; + if (var_fv0 > 12800.0f) { + var_fv0 = 12800.0f; + } + + View_SetPerspective(&this->view, this->view.fovy, this->view.zNear, var_fv0); + + View_Apply(&this->view, 0xF); + + // The billboard matrix temporarily stores the viewing matrix + Matrix_MtxToMtxF(&this->view.viewing, &this->billboardMtxF); + Matrix_MtxToMtxF(&this->view.projection, &this->viewProjectionMtxF); + + this->projectionMtxFDiagonal.x = this->viewProjectionMtxF.xx; + this->projectionMtxFDiagonal.y = this->viewProjectionMtxF.yy; + this->projectionMtxFDiagonal.z = -this->viewProjectionMtxF.zz; + + SkinMatrix_MtxFMtxFMult(&this->viewProjectionMtxF, &this->billboardMtxF, &this->viewProjectionMtxF); + + this->billboardMtxF.mf[3][2] = this->billboardMtxF.mf[3][1] = this->billboardMtxF.mf[3][0] = + this->billboardMtxF.mf[2][3] = this->billboardMtxF.mf[1][3] = this->billboardMtxF.mf[0][3] = 0.0f; + + Matrix_Transpose(&this->billboardMtxF); + + this->billboardMtx = GRAPH_ALLOC(this->state.gfxCtx, 2 * sizeof(Mtx)); + + Matrix_MtxFToMtx(&this->billboardMtxF, this->billboardMtx); + Matrix_RotateYF(BINANG_TO_RAD((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(this)) + 0x8000)), MTXMODE_NEW); + Matrix_ToMtx(this->billboardMtx + 1); + + gSPSegment(POLY_OPA_DISP++, 0x01, this->billboardMtx); + gSPSegment(POLY_XLU_DISP++, 0x01, this->billboardMtx); + gSPSegment(OVERLAY_DISP++, 0x01, this->billboardMtx); + + if (1) { + Gfx* sp218; + Gfx* sp214 = POLY_OPA_DISP; + + sp218 = Graph_GfxPlusOne(sp214); + gSPDisplayList(OVERLAY_DISP++, sp218); + + if (((this->transitionMode == TRANS_MODE_INSTANCE_RUNNING) || + (this->transitionMode == TRANS_TYPE_INSTANT)) || + D_801D0D54) { + View spA8; + + View_Init(&spA8, gfxCtx); + spA8.flags = 0xA; + + SET_FULLSCREEN_VIEWPORT(&spA8); + + View_ApplyTo(&spA8, &sp218); + this->transitionCtx.draw(&this->transitionCtx.instanceData, &sp218); + } + + TransitionFade_Draw(&this->unk_18E48, &sp218); + + if (gVisMonoColor.a != 0) { + sVisMono.primColor.rgba = gVisMonoColor.rgba; + VisMono_Draw(&sVisMono, &sp218); + } + + gSPEndDisplayList(sp218++); + Graph_BranchDlist(sp214, sp218); + POLY_OPA_DISP = sp218; + } + + if (gTransitionTileState == TRANS_TILE_READY) { + Gfx* sp90 = POLY_OPA_DISP; + + TransitionTile_Draw(&sTransitionTile, &sp90); + POLY_OPA_DISP = sp90; + sp25B = true; + goto PostWorldDraw; + } + + PreRender_SetValues(&this->pauseBgPreRender, D_801FBBCC, D_801FBBCE, gfxCtx->curFrameBuffer, gfxCtx->zbuffer); + + if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_PROCESS) { + MsgEvent_SendNullTask(); + if (!gSaveContext.screenScaleFlag) { + PreRender_ApplyFiltersSlowlyInit(&this->pauseBgPreRender); + } + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_READY; + SREG(33) |= 1; + } else { + if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_READY) { + Gfx* sp8C = POLY_OPA_DISP; + + if (this->pauseBgPreRender.unk_4D == 2) { + func_80170B28(&this->pauseBgPreRender, &sp8C); + } else { + func_80170798(&this->pauseBgPreRender, &sp8C); + } + + gSPDisplayList(sp8C++, D_0E000000.syncSegments); + POLY_OPA_DISP = sp8C; + sp25B = true; + goto PostWorldDraw; + } + + if (!this->unk_18844) { + if (1) { + if ((this->skyboxId != SKYBOX_NONE) && !this->envCtx.skyboxDisabled) { + if ((this->skyboxId == SKYBOX_NORMAL_SKY) || (this->skyboxId == SKYBOX_3)) { + Environment_UpdateSkybox(this->skyboxId, &this->envCtx, &this->skyboxCtx); + Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, this->envCtx.unk_13, this->view.eye.x, + this->view.eye.y, this->view.eye.z); + } else if (!this->skyboxCtx.skyboxShouldDraw) { + Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x, this->view.eye.y, + this->view.eye.z); + } + } + + func_800FE390(this); + } + + sp268 = LightContext_NewLights(&this->lightCtx, gfxCtx); + + if (this->roomCtx.curRoom.enablePosLights || (MREG(93) != 0)) { + sp268->enablePosLights = true; + } + + Lights_BindAll(sp268, this->lightCtx.listHead, NULL, this); + Lights_Draw(sp268, gfxCtx); + + if (1) { + u32 roomDrawFlags = ((1) ? 1 : 0) | (((void)0, 1) ? 2 : 0); // FAKE: + + Scene_Draw(this); + if (this->roomCtx.unk78) { + Room_Draw(this, &this->roomCtx.curRoom, roomDrawFlags & 3); + Room_Draw(this, &this->roomCtx.prevRoom, roomDrawFlags & 3); + } + } + + if (this->skyboxCtx.skyboxShouldDraw) { + Vec3f sp78; + + if (1) {} + Camera_GetQuakeOffset(&sp78, GET_ACTIVE_CAM(this)); + Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x + sp78.x, + this->view.eye.y + sp78.y, this->view.eye.z + sp78.z); + } + + // envCtx.precipitation[PRECIP_RAIN_CUR] + if (this->envCtx.unk_F2[1] != 0) { + Environment_DrawRain(this, &this->view, gfxCtx); + } + } + + if (1) { + Environment_FillScreen(gfxCtx, 0, 0, 0, this->bgCoverAlpha, 1); + } + + if (1) { + Actor_DrawAll(this, &this->actorCtx); + } + + if (1) { + if (!this->envCtx.sunMoonDisabled) { + sp25C.x = this->view.eye.x + this->envCtx.sunPos.x; + sp25C.y = this->view.eye.y + this->envCtx.sunPos.y; + sp25C.z = this->view.eye.z + this->envCtx.sunPos.z; + Environment_DrawSunLensFlare(this, &this->envCtx, &this->view, gfxCtx, sp25C); + } + + Environment_DrawCustomLensFlare(this); + } + + if (1) { + if (R_PLAY_FILL_SCREEN_ON) { + Environment_FillScreen(gfxCtx, R_PLAY_FILL_SCREEN_R, R_PLAY_FILL_SCREEN_G, R_PLAY_FILL_SCREEN_B, + R_PLAY_FILL_SCREEN_ALPHA, 3); + } + + switch (this->envCtx.fillScreen) { + case 1: + Environment_FillScreen(gfxCtx, this->envCtx.screenFillColor[0], this->envCtx.screenFillColor[1], + this->envCtx.screenFillColor[2], this->envCtx.screenFillColor[3], 3); + break; + + default: + break; + } + } + + if (1) { + if (this->envCtx.sandstormState != 0) { + Environment_DrawSandstorm(this, this->envCtx.sandstormState); + } + } + + if (this->worldCoverAlpha != 0) { + Environment_FillScreen(gfxCtx, 0, 0, 0, this->worldCoverAlpha, 3); + } + + if (1) { + DebugDisplay_DrawObjects(this); + } + + Play_DrawMotionBlur(this); + + if (((R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_SETUP) || + (gTransitionTileState == TRANS_TILE_SETUP)) || + (R_PICTO_PHOTO_STATE == PICTO_PHOTO_STATE_SETUP)) { + Gfx* sp74; + Gfx* sp70 = POLY_OPA_DISP; + + sp74 = Graph_GfxPlusOne(sp70); + gSPDisplayList(OVERLAY_DISP++, sp74); + this->pauseBgPreRender.fbuf = gfxCtx->curFrameBuffer; + + if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_SETUP) { + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_PROCESS; + this->pauseBgPreRender.fbufSave = gfxCtx->zbuffer; + this->pauseBgPreRender.cvgSave = this->unk_18E58; + } else if (R_PICTO_PHOTO_STATE == PICTO_PHOTO_STATE_SETUP) { + R_PICTO_PHOTO_STATE = PICTO_PHOTO_STATE_PROCESS; + this->pauseBgPreRender.fbufSave = gfxCtx->zbuffer; + this->pauseBgPreRender.cvgSave = this->unk_18E58; + } else { + gTransitionTileState = TRANS_TILE_PROCESS; + this->pauseBgPreRender.fbufSave = gfxCtx->zbuffer; + this->pauseBgPreRender.cvgSave = NULL; + } + + func_801705B4(&this->pauseBgPreRender, &sp74); + + if (this->pauseBgPreRender.cvgSave != NULL) { + func_80170730(&this->pauseBgPreRender, &sp74); + } + + gSPEndDisplayList(sp74++); + Graph_BranchDlist(sp70, sp74); + POLY_OPA_DISP = sp74; + this->unk_18B49 = 2; + SREG(33) |= 1; + } else { + PostWorldDraw: + if (1) { + Play_PostWorldDraw(this); + } + } + } + } + + if ((this->view.unk164 != 0) && !gDbgCamEnabled) { + Vec3s sp4C; + + Camera_Update(&sp4C, GET_ACTIVE_CAM(this)); + View_UpdateViewingMatrix(&this->view); + this->view.unk164 = 0; + if ((this->skyboxId != SKYBOX_NONE) && !this->envCtx.skyboxDisabled) { + Skybox_UpdateMatrix(&this->skyboxCtx, this->view.eye.x, this->view.eye.y, this->view.eye.z); + } + } + + if (!sp25B) { + func_800FE3E0(this); + } + + CLOSE_DISPS(this->state.gfxCtx); +} +#else +void Play_DrawMain(PlayState* this); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_DrawMain.s") +#endif + +void Play_Draw(PlayState* this) { + GraphicsContext* gfxCtx = this->state.gfxCtx; + + { + GraphicsContext* gfxCtx2 = this->state.gfxCtx; + + if (sBombersNotebookOpen) { + if (D_801FBBD4 != 1) { + MsgEvent_SendNullTask(); + func_80178818(); + gfxCtx2->curFrameBuffer = SysCfb_GetFbPtr(gfxCtx2->framebufferIndex % 2); + gfxCtx2->zbuffer = SysCfb_GetZBuffer(); + gfxCtx2->viMode = D_801FBB88; + gfxCtx2->viConfigFeatures = gViConfigFeatures; + gfxCtx2->xScale = gViConfigXScale; + gfxCtx2->yScale = gViConfigYScale; + gfxCtx2->updateViMode = true; + } + } else { + if (D_801FBBD4 != 0) { + MsgEvent_SendNullTask(); + func_80178750(); + gfxCtx2->curFrameBuffer = SysCfb_GetFbPtr(gfxCtx2->framebufferIndex % 2); + gfxCtx2->zbuffer = SysCfb_GetZBuffer(); + gfxCtx2->viMode = D_801FBB88; + gfxCtx2->viConfigFeatures = gViConfigFeatures; + gfxCtx2->xScale = gViConfigXScale; + gfxCtx2->yScale = gViConfigYScale; + gfxCtx2->updateViMode = true; + } + } + } + + if (sBombersNotebookOpen && ((SREG(2) != 2) || (gZBufferPtr == NULL))) { + BombersNotebook_Draw(&sBombersNotebook, gfxCtx); + Message_Draw(this); + } else { + Play_DrawMain(this); + } +} + +void Play_Main(GameState* thisx) { + static Input* prevInput = NULL; + PlayState* this = (PlayState*)thisx; + + prevInput = CONTROLLER1(&this->state); + DebugDisplay_Init(); + + { + GraphicsContext* gfxCtx = this->state.gfxCtx; + + if (1) { + this->state.gfxCtx = NULL; + } + Play_Update(this); + this->state.gfxCtx = gfxCtx; + } + + { + Input input = *CONTROLLER1(&this->state); + + if (1) { + *CONTROLLER1(&this->state) = D_801F6C18; + } + Play_Draw(this); + *CONTROLLER1(&this->state) = input; + } + + CutsceneManager_Update(); + CutsceneManager_ClearWaiting(); +} s32 Play_InCsMode(PlayState* this) { return (this->csCtx.state != 0) || Player_InCsMode(this); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169100.s") +f32 Play_GetFloorSurfaceImpl(PlayState* this, MtxF* mtx, CollisionPoly** poly, s32* bgId, Vec3f* pos) { + f32 floorHeight = BgCheck_EntityRaycastFloor3(&this->colCtx, poly, bgId, pos); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801691F0.s") + if (floorHeight > BGCHECK_Y_MIN) { + func_800C0094(*poly, pos->x, floorHeight, pos->z, mtx); + } else { + mtx->xy = 0.0f; + mtx->zx = 0.0f; + mtx->yx = 0.0f; + mtx->xx = 0.0f; + mtx->wz = 0.0f; + mtx->xz = 0.0f; + mtx->wy = 0.0f; + mtx->wx = 0.0f; + mtx->zz = 0.0f; + mtx->yz = 0.0f; + mtx->zy = 0.0f; + mtx->yy = 1.0f; + mtx->xw = pos->x; + mtx->yw = pos->y; + mtx->zw = pos->z; + mtx->ww = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_LoadScene.s") + return floorHeight; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016927C.s") +void Play_GetFloorSurface(PlayState* this, MtxF* mtx, Vec3f* pos) { + CollisionPoly* poly; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801692C4.s") + Play_GetFloorSurfaceImpl(this, mtx, &poly, &bgId, pos); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_SceneInit.s") +void* Play_LoadFile(PlayState* this, RomFile* entry) { + size_t size = entry->vromEnd - entry->vromStart; + void* allocp = THA_AllocTailAlign16(&this->state.heap, size); + + DmaMgr_SendRequest0(allocp, entry->vromStart, size); + + return allocp; +} + +void Play_InitEnvironment(PlayState* this, s16 skyboxId) { + Skybox_Init(&this->state, &this->skyboxCtx, skyboxId); + Environment_Init(this, &this->envCtx, 0); +} + +void Play_InitScene(PlayState* this, s32 spawn) { + this->curSpawn = spawn; + this->linkActorEntry = NULL; + this->actorCsCamList = NULL; + this->setupEntranceList = NULL; + this->setupExitList = NULL; + this->naviQuestHints = NULL; + this->setupPathList = NULL; + this->sceneMaterialAnims = NULL; + this->roomCtx.unk74 = NULL; + this->numSetupActors = 0; + Object_InitBank(&this->state, &this->objectCtx); + LightContext_Init(this, &this->lightCtx); + Scene_ResetTransiActorList(&this->state, &this->transitionActors); + Room_Init(this, &this->roomCtx); + gSaveContext.worldMapArea = 0; + Scene_ExecuteCommands(this, this->sceneSegment); + Play_InitEnvironment(this, this->skyboxId); +} + +void Play_SpawnScene(PlayState* this, s32 sceneId, s32 spawn) { + s32 pad; + SceneTableEntry* scene = &gSceneTable[sceneId]; + + scene->unk_D = 0; + this->loadedScene = scene; + this->sceneId = sceneId; + this->sceneConfig = scene->drawConfig; + this->sceneSegment = Play_LoadFile(this, &scene->segment); + scene->unk_D = 0; + gSegments[2] = VIRTUAL_TO_PHYSICAL(this->sceneSegment); + Play_InitScene(this, spawn); + Room_AllocateAndLoad(this, &this->roomCtx); +} void Play_GetScreenPos(PlayState* this, Vec3f* worldPos, Vec3f* screenPos) { f32 invW; @@ -164,11 +1681,11 @@ s32 Play_SetCameraAtEye(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye) { camera->dist = Math3D_Distance(at, eye); if (camera->focalActor != NULL) { - camera->atActorOffset.x = at->x - camera->focalActor->world.pos.x; - camera->atActorOffset.y = at->y - camera->focalActor->world.pos.y; - camera->atActorOffset.z = at->z - camera->focalActor->world.pos.z; + camera->focalActorAtOffset.x = at->x - camera->focalActor->world.pos.x; + camera->focalActorAtOffset.y = at->y - camera->focalActor->world.pos.y; + camera->focalActorAtOffset.z = at->z - camera->focalActor->world.pos.z; } else { - camera->atActorOffset.x = camera->atActorOffset.y = camera->atActorOffset.z = 0.0f; + camera->focalActorAtOffset.x = camera->focalActorAtOffset.y = camera->focalActorAtOffset.z = 0.0f; } camera->atLerpStepScale = 0.01f; @@ -193,11 +1710,11 @@ s32 Play_SetCameraAtEyeUp(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye, Vec camera->dist = Math3D_Distance(at, eye); if (camera->focalActor != NULL) { - camera->atActorOffset.x = at->x - camera->focalActor->world.pos.x; - camera->atActorOffset.y = at->y - camera->focalActor->world.pos.y; - camera->atActorOffset.z = at->z - camera->focalActor->world.pos.z; + camera->focalActorAtOffset.x = at->x - camera->focalActor->world.pos.x; + camera->focalActorAtOffset.y = at->y - camera->focalActor->world.pos.y; + camera->focalActorAtOffset.z = at->z - camera->focalActor->world.pos.z; } else { - camera->atActorOffset.x = camera->atActorOffset.y = camera->atActorOffset.z = 0.0f; + camera->focalActorAtOffset.x = camera->focalActorAtOffset.y = camera->focalActorAtOffset.z = 0.0f; } camera->atLerpStepScale = 0.01f; @@ -231,13 +1748,13 @@ void Play_CopyCamera(PlayState* this, s16 destCamId, s16 srcCamId) { Camera_Copy(this->cameraPtrs[destCamId1], this->cameraPtrs[srcCamId2]); } -// Same as Play_ChangeCameraSetting but also calls Camera_InitPlayerSettings +// Same as Play_ChangeCameraSetting but also calls Camera_InitFocalActorSettings s32 func_80169A50(PlayState* this, s16 camId, Player* player, s16 setting) { Camera* camera; s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; camera = this->cameraPtrs[camIdx]; - Camera_InitPlayerSettings(camera, player); + Camera_InitFocalActorSettings(camera, &player->actor); return Camera_ChangeSetting(camera, setting); } @@ -379,9 +1896,8 @@ void Play_SetupRespawnPoint(GameState* thisx, s32 respawnMode, s32 playerParams) Player* player = GET_PLAYER(this); if (this->sceneId != SCENE_KAKUSIANA) { // Grottos - Play_SetRespawnData(&this->state, respawnMode, (u16)((void)0, gSaveContext.save.entrance), - this->roomCtx.curRoom.num, playerParams, &player->actor.world.pos, - player->actor.shape.rot.y); + Play_SetRespawnData(&this->state, respawnMode, ((void)0, gSaveContext.save.entrance), this->roomCtx.curRoom.num, + playerParams, &player->actor.world.pos, player->actor.shape.rot.y); } } @@ -405,7 +1921,7 @@ void func_80169EFC(GameState* thisx) { gSaveContext.respawnFlag = 1; func_80169ECC(this); this->transitionTrigger = TRANS_TRIGGER_START; - this->transitionType = TRANS_TYPE_02; + this->transitionType = TRANS_TYPE_FADE_BLACK; } // Gameplay_LoadToLastEntrance ? @@ -417,7 +1933,7 @@ void func_80169F78(GameState* thisx) { gSaveContext.respawnFlag = -1; func_80169ECC(this); this->transitionTrigger = TRANS_TRIGGER_START; - this->transitionType = TRANS_TYPE_02; + this->transitionType = TRANS_TYPE_FADE_BLACK; } // Gameplay_TriggerRespawn ? @@ -426,11 +1942,10 @@ void func_80169FDC(GameState* thisx) { func_80169F78(thisx); } -// Used by Kankyo to determine how to change the lighting, e.g. for game over. -s32 func_80169FFC(GameState* thisx) { +s32 Play_CamIsNotFixed(GameState* thisx) { PlayState* this = (PlayState*)thisx; - return this->roomCtx.curRoom.mesh->type0.type != 1; + return this->roomCtx.curRoom.roomShape->base.type != ROOM_SHAPE_TYPE_IMAGE; } s32 FrameAdvance_IsEnabled(GameState* thisx) { @@ -476,7 +1991,7 @@ s32 func_8016A02C(GameState* thisx, Actor* actor, s16* yaw) { /** * @brief Tests if \p pos is underwater. * - * @param[in] play PlayState + * @param[in] this PlayState * @param[in] pos position to test * @return true if inside a waterbox and not above a void. */ @@ -502,38 +2017,47 @@ s32 Play_IsDebugCamEnabled(void) { return gDbgCamEnabled; } -// A mapping from playerActorCsIds to sGlobalCamDataSettings indices. -extern s16 D_801D0D64[]; -// s16 D_801D0D64[] = { -3, -2, -4, -5, -7, -11, -8, -9, -6, -16 }; +// A mapping from playerCsIds to sGlobalCamDataSettings indices. +s16 sPlayerCsIdToCsCamId[] = { + CS_CAM_ID_GLOBAL_ITEM_OCARINA, // PLAYER_CS_ID_ITEM_OCARINA + CS_CAM_ID_GLOBAL_ITEM_GET, // PLAYER_CS_ID_ITEM_GET + CS_CAM_ID_GLOBAL_ITEM_BOTTLE, // PLAYER_CS_ID_ITEM_BOTTLE + CS_CAM_ID_GLOBAL_ITEM_SHOW, // PLAYER_CS_ID_ITEM_SHOW + CS_CAM_ID_GLOBAL_WARP_PAD_MOON, // PLAYER_CS_ID_WARP_PAD_MOON + CS_CAM_ID_GLOBAL_MASK_TRANSFORMATION, // PLAYER_CS_ID_MASK_TRANSFORMATION + CS_CAM_ID_GLOBAL_DEATH, // PLAYER_CS_ID_DEATH + CS_CAM_ID_GLOBAL_REVIVE, // PLAYER_CS_ID_REVIVE + CS_CAM_ID_GLOBAL_SONG_WARP, // PLAYER_CS_ID_SONG_WARP + CS_CAM_ID_GLOBAL_WARP_PAD_ENTRANCE, // PLAYER_CS_ID_WARP_PAD_ENTRANCE +}; // Used by Player /** - * Extract the common actor cutscene ids used by Player from the scene and set the actor cutscene ids in - * this->playerActorCsIds. If a playerActorCsId is not present in the scene, then that particular id is set - * to -1. Otherwise, if there is an ActorCutscene where csCamSceneDataId matches the appropriate element of D_801D0D64, - * set the corresponding playerActorCsId (and possibly change its priority for the zeroth one) + * Extract the common cutscene ids used by Player from the scene and set the cutscene ids in this->playerCsIds. + * If a playerCsId is not present in the scene, then that particular id is set to CS_ID_NONE. + * Otherwise, if there is an ActorCutscene where csCamId matches the appropriate element of sPlayerCsIdToCsCamId, + * set the corresponding playerActorCsId (and possibly change its priority for the zeroth one). */ -void Play_AssignPlayerActorCsIdsFromScene(GameState* thisx, s32 startActorCsId) { +void Play_AssignPlayerCsIdsFromScene(GameState* thisx, s32 spawnCsId) { PlayState* this = (PlayState*)thisx; s32 i; - s16* curPlayerActorCsId = this->playerActorCsIds; - s16* phi_s1 = D_801D0D64; + s16* curPlayerCsId = this->playerCsIds; + s16* csCamId = sPlayerCsIdToCsCamId; - for (i = 0; i < ARRAY_COUNT(this->playerActorCsIds); i++, curPlayerActorCsId++, phi_s1++) { - ActorCutscene* actorCutscene; - s32 curActorCsId; + for (i = 0; i < ARRAY_COUNT(this->playerCsIds); i++, curPlayerCsId++, csCamId++) { + ActorCutscene* csEntry; + s32 curCsId; - *curPlayerActorCsId = -1; + *curPlayerCsId = CS_ID_NONE; - for (curActorCsId = startActorCsId; curActorCsId != -1; curActorCsId = actorCutscene->additionalCutscene) { - actorCutscene = ActorCutscene_GetCutscene(curActorCsId); + for (curCsId = spawnCsId; curCsId != CS_ID_NONE; curCsId = csEntry->additionalCsId) { + csEntry = CutsceneManager_GetCutsceneEntry(curCsId); - if (actorCutscene->csCamSceneDataId == *phi_s1) { - if ((actorCutscene->csCamSceneDataId == -3) && - (actorCutscene->priority == 700)) { // override ocarina cs priority - actorCutscene->priority = 550; + if (csEntry->csCamId == *csCamId) { + if ((csEntry->csCamId == CS_CAM_ID_GLOBAL_ITEM_OCARINA) && (csEntry->priority == 700)) { + csEntry->priority = 550; } - *curPlayerActorCsId = curActorCsId; + *curPlayerCsId = curCsId; break; } } @@ -549,4 +2073,272 @@ void Play_FillScreen(GameState* thisx, s16 fillScreenOn, u8 red, u8 green, u8 bl R_PLAY_FILL_SCREEN_ALPHA = alpha; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Init.s") +void Play_Init(GameState* thisx) { + PlayState* this = (PlayState*)thisx; + GraphicsContext* gfxCtx = this->state.gfxCtx; + s32 pad; + uintptr_t zAlloc; + s32 zAllocSize; + Player* player; + s32 i; + s32 spawn; + u8 sceneLayer; + s32 scene; + + if ((gSaveContext.respawnFlag == -4) || (gSaveContext.respawnFlag == -0x63)) { + if (CHECK_EVENTINF(EVENTINF_27)) { + CLEAR_EVENTINF(EVENTINF_27); + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, DayTelop_Init, sizeof(DayTelopState)); + return; + } + + gSaveContext.unk_3CA7 = 1; + if (gSaveContext.respawnFlag == -0x63) { + gSaveContext.respawnFlag = 2; + } + } else { + gSaveContext.unk_3CA7 = 0; + } + + if (gSaveContext.save.entrance == -1) { + gSaveContext.save.entrance = 0; + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, TitleSetup_Init, sizeof(TitleSetupState)); + return; + } + + if ((gSaveContext.nextCutsceneIndex == 0xFFEF) || (gSaveContext.nextCutsceneIndex == 0xFFF0)) { + scene = ((void)0, gSaveContext.save.entrance) >> 9; + spawn = (((void)0, gSaveContext.save.entrance) >> 4) & 0x1F; + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE)) { + if (scene == ENTR_SCENE_MOUNTAIN_VILLAGE_WINTER) { + scene = ENTR_SCENE_MOUNTAIN_VILLAGE_SPRING; + } else if (scene == ENTR_SCENE_GORON_VILLAGE_WINTER) { + scene = ENTR_SCENE_GORON_VILLAGE_SPRING; + } else if (scene == ENTR_SCENE_PATH_TO_GORON_VILLAGE_WINTER) { + scene = ENTR_SCENE_PATH_TO_GORON_VILLAGE_SPRING; + } else if ((scene == ENTR_SCENE_SNOWHEAD) || (scene == ENTR_SCENE_PATH_TO_SNOWHEAD) || + (scene == ENTR_SCENE_PATH_TO_MOUNTAIN_VILLAGE) || (scene == ENTR_SCENE_GORON_SHRINE) || + (scene == ENTR_SCENE_GORON_RACETRACK)) { + gSaveContext.nextCutsceneIndex = 0xFFF0; + } + } + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE)) { + if (scene == ENTR_SCENE_SOUTHERN_SWAMP_POISONED) { + scene = ENTR_SCENE_SOUTHERN_SWAMP_CLEARED; + } else if (scene == ENTR_SCENE_WOODFALL) { + gSaveContext.nextCutsceneIndex = 0xFFF1; + } + } + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE) && (scene == ENTR_SCENE_IKANA_CANYON)) { + gSaveContext.nextCutsceneIndex = 0xFFF2; + } + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE) && + ((scene == ENTR_SCENE_GREAT_BAY_COAST) || (scene == ENTR_SCENE_ZORA_CAPE))) { + gSaveContext.nextCutsceneIndex = 0xFFF0; + } + + // "First cycle" Termina Field + if (INV_CONTENT(ITEM_OCARINA) != ITEM_OCARINA) { + if ((scene == ENTR_SCENE_TERMINA_FIELD) && + (((void)0, gSaveContext.save.entrance) != ENTRANCE(TERMINA_FIELD, 10))) { + gSaveContext.nextCutsceneIndex = 0xFFF4; + } + } + //! FAKE: + gSaveContext.save.entrance = + Entrance_Create(((void)0, scene), spawn, ((void)0, gSaveContext.save.entrance) & 0xF); + } + + GameState_Realloc(&this->state, 0); + KaleidoManager_Init(this); + ShrinkWindow_Init(); + View_Init(&this->view, gfxCtx); + func_801A3EC0(0); + Quake_Init(); + Distortion_Init(this); + + for (i = 0; i < ARRAY_COUNT(this->cameraPtrs); i++) { + this->cameraPtrs[i] = NULL; + } + + Camera_Init(&this->mainCamera, &this->view, &this->colCtx, this); + Camera_ChangeStatus(&this->mainCamera, CAM_STATUS_ACTIVE); + + for (i = 0; i < ARRAY_COUNT(this->subCameras); i++) { + Camera_Init(&this->subCameras[i], &this->view, &this->colCtx, this); + Camera_ChangeStatus(&this->subCameras[i], CAM_STATUS_INACTIVE); + } + + this->cameraPtrs[CAM_ID_MAIN] = &this->mainCamera; + this->cameraPtrs[CAM_ID_MAIN]->uid = CAM_ID_MAIN; + this->activeCamId = CAM_ID_MAIN; + + Camera_OverwriteStateFlags(&this->mainCamera, CAM_STATE_0 | CAM_STATE_CHECK_WATER | CAM_STATE_2 | CAM_STATE_3 | + CAM_STATE_4 | CAM_STATE_DISABLE_MODE_CHANGE | CAM_STATE_6); + Sram_Alloc(&this->state, &this->sramCtx); + Regs_InitData(this); + Message_Init(this); + GameOver_Init(this); + SoundSource_InitAll(this); + EffFootmark_Init(this); + Effect_Init(this); + EffectSS_Init(this, 100); + CollisionCheck_InitContext(this, &this->colChkCtx); + AnimationContext_Reset(&this->animationCtx); + Cutscene_InitContext(this, &this->csCtx); + + if (gSaveContext.nextCutsceneIndex != 0xFFEF) { + gSaveContext.save.cutsceneIndex = gSaveContext.nextCutsceneIndex; + gSaveContext.nextCutsceneIndex = 0xFFEF; + } + + if (gSaveContext.save.cutsceneIndex == 0xFFFD) { + gSaveContext.save.cutsceneIndex = 0; + } + + if (gSaveContext.nextDayTime != 0xFFFF) { + gSaveContext.save.time = gSaveContext.nextDayTime; + gSaveContext.skyboxTime = gSaveContext.nextDayTime; + } + + if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 30))) { + gSaveContext.save.isNight = true; + } else { + gSaveContext.save.isNight = false; + } + + func_800EDDB0(this); + + if (((gSaveContext.gameMode != GAMEMODE_NORMAL) && (gSaveContext.gameMode != GAMEMODE_TITLE_SCREEN)) || + (gSaveContext.save.cutsceneIndex >= 0xFFF0)) { + gSaveContext.unk_3DC0 = 0; + Magic_Reset(this); + gSaveContext.sceneLayer = (gSaveContext.save.cutsceneIndex & 0xF) + 1; + + // Set saved cutscene to 0 so it doesn't immediately play, but instead let the `CutsceneManager` handle it. + gSaveContext.save.cutsceneIndex = 0; + } else { + gSaveContext.sceneLayer = 0; + } + + sceneLayer = gSaveContext.sceneLayer; + + Play_SpawnScene( + this, Entrance_GetSceneIdAbsolute(((void)0, gSaveContext.save.entrance) + ((void)0, gSaveContext.sceneLayer)), + Entrance_GetSpawnNum(((void)0, gSaveContext.save.entrance) + ((void)0, gSaveContext.sceneLayer))); + KaleidoScopeCall_Init(this); + Interface_Init(this); + + if (gSaveContext.nextDayTime != 0xFFFF) { + if (gSaveContext.nextDayTime == 0x8000) { + gSaveContext.save.day++; + gSaveContext.save.daysElapsed++; + gSaveContext.dogIsLost = true; + gSaveContext.nextDayTime = -2; + } else { + gSaveContext.nextDayTime = -3; + } + } + + Play_InitMotionBlur(); + + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_OFF; + R_PICTO_PHOTO_STATE = PICTO_PHOTO_STATE_OFF; + + PreRender_Init(&this->pauseBgPreRender); + PreRender_SetValuesSave(&this->pauseBgPreRender, D_801FBBCC, D_801FBBCE, NULL, NULL, NULL); + PreRender_SetValues(&this->pauseBgPreRender, D_801FBBCC, D_801FBBCE, NULL, NULL); + + this->unk_18E64 = D_801FBB90; + this->pictoPhotoI8 = gPictoPhotoI8; + this->unk_18E68 = D_80784600; + this->unk_18E58 = D_80784600; + this->unk_18E60 = D_80784600; + gTransitionTileState = TRANS_TILE_OFF; + this->transitionMode = TRANS_MODE_OFF; + D_801D0D54 = false; + + FrameAdvance_Init(&this->frameAdvCtx); + Rand_Seed(osGetTime()); + Matrix_Init(&this->state); + + this->state.main = Play_Main; + this->state.destroy = Play_Destroy; + + this->transitionTrigger = TRANS_TRIGGER_END; + this->worldCoverAlpha = 0; + this->bgCoverAlpha = 0; + this->haltAllActors = false; + this->unk_18844 = false; + + if (gSaveContext.gameMode != GAMEMODE_TITLE_SCREEN) { + if (gSaveContext.nextTransitionType == TRANS_NEXT_TYPE_DEFAULT) { + this->transitionType = + (Entrance_GetTransitionFlags(((void)0, gSaveContext.save.entrance) + sceneLayer) >> 7) & 0x7F; + } else { + this->transitionType = gSaveContext.nextTransitionType; + gSaveContext.nextTransitionType = TRANS_NEXT_TYPE_DEFAULT; + } + } else { + this->transitionType = TRANS_TYPE_FADE_BLACK; + } + + TransitionFade_Init(&this->unk_18E48); + TransitionFade_SetType(&this->unk_18E48, 3); + TransitionFade_SetColor(&this->unk_18E48, RGBA8(160, 160, 160, 255)); + TransitionFade_Start(&this->unk_18E48); + VisMono_Init(&sVisMono); + + gVisMonoColor.a = 0; + D_801F6D4C = &D_801F6D38; + func_80140E80(D_801F6D4C); + D_801F6D4C->lodProportion = 0.0f; + D_801F6D4C->mode = 1; + D_801F6D4C->primColor.r = 0; + D_801F6D4C->primColor.g = 0; + D_801F6D4C->primColor.b = 0; + D_801F6D4C->primColor.a = 0; + D_801F6D4C->envColor.r = 0; + D_801F6D4C->envColor.g = 0; + D_801F6D4C->envColor.b = 0; + D_801F6D4C->envColor.a = 0; + CutsceneFlags_UnsetAll(this); + THA_GetRemaining(&this->state.heap); + zAllocSize = THA_GetRemaining(&this->state.heap); + zAlloc = (uintptr_t)THA_AllocTailAlign16(&this->state.heap, zAllocSize); + ZeldaArena_Init(((zAlloc + 8) & ~0xF), (zAllocSize - ((zAlloc + 8) & ~0xF)) + zAlloc); //! @bug: Incorrect ALIGN16s + Actor_InitContext(this, &this->actorCtx, this->linkActorEntry); + + while (!Room_HandleLoadCallbacks(this, &this->roomCtx)) {} + + if ((CURRENT_DAY != 0) && ((this->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_1) || + (this->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_5))) { + Actor_Spawn(&this->actorCtx, this, ACTOR_EN_TEST4, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0); + } + + player = GET_PLAYER(this); + + Camera_InitFocalActorSettings(&this->mainCamera, &player->actor); + gDbgCamEnabled = false; + + if ((player->actor.params & 0xFF) != 0xFF) { + Camera_ChangeActorCsCamIndex(&this->mainCamera, player->actor.params & 0xFF); + } + + CutsceneManager_StoreCamera(&this->mainCamera); + Interface_SetSceneRestrictions(this); + func_800FB758(this); + gSaveContext.seqId = this->sequenceCtx.seqId; + gSaveContext.ambienceId = this->sequenceCtx.ambienceId; + AnimationContext_Update(this, &this->animationCtx); + Cutscene_HandleEntranceTriggers(this); + gSaveContext.respawnFlag = 0; + sBombersNotebookOpen = false; + BombersNotebook_Init(&sBombersNotebook); +} diff --git a/src/code/z_play_hireso.c b/src/code/z_play_hireso.c index e429051c8..829fe71f2 100644 --- a/src/code/z_play_hireso.c +++ b/src/code/z_play_hireso.c @@ -16,12 +16,12 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_play_hireso/func_8016EA90.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play_hireso/func_8016F1A8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play_hireso/BombersNotebook_Draw.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play_hireso/func_8016F4EC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play_hireso/func_8016F5A8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play_hireso/BombersNotebook_Update.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play_hireso/func_8016FC78.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play_hireso/BombersNotebook_Init.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play_hireso/func_8016FC98.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play_hireso/BombersNotebook_Destroy.s") diff --git a/src/code/z_player_call.c b/src/code/z_player_call.c index a4ceeba95..a109dab17 100644 --- a/src/code/z_player_call.c +++ b/src/code/z_player_call.c @@ -1,8 +1,9 @@ +#include "prevent_bss_reordering.h" #include "global.h" #define FLAGS \ (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000 | \ - ACTOR_FLAG_4000000 | ACTOR_FLAG_80000000) + ACTOR_FLAG_CAN_PRESS_SWITCH | ACTOR_FLAG_80000000) ActorFunc sPlayerCallInitFunc; ActorFunc sPlayerCallDestroyFunc; diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index d00325224..f8b33b853 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1,13 +1,21 @@ +/** + * File: z_player_lib.c + * Description: Set of library functions to interact with the Player system + */ + +#include "prevent_bss_reordering.h" #include "global.h" #include "objects/gameplay_keep/gameplay_keep.h" +// Assets for each player form #include "objects/object_link_boy/object_link_boy.h" #include "objects/object_link_goron/object_link_goron.h" #include "objects/object_link_zora/object_link_zora.h" #include "objects/object_link_nuts/object_link_nuts.h" #include "objects/object_link_child/object_link_child.h" +// Assets for each mask #include "objects/object_mask_truth/object_mask_truth.h" #include "objects/object_mask_kerfay/object_mask_kerfay.h" #include "objects/object_mask_yofukasi/object_mask_yofukasi.h" @@ -33,6 +41,9 @@ #include "objects/object_mask_zora/object_mask_zora.h" #include "objects/object_mask_nuts/object_mask_nuts.h" +// Assets for other actors +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" + void PlayerCall_Init(Actor* thisx, PlayState* play); void PlayerCall_Destroy(Actor* thisx, PlayState* play); void PlayerCall_Update(Actor* thisx, PlayState* play); @@ -47,30 +58,29 @@ typedef struct { struct_801F58B0 D_801F58B0[3][3]; -Vec3f D_801F59B0[2]; +#define D_801F59B0_LEN 2 -s32 D_801F59C8[2]; +Vec3f D_801F59B0[D_801F59B0_LEN]; -typedef struct { - /* 0x0 */ s16 unk_0; - /* 0x2 */ s16 unk_2; - /* 0x4 */ s16 unk_4; - /* 0x6 */ s16 unk_6; - /* 0x8 */ s16 unk_8; -} struct_801F59D0; // size = 0xA +s32 D_801F59C8[D_801F59B0_LEN]; -struct_801F59D0 D_801F59D0; +typedef struct BunnyEarKinematics { + /* 0x0 */ Vec3s rot; + /* 0x6 */ Vec3s angVel; +} BunnyEarKinematics; // size = 0xC -Vec3f* D_801F59DC; +BunnyEarKinematics sBunnyEarKinematics; + +Vec3f* sPlayerCurBodyPartPos; s32 D_801F59E0; -s32 D_801F59E4; +s32 sPlayerLod; -Vec3f D_801F59E8; +Vec3f sPlayerGetItemRefPos; -s32 D_801F59F4; -s32 D_801F59F8; +PlayerModelType sPlayerLeftHandType; +PlayerModelType sPlayerRightHandType; void func_80127B64(struct_801F58B0 arg0[], s32 count, Vec3f* arg2); @@ -141,21 +151,41 @@ void func_801229A0(PlayState* play, Player* player) { OPEN_DISPS(play->state.gfxCtx); if ((gSaveContext.jinxTimer != 0) || (player->invincibilityTimer > 0)) { - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); } CLOSE_DISPS(play->state.gfxCtx); } +// Update function void func_801229EC(Actor* thisx, PlayState* play) { } s16 sMaskObjectIds[PLAYER_MASK_MAX - 1] = { - OBJECT_MASK_TRUTH, OBJECT_MASK_KERFAY, OBJECT_MASK_YOFUKASI, OBJECT_MASK_RABIT, OBJECT_MASK_KI_TAN, - OBJECT_MASK_JSON, OBJECT_MASK_ROMERNY, OBJECT_MASK_ZACHO, OBJECT_MASK_POSTHAT, OBJECT_MASK_MEOTO, - OBJECT_MASK_BIGELF, OBJECT_MASK_GIBUDO, OBJECT_MASK_GERO, OBJECT_MASK_DANCER, OBJECT_MASK_SKJ, - OBJECT_MASK_STONE, OBJECT_MASK_BREE, OBJECT_MASK_BAKURETU, OBJECT_MASK_BU_SAN, OBJECT_MASK_KYOJIN, - OBJECT_MASK_BOY, OBJECT_MASK_GORON, OBJECT_MASK_ZORA, OBJECT_MASK_NUTS, + OBJECT_MASK_TRUTH, // PLAYER_MASK_TRUTH + OBJECT_MASK_KERFAY, // PLAYER_MASK_KAFEIS_MASK + OBJECT_MASK_YOFUKASI, // PLAYER_MASK_ALL_NIGHT + OBJECT_MASK_RABIT, // PLAYER_MASK_BUNNY + OBJECT_MASK_KI_TAN, // PLAYER_MASK_KEATON + OBJECT_MASK_JSON, // PLAYER_MASK_GARO + OBJECT_MASK_ROMERNY, // PLAYER_MASK_ROMANI + OBJECT_MASK_ZACHO, // PLAYER_MASK_CIRCUS_LEADER + OBJECT_MASK_POSTHAT, // PLAYER_MASK_POSTMAN + OBJECT_MASK_MEOTO, // PLAYER_MASK_COUPLE + OBJECT_MASK_BIGELF, // PLAYER_MASK_GREAT_FAIRY + OBJECT_MASK_GIBUDO, // PLAYER_MASK_GIBDO + OBJECT_MASK_GERO, // PLAYER_MASK_DON_GERO + OBJECT_MASK_DANCER, // PLAYER_MASK_KAMARO + OBJECT_MASK_SKJ, // PLAYER_MASK_CAPTAIN + OBJECT_MASK_STONE, // PLAYER_MASK_STONE + OBJECT_MASK_BREE, // PLAYER_MASK_BREMEN + OBJECT_MASK_BAKURETU, // PLAYER_MASK_BLAST + OBJECT_MASK_BU_SAN, // PLAYER_MASK_SCENTS + OBJECT_MASK_KYOJIN, // PLAYER_MASK_GIANT + OBJECT_MASK_BOY, // PLAYER_MASK_FIERCE_DEITY + OBJECT_MASK_GORON, // PLAYER_MASK_GORON + OBJECT_MASK_ZORA, // PLAYER_MASK_ZORA + OBJECT_MASK_NUTS, // PLAYER_MASK_DEKU }; // Load mask object? @@ -195,7 +225,7 @@ void func_801229FC(Player* player) { } else if (player->currentMask == PLAYER_MASK_CIRCUS_LEADER) { s32 i; - for (i = 0; i < ARRAY_COUNT(D_801F59C8); i++) { + for (i = 0; i < D_801F59B0_LEN; i++) { D_801F59C8[i] += Rand_S16Offset(4, 23) + (s32)(fabsf(player->linearVelocity) * 50.0f); } } @@ -329,9 +359,9 @@ void func_80122F28(Player* player) { PLAYER_STATE1_20000000))) && (!(player->stateFlags2 & PLAYER_STATE2_1))) { if (player->doorType <= PLAYER_DOORTYPE_TALKING) { - ActorCutscene_SetIntentToPlay(0x7C); + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); } else { - ActorCutscene_SetIntentToPlay(0x7D); + CutsceneManager_Queue(CS_ID_GLOBAL_DOOR); } } } @@ -354,6 +384,7 @@ void func_8012300C(PlayState* play, s32 arg1) { player->unk_B2B = arg1; } +// Update function void func_8012301C(Actor* thisx, PlayState* play2) { PlayState* play = play2; Player* this = (Player*)thisx; @@ -384,21 +415,29 @@ FlexSkeletonHeader* gPlayerSkeletons[PLAYER_FORM_MAX] = { &gLinkFierceDeitySkel, &gLinkGoronSkel, &gLinkZoraSkel, &gLinkDekuSkel, &gLinkHumanSkel, }; -s16 D_801BFE14[][18] = { +s16 D_801BFE14[PLAYER_BOOTS_MAX][18] = { + // PLAYER_BOOTS_FIERCE_DEITY { 200, 666, 200, 700, 366, 200, 600, 175, 60, 800, 1000, -100, 600, 590, 800, 125, 300, 65 }, + // PLAYER_BOOTS_HYLIAN { 200, 1000, 300, 800, 500, 400, 800, 400, 120, 800, 550, -100, 600, 540, 750, 125, 400, 200 }, + // PLAYER_BOOTS_GIANT { 100, 1000, 300, 800, 250, 200, 800, 200, 90, 800, 350, -80, 600, 540, 750, 60, 200, 200 }, + // PLAYER_BOOTS_DEKU { 200, 1000, 300, 700, 550, 270, 600, 1000, 120, 800, 600, -100, 600, 590, 750, 125, 200, 130 }, + // PLAYER_BOOTS_ZORA_LAND { 200, 1000, 300, 700, 550, 270, 700, 300, 120, 800, 600, -100, 600, 590, 750, 125, 200, 130 }, + // PLAYER_BOOTS_ZORA_UNDERWATER { 200, 1000, 300, 700, 550, 270, 700, 300, 120, 800, 600, -100, 600, 590, 750, 125, 200, 130 }, + // PLAYER_BOOTS_GORON { 200, 1000, 300, 700, 550, 270, 700, 200, 120, 800, 600, -140, 600, 590, 750, 125, 200, 130 }, + // PLAYER_BOOTS_7 { 80, 800, 150, 700, 480, 270, 600, 50, 120, 800, 300, -40, 400, 540, 270, 25, 0, 80 }, }; // OoT's Player_SetBootData void func_80123140(PlayState* play, Player* player) { s16* bootRegs; - s32 currentBoots; + PlayerBoots currentBoots; f32 scale; if ((player->actor.id == ACTOR_PLAYER) && (player->transformation == PLAYER_FORM_FIERCE_DEITY)) { @@ -441,7 +480,7 @@ void func_80123140(PlayState* play, Player* player) { IREG(69) = bootRegs[16]; MREG(95) = bootRegs[17]; - if (play->roomCtx.curRoom.unk3 == 2) { + if (play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_2) { R_RUN_SPEED_LIMIT = 500; } @@ -492,10 +531,11 @@ s32 Player_IsGoronOrDeku(Player* player) { s32 func_801234D4(PlayState* play) { Player* player = GET_PLAYER(play); - return (player->stateFlags2 & PLAYER_STATE2_8) || player->actor.speedXZ != 0.0f || + return (player->stateFlags2 & PLAYER_STATE2_8) || (player->actor.speed != 0.0f) || ((player->transformation != PLAYER_FORM_ZORA) && (player->stateFlags1 & PLAYER_STATE1_8000000)) || ((player->transformation == PLAYER_FORM_ZORA) && (player->stateFlags1 & PLAYER_STATE1_8000000) && - (!(player->actor.bgCheckFlags & 1) || (player->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER))); + (!(player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || + (player->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER))); } s32 func_80123590(PlayState* play, Actor* actor) { @@ -634,7 +674,7 @@ u8 sActionModelGroups[PLAYER_IA_MAX] = { PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_NUT PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_PICTO_BOX PLAYER_MODELGROUP_INSTRUMENT, // PLAYER_IA_OCARINA - PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_EMPTY PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_FISH PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_SPRING_WATER PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_HOT_SPRING_WATER @@ -748,10 +788,10 @@ PlayerModelIndices gPlayerModelTypes[PLAYER_MODELGROUP_MAX] = { { PLAYER_ANIMTYPE_1, PLAYER_MODELTYPE_LH_ONE_HAND_SWORD, PLAYER_MODELTYPE_RH_SHIELD, PLAYER_MODELTYPE_SHEATH_13, PLAYER_MODELTYPE_WAIST }, /* PLAYER_MODELGROUP_DEFAULT */ - { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, + { PLAYER_ANIMTYPE_DEFAULT, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, PLAYER_MODELTYPE_WAIST }, /* PLAYER_MODELGROUP_4 */ - { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, + { PLAYER_ANIMTYPE_DEFAULT, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, PLAYER_MODELTYPE_WAIST }, /* PLAYER_MODELGROUP_TWO_HAND_SWORD */ { PLAYER_ANIMTYPE_3, PLAYER_MODELTYPE_LH_TWO_HAND_SWORD, PLAYER_MODELTYPE_RH_CLOSED, PLAYER_MODELTYPE_SHEATH_14, @@ -763,7 +803,7 @@ PlayerModelIndices gPlayerModelTypes[PLAYER_MODELGROUP_MAX] = { { PLAYER_ANIMTYPE_5, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, PLAYER_MODELTYPE_WAIST }, /* PLAYER_MODELGROUP_8 */ - { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_4, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, + { PLAYER_ANIMTYPE_DEFAULT, PLAYER_MODELTYPE_LH_4, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, PLAYER_MODELTYPE_WAIST }, /* PLAYER_MODELGROUP_HOOKSHOT */ { PLAYER_ANIMTYPE_4, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_HOOKSHOT, PLAYER_MODELTYPE_SHEATH_14, @@ -772,16 +812,16 @@ PlayerModelIndices gPlayerModelTypes[PLAYER_MODELGROUP_MAX] = { { PLAYER_ANIMTYPE_3, PLAYER_MODELTYPE_LH_CLOSED, PLAYER_MODELTYPE_RH_CLOSED, PLAYER_MODELTYPE_SHEATH_14, PLAYER_MODELTYPE_WAIST }, /* PLAYER_MODELGROUP_INSTRUMENT */ - { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_INSTRUMENT, PLAYER_MODELTYPE_SHEATH_14, + { PLAYER_ANIMTYPE_DEFAULT, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_INSTRUMENT, PLAYER_MODELTYPE_SHEATH_14, PLAYER_MODELTYPE_WAIST }, /* PLAYER_MODELGROUP_BOTTLE */ - { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_BOTTLE, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, + { PLAYER_ANIMTYPE_DEFAULT, PLAYER_MODELTYPE_LH_BOTTLE, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, PLAYER_MODELTYPE_WAIST }, /* PLAYER_MODELGROUP_13 */ - { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_ONE_HAND_SWORD, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_15, + { PLAYER_ANIMTYPE_DEFAULT, PLAYER_MODELTYPE_LH_ONE_HAND_SWORD, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_15, PLAYER_MODELTYPE_WAIST }, /* PLAYER_MODELGROUP_ZORA_FINS */ - { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_CLOSED, PLAYER_MODELTYPE_RH_CLOSED, PLAYER_MODELTYPE_SHEATH_14, + { PLAYER_ANIMTYPE_DEFAULT, PLAYER_MODELTYPE_LH_CLOSED, PLAYER_MODELTYPE_RH_CLOSED, PLAYER_MODELTYPE_SHEATH_14, PLAYER_MODELTYPE_WAIST }, }; @@ -793,9 +833,11 @@ Gfx* gPlayerWaistDLs[2 * PLAYER_FORM_MAX] = { gLinkZoraWaistDL, gLinkDekuWaistDL, gLinkDekuWaistDL, gLinkHumanWaistDL, gLinkHumanWaistDL, }; -Gfx* gPlayerHandHoldingShields[PLAYER_SHIELD_MAX - 1][2] = { - { gLinkHumanRightHandHoldingHylianShieldDL, gLinkHumanRightHandHoldingHylianShieldDL }, - { gLinkHumanRightHandHoldingMirrorShieldDL, gLinkHumanRightHandHoldingMirrorShieldDL }, +Gfx* gPlayerHandHoldingShields[2 * (PLAYER_SHIELD_MAX - 1)] = { + gLinkHumanRightHandHoldingHerosShieldDL, + gLinkHumanRightHandHoldingHerosShieldDL, + gLinkHumanRightHandHoldingMirrorShieldDL, + gLinkHumanRightHandHoldingMirrorShieldDL, }; Gfx* gPlayerSheath12DLs[2 * PLAYER_FORM_MAX] = { @@ -837,21 +879,21 @@ Gfx* gPlayerSheath14DLs[2 * PLAYER_FORM_MAX] = { gLinkHumanSheathEmptyDL, }; -Gfx* gPlayerShields[][2] = { - { gLinkHumanHylianShieldWithMtxDL, gLinkHumanHylianShieldWithMtxDL }, - { gLinkHumanMirrorShieldWithMtxDL, gLinkHumanMirrorShieldWithMtxDL }, +Gfx* gPlayerShields[] = { + gLinkHumanHerosShieldWithMtxDL, + gLinkHumanHerosShieldWithMtxDL, + gLinkHumanMirrorShieldWithMtxDL, + gLinkHumanMirrorShieldWithMtxDL, }; -Gfx* gPlayerSheathedSwords[][2] = { - { gLinkHumanSheathedKokiriSwordDL, gLinkHumanSheathedKokiriSwordDL }, - { gLinkHumanSheathedRazorSwordDL, gLinkHumanSheathedRazorSwordDL }, - { gLinkHumanSheathedGildedSwordDL, gLinkHumanSheathedGildedSwordDL }, +Gfx* gPlayerSheathedSwords[] = { + gLinkHumanSheathedKokiriSwordDL, gLinkHumanSheathedKokiriSwordDL, gLinkHumanSheathedRazorSwordDL, + gLinkHumanSheathedRazorSwordDL, gLinkHumanSheathedGildedSwordDL, gLinkHumanSheathedGildedSwordDL, }; -Gfx* gPlayerSwordSheaths[][2] = { - { gLinkHumanKokiriSwordSheathDL, gLinkHumanKokiriSwordSheathDL }, - { gLinkHumanRazorSwordSheathDL, gLinkHumanRazorSwordSheathDL }, - { gLinkHumanGildedSwordSheathDL, gLinkHumanGildedSwordSheathDL }, +Gfx* gPlayerSwordSheaths[] = { + gLinkHumanKokiriSwordSheathDL, gLinkHumanKokiriSwordSheathDL, gLinkHumanRazorSwordSheathDL, + gLinkHumanRazorSwordSheathDL, gLinkHumanGildedSwordSheathDL, gLinkHumanGildedSwordSheathDL, }; Gfx* gPlayerLeftHandTwoHandSwordDLs[2 * PLAYER_FORM_MAX] = { @@ -892,10 +934,16 @@ Gfx* gPlayerLeftHandOneHandSwordDLs[2 * PLAYER_FORM_MAX] = { gLinkHumanLeftHandHoldingKokiriSwordDL, }; -Gfx* D_801C018C[][2] = { - { gLinkHumanLeftHandHoldingKokiriSwordDL, gLinkHumanLeftHandHoldingKokiriSwordDL }, - { gLinkHumanLeftHandHoldingRazorSwordDL, gLinkHumanLeftHandHoldingRazorSwordDL }, - { gLinkHumanLeftHandHoldingGildedSwordDL, gLinkHumanLeftHandHoldingGildedSwordDL }, +Gfx* D_801C018C[] = { + // EQUIP_VALUE_SWORD_KOKIRI + gLinkHumanLeftHandHoldingKokiriSwordDL, + gLinkHumanLeftHandHoldingKokiriSwordDL, + // EQUIP_VALUE_SWORD_RAZOR + gLinkHumanLeftHandHoldingRazorSwordDL, + gLinkHumanLeftHandHoldingRazorSwordDL, + // EQUIP_VALUE_SWORD_GILDED + gLinkHumanLeftHandHoldingGildedSwordDL, + gLinkHumanLeftHandHoldingGildedSwordDL, }; Gfx* gPlayerRightHandOpenDLs[2 * PLAYER_FORM_MAX] = { @@ -964,22 +1012,22 @@ Gfx* gPlayerLeftHandBottleDLs[2 * PLAYER_FORM_MAX] = { /* DLists groups end */ -Gfx* D_801C0294[PLAYER_FORM_MAX] = { +Gfx* sPlayerFirstPersonLeftForearmDLs[PLAYER_FORM_MAX] = { gLinkFierceDeityLeftForearmDL, gLinkGoronLeftForearmDL, gLinkZoraLeftForearmDL, gLinkDekuLeftForearmDL, gLinkHumanLeftForearmDL, }; -Gfx* D_801C02A8[PLAYER_FORM_MAX] = { +Gfx* sPlayerFirstPersonLeftHandDLs[PLAYER_FORM_MAX] = { gLinkFierceDeityLeftHandDL, gLinkGoronLeftHandOpenDL, gLinkZoraLeftHandClosedDL, gLinkDekuLeftHandDL, gLinkHumanLeftHandClosedDL, }; -Gfx* D_801C02BC[PLAYER_FORM_MAX] = { +Gfx* sPlayerFirstPersonRightShoulderDLs[PLAYER_FORM_MAX] = { gLinkFierceDeityRightShoulderDL, gLinkGoronRightShoulderDL, gLinkZoraRightShoulderDL, gLinkDekuRightShoulderDL, gLinkHumanRightShoulderDL, }; -Gfx* D_801C02D0[PLAYER_FORM_MAX] = { +Gfx* sPlayerFirstPersonRightHandDLs[PLAYER_FORM_MAX] = { gLinkFierceDeityRightHandDL, //! @bug This is in the middle of a texture in the link_goron object. It has the same offset as a link_nuts dlist 0x060038C0, @@ -988,7 +1036,7 @@ Gfx* D_801C02D0[PLAYER_FORM_MAX] = { object_link_child_DL_018490, }; -Gfx* D_801C02E4[PLAYER_FORM_MAX] = { +Gfx* sPlayerFirstPersonRightHandHookshotDLs[PLAYER_FORM_MAX] = { gLinkFierceDeityRightHandDL, //! @bug This is in the middle of a texture in the link_goron object. It has the same offset as a link_nuts dlist 0x060038C0, @@ -1221,7 +1269,7 @@ void Player_SetModelGroup(Player* player, PlayerModelGroup modelGroup) { player->modelGroup = modelGroup; if (modelGroup == PLAYER_MODELGROUP_1) { - player->modelAnimType = PLAYER_ANIMTYPE_0; + player->modelAnimType = PLAYER_ANIMTYPE_DEFAULT; } else { player->modelAnimType = gPlayerModelTypes[modelGroup].modelAnimType; } @@ -1229,7 +1277,7 @@ void Player_SetModelGroup(Player* player, PlayerModelGroup modelGroup) { if (player->modelAnimType < PLAYER_ANIMTYPE_3) { if (((player->transformation != PLAYER_FORM_FIERCE_DEITY) && (player->transformation != PLAYER_FORM_HUMAN)) || (player->currentShield == PLAYER_SHIELD_NONE)) { - player->modelAnimType = PLAYER_ANIMTYPE_0; + player->modelAnimType = PLAYER_ANIMTYPE_DEFAULT; } } @@ -1274,7 +1322,7 @@ void func_80123DA4(Player* player) { } void func_80123DC0(Player* player) { - if ((player->actor.bgCheckFlags & 1) || + if ((player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (player->stateFlags1 & (PLAYER_STATE1_200000 | PLAYER_STATE1_800000 | PLAYER_STATE1_8000000)) || (!(player->stateFlags1 & (PLAYER_STATE1_40000 | PLAYER_STATE1_80000)) && ((player->actor.world.pos.y - player->actor.floorHeight) < 100.0f))) { @@ -1364,34 +1412,35 @@ s32 func_801240DC(Player* player) { return Player_IsHoldingHookshot(player) && (player->heldActor == NULL); } -s32 func_80124110(Player* player, PlayerItemAction itemAction) { - s32 temp_v0 = itemAction - PLAYER_IA_FISHING_ROD; +PlayerBButtonSword Player_BButtonSwordFromIA(Player* player, PlayerItemAction itemAction) { + PlayerBButtonSword bButtonSword = GET_B_SWORD_FROM_IA(itemAction); if (player->transformation != PLAYER_FORM_GORON) { - if (((itemAction - PLAYER_IA_FISHING_ROD) > (PLAYER_IA_FISHING_ROD - PLAYER_IA_FISHING_ROD)) && - ((itemAction - PLAYER_IA_FISHING_ROD) < (PLAYER_IA_SWORD_GREAT_FAIRY - PLAYER_IA_FISHING_ROD))) { - return temp_v0; + if ((GET_B_SWORD_FROM_IA(itemAction) > PLAYER_B_SWORD_NONE) && + (GET_B_SWORD_FROM_IA(itemAction) < PLAYER_B_SWORD_MAX)) { + return bButtonSword; } } - return 0; + return PLAYER_B_SWORD_NONE; } -s32 func_80124148(Player* player) { - return func_80124110(player, player->heldItemAction); +PlayerBButtonSword Player_GetHeldBButtonSword(Player* player) { + return Player_BButtonSwordFromIA(player, player->heldItemAction); } -s32 Player_ActionToMeleeWeapon(PlayerItemAction itemAction) { - s32 weapon = itemAction - (PLAYER_IA_SWORD_KOKIRI - 1); +PlayerMeleeWeapon Player_MeleeWeaponFromIA(PlayerItemAction itemAction) { + PlayerMeleeWeapon weapon = GET_MELEE_WEAPON_FROM_IA(itemAction); - if ((weapon > 0) && (weapon <= (PLAYER_IA_ZORA_FINS - (PLAYER_IA_SWORD_KOKIRI - 1)))) { + if ((weapon > PLAYER_MELEEWEAPON_NONE) && (weapon < PLAYER_MELEEWEAPON_MAX)) { return weapon; } - return 0; + + return PLAYER_MELEEWEAPON_NONE; } -s32 Player_GetMeleeWeaponHeld(Player* player) { - return Player_ActionToMeleeWeapon(player->heldItemAction); +PlayerMeleeWeapon Player_GetMeleeWeaponHeld(Player* player) { + return Player_MeleeWeaponFromIA(player->heldItemAction); } s32 Player_IsHoldingTwoHandedWeapon(Player* player) { @@ -1403,47 +1452,45 @@ s32 Player_IsHoldingTwoHandedWeapon(Player* player) { return false; } -s32 Player_ActionToBottle(Player* player, PlayerItemAction itemAction) { - s32 bottle = itemAction - PLAYER_IA_BOTTLE; +PlayerBottle Player_BottleFromIA(Player* player, PlayerItemAction itemAction) { + PlayerBottle bottle = GET_BOTTLE_FROM_IA(itemAction); - // Relies on bottle-related item actions to be contiguous - if ((bottle >= (PLAYER_IA_BOTTLE - PLAYER_IA_BOTTLE)) && (bottle <= (PLAYER_IA_BOTTLE_FAIRY - PLAYER_IA_BOTTLE))) { + if ((bottle > PLAYER_BOTTLE_NONE) && (bottle < PLAYER_BOTTLE_MAX)) { return bottle; } - return -1; + return PLAYER_BOTTLE_NONE; } -s32 Player_GetBottleHeld(Player* Player) { - return Player_ActionToBottle(Player, Player->heldItemAction); +PlayerBottle Player_GetBottleHeld(Player* Player) { + return Player_BottleFromIA(Player, Player->heldItemAction); } -s32 Player_ActionToExplosive(Player* player, PlayerItemAction itemAction) { - s32 explosive = itemAction - PLAYER_IA_BOMB; +PlayerExplosive Player_ExplosiveFromIA(Player* player, PlayerItemAction itemAction) { + PlayerExplosive explosive = GET_EXPLOSIVE_FROM_IA(itemAction); - // Relies on explosive-related item actions to be contiguous - if ((explosive >= (PLAYER_IA_BOMB - PLAYER_IA_BOMB)) && (explosive <= (PLAYER_IA_BOMBCHU - PLAYER_IA_BOMB))) { + if ((explosive > PLAYER_EXPLOSIVE_NONE) && (explosive < PLAYER_EXPLOSIVE_MAX)) { return explosive; } - return -1; + return PLAYER_EXPLOSIVE_NONE; } -s32 Player_GetExplosiveHeld(Player* player) { - return Player_ActionToExplosive(player, player->heldItemAction); +PlayerExplosive Player_GetExplosiveHeld(Player* player) { + return Player_ExplosiveFromIA(player, player->heldItemAction); } -s32 Player_ActionToSword(Actor* actor, PlayerItemAction itemAction) { - s32 sword = 0; +// Note this function maps PLAYER_IA_LAST_USED to PLAYER_SWORD_KOKIRI +PlayerSword Player_SwordFromIA(Player* player, PlayerItemAction itemAction) { + PlayerSword sword = PLAYER_SWORD_KOKIRI; //! FAKE: if ((itemAction == PLAYER_IA_LAST_USED) || - ((sword = itemAction - PLAYER_IA_SWORD_KOKIRI, (sword >= PLAYER_IA_SWORD_KOKIRI - PLAYER_IA_SWORD_KOKIRI)) && - (sword <= PLAYER_IA_SWORD_GREAT_FAIRY - PLAYER_IA_SWORD_KOKIRI))) { + ((sword = GET_SWORD_FROM_IA(itemAction), (sword > PLAYER_SWORD_NONE)) && (sword < PLAYER_SWORD_MAX))) { return sword; } - return -1; + return PLAYER_SWORD_NONE; } s32 func_801242B4(Player* player) { @@ -1455,13 +1502,13 @@ s32 Player_GetEnvironmentalHazard(PlayState* play) { EnvHazardTextTriggerEntry* triggerEntry; s32 envHazard; - if (play->roomCtx.curRoom.unk2 == 3) { // Room is hot + if (play->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_HOT) { envHazard = PLAYER_ENV_HAZARD_HOTROOM - 1; } else if ((player->transformation != PLAYER_FORM_ZORA) && (player->underwaterTimer > 80)) { envHazard = PLAYER_ENV_HAZARD_UNDERWATER_FREE - 1; } else if (player->stateFlags1 & PLAYER_STATE1_8000000) { if ((player->transformation == PLAYER_FORM_ZORA) && (player->currentBoots >= PLAYER_BOOTS_ZORA_UNDERWATER) && - (player->actor.bgCheckFlags & 1)) { + (player->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { envHazard = PLAYER_ENV_HAZARD_UNDERWATER_FLOOR - 1; } else { envHazard = PLAYER_ENV_HAZARD_SWIMMING - 1; @@ -1482,8 +1529,45 @@ s32 Player_GetEnvironmentalHazard(PlayState* play) { return envHazard + 1; } -void func_80124420(Player* player); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124420.s") +void Player_UpdateBunnyEars(Player* player) { + Vec3s force; + s16 angle; + + sBunnyEarKinematics.angVel.x -= sBunnyEarKinematics.angVel.x >> 3; + sBunnyEarKinematics.angVel.y -= sBunnyEarKinematics.angVel.y >> 3; + sBunnyEarKinematics.angVel.x += -sBunnyEarKinematics.rot.x >> 2; + sBunnyEarKinematics.angVel.y += -sBunnyEarKinematics.rot.y >> 2; + + angle = player->actor.world.rot.y - player->actor.shape.rot.y; + force.x = + (s32)(player->actor.speed * -200.0f * Math_CosS(angle) * (randPlusMinusPoint5Scaled(2.0f) + 10.0f)) & 0xFFFF; + force.y = + (s32)(player->actor.speed * 100.0f * Math_SinS(angle) * (randPlusMinusPoint5Scaled(2.0f) + 10.0f)) & 0xFFFF; + + sBunnyEarKinematics.angVel.x += force.x >> 2; + sBunnyEarKinematics.angVel.y += force.y >> 2; + + if (sBunnyEarKinematics.angVel.x > 0x1770) { + sBunnyEarKinematics.angVel.x = 0x1770; + } else if (sBunnyEarKinematics.angVel.x < -0x1770) { + sBunnyEarKinematics.angVel.x = -0x1770; + } + + if (sBunnyEarKinematics.angVel.y > 0x1770) { + sBunnyEarKinematics.angVel.y = 0x1770; + } else if (sBunnyEarKinematics.angVel.y < -0x1770) { + sBunnyEarKinematics.angVel.y = -0x1770; + } + + sBunnyEarKinematics.rot.x += sBunnyEarKinematics.angVel.x; + sBunnyEarKinematics.rot.y += sBunnyEarKinematics.angVel.y; + + if (sBunnyEarKinematics.rot.x < 0) { + sBunnyEarKinematics.rot.z = sBunnyEarKinematics.rot.x >> 1; + } else { + sBunnyEarKinematics.rot.z = 0; + } +} void func_80124618(struct_80124618 arg0[], f32 curFrame, Vec3f* arg2) { s32 currentFrame = curFrame; @@ -1539,16 +1623,22 @@ Gfx gCullFrontDList[] = { gsSPEndDisplayList(), }; -TexturePtr sPlayerEyesTextures[] = { - gLinkHumanEyesOpenTex, gLinkHumanEyesHalfTex, gLinkHumanEyesClosedTex, gLinkHumanEyesRollRightTex, - gLinkHumanEyesRollLeftTex, gLinkHumanEyesRollUpTex, gLinkHumanEyesRollDownTex, object_link_child_Tex_003800, +TexturePtr sPlayerEyesTextures[PLAYER_EYES_MAX] = { + gLinkHumanEyesOpenTex, // PLAYER_EYES_OPEN + gLinkHumanEyesHalfTex, // PLAYER_EYES_HALF + gLinkHumanEyesClosedTex, // PLAYER_EYES_CLOSED + gLinkHumanEyesRollRightTex, // PLAYER_EYES_ROLL_RIGHT + gLinkHumanEyesRollLeftTex, // PLAYER_EYES_ROLL_LEFT + gLinkHumanEyesRollUpTex, // PLAYER_EYES_ROLL_UP + gLinkHumanEyesRollDownTex, // PLAYER_EYES_ROLL_DOWN + object_link_child_Tex_003800, // PLAYER_EYES_7 }; -TexturePtr sPlayerMouthTextures[] = { - gLinkHumanMouthClosedTex, - gLinkHumanMouthTeethTex, - gLinkHumanMouthAngryTex, - gLinkHumanMouthHappyTex, +TexturePtr sPlayerMouthTextures[PLAYER_MOUTH_MAX] = { + gLinkHumanMouthClosedTex, // PLAYER_MOUTH_CLOSED + gLinkHumanMouthTeethTex, // PLAYER_MOUTH_TEETH + gLinkHumanMouthAngryTex, // PLAYER_MOUTH_ANGRY + gLinkHumanMouthHappyTex, // PLAYER_MOUTH_HAPPY }; typedef struct PlayerFaceIndices { @@ -1580,8 +1670,8 @@ PlayerFaceIndices sPlayerFaces[] = { void Player_DrawImpl(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, s32 lod, PlayerTransformation playerForm, s32 boots, s32 face, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor) { - s32 eyeIndex = (jointTable[22].x & 0xF) - 1; - s32 mouthIndex = ((jointTable[22].x >> 4) & 0xF) - 1; + s32 eyeIndex = GET_EYE_INDEX_FROM_JOINT_TABLE(jointTable); + s32 mouthIndex = GET_MOUTH_INDEX_FROM_JOINT_TABLE(jointTable); Gfx* gfx; OPEN_DISPS(play->state.gfxCtx); @@ -1611,68 +1701,172 @@ void Player_DrawImpl(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dL POLY_OPA_DISP = &gfx[2]; D_801F59E0 = playerForm * 2; - D_801F59E4 = lod; + sPlayerLod = lod; SkelAnime_DrawFlexLod(play, skeleton, jointTable, dListCount, overrideLimbDraw, postLimbDraw, actor, lod); CLOSE_DISPS(play->state.gfxCtx); } Vec3f D_801C08C0[PLAYER_FORM_MAX] = { - { 1304.0f, 0.0f, 0.0f }, { 1156.0f, 0.0f, 0.0f }, { 1406.0f, 0.0f, 0.0f }, - { 408.0f, 0.0f, 0.0f }, { 695.0f, 0.0f, 0.0f }, + { 1304.0f, 0.0f, 0.0f }, // PLAYER_FORM_FIERCE_DEITY + { 1156.0f, 0.0f, 0.0f }, // PLAYER_FORM_GORON + { 1406.0f, 0.0f, 0.0f }, // PLAYER_FORM_ZORA + { 408.0f, 0.0f, 0.0f }, // PLAYER_FORM_DEKU + { 695.0f, 0.0f, 0.0f }, // PLAYER_FORM_HUMAN }; f32 D_801C08FC[PLAYER_FORM_MAX] = { - 1265.0f, 1056.0f, 1506.0f, 359.0f, 826.0f, + 1265.0f, // PLAYER_FORM_FIERCE_DEITY + 1056.0f, // PLAYER_FORM_GORON + 1506.0f, // PLAYER_FORM_ZORA + 359.0f, // PLAYER_FORM_DEKU + 826.0f, // PLAYER_FORM_HUMAN }; f32 D_801C0910[PLAYER_FORM_MAX] = { - 170.0416f, 133.63359f, 197.68358f, 16.646399f, 48.302498f, + 170.0416f, // PLAYER_FORM_FIERCE_DEITY + 133.63359f, // PLAYER_FORM_GORON + 197.68358f, // PLAYER_FORM_ZORA + 16.646399f, // PLAYER_FORM_DEKU + 48.302498f, // PLAYER_FORM_HUMAN }; f32 D_801C0924[PLAYER_FORM_MAX] = { - 10.019104f, 22.120003f, -29.12001f, 3.7582989f, -19.925102f, + 10.019104f, // PLAYER_FORM_FIERCE_DEITY + 22.120003f, // PLAYER_FORM_GORON + -29.12001f, // PLAYER_FORM_ZORA + 3.7582989f, // PLAYER_FORM_DEKU + -19.925102f, // PLAYER_FORM_HUMAN }; f32 D_801C0938[PLAYER_FORM_MAX] = { - 5.0f, 4.0f, 1.0f, 1.0f, 3.0f, + 5.0f, // PLAYER_FORM_FIERCE_DEITY + 4.0f, // PLAYER_FORM_GORON + 1.0f, // PLAYER_FORM_ZORA + 1.0f, // PLAYER_FORM_DEKU + 3.0f, // PLAYER_FORM_HUMAN }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124870.s") +/** + * Adjusts player's legs to slopes and spawns flames when running on lava + */ +void Player_AdjustSingleLeg(PlayState* play, Player* player, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, + s32 thighLimbIndex, s32 shinLimbIndex, s32 footLimbIndex) { + CollisionPoly* poly; + s32 bgId; + f32 yIntersect; + Vec3f sp90; + Vec3f sp84; + Vec3f footprintPos; + f32 sp74; + f32 sp70; + f32 sp7C; -void func_80124CC4(PlayState* play, Player* player, f32 arg2) { + if ((player->stateFlags3 & PLAYER_STATE3_1) || !(player->actor.scale.y >= 0.0f) || + (player->stateFlags1 & PLAYER_STATE1_80) || play->unk_18844) { + return; + } + + sp74 = D_801C0910[player->transformation]; + sp70 = D_801C0924[player->transformation]; + sp7C = D_801C0938[player->transformation] - player->unk_AB8; + Matrix_Push(); + Matrix_TranslateRotateZYX(pos, rot); + Matrix_MultZero(&sp90); + Matrix_TranslateRotateZYX(&D_801C08C0[player->transformation], &skelAnime->jointTable[shinLimbIndex]); + Matrix_Translate(D_801C08FC[player->transformation], 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultZero(&sp84); + Matrix_MultVecY(-300.0f, &footprintPos); + Matrix_Pop(); + + footprintPos.y += 15.0f; + yIntersect = BgCheck_EntityRaycastFloor3(&play->colCtx, &poly, &bgId, &footprintPos) + sp7C + + (player->unk_ABC * player->actor.scale.y); + if (sp84.y < yIntersect) { + f32 diffX = sp84.x - sp90.x; + f32 diffY = sp84.y - sp90.y; + f32 diffZ = sp84.z - sp90.z; + f32 distance; + f32 sp58; + f32 sp54; + f32 temp_f20; + f32 sp4C; + f32 sp48; + s16 temp_f8; + s32 temp_v0_4; + s16 phi_t1; + + distance = sqrtf(SQ(diffX) + SQ(diffY) + SQ(diffZ)); + + sp58 = (SQ(distance) + sp70) / (2.0f * distance); + + temp_f20 = sp74 - SQ(sp58); + temp_f20 = (temp_f20 < 0.0f) ? 0.0f : sqrtf(temp_f20); + + sp4C = func_80086B30(temp_f20, sp58); + distance = sqrtf(SQ(diffX) + SQ(yIntersect - sp90.y) + SQ(diffZ)); + sp58 = (SQ(distance) + sp70) / (2.0f * distance); + sp54 = distance - sp58; + + temp_f20 = sp74 - SQ(sp58); + temp_f20 = (temp_f20 < 0.0f) ? 0.0f : sqrtf(temp_f20); + + sp48 = func_80086B30(temp_f20, sp58); + phi_t1 = (M_PI - (func_80086B30(sp54, temp_f20) + ((M_PI / 2.0f) - sp48))) * (0x8000 / M_PI); + phi_t1 = -skelAnime->jointTable[shinLimbIndex].z + phi_t1; + temp_f8 = (sp48 - sp4C) * (0x8000 / M_PI); + + if ((s16)(ABS_ALT(skelAnime->jointTable[shinLimbIndex].x) + ABS_ALT(skelAnime->jointTable[shinLimbIndex].y)) < + 0) { + phi_t1 = BINANG_ROT180(phi_t1); + } + + rot->z -= temp_f8; + + skelAnime->jointTable[thighLimbIndex].z -= temp_f8; + skelAnime->jointTable[shinLimbIndex].z += phi_t1; + skelAnime->jointTable[footLimbIndex].z = (skelAnime->jointTable[footLimbIndex].z + temp_f8) - phi_t1; + + temp_v0_4 = SurfaceType_GetFloorType(&play->colCtx, poly, bgId); + if ((temp_v0_4 >= 2) && (temp_v0_4 < 4) && !SurfaceType_IsWallDamage(&play->colCtx, poly, bgId)) { + footprintPos.y = yIntersect; + EffectSsGFire_Spawn(play, &footprintPos); + } + } +} + +void Player_DrawHookshotReticle(PlayState* play, Player* player, f32 hookshotDistance) { static Vec3f D_801C094C = { -500.0f, -100.0f, 0.0f }; CollisionPoly* poly; s32 bgId; Vec3f sp7C; Vec3f sp70; Vec3f pos; - Vec3f sp58; - f32 sp54; - f32 scale; D_801C094C.z = 0.0f; Matrix_MultVec3f(&D_801C094C, &sp7C); - D_801C094C.z = arg2; + D_801C094C.z = hookshotDistance; Matrix_MultVec3f(&D_801C094C, &sp70); if (BgCheck_AnyLineTest3(&play->colCtx, &sp7C, &sp70, &pos, &poly, true, true, true, true, &bgId)) { if (!func_800B90AC(play, &player->actor, poly, bgId, &pos) || BgCheck_ProjectileLineTest(&play->colCtx, &sp7C, &sp70, &pos, &poly, true, true, true, true, &bgId)) { + Vec3f sp58; + f32 sp54; + f32 scale; + OPEN_DISPS(play->state.gfxCtx); OVERLAY_DISP = Gfx_CallSetupDL(OVERLAY_DISP, 7); SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &sp58, &sp54); - if (sp54 < 200.0f) { - scale = 0.08f; - } else { - scale = (sp54 / 200.0f) * 0.08f; - } + + scale = (sp54 < 200.0f) ? 0.08f : (sp54 / 200.0f) * 0.08f; + Matrix_Translate(pos.x, pos.y, pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(OVERLAY_DISP++, 0x06, play->objectCtx.status[player->actor.objBankIndex].segment); - gSPDisplayList(OVERLAY_DISP++, gameplay_keep_DL_04F250); + gSPDisplayList(OVERLAY_DISP++, gHookshotReticleDL); CLOSE_DISPS(play->state.gfxCtx); } @@ -1691,8 +1885,6 @@ Gfx** D_801C0964[] = { }; void func_80124F18(s16* arg0, f32* arg1, s16 arg2, f32 arg3, f32 arg4) { - f32 phi_f12; - if (*arg0 < arg2) { *arg1 += arg3; } else { @@ -1739,7 +1931,26 @@ void func_80124FF0(f32 arg0, s16 arg1, Vec3f* arg2, s16 arg3, Vec3f* arg4, Vec3f func_80124F18(arg6, arg7, temp_v0, 20.0f, 2000.0f); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801251C4.s") +void func_801251C4(Player* player, Vec3f* arg1) { + Vec3f sp4C; + Vec3f sp40; + + sp4C.x = player->actor.world.pos.x; + sp4C.y = player->actor.world.pos.y + 60.0f; + sp4C.z = player->actor.world.pos.z; + func_80124FF0(-20.0f, player->unk_B8C, &sp4C, player->actor.shape.rot.y, + &player->bodyPartsPos[PLAYER_BODYPART_WAIST], arg1, &player->unk_B90, &player->unk_B10[0], 0.0f, + 0x1F40, &player->unk_B92, &player->unk_B10[1], 0); + + sp40.x = + (player->bodyPartsPos[PLAYER_BODYPART_LEFT_FOOT].x + player->bodyPartsPos[PLAYER_BODYPART_RIGHT_FOOT].x) / 2.0f; + sp40.y = + (player->bodyPartsPos[PLAYER_BODYPART_LEFT_FOOT].y + player->bodyPartsPos[PLAYER_BODYPART_RIGHT_FOOT].y) / 2.0f; + sp40.z = + (player->bodyPartsPos[PLAYER_BODYPART_LEFT_FOOT].z + player->bodyPartsPos[PLAYER_BODYPART_RIGHT_FOOT].z) / 2.0f; + func_80124FF0(-20.0f, player->unk_B90, arg1, (player->actor.shape.rot.y + player->unk_B92), &sp40, arg1, + &player->unk_B94, &player->unk_B10[2], -1.9f, 0x1F40, &player->unk_B96, &player->unk_B10[3], 0); +} void func_80125318(Vec3f* arg0, Vec3s* arg1) { arg0->x = 0.0f; @@ -1766,11 +1977,9 @@ void Player_DrawZoraShield(PlayState* play, Player* player) { u8* phi_a0; Vtx* vtx; Gfx* dList; - f32 scale; + f32 scale = player->unk_B62 * (10.0f / 51.0f); s32 i; - scale = player->unk_B62 * (10.0f / 51.0f); - OPEN_DISPS(play->state.gfxCtx); AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(&object_link_zora_Matanimheader_012A80)); @@ -1798,49 +2007,399 @@ void Player_DrawZoraShield(PlayState* play, Player* player) { CLOSE_DISPS(play->state.gfxCtx); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80125500.s") +void func_80125500(PlayState* play, Player* player, s32 limbIndex, Vec3f* pos, Vec3s* rot) { + if (limbIndex == PLAYER_LIMB_LEFT_THIGH) { + Player_AdjustSingleLeg(play, player, &player->skelAnime, pos, rot, PLAYER_LIMB_LEFT_THIGH, + PLAYER_LIMB_LEFT_SHIN, PLAYER_LIMB_LEFT_FOOT); + } else if (limbIndex == PLAYER_LIMB_RIGHT_THIGH) { + Player_AdjustSingleLeg(play, player, &player->skelAnime, pos, rot, PLAYER_LIMB_RIGHT_THIGH, + PLAYER_LIMB_RIGHT_SHIN, PLAYER_LIMB_RIGHT_FOOT); + } +} -s32 func_80125580(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80125580.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80125CE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80125D4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801262C8.s") - -// unused -s32 func_801263FC(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + s32 pad; Player* player = (Player*)thisx; - if (!func_80125580(play, limbIndex, dList, pos, rot, thisx)) { + if (limbIndex == PLAYER_LIMB_ROOT) { + sPlayerLeftHandType = player->leftHandType; + sPlayerRightHandType = player->rightHandType; + + // `sPlayerCurBodyPartPos` is incremented before each usage, so it starts at index -1. + // What determines if a limb corresponds to a body part is whether or not it has a non-NULL `dList`. + // Note: The increment would not be done for the root limb, even if it had a non-NULL `dList`. + // So if the root limb had a non-NULL `dList` (which is not the case in vanilla), + // an out-of-bounds write to `bodyPartsPos` would occur. + sPlayerCurBodyPartPos = &player->bodyPartsPos[-1]; + + if (player->transformation != PLAYER_FORM_FIERCE_DEITY) { + if (!(player->skelAnime.moveFlags & ANIM_FLAG_4) || (player->skelAnime.moveFlags & ANIM_FLAG_1)) { + pos->x *= player->ageProperties->unk_08; + pos->z *= player->ageProperties->unk_08; + } + if (!(player->skelAnime.moveFlags & ANIM_FLAG_4) || (player->skelAnime.moveFlags & ANIM_FLAG_UPDATEY)) { + pos->y *= player->ageProperties->unk_08; + } + } + + pos->y -= player->unk_AB8; + if ((player->transformation == PLAYER_FORM_ZORA) && (player->stateFlags3 & PLAYER_STATE3_8000)) { + Matrix_Translate(pos->x, ((Math_CosS(player->unk_AAA) - 1.0f) * 200.0f) + pos->y, pos->z, MTXMODE_APPLY); + Matrix_RotateXS(player->unk_AAA, MTXMODE_APPLY); + + if (player->unk_B62 != 0) { + Matrix_Push(); + Matrix_RotateZS(player->unk_B8E, MTXMODE_APPLY); + Matrix_RotateZYX(rot->x, rot->y, rot->z, MTXMODE_APPLY); + Matrix_RotateXS(-0x8000, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -4000.0f, MTXMODE_APPLY); + Player_DrawZoraShield(play, player); + Matrix_Pop(); + } + + Matrix_RotateZS(player->unk_B86[1], MTXMODE_APPLY); + Matrix_RotateZYX(rot->x, rot->y, rot->z, MTXMODE_APPLY); + func_80125318(pos, rot); + } else if (player->stateFlags3 & PLAYER_STATE3_2000) { + Vec3f sp54; + + func_801251C4(player, &sp54); + sp54.x -= player->actor.world.pos.x; + sp54.y -= player->actor.world.pos.y; + sp54.z -= player->actor.world.pos.z; + Matrix_Translate(pos->x + sp54.x, pos->y + sp54.y, pos->z + sp54.z, MTXMODE_APPLY); + Matrix_RotateXS(player->unk_B94, MTXMODE_APPLY); + Matrix_RotateZS(player->unk_B8E, MTXMODE_APPLY); + player->upperLimbRot.x = player->unk_B90 - player->unk_B94; + Matrix_RotateZYX(rot->x, rot->y, rot->z, MTXMODE_APPLY); + func_80125318(pos, rot); + } else if (player->unk_AAA != 0) { + Matrix_Translate(pos->x, ((Math_CosS(player->unk_AAA) - 1.0f) * 200.0f) + pos->y, pos->z, MTXMODE_APPLY); + Matrix_RotateXS(player->unk_AAA, MTXMODE_APPLY); + Matrix_RotateZYX(rot->x, rot->y, rot->z, MTXMODE_APPLY); + func_80125318(pos, rot); + } + } else { + if (*dList != NULL) { + sPlayerCurBodyPartPos++; + } + + if (limbIndex == PLAYER_LIMB_HEAD) { + rot->x += player->headLimbRot.z; + rot->y -= player->headLimbRot.y; + rot->z += player->headLimbRot.x; + + if (player->transformation == PLAYER_FORM_DEKU) { + EnArrow* bubble = NULL; + + if (((player->skelAnime.animation == &gPlayerAnim_pn_drinkend)) || + (player->unk_284.animation == &gPlayerAnim_pn_tamahaki) || + ((player->stateFlags3 & PLAYER_STATE3_40) && ((bubble = (EnArrow*)player->heldActor) != NULL))) { + Matrix_TranslateRotateZYX(pos, rot); + func_80125340(); + func_80125318(pos, rot); + + if (bubble != NULL) { + s32 requiredScopeTemp[2]; + + player->unk_AF0[0].x = 1.0f - (bubble->bubble.unk_144 * 0.03f); + player->unk_AF0[0].y = 1.0f - (bubble->bubble.unk_144 * 0.01f); + player->unk_AF0[0].z = 1.0f - (bubble->bubble.unk_144 * 0.04f); + rot->z = bubble->bubble.unk_144 * 320.0f; + } else if (player->skelAnime.animation == &gPlayerAnim_pn_drinkend) { + func_80124618(D_801C03E0, player->skelAnime.curFrame, player->unk_AF0); + } else { + func_80124618(D_801C03C0, player->unk_284.curFrame, player->unk_AF0); + } + + Matrix_Scale(player->unk_AF0[0].x, player->unk_AF0[0].y, player->unk_AF0[0].z, MTXMODE_APPLY); + } + } + } else if (limbIndex == PLAYER_LIMB_TORSO) { + if ((player->skelAnime.animation == &gPlayerAnim_pg_gakkistart) || + (player->skelAnime.animation == &gPlayerAnim_pg_wait) || + (player->skelAnime.animation == &gPlayerAnim_pg_punchC) || + (player->transformation == PLAYER_FORM_ZORA)) { + Matrix_TranslateRotateZYX(pos, rot); + if (player->transformation == PLAYER_FORM_GORON) { + func_80125340(); + } + + func_80125318(pos, rot); + if ((player->transformation != PLAYER_FORM_ZORA) || + (player->skelAnime.animation == &gPlayerAnim_pz_wait)) { + struct_80124618* phi_a0 = + (player->skelAnime.animation == &gPlayerAnim_pz_wait) + ? D_801C0608 + : ((player->skelAnime.animation == &gPlayerAnim_pg_wait) + ? D_801C0628 + : ((player->skelAnime.animation == &gPlayerAnim_pg_punchC) ? D_801C07C0 + : D_801C0460)); + + func_80124618(phi_a0, player->skelAnime.curFrame, player->unk_AF0); + } else { + player->unk_AF0[0].y = 1.0f; + } + + if (player->transformation == PLAYER_FORM_ZORA) { + player->unk_AF0[0].y *= 1.0f + (0.29999995f * player->unk_B10[0]); + player->unk_AF0[0].x = 1.0f; + player->unk_AF0[0].z = 1.0f; + } + Matrix_Scale(player->unk_AF0[0].x, player->unk_AF0[0].y, player->unk_AF0[0].z, MTXMODE_APPLY); + } + } else if (limbIndex == PLAYER_LIMB_UPPER_ROOT) { + s16 rotX; + s16 rotZ = 0x44C; + + if (player->unk_AA8 != 0) { + Matrix_RotateZS(rotZ, MTXMODE_APPLY); + Matrix_RotateYS(player->unk_AA8, MTXMODE_APPLY); + } + + if (player->upperLimbRot.y != 0) { + Matrix_RotateYS(player->upperLimbRot.y, MTXMODE_APPLY); + } + + rotX = player->upperLimbRot.x; + if ((player->transformation == PLAYER_FORM_DEKU) && (player->stateFlags3 & PLAYER_STATE3_40)) { + if (player->heldActor != NULL) { + rotX += (s16)(((EnArrow*)(player->heldActor))->bubble.unk_144 * -470.0f); + } + } + + Matrix_RotateXS(rotX, MTXMODE_APPLY); + if (player->upperLimbRot.z != 0) { + Matrix_RotateZS(player->upperLimbRot.z, MTXMODE_APPLY); + } + } else { + func_80125500(play, player, limbIndex, pos, rot); + } + } + + return false; +} + +void func_80125CE0(Player* player, struct_80124618* arg1, Vec3f* pos, Vec3s* rot) { + Matrix_TranslateRotateZYX(pos, rot); + func_80125318(pos, rot); + func_80124618(arg1, player->skelAnime.curFrame, player->unk_AF0); + Matrix_Scale(player->unk_AF0[0].x, player->unk_AF0[0].y, player->unk_AF0[0].z, MTXMODE_APPLY); +} + +s32 Player_OverrideLimbDrawGameplayDefault(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* actor) { + Player* player = (Player*)actor; + + if (!Player_OverrideLimbDrawGameplayCommon(play, limbIndex, dList, pos, rot, &player->actor)) { + if (limbIndex == PLAYER_LIMB_LEFT_HAND) { + Gfx** leftHandDLists = player->leftHandDLists; + EquipValueSword swordEquipValue; + + if (player->stateFlags3 & PLAYER_STATE3_2000) { + rot->z -= player->unk_B8C; + } else if ((sPlayerLeftHandType == PLAYER_MODELTYPE_LH_4) && + (player->stateFlags1 & PLAYER_STATE1_2000000)) { + leftHandDLists = &gPlayerLeftHandOpenDLs[D_801F59E0]; + sPlayerLeftHandType = PLAYER_MODELTYPE_LH_OPEN; + } else if ((player->leftHandType == PLAYER_MODELTYPE_LH_OPEN) && (player->actor.speed > 2.0f) && + !(player->stateFlags1 & PLAYER_STATE1_8000000)) { + leftHandDLists = &gPlayerLeftHandClosedDLs[D_801F59E0]; + sPlayerLeftHandType = PLAYER_MODELTYPE_LH_CLOSED; + } else if ((player->leftHandType == PLAYER_MODELTYPE_LH_ONE_HAND_SWORD) && + (player->transformation == PLAYER_FORM_HUMAN) && + ((swordEquipValue = GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD), + swordEquipValue != EQUIP_VALUE_SWORD_NONE))) { + leftHandDLists = &D_801C018C[2 * ((swordEquipValue - 1) ^ 0)]; + } else { + s32 handIndex = GET_LEFT_HAND_INDEX_FROM_JOINT_TABLE(player->skelAnime.jointTable); + + if (handIndex != 0) { + handIndex = (handIndex >> 12) - 1; + if (handIndex >= 2) { + handIndex = 0; + } + leftHandDLists = &D_801C095C[handIndex][D_801F59E0]; + } + } + + *dList = leftHandDLists[sPlayerLod]; + + if (player->transformation == PLAYER_FORM_GORON) { + if (player->skelAnime.animation == &gPlayerAnim_pg_punchA) { + func_80125CE0(player, D_801C0750, pos, rot); + } + } else if (player->transformation == PLAYER_FORM_ZORA) { + if ((player->stateFlags1 & PLAYER_STATE1_2) || (player->stateFlags1 & PLAYER_STATE1_400) || + func_801242B4(player)) { + *dList = gLinkZoraLeftHandOpenDL; + } else { + s32 phi_a1 = (player->skelAnime.animation == &gPlayerAnim_pz_gakkistart) && + (player->skelAnime.curFrame >= 6.0f); + + if (phi_a1 || (player->skelAnime.animation == &gPlayerAnim_pz_gakkiplay)) { + *dList = object_link_zora_DL_00E2A0; + func_80125CE0(player, phi_a1 ? D_801C0538 : D_801C0560, pos, rot); + } + } + } + } else if (limbIndex == PLAYER_LIMB_RIGHT_HAND) { + if ((player->transformation == PLAYER_FORM_ZORA) && + (((player->stateFlags1 & PLAYER_STATE1_2)) || (player->stateFlags1 & PLAYER_STATE1_400) || + func_801242B4(player))) { + *dList = gLinkZoraRightHandOpenDL; + } else { + Gfx** rightHandDLists = player->rightHandDLists; + + if (player->stateFlags3 & PLAYER_STATE3_2000) { + rot->z -= player->unk_B8C; + } + + if (sPlayerRightHandType == PLAYER_MODELTYPE_RH_SHIELD) { + if (player->transformation == PLAYER_FORM_HUMAN) { + if (player->currentShield != PLAYER_SHIELD_NONE) { + //! FAKE + rightHandDLists = &gPlayerHandHoldingShields[2 * ((player->currentShield - 1) ^ 0)]; + } + } + } else if ((player->rightHandType == PLAYER_MODELTYPE_RH_OPEN) && (player->actor.speed > 2.0f) && + (!(player->stateFlags1 & PLAYER_STATE1_8000000))) { + rightHandDLists = &gPlayerRightHandClosedDLs[D_801F59E0]; + sPlayerRightHandType = PLAYER_MODELTYPE_RH_CLOSED; + } else { + s32 handIndex = GET_RIGHT_HAND_INDEX_FROM_JOINT_TABLE(player->skelAnime.jointTable); + + if (handIndex != 0) { + handIndex = (handIndex >> 8) - 1; + rightHandDLists = &D_801C0964[handIndex][D_801F59E0]; + } + } + + *dList = rightHandDLists[sPlayerLod]; + if (player->skelAnime.animation == &gPlayerAnim_pg_punchB) { + func_80125CE0(player, D_801C0784, pos, rot); + } + } + } else if (limbIndex == PLAYER_LIMB_SHEATH) { + Gfx** sheathDLists = player->sheathDLists; + + if (player->transformation == PLAYER_FORM_HUMAN) { + EquipValueSword swordEquipValue = GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD); + + if (swordEquipValue != EQUIP_VALUE_SWORD_NONE) { + if ((player->sheathType == PLAYER_MODELTYPE_SHEATH_14) || + (player->sheathType == PLAYER_MODELTYPE_SHEATH_12)) { + sheathDLists = &gPlayerSheathedSwords[2 * ((swordEquipValue - 1) ^ 0)]; + } else { + sheathDLists = &gPlayerSwordSheaths[2 * ((swordEquipValue - 1) ^ 0)]; + } + } + } + + *dList = sheathDLists[sPlayerLod]; + } else if (limbIndex == PLAYER_LIMB_WAIST) { + *dList = player->waistDLists[sPlayerLod]; + } else if (limbIndex == PLAYER_LIMB_HAT) { + if (player->transformation == PLAYER_FORM_ZORA) { + Matrix_Scale((player->unk_B10[0] * 1) + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + } + } + } + + return false; +} + +s32 Player_OverrideLimbDrawGameplayFirstPerson(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* actor) { + Player* player = (Player*)actor; + + if (!Player_OverrideLimbDrawGameplayCommon(play, limbIndex, dList, pos, rot, actor)) { + if (player->unk_AA5 != 3) { + *dList = NULL; + } else if (limbIndex == PLAYER_LIMB_LEFT_FOREARM) { + *dList = sPlayerFirstPersonLeftForearmDLs[player->transformation]; + } else if (limbIndex == PLAYER_LIMB_LEFT_HAND) { + *dList = sPlayerFirstPersonLeftHandDLs[player->transformation]; + } else if (limbIndex == PLAYER_LIMB_RIGHT_SHOULDER) { + *dList = sPlayerFirstPersonRightShoulderDLs[player->transformation]; + } else if (limbIndex == PLAYER_LIMB_RIGHT_HAND) { + if (Player_IsHoldingHookshot(player)) { + *dList = sPlayerFirstPersonRightHandHookshotDLs[player->transformation]; + } else { + *dList = sPlayerFirstPersonRightHandDLs[player->transformation]; + } + } else { + *dList = NULL; + } + } + + return false; +} + +// Unused remnant of OoT +s32 Player_OverrideLimbDrawGameplayCrawling(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + Player* player = (Player*)thisx; + + if (!Player_OverrideLimbDrawGameplayCommon(play, limbIndex, dList, pos, rot, thisx)) { *dList = NULL; } return false; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80126440.s") +s32 func_80126440(PlayState* play, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* newTip, Vec3f* newBase) { + if (!weaponInfo->active) { + if (collider != NULL) { + Collider_ResetQuadAT(play, &collider->base); + } + Math_Vec3f_Copy(&weaponInfo->tip, newTip); + Math_Vec3f_Copy(&weaponInfo->base, newBase); + weaponInfo->active = true; -u8 D_801C096C[PLAYER_SHIELD_MAX] = { - COLTYPE_METAL, - COLTYPE_METAL, - COLTYPE_METAL, + return true; + } + + if ((weaponInfo->tip.x == newTip->x) && (weaponInfo->tip.y == newTip->y) && (weaponInfo->tip.z == newTip->z)) { + if ((weaponInfo->base.x == newBase->x) && (weaponInfo->base.y == newBase->y) && + (weaponInfo->base.z == newBase->z)) { + if (collider != NULL) { + Collider_ResetQuadAT(play, &collider->base); + } + + return false; + } + } + + if (collider != NULL) { + Collider_SetQuadVertices(collider, newBase, newTip, &weaponInfo->base, &weaponInfo->tip); + CollisionCheck_SetAT(play, &play->colChkCtx, &collider->base); + } + + Math_Vec3f_Copy(&weaponInfo->base, newBase); + Math_Vec3f_Copy(&weaponInfo->tip, newTip); + weaponInfo->active = true; + + return true; +} + +u8 sPlayerShieldCollisionTypes[PLAYER_SHIELD_MAX] = { + COLTYPE_METAL, // PLAYER_SHIELD_NONE + COLTYPE_METAL, // PLAYER_SHIELD_HEROS_SHIELD + COLTYPE_METAL, // PLAYER_SHIELD_MIRROR_SHIELD }; -void func_801265C8(PlayState* play, Player* player, ColliderQuad* collider, Vec3f arg3[4]) { +void Player_UpdateShieldCollider(PlayState* play, Player* player, ColliderQuad* collider, Vec3f quadSrc[4]) { if (player->stateFlags1 & PLAYER_STATE1_400000) { - Vec3f sp4C; - Vec3f sp40; - Vec3f sp34; - Vec3f sp28; + Vec3f quadDest[4]; - player->shieldQuad.base.colType = D_801C096C[player->currentShield]; - Matrix_MultVec3f(&arg3[0], &sp28); - Matrix_MultVec3f(&arg3[1], &sp34); - Matrix_MultVec3f(&arg3[2], &sp40); - Matrix_MultVec3f(&arg3[3], &sp4C); - Collider_SetQuadVertices(collider, &sp28, &sp34, &sp40, &sp4C); + player->shieldQuad.base.colType = sPlayerShieldCollisionTypes[player->currentShield]; + Matrix_MultVec3f(&quadSrc[0], &quadDest[0]); + Matrix_MultVec3f(&quadSrc[1], &quadDest[1]); + Matrix_MultVec3f(&quadSrc[2], &quadDest[2]); + Matrix_MultVec3f(&quadSrc[3], &quadDest[3]); + Collider_SetQuadVertices(collider, &quadDest[0], &quadDest[1], &quadDest[2], &quadDest[3]); CollisionCheck_SetAC(play, &play->colChkCtx, &collider->base); CollisionCheck_SetAT(play, &play->colChkCtx, &collider->base); } @@ -1946,47 +2505,73 @@ Gfx* D_801C0B14[] = { }; u8 D_801C0B1C[] = { - 0x0C, - 0x0F, + PLAYER_BODYPART_LEFT_HAND, + PLAYER_BODYPART_RIGHT_HAND, }; Gfx* D_801C0B20[] = { - object_mask_truth_DL_0001A0, - object_mask_kerfay_DL_000D40, - object_mask_yofukasi_DL_000490, - object_mask_rabit_DL_000610, - object_mask_ki_tan_DL_0004A0, - object_mask_json_DL_0004C0, - object_mask_romerny_DL_0007A0, - object_mask_zacho_DL_000700, - object_mask_posthat_DL_000290, - object_mask_meoto_DL_0005A0, - object_mask_bigelf_DL_0016F0, - object_mask_gibudo_DL_000250, - gDonGeroMaskDL, - object_mask_dancer_DL_000EF0, - object_mask_skj_DL_0009F0, - object_mask_stone_DL_000820, - object_mask_bree_DL_0003C0, - object_mask_bakuretu_DL_0005C0, - object_mask_bu_san_DL_000710, - object_mask_kyojin_DL_000380, - gameplay_keep_DL_00B260, - gameplay_keep_DL_005A10, - gameplay_keep_DL_005360, - gDekuMaskDL, + object_mask_truth_DL_0001A0, // PLAYER_MASK_TRUTH + object_mask_kerfay_DL_000D40, // PLAYER_MASK_KAFEIS_MASK + object_mask_yofukasi_DL_000490, // PLAYER_MASK_ALL_NIGHT + object_mask_rabit_DL_000610, // PLAYER_MASK_BUNNY + object_mask_ki_tan_DL_0004A0, // PLAYER_MASK_KEATON + object_mask_json_DL_0004C0, // PLAYER_MASK_GARO + object_mask_romerny_DL_0007A0, // PLAYER_MASK_ROMANI + object_mask_zacho_DL_000700, // PLAYER_MASK_CIRCUS_LEADER + object_mask_posthat_DL_000290, // PLAYER_MASK_POSTMAN + object_mask_meoto_DL_0005A0, // PLAYER_MASK_COUPLE + object_mask_bigelf_DL_0016F0, // PLAYER_MASK_GREAT_FAIRY + object_mask_gibudo_DL_000250, // PLAYER_MASK_GIBDO + gDonGeroMaskDL, // PLAYER_MASK_DON_GERO + object_mask_dancer_DL_000EF0, // PLAYER_MASK_KAMARO + object_mask_skj_DL_0009F0, // PLAYER_MASK_CAPTAIN + object_mask_stone_DL_000820, // PLAYER_MASK_STONE + object_mask_bree_DL_0003C0, // PLAYER_MASK_BREMEN + object_mask_bakuretu_DL_0005C0, // PLAYER_MASK_BLAST + object_mask_bu_san_DL_000710, // PLAYER_MASK_SCENTS + object_mask_kyojin_DL_000380, // PLAYER_MASK_GIANT + gameplay_keep_DL_00B260, // PLAYER_MASK_FIERCE_DEITY + gameplay_keep_DL_005A10, // PLAYER_MASK_GORON + gameplay_keep_DL_005360, // PLAYER_MASK_ZORA + gDekuMaskDL, // PLAYER_MASK_DEKU object_mask_boy_DL_000900, object_mask_goron_DL_0014A0, object_mask_zora_DL_000DB0, object_mask_nuts_DL_001D90, }; -Vec3f D_801C0B90[] = { +Vec3f D_801C0B90[D_801F59B0_LEN] = { { 950.0f, -800.0f, 300.0f }, { 950.0f, -800.0f, -300.0f }, }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012669C.s") +void func_8012669C(PlayState* play, Player* player, Vec3f* arg2, Vec3f* arg3) { + Vec3f sp3C; + Vec3f sp30; + + Matrix_MultVec3f(arg2, &sp3C); + Matrix_MultVec3f(arg3, &sp30); + + if (player->meleeWeaponState != 0) { + if (func_80126440(play, NULL, &player->meleeWeaponInfo[0], &sp3C, &sp30) && + (player->transformation != PLAYER_FORM_GORON) && (!(player->stateFlags1 & PLAYER_STATE1_400000))) { + EffectBlure_AddVertex(Effect_GetByIndex(player->meleeWeaponEffectIndex[0]), &player->meleeWeaponInfo[0].tip, + &player->meleeWeaponInfo[0].base); + } + if ((player->meleeWeaponState > 0) && ((player->meleeWeaponAnimation < PLAYER_MWA_SPIN_ATTACK_1H) || + (player->stateFlags2 & PLAYER_STATE2_20000))) { + Matrix_MultVec3f(&arg2[1], &sp3C); + Matrix_MultVec3f(&arg3[1], &sp30); + func_80126440(play, &player->meleeWeaponQuads[0], &player->meleeWeaponInfo[1], &sp3C, &sp30); + Matrix_MultVec3f(&arg2[2], &sp3C); + Matrix_MultVec3f(&arg3[2], &sp30); + func_80126440(play, &player->meleeWeaponQuads[1], &player->meleeWeaponInfo[2], &sp3C, &sp30); + } + } else { + Math_Vec3f_Copy(&player->meleeWeaponInfo[0].tip, &sp3C); + Math_Vec3f_Copy(&player->meleeWeaponInfo[0].base, &sp30); + } +} void Player_DrawGetItemImpl(PlayState* play, Player* player, Vec3f* refPos, s32 drawIdPlusOne) { f32 sp34; @@ -2035,21 +2620,203 @@ void Player_DrawGetItem(PlayState* play, Player* player) { refPos.y = player->actor.world.pos.y + 28.0f; } } else { - Math_Vec3f_Copy(&refPos, &D_801F59E8); + Math_Vec3f_Copy(&refPos, &sPlayerGetItemRefPos); } - drawIdPlusOne = ABS_ALT(player->getItemDrawId); + drawIdPlusOne = ABS_ALT(player->getItemDrawIdPlusOne); Player_DrawGetItemImpl(play, player, &refPos, drawIdPlusOne); } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80126AB4.s") +void func_80126AB4(Player* player, Vec3f** arg1) { + if ((player->transformation == PLAYER_FORM_GORON) || (player->actor.id == ACTOR_EN_TEST3)) { + Math_Vec3f_Copy(&player->unk_AF0[1], &player->meleeWeaponInfo[0].base); + *arg1 = D_801C09B8; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80126B8C.s") + D_801C0994[1].x = D_801C0994[0].x; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80126BD0.s") + if (player->unk_ADD >= 3) { + player->unk_ADD++; + D_801C0994[1].x *= 1.0f + ((9 - player->unk_ADD) * 0.1f); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801271B0.s") + D_801C0994[1].x += 1200.0f; + D_801C0994[2].x = D_801C0994[1].x; + *arg1 = D_801C0994; +} + +void func_80126B8C(PlayState* play, Player* player) { + Vec3f* sp1C; + + func_80126AB4(player, &sp1C); + func_8012669C(play, player, sp1C, D_801C0970); +} + +// Zora boomerangs (?) +void func_80126BD0(PlayState* play, Player* player, s32 arg2) { + if ((player->transformation != PLAYER_FORM_ZORA) || (player->rightHandType == PLAYER_MODELTYPE_RH_HOOKSHOT)) { + return; + } + + if ((arg2 != 0) && (player->stateFlags1 & PLAYER_STATE1_400000)) { + OPEN_DISPS(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_link_zora_DL_0110A8); + + CLOSE_DISPS(play->state.gfxCtx); + } else { + Actor* boomerangActor = player->boomerangActor; + Vec3f sp58; + Vec3f sp4C; + + if (player->stateFlags1 & PLAYER_STATE1_2000000) { + if (player->boomerangActor == NULL) { + return; + } + if ((player->boomerangActor->params == arg2) || + (((boomerangActor->child != NULL)) && (boomerangActor->child->params == arg2))) { + return; + } + } + + OPEN_DISPS(play->state.gfxCtx); + + if ((player->skelAnime.animation != &gPlayerAnim_pz_gakkiplay) && + (player->skelAnime.animation != &gPlayerAnim_pz_fishswim)) { + if (player->skelAnime.animation == &gPlayerAnim_pz_gakkistart) { + func_80124618(D_801C0580, player->skelAnime.curFrame, player->unk_AF0); + } else if (player->skelAnime.animation == &gPlayerAnim_pz_waterroll) { + func_80124618(D_801C05A8, player->skelAnime.curFrame, player->unk_AF0); + } else if (player->skelAnime.animation == &gPlayerAnim_pz_swimtowait) { + func_80124618(D_801C05D8, player->skelAnime.curFrame, player->unk_AF0); + } else if (player->skelAnime.animation == &gPlayerAnim_pz_bladeon) { + func_80124618(D_801C07F0, player->skelAnime.curFrame, player->unk_AF0); + } else if (player->skelAnime.animation == &gPlayerAnim_pz_jumpAT) { + func_80124618(D_801C0820, player->skelAnime.curFrame, player->unk_AF0); + } else if (player->skelAnime.animation == &gPlayerAnim_pz_jumpATend) { + func_80124618(D_801C0838, player->skelAnime.curFrame, player->unk_AF0); + } else if (player->heldItemAction == PLAYER_IA_ZORA_FINS) { + player->unk_AF0[0].x = 1.0f; + player->unk_AF0[0].y = 1.0f; + player->unk_AF0[0].z = 1.0f; + } else { + player->unk_AF0[0].x = 0.4f; + player->unk_AF0[0].y = 0.6f; + player->unk_AF0[0].z = 0.7f; + } + Matrix_Push(); + + Matrix_Scale(player->unk_AF0[0].x, player->unk_AF0[0].y, player->unk_AF0[0].z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, D_801C0AB4[arg2]); + + if (player->meleeWeaponState != 0) { + if ((((player->meleeWeaponAnimation == PLAYER_MWA_ZORA_PUNCH_LEFT)) && (arg2 == 0)) || + ((player->meleeWeaponAnimation == PLAYER_MWA_ZORA_PUNCH_COMBO) && (arg2 != 0))) { + func_8012669C(play, player, D_801C0A00, D_801C09DC); + } + } + + Matrix_Pop(); + } + + if (player->skelAnime.animation == &gPlayerAnim_pz_waterroll) { + func_80124618(D_801C05C8, player->skelAnime.curFrame, player->unk_AF0); + D_801C05F0[0].unk_2.x = 50; + D_801C05F0[0].unk_2.y = 50; + D_801C05F0[0].unk_2.z = 50; + D_801C05F0[1].unk_2 = D_801C05F0[0].unk_2; + } else if (player->skelAnime.animation == &gPlayerAnim_pz_swimtowait) { + func_80124618(D_801C05F0, player->skelAnime.curFrame, player->unk_AF0); + } else if (player->skelAnime.animation == &gPlayerAnim_pz_fishswim) { + player->unk_AF0[0].x = (ABS_ALT(player->unk_B8A) * 0.00003f) + 0.5f; + player->unk_AF0[0].y = player->unk_AF0[0].x; + player->unk_AF0[0].z = player->unk_AF0[0].x; + + D_801C05F0[0].unk_2.x = (player->unk_AF0[0].x * 100.0f); + + D_801C05F0[0].unk_2.y = D_801C05F0[0].unk_2.x; + D_801C05F0[0].unk_2.z = D_801C05F0[0].unk_2.x; + + D_801C05F0[1].unk_2 = D_801C05F0[0].unk_2; + } else { + //! @bug Skips CLOSE_DISPS + return; + } + + Matrix_Push(); + Matrix_Scale(player->unk_AF0[0].x, player->unk_AF0[0].y, player->unk_AF0[0].z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_801C0ABC[arg2]); + + Matrix_MultVec3f(&D_801C0AC4[arg2], &sp58); + Matrix_MultVec3f(&D_801C0ADC[arg2], &sp4C); + + if (func_80126440(play, NULL, &player->meleeWeaponInfo[arg2], &sp58, &sp4C) && + (player->stateFlags1 & PLAYER_STATE1_8000000)) { + EffectBlure_AddVertex(Effect_GetByIndex(player->meleeWeaponEffectIndex[arg2]), + &player->meleeWeaponInfo[arg2].tip, &player->meleeWeaponInfo[arg2].base); + } + Matrix_Pop(); + + CLOSE_DISPS(play->state.gfxCtx); + } +} + +s32 func_801271B0(PlayState* play, Player* player, s32 arg2) { + if (player->transformation == PLAYER_FORM_DEKU) { + if (((player->skelAnime.animation == &gPlayerAnim_pn_kakku)) || + (player->skelAnime.animation == &gPlayerAnim_pn_kakkufinish) || + (player->skelAnime.animation == &gPlayerAnim_pn_rakkafinish) || + (player->skelAnime.animation == &gPlayerAnim_pn_batabata)) { + struct_80124618** sp3C = D_801C0AF4; + + OPEN_DISPS(play->state.gfxCtx); + + if (player->skelAnime.animation == &gPlayerAnim_pn_kakkufinish) { + sp3C = D_801C0AFC; + } else if (player->skelAnime.animation == &gPlayerAnim_pn_batabata) { + sp3C = D_801C0B0C; + } else if (player->skelAnime.animation == &gPlayerAnim_pn_rakkafinish) { + sp3C = D_801C0B04; + } + + Matrix_Push(); + Matrix_Translate(0.0f, 150.0f, 0.0f, MTXMODE_APPLY); + func_80124618(sp3C[0], player->skelAnime.curFrame, &player->unk_AF0[1]); + Matrix_Scale(player->unk_AF0[1].x, player->unk_AF0[1].y, player->unk_AF0[1].z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, D_801C0B14[arg2]); + + Matrix_Translate(2150.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(player->unk_B8A, MTXMODE_APPLY); + func_80124618(sp3C[1], player->skelAnime.curFrame, &player->unk_AF0[1]); + Matrix_Scale(player->unk_AF0[1].x, player->unk_AF0[1].y, player->unk_AF0[1].z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + // Close flower / Open flower + gSPDisplayList(POLY_OPA_DISP++, + player->actor.velocity.y < -6.0f ? gLinkDekuClosedFlowerDL : gLinkDekuOpenFlowerDL); + + Matrix_MultZero(&player->bodyPartsPos[D_801C0B1C[arg2]]); + Matrix_Pop(); + + CLOSE_DISPS(play->state.gfxCtx); + + return true; + } + } + + return false; +} // Player_SetMaskSegment? s32 func_80127438(PlayState* play, Player* player, s32 currentMask) { @@ -2083,7 +2850,7 @@ void Player_DrawCouplesMask(PlayState* play, Player* player) { AnimatedMat_DrawOpa(play, Lib_SegmentedToVirtual(&object_mask_meoto_Matanimheader_001CD8)); } -void Player_DrawCircusLeadersMask(PlayState* play, Actor* actor) { +void Player_DrawCircusLeadersMask(PlayState* play, Player* player) { static Vec3f bubbleVelocity = { 0.0f, 0.0f, 0.0f }; static Vec3f bubbleAccel = { 0.0f, 0.0f, 0.0f }; Gfx* gfx; @@ -2093,7 +2860,7 @@ void Player_DrawCircusLeadersMask(PlayState* play, Actor* actor) { gfx = POLY_XLU_DISP; - for (i = 0; i < ARRAY_COUNT(D_801C0B90); i++) { + for (i = 0; i < D_801F59B0_LEN; i++) { f32 scaleY = (D_801F59C8[i] / 400.0f) * 0.1f; Matrix_MultVec3f(&D_801C0B90[i], &D_801F59B0[i]); @@ -2103,7 +2870,7 @@ void Player_DrawCircusLeadersMask(PlayState* play, Actor* actor) { D_801F59B0[i].y += -10.0f * scaleY; - if (D_801F59C8[i] < 0x190) { + if (D_801F59C8[i] < 400) { f32 scaleXZ = CLAMP_MAX(scaleY, 0.05f); Matrix_Push(); @@ -2121,12 +2888,11 @@ void Player_DrawCircusLeadersMask(PlayState* play, Actor* actor) { gfx = &gfx[6]; } else { - Player* player = (Player*)actor; - f32 temp_f0 = sqrtf(SQ(player->actor.velocity.x) + SQ(player->actor.velocity.z)); - s16 phi_s0 = temp_f0 * 2000.0f; + f32 speedXZ = sqrtf(SQ(player->actor.velocity.x) + SQ(player->actor.velocity.z)); + s16 phi_s0 = speedXZ * 2000.0f; f32 temp_f20; - bubbleVelocity.y = temp_f0 * 0.4f; + bubbleVelocity.y = speedXZ * 0.4f; bubbleAccel.y = -0.3f; if (phi_s0 > 0x3E80) { @@ -2134,17 +2900,14 @@ void Player_DrawCircusLeadersMask(PlayState* play, Actor* actor) { } phi_s0 = player->actor.focus.rot.y + ((i != 0) ? phi_s0 : -phi_s0); - temp_f20 = temp_f0 * 0.2f; - - if (temp_f20 > 4.0f) { - temp_f20 = 4.0f; - } + temp_f20 = speedXZ * 0.2f; + temp_f20 = CLAMP_MAX(temp_f20, 4.0f); bubbleVelocity.x = -Math_SinS(phi_s0) * temp_f20; bubbleVelocity.z = -Math_CosS(phi_s0) * temp_f20; EffectSsDtBubble_SpawnColorProfile(play, &D_801F59B0[i], &bubbleVelocity, &bubbleAccel, 20, 20, 3, 0); - D_801F59C8[i] -= 0x190; + D_801F59C8[i] -= 400; } } @@ -2168,15 +2931,15 @@ void Player_DrawBlastMask(PlayState* play, Player* player) { OPEN_DISPS(play->state.gfxCtx); - if (player->unk_B60 != 0) { + if (player->blastMaskTimer != 0) { s32 alpha; gSegments[0xA] = VIRTUAL_TO_PHYSICAL(player->maskObjectSegment); AnimatedMat_DrawOpa(play, Lib_SegmentedToVirtual(&object_mask_bakuretu_Matanimheader_0011F8)); - if (player->unk_B60 < 11) { - alpha = (player->unk_B60 / 10.0f) * 255; + if (player->blastMaskTimer <= 10) { + alpha = (player->blastMaskTimer / 10.0f) * 255; } else { alpha = 255; } @@ -2211,7 +2974,7 @@ Vec3f D_801C0C30[] = { { 301.0f, -729.0f, 699.0f }, }; -typedef struct { +typedef struct struct_80128388_arg1 { /* 0x00 */ f32 unk_00; /* 0x04 */ s16 unk_04; /* 0x06 */ s16 unk_06; @@ -2227,91 +2990,237 @@ struct_80128388_arg1 D_801C0C54[] = { { 30.0f, 0x0000, 0x0000, { 0.0f, 0.0f, 0.0f }, 20.0f, 0x1F40, 0x2EE0 }, }; -Color_RGB8 D_801C0CA8[] = { - { 255, 255, 255 }, { 80, 80, 255 }, { 136, 192, 255 }, { 136, 192, 255 }, { 184, 232, 232 }, { 248, 200, 0 }, - { 255, 180, 0 }, { 0, 128, 0 }, { 252, 238, 0 }, { 131, 0, 174 }, { 64, 64, 32 }, { 0, 0, 255 }, - { 255, 0, 255 }, { 255, 0, 255 }, { 255, 0, 0 }, { 0, 0, 255 }, { 0, 200, 0 }, { 255, 255, 255 }, - { 255, 255, 255 }, { 255, 255, 255 }, { 80, 80, 255 }, +Color_RGB8 sPlayerBottleColors[PLAYER_BOTTLE_MAX] = { + { 255, 255, 255 }, // PLAYER_BOTTLE_EMPTY + { 80, 80, 255 }, // PLAYER_BOTTLE_FISH + { 136, 192, 255 }, // PLAYER_BOTTLE_SPRING_WATER + { 136, 192, 255 }, // PLAYER_BOTTLE_HOT_SPRING_WATER + { 184, 232, 232 }, // PLAYER_BOTTLE_ZORA_EGG + { 248, 200, 0 }, // PLAYER_BOTTLE_DEKU_PRINCESS + { 255, 180, 0 }, // PLAYER_BOTTLE_GOLD_DUST + { 0, 128, 0 }, // PLAYER_BOTTLE_1C + { 252, 238, 0 }, // PLAYER_BOTTLE_SEAHORSE + { 131, 0, 174 }, // PLAYER_BOTTLE_MUSHROOM + { 64, 64, 32 }, // PLAYER_BOTTLE_HYLIAN_LOACH + { 0, 0, 255 }, // PLAYER_BOTTLE_BUG + { 255, 0, 255 }, // PLAYER_BOTTLE_POE + { 255, 0, 255 }, // PLAYER_BOTTLE_BIG_POE + { 255, 0, 0 }, // PLAYER_BOTTLE_POTION_RED + { 0, 0, 255 }, // PLAYER_BOTTLE_POTION_BLUE + { 0, 200, 0 }, // PLAYER_BOTTLE_POTION_GREEN + { 255, 255, 255 }, // PLAYER_BOTTLE_MILK + { 255, 255, 255 }, // PLAYER_BOTTLE_MILK_HALF + { 255, 255, 255 }, // PLAYER_BOTTLE_CHATEAU + { 80, 80, 255 }, // PLAYER_BOTTLE_FAIRY }; Vec3f D_801C0CE8[PLAYER_FORM_MAX] = { - { 0.0f, 0.0f, 0.0f }, { 300.0f, 300.0f, -230.0f }, { 0.0f, 90.0f, -50.0f }, - { 0.0f, 20.0f, -60.0f }, { 0.0f, 0.0f, 0.0f }, -}; -Vec3f D_801C0D24[PLAYER_FORM_MAX] = { - { 200.0f, 300.0f, 0.0f }, { 200.0f, 200.0f, 0.0f }, { 200.0f, 300.0f, 0.0f }, - { 200.0f, 150.0f, 0.0f }, { 200.0f, 200.0f, 0.0f }, -}; -Vec3f D_801C0D60 = { 398.0f, 1419.0f, 244.0f }; -Vec3f D_801C0D6C = { 420.0f, 1210.0f, 380.0f }; - -f32 D_801C0D78[] = { - 0.0f, // Player is not holding a melee weapon - 3000.0f, // PLAYER_IA_SWORD_KOKIRI - 3000.0f, // PLAYER_IA_SWORD_RAZOR - 4000.0f, // PLAYER_IA_SWORD_GILDED - 5500.0f, // PLAYER_IA_SWORD_GREAT_FAIRY - -1.0f, // PLAYER_IA_STICK - 2500.0f, // PLAYER_IA_ZORA_FINS + { 0.0f, 0.0f, 0.0f }, // PLAYER_FORM_FIERCE_DEITY + { 300.0f, 300.0f, -230.0f }, // PLAYER_FORM_GORON + { 0.0f, 90.0f, -50.0f }, // PLAYER_FORM_ZORA + { 0.0f, 20.0f, -60.0f }, // PLAYER_FORM_DEKU + { 0.0f, 0.0f, 0.0f }, // PLAYER_FORM_HUMAN }; -Gfx* D_801C0D94 = object_link_child_DL_017818; +void Player_DrawBunnyHood(PlayState* play) { + Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Mtx)); + Vec3s earRot; -f32 D_801C0D98 = -35.0f; + OPEN_DISPS(play->state.gfxCtx); -f32 D_801C0D9C = -395.0f; -f32 D_801C0DA0 = 0.0f; + gSPSegment(POLY_OPA_DISP++, 0x0B, mtx); -f32 D_801C0DA4 = 0.0f; + Matrix_Push(); -Vec3f D_801C0DA8[4] = { - { -4500.0f, -3000.0f, -600.0f }, - { 1500.0f, -3000.0f, -600.0f }, - { -4500.0f, 3000.0f, -600.0f }, - { 1500.0f, 3000.0f, -600.0f }, -}; + earRot.x = sBunnyEarKinematics.rot.y + 0x3E2; + earRot.y = sBunnyEarKinematics.rot.z + 0xDBE; + earRot.z = sBunnyEarKinematics.rot.x - 0x348A; + Matrix_SetTranslateRotateYXZ(97.0f, -1203.0f, -240.0f, &earRot); -Vec3f D_801C0DD8 = { 50.0f, 800.0f, 0.0f }; -Vec3f D_801C0DE4 = { 50.0f, 850.0f, 0.0f }; -Gfx* D_801C0DF0[] = { - object_link_goron_DL_010590, object_link_goron_DL_010368, object_link_goron_DL_010140, - object_link_goron_DL_00FF18, object_link_goron_DL_00FCF0, -}; + Matrix_ToMtx(mtx++); -Vec2f D_801C0E04[PLAYER_FORM_MAX] = { - { 140.0f, -130.0f }, { 0.0f, -200.0f }, { -160.0f, 0.0f }, { 220.0f, -200.0f }, { 0.0f, 0.0f }, -}; + earRot.x = sBunnyEarKinematics.rot.y - 0x3E2; + earRot.y = -sBunnyEarKinematics.rot.z - 0xDBE; + earRot.z = sBunnyEarKinematics.rot.x - 0x348A; + Matrix_SetTranslateRotateYXZ(97.0f, -1203.0f, 240.0f, &earRot); -Gfx* D_801C0E2C[] = { - object_link_nuts_DL_007A28, object_link_nuts_DL_0077D0, object_link_nuts_DL_007548, - object_link_nuts_DL_007900, object_link_nuts_DL_0076A0, -}; -Vec3f D_801C0E40[PLAYER_FORM_MAX] = { - { 0.0f, 0.0f, 0.0f }, { -578.3f, -1100.9f, 0.0f }, { -189.5f, -594.87f, 0.0f }, - { -570.0f, -812.0f, 0.0f }, { -230.0f, -520.0f, 0.0f }, -}; -Vec3f D_801C0E7C = { 1100.0f, -700.0f, 0.0f }; + Matrix_ToMtx(mtx); -// unused -Vec3f D_801C0E88 = { 1600.0f, -1700.0f, -70.0f }; + Matrix_Pop(); -Vec3f D_801C0E94 = { 1800.0f, -300.0f, 0.0f }; -Vec3f D_801C0EA0 = { 1300.0f, -400.0f, 0.0f }; -Vec3f D_801C0EAC = { 630.0f, 100.0f, -30.0f }; -Vec3s D_801C0EB8 = { 0, 0, 0x7FFF }; + CLOSE_DISPS(play->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_DrawBunnyHood.s") +void func_80127B64(struct_801F58B0 arg0[], s32 count, Vec3f* arg2) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127B64.s") + for (i = 0; i < count; i++, arg0++) { + Math_Vec3f_Copy(&arg0->unk_00, arg2); + Math_Vec3f_Copy(&arg0->unk_0C, &gZeroVec3f); + arg0->unk_18 = 0; + arg0->unk_1A = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127BE8.s") +// Draws the Great Fairy's Mask particles when a stray fairy is in the room +void Player_DrawStrayFairyParticles(PlayState* play, Vec3f* arg1) { + Vec3f sp2C; + f32 sp28; + + D_801C0BE0.y = Rand_ZeroFloat(0.07f) + -0.1f; + D_801C0BEC.y = Rand_ZeroFloat(0.1f) + 0.04f; + if (Rand_ZeroOne() < 0.5f) { + sp28 = -1.0f; + } else { + sp28 = 1.0f; + } + + D_801C0BE0.x = (Rand_ZeroFloat(0.2f) + 0.1f) * sp28; + D_801C0BEC.x = 0.1f * sp28; + if (Rand_ZeroOne() < 0.5f) { + sp28 = -1.0f; + } else { + sp28 = 1.0f; + } + + D_801C0BE0.z = (Rand_ZeroFloat(0.2f) + 0.1f) * sp28; + D_801C0BEC.z = 0.1f * sp28; + sp2C.x = arg1->x; + sp2C.y = Rand_ZeroFloat(15.0f) + arg1->y; + sp2C.z = arg1->z; + EffectSsKirakira_SpawnDispersed(play, &sp2C, &D_801C0BE0, &D_801C0BEC, &D_801C0BF8, &D_801C0BFC, -50, 11); +} void func_80127DA4(PlayState* play, struct_801F58B0 arg1[], struct_80128388_arg1 arg2[], s32 arg3, Vec3f* arg4, - Vec3f* arg5, u32* arg6); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127DA4.s") + Vec3f* arg5, u32* arg6) { + struct_801F58B0* phi_s1 = &arg1[1]; + Vec3f spB0; + Vec3f spA4; + f32 f22; + f32 f28; + f32 f24; + f32 f20; + f32 f0; + f32 sp8C = -1.0f; + s32 i; + s16 s0; + s16 s2; -void func_80128388(struct_801F58B0 arg0[], struct_80128388_arg1 arg1[], s32 arg2, Mtx** arg3); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80128388.s") + Math_Vec3f_Copy(&arg1->unk_00, arg4); + Math_Vec3f_Diff(arg5, arg4, &spB0); + arg1->unk_18 = Math_Atan2S_XY(spB0.z, spB0.x); + arg1->unk_1A = Math_Atan2S_XY(sqrtf(SQXZ(spB0)), spB0.y); + i = 1; + arg2++; + + while (i < arg3) { + if (play->actorCtx.flags & ACTORCTX_FLAG_3) { + if (*arg6 & 0x20) { + sp8C = -0.2f; + } else { + sp8C = 0.2f; + } + + *arg6 += 0x16; + if (!(*arg6 & 1)) { + Player_DrawStrayFairyParticles(play, &phi_s1->unk_00); + } + } + Math_Vec3f_Sum(&phi_s1->unk_00, &phi_s1->unk_0C, &phi_s1->unk_00); + + f0 = Math_Vec3f_DistXYZAndStoreDiff(&arg1->unk_00, &phi_s1->unk_00, &spB0); + f28 = f0 - arg2->unk_00; + if (f0 == 0.0f) { + spB0.x = 0.0f; + spB0.y = arg2->unk_00; + spB0.z = 0.0f; + } + f20 = sqrtf(SQXZ(spB0)); + + if (f20 > 4.0f) { + phi_s1->unk_18 = Math_Atan2S_XY(spB0.z, spB0.x); + s2 = phi_s1->unk_18 - arg1->unk_18; + + if (ABS_ALT(s2) > 0x4000) { + phi_s1->unk_18 = (s16)(phi_s1->unk_18 + 0x8000); + f20 = -f20; + } + } + + phi_s1->unk_1A = Math_Atan2S_XY(f20, spB0.y); + + s2 = phi_s1->unk_18 - arg1->unk_18; + s2 = CLAMP(s2, -arg2->unk_18, arg2->unk_18); + phi_s1->unk_18 = arg1->unk_18 + s2; + + s0 = phi_s1->unk_1A - arg1->unk_1A; + s0 = CLAMP(s0, -arg2->unk_1A, arg2->unk_1A); + phi_s1->unk_1A = arg1->unk_1A + s0; + + f20 = Math_CosS(phi_s1->unk_1A) * arg2->unk_00; + spA4.x = Math_SinS(phi_s1->unk_18) * f20; + spA4.z = Math_CosS(phi_s1->unk_18) * f20; + spA4.y = Math_SinS(phi_s1->unk_1A) * arg2->unk_00; + Math_Vec3f_Sum(&arg1->unk_00, &spA4, &phi_s1->unk_00); + phi_s1->unk_0C.x *= 0.9f; + phi_s1->unk_0C.z *= 0.9f; + + f22 = Math_CosS(s0) * f28; + f24 = Math_SinS(s0) * f28; + phi_s1->unk_0C.y += sp8C; + + if (play->actorCtx.flags & ACTORCTX_FLAG_3) { + phi_s1->unk_0C.y = CLAMP(phi_s1->unk_0C.y, -0.8f, 0.8f); + } else { + phi_s1->unk_0C.y = phi_s1->unk_0C.y; + f20 = Math_SinS(arg1->unk_1A); + phi_s1->unk_0C.y += (((f22 * Math_CosS(arg1->unk_1A)) + (f24 * f20)) * 0.2f); + phi_s1->unk_0C.y = CLAMP(phi_s1->unk_0C.y, -2.0f, 4.0f); + } + + f20 = (f24 * Math_CosS(arg1->unk_1A)) - (Math_SinS(arg1->unk_1A) * f22); + f22 = Math_CosS(s2) * f20; + f24 = Math_SinS(s2) * f20; + + f20 = Math_SinS(arg1->unk_18); + + phi_s1->unk_0C.x += (((f24 * Math_CosS(arg1->unk_18)) - (f22 * f20)) * 0.1f); + phi_s1->unk_0C.x = CLAMP(phi_s1->unk_0C.x, -4.0f, 4.0f); + + f20 = Math_SinS(arg1->unk_18); + + phi_s1->unk_0C.z += (((f22 * Math_CosS(arg1->unk_18)) + (f24 * f20)) * -0.1f); + phi_s1->unk_0C.z = CLAMP(phi_s1->unk_0C.z, -4.0f, 4.0f); + + arg1++; + phi_s1++; + i++; + arg2++; + } +} + +void func_80128388(struct_801F58B0 arg0[], struct_80128388_arg1 arg1[], s32 arg2, Mtx** arg3) { + struct_801F58B0* phi_s1 = &arg0[1]; + Vec3f sp58; + Vec3s sp50; + s32 i; + + sp58.y = 0.0f; + sp58.z = 0.0f; + sp50.x = 0; + + for (i = 1; i < arg2; i++) { + sp58.x = arg1->unk_00 * 100.0f; + sp50.z = arg1->unk_06 + (s16)(phi_s1->unk_1A - arg0->unk_1A); + sp50.y = arg1->unk_04 + (s16)(phi_s1->unk_18 - arg0->unk_18); + Matrix_TranslateRotateZYX(&sp58, &sp50); + Matrix_ToMtx(*arg3); + (*arg3)++; + arg0++; + phi_s1++; + arg1++; + } +} void Player_DrawGreatFairysMask(PlayState* play, Player* player) { s32 pad; @@ -2328,7 +3237,8 @@ void Player_DrawGreatFairysMask(PlayState* play, Player* player) { gSPSegment(POLY_OPA_DISP++, 0x0B, mtx); Matrix_MultVec3f(&D_801C0C00, &D_801C0C54[1].unk_08); - Math_Vec3f_Lerp(&player->bodyPartsPos[7], &player->bodyPartsPos[0], 0.2f, &D_801C0C54[2].unk_08); + Math_Vec3f_Lerp(&player->bodyPartsPos[PLAYER_BODYPART_HEAD], &player->bodyPartsPos[PLAYER_BODYPART_WAIST], 0.2f, + &D_801C0C54[2].unk_08); for (i = 0; i < ARRAY_COUNT(D_801C0C0C); i++) { Matrix_MultVec3f(iter, &sp84); @@ -2348,8 +3258,598 @@ void Player_DrawGreatFairysMask(PlayState* play, Player* player) { CLOSE_DISPS(play->state.gfxCtx); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80128640.s") +s32 func_80128640(PlayState* play, Player* player, Gfx* dlist) { + s32 temp_v1 = player->skelAnime.animation == &gPlayerAnim_cl_maskoff; + f32 temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80128B74.s") + if (temp_v1 || + ((player->currentMask != PLAYER_MASK_NONE) && (player->skelAnime.animation == &gPlayerAnim_cl_setmask) && + (temp_f0 = player->skelAnime.curFrame - 8.0f, (temp_f0 >= 0.0f)) && (temp_f0 < 4.0f)) || + (player->stateFlags2 & PLAYER_STATE2_1000000)) { + s32 mask; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80128BD0.s") + if (temp_v1) { + mask = player->prevMask; + } else { + mask = player->currentMask; + } + + if (func_80127438(play, player, mask)) { + OPEN_DISPS(play->state.gfxCtx); + + Matrix_Push(); + Matrix_Translate(-323.67f, 412.15f, -969.96f, MTXMODE_APPLY); + Matrix_RotateZYX(-0x32BE, -0x50DE, -0x7717, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, D_801C0B20[mask - 1]); + + Matrix_Pop(); + + CLOSE_DISPS(play->state.gfxCtx); + } + + } else if (player->itemAction == PLAYER_IA_STICK) { + OPEN_DISPS(play->state.gfxCtx); + + Matrix_Push(); + Matrix_Translate(-428.26f, 267.2f, -33.82f, MTXMODE_APPLY); + Matrix_RotateZYX(-0x8000, 0, 0x4000, MTXMODE_APPLY); + Matrix_Scale(1.0f, player->unk_B08[1], 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDekuStickDL); + + Matrix_Pop(); + + CLOSE_DISPS(play->state.gfxCtx); + } else if (player->leftHandType == PLAYER_MODELTYPE_LH_BOTTLE) { + PlayerBottle bottle = Player_BottleFromIA(player, player->itemAction); + Vec3f* temp_v1_2 = &D_801C0CE8[player->transformation]; + + OPEN_DISPS(play->state.gfxCtx); + + Matrix_Push(); + Matrix_Translate(temp_v1_2->x, temp_v1_2->y, temp_v1_2->z, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + // Note this does not check for PLAYER_BOTTLE_NONE, which would produce an OoB access on sPlayerBottleColors. + // Under normal circunstances it should not be a problem because of the previous + // `player->leftHandType == PLAYER_MODELTYPE_LH_BOTTLE` check + if (bottle != PLAYER_BOTTLE_EMPTY) { + Color_RGB8* bottleColor = &sPlayerBottleColors[bottle]; + + gDPSetEnvColor(POLY_XLU_DISP++, bottleColor->r, bottleColor->g, bottleColor->b, 0); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_000320); + } + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0003E0); + + Matrix_Pop(); + + CLOSE_DISPS(play->state.gfxCtx); + } else if (dlist == object_link_zora_DL_00E2A0) { // zora guitar + s16 sp26 = Math_SinS(player->unk_B86[0]) * (ABS_ALT(player->upperLimbRot.x) * ((f32)(IREG(52) + 20)) / 100.0f); + s16 sp24 = Math_SinS(player->unk_B86[1]) * (ABS_ALT(player->upperLimbRot.y) * ((f32)(IREG(53) + 15)) / 100.0f); + + OPEN_DISPS(play->state.gfxCtx); + + Matrix_Push(); + Matrix_RotateXS(sp26, MTXMODE_APPLY); + Matrix_RotateYS(sp24, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_link_zora_DL_00E088); // hand + + Matrix_Pop(); + + CLOSE_DISPS(play->state.gfxCtx); + } else { + return false; + } + + return true; +} + +Vec3f sPlayerFootPos[PLAYER_FORM_MAX] = { + { 200.0f, 300.0f, 0.0f }, // PLAYER_FORM_FIERCE_DEITY + { 200.0f, 200.0f, 0.0f }, // PLAYER_FORM_GORON + { 200.0f, 300.0f, 0.0f }, // PLAYER_FORM_ZORA + { 200.0f, 150.0f, 0.0f }, // PLAYER_FORM_DEKU + { 200.0f, 200.0f, 0.0f }, // PLAYER_FORM_HUMAN +}; + +void Player_SetFeetPos(PlayState* play, Player* player, s32 limbIndex) { + Vec3f* footPos = &sPlayerFootPos[player->transformation]; + + Actor_SetFeetPos(&player->actor, limbIndex, PLAYER_LIMB_LEFT_FOOT, footPos, PLAYER_LIMB_RIGHT_FOOT, footPos); +} + +void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot, Actor* actor) { + Player* player = (Player*)actor; + + if (*dList2 != NULL) { + Matrix_MultZero(sPlayerCurBodyPartPos); + } + + if (limbIndex == PLAYER_LIMB_LEFT_HAND) { + Math_Vec3f_Copy(&player->leftHandWorld.pos, sPlayerCurBodyPartPos); + + if ((*dList1 != NULL) && !func_801271B0(play, player, 0) && !func_80128640(play, player, *dList1) && + (player->skelAnime.animation == &gPlayerAnim_pg_punchA)) { + func_80127488(play, player, D_801C0778[(s32)player->skelAnime.curFrame]); + } + + if (player->actor.scale.y >= 0.0f) { + Actor* heldActor; + MtxF sp230; + + if (!Player_IsHoldingHookshot(player) && ((heldActor = player->heldActor) != NULL)) { + if ((player->stateFlags3 & PLAYER_STATE3_40) && (player->transformation != PLAYER_FORM_DEKU)) { + static Vec3f D_801C0D60 = { 398.0f, 1419.0f, 244.0f }; + static Vec3f D_801C0D6C = { 420.0f, 1210.0f, 380.0f }; + Vec3s* temp_s1; + Vec3f* var_a0 = &D_801C0D60; + + if (player->transformation == PLAYER_FORM_HUMAN) { + var_a0 = &D_801C0D6C; + } + + Matrix_MultVec3f(var_a0, &heldActor->world.pos); + Matrix_RotateZYX(0x69E8, -0x5708, 0x458E, MTXMODE_APPLY); + + Matrix_Get(&sp230); + temp_s1 = &heldActor->world.rot; + Matrix_MtxFToYXZRot(&sp230, temp_s1, false); + heldActor->shape.rot = *temp_s1; + } else if (player->stateFlags1 & PLAYER_STATE1_800) { + heldActor->world.rot.y = heldActor->shape.rot.y = + player->actor.shape.rot.y + player->leftHandWorld.rot.y; + } + } else { + static f32 sMeleeWeaponLengths[PLAYER_MELEEWEAPON_MAX] = { + 0.0f, // PLAYER_MELEEWEAPON_NONE + 3000.0f, // PLAYER_MELEEWEAPON_SWORD_KOKIRI + 3000.0f, // PLAYER_MELEEWEAPON_SWORD_RAZOR + 4000.0f, // PLAYER_MELEEWEAPON_SWORD_GILDED + 5500.0f, // PLAYER_MELEEWEAPON_SWORD_GREAT_FAIRY + -1.0f, // PLAYER_MELEEWEAPON_STICK + 2500.0f, // PLAYER_MELEEWEAPON_ZORA_FINS + }; + + if ((player->transformation == PLAYER_FORM_FIERCE_DEITY) || + ((player->transformation != PLAYER_FORM_ZORA) && + ((player->itemAction == PLAYER_IA_STICK) || + ((player->meleeWeaponState != 0) && + (player->meleeWeaponAnimation != PLAYER_MWA_GORON_PUNCH_RIGHT) && + (player->meleeWeaponAnimation != PLAYER_MWA_GORON_PUNCH_BUTT))))) { + if (player->itemAction == PLAYER_IA_STICK) { + D_801C0994->x = player->unk_B08[1] * 5000.0f; + } else { + D_801C0994->x = sMeleeWeaponLengths[Player_GetMeleeWeaponHeld(player)]; + } + func_80126B8C(play, player); + } + + Matrix_Get(&player->mf_CC4); + Matrix_MtxFToYXZRot(&player->mf_CC4, &player->leftHandWorld.rot, false); + } + } + } else if (limbIndex == PLAYER_LIMB_RIGHT_HAND) { + Actor* heldActor = player->heldActor; + s32 pad; + + if (*dList1 != NULL) { + if (player->rightHandType == PLAYER_MODELTYPE_RH_BOW) { + static Gfx* D_801C0D94 = object_link_child_DL_017818; + static Vec3f D_801C0D98 = { -35.0f, -395.0f, 0.0f }; + // Unused + static s32 D_801C0DA4 = 0; + + OPEN_DISPS(play->state.gfxCtx); + + Matrix_Push(); + Matrix_Translate(D_801C0D98.x, D_801C0D98.y, D_801C0D98.z, MTXMODE_APPLY); + if ((player->stateFlags3 & PLAYER_STATE3_40) && (player->unk_B28 >= 0) && (player->unk_ACC < 0xB)) { + Vec3f sp20C; + f32 temp_fv0; + s32 pad2; + + Matrix_MultZero(&sp20C); + temp_fv0 = Math_Vec3f_DistXYZ(sPlayerCurBodyPartPos, &sp20C); + player->unk_B08[0] = temp_fv0 - 3.0f; + if (temp_fv0 < 3.0f) { + player->unk_B08[0] = 0.0f; + } else { + player->unk_B08[0] *= 1.6f; + if (player->unk_B08[0] > 1.0f) { + player->unk_B08[0] = 1.0f; + } + } + player->unk_B08[1] = -0.5f; + } + Matrix_Scale(1.0f, player->unk_B08[0], 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_801C0D94); + + Matrix_Pop(); + + CLOSE_DISPS(play->state.gfxCtx); + } else if (player->skelAnime.animation == &gPlayerAnim_pg_punchB) { + func_80127488(play, player, D_801C07AC[(s32)player->skelAnime.curFrame]); + } else { + func_801271B0(play, player, 1); + } + } + + if (player->actor.scale.y >= 0.0f) { + if (player->rightHandType == PLAYER_MODELTYPE_RH_FF) { + Matrix_Get(&player->shieldMf); + } else if (player->rightHandType == PLAYER_MODELTYPE_RH_SHIELD) { + // Coordinates of the shield quad collider vertices, in the right hand limb's own model space. + static Vec3f sRightHandLimbModelShieldQuadVertices[4] = { + { -4500.0f, -3000.0f, -600.0f }, + { 1500.0f, -3000.0f, -600.0f }, + { -4500.0f, 3000.0f, -600.0f }, + { 1500.0f, 3000.0f, -600.0f }, + }; + + Matrix_Get(&player->shieldMf); + Player_UpdateShieldCollider(play, player, &player->shieldQuad, sRightHandLimbModelShieldQuadVertices); + } else if (player->rightHandType == PLAYER_MODELTYPE_RH_HOOKSHOT) { + static Vec3f D_801C0DD8 = { 50.0f, 800.0f, 0.0f }; + + Matrix_MultVec3f(&D_801C0DD8, &player->rightHandWorld.pos); + + if (heldActor != NULL) { + static Vec3f D_801C0DE4 = { 50.0f, 850.0f, 0.0f }; + MtxF sp1BC; + + Matrix_MultVec3f(&D_801C0DE4, &heldActor->world.pos); + Matrix_RotateZYX(0, -0x4000, -0x4000, MTXMODE_APPLY); + Matrix_Get(&sp1BC); + Matrix_MtxFToYXZRot(&sp1BC, &heldActor->world.rot, false); + heldActor->shape.rot = heldActor->world.rot; + if (func_800B7128(player)) { + Matrix_Translate(500.0f, 300.0f, 0.0f, MTXMODE_APPLY); + Player_DrawHookshotReticle(play, player, 77600.0f); + } + } + } else if (player->meleeWeaponState != 0) { + if (player->meleeWeaponAnimation == PLAYER_MWA_GORON_PUNCH_RIGHT) { + func_80126B8C(play, player); + } + } + if ((player->getItemDrawIdPlusOne != (GID_NONE + 1)) || + ((func_800B7118(player) == 0) && (heldActor != NULL))) { + if (!(player->stateFlags1 & PLAYER_STATE1_400) && (player->getItemDrawIdPlusOne != (GID_NONE + 1)) && + (player->exchangeItemId != PLAYER_IA_NONE)) { + Math_Vec3f_Copy(&sPlayerGetItemRefPos, &player->leftHandWorld.pos); + } else { + sPlayerGetItemRefPos.x = + (player->bodyPartsPos[PLAYER_BODYPART_RIGHT_HAND].x + player->leftHandWorld.pos.x) * 0.5f; + sPlayerGetItemRefPos.y = + (player->bodyPartsPos[PLAYER_BODYPART_RIGHT_HAND].y + player->leftHandWorld.pos.y) * 0.5f; + sPlayerGetItemRefPos.z = + (player->bodyPartsPos[PLAYER_BODYPART_RIGHT_HAND].z + player->leftHandWorld.pos.z) * 0.5f; + } + + if (player->getItemDrawIdPlusOne == (GID_NONE + 1)) { + Math_Vec3f_Copy(&heldActor->world.pos, &sPlayerGetItemRefPos); + } + } + } + } else if (limbIndex == PLAYER_LIMB_LEFT_FOREARM) { + func_80126BD0(play, player, 0); + } else if (limbIndex == PLAYER_LIMB_RIGHT_FOREARM) { + func_80126BD0(play, player, 1); + } else if (limbIndex == PLAYER_LIMB_TORSO) { + if (player->transformation == PLAYER_FORM_GORON) { + s32 temp_a0 = player->skelAnime.animation == &gPlayerAnim_pg_gakkistart; + s32 temp_v1_3 = player->skelAnime.animation == &gPlayerAnim_pg_gakkiwait; + + if ((temp_a0 || temp_v1_3 || (player->skelAnime.animation == &gPlayerAnim_pg_gakkiplay))) { + static Gfx* D_801C0DF0[] = { + object_link_goron_DL_010590, object_link_goron_DL_010368, object_link_goron_DL_010140, + object_link_goron_DL_00FF18, object_link_goron_DL_00FCF0, + }; + Vec3f sp178[ARRAY_COUNT(D_801C0DF0)]; + s32 i; + + OPEN_DISPS(play->state.gfxCtx); + + if (temp_v1_3) { + f32* var_v0 = player->unk_B10; + + for (i = 0; i < ARRAY_COUNT(sp178); i++, var_v0++) { + func_80124618(D_801C0510, *var_v0, &sp178[i]); + } + } else { + if (temp_a0 != 0) { + func_8012536C(); + func_80124618(D_801C0428, player->skelAnime.curFrame, &player->unk_AF0[1]); + } + + for (i = 0; i < ARRAY_COUNT(sp178); i++) { + Math_Vec3f_Copy(&sp178[i], &player->unk_AF0[1]); + } + } + Matrix_Push(); + Matrix_Scale(player->unk_AF0[1].x, player->unk_AF0[1].y, player->unk_AF0[1].z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, object_link_goron_DL_00FC18); + + Matrix_Pop(); + + for (i = 0; i < ARRAY_COUNT(sp178); i++) { + Matrix_Push(); + Matrix_Scale(sp178[i].x, sp178[i].y, sp178[i].z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, D_801C0DF0[i]); + Matrix_Pop(); + } + + CLOSE_DISPS(play->state.gfxCtx); + } + } + } else if (limbIndex == PLAYER_LIMB_HEAD) { + //! FAKE + if (((*dList1 != NULL) && ((((void)0, player->currentMask)) != (((void)0, PLAYER_MASK_NONE)))) && + (((player->transformation == PLAYER_FORM_HUMAN) && + ((player->skelAnime.animation != &gPlayerAnim_cl_setmask) || (player->skelAnime.curFrame >= 12.0f))) || + ((((player->transformation != PLAYER_FORM_HUMAN) && (player->currentMask >= PLAYER_MASK_FIERCE_DEITY)) && + ((player->transformation + PLAYER_MASK_FIERCE_DEITY) != player->currentMask)) && + (player->skelAnime.curFrame >= 10.0f)))) { + if (func_80127438(play, player, player->currentMask)) { + s32 maskMinusOne = ((void)0, player->currentMask) - 1; + + OPEN_DISPS(play->state.gfxCtx); + + if (((void)0, player->currentMask) == PLAYER_MASK_COUPLE) { + Player_DrawCouplesMask(play, player); + } else if (((void)0, player->currentMask) == PLAYER_MASK_CIRCUS_LEADER) { + Player_DrawCircusLeadersMask(play, player); + } else if (((void)0, player->currentMask) == PLAYER_MASK_BLAST) { + Player_DrawBlastMask(play, player); + } else if (((void)0, player->currentMask) == PLAYER_MASK_BUNNY) { + Player_DrawBunnyHood(play); + } else if (((void)0, player->currentMask) == PLAYER_MASK_GREAT_FAIRY) { + Player_DrawGreatFairysMask(play, player); + } else if (((void)0, player->currentMask) >= PLAYER_MASK_FIERCE_DEITY) { + static Vec2f D_801C0E04[PLAYER_FORM_MAX] = { + { 140.0f, -130.0f }, // PLAYER_FORM_FIERCE_DEITY + { 0.0f, -200.0f }, // PLAYER_FORM_GORON + { -160.0f, 0.0f }, // PLAYER_FORM_ZORA + { 220.0f, -200.0f }, // PLAYER_FORM_DEKU + { 0.0f, 0.0f }, // PLAYER_FORM_HUMAN + }; + Vec2f* temp_s0_4 = &D_801C0E04[player->transformation]; + + Matrix_Push(); + Matrix_Translate(temp_s0_4->x, temp_s0_4->z, 0.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, 1.0f - player->unk_B10[3], 1.0f - player->unk_B10[2], MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + Matrix_Pop(); + + if (((player->skelAnime.animation == &gPlayerAnim_cl_setmask) && + (player->skelAnime.curFrame >= 51.0f)) || + (player->skelAnime.animation == &gPlayerAnim_cl_setmaskend)) { + maskMinusOne += 4; + } + } + + gSPDisplayList(POLY_OPA_DISP++, D_801C0B20[maskMinusOne]); + + CLOSE_DISPS(play->state.gfxCtx); + } + } else if (player->transformation == PLAYER_FORM_DEKU) { + if (player->skelAnime.animation == &gPlayerAnim_pn_gurd) { + OPEN_DISPS(play->state.gfxCtx); + + func_80124618(D_801C0410, player->skelAnime.curFrame, player->unk_AF0); + Matrix_Push(); + + Matrix_Scale(player->unk_AF0[0].x, player->unk_AF0[0].y, player->unk_AF0[0].z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_link_nuts_DL_00A348); + + Matrix_Pop(); + + CLOSE_DISPS(play->state.gfxCtx); + } else { + s32 temp_v1_5 = player->skelAnime.animation == &gPlayerAnim_pn_gakkistart; + + if (temp_v1_5 || (player->skelAnime.animation == &gPlayerAnim_pn_gakkiplay) || + (player->skelAnime.animation == &gPlayerAnim_dl_kokeru)) { + static Gfx* D_801C0E2C[] = { + object_link_nuts_DL_007A28, object_link_nuts_DL_0077D0, object_link_nuts_DL_007548, + object_link_nuts_DL_007900, object_link_nuts_DL_0076A0, + }; + Vec3f spF0[ARRAY_COUNT(D_801C0E2C)]; + s32 i; + f32* temp; + + OPEN_DISPS(play->state.gfxCtx); + + if (temp_v1_5) { + Vec3f spD4; + + func_80124618(D_801C0340, player->skelAnime.curFrame, &spD4); + player->arr_AF0[0] = spD4.x; + func_80124618(D_801C0368, player->skelAnime.curFrame, spF0); + + for (i = 0; i < ARRAY_COUNT(spF0) - 1; i++) { + Math_Vec3f_Copy(&spF0[i + 1], spF0); + } + + temp = &player->arr_AF0[1]; + for (i = 0; i < ARRAY_COUNT(spF0); i++) { + *temp = spF0[0].x; + temp++; + } + } else { + temp = &player->arr_AF0[1]; + for (i = 0; i < ARRAY_COUNT(spF0); i++) { + spF0[i].x = *temp; + spF0[i].y = *temp; + spF0[i].z = *temp; + temp++; + } + } + + Matrix_Push(); + Matrix_Scale(player->arr_AF0[0], player->arr_AF0[0], player->arr_AF0[0], MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_link_nuts_DL_007390); + + Matrix_Pop(); + + for (i = 0; i < ARRAY_COUNT(spF0); i++) { + Matrix_Push(); + + Matrix_Scale(spF0[i].x, spF0[i].y, spF0[i].z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + //! FAKE (yes, all of them are required) + // https://decomp.me/scratch/AdU3G + if (1) {} + if (1) {} + if (1) {} + if (1) {} + if (1) {} + if (1) {} + gSPDisplayList(POLY_OPA_DISP++, D_801C0E2C[i]); + + Matrix_Pop(); + } + + CLOSE_DISPS(play->state.gfxCtx); + } + } + } + + if ((player->stateFlags1 & (PLAYER_STATE1_2 | PLAYER_STATE1_100)) && (player->unk_AE8 != 0)) { + static Vec3f D_801C0E40[PLAYER_FORM_MAX] = { + { 0.0f, 0.0f, 0.0f }, // PLAYER_FORM_FIERCE_DEITY + { -578.3f, -1100.9f, 0.0f }, // PLAYER_FORM_GORON + { -189.5f, -594.87f, 0.0f }, // PLAYER_FORM_ZORA + { -570.0f, -812.0f, 0.0f }, // PLAYER_FORM_DEKU + { -230.0f, -520.0f, 0.0f }, // PLAYER_FORM_HUMAN + }; + Vec3f* temp_s0_7 = &D_801C0E40[player->transformation]; + + OPEN_DISPS(play->state.gfxCtx); + + Matrix_Push(); + AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_054F18)); + Matrix_Translate(temp_s0_7->x, temp_s0_7->y, 0.0f, MTXMODE_APPLY); + if (player->transformation == PLAYER_FORM_ZORA) { + Matrix_Scale(0.7f, 0.7f, 0.7f, MTXMODE_APPLY); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, (u8)player->unk_AE8); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054C90); + + Matrix_Pop(); + + CLOSE_DISPS(play->state.gfxCtx); + } + if (player->actor.scale.y >= 0.0f) { + static Vec3f sPlayerFocusHeadLimbModelPos = { 1100.0f, -700.0f, 0.0f }; + static Vec3f D_801C0E88 = { 1600.0f, -1700.0f, -70.0f }; // unused + Actor* spA8 = NULL; + + if (player->transformation != PLAYER_FORM_DEKU) { + Matrix_MultVec3f(&sPlayerFocusHeadLimbModelPos, &player->actor.focus.pos); + } else { + static Vec3f D_801C0E94 = { 1800.0f, -300.0f, 0.0f }; + + Matrix_MultVec3f(&sPlayerFocusHeadLimbModelPos, &player->actor.focus.pos); + Matrix_MultVec3f(&D_801C0E94, sPlayerCurBodyPartPos); + if ((player->skelAnime.animation == &gPlayerAnim_pn_drinkend) || + (player->unk_284.animation == &gPlayerAnim_pn_tamahaki) || + ((player->stateFlags3 & PLAYER_STATE3_40) && ((spA8 = player->heldActor) != NULL))) { + if (spA8 != NULL) { + static Vec3f D_801C0EA0 = { 1300.0f, -400.0f, 0.0f }; + MtxF sp68; + + Matrix_Push(); + Matrix_MultVec3f(&D_801C0EA0, &spA8->world.pos); + Matrix_RotateZYX(0, 0x4000, 0, MTXMODE_APPLY); + Matrix_Get(&sp68); + Matrix_MtxFToYXZRot(&sp68, &spA8->world.rot, false); + spA8->shape.rot = spA8->world.rot; + Matrix_Pop(); + } + } + } + } + } else if ((limbIndex == PLAYER_LIMB_HAT) && (player->stateFlags3 & PLAYER_STATE3_100000)) { + Vec3f sp5C; + Vec3f sp50; + + Matrix_MultVecX(3000.0f, &sp5C); + Matrix_MultVecX(2300.0f, &sp50); + if (func_80126440(play, NULL, player->meleeWeaponInfo, &sp5C, &sp50)) { + EffectBlure_AddVertex(Effect_GetByIndex(player->meleeWeaponEffectIndex[0]), &player->meleeWeaponInfo[0].tip, + &player->meleeWeaponInfo[0].base); + } + } else if (limbIndex == PLAYER_LIMB_RIGHT_SHIN) { + if (player->meleeWeaponState != 0) { + if ((player->meleeWeaponAnimation == PLAYER_MWA_ZORA_PUNCH_KICK) || + (player->meleeWeaponAnimation == PLAYER_MWA_ZORA_JUMPKICK_START) || + (player->meleeWeaponAnimation == PLAYER_MWA_ZORA_JUMPKICK_FINISH)) { + func_8012669C(play, player, D_801C0A48, D_801C0A24); + } + } + } else if (limbIndex == PLAYER_LIMB_WAIST) { + if (player->meleeWeaponState != 0) { + if (player->meleeWeaponAnimation == PLAYER_MWA_GORON_PUNCH_BUTT) { + Math_Vec3f_Copy(&player->unk_AF0[1], &player->meleeWeaponInfo[0].base); + func_8012669C(play, player, D_801C0A90, D_801C0A6C); + } + } + } else if (limbIndex == PLAYER_LIMB_SHEATH) { + if ((*dList1 != NULL) && (player->transformation == PLAYER_FORM_HUMAN) && + (player->currentShield != PLAYER_SHIELD_NONE) && + ((player->sheathType == PLAYER_MODELTYPE_SHEATH_14) || + (player->sheathType == PLAYER_MODELTYPE_SHEATH_15))) { + OPEN_DISPS(play->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, gPlayerShields[2 * ((player->currentShield - 1) ^ 0)]); + + CLOSE_DISPS(play->state.gfxCtx); + } + + if (player->actor.scale.y >= 0.0f) { + if ((player->rightHandType != PLAYER_MODELTYPE_RH_SHIELD) && + (player->rightHandType != PLAYER_MODELTYPE_RH_FF)) { + static Vec3f sSheathLimbModelShieldOnBackPos = { 630.0f, 100.0f, -30.0f }; + static Vec3s sSheathLimbModelShieldOnBackZyxRot = { 0, 0, 0x7FFF }; + + Matrix_TranslateRotateZYX(&sSheathLimbModelShieldOnBackPos, &sSheathLimbModelShieldOnBackZyxRot); + Matrix_Get(&player->shieldMf); + } + } + } else if (player->actor.scale.y >= 0.0f) { + Player_SetFeetPos(play, player, limbIndex); + } + + func_8012536C(); +} diff --git a/src/code/z_quake.c b/src/code/z_quake.c index b57012ce1..c5115375c 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -3,35 +3,28 @@ #include "z64view.h" typedef struct { - /* 0x00 */ s16 randIndex; - /* 0x02 */ s16 countdownMax; + /* 0x00 */ s16 index; + /* 0x02 */ s16 duration; /* 0x04 */ Camera* camera; /* 0x08 */ u32 type; - /* 0x0C */ s16 verticalMag; - /* 0x0E */ s16 horizontalMag; - /* 0x10 */ s16 zoom; - /* 0x12 */ s16 rollOffset; - /* 0x14 */ Vec3s shakePlaneOffset; // angle deviations from shaking in the perpendicular plane + /* 0x0C */ s16 y; + /* 0x0E */ s16 x; + /* 0x10 */ s16 fov; + /* 0x12 */ s16 upRollOffset; + /* 0x14 */ Vec3s orientation; // alters the orientation of the xy perturbation. Only x (pitch) and y (yaw) are used /* 0x1A */ s16 speed; - /* 0x1C */ s16 isShakePerpendicular; - /* 0x1E */ s16 countdown; + /* 0x1C */ s16 isRelativeToScreen; // is the quake relative to the screen or on world coordinates + /* 0x1E */ s16 timer; /* 0x20 */ s16 camId; } QuakeRequest; // size = 0x24 typedef struct { /* 0x0 */ PlayState* play; /* 0x4 */ s32 type; // bitfield, highest set bit determines type - /* 0x8 */ s16 countdown; + /* 0x8 */ s16 timer; /* 0xA */ s16 state; } DistortionRequest; // size = 0xC -typedef struct { - /* 0x00 */ Vec3f atOffset; - /* 0x0C */ Vec3f eyeOffset; - /* 0x18 */ s16 rollOffset; - /* 0x1A */ s16 zoom; -} ShakeInfo; // size = 0x1C - typedef s16 (*QuakeCallbackFunc)(QuakeRequest*, ShakeInfo*); typedef enum { @@ -40,230 +33,257 @@ typedef enum { /* 2 */ DISTORTION_SETUP } DistortionState; -QuakeRequest sQuakeRequest[4]; +QuakeRequest sQuakeRequests[4]; DistortionRequest sDistortionRequest; -static s16 sIsQuakeInitialized = true; +static s16 sQuakeUnused = 1; static s16 sQuakeRequestCount = 0; f32 Quake_Random(void) { return 2.0f * (Rand_ZeroOne() - 0.5f); } -void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 verticalPertubation, f32 horizontalPertubation) { +void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 yOffset, f32 xOffset) { Vec3f* at = &req->camera->at; Vec3f* eye = &req->camera->eye; Vec3f atEyeOffset; - VecSph atEyeOffsetSph2; - VecSph eyeAtAngle; + VecSph geo; + VecSph eyeToAtGeo; - // isShakePerpendicular is always set to 1 before reaching this conditional - // alternative is an unused fixed vertical shake - if (req->isShakePerpendicular) { + if (req->isRelativeToScreen) { atEyeOffset.x = 0; atEyeOffset.y = 0; atEyeOffset.z = 0; - OLib_Vec3fDiffToVecSphGeo(&eyeAtAngle, eye, at); + OLib_Vec3fDiffToVecGeo(&eyeToAtGeo, eye, at); - atEyeOffsetSph2.r = req->verticalMag * verticalPertubation; - atEyeOffsetSph2.pitch = eyeAtAngle.pitch + req->shakePlaneOffset.x + 0x4000; - atEyeOffsetSph2.yaw = eyeAtAngle.yaw + req->shakePlaneOffset.y; - OLib_VecSphAddToVec3f(&atEyeOffset, &atEyeOffset, &atEyeOffsetSph2); + // y shake + geo.r = req->y * yOffset; + // point unit vector up, then add on `req->orientation` + geo.pitch = eyeToAtGeo.pitch + req->orientation.x + 0x4000; + geo.yaw = eyeToAtGeo.yaw + req->orientation.y; + // apply y shake + OLib_AddVecGeoToVec3f(&atEyeOffset, &atEyeOffset, &geo); - atEyeOffsetSph2.r = req->horizontalMag * horizontalPertubation; - atEyeOffsetSph2.pitch = eyeAtAngle.pitch + req->shakePlaneOffset.x; - atEyeOffsetSph2.yaw = eyeAtAngle.yaw + req->shakePlaneOffset.y + 0x4000; - OLib_VecSphAddToVec3f(&atEyeOffset, &atEyeOffset, &atEyeOffsetSph2); + // x shake + geo.r = req->x * xOffset; + // point unit vector left, then add on `req->orientation` + geo.pitch = eyeToAtGeo.pitch + req->orientation.x; + geo.yaw = eyeToAtGeo.yaw + req->orientation.y + 0x4000; + // apply x shake + OLib_AddVecGeoToVec3f(&atEyeOffset, &atEyeOffset, &geo); } else { atEyeOffset.x = 0; - atEyeOffset.y = req->verticalMag * verticalPertubation; + atEyeOffset.y = req->y * yOffset; atEyeOffset.z = 0; - atEyeOffsetSph2.r = req->horizontalMag * horizontalPertubation; - atEyeOffsetSph2.pitch = req->shakePlaneOffset.x; - atEyeOffsetSph2.yaw = req->shakePlaneOffset.y; + geo.r = req->x * xOffset; + geo.pitch = req->orientation.x; + geo.yaw = req->orientation.y; - OLib_VecSphAddToVec3f(&atEyeOffset, &atEyeOffset, &atEyeOffsetSph2); + OLib_AddVecGeoToVec3f(&atEyeOffset, &atEyeOffset, &geo); } shake->atOffset = shake->eyeOffset = atEyeOffset; - shake->rollOffset = req->rollOffset * verticalPertubation; - shake->zoom = req->zoom * verticalPertubation; + shake->upRollOffset = req->upRollOffset * yOffset; + shake->fovOffset = req->fov * yOffset; } s16 Quake_CallbackType1(QuakeRequest* req, ShakeInfo* shake) { - if (req->countdown > 0) { - f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown); + if (req->timer > 0) { + f32 xyOffset = Math_SinS(req->speed * req->timer); - Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, Rand_ZeroOne() * perpendicularPertubation); - req->countdown--; + Quake_UpdateShakeInfo(req, shake, xyOffset, Rand_ZeroOne() * xyOffset); + req->timer--; } - return req->countdown; + return req->timer; } s16 Quake_CallbackType5(QuakeRequest* req, ShakeInfo* shake) { - if (req->countdown > 0) { - f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown); + if (req->timer > 0) { + f32 xyOffset = Math_SinS(req->speed * req->timer); - Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, perpendicularPertubation); - req->countdown--; + Quake_UpdateShakeInfo(req, shake, xyOffset, xyOffset); + req->timer--; } - return req->countdown; + return req->timer; } s16 Quake_CallbackType6(QuakeRequest* req, ShakeInfo* shake) { - f32 perpendicularPertubation; + f32 xyOffset; - req->countdown--; - perpendicularPertubation = Math_SinS(req->speed * ((req->countdown & 0xF) + 500)); - Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, Rand_ZeroOne() * perpendicularPertubation); + req->timer--; + xyOffset = Math_SinS(req->speed * ((req->timer & 0xF) + 500)); + Quake_UpdateShakeInfo(req, shake, xyOffset, Rand_ZeroOne() * xyOffset); + + // Not returning the timer ensures quake type 6 continues indefinitely until manually removed return 1; } s16 Quake_CallbackType3(QuakeRequest* req, ShakeInfo* shake) { - if (req->countdown > 0) { - f32 perpendicularPertubation = - Math_SinS(req->speed * req->countdown) * ((f32)req->countdown / (f32)req->countdownMax); + if (req->timer > 0) { + f32 xyOffset = Math_SinS(req->speed * req->timer) * ((f32)req->timer / req->duration); - Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, perpendicularPertubation); - req->countdown--; + Quake_UpdateShakeInfo(req, shake, xyOffset, xyOffset); + req->timer--; } - return req->countdown; + return req->timer; } s16 Quake_CallbackType2(QuakeRequest* req, ShakeInfo* shake) { - if (req->countdown > 0) { - f32 perpendicularPertubation = Quake_Random(); + if (req->timer > 0) { + f32 xyOffset = Quake_Random(); - Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, Rand_ZeroOne() * perpendicularPertubation); - req->countdown--; + Quake_UpdateShakeInfo(req, shake, xyOffset, Rand_ZeroOne() * xyOffset); + req->timer--; } - return req->countdown; + return req->timer; } s16 Quake_CallbackType4(QuakeRequest* req, ShakeInfo* shake) { - if (req->countdown > 0) { - f32 perpendicularPertubation = Quake_Random() * ((f32)req->countdown / (f32)req->countdownMax); + if (req->timer > 0) { + f32 xyOffset = Quake_Random() * ((f32)req->timer / req->duration); - Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, Rand_ZeroOne() * perpendicularPertubation); - req->countdown--; + Quake_UpdateShakeInfo(req, shake, xyOffset, Rand_ZeroOne() * xyOffset); + req->timer--; } - return req->countdown; + return req->timer; } s16 Quake_GetFreeIndex(void) { s32 i; - s32 ret = 0; - s32 min = 0x10000; + s32 index = 0; + s32 timerMin = UINT16_MAX + 1; // timer is a short, so start with a value beyond its range - for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) { - if (sQuakeRequest[i].type == 0) { - ret = i; + for (i = 0; i < ARRAY_COUNT(sQuakeRequests); i++) { + if (sQuakeRequests[i].type == QUAKE_TYPE_NONE) { + index = i; break; } - if (sQuakeRequest[i].countdown < min) { - min = sQuakeRequest[i].countdown; - ret = i; + if (timerMin > sQuakeRequests[i].timer) { + timerMin = sQuakeRequests[i].timer; + index = i; } } - return ret; + return index; } -QuakeRequest* Quake_AddImpl(Camera* camera, u32 type) { +QuakeRequest* Quake_RequestImpl(Camera* camera, u32 type) { s16 index = Quake_GetFreeIndex(); - QuakeRequest* req = &sQuakeRequest[index]; + QuakeRequest* req = &sQuakeRequests[index]; __osMemset(req, 0, sizeof(QuakeRequest)); + req->camera = camera; req->camId = camera->camId; req->type = type; - req->isShakePerpendicular = true; - req->randIndex = ((s16)(Rand_ZeroOne() * 0x10000) & ~3) + index; + req->isRelativeToScreen = true; + + // Add a unique random identifier to the upper bits of the index + // The `~3` assumes there are only 4 requests + req->index = index + ((s16)(Rand_ZeroOne() * 0x10000) & ~3); + sQuakeRequestCount++; return req; } -void Quake_RemoveRequest(QuakeRequest* req) { - req->type = 0; - req->countdown = -1; +void Quake_Remove(QuakeRequest* req) { + req->type = QUAKE_TYPE_NONE; + req->timer = -1; sQuakeRequestCount--; } -QuakeRequest* Quake_GetRequest(s16 quakeIndex) { - QuakeRequest* req = &sQuakeRequest[quakeIndex & 3]; +QuakeRequest* Quake_GetRequest(s16 index) { + QuakeRequest* req = &sQuakeRequests[index & 3]; - if (req->type == 0) { + if (req->type == QUAKE_TYPE_NONE) { return NULL; } - if (quakeIndex != req->randIndex) { + if (index != req->index) { return NULL; } return req; } -u32 Quake_SetValue(s16 quakeIndex, s16 valueType, s16 value) { - QuakeRequest* req = Quake_GetRequest(quakeIndex); +// valueType for Quake_SetValue() +#define QUAKE_SPEED (1 << 0) +#define QUAKE_Y_OFFSET (1 << 1) +#define QUAKE_X_OFFSET (1 << 2) +#define QUAKE_FOV (1 << 3) +#define QUAKE_ROLL (1 << 4) +#define QUAKE_ORIENTATION_PITCH (1 << 5) +#define QUAKE_ORIENTATION_YAW (1 << 6) +#define QUAKE_ORIENTATION_ROLL (1 << 7) +#define QUAKE_DURATION (1 << 8) +#define QUAKE_IS_RELATIVE_TO_SCREEN (1 << 9) + +u32 Quake_SetValue(s16 index, s16 valueType, s16 value) { + QuakeRequest* req = Quake_GetRequest(index); if (req == NULL) { return false; - } else { - switch (valueType) { - case QUAKE_SPEED: - req->speed = value; - break; - - case QUAKE_VERTICAL_MAG: - req->verticalMag = value; - break; - - case QUAKE_HORIZONTAL_MAG: - req->horizontalMag = value; - break; - - case QUAKE_ZOOM: - req->zoom = value; - break; - - case QUAKE_ROLL_OFFSET: - req->rollOffset = value; - break; - - case QUAKE_SHAKE_PLANE_OFFSET_X: - req->shakePlaneOffset.x = value; - break; - - case QUAKE_SHAKE_PLANE_OFFSET_Y: - req->shakePlaneOffset.y = value; - break; - - case QUAKE_SHAKE_PLANE_OFFSET_Z: - req->shakePlaneOffset.z = value; - break; - - case QUAKE_COUNTDOWN: - req->countdown = value; - req->countdownMax = req->countdown; - break; - - case QUAKE_IS_SHAKE_PERPENDICULAR: - req->isShakePerpendicular = value; - break; - - default: - break; - } - - return true; } + + switch (valueType) { + case QUAKE_SPEED: + req->speed = value; + break; + + case QUAKE_Y_OFFSET: + req->y = value; + break; + + case QUAKE_X_OFFSET: + req->x = value; + break; + + case QUAKE_FOV: + req->fov = value; + break; + + case QUAKE_ROLL: + req->upRollOffset = value; + break; + + case QUAKE_ORIENTATION_PITCH: + req->orientation.x = value; + break; + + case QUAKE_ORIENTATION_YAW: + req->orientation.y = value; + break; + + case QUAKE_ORIENTATION_ROLL: + req->orientation.z = value; + break; + + case QUAKE_DURATION: + req->timer = value; + req->duration = req->timer; + break; + + case QUAKE_IS_RELATIVE_TO_SCREEN: + req->isRelativeToScreen = value; + break; + + default: + break; + } + + return true; } -u32 Quake_SetSpeed(s16 quakeIndex, s16 speed) { - QuakeRequest* req = Quake_GetRequest(quakeIndex); +/** + * @param index + * @param speed for periodic types only, the angular frequency of the sine wave (binang / frame) + * @return true if successfully applied, false if the request does not exist + */ +u32 Quake_SetSpeed(s16 index, s16 speed) { + QuakeRequest* req = Quake_GetRequest(index); if (req != NULL) { req->speed = speed; @@ -272,45 +292,67 @@ u32 Quake_SetSpeed(s16 quakeIndex, s16 speed) { return false; } -u32 Quake_SetCountdown(s16 quakeIndex, s16 countdown) { - QuakeRequest* req = Quake_GetRequest(quakeIndex); +/** + * @param index quake request index to apply + * @param duration number of frames to apply the quake + * @return true if successfully applied, false if the request does not exist + */ +u32 Quake_SetDuration(s16 index, s16 duration) { + QuakeRequest* req = Quake_GetRequest(index); if (req != NULL) { - req->countdown = countdown; - req->countdownMax = req->countdown; + req->duration = req->timer = duration; return true; } return false; } -s16 Quake_GetCountdown(s16 quakeIndex) { - QuakeRequest* req = Quake_GetRequest(quakeIndex); +/** + * @param index quake request index to get + * @return number of frames until the quake is finished + */ +s16 Quake_GetTimeLeft(s16 index) { + QuakeRequest* req = Quake_GetRequest(index); if (req != NULL) { - return req->countdown; + return req->timer; } return 0; } -u32 Quake_SetQuakeValues(s16 quakeIndex, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset) { - QuakeRequest* req = Quake_GetRequest(quakeIndex); +/** + * @param index quake request index to apply + * @param y apply up/down shake + * @param x apply left/right shake + * @param fov apply zooming in/out shake (binang) + * @param roll apply rolling shake (binang) + * @return true if successfully applied, false if the request does not exist + */ +u32 Quake_SetPerturbations(s16 index, s16 y, s16 x, s16 fov, s16 roll) { + QuakeRequest* req = Quake_GetRequest(index); if (req != NULL) { - req->verticalMag = verticalMag; - req->horizontalMag = horizontalMag; - req->zoom = zoom; - req->rollOffset = rollOffset; + req->y = y; + req->x = x; + req->fov = fov; + req->upRollOffset = roll; return true; } return false; } -u32 Quake_SetQuakeValues2(s16 quakeIndex, s16 isShakePerpendicular, Vec3s shakePlaneOffset) { - QuakeRequest* req = Quake_GetRequest(quakeIndex); +/** + * @param index quake request index to apply + * @param isRelativeToScreen is the quake applied relative to the screen or in absolute world coordinates + * @param orientation orient the x/y shake to a different direction + * @return true if successfully applied, false if the request does not exist + */ +u32 Quake_SetOrientation(s16 index, s16 isRelativeToScreen, Vec3s orientation) { + QuakeRequest* req = Quake_GetRequest(index); if (req != NULL) { - req->isShakePerpendicular = isShakePerpendicular; - req->shakePlaneOffset = shakePlaneOffset; + req->isRelativeToScreen = isRelativeToScreen; + req->orientation = orientation; return true; } return false; @@ -319,156 +361,167 @@ u32 Quake_SetQuakeValues2(s16 quakeIndex, s16 isShakePerpendicular, Vec3s shakeP void Quake_Init(void) { s16 i; - for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) { - sQuakeRequest[i].type = 0; - sQuakeRequest[i].countdown = 0; + for (i = 0; i < ARRAY_COUNT(sQuakeRequests); i++) { + sQuakeRequests[i].type = QUAKE_TYPE_NONE; + sQuakeRequests[i].timer = 0; } - sIsQuakeInitialized = true; + sQuakeUnused = 1; sQuakeRequestCount = 0; } -s16 Quake_Add(Camera* camera, u32 type) { - return Quake_AddImpl(camera, type)->randIndex; +s16 Quake_Request(Camera* camera, u32 type) { + return Quake_RequestImpl(camera, type)->index; } -u32 Quake_Remove(s16 index) { +u32 Quake_RemoveRequest(s16 index) { QuakeRequest* req = Quake_GetRequest(index); if (req != NULL) { - Quake_RemoveRequest(req); + Quake_Remove(req); return true; } return false; } static QuakeCallbackFunc sQuakeCallbacks[] = { - NULL, - Quake_CallbackType1, - Quake_CallbackType2, - Quake_CallbackType3, - Quake_CallbackType4, - Quake_CallbackType5, - Quake_CallbackType6, + NULL, // QUAKE_TYPE_NONE + Quake_CallbackType1, // QUAKE_TYPE_1 + Quake_CallbackType2, // QUAKE_TYPE_2 + Quake_CallbackType3, // QUAKE_TYPE_3 + Quake_CallbackType4, // QUAKE_TYPE_4 + Quake_CallbackType5, // QUAKE_TYPE_5 + Quake_CallbackType6, // QUAKE_TYPE_6 }; -s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { - s32 pad; - QuakeRequest* req; - ShakeInfo shake; +s16 Quake_Update(Camera* camera, ShakeInfo* camShake) { f32 absSpeedDiv; + ShakeInfo shake; + QuakeRequest* req; f32 maxCurr; f32 maxNext; s32 index; - s32 ret; - u32 eq; - Vec3f originVec; + s32 numQuakesApplied; + u32 isDifferentCamId; + Vec3f zeroVec; PlayState* play = camera->play; - originVec.x = 0.0f; - originVec.y = 0.0f; - originVec.z = 0.0f; - camData->atOffset.x = 0.0f; - camData->atOffset.y = 0.0f; - camData->atOffset.z = 0.0f; - camData->eyeOffset.x = 0.0f; - camData->eyeOffset.y = 0.0f; - camData->eyeOffset.z = 0.0f; - camData->rollOffset = 0; - camData->zoom = 0; - camData->max = 0.0f; + zeroVec.x = 0.0f; + zeroVec.y = 0.0f; + zeroVec.z = 0.0f; + + camShake->atOffset.x = 0.0f; + camShake->atOffset.y = 0.0f; + camShake->atOffset.z = 0.0f; + + camShake->eyeOffset.x = 0.0f; + camShake->eyeOffset.y = 0.0f; + camShake->eyeOffset.z = 0.0f; + + camShake->upRollOffset = 0; + camShake->fovOffset = 0; + camShake->maxOffset = 0.0f; if (sQuakeRequestCount == 0) { return 0; } - ret = 0; - for (index = 0; index < ARRAY_COUNT(sQuakeRequest); index++) { - req = &sQuakeRequest[index]; - if (req->type != 0) { - if (play->cameraPtrs[req->camId] == NULL) { - Quake_RemoveRequest(req); - } else { - eq = (camera->camId != req->camera->camId); - absSpeedDiv = ABS(req->speed) / (f32)0x8000; - if (sQuakeCallbacks[req->type](req, &shake) == 0) { - Quake_RemoveRequest(req); - } else if (eq == 0) { - if (fabsf(camData->atOffset.x) < fabsf(shake.atOffset.x)) { - camData->atOffset.x = shake.atOffset.x; - } - if (fabsf(camData->atOffset.y) < fabsf(shake.atOffset.y)) { - camData->atOffset.y = shake.atOffset.y; - } - if (fabsf(camData->atOffset.z) < fabsf(shake.atOffset.z)) { - camData->atOffset.z = shake.atOffset.z; - } - if (fabsf(camData->eyeOffset.x) < fabsf(shake.eyeOffset.x)) { - camData->eyeOffset.x = shake.eyeOffset.x; - } - if (fabsf(camData->eyeOffset.y) < fabsf(shake.eyeOffset.y)) { - camData->eyeOffset.y = shake.eyeOffset.y; - } - if (fabsf(camData->eyeOffset.z) < fabsf(shake.eyeOffset.z)) { - camData->eyeOffset.z = shake.eyeOffset.z; - } - if (camData->rollOffset < shake.rollOffset) { - camData->rollOffset = shake.rollOffset; - } - if (camData->zoom < shake.zoom) { - camData->zoom = shake.zoom; - } - - maxCurr = OLib_Vec3fDist(&shake.atOffset, &originVec) * absSpeedDiv; - - maxNext = OLib_Vec3fDist(&shake.eyeOffset, &originVec) * absSpeedDiv; - maxCurr = CLAMP_MIN(maxCurr, maxNext); - - maxNext = (camData->rollOffset * (7.0f / 2500.0f)) * absSpeedDiv; - maxCurr = CLAMP_MIN(maxCurr, maxNext); - - maxNext = (camData->zoom * (7.0f / 2500.0f)) * absSpeedDiv; - maxCurr = CLAMP_MIN(maxCurr, maxNext); - - if (camData->max < maxCurr) { - camData->max = maxCurr; - } - - ret++; - } - } + numQuakesApplied = 0; + for (index = 0; index < ARRAY_COUNT(sQuakeRequests); index++) { + req = &sQuakeRequests[index]; + if (req->type == QUAKE_TYPE_NONE) { + continue; } + + if (play->cameraPtrs[req->camId] == NULL) { + Quake_Remove(req); + continue; + } + + isDifferentCamId = (camera->camId != req->camera->camId); + absSpeedDiv = (f32)ABS(req->speed) / 0x8000; + if (sQuakeCallbacks[req->type](req, &shake) == 0) { + // Quake has reached the end of its timer. + Quake_Remove(req); + continue; + } + + if (isDifferentCamId) { + // Quake is attached to a different camId + continue; + } + + if (fabsf(camShake->atOffset.x) < fabsf(shake.atOffset.x)) { + camShake->atOffset.x = shake.atOffset.x; + } + if (fabsf(camShake->atOffset.y) < fabsf(shake.atOffset.y)) { + camShake->atOffset.y = shake.atOffset.y; + } + if (fabsf(camShake->atOffset.z) < fabsf(shake.atOffset.z)) { + camShake->atOffset.z = shake.atOffset.z; + } + if (fabsf(camShake->eyeOffset.x) < fabsf(shake.eyeOffset.x)) { + camShake->eyeOffset.x = shake.eyeOffset.x; + } + if (fabsf(camShake->eyeOffset.y) < fabsf(shake.eyeOffset.y)) { + camShake->eyeOffset.y = shake.eyeOffset.y; + } + if (fabsf(camShake->eyeOffset.z) < fabsf(shake.eyeOffset.z)) { + camShake->eyeOffset.z = shake.eyeOffset.z; + } + if (camShake->upRollOffset < shake.upRollOffset) { + camShake->upRollOffset = shake.upRollOffset; + } + if (camShake->fovOffset < shake.fovOffset) { + camShake->fovOffset = shake.fovOffset; + } + + maxCurr = OLib_Vec3fDist(&shake.atOffset, &zeroVec) * absSpeedDiv; + maxNext = OLib_Vec3fDist(&shake.eyeOffset, &zeroVec) * absSpeedDiv; + maxCurr = CLAMP_MIN(maxCurr, maxNext); + + maxNext = (camShake->upRollOffset * (7.0f / 2500.0f)) * absSpeedDiv; + maxCurr = CLAMP_MIN(maxCurr, maxNext); + + maxNext = (camShake->fovOffset * (7.0f / 2500.0f)) * absSpeedDiv; + maxCurr = CLAMP_MIN(maxCurr, maxNext); + + if (camShake->maxOffset < maxCurr) { + camShake->maxOffset = maxCurr; + } + + numQuakesApplied++; } - return ret; + return numQuakesApplied; } void Distortion_Init(PlayState* play) { sDistortionRequest.play = play; View_ClearDistortion(&play->view); sDistortionRequest.type = 0; - sDistortionRequest.countdown = 0; + sDistortionRequest.timer = 0; sDistortionRequest.state = DISTORTION_INACTIVE; } -void Distortion_SetCountdown(s16 countdown) { - sDistortionRequest.countdown = countdown; +void Distortion_SetDuration(s16 duration) { + sDistortionRequest.timer = duration; sDistortionRequest.state = DISTORTION_SETUP; } -s16 Distortion_GetCountdown(void) { - return sDistortionRequest.countdown; +s16 Distortion_GetTimeLeft(void) { + return sDistortionRequest.timer; } s16 Distortion_GetType(void) { return sDistortionRequest.type; } -void Distortion_SetType(s32 type) { +void Distortion_Request(s32 type) { if (sDistortionRequest.type < type) { sDistortionRequest.type = type; } } -void Distortion_ClearType(s32 type) { +void Distortion_RemoveRequest(s32 type) { if (sDistortionRequest.type == type) { sDistortionRequest.type = 0; } @@ -477,19 +530,19 @@ void Distortion_ClearType(s32 type) { /** * Checks that the bg surface is an underwater conveyor type and if so, returns the conveyor speed */ -s32 Distortion_GetUnderwaterCurrentSpeed(Player* player) { +ConveyorSpeed Distortion_GetUnderwaterCurrentSpeed(Player* player) { if (!SurfaceType_IsFloorConveyor(&sDistortionRequest.play->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { return SurfaceType_GetConveyorSpeed(&sDistortionRequest.play->colCtx, player->actor.floorPoly, player->actor.floorBgId); } - return 0; + return CONVEYOR_SPEED_DISABLED; } void Distortion_Update(void) { static s16 depthPhase = 0x3F0; static s16 screenPlanePhase = 0x156; - static s16 countdownMax = 1; + static s16 duration = 1; f32 xyScaleFactor; f32 zScaleFactor; f32 speedScaleFactor; @@ -511,8 +564,8 @@ void Distortion_Update(void) { f32 speedRatio = CLAMP_MAX(camera->speedRatio, 1.0f); if (sDistortionRequest.type != 0) { - if (sDistortionRequest.type & DISTORTION_TYPE_B) { - sDistortionRequest.countdown = 2; + if (sDistortionRequest.type & DISTORTION_TYPE_MASK_TRANSFORM_2) { + sDistortionRequest.timer = 2; depthPhase = 0x3F0; screenPlanePhase = 0x156; @@ -528,17 +581,17 @@ void Distortion_Update(void) { zScale = 0.0f; speed = 0.6f; - xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / 60.0f; + xyScaleFactor = zScaleFactor = sDistortionRequest.timer / 60.0f; speedScaleFactor = 1.0f; - } else if (sDistortionRequest.type & DISTORTION_TYPE_A) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_BOSS_WARP) { if (sDistortionRequest.state == DISTORTION_SETUP) { - countdownMax = sDistortionRequest.countdown; + duration = sDistortionRequest.timer; depthPhase = 0x3F0; screenPlanePhase = 0x156; } depthPhaseStep = 0.0f; - screenPlanePhaseStep = 50.0f / countdownMax; + screenPlanePhaseStep = 50.0f / duration; rotX = 0.0f; rotY = 0.0f; @@ -549,11 +602,11 @@ void Distortion_Update(void) { zScale = 0.0f; speed = 0.4f; - xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax; + xyScaleFactor = zScaleFactor = ((f32)duration - sDistortionRequest.timer) / (f32)duration; speedScaleFactor = 0.5f; - } else if (sDistortionRequest.type & DISTORTION_TYPE_9) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_MASK_TRANSFORM_1) { if (sDistortionRequest.state == DISTORTION_SETUP) { - countdownMax = sDistortionRequest.countdown; + duration = sDistortionRequest.timer; depthPhase = 0x1FC; screenPlanePhase = 0x156; } @@ -570,11 +623,11 @@ void Distortion_Update(void) { zScale = 0.0f; speed = 0.1f; - xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax; + xyScaleFactor = zScaleFactor = ((f32)duration - sDistortionRequest.timer) / (f32)duration; speedScaleFactor = 1.0f; - } else if (sDistortionRequest.type & DISTORTION_TYPE_8) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_GORON_BUTT) { if (sDistortionRequest.state == DISTORTION_SETUP) { - countdownMax = sDistortionRequest.countdown; + duration = sDistortionRequest.timer; depthPhase = 0x2710; screenPlanePhase = 0x3E8; } @@ -591,15 +644,15 @@ void Distortion_Update(void) { zScale = 0.01f; speed = 1.5f; - if (sDistortionRequest.countdown < 5) { - xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax; + if (sDistortionRequest.timer < 5) { + xyScaleFactor = zScaleFactor = ((f32)duration - sDistortionRequest.timer) / (f32)duration; } else { xyScaleFactor = zScaleFactor = 0.0f; } speedScaleFactor = 1.0f; - } else if (sDistortionRequest.type & DISTORTION_TYPE_7) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_UNK_ATTACK) { if (sDistortionRequest.state == DISTORTION_SETUP) { - countdownMax = sDistortionRequest.countdown; + duration = sDistortionRequest.timer; depthPhase = 0x4B0; screenPlanePhase = 0x7D0; } @@ -616,11 +669,11 @@ void Distortion_Update(void) { zScale = 0.01f; speed = 1.5f; - xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / (f32)countdownMax; + xyScaleFactor = zScaleFactor = sDistortionRequest.timer / (f32)duration; speedScaleFactor = 1.0f; - } else if (sDistortionRequest.type & DISTORTION_TYPE_6) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_ZORA_KICK) { if (sDistortionRequest.state == DISTORTION_SETUP) { - countdownMax = sDistortionRequest.countdown; + duration = sDistortionRequest.timer; depthPhase = 0x9C4; screenPlanePhase = 0xBB8; } @@ -637,14 +690,14 @@ void Distortion_Update(void) { zScale = 0.01f; speed = 1.3f; - if (sDistortionRequest.countdown < 4) { - xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / (f32)countdownMax; + if (sDistortionRequest.timer < 4) { + xyScaleFactor = zScaleFactor = sDistortionRequest.timer / (f32)duration; } else { xyScaleFactor = zScaleFactor = 0.0f; } speedScaleFactor = 1.0f; - } else if (sDistortionRequest.type & DISTORTION_TYPE_5) { - sDistortionRequest.countdown = 2; + } else if (sDistortionRequest.type & DISTORTION_TYPE_SONG_OF_TIME) { + sDistortionRequest.timer = 2; if (sDistortionRequest.state == DISTORTION_SETUP) { depthPhase = 0x9C4; screenPlanePhase = 0xBB8; @@ -668,9 +721,9 @@ void Distortion_Update(void) { zScaleFactor = 1.0f; xyScaleFactor = 1.0f; speedScaleFactor = 1.0f; - } else if (sDistortionRequest.type & DISTORTION_TYPE_4) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_UNDERWATER_ENTRY) { if (sDistortionRequest.state == DISTORTION_SETUP) { - countdownMax = sDistortionRequest.countdown; + duration = sDistortionRequest.timer; depthPhase = 0x760; screenPlanePhase = 0x1BC; } @@ -687,14 +740,14 @@ void Distortion_Update(void) { zScale = 0.2f; speed = 0.25f; - countdownRatio = sDistortionRequest.countdown / (f32)countdownMax; + countdownRatio = sDistortionRequest.timer / (f32)duration; zScaleFactor = xyScaleFactor = countdownRatio; speedScaleFactor = 1.0f; - } else if (sDistortionRequest.type & DISTORTION_TYPE_3) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_ZORA_SWIMMING) { depthPhase = 0x3F0; screenPlanePhase = 0x156; - sDistortionRequest.countdown = 2; + sDistortionRequest.timer = 2; player = GET_PLAYER(play); if (player != NULL) { @@ -709,21 +762,21 @@ void Distortion_Update(void) { rotZ = 0.3f; switch (Distortion_GetUnderwaterCurrentSpeed(player)) { - case 3: + case CONVEYOR_SPEED_FAST: xScale = -0.06f; yScale = 0.1f; zScale = 0.03f; speed = 0.33f; break; - case 2: + case CONVEYOR_SPEED_MEDIUM: xScale = -0.06f; yScale = 0.1f; zScale = 0.03f; speed = 0.33f; break; - case 1: + case CONVEYOR_SPEED_SLOW: xScale = -0.06f; yScale = 0.1f; zScale = 0.03f; @@ -745,11 +798,11 @@ void Distortion_Update(void) { } zScaleFactor = -xyScaleFactor; speedScaleFactor = 1.0f; - } else if (sDistortionRequest.type & DISTORTION_TYPE_2) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_NON_ZORA_SWIMMING) { depthPhase = 0x3F0; screenPlanePhase = 0x156; - sDistortionRequest.countdown = 2; + sDistortionRequest.timer = 2; player = GET_PLAYER(play); depthPhaseStep = 359.2f; @@ -759,21 +812,21 @@ void Distortion_Update(void) { rotY = 0.0f; rotZ = 0.0f; switch (Distortion_GetUnderwaterCurrentSpeed(player)) { - case 3: + case CONVEYOR_SPEED_FAST: xScale = 0.12f; yScale = 0.12f; zScale = 0.08f; speed = 0.18f; break; - case 2: + case CONVEYOR_SPEED_MEDIUM: xScale = 0.12f; yScale = 0.12f; zScale = 0.08f; speed = 0.12f; break; - case 1: + case CONVEYOR_SPEED_SLOW: xScale = 0.12f; yScale = 0.12f; zScale = 0.08f; @@ -796,12 +849,12 @@ void Distortion_Update(void) { xyScaleFactor = speedScaleFactor = (waterYScaleFactor * 0.15f) + 0.35f + (speedRatio * 0.4f); zScaleFactor = 0.9f - xyScaleFactor; - } else if (sDistortionRequest.type & DISTORTION_TYPE_0) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_HOT_ROOM) { // Gives a small mirage-like appearance depthPhase = 0x3F0; screenPlanePhase = 0x156; - sDistortionRequest.countdown = 2; + sDistortionRequest.timer = 2; depthPhaseStep = 0.0f; screenPlanePhaseStep = 150.0f; @@ -825,9 +878,9 @@ void Distortion_Update(void) { screenPlanePhase += CAM_DEG_TO_BINANG(screenPlanePhaseStep); View_SetDistortionOrientation(&sDistortionRequest.play->view, - Math_CosS(depthPhase) * (DEGF_TO_RADF(rotX) * xyScaleFactor), - Math_SinS(depthPhase) * (DEGF_TO_RADF(rotY) * xyScaleFactor), - Math_SinS(screenPlanePhase) * (DEGF_TO_RADF(rotZ) * zScaleFactor)); + Math_CosS(depthPhase) * (DEG_TO_RAD(rotX) * xyScaleFactor), + Math_SinS(depthPhase) * (DEG_TO_RAD(rotY) * xyScaleFactor), + Math_SinS(screenPlanePhase) * (DEG_TO_RAD(rotZ) * zScaleFactor)); View_SetDistortionScale(&sDistortionRequest.play->view, (Math_SinS(screenPlanePhase) * (xScale * xyScaleFactor)) + 1.0f, (Math_CosS(screenPlanePhase) * (yScale * xyScaleFactor)) + 1.0f, @@ -840,32 +893,25 @@ void Distortion_Update(void) { View_ClearDistortion(&play->view); sDistortionRequest.state = DISTORTION_INACTIVE; - sDistortionRequest.countdown = 0; + sDistortionRequest.timer = 0; } - if (sDistortionRequest.countdown != 0) { - sDistortionRequest.countdown--; - if (sDistortionRequest.countdown == 0) { + if (sDistortionRequest.timer != 0) { + sDistortionRequest.timer--; + if (sDistortionRequest.timer == 0) { sDistortionRequest.type = 0; } } } -s32 Quake_NumActiveQuakes(void) { - QuakeRequest* req = sQuakeRequest; +s32 Quake_GetNumActiveQuakes(void) { s32 numActiveQuakes = 0; + s32 i; - if (req[0].type != 0) { - numActiveQuakes++; - } - if (req[1].type != 0) { - numActiveQuakes++; - } - if (req[2].type != 0) { - numActiveQuakes++; - } - if (req[3].type != 0) { - numActiveQuakes++; + for (i = 0; i < ARRAY_COUNT(sQuakeRequests); i++) { + if (sQuakeRequests[i].type != QUAKE_TYPE_NONE) { + numActiveQuakes++; + } } return numActiveQuakes; diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index 39f09f1d4..ab972159c 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -778,19 +778,19 @@ Gfx* Gfx_SetFog(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f) { if (n >= 997) { if (n >= 1000) { - gSPFogFactor(gfx + 1, 0, 0); // gSPFogPosition(gfx++, ?, ?) + gSPFogFactor(&gfx[1], 0, 0); // gSPFogPosition(gfx++, ?, ?) } else { - gSPFogFactor(gfx + 1, 0x7FFF, 0x8100); // gSPFogPosition(gfx++, ?, ?) + gSPFogFactor(&gfx[1], 0x7FFF, 0x8100); // gSPFogPosition(gfx++, ?, ?) } } else { if (n < 0) { - gSPFogFactor(gfx + 1, 0, 255); // gSPFogPosition(gfx++, ?, ?) + gSPFogFactor(&gfx[1], 0, 255); // gSPFogPosition(gfx++, ?, ?) } else { - gSPFogPosition(gfx + 1, n, f); + gSPFogPosition(&gfx[1], n, f); } } - return gfx + 2; + return &gfx[2]; } Gfx* Gfx_SetFogWithSync(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f) { @@ -897,8 +897,8 @@ void func_8012C240(GraphicsContext* gfxCtx) { gSPDisplayList(gfxCtx->polyXlu.p++, &sSetupDL[6 * 0x19]); } -void func_8012C268(PlayState* play) { - func_8012C28C(play->state.gfxCtx); +void func_8012C268(GameState* gameState) { + func_8012C28C(gameState->gfxCtx); } void func_8012C28C(GraphicsContext* gfxCtx) { @@ -1299,7 +1299,7 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g } void func_8012D374(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b) { - if ((R_PAUSE_BG_PRERENDER_STATE <= PAUSE_BG_PRERENDER_SETUP) && (D_801F6D10 < 2)) { + if ((R_PAUSE_BG_PRERENDER_STATE <= PAUSE_BG_PRERENDER_SETUP) && (gTransitionTileState <= TRANS_TILE_SETUP)) { func_8012CF0C(gfxCtx, true, true, r, g, b); } else { func_8012CF0C(gfxCtx, false, false, r, g, b); diff --git a/src/code/z_room.c b/src/code/z_room.c index eb615c409..34aca7461 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -1,62 +1,465 @@ #include "global.h" -void Room_nop8012D510(PlayState* play, Room* room, UNK_PTR param_3, UNK_TYPE1 param_4) { +void Room_Noop(PlayState* play, Room* room, Input* input, s32 arg3) { } -void Room_DrawType3Mesh(PlayState* play, Room* room, u32 flags) { +void Room_DrawNone(PlayState* play, Room* room, u32 flags) { } -void Room_DrawType0Mesh(PlayState* play, Room* room, u32 flags) { - RoomMeshType0* mesh; +static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; + +void Room_DrawNormal(PlayState* play, Room* room, u32 flags) { + RoomShapeNormal* roomShape; + RoomShapeDListsEntry* entry; s32 i; - RoomMeshType0Params* meshParams; - GraphicsContext* gfxCtx; - UNK_TYPE4 pad; - gfxCtx = play->state.gfxCtx; - if (flags & 1) { - func_800BCBF4(&D_801C1D10, play); - gSPSegment(gfxCtx->polyOpa.p++, 0x03, room->segment); - func_8012C268(play); - gSPMatrix(gfxCtx->polyOpa.p++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + OPEN_DISPS(play->state.gfxCtx); + + if (flags & ROOM_DRAW_OPA) { + func_800BCBF4(&sZeroVec, play); + gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); + func_8012C268(&play->state); + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); } - if (flags & 2) { - func_800BCC68(&D_801C1D10, play); - gSPSegment(gfxCtx->polyXlu.p++, 0x03, room->segment); + if (flags & ROOM_DRAW_XLU) { + func_800BCC68(&sZeroVec, play); + gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); func_8012C2DC(play->state.gfxCtx); - gSPMatrix(gfxCtx->polyXlu.p++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); } - mesh = &room->mesh->type0; - meshParams = Lib_SegmentedToVirtual(mesh->paramsStart); - for (i = 0; i < mesh->count; i++) { - if ((flags & 1) && (meshParams->opaqueDl != NULL)) { - gSPDisplayList(gfxCtx->polyOpa.p++, meshParams->opaqueDl); + roomShape = &room->roomShape->normal; + entry = Lib_SegmentedToVirtual(roomShape->entries); + for (i = 0; i < roomShape->numEntries; i++) { + if ((flags & ROOM_DRAW_OPA) && (entry->opa != NULL)) { + gSPDisplayList(POLY_OPA_DISP++, entry->opa); } - if ((flags & 2) && (meshParams->translucentDl != NULL)) { - gSPDisplayList(gfxCtx->polyXlu.p++, meshParams->translucentDl); + if ((flags & ROOM_DRAW_XLU) && (entry->xlu != NULL)) { + gSPDisplayList(POLY_XLU_DISP++, entry->xlu); } - meshParams++; + entry++; } + + CLOSE_DISPS(play->state.gfxCtx); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/Room_DrawType2Mesh.s") +typedef enum { + /* 0 */ ROOM_CULL_DEBUG_MODE_OFF, + /* 1 */ ROOM_CULL_DEBUG_MODE_UP_TO_TARGET, + /* 2 */ ROOM_CULL_DEBUG_MODE_ONLY_TARGET +} RoomCullableDebugMode; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/func_8012DEE8.s") +typedef struct RoomShapeCullableEntryLinked { + /* 0x00 */ RoomShapeCullableEntry* entry; + /* 0x04 */ f32 boundsNearZ; + /* 0x08 */ struct RoomShapeCullableEntryLinked* prev; + /* 0x0C */ struct RoomShapeCullableEntryLinked* next; +} RoomShapeCullableEntryLinked; // size = 0x10 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/func_8012E254.s") +#define ROOM_SHAPE_CULLABLE_MAX_ENTRIES 128 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/func_8012E32C.s") +void Room_DrawCullable(PlayState* play, Room* room, u32 flags) { + RoomShapeCullable* roomShape; + RoomShapeCullableEntry* roomShapeCullableEntry; + RoomShapeCullableEntryLinked linkedEntriesBuffer[ROOM_SHAPE_CULLABLE_MAX_ENTRIES]; + RoomShapeCullableEntryLinked* head = NULL; + RoomShapeCullableEntryLinked* tail = NULL; + RoomShapeCullableEntryLinked* iter; + Gfx* displayList; + RoomShapeCullableEntryLinked* insert; + f32 entryBoundsNearZ; + s32 i; + Vec3f pos; + Vec3f projectedPos; + RoomShapeCullableEntry* roomShapeCullableEntries; -void Room_DrawType1Mesh(PlayState* play, Room* room, u32 flags) { - RoomMeshType1* mesh = &room->mesh->type1; - if (mesh->format == 1) { - func_8012DEE8(play, room, flags); - } else if (mesh->format == 2) { - func_8012E32C(play, room, flags); + OPEN_DISPS(play->state.gfxCtx); + + if (flags & ROOM_DRAW_OPA) { + func_800BCBF4(&sZeroVec, play); + + gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); + if (play->roomCtx.unk74 != NULL) { + gSPSegment(POLY_OPA_DISP++, 0x06, play->roomCtx.unk74); + } + func_8012C268(&play->state); + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + } + + if (flags & ROOM_DRAW_XLU) { + func_800BCC68(&sZeroVec, play); + gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); + if (play->roomCtx.unk74 != NULL) { + gSPSegment(POLY_XLU_DISP++, 0x06, play->roomCtx.unk74); + } + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + } + + if ((room->enablePosLights != 0) || (MREG(93) != 0)) { + gSPSetGeometryMode(POLY_OPA_DISP++, G_LIGHTING_POSITIONAL); + gSPSetGeometryMode(POLY_XLU_DISP++, G_LIGHTING_POSITIONAL); + } + + roomShape = &room->roomShape->cullable; + roomShapeCullableEntry = Lib_SegmentedToVirtual(roomShape->entries); + insert = linkedEntriesBuffer; + + roomShapeCullableEntries = roomShapeCullableEntry; + + if (play->roomCtx.unk78 < 0) { + for (i = 0; i < roomShape->numEntries; i++, roomShapeCullableEntry++) { + if (R_ROOM_CULL_DEBUG_MODE != 0) { + if (((R_ROOM_CULL_DEBUG_MODE == ROOM_CULL_DEBUG_MODE_UP_TO_TARGET) && + (i <= R_ROOM_CULL_DEBUG_TARGET)) || + ((R_ROOM_CULL_DEBUG_MODE == ROOM_CULL_DEBUG_MODE_ONLY_TARGET) && (i == R_ROOM_CULL_DEBUG_TARGET))) { + if (flags & ROOM_DRAW_OPA) { + displayList = roomShapeCullableEntry->opa; + if (displayList != NULL) { + gSPDisplayList(POLY_OPA_DISP++, displayList); + } + } + + if (flags & ROOM_DRAW_XLU) { + displayList = roomShapeCullableEntry->xlu; + if (displayList != NULL) { + gSPDisplayList(POLY_XLU_DISP++, displayList); + } + } + } + } else { + if (flags & ROOM_DRAW_OPA) { + displayList = roomShapeCullableEntry->opa; + if (displayList != NULL) { + gSPDisplayList(POLY_OPA_DISP++, displayList); + } + } + + if (flags & ROOM_DRAW_XLU) { + displayList = roomShapeCullableEntry->xlu; + if (displayList != NULL) { + gSPDisplayList(POLY_XLU_DISP++, displayList); + } + } + } + } + } else { + f32 var_fa1 = 1.0f / play->projectionMtxFDiagonal.z; + f32 var_fv1; + s32 var_a1; + + // Pick and sort entries by depth + for (i = 0; i < roomShape->numEntries; i++, roomShapeCullableEntry++) { + + // Project the entry position, to get the depth it is at. + pos.x = roomShapeCullableEntry->boundsSphereCenter.x; + pos.y = roomShapeCullableEntry->boundsSphereCenter.y; + pos.z = roomShapeCullableEntry->boundsSphereCenter.z; + SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &pos, &projectedPos); + + projectedPos.z *= var_fa1; + + var_fv1 = ABS_ALT(roomShapeCullableEntry->boundsSphereRadius); + + // If the entry bounding sphere isn't fully before the rendered depth range + if (-var_fv1 < projectedPos.z) { + + // Compute the depth of the nearest point in the entry's bounding sphere + entryBoundsNearZ = projectedPos.z - var_fv1; + + // If the entry bounding sphere isn't fully beyond the rendered depth range + if (entryBoundsNearZ < play->lightCtx.zFar) { + + // This entry will be rendered + insert->entry = roomShapeCullableEntry; + + if (roomShapeCullableEntry->boundsSphereRadius < 0) { + insert->boundsNearZ = FLT_MAX; + } else { + insert->boundsNearZ = entryBoundsNearZ; + } + + // Insert into the linked list, ordered by ascending depth of the nearest point in the bounding + // sphere + iter = head; + if (iter == NULL) { + head = tail = insert; + insert->prev = insert->next = NULL; + } else { + do { + if (insert->boundsNearZ < iter->boundsNearZ) { + break; + } + iter = iter->next; + } while (iter != NULL); + + if (iter == NULL) { + insert->prev = tail; + insert->next = NULL; + tail->next = insert; + tail = insert; + } else { + insert->prev = iter->prev; + if (insert->prev == NULL) { + head = insert; + } else { + insert->prev->next = insert; + } + iter->prev = insert; + insert->next = iter; + } + } + + insert++; + } + } + } + + //! FAKE: Similar trick used in OoT + R_ROOM_CULL_NUM_ENTRIES = roomShape->numEntries & 0xFFFF & 0xFFFF & 0xFFFF; + + // Draw entries, from nearest to furthest + i = 1; + + if (flags & ROOM_DRAW_OPA) { + for (; head != NULL; head = head->next, i++) { + s32 pad; + + roomShapeCullableEntry = head->entry; + + if (R_ROOM_CULL_DEBUG_MODE != ROOM_CULL_DEBUG_MODE_OFF) { + // Debug mode drawing + + if (((R_ROOM_CULL_DEBUG_MODE == ROOM_CULL_DEBUG_MODE_UP_TO_TARGET) && + (i <= R_ROOM_CULL_DEBUG_TARGET)) || + ((R_ROOM_CULL_DEBUG_MODE == ROOM_CULL_DEBUG_MODE_ONLY_TARGET) && + (i == R_ROOM_CULL_DEBUG_TARGET))) { + + displayList = roomShapeCullableEntry->opa; + if (displayList != NULL) { + gSPDisplayList(POLY_OPA_DISP++, displayList); + } + } + } else { + displayList = roomShapeCullableEntry->opa; + if (displayList != NULL) { + gSPDisplayList(POLY_OPA_DISP++, displayList); + } + } + } + } + + if (flags & ROOM_DRAW_XLU) { + for (; tail != NULL; tail = tail->prev) { + f32 temp_fv0; + f32 temp_fv1; + + roomShapeCullableEntry = tail->entry; + displayList = roomShapeCullableEntry->xlu; + + if (displayList != NULL) { + if (roomShapeCullableEntry->boundsSphereRadius & 1) { + + temp_fv0 = tail->boundsNearZ - (f32)(iREG(93) + 0xBB8); + temp_fv1 = iREG(94) + 0x7D0; + + if (temp_fv0 < temp_fv1) { + if (temp_fv0 < 0.0f) { + var_a1 = 255; + } else { + var_a1 = 255 - (s32)((temp_fv0 / temp_fv1) * 255.0f); + } + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, var_a1); + gSPDisplayList(POLY_XLU_DISP++, displayList); + } + } else { + gSPDisplayList(POLY_XLU_DISP++, displayList); + } + } + } + } + + R_ROOM_CULL_USED_ENTRIES = i - 1; + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +#define ROOM_IMAGE_NODRAW_BACKGROUND (1 << 0) +#define ROOM_IMAGE_NODRAW_OPA (1 << 1) +#define ROOM_IMAGE_NODRAW_XLU (1 << 2) + +void Room_DrawImageSingle(PlayState* play, Room* room, u32 flags) { + Camera* activeCam; + Gfx* gfx; + RoomShapeImageSingle* roomShape; + RoomShapeDListsEntry* entry; + u32 isFixedCamera; + u32 drawBackground; + u32 drawOpa; + u32 drawXlu; + + OPEN_DISPS(play->state.gfxCtx); + + activeCam = GET_ACTIVE_CAM(play); + isFixedCamera = false; // Condition is inferred from OoT + roomShape = &room->roomShape->image.single; + entry = Lib_SegmentedToVirtual(roomShape->base.entry); + drawBackground = (flags & ROOM_DRAW_OPA) && isFixedCamera && (roomShape->source != NULL) && + !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_BACKGROUND); + drawOpa = (flags & ROOM_DRAW_OPA) && (entry->opa != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_OPA); + drawXlu = (flags & ROOM_DRAW_XLU) && (entry->xlu != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_XLU); + + if (drawOpa || drawBackground) { + gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); + + if (drawOpa) { + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(POLY_OPA_DISP++, entry->opa); + } + + if (drawBackground) { + gSPLoadUcodeL(POLY_OPA_DISP++, gspS2DEX2_fifo); + + gfx = POLY_OPA_DISP; + + { + Vec3f quakeOffset; + + Camera_GetQuakeOffset(&quakeOffset, activeCam); + + Prerender_DrawBackground2D( + &gfx, roomShape->source, roomShape->tlut, roomShape->width, roomShape->height, roomShape->fmt, + roomShape->siz, roomShape->tlutMode, roomShape->tlutCount, + (quakeOffset.x + quakeOffset.z) * 1.2f + quakeOffset.y * 0.6f, + quakeOffset.y * 2.4f + (quakeOffset.x + quakeOffset.z) * 0.3f, 1.0f, 1.0f, 0); + } + + POLY_OPA_DISP = gfx; + + gSPLoadUcode(POLY_OPA_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData()); + } + } + + if (drawXlu) { + gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(POLY_XLU_DISP++, entry->xlu); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +RoomShapeImageMultiBgEntry* Room_GetImageMultiBgEntry(RoomShapeImageMulti* roomShapeImageMulti, PlayState* play) { + Camera* activeCam = GET_ACTIVE_CAM(play); + s32 bgCamIndex = activeCam->bgCamIndex; + s16 overrideBgCamIndex; + Player* player; + RoomShapeImageMultiBgEntry* bgEntry; + s32 i; + + overrideBgCamIndex = ((BgCamFuncData*)BgCheck_GetBgCamFuncDataImpl(&play->colCtx, bgCamIndex, BGCHECK_SCENE)) + ->roomImageOverrideBgCamIndex; + if (overrideBgCamIndex >= 0) { + bgCamIndex = overrideBgCamIndex; + } + + player = GET_PLAYER(play); + player->actor.params = (player->actor.params & 0xFF00) | bgCamIndex; + + bgEntry = Lib_SegmentedToVirtual(roomShapeImageMulti->backgrounds); + for (i = 0; i < roomShapeImageMulti->numBackgrounds; i++) { + if (bgEntry->bgCamIndex == bgCamIndex) { + return bgEntry; + } + bgEntry++; + } + + __assert("../z_room.c", 849); + + return NULL; +} + +void Room_DrawImageMulti(PlayState* play, Room* room, u32 flags) { + Camera* activeCam; + Gfx* gfx; + RoomShapeImageMulti* roomShape; + RoomShapeImageMultiBgEntry* bgEntry; + RoomShapeDListsEntry* dListsEntry; + u32 isFixedCamera; + u32 drawBackground; + u32 drawOpa; + u32 drawXlu; + + OPEN_DISPS(play->state.gfxCtx); + + activeCam = GET_ACTIVE_CAM(play); + isFixedCamera = false; // Condition is inferred from OoT + roomShape = &room->roomShape->image.multi; + dListsEntry = Lib_SegmentedToVirtual(roomShape->base.entry); + + bgEntry = Room_GetImageMultiBgEntry(roomShape, play); + + drawBackground = (flags & ROOM_DRAW_OPA) && isFixedCamera && (bgEntry->source != NULL) && + !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_BACKGROUND); + drawOpa = + (flags & ROOM_DRAW_OPA) && (dListsEntry->opa != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_OPA); + drawXlu = + (flags & ROOM_DRAW_XLU) && (dListsEntry->xlu != NULL) && !(R_ROOM_IMAGE_NODRAW_FLAGS & ROOM_IMAGE_NODRAW_XLU); + + if (drawOpa || drawBackground) { + gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); + + if (drawOpa) { + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(POLY_OPA_DISP++, dListsEntry->opa); + } + + if (drawBackground) { + gSPLoadUcodeL(POLY_OPA_DISP++, gspS2DEX2_fifo); + + gfx = POLY_OPA_DISP; + + { + Vec3f quakeOffset; + + Camera_GetQuakeOffset(&quakeOffset, activeCam); + Prerender_DrawBackground2D(&gfx, bgEntry->source, bgEntry->tlut, bgEntry->width, bgEntry->height, + bgEntry->fmt, bgEntry->siz, bgEntry->tlutMode, bgEntry->tlutCount, + (quakeOffset.x + quakeOffset.z) * 1.2f + quakeOffset.y * 0.6f, + quakeOffset.y * 2.4f + (quakeOffset.x + quakeOffset.z) * 0.3f, 1.0f, 1.0f, + 0); + } + + POLY_OPA_DISP = gfx; + + gSPLoadUcode(POLY_OPA_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData()); + } + } + + if (drawXlu) { + gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); + func_8012C2DC(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(POLY_XLU_DISP++, dListsEntry->xlu); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +void Room_DrawImage(PlayState* play, Room* room, u32 flags) { + RoomShapeImageBase* roomShape = &room->roomShape->image.base; + + if (roomShape->amountType == ROOM_SHAPE_IMAGE_AMOUNT_SINGLE) { + Room_DrawImageSingle(play, room, flags); + } else if (roomShape->amountType == ROOM_SHAPE_IMAGE_AMOUNT_MULTI) { + Room_DrawImageMulti(play, room, flags); } else { __assert("../z_room.c", 965); } @@ -64,31 +467,96 @@ void Room_DrawType1Mesh(PlayState* play, Room* room, u32 flags) { void Room_Init(PlayState* play, RoomContext* roomCtx) { s32 i; + roomCtx->curRoom.num = -1; roomCtx->curRoom.segment = NULL; roomCtx->unk78 = 1; roomCtx->unk79 = 0; - for (i = 0; i < 3; i++) { + for (i = 0; i < ARRAY_COUNT(roomCtx->unk7A); i++) { roomCtx->unk7A[i] = 0; } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/Room_AllocateAndLoad.s") +size_t Room_AllocateAndLoad(PlayState* play, RoomContext* roomCtx) { + size_t maxRoomSize = 0; + size_t roomSize; + s32 i; + s32 j; + s32 frontRoom; + s32 backRoom; + size_t frontRoomSize; + size_t backRoomSize; + size_t cumulRoomSize; + s32 pad[2]; + + { + RomFile* roomList = play->roomList; + + for (i = 0; i < play->numRooms; i++) { + roomSize = roomList[i].vromEnd - roomList[i].vromStart; + maxRoomSize = MAX(roomSize, maxRoomSize); + } + } + + if ((u32)play->transitionActors.count != 0) { + RomFile* roomList = play->roomList; + TransitionActorEntry* transitionActor = &play->transitionActors.list[0]; + + for (j = 0; j < play->transitionActors.count; j++) { + frontRoom = transitionActor->sides[0].room; + backRoom = transitionActor->sides[1].room; + frontRoomSize = (frontRoom < 0) ? 0 : roomList[frontRoom].vromEnd - roomList[frontRoom].vromStart; + backRoomSize = (backRoom < 0) ? 0 : roomList[backRoom].vromEnd - roomList[backRoom].vromStart; + cumulRoomSize = (frontRoom != backRoom) ? frontRoomSize + backRoomSize : frontRoomSize; + + maxRoomSize = MAX(cumulRoomSize, maxRoomSize); + transitionActor++; + } + } + + roomCtx->roomMemPages[0] = THA_AllocTailAlign16(&play->state.heap, maxRoomSize); + if (roomCtx->roomMemPages[0] == NULL) { + __assert("../z_room.c", 1078); + } + roomCtx->roomMemPages[1] = (void*)((uintptr_t)roomCtx->roomMemPages[0] + maxRoomSize); + roomCtx->activeMemPage = 0; + roomCtx->status = 0; + + if ((gSaveContext.respawnFlag != 0) && (gSaveContext.respawnFlag != -2) && (gSaveContext.respawnFlag != -7)) { + s32 respawnMode; + + if ((gSaveContext.respawnFlag == -8) || (gSaveContext.respawnFlag == -5) || (gSaveContext.respawnFlag == -4) || + ((gSaveContext.respawnFlag < 0) && (gSaveContext.respawnFlag != -1) && (gSaveContext.respawnFlag != -6))) { + respawnMode = RESPAWN_MODE_DOWN; + } else if (gSaveContext.respawnFlag < 0) { + respawnMode = RESPAWN_MODE_TOP; + } else { + respawnMode = gSaveContext.respawnFlag - 1; + } + frontRoom = gSaveContext.respawn[respawnMode].roomIndex; + } else { + frontRoom = play->setupEntranceList[play->curSpawn].room; + } + + Room_StartRoomTransition(play, roomCtx, frontRoom); + + return maxRoomSize; +} s32 Room_StartRoomTransition(PlayState* play, RoomContext* roomCtx, s32 index) { - if (roomCtx->unk31 == 0) { - s32 size; + if (roomCtx->status == 0) { + size_t size; roomCtx->prevRoom = roomCtx->curRoom; roomCtx->curRoom.num = index; roomCtx->curRoom.segment = NULL; - roomCtx->unk31 = 1; + roomCtx->status = 1; size = play->roomList[index].vromEnd - play->roomList[index].vromStart; - roomCtx->activeRoomVram = (void*)(ALIGN16((u32)roomCtx->roomMemPages[roomCtx->activeMemPage] - + roomCtx->activeRoomVram = (void*)(ALIGN16((uintptr_t)roomCtx->roomMemPages[roomCtx->activeMemPage] - (size + 8) * roomCtx->activeMemPage - 7)); - osCreateMesgQueue(&roomCtx->loadQueue, roomCtx->loadMsg, 1); + osCreateMesgQueue(&roomCtx->loadQueue, roomCtx->loadMsg, ARRAY_COUNT(roomCtx->loadMsg)); DmaMgr_SendRequestImpl(&roomCtx->dmaRequest, roomCtx->activeRoomVram, play->roomList[index].vromStart, size, 0, &roomCtx->loadQueue, NULL); roomCtx->activeMemPage ^= 1; @@ -100,14 +568,13 @@ s32 Room_StartRoomTransition(PlayState* play, RoomContext* roomCtx, s32 index) { } s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx) { - if (roomCtx->unk31 == 1) { - if (!osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK)) { - roomCtx->unk31 = 0; + if (roomCtx->status == 1) { + if (osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) { + roomCtx->status = 0; roomCtx->curRoom.segment = roomCtx->activeRoomVram; - // TODO: Segment number enum - gSegments[0x03] = VIRTUAL_TO_PHYSICAL(roomCtx->activeRoomVram); + gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->activeRoomVram); - Scene_ProcessHeader(play, (SceneCmd*)roomCtx->curRoom.segment); + Scene_ExecuteCommands(play, roomCtx->curRoom.segment); func_80123140(play, GET_PLAYER(play)); Actor_SpawnTransitionActors(play, &play->actorCtx); @@ -127,11 +594,17 @@ s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx) { return 1; } +RoomDrawHandler sRoomDrawHandlers[] = { + Room_DrawNormal, // ROOM_SHAPE_TYPE_NORMAL + Room_DrawImage, // ROOM_SHAPE_TYPE_IMAGE + Room_DrawCullable, // ROOM_SHAPE_TYPE_CULLABLE + Room_DrawNone, // ROOM_SHAPE_TYPE_NONE +}; + void Room_Draw(PlayState* play, Room* room, u32 flags) { if (room->segment != NULL) { - // TODO: Segment number enum - gSegments[0x03] = VIRTUAL_TO_PHYSICAL(room->segment); - roomDrawFuncs[room->mesh->type0.type](play, room, flags); + gSegments[3] = VIRTUAL_TO_PHYSICAL(room->segment); + sRoomDrawHandlers[room->roomShape->base.type](play, room, flags); } return; } diff --git a/src/code/z_rumble.c b/src/code/z_rumble.c index ce5cc16b4..3cca1d432 100644 --- a/src/code/z_rumble.c +++ b/src/code/z_rumble.c @@ -68,11 +68,11 @@ void Rumble_Request(f32 distSq, u8 sourceIntensity, u8 decayTimer, u8 decayStep) void Rumble_Init(void) { RumbleManager_Init(&gRumbleMgr); - func_80174F24(Rumble_Update, NULL); + PadMgr_SetRumbleRetraceCallback(Rumble_Update, NULL); } void Rumble_Destroy(void) { - func_80174F44(Rumble_Update, NULL); + PadMgr_UnsetRumbleRetraceCallback(Rumble_Update, NULL); RumbleManager_Destroy(&gRumbleMgr); } diff --git a/src/code/z_scene.c b/src/code/z_scene.c index ac0770c80..e7edaecd1 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -48,7 +48,7 @@ void Object_InitBank(GameState* gameState, ObjectContext* objectCtx) { for (i = 0; i < OBJECT_EXCHANGE_BANK_MAX; i++) { objectCtx->status[i].id = 0; } // clang-format on - objectCtx->spaceStart = objectCtx->status[0].segment = THA_AllocEndAlign16(&gameState->heap, spaceSize); + objectCtx->spaceStart = objectCtx->status[0].segment = THA_AllocTailAlign16(&gameState->heap, spaceSize); objectCtx->spaceEnd = (void*)((u32)objectCtx->spaceStart + spaceSize); objectCtx->mainKeepIndex = Object_Spawn(objectCtx, GAMEPLAY_KEEP); @@ -141,7 +141,7 @@ void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id) { } // SceneTableEntry Header Command 0x00: Spawn List -void Scene_HeaderCmdSpawnList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandSpawnList(PlayState* play, SceneCmd* cmd) { s32 loadedCount; s16 playerObjectId; void* nextObject; @@ -149,7 +149,7 @@ void Scene_HeaderCmdSpawnList(PlayState* play, SceneCmd* cmd) { play->linkActorEntry = (ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) + play->setupEntranceList[play->curSpawn].spawn; if ((PLAYER_GET_INITMODE(play->linkActorEntry) == PLAYER_INITMODE_TELESCOPE) || - ((gSaveContext.respawnFlag == 0x02) && + ((gSaveContext.respawnFlag == 2) && (gSaveContext.respawn[RESPAWN_MODE_RETURN].playerParams == PLAYER_PARAMS(0xFF, PLAYER_INITMODE_TELESCOPE)))) { // Skull Kid Object Object_Spawn(&play->objectCtx, OBJECT_STK); @@ -168,19 +168,19 @@ void Scene_HeaderCmdSpawnList(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x01: Actor List -void Scene_HeaderCmdActorList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandActorList(PlayState* play, SceneCmd* cmd) { play->numSetupActors = cmd->actorList.num; play->setupActorList = Lib_SegmentedToVirtual(cmd->actorList.segment); - play->actorCtx.unkC = 0; + play->actorCtx.halfDaysBit = 0; } // SceneTableEntry Header Command 0x02: List of camera data for actor cutscenes -void Scene_HeaderCmdActorCutsceneCamList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandActorCutsceneCamList(PlayState* play, SceneCmd* cmd) { play->actorCsCamList = Lib_SegmentedToVirtual(cmd->actorCsCamList.segment); } // SceneTableEntry Header Command 0x03: Collision Header -void Scene_HeaderCmdColHeader(PlayState* play, SceneCmd* cmd) { +void Scene_CommandCollisionHeader(PlayState* play, SceneCmd* cmd) { CollisionHeader* colHeaderTemp; CollisionHeader* colHeader; @@ -205,18 +205,18 @@ void Scene_HeaderCmdColHeader(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x04: Room List -void Scene_HeaderCmdRoomList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandRoomList(PlayState* play, SceneCmd* cmd) { play->numRooms = cmd->roomList.num; play->roomList = Lib_SegmentedToVirtual(cmd->roomList.segment); } // SceneTableEntry Header Command 0x06: Entrance List -void Scene_HeaderCmdEntranceList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandEntranceList(PlayState* play, SceneCmd* cmd) { play->setupEntranceList = Lib_SegmentedToVirtual(cmd->entranceList.segment); } // SceneTableEntry Header Command 0x07: Special Files -void Scene_HeaderCmdSpecialFiles(PlayState* play, SceneCmd* cmd) { +void Scene_CommandSpecialFiles(PlayState* play, SceneCmd* cmd) { // @note These quest hint files are identical to OoT's. // They are not relevant in this game and the system to process these scripts has been removed. static RomFile naviQuestHintFiles[2] = { @@ -231,27 +231,27 @@ void Scene_HeaderCmdSpecialFiles(PlayState* play, SceneCmd* cmd) { } if (cmd->specialFiles.naviQuestHintFileId != NAVI_QUEST_HINTS_NONE) { - play->naviQuestHints = Play_LoadScene(play, &naviQuestHintFiles[cmd->specialFiles.naviQuestHintFileId - 1]); + play->naviQuestHints = Play_LoadFile(play, &naviQuestHintFiles[cmd->specialFiles.naviQuestHintFileId - 1]); } } // SceneTableEntry Header Command 0x08: Room Behavior -void Scene_HeaderCmdRoomBehavior(PlayState* play, SceneCmd* cmd) { - play->roomCtx.curRoom.unk3 = cmd->roomBehavior.gpFlag1; - play->roomCtx.curRoom.unk2 = cmd->roomBehavior.gpFlag2 & 0xFF; - play->roomCtx.curRoom.unk5 = (cmd->roomBehavior.gpFlag2 >> 8) & 1; +void Scene_CommandRoomBehavior(PlayState* play, SceneCmd* cmd) { + play->roomCtx.curRoom.behaviorType1 = cmd->roomBehavior.gpFlag1; + play->roomCtx.curRoom.behaviorType2 = cmd->roomBehavior.gpFlag2 & 0xFF; + play->roomCtx.curRoom.lensMode = (cmd->roomBehavior.gpFlag2 >> 8) & 1; play->msgCtx.unk12044 = (cmd->roomBehavior.gpFlag2 >> 0xA) & 1; play->roomCtx.curRoom.enablePosLights = (cmd->roomBehavior.gpFlag2 >> 0xB) & 1; play->envCtx.unk_E2 = (cmd->roomBehavior.gpFlag2 >> 0xC) & 1; } // SceneTableEntry Header Command 0x0A: Mesh Header -void Scene_HeaderCmdMesh(PlayState* play, SceneCmd* cmd) { - play->roomCtx.curRoom.mesh = Lib_SegmentedToVirtual(cmd->mesh.segment); +void Scene_CommandMesh(PlayState* play, SceneCmd* cmd) { + play->roomCtx.curRoom.roomShape = Lib_SegmentedToVirtual(cmd->mesh.segment); } // SceneTableEntry Header Command 0x0B: Object List -void Scene_HeaderCmdObjectList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandObjectList(PlayState* play, SceneCmd* cmd) { s32 i; s32 j; s32 k; @@ -277,7 +277,7 @@ void Scene_HeaderCmdObjectList(PlayState* play, SceneCmd* cmd) { } play->objectCtx.num = i; - func_800BA6FC(play, &play->actorCtx); + Actor_KillAllWithMissingObject(play, &play->actorCtx); continue; } @@ -304,7 +304,7 @@ void Scene_HeaderCmdObjectList(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x0C: Light List -void Scene_HeaderCmdLightList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandLightList(PlayState* play, SceneCmd* cmd) { s32 i; LightInfo* lightInfo = Lib_SegmentedToVirtual(cmd->lightList.segment); @@ -315,12 +315,12 @@ void Scene_HeaderCmdLightList(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x0D: Path List -void Scene_HeaderCmdPathList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandPathList(PlayState* play, SceneCmd* cmd) { play->setupPathList = Lib_SegmentedToVirtual(cmd->pathList.segment); } // SceneTableEntry Header Command 0x0E: Transition Actor List -void Scene_HeaderCmdTransiActorList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandTransiActorList(PlayState* play, SceneCmd* cmd) { play->transitionActors.count = cmd->transiActorList.num; play->transitionActors.list = Lib_SegmentedToVirtual(cmd->transiActorList.segment); func_80105818(play, play->transitionActors.count, play->transitionActors.list); @@ -332,7 +332,7 @@ void Scene_ResetTransiActorList(GameState* state, TransitionActorList* transitio } // SceneTableEntry Header Command 0x0F: Environment Light Settings List -void Scene_HeaderCmdEnvLightSettings(PlayState* play, SceneCmd* cmd) { +void Scene_CommandEnvLightSettings(PlayState* play, SceneCmd* cmd) { play->envCtx.numLightSettings = cmd->lightSettingList.num; play->envCtx.lightSettingsList = Lib_SegmentedToVirtual(cmd->lightSettingList.segment); } @@ -357,13 +357,13 @@ void Scene_LoadAreaTextures(PlayState* play, s32 fileIndex) { size_t size = sceneTextureFiles[fileIndex].vromEnd - vromStart; if (size != 0) { - play->roomCtx.unk74 = THA_AllocEndAlign16(&play->state.heap, size); + play->roomCtx.unk74 = THA_AllocTailAlign16(&play->state.heap, size); DmaMgr_SendRequest0(play->roomCtx.unk74, vromStart, size); } } // SceneTableEntry Header Command 0x11: Skybox Settings -void Scene_HeaderCmdSkyboxSettings(PlayState* play, SceneCmd* cmd) { +void Scene_CommandSkyboxSettings(PlayState* play, SceneCmd* cmd) { play->skyboxId = cmd->skyboxSettings.skyboxId & 3; play->envCtx.unk_17 = play->envCtx.unk_18 = cmd->skyboxSettings.unk5; play->envCtx.unk_1E = cmd->skyboxSettings.unk6; @@ -371,13 +371,13 @@ void Scene_HeaderCmdSkyboxSettings(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x12: Skybox Disables -void Scene_HeaderCmdSkyboxDisables(PlayState* play, SceneCmd* cmd) { +void Scene_CommandSkyboxDisables(PlayState* play, SceneCmd* cmd) { play->envCtx.skyboxDisabled = cmd->skyboxDisables.unk4; play->envCtx.sunMoonDisabled = cmd->skyboxDisables.unk5; } // SceneTableEntry Header Command 0x10: Time Settings -void Scene_HeaderCmdTimeSettings(PlayState* play, SceneCmd* cmd) { +void Scene_CommandTimeSettings(PlayState* play, SceneCmd* cmd) { if ((cmd->timeSettings.hour != 0xFF) && (cmd->timeSettings.min != 0xFF)) { gSaveContext.skyboxTime = gSaveContext.save.time = CLOCK_TIME_ALT2_F(cmd->timeSettings.hour, cmd->timeSettings.min); @@ -390,7 +390,7 @@ void Scene_HeaderCmdTimeSettings(PlayState* play, SceneCmd* cmd) { } // Increase time speed during first cycle - if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (play->envCtx.sceneTimeSpeed != 0)) { + if ((gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (play->envCtx.sceneTimeSpeed != 0)) { play->envCtx.sceneTimeSpeed = 5; } @@ -402,7 +402,7 @@ void Scene_HeaderCmdTimeSettings(PlayState* play, SceneCmd* cmd) { play->envCtx.sunPos.y = (Math_CosS(((void)0, gSaveContext.save.time) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f; play->envCtx.sunPos.z = (Math_CosS(((void)0, gSaveContext.save.time) - CLOCK_TIME(12, 0)) * 20.0f) * 25.0f; - if ((play->envCtx.sceneTimeSpeed == 0) && (gSaveContext.save.cutscene < 0xFFF0)) { + if ((play->envCtx.sceneTimeSpeed == 0) && (gSaveContext.save.cutsceneIndex < 0xFFF0)) { gSaveContext.skyboxTime = gSaveContext.save.time; if ((gSaveContext.skyboxTime >= CLOCK_TIME(4, 0)) && (gSaveContext.skyboxTime < CLOCK_TIME(6, 30))) { @@ -418,7 +418,7 @@ void Scene_HeaderCmdTimeSettings(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x05: Wind Settings -void Scene_HeaderCmdWindSettings(PlayState* play, SceneCmd* cmd) { +void Scene_CommandWindSettings(PlayState* play, SceneCmd* cmd) { s8 temp1 = cmd->windSettings.west; s8 temp2 = cmd->windSettings.vertical; s8 temp3 = cmd->windSettings.south; @@ -430,32 +430,32 @@ void Scene_HeaderCmdWindSettings(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x13: Exit List -void Scene_HeaderCmdExitList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandExitList(PlayState* play, SceneCmd* cmd) { play->setupExitList = Lib_SegmentedToVirtual(cmd->exitList.segment); } // SceneTableEntry Header Command 0x09: Undefined -void Scene_HeaderCmd09(PlayState* play, SceneCmd* cmd) { +void Scene_Command09(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x15: Sound Settings= -void Scene_HeaderCmdSoundSettings(PlayState* play, SceneCmd* cmd) { +void Scene_CommandSoundSettings(PlayState* play, SceneCmd* cmd) { play->sequenceCtx.seqId = cmd->soundSettings.seqId; play->sequenceCtx.ambienceId = cmd->soundSettings.ambienceId; if (gSaveContext.seqId == (u8)NA_BGM_DISABLED || - Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) == NA_BGM_FINAL_HOURS) { + AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_FINAL_HOURS) { Audio_SetSpec(cmd->soundSettings.specId); } } // SceneTableEntry Header Command 0x16: Echo Setting -void Scene_HeaderCmdEchoSetting(PlayState* play, SceneCmd* cmd) { +void Scene_CommandEchoSetting(PlayState* play, SceneCmd* cmd) { play->roomCtx.curRoom.echo = cmd->echoSettings.echo; } // SceneTableEntry Header Command 0x18: Alternate Header List= -void Scene_HeaderCmdAltHeaderList(PlayState* play, SceneCmd* cmd) { +void Scene_CommandAltHeaderList(PlayState* play, SceneCmd* cmd) { SceneCmd** altHeaderList; SceneCmd* altHeader; @@ -464,40 +464,40 @@ void Scene_HeaderCmdAltHeaderList(PlayState* play, SceneCmd* cmd) { altHeader = altHeaderList[gSaveContext.sceneLayer - 1]; if (altHeader != NULL) { - Scene_ProcessHeader(play, Lib_SegmentedToVirtual(altHeader)); + Scene_ExecuteCommands(play, Lib_SegmentedToVirtual(altHeader)); (cmd + 1)->base.code = 0x14; } } } -// SceneTableEntry Header Command 0x17: Cutscene List -void Scene_HeaderCmdCutsceneList(PlayState* play, SceneCmd* cmd) { - play->csCtx.sceneCsCount = cmd->cutsceneList.sceneCsCount; - play->csCtx.sceneCsList = Lib_SegmentedToVirtual(cmd->cutsceneList.segment); +// SceneTableEntry Header Command 0x17: Cutscene Script List +void Scene_CommandCutsceneScriptList(PlayState* play, SceneCmd* cmd) { + play->csCtx.scriptListCount = cmd->scriptList.scriptListCount; + play->csCtx.scriptList = Lib_SegmentedToVirtual(cmd->scriptList.segment); } -// SceneTableEntry Header Command 0x1B: Actor Cutscene List -void Scene_HeaderCmdActorCutsceneList(PlayState* play, SceneCmd* cmd) { - ActorCutscene_Init(play, Lib_SegmentedToVirtual(cmd->cutsceneActorList.segment), cmd->cutsceneActorList.num); +// SceneTableEntry Header Command 0x1B: Cutscene List +void Scene_CommandCutsceneList(PlayState* play, SceneCmd* cmd) { + CutsceneManager_Init(play, Lib_SegmentedToVirtual(cmd->cutsceneList.segment), cmd->cutsceneList.num); } // SceneTableEntry Header Command 0x1C: Mini Maps -void Scene_HeaderCmdMiniMap(PlayState* play, SceneCmd* cmd) { +void Scene_CommandMiniMap(PlayState* play, SceneCmd* cmd) { MapDisp_Init(play); func_8010549C(play, cmd->minimapSettings.segment); } // SceneTableEntry Header Command 0x1D: Undefined -void Scene_HeaderCmd1D(PlayState* play, SceneCmd* cmd) { +void Scene_Command1D(PlayState* play, SceneCmd* cmd) { } // SceneTableEntry Header Command 0x1E: Minimap Compass Icon Info -void Scene_HeaderCmdMiniMapCompassInfo(PlayState* play, SceneCmd* cmd) { +void Scene_CommandMiniMapCompassInfo(PlayState* play, SceneCmd* cmd) { func_8010565C(play, cmd->minimapChests.num, cmd->minimapChests.segment); } // SceneTableEntry Header Command 0x19: Sets Region Visited Flag -void Scene_HeaderCmdSetRegionVisitedFlag(PlayState* play, SceneCmd* cmd) { +void Scene_CommandSetRegionVisitedFlag(PlayState* play, SceneCmd* cmd) { s16 j = 0; s16 i = 0; @@ -519,13 +519,13 @@ void Scene_HeaderCmdSetRegionVisitedFlag(PlayState* play, SceneCmd* cmd) { } if (i < REGION_MAX) { - gSaveContext.save.regionsVisited = - (gBitFlags[i] | gSaveContext.save.regionsVisited) | gSaveContext.save.regionsVisited; + gSaveContext.save.saveInfo.regionsVisited = + (gBitFlags[i] | gSaveContext.save.saveInfo.regionsVisited) | gSaveContext.save.saveInfo.regionsVisited; } } // SceneTableEntry Header Command 0x1A: Material Animations -void Scene_HeaderCmdAnimatedMaterials(PlayState* play, SceneCmd* cmd) { +void Scene_CommandAnimatedMaterials(PlayState* play, SceneCmd* cmd) { play->sceneMaterialAnims = (AnimatedMaterial*)Lib_SegmentedToVirtual(cmd->textureAnimations.segment); } @@ -536,57 +536,58 @@ void Scene_SetExitFade(PlayState* play) { play->transitionType = Entrance_GetTransitionFlags(play->nextEntrance) & 0x7F; } +void (*sSceneCmdHandlers[])(PlayState*, SceneCmd*) = { + Scene_CommandSpawnList, + Scene_CommandActorList, + Scene_CommandActorCutsceneCamList, + Scene_CommandCollisionHeader, + Scene_CommandRoomList, + Scene_CommandWindSettings, + Scene_CommandEntranceList, + Scene_CommandSpecialFiles, + Scene_CommandRoomBehavior, + Scene_Command09, + Scene_CommandMesh, + Scene_CommandObjectList, + Scene_CommandLightList, + Scene_CommandPathList, + Scene_CommandTransiActorList, + Scene_CommandEnvLightSettings, + Scene_CommandTimeSettings, + Scene_CommandSkyboxSettings, + Scene_CommandSkyboxDisables, + Scene_CommandExitList, + NULL, + Scene_CommandSoundSettings, + Scene_CommandEchoSetting, + Scene_CommandCutsceneScriptList, + Scene_CommandAltHeaderList, + Scene_CommandSetRegionVisitedFlag, + Scene_CommandAnimatedMaterials, + Scene_CommandCutsceneList, + Scene_CommandMiniMap, + Scene_Command1D, + Scene_CommandMiniMapCompassInfo, +}; + /** * Executes all of the commands in a scene or room header. */ -s32 Scene_ProcessHeader(PlayState* play, SceneCmd* header) { - static void (*sceneCmdHandlers[])(PlayState*, SceneCmd*) = { - Scene_HeaderCmdSpawnList, - Scene_HeaderCmdActorList, - Scene_HeaderCmdActorCutsceneCamList, - Scene_HeaderCmdColHeader, - Scene_HeaderCmdRoomList, - Scene_HeaderCmdWindSettings, - Scene_HeaderCmdEntranceList, - Scene_HeaderCmdSpecialFiles, - Scene_HeaderCmdRoomBehavior, - Scene_HeaderCmd09, - Scene_HeaderCmdMesh, - Scene_HeaderCmdObjectList, - Scene_HeaderCmdLightList, - Scene_HeaderCmdPathList, - Scene_HeaderCmdTransiActorList, - Scene_HeaderCmdEnvLightSettings, - Scene_HeaderCmdTimeSettings, - Scene_HeaderCmdSkyboxSettings, - Scene_HeaderCmdSkyboxDisables, - Scene_HeaderCmdExitList, - NULL, - Scene_HeaderCmdSoundSettings, - Scene_HeaderCmdEchoSetting, - Scene_HeaderCmdCutsceneList, - Scene_HeaderCmdAltHeaderList, - Scene_HeaderCmdSetRegionVisitedFlag, - Scene_HeaderCmdAnimatedMaterials, - Scene_HeaderCmdActorCutsceneList, - Scene_HeaderCmdMiniMap, - Scene_HeaderCmd1D, - Scene_HeaderCmdMiniMapCompassInfo, - }; +s32 Scene_ExecuteCommands(PlayState* play, SceneCmd* sceneCmd) { u32 cmdId; while (true) { - cmdId = header->base.code; + cmdId = sceneCmd->base.code; if (cmdId == SCENE_CMD_ID_END) { break; } if (cmdId < SCENE_CMD_MAX) { - sceneCmdHandlers[cmdId](play, header); + sSceneCmdHandlers[cmdId](play, sceneCmd); } - header++; + sceneCmd++; } return 0; @@ -600,8 +601,8 @@ u16 Entrance_Create(s32 scene, s32 spawn, s32 layer) { } /** - * Creates an layer 0 entranace from the current entrance and the given spawn. + * Creates an layer 0 entrance from the current entrance and the given spawn. */ u16 Entrance_CreateFromSpawn(s32 spawn) { - return Entrance_Create(gSaveContext.save.entrance >> 9, spawn, 0); + return Entrance_Create((u32)gSaveContext.save.entrance >> 9, spawn, 0); } diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index 67f503e58..6ec3f2b80 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" s32 sMatAnimStep; @@ -22,7 +23,7 @@ static Gfx sSceneDrawDefaultDL[] = { /** * Executes the current scene draw config handler. */ -void Scene_ExecuteDrawConfig(PlayState* play) { +void Scene_Draw(PlayState* play) { static void (*sceneDrawConfigHandlers[])(PlayState*) = { Scene_DrawConfigDefault, Scene_DrawConfigMatAnim, diff --git a/src/code/z_scene_table.c b/src/code/z_scene_table.c index ed4549966..f80ad551d 100644 --- a/src/code/z_scene_table.c +++ b/src/code/z_scene_table.c @@ -1,10 +1,10 @@ #include "global.h" #define SCENE_ENTRY(name, textId, config) \ - { { SEGMENT_ROM_START(name), SEGMENT_ROM_END(name) }, textId, 0, config, 0 } + { { SEGMENT_ROM_START(name), SEGMENT_ROM_END(name) }, textId, 0, config, 0, 0 } #define SCENE_ENTRY_NONE() \ - { { 0, 0 }, 0, 0, 0, 0 } + { { 0, 0 }, 0, 0, 0, 0, 0 } SceneTableEntry gSceneTable[] = { /* 0x00 */ SCENE_ENTRY(Z2_20SICHITAI2, 0x0116, SCENE_DRAW_CFG_MAT_ANIM), diff --git a/src/code/z_shrink_window.c b/src/code/z_shrink_window.c index 21d8bde40..c4084a18c 100644 --- a/src/code/z_shrink_window.c +++ b/src/code/z_shrink_window.c @@ -3,6 +3,7 @@ * Description: Draws black top/bottom/side borders on the viewing window (e.g. Z-targeting, talking to NPC) */ +#include "prevent_bss_reordering.h" #include "global.h" #include "z64shrink_window.h" diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 318f49809..085cb4de2 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1,18 +1,26 @@ +#include "prevent_bss_reordering.h" #include "global.h" #define ANIM_INTERP 1 -s32 LinkAnimation_Loop(PlayState* play, SkelAnime* skelAnime); -s32 LinkAnimation_Once(PlayState* play, SkelAnime* skelAnime); +s32 PlayerAnimation_Loop(PlayState* play, SkelAnime* skelAnime); +s32 PlayerAnimation_Once(PlayState* play, SkelAnime* skelAnime); s32 SkelAnime_LoopFull(SkelAnime* skelAnime); s32 SkelAnime_LoopPartial(SkelAnime* skelAnime); s32 SkelAnime_Once(SkelAnime* skelAnime); void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animation); void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* diff, s16 angle); -void LinkAnimation_Change(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, - f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames); +void PlayerAnimation_Change(PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation, f32 playSpeed, + f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); +void AnimationContext_LoadFrame(struct PlayState* play, AnimationEntryData* data); +void AnimationContext_CopyAll(struct PlayState* play, AnimationEntryData* data); +void AnimationContext_Interp(struct PlayState* play, AnimationEntryData* data); +void AnimationContext_CopyTrue(struct PlayState* play, AnimationEntryData* data); +void AnimationContext_CopyFalse(struct PlayState* play, AnimationEntryData* data); +void AnimationContext_MoveActor(struct PlayState* play, AnimationEntryData* data); + static AnimationEntryCallback sAnimationLoadDone[] = { AnimationContext_LoadFrame, AnimationContext_CopyAll, AnimationContext_Interp, AnimationContext_CopyTrue, AnimationContext_CopyFalse, AnimationContext_MoveActor, @@ -43,7 +51,7 @@ void SkelAnime_DrawLimbLod(PlayState* play, s32 limbIndex, void** skeleton, Vec3 pos.z = limb->jointPos.z; dList = limb->dLists[lod]; - if ((overrideLimbDraw == NULL) || (overrideLimbDraw(play, limbIndex, &dList, &pos, &rot, actor) == 0)) { + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &dList, &pos, &rot, actor)) { Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -629,7 +637,8 @@ void SkelAnime_GetFrameData(AnimationHeader* animation, s32 frame, s32 limbCount frameTable->x = jointIndices->x >= staticIndexMax ? dynamicData[jointIndices->x] : frameData[jointIndices->x]; frameTable->y = jointIndices->y >= staticIndexMax ? dynamicData[jointIndices->y] : frameData[jointIndices->y]; frameTable->z = jointIndices->z >= staticIndexMax ? dynamicData[jointIndices->z] : frameData[jointIndices->z]; - jointIndices++, frameTable++; + jointIndices++; + frameTable++; } } @@ -874,7 +883,7 @@ Gfx* SkelAnime_DrawFlex(PlayState* play, void** skeleton, Vec3s* jointTable, s32 s16 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Vec3s* frameTable) { LegacyAnimationHeader* animHeader = Lib_SegmentedToVirtual(animation); s16 limbCount = animHeader->limbCount; - JointKey* key = Lib_SegmentedToVirtual(animHeader->jointKey); + LegacyJointKey* key = Lib_SegmentedToVirtual(animHeader->jointKey); s16* frameData = Lib_SegmentedToVirtual(animHeader->frameData); s16* staticData = &frameData[0]; s16* dynamicData = &frameData[frame]; @@ -899,7 +908,7 @@ s16 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Ve /** * Used by legacy animation format */ -s16 Animation_GetLimbCount2(LegacyAnimationHeader* animation) { +s16 Animation_GetLimbCountLegacy(LegacyAnimationHeader* animation) { LegacyAnimationHeader* animHeader = Lib_SegmentedToVirtual(animation); return animHeader->limbCount; @@ -908,7 +917,7 @@ s16 Animation_GetLimbCount2(LegacyAnimationHeader* animation) { /** * Used by legacy animation format */ -s16 Animation_GetLength2(LegacyAnimationHeader* animation) { +s16 Animation_GetLengthLegacy(LegacyAnimationHeader* animation) { LegacyAnimationHeader* animHeader = Lib_SegmentedToVirtual(animation); return animHeader->frameCount; @@ -917,7 +926,7 @@ s16 Animation_GetLength2(LegacyAnimationHeader* animation) { /** * Used by legacy animation format */ -s16 Animation_GetLastFrame2(LegacyAnimationHeader* animation) { +s16 Animation_GetLastFrameLegacy(LegacyAnimationHeader* animation) { AnimationHeaderCommon* animHeader = Lib_SegmentedToVirtual(animation); return animHeader->frameCount - 1; @@ -977,7 +986,7 @@ AnimationEntry* AnimationContext_AddEntry(AnimationContext* animationCtx, Animat AnimationEntry* entry; s16 index = animationCtx->animationCount; - if (index >= ANIMATION_ENTRY_MAX) { + if (index >= ARRAY_COUNT(animationCtx->entries)) { return NULL; } @@ -987,21 +996,25 @@ AnimationEntry* AnimationContext_AddEntry(AnimationContext* animationCtx, Animat return entry; } +#define LINK_ANIMETION_OFFSET(addr, offset) \ + (SEGMENT_ROM_START(link_animetion) + ((uintptr_t)addr & 0xFFFFFF) + ((u32)offset)) + /** - * Requests loading frame data from the Link animation into frameTable + * Requests loading frame data from the Player animation into frameTable */ -void AnimationContext_SetLoadFrame(PlayState* play, LinkAnimationHeader* animation, s32 frame, s32 limbCount, +void AnimationContext_SetLoadFrame(PlayState* play, PlayerAnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable) { AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMATION_LINKANIMETION); if (entry != NULL) { - LinkAnimationHeader* linkAnimHeader = Lib_SegmentedToVirtual(animation); - uintptr_t ram = frameTable; + PlayerAnimationHeader* playerAnimHeader = Lib_SegmentedToVirtual(animation); + void* ram = (void*)frameTable; - osCreateMesgQueue(&entry->data.load.msgQueue, &entry->data.load.msg, 1); - DmaMgr_SendRequestImpl(&entry->data.load.req, ram, - LINK_ANIMETION_OFFSET(linkAnimHeader->segment, (sizeof(Vec3s) * limbCount + 2) * frame), - sizeof(Vec3s) * limbCount + 2, 0, &entry->data.load.msgQueue, NULL); + osCreateMesgQueue(&entry->data.load.msgQueue, entry->data.load.msg, ARRAY_COUNT(entry->data.load.msg)); + DmaMgr_SendRequestImpl( + &entry->data.load.req, ram, + LINK_ANIMETION_OFFSET(playerAnimHeader->linkAnimSegment, (sizeof(Vec3s) * limbCount + sizeof(s16)) * frame), + sizeof(Vec3s) * limbCount + sizeof(s16), 0, &entry->data.load.msgQueue, NULL); } } @@ -1078,7 +1091,7 @@ void AnimationContext_SetMoveActor(PlayState* play, Actor* actor, SkelAnime* ske } /** - * Receives the request for Link's animation frame data + * Receives the request for Player's animation frame data */ void AnimationContext_LoadFrame(PlayState* play, AnimationEntryData* data) { AnimEntryLoadFrame* entry = &data->load; @@ -1183,12 +1196,12 @@ void AnimationContext_Update(PlayState* play, AnimationContext* animationCtx) { } /** - * Initializes a skeleton to be used with Link animations to a looping animation, dynamically allocating the frame + * Initializes a skeleton to be used with Player animations to a looping animation, dynamically allocating the frame * tables if not given. */ -void SkelAnime_InitLink(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, - LinkAnimationHeader* animation, s32 flags, void* jointTableBuffer, void* morphTableBuffer, - s32 limbBufCount) { +void SkelAnime_InitPlayer(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, + PlayerAnimationHeader* animation, s32 flags, void* jointTableBuffer, void* morphTableBuffer, + s32 limbBufCount) { FlexSkeletonHeader* skeletonHeader; s32 headerJointCount; s32 limbCount; @@ -1213,7 +1226,7 @@ void SkelAnime_InitLink(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeade allocSize = sizeof(Vec3s) * limbCount; if (flags & 8) { - allocSize += 2; + allocSize += sizeof(u16); } if (jointTableBuffer == NULL) { @@ -1224,52 +1237,52 @@ void SkelAnime_InitLink(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeade skelAnime->morphTable = (void*)ALIGN16((uintptr_t)morphTableBuffer); } - LinkAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f); + PlayerAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f); } /** - * Sets the update function of a SkelAnime that uses Link animations based on its mode + * Sets the update function of a SkelAnime that uses Player animations based on its mode */ -void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime) { +void PlayerAnimation_SetUpdateFunction(SkelAnime* skelAnime) { if (skelAnime->mode <= ANIMMODE_LOOP_INTERP) { - skelAnime->update.link = LinkAnimation_Loop; + skelAnime->update.player = PlayerAnimation_Loop; } else { - skelAnime->update.link = LinkAnimation_Once; + skelAnime->update.player = PlayerAnimation_Once; } skelAnime->morphWeight = 0.0f; } /** - * Advances the current Link animation and updates all frame tables. If the animation plays once, returns true when it + * Advances the current Player animation and updates all frame tables. If the animation plays once, returns true when it * finishes. */ -s32 LinkAnimation_Update(PlayState* play, SkelAnime* skelAnime) { - return skelAnime->update.link(play, skelAnime); +s32 PlayerAnimation_Update(PlayState* play, SkelAnime* skelAnime) { + return skelAnime->update.player(play, skelAnime); } /** * Requests an interpolation between the pose in jointTable to the one in morphTable, advancing the morph but not the * animation frame */ -s32 LinkAnimation_Morph(PlayState* play, SkelAnime* skelAnime) { +s32 PlayerAnimation_Morph(PlayState* play, SkelAnime* skelAnime) { f32 prevMorphWeight = skelAnime->morphWeight; f32 updateRate = (s32)play->state.framerateDivisor * 0.5f; skelAnime->morphWeight -= skelAnime->morphRate * updateRate; if (skelAnime->morphWeight <= 0.0f) { - LinkAnimation_SetUpdateFunction(skelAnime); + PlayerAnimation_SetUpdateFunction(skelAnime); } AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, 1.0f - (skelAnime->morphWeight / prevMorphWeight)); - return 0; + return false; } /** - * Requests a load of the next frame of a Link animation, advances the morph, and requests an interpolation between + * Requests a load of the next frame of a Player animation, advances the morph, and requests an interpolation between * jointTable and morphTable */ -void LinkAnimation_AnimateFrame(PlayState* play, SkelAnime* skelAnime) { +void PlayerAnimation_AnimateFrame(PlayState* play, SkelAnime* skelAnime) { AnimationContext_SetLoadFrame(play, skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, skelAnime->jointTable); if (skelAnime->morphWeight != 0) { @@ -1285,9 +1298,9 @@ void LinkAnimation_AnimateFrame(PlayState* play, SkelAnime* skelAnime) { } /** - * Advances a Link animation that loops over its full length + * Advances a Player animation that loops over its full length */ -s32 LinkAnimation_Loop(PlayState* play, SkelAnime* skelAnime) { +s32 PlayerAnimation_Loop(PlayState* play, SkelAnime* skelAnime) { f32 updateRate = (s32)play->state.framerateDivisor * 0.5f; skelAnime->curFrame += skelAnime->playSpeed * updateRate; @@ -1296,19 +1309,19 @@ s32 LinkAnimation_Loop(PlayState* play, SkelAnime* skelAnime) { } else if (skelAnime->animLength <= skelAnime->curFrame) { skelAnime->curFrame -= skelAnime->animLength; } - LinkAnimation_AnimateFrame(play, skelAnime); - return 0; + PlayerAnimation_AnimateFrame(play, skelAnime); + return false; } /** - * Advances a Link animation that stops at endFrame and returns true when it is reached. + * Advances a Player animation that stops at endFrame and returns true when it is reached. */ -s32 LinkAnimation_Once(PlayState* play, SkelAnime* skelAnime) { +s32 PlayerAnimation_Once(PlayState* play, SkelAnime* skelAnime) { f32 updateRate = (s32)play->state.framerateDivisor * 0.5f; if (skelAnime->curFrame == skelAnime->endFrame) { - LinkAnimation_AnimateFrame(play, skelAnime); - return 1; + PlayerAnimation_AnimateFrame(play, skelAnime); + return true; } skelAnime->curFrame += skelAnime->playSpeed * updateRate; @@ -1322,8 +1335,8 @@ s32 LinkAnimation_Once(PlayState* play, SkelAnime* skelAnime) { skelAnime->curFrame -= skelAnime->animLength; } } - LinkAnimation_AnimateFrame(play, skelAnime); - return 0; + PlayerAnimation_AnimateFrame(play, skelAnime); + return false; } /** @@ -1335,28 +1348,28 @@ void Animation_SetMorph(PlayState* play, SkelAnime* skelAnime, f32 morphFrames) } /** - * General way to set a new Link animation, allowing choice of playback speed, start frame, end frame, play mode, and + * General way to set a new Player animation, allowing choice of playback speed, start frame, end frame, play mode, and * number of transition frames. Positive morph frames morph from the current pose to the start pose of the new * animation, then start the new animation. Negative morph frames start the new animation immediately, modified by the * pose immediately before the animation change. */ -void LinkAnimation_Change(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, - f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames) { +void PlayerAnimation_Change(PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation, f32 playSpeed, + f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames) { skelAnime->mode = mode; if ((morphFrames != 0.0f) && ((animation != skelAnime->animation) || (startFrame != skelAnime->curFrame))) { if (morphFrames < 0) { - LinkAnimation_SetUpdateFunction(skelAnime); + PlayerAnimation_SetUpdateFunction(skelAnime); SkelAnime_CopyFrameTable(skelAnime, skelAnime->morphTable, skelAnime->jointTable); morphFrames = -morphFrames; } else { - skelAnime->update.link = LinkAnimation_Morph; + skelAnime->update.player = PlayerAnimation_Morph; AnimationContext_SetLoadFrame(play, animation, (s32)startFrame, skelAnime->limbCount, skelAnime->morphTable); } skelAnime->morphWeight = 1.0f; skelAnime->morphRate = 1.0f / morphFrames; } else { - LinkAnimation_SetUpdateFunction(skelAnime); + PlayerAnimation_SetUpdateFunction(skelAnime); AnimationContext_SetLoadFrame(play, animation, (s32)startFrame, skelAnime->limbCount, skelAnime->jointTable); skelAnime->morphWeight = 0.0f; } @@ -1371,79 +1384,80 @@ void LinkAnimation_Change(PlayState* play, SkelAnime* skelAnime, LinkAnimationHe } /** - * Immediately changes to a Link animation that plays once at the default speed. + * Immediately changes to a Player animation that plays once at the default speed. */ -void LinkAnimation_PlayOnce(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation) { - LinkAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common), - ANIMMODE_ONCE, 0.0f); +void PlayerAnimation_PlayOnce(PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation) { + PlayerAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common), + ANIMMODE_ONCE, 0.0f); } /** - * Immediately changes to a Link animation that plays once at the specified speed. + * Immediately changes to a Player animation that plays once at the specified speed. */ -void LinkAnimation_PlayOnceSetSpeed(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, - f32 playSpeed) { - LinkAnimation_Change(play, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common), - ANIMMODE_ONCE, 0.0f); +void PlayerAnimation_PlayOnceSetSpeed(PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation, + f32 playSpeed) { + PlayerAnimation_Change(play, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common), + ANIMMODE_ONCE, 0.0f); } /** - * Immediately changes to a Link animation that loops at the default speed. + * Immediately changes to a Player animation that loops at the default speed. */ -void LinkAnimation_PlayLoop(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation) { - LinkAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common), - ANIMMODE_LOOP, 0.0f); +void PlayerAnimation_PlayLoop(PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation) { + PlayerAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common), + ANIMMODE_LOOP, 0.0f); } /** - * Immediately changes to a Link animation that loops at the specified speed. + * Immediately changes to a Player animation that loops at the specified speed. */ -void LinkAnimation_PlayLoopSetSpeed(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, - f32 playSpeed) { - LinkAnimation_Change(play, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common), - ANIMMODE_LOOP, 0.0f); +void PlayerAnimation_PlayLoopSetSpeed(PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation, + f32 playSpeed) { + PlayerAnimation_Change(play, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common), + ANIMMODE_LOOP, 0.0f); } /** * Requests copying jointTable to morphTable */ -void LinkAnimation_CopyJointToMorph(PlayState* play, SkelAnime* skelAnime) { +void PlayerAnimation_CopyJointToMorph(PlayState* play, SkelAnime* skelAnime) { AnimationContext_SetCopyAll(play, skelAnime->limbCount, skelAnime->morphTable, skelAnime->jointTable); } /** * Requests copying morphTable to jointTable */ -void LinkAnimation_CopyMorphToJoint(PlayState* play, SkelAnime* skelAnime) { +void PlayerAnimation_CopyMorphToJoint(PlayState* play, SkelAnime* skelAnime) { AnimationContext_SetCopyAll(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable); } /** - * Requests loading frame data from the Link animation into morphTable + * Requests loading frame data from the Player animation into morphTable */ -void LinkAnimation_LoadToMorph(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame) { +void PlayerAnimation_LoadToMorph(PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation, f32 frame) { AnimationContext_SetLoadFrame(play, animation, (s32)frame, skelAnime->limbCount, skelAnime->morphTable); } /** - * Requests loading frame data from the Link animation into jointTable + * Requests loading frame data from the Player animation into jointTable */ -void LinkAnimation_LoadToJoint(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame) { +void PlayerAnimation_LoadToJoint(PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation, f32 frame) { AnimationContext_SetLoadFrame(play, animation, (s32)frame, skelAnime->limbCount, skelAnime->jointTable); } /** * Requests interpolating between jointTable and morphTable, placing the result in jointTable */ -void LinkAnimation_InterpJointMorph(PlayState* play, SkelAnime* skelAnime, f32 weight) { +void PlayerAnimation_InterpJointMorph(PlayState* play, SkelAnime* skelAnime, f32 weight) { AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, weight); } /** - * Requests loading frame data from the Link animations and blending them, placing the result in jointTable + * Requests loading frame data from the Player animations and blending them, placing the result in jointTable */ -void LinkAnimation_BlendToJoint(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, - LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, void* blendTableBuffer) { +void PlayerAnimation_BlendToJoint(PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation1, f32 frame1, + PlayerAnimationHeader* animation2, f32 frame2, f32 blendWeight, + void* blendTableBuffer) { void* alignedBlendTable; AnimationContext_SetLoadFrame(play, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->jointTable); @@ -1455,10 +1469,11 @@ void LinkAnimation_BlendToJoint(PlayState* play, SkelAnime* skelAnime, LinkAnima } /** - * Requests loading frame data from the Link animations and blending them, placing the result in morphTable + * Requests loading frame data from the Player animations and blending them, placing the result in morphTable */ -void LinkAnimation_BlendToMorph(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, - LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, void* blendTableBuffer) { +void PlayerAnimation_BlendToMorph(PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation1, f32 frame1, + PlayerAnimationHeader* animation2, f32 frame2, f32 blendWeight, + void* blendTableBuffer) { void* alignedBlendTable; AnimationContext_SetLoadFrame(play, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->morphTable); @@ -1472,9 +1487,9 @@ void LinkAnimation_BlendToMorph(PlayState* play, SkelAnime* skelAnime, LinkAnima /** * Changes a looping animation to one that stops at the end. */ -void LinkAnimation_EndLoop(SkelAnime* skelAnime) { +void PlayerAnimation_EndLoop(SkelAnime* skelAnime) { skelAnime->mode = ANIMMODE_ONCE; - LinkAnimation_SetUpdateFunction(skelAnime); + PlayerAnimation_SetUpdateFunction(skelAnime); } /** @@ -1505,9 +1520,9 @@ s32 Animation_OnFrameImpl(SkelAnime* skelAnime, f32 frame, f32 updateRate) { } /** - * Checks if the current Link animation has reached the specified frame + * Checks if the current Player animation has reached the specified frame */ -s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 frame) { +s32 PlayerAnimation_OnFrame(SkelAnime* skelAnime, f32 frame) { f32 updateRate = gFramerateDivisorHalf; return Animation_OnFrameImpl(skelAnime, frame, updateRate); @@ -1576,7 +1591,7 @@ void SkelAnime_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHead skelAnime->morphTable = ZeldaArena_Malloc(sizeof(*skelAnime->morphTable) * skelAnime->limbCount); // Debug prints here, required to match. - if (1) {}; + if (1) {} if (animation != NULL) { Animation_PlayLoop(skelAnime, animation); @@ -1618,7 +1633,7 @@ s32 SkelAnime_Morph(SkelAnime* skelAnime) { } SkelAnime_InterpFrameTable(skelAnime->limbCount, skelAnime->jointTable, skelAnime->jointTable, skelAnime->morphTable, 1.0f - (skelAnime->morphWeight / prevMorphWeight)); - return 0; + return false; } /** @@ -1652,7 +1667,7 @@ s32 SkelAnime_MorphTaper(SkelAnime* skelAnime) { } SkelAnime_InterpFrameTable(skelAnime->limbCount, skelAnime->jointTable, skelAnime->jointTable, skelAnime->morphTable, 1.0f - curWeight); - return 0; + return false; } /** @@ -1699,7 +1714,7 @@ s32 SkelAnime_LoopFull(SkelAnime* skelAnime) { } SkelAnime_AnimateFrame(skelAnime); - return 0; + return false; } /** @@ -1716,7 +1731,7 @@ s32 SkelAnime_LoopPartial(SkelAnime* skelAnime) { } SkelAnime_AnimateFrame(skelAnime); - return 0; + return false; } /** @@ -1728,7 +1743,7 @@ s32 SkelAnime_Once(SkelAnime* skelAnime) { if (skelAnime->curFrame == skelAnime->endFrame) { SkelAnime_GetFrameData(skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, skelAnime->jointTable); SkelAnime_AnimateFrame(skelAnime); - return 1; + return true; } skelAnime->curFrame += skelAnime->playSpeed * updateRate; @@ -1744,7 +1759,7 @@ s32 SkelAnime_Once(SkelAnime* skelAnime) { } } SkelAnime_AnimateFrame(skelAnime); - return 0; + return false; } /** diff --git a/src/code/z_skin.c b/src/code/z_skin.c index 0d3e0bf85..9bfd8d566 100644 --- a/src/code/z_skin.c +++ b/src/code/z_skin.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #include "z64skin.h" diff --git a/src/code/z_snap.c b/src/code/z_snap.c index 5d37e3eac..9361cc1e0 100644 --- a/src/code/z_snap.c +++ b/src/code/z_snap.c @@ -18,11 +18,11 @@ s32 Snap_RecordPictographedActors(PlayState* play) { s32 seen; s32 validCount = 0; - gSaveContext.save.pictoFlags0 = 0; - gSaveContext.save.pictoFlags1 = 0; + gSaveContext.save.saveInfo.pictoFlags0 = 0; + gSaveContext.save.saveInfo.pictoFlags1 = 0; if (play->sceneId == SCENE_20SICHITAI) { - Snap_SetFlag(PICTOGRAPH_IN_SWAMP); + Snap_SetFlag(PICTO_VALID_IN_SWAMP); } for (; category < ACTORCAT_MAX; category++) { @@ -42,9 +42,8 @@ s32 Snap_RecordPictographedActors(PlayState* play) { break; } - if (actor->id) { - ; // Needed to match - } + //! FAKE: + if (1) {} // Actors which may be pictographed anywhere switch (actor->id) { @@ -92,20 +91,20 @@ s32 Snap_RecordPictographedActors(PlayState* play) { // Only used in this file void Snap_SetFlag(s32 flag) { if (flag < 0x20) { - gSaveContext.save.pictoFlags0 |= (1 << flag); + gSaveContext.save.saveInfo.pictoFlags0 |= (1 << flag); } else { flag &= 0x1F; - gSaveContext.save.pictoFlags1 |= (1 << flag); + gSaveContext.save.saveInfo.pictoFlags1 |= (1 << flag); } } // Unused void Snap_UnsetFlag(s32 flag) { if (flag < 0x20) { - gSaveContext.save.pictoFlags0 &= ~(1 << flag); + gSaveContext.save.saveInfo.pictoFlags0 &= ~(1 << flag); } else { flag &= 0x1F; - gSaveContext.save.pictoFlags1 &= ~(1 << flag); + gSaveContext.save.saveInfo.pictoFlags1 &= ~(1 << flag); } } @@ -113,10 +112,10 @@ u32 Snap_CheckFlag(s32 flag) { SaveContext* saveCtx = &gSaveContext; if (flag < 0x20) { - return saveCtx->save.pictoFlags0 & (1 << flag); + return saveCtx->save.saveInfo.pictoFlags0 & (1 << flag); } else { flag &= 0x1F; - return saveCtx->save.pictoFlags1 & (1 << flag); + return saveCtx->save.saveInfo.pictoFlags1 & (1 << flag); } } @@ -155,43 +154,43 @@ s32 Snap_ValidatePictograph(PlayState* play, Actor* actor, s32 flag, Vec3f* pos, // Check distance distance = OLib_Vec3fDist(pos, &camera->eye); if ((distance < distanceMin) || (distanceMax < distance)) { - Snap_SetFlag(PICTOGRAPH_BAD_DISTANCE); - ret = PICTOGRAPH_BAD_DISTANCE; + Snap_SetFlag(PICTO_VALID_BAD_DISTANCE); + ret = PICTO_VALID_BAD_DISTANCE; } // Check rot is facing camera? x = Snap_AbsS(Camera_GetCamDirPitch(camera) + rot->x); y = Snap_AbsS(Camera_GetCamDirYaw(camera) - BINANG_SUB(rot->y, 0x7FFF)); if ((0 < angleRange) && ((angleRange < x) || (angleRange < y))) { - Snap_SetFlag(PICTOGRAPH_BAD_ANGLE); - ret |= PICTOGRAPH_BAD_ANGLE; + Snap_SetFlag(PICTO_VALID_BAD_ANGLE); + ret |= PICTO_VALID_BAD_ANGLE; } // Check in capture region Actor_GetProjectedPos(play, pos, &projectedPos, &distance); // Convert to projected position to device coordinates, shift to be relative to the capture region's top-left corner - x = (s16)PROJECTED_TO_SCREEN_X(projectedPos, distance) - PICTO_CAPTURE_REGION_TOPLEFT_X; - y = (s16)PROJECTED_TO_SCREEN_Y(projectedPos, distance) - PICTO_CAPTURE_REGION_TOPLEFT_Y; + x = (s16)PROJECTED_TO_SCREEN_X(projectedPos, distance) - PICTO_VALID_TOPLEFT_X; + y = (s16)PROJECTED_TO_SCREEN_Y(projectedPos, distance) - PICTO_VALID_TOPLEFT_Y; // checks if the coordinates are within the capture region - if ((x < 0) || (x > PICTO_RESOLUTION_HORIZONTAL) || (y < 0) || (y > PICTO_RESOLUTION_VERTICAL)) { - Snap_SetFlag(PICTOGRAPH_NOT_IN_VIEW); - ret |= PICTOGRAPH_NOT_IN_VIEW; + if ((x < 0) || (x > PICTO_VALID_WIDTH) || (y < 0) || (y > PICTO_VALID_HEIGHT)) { + Snap_SetFlag(PICTO_VALID_NOT_IN_VIEW); + ret |= PICTO_VALID_NOT_IN_VIEW; } // Check not obscured by bg collision if (BgCheck_ProjectileLineTest(&play->colCtx, pos, &camera->eye, &projectedPos, &poly, true, true, true, true, &bgId)) { - Snap_SetFlag(PICTOGRAPH_BEHIND_BG); - ret |= PICTOGRAPH_BEHIND_BG; + Snap_SetFlag(PICTO_VALID_BEHIND_BG); + ret |= PICTO_VALID_BEHIND_BG; } // Check not obscured by actor collision actors[0] = actor; actors[1] = &GET_PLAYER(play)->actor; if (CollisionCheck_LineOCCheck(play, &play->colChkCtx, pos, &camera->eye, actors, 2)) { - Snap_SetFlag(PICTOGRAPH_BEHIND_COLLISION); - ret |= PICTOGRAPH_BEHIND_COLLISION; + Snap_SetFlag(PICTO_VALID_BEHIND_COLLISION); + ret |= PICTO_VALID_BEHIND_COLLISION; } // If all of the above checks pass, set the flag diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 94d0e69c3..c10c1943e 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #include "overlays/gamestates/ovl_file_choose/z_file_choose.h" @@ -133,7 +134,7 @@ u32 D_801C5FC0[SCENE_MAX][4] = { // TODO: figure out a way to use the WEEKEVENTREG defines here // weekEventReg flags which will be not be cleared on a cycle reset -u16 D_801C66D0[ARRAY_COUNT(gSaveContext.save.weekEventReg)] = { +u16 D_801C66D0[ARRAY_COUNT(gSaveContext.save.saveInfo.weekEventReg)] = { /* 0 */ 0xFFFC, /* 1 */ 0xFFFF, /* 2 */ 0xFFFF, @@ -295,24 +296,24 @@ u16 D_801F6AF0; u8 D_801F6AF2; void Sram_ActivateOwl(u8 owlId) { - gSaveContext.save.playerData.owlActivationFlags = - ((void)0, gSaveContext.save.playerData.owlActivationFlags) | (u16)gBitFlags[owlId]; + gSaveContext.save.saveInfo.playerData.owlActivationFlags = + ((void)0, gSaveContext.save.saveInfo.playerData.owlActivationFlags) | (u16)gBitFlags[owlId]; - if (gSaveContext.save.playerData.unk_20 == 0xFF) { - gSaveContext.save.playerData.unk_20 = owlId; + if (gSaveContext.save.saveInfo.playerData.unk_20 == 0xFF) { + gSaveContext.save.saveInfo.playerData.unk_20 = owlId; } } void Sram_ClearHighscores(void) { - gSaveContext.save.unk_EE8 = (gSaveContext.save.unk_EE8 & 0xFFFF) | 0x130000; - gSaveContext.save.unk_EE8 = (gSaveContext.save.unk_EE8 & 0xFFFF0000) | 0xA; - gSaveContext.save.horseBackBalloonHighScore = SECONDS_TO_TIMER(60); + gSaveContext.save.saveInfo.unk_EC4 = (gSaveContext.save.saveInfo.unk_EC4 & 0xFFFF) | 0x130000; + gSaveContext.save.saveInfo.unk_EC4 = (gSaveContext.save.saveInfo.unk_EC4 & 0xFFFF0000) | 0xA; + gSaveContext.save.saveInfo.horseBackBalloonHighScore = SECONDS_TO_TIMER(60); SET_TOWN_SHOOTING_GALLERY_HIGH_SCORE(39); SET_SWAMP_SHOOTING_GALLERY_HIGH_SCORE(10); - gSaveContext.save.dekuPlaygroundHighScores[0] = SECONDS_TO_TIMER(75); - gSaveContext.save.dekuPlaygroundHighScores[1] = SECONDS_TO_TIMER(75); - gSaveContext.save.dekuPlaygroundHighScores[2] = SECONDS_TO_TIMER(76); + gSaveContext.save.saveInfo.dekuPlaygroundHighScores[0] = SECONDS_TO_TIMER(75); + gSaveContext.save.saveInfo.dekuPlaygroundHighScores[1] = SECONDS_TO_TIMER(75); + gSaveContext.save.saveInfo.dekuPlaygroundHighScores[2] = SECONDS_TO_TIMER(76); } /** @@ -341,9 +342,9 @@ void Sram_SaveEndOfCycle(PlayState* play) { gSaveContext.save.day = 0; gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; - gSaveContext.save.playerData.deaths++; - if (gSaveContext.save.playerData.deaths > 999) { - gSaveContext.save.playerData.deaths = 999; + gSaveContext.save.saveInfo.playerData.deaths++; + if (gSaveContext.save.saveInfo.playerData.deaths > 999) { + gSaveContext.save.saveInfo.playerData.deaths = 999; } sceneId = Play_GetOriginalSceneId(play->sceneId); @@ -362,8 +363,8 @@ void Sram_SaveEndOfCycle(PlayState* play) { gSaveContext.cycleSceneFlags[i].collectible = ((void)0, gSaveContext.cycleSceneFlags[i].collectible) & D_801C5FC0[i][3]; gSaveContext.cycleSceneFlags[i].clearedRoom = 0; - gSaveContext.save.permanentSceneFlags[i].unk_14 = 0; - gSaveContext.save.permanentSceneFlags[i].rooms = 0; + gSaveContext.save.saveInfo.permanentSceneFlags[i].unk_14 = 0; + gSaveContext.save.saveInfo.permanentSceneFlags[i].rooms = 0; } for (; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { @@ -387,8 +388,8 @@ void Sram_SaveEndOfCycle(PlayState* play) { for (j = 0; j < ARRAY_COUNT(D_801C6890); j++) { if ((phi_v1_3 & 3) == 0) { - gSaveContext.save.weekEventReg[i] = - ((void)0, gSaveContext.save.weekEventReg[i]) & (0xFF ^ D_801C6890[j]); + gSaveContext.save.saveInfo.weekEventReg[i] = + ((void)0, gSaveContext.save.saveInfo.weekEventReg[i]) & (0xFF ^ D_801C6890[j]); } phi_v1_3 >>= 2; } @@ -404,7 +405,7 @@ void Sram_SaveEndOfCycle(PlayState* play) { CLEAR_EVENTINF(EVENTINF_73); CLEAR_EVENTINF(EVENTINF_74); - if (gSaveContext.save.playerData.rupees != 0) { + if (gSaveContext.save.saveInfo.playerData.rupees != 0) { SET_EVENTINF(EVENTINF_70); } @@ -435,8 +436,8 @@ void Sram_SaveEndOfCycle(PlayState* play) { for (i = 0; i < ARRAY_COUNT(gAmmoItems); i++) { if (gAmmoItems[i] != ITEM_NONE) { - if ((gSaveContext.save.inventory.items[i] != ITEM_NONE) && (i != SLOT_PICTO_BOX)) { - item = gSaveContext.save.inventory.items[i]; + if ((gSaveContext.save.saveInfo.inventory.items[i] != ITEM_NONE) && (i != SLOT_PICTO_BOX)) { + item = gSaveContext.save.saveInfo.inventory.items[i]; AMMO(item) = 0; } } @@ -444,23 +445,23 @@ void Sram_SaveEndOfCycle(PlayState* play) { for (i = SLOT_BOTTLE_1; i <= SLOT_BOTTLE_6; i++) { // Check for all bottled items - if (gSaveContext.save.inventory.items[i] >= ITEM_POTION_RED) { - if (gSaveContext.save.inventory.items[i] <= ITEM_OBABA_DRINK) { + if (gSaveContext.save.saveInfo.inventory.items[i] >= ITEM_POTION_RED) { + if (gSaveContext.save.saveInfo.inventory.items[i] <= ITEM_OBABA_DRINK) { for (j = EQUIP_SLOT_C_LEFT; j <= EQUIP_SLOT_C_RIGHT; j++) { - if (GET_CUR_FORM_BTN_ITEM(j) == gSaveContext.save.inventory.items[i]) { + if (GET_CUR_FORM_BTN_ITEM(j) == gSaveContext.save.saveInfo.inventory.items[i]) { SET_CUR_FORM_BTN_ITEM(j, ITEM_BOTTLE); Interface_LoadItemIconImpl(play, j); } } - gSaveContext.save.inventory.items[i] = ITEM_BOTTLE; + gSaveContext.save.saveInfo.inventory.items[i] = ITEM_BOTTLE; } } } REMOVE_QUEST_ITEM(QUEST_PICTOGRAPH); - if (gSaveContext.save.playerData.health < 0x30) { - gSaveContext.save.playerData.health = 0x30; + if (gSaveContext.save.saveInfo.playerData.health < 0x30) { + gSaveContext.save.saveInfo.playerData.health = 0x30; } if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) <= EQUIP_VALUE_SWORD_RAZOR) { @@ -490,8 +491,8 @@ void Sram_SaveEndOfCycle(PlayState* play) { if (STOLEN_ITEM_1 == ITEM_BOTTLE) { slot = SLOT(ITEM_BOTTLE); for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { - if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { - gSaveContext.save.inventory.items[slot + i] = ITEM_BOTTLE; + if (gSaveContext.save.saveInfo.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.saveInfo.inventory.items[slot + i] = ITEM_BOTTLE; break; } } @@ -500,8 +501,8 @@ void Sram_SaveEndOfCycle(PlayState* play) { if (STOLEN_ITEM_2 == ITEM_BOTTLE) { slot = SLOT(ITEM_BOTTLE); for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { - if (gSaveContext.save.inventory.items[slot + i] == ITEM_NONE) { - gSaveContext.save.inventory.items[slot + i] = ITEM_BOTTLE; + if (gSaveContext.save.saveInfo.inventory.items[slot + i] == ITEM_NONE) { + gSaveContext.save.saveInfo.inventory.items[slot + i] = ITEM_BOTTLE; break; } } @@ -521,28 +522,28 @@ void Sram_SaveEndOfCycle(PlayState* play) { } } - gSaveContext.save.skullTokenCount &= ~0xFFFF0000; - gSaveContext.save.skullTokenCount &= ~0x0000FFFF; - gSaveContext.save.unk_EC4 = 0; + gSaveContext.save.saveInfo.skullTokenCount &= ~0xFFFF0000; + gSaveContext.save.saveInfo.skullTokenCount &= ~0x0000FFFF; + gSaveContext.save.saveInfo.unk_EA0 = 0; - gSaveContext.save.unk_E88[0] = 0; - gSaveContext.save.unk_E88[1] = 0; - gSaveContext.save.unk_E88[2] = 0; - gSaveContext.save.unk_E88[3] = 0; - gSaveContext.save.unk_E88[4] = 0; - gSaveContext.save.unk_E88[5] = 0; - gSaveContext.save.unk_E88[6] = 0; + gSaveContext.save.saveInfo.unk_E64[0] = 0; + gSaveContext.save.saveInfo.unk_E64[1] = 0; + gSaveContext.save.saveInfo.unk_E64[2] = 0; + gSaveContext.save.saveInfo.unk_E64[3] = 0; + gSaveContext.save.saveInfo.unk_E64[4] = 0; + gSaveContext.save.saveInfo.unk_E64[5] = 0; + gSaveContext.save.saveInfo.unk_E64[6] = 0; Sram_ClearHighscores(); for (i = 0; i < 8; i++) { - gSaveContext.save.inventory.dungeonItems[i] &= (u8)~1; // remove boss key + gSaveContext.save.saveInfo.inventory.dungeonItems[i] &= (u8)~1; // remove boss key DUNGEON_KEY_COUNT(i) = 0; - gSaveContext.save.inventory.strayFairies[i] = 0; + gSaveContext.save.saveInfo.inventory.strayFairies[i] = 0; } - gSaveContext.save.playerData.rupees = 0; - gSaveContext.save.unk_F65 = 0; + gSaveContext.save.saveInfo.playerData.rupees = 0; + gSaveContext.save.saveInfo.unk_F41 = 0; gSaveContext.powderKegTimer = 0; gSaveContext.unk_1014 = 0; gSaveContext.jinxTimer = 0; @@ -557,12 +558,12 @@ void Sram_IncrementDay(void) { gSaveContext.save.daysElapsed++; } - gSaveContext.save.bombersCaughtNum = 0; - gSaveContext.save.bombersCaughtOrder[0] = 0; - gSaveContext.save.bombersCaughtOrder[1] = 0; - gSaveContext.save.bombersCaughtOrder[2] = 0; - gSaveContext.save.bombersCaughtOrder[3] = 0; - gSaveContext.save.bombersCaughtOrder[4] = 0; + gSaveContext.save.saveInfo.bombersCaughtNum = 0; + gSaveContext.save.saveInfo.bombersCaughtOrder[0] = 0; + gSaveContext.save.saveInfo.bombersCaughtOrder[1] = 0; + gSaveContext.save.saveInfo.bombersCaughtOrder[2] = 0; + gSaveContext.save.saveInfo.bombersCaughtOrder[3] = 0; + gSaveContext.save.saveInfo.bombersCaughtOrder[4] = 0; CLEAR_WEEKEVENTREG(WEEKEVENTREG_73_10); CLEAR_WEEKEVENTREG(WEEKEVENTREG_85_02); @@ -592,9 +593,7 @@ void Sram_ResetSave(void) { gSaveContext.save.hasTatl = false; gSaveContext.save.isOwlSave = false; - // Instead of bloating all save context accesses with an extra sub-struct, the size of the would-be sub-struct - // is calculated manually - bzero(&gSaveContext.save.playerData, sizeof(Save) - offsetof(Save, playerData)); + bzero(&gSaveContext.save.saveInfo, sizeof(SaveInfo)); } /** @@ -614,15 +613,15 @@ void Sram_GenerateRandomSaveFields(void) { Sram_ClearHighscores(); - gSaveContext.save.lotteryCodes[0][0] = Rand_S16Offset(0, 10); - gSaveContext.save.lotteryCodes[0][1] = Rand_S16Offset(0, 10); - gSaveContext.save.lotteryCodes[0][2] = Rand_S16Offset(0, 10); - gSaveContext.save.lotteryCodes[1][0] = Rand_S16Offset(0, 10); - gSaveContext.save.lotteryCodes[1][1] = Rand_S16Offset(0, 10); - gSaveContext.save.lotteryCodes[1][2] = Rand_S16Offset(0, 10); - gSaveContext.save.lotteryCodes[2][0] = Rand_S16Offset(0, 10); - gSaveContext.save.lotteryCodes[2][1] = Rand_S16Offset(0, 10); - gSaveContext.save.lotteryCodes[2][2] = Rand_S16Offset(0, 10); + gSaveContext.save.saveInfo.lotteryCodes[0][0] = Rand_S16Offset(0, 10); + gSaveContext.save.saveInfo.lotteryCodes[0][1] = Rand_S16Offset(0, 10); + gSaveContext.save.saveInfo.lotteryCodes[0][2] = Rand_S16Offset(0, 10); + gSaveContext.save.saveInfo.lotteryCodes[1][0] = Rand_S16Offset(0, 10); + gSaveContext.save.saveInfo.lotteryCodes[1][1] = Rand_S16Offset(0, 10); + gSaveContext.save.saveInfo.lotteryCodes[1][2] = Rand_S16Offset(0, 10); + gSaveContext.save.saveInfo.lotteryCodes[2][0] = Rand_S16Offset(0, 10); + gSaveContext.save.saveInfo.lotteryCodes[2][1] = Rand_S16Offset(0, 10); + gSaveContext.save.saveInfo.lotteryCodes[2][2] = Rand_S16Offset(0, 10); // Needed to match... for (i = 0; i < 3; i++) { @@ -635,7 +634,7 @@ void Sram_GenerateRandomSaveFields(void) { while (i != k) { randSpiderHouse = Rand_S16Offset(0, 16) & 3; if (sp2A != randSpiderHouse) { - gSaveContext.save.spiderHouseMaskOrder[i] = randSpiderHouse; + gSaveContext.save.saveInfo.spiderHouseMaskOrder[i] = randSpiderHouse; i++; sp2A = randSpiderHouse; } @@ -645,7 +644,7 @@ void Sram_GenerateRandomSaveFields(void) { randBombers = Rand_S16Offset(0, 6); } while (randBombers <= 0 || randBombers >= 6); - gSaveContext.save.bomberCode[0] = randBombers; + gSaveContext.save.saveInfo.bomberCode[0] = randBombers; i = 1; while (i != 5) { @@ -657,14 +656,14 @@ void Sram_GenerateRandomSaveFields(void) { sp2A = 0; do { - if (randBombers == gSaveContext.save.bomberCode[sp2A]) { + if (randBombers == gSaveContext.save.saveInfo.bomberCode[sp2A]) { k = true; } sp2A++; } while (sp2A < i); if (k == false) { - gSaveContext.save.bomberCode[i] = randBombers; + gSaveContext.save.saveInfo.bomberCode[i] = randBombers; i++; } } @@ -754,19 +753,20 @@ void Sram_InitNewSave(void) { gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; Sram_ResetSave(); - Lib_MemCpy(&gSaveContext.save.playerData, &sSaveDefaultPlayerData, sizeof(SavePlayerData)); - Lib_MemCpy(&gSaveContext.save.equips, &sSaveDefaultItemEquips, sizeof(ItemEquips)); - Lib_MemCpy(&gSaveContext.save.inventory, &sSaveDefaultInventory, sizeof(Inventory)); - Lib_MemCpy(&gSaveContext.save.checksum, &sSaveDefaultChecksum, sizeof(gSaveContext.save.checksum)); + Lib_MemCpy(&gSaveContext.save.saveInfo.playerData, &sSaveDefaultPlayerData, sizeof(SavePlayerData)); + Lib_MemCpy(&gSaveContext.save.saveInfo.equips, &sSaveDefaultItemEquips, sizeof(ItemEquips)); + Lib_MemCpy(&gSaveContext.save.saveInfo.inventory, &sSaveDefaultInventory, sizeof(Inventory)); + Lib_MemCpy(&gSaveContext.save.saveInfo.checksum, &sSaveDefaultChecksum, + sizeof(gSaveContext.save.saveInfo.checksum)); - gSaveContext.save.horseData.sceneId = SCENE_F01; - gSaveContext.save.horseData.pos.x = -1420; - gSaveContext.save.horseData.pos.y = 257; - gSaveContext.save.horseData.pos.z = -1285; - gSaveContext.save.horseData.yaw = -0x7554; + gSaveContext.save.saveInfo.horseData.sceneId = SCENE_F01; + gSaveContext.save.saveInfo.horseData.pos.x = -1420; + gSaveContext.save.saveInfo.horseData.pos.y = 257; + gSaveContext.save.saveInfo.horseData.pos.z = -1285; + gSaveContext.save.saveInfo.horseData.yaw = -0x7554; gSaveContext.nextCutsceneIndex = 0; - gSaveContext.save.playerData.magicLevel = 0; + gSaveContext.save.saveInfo.playerData.magicLevel = 0; Sram_GenerateRandomSaveFields(); } @@ -907,10 +907,10 @@ u8 D_801C6A50[] = { void Sram_InitDebugSave(void) { Sram_ResetSave(); - Lib_MemCpy(&gSaveContext.save.playerData, &sSaveDebugPlayerData, sizeof(SavePlayerData)); - Lib_MemCpy(&gSaveContext.save.equips, &sSaveDebugItemEquips, sizeof(ItemEquips)); - Lib_MemCpy(&gSaveContext.save.inventory, &sSaveDebugInventory, sizeof(Inventory)); - Lib_MemCpy(&gSaveContext.save.checksum, &sSaveDebugChecksum, sizeof(gSaveContext.save.checksum)); + Lib_MemCpy(&gSaveContext.save.saveInfo.playerData, &sSaveDebugPlayerData, sizeof(SavePlayerData)); + Lib_MemCpy(&gSaveContext.save.saveInfo.equips, &sSaveDebugItemEquips, sizeof(ItemEquips)); + Lib_MemCpy(&gSaveContext.save.saveInfo.inventory, &sSaveDebugInventory, sizeof(Inventory)); + Lib_MemCpy(&gSaveContext.save.saveInfo.checksum, &sSaveDebugChecksum, sizeof(gSaveContext.save.saveInfo.checksum)); if (GET_PLAYER_FORM != PLAYER_FORM_HUMAN) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = D_801C6A48[GET_PLAYER_FORM]; @@ -919,11 +919,11 @@ void Sram_InitDebugSave(void) { gSaveContext.save.hasTatl = true; - gSaveContext.save.horseData.sceneId = SCENE_F01; - gSaveContext.save.horseData.pos.x = -1420; - gSaveContext.save.horseData.pos.y = 257; - gSaveContext.save.horseData.pos.z = -1285; - gSaveContext.save.horseData.yaw = -0x7554; + gSaveContext.save.saveInfo.horseData.sceneId = SCENE_F01; + gSaveContext.save.saveInfo.horseData.pos.x = -1420; + gSaveContext.save.saveInfo.horseData.pos.y = 257; + gSaveContext.save.saveInfo.horseData.pos.z = -1285; + gSaveContext.save.saveInfo.horseData.yaw = -0x7554; gSaveContext.save.entrance = ENTRANCE(CUTSCENE, 0); gSaveContext.save.isFirstCycle = true; @@ -933,16 +933,15 @@ void Sram_InitDebugSave(void) { SET_WEEKEVENTREG(WEEKEVENTREG_31_04); gSaveContext.cycleSceneFlags[SCENE_INSIDETOWER].switch0 = 1; - gSaveContext.save.permanentSceneFlags[SCENE_INSIDETOWER].switch0 = 1; - gSaveContext.save.playerData.magicLevel = 0; + gSaveContext.save.saveInfo.permanentSceneFlags[SCENE_INSIDETOWER].switch0 = 1; + gSaveContext.save.saveInfo.playerData.magicLevel = 0; Sram_GenerateRandomSaveFields(); } -// Unused -void func_80144A94(SramContext* sramCtx) { +void Sram_ResetSaveFromMoonCrash(SramContext* sramCtx) { s32 i; - s32 cutscene = gSaveContext.save.cutscene; + s32 cutsceneIndex = gSaveContext.save.cutsceneIndex; bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); @@ -952,23 +951,23 @@ void func_80144A94(SramContext* sramCtx) { D_801C67F0[gSaveContext.fileNum * 2 + 1]); } Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); - if (CHECK_NEWF(gSaveContext.save.playerData.newf)) { + if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf)) { func_80185968(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2 + 1], D_801C67F0[gSaveContext.fileNum * 2 + 1]); Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, sizeof(Save)); } - gSaveContext.save.cutscene = cutscene; + gSaveContext.save.cutsceneIndex = cutsceneIndex; for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { gSaveContext.eventInf[i] = 0; } for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { - gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.permanentSceneFlags[i].chest; - gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.permanentSceneFlags[i].switch0; - gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.permanentSceneFlags[i].switch1; - gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.permanentSceneFlags[i].clearedRoom; - gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.permanentSceneFlags[i].collectible; + gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.saveInfo.permanentSceneFlags[i].chest; + gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.saveInfo.permanentSceneFlags[i].switch0; + gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.saveInfo.permanentSceneFlags[i].switch1; + gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.saveInfo.permanentSceneFlags[i].clearedRoom; + gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.saveInfo.permanentSceneFlags[i].collectible; } for (i = 0; i < TIMER_ID_MAX; i++) { @@ -1025,13 +1024,13 @@ void Sram_OpenSave(FileSelectState* fileSelect, SramContext* sramCtx) { Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[phi_t1]); - if (CHECK_NEWF(gSaveContext.save.playerData.newf)) { + if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf)) { func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]); Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[phi_t1]); } } - gSaveContext.save.playerData.magicLevel = 0; + gSaveContext.save.saveInfo.playerData.magicLevel = 0; if (!gSaveContext.save.isOwlSave) { for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { @@ -1039,11 +1038,11 @@ void Sram_OpenSave(FileSelectState* fileSelect, SramContext* sramCtx) { } for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { - gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.permanentSceneFlags[i].chest; - gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.permanentSceneFlags[i].switch0; - gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.permanentSceneFlags[i].switch1; - gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.permanentSceneFlags[i].clearedRoom; - gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.permanentSceneFlags[i].collectible; + gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.saveInfo.permanentSceneFlags[i].chest; + gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.saveInfo.permanentSceneFlags[i].switch0; + gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.saveInfo.permanentSceneFlags[i].switch1; + gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.saveInfo.permanentSceneFlags[i].clearedRoom; + gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.saveInfo.permanentSceneFlags[i].collectible; } for (i = 0; i < TIMER_ID_MAX; i++) { @@ -1067,26 +1066,26 @@ void Sram_OpenSave(FileSelectState* fileSelect, SramContext* sramCtx) { } else { gSaveContext.save.entrance = D_801C6A58[(void)0, gSaveContext.save.owlSaveLocation]; if ((gSaveContext.save.entrance == ENTRANCE(SOUTHERN_SWAMP_POISONED, 10)) && - CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { + CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE)) { gSaveContext.save.entrance = ENTRANCE(SOUTHERN_SWAMP_CLEARED, 10); } else if ((gSaveContext.save.entrance == ENTRANCE(MOUNTAIN_VILLAGE_WINTER, 8)) && - CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { + CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE)) { gSaveContext.save.entrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 8); } for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { - gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.permanentSceneFlags[i].chest; - gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.permanentSceneFlags[i].switch0; - gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.permanentSceneFlags[i].switch1; - gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.permanentSceneFlags[i].clearedRoom; - gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.permanentSceneFlags[i].collectible; + gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.saveInfo.permanentSceneFlags[i].chest; + gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.saveInfo.permanentSceneFlags[i].switch0; + gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.saveInfo.permanentSceneFlags[i].switch1; + gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.saveInfo.permanentSceneFlags[i].clearedRoom; + gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.saveInfo.permanentSceneFlags[i].collectible; } - if (gSaveContext.save.unk_F65) { - Lib_MemCpy(gScarecrowSpawnSongPtr, gSaveContext.save.scarecrowSpawnSong, - sizeof(gSaveContext.save.scarecrowSpawnSong)); + if (gSaveContext.save.saveInfo.unk_F41) { + Lib_MemCpy(gScarecrowSpawnSongPtr, gSaveContext.save.saveInfo.scarecrowSpawnSong, + sizeof(gSaveContext.save.saveInfo.scarecrowSpawnSong)); - for (i = 0; i != ARRAY_COUNT(gSaveContext.save.scarecrowSpawnSong); i++) {} + for (i = 0; i != ARRAY_COUNT(gSaveContext.save.saveInfo.scarecrowSpawnSong); i++) {} } fileNum = gSaveContext.fileNum; @@ -1100,28 +1099,28 @@ void func_8014546C(SramContext* sramCtx) { if (gSaveContext.save.isOwlSave) { for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { - gSaveContext.save.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; - gSaveContext.save.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; - gSaveContext.save.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; - gSaveContext.save.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; - gSaveContext.save.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; + gSaveContext.save.saveInfo.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; + gSaveContext.save.saveInfo.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; + gSaveContext.save.saveInfo.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; + gSaveContext.save.saveInfo.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; + gSaveContext.save.saveInfo.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; } - gSaveContext.save.checksum = 0; - gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext, offsetof(SaveContext, fileNum)); + gSaveContext.save.saveInfo.checksum = 0; + gSaveContext.save.saveInfo.checksum = Sram_CalcChecksum(&gSaveContext, offsetof(SaveContext, fileNum)); Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, offsetof(SaveContext, fileNum)); } else { for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { - gSaveContext.save.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; - gSaveContext.save.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; - gSaveContext.save.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; - gSaveContext.save.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; - gSaveContext.save.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; + gSaveContext.save.saveInfo.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; + gSaveContext.save.saveInfo.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; + gSaveContext.save.saveInfo.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; + gSaveContext.save.saveInfo.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; + gSaveContext.save.saveInfo.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; } - gSaveContext.save.checksum = 0; - gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); + gSaveContext.save.saveInfo.checksum = 0; + gSaveContext.save.saveInfo.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); if (gSaveContext.unk_3F3F) { Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, sizeof(Save)); @@ -1137,15 +1136,15 @@ void func_80145698(SramContext* sramCtx) { s32 i; for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { - gSaveContext.save.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; - gSaveContext.save.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; - gSaveContext.save.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; - gSaveContext.save.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; - gSaveContext.save.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; + gSaveContext.save.saveInfo.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; + gSaveContext.save.saveInfo.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; + gSaveContext.save.saveInfo.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; + gSaveContext.save.saveInfo.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; + gSaveContext.save.saveInfo.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; } - gSaveContext.save.checksum = 0; - gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); + gSaveContext.save.saveInfo.checksum = 0; + gSaveContext.save.saveInfo.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); if (gSaveContext.unk_3F3F) { Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, sizeof(Save)); Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); @@ -1201,14 +1200,14 @@ void func_801457CC(FileSelectState* fileSelect2, SramContext* sramCtx) { } else { // Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); - temp_s2 = gSaveContext.save.checksum; - gSaveContext.save.checksum = 0; + temp_s2 = gSaveContext.save.saveInfo.checksum; + gSaveContext.save.saveInfo.checksum = 0; temp_v0_2 = Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]); - gSaveContext.save.checksum = temp_s2; + gSaveContext.save.saveInfo.checksum = temp_s2; - if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (temp_s2 != temp_v0_2)) { + if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (temp_s2 != temp_v0_2)) { sp6E = 1; - if (CHECK_NEWF2(gSaveContext.save.playerData.newf)) {} + if (CHECK_NEWF2(gSaveContext.save.saveInfo.playerData.newf)) {} phi_s2 = false; if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { @@ -1216,9 +1215,9 @@ void func_801457CC(FileSelectState* fileSelect2, SramContext* sramCtx) { } Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); - temp_s2 = gSaveContext.save.checksum; - gSaveContext.save.checksum = 0; - if (phi_s2 || CHECK_NEWF(gSaveContext.save.playerData.newf) || + temp_s2 = gSaveContext.save.saveInfo.checksum; + gSaveContext.save.saveInfo.checksum = 0; + if (phi_s2 || CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (temp_s2 != Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]))) { bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); @@ -1227,55 +1226,57 @@ void func_801457CC(FileSelectState* fileSelect2, SramContext* sramCtx) { } } - gSaveContext.save.checksum = 0; - gSaveContext.save.checksum = + gSaveContext.save.saveInfo.checksum = 0; + gSaveContext.save.saveInfo.checksum = Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64 & 0xFFFFFFFF]); // TODO: Needed? - for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.newf); sp7A++) { - fileSelect->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.saveInfo.playerData.newf); sp7A++) { + fileSelect->newf[sp76][sp7A] = gSaveContext.save.saveInfo.playerData.newf[sp7A]; } if (!CHECK_NEWF(fileSelect->newf[sp76])) { - fileSelect->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; + fileSelect->unk_2440C[sp76] = gSaveContext.save.saveInfo.playerData.deaths; - for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.playerName); sp7A++) { - fileSelect->unk_24414[sp76][sp7A] = gSaveContext.save.playerData.playerName[sp7A]; + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.saveInfo.playerData.playerName); sp7A++) { + fileSelect->unk_24414[sp76][sp7A] = gSaveContext.save.saveInfo.playerData.playerName[sp7A]; } - fileSelect->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; - fileSelect->health[sp76] = gSaveContext.save.playerData.health; - fileSelect->unk_24454[sp76] = gSaveContext.save.inventory.defenseHearts; - fileSelect->unk_24444[sp76] = gSaveContext.save.inventory.questItems; + fileSelect->healthCapacity[sp76] = gSaveContext.save.saveInfo.playerData.healthCapacity; + fileSelect->health[sp76] = gSaveContext.save.saveInfo.playerData.health; + fileSelect->unk_24454[sp76] = gSaveContext.save.saveInfo.inventory.defenseHearts; + fileSelect->unk_24444[sp76] = gSaveContext.save.saveInfo.inventory.questItems; fileSelect->unk_24458[sp76] = gSaveContext.save.time; fileSelect->unk_24460[sp76] = gSaveContext.save.day; fileSelect->unk_24468[sp76] = gSaveContext.save.isOwlSave; - fileSelect->rupees[sp76] = gSaveContext.save.playerData.rupees; + fileSelect->rupees[sp76] = gSaveContext.save.saveInfo.playerData.rupees; fileSelect->unk_24474[sp76] = CUR_UPG_VALUE(4); for (sp7A = 0, phi_a0 = 0; sp7A < 24; sp7A++) { - if (gSaveContext.save.inventory.items[sp7A + 24] != 0xFF) { + if (gSaveContext.save.saveInfo.inventory.items[sp7A + 24] != 0xFF) { phi_a0++; } } fileSelect->maskCount[sp76] = phi_a0; - fileSelect->heartPieceCount[sp76] = ((gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C); + fileSelect->heartPieceCount[sp76] = + ((gSaveContext.save.saveInfo.inventory.questItems & 0xF0000000) >> 0x1C); } if (sp6E == 1) { Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C6818[sp64]); } else if (sp6E == 0) { // TODO: == 0? - temp_s2 = gSaveContext.save.checksum; + temp_s2 = gSaveContext.save.saveInfo.checksum; if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { phi_s2_3 = 1; } else { Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); - phi_s2_3 = gSaveContext.save.checksum; - gSaveContext.save.checksum = 0; + phi_s2_3 = gSaveContext.save.saveInfo.checksum; + gSaveContext.save.saveInfo.checksum = 0; sp7A = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); } - if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (phi_s2_3 != sp7A) || (phi_s2_3 != temp_s2)) { + if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (phi_s2_3 != sp7A) || + (phi_s2_3 != temp_s2)) { func_80185968(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64]); Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); @@ -1292,15 +1293,15 @@ void func_801457CC(FileSelectState* fileSelect2, SramContext* sramCtx) { D_801C6870[sp64]); // TODO: Needed? } else { Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); - temp_s2 = gSaveContext.save.checksum; + temp_s2 = gSaveContext.save.saveInfo.checksum; - gSaveContext.save.checksum = 0; + gSaveContext.save.saveInfo.checksum = 0; temp_v0_2 = Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]); - gSaveContext.save.checksum = temp_s2; - if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (temp_s2 != temp_v0_2)) { + gSaveContext.save.saveInfo.checksum = temp_s2; + if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (temp_s2 != temp_v0_2)) { sp6E = 1; - if ((gSaveContext.save.playerData.newf[0] == 'Z') && - (gSaveContext.save.playerData.newf[1] == 'E')) { + if ((gSaveContext.save.saveInfo.playerData.newf[0] == 'Z') && + (gSaveContext.save.saveInfo.playerData.newf[1] == 'E')) { phi_s2 = false; } @@ -1309,9 +1310,9 @@ void func_801457CC(FileSelectState* fileSelect2, SramContext* sramCtx) { } Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); - temp_s2 = gSaveContext.save.checksum; - gSaveContext.save.checksum = 0; - if (phi_s2 || CHECK_NEWF(gSaveContext.save.playerData.newf) || + temp_s2 = gSaveContext.save.saveInfo.checksum; + gSaveContext.save.saveInfo.checksum = 0; + if (phi_s2 || CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (temp_s2 != Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]))) { bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); @@ -1320,58 +1321,58 @@ void func_801457CC(FileSelectState* fileSelect2, SramContext* sramCtx) { } } - gSaveContext.save.checksum = 0; - gSaveContext.save.checksum = + gSaveContext.save.saveInfo.checksum = 0; + gSaveContext.save.saveInfo.checksum = Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64 & 0xFFFFFFFF]); // TODO: Needed? - for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.newf); sp7A++) { - fileSelect->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.saveInfo.playerData.newf); sp7A++) { + fileSelect->newf[sp76][sp7A] = gSaveContext.save.saveInfo.playerData.newf[sp7A]; } if (!CHECK_NEWF(fileSelect->newf[sp76])) { - fileSelect->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; + fileSelect->unk_2440C[sp76] = gSaveContext.save.saveInfo.playerData.deaths; - for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.playerName); sp7A++) { + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.saveInfo.playerData.playerName); sp7A++) { phi_s2 += 0; // TODO: Needed? - fileSelect->unk_24414[sp76][sp7A] = gSaveContext.save.playerData.playerName[sp7A]; + fileSelect->unk_24414[sp76][sp7A] = gSaveContext.save.saveInfo.playerData.playerName[sp7A]; } - fileSelect->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; - fileSelect->health[sp76] = gSaveContext.save.playerData.health; - fileSelect->unk_24454[sp76] = gSaveContext.save.inventory.defenseHearts; - fileSelect->unk_24444[sp76] = gSaveContext.save.inventory.questItems; + fileSelect->healthCapacity[sp76] = gSaveContext.save.saveInfo.playerData.healthCapacity; + fileSelect->health[sp76] = gSaveContext.save.saveInfo.playerData.health; + fileSelect->unk_24454[sp76] = gSaveContext.save.saveInfo.inventory.defenseHearts; + fileSelect->unk_24444[sp76] = gSaveContext.save.saveInfo.inventory.questItems; fileSelect->unk_24458[sp76] = gSaveContext.save.time; fileSelect->unk_24460[sp76] = gSaveContext.save.day; fileSelect->unk_24468[sp76] = gSaveContext.save.isOwlSave; - fileSelect->rupees[sp76] = gSaveContext.save.playerData.rupees; + fileSelect->rupees[sp76] = gSaveContext.save.saveInfo.playerData.rupees; fileSelect->unk_24474[sp76] = CUR_UPG_VALUE(4); for (sp7A = 0, phi_a0 = 0; sp7A < 24; sp7A++) { - if (gSaveContext.save.inventory.items[sp7A + 24] != 0xFF) { + if (gSaveContext.save.saveInfo.inventory.items[sp7A + 24] != 0xFF) { phi_a0++; } } fileSelect->maskCount[sp76] = phi_a0; fileSelect->heartPieceCount[sp76] = - ((gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C); + ((gSaveContext.save.saveInfo.inventory.questItems & 0xF0000000) >> 0x1C); } if (sp6E == 1) { func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C67F0[sp64]); func_80146EBC(sramCtx, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1]); } else if (!sp6E) { // TODO: == 0? - temp_s2 = gSaveContext.save.checksum; + temp_s2 = gSaveContext.save.saveInfo.checksum; if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { phi_s2_3 = 1; } else { Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); - phi_s2_3 = gSaveContext.save.checksum; - gSaveContext.save.checksum = 0; - // phi_s2_3 = gSaveContext.save.checksum; + phi_s2_3 = gSaveContext.save.saveInfo.checksum; + gSaveContext.save.saveInfo.checksum = 0; + // phi_s2_3 = gSaveContext.save.saveInfo.checksum; sp7A = Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]); } - if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (phi_s2_3 != sp7A) || + if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (phi_s2_3 != sp7A) || (phi_s2_3 != temp_s2)) { func_80185968(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64]); Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); @@ -1443,32 +1444,33 @@ void func_80146628(FileSelectState* fileSelect2, SramContext* sramCtx) { if (gSaveContext.unk_3F3F) { if (fileSelect->unk_2446A[fileSelect->unk_2448E]) { func_80147414(sramCtx, fileSelect->unk_2448E, fileSelect->fileNum); - fileSelect->unk_24410[fileSelect->fileNum] = gSaveContext.save.playerData.deaths; + fileSelect->unk_24410[fileSelect->fileNum] = gSaveContext.save.saveInfo.playerData.deaths; - for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { - fileSelect->unk_24424[fileSelect->fileNum][i] = gSaveContext.save.playerData.playerName[i]; + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.saveInfo.playerData.playerName); i++) { + fileSelect->unk_24424[fileSelect->fileNum][i] = gSaveContext.save.saveInfo.playerData.playerName[i]; } - fileSelect->unk_24438[fileSelect->fileNum] = gSaveContext.save.playerData.healthCapacity; - fileSelect->unk_24440[fileSelect->fileNum] = gSaveContext.save.playerData.health; - fileSelect->unk_24456[fileSelect->fileNum] = gSaveContext.save.inventory.defenseHearts; - fileSelect->unk_2444C[fileSelect->fileNum] = gSaveContext.save.inventory.questItems; + fileSelect->unk_24438[fileSelect->fileNum] = gSaveContext.save.saveInfo.playerData.healthCapacity; + fileSelect->unk_24440[fileSelect->fileNum] = gSaveContext.save.saveInfo.playerData.health; + fileSelect->unk_24456[fileSelect->fileNum] = gSaveContext.save.saveInfo.inventory.defenseHearts; + fileSelect->unk_2444C[fileSelect->fileNum] = gSaveContext.save.saveInfo.inventory.questItems; fileSelect->unk_2445C[fileSelect->fileNum] = gSaveContext.save.time; fileSelect->unk_24464[fileSelect->fileNum] = gSaveContext.save.day; fileSelect->unk_2446A[fileSelect->fileNum] = gSaveContext.save.isOwlSave; - fileSelect->unk_24470[fileSelect->fileNum] = gSaveContext.save.playerData.rupees; + fileSelect->unk_24470[fileSelect->fileNum] = gSaveContext.save.saveInfo.playerData.rupees; // = CUR_UPG_VALUE(UPG_WALLET); fileSelect->unk_24476[fileSelect->fileNum] = - (gSaveContext.save.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; + (gSaveContext.save.saveInfo.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; for (i = 0, maskCount = 0; i < 24; i++) { - if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[i + 24] != ITEM_NONE) { maskCount++; } } fileSelect->unk_2447A[fileSelect->fileNum] = maskCount; - fileSelect->unk_2447E[fileSelect->fileNum] = (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + fileSelect->unk_2447E[fileSelect->fileNum] = + (gSaveContext.save.saveInfo.inventory.questItems & 0xF0000000) >> 0x1C; } // clear buffer @@ -1484,33 +1486,33 @@ void func_80146628(FileSelectState* fileSelect2, SramContext* sramCtx) { // copy buffer to save context Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); - fileSelect->unk_2440C[fileSelect->fileNum] = gSaveContext.save.playerData.deaths; + fileSelect->unk_2440C[fileSelect->fileNum] = gSaveContext.save.saveInfo.playerData.deaths; - for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { - fileSelect->unk_24414[fileSelect->fileNum][i] = gSaveContext.save.playerData.playerName[i]; + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.saveInfo.playerData.playerName); i++) { + fileSelect->unk_24414[fileSelect->fileNum][i] = gSaveContext.save.saveInfo.playerData.playerName[i]; } - fileSelect->healthCapacity[fileSelect->fileNum] = gSaveContext.save.playerData.healthCapacity; - fileSelect->health[fileSelect->fileNum] = gSaveContext.save.playerData.health; - fileSelect->unk_24454[fileSelect->fileNum] = gSaveContext.save.inventory.defenseHearts; - fileSelect->unk_24444[fileSelect->fileNum] = gSaveContext.save.inventory.questItems; + fileSelect->healthCapacity[fileSelect->fileNum] = gSaveContext.save.saveInfo.playerData.healthCapacity; + fileSelect->health[fileSelect->fileNum] = gSaveContext.save.saveInfo.playerData.health; + fileSelect->unk_24454[fileSelect->fileNum] = gSaveContext.save.saveInfo.inventory.defenseHearts; + fileSelect->unk_24444[fileSelect->fileNum] = gSaveContext.save.saveInfo.inventory.questItems; fileSelect->unk_24458[fileSelect->fileNum] = gSaveContext.save.time; fileSelect->unk_24460[fileSelect->fileNum] = gSaveContext.save.day; fileSelect->unk_24468[fileSelect->fileNum] = gSaveContext.save.isOwlSave; - fileSelect->rupees[fileSelect->fileNum] = gSaveContext.save.playerData.rupees; + fileSelect->rupees[fileSelect->fileNum] = gSaveContext.save.saveInfo.playerData.rupees; // = CUR_UPG_VALUE(UPG_WALLET); fileSelect->unk_24474[fileSelect->fileNum] = - (gSaveContext.save.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; + (gSaveContext.save.saveInfo.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; for (i = 0, maskCount = 0; i < 24; i++) { - if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[i + 24] != ITEM_NONE) { maskCount++; } } fileSelect->maskCount[fileSelect->fileNum] = maskCount; fileSelect->heartPieceCount[fileSelect->fileNum] = - (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + (gSaveContext.save.saveInfo.inventory.questItems & 0xF0000000) >> 0x1C; } gSaveContext.save.time = D_801F6AF0; @@ -1529,54 +1531,55 @@ void Sram_InitSave(FileSelectState* fileSelect2, SramContext* sramCtx) { if (gSaveContext.unk_3F3F) { Sram_InitNewSave(); if (fileSelect->unk_24480 == 0) { - gSaveContext.save.cutscene = 0xFFF0; + gSaveContext.save.cutsceneIndex = 0xFFF0; } - for (phi_v0 = 0; phi_v0 < ARRAY_COUNT(gSaveContext.save.playerData.playerName); phi_v0++) { - gSaveContext.save.playerData.playerName[phi_v0] = fileSelect->unk_24414[fileSelect->unk_24480][phi_v0]; + for (phi_v0 = 0; phi_v0 < ARRAY_COUNT(gSaveContext.save.saveInfo.playerData.playerName); phi_v0++) { + gSaveContext.save.saveInfo.playerData.playerName[phi_v0] = + fileSelect->unk_24414[fileSelect->unk_24480][phi_v0]; } - gSaveContext.save.playerData.newf[0] = 'Z'; - gSaveContext.save.playerData.newf[1] = 'E'; - gSaveContext.save.playerData.newf[2] = 'L'; - gSaveContext.save.playerData.newf[3] = 'D'; - gSaveContext.save.playerData.newf[4] = 'A'; - gSaveContext.save.playerData.newf[5] = '3'; + gSaveContext.save.saveInfo.playerData.newf[0] = 'Z'; + gSaveContext.save.saveInfo.playerData.newf[1] = 'E'; + gSaveContext.save.saveInfo.playerData.newf[2] = 'L'; + gSaveContext.save.saveInfo.playerData.newf[3] = 'D'; + gSaveContext.save.saveInfo.playerData.newf[4] = 'A'; + gSaveContext.save.saveInfo.playerData.newf[5] = '3'; - gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); + gSaveContext.save.saveInfo.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); Lib_MemCpy(sramCtx->saveBuf, &gSaveContext.save, sizeof(Save)); Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); - for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.newf); i++) { - fileSelect->newf[fileSelect->unk_24480][i] = gSaveContext.save.playerData.newf[i]; + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.saveInfo.playerData.newf); i++) { + fileSelect->newf[fileSelect->unk_24480][i] = gSaveContext.save.saveInfo.playerData.newf[i]; } - fileSelect->unk_2440C[fileSelect->unk_24480] = gSaveContext.save.playerData.deaths; + fileSelect->unk_2440C[fileSelect->unk_24480] = gSaveContext.save.saveInfo.playerData.deaths; - for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { - fileSelect->unk_24414[fileSelect->unk_24480][i] = gSaveContext.save.playerData.playerName[i]; + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.saveInfo.playerData.playerName); i++) { + fileSelect->unk_24414[fileSelect->unk_24480][i] = gSaveContext.save.saveInfo.playerData.playerName[i]; } - fileSelect->healthCapacity[fileSelect->unk_24480] = gSaveContext.save.playerData.healthCapacity; - fileSelect->health[fileSelect->unk_24480] = gSaveContext.save.playerData.health; - fileSelect->unk_24454[fileSelect->unk_24480] = gSaveContext.save.inventory.defenseHearts; - fileSelect->unk_24444[fileSelect->unk_24480] = gSaveContext.save.inventory.questItems; + fileSelect->healthCapacity[fileSelect->unk_24480] = gSaveContext.save.saveInfo.playerData.healthCapacity; + fileSelect->health[fileSelect->unk_24480] = gSaveContext.save.saveInfo.playerData.health; + fileSelect->unk_24454[fileSelect->unk_24480] = gSaveContext.save.saveInfo.inventory.defenseHearts; + fileSelect->unk_24444[fileSelect->unk_24480] = gSaveContext.save.saveInfo.inventory.questItems; fileSelect->unk_24458[fileSelect->unk_24480] = gSaveContext.save.time; fileSelect->unk_24460[fileSelect->unk_24480] = gSaveContext.save.day; fileSelect->unk_24468[fileSelect->unk_24480] = gSaveContext.save.isOwlSave; - fileSelect->rupees[fileSelect->unk_24480] = gSaveContext.save.playerData.rupees; + fileSelect->rupees[fileSelect->unk_24480] = gSaveContext.save.saveInfo.playerData.rupees; fileSelect->unk_24474[fileSelect->unk_24480] = CUR_UPG_VALUE(UPG_WALLET); for (i = 0, maskCount = 0; i < 24; i++) { - if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[i + 24] != ITEM_NONE) { maskCount++; } } fileSelect->maskCount[fileSelect->unk_24480] = maskCount; fileSelect->heartPieceCount[fileSelect->unk_24480] = - (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + (gSaveContext.save.saveInfo.inventory.questItems & 0xF0000000) >> 0x1C; } gSaveContext.save.time = D_801F6AF0; @@ -1599,7 +1602,7 @@ void Sram_InitSram(GameState* gameState, SramContext* sramCtx) { void Sram_Alloc(GameState* gameState, SramContext* sramCtx) { if (gSaveContext.unk_3F3F) { - sramCtx->saveBuf = THA_AllocEndAlign16(&gameState->heap, SAVE_BUFFER_SIZE); + sramCtx->saveBuf = THA_AllocTailAlign16(&gameState->heap, SAVE_BUFFER_SIZE); sramCtx->status = 0; } } @@ -1630,7 +1633,7 @@ void Sram_SaveSpecialEnterClockTown(PlayState* play) { * Saves when beating the game, after showing the "Dawn of the New Day" message */ void Sram_SaveSpecialNewDay(PlayState* play) { - s32 cutscene = gSaveContext.save.cutscene; + s32 cutsceneIndex = gSaveContext.save.cutsceneIndex; s32 day; u16 time = gSaveContext.save.time; @@ -1643,7 +1646,7 @@ void Sram_SaveSpecialNewDay(PlayState* play) { gSaveContext.save.day = day; gSaveContext.save.time = time; - gSaveContext.save.cutscene = cutscene; + gSaveContext.save.cutsceneIndex = cutsceneIndex; func_80185F64(play->sramCtx.saveBuf, D_801C67C8[gSaveContext.fileNum * 2], D_801C67F0[gSaveContext.fileNum * 2]); } @@ -1713,7 +1716,7 @@ void func_80147198(SramContext* sramCtx) { sramCtx->status = 0; bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); gSaveContext.save.isOwlSave = false; - gSaveContext.save.checksum = 0; + gSaveContext.save.saveInfo.checksum = 0; // flash read to buffer then copy to save context func_80185968(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages); Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, offsetof(SaveContext, fileNum)); @@ -1725,15 +1728,15 @@ void func_80147314(SramContext* sramCtx, s32 fileNum) { gSaveContext.save.isOwlSave = false; - gSaveContext.save.playerData.newf[0] = '\0'; - gSaveContext.save.playerData.newf[1] = '\0'; - gSaveContext.save.playerData.newf[2] = '\0'; - gSaveContext.save.playerData.newf[3] = '\0'; - gSaveContext.save.playerData.newf[4] = '\0'; - gSaveContext.save.playerData.newf[5] = '\0'; + gSaveContext.save.saveInfo.playerData.newf[0] = '\0'; + gSaveContext.save.saveInfo.playerData.newf[1] = '\0'; + gSaveContext.save.saveInfo.playerData.newf[2] = '\0'; + gSaveContext.save.saveInfo.playerData.newf[3] = '\0'; + gSaveContext.save.saveInfo.playerData.newf[4] = '\0'; + gSaveContext.save.saveInfo.playerData.newf[5] = '\0'; - gSaveContext.save.checksum = 0; - gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext, offsetof(SaveContext, fileNum)); + gSaveContext.save.saveInfo.checksum = 0; + gSaveContext.save.saveInfo.checksum = Sram_CalcChecksum(&gSaveContext, offsetof(SaveContext, fileNum)); Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, offsetof(SaveContext, fileNum)); func_80146EBC(sramCtx, D_801C6840[fileNum * 2], D_801C6850[fileNum * 2]); @@ -1741,12 +1744,12 @@ void func_80147314(SramContext* sramCtx, s32 fileNum) { gSaveContext.save.isOwlSave = true; - gSaveContext.save.playerData.newf[0] = 'Z'; - gSaveContext.save.playerData.newf[1] = 'E'; - gSaveContext.save.playerData.newf[2] = 'L'; - gSaveContext.save.playerData.newf[3] = 'D'; - gSaveContext.save.playerData.newf[4] = 'A'; - gSaveContext.save.playerData.newf[5] = '3'; + gSaveContext.save.saveInfo.playerData.newf[0] = 'Z'; + gSaveContext.save.saveInfo.playerData.newf[1] = 'E'; + gSaveContext.save.saveInfo.playerData.newf[2] = 'L'; + gSaveContext.save.saveInfo.playerData.newf[3] = 'D'; + gSaveContext.save.saveInfo.playerData.newf[4] = 'A'; + gSaveContext.save.saveInfo.playerData.newf[5] = '3'; } void func_80147414(SramContext* sramCtx, s32 fileNum, s32 arg2) { diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 8f412364d..a4d95af64 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -517,7 +517,7 @@ Actor* SubS_FindNearestActor(Actor* actor, PlayState* play, u8 actorCategory, s1 actorIter = actorTmp; if (actorIter != actor) { - dist = Actor_DistanceBetweenActors(actor, actorIter); + dist = Actor_WorldDistXYZToActor(actor, actorIter); if (!isSetup || dist < minDist) { closestActor = actorIter; minDist = dist; @@ -577,7 +577,7 @@ s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex) { diffZ = points[index + 1].z - points[index - 1].z; } - func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + func_8017B7F8(&point, RAD_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); if (((px * actor->world.pos.x) + (pz * actor->world.pos.z) + d) > 0.0f) { reached = true; } @@ -762,7 +762,7 @@ s32 SubS_WeightPathing_Move(Actor* actor, Path* path, s32* waypoint, f32* progre } while (true) { if (!SubS_WeightPathing_ComputePoint(path, *waypoint, &point, *progress, direction) || - ((s32)(actor->speedXZ * 10000.0f) == 0)) { + ((s32)(actor->speed * 10000.0f) == 0)) { return false; } dist = Math_Vec3f_DistXZ(&actor->world.pos, &point); @@ -828,7 +828,7 @@ s32 func_8013C964(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, s32 it case 1: yRange = fabsf(actor->playerHeightRel) + 1.0f; xzRange = actor->xzDistToPlayer + 1.0f; - ret = Actor_PickUp(actor, play, itemId, xzRange, yRange); + ret = Actor_OfferGetItem(actor, play, itemId, xzRange, yRange); break; case 2: @@ -1023,13 +1023,13 @@ s16 SubS_ComputeTrackPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f3 f32 step; f32 prevRotStep; - step = (f32)(target - *rot) * (360.0f / (f32)0x10000); + step = BINANG_TO_DEG(target - *rot); step *= gFramerateDivisorHalf; prevRotStep = step; if (step >= 0.0f) { step /= slowness; step = CLAMP(step, stepMin, stepMax); - *rot += (s16)((step * (f32)0x10000) / 360.0f); + *rot += DEG_TO_BINANG_ALT2(step); if (prevRotStep < stepMin) { *rot = target; } @@ -1039,7 +1039,7 @@ s16 SubS_ComputeTrackPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f3 } else { step = (step / slowness) * -1.0f; step = CLAMP(step, stepMin, stepMax); - *rot -= (s16)((step * (f32)0x10000) / 360.0f); + *rot -= DEG_TO_BINANG_ALT2(step); if (-stepMin < prevRotStep) { *rot = target; } @@ -1386,48 +1386,53 @@ void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* a *curAnimIndex = nextAnimIndex; } -s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type) { +s32 SubS_StartCutscene(Actor* actor, s16 nextCsId, s16 curCsId, s32 type) { s32 isStarted = false; - if ((curCutscene != -1) && (ActorCutscene_GetCurrentIndex() == curCutscene)) { - ActorCutscene_Stop(curCutscene); - ActorCutscene_SetIntentToPlay(nextCutscene); - } else if (ActorCutscene_GetCanPlayNext(nextCutscene)) { + if ((curCsId != CS_ID_NONE) && (CutsceneManager_GetCurrentCsId() == curCsId)) { + CutsceneManager_Stop(curCsId); + CutsceneManager_Queue(nextCsId); + } else if (CutsceneManager_IsNext(nextCsId)) { switch (type) { - case SUBS_CUTSCENE_SET_UNK_LINK_FIELDS: - ActorCutscene_StartAndSetUnkLinkFields(nextCutscene, actor); + case SUBS_CUTSCENE_WITH_PLAYER: + CutsceneManager_StartWithPlayerCs(nextCsId, actor); break; + case SUBS_CUTSCENE_NORMAL: - ActorCutscene_Start(nextCutscene, actor); + CutsceneManager_Start(nextCsId, actor); break; - case SUBS_CUTSCENE_SET_FLAG: - ActorCutscene_StartAndSetFlag(nextCutscene, actor); + + case SUBS_CUTSCENE_WITH_PLAYER_SET_FLAG: + CutsceneManager_StartWithPlayerCsAndSetFlag(nextCsId, actor); + break; + + default: break; } isStarted = true; } else { - ActorCutscene_SetIntentToPlay(nextCutscene); + CutsceneManager_Queue(nextCsId); } return isStarted; } -s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes) { - s16 cs; +s32 SubS_FillCutscenesList(Actor* actor, s16 csIdList[], s16 numCutscenes) { + s16 csId; s32 i; for (i = 0; i < numCutscenes; i++) { - cutscenes[i] = -1; + csIdList[i] = CS_ID_NONE; } - cs = actor->cutscene; + csId = actor->csId; i = 0; - while (cs != -1) { - // Note: Infinite loop if numCutscenes is less than possible additional cutscenes + while (csId != CS_ID_NONE) { + // Note: Infinite loop if numCutscenes is less than possible additional csIdList if (i < numCutscenes) { - cutscenes[i] = cs; - cs = ActorCutscene_GetAdditionalCutscene(cs); + csIdList[i] = csId; + csId = CutsceneManager_GetAdditionalCsId(csId); i++; } } @@ -1522,7 +1527,7 @@ s32 func_8013E748(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, s32 ex s32 SubS_ActorAndPlayerFaceEachOther(PlayState* play, Actor* actor, void* data) { Player* player = GET_PLAYER(play); Vec3s* yawTols = (Vec3s*)data; - s16 playerYaw = ABS(BINANG_SUB(Actor_YawBetweenActors(&player->actor, actor), player->actor.shape.rot.y)); + s16 playerYaw = ABS(BINANG_SUB(Actor_WorldYawTowardActor(&player->actor, actor), player->actor.shape.rot.y)); s16 actorYaw = ABS(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); s32 areFacing = false; s32 actorYawTol = ABS(yawTols->y); diff --git a/src/code/z_viszbuf.c b/src/code/z_viszbuf.c new file mode 100644 index 000000000..9970a1e1b --- /dev/null +++ b/src/code/z_viszbuf.c @@ -0,0 +1,56 @@ +#include "global.h" + +#define VISZBUF_ZBUFFRAG_HEIGHT (TMEM_SIZE / (D_801FBBCC * G_IM_SIZ_16b_BYTES)) + +void VisZbuf_Init(VisZbuf* this) { + this->useRgba = false; + this->setScissor = false; + this->primColor.r = 255; + this->primColor.g = 255; + this->primColor.b = 255; + this->primColor.a = 255; + this->envColor.r = 0; + this->envColor.g = 0; + this->envColor.b = 0; + this->envColor.a = 255; +} + +void VisZbuf_Destroy(VisZbuf* this) { +} + +void VisZbuf_Draw(VisZbuf* this, Gfx** gfxP, void* zbuffer) { + Gfx* gfx = *gfxP; + s32 height = VISZBUF_ZBUFFRAG_HEIGHT; + s32 y; + s32 fmt = !this->useRgba ? G_IM_FMT_IA : G_IM_FMT_RGBA; + + if (zbuffer == NULL) { + return; + } + + gDPPipeSync(gfx++); + if (this->setScissor == true) { + gSPDisplayList(gfx++, D_0E000000.setScissor); + } + + gDPSetOtherMode(gfx++, + G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_NONE | G_ZS_PRIM | G_RM_OPA_SURF | G_RM_OPA_SURF2); + gDPSetCombineLERP(gfx++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT); + gDPSetColor(gfx++, G_SETPRIMCOLOR, this->primColor.rgba); + gDPSetColor(gfx++, G_SETENVCOLOR, this->envColor.rgba); + + for (y = 0; y < (D_801FBBCE - height) + 1; y += height) { + gDPLoadTextureTile(gfx++, zbuffer, fmt, G_IM_SIZ_16b, D_801FBBCC, 0, 0, y, D_801FBBCC - 1, (y + height) - 1, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gSPTextureRectangle(gfx++, 0, y << 2, D_801FBBCC << 2, (y + height) << 2, G_TX_RENDERTILE, 0, y << 5, 1 << 10, + 1 << 10); + } + + gDPPipeSync(gfx++); + *gfxP = gfx; +} diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c index 907004a7a..911e3e757 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.c @@ -188,10 +188,10 @@ void Skybox_Setup(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId) size_t size; void* segment; - skyboxCtx->rotZ = 0.0f; + skyboxCtx->rot.z = 0.0f; switch (skyboxId) { - case 1: + case SKYBOX_NORMAL_SKY: // Send a DMA request for the cloudy sky texture skyboxCtx->staticSegments[0] = &D_80025D00; size = SEGMENT_ROM_SIZE(d2_cloud_static); @@ -210,21 +210,21 @@ void Skybox_Setup(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId) segment = (void*)ALIGN8((uintptr_t)segment + size); DmaMgr_SendRequest0(skyboxCtx->paletteStaticSegment, SEGMENT_ROM_START(d2_fine_pal_static), size); - skyboxCtx->primR = 145; - skyboxCtx->primG = 120; - skyboxCtx->primB = 155; + skyboxCtx->prim.r = 145; + skyboxCtx->prim.g = 120; + skyboxCtx->prim.b = 155; - skyboxCtx->envR = 40; - skyboxCtx->envG = 0; - skyboxCtx->envB = 40; + skyboxCtx->env.r = 40; + skyboxCtx->env.g = 0; + skyboxCtx->env.b = 40; // Inverted Stone Tower Temple and Inverted Stone Tower if ((play->sceneId == SCENE_F41) || (play->sceneId == SCENE_INISIE_R)) { - skyboxCtx->rotZ = 3.15000009537f; + skyboxCtx->rot.z = 3.15f; } break; - case 2: + case SKYBOX_2: break; default: @@ -236,7 +236,7 @@ void func_80143324(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { size_t size; switch (skyboxId) { - case 1: + case SKYBOX_NORMAL_SKY: osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1); if (play->envCtx.unk_10 == 0) { @@ -288,21 +288,21 @@ void func_80143324(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { } void Skybox_Init(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId) { - skyboxCtx->skyboxShouldDraw = 0; - skyboxCtx->rotX = skyboxCtx->rotY = skyboxCtx->rotZ = 0.0f; + skyboxCtx->skyboxShouldDraw = false; + skyboxCtx->rot.x = skyboxCtx->rot.y = skyboxCtx->rot.z = 0.0f; Skybox_Setup(gameState, skyboxCtx, skyboxId); - if (skyboxId != 0) { - skyboxCtx->dListBuf = THA_AllocEndAlign16(&gameState->heap, 0x3840); + if (skyboxId != SKYBOX_NONE) { + skyboxCtx->dListBuf = THA_AllocTailAlign16(&gameState->heap, 0x3840); - if (skyboxId == 5) { + if (skyboxId == SKYBOX_CUTSCENE_MAP) { // Allocate enough space for the vertices for a 6 sided skybox (cube) - skyboxCtx->roomVtx = THA_AllocEndAlign16(&gameState->heap, sizeof(Vtx) * 32 * 6); + skyboxCtx->roomVtx = THA_AllocTailAlign16(&gameState->heap, sizeof(Vtx) * 32 * 6); func_80143148(skyboxCtx, 6); } else { // Allocate enough space for the vertices for a 5 sided skybox (bottom is missing) - skyboxCtx->roomVtx = THA_AllocEndAlign16(&gameState->heap, sizeof(Vtx) * 32 * 5); + skyboxCtx->roomVtx = THA_AllocTailAlign16(&gameState->heap, sizeof(Vtx) * 32 * 5); func_80143148(skyboxCtx, 5); } } diff --git a/src/code/z_vr_box_draw.c b/src/code/z_vr_box_draw.c index 88da288f0..489f596e5 100644 --- a/src/code/z_vr_box_draw.c +++ b/src/code/z_vr_box_draw.c @@ -2,25 +2,25 @@ Mtx* sSkyboxDrawMatrix; -Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z) { +Mtx* Skybox_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z) { Matrix_Translate(x, y, z, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateXFApply(skyboxCtx->rotX); - Matrix_RotateYF(skyboxCtx->rotY, MTXMODE_APPLY); - Matrix_RotateZF(skyboxCtx->rotZ, MTXMODE_APPLY); + Matrix_RotateXFApply(skyboxCtx->rot.x); + Matrix_RotateYF(skyboxCtx->rot.y, MTXMODE_APPLY); + Matrix_RotateZF(skyboxCtx->rot.z, MTXMODE_APPLY); return Matrix_ToMtx(sSkyboxDrawMatrix); } -void SkyboxDraw_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB) { - skyboxCtx->primR = primR; - skyboxCtx->primG = primG; - skyboxCtx->primB = primB; - skyboxCtx->envR = envR; - skyboxCtx->envG = envG; - skyboxCtx->envB = envB; +void Skybox_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB) { + skyboxCtx->prim.r = primR; + skyboxCtx->prim.g = primG; + skyboxCtx->prim.b = primB; + skyboxCtx->env.r = envR; + skyboxCtx->env.g = envG; + skyboxCtx->env.b = envB; } -void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z) { +void Skybox_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z) { OPEN_DISPS(gfxCtx); func_8012C6AC(gfxCtx); @@ -32,9 +32,9 @@ void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyb Matrix_Translate(x, y, z, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateXFApply(skyboxCtx->rotX); - Matrix_RotateYF(skyboxCtx->rotY, MTXMODE_APPLY); - Matrix_RotateZF(skyboxCtx->rotZ, MTXMODE_APPLY); + Matrix_RotateXFApply(skyboxCtx->rot.x); + Matrix_RotateYF(skyboxCtx->rot.y, MTXMODE_APPLY); + Matrix_RotateZF(skyboxCtx->rot.z, MTXMODE_APPLY); Matrix_ToMtx(sSkyboxDrawMatrix); gSPMatrix(POLY_OPA_DISP++, sSkyboxDrawMatrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -45,8 +45,8 @@ void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyb gDPSetTextureConvert(POLY_OPA_DISP++, G_TC_FILT); gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL1, TEXEL0, PRIMITIVE_ALPHA, TEXEL0, TEXEL1, TEXEL0, PRIMITIVE, TEXEL0, PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, 0, 0, 0, COMBINED); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, skyboxCtx->primR, skyboxCtx->primG, skyboxCtx->primB, blend); - gDPSetEnvColor(POLY_OPA_DISP++, skyboxCtx->envR, skyboxCtx->envG, skyboxCtx->envB, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, skyboxCtx->prim.r, skyboxCtx->prim.g, skyboxCtx->prim.b, blend); + gDPSetEnvColor(POLY_OPA_DISP++, skyboxCtx->env.r, skyboxCtx->env.g, skyboxCtx->env.b, 0); gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[0]); gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[2]); @@ -63,5 +63,5 @@ void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyb CLOSE_DISPS(gfxCtx); } -void SkyboxDraw_Noop(SkyboxContext* skyboxCtx) { +void Skybox_Update(SkyboxContext* skyboxCtx) { } diff --git a/src/libultra/flash/osFlash.c b/src/libultra/flash/osFlash.c index cd4420c4a..3ed33f45d 100644 --- a/src/libultra/flash/osFlash.c +++ b/src/libultra/flash/osFlash.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "ultra64.h" #include "global.h" diff --git a/src/libultra/gu/position.c b/src/libultra/gu/position.c index 95bd65fe3..4af6dadc4 100644 --- a/src/libultra/gu/position.c +++ b/src/libultra/gu/position.c @@ -5,7 +5,7 @@ * Creates a rotation/parallel translation modelling matrix (floating point) */ void guPositionF(f32 mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z) { - static f32 D_80134D00 = M_PI / 180.0; + static f32 D_80134D00 = M_PI / 180.0f; f32 sinr, sinp, sinh; f32 cosr, cosp, cosh; diff --git a/src/libultra/io/contreaddata.c b/src/libultra/io/contreaddata.c index 163756e07..061c01b0a 100644 --- a/src/libultra/io/contreaddata.c +++ b/src/libultra/io/contreaddata.c @@ -34,7 +34,7 @@ void osContGetReadData(OSContPad* data) { data->stick_x = readformat.stick_x; data->stick_y = readformat.stick_y; } - }; + } } void __osPackReadData() { diff --git a/src/libultra/io/motor.c b/src/libultra/io/motor.c index 649a8b368..9e0eb127e 100644 --- a/src/libultra/io/motor.c +++ b/src/libultra/io/motor.c @@ -6,40 +6,40 @@ #define BANK_ADDR 0x400 #define MOTOR_ID 0x80 -OSPifRam osPifBuffers[MAXCONTROLLERS]; +OSPifRam __MotorDataBuf[MAXCONTROLLERS]; s32 __osPfsSelectBank(OSPfs* pfs, u8 bank); -s32 __osMotorAccess(OSPfs* pfs, u32 vibrate) { +s32 __osMotorAccess(OSPfs* pfs, s32 flag) { s32 i; s32 ret; - u8* buf = (u8*)&osPifBuffers[pfs->channel]; + u8* ptr = (u8*)&__MotorDataBuf[pfs->channel]; - if (!(pfs->status & 8)) { - return 5; + if (!(pfs->status & PFS_MOTOR_INITIALIZED)) { + return PFS_ERR_INVALID; } __osSiGetAccess(); - osPifBuffers[pfs->channel].status = 1; - buf += pfs->channel; + __MotorDataBuf[pfs->channel].status = CONT_CMD_EXE; + ptr += pfs->channel; for (i = 0; i < BLOCKSIZE; i++) { - ((__OSContRamReadFormat*)buf)->data[i] = vibrate; + READFORMAT(ptr)->data[i] = flag; } __osContLastPoll = CONT_CMD_END; - __osSiRawStartDma(OS_WRITE, &osPifBuffers[pfs->channel]); + __osSiRawStartDma(OS_WRITE, &__MotorDataBuf[pfs->channel]); osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK); - __osSiRawStartDma(OS_READ, &osPifBuffers[pfs->channel]); + __osSiRawStartDma(OS_READ, &__MotorDataBuf[pfs->channel]); osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK); - ret = ((__OSContRamReadFormat*)buf)->rxsize & 0xC0; + ret = READFORMAT(ptr)->rxsize & CHNL_ERR_MASK; if (!ret) { - if (!vibrate) { - if (((__OSContRamReadFormat*)buf)->datacrc != 0) { + if (!flag) { + if (READFORMAT(ptr)->datacrc != 0) { ret = PFS_ERR_CONTRFAIL; } } else { - if (((__OSContRamReadFormat*)buf)->datacrc != 0xEB) { + if (READFORMAT(ptr)->datacrc != 0xEB) { ret = PFS_ERR_CONTRFAIL; } } @@ -50,76 +50,75 @@ s32 __osMotorAccess(OSPfs* pfs, u32 vibrate) { return ret; } -void _MakeMotorData(s32 channel, OSPifRam* buf) { - u8* bufptr = (u8*)buf; - __OSContRamReadFormat mempakwr; +void _MakeMotorData(s32 channel, OSPifRam* mdata) { + u8* ptr = (u8*)mdata->ramarray; + __OSContRamReadFormat ramreadformat; s32 i; - mempakwr.dummy = 0xFF; - mempakwr.txsize = 0x23; - mempakwr.rxsize = 1; - mempakwr.cmd = 3; // write mempak - mempakwr.hi = 0x600 >> 3; - mempakwr.lo = (u8)(__osContAddressCrc(0x600) | (0x600 << 5)); + ramreadformat.dummy = CONT_CMD_NOP; + ramreadformat.txsize = CONT_CMD_WRITE_PAK_TX; + ramreadformat.rxsize = CONT_CMD_WRITE_PAK_RX; + ramreadformat.cmd = CONT_CMD_WRITE_PAK; + ramreadformat.hi = CONT_BLOCK_RUMBLE >> 3; + ramreadformat.lo = (u8)(__osContAddressCrc(CONT_BLOCK_RUMBLE) | (CONT_BLOCK_RUMBLE << 5)); if (channel != 0) { for (i = 0; i < channel; i++) { - *bufptr++ = 0; + *ptr++ = 0; } } - *(__OSContRamReadFormat*)bufptr = mempakwr; - bufptr += sizeof(mempakwr); - *bufptr = 0xFE; + *READFORMAT(ptr) = ramreadformat; + ptr += sizeof(ramreadformat); + *ptr = CONT_CMD_END; } -s32 osMotorInit(OSMesgQueue* ctrlrqueue, OSPfs* pfs, s32 channel) { +s32 osMotorInit(OSMesgQueue* mq, OSPfs* pfs, s32 channel) { s32 ret; - u8 sp24[BLOCKSIZE]; + u8 temp[BLOCKSIZE]; - pfs->queue = ctrlrqueue; + pfs->queue = mq; pfs->channel = channel; pfs->activebank = 0xFF; pfs->status = 0; ret = __osPfsSelectBank(pfs, 0xFE); - if (ret == 2) { + if (ret == PFS_ERR_NEW_PACK) { ret = __osPfsSelectBank(pfs, MOTOR_ID); } if (ret != 0) { return ret; } - ret = __osContRamRead(ctrlrqueue, channel, 0x400, sp24); - if (ret == 2) { - ret = 4; // "Controller pack communication error" + ret = __osContRamRead(mq, channel, CONT_BLOCK_DETECT, temp); + if (ret == PFS_ERR_NEW_PACK) { + ret = PFS_ERR_CONTRFAIL; } if (ret != 0) { return ret; } - if (sp24[BLOCKSIZE - 1] == 0xFE) { - return 0xB; + if (temp[BLOCKSIZE - 1] == 0xFE) { + return PFS_ERR_DEVICE; } ret = __osPfsSelectBank(pfs, MOTOR_ID); if (ret == 2) { - ret = 4; // "Controller pack communication error" + ret = PFS_ERR_CONTRFAIL; } if (ret != 0) { return ret; } - ret = __osContRamRead(ctrlrqueue, channel, BANK_ADDR, sp24); - if (ret == 2) { - ret = 4; // "Controller pack communication error" + ret = __osContRamRead(mq, channel, BANK_ADDR, temp); + if (ret == PFS_ERR_NEW_PACK) { + ret = PFS_ERR_CONTRFAIL; } if (ret != 0) { return ret; } - if (sp24[BLOCKSIZE - 1] != MOTOR_ID) { - return 0xB; + if (temp[BLOCKSIZE - 1] != MOTOR_ID) { + return PFS_ERR_DEVICE; } if (!(pfs->status & PFS_MOTOR_INITIALIZED)) { - _MakeMotorData(channel, &osPifBuffers[channel]); + _MakeMotorData(channel, &__MotorDataBuf[channel]); } pfs->status = PFS_MOTOR_INITIALIZED; - - return 0; // "Recognized rumble pak" + return 0; } diff --git a/src/libultra/io/pimgr.c b/src/libultra/io/pimgr.c index 3d618de74..63cc7ba66 100644 --- a/src/libultra/io/pimgr.c +++ b/src/libultra/io/pimgr.c @@ -1,9 +1,10 @@ #include "global.h" +#include "stack.h" OSPiHandle D_8009D130; OSPiHandle D_8009D1A8; -OSThread D_8009D220; -u8 piManagerStack[0x1000]; +OSThread sPiMgrThread; +STACK(sPiMgrStack, 0x1000); OSMesgQueue D_8009E3D0; OSMesg D_8009E3E8[1]; @@ -18,7 +19,7 @@ void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgC if (!__osPiAccessQueueEnabled) { __osPiCreateAccessQueue(); } - osSetEventMesg(8, &D_8009E3D0, (OSMesg)0x22222222); + osSetEventMesg(OS_EVENT_PI, &D_8009E3D0, (OSMesg)0x22222222); oldPri = -1; myPri = osGetThreadPri(NULL); if (myPri < pri) { @@ -27,14 +28,14 @@ void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgC } savedMask = __osDisableInt(); __osPiDevMgr.active = 1; - __osPiDevMgr.thread = &D_8009D220; + __osPiDevMgr.thread = &sPiMgrThread; __osPiDevMgr.cmdQueue = cmdQ; __osPiDevMgr.evtQueue = &D_8009E3D0; __osPiDevMgr.acsQueue = &__osPiAccessQueue; __osPiDevMgr.piDmaCallback = __osPiRawStartDma; __osPiDevMgr.epiDmaCallback = __osEPiRawStartDma; - osCreateThread(&D_8009D220, 0, __osDevMgrMain, (void*)&__osPiDevMgr, &piManagerStack[4096], pri); - osStartThread(&D_8009D220); + osCreateThread(&sPiMgrThread, 0, __osDevMgrMain, &__osPiDevMgr, STACK_TOP(sPiMgrStack), pri); + osStartThread(&sPiMgrThread); __osRestoreInt(savedMask); if (oldPri != -1) { osSetThreadPri(NULL, oldPri); diff --git a/src/libultra/io/sptask.c b/src/libultra/io/sptask.c index aeaaf0f82..8445f53b0 100644 --- a/src/libultra/io/sptask.c +++ b/src/libultra/io/sptask.c @@ -3,7 +3,8 @@ #define _osVirtualToPhysical(ptr) \ if (ptr != NULL) { \ ptr = (void*)osVirtualToPhysical(ptr); \ - } + } \ + (void)0 static OSTask sTmpTask; diff --git a/src/libultra/io/vimgr.c b/src/libultra/io/vimgr.c index 07babf351..ad9cbffd8 100644 --- a/src/libultra/io/vimgr.c +++ b/src/libultra/io/vimgr.c @@ -1,8 +1,9 @@ #include "global.h" +#include "stack.h" #include "osint.h" OSThread viThread; -u8 viThreadStack[0x1000]; +STACK(sViStack, 0x1000); OSMesgQueue viEventQueue; OSMesg viEventBuf[6]; OSIoMesg viRetraceMsg; @@ -45,7 +46,7 @@ void osCreateViManager(OSPri pri) { __osViDevMgr.piDmaCallback = NULL; __osViDevMgr.epiDmaCallback = NULL; - osCreateThread(&viThread, 0, &viMgrMain, &__osViDevMgr, viThreadStack + sizeof(viThreadStack), pri); + osCreateThread(&viThread, 0, &viMgrMain, &__osViDevMgr, STACK_TOP(sViStack), pri); __osViInit(); osStartThread(&viThread); __osRestoreInt(prevInt); diff --git a/src/libultra/os/initialize.c b/src/libultra/os/initialize.c index 9fbf5ff64..776191227 100644 --- a/src/libultra/os/initialize.c +++ b/src/libultra/os/initialize.c @@ -39,12 +39,9 @@ void osInitialize(void) { __osSetFpcCsr(0x01000800); __osSetWatchLo(0x04900000); - while (__osSiRawReadIo(0x1FC007FC, &pifdata)) { - ; - } - while (__osSiRawWriteIo(0x1FC007FC, pifdata | 8)) { - ; - } + while (__osSiRawReadIo(0x1FC007FC, &pifdata)) {} + + while (__osSiRawWriteIo(0x1FC007FC, pifdata | 8)) {} *(struct_exceptionPreamble*)0x80000000 = *((struct_exceptionPreamble*)__osExceptionPreamble); *(struct_exceptionPreamble*)0x80000080 = *((struct_exceptionPreamble*)__osExceptionPreamble); @@ -72,9 +69,7 @@ void osInitialize(void) { } if (__osGetCause() & 0x1000) { - while (1) { - ; - } + while (true) {} } HW_REG(AI_CONTROL_REG, u32) = 1; diff --git a/src/libultra/os/settimer.c b/src/libultra/os/settimer.c index c6de3c3e4..77f568a02 100644 --- a/src/libultra/os/settimer.c +++ b/src/libultra/os/settimer.c @@ -21,9 +21,9 @@ int osSetTimer(OSTimer* t, OSTime value, OSTime interval, OSMesgQueue* mq, OSMes saveMask = __osDisableInt(); if (__osTimerList->next != __osTimerList) { - if (0) { - ; - } + //! FAKE: + if (1) {} + spC = __osTimerList->next; sp14 = osGetCount(); sp10 = sp14 - __osTimerCounter; diff --git a/src/libultra/os/timerintr.c b/src/libultra/os/timerintr.c index 87f7129df..6b112e952 100644 --- a/src/libultra/os/timerintr.c +++ b/src/libultra/os/timerintr.c @@ -29,7 +29,7 @@ void __osTimerInterrupt(void) { if (__osTimerList->next == __osTimerList) { return; } - while (1) { + while (true) { t = __osTimerList->next; if (t == __osTimerList) { __osSetCompare(0); @@ -84,9 +84,8 @@ OSTime __osInsertTimer(OSTimer* t) { savedMask = __osDisableInt(); for (timep = __osTimerList->next, tim = t->value; timep != __osTimerList && tim > timep->value; - tim -= timep->value, timep = timep->next) { - ; - } + tim -= timep->value, timep = timep->next) {} + t->value = tim; if (timep != __osTimerList) { timep->value -= tim; diff --git a/src/libultra/voice/voicegetstatus.c b/src/libultra/voice/voicegetstatus.c index d8e7edb67..a3608277f 100644 --- a/src/libultra/voice/voicegetstatus.c +++ b/src/libultra/voice/voicegetstatus.c @@ -14,9 +14,7 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { if (ret != CONT_ERR_CONTRFAIL) { __osContPifRam.status = CONT_CMD_READ_BUTTON; - for (i = 0; i < port; i++, *ptr++ = 0) { - ; - } + for (i = 0; i < port; i++, *ptr++ = 0) {} *ptr++ = 1; *ptr++ = 3; 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 e3ac3e753..e271449b5 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -109,7 +109,7 @@ s32 ArmsHook_CheckForCancel(ArmsHook* this) { Player* player = (Player*)this->actor.parent; if (Player_IsHoldingHookshot(player)) { - if ((player->itemAction != player->heldItemAction) || (player->actor.flags & ACTOR_FLAG_100) || + if ((player->itemAction != player->heldItemAction) || (player->actor.flags & ACTOR_FLAG_TALK_REQUESTED) || (player->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_4000000))) { this->timer = 0; ArmsHook_DetachHookFromActor(this); @@ -168,7 +168,7 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { grabbed = NULL; this->grabbed = NULL; } else if (this->actor.child != NULL) { - f32 sp94 = Actor_DistanceBetweenActors(&this->actor, grabbed); + f32 sp94 = Actor_WorldDistXYZToActor(&this->actor, grabbed); f32 sp90 = sqrtf(SQXYZ(this->unk1FC)); Math_Vec3f_Diff(&grabbed->world.pos, &this->unk1FC, &this->actor.world.pos); @@ -238,7 +238,7 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { 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_Atan2S_XY(this->actor.speedXZ, -this->actor.velocity.y); + this->actor.shape.rot.x = Math_Atan2S_XY(this->actor.speed, -this->actor.velocity.y); sp60.x = this->unk1EC.x - (this->unk1E0.x - this->unk1EC.x); sp60.y = this->unk1EC.y - (this->unk1E0.y - this->unk1EC.y); sp60.z = this->unk1EC.z - (this->unk1E0.z - this->unk1EC.z); diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c index 41a3f25ec..c356a5f17 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -19,7 +19,7 @@ void ArrowFire_Draw(Actor* thisx, PlayState* play); void FireArrow_ChargeAndWait(ArrowFire* this, PlayState* play); void FireArrow_Fly(ArrowFire* this, PlayState* play); -#include "overlays/ovl_Arrow_fire/ovl_Arrow_Fire.c" +#include "overlays/ovl_Arrow_Fire/ovl_Arrow_Fire.c" ActorInit Arrow_Fire_InitVars = { ACTOR_ARROW_FIRE, @@ -186,7 +186,7 @@ void FireArrow_Fly(ArrowFire* this, PlayState* play) { FireArrow_Lerp(&this->firedPos, &this->actor.world.pos, 0.05f); if (arrow->unk_261 & 1) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_EXPLOSION_FRAME); + Actor_PlaySfx(&this->actor, NA_SE_IT_EXPLOSION_FRAME); ArrowFire_SetupAction(this, FireArrow_Hit); this->timer = 32; this->alpha = 255; 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 5c5cd0c87..62c97ccde 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -160,7 +160,7 @@ void ArrowIce_Fly(ArrowIce* this, PlayState* play) { ArrowIce_LerpFiredPosition(&this->firedPos, &this->actor.world.pos, 0.05f); if (arrow->unk_261 & 1) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_EXPLOSION_ICE); + Actor_PlaySfx(&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_Arrow_Light/z_arrow_light.c b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c index b7918b5b4..360afa4ac 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -154,7 +154,7 @@ void ArrowLight_Fly(ArrowLight* this, PlayState* play) { ArrowLight_Lerp(&this->firedPos, &this->actor.world.pos, 0.05f); if (arrow->unk_261 & 1) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_EXPLOSION_LIGHT); + Actor_PlaySfx(&this->actor, NA_SE_IT_EXPLOSION_LIGHT); ArrowLight_SetupAction(this, ArrowLight_Hit); this->timer = 32; this->alpha = 255; diff --git a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c index dcf37d848..59348962a 100644 --- a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c @@ -100,7 +100,7 @@ void BgAstrBombwall_Init(Actor* thisx, PlayState* play) { BgAstrBombwall* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_astr_obj_Colheader_002498); Collider_InitTris(play, &this->collider); if (Flags_GetSwitch(play, BGASTRBOMBWALL_GET_SWITCHFLAG(thisx))) { @@ -113,7 +113,7 @@ void BgAstrBombwall_Init(Actor* thisx, PlayState* play) { return; } BgAstrBombwall_InitCollider(&sTrisInit, &this->dyna.actor.world.pos, &this->dyna.actor.shape.rot, &this->collider); - SubS_FillCutscenesList(&this->dyna.actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_FillCutscenesList(&this->dyna.actor, this->csIdList, ARRAY_COUNT(this->csIdList)); func_80C0A378(this); } @@ -175,16 +175,16 @@ void func_80C0A400(BgAstrBombwall* this, PlayState* play) { } void func_80C0A418(BgAstrBombwall* this, PlayState* play) { - if (SubS_StartActorCutscene(&this->dyna.actor, this->cutscenes[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + if (SubS_StartCutscene(&this->dyna.actor, this->csIdList[0], CS_ID_NONE, SUBS_CUTSCENE_WITH_PLAYER)) { func_80C0A458(this, play); } } void func_80C0A458(BgAstrBombwall* this, PlayState* play) { - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = NULL; func_80C0A120(this, play); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); this->actionFunc = func_80C0A4BC; } diff --git a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h index 4f42a8b3c..224d94d7a 100644 --- a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h @@ -13,6 +13,6 @@ typedef struct BgAstrBombwall { /* 0x15C */ BgAstrBombwallActionFunc actionFunc; /* 0x160 */ ColliderTris collider; /* 0x180 */ ColliderTrisElement colliderElements[2]; - /* 0x238 */ s16 cutscenes[1]; + /* 0x238 */ s16 csIdList[1]; } BgAstrBombwall; #endif // Z_BG_ASTR_BOMBWALL_H diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c index 4c73987ec..b2e59a51b 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c @@ -153,7 +153,7 @@ s32 func_808B7380(BgBreakwall* this, PlayState* play) { } s32 func_808B73C4(BgBreakwall* this, PlayState* play) { - return CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80) || CHECK_WEEKEVENTREG(WEEKEVENTREG_21_01); + return CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE) || CHECK_WEEKEVENTREG(WEEKEVENTREG_21_01); } s32 func_808B73FC(BgBreakwall* this, PlayState* play) { @@ -176,7 +176,7 @@ s32 func_808B7460(BgBreakwall* this, PlayState* play) { } s32 func_808B74A8(BgBreakwall* this, PlayState* play) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { return false; } return true; @@ -285,7 +285,7 @@ void func_808B782C(BgBreakwall* this, PlayState* play) { } void func_808B78A4(BgBreakwall* this, PlayState* play) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { Actor_Kill(&this->dyna.actor); } } diff --git a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c index 19cafc2bd..2a1a7dce8 100644 --- a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c +++ b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c @@ -75,7 +75,7 @@ void BgCraceMovebg_Init(Actor* thisx, PlayState* play) { sHasInitializedIsLoaded = true; } - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &gDekuShrineSlidingDoorCol); this->index = BG_CRACE_MOVEBG_GET_INDEX(&this->dyna.actor); @@ -328,7 +328,7 @@ void BgCraceMovebg_ClosingDoor_Close(BgCraceMovebg* this, PlayState* play) { if (Math_StepToF(&this->doorHeight, 0.0f, 1.0f)) { if (!(this->stateFlags & BG_CRACE_MOVEBG_FLAG_PLAYER_IS_BEYOND_DOOR) && !Flags_GetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor) + 1)) { - play->unk_18845 = 1; + play->haltAllActors = true; func_80169FDC(&play->state); play_sound(NA_SE_OC_ABYSS); } @@ -343,7 +343,7 @@ void BgCraceMovebg_ClosingDoor_SetupDoNothing(BgCraceMovebg* this, PlayState* pl this->targetDoorHeight = 0.0f; this->doorHeight = 0.0f; this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); this->actionFunc = BgCraceMovebg_ClosingDoor_DoNothing; } 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 68b2d77d2..adf9b3c96 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 @@ -108,7 +108,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, PlayState* play) { } } } - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WATERWHEEL_LEVEL); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_WATERWHEEL_LEVEL); } } @@ -127,12 +127,12 @@ void BgCtowerGear_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); } if (type == BGCTOWERGEAR_WATER_WHEEL) { - DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); DynaPolyActor_LoadMesh(play, &this->dyna, &gClockTowerWaterWheelCol); } else if (type == BGCTOWERGEAR_ORGAN) { DynaPolyActor_Init(&this->dyna, 0); DynaPolyActor_LoadMesh(play, &this->dyna, &gClockTowerOrganCol); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } } @@ -163,19 +163,24 @@ void BgCtowerGear_Update(Actor* thisx, PlayState* play) { void BgCtowerGear_UpdateOrgan(Actor* thisx, PlayState* play) { BgCtowerGear* this = THIS; - if (Cutscene_CheckActorAction(play, 104)) { - switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 104)]->action) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_104)) { + switch (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_104)]->id) { case 1: this->dyna.actor.draw = NULL; - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); break; + case 2: this->dyna.actor.draw = BgCtowerGear_DrawOrgan; - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); break; + case 3: Actor_Kill(&this->dyna.actor); break; + + default: + break; } } } 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 85dcb0aca..571523fcb 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 @@ -46,7 +46,7 @@ void BgCtowerRot_Init(Actor* thisx, PlayState* play) { Vec3f offset; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); if (this->dyna.actor.params == BGCTOWERROT_CORRIDOR) { DynaPolyActor_LoadMesh(play, &this->dyna, &gClockTowerCorridorCol); this->actionFunc = BgCtowerRot_CorridorRotate; @@ -88,7 +88,7 @@ void BgCtowerRot_CorridorRotate(BgCtowerRot* this, PlayState* play) { Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); this->dyna.actor.shape.rot.z = rotZ * 16.384f; - if (play->csCtx.frames == 132) { + if (play->csCtx.curFrame == 132) { play_sound(NA_SE_SY_SPIRAL_DASH); } } @@ -99,8 +99,8 @@ void BgCtowerRot_DoorDoNothing(BgCtowerRot* this, PlayState* play) { void BgCtowerRot_DoorClose(BgCtowerRot* this, PlayState* play) { if (!Math_SmoothStepToF(&this->timer, 0.0f, 0.1f, 15.0f, 0.1f)) { if (this->dyna.actor.params == BGCTOWERROT_STONE_DOOR_MAIN) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); - ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + CutsceneManager_Stop(this->dyna.actor.csId); } this->actionFunc = BgCtowerRot_DoorDoNothing; } else if (this->dyna.actor.params == BGCTOWERROT_STONE_DOOR_MAIN) { @@ -119,19 +119,19 @@ void BgCtowerRot_DoorIdle(BgCtowerRot* this, PlayState* play) { 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); + CutsceneManager_Queue(this->dyna.actor.csId); this->actionFunc = BgCtowerRot_SetupDoorClose; } } void BgCtowerRot_SetupDoorClose(BgCtowerRot* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { if (this->dyna.actor.params == BGCTOWERROT_STONE_DOOR_MAIN) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); } this->actionFunc = BgCtowerRot_DoorClose; } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c index c962cf8ef..2a59a9b8f 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c @@ -317,7 +317,7 @@ void BgDblueBalance_Init(Actor* thisx, PlayState* play) { this->dyna.actor.update = sTypeInfo[sp2C].update; this->dyna.actor.draw = sTypeInfo[sp2C].draw; - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, sTypeInfo[sp2C].colHeader); if (sp2C == 3) { @@ -412,17 +412,17 @@ void func_80B82DE0(BgDblueBalance* this, PlayState* play) { phi_a1 = 1; this->unk_17D = 20; if (balance1 != NULL) { - if (balance1->unk_181 != 0) { + if (balance1->isHeavySwitchPressed) { phi_a0 = 4; - } else if (balance1->unk_180 != 0) { + } else if (balance1->isSwitchPressed) { phi_a0 = 2; } } if (balance2 != NULL) { - if (balance2->unk_181 != 0) { + if (balance2->isHeavySwitchPressed) { phi_a1 = 5; - } else if (balance2->unk_180 != 0) { + } else if (balance2->isSwitchPressed) { phi_a1 = 3; } } @@ -485,7 +485,7 @@ void func_80B82DE0(BgDblueBalance* this, PlayState* play) { this->unk_178 *= -0.6f; this->unk_17C++; if (this->unk_182) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); sp5C = this->unk_15C; Matrix_Push(); Matrix_RotateYS(BINANG_SUB(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); @@ -498,7 +498,7 @@ void func_80B82DE0(BgDblueBalance* this, PlayState* play) { func_80B8296C(play, &sp50, 70.0f); } else { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SEESAW_BOUND); } } else { this->dyna.actor.shape.rot.z = 0x1C72; @@ -510,7 +510,7 @@ void func_80B82DE0(BgDblueBalance* this, PlayState* play) { this->unk_178 *= -0.6f; this->unk_17C++; if (this->unk_182) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); sp3C = this->unk_160; Matrix_Push(); Matrix_RotateYS(BINANG_ADD(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); @@ -523,7 +523,7 @@ void func_80B82DE0(BgDblueBalance* this, PlayState* play) { func_80B8296C(play, &sp30, 47.0f); } else { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SEESAW_BOUND); } } else { this->dyna.actor.shape.rot.z = -0x1C72; @@ -546,8 +546,8 @@ void BgDblueBalance_Update(Actor* thisx, PlayState* play) { void func_80B8330C(Actor* thisx, PlayState* play) { BgDblueBalance* this = THIS; - this->unk_180 = DynaPolyActor_IsInSwitchPressedState(&this->dyna); - this->unk_181 = DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna); + this->isSwitchPressed = DynaPolyActor_IsSwitchPressed(&this->dyna); + this->isHeavySwitchPressed = DynaPolyActor_IsHeavySwitchPressed(&this->dyna); } void func_80B83344(BgDblueBalance* this) { @@ -627,16 +627,16 @@ void func_80B83518(Actor* thisx, PlayState* play) { if (this->unk_17F == 2) { this->unk_17E--; if (this->unk_17E <= 0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); this->unk_17F = 0; } } else if ((this->unk_17F != 0) && (this->unk_17F == 1)) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); this->unk_17F = 2; this->unk_17E = 0x50; } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } this->unk_16C = this->unk_170; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h index f2200e96f..5d72ea3db 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h @@ -33,8 +33,8 @@ typedef struct BgDblueBalance { /* 0x17D */ s8 unk_17D; /* 0x17E */ s8 unk_17E; /* 0x17F */ s8 unk_17F; - /* 0x180 */ s8 unk_180; - /* 0x181 */ s8 unk_181; + /* 0x180 */ s8 isSwitchPressed; + /* 0x181 */ s8 isHeavySwitchPressed; /* 0x182 */ s8 unk_182; /* 0x183 */ u8 unk_183; /* 0x184 */ s16 unk_184; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c index d6819aa00..570369f07 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c @@ -97,7 +97,7 @@ static AnimatedMaterial* sTexAnims[] = { s16 D_80A2B96C[] = { 0, 0x16C, -0x16C, 0 }; -s16 D_80A2B974[] = { -1, -1 }; +static s16 sCsIdList[] = { CS_ID_NONE, CS_ID_NONE }; static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), @@ -163,7 +163,7 @@ void BgDblueMovebg_Init(Actor* thisx, PlayState* play) { this->unk_160 = BGDBLUEMOVEBG_GET_F(thisx); this->unk_1BC = BGDBLUEMOVEBG_GET_F000(thisx); this->unk_1C0 = BGDBLUEMOVEBG_GET_FF0(thisx); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); if ((this->unk_160 == 9) || (this->unk_160 == 8)) { if (D_80A2BBF4.unk_00 != 0) { @@ -197,7 +197,7 @@ void BgDblueMovebg_Init(Actor* thisx, PlayState* play) { this->xluDList = sXluDLists[this->unk_160]; this->texAnim = sTexAnims[this->unk_160]; - SubS_FillCutscenesList(&this->dyna.actor, this->unk_1B6, ARRAY_COUNT(this->unk_1B6)); + SubS_FillCutscenesList(&this->dyna.actor, this->csIdList, ARRAY_COUNT(this->csIdList)); switch (this->unk_160) { case 1: @@ -219,7 +219,7 @@ void BgDblueMovebg_Init(Actor* thisx, PlayState* play) { } else { this->unk_18C = 0; } - this->dyna.actor.shape.rot.y += (s16)((this->unk_18C / 10.0f) * (0x10000 / 360.0f)); + this->dyna.actor.shape.rot.y += DEG_TO_BINANG(this->unk_18C / 10.0f); this->actionFunc = func_80A2A714; break; @@ -245,7 +245,7 @@ void BgDblueMovebg_Init(Actor* thisx, PlayState* play) { this->dyna.actor.draw = func_80A2B308; this->unk_17E = 0; this->unk_184 = 0.0f; - this->dyna.actor.shape.rot.y += (s16)((this->unk_18C / 10.0f) * (0x10000 / 360.0f)); + this->dyna.actor.shape.rot.y += DEG_TO_BINANG(this->unk_18C / 10.0f); this->actionFunc = func_80A2A32C; break; @@ -254,8 +254,8 @@ void BgDblueMovebg_Init(Actor* thisx, PlayState* play) { this->unk_2F8[1] = NULL; this->unk_2F8[0] = NULL; label: - for (i = 0; i < ARRAY_COUNT(D_80A2B974); i++) { - D_80A2B974[i] = this->unk_1B6[i]; + for (i = 0; i < ARRAY_COUNT(sCsIdList); i++) { + sCsIdList[i] = this->csIdList[i]; } this->unk_178 = func_80A29A80(play, this->unk_1C0, this->unk_1BC); this->unk_1CC = D_80A2B96C[this->unk_178]; @@ -385,8 +385,8 @@ void func_80A2A32C(BgDblueMovebg* this, PlayState* play) { } if (phi_v1) { - this->unk_180 = func_800F2178(this->unk_1B6[0]); - this->unk_1D2 = this->unk_1B6[0]; + this->unk_180 = CutsceneManager_GetCutsceneCustomValue(this->csIdList[0]); + this->csId = this->csIdList[0]; this->unk_172 |= 8; this->actionFunc = func_80A2A444; } else { @@ -408,7 +408,7 @@ void func_80A2A444(BgDblueMovebg* this, PlayState* play) { sp20 = Math_StepToS(&this->unk_18A, 900, this->unk_188); temp_v0 = this->unk_18A * this->unk_17E; this->dyna.actor.shape.rot.y = - (s32)((this->unk_18C + temp_v0) * 0.1f * (0x10000 / 360.0f)) + this->dyna.actor.home.rot.y; + (s32)DEG_TO_BINANG_ALT3((this->unk_18C + temp_v0) * 0.1f) + this->dyna.actor.home.rot.y; if ((player->stateFlags2 & PLAYER_STATE2_10) && (this->unk_184 > 0.0f)) { player->actor.world.pos.x = @@ -423,7 +423,7 @@ void func_80A2A444(BgDblueMovebg* this, PlayState* play) { player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; Flags_SetSwitch(play, this->unk_1C0); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); if (func_80A29A80(play, this->unk_1C8, this->unk_1C4)) { this->unk_172 |= 1; @@ -447,7 +447,7 @@ void func_80A2A670(BgDblueMovebg* this, PlayState* play) { void func_80A2A688(BgDblueMovebg* this, PlayState* play) { this->unk_180--; if (this->unk_180 <= 0) { - ActorCutscene_Stop(this->unk_1B6[0]); + CutsceneManager_Stop(this->csIdList[0]); } if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 60.0f, 2.0f) && @@ -477,8 +477,8 @@ void func_80A2A714(BgDblueMovebg* this, PlayState* play) { } this->unk_17E = phi_v0 * phi_f0; - this->unk_180 = func_800F2178(this->unk_1B6[0]); - this->unk_1D2 = this->unk_1B6[0]; + this->unk_180 = CutsceneManager_GetCutsceneCustomValue(this->csIdList[0]); + this->csId = this->csIdList[0]; this->unk_172 |= 8; this->actionFunc = func_80A2A7F8; } @@ -495,8 +495,7 @@ void func_80A2A7F8(BgDblueMovebg* this, PlayState* play) { sp28 = Math_StepToS(&this->unk_18A, 900, this->unk_188); sp26 = this->unk_18A * this->unk_17E; - this->dyna.actor.shape.rot.y = - (s32)((this->unk_18C + sp26) * 0.1f * (0x10000 / 360.0f)) + this->dyna.actor.home.rot.y; + this->dyna.actor.shape.rot.y = (s32)DEG_TO_BINANG_ALT3((this->unk_18C + sp26) * 0.1f) + this->dyna.actor.home.rot.y; if ((player->stateFlags2 & PLAYER_STATE2_10) && (this->unk_184 > 0.0f)) { player->actor.world.pos.x = @@ -525,7 +524,7 @@ void func_80A2A7F8(BgDblueMovebg* this, PlayState* play) { this->unk_18A = 0; this->unk_17E = 0; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); if (func_80A29A80(play, this->unk_1C8, this->unk_1C4)) { this->unk_172 |= 1; @@ -550,12 +549,12 @@ void func_80A2AAB8(BgDblueMovebg* this, PlayState* play) { s32 sp18; if (this->unk_180-- <= 0) { - ActorCutscene_Stop(this->unk_1B6[0]); + CutsceneManager_Stop(this->csIdList[0]); } sp18 = false; - if ((this->unk_1D0 > 0) && ((D_80A2B974[0] >= 0) || (D_80A2B974[1] >= 0))) { - if (ActorCutscene_GetCurrentIndex() != -1) { + if ((this->unk_1D0 > 0) && ((sCsIdList[0] >= 0) || (sCsIdList[1] >= 0))) { + if (CutsceneManager_GetCurrentCsId() != CS_ID_NONE) { sp18 = true; } } @@ -643,13 +642,13 @@ void func_80A2AED0(BgDblueMovebg* this, PlayState* play) { switch (temp_v0_3) { case 1: case 2: - this->unk_1D2 = this->unk_1B6[0]; + this->csId = this->csIdList[0]; this->unk_17E = 40; break; case 0: case 3: - this->unk_1D2 = this->unk_1B6[1]; + this->csId = this->csIdList[1]; this->unk_17E = 15; break; } @@ -722,7 +721,7 @@ void BgDblueMovebg_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); if (this->unk_172 & 8) { - if (SubS_StartActorCutscene(&this->dyna.actor, this->unk_1D2, -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + if (SubS_StartCutscene(&this->dyna.actor, this->csId, CS_ID_NONE, SUBS_CUTSCENE_WITH_PLAYER)) { this->unk_172 &= ~8; } } diff --git a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h index 8fc016585..6e81c24c1 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h @@ -37,7 +37,7 @@ typedef struct BgDblueMovebg { /* 0x19C */ Vec3f unk_19C; /* 0x1A8 */ Vec3f unk_1A8; /* 0x1B4 */ UNK_TYPE1 unk1B4[2]; - /* 0x1B6 */ s16 unk_1B6[2]; + /* 0x1B6 */ s16 csIdList[2]; /* 0x1BC */ s32 unk_1BC; /* 0x1C0 */ s32 unk_1C0; /* 0x1C4 */ s32 unk_1C4; @@ -45,7 +45,7 @@ typedef struct BgDblueMovebg { /* 0x1CC */ s16 unk_1CC; /* 0x1CE */ s16 unk_1CE; /* 0x1D0 */ s16 unk_1D0; - /* 0x1D2 */ s16 unk_1D2; + /* 0x1D2 */ s16 csId; /* 0x1D4 */ f32 unk_1D4; /* 0x1D8 */ s16 unk_1D8[2][8]; /* 0x1F8 */ f32 unk_1F8[2][8]; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c index b4c97fdde..8f3de2b2e 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c @@ -223,7 +223,7 @@ void func_80B841A0(BgDblueWaterfall* this, PlayState* play) { EffectSsGSplash_Spawn(play, &sp94, NULL, NULL, 0, 250); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_REFLECTION_WATER); + Actor_PlaySfx(&this->actor, NA_SE_IT_REFLECTION_WATER); } } @@ -423,13 +423,13 @@ void func_80B84928(BgDblueWaterfall* this, PlayState* play) { if (sp30 != 0) { func_80B83EA4(this, play); if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800) { - this->unk_1A4 = this->actor.cutscene; + this->csId = this->actor.csId; func_80B84AD4(this, play); } } else { func_80B841A0(this, play); if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1000) { - this->unk_1A4 = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + this->csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); func_80B84AD4(this, play); } } @@ -448,9 +448,9 @@ void func_80B84AEC(BgDblueWaterfall* this, PlayState* play) { s32 pad; s32 sp20; - if (ActorCutscene_GetCanPlayNext(this->unk_1A4)) { + if (CutsceneManager_IsNext(this->csId)) { sp20 = func_80B83D04(this, play); - ActorCutscene_StartAndSetUnkLinkFields(this->unk_1A4, &this->actor); + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); this->unk_1A3 = true; if (sp20) { func_80B83D94(this, play); @@ -460,7 +460,7 @@ void func_80B84AEC(BgDblueWaterfall* this, PlayState* play) { func_80B84B9C(this, play); } } else { - ActorCutscene_SetIntentToPlay(this->unk_1A4); + CutsceneManager_Queue(this->csId); } } @@ -533,7 +533,7 @@ void func_80B84BCC(BgDblueWaterfall* this, PlayState* play) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } else { if (this->unk_1A3) { - ActorCutscene_Stop(this->unk_1A4); + CutsceneManager_Stop(this->csId); } func_80B8484C(this, play); } @@ -572,7 +572,7 @@ void func_80B84F20(BgDblueWaterfall* this, PlayState* play) { func_800B9010(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); } else { if (this->unk_1A3) { - ActorCutscene_Stop(this->unk_1A4); + CutsceneManager_Stop(this->csId); } func_80B8484C(this, play); } diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h index 5ab64495e..fae5cca6a 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h @@ -22,7 +22,7 @@ typedef struct BgDblueWaterfall { /* 0x1A0 */ u8 unk_1A0; /* 0x1A1 */ UNK_TYPE1 unk1A1[2]; /* 0x1A3 */ s8 unk_1A3; - /* 0x1A4 */ s16 unk_1A4; + /* 0x1A4 */ s16 csId; /* 0x1A6 */ UNK_TYPE1 unk1A6[1]; /* 0x1A7 */ s8 unk_1A7; /* 0x1A8 */ f32 unk_1A8; diff --git a/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c b/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c index 6ec845e2c..e9f8916d0 100644 --- a/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c +++ b/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.c @@ -146,7 +146,7 @@ void BgDkjailIvy_WaitForCut(BgDkjailIvy* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; this->dyna.actor.flags |= ACTOR_FLAG_10; - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); BgDkjailIvy_SetupCutscene(this); } else { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); @@ -158,16 +158,16 @@ void BgDkjailIvy_SetupCutscene(BgDkjailIvy* this) { } void BgDkjailIvy_BeginCutscene(BgDkjailIvy* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); this->fadeOutTimer = 50; - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); Flags_SetSwitch(play, BG_DKJAIL_GET_SWITCH(&this->dyna.actor)); BgDkjailIvy_IvyCutEffects(this, play); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_GRASS_WALL_BROKEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_GRASS_WALL_BROKEN); BgDkjailIvy_SetupFadeOut(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } diff --git a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c index 71aa958dc..be1958cb4 100644 --- a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c +++ b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c @@ -148,7 +148,7 @@ s32 func_80BC3B00(BgF40Block* this) { } } - if (Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &sp28, this->dyna.actor.speedXZ) <= 0.0f) { + if (Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &sp28, this->dyna.actor.speed) <= 0.0f) { this->unk_168 = 6; this->unk_160 = this->unk_164; return true; @@ -157,16 +157,16 @@ s32 func_80BC3B00(BgF40Block* this) { } s32 func_80BC3CA4(BgF40Block* this) { - if (this->dyna.actor.cutscene == -1) { + if (this->dyna.actor.csId == CS_ID_NONE) { return true; } - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); return true; } - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); return false; } @@ -182,26 +182,26 @@ s32 func_80BC3D08(BgF40Block* this, PlayState* play, s32 arg2) { if (arg2 != 0) { sp48.x = - (D_80BC4620[this->unk_168].x * ((800.0f * this->dyna.actor.scale.x) - (this->dyna.actor.speedXZ * 0.5f))) + + (D_80BC4620[this->unk_168].x * ((800.0f * this->dyna.actor.scale.x) - (this->dyna.actor.speed * 0.5f))) + this->dyna.actor.world.pos.x; sp48.y = - (D_80BC4620[this->unk_168].y * ((800.0f * this->dyna.actor.scale.y) - (this->dyna.actor.speedXZ * 0.5f))) + + (D_80BC4620[this->unk_168].y * ((800.0f * this->dyna.actor.scale.y) - (this->dyna.actor.speed * 0.5f))) + this->dyna.actor.world.pos.y; sp48.z = - (D_80BC4620[this->unk_168].z * ((800.0f * this->dyna.actor.scale.z) - (this->dyna.actor.speedXZ * 0.5f))) + + (D_80BC4620[this->unk_168].z * ((800.0f * this->dyna.actor.scale.z) - (this->dyna.actor.speed * 0.5f))) + this->dyna.actor.world.pos.z; - sp3C.x = (D_80BC4620[this->unk_168].x * this->dyna.actor.speedXZ) + sp48.x; - sp3C.y = (D_80BC4620[this->unk_168].y * this->dyna.actor.speedXZ) + sp48.y; - sp3C.z = (D_80BC4620[this->unk_168].z * this->dyna.actor.speedXZ) + sp48.z; + sp3C.x = (D_80BC4620[this->unk_168].x * this->dyna.actor.speed) + sp48.x; + sp3C.y = (D_80BC4620[this->unk_168].y * this->dyna.actor.speed) + sp48.y; + sp3C.z = (D_80BC4620[this->unk_168].z * this->dyna.actor.speed) + sp48.z; } else { sp3C.x = (D_80BC4620[this->unk_168].x * 800.0f * this->dyna.actor.scale.x) + this->dyna.actor.world.pos.x; sp3C.y = (D_80BC4620[this->unk_168].y * 800.0f * this->dyna.actor.scale.y) + this->dyna.actor.world.pos.y; sp3C.z = (D_80BC4620[this->unk_168].z * 800.0f * this->dyna.actor.scale.z) + this->dyna.actor.world.pos.z; - sp48.x = sp3C.x - (D_80BC4620[this->unk_168].x * this->dyna.actor.speedXZ * 1.5f); - sp48.y = sp3C.y - (D_80BC4620[this->unk_168].y * this->dyna.actor.speedXZ * 1.5f); - sp48.z = sp3C.z - (D_80BC4620[this->unk_168].z * this->dyna.actor.speedXZ * 1.5f); + sp48.x = sp3C.x - (D_80BC4620[this->unk_168].x * this->dyna.actor.speed * 1.5f); + sp48.y = sp3C.y - (D_80BC4620[this->unk_168].y * this->dyna.actor.speed * 1.5f); + sp48.z = sp3C.z - (D_80BC4620[this->unk_168].z * this->dyna.actor.speed * 1.5f); } if (BgCheck_AnyLineTest1(&play->colCtx, &sp48, &sp3C, &sp30, &sp54, true)) { @@ -228,7 +228,7 @@ void BgF40Block_Init(Actor* thisx, PlayState* play) { BgF40Block* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_f40_obj_Colheader_004640); if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { @@ -240,11 +240,11 @@ void BgF40Block_Init(Actor* thisx, PlayState* play) { if (this->path != NULL) { if (Flags_GetSwitch(play, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { this->actionFunc = func_80BC4530; - this->dyna.actor.speedXZ = 40.0f; + this->dyna.actor.speed = 40.0f; func_80BC3A2C(this, play); } else { this->actionFunc = func_80BC4380; - this->dyna.actor.speedXZ = 20.0f; + this->dyna.actor.speed = 20.0f; func_80BC3980(this, play); } } else { @@ -272,20 +272,20 @@ void func_80BC41AC(BgF40Block* this, PlayState* play) { void func_80BC4228(BgF40Block* this, PlayState* play) { if (func_80BC3B00(this)) { - this->dyna.actor.speedXZ = 20.0f; + this->dyna.actor.speed = 20.0f; if (this->unk_160 < (this->path->count - 1)) { this->unk_164 = this->unk_160 + 1; } else { this->actionFunc = func_80BC4530; - ActorCutscene_Stop(this->dyna.actor.cutscene); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_C); + CutsceneManager_Stop(this->dyna.actor.csId); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_C); } } if (func_80BC3D08(this, play, 0)) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); this->actionFunc = func_80BC41AC; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_F); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_F); return; } @@ -332,20 +332,20 @@ void func_80BC43CC(BgF40Block* this, PlayState* play) { void func_80BC4448(BgF40Block* this, PlayState* play) { if (func_80BC3B00(this)) { - this->dyna.actor.speedXZ = 40.0f; + this->dyna.actor.speed = 40.0f; if (this->unk_160 > 0) { this->unk_164 = this->unk_160 - 1; } else { this->actionFunc = func_80BC4380; - ActorCutscene_Stop(this->dyna.actor.cutscene); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_C); + CutsceneManager_Stop(this->dyna.actor.csId); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_C); } } if (func_80BC3D08(this, play, 0)) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); this->actionFunc = func_80BC43CC; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_F); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_F); } } diff --git a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c index 4ae6a8ed7..075f38607 100644 --- a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c +++ b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c @@ -41,7 +41,7 @@ void BgF40Flift_Init(Actor* thisx, PlayState* play) { BgF40Flift* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_f40_obj_Colheader_004240); this->dyna.actor.params = 1; this->actionFunc = func_808D75F0; @@ -54,8 +54,8 @@ void BgF40Flift_Destroy(Actor* thisx, PlayState* play) { } void func_808D75F0(BgF40Flift* this, PlayState* play) { - if (((this->dyna.actor.params == 1) && (DynaPolyActor_IsInRidingMovingState(&this->dyna))) || - ((this->dyna.actor.params == -1) && (!DynaPolyActor_IsInRidingMovingState(&this->dyna)))) { + if (((this->dyna.actor.params == 1) && DynaPolyActor_IsPlayerOnTop(&this->dyna)) || + ((this->dyna.actor.params == -1) && !DynaPolyActor_IsPlayerOnTop(&this->dyna))) { this->timer = 96; this->actionFunc = func_808D7714; } else { diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c index 3a7916e7d..67703f0cd 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c @@ -56,7 +56,7 @@ void BgF40Switch_CheckAll(BgF40Switch* this, PlayState* play) { if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->dyna.actor.room && actor->update != NULL) { actorAsSwitch = (BgF40Switch*)actor; actorAsSwitch->wasPressed = actorAsSwitch->isPressed; - isPressed = DynaPolyActor_IsInSwitchPressedState(&actorAsSwitch->dyna); + isPressed = DynaPolyActor_IsSwitchPressed(&actorAsSwitch->dyna); if (actorAsSwitch->isPressed && actorAsSwitch->actionFunc == BgF40Switch_IdlePressed) { // Switch is fully pressed - if there's nothing keeping it pressed, wait a short time before // reverting to unpressed state. @@ -112,7 +112,7 @@ void BgF40Switch_Init(Actor* thisx, PlayState* play) { this->dyna.actor.scale.y = 0.165f; this->actionFunc = BgF40Switch_IdleUnpressed; this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.0f; - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_f40_switch_Colheader_000118); if (!sBgF40SwitchGlobalsInitialized) { sBgF40SwitchLastUpdateFrame = play->gameplayFrames; @@ -129,7 +129,7 @@ void BgF40Switch_Destroy(Actor* thisx, PlayState* play) { void BgF40Switch_Unpress(BgF40Switch* this, PlayState* play) { this->dyna.actor.scale.y += 0.0495f; if (this->dyna.actor.scale.y >= 0.165f) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); this->actionFunc = BgF40Switch_IdleUnpressed; this->dyna.actor.scale.y = 0.165f; } @@ -144,10 +144,10 @@ void BgF40Switch_IdlePressed(BgF40Switch* this, PlayState* play) { void BgF40Switch_Press(BgF40Switch* this, PlayState* play) { this->dyna.actor.scale.y -= 0.0495f; if (this->dyna.actor.scale.y <= 0.0165f) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); if (this->isInitiator) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); this->isInitiator = false; } this->actionFunc = BgF40Switch_IdlePressed; @@ -157,19 +157,19 @@ void BgF40Switch_Press(BgF40Switch* this, PlayState* play) { } void BgF40Switch_WaitToPress(BgF40Switch* this, PlayState* play) { - if (!this->isInitiator || this->dyna.actor.cutscene == -1) { + if (!this->isInitiator || (this->dyna.actor.csId == CS_ID_NONE)) { this->actionFunc = BgF40Switch_Press; if (this->isInitiator) { Flags_SetSwitch(play, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); } - } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + } else if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); this->actionFunc = BgF40Switch_Press; if (this->isInitiator) { Flags_SetSwitch(play, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); } } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } diff --git a/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c b/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c index 40a981a6e..bec649b57 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c +++ b/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c @@ -34,7 +34,7 @@ void BgFuKaiten_Init(Actor* thisx, PlayState* play) { CollisionHeader* header = NULL; Actor_SetScale(thisx, 1.0); - DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); CollisionHeader_GetVirtual(&object_fu_kaiten_Colheader_002D30, &header); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, header); diff --git a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c index 5cb337238..7f485be1d 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c +++ b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c @@ -34,7 +34,7 @@ void BgFuMizu_Init(Actor* thisx, PlayState* play) { CollisionHeader* colHeader = NULL; Actor_SetScale(&this->dyna.actor, 1.0f); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); CollisionHeader_GetVirtual(&object_fu_kaiten_Colheader_0037F8, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); this->unk_160 = 0; 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 cfd9003ec..7d0ed6a1a 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 @@ -42,7 +42,7 @@ void func_80B40080(BgGoronOyu* this) { void func_80B4009C(BgGoronOyu* this) { this->unk_17E = 0; - this->initialActorCutscene = this->dyna.actor.cutscene; + this->initCsId = this->dyna.actor.csId; this->actionFunc = func_80B40100; this->unk_164 = 20.0f; } @@ -53,11 +53,11 @@ void func_80B400C8(BgGoronOyu* this, PlayState* play) { } void func_80B40100(BgGoronOyu* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->initialActorCutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->initialActorCutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->initCsId)) { + CutsceneManager_StartWithPlayerCs(this->initCsId, &this->dyna.actor); this->actionFunc = func_80B40160; } else { - ActorCutscene_SetIntentToPlay(this->initialActorCutscene); + CutsceneManager_Queue(this->initCsId); } } @@ -69,7 +69,7 @@ void func_80B40160(BgGoronOyu* this, PlayState* play) { BgGoronOyu_UpdateWaterBoxInfo(this, play); if (this->unk_164 <= 0.0f) { - ActorCutscene_Stop(this->initialActorCutscene); + CutsceneManager_Stop(this->initCsId); this->unk_164 = 0.0f; func_80B40080(this); } @@ -91,8 +91,8 @@ void func_80B401F8(BgGoronOyu* this, PlayState* play) { 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) { - Actor_PickUp(&this->dyna.actor, play, GI_MAX, this->dyna.actor.xzDistToPlayer, - fabsf(this->dyna.actor.playerHeightRel)); + Actor_OfferGetItem(&this->dyna.actor, play, GI_MAX, this->dyna.actor.xzDistToPlayer, + fabsf(this->dyna.actor.playerHeightRel)); } } @@ -152,7 +152,7 @@ void BgGoronOyu_Init(Actor* thisx, PlayState* play) { CollisionHeader* colHeader = NULL; Actor_SetScale(&this->dyna.actor, 0.1f); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); CollisionHeader_GetVirtual(&object_oyu_Colheader_000988, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); diff --git a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.h b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.h index d17ff87b3..57459364b 100644 --- a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.h +++ b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.h @@ -15,7 +15,7 @@ typedef struct BgGoronOyu { /* 0x168 */ Vec3f waterBoxPos; /* 0x174 */ f32 waterBoxXLength; /* 0x178 */ f32 waterBoxZLength; - /* 0x17C */ s16 initialActorCutscene; + /* 0x17C */ s16 initCsId; /* 0x17E */ u16 unk_17E; } BgGoronOyu; // size = 0x180 diff --git a/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c b/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c index 331a6dfe5..fc209773b 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c @@ -191,21 +191,21 @@ void func_80BD6274(BgHakaBombwall* this, PlayState* play) { void BgHakaBombwall_SetupPlayCutscene(BgHakaBombwall* this) { this->dyna.actor.flags |= ACTOR_FLAG_10; - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); this->actionFunc = BgHakaBombwall_PlayCutscene; } void BgHakaBombwall_PlayCutscene(BgHakaBombwall* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); func_80BD5E6C(this, play); this->dyna.actor.draw = NULL; Flags_SetSwitch(play, BGHAKABOMBWALL_GET_7F(&this->dyna.actor)); SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 0x3C, NA_SE_EV_WALL_BROKEN); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); BgHakaBombwall_SetupEndCutscene(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -217,7 +217,7 @@ void BgHakaBombwall_SetupEndCutscene(BgHakaBombwall* this) { void BgHakaBombwall_EndCutscene(BgHakaBombwall* this, PlayState* play) { this->csTimer--; if (this->csTimer <= 0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); Actor_Kill(&this->dyna.actor); } } 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 412ea3a39..dfc176eff 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 @@ -49,7 +49,7 @@ void BgHakaCurtain_Init(Actor* thisx, PlayState* play) { BgHakaCurtain* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_haka_obj_Colheader_001588); if (Flags_GetClear(play, this->dyna.actor.room)) { func_80B6DE80(this); @@ -79,12 +79,12 @@ void func_80B6DCEC(BgHakaCurtain* this) { } void func_80B6DD00(BgHakaCurtain* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); func_80B6DD5C(this); return; } - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } void func_80B6DD5C(BgHakaCurtain* this) { @@ -123,11 +123,11 @@ void func_80B6DEA8(BgHakaCurtain* this, PlayState* play) { void BgHakaCurtain_Update(Actor* thisx, PlayState* play) { BgHakaCurtain* this = THIS; - CsCmdActorAction* actorAction; + CsCmdActorCue* cue; - if (Cutscene_CheckActorAction(play, 469)) { - actorAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 469)]; - if (actorAction->startFrame == play->csCtx.frames && actorAction->action == 2) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_469)) { + cue = play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_469)]; + if ((cue->startFrame == play->csCtx.curFrame) && (cue->id == 2)) { func_80B6DD80(this); } } 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 a8d63c309..693fff484 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 @@ -45,9 +45,9 @@ void BgHakaTomb_Init(Actor* thisx, PlayState* play) { BgHakaTomb* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_haka_obj_Colheader_000EE8); - SubS_FillCutscenesList(&this->dyna.actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_FillCutscenesList(&this->dyna.actor, this->csIdList, ARRAY_COUNT(this->csIdList)); func_80BD6624(this); } @@ -61,15 +61,15 @@ void func_80BD6624(BgHakaTomb* this) { this->actionFunc = func_80BD66AC; } -s32 func_80BD6638(s16* arg0, s16* arg1, s32 arg2) { +s32 func_80BD6638(s16* csId, s16* csIdList, s32 numCutscenes) { s32 pad; s32 retVal = false; s32 i; - *arg0 = ActorCutscene_GetCurrentIndex(); - if (*arg0 >= 0) { - for (i = 0; i < arg2; i++) { - if (*arg0 == arg1[i]) { + *csId = CutsceneManager_GetCurrentCsId(); + if (*csId >= 0) { + for (i = 0; i < numCutscenes; i++) { + if (*csId == csIdList[i]) { retVal = true; break; } @@ -80,12 +80,13 @@ s32 func_80BD6638(s16* arg0, s16* arg1, s32 arg2) { } void func_80BD66AC(BgHakaTomb* this, PlayState* play) { - s16 temp; + s16 csId; if (Flags_GetClear(play, this->dyna.actor.room)) { this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } - if (!func_80BD6638(&temp, this->cutscenes, 1) && (temp < 0) && Flags_GetClear(play, this->dyna.actor.room)) { + if (!func_80BD6638(&csId, this->csIdList, ARRAY_COUNT(this->csIdList)) && (csId < 0) && + Flags_GetClear(play, this->dyna.actor.room)) { this->dyna.actor.flags |= ACTOR_FLAG_1; if (this->dyna.actor.isTargeted) { func_80BD6754(this); @@ -100,7 +101,7 @@ void func_80BD6754(BgHakaTomb* this) { } void func_80BD6768(BgHakaTomb* this, PlayState* play) { - if (SubS_StartActorCutscene(&this->dyna.actor, this->cutscenes[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + if (SubS_StartCutscene(&this->dyna.actor, this->csIdList[0], CS_ID_NONE, SUBS_CUTSCENE_WITH_PLAYER)) { BgHakaTomb_SetupDoNothing(this); } } diff --git a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.h b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.h index 3c607e0e2..fa06a8695 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.h +++ b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.h @@ -10,7 +10,7 @@ typedef void (*BgHakaTombActionFunc)(struct BgHakaTomb*, PlayState*); typedef struct BgHakaTomb { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ BgHakaTombActionFunc actionFunc; - /* 0x160 */ s16 cutscenes[1]; + /* 0x160 */ s16 csIdList[1]; } BgHakaTomb; // size = 0x164 #endif // Z_BG_HAKA_TOMB_H diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c index bde3c8540..99a5a759c 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c @@ -369,7 +369,7 @@ s32 func_80ABCC00(BgHakuginBombwall* this, PlayState* play) { return true; } } - } else if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + } else if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 50, NA_SE_EV_WALL_BROKEN); return true; } @@ -382,7 +382,7 @@ void func_80ABCCE4(BgHakuginBombwall* this, PlayState* play) { if (ptr->unk_20(this, play)) { this->dyna.actor.flags |= ACTOR_FLAG_10; - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); this->actionFunc = func_80ABCD98; } else { this->collider.base.acFlags &= ~AC_HIT; @@ -393,18 +393,18 @@ void func_80ABCCE4(BgHakuginBombwall* this, PlayState* play) { void func_80ABCD98(BgHakuginBombwall* this, PlayState* play) { s32 pad; - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); ptr->unk_24(this, play); this->dyna.actor.draw = NULL; this->unk_1AC = 20; Flags_SetSwitch(play, BGHAKUGIN_BOMBWALL_SWITCHFLAG(&this->dyna.actor)); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->actionFunc = func_80ABCE60; } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -413,7 +413,7 @@ void func_80ABCE60(BgHakuginBombwall* this, PlayState* play) { this->unk_1AC--; if (this->unk_1AC <= 0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); Actor_Kill(&this->dyna.actor); } else if (this->unk_1AC == ptr->unk_2C) { ptr->unk_28(this, play); diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c b/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c index 0b8d2490b..7cd94bd86 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c @@ -68,7 +68,7 @@ void func_80ABD92C(BgHakuginElvpole* this, PlayState* play) { sp28 = true; } else if (this->unk_15E > 0) { if (this->unk_15E == 100) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); } this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 120.0f; //! FAKE: @@ -83,7 +83,7 @@ void func_80ABD92C(BgHakuginElvpole* this, PlayState* play) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 320.0f; Flags_UnsetSwitch(play, BGHAKUGINELVPOLE_GET_SWITCHFLAG(&this->dyna.actor)); this->unk_15E = -1; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); } } else if ((BGHAKUGINELVPOLE_GET_SWITCHFLAG(&this->dyna.actor) != 0x7F) && Flags_GetSwitch(play, BGHAKUGINELVPOLE_GET_SWITCHFLAG(&this->dyna.actor))) { @@ -104,15 +104,15 @@ void func_80ABD92C(BgHakuginElvpole* this, PlayState* play) { this->unk_15C = 0; } if (this->unk_160) { - if (this->dyna.actor.cutscene == -1) { + if (this->dyna.actor.csId == CS_ID_NONE) { this->unk_160 = false; return; - } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + } else if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); this->unk_160 = false; return; } - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } 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 7f77b6645..c784c1318 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 @@ -28,9 +28,9 @@ void func_80A9CE00(BgHakuginPost* this); void func_80A9CE1C(BgHakuginPost* this, PlayState* play); void func_80A9D0A0(BgHakuginPost* this); void func_80A9D0B4(BgHakuginPost* this, PlayState* play); -void func_80A9D1E0(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 arg3, s16 arg4); +void func_80A9D1E0(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 csLength, s16 csId); void func_80A9D260(BgHakuginPost* this, PlayState* play); -void func_80A9D2C4(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 arg3, s16 arg4); +void func_80A9D2C4(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 csId, s16 additionalCsId); void func_80A9D360(BgHakuginPost* this, PlayState* play); void func_80A9D3E4(BgHakuginPost* this); void func_80A9D434(BgHakuginPost* this, PlayState* play); @@ -162,12 +162,12 @@ void func_80A9AFB4(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* } else { unkStruct->unk_0000[i].unk_34 = 1; } - unkStruct->unk_0000[i].unk_2A = this->dyna.actor.cutscene; - unkStruct->unk_0000[i].unk_2C = ActorCutscene_GetAdditionalCutscene(unkStruct->unk_0000[i].unk_2A); + unkStruct->unk_0000[i].csId = this->dyna.actor.csId; + unkStruct->unk_0000[i].additionalCsId = CutsceneManager_GetAdditionalCsId(unkStruct->unk_0000[i].csId); } else { unkStruct->unk_0000[i].unk_34 = 1; - unkStruct->unk_0000[i].unk_2A = -1; - unkStruct->unk_0000[i].unk_2C = -1; + unkStruct->unk_0000[i].csId = CS_ID_NONE; + unkStruct->unk_0000[i].additionalCsId = CS_ID_NONE; } unkStruct->unk_0000[i].unk_2F = 1; @@ -522,10 +522,10 @@ void func_80A9C058(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* sp44.z = this->dyna.actor.home.pos.z + unkStruct1->unk_14.z; Rumble_Request(Math3D_Vec3fDistSq(&sp44, &GET_PLAYER(play)->actor.world.pos), 255, 20, 150); - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 20000); - Quake_SetQuakeValues(quakeIndex, 7, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 12); + Quake_SetPerturbations(quakeIndex, 7, 0, 0, 0); + Quake_SetDuration(quakeIndex, 12); if (this->unk_179 <= 0) { func_8019F128(NA_SE_EV_STONEDOOR_STOP); @@ -537,7 +537,7 @@ void func_80A9C058(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* } } -void func_80A9C18C(BgHakuginPost* this, PlayState* play) { +void BgHakuginPost_RequestQuakeAndRumble(BgHakuginPost* this, PlayState* play) { s32 pad; Player* player = GET_PLAYER(play); Camera* activeCam = GET_ACTIVE_CAM(play); @@ -547,10 +547,10 @@ void func_80A9C18C(BgHakuginPost* this, PlayState* play) { this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.z), 255, 20, 150); - quakeIndex = Quake_Add(activeCam, QUAKE_TYPE_3); + quakeIndex = Quake_Request(activeCam, QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 17232); - Quake_SetQuakeValues(quakeIndex, 6, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 20); + Quake_SetPerturbations(quakeIndex, 6, 0, 0, 0); + Quake_SetDuration(quakeIndex, 20); } void func_80A9C228(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* unkStruct) { @@ -703,7 +703,7 @@ void BgHakuginPost_Init(Actor* thisx, PlayState* play) { this->dyna.actor.world.rot.z = 0; this->dyna.actor.shape.rot.x = 0; this->dyna.actor.shape.rot.z = 0; - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_hakugin_obj_Colheader_00D3B0); func_80A9B3BC(this, play); func_80A9CA94(this); @@ -783,7 +783,7 @@ void func_80A9CC84(BgHakuginPost* this) { void func_80A9CCA0(BgHakuginPost* this, PlayState* play) { if (this->unk_174 != 0) { func_80A9D1E0(this, func_80A9CD00, (this->unk_164 - this->dyna.actor.home.pos.y) + 100.0f, 60, - this->dyna.actor.cutscene); + this->dyna.actor.csId); } } @@ -798,7 +798,7 @@ void func_80A9CD14(BgHakuginPost* this, PlayState* play) { temp_f12 = CLAMP_MAX(temp_f12, 40.0f); this->unk_16C += temp_f12; if (this->unk_168 <= this->unk_16C) { - func_80A9C18C(this, play); + BgHakuginPost_RequestQuakeAndRumble(this, play); func_8019F128(NA_SE_EV_STONEDOOR_STOP); func_80A9CE00(this); } else { @@ -823,7 +823,7 @@ void func_80A9CE1C(BgHakuginPost* this, PlayState* play) { if (this->unk_170 != 0) { func_80A9D1E0(this, func_80A9D0A0, (this->unk_164 - this->dyna.actor.home.pos.y) + 100.0f, 0x3C, - ActorCutscene_GetAdditionalCutscene(this->dyna.actor.cutscene)); + CutsceneManager_GetAdditionalCsId(this->dyna.actor.csId)); return; } @@ -839,12 +839,12 @@ void func_80A9CE1C(BgHakuginPost* this, PlayState* play) { 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, NA_SE_IT_HAMMER_HIT); + Player_PlaySfx(player, NA_SE_IT_HAMMER_HIT); func_8019F128(NA_SE_EV_SLIDE_DOOR_OPEN); Flags_SetSwitch(play, 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); + func_80A9D2C4(this, func_80A9CE00, D_80A9E028.unk_0000[i].unk_14.y + 50.0f, D_80A9E028.unk_0000[i].csId, + D_80A9E028.unk_0000[i].additionalCsId); break; } } @@ -876,7 +876,7 @@ void func_80A9D0B4(BgHakuginPost* this, PlayState* play) { func_80A9C634(this, play); func_80A9B160(&D_80A9E028, play); this->unk_16C = this->unk_164; - func_80A9C18C(this, play); + BgHakuginPost_RequestQuakeAndRumble(this, play); func_8019F128(NA_SE_EV_STONEDOOR_STOP); func_80A9CC84(this); } else { @@ -884,12 +884,12 @@ void func_80A9D0B4(BgHakuginPost* this, PlayState* play) { } } -void func_80A9D1E0(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 arg3, s16 arg4) { +void func_80A9D1E0(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 csLength, s16 csId) { this->unkFunc = unkFunc; - this->unk_184 = arg4; - this->unk_180 = ActorCutscene_GetLength(arg4); - if (this->unk_180 < 0) { - this->unk_180 = arg3; + this->csId = csId; + this->csLength = CutsceneManager_GetLength(csId); + if (this->csLength < 0) { + this->csLength = csLength; } this->dyna.actor.focus.pos.x = this->dyna.actor.home.pos.x; this->dyna.actor.focus.pos.y = this->unk_16C + arg2; @@ -898,22 +898,22 @@ void func_80A9D1E0(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 } void func_80A9D260(BgHakuginPost* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->unk_184)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_184, &this->dyna.actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->dyna.actor); this->unkFunc(this); } else { - ActorCutscene_SetIntentToPlay(this->unk_184); + CutsceneManager_Queue(this->csId); } } -void func_80A9D2C4(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 arg3, s16 arg4) { +void func_80A9D2C4(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 csId, s16 additionalCsId) { this->unkFunc = unkFunc; - this->unk_184 = arg3; - this->unk_186 = arg4; - this->unk_180 = -1; - this->unk_180 = ActorCutscene_GetLength(arg3); - if (this->unk_180 < 0) { - this->unk_180 = 15; + this->csId = csId; + this->additionalCsId = additionalCsId; + this->csLength = -1; + this->csLength = CutsceneManager_GetLength(csId); + if (this->csLength < 0) { + this->csLength = 15; } this->dyna.actor.focus.pos.x = this->dyna.actor.home.pos.x; this->dyna.actor.focus.pos.y = this->unk_16C + arg2; @@ -922,32 +922,32 @@ void func_80A9D2C4(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 } void func_80A9D360(BgHakuginPost* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->unk_184)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_184, &this->dyna.actor); - if (this->unk_186 >= 0) { + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->dyna.actor); + if (this->additionalCsId >= 0) { func_80A9D3E4(this); } else { this->unkFunc(this); } } else { - ActorCutscene_SetIntentToPlay(this->unk_184); + CutsceneManager_Queue(this->csId); } } void func_80A9D3E4(BgHakuginPost* this) { - this->unk_182 = ActorCutscene_GetLength(this->unk_186); - if (this->unk_182 < 0) { - this->unk_182 = 30; + this->additionalCsLength = CutsceneManager_GetLength(this->additionalCsId); + if (this->additionalCsLength < 0) { + this->additionalCsLength = 30; } this->actionFunc = func_80A9D434; } void func_80A9D434(BgHakuginPost* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->unk_186) != 0) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_186, &this->dyna.actor); + if (CutsceneManager_IsNext(this->additionalCsId)) { + CutsceneManager_StartWithPlayerCs(this->additionalCsId, &this->dyna.actor); this->unkFunc(this); } else { - ActorCutscene_SetIntentToPlay(this->unk_186); + CutsceneManager_Queue(this->additionalCsId); } } @@ -956,17 +956,17 @@ void BgHakuginPost_Update(Actor* thisx, PlayState* play) { f32 temp; func_80A9B46C(this, play); - if ((this->unk_180 >= 0) && ((this->actionFunc != func_80A9D260) || (this->actionFunc != func_80A9D360))) { - this->unk_180--; - if (this->unk_180 < 0) { - ActorCutscene_Stop(this->unk_184); + if ((this->csLength >= 0) && ((this->actionFunc != func_80A9D260) || (this->actionFunc != func_80A9D360))) { + this->csLength--; + if (this->csLength < 0) { + CutsceneManager_Stop(this->csId); } } - if ((this->unk_182 >= 0) && (this->actionFunc != func_80A9D434)) { - this->unk_182--; - if (this->unk_182 < 0) { - ActorCutscene_Stop(this->unk_186); + if ((this->additionalCsLength >= 0) && (this->actionFunc != func_80A9D434)) { + this->additionalCsLength--; + if (this->additionalCsLength < 0) { + CutsceneManager_Stop(this->additionalCsId); } } diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h index 5a23fa070..4797a684a 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h @@ -19,8 +19,8 @@ typedef struct { /* 0x20 */ f32 unk_20; /* 0x24 */ f32 unk_24; /* 0x28 */ s16 unk_28; - /* 0x2A */ s16 unk_2A; - /* 0x2C */ s16 unk_2C; + /* 0x2A */ s16 csId; + /* 0x2C */ s16 additionalCsId; /* 0x2E */ u8 unk_2E; /* 0x2F */ u8 unk_2F; /* 0x30 */ s8 unk_30; @@ -64,10 +64,10 @@ typedef struct BgHakuginPost { /* 0x178 */ s8 unk_178; /* 0x179 */ s8 unk_179; /* 0x17C */ BgHakuginPostFunc unkFunc; - /* 0x180 */ s16 unk_180; - /* 0x182 */ s16 unk_182; - /* 0x184 */ s16 unk_184; - /* 0x186 */ s16 unk_186; + /* 0x180 */ s16 csLength; + /* 0x182 */ s16 additionalCsLength; + /* 0x184 */ s16 csId; + /* 0x186 */ s16 additionalCsId; } BgHakuginPost; // size = 0x188 #endif // Z_BG_HAKUGIN_POST_H diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c index aa22dd8af..c7fa3d69e 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c @@ -102,7 +102,7 @@ static InitChainEntry sInitChain2[] = { void func_80B15790(BgHakuginSwitch* this, u16 sfxId) { if (this->unk_1B2 <= 0) { - Actor_PlaySfxAtPos(&this->dyna.actor, sfxId); + Actor_PlaySfx(&this->dyna.actor, sfxId); } } @@ -126,7 +126,7 @@ void BgHakuginSwitch_Init(Actor* thisx, PlayState* play) { sp30 = false; } - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_goronswitch_Colheader_0005C8); Collider_InitCylinder(play, &this->collider); @@ -143,12 +143,12 @@ void BgHakuginSwitch_Init(Actor* thisx, PlayState* play) { this->collider.dim.yShift = 0x1D; this->unk_1A8 = object_goronswitch_DL_000268; - this->unk_1B8 = this->dyna.actor.cutscene; + this->csId = this->dyna.actor.csId; if (sp34 == 0) { - this->unk_1BA = -1; + this->additionalCsId = CS_ID_NONE; } else { - this->unk_1BA = ActorCutscene_GetAdditionalCutscene(this->unk_1B8); + this->additionalCsId = CutsceneManager_GetAdditionalCsId(this->csId); } if (sp30) { @@ -166,8 +166,8 @@ void BgHakuginSwitch_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain2); this->unk_1A8 = D_80B1688C[sp34].unk_10; - this->unk_1B8 = this->dyna.actor.cutscene; - this->unk_1BA = ActorCutscene_GetAdditionalCutscene(this->unk_1B8); + this->csId = this->dyna.actor.csId; + this->additionalCsId = CutsceneManager_GetAdditionalCsId(this->csId); if (sp30 == sp28) { func_80B15F3C(this, play); @@ -186,9 +186,9 @@ void BgHakuginSwitch_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void func_80B15A4C(BgHakuginSwitch* this, BgHakuginSwitchUnkFunc func, s32 arg2) { +void func_80B15A4C(BgHakuginSwitch* this, BgHakuginSwitchUnkFunc func, s32 csId) { this->unk_1B4 = func; - this->unk_1BC = arg2; + this->curCsId = csId; this->actionFunc = func_80B15A68; } @@ -197,14 +197,14 @@ void func_80B15A68(BgHakuginSwitch* this, PlayState* play) { BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; s32 sp18 = !(s->unk_14 & 0x40); - if (ActorCutscene_GetCanPlayNext(this->unk_1BC)) { + if (CutsceneManager_IsNext(this->curCsId)) { if (sp18) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_1BC, &this->dyna.actor); + CutsceneManager_StartWithPlayerCs(this->curCsId, &this->dyna.actor); this->unk_1BF = 40; } this->unk_1B4(this, play); } else if (sp18) { - ActorCutscene_SetIntentToPlay(this->unk_1BC); + CutsceneManager_Queue(this->curCsId); } } @@ -244,7 +244,7 @@ void func_80B15B74(BgHakuginSwitch* this, PlayState* play) { if (sp34) { this->collider.base.acFlags &= ~AC_HIT; - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { sp24 = true; sp20 = sp28; } @@ -281,7 +281,7 @@ void func_80B15B74(BgHakuginSwitch* this, PlayState* play) { D_80B16AF0 = play->gameplayFrames; if (sp38->unk_14 & 0x10) { - func_80B15A4C(this, func_80B15E0C, this->unk_1B8); + func_80B15A4C(this, func_80B15E0C, this->csId); } else { func_80B15E0C(this, play); } @@ -306,7 +306,7 @@ void func_80B15E78(BgHakuginSwitch* this, PlayState* play) { BgHakuginSwitchStruct* sp20 = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; if (Math_StepToF(&this->dyna.actor.world.pos.y, sp20->unk_4 + this->dyna.actor.home.pos.y, sp20->unk_C)) { - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); } func_80B15F3C(this, play); @@ -343,7 +343,7 @@ void func_80B15F88(BgHakuginSwitch* this, PlayState* play) { if (phi_a0 != phi_v1) { if ((sp18->unk_14 & 0xFF) & 0x20) { if (D_80B16AF0 < play->gameplayFrames) { - func_80B15A4C(this, func_80B1606C, this->unk_1BA); + func_80B15A4C(this, func_80B1606C, this->additionalCsId); } } else { func_80B1606C(this, play); @@ -372,16 +372,16 @@ void func_80B160DC(BgHakuginSwitch* this, PlayState* play) { } } -void func_80B16180(BgHakuginSwitch* this, BgHakuginSwitchUnkFunc func, s32 arg2, s32 arg3) { +void func_80B16180(BgHakuginSwitch* this, BgHakuginSwitchUnkFunc func, s32 arg2, s32 csId) { this->unk_1B4 = func; this->unk_1BE = arg2; - this->unk_1BC = arg3; + this->curCsId = csId; this->actionFunc = func_80B161A0; } void func_80B161A0(BgHakuginSwitch* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->unk_1BC)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_1BC, &this->dyna.actor); + if (CutsceneManager_IsNext(this->curCsId)) { + CutsceneManager_StartWithPlayerCs(this->curCsId, &this->dyna.actor); if (this->unk_1BE != 0) { Flags_SetSwitch(play, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); } else { @@ -390,7 +390,7 @@ void func_80B161A0(BgHakuginSwitch* this, PlayState* play) { this->unk_1BF = 50; this->unk_1B4(this, play); } else { - ActorCutscene_SetIntentToPlay(this->unk_1BC); + CutsceneManager_Queue(this->curCsId); } } @@ -413,7 +413,7 @@ void func_80B162AC(BgHakuginSwitch* this, PlayState* play) { if (sp34) { this->collider.base.acFlags &= ~AC_HIT; - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { sp24 = true; sp28 = true; } @@ -427,7 +427,7 @@ void func_80B162AC(BgHakuginSwitch* this, PlayState* play) { if (sp24) { if (sp28) { - func_80B16180(this, func_80B163C4, 1, this->unk_1B8); + func_80B16180(this, func_80B163C4, 1, this->csId); } else { func_80B163C4(this, play); } @@ -446,7 +446,7 @@ void func_80B163C4(BgHakuginSwitch* this, PlayState* play) { void func_80B16400(BgHakuginSwitch* this, PlayState* play) { if (Math_StepToF(&this->dyna.actor.world.pos.y, (this->dyna.actor.home.pos.y + 2.0f) - (1800.0f * this->dyna.actor.scale.y), 10.0f)) { - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); } func_80B16494(this, play); @@ -466,7 +466,7 @@ void func_80B16494(BgHakuginSwitch* this, PlayState* play) { void func_80B16520(BgHakuginSwitch* this, PlayState* play) { if (!Flags_GetSwitch(play, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { if (BGHAKUGINSWITCH_GET_7(&this->dyna.actor) == BGHAKUGINSWITCH_GET_7_1) { - func_80B16180(this, func_80B165A0, 0, this->unk_1BA); + func_80B16180(this, func_80B165A0, 0, this->additionalCsId); } else { func_80B165A0(this, play); } @@ -498,7 +498,7 @@ void BgHakuginSwitch_Update(Actor* thisx, PlayState* play) { if ((this->actionFunc != func_80B15A68) && (this->actionFunc != func_80B161A0)) { this->unk_1BF--; if (this->unk_1BF == 0) { - ActorCutscene_Stop(this->unk_1BC); + CutsceneManager_Stop(this->curCsId); } } } @@ -510,8 +510,8 @@ void BgHakuginSwitch_Update(Actor* thisx, PlayState* play) { if (this->unk_1C0 != 0) { f32 phi_f0; - if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { - if (DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + if (DynaPolyActor_IsSwitchPressed(&this->dyna)) { + if (DynaPolyActor_IsHeavySwitchPressed(&this->dyna)) { phi_f0 = (sp24 - -10.0f) * -0.21f; } else { phi_f0 = (sp24 - -3.0f) * -0.08f; diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h index 164220b29..caf3c2f65 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h @@ -22,9 +22,9 @@ typedef struct BgHakuginSwitch { /* 0x1B0 */ s16 unk_1B0; /* 0x1B2 */ s8 unk_1B2; /* 0x1B4 */ BgHakuginSwitchUnkFunc unk_1B4; - /* 0x1B8 */ s16 unk_1B8; - /* 0x1BA */ s16 unk_1BA; - /* 0x1BC */ s16 unk_1BC; + /* 0x1B8 */ s16 csId; + /* 0x1BA */ s16 additionalCsId; + /* 0x1BC */ s16 curCsId; /* 0x1BE */ s8 unk_1BE; /* 0x1BF */ s8 unk_1BF; /* 0x1C0 */ s8 unk_1C0; diff --git a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c index 265490e52..27e5d2fee 100644 --- a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c +++ b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c @@ -86,7 +86,7 @@ void func_80AC4A80(BgIcefloe* this, PlayState* play) { this->timer = 20; SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &this->dyna.actor.world.pos, &this->dyna.actor.projectedPos, &this->dyna.actor.projectedW); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_ICE_STAND_APPEAR); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_ICE_STAND_APPEAR); this->actionFunc = BgIcefloe_Grow; } @@ -133,7 +133,7 @@ void func_80AC4C34(BgIcefloe* this, PlayState* play) { void func_80AC4CF0(BgIcefloe* this) { this->timer = 50; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_ICE_MELT_LEVEL); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_ICE_MELT_LEVEL); this->actionFunc = func_80AC4D2C; } 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 743213652..740d807d8 100644 --- a/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c +++ b/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c @@ -142,7 +142,7 @@ void BgIcicle_Shiver(BgIcicle* this, PlayState* play) { } if (!(this->shiverTimer % 4)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_ICE_SWING); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_ICE_SWING); } if (this->shiverTimer == 0) { @@ -150,7 +150,7 @@ void BgIcicle_Shiver(BgIcicle* this, PlayState* play) { this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z; CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->actionFunc = BgIcicle_Fall; } else { rand = Rand_ZeroOne(); @@ -163,9 +163,9 @@ void BgIcicle_Shiver(BgIcicle* this, PlayState* play) { } void BgIcicle_Fall(BgIcicle* this, PlayState* play) { - if ((this->collider.base.atFlags & AT_HIT) || (this->dyna.actor.bgCheckFlags & 1)) { + if ((this->collider.base.atFlags & AT_HIT) || (this->dyna.actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->collider.base.atFlags &= ~AT_HIT; - this->dyna.actor.bgCheckFlags &= ~1; + this->dyna.actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; if (this->dyna.actor.world.pos.y < this->dyna.actor.floorHeight) { this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; @@ -175,7 +175,7 @@ void BgIcicle_Fall(BgIcicle* this, PlayState* play) { if (this->dyna.actor.params == ICICLE_STALACTITE_REGROW) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 120.0f; - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->actionFunc = BgIcicle_Regrow; } else { Actor_Kill(&this->dyna.actor); @@ -183,7 +183,7 @@ void BgIcicle_Fall(BgIcicle* this, PlayState* play) { } else { Actor_MoveWithGravity(&this->dyna.actor); this->dyna.actor.world.pos.y += 40.0f; - Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); this->dyna.actor.world.pos.y -= 40.0f; CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } @@ -216,7 +216,7 @@ void BgIcicle_UpdateAttacked(BgIcicle* this, PlayState* play) { if (this->dyna.actor.params == ICICLE_STALACTITE_REGROW) { BgIcicle_Break(this, play, 40.0f); this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 120.0f; - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->actionFunc = BgIcicle_Regrow; return; } diff --git a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c index 9d249314a..401d3543e 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c @@ -184,9 +184,9 @@ void BgIkanaBlock_Init(Actor* thisx, PlayState* play) { BgIkanaBlock* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->unk_15C = Lib_SegmentedToVirtual(gameplay_dangeon_keep_Matanimheader_01B370); this->unk_174 = this->dyna.actor.shape.rot; func_80B7ED54(this); @@ -211,7 +211,7 @@ void func_80B7F034(BgIkanaBlock* this, PlayState* play) { } if (func_80B7EEB4(this, play)) { - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = func_80B7F564; func_80B7F0A4(this); } @@ -294,7 +294,7 @@ void func_80B7F290(BgIkanaBlock* this, PlayState* play) { Player* player = GET_PLAYER(play); if (!func_80B7EB94(this, play)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } player->stateFlags2 &= ~PLAYER_STATE2_10; @@ -334,10 +334,10 @@ void func_80B7F398(BgIkanaBlock* this, PlayState* play) { this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; if (func_80B7EE70(this, play)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - Actor_PlaySfxAtPos(&this->dyna.actor, - SurfaceType_GetSfx(&play->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) + - SFX_FLAG); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfx(&this->dyna.actor, + NA_SE_PL_WALK_GROUND + SurfaceType_GetSfxOffset(&play->colCtx, this->dyna.actor.floorPoly, + this->dyna.actor.floorBgId)); func_80B7F0A4(this); } } @@ -358,13 +358,13 @@ void BgIkanaBlock_Update(Actor* thisx, PlayState* play) { if (this->unk_17E != 0) { if (this->unk_17F > 0) { this->unk_17F--; - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); this->unk_17E = 0; - } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + } else if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); this->unk_17F = 30; } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } } diff --git a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c index 04f7f514b..edcda4b37 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c @@ -319,13 +319,13 @@ void func_80BD4F9C(BgIkanaBombwall* this, PlayState* play) { void func_80BD4FF8(BgIkanaBombwall* this) { this->dyna.actor.flags |= ACTOR_FLAG_10; - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); this->actionFunc = func_80BD503C; } void func_80BD503C(BgIkanaBombwall* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); if (!BGIKANABOMBWALL_GET_100(&this->dyna.actor)) { func_80BD4720(this, play); } else { @@ -335,11 +335,11 @@ void func_80BD503C(BgIkanaBombwall* this, PlayState* play) { SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 60, NA_SE_EV_WALL_BROKEN); Flags_SetSwitch(play, BGIKANABOMBWALL_GET_SWITCHFLAG(&this->dyna.actor)); if (!BGIKANABOMBWALL_GET_100(&this->dyna.actor)) { - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } func_80BD5118(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -352,11 +352,11 @@ void func_80BD5134(BgIkanaBombwall* this, PlayState* play) { if (!BGIKANABOMBWALL_GET_100(&this->dyna.actor)) { this->unk_1AC--; if (this->unk_1AC <= 0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); Actor_Kill(&this->dyna.actor); } - } else if (this->dyna.actor.cutscene >= 0) { - if (ActorCutscene_GetCurrentIndex() != this->dyna.actor.cutscene) { + } else if (this->dyna.actor.csId >= 0) { + if (CutsceneManager_GetCurrentCsId() != this->dyna.actor.csId) { Actor_Kill(&this->dyna.actor); } } else { diff --git a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c index 678080ae1..f853fdfc5 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c @@ -115,11 +115,11 @@ void BgIkanaDharma_Init(Actor* thisx, PlayState* play2) { Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_BG_IKANA_DHARMA, this->dyna.actor.world.pos.x, segmentY, this->dyna.actor.world.pos.z, this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, - BGIKANADHARMA_PARAMS(0, true, 0), this->dyna.actor.cutscene, - this->dyna.actor.unk20, NULL); + BGIKANADHARMA_PARAMS(0, true, 0), this->dyna.actor.csId, + this->dyna.actor.halfDaysBits, NULL); } - this->dyna.actor.bgCheckFlags |= 1; + this->dyna.actor.bgCheckFlags |= BGCHECKFLAG_GROUND; } BgIkanaDharma_SetupWaitForHit(this); @@ -137,7 +137,7 @@ void BgIkanaDharma_Destroy(Actor* thisx, PlayState* play) { void BgIkanaDharma_SetupWaitForHit(BgIkanaDharma* this) { this->actionFunc = BgIkanaDharma_WaitForHit; - this->dyna.actor.speedXZ = 0.0f; + this->dyna.actor.speed = 0.0f; } void BgIkanaDharma_WaitForHit(BgIkanaDharma* this, PlayState* play) { @@ -157,8 +157,8 @@ void BgIkanaDharma_WaitForHit(BgIkanaDharma* this, PlayState* play) { tempAngle1 = BINANG_ADD(this->dyna.actor.yawTowardsPlayer, 0x8000); tempAngle2 = (BINANG_SUB(player->actor.shape.rot.y, tempAngle1) >> 1); this->dyna.actor.world.rot.y = tempAngle1 + tempAngle2 + 0xF000; - this->dyna.actor.speedXZ = 20.0f; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DARUMA_VANISH); + this->dyna.actor.speed = 20.0f; + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_DARUMA_VANISH); BgIkanaDharma_SetupStartCutscene(this); } else if ((this->dyna.actor.flags & ACTOR_FLAG_40) == ACTOR_FLAG_40 && sFirstHitBgIkanaDharma == NULL && this->dyna.actor.xzDistToPlayer < 420.0f) { @@ -173,16 +173,16 @@ void BgIkanaDharma_WaitForHit(BgIkanaDharma* this, PlayState* play) { } void BgIkanaDharma_SetupStartCutscene(BgIkanaDharma* this) { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); this->actionFunc = BgIkanaDharma_StartCutscene; } void BgIkanaDharma_StartCutscene(BgIkanaDharma* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); BgIkanaDharma_SetupWaitForCutsceneToEnd(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -200,7 +200,7 @@ void BgIkanaDharma_WaitForCutsceneToEnd(BgIkanaDharma* this, PlayState* play) { sFirstHitBgIkanaDharma = NULL; } - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); } } @@ -226,15 +226,15 @@ void BgIkanaDharma_Update(Actor* thisx, PlayState* play) { actorBelow = DynaPoly_GetActor(&play->colCtx, this->dyna.actor.floorBgId); if (actorBelow == NULL) { Actor_MoveWithGravity(&this->dyna.actor); - Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); - if (this->dyna.actor.bgCheckFlags & 2) { - s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); + if (this->dyna.actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 21536); - Quake_SetQuakeValues(quakeIndex, 4, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 12); + Quake_SetPerturbations(quakeIndex, 4, 0, 0, 0); + Quake_SetDuration(quakeIndex, 12); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } } else { if (actorBelow->actor.id == ACTOR_BG_IKANA_DHARMA) { @@ -250,7 +250,8 @@ void BgIkanaDharma_Update(Actor* thisx, PlayState* play) { wallCheckRadius = CLAMP_MIN(wallCheckRadius, 2.0f); Actor_MoveWithGravity(&this->dyna.actor); - Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 20.0f, wallCheckRadius, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 20.0f, wallCheckRadius, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } Actor_SetFocus(&this->dyna.actor, 40.0f); diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c index 27cecd05a..8a90a6809 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c @@ -179,7 +179,7 @@ void func_80B80440(BgIkanaRotaryroom* this, PlayState* play) { this->unk_204.unk_00 = Actor_SpawnAsChildAndCutscene( &play->actorCtx, play, ACTOR_BG_IKANA_BLOCK, sp50.x, sp50.y, sp50.z, this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, -1, - ActorCutscene_GetAdditionalCutscene(this->dyna.actor.cutscene), this->dyna.actor.unk20, NULL); + CutsceneManager_GetAdditionalCsId(this->dyna.actor.csId), this->dyna.actor.halfDaysBits, NULL); Matrix_Pop(); } @@ -515,7 +515,7 @@ void func_80B81010(BgIkanaRotaryroom* this, PlayState* play) { CollisionPoly* sp7C; s32 sp78; - if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { + if (CutsceneManager_GetCurrentCsId() == this->dyna.actor.csId) { phi_s7 = true; for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { @@ -582,7 +582,7 @@ void func_80B81234(BgIkanaRotaryroom* this, PlayState* play) { CollisionPoly* sp40; s32 sp3C; - if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { + if (CutsceneManager_GetCurrentCsId() == this->dyna.actor.csId) { if (player == NULL) { return; } @@ -646,12 +646,12 @@ void func_80B81234(BgIkanaRotaryroom* this, PlayState* play) { void func_80B814B8(BgIkanaRotaryroom* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { - if (player->actor.bgCheckFlags & 0x100) { - func_800B8E58(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->voiceSfxIdOffset); + if (CutsceneManager_GetCurrentCsId() == this->dyna.actor.csId) { + if (player->actor.bgCheckFlags & BGCHECKFLAG_CRUSHED) { + Player_PlaySfx(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->voiceSfxIdOffset); func_80169EFC(&play->state); - func_800B8E58(player, NA_SE_VO_LI_TAKEN_AWAY + player->ageProperties->voiceSfxIdOffset); - play->unk_18845 = 1; + Player_PlaySfx(player, NA_SE_VO_LI_TAKEN_AWAY + player->ageProperties->voiceSfxIdOffset); + play->haltAllActors = true; play_sound(NA_SE_OC_ABYSS); this->actionFunc = NULL; } @@ -714,7 +714,7 @@ void BgIkanaRotaryroom_Init(Actor* thisx, PlayState* play) { this->dyna.actor.shape.rot.x = 0; } - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, D_80B82218[sp34]); Collider_InitJntSph(play, &this->collider); @@ -791,14 +791,14 @@ void func_80B819DC(BgIkanaRotaryroom* this) { void func_80B819F0(Actor* thisx, PlayState* play) { BgIkanaRotaryroom* this = THIS; - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - if (this->dyna.actor.cutscene >= 0) { - func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_7); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); + if (this->dyna.actor.csId >= 0) { + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_WAIT); } func_80B81A64(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -832,11 +832,11 @@ void func_80B81A80(Actor* thisx, PlayState* play) { func_80B81B84(this); } else if (this->unk_584 == 15) { - s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 31536); - Quake_SetQuakeValues(quakeIndex, 6, 0, 100, 0); - Quake_SetCountdown(quakeIndex, 22); + Quake_SetPerturbations(quakeIndex, 6, 0, 100, 0); + Quake_SetDuration(quakeIndex, 22); } } @@ -859,11 +859,11 @@ void func_80B81BA0(Actor* thisx, PlayState* play) { thisx->shape.rot.x += 0x1F4; if (!(this->unk_584 & 7)) { - s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 31536); - Quake_SetQuakeValues(quakeIndex, (s32)(Rand_ZeroOne() * 2.5f) + 3, 0, 10, 0); - Quake_SetCountdown(quakeIndex, 15); + Quake_SetPerturbations(quakeIndex, (s32)(Rand_ZeroOne() * 2.5f) + 3, 0, 10, 0); + Quake_SetDuration(quakeIndex, 15); } if (Flags_GetSwitch(play, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) { @@ -926,14 +926,14 @@ void func_80B81DC8(Actor* thisx, PlayState* play) { this->unk_584--; if (this->unk_584 <= 0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); func_80B818B4(this); } else if (this->unk_584 == 19) { - s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 20000); - Quake_SetQuakeValues(quakeIndex, 5, 0, 40, 60); - Quake_SetCountdown(quakeIndex, 17); + Quake_SetPerturbations(quakeIndex, 5, 0, 40, 60); + Quake_SetDuration(quakeIndex, 17); } } 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 a7ba89cdc..4a0abb472 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 @@ -106,12 +106,12 @@ void func_80BD5878(BgIkanaShutter* this) { } void func_80BD5894(BgIkanaShutter* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); func_80BD58F0(this); return; } - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } void func_80BD58F0(BgIkanaShutter* this) { @@ -151,10 +151,10 @@ void func_80BD5A18(BgIkanaShutter* this, PlayState* play) { this->dyna.actor.velocity.y *= 0.978f; this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; if (this->dyna.actor.world.pos.y <= this->dyna.actor.home.pos.y) { - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 21536); - Quake_SetQuakeValues(quakeIndex, 4, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 12); + Quake_SetPerturbations(quakeIndex, 4, 0, 0, 0); + Quake_SetDuration(quakeIndex, 12); func_80BD5828(this); } @@ -177,13 +177,13 @@ void func_80BD5B44(BgIkanaShutter* this) { } void func_80BD5B60(BgIkanaShutter* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); Flags_SetClear(play, this->dyna.actor.room); func_80BD5BC4(this); return; } - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } void func_80BD5BC4(BgIkanaShutter* this) { 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 f9a9fcc37..48045527f 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 @@ -62,26 +62,27 @@ s32 func_80C0A740(BgIkninSusceil* this, PlayState* play) { } void func_80C0A804(BgIkninSusceil* this, PlayState* play) { - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } void func_80C0A838(BgIkninSusceil* this, PlayState* play) { - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } -void func_80C0A86C(BgIkninSusceil* this, PlayState* play, s16 verticalMag, s16 countdown, s32 arg4) { +void BgIkninSusceil_RequestQuakeAndRumble(BgIkninSusceil* this, PlayState* play, s16 quakeY, s16 quakeDuration, + s32 rumbleType) { s32 pad; - s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 31536); - Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0); - Quake_SetCountdown(quakeIndex, countdown); + Quake_SetPerturbations(quakeIndex, quakeY, 0, 0, 0); + Quake_SetDuration(quakeIndex, quakeDuration); - if (arg4 == 1) { + if (rumbleType == 1) { Rumble_Request(SQ(100.0f), 255, 20, 150); - } else if (arg4 == 2) { + } else if (rumbleType == 2) { Rumble_Request(SQ(100.0f), 180, 20, 100); - } else if (arg4 == 3) { + } else if (rumbleType == 3) { Rumble_Request(SQ(100.0f), 120, 20, 10); } } @@ -115,7 +116,7 @@ void BgIkninSusceil_Init(Actor* thisx, PlayState* play) { BgIkninSusceil* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_ikninside_obj_Colheader_00CBAC); this->animatedTexture = Lib_SegmentedToVirtual(object_ikninside_obj_Matanimheader_00C670); func_80C0AC74(this); @@ -154,9 +155,9 @@ void func_80C0ABA8(BgIkninSusceil* this, PlayState* play) { this->dyna.actor.velocity.y *= 0.93f; 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, play, 4, 14, 1); + BgIkninSusceil_RequestQuakeAndRumble(this, play, 4, 14, 1); Flags_UnsetSwitch(play, SUSCEIL_GET_SWITCHFLAG(&this->dyna.actor)); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND); + Actor_PlaySfx(&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); @@ -179,11 +180,11 @@ void func_80C0ACD4(BgIkninSusceil* this) { } void func_80C0ACE8(BgIkninSusceil* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); func_80C0AD44(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -197,8 +198,8 @@ void func_80C0AD64(BgIkninSusceil* this, PlayState* play) { this->dyna.actor.velocity.y *= 0.98f; if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 365.0f, 0.5f, this->dyna.actor.velocity.y, 1.0f) < 0.1f) { - func_80C0A86C(this, play, 1, 14, 3); - ActorCutscene_Stop(this->dyna.actor.cutscene); + BgIkninSusceil_RequestQuakeAndRumble(this, play, 1, 14, 3); + CutsceneManager_Stop(this->dyna.actor.csId); func_80C0AB14(this); } else { func_800B9010(&this->dyna.actor, NA_SE_EV_ICE_PILLAR_RISING - SFX_FLAG); @@ -216,7 +217,7 @@ void func_80C0AE5C(BgIkninSusceil* this, PlayState* play) { this->dyna.actor.velocity.y = CLAMP_MIN(this->dyna.actor.velocity.y, 1.0f); this->dyna.actor.world.pos.y = this->dyna.actor.world.pos.y + this->dyna.actor.velocity.y; if ((this->dyna.actor.home.pos.y + 365.0f) < this->dyna.actor.world.pos.y) { - func_80C0A86C(this, play, 3, 14, 2); + BgIkninSusceil_RequestQuakeAndRumble(this, play, 3, 14, 2); func_80C0AB14(this); } } @@ -230,7 +231,7 @@ void BgIkninSusceil_Update(Actor* thisx, PlayState* play) { (player->unk_B48 > 1000.0f)) { this->unk168 = 2; if ((func_80C0A95C(this, play) != 0) && (this->actionFunc != func_80C0AE5C)) { - func_800B8E58(player, NA_SE_PL_BODY_HIT); + Player_PlaySfx(player, NA_SE_PL_BODY_HIT); func_80C0AE3C(this); } } diff --git a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c index 6016b2e44..36f8e94fc 100644 --- a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c +++ b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c @@ -80,16 +80,16 @@ void func_80C07220(BgIkninside* this, PlayState* play) { } void func_80C07230(BgIkninside* this, PlayState* play) { - if (this->dyna.actor.cutscene == -1) { + if (this->dyna.actor.csId == CS_ID_NONE) { this->actionFunc = func_80C07220; - } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); - } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + } else if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->dyna.actor.csId); + } else if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); this->actionFunc = func_80C07220; } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -121,7 +121,7 @@ void func_80C072D0(BgIkninside* this, PlayState* play) { Flags_SetSwitch(play, DMIKNINSIDE_GET_SWITCH(&this->dyna.actor)); this->actionFunc = func_80C07230; this->dyna.actor.draw = NULL; - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } else { this->timer = 20; } diff --git a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c index 9cbfaec61..2c24a5580 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c @@ -51,9 +51,9 @@ void BgIknvDoukutu_Init(Actor* thisx, PlayState* play) { switch (BGIKNVDOUKUTU_GET_F(&this->dyna.actor)) { case BGIKNVDOUKUTU_F_0: this->actionFunc = func_80BD71BC; - this->csAction = 0x204; + this->cueType = CS_CMD_ACTOR_CUE_516; this->unk_160 = 1.0f; - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_04) || CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_04) || CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE)) { this->dyna.actor.draw = func_80BD7768; this->actionFunc = func_80BD73D0; play->envCtx.lightSettingOverride = 25; @@ -65,7 +65,7 @@ void BgIknvDoukutu_Init(Actor* thisx, PlayState* play) { case BGIKNVDOUKUTU_F_1: Actor_SetScale(&this->dyna.actor, 1.0f); this->dyna.actor.draw = func_80BD7820; - this->csAction = 0x204; + this->cueType = CS_CMD_ACTOR_CUE_516; DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&object_iknv_obj_Colheader_012788, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); @@ -75,7 +75,7 @@ void BgIknvDoukutu_Init(Actor* thisx, PlayState* play) { break; case BGIKNVDOUKUTU_F_2: - this->csAction = 0x204; + this->cueType = CS_CMD_ACTOR_CUE_516; this->dyna.actor.draw = func_80BD78C4; DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&object_iknv_obj_Colheader_0117C8, &colHeader); @@ -116,8 +116,8 @@ void func_80BD716C(BgIknvDoukutu* this, PlayState* play) { void func_80BD71BC(BgIknvDoukutu* this, PlayState* play) { play->envCtx.lightSettingOverride = 24; - if (Cutscene_CheckActorAction(play, this->csAction) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action == 2)) { + if (Cutscene_IsCueInChannel(play, this->cueType) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id == 2)) { this->actionFunc = func_80BD716C; this->dyna.actor.draw = func_80BD7538; } @@ -135,8 +135,8 @@ void func_80BD7250(BgIknvDoukutu* this, PlayState* play) { } void func_80BD72BC(BgIknvDoukutu* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, this->csAction) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action == 3)) { + if (Cutscene_IsCueInChannel(play, this->cueType) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id == 3)) { this->actionFunc = func_80BD7250; } @@ -146,8 +146,8 @@ void func_80BD72BC(BgIknvDoukutu* this, PlayState* play) { } void func_80BD7360(BgIknvDoukutu* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, this->csAction) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action == 2)) { + if (Cutscene_IsCueInChannel(play, this->cueType) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id == 2)) { this->actionFunc = func_80BD72BC; } } diff --git a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.h b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.h index f36393869..beeeb0b81 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.h +++ b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.h @@ -18,7 +18,7 @@ enum { typedef struct BgIknvDoukutu { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ s16 unk_15C; // set and not used - /* 0x15E */ u16 csAction; + /* 0x15E */ u16 cueType; /* 0x160 */ f32 unk_160; /* 0x164 */ BgIknvDoukutuActionFunc actionFunc; } BgIknvDoukutu;// size = 0x168 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 ba65baca4..cca6b17ee 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 @@ -107,20 +107,20 @@ void BgIknvObj_Destroy(Actor* thisx, PlayState* play) { } s32 func_80BD7CEC(BgIknvObj* this) { - if (this->dyna.actor.cutscene == -1) { + if (this->dyna.actor.csId == CS_ID_NONE) { return true; } - if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { + if (CutsceneManager_GetCurrentCsId() == this->dyna.actor.csId) { return true; } - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); return true; } - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); return false; } @@ -131,8 +131,8 @@ void BgIknvObj_UpdateWaterwheel(BgIknvObj* this, PlayState* play) { func_800B9010(&this->dyna.actor, NA_SE_EV_WOOD_WATER_WHEEL - SFX_FLAG); } - if ((play->csCtx.state != 0) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 4) && - (play->csCtx.frames == 1495)) { + if ((play->csCtx.state != CS_STATE_IDLE) && (gSaveContext.sceneLayer == 1) && (play->csCtx.scriptIndex == 4) && + (play->csCtx.curFrame == 1495)) { func_8019F128(NA_SE_EV_DOOR_UNLOCK); } } @@ -149,7 +149,7 @@ s32 func_80BD7E0C(BgIknvObj* this, s16 targetRotation, PlayState* play) { func_800B9010(&this->dyna.actor, NA_SE_EV_STONEDOOR_OPEN_S - SFX_FLAG); return false; } - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); return true; } @@ -166,7 +166,7 @@ void func_80BD7F4C(BgIknvObj* this, PlayState* play) { this->actionFunc = func_80BD7ED8; } if ((this->dyna.actor.home.rot.x == 1) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_58_80)) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); this->dyna.actor.home.rot.x = 0; } CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index 4ed78d458..502b29086 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -126,7 +126,7 @@ s32 func_80953DA8(BgIngate* this, PlayState* play) { Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); if (CHECK_EVENTINF(EVENTINF_35)) { - func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_7); + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_WAIT); } else { SET_EVENTINF(EVENTINF_41); } @@ -169,7 +169,7 @@ void func_80953F14(BgIngate* this, PlayState* play) { if (this->timePath != NULL) { func_80953B40(this); } - this->unk16E = -1; + this->csId = CS_ID_NONE; this->actionFunc = func_80953F9C; } @@ -192,7 +192,7 @@ void func_80953F9C(BgIngate* this, PlayState* play) { if (this->timePath->unk1 != 0xFF) { func_80953E38(play); - func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_7); + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_WAIT); this->dyna.actor.textId = 0x9E4; Message_StartTextbox(play, this->dyna.actor.textId, NULL); this->unk16C += 1; @@ -206,13 +206,13 @@ void func_80953F9C(BgIngate* this, PlayState* play) { } this->actionFunc = func_809542A0; } - } else if ((ActorCutscene_GetCurrentIndex() == -1) && (this->timePath != NULL)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CRUISER - SFX_FLAG); + } else if ((CutsceneManager_GetCurrentCsId() == CS_ID_NONE) && (this->timePath != NULL)) { + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_CRUISER - SFX_FLAG); func_80953BEC(this); } } - if (ActorCutscene_GetCurrentIndex() != this->unk16E) { - if (ActorCutscene_GetCurrentIndex() != -1) { + if (CutsceneManager_GetCurrentCsId() != this->csId) { + if (CutsceneManager_GetCurrentCsId() != CS_ID_NONE) { Camera_ChangeSetting(mainCam, CAM_SET_NORMAL0); player->stateFlags1 |= PLAYER_STATE1_20; play->actorCtx.flags &= ~ACTORCTX_FLAG_PICTO_BOX_ON; @@ -221,23 +221,23 @@ void func_80953F9C(BgIngate* this, PlayState* play) { player->stateFlags1 &= ~PLAYER_STATE1_20; } } - this->unk16E = ActorCutscene_GetCurrentIndex(); + this->csId = CutsceneManager_GetCurrentCsId(); } void func_809541B8(BgIngate* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->unk160 & 0x4) { - if ((player->transformation == PLAYER_FORM_HUMAN) && (player->actor.bgCheckFlags & 1) && + if ((player->transformation == PLAYER_FORM_HUMAN) && (player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->dyna.actor.xzDistToPlayer < 40.0f)) { if (this->dyna.actor.playerHeightRel > 15.0f) { - func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_7); + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_WAIT); this->dyna.actor.textId = 0x9E6; Message_StartTextbox(play, this->dyna.actor.textId, NULL); this->actionFunc = func_809543D4; } } - } else if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + } else if (!DynaPolyActor_IsPlayerOnTop(&this->dyna)) { this->unk160 |= 4; } } @@ -251,8 +251,8 @@ void func_809542A0(BgIngate* this, PlayState* play) { } gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; this->actionFunc = func_80953F8C; CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_40); Environment_StartTime(); @@ -261,7 +261,7 @@ void func_809542A0(BgIngate* this, PlayState* play) { void func_80954340(BgIngate* this, PlayState* play) { if (!DECR(this->unk16A)) { if (this->timePath != NULL) { - func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_6); + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_END); this->timePath = &play->setupPathList[this->timePath->unk1]; func_80953F14(this, play); Environment_StopTime(); @@ -276,11 +276,11 @@ void func_809543D4(BgIngate* this, PlayState* play) { switch (this->dyna.actor.textId) { case 0x9E4: this->dyna.actor.textId = 0x9E5; - func_80151938(play, this->dyna.actor.textId); + Message_ContinueTextbox(play, this->dyna.actor.textId); break; case 0x9E5: if (play->msgCtx.choiceIndex == 0) { - func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_6); + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_END); this->unk160 &= ~0x4; this->actionFunc = func_809541B8; Environment_StartTime(); @@ -293,7 +293,7 @@ void func_809543D4(BgIngate* this, PlayState* play) { CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_40); func_8019F230(); } - func_801477B4(play); + Message_CloseTextbox(play); break; case 0x9E6: if (play->msgCtx.choiceIndex == 0) { @@ -301,13 +301,13 @@ void func_809543D4(BgIngate* this, PlayState* play) { CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_40); func_8019F208(); } else { - func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_6); + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_END); this->unk160 &= ~0x4; this->actionFunc = func_809541B8; Environment_StartTime(); func_8019F230(); } - func_801477B4(play); + Message_CloseTextbox(play); break; } } @@ -322,7 +322,7 @@ void BgIngate_Init(Actor* thisx, PlayState* play2) { Vec3f sp20; if (BgIngate_FindActor(this, play, ACTORCAT_BG, ACTOR_BG_INGATE) == NULL) { - DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); DynaPolyActor_LoadMesh(play, &this->dyna, &gSichitaiBoatCol); this->unk160 = 0; this->unk160 |= 0x8; @@ -330,7 +330,7 @@ void BgIngate_Init(Actor* thisx, PlayState* play2) { Actor_SetScale(&this->dyna.actor, 1.0f); this->timePath = SubS_GetAdditionalPath(play, BGINGATE_GET_FF(&this->dyna.actor), 0); this->dyna.actor.room = -1; - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE)) { CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_40); } if (!CHECK_EVENTINF(EVENTINF_35) && CHECK_WEEKEVENTREG(WEEKEVENTREG_90_40)) { diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h index cc0befd19..6046fc31e 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h @@ -17,7 +17,7 @@ typedef struct BgIngate { /* 0x168 */ s16 timePathTimeSpeed; /* 0x16A */ s16 unk16A; /* 0x16C */ s16 unk16C; - /* 0x16E */ s16 unk16E; + /* 0x16E */ s16 csId; /* 0x170 */ Vec3f timePathTargetPos; /* 0x17C */ f32 timePathProgress; /* 0x180 */ s32 timePathTotalTime; 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 1b1deb6c2..2eac2ed07 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 @@ -39,7 +39,7 @@ void BgInibsMovebg_Init(Actor* thisx, PlayState* play) { BgInibsMovebg* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); this->opaDList = sOpaDLists[BG_INIBS_MOVEBG_GET_MODE(thisx)]; this->xluDList = sXluDLists[BG_INIBS_MOVEBG_GET_MODE(thisx)]; diff --git a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c index 12bfc0f3c..282a43925 100644 --- a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c +++ b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c @@ -61,10 +61,10 @@ void func_80A5389C(BgKeikokuSaku* this, PlayState* play) { } void func_80A538E0(BgKeikokuSaku* this, PlayState* play) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); this->dyna.actor.world.pos.z -= 2.0f + BREG(8); if (this->dyna.actor.world.pos.z < (BREG(9) + 2660.0f)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); this->timer = 30; this->actionFunc = func_80A53994; } diff --git a/src/overlays/actors/ovl_Bg_Keikoku_Spr/z_bg_keikoku_spr.c b/src/overlays/actors/ovl_Bg_Keikoku_Spr/z_bg_keikoku_spr.c index 8afd5d730..8246a0298 100644 --- a/src/overlays/actors/ovl_Bg_Keikoku_Spr/z_bg_keikoku_spr.c +++ b/src/overlays/actors/ovl_Bg_Keikoku_Spr/z_bg_keikoku_spr.c @@ -1,9 +1,3 @@ -/* - * File: z_bg_keikoku_spr.c - * Overlay: ovl_Bg_Keikoku_Spr - * Description: Termina Field Fountain Water - */ - #include "z_bg_keikoku_spr.h" #include "objects/object_keikoku_obj/object_keikoku_obj.h" @@ -16,7 +10,8 @@ void BgKeikokuSpr_Destroy(Actor* thisx, PlayState* play); void BgKeikokuSpr_Update(Actor* thisx, PlayState* play); void BgKeikokuSpr_Draw(Actor* thisx, PlayState* play); -ActorInit Bg_Keikoku_Spr_InitVars = { +/* +const ActorInit Bg_Keikoku_Spr_InitVars = { ACTOR_BG_KEIKOKU_SPR, ACTORCAT_PROP, FLAGS, @@ -25,38 +20,14 @@ ActorInit Bg_Keikoku_Spr_InitVars = { (ActorFunc)BgKeikokuSpr_Init, (ActorFunc)BgKeikokuSpr_Destroy, (ActorFunc)BgKeikokuSpr_Update, - (ActorFunc)BgKeikokuSpr_Draw, + (ActorFunc)BgKeikokuSpr_Draw }; +*/ -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 20, ICHAIN_STOP), -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Spr/BgKeikokuSpr_Init.s") -void BgKeikokuSpr_Init(Actor* thisx, PlayState* play) { - Actor_ProcessInitChain(thisx, sInitChain); -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Spr/BgKeikokuSpr_Destroy.s") -void BgKeikokuSpr_Destroy(Actor* thisx, PlayState* play) { -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Spr/BgKeikokuSpr_Update.s") -void BgKeikokuSpr_Update(Actor* thisx, PlayState* play) { -} - -void BgKeikokuSpr_Draw(Actor* thisx, PlayState* play) { - s32 pad; - - OPEN_DISPS(play->state.gfxCtx); - - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_keikoku_obj_Matanimheader_0001F8)); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_keikoku_obj_DL_000100); - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_keikoku_obj_Matanimheader_0003F8)); - gSPDisplayList(POLY_XLU_DISP++, object_keikoku_obj_DL_000300); - AnimatedMat_Draw(play, Lib_SegmentedToVirtual(object_keikoku_obj_Matanimheader_0005F8)); - gSPDisplayList(POLY_XLU_DISP++, object_keikoku_obj_DL_000500); - - CLOSE_DISPS(play->state.gfxCtx); -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Spr/BgKeikokuSpr_Draw.s") diff --git a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c b/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c index 2da4ddcee..a868b355c 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c @@ -171,7 +171,7 @@ void BgKin2Bombwall_SetupWait(BgKin2Bombwall* this) { void BgKin2Bombwall_Wait(BgKin2Bombwall* this, PlayState* play) { if (BgKin2Bombwall_IsHitFromNearby(this, play)) { this->collider.base.acFlags &= ~AC_HIT; - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); BgKin2Bombwall_SetupPlayCutscene(this); } else { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); @@ -183,17 +183,17 @@ void BgKin2Bombwall_SetupPlayCutscene(BgKin2Bombwall* this) { } void BgKin2Bombwall_PlayCutscene(BgKin2Bombwall* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); Flags_SetSwitch(play, BG_KIN2_BOMBWALL_SWITCH_FLAG(&this->dyna.actor)); SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 60, NA_SE_EV_WALL_BROKEN); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = NULL; BgKin2Bombwall_SpawnEffects(this, play); BgKin2Bombwall_SetupEndCutscene(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -205,7 +205,7 @@ void BgKin2Bombwall_SetupEndCutscene(BgKin2Bombwall* this) { void BgKin2Bombwall_EndCutscene(BgKin2Bombwall* this, PlayState* play) { this->timer--; if (this->timer <= 0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); Actor_Kill(&this->dyna.actor); } } 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 dfb22deee..66ac02634 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 @@ -187,7 +187,7 @@ void BgKin2Fence_HandleMaskCode(BgKin2Fence* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { hitMask = BgKin2Fence_CheckHitMask(this); if (hitMask >= 0) { - nextMask = (s8)gSaveContext.save.spiderHouseMaskOrder[this->masksHit]; + nextMask = (s8)gSaveContext.save.saveInfo.spiderHouseMaskOrder[this->masksHit]; if (hitMask == nextMask) { play_sound(NA_SE_SY_TRE_BOX_APPEAR); this->masksHit += 1; @@ -217,13 +217,13 @@ void BgKin2Fence_SetupPlayOpenCutscene(BgKin2Fence* this) { } void BgKin2Fence_PlayOpenCutscene(BgKin2Fence* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); Flags_SetSwitch(play, this->dyna.actor.params & 0x7F); BgKin2Fence_SetupWaitBeforeOpen(this); return; } - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } void BgKin2Fence_SetupWaitBeforeOpen(BgKin2Fence* this) { 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 5892376ba..7da9237bc 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 @@ -162,7 +162,7 @@ void BgKin2Picture_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); DynaPolyActor_LoadMesh(play, &this->dyna, &gOceanSpiderHouseSkullkidPaintingCol); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); Collider_InitTris(play, &this->colliderTris); Collider_SetTris(play, &this->colliderTris, &this->dyna.actor, &sTrisInit, this->colliderElement); Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, @@ -202,12 +202,12 @@ void BgKin2Picture_Wait(BgKin2Picture* this, PlayState* play) { // hit by projectile if (this->colliderTris.base.acFlags & AC_HIT) { this->colliderTris.base.acFlags &= ~AC_HIT; - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); BgKin2Picture_SetupPlayCutscene(this); } else { // Gold Skulltula can be heard behind Skullkid's painting. if (this->skulltulaNoiseTimer >= 0) { if (this->skulltulaNoiseTimer == 0) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EN_STALGOLD_ROLL); if (Rand_ZeroOne() < 0.1f) { this->skulltulaNoiseTimer = Rand_S16Offset(40, 80); @@ -227,12 +227,12 @@ void BgKin2Picture_SetupPlayCutscene(BgKin2Picture* this) { } void BgKin2Picture_PlayCutscene(BgKin2Picture* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); this->cutsceneStarted = true; BgKin2Picture_SetupShiver(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -281,9 +281,9 @@ void BgKin2Picture_Fall(BgKin2Picture* this, PlayState* play) { } Actor_MoveWithGravity(&this->dyna.actor); - Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); - if (this->dyna.actor.bgCheckFlags & 1) { + if (this->dyna.actor.bgCheckFlags & BGCHECKFLAG_GROUND) { Math_StepToS(&this->step, 0x7D0, 0x78); if (this->landTimer < 3) { @@ -297,7 +297,7 @@ void BgKin2Picture_Fall(BgKin2Picture* this, PlayState* play) { } if (this->landTimer < 3) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SMALL_WOODPLATE_BOUND_0); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SMALL_WOODPLATE_BOUND_0); } } } @@ -314,11 +314,11 @@ void BgKin2Picture_Fall(BgKin2Picture* this, PlayState* play) { this->dyna.actor.shape.yOffset = 40.0f; if (this->cutsceneStarted) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); } - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODPLATE_BROKEN); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_WOODPLATE_BROKEN); BgKin2Picture_SetupDoNothing(this); } else { this->dyna.actor.shape.yOffset = Math_SinS(this->dyna.actor.shape.rot.x) * 40.0f; diff --git a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c index 6c30347ef..f36944db6 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c @@ -207,7 +207,7 @@ void BgKin2Shelf_Init(Actor* thisx, PlayState* play) { this->dyna.actor.flags |= ACTOR_FLAG_10000000; } - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, D_80B70780[sp24]); func_80B700A8(this); } 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 f766fef78..208babf77 100644 --- a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c +++ b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c @@ -75,7 +75,7 @@ void BgLadder_Init(Actor* thisx, PlayState* play) { } else { // Otherwise, the ladder doesn't draw; wait for the flag to be set this->alpha = 5; - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = NULL; this->action = BgLadder_Wait; } @@ -90,20 +90,20 @@ void BgLadder_Destroy(Actor* thisx, PlayState* play) { void BgLadder_Wait(BgLadder* this, PlayState* play) { // Wait for the flag to be set, then trigger the cutscene if (Flags_GetSwitch(play, this->switchFlag)) { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); this->action = BgLadder_StartCutscene; } } void BgLadder_StartCutscene(BgLadder* this, PlayState* play) { // Trigger the cutscene, then make the ladder fade in - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); this->dyna.actor.draw = BgLadder_Draw; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SECRET_LADDER_APPEAR); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SECRET_LADDER_APPEAR); this->action = BgLadder_FadeIn; } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -112,8 +112,8 @@ void BgLadder_FadeIn(BgLadder* this, PlayState* play) { this->alpha += 5; if (this->alpha >= 255) { this->alpha = 255; - ActorCutscene_Stop(this->dyna.actor.cutscene); - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + CutsceneManager_Stop(this->dyna.actor.csId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.flags &= ~ACTOR_FLAG_10; // always update = off this->action = BgLadder_DoNothing; } diff --git a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c index d704adf86..6085a93a2 100644 --- a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c +++ b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c @@ -149,7 +149,7 @@ void BgLastBwall_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, D_80C18AC8); this->type = BGLASTBWALL_GET_TYPE(&this->dyna.actor); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, D_80C18A48[this->type].colHeader); Collider_InitTris(play, &this->colliderTris); if (Flags_GetSwitch(play, BGLASTBWALL_GET_SWITCHFLAGS(&this->dyna.actor))) { @@ -164,7 +164,7 @@ void BgLastBwall_Init(Actor* thisx, PlayState* play) { BgLastBwall_InitCollider(&sTrisInit, &this->dyna.actor.world.pos, &this->dyna.actor.shape.rot, &this->colliderTris, D_80C18AC0[this->type]); - SubS_FillCutscenesList(&this->dyna.actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_FillCutscenesList(&this->dyna.actor, this->csIdList, ARRAY_COUNT(this->csIdList)); func_80C187E4(this); } @@ -239,16 +239,16 @@ void func_80C1886C(BgLastBwall* this, PlayState* play) { } void func_80C18884(BgLastBwall* this, PlayState* play) { - if (SubS_StartActorCutscene(&this->dyna.actor, this->cutscenes[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + if (SubS_StartCutscene(&this->dyna.actor, this->csIdList[0], CS_ID_NONE, SUBS_CUTSCENE_WITH_PLAYER)) { func_80C188C4(this, play); } } void func_80C188C4(BgLastBwall* this, PlayState* play) { - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = NULL; func_80C184EC(this, play); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); this->actionFunc = BgLastBwall_DoNothing; } diff --git a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.h b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.h index 3fafc71ea..e6d752c28 100644 --- a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.h +++ b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.h @@ -22,7 +22,7 @@ typedef struct BgLastBwall { /* 0x160 */ ColliderTris colliderTris; /* 0x180 */ ColliderTrisElement colliderTrisElement[2]; /* 0x238 */ u8 type; - /* 0x23A */ s16 cutscenes[1]; + /* 0x23A */ s16 csIdList[1]; } BgLastBwall; // size = 0x23C #endif // Z_BG_LAST_BWALL_H 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 75e7b9e32..24c7ec1b3 100644 --- a/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c +++ b/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c @@ -36,7 +36,7 @@ void BgLbfshot_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); this->dyna.actor.uncullZoneForward = 4000.0f; - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_lbfshot_Colheader_0014D8); } void BgLbfshot_Destroy(Actor* thisx, PlayState* play) { 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 20be54a2f..765b58dbd 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -1,9 +1,3 @@ -/* - * File: z_bg_lotus.c - * Overlay: ovl_Bg_Lotus - * Description: Southern Swamp Lilypads - */ - #include "z_bg_lotus.h" #include "objects/object_lotus/object_lotus.h" @@ -16,11 +10,8 @@ void BgLotus_Destroy(Actor* thisx, PlayState* play); void BgLotus_Update(Actor* thisx, PlayState* play); void BgLotus_Draw(Actor* thisx, PlayState* play); -void BgLotus_Wait(BgLotus* this, PlayState* play); -void BgLotus_Sink(BgLotus* this, PlayState* play); -void BgLotus_WaitToAppear(BgLotus* this, PlayState* play); - -ActorInit Bg_Lotus_InitVars = { +/* +const ActorInit Bg_Lotus_InitVars = { ACTOR_BG_LOTUS, ACTORCAT_BG, FLAGS, @@ -29,147 +20,22 @@ ActorInit Bg_Lotus_InitVars = { (ActorFunc)BgLotus_Init, (ActorFunc)BgLotus_Destroy, (ActorFunc)BgLotus_Update, - (ActorFunc)BgLotus_Draw, + (ActorFunc)BgLotus_Draw }; +*/ -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Lotus/BgLotus_Init.s") -void BgLotus_Init(Actor* thisx, PlayState* play) { - BgLotus* this = THIS; - s32 pad; - s32 bgId; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Lotus/BgLotus_Destroy.s") - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(play, &this->dyna, &gLilyPadCol); - this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &thisx->floorPoly, &bgId, - &this->dyna.actor, &this->dyna.actor.world.pos); - this->timer2 = 96; - this->dyna.actor.world.rot.y = (s32)Rand_Next() >> 0x10; - this->actionFunc = BgLotus_Wait; -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Lotus/func_80AD6830.s") -void BgLotus_Destroy(Actor* thisx, PlayState* play) { - BgLotus* this = THIS; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Lotus/func_80AD68DC.s") - DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Lotus/func_80AD6A88.s") -void BgLotus_SetScaleXZ(BgLotus* this) { - f32 scale; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Lotus/func_80AD6B68.s") - if (this->dyna.actor.params == 0) { - scale = sin_rad(this->timer * 0.7853982f) * ((0.014f * ((f32)this->timer / 8)) + 0.01f); - this->dyna.actor.scale.x = (1.0f + scale) * 0.1f; - this->dyna.actor.scale.z = (1.0f - scale) * 0.1f; - } -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Lotus/BgLotus_Update.s") -void BgLotus_Wait(BgLotus* this, PlayState* play) { - f32 moveDist; // distance for the xz position of the lilypad to move - - this->timer2--; - - moveDist = sin_rad(this->timer2 * 0.06544985f) * 6.0f; - - if (this->dyna.actor.params == 0) { - this->dyna.actor.world.pos.x = - (Math_SinS(this->dyna.actor.world.rot.y) * moveDist) + this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = - (Math_CosS(this->dyna.actor.world.rot.y) * moveDist) + this->dyna.actor.home.pos.z; - - if (this->timer2 == 0) { - this->timer2 = 96; - this->dyna.actor.world.rot.y += (s16)((s32)Rand_Next() >> 0x12); - } - } - - if (this->height < this->dyna.actor.floorHeight) { - this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; - } else { - this->dyna.actor.world.pos.y = this->height; - - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { - if (this->hasSpawnedRipples == 0) { - EffectSsGRipple_Spawn(play, &this->dyna.actor.world.pos, 1000, 1400, 0); - EffectSsGRipple_Spawn(play, &this->dyna.actor.world.pos, 1000, 1400, 8); - this->timer = 40; - } - if (gSaveContext.save.playerForm != PLAYER_FORM_DEKU) { - this->timer = 40; - this->dyna.actor.flags |= ACTOR_FLAG_10; - this->actionFunc = BgLotus_Sink; - return; - } - - this->hasSpawnedRipples = 1; - } else { - this->hasSpawnedRipples = 0; - } - } - - if (this->timer > 0) { - this->timer--; - } - - BgLotus_SetScaleXZ(this); -} - -void BgLotus_Sink(BgLotus* this, PlayState* play) { - if (this->height < this->dyna.actor.world.pos.y) { - this->dyna.actor.world.pos.y = this->height; - } - - this->dyna.actor.world.pos.y -= 1.0f; - - if (this->dyna.actor.world.pos.y <= this->dyna.actor.floorHeight) { - this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; - this->timer = 0; - } - - if (this->timer > 0) { - this->timer--; - BgLotus_SetScaleXZ(this); - } else { - if (Math_StepToF(&this->dyna.actor.scale.x, 0, 0.0050000003539f)) { - this->dyna.actor.draw = NULL; - this->timer = 100; - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); - this->actionFunc = BgLotus_WaitToAppear; - } - - this->dyna.actor.scale.z = this->dyna.actor.scale.x; - } -} - -void BgLotus_WaitToAppear(BgLotus* this, PlayState* play) { - if (this->timer > 0) { - this->timer--; - } else if ((this->dyna.actor.xzDistToPlayer > 100.0f) && (this->dyna.actor.projectedPos.z < 0.0f)) { - this->dyna.actor.draw = BgLotus_Draw; - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); - Actor_SetScale(&this->dyna.actor, 0.1f); - this->dyna.actor.world.pos.y = CLAMP_MIN(this->height, this->dyna.actor.floorHeight); - this->dyna.actor.flags &= ~ACTOR_FLAG_10; - this->timer2 = 96; - this->actionFunc = BgLotus_Wait; - this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; - this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z; - } -} - -void BgLotus_Update(Actor* thisx, PlayState* play) { - BgLotus* this = THIS; - s32 pad; - WaterBox* waterBox; - - WaterBox_GetSurface1_2(play, &play->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, - &this->height, &waterBox); - this->actionFunc(this, play); -} - -void BgLotus_Draw(Actor* thisx, PlayState* play) { - Gfx_DrawDListOpa(play, gLilyPadDL); -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Lotus/BgLotus_Draw.s") diff --git a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.h b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.h index 540c21b0e..61d340a49 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.h +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.h @@ -5,15 +5,9 @@ struct BgLotus; -typedef void (*BgLotusActionFunc)(struct BgLotus*, PlayState*); - typedef struct BgLotus { - /* 0x000 */ DynaPolyActor dyna; - /* 0x15C */ BgLotusActionFunc actionFunc; - /* 0x160 */ f32 height; - /* 0x164 */ u8 hasSpawnedRipples; - /* 0x166 */ s16 timer; - /* 0x168 */ s16 timer2; + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x28]; } BgLotus; // size = 0x16C #endif // Z_BG_LOTUS_H diff --git a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c index 497ed10ab..3a11a2fdf 100644 --- a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c +++ b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c @@ -63,7 +63,7 @@ static ColliderCylinderInit sCylinderInit = { }; static FireObjInitParams sFireObjInit = { - 0.00405000010505f, 0.0500000007451f, 3, 1, 0, 0, 0, + 0.00405f, 1.0f / 20.0f, FIRE_STATE_NOT_LIT, 1, 0, 0, 0, }; static s16 sInitialAnglePerPetal[] = { 0x0000, 0x2AAA, 0x5555, 0x8000, 0xAAAA, 0xD555 }; @@ -144,7 +144,7 @@ void BgNumaHana_Init(Actor* thisx, PlayState* play) { type = BG_NUMA_HANA_GET_TYPE(&this->dyna.actor); Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); if (type == BG_NUMA_HANA_TYPE_OPEN_FLOWER_COLLISION) { DynaPolyActor_LoadMesh(play, &this->dyna, &gWoodenFlowerOpenedFlowerCol); @@ -162,7 +162,7 @@ void BgNumaHana_Init(Actor* thisx, PlayState* play) { } if (CHECK_WEEKEVENTREG(WEEKEVENTREG_12_01)) { - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->petalZRotation = 0x2000; this->innerPetalZRotation = 0x2000; @@ -175,12 +175,12 @@ void BgNumaHana_Init(Actor* thisx, PlayState* play) { this->flowerRotationalVelocity = 0x147; this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 210.0f; - FireObj_SetState2(&this->fire, 0.05f, 2); + FireObj_SetState2(&this->fire, 0.05f, FIRE_STATE_FULLY_LIT); Flags_SetSwitch(play, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); BgNumaHana_SetupOpenedIdle(this); } else { child = (DynaPolyActor*)this->dyna.actor.child; - func_800C62BC(play, &play->colCtx.dyna, child->bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, child->bgId); Flags_UnsetSwitch(play, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); BgNumaHana_SetupClosedIdle(this); } @@ -215,15 +215,15 @@ void BgNumaHana_SetupClosedIdle(BgNumaHana* this) { * the cutscene where the petals unfold. */ void BgNumaHana_ClosedIdle(BgNumaHana* this, PlayState* play) { - if (this->fire.state != 3) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLAME_IGNITION); - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (this->fire.state != FIRE_STATE_NOT_LIT) { + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_FLAME_IGNITION); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); SET_WEEKEVENTREG(WEEKEVENTREG_12_01); Flags_SetSwitch(play, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); BgNumaHana_SetupUnfoldInnerPetals(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } } @@ -247,7 +247,7 @@ void BgNumaHana_UnfoldInnerPetals(BgNumaHana* this, PlayState* play) { this->settleZRotation = 0; this->settleAngle = 0; this->settleScale = 420.0f; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_STOP); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_STOP); } this->transitionTimer++; } @@ -279,7 +279,7 @@ void BgNumaHana_UnfoldOuterPetals(BgNumaHana* this, PlayState* play) { this->settleZRotation = 0; this->settleAngle = 0x5120; this->settleScale = 130.0f; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_STOP); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_STOP); } this->transitionTimer++; } @@ -314,8 +314,8 @@ void BgNumaHana_RaiseFlower(BgNumaHana* this, PlayState* play) { child = (DynaPolyActor*)this->dyna.actor.child; // Swaps out the "closed" flower collision for the "opened" collision. - func_800C6314(play, &play->colCtx.dyna, child->bgId); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, child->bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->petalZRotation = 0x2000; this->innerPetalZRotation = 0x2000; @@ -327,7 +327,7 @@ void BgNumaHana_RaiseFlower(BgNumaHana* this, PlayState* play) { this->flowerRotationalVelocity = 0x147; this->settleScale = 0.0f; - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); BgNumaHana_SetupOpenedIdle(this); } diff --git a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.h b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.h index fd71577cd..0e377f539 100644 --- a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.h +++ b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.h @@ -2,6 +2,7 @@ #define Z_BG_NUMA_HANA_H #include "global.h" +#include "z_fireobj.h" #define BG_NUMA_HANA_GET_TYPE(thisx) ((thisx)->params & 1) #define BG_NUMA_HANA_SWITCH_FLAG(thisx) (((thisx)->params >> 8) & 0x7F) diff --git a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c index c038ed575..a7ea2e6ea 100644 --- a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c +++ b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c @@ -92,7 +92,7 @@ void BgOpenShutter_Init(Actor* thisx, PlayState* play) { BgOpenShutter* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_open_obj_Colheader_001640); this->actionFunc = func_80ACAD88; } @@ -111,7 +111,7 @@ void func_80ACAD88(BgOpenShutter* this, PlayState* play) { if (this->unk_15C != 0) { Player* player = GET_PLAYER(play); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); Camera_ChangeDoorCam(play->cameraPtrs[CAM_ID_MAIN], &this->dyna.actor, player->unk_3BA, 0.0f, 12, 15, 10); this->unk_164 = 0; this->actionFunc = func_80ACAE5C; @@ -136,7 +136,7 @@ void func_80ACAE5C(BgOpenShutter* this, PlayState* play) { this->unk_164++; } if (this->unk_164 >= 10) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); this->actionFunc = func_80ACAEF0; } } @@ -149,12 +149,12 @@ void func_80ACAEF0(BgOpenShutter* this, PlayState* play) { if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, this->dyna.actor.velocity.y)) { this->dyna.actor.floorHeight = this->dyna.actor.home.pos.y; Actor_SpawnFloorDustRing(play, &this->dyna.actor, &this->dyna.actor.world.pos, 60.0f, 10, 8.0f, 500, 10, true); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND); - quakeIndex = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); + quakeIndex = Quake_Request(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, -32536); - Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 10); + Quake_SetPerturbations(quakeIndex, 2, 0, 0, 0); + Quake_SetDuration(quakeIndex, 10); Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 180, 20, 100); @@ -166,20 +166,20 @@ void func_80ACAEF0(BgOpenShutter* this, PlayState* play) { void BgOpenShutter_Update(Actor* thisx, PlayState* play2) { BgOpenShutter* this = THIS; PlayState* play = play2; - s32 index; + s32 cueChannel; - if (Cutscene_CheckActorAction(play, 0x7C)) { - index = Cutscene_GetActorActionIndex(play, 0x7C); - if (play->csCtx.actorActions[index]->action == BGOPENSHUTTER_DOOR_OPEN) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_124)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_124); + if (play->csCtx.actorCues[cueChannel]->id == BGOPENSHUTTER_DOOR_OPEN) { if (this->actionFunc == func_80ACAD88) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); this->actionFunc = func_80ACAE5C; this->dyna.actor.velocity.y = 0.0f; } this->unk_164 = 0; - } else if (play->csCtx.actorActions[index]->action == BGOPENSHUTTER_DOOR_CLOSED) { + } else if (play->csCtx.actorCues[cueChannel]->id == BGOPENSHUTTER_DOOR_CLOSED) { if (this->actionFunc == func_80ACAE5C) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); this->actionFunc = func_80ACAEF0; } } diff --git a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c index dbe935b3f..275b1b565 100644 --- a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c +++ b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c @@ -47,13 +47,13 @@ void BgOpenSpot_Destroy(Actor* thisx, PlayState* play) { void BgOpenSpot_Update(Actor* thisx, PlayState* play) { BgOpenSpot* this = THIS; - u32 action; + u32 cueId; - if (Cutscene_CheckActorAction(play, 0x7D)) { - action = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x7D)]->action; - if (action == 1) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_125)) { + cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_125)]->id; + if (cueId == 1) { this->actor.draw = NULL; - } else if (action == 2) { + } else if (cueId == 2) { this->actor.draw = BgOpenSpot_Draw; } } diff --git a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c index 2ec37cb7e..1b9e93009 100644 --- a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c +++ b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c @@ -45,7 +45,7 @@ void BgSinkaiKabe_Init(Actor* thisx, PlayState* play) { Vec3f pos; s32 pad2; s32 shouldSpawnSeahorse; - s32 cs; + s32 csId; s32 i; DynaPolyActor_Init(&this->dyna, 0); @@ -54,11 +54,11 @@ void BgSinkaiKabe_Init(Actor* thisx, PlayState* play) { Math_Vec3f_Copy(&pos, &this->dyna.actor.world.pos); pos.x += Math_SinS(this->dyna.actor.world.rot.y + 0x8000) * 3000.0f; pos.z += Math_CosS(this->dyna.actor.world.rot.y + 0x8000) * 3000.0f; - cs = this->dyna.actor.cutscene; + csId = this->dyna.actor.csId; i = 0; // clang-format off - while (cs != -1) { this->cutscenes[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; } + while (csId != CS_ID_NONE) { this->csIdList[i] = csId; csId = CutsceneManager_GetAdditionalCsId(csId); i++; } // clang-format on this->dyna.actor.scale.x = 0.1f; @@ -74,9 +74,9 @@ void BgSinkaiKabe_Init(Actor* thisx, PlayState* play) { if (this->deepPython != NULL) { EnDragon* dragon = (EnDragon*)this->deepPython; - dragon->grabCutsceneIndex = this->cutscenes[0]; - dragon->deathCutsceneIndex = this->cutscenes[1]; - dragon->actor.cutscene = this->dyna.actor.cutscene; + dragon->grabCsId = this->csIdList[0]; + dragon->deathCsId = this->csIdList[1]; + dragon->actor.csId = this->dyna.actor.csId; Math_Vec3f_Copy(&dragon->burrowEntrancePos, &this->dyna.actor.world.pos); dragon->pythonIndex = this->pythonIndex; } @@ -99,8 +99,8 @@ void BgSinkaiKabe_Init(Actor* thisx, PlayState* play) { pos.z += (Math_CosS(this->dyna.actor.world.rot.y + 0x8000) * 500.0f); if (shouldSpawnSeahorse) { Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_OT, pos.x, pos.y, pos.z, 0, - this->dyna.actor.shape.rot.y, 0, 0x4000, this->dyna.actor.cutscene, - this->dyna.actor.unk20, NULL); + this->dyna.actor.shape.rot.y, 0, 0x4000, this->dyna.actor.csId, + this->dyna.actor.halfDaysBits, NULL); } Actor_Kill(&this->dyna.actor); diff --git a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h index abb341797..96c771c62 100644 --- a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h +++ b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h @@ -12,7 +12,7 @@ typedef struct BgSinkaiKabe { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ BgSinkaiKabeActionFunc actionFunc; /* 0x160 */ Actor* deepPython; - /* 0x164 */ s16 cutscenes[2]; + /* 0x164 */ s16 csIdList[2]; /* 0x168 */ UNK_TYPE1 unk_168[0x4]; /* 0x16C */ s32 pythonIndex; } BgSinkaiKabe; // size = 0x170 diff --git a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c index fb8d464c8..0ebae5c1e 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c @@ -150,7 +150,7 @@ void BgSpdweb_Init(Actor* thisx, PlayState* play) { this->unk_161 = 0; this->switchFlag = BGSPDWEB_GET_SWITCHFLAG(&this->dyna.actor); thisx->params &= 0xFF; - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); if (this->dyna.actor.params == BGSPDWEB_FF_0) { Collider_InitAndSetTris(play, &this->collider, &this->dyna.actor, &sTrisInit1, this->colliderElements); @@ -229,7 +229,7 @@ void func_809CE234(BgSpdweb* this, PlayState* play) { } if (this->unk_162 == 0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); Actor_Kill(&this->dyna.actor); return; } @@ -297,7 +297,7 @@ void func_809CE4C8(BgSpdweb* this, PlayState* play) { return; } - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { sp3A = 300; break; } @@ -305,7 +305,7 @@ void func_809CE4C8(BgSpdweb* this, PlayState* play) { } } - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { temp_f12 = 2.0f * sqrtf(CLAMP_MIN(sp3A, 0)); if ((this->unk_164 < temp_f12) && (temp_f12 > 2.0f)) { this->unk_164 = temp_f12; @@ -314,7 +314,7 @@ void func_809CE4C8(BgSpdweb* this, PlayState* play) { player->stateFlags1 |= PLAYER_STATE1_20; this->unk_161 = 1; } - } else if (player->actor.speedXZ != 0.0f) { + } else if (player->actor.speed != 0.0f) { this->unk_164 = CLAMP_MIN(this->unk_164, 2.0f); } } @@ -327,8 +327,7 @@ void func_809CE4C8(BgSpdweb* this, PlayState* play) { Math_ApproachZeroF(&this->unk_164, 1.0f, 0.8f); if (this->unk_162 == 4) { - if ((this->unk_161 != 0) || - ((DynaPolyActor_IsInRidingMovingState(&this->dyna) != 0) && (this->unk_164 > 2.0f))) { + if ((this->unk_161 != 0) || (DynaPolyActor_IsPlayerOnTop(&this->dyna) && (this->unk_164 > 2.0f))) { player->actor.velocity.y = this->unk_164 * 0.7f; player->fallStartHeight = (SQ(this->unk_164) * 0.15f) + this->dyna.actor.world.pos.y; this->unk_161 = 0; @@ -336,7 +335,7 @@ void func_809CE4C8(BgSpdweb* this, PlayState* play) { } } else if (this->unk_162 == 11) { if (this->unk_164 > 3.0f) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WEB_VIBRATION); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_WEB_VIBRATION); } else { AudioSfx_StopById(NA_SE_EV_WEB_VIBRATION); } @@ -370,8 +369,8 @@ void func_809CE830(BgSpdweb* this, PlayState* play) { } if (this->unk_162 == 0) { - if (ActorCutscene_GetLength(this->dyna.actor.cutscene) == -1) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + if (CutsceneManager_GetLength(this->dyna.actor.csId) == -1) { + CutsceneManager_Stop(this->dyna.actor.csId); } Actor_Kill(&this->dyna.actor); return; @@ -471,16 +470,16 @@ void func_809CEBC0(BgSpdweb* this, PlayState* play) { } void func_809CEE74(BgSpdweb* this) { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); this->actionFunc = func_809CEEAC; } void func_809CEEAC(BgSpdweb* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); func_809CE1D0(this, play); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } 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 d6617ef1c..17722bda2 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c @@ -16,7 +16,8 @@ void BgTobira01_Destroy(Actor* thisx, PlayState* play); void BgTobira01_Update(Actor* thisx, PlayState* play); void BgTobira01_Draw(Actor* thisx, PlayState* play); -ActorInit Bg_Tobira01_InitVars = { +/* +const ActorInit Bg_Tobira01_InitVars = { ACTOR_BG_TOBIRA01, ACTORCAT_PROP, FLAGS, @@ -27,85 +28,14 @@ ActorInit Bg_Tobira01_InitVars = { (ActorFunc)BgTobira01_Update, (ActorFunc)BgTobira01_Draw, }; +*/ -void BgTobira01_Open(BgTobira01* this, PlayState* play) { - Player* player = GET_PLAYER(play); - s16 cutsceneId = this->dyna.actor.cutscene; - s16 prevTimer; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Tobira01/func_80B12430.s") - if (this->playCutscene) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - } else if (ActorCutscene_GetCanPlayNext(cutsceneId)) { - ActorCutscene_StartAndSetUnkLinkFields(cutsceneId, &this->dyna.actor); - SET_WEEKEVENTREG(WEEKEVENTREG_88_40); - this->playCutscene = false; - } else { - ActorCutscene_SetIntentToPlay(cutsceneId); - } - } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_88_40) && (this->timer == 0) && (play->actorCtx.unk1F5 != 0) && - (play->actorCtx.unk1F4 == 0) && - (SurfaceType_GetSceneExitIndex(&play->colCtx, player->actor.floorPoly, player->actor.floorBgId) == 6)) { - this->playCutscene = true; - this->unk_16C = 0; // this variable is not used anywhere else - } +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Tobira01/BgTobira01_Init.s") - prevTimer = this->timer; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Tobira01/BgTobira01_Destroy.s") - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_88_40)) { - this->timer++; - } else { - this->timer--; - }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Tobira01/BgTobira01_Update.s") - this->timer = CLAMP(this->timer, 0, 60); - - if (this->timer != prevTimer) { - if (1) {} - 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; - } - - if (!(player->stateFlags1 & PLAYER_STATE1_40) && CHECK_WEEKEVENTREG(WEEKEVENTREG_88_40) && - (DECR(this->timer2) == 0)) { - CLEAR_WEEKEVENTREG(WEEKEVENTREG_88_40); - } -} - -void BgTobira01_Init(Actor* thisx, PlayState* play) { - BgTobira01* this = THIS; - s32 pad; - - DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(play, &this->dyna, &object_spot11_obj_Colheader_0011C0); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_88_40); - Actor_SetScale(&this->dyna.actor, 1.0f); - this->timer2 = gSaveContext.save.isNight; - this->timer = 0; - this->actionFunc = BgTobira01_Open; -} - -void BgTobira01_Destroy(Actor* thisx, PlayState* play) { - BgTobira01* this = THIS; - s32 pad; - - DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); -} - -void BgTobira01_Update(Actor* thisx, PlayState* play) { - BgTobira01* this = THIS; - s32 pad; - - this->actionFunc(this, play); -} - -void BgTobira01_Draw(Actor* thisx, PlayState* play) { - OPEN_DISPS(play->state.gfxCtx); - - func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_spot11_obj_DL_000088); - - CLOSE_DISPS(play->state.gfxCtx); -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Tobira01/BgTobira01_Draw.s") diff --git a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.h b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.h index 14a5e1b8e..9ddd0233d 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.h +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.h @@ -5,16 +5,9 @@ struct BgTobira01; -typedef void (*BgTobira01ActionFunc)(struct BgTobira01*, struct PlayState*); - typedef struct BgTobira01 { - /* 0x000 */ DynaPolyActor dyna; - /* 0x15C */ BgTobira01ActionFunc actionFunc; - /* 0x160 */ s16 timer; - /* 0x162 */ s16 timer2; - /* 0x164 */ f32 yOffset; - /* 0x168 */ s32 playCutscene; - /* 0x16C */ s32 unk_16C; // unused besides being set to 0 + /* 0x000 */ Actor actor; + /* 0x144 */ char unk_144[0x2C]; } BgTobira01; // size = 0x170 #endif // Z_BG_TOBIRA01_H diff --git a/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c b/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c index bef32aedd..d4d2c7274 100644 --- a/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c +++ b/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c @@ -47,24 +47,24 @@ void func_80919F30(BgUmajump* this, PlayState* play) { } void BgUmajump_StopCutscene(BgUmajump* this, PlayState* play) { - if ((play->csCtx.frames >= 6) && !this->hasSoundPlayed) { + if ((play->csCtx.curFrame >= 6) && !this->hasSoundPlayed) { this->hasSoundPlayed = true; play_sound(NA_SE_EV_KID_HORSE_NEIGH); } - if (play->csCtx.state == CS_STATE_0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + if (play->csCtx.state == CS_STATE_IDLE) { + CutsceneManager_Stop(this->dyna.actor.csId); this->dyna.actor.update = Actor_Noop; } } void BgUmajump_PlayCutscene(BgUmajump* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); SET_WEEKEVENTREG(WEEKEVENTREG_89_20); this->actionFunc = BgUmajump_StopCutscene; } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -95,7 +95,7 @@ void BgUmajump_Init(Actor* thisx, PlayState* play) { if ((thisx->params == BG_UMAJUMP_TYPE_2)) { if ((((play->sceneId == SCENE_F01) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_89_20)) && !CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) && - (thisx->cutscene != -1)) { + (thisx->csId != CS_ID_NONE)) { this->actionFunc = BgUmajump_CheckDistance; thisx->update = func_8091A5A0; thisx->flags |= ACTOR_FLAG_10; @@ -165,10 +165,10 @@ void BgUmajump_Update(Actor* thisx, PlayState* play) { (gSaveContext.save.time <= CLOCK_TIME(6, 0)))))) { DynaPolyActor_LoadMesh(play, &this->dyna, &object_umajump_Colheader_001558); } - func_800C641C(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableFloorCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.update = func_8091A5A0; } else if (this->dyna.actor.params == BG_UMAJUMP_TYPE_4) { - func_800C641C(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableFloorCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.update = Actor_Noop; } else { this->dyna.actor.update = Actor_Noop; 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 f28c3cd34..eae9fe0b3 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -4,7 +4,6 @@ * Description: Twinmold */ -#include "prevent_bss_reordering.h" #include "z_boss_02.h" #include "z64rumble.h" #include "z64shrink_window.h" @@ -551,7 +550,7 @@ void Boss02_Init(Actor* thisx, PlayState* play) { s32 i; s32 pad[2]; - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20) && (this->actor.params == TWINMOLD_RED)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE) && (this->actor.params == TWINMOLD_RED)) { sBlueWarp = (DoorWarp1*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_WARP1, 0.0f, 60.0f, 0.0f, 0, 0, 0, 1); Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_B_HEART, 0.0f, 30.0f, -150.0f, 0, 1, 0, 0); @@ -710,10 +709,10 @@ void func_809DAB78(Boss02* this, PlayState* play) { this->unk_0168 = 2000.0f; if (this->unk_0195 != 0) { - this->actor.speedXZ = this->unk_01A8 * D_809DF5B0 * 1.25f; + this->actor.speed = this->unk_01A8 * D_809DF5B0 * 1.25f; this->skelAnime.playSpeed = 2.0f; } else { - this->actor.speedXZ = this->unk_01A8 * D_809DF5B0; + this->actor.speed = this->unk_01A8 * D_809DF5B0; } Actor_UpdateVelocityWithoutGravity(&this->actor); @@ -732,7 +731,7 @@ void func_809DAB78(Boss02* this, PlayState* play) { this->unk_0170 = this->unk_017C; this->unk_0170.y = temp_f0; this->unk_016C = 120; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); + Actor_PlaySfx(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); } this->actor.flags &= ~ACTOR_FLAG_1; @@ -751,9 +750,9 @@ void func_809DAB78(Boss02* this, PlayState* play) { this->unk_01BC[this->unk_014E].y = this->actor.world.pos.y; this->unk_01BC[this->unk_014E].z = this->actor.world.pos.z; - this->unk_0B1C[this->unk_014E].x = BINANG_TO_RAD(this->actor.world.rot.x); - this->unk_0B1C[this->unk_014E].y = BINANG_TO_RAD(this->actor.world.rot.y); - this->unk_0B1C[this->unk_014E].z = BINANG_TO_RAD(this->actor.world.rot.z); + this->unk_0B1C[this->unk_014E].x = BINANG_TO_RAD_ALT(this->actor.world.rot.x); + this->unk_0B1C[this->unk_014E].y = BINANG_TO_RAD_ALT(this->actor.world.rot.y); + this->unk_0B1C[this->unk_014E].z = BINANG_TO_RAD_ALT(this->actor.world.rot.z); } if ((this->unk_0144 < 10) && (otherTwinmold->unk_0144 >= 20)) { @@ -941,13 +940,13 @@ void func_809DAB78(Boss02* this, PlayState* play) { sTwinmoldStatic->subCamAtVel = 0.0f; play_sound(NA_SE_EN_INBOSS_DEAD_PRE2_OLD); } else if (!(this->unk_0146[1] & 0xF) && (Rand_ZeroOne() < 0.5f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); + Actor_PlaySfx(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); } return; case 21: this->unk_01A8 = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->unk_0146[0] == 0) { this->unk_0146[0] = 3; @@ -969,20 +968,20 @@ void func_809DAB78(Boss02* this, PlayState* play) { spCC = player->actor.world.pos.x - this->actor.world.pos.x; spC4 = player->actor.world.pos.z - this->actor.world.pos.z; if (sqrtf(SQ(spCC) + SQ(spC4)) < (400.0f * D_809DF5B0)) { - this->actor.speedXZ = 15.0f * D_809DF5B0; + this->actor.speed = 15.0f * D_809DF5B0; } spCC = this->actor.world.pos.x; spC4 = this->actor.world.pos.z; if (sqrtf(SQ(spCC) + SQ(spC4)) < (400.0f * D_809DF5B0)) { - this->actor.speedXZ = 15.0f * D_809DF5B0; + this->actor.speed = 15.0f * D_809DF5B0; } if (otherTwinmold->unk_0144 >= 10) { - Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_CLEAR_BOSS | SEQ_FLAG_ASYNC); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_DEAD_OLD); + Actor_PlaySfx(&this->actor, NA_SE_EN_INBOSS_DEAD_OLD); } } return; @@ -994,11 +993,11 @@ void func_809DAB78(Boss02* this, PlayState* play) { this->unk_0B1C[i].y += this->unk_0164; Math_ApproachF(&this->unk_0B1C[i].x, -(M_PI / 2), 0.1f, 0.07f); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 150.0f, 100.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 150.0f, 100.0f, UPDBGCHECKINFO_FLAG_4); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->unk_0144 = 23; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_0170 = this->unk_017C; this->unk_016C = 30; this->unk_0170.y = this->actor.floorHeight; @@ -1075,7 +1074,7 @@ void func_809DBFB4(Boss02* this, PlayState* play) { this->unk_0156 = 15; if (i == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); + Actor_PlaySfx(&this->actor, NA_SE_EN_INBOSS_DAMAGE_OLD); this->unk_015C = 1; } else { Audio_PlaySfxAtPos(&this->unk_167C, NA_SE_EN_INBOSS_DAMAGE_OLD); @@ -1105,7 +1104,7 @@ void func_809DBFB4(Boss02* this, PlayState* play) { this->unk_0144 = 20; if (otherTwinmold->unk_0144 >= 10) { - Audio_QueueSeqCmd(0x100100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); } else { otherTwinmold->unk_0195 = 1; } @@ -1201,9 +1200,9 @@ void Boss02_Twinmold_Update(Actor* thisx, PlayState* play) { if (this->unk_016C != 0) { if ((this->unk_016C == 60) && (this->unk_0144 < 20)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); + Actor_PlaySfx(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_SAND_OLD - SFX_FLAG); + Actor_PlaySfx(&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; @@ -1288,17 +1287,17 @@ void Boss02_Static_Update(Actor* thisx, PlayState* play) { this->unk_1D74 = KREG(23) + -15.0f; D_801F4E30 = 0; play->envCtx.lightSettingOverride = 1; - play->skyboxId = 1; + play->skyboxId = SKYBOX_NORMAL_SKY; } else if (!sIsInGiantMode) { this->unk_1D74 = 0.0f; D_801F4E30 = this->unk_1D7C; play->envCtx.lightSettingOverride = 0; - play->skyboxId = 2; + play->skyboxId = SKYBOX_2; } else { this->unk_1D74 = KREG(23) + -15.0f; D_801F4E30 = ((KREG(24) * 0.1f) + 1.0f) * this->unk_1D7C; play->envCtx.lightSettingOverride = 1; - play->skyboxId = 1; + play->skyboxId = SKYBOX_NORMAL_SKY; } Math_ApproachS(&this->unk_1D7C, this->unk_1D7E, 1, 3); @@ -1311,7 +1310,7 @@ void Boss02_Static_Update(Actor* thisx, PlayState* play) { if (sMusicStartTimer != 0) { sMusicStartTimer--; if (sMusicStartTimer == 0) { - Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_BOSS | SEQ_FLAG_ASYNC); } } } @@ -1391,7 +1390,7 @@ void Boss02_Twinmold_Draw(Actor* thisx, PlayState* play2) { } SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); spA4 = 0.0f; spA0 = 0.0f; @@ -1426,7 +1425,7 @@ void Boss02_Twinmold_Draw(Actor* thisx, PlayState* play2) { if (sp98 < this->unk_01BC[phi_v0].y) { gSPDisplayList(POLY_OPA_DISP++, D_809DFA9C[i]); } - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); } if (i == 21) { @@ -1632,11 +1631,11 @@ void func_809DD934(Boss02* this, PlayState* play) { switch (this->unk_1D18) { case 0: if (player->stateFlags1 & PLAYER_STATE1_100) { - Cutscene_Start(play, &play->csCtx); + Cutscene_StartManual(play, &play->csCtx); this->subCamId = Play_CreateSubCamera(play); Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); - func_8016566C(150); + Play_EnableMotionBlur(150); this->unk_1D14 = 0; this->subCamAtVel = 0.0f; this->unk_1D58 = 0.0f; @@ -1752,11 +1751,11 @@ void func_809DD934(Boss02* this, PlayState* play) { this->unk_1D18 = 0; func_80169AFC(play, this->subCamId, 0); this->subCamId = SUB_CAM_ID_DONE; - Cutscene_End(play, &play->csCtx); + Cutscene_StopManual(play, &play->csCtx); this->actor.flags |= ACTOR_FLAG_1; player->stateFlags1 &= ~PLAYER_STATE1_100; this->unk_1D70 = 0.01f; - func_80165690(); + Play_DisableMotionBlur(); break; } @@ -1958,7 +1957,7 @@ void func_809DD934(Boss02* this, PlayState* play) { temp_a0_5->world.pos.x *= phi_f0_2; temp_a0_5->world.pos.z *= phi_f0_2; - temp_a0_5->speedXZ *= phi_f0_2; + temp_a0_5->speed *= phi_f0_2; temp_a0_5->velocity.x *= phi_f0_2; temp_a0_5->velocity.y *= phi_f0_2; @@ -2051,10 +2050,11 @@ void func_809DEAC4(Boss02* this, PlayState* play) { break; case 1: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20) || ((u32)(KREG(13) + 15) >= this->unk_1D1C)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE) || + ((u32)(KREG(13) + 15) >= this->unk_1D1C)) { break; } - Cutscene_Start(play, &play->csCtx); + Cutscene_StartManual(play, &play->csCtx); this->subCamId = Play_CreateSubCamera(play); Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); @@ -2139,8 +2139,8 @@ void func_809DEAC4(Boss02* this, PlayState* play) { if (this->unk_1D1C == (u32)(BREG(27) + 335)) { func_80169AFC(play, this->subCamId, 0); this->subCamId = SUB_CAM_ID_DONE; - Cutscene_End(play, &play->csCtx); - func_800B7298(play, &this->actor, PLAYER_CSMODE_6); + Cutscene_StopManual(play, &play->csCtx); + func_800B7298(play, &this->actor, PLAYER_CSMODE_END); this->actor.flags |= ACTOR_FLAG_1; this->unk_1D20 = 0; sRedTwinmold->unk_0144 = sBlueTwinmold->unk_0144 = 3; @@ -2150,8 +2150,8 @@ void func_809DEAC4(Boss02* this, PlayState* play) { break; case 100: - if (ActorCutscene_GetCurrentIndex() == -1) { - Cutscene_Start(play, &play->csCtx); + if (CutsceneManager_GetCurrentCsId() == CS_ID_NONE) { + Cutscene_StartManual(play, &play->csCtx); this->subCamId = Play_CreateSubCamera(play); Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); @@ -2200,8 +2200,8 @@ void func_809DEAC4(Boss02* this, PlayState* play) { if (this->unk_1D1C == 30) { func_80169AFC(play, this->subCamId, 0); this->subCamId = SUB_CAM_ID_DONE; - Cutscene_End(play, &play->csCtx); - func_800B7298(play, &this->actor, PLAYER_CSMODE_6); + Cutscene_StopManual(play, &play->csCtx); + func_800B7298(play, &this->actor, PLAYER_CSMODE_END); this->unk_1D20 = 0; this->actor.flags |= ACTOR_FLAG_1; sp68->unk_0144 = 10; diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index 4c3b34fbb..054b612bc 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -48,7 +48,6 @@ * - Effect Update/Draw * - Seaweed */ -#include "prevent_bss_reordering.h" #include "z_boss_03.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h" @@ -449,7 +448,7 @@ void Boss03_Init(Actor* thisx, PlayState* play2) { PlayState* play = play2; Vec3f sp70; - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_WARP1, 0.0f, PLATFORM_HEIGHT, 200.0f, 0, 0, 0, ENDOORWARP1_FF_1); Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_B_HEART, 0.0f, PLATFORM_HEIGHT, 0.0f, 0, 0, 0, 0); @@ -519,7 +518,7 @@ void Boss03_Init(Actor* thisx, PlayState* play2) { if ((KREG(64) != 0) || CHECK_EVENTINF(EVENTINF_56)) { this->actionFunc = func_809E344C; D_809E9842 = false; - Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); } else { Boss03_SetupIntroCutscene(this, play); D_809E9842 = true; @@ -582,10 +581,10 @@ void func_809E34B8(Boss03* this, PlayState* play) { Math_ApproachS(&this->bodyYRot, bodyYRotTarget, 5, 0x100); Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); - Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); + Math_ApproachF(&this->actor.speed, this->unk_278, 1.0f, this->unk_27C); Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); - if ((this->workTimer[WORK_TIMER_UNK2_A] == 0) && (this->actor.bgCheckFlags & 8)) { + if ((this->workTimer[WORK_TIMER_UNK2_A] == 0) && (this->actor.bgCheckFlags & BGCHECKFLAG_WALL)) { Matrix_MultVecZ(-500.0f, &this->unk_268); this->unk_268.y = Rand_ZeroFloat(100.0f) + 150.0f; this->workTimer[WORK_TIMER_UNK2_A] = 60; @@ -619,7 +618,7 @@ void func_809E34B8(Boss03* this, PlayState* play) { if (this->workTimer[WORK_TIMER_UNK1_A] == 0) { // Player is above water && Player is standing on ground - if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { Boss03_SetupPrepareCharge(this, play); } else if ((player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_DEKU)) { if (KREG(70) == 0) { @@ -670,7 +669,7 @@ void Boss03_ChasePlayer(Boss03* this, PlayState* play) { Math_ApproachS(&this->bodyYRot, bodyYRotTarget, 5, 0x100); Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); - Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); + Math_ApproachF(&this->actor.speed, this->unk_278, 1.0f, this->unk_27C); Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); Actor_MoveWithoutGravityReverse(&this->actor); @@ -679,7 +678,8 @@ void Boss03_ChasePlayer(Boss03* this, PlayState* play) { // If either (Player is standing on ground && Player is above water) or (WORK_TIMER_CURRENT_ACTION timer runs out), // then stop chasing - if (((player->actor.bgCheckFlags & 1) && (player->actor.shape.feetPos[0].y >= WATER_HEIGHT + 8.0f)) || + if (((player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + (player->actor.shape.feetPos[0].y >= WATER_HEIGHT + 8.0f)) || (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0)) { if (&this->actor == player->actor.parent) { player->unk_AE8 = 101; @@ -766,7 +766,7 @@ void Boss03_CatchPlayer(Boss03* this, PlayState* play) { -0.5f, 5, 0x100); Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); - Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); + Math_ApproachF(&this->actor.speed, this->unk_278, 1.0f, this->unk_27C); Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); Actor_MoveWithoutGravityReverse(&this->actor); Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); @@ -774,13 +774,14 @@ void Boss03_CatchPlayer(Boss03* this, PlayState* play) { // If either (Player is standing on ground && Player is above water) or (WORK_TIMER_CURRENT_ACTION timer runs out) // then stop trying to catch Player - if (((player->actor.bgCheckFlags & 1) && (player->actor.shape.feetPos[FOOT_LEFT].y >= WATER_HEIGHT + 8.0f)) || + if (((player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + (player->actor.shape.feetPos[FOOT_LEFT].y >= WATER_HEIGHT + 8.0f)) || (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0)) { if (&this->actor == player->actor.parent) { player->unk_AE8 = 101; player->actor.parent = NULL; player->csMode = PLAYER_CSMODE_0; - func_80165690(); + Play_DisableMotionBlur(); } func_809E344C(this, play); @@ -852,7 +853,7 @@ void Boss03_ChewPlayer(Boss03* this, PlayState* play) { this->unk_25C = 15; if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 90) { - func_8016566C(0x96); + Play_EnableMotionBlur(150); } SkelAnime_Update(&this->skelAnime); @@ -874,7 +875,7 @@ void Boss03_ChewPlayer(Boss03* this, PlayState* play) { switch (this->unk_242) { case 0: - Math_ApproachF(&this->actor.speedXZ, 10.0f, 1.0f, 1.0f); + Math_ApproachF(&this->actor.speed, 10.0f, 1.0f, 1.0f); if (sqrtf(SQ(xDiff) + SQ(zDiff)) < 100.0f) { this->unk_242 = 1; Animation_MorphToLoop(&this->skelAnime, &gGyorgBackingUpAnim, -15.0f); @@ -882,7 +883,7 @@ void Boss03_ChewPlayer(Boss03* this, PlayState* play) { break; case 1: - Math_ApproachF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f); + Math_ApproachF(&this->actor.speed, 0.0f, 1.0f, 0.5f); Math_ApproachF(&this->actor.world.pos.y, 200.0f, 0.05f, 5.0f); break; } @@ -908,7 +909,7 @@ void Boss03_ChewPlayer(Boss03* this, PlayState* play) { player->unk_AE8 = 101; player->actor.parent = NULL; player->csMode = PLAYER_CSMODE_0; - func_80165690(); + Play_DisableMotionBlur(); func_800B8D50(play, NULL, 10.0f, this->actor.shape.rot.y, 0.0f, 0x20); } @@ -986,7 +987,7 @@ void Boss03_PrepareCharge(Boss03* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); // Player is above water && Player is standing on ground - if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0) { Boss03_SetupCharge(this, play); } @@ -996,7 +997,7 @@ void Boss03_PrepareCharge(Boss03* this, PlayState* play) { } // Turns back slowly - Math_ApproachF(&this->actor.speedXZ, -3.0f, 1.0f, 0.5f); + Math_ApproachF(&this->actor.speed, -3.0f, 1.0f, 0.5f); Actor_MoveWithoutGravityReverse(&this->actor); } @@ -1033,11 +1034,11 @@ void Boss03_Charge(Boss03* this, PlayState* play) { this->actor.shape.rot = this->actor.world.rot; - Math_ApproachF(&this->actor.speedXZ, 25.0f, 1.0f, 3.0f); + Math_ApproachF(&this->actor.speed, 25.0f, 1.0f, 3.0f); Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); Actor_MoveWithoutGravityReverse(&this->actor); - if (this->actor.speedXZ >= 20.0f) { + if (this->actor.speed >= 20.0f) { // Jump over platform if (this->unk_242 == 1) { if (sqrtf(SQXZ(this->actor.world.pos)) < 700.0f) { @@ -1047,14 +1048,14 @@ void Boss03_Charge(Boss03* this, PlayState* play) { } // Attack platform - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); - func_800BC848(&this->actor, play, 20, 15); + Actor_RequestQuakeAndRumble(&this->actor, play, 20, 15); Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, 0.0f, this->waterHeight, 0.0f, 0, 0, 0x96, ENWATEREFFECT_TYPE_GYORG_SHOCKWAVE); // Player is above water && Player is standing on ground - if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { func_800B8D50(play, NULL, 7.0f, Math_Atan2S_XY(player->actor.world.pos.z, player->actor.world.pos.x), 7.0f, 0); } @@ -1069,7 +1070,7 @@ void Boss03_SetupJumpOverPlatform(Boss03* this, PlayState* play) { this->actionFunc = Boss03_JumpOverPlatform; this->actor.gravity = -2.0f; this->actor.velocity.y = 30.0f; - this->actor.speedXZ = 25.0f; + this->actor.speed = 25.0f; Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_JUMP_OLD); } @@ -1144,8 +1145,8 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { switch (this->csState) { case 0: if (player->actor.world.pos.y < 1350.0f) { - Cutscene_Start(play, &play->csCtx); - func_800B7298(play, &this->actor, PLAYER_CSMODE_7); + Cutscene_StartManual(play, &play->csCtx); + func_800B7298(play, &this->actor, PLAYER_CSMODE_WAIT); this->subCamId = Play_CreateSubCamera(play); Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); @@ -1172,7 +1173,7 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { case 1: player->actor.world.pos.z = 0.0f; player->actor.world.pos.x = 0.0f; - player->actor.speedXZ = 0.0f; + player->actor.speed = 0.0f; this->subCamEye.x = 100.0f; this->subCamEye.y = 540.0f; @@ -1187,11 +1188,11 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { this->csState = 2; this->csTimer = 0; this->unk_240 = 0; - func_8016566C(0x96); + Play_EnableMotionBlur(150); this->subCamFov = 80.0f; case 2: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEMO_MOVE_OLD - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_KONB_DEMO_MOVE_OLD - SFX_FLAG); xDiff = D_809E9104[this->unk_242].x - this->actor.world.pos.x; yDiff = D_809E9104[this->unk_242].y - this->actor.world.pos.y; @@ -1207,11 +1208,11 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { } if ((this->csTimer == 40) || (this->csTimer == (u32)(KREG(91) + 270))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_WATER_DEEP); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_WATER_DEEP); } if (this->csTimer > 50) { - Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, 0.1f); + Math_ApproachF(&this->actor.speed, this->unk_278, 1.0f, 0.1f); } if (this->unk_242 < 2) { @@ -1226,15 +1227,15 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { } else { this->unk_278 = 0.0f; bubblesToSpawnNum = 1; - if ((this->actor.speedXZ == 0.0f) && (this->csTimer > 230)) { + if ((this->actor.speed == 0.0f) && (this->csTimer > 230)) { this->csState = 3; this->csTimer = 0; } if (this->csTimer == 165) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_WATER_MID); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_WATER_MID); } if (this->csTimer == 180) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_WATER_DEEP); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_WATER_DEEP); } } } @@ -1244,7 +1245,7 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { case 3: Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_PREATTACK_OLD - SFX_FLAG); sp5A = 0x1970; - Math_ApproachF(&this->actor.speedXZ, 15.0f, 1.0f, 2.0f); + Math_ApproachF(&this->actor.speed, 15.0f, 1.0f, 2.0f); if (this->csTimer > 20) { this->csState = 4; this->csTimer = 0; @@ -1277,14 +1278,14 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { this->csState = 5; this->csTimer = 0; this->unk_2D5 = false; - this->actor.speedXZ = -200.0f; + this->actor.speed = -200.0f; Actor_MoveWithoutGravityReverse(&this->actor); this->actor.world.pos.y = this->waterHeight - 150.0f; - func_80165690(); + Play_DisableMotionBlur(); case 5: SkelAnime_Update(&this->skelAnime); - this->actor.speedXZ = 20.0f; + this->actor.speed = 20.0f; Actor_MoveWithoutGravityReverse(&this->actor); player->actor.shape.rot.y = -0x1470; player->actor.world.rot.y = player->actor.shape.rot.y; @@ -1302,17 +1303,17 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { this->csState = 6; this->csTimer = 0; this->actor.gravity = -1.5f; - this->actor.speedXZ = 20.0f; + this->actor.speed = 20.0f; - Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_JUMP_OLD); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_BOSS | SEQ_FLAG_ASYNC); + Actor_PlaySfx(&this->actor, NA_SE_EN_KONB_JUMP_OLD); this->skelAnime.playSpeed = 1.0f; } } break; case 6: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); if (this->csTimer == 30) { TitleCard_InitBossName(&play->state, &play->actorCtx.titleCtxt, @@ -1327,7 +1328,7 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { this->bubbleEffectSpawnCount = 2; this->actor.gravity = 0.0f; Math_ApproachZeroF(&this->actor.velocity.y, 1.0f, 1.0f); - Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.5f); + Math_ApproachZeroF(&this->actor.speed, 1.0f, 0.5f); } else { if (1) {} if (1) {} @@ -1366,8 +1367,8 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { mainCam->at = this->subCamAt; func_80169AFC(play, this->subCamId, 0); - Cutscene_End(play, &play->csCtx); - func_800B7298(play, &this->actor, PLAYER_CSMODE_6); + Cutscene_StopManual(play, &play->csCtx); + func_800B7298(play, &this->actor, PLAYER_CSMODE_END); this->subCamId = SUB_CAM_ID_DONE; func_809E344C(this, play); @@ -1383,7 +1384,7 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) { if ((this->csState == 2) || (this->csState == 3)) { Actor_MoveWithoutGravityReverse(&this->actor); - phi_f2 = this->actor.speedXZ * 0.02f; + phi_f2 = this->actor.speed * 0.02f; phi_f2 = CLAMP_MAX(phi_f2, 0.12f); sp5C = Math_SinS(this->unk_240 * sp5A) * phi_f2; @@ -1414,7 +1415,7 @@ void Boss03_SetupDeathCutscene(Boss03* this, PlayState* play) { this->actionFunc = Boss03_DeathCutscene; Animation_MorphToLoop(&this->skelAnime, &gGyorgFloppingAnim, -10.0f); this->floppingAnimLastFrame = Animation_GetLastFrame(&gGyorgFloppingAnim); - Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); this->workTimer[WORK_TIMER_UNK0_C] = 0; this->unk_242 = 0; this->csState = 0; @@ -1443,8 +1444,8 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) { switch (this->csState) { case 0: - if (ActorCutscene_GetCurrentIndex() == -1) { - Cutscene_Start(play, &play->csCtx); + if (CutsceneManager_GetCurrentCsId() == CS_ID_NONE) { + Cutscene_StartManual(play, &play->csCtx); func_800B7298(play, &this->actor, PLAYER_CSMODE_1); this->subCamId = Play_CreateSubCamera(play); Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); @@ -1452,7 +1453,8 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) { this->unk_2BE = Math_Atan2S_XY(this->actor.world.pos.z, this->actor.world.pos.x); // Player is above water && Player is standing on ground - if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + if ((this->waterHeight < player->actor.world.pos.y) && + (player->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { player->actor.world.pos.x = 0.0f; player->actor.world.pos.z = -200.0f; } @@ -1515,10 +1517,10 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) { Math_ApproachF(&this->actor.world.pos.z, sp84.z, 0.1f, 5.0f); if (Animation_OnFrame(&this->skelAnime, this->floppingAnimLastFrame)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEAD_JUMP2_OLD); + Actor_PlaySfx(&this->actor, NA_SE_EN_KONB_DEAD_JUMP2_OLD); } if (Animation_OnFrame(&this->skelAnime, this->floppingAnimLastFrame * 0.5f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEAD_JUMP_OLD); + Actor_PlaySfx(&this->actor, NA_SE_EN_KONB_DEAD_JUMP_OLD); } if ((this->workTimer[WORK_TIMER_UNK0_C] == 0) && ((this->waterHeight - 100.0f) < this->actor.world.pos.y)) { @@ -1545,10 +1547,10 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) { this->unk_242 = 1; this->actor.gravity = -2.0f; this->actor.velocity.y = 25.0f; - this->actor.speedXZ = 10.0f; + this->actor.speed = 10.0f; this->actor.world.rot.y = this->unk_2BE + 0x8000; this->unk_240 = 0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEAD_JUMP2_OLD); + Actor_PlaySfx(&this->actor, NA_SE_EN_KONB_DEAD_JUMP2_OLD); } } Math_ApproachF(&this->unk_56C, 0.01f, 1.0f, 0.0005f); @@ -1556,7 +1558,7 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) { case 1: if (this->unk_240 == 0x96) { - Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_CLEAR_BOSS | SEQ_FLAG_ASYNC); } Math_ApproachF(&this->unk_56C, 0.01f, 1.0f, 0.0005f); Math_ApproachF(&this->actor.scale.x, 0.01f, 0.05f, 0.001f); @@ -1566,7 +1568,7 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) { if (this->actor.world.pos.y < PLATFORM_HEIGHT + (100.0f * sp64)) { this->actor.world.pos.y = PLATFORM_HEIGHT + (100.0f * sp64); this->actor.velocity.y = ((Rand_ZeroFloat(10.0f) + 7.5f) * sp64) + 7.5f; - this->actor.speedXZ = ((Rand_ZeroFloat(5.0f) + 2.5f) * sp64) + 2.5f; + this->actor.speed = ((Rand_ZeroFloat(5.0f) + 2.5f) * sp64) + 2.5f; if (Rand_ZeroOne() < 0.5f) { this->shapeRotTargetX = @@ -1624,10 +1626,10 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) { mainCam->at = this->subCamAt; func_80169AFC(play, this->subCamId, 0); this->subCamId = SUB_CAM_ID_DONE; - Cutscene_End(play, &play->csCtx); - func_800B7298(play, &this->actor, PLAYER_CSMODE_6); + Cutscene_StopManual(play, &play->csCtx); + func_800B7298(play, &this->actor, PLAYER_CSMODE_END); this->csState = 3; - func_80165690(); + Play_DisableMotionBlur(); Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_INIT_OLD); Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_INIT_OLD); } @@ -1657,8 +1659,8 @@ void Boss03_SpawnSmallFishesCutscene(Boss03* this, PlayState* play) { this->csTimer++; switch (this->csState) { case 0: - if (ActorCutscene_GetCurrentIndex() == -1) { - Cutscene_Start(play, &play->csCtx); + if (CutsceneManager_GetCurrentCsId() == CS_ID_NONE) { + Cutscene_StartManual(play, &play->csCtx); func_800B7298(play, &this->actor, PLAYER_CSMODE_1); this->subCamId = Play_CreateSubCamera(play); Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); @@ -1705,7 +1707,7 @@ void Boss03_SpawnSmallFishesCutscene(Boss03* this, PlayState* play) { this->numSpawnedSmallFish++; } if ((this->csTimer % 8) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_MINI_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_KONB_MINI_APPEAR); } } } @@ -1719,8 +1721,8 @@ void Boss03_SpawnSmallFishesCutscene(Boss03* this, PlayState* play) { func_80169AFC(play, this->subCamId, 0); this->subCamId = SUB_CAM_ID_DONE; - Cutscene_End(play, &play->csCtx); - func_800B7298(play, &this->actor, PLAYER_CSMODE_6); + Cutscene_StopManual(play, &play->csCtx); + func_800B7298(play, &this->actor, PLAYER_CSMODE_END); func_809E344C(this, play); this->workTimer[WORK_TIMER_UNK1_A] = 50; @@ -1751,7 +1753,7 @@ void Boss03_SetupStunned(Boss03* this, PlayState* play) { player->unk_AE8 = 101; player->actor.parent = NULL; player->csMode = PLAYER_CSMODE_0; - func_80165690(); + Play_DisableMotionBlur(); } this->unk_240 = 0; @@ -1769,9 +1771,9 @@ void Boss03_Stunned(Boss03* this, PlayState* play) { if ((this->waterHeight + 30.0f) < this->actor.world.pos.y) { this->actor.gravity = -2.0f; Actor_MoveWithGravity(&this->actor); - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { play_sound(NA_SE_IT_WALL_HIT_HARD); - func_800BC848(&this->actor, play, 10, 10); + Actor_RequestQuakeAndRumble(&this->actor, play, 10, 10); } } else { Math_ApproachS(&this->actor.shape.rot.z, -0x6000, 0xA, 0x900); @@ -1779,7 +1781,7 @@ void Boss03_Stunned(Boss03* this, PlayState* play) { this->actor.shape.rot.x = this->actor.world.rot.x; Math_ApproachF(&this->actor.world.pos.y, 100.0f, 0.05f, 5.0f); - Math_ApproachF(&this->actor.speedXZ, 0.0f, 1.0f, 1.5f); + Math_ApproachF(&this->actor.speed, 0.0f, 1.0f, 1.5f); Actor_MoveWithoutGravityReverse(&this->actor); } @@ -1903,7 +1905,7 @@ void Boss03_UpdateCollision(Boss03* this, PlayState* play) { player->unk_AE8 = 101; player->actor.parent = NULL; player->csMode = PLAYER_CSMODE_0; - func_80165690(); + Play_DisableMotionBlur(); } continue; @@ -1991,7 +1993,8 @@ void Boss03_Update(Actor* thisx, PlayState* play2) { Math_ApproachS(&this->actor.shape.rot.z, 0, 0xA, 0x800); this->actor.world.pos.y -= 100.0f; this->actor.prevPos.y -= 100.0f; - Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 150.0f, 100.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 150.0f, 100.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); this->actor.world.pos.y += 100.0f; this->actor.prevPos.y += 100.0f; } @@ -2004,7 +2007,7 @@ void Boss03_Update(Actor* thisx, PlayState* play2) { ((this->waterHeight - 50.0f < this->actor.world.pos.y) && (this->actor.prevPos.y <= this->waterHeight - 50.0f))) { if ((this->actor.velocity.y < 0.0f) && (this->actionFunc != Boss03_DeathCutscene)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_SINK_OLD); + Actor_PlaySfx(&this->actor, NA_SE_EN_KONB_SINK_OLD); } Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, this->waterHeight, @@ -2082,7 +2085,7 @@ void Boss03_Update(Actor* thisx, PlayState* play2) { if (D_809E9841 != 0) { D_809E9841--; if (D_809E9841 == 0) { - Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_BOSS | SEQ_FLAG_ASYNC); } } @@ -2096,7 +2099,8 @@ void Boss03_Update(Actor* thisx, PlayState* play2) { } // Player is standing on ground && Player is above water - if ((player->actor.bgCheckFlags & 1) && (player->actor.shape.feetPos[FOOT_LEFT].y >= WATER_HEIGHT + 8.0f)) { + if ((player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + (player->actor.shape.feetPos[FOOT_LEFT].y >= WATER_HEIGHT + 8.0f)) { if (this->wetSpotEffectSpawnCount != 0) { this->wetSpotEffectSpawnCount--; @@ -2270,7 +2274,7 @@ void Boss03_Draw(Actor* thisx, PlayState* play) { Matrix_Translate(0.0f, -600.0f, 0.0f, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, Boss03_OverrideLimbDraw, Boss03_PostLimbDraw, &this->actor); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); } this->unk_2BC = 0; @@ -2436,7 +2440,7 @@ void Boss03_DrawEffects(PlayState* play) { Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); if (eff->type == GYORG_EFFECT_DROPLET) { - Matrix_RotateYF(Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)) * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateYF(BINANG_TO_RAD(Camera_GetInputDirYaw(GET_ACTIVE_CAM(play))), MTXMODE_APPLY); } else { // GYORG_EFFECT_SPLASH Matrix_ReplaceRotation(&play->billboardMtxF); } @@ -2512,13 +2516,13 @@ void Boss03_SeaweedUpdate(Actor* thisx, PlayState* play) { yDiff = player->actor.world.pos.y - this->seaweedSegmentPositions[i].y; zDiff = player->actor.world.pos.z - this->seaweedSegmentPositions[i].z; distanceBetweenSeaweedAndDisturbance = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); - disturbanceFactor = player->actor.speedXZ * 3.0f + 70.0f; + disturbanceFactor = player->actor.speed * 3.0f + 70.0f; // Player is standing on ground - if (player->actor.bgCheckFlags & 1) { + if (player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { maxBendSpeed = 0; } else { - maxBendSpeed = player->actor.speedXZ * 16.0f; + maxBendSpeed = player->actor.speed * 16.0f; if (maxBendSpeed > 0x1000) { maxBendSpeed = 0x1000; } else if (maxBendSpeed < 0x100) { @@ -2551,8 +2555,8 @@ void Boss03_SeaweedUpdate(Actor* thisx, PlayState* play) { break; } - maxBendSpeed = sGyorgBossInstance->actor.speedXZ * 16.0f; - disturbanceFactor = sGyorgBossInstance->actor.speedXZ * 5.0f + 150.0f; + maxBendSpeed = sGyorgBossInstance->actor.speed * 16.0f; + disturbanceFactor = sGyorgBossInstance->actor.speed * 5.0f + 150.0f; if (maxBendSpeed > 0x1000) { maxBendSpeed = 0x1000; } else if (maxBendSpeed < 0x100) { 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 0b59ff9ed..80fc52a22 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -197,7 +197,7 @@ void Boss04_Init(Actor* thisx, PlayState* play2) { 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(play, &this->actor, 35.0f, 60.0f, 60.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 60.0f, 60.0f, UPDBGCHECKINFO_FLAG_4); if ((KREG(64) != 0) || CHECK_EVENTINF(EVENTINF_60)) { func_809ECD00(this, play); @@ -254,16 +254,16 @@ void func_809EC568(Boss04* this, PlayState* play) { this->unk_2D0 = 2000.0f; if ((player->stateFlags1 & PLAYER_STATE1_100000) && (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)) { + if ((this->unk_704 >= 15) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE)) { Actor* boss; this->unk_708 = 10; this->unk_704 = 0; - Cutscene_Start(play, &play->csCtx); + Cutscene_StartManual(play, &play->csCtx); this->subCamId = Play_CreateSubCamera(play); Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); - func_800B7298(play, &this->actor, PLAYER_CSMODE_7); + func_800B7298(play, &this->actor, PLAYER_CSMODE_WAIT); player->actor.world.pos.x = this->unk_6E8; player->actor.world.pos.z = this->unk_6F0 + 410.0f; player->actor.shape.rot.y = 0x7FFF; @@ -271,7 +271,7 @@ void func_809EC568(Boss04* this, PlayState* play) { Math_Vec3f_Copy(&this->subCamEye, &player->actor.world.pos); this->subCamEye.y += 100.0f; Math_Vec3f_Copy(&this->subCamAt, &this->actor.world.pos); - func_8016566C(150); + Play_EnableMotionBlur(150); this->subCamFov = 60.0f; boss = play->actorCtx.actorLists[ACTORCAT_BOSS].first; @@ -289,7 +289,7 @@ void func_809EC568(Boss04* this, PlayState* play) { case 10: if (this->unk_704 == 3) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEMO_EYE); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_DEMO_EYE); this->unk_74A = 1; } this->unk_2D0 = 10000.0f; @@ -319,11 +319,11 @@ void func_809EC568(Boss04* this, PlayState* play) { } case 12: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_ATTACK - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_ME_ATTACK - SFX_FLAG); Math_ApproachF(&this->subCamAt.x, this->actor.world.pos.x, 0.5f, 1000.0f); Math_ApproachF(&this->subCamAt.y, this->actor.world.pos.y, 0.5f, 1000.0f); Math_ApproachF(&this->subCamAt.z, this->actor.world.pos.z, 0.5f, 1000.0f); - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); this->unk_6F4 = 15; this->unk_708 = 13; @@ -331,7 +331,7 @@ void func_809EC568(Boss04* this, PlayState* play) { this->unk_2DA = 10; Actor_Spawn(&play->actorCtx, play, 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); + Actor_PlaySfx(&this->actor, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); this->subCamAtOscillator = 20; } break; @@ -389,9 +389,9 @@ void func_809EC568(Boss04* this, PlayState* play) { mainCam->at = this->subCamAt; func_80169AFC(play, this->subCamId, 0); this->subCamId = SUB_CAM_ID_DONE; - Cutscene_End(play, &play->csCtx); - func_800B7298(play, &this->actor, PLAYER_CSMODE_6); - func_80165690(); + Cutscene_StopManual(play, &play->csCtx); + func_800B7298(play, &this->actor, PLAYER_CSMODE_END); + Play_DisableMotionBlur(); SET_EVENTINF(EVENTINF_60); } break; @@ -431,7 +431,7 @@ void func_809ECD18(Boss04* this, PlayState* play) { 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); + Math_ApproachF(&this->actor.speed, this->unk_6D4, 1.0f, 0.5f); if (this->unk_1F8 == 0) { this->unk_1F8 = Rand_ZeroFloat(100.0f) + 50.0f; @@ -460,14 +460,14 @@ void func_809ECEF4(Boss04* this) { this->unk_1F8 = 0; this->unk_1F6 = 1; this->unk_1FA = 60; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.gravity = -3.0f; } void func_809ECF58(Boss04* this, PlayState* play) { Vec3f sp3C; - if ((this->unk_1FE == 14) || ((this->actor.bgCheckFlags & 8) && (this->unk_1F8 == 0))) { + if ((this->unk_1FE == 14) || ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && (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; @@ -477,11 +477,11 @@ void func_809ECF58(Boss04* this, PlayState* play) { this->actor.world.rot.y = BINANG_ROT180((s16)Rand_ZeroFloat(8000.0f) + this->actor.world.rot.y); } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); - func_800BC848(&this->actor, play, 15, 10); + Actor_RequestQuakeAndRumble(&this->actor, play, 15, 10); this->unk_6F4 = 15; sp3C.x = this->actor.focus.pos.x; sp3C.y = this->actor.focus.pos.y; @@ -496,12 +496,12 @@ void func_809ECF58(Boss04* this, PlayState* play) { 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); + Math_ApproachF(&this->actor.speed, 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(play, &sp3C, 1400, 500, 0); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_ATTACK - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_ME_ATTACK - SFX_FLAG); } } @@ -517,10 +517,10 @@ void func_809ED224(Boss04* this) { this->actionFunc = func_809ED2A0; this->unk_1F8 = 60; this->unk_1FA = 100; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_2D0 = 10000.0f; this->unk_2C8 = 200; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_ME_DEAD); this->actor.flags &= ~ACTOR_FLAG_1; Audio_RestorePrevBgm(); this->unk_1F6 = 10; @@ -569,7 +569,7 @@ void func_809ED45C(Boss04* this, PlayState* play) { 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); + Actor_PlaySfx(&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) { @@ -709,7 +709,8 @@ void Boss04_Update(Actor* thisx, PlayState* play2) { Actor_MoveWithGravity(&this->actor); this->actor.world.pos.y -= 100.0f; this->actor.prevPos.y -= 100.0f; - Actor_UpdateBgCheckInfo(play, &this->actor, 100.0f, 120.0f, 200.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 100.0f, 120.0f, 200.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); this->actor.world.pos.y += 100.0f; this->actor.prevPos.y += 100.0f; } @@ -765,7 +766,7 @@ void Boss04_Update(Actor* thisx, PlayState* play2) { } if (this->unk_74A != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_EXIST - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_ME_EXIST - SFX_FLAG); } } @@ -828,7 +829,7 @@ void Boss04_Draw(Actor* thisx, PlayState* play) { SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, Boss04_OverrideLimbDraw, Boss04_PostLimbDraw, &this->actor); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); if (this->actionFunc != func_809EC568) { func_8012C448(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 5dce58c4e..3d8beb79d 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -4,6 +4,7 @@ * Description: Igos du Ikana window - curtains and ray effects */ +#include "prevent_bss_reordering.h" #include "z_boss_06.h" #include "z64shrink_window.h" #include "overlays/actors/ovl_En_Knight/z_en_knight.h" @@ -194,12 +195,12 @@ void func_809F24C8(Boss06* this, PlayState* play) { switch (this->unk_1C9) { case 0: - if (ActorCutscene_GetCurrentIndex() != -1) { + if (CutsceneManager_GetCurrentCsId() != CS_ID_NONE) { break; } - Cutscene_Start(play, &play->csCtx); - func_800B7298(play, &this->actor, PLAYER_CSMODE_7); + Cutscene_StartManual(play, &play->csCtx); + func_800B7298(play, &this->actor, PLAYER_CSMODE_WAIT); this->subCamId = Play_CreateSubCamera(play); Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); @@ -220,7 +221,7 @@ void func_809F24C8(Boss06* this, PlayState* play) { case 1: if (this->unk_1CA >= 10) { Math_ApproachF(&this->unk_1E4, 30.0f, 0.2f, 1.0f); - play->envCtx.fillScreen = 1; + play->envCtx.fillScreen = true; play->envCtx.screenFillColor[2] = 0; play->envCtx.screenFillColor[1] = 0; play->envCtx.screenFillColor[0] = 0; @@ -233,7 +234,7 @@ void func_809F24C8(Boss06* this, PlayState* play) { } if (this->unk_1CA >= 60) { - play->envCtx.fillScreen = 0; + play->envCtx.fillScreen = false; this->unk_1C8 = 0; this->unk_1DC = 0.0f; this->unk_1D8 = 0.0f; @@ -331,8 +332,8 @@ void func_809F24C8(Boss06* this, PlayState* play) { func_809F2ED0(this, play); func_80169AFC(play, this->subCamId, 0); this->subCamId = SUB_CAM_ID_DONE; - Cutscene_End(play, &play->csCtx); - func_800B7298(play, &this->actor, PLAYER_CSMODE_6); + Cutscene_StopManual(play, &play->csCtx); + func_800B7298(play, &this->actor, PLAYER_CSMODE_END); D_809F4970->unk_151 = 0; } break; diff --git a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c index aa37e7b85..6882c189a 100644 --- a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c +++ b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c @@ -34,7 +34,7 @@ static s16 sObjectBankIndices[] = { OBJECT_GI_MASK14, OBJECT_GI_SWORD_4 }; static s16 sGetItemDraws[] = { GID_MASK_GREAT_FAIRY, GID_SWORD_GREAT_FAIRY }; -static u16 sCsActionIndices[] = { 0x6E, 0x236 }; +static u16 sCueTypes[] = { CS_CMD_ACTOR_CUE_110, CS_CMD_ACTOR_CUE_566 }; void DemoGetitem_Init(Actor* thisx, PlayState* play) { s32 pad; @@ -49,7 +49,7 @@ void DemoGetitem_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.25f); this->actionFunc = func_80A4FB10; this->item = sGetItemDraws[itemIndex]; - this->csAction = sCsActionIndices[itemIndex]; + this->cueType = sCueTypes[itemIndex]; objectIndex = Object_GetIndex(&play->objectCtx, sObjectBankIndices[itemIndex]); if (objectIndex < 0) { Actor_Kill(&this->actor); @@ -74,14 +74,14 @@ void func_80A4FB68(DemoGetitem* this, PlayState* play2) { PlayState* play = play2; u16 sp22 = (play->gameplayFrames * 1000) & 0xFFFF; - if (Cutscene_CheckActorAction(play, this->csAction)) { - if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action != 4) { + if (Cutscene_IsCueInChannel(play, this->cueType)) { + if (play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id != 4) { this->actor.shape.yOffset = 0.0f; } - switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action) { + switch (play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id) { case 2: this->actor.draw = DemoGetitem_Draw; - Cutscene_ActorTranslate(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csAction)); + Cutscene_ActorTranslate(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); this->actor.shape.rot.y += 0x3E8; break; @@ -91,7 +91,7 @@ void func_80A4FB68(DemoGetitem* this, PlayState* play2) { case 4: this->actor.draw = DemoGetitem_Draw; - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csAction)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); this->actor.shape.yOffset = Math_SinS(sp22) * 15.0f; break; diff --git a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.h b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.h index 91c7dc97e..ca00f6048 100644 --- a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.h +++ b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.h @@ -12,7 +12,7 @@ typedef void (*DemoGetitemActionFunc)(struct DemoGetitem*, PlayState*); typedef struct DemoGetitem { /* 0x000 */ Actor actor; /* 0x144 */ s16 item; - /* 0x146 */ u16 csAction; + /* 0x146 */ u16 cueType; /* 0x148 */ s8 objectIndex; /* 0x14C */ DemoGetitemActionFunc actionFunc; } DemoGetitem; // size = 0x150 diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index c1303efab..629f49398 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -444,7 +444,8 @@ void DemoKankyo_Init(Actor* thisx, PlayState* play) { for (i = 0; i < ARRAY_COUNT(this->effects); i++) { this->effects[i].state = DEMO_KANKYO_STATE_INIT; } // clang-format on - if (1) {}; + //! FAKE: + if (1) {} switch (this->actor.params) { case DEMO_KANKYO_TYPE_LOSTWOODS: @@ -571,7 +572,7 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, PlayState* play2) { } Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZF(DEGF_TO_RADF(play->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_RotateZF(DEG_TO_RAD(play->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -643,7 +644,7 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, PlayState* play2) { Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZF(DEGF_TO_RADF(play->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_RotateZF(DEG_TO_RAD(play->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c index 60f9e898b..111ce284f 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c @@ -68,7 +68,7 @@ void DemoSyoten_Init(Actor* thisx, PlayState* play) { this->unk_3E6 = 0; this->unk_3DC = NULL; this->unk_3E0 = NULL; - this->unk_3F2 = 0; + this->cueId = 0; this->unk_3D8 = 1.0f; switch (DEMOSYOTEN_GET_F(&this->actor)) { @@ -81,7 +81,7 @@ void DemoSyoten_Init(Actor* thisx, PlayState* play) { this->actor.child = Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EFF_DUST, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, 0); - this->unk_3F0 = 0x215; + this->cueType = CS_CMD_ACTOR_CUE_533; Actor_SetScale(&this->actor, 0.05f); break; @@ -91,14 +91,14 @@ void DemoSyoten_Init(Actor* thisx, PlayState* play) { this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_001448); this->unk_3E4 |= 1; this->actionFunc = func_80C16BD4; - this->unk_3F0 = 0x215; + this->cueType = CS_CMD_ACTOR_CUE_533; Actor_SetScale(&this->actor, 0.05f); break; case DEMOSYOTEN_F_2: this->unk_3DC = object_syoten_DL_001730; this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_0018B8); - this->unk_3F0 = 0x216; + this->cueType = CS_CMD_ACTOR_CUE_534; this->actionFunc = func_80C16DD4; this->unk_3E4 |= 2; Actor_SetScale(&this->actor, 4.0f); @@ -107,7 +107,7 @@ void DemoSyoten_Init(Actor* thisx, PlayState* play) { case DEMOSYOTEN_F_3: this->unk_3DC = object_syoten_DL_001DD0; this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_002B98); - this->unk_3F0 = 0x218; + this->cueType = CS_CMD_ACTOR_CUE_536; this->unk_3E4 |= 8; this->actionFunc = func_80C16EAC; Actor_SetScale(&this->actor, 0.5f); @@ -118,7 +118,7 @@ void DemoSyoten_Init(Actor* thisx, PlayState* play) { this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_002B88); this->unk_3E4 |= 2; this->actionFunc = func_80C17008; - this->unk_3F0 = 0x217; + this->cueType = CS_CMD_ACTOR_CUE_535; this->unk_3E4 |= 1; this->unk_3E4 |= 8; this->actor.draw = func_80C17690; @@ -219,20 +219,20 @@ void func_80C16A64(DemoSyoten* this, PlayState* play) { } void func_80C16A74(DemoSyoten* this, PlayState* play) { - u16 temp_a0; + u16 cueId; func_80183DE0(&this->unk_144); - if (Cutscene_CheckActorAction(play, this->unk_3F0)) { - if ((play->csCtx.frames >= 160) && (play->csCtx.frames < 322)) { + if (Cutscene_IsCueInChannel(play, this->cueType)) { + if ((play->csCtx.curFrame >= 160) && (play->csCtx.curFrame < 322)) { func_800B9010(&this->actor, NA_SE_EV_IKANA_SOUL_LV - SFX_FLAG); - } else if (play->csCtx.frames == 322) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_IKANA_SOUL_TRANSFORM); + } else if (play->csCtx.curFrame == 322) { + Actor_PlaySfx(&this->actor, NA_SE_EV_IKANA_SOUL_TRANSFORM); } - temp_a0 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_3F0)]->action; - if (this->unk_3F2 != temp_a0) { - this->unk_3F2 = temp_a0; - switch (temp_a0) { + cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; + if (this->cueId != cueId) { + this->cueId = cueId; + switch (cueId) { case 1: this->actor.draw = NULL; break; @@ -251,7 +251,7 @@ void func_80C16A74(DemoSyoten* this, PlayState* play) { } } - if (temp_a0 == 3) { + if (cueId == 3) { if (this->unk_3D8 > 0.0125f) { this->unk_3D8 -= 0.0125f; if (this->actor.child != NULL) { @@ -271,13 +271,13 @@ void func_80C16A74(DemoSyoten* this, PlayState* play) { void func_80C16BD4(DemoSyoten* this, PlayState* play) { s32 pad; - u16 temp_a0; + u16 cueId; - if (Cutscene_CheckActorAction(play, this->unk_3F0)) { - temp_a0 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_3F0)]->action; - if (this->unk_3F2 != temp_a0) { - this->unk_3F2 = temp_a0; - switch (temp_a0) { + if (Cutscene_IsCueInChannel(play, this->cueType)) { + cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; + if (this->cueId != cueId) { + this->cueId = cueId; + switch (cueId) { default: this->actor.draw = NULL; break; @@ -304,7 +304,7 @@ void func_80C16BD4(DemoSyoten* this, PlayState* play) { } } - switch (temp_a0) { + switch (cueId) { case 3: if (this->actor.scale.x < 0.05f) { this->actor.scale.x += 0.000625f; @@ -313,8 +313,8 @@ void func_80C16BD4(DemoSyoten* this, PlayState* play) { break; case 4: - this->actor.speedXZ = - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_3F0)]->urot.z * 0.005493164f; + this->actor.speed = + play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->rot.z * 0.005493164f; if (this->unk_3EC < this->unk_3E8->count) { if (func_80C16818(this)) { this->unk_3EC++; @@ -330,13 +330,13 @@ void func_80C16BD4(DemoSyoten* this, PlayState* play) { void func_80C16DD4(DemoSyoten* this, PlayState* play) { s32 pad; - u16 temp_a0; + u16 cueId; - if (Cutscene_CheckActorAction(play, this->unk_3F0)) { - temp_a0 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_3F0)]->action; - if (this->unk_3F2 != temp_a0) { - this->unk_3F2 = temp_a0; - switch (temp_a0) { + if (Cutscene_IsCueInChannel(play, this->cueType)) { + cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; + if (this->cueId != cueId) { + this->cueId = cueId; + switch (cueId) { case 1: this->actor.draw = NULL; break; @@ -344,12 +344,12 @@ void func_80C16DD4(DemoSyoten* this, PlayState* play) { case 2: this->actor.draw = DemoSyoten_Draw; this->unk_3E6 = -6; - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_DM_FLYING_GOD_DASH); + Actor_PlaySfx(&this->actor, NA_SE_IT_DM_FLYING_GOD_DASH); break; } } - if ((temp_a0 == 2) && (this->unk_3E6 < 40)) { + if ((cueId == 2) && (this->unk_3E6 < 40)) { this->unk_3E6++; } } else { @@ -359,13 +359,13 @@ void func_80C16DD4(DemoSyoten* this, PlayState* play) { void func_80C16EAC(DemoSyoten* this, PlayState* play) { s32 pad; - u16 temp_a0; + u16 cueId; - if (Cutscene_CheckActorAction(play, this->unk_3F0)) { - temp_a0 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_3F0)]->action; - if (this->unk_3F2 != temp_a0) { - this->unk_3F2 = temp_a0; - switch (temp_a0) { + if (Cutscene_IsCueInChannel(play, this->cueType)) { + cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; + if (this->cueId != cueId) { + this->cueId = cueId; + switch (cueId) { case 1: this->actor.draw = NULL; this->unk_3D8 = 0.0f; @@ -378,7 +378,7 @@ void func_80C16EAC(DemoSyoten* this, PlayState* play) { } } - if (temp_a0 == 2) { + if (cueId == 2) { if (this->actor.scale.x < 8.0f) { this->actor.scale.x += 0.1875f; } @@ -401,13 +401,13 @@ void func_80C16EAC(DemoSyoten* this, PlayState* play) { } void func_80C17008(DemoSyoten* this, PlayState* play) { - u16 temp_a0; + u16 cueId; - if (Cutscene_CheckActorAction(play, this->unk_3F0)) { - temp_a0 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_3F0)]->action; - if (this->unk_3F2 != temp_a0) { - this->unk_3F2 = temp_a0; - switch (temp_a0) { + if (Cutscene_IsCueInChannel(play, this->cueType)) { + cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; + if (this->cueId != cueId) { + this->cueId = cueId; + switch (cueId) { case 1: this->actor.draw = NULL; break; @@ -419,7 +419,7 @@ void func_80C17008(DemoSyoten* this, PlayState* play) { } } - if ((temp_a0 == 2) && (this->unk_3E6 < 15)) { + if ((cueId == 2) && (this->unk_3E6 < 15)) { this->unk_3E6++; } } else { diff --git a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h index 7b60ae951..1997a2bc5 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h @@ -32,8 +32,8 @@ typedef struct DemoSyoten { /* 0x3E6 */ s16 unk_3E6; /* 0x3E8 */ Path* unk_3E8; /* 0x3EC */ s32 unk_3EC; - /* 0x3F0 */ u16 unk_3F0; - /* 0x3F2 */ u16 unk_3F2; + /* 0x3F0 */ u16 cueType; + /* 0x3F2 */ u16 cueId; /* 0x3F4 */ DemoSyotenActionFunc actionFunc; } DemoSyoten; // size = 0x3F8 diff --git a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c index 1a1f4ae22..12815a044 100644 --- a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c +++ b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c @@ -124,23 +124,23 @@ Actor* func_80C1D78C(PlayState* play) { void func_80C1D7FC(DmAh* this, PlayState* play) { s32 D_80C1DE00[] = { 0, 0, 0, 0, 0 }; - u16 csAction; - s32 actionIndex; + u16 cueId; + s32 cueChannel; - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { if (!this->unk_29C) { - this->action = 0xFF; + this->cueId = 255; this->unk_29C = true; this->animationIndex2 = this->animationIndex; } - if (Cutscene_CheckActorAction(play, 0x232)) { - actionIndex = Cutscene_GetActorActionIndex(play, 0x232); - csAction = play->csCtx.actorActions[actionIndex]->action; - if (this->action != (u8)csAction) { - this->action = csAction; - func_80C1D410(this, D_80C1DE00[csAction]); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_562)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_562); + cueId = play->csCtx.actorCues[cueChannel]->id; + if (this->cueId != (u8)cueId) { + this->cueId = cueId; + func_80C1D410(this, D_80C1DE00[cueId]); } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } } else if (this->unk_29C) { this->unk_29C = false; @@ -181,7 +181,7 @@ void DmAh_Update(Actor* thisx, PlayState* play) { func_80C1D6E0(this, play); SkelAnime_Update(&this->skelAnime); func_80C1D458(this); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } static Vec3f D_80C1DE14 = { 1000.0f, 0.0f, 0.0f }; diff --git a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.h b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.h index df179c6f6..b1e16f6e0 100644 --- a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.h +++ b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.h @@ -19,7 +19,7 @@ typedef struct DmAh { /* 0x1B0 */ Vec3s morphTable[OBJECT_AH_LIMB_MAX]; /* 0x216 */ Vec3s jointTable[OBJECT_AH_LIMB_MAX]; /* 0x27C */ u16 unk_27C; - /* 0x27E */ u8 action; + /* 0x27E */ u8 cueId; /* 0x280 */ Actor* unk_280; /* 0x284 */ s16 unk_284; /* 0x286 */ s16 unk_286; diff --git a/src/overlays/actors/ovl_Dm_Al/z_dm_al.c b/src/overlays/actors/ovl_Dm_Al/z_dm_al.c index f81713731..43ca006f2 100644 --- a/src/overlays/actors/ovl_Dm_Al/z_dm_al.c +++ b/src/overlays/actors/ovl_Dm_Al/z_dm_al.c @@ -48,23 +48,23 @@ s32 DmAl_ChangeAnim(DmAl* this, s32 animIndex) { void func_80C1BDD8(DmAl* this, PlayState* play) { s32 D_80C1C280[] = { 0, 0, 0, 0, 0 }; - u16 csAction; - s32 actionIndex; + u16 cueId; + s32 cueChannel; - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { if (!this->unk_45C) { - this->action = 0xFF; + this->cueId = 255; this->unk_45C = true; this->animIndex2 = this->animIndex; } - if (Cutscene_CheckActorAction(play, 0x232)) { - actionIndex = Cutscene_GetActorActionIndex(play, 0x232); - csAction = play->csCtx.actorActions[actionIndex]->action; - if (this->action != (u8)csAction) { - this->action = csAction; - DmAl_ChangeAnim(this, D_80C1C280[csAction]); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_562)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_562); + cueId = play->csCtx.actorCues[cueChannel]->id; + if (this->cueId != (u8)cueId) { + this->cueId = cueId; + DmAl_ChangeAnim(this, D_80C1C280[cueId]); } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } } else if (this->unk_45C) { this->unk_45C = false; @@ -93,7 +93,7 @@ void DmAl_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } s32 DmAl_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* rot, Vec3s* pos, Actor* thisx) { diff --git a/src/overlays/actors/ovl_Dm_Al/z_dm_al.h b/src/overlays/actors/ovl_Dm_Al/z_dm_al.h index 57e462de1..4114b9f9c 100644 --- a/src/overlays/actors/ovl_Dm_Al/z_dm_al.h +++ b/src/overlays/actors/ovl_Dm_Al/z_dm_al.h @@ -15,7 +15,7 @@ typedef struct DmAl { /* 0x18C */ MtxF shawlMatrices[6]; /* 0x30C */ Vec3s jointTable[MADAME_AROMA_LIMB_MAX]; /* 0x3AE */ Vec3s morphTable[MADAME_AROMA_LIMB_MAX]; - /* 0x450 */ u8 action; + /* 0x450 */ u8 cueId; /* 0x454 */ s32 animIndex; /* 0x458 */ s32 animIndex2; /* 0x45C */ s32 unk_45C; diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.c b/src/overlays/actors/ovl_Dm_An/z_dm_an.c index d536425b0..2d474d111 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -195,28 +195,28 @@ void func_80C1C958(DmAn* this, PlayState* play) { void func_80C1CAB0(DmAn* this, PlayState* play) { s32 sp28[] = { 0, 0, 12, 2, 4, 6, 8, 10, 11, 3 }; - u16 action; - s32 sp20; + u16 cueId; + s32 cueChannel; - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { if (this->unk_2D0 == 0) { - this->unk_2B0 = 255; + this->cueId = 255; this->unk_2D0 = 1; this->unk_2D4 = 0; this->unk_2CC = this->unk_2C8; } - if (Cutscene_CheckActorAction(play, 0x22D)) { - sp20 = Cutscene_GetActorActionIndex(play, 0x22D); - action = play->csCtx.actorActions[sp20]->action; + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_557)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_557); + cueId = play->csCtx.actorCues[cueChannel]->id; - if (this->unk_2B0 != (action & 0xFF)) { - this->unk_2B0 = action; + if (this->cueId != (u8)cueId) { + this->cueId = cueId; this->unk_2D4 = 1; - func_80C1C4D8(this, play, sp28[action]); + func_80C1C4D8(this, play, sp28[cueId]); } - switch (this->unk_2B0) { + switch (this->cueId) { case 2: case 4: case 5: @@ -230,7 +230,7 @@ void func_80C1CAB0(DmAn* this, PlayState* play) { } break; } - Cutscene_ActorTranslateAndYaw(&this->actor, play, sp20); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } } else if (this->unk_2D0 != 0) { this->unk_2D0 = 0; @@ -264,7 +264,7 @@ void DmAn_Update(Actor* thisx, PlayState* play) { func_80C1C410(this, play); func_80C1C5B4(this); } - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } Vec3f D_80C1D2C8 = { 450.0f, 700.0f, -760.0f }; diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.h b/src/overlays/actors/ovl_Dm_An/z_dm_an.h index 2001a8ba6..6908e9342 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.h +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.h @@ -21,7 +21,7 @@ typedef struct DmAn { /* 0x2AC */ s8 unk_2AC; /* 0x2AD */ s8 unk_2AD; /* 0x2AE */ u16 unk_2AE; - /* 0x2B0 */ u8 unk_2B0; + /* 0x2B0 */ u8 cueId; /* 0x2B4 */ Actor* unk_2B4; /* 0x2B8 */ s16 unk_2B8; /* 0x2BA */ s16 unk_2BA; diff --git a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c index b9c4cb33c..9e5ffed89 100644 --- a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c +++ b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c @@ -56,7 +56,7 @@ void DmBal_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); SkelAnime_InitFlex(play, &this->skelAnime, &object_bal_Skel_00A6D0, &object_bal_Anim_0005FC, this->jointTable, this->morphTable, OBJECT_BAL_LIMB_MAX); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); this->timer = 60; this->eyeIndex = 0; this->keepEyesShut = false; @@ -74,15 +74,15 @@ void DmBal_DoNothing(DmBal* this, PlayState* play) { } void func_80C1EAE8(DmBal* this, PlayState* play) { - static u16 D_80C1F2C0 = 0x63; - s32 actionIndex; + static u16 sCueId = 99; + s32 cueChannel; - if (Cutscene_CheckActorAction(play, 0x238)) { - actionIndex = Cutscene_GetActorActionIndex(play, 0x238); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_568)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_568); - if (D_80C1F2C0 != play->csCtx.actorActions[actionIndex]->action) { - D_80C1F2C0 = play->csCtx.actorActions[actionIndex]->action; - switch (play->csCtx.actorActions[actionIndex]->action) { + if (sCueId != play->csCtx.actorCues[cueChannel]->id) { + sCueId = play->csCtx.actorCues[cueChannel]->id; + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: this->keepEyesShut = false; this->eyeIndex = 0; @@ -96,7 +96,7 @@ void func_80C1EAE8(DmBal* this, PlayState* play) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 13); break; } - } else if (D_80C1F2C0 == 3) { + } else if (sCueId == 3) { if (Animation_OnFrame(&this->skelAnime, 0.0f)) { this->keepEyesShut = true; } else if (Animation_OnFrame(&this->skelAnime, 29.0f)) { @@ -104,12 +104,12 @@ void func_80C1EAE8(DmBal* this, PlayState* play) { this->eyeIndex = 0; } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); this->actor.home.pos = this->actor.world.pos; } else { this->keepEyesShut = false; this->eyeIndex = 0; - D_80C1F2C0 = 0x63; + sCueId = 99; } } diff --git a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c index 43cc62603..8657a9dc9 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -150,26 +150,26 @@ void func_80AA5580(SkelAnime* skelAnime, AnimationInfo* animation, u16 idx) { void func_80AA561C(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (play->csCtx.frames + 20) { + switch (play->csCtx.curFrame + 20) { case 503: case 926: case 979: case 1222: case 1682: case 2194: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); break; case 1858: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EV_FAIRY_ATTACK); break; case 2043: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + Actor_PlaySfx(&this->actor, NA_SE_EV_FAIRY_SURPRISE); break; } } else { - switch (play->csCtx.frames + 20) { + switch (play->csCtx.curFrame + 20) { case 503: case 926: case 979: @@ -177,25 +177,25 @@ void func_80AA561C(DmChar00* this, PlayState* play) { case 1687: case 2194: case 2210: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); break; case 2043: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONDO_SURPRISE); + Actor_PlaySfx(&this->actor, NA_SE_EV_MONDO_SURPRISE); break; } } } void func_80AA5720(DmChar00* this, PlayState* play) { - if ((DMCHAR00_GET(&this->actor) == DMCHAR00_0) && (play->csCtx.frames == 505)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SPOT_LIGHT_OPEN); + if ((DMCHAR00_GET(&this->actor) == DMCHAR00_0) && (play->csCtx.curFrame == 505)) { + Actor_PlaySfx(&this->actor, NA_SE_EV_SPOT_LIGHT_OPEN); } } void func_80AA575C(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 474: case 489: case 495: @@ -207,51 +207,51 @@ void func_80AA575C(DmChar00* this, PlayState* play) { case 877: case 882: case 887: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EV_FAIRY_ATTACK); break; case 520: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_SPIT); + Actor_PlaySfx(&this->actor, NA_SE_EV_BELL_SPIT); break; case 774: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + Actor_PlaySfx(&this->actor, NA_SE_EV_FAIRY_SURPRISE); break; case 904: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_SIGH); + Actor_PlaySfx(&this->actor, NA_SE_EV_BELL_SIGH); break; case 813: case 972: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_BRAKE); + Actor_PlaySfx(&this->actor, NA_SE_EV_BELL_BRAKE); break; } - } else if (play->csCtx.frames == 660) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONDO_SURPRISE); + } else if (play->csCtx.curFrame == 660) { + Actor_PlaySfx(&this->actor, NA_SE_EV_MONDO_SURPRISE); } } void func_80AA5890(DmChar00* this, PlayState* play) { - if ((DMCHAR00_GET(&this->actor) == DMCHAR00_0) && (play->csCtx.frames == 20)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + if ((DMCHAR00_GET(&this->actor) == DMCHAR00_0) && (play->csCtx.curFrame == 20)) { + Actor_PlaySfx(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } } void func_80AA58CC(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - if (play->csCtx.frames == 568) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + if (play->csCtx.curFrame == 568) { + Actor_PlaySfx(&this->actor, NA_SE_EV_FAIRY_SURPRISE); } } else { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 375: case 479: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); break; case 534: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EV_FAIRY_ATTACK); break; } } @@ -262,18 +262,18 @@ void func_80AA5950(DmChar00* this, PlayState* play) { void func_80AA5960(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - if (play->csCtx.frames == 280) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + if (play->csCtx.curFrame == 280) { + Actor_PlaySfx(&this->actor, NA_SE_EV_FAIRY_SURPRISE); } } else { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 87: case 190: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); break; case 244: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EV_FAIRY_ATTACK); break; } } @@ -281,114 +281,114 @@ void func_80AA5960(DmChar00* this, PlayState* play) { void func_80AA59E4(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 125: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); break; case 1832: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_WHITE_OUT_INTO_MOON); + Actor_PlaySfx(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_SY_WHITE_OUT_INTO_MOON); break; } - } else if (play->csCtx.frames == 125) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + } else if (play->csCtx.curFrame == 125) { + Actor_PlaySfx(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); } } void func_80AA5A6C(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 44: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); break; case 891: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_WHITE_OUT_INTO_MOON); + Actor_PlaySfx(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_SY_WHITE_OUT_INTO_MOON); break; } - } else if (play->csCtx.frames == 44) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + } else if (play->csCtx.curFrame == 44) { + Actor_PlaySfx(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); } } void func_80AA5AF4(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 352: case 401: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); break; case 440: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); break; case 550: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_BRAKE); + Actor_PlaySfx(&this->actor, NA_SE_EV_BELL_BRAKE); break; } } else { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 362: case 401: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); break; case 454: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); break; } - if ((play->csCtx.frames >= 500) && (play->csCtx.frames < 602)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SHIVER - SFX_FLAG); + if ((play->csCtx.curFrame >= 500) && (play->csCtx.curFrame < 602)) { + Actor_PlaySfx(&this->actor, NA_SE_EV_FAIRY_SHIVER - SFX_FLAG); } } } void func_80AA5BF8(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 762: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_SHOT_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_WHITE_FAIRY_SHOT_DASH); break; case 797: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); break; } } else { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 762: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_SHOT_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_BLACK_FAIRY_SHOT_DASH); break; case 797: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); break; } } if ((this->unk_261 == 53) && Animation_OnFrame(&this->skelAnime, 16.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); } } void func_80AA5CD4(DmChar00* this, PlayState* play) { - if ((DMCHAR00_GET(&this->actor) != DMCHAR00_0) && (play->csCtx.frames == 467)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + if ((DMCHAR00_GET(&this->actor) != DMCHAR00_0) && (play->csCtx.curFrame == 467)) { + Actor_PlaySfx(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); } } void func_80AA5D10(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 8: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + Actor_PlaySfx(&this->actor, NA_SE_EV_FAIRY_SURPRISE); break; case 130: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); + Actor_PlaySfx(&this->actor, NA_SE_EV_NAVY_VANISH); break; } } @@ -396,14 +396,14 @@ void func_80AA5D10(DmChar00* this, PlayState* play) { void func_80AA5D6C(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 2: case 166: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); break; case 31: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + Actor_PlaySfx(&this->actor, NA_SE_EV_FAIRY_SURPRISE); break; } } @@ -411,15 +411,15 @@ void func_80AA5D6C(DmChar00* this, PlayState* play) { void func_80AA5DC8(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 233: case 415: case 593: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); break; case 130: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); + Actor_PlaySfx(&this->actor, NA_SE_EV_NAVY_VANISH); break; } } @@ -427,28 +427,28 @@ void func_80AA5DC8(DmChar00* this, PlayState* play) { void func_80AA5E2C(DmChar00* this, PlayState* play) { if (DMCHAR00_GET(&this->actor) == DMCHAR00_1) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 32: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); break; case 42: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); break; case 192: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_BRAKE); + Actor_PlaySfx(&this->actor, NA_SE_EV_BELL_BRAKE); break; case 215: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WEED); + Actor_PlaySfx(&this->actor, NA_SE_EV_DIVE_INTO_WEED); break; } } } void func_80AA5EBC(DmChar00* this, PlayState* play) { - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { switch (play->sceneId) { case SCENE_LOST_WOODS: if (gSaveContext.sceneLayer == 1) { @@ -458,11 +458,11 @@ void func_80AA5EBC(DmChar00* this, PlayState* play) { case SCENE_OPENINGDAN: if (gSaveContext.sceneLayer == 0) { - if (play->csCtx.currentCsIndex == 0) { + if (play->csCtx.scriptIndex == 0) { func_80AA5720(this, play); - } else if (play->csCtx.currentCsIndex == 1) { + } else if (play->csCtx.scriptIndex == 1) { func_80AA575C(this, play); - } else if (play->csCtx.currentCsIndex == 2) { + } else if (play->csCtx.scriptIndex == 2) { func_80AA5890(this, play); } } @@ -470,17 +470,17 @@ void func_80AA5EBC(DmChar00* this, PlayState* play) { case SCENE_OKUJOU: if (gSaveContext.sceneLayer == 0) { - if (play->csCtx.currentCsIndex == 0) { + if (play->csCtx.scriptIndex == 0) { func_80AA58CC(this, play); - } else if (play->csCtx.currentCsIndex == 1) { + } else if (play->csCtx.scriptIndex == 1) { func_80AA5950(this, play); - } else if (play->csCtx.currentCsIndex == 2) { + } else if (play->csCtx.scriptIndex == 2) { func_80AA5960(this, play); } } else if (gSaveContext.sceneLayer == 2) { - if (play->csCtx.currentCsIndex == 0) { + if (play->csCtx.scriptIndex == 0) { func_80AA59E4(this, play); - } else if (play->csCtx.currentCsIndex == 1) { + } else if (play->csCtx.scriptIndex == 1) { func_80AA5A6C(this, play); } } @@ -488,34 +488,34 @@ void func_80AA5EBC(DmChar00* this, PlayState* play) { case SCENE_00KEIKOKU: if (gSaveContext.sceneLayer == 3) { - if (play->csCtx.currentCsIndex == 0) { + if (play->csCtx.scriptIndex == 0) { func_80AA5AF4(this, play); - } else if (play->csCtx.currentCsIndex == 2) { + } else if (play->csCtx.scriptIndex == 2) { func_80AA5E2C(this, play); } } else if (gSaveContext.sceneLayer == 7) { - if (play->csCtx.currentCsIndex == 0) { + if (play->csCtx.scriptIndex == 0) { func_80AA5BF8(this, play); - } else if (play->csCtx.currentCsIndex == 1) { + } else if (play->csCtx.scriptIndex == 1) { func_80AA5CD4(this, play); } } break; case SCENE_MITURIN: - if ((gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 1)) { + if ((gSaveContext.sceneLayer == 0) && (play->csCtx.scriptIndex == 1)) { func_80AA5DC8(this, play); } break; case SCENE_INSIDETOWER: - if ((gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 0)) { + if ((gSaveContext.sceneLayer == 0) && (play->csCtx.scriptIndex == 0)) { func_80AA5D10(this, play); } break; case SCENE_PIRATE: - if ((gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 0)) { + if ((gSaveContext.sceneLayer == 0) && (play->csCtx.scriptIndex == 0)) { func_80AA5D6C(this, play); } break; @@ -535,7 +535,7 @@ void DmChar00_Init(Actor* thisx, PlayState* play) { this->unk_250 = D_80AA77D8[DMCHAR00_GET(thisx)]; thisx->targetArrowOffset = 3000.0f; - this->unk_260 = 99; + this->cueId = 99; this->unk_262 = DMCHAR00_GET_F800(thisx); ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 24.0f); @@ -551,18 +551,18 @@ void DmChar00_Destroy(Actor* thisx, PlayState* play) { } void func_80AA62FC(DmChar00* this, PlayState* play) { - u16 sp26 = DMCHAR00_GET(&this->actor) + 113; - s32 temp_v0; + u16 cueType = CS_CMD_ACTOR_CUE_113 + DMCHAR00_GET(&this->actor); + s32 cueChannel; s32 pad; - if (Cutscene_CheckActorAction(play, sp26)) { - temp_v0 = Cutscene_GetActorActionIndex(play, sp26); + if (Cutscene_IsCueInChannel(play, cueType)) { + cueChannel = Cutscene_GetCueChannel(play, cueType); - if (play->csCtx.frames == play->csCtx.actorActions[temp_v0]->startFrame) { - if (this->unk_260 != play->csCtx.actorActions[temp_v0]->action) { - this->unk_260 = play->csCtx.actorActions[temp_v0]->action; + if (play->csCtx.curFrame == play->csCtx.actorCues[cueChannel]->startFrame) { + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; - switch (play->csCtx.actorActions[temp_v0]->action) { + switch (play->csCtx.actorCues[cueChannel]->id) { case 0x1: this->unk_261 = 0; break; @@ -786,9 +786,9 @@ void func_80AA62FC(DmChar00* this, PlayState* play) { func_80AA5580(&this->skelAnime, &sAnimationInfo[this->unk_261], 0); } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } else { - this->unk_260 = 99; + this->cueId = 99; } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -853,7 +853,7 @@ void func_80AA62FC(DmChar00* this, PlayState* play) { void func_80AA67F8(DmChar00* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((play->csCtx.state == 0) && (gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 1)) { + if ((play->csCtx.state == CS_STATE_IDLE) && (gSaveContext.sceneLayer == 0) && (play->csCtx.scriptIndex == 1)) { if (this->unk_261 != 42) { this->unk_261 = 42; func_80AA5580(&this->skelAnime, &sAnimationInfo[this->unk_261], 0); @@ -914,9 +914,9 @@ void DmChar00_Draw(Actor* thisx, PlayState* play2) { s32 pad; Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, 4 * sizeof(Gfx)); - if ((play->csCtx.state == 0) && + if ((play->csCtx.state == CS_STATE_IDLE) && ((play->sceneId != SCENE_OPENINGDAN) || (gSaveContext.sceneLayer != 0) || (play->roomCtx.curRoom.num != 0) || - (play->csCtx.currentCsIndex != 1) || (DMCHAR00_GET(&this->actor) != DMCHAR00_0))) { + (play->csCtx.scriptIndex != 1) || (DMCHAR00_GET(&this->actor) != DMCHAR00_0))) { return; } diff --git a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h index 62ee0cb40..b4679647b 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h @@ -23,7 +23,7 @@ typedef struct DmChar00 { /* 0x23C */ DmChar00ActionFunc actionFunc; /* 0x240 */ Color_RGBAf unk_240; /* 0x250 */ Color_RGBAf unk_250; - /* 0x260 */ u8 unk_260; + /* 0x260 */ u8 cueId; /* 0x261 */ u8 unk_261; /* 0x262 */ u16 unk_262; } DmChar00; // size = 0x264 diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c index 069d829c1..7b700f4eb 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -3,7 +3,7 @@ * Overlay: ovl_Dm_Char01 * Description: Woodfall scene objects (temple, water, walls, etc) */ - +#include "prevent_bss_reordering.h" #include "z_dm_char01.h" #include "objects/object_mtoride/object_mtoride.h" #include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h" @@ -67,7 +67,7 @@ void DmChar01_Init(Actor* thisx, PlayState* play) { switch (DMCHAR01_GET(&this->dyna.actor)) { case DMCHAR01_0: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE)) { this->unk_34C = 2; this->actionFunc = func_80AA8F1C; break; @@ -97,7 +97,7 @@ void DmChar01_Init(Actor* thisx, PlayState* play) { break; case DMCHAR01_1: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02) || (gSaveContext.sceneLayer == 1)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE) || (gSaveContext.sceneLayer == 1)) { this->unk_34C = 1; this->actionFunc = func_80AA8F1C; } else { @@ -134,7 +134,7 @@ void DmChar01_Init(Actor* thisx, PlayState* play) { DynaPolyActor_LoadMesh(play, &this->dyna, &gWoodfallSceneryTempleRampAndPlatformCol); this->unk_34D = true; - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE)) { this->actionFunc = func_80AA9020; this->dyna.actor.world.pos.y -= 120.0f; } else { @@ -187,21 +187,22 @@ void func_80AA8698(DmChar01* this, PlayState* play) { } void func_80AA884C(DmChar01* this, PlayState* play) { - s16 sp1E = this->dyna.actor.cutscene; + s16 csId = this->dyna.actor.csId; - if (ActorCutscene_GetCanPlayNext(sp1E)) { - ActorCutscene_Start(sp1E, &this->dyna.actor); + if (CutsceneManager_IsNext(csId)) { + CutsceneManager_Start(csId, &this->dyna.actor); this->actionFunc = func_80AA88A8; } else { - ActorCutscene_SetIntentToPlay(sp1E); + CutsceneManager_Queue(csId); } } void func_80AA88A8(DmChar01* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 135)) { - if (play->csCtx.frames == play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 135)]->startFrame) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_135)) { + if (play->csCtx.curFrame == + play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_135)]->startFrame) { D_80AAAE24 = 1; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FORT_RISING); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_FORT_RISING); } } else { D_80AAAE24 = 0; @@ -277,7 +278,7 @@ void func_80AA8C28(DmChar01* this, PlayState* play) { switch (this->unk_346) { case 0: - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WATER_PURIFICATION); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_WATER_PURIFICATION); D_80AAAE22 = -2200; D_80AAAE20 = 100; this->unk_346++; @@ -344,11 +345,11 @@ void func_80AA8F2C(DmChar01* this, PlayState* play) { } void func_80AA9020(DmChar01* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 135)) { - CsCmdActorAction* temp_v1 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 135)]; + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_135)) { + CsCmdActorCue* cue = play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_135)]; - if ((temp_v1->startFrame == play->csCtx.frames) && (temp_v1->action == 2)) { - SET_WEEKEVENTREG(WEEKEVENTREG_20_02); + if ((cue->startFrame == play->csCtx.curFrame) && (cue->id == 2)) { + SET_WEEKEVENTREG(WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE); this->actionFunc = func_80AA90AC; } } @@ -373,17 +374,17 @@ void DmChar01_Update(Actor* thisx, PlayState* play2) { Player* player = GET_PLAYER(play); if (player->actor.world.pos.y > 5.0f) { - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } else { - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } } if (DMCHAR01_GET(&this->dyna.actor) == DMCHAR01_2) { if (this->dyna.actor.xzDistToPlayer > 600.0f) { - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } else { - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } } } diff --git a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c index b618281c2..ec1e12a8f 100644 --- a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c +++ b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c @@ -61,21 +61,21 @@ void DmChar02_ChangeAnim(SkelAnime* skelAnime, AnimationInfo* animationInfo, u16 } void DmChar02_PlaySfxForDroppingOcarinaCutscene(DmChar02* this, PlayState* play) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 95: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OCARINA_BOUND_0); + Actor_PlaySfx(&this->actor, NA_SE_EV_OCARINA_BOUND_0); break; case 101: case 105: case 112: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OCARINA_BOUND_1); + Actor_PlaySfx(&this->actor, NA_SE_EV_OCARINA_BOUND_1); break; } } void DmChar02_PlaySfxForCutscenes(DmChar02* this, PlayState* play) { - if ((play->csCtx.state != 0) && (play->sceneId == SCENE_OKUJOU) && (play->csCtx.currentCsIndex == 1)) { + if ((play->csCtx.state != CS_STATE_IDLE) && (play->sceneId == SCENE_OKUJOU) && (play->csCtx.scriptIndex == 1)) { DmChar02_PlaySfxForDroppingOcarinaCutscene(this, play); } } @@ -83,7 +83,7 @@ void DmChar02_PlaySfxForCutscenes(DmChar02* this, PlayState* play) { void DmChar02_Init(Actor* thisx, PlayState* play) { DmChar02* this = THIS; - if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] == ITEM_NONE) { this->animIndex = DMCHAR02_ANIM_HIT_GROUND; this->actor.targetArrowOffset = 3000.0f; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); @@ -101,12 +101,12 @@ void DmChar02_Destroy(Actor* thisx, PlayState* play) { void DmChar02_PerformCutsceneActions(DmChar02* this, PlayState* play) { u8 shouldChangeAnimation = true; - s32 actionIndex; + s32 cueChannel; - if (Cutscene_CheckActorAction(play, 0x83)) { - actionIndex = Cutscene_GetActorActionIndex(play, 0x83); - if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { - switch (play->csCtx.actorActions[actionIndex]->action) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_131)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_131); + if (play->csCtx.curFrame == play->csCtx.actorCues[cueChannel]->startFrame) { + switch (play->csCtx.actorCues[cueChannel]->id) { default: this->animIndex = DMCHAR02_ANIM_HIT_GROUND; shouldChangeAnimation = false; @@ -130,7 +130,7 @@ void DmChar02_PerformCutsceneActions(DmChar02* this, PlayState* play) { } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -148,7 +148,7 @@ void DmChar02_Update(Actor* thisx, PlayState* play) { this->unk_2F0 = this->unk_2F0; this->actionFunc(this, play); if (!Actor_HasParent(&this->actor, play)) { - Actor_PickUp(&this->actor, play, GI_OCARINA, 30.0f, 80.0f); + Actor_OfferGetItem(&this->actor, play, GI_OCARINA, 30.0f, 80.0f); } else { gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; Actor_Kill(&this->actor); @@ -172,10 +172,10 @@ void DmChar02_Draw(Actor* thisx, PlayState* play) { DmChar02* this = THIS; s32 shouldDraw = false; - if ((play->csCtx.state == 0) && (this->actor.world.pos.y < 100.0f)) { + if ((play->csCtx.state == CS_STATE_IDLE) && (this->actor.world.pos.y < 100.0f)) { shouldDraw = true; - } else if (Cutscene_CheckActorAction(play, 0x6B)) { - switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x6B)]->action) { + } else if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_107)) { + switch (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_107)]->id) { case 0x17: case 0x1C: case 0x26: diff --git a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c index 714913231..21b9f94df 100644 --- a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c +++ b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c @@ -76,14 +76,14 @@ void func_80AAB5F8(DmChar03* this, PlayState* play) { } void func_80AAB644(DmChar03* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 0x88)) { - s32 index = Cutscene_GetActorActionIndex(play, 0x88); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_136)) { + s32 cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_136); - if (play->csCtx.actorActions[index]->action == 4) { + if (play->csCtx.actorCues[cueChannel]->id == 4) { this->unk_18E = true; - this->offset.x = play->csCtx.actorActions[index]->startPos.x; - this->offset.y = play->csCtx.actorActions[index]->startPos.y; - this->offset.z = play->csCtx.actorActions[index]->startPos.z; + this->offset.x = play->csCtx.actorCues[cueChannel]->startPos.x; + this->offset.y = play->csCtx.actorCues[cueChannel]->startPos.y; + this->offset.z = play->csCtx.actorCues[cueChannel]->startPos.z; } } } @@ -94,11 +94,11 @@ void DmChar03_DoNothing(DmChar03* this, PlayState* play) { void func_80AAB710(DmChar03* this, PlayState* play) { u8 shouldChangeAnim = true; - if (Cutscene_CheckActorAction(play, 0x88)) { - s32 index = Cutscene_GetActorActionIndex(play, 0x88); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_136)) { + s32 cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_136); - if (play->csCtx.frames == play->csCtx.actorActions[index]->startFrame) { - switch (play->csCtx.actorActions[index]->action) { + if (play->csCtx.curFrame == play->csCtx.actorCues[cueChannel]->startFrame) { + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: shouldChangeAnim = false; break; @@ -124,24 +124,24 @@ void func_80AAB710(DmChar03* this, PlayState* play) { DmChar03_ChangeAnim(&this->skelAnime, &sAnimationInfo[this->animIndex], 0); } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, index); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } } void func_80AAB838(DmChar03* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_0); + Actor_PlaySfx(&this->actor, NA_SE_IT_MASK_BOUND_0); } else if ((Animation_OnFrame(&this->skelAnime, 10.0f)) || (Animation_OnFrame(&this->skelAnime, 18.0f)) || (Animation_OnFrame(&this->skelAnime, 30.0f)) || (Animation_OnFrame(&this->skelAnime, 38.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_1); + Actor_PlaySfx(&this->actor, NA_SE_IT_MASK_BOUND_1); } } void DmChar03_Update(Actor* thisx, PlayState* play) { DmChar03* this = THIS; - if (Cutscene_CheckActorAction(play, 0x88) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x88)]->action == 2)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_136) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_136)]->id == 2)) { SkelAnime_Update(&this->skelAnime); } this->actionFunc(this, play); @@ -163,8 +163,8 @@ void DmChar03_Draw(Actor* thisx, PlayState* play) { DmChar03* this = THIS; if (!this->unk_18E) { - if ((Cutscene_CheckActorAction(play, 0x88)) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x88)]->action != 1)) { + if ((Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_136)) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_136)]->id != 1)) { func_8012C28C(play->state.gfxCtx); SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, DmChar03_OverrideLimbDraw, DmChar03_PostLimbDraw, diff --git a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c index 5c835152d..ac479344d 100644 --- a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c +++ b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c @@ -66,7 +66,7 @@ void DmChar04_Init(Actor* thisx, PlayState* play) { this->primColors = sPrimColors[this->actor.params]; this->envColors = sEnvColors[this->actor.params]; this->actor.targetArrowOffset = 3000.0f; - this->csAction = 0x63; + this->cueId = 99; this->timer = this->actor.params << 0xB; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_Init(play, &this->skelAnime, &gameplay_keep_Skel_02AF58.sh, &gameplay_keep_Anim_029140, this->jointTable, @@ -81,15 +81,15 @@ void DmChar04_Destroy(Actor* thisx, PlayState* play) { } void func_80AABE34(DmChar04* this, PlayState* play) { - u16 params = this->actor.params + 0x71; + u16 cueType = CS_CMD_ACTOR_CUE_113 + this->actor.params; - if (Cutscene_CheckActorAction(play, params)) { - s32 actionIndex = Cutscene_GetActorActionIndex(play, params); + if (Cutscene_IsCueInChannel(play, cueType)) { + s32 cueChannel = Cutscene_GetCueChannel(play, cueType); - if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { - if (this->csAction != play->csCtx.actorActions[actionIndex]->action) { - this->csAction = play->csCtx.actorActions[actionIndex]->action; - if (play->csCtx.actorActions[actionIndex]->action == 1) { + if (play->csCtx.curFrame == play->csCtx.actorCues[cueChannel]->startFrame) { + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; + if (play->csCtx.actorCues[cueChannel]->id == 1) { this->animIndex = 0; } else { this->animIndex = 0; @@ -97,9 +97,9 @@ void func_80AABE34(DmChar04* this, PlayState* play) { DmChar04_ChangeAnim(&this->skelAnime, &sAnimationInfo[this->animIndex], 0); } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } else { - this->csAction = 0x63; + this->cueId = 99; } } diff --git a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.h b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.h index 0f0fcb6a1..c3d809c63 100644 --- a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.h +++ b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.h @@ -15,7 +15,7 @@ typedef struct DmChar04 { /* 0x023C */ DmChar04ActionFunc actionFunc; /* 0x240 */ Color_RGBAf primColors; /* 0x250 */ Color_RGBAf envColors; - /* 0x260 */ u8 csAction; + /* 0x260 */ u8 cueId; /* 0x261 */ u8 animIndex; /* 0x262 */ u16 timer; } DmChar04; // size = 0x264 diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c index 7e368b9e3..6b85df5d3 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -177,14 +177,14 @@ void func_80AAC990(DmChar05* this, PlayState* play) { } void func_80AAC9DC(DmChar05* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 109) != 0) { - s32 actionIndex = Cutscene_GetActorActionIndex(play, 109); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_109)) { + s32 cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_109); - if (play->csCtx.actorActions[actionIndex]->action == 4) { + if (play->csCtx.actorCues[cueChannel]->id == 4) { this->unk_18E = 1; - this->unk_190.x = play->csCtx.actorActions[actionIndex]->startPos.x; - this->unk_190.y = play->csCtx.actorActions[actionIndex]->startPos.y; - this->unk_190.z = play->csCtx.actorActions[actionIndex]->startPos.z; + this->unk_190.x = play->csCtx.actorCues[cueChannel]->startPos.x; + this->unk_190.y = play->csCtx.actorCues[cueChannel]->startPos.y; + this->unk_190.z = play->csCtx.actorCues[cueChannel]->startPos.z; } } } @@ -199,17 +199,17 @@ void func_80AACA98(DmChar05* this, PlayState* play) { } void func_80AACAE4(DmChar05* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 564)) { - s32 actionIndex = Cutscene_GetActorActionIndex(play, 564); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_564)) { + s32 cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_564); - if (play->csCtx.actorActions[actionIndex]->action == 2) { - if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { + if (play->csCtx.actorCues[cueChannel]->id == 2) { + if (play->csCtx.curFrame == play->csCtx.actorCues[cueChannel]->startFrame) { Item_Give(play, ITEM_MASK_COUPLE); } this->unk_18E = 1; - this->unk_190.x = play->csCtx.actorActions[actionIndex]->startPos.x; - this->unk_190.y = play->csCtx.actorActions[actionIndex]->startPos.y; - this->unk_190.z = play->csCtx.actorActions[actionIndex]->startPos.z; + this->unk_190.x = play->csCtx.actorCues[cueChannel]->startPos.x; + this->unk_190.y = play->csCtx.actorCues[cueChannel]->startPos.y; + this->unk_190.z = play->csCtx.actorCues[cueChannel]->startPos.z; } else { this->unk_18E = 0; } @@ -277,13 +277,13 @@ void func_80AACD1C(DmChar05* this, PlayState* play) { } void func_80AACD68(DmChar05* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 473)) { - s32 actionIndex = Cutscene_GetActorActionIndex(play, 473); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_473)) { + s32 cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_473); this->unk_18E = 1; - this->unk_190.x = play->csCtx.actorActions[actionIndex]->startPos.x; - this->unk_190.y = play->csCtx.actorActions[actionIndex]->startPos.y; - this->unk_190.z = play->csCtx.actorActions[actionIndex]->startPos.z; + this->unk_190.x = play->csCtx.actorCues[cueChannel]->startPos.x; + this->unk_190.y = play->csCtx.actorCues[cueChannel]->startPos.y; + this->unk_190.z = play->csCtx.actorCues[cueChannel]->startPos.z; } } @@ -297,27 +297,27 @@ void func_80AACE10(DmChar05* this, PlayState* play) { } void func_80AACE5C(DmChar05* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 518)) { - s32 actionIndex = Cutscene_GetActorActionIndex(play, 518); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_518)) { + s32 cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_518); this->unk_18E = 1; - this->unk_190.x = play->csCtx.actorActions[actionIndex]->startPos.x; - this->unk_190.y = play->csCtx.actorActions[actionIndex]->startPos.y; - this->unk_190.z = play->csCtx.actorActions[actionIndex]->startPos.z; + this->unk_190.x = play->csCtx.actorCues[cueChannel]->startPos.x; + this->unk_190.y = play->csCtx.actorCues[cueChannel]->startPos.y; + this->unk_190.z = play->csCtx.actorCues[cueChannel]->startPos.z; } } void func_80AACF04(DmChar05* this, PlayState* play) { u8 sp2F = true; - s32 actionIndex; + s32 cueChannel; switch (DMCHAR05_GET(&this->actor)) { case DMCHAR05_0: - if (Cutscene_CheckActorAction(play, 109)) { - actionIndex = Cutscene_GetActorActionIndex(play, 109); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_109)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_109); - if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { - switch (play->csCtx.actorActions[actionIndex]->action) { + if (play->csCtx.curFrame == play->csCtx.actorCues[cueChannel]->startFrame) { + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: sp2F = false; break; @@ -351,16 +351,16 @@ void func_80AACF04(DmChar05* this, PlayState* play) { } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } break; case DMCHAR05_1: - if (Cutscene_CheckActorAction(play, 473)) { - actionIndex = Cutscene_GetActorActionIndex(play, 473); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_473)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_473); - if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { - switch (play->csCtx.actorActions[actionIndex]->action) { + if (play->csCtx.curFrame == play->csCtx.actorCues[cueChannel]->startFrame) { + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: sp2F = false; break; @@ -395,16 +395,16 @@ void func_80AACF04(DmChar05* this, PlayState* play) { } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } break; case DMCHAR05_2: - if (Cutscene_CheckActorAction(play, 518)) { - actionIndex = Cutscene_GetActorActionIndex(play, 518); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_518)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_518); - if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { - switch (play->csCtx.actorActions[actionIndex]->action) { + if (play->csCtx.curFrame == play->csCtx.actorCues[cueChannel]->startFrame) { + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: sp2F = false; break; @@ -438,16 +438,16 @@ void func_80AACF04(DmChar05* this, PlayState* play) { } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } break; case DMCHAR05_3: - if (Cutscene_CheckActorAction(play, 559)) { - actionIndex = Cutscene_GetActorActionIndex(play, 559); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_559)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_559); - if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { - switch (play->csCtx.actorActions[actionIndex]->action) { + if (play->csCtx.curFrame == play->csCtx.actorCues[cueChannel]->startFrame) { + switch (play->csCtx.actorCues[cueChannel]->id) { default: sp2F = false; break; @@ -474,10 +474,10 @@ void func_80AACF04(DmChar05* this, PlayState* play) { } } - if (play->csCtx.actorActions[actionIndex]->action != 4) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + if (play->csCtx.actorCues[cueChannel]->id != 4) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } else { - Cutscene_ActorTranslate(&this->actor, play, actionIndex); + Cutscene_ActorTranslate(&this->actor, play, cueChannel); } } @@ -492,73 +492,73 @@ void func_80AACF04(DmChar05* this, PlayState* play) { } void func_80AAD3F8(DmChar05* this, PlayState* play) { - if (play->csCtx.frames == 490) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); + if (play->csCtx.curFrame == 490) { + Actor_PlaySfx(&this->actor, NA_SE_EN_EVIL_POWER); } - if (play->csCtx.frames > 550) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MASK_FLOAT - SFX_FLAG); + if (play->csCtx.curFrame > 550) { + Actor_PlaySfx(&this->actor, NA_SE_EN_MASK_FLOAT - SFX_FLAG); } } void func_80AAD450(DmChar05* this, PlayState* play) { - if (play->csCtx.frames == 262) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); + if (play->csCtx.curFrame == 262) { + Actor_PlaySfx(&this->actor, NA_SE_EN_EVIL_POWER); } - if (play->csCtx.frames > 318) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MASK_FLOAT - SFX_FLAG); + if (play->csCtx.curFrame > 318) { + Actor_PlaySfx(&this->actor, NA_SE_EN_MASK_FLOAT - SFX_FLAG); } } void func_80AAD4A8(DmChar05* this, PlayState* play) { if (DMCHAR05_GET(&this->actor) == DMCHAR05_0) { - if (Cutscene_CheckActorAction(play, 109) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 109)]->action == 3)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_109) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_109)]->id == 3)) { if (Animation_OnFrame(&this->skelAnime, 14.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_0); + Actor_PlaySfx(&this->actor, NA_SE_IT_MASK_BOUND_0); } else if (Animation_OnFrame(&this->skelAnime, 19.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_1); + Actor_PlaySfx(&this->actor, NA_SE_IT_MASK_BOUND_1); } } } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_1) { - if (Cutscene_CheckActorAction(play, 473)) { - if ((play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 473)]->action == 3) && + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_473)) { + if ((play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_473)]->id == 3) && Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_SAND); + Actor_PlaySfx(&this->actor, NA_SE_IT_MASK_BOUND_SAND); } } } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_2) { - if (Cutscene_CheckActorAction(play, 518) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 518)]->action == 2)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_518) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_518)]->id == 2)) { if (Animation_OnFrame(&this->skelAnime, 7.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_0); + Actor_PlaySfx(&this->actor, NA_SE_IT_MASK_BOUND_0); } if (Animation_OnFrame(&this->skelAnime, 14.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_1); + Actor_PlaySfx(&this->actor, NA_SE_IT_MASK_BOUND_1); } if (Animation_OnFrame(&this->skelAnime, 18.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_1); + Actor_PlaySfx(&this->actor, NA_SE_IT_MASK_BOUND_1); } } } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_3) { if (play->sceneId == SCENE_OKUJOU) { if (gSaveContext.sceneLayer == 2) { - if (play->csCtx.currentCsIndex == 0) { + if (play->csCtx.scriptIndex == 0) { func_80AAD3F8(this, play); - } else if (play->csCtx.currentCsIndex == 1) { + } else if (play->csCtx.scriptIndex == 1) { func_80AAD450(this, play); } } } else if (play->sceneId == SCENE_SPOT00) { if (gSaveContext.sceneLayer == 9) { - if ((play->csCtx.currentCsIndex == 0) && (play->csCtx.frames == 255)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); + if ((play->csCtx.scriptIndex == 0) && (play->csCtx.curFrame == 255)) { + Actor_PlaySfx(&this->actor, NA_SE_EN_EVIL_POWER); } - } else if ((gSaveContext.sceneLayer == 0xB) && (play->csCtx.frames == 115)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER_PREDEMO); + } else if ((gSaveContext.sceneLayer == 0xB) && (play->csCtx.curFrame == 115)) { + Actor_PlaySfx(&this->actor, NA_SE_EN_EVIL_POWER_PREDEMO); } } } @@ -568,25 +568,25 @@ void DmChar05_Update(Actor* thisx, PlayState* play) { DmChar05* this = THIS; func_80AACF04(this, play); - if (Cutscene_CheckActorAction(play, 109)) { - if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 109)]->action == 3) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_109)) { + if (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_109)]->id == 3) { SkelAnime_Update(&this->skelAnime); } - } else if (Cutscene_CheckActorAction(play, 473)) { - if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 473)]->action == 3) { + } else if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_473)) { + if (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_473)]->id == 3) { SkelAnime_Update(&this->skelAnime); } - } else if (Cutscene_CheckActorAction(play, 518)) { - if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 518)]->action == 2) { + } else if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_518)) { + if (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_518)]->id == 2) { SkelAnime_Update(&this->skelAnime); } - } else if (Cutscene_CheckActorAction(play, 559)) { - if ((play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 559)]->action == 2) || - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 559)]->action == 3)) { + } else if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_559)) { + if ((play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_559)]->id == 2) || + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_559)]->id == 3)) { SkelAnime_Update(&this->skelAnime); } - if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 559)]->action == 4) { + if (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_559)]->id == 4) { this->actor.world.rot.y += 0x258; this->actor.shape.rot.y += 0x258; } @@ -607,8 +607,8 @@ void func_80AAD998(Actor* thisx, PlayState* play) { s32 pad[2]; if (this->unk_18E == 0) { - if (Cutscene_CheckActorAction(play, 109) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 109)]->action != 1)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_109) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_109)]->id != 1)) { OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); @@ -628,8 +628,8 @@ void func_80AADA90(Actor* thisx, PlayState* play) { DmChar05* this = THIS; if (this->unk_18E == 0) { - if (Cutscene_CheckActorAction(play, 473) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 473)]->action != 1)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_473) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_473)]->id != 1)) { func_8012C28C(play->state.gfxCtx); SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, DmChar05_OverrideLimbDraw, DmChar05_PostLimbDraw, &this->actor); @@ -643,8 +643,8 @@ void func_80AADB4C(Actor* thisx, PlayState* play) { DmChar05* this = THIS; if (this->unk_18E == 0) { - if (Cutscene_CheckActorAction(play, 518) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 518)]->action != 1)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_518) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_518)]->id != 1)) { func_8012C28C(play->state.gfxCtx); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, NULL, &this->actor); @@ -657,19 +657,18 @@ void func_80AADB4C(Actor* thisx, PlayState* play) { void func_80AADC00(Actor* thisx, PlayState* play) { s32 pad; DmChar05* this = THIS; - s32 actionIndex; + s32 cueChannel; - if (Cutscene_CheckActorAction(play, 559)) { - actionIndex = Cutscene_GetActorActionIndex(play, 559); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_559)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_559); - if ((play->csCtx.actorActions[actionIndex]->action != 1) && - (play->csCtx.actorActions[actionIndex]->action != 4)) { + if ((play->csCtx.actorCues[cueChannel]->id != 1) && (play->csCtx.actorCues[cueChannel]->id != 4)) { func_8012C28C(play->state.gfxCtx); SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, DmChar05_OverrideLimbDraw, DmChar05_PostLimbDraw, &this->actor); } - if (play->csCtx.actorActions[actionIndex]->action == 4) { + if (play->csCtx.actorCues[cueChannel]->id == 4) { Matrix_Translate(-600.0f, 0.0f, 0.0f, MTXMODE_APPLY); Gfx_DrawDListOpa(play, object_dmask_DL_001E70); } diff --git a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c index 0385a82d4..747b2e0c9 100644 --- a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c +++ b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c @@ -37,7 +37,7 @@ void DmChar06_SetupAction(DmChar06* this, DmChar06ActionFunc actionFunc) { void DmChar06_Init(Actor* thisx, PlayState* play) { DmChar06* this = THIS; - SET_WEEKEVENTREG(WEEKEVENTREG_33_80); + SET_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE); Actor_SetScale(&this->actor, 1.0f); this->alpha = 255; DmChar06_SetupAction(this, func_80AAE6F0); @@ -47,17 +47,17 @@ void DmChar06_Destroy(Actor* thisx, PlayState* play) { } void func_80AAE6F0(DmChar06* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 0x1CF)) { - s32 actionIndex = Cutscene_GetActorActionIndex(play, 0x1CF); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_463)) { + s32 cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_463); - if ((play->csCtx.frames >= play->csCtx.actorActions[actionIndex]->startFrame) && - (play->csCtx.actorActions[actionIndex]->endFrame >= play->csCtx.frames)) { - if (play->csCtx.actorActions[actionIndex]->action == 1) { + if ((play->csCtx.curFrame >= play->csCtx.actorCues[cueChannel]->startFrame) && + (play->csCtx.actorCues[cueChannel]->endFrame >= play->csCtx.curFrame)) { + if (play->csCtx.actorCues[cueChannel]->id == 1) { this->alpha = 255; - } else if (play->csCtx.actorActions[actionIndex]->action == 2) { - f32 lerp = 1.0f - Environment_LerpWeight(play->csCtx.actorActions[actionIndex]->endFrame, - play->csCtx.actorActions[actionIndex]->startFrame, - play->csCtx.frames); + } else if (play->csCtx.actorCues[cueChannel]->id == 2) { + f32 lerp = + 1.0f - Environment_LerpWeight(play->csCtx.actorCues[cueChannel]->endFrame, + play->csCtx.actorCues[cueChannel]->startFrame, play->csCtx.curFrame); this->alpha = 255 * lerp; } } diff --git a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c index 4129adfbe..35611375b 100644 --- a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c +++ b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c @@ -165,15 +165,15 @@ void DmChar08_Init(Actor* thisx, PlayState* play2) { this->unk_1F0 = 0.0f; if (play->sceneId == SCENE_31MISAKI) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_53_20)) { - DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); DynaPolyActor_LoadMesh(play, &this->dyna, &gTurtleZoraCapeAwakeCol); } else { - DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); DynaPolyActor_LoadMesh(play, &this->dyna, &gTurtleZoraCapeAsleepCol); } this->dynapolyInitialized = true; } else if (play->sceneId == SCENE_SEA) { - DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); DynaPolyActor_LoadMesh(play, &this->dyna, &sTurtleGreatBayTempleCol); this->dynapolyInitialized = true; } @@ -275,28 +275,28 @@ void DmChar08_WaitForSong(DmChar08* this, PlayState* play) { } void DmChar08_SetupAppearCs(DmChar08* this, PlayState* play) { - s16 cs1 = this->dyna.actor.cutscene; - s16 cs = ActorCutscene_GetAdditionalCutscene( - ActorCutscene_GetAdditionalCutscene(ActorCutscene_GetAdditionalCutscene(cs1))); + s16 csId = this->dyna.actor.csId; + s16 additionalCsId = + CutsceneManager_GetAdditionalCsId(CutsceneManager_GetAdditionalCsId(CutsceneManager_GetAdditionalCsId(csId))); if (CHECK_WEEKEVENTREG(WEEKEVENTREG_93_08)) { - cs1 = cs; + csId = additionalCsId; } - if (ActorCutscene_GetCanPlayNext(cs1)) { - ActorCutscene_Start(cs1, &this->dyna.actor); + if (CutsceneManager_IsNext(csId)) { + CutsceneManager_Start(csId, &this->dyna.actor); SET_WEEKEVENTREG(WEEKEVENTREG_53_20); SET_WEEKEVENTREG(WEEKEVENTREG_93_08); DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); this->actionFunc = func_80AAF884; } else { - ActorCutscene_SetIntentToPlay(cs1); + CutsceneManager_Queue(csId); } } void func_80AAF884(DmChar08* this, PlayState* play) { - if (play->csCtx.state == CS_STATE_0) { - DynaPolyActor_Init(&this->dyna, 3); + if (play->csCtx.state == CS_STATE_IDLE) { + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); DynaPolyActor_LoadMesh(play, &this->dyna, &gTurtleZoraCapeAwakeCol); this->dyna.actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80AAF8F4; @@ -321,33 +321,33 @@ void func_80AAF8F4(DmChar08* this, PlayState* play) { } void func_80AAFA18(DmChar08* this, PlayState* play) { - s16 nextCs; - s16 nextCs2; - s16 nextCs1; + s16 nextCsId; + s16 nextCsId2; + s16 nextCsId1; - nextCs1 = ActorCutscene_GetAdditionalCutscene(this->dyna.actor.cutscene); - nextCs2 = nextCs1; - nextCs1 = ActorCutscene_GetAdditionalCutscene(nextCs1); + nextCsId1 = CutsceneManager_GetAdditionalCsId(this->dyna.actor.csId); + nextCsId2 = nextCsId1; + nextCsId1 = CutsceneManager_GetAdditionalCsId(nextCsId1); - nextCs = CHECK_WEEKEVENTREG(WEEKEVENTREG_53_40) ? nextCs1 : nextCs2; + nextCsId = CHECK_WEEKEVENTREG(WEEKEVENTREG_53_40) ? nextCsId1 : nextCsId2; - if (ActorCutscene_GetCanPlayNext(nextCs) != 0) { + if (CutsceneManager_IsNext(nextCsId)) { SET_WEEKEVENTREG(WEEKEVENTREG_53_40); - ActorCutscene_Start(nextCs, &this->dyna.actor); + CutsceneManager_Start(nextCsId, &this->dyna.actor); this->actionFunc = DmChar08_DoNothing; } else { - ActorCutscene_SetIntentToPlay(nextCs); + CutsceneManager_Queue(nextCsId); } } void func_80AAFAC4(DmChar08* this, PlayState* play) { - if (play->csCtx.state == 0) { + if (play->csCtx.state == CS_STATE_IDLE) { this->actionFunc = func_80AAF8F4; } } void func_80AAFAE4(DmChar08* this, PlayState* play) { - if (play->csCtx.state == 0) { + if (play->csCtx.state == CS_STATE_IDLE) { this->actionFunc = func_80AAFB04; } } @@ -390,7 +390,7 @@ void DmChar08_SpawnBubbles(DmChar08* this, PlayState* play) { void func_80AAFCCC(DmChar08* this, PlayState* play) { switch (play->sceneId) { case SCENE_31MISAKI: - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { switch (this->unk_206) { case 0: break; @@ -422,7 +422,7 @@ void func_80AAFCCC(DmChar08* this, PlayState* play) { case 2: if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { - func_801477B4(play); + Message_CloseTextbox(play); this->unk_206 = 0; } break; @@ -455,15 +455,15 @@ void DmChar08_DoNothing(DmChar08* this, PlayState* play) { } void func_80AAFE88(DmChar08* this, PlayState* play) { - s32 actorActionIndex; - CsCmdActorAction* csAction; + s32 cueChannel; + s32 pad; f32 phi_f12; - if (Cutscene_CheckActorAction(play, 474)) { - actorActionIndex = Cutscene_GetActorActionIndex(play, 474); - if (this->unk_1F6 != play->csCtx.actorActions[actorActionIndex]->action) { - this->unk_1F6 = play->csCtx.actorActions[actorActionIndex]->action; - switch (play->csCtx.actorActions[actorActionIndex]->action) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_474)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_474); + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: this->animIndex = TURTLE_ANIM_IDLE; break; @@ -509,17 +509,17 @@ void func_80AAFE88(DmChar08* this, PlayState* play) { break; case 14: - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIG_TORTOISE_ROLL); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BIG_TORTOISE_ROLL); this->animIndex = TURTLE_ANIM_FLOAT; break; } } - switch (play->csCtx.actorActions[actorActionIndex]->action) { + switch (play->csCtx.actorCues[cueChannel]->id) { case 2: this->unk_1FF = 1; - phi_f12 = 2.0f * Environment_LerpWeight(play->csCtx.actorActions[actorActionIndex]->endFrame, - play->csCtx.actorActions[actorActionIndex]->startFrame, - play->csCtx.frames); + phi_f12 = + 2.0f * Environment_LerpWeight(play->csCtx.actorCues[cueChannel]->endFrame, + play->csCtx.actorCues[cueChannel]->startFrame, play->csCtx.curFrame); if (phi_f12 > 1.0f) { phi_f12 = 1.0f; } @@ -529,30 +529,30 @@ void func_80AAFE88(DmChar08* this, PlayState* play) { this->unk_1FF = 2; } - Cutscene_ActorTranslateAndYaw(&this->dyna.actor, play, actorActionIndex); + Cutscene_ActorTranslateAndYaw(&this->dyna.actor, play, cueChannel); break; case 5: - Cutscene_ActorTranslateAndYawSmooth(&this->dyna.actor, play, actorActionIndex); + Cutscene_ActorTranslateAndYawSmooth(&this->dyna.actor, play, cueChannel); break; case 14: - Cutscene_ActorTranslate(&this->dyna.actor, play, actorActionIndex); - Math_SmoothStepToS(&this->dyna.actor.world.rot.y, play->csCtx.actorActions[actorActionIndex]->rot.y, - 0xA, 0xDC, 1); + Cutscene_ActorTranslate(&this->dyna.actor, play, cueChannel); + Math_SmoothStepToS(&this->dyna.actor.world.rot.y, play->csCtx.actorCues[cueChannel]->rot.y, 0xA, 0xDC, + 1); this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; break; default: - Cutscene_ActorTranslateAndYaw(&this->dyna.actor, play, actorActionIndex); + Cutscene_ActorTranslateAndYaw(&this->dyna.actor, play, cueChannel); break; } this->targetYPos = this->dyna.actor.world.pos.y; - if ((this->unk_1FF >= 2) || (play->csCtx.actorActions[actorActionIndex]->action == 2)) { + if ((this->unk_1FF >= 2) || (play->csCtx.actorCues[cueChannel]->id == 2)) { Math_SmoothStepToF(&this->unk_1F0, 1.0f, 0.02f, 0.1f, 0.00001f); } } else { - this->unk_1F6 = 99; + this->cueId = 99; } } @@ -893,14 +893,14 @@ void func_80AB032C(DmChar08* this, PlayState* play) { } void func_80AB096C(DmChar08* this, PlayState* play) { - if ((play->csCtx.state != 0) && (play->sceneId == SCENE_31MISAKI) && (gSaveContext.sceneLayer == 0) && - (play->csCtx.currentCsIndex == 0)) { - if ((play->csCtx.frames >= 890) && (play->csCtx.frames < 922)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_EARTHQUAKE_LAST2 - SFX_FLAG); + if ((play->csCtx.state != CS_STATE_IDLE) && (play->sceneId == SCENE_31MISAKI) && (gSaveContext.sceneLayer == 0) && + (play->csCtx.scriptIndex == 0)) { + if ((play->csCtx.curFrame >= 890) && (play->csCtx.curFrame < 922)) { + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_EARTHQUAKE_LAST2 - SFX_FLAG); } } if ((this->animIndex == TURTLE_ANIM_SWIM) && Animation_OnFrame(&this->skelAnime, 16.0f)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIG_TORTOISE_SWIM); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BIG_TORTOISE_SWIM); } } @@ -960,7 +960,7 @@ void DmChar08_UpdateCollision(DmChar08* this, PlayState* play) { sTurtleGreatBayTempleColVertices[5].y = 0x4B0; sTurtleGreatBayTempleColVertices[9].y = 0x6A4; } - func_800C6554(play, &play->colCtx.dyna); + DynaPoly_InvalidateLookup(play, &play->colCtx.dyna); } void DmChar08_Update(Actor* thisx, PlayState* play) { @@ -988,9 +988,9 @@ void DmChar08_Update(Actor* thisx, PlayState* play) { this->dyna.actor.world.pos.y = this->targetYPos; if (play->sceneId == SCENE_31MISAKI) { if (this->dyna.actor.xzDistToPlayer > 1300.0f) { - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } else { - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } } if (this->unk_1FF != 0) { @@ -1002,7 +1002,7 @@ void DmChar08_Update(Actor* thisx, PlayState* play) { } s32 DmChar08_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { - if ((play->csCtx.state == 0) && (play->sceneId == SCENE_31MISAKI) && + if ((play->csCtx.state == CS_STATE_IDLE) && (play->sceneId == SCENE_31MISAKI) && (limbIndex == TURTLE_LIMB_FRONT_RIGHT_UPPER_FLIPPER)) { rot->z = -0x5E24; } @@ -1097,7 +1097,7 @@ void DmChar08_Draw(Actor* thisx, PlayState* play) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sBigTurtleEyeTextures[this->eyeIndex])); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sBigTurtleEyeTextures[this->eyeIndex])); - if ((this->unk_1FF > 0) || (play->csCtx.state != CS_STATE_0)) { + if ((this->unk_1FF > 0) || (play->csCtx.state != CS_STATE_IDLE)) { SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, DmChar08_OverrideLimbDraw, DmChar08_PostLimbDraw, DmChar08_TransformLimbDraw, &this->dyna.actor); diff --git a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.h b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.h index f339bceaa..9fdbade43 100644 --- a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.h +++ b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.h @@ -22,7 +22,7 @@ typedef struct DmChar08 { /* 0x1E8 */ UNK_TYPE1 unk_1E8[8]; /* 0x1F0 */ f32 unk_1F0; /* 0x1F4 */ s16 unk_1F4; - /* 0x1F6 */ s16 unk_1F6; + /* 0x1F6 */ s16 cueId; /* 0x1F6 */ s16 blinkTimer; /* 0x1FA */ s16 unk_1FA; /* 0x1FC */ u16 unk_1FC; diff --git a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c index 654bc6c07..93fa0e94c 100644 --- a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c +++ b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c @@ -90,15 +90,15 @@ void func_80AB1FDC(DmChar09* this, PlayState* play) { phi_fv0 = this->speed; phi_fa0 = this->speed * 0.16f; } - Math_StepToF(&thisx->speedXZ, phi_fv0, phi_fa0); - if ((thisx->speedXZ + 0.05f) < sp54) { - Math_Vec3f_Scale(&thisx->velocity, thisx->speedXZ / sp54); + Math_StepToF(&thisx->speed, phi_fv0, phi_fa0); + if ((thisx->speed + 0.05f) < sp54) { + Math_Vec3f_Scale(&thisx->velocity, thisx->speed / sp54); thisx->world.pos.x += thisx->velocity.x; thisx->world.pos.y += thisx->velocity.y; thisx->world.pos.z += thisx->velocity.z; } else { this->unk_21C += this->unk_220; - thisx->speedXZ *= 0.4f; + thisx->speed *= 0.4f; phi_a1 = true; if (((this->unk_21C >= this->unk_218) && (this->unk_220 > 0)) || ((this->unk_21C <= 0) && (this->unk_220 < 0))) { @@ -127,24 +127,24 @@ void func_80AB2268(DmChar09* this, PlayState* play) { Path* path; s32 pad; s32 i; - s32 actionIndex; + s32 cueChannel; s32 max = 0; s32 pathnum; u8 temp = false; if (!DMCHAR09_GET_F(&this->actor)) { - if (play->csCtx.currentCsIndex == 1) { + if (play->csCtx.scriptIndex == 1) { temp = true; } - } else if (play->csCtx.currentCsIndex == 0) { + } else if (play->csCtx.scriptIndex == 0) { temp = true; } - if (Cutscene_CheckActorAction(play, 0x1F7) && temp) { - actionIndex = Cutscene_GetActorActionIndex(play, 0x1F7); - if (this->unk_22F != play->csCtx.actorActions[actionIndex]->action) { - this->unk_22F = play->csCtx.actorActions[actionIndex]->action; - switch (play->csCtx.actorActions[actionIndex]->action) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_503) && temp) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_503); + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; + switch (play->csCtx.actorCues[cueChannel]->id) { case 2: max = 0; break; @@ -159,7 +159,7 @@ void func_80AB2268(DmChar09* this, PlayState* play) { break; } - if (play->csCtx.actorActions[actionIndex]->action >= 2) { + if (play->csCtx.actorCues[cueChannel]->id >= 2) { pathnum = DMCHAR09_GET_PATH(&this->actor); path = &play->setupPathList[pathnum]; @@ -175,7 +175,7 @@ void func_80AB2268(DmChar09* this, PlayState* play) { this->unk_220 = 1; this->unk_22E = true; - this->speed = (u16)play->csCtx.actorActions[actionIndex]->rot.z * 0.00390625f; + this->speed = (u16)play->csCtx.actorCues[cueChannel]->rot.z * 0.00390625f; this->actionFunc = func_80AB1FDC; } else { this->unk_22E = false; @@ -183,7 +183,7 @@ void func_80AB2268(DmChar09* this, PlayState* play) { } } } else { - this->unk_22F = 0x63; + this->cueId = 99; } } @@ -202,8 +202,8 @@ void DmChar09_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); func_80AB2268(this, play); func_80AB24BC(this, play); - if ((play->csCtx.state != 0) && this->unk_22E && DMCHAR09_GET_100(thisx)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK + SFX_FLAG); + if ((play->csCtx.state != CS_STATE_IDLE) && this->unk_22E && DMCHAR09_GET_100(thisx)) { + Actor_PlaySfx(&this->actor, NA_SE_EV_POSTMAN_WALK + SFX_FLAG); } } @@ -217,7 +217,7 @@ s32 DmChar09_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f void DmChar09_Draw(Actor* thisx, PlayState* play) { DmChar09* this = THIS; - if ((play->csCtx.state != 0) && this->unk_22E) { + if ((play->csCtx.state != CS_STATE_IDLE) && this->unk_22E) { func_8012C28C(play->state.gfxCtx); func_8012C2DC(play->state.gfxCtx); SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, DmChar09_OverrideLimbDraw, NULL, diff --git a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.h b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.h index dffe65975..cfb3523e6 100644 --- a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.h +++ b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.h @@ -31,7 +31,7 @@ typedef struct DmChar09 { /* 0x22A */ s16 unk_22A; /* 0x22C */ UNK_TYPE1 pad22C[2]; /* 0x22E */ u8 unk_22E; - /* 0x22F */ u8 unk_22F; + /* 0x22F */ u8 cueId; } DmChar09; // size = 0x230 #endif // Z_DM_CHAR09_H diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c index 5321abc92..2cdddbf19 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -195,28 +195,28 @@ void func_80C248A8(DmGm* this, PlayState* play) { void func_80C24A00(DmGm* this, PlayState* play) { s32 sp28[] = { 0, 0, 12, 2, 4, 6, 8, 10, 11, 3 }; - u16 action; - s32 sp20; + u16 cueId; + s32 cueChannel; - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { if (this->unk_2D0 == 0) { - this->unk_2B0 = 255; + this->cueId = 255; this->unk_2D0 = 1; this->unk_2D4 = 0; this->unk_2CC = this->unk_2C8; } - if (Cutscene_CheckActorAction(play, 0x22D)) { - sp20 = Cutscene_GetActorActionIndex(play, 0x22D); - action = play->csCtx.actorActions[sp20]->action; + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_557)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_557); + cueId = play->csCtx.actorCues[cueChannel]->id; - if (this->unk_2B0 != (action & 0xFF)) { - this->unk_2B0 = action; + if (this->cueId != (u8)cueId) { + this->cueId = cueId; this->unk_2D4 = 1; - func_80C24428(this, play, sp28[action]); + func_80C24428(this, play, sp28[cueId]); } - switch (this->unk_2B0) { + switch (this->cueId) { case 2: case 4: case 5: @@ -230,7 +230,7 @@ void func_80C24A00(DmGm* this, PlayState* play) { } break; } - Cutscene_ActorTranslateAndYaw(&this->actor, play, sp20); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } } else if (this->unk_2D0 != 0) { this->unk_2D0 = 0; @@ -264,7 +264,7 @@ void DmGm_Update(Actor* thisx, PlayState* play) { func_80C24360(this, play); func_80C24504(this); } - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } Vec3f D_80C25218 = { 450.0f, 700.0f, -760.0f }; diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h index 54db8d30f..8b6b3f652 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h @@ -21,7 +21,7 @@ typedef struct DmGm { /* 0x2AC */ s8 unk_2AC; /* 0x2AD */ s8 unk_2AD; /* 0x2AE */ u16 unk_2AE; - /* 0x2B0 */ u8 unk_2B0; + /* 0x2B0 */ u8 cueId; /* 0x2B4 */ Actor* unk_2B4; /* 0x2B8 */ s16 unk_2B8; /* 0x2BA */ s16 unk_2BA; diff --git a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c index 98f7bac48..c42ad3c2b 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c @@ -43,23 +43,23 @@ s32 func_80C1DED0(DmNb* this, s32 arg1) { void func_80C1DF18(DmNb* this, PlayState* play) { s32 sp2C[] = { 0, 0, 0, 0, 0 }; - u16 csAction; - s32 csActionIndex; + u16 cueId; + s32 cueChannel; - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { if (this->unk1F8 == 0) { - this->unk1EC = 0xFF; + this->cueId = 255; this->unk1F8 = 1; this->unk1F4 = this->unk1F0; } - if (Cutscene_CheckActorAction(play, 0x232)) { - csActionIndex = Cutscene_GetActorActionIndex(play, 0x232); - csAction = play->csCtx.actorActions[csActionIndex]->action; - if (this->unk1EC != (u8)csAction) { - this->unk1EC = csAction; - func_80C1DED0(this, sp2C[csAction]); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_562)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_562); + cueId = play->csCtx.actorCues[cueChannel]->id; + if (this->cueId != (u8)cueId) { + this->cueId = cueId; + func_80C1DED0(this, sp2C[cueId]); } - Cutscene_ActorTranslateAndYaw(&this->actor, play, csActionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } } else if (this->unk1F8 != 0) { this->unk1F8 = 0; @@ -87,7 +87,7 @@ void DmNb_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } void DmNb_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { diff --git a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h index 3f35beea0..7bb7b39cd 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h @@ -14,7 +14,7 @@ typedef struct DmNb { /* 0x188 */ DmNbActionFunc actionFunc; /* 0x18C */ Vec3s jointTable[NB_LIMB_MAX]; /* 0x1BC */ Vec3s morphTable[NB_LIMB_MAX]; - /* 0x1EC */ u8 unk1EC; + /* 0x1EC */ u8 cueId; /* 0x1F0 */ s32 unk1F0; /* 0x1F4 */ s32 unk1F4; /* 0x1F8 */ s32 unk1F8; diff --git a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c index db76db278..e0d2fc2a3 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c @@ -70,24 +70,24 @@ void DmOpstage_Destroy(Actor* thisx, PlayState* play) { } void DmOpstage_FollowCutsceneScript(DmOpstage* this, PlayState* play) { - s32 actionIndex; + s32 cueChannel; if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DMOPSTAGE_TYPE_GROUND) { - if (Cutscene_CheckActorAction(play, 0x73)) { - actionIndex = Cutscene_GetActorActionIndex(play, 0x73); - if (play->csCtx.actorActions[actionIndex]->action == 2) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_115)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_115); + if (play->csCtx.actorCues[cueChannel]->id == 2) { this->dyna.actor.scale.x = 0.075f; this->dyna.actor.scale.z = 0.3f; } else { this->dyna.actor.scale.x = 0.1f; this->dyna.actor.scale.z = 0.1f; } - Cutscene_ActorTranslateAndYaw(&this->dyna.actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->dyna.actor, play, cueChannel); } - } else if (Cutscene_CheckActorAction(play, DMOPSTAGE_GET_ACTORACTION(&this->dyna.actor) + 0x74)) { + } else if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_116 + DMOPSTAGE_GET_CUE_TYPE_OFFSET(&this->dyna.actor))) { Cutscene_ActorTranslateAndYaw( &this->dyna.actor, play, - Cutscene_GetActorActionIndex(play, DMOPSTAGE_GET_ACTORACTION(&this->dyna.actor) + 0x74)); + Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_116 + DMOPSTAGE_GET_CUE_TYPE_OFFSET(&this->dyna.actor))); } } @@ -95,7 +95,7 @@ void DmOpstage_Update(Actor* thisx, PlayState* play) { DmOpstage* this = THIS; this->actionFunc(this, play); - if ((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 0) && (play->csCtx.frames == 480)) { + if ((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 0) && (play->csCtx.curFrame == 480)) { // This actor is responsible for playing the fairy sound during the exposition in the intro, // during the transition to Lost Woods, before Ocarina gets stolen. func_8019F128(NA_SE_EV_NAVY_FLY_REBIRTH); diff --git a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h index 3d9195413..03fd093f3 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h @@ -4,7 +4,7 @@ #include "global.h" #define DMOPSTAGE_GET_TYPE(thisx) ((thisx)->params & 0xFF) -#define DMOPSTAGE_GET_ACTORACTION(thisx) (((thisx)->params >> 8) & 0xFF) +#define DMOPSTAGE_GET_CUE_TYPE_OFFSET(thisx) (((thisx)->params >> 8) & 0xFF) struct DmOpstage; diff --git a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c index 25fee11db..42a846357 100644 --- a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c +++ b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c @@ -32,7 +32,7 @@ void DmRavine_Init(Actor* thisx, PlayState* play) { s32 pad; DmRavine* this = THIS; - if (CHECK_WEEKEVENTREG_ALT(WEEKEVENTREG_00_10) | cREG(0)) { + if (CHECK_WEEKEVENTREG_ALT(WEEKEVENTREG_ENTERED_GORMAN_TRACK) | cREG(0)) { Actor_Kill(&this->actor); return; } @@ -63,7 +63,7 @@ void DmRavine_Update(Actor* thisx, PlayState* play) { play->roomCtx.unk7A[1]++; if (play->roomCtx.unk7A[1] > 254) { play->roomCtx.unk7A[1] = 254; - if (play->csCtx.frames > 700) { + if (play->csCtx.curFrame > 700) { play->roomCtx.unk7A[1] = 255; play->roomCtx.unk7A[0] = 0; this->state++; // -> DM_RAVINE_STATE_PENDING_DEATH 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 11f2724de..77ce3c738 100644 --- a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c +++ b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c @@ -7,7 +7,7 @@ #include "z_dm_statue.h" #include "objects/object_smtower/object_smtower.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000000) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_CAN_PRESS_SWITCH) #define THIS ((DmStatue*)thisx) 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 4f9d7d702..9a9e14dbc 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -336,9 +336,9 @@ void DmStk_ChangeAnim(DmStk* this, PlayState* play, SkelAnime* skelAnime, Animat * after Skull Kid steals Epona. */ void DmStk_PlaySfxForIntroCutsceneFirstPart(DmStk* this, PlayState* play) { - switch (play->csCtx.frames + 20) { + switch (play->csCtx.curFrame + 20) { case 1195: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_APPEAR); break; case 1232: @@ -346,48 +346,48 @@ void DmStk_PlaySfxForIntroCutsceneFirstPart(DmStk* this, PlayState* play) { case 1252: case 1255: case 1257: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); break; case 1285: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); break; case 1343: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 1410: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); break; case 1603: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_WALK); break; case 1610: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_REVERSE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_REVERSE); break; case 2095: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_SURPRISED); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_SURPRISED); break; case 2190: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_JUMP); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_JUMP); break; case 2212: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_ONGND); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_ONGND); break; case 2214: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL02_LAUGH_SHORT); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL02_LAUGH_SHORT); break; case 2250: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL06_SURPRISED); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL06_SURPRISED); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); break; case 2255: @@ -416,7 +416,7 @@ void DmStk_PlaySfxForIntroCutsceneFirstPart(DmStk* this, PlayState* play) { case 2508: case 2519: case 2530: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; } } @@ -427,7 +427,7 @@ void DmStk_PlaySfxForIntroCutsceneFirstPart(DmStk* this, PlayState* play) { * any sound in-game, since all sound effects are muted when it plays. */ void DmStk_PlaySfxForTitleCutscene(DmStk* this, PlayState* play) { - if (play->csCtx.frames == 535) { + if (play->csCtx.curFrame == 535) { func_8019F128(NA_SE_EV_CLOCK_TOWER_BELL); } } @@ -437,7 +437,7 @@ void DmStk_PlaySfxForTitleCutscene(DmStk* this, PlayState* play) { * that starts after the fade-to-white and ends when the player gains control. */ void DmStk_PlaySfxForIntroCutsceneSecondPart(DmStk* this, PlayState* play) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 78: case 89: case 100: @@ -455,11 +455,11 @@ void DmStk_PlaySfxForIntroCutsceneSecondPart(DmStk* this, PlayState* play) { case 232: case 243: case 254: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; case 173: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); break; } } @@ -469,17 +469,17 @@ void DmStk_PlaySfxForIntroCutsceneSecondPart(DmStk* this, PlayState* play) { * the Happy Mask Salesman. */ void DmStk_PlaySfxForObtainingMajorasMaskCutscene(DmStk* this, PlayState* play) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 18: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_GASAGOSO); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_GASAGOSO); break; case 90: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); break; case 142: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); + Actor_PlaySfx(&this->actor, NA_SE_EN_EVIL_POWER); break; } } @@ -490,7 +490,7 @@ void DmStk_PlaySfxForObtainingMajorasMaskCutscene(DmStk* this, PlayState* play) * the hallucinatory Deku Scrubs scene. */ void DmStk_PlaySfxForCurseCutsceneFirstPart(DmStk* this, PlayState* play) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 415: func_801A479C(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 100); break; @@ -501,11 +501,11 @@ void DmStk_PlaySfxForCurseCutsceneFirstPart(DmStk* this, PlayState* play) { break; case 560: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL02_LAUGH_SHORT); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL02_LAUGH_SHORT); break; case 890: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL21_PSYCHO_VOICE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL21_PSYCHO_VOICE); break; } } @@ -518,13 +518,13 @@ void DmStk_PlaySfxForCurseCutsceneFirstPart(DmStk* this, PlayState* play) { void DmStk_PlaySfxForCurseCutsceneSecondPart(DmStk* this, PlayState* play) { Player* player = GET_PLAYER(play); - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 10: func_801A479C(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 50); break; case 71: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_BODY); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_BODY); break; case 365: @@ -536,30 +536,30 @@ void DmStk_PlaySfxForCurseCutsceneSecondPart(DmStk* this, PlayState* play) { break; case 265: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL03_LAUGH_BIG); break; case 126: - Actor_PlaySfxAtPos(&player->actor, NA_SE_VO_DUMMY_150); + Actor_PlaySfx(&player->actor, NA_SE_VO_DUMMY_150); break; case 197: - Actor_PlaySfxAtPos(&player->actor, NA_SE_VO_DUMMY_134); + Actor_PlaySfx(&player->actor, NA_SE_VO_DUMMY_134); break; case 207: - Actor_PlaySfxAtPos(&player->actor, NA_SE_VO_DUMMY_135); + Actor_PlaySfx(&player->actor, NA_SE_VO_DUMMY_135); break; case 217: - Actor_PlaySfxAtPos(&player->actor, NA_SE_VO_DUMMY_136); + Actor_PlaySfx(&player->actor, NA_SE_VO_DUMMY_136); break; } if (player) {} - if ((play->csCtx.frames >= 263) && (play->csCtx.frames < 698)) { - Actor_PlaySfxAtPos(&player->actor, NA_SE_EN_STALKIDS_BODY_LEV - SFX_FLAG); + if ((play->csCtx.curFrame >= 263) && (play->csCtx.curFrame < 698)) { + Actor_PlaySfx(&player->actor, NA_SE_EN_STALKIDS_BODY_LEV - SFX_FLAG); } } @@ -571,43 +571,43 @@ void DmStk_PlaySfxForCurseCutsceneSecondPart(DmStk* this, PlayState* play) { void DmStk_PlaySfxForClockTowerIntroCutsceneVersion1(DmStk* this, PlayState* play) { static s32 sMoonCallTimer = 0; - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 140: func_801A479C(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 80); break; case 258: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_TURN); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_TURN); break; case 524: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_TURN); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL04_ANGER); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_TURN); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL04_ANGER); break; case 534: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_ROLL); break; case 678: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_STRETCH); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_STRETCH); break; } - if ((this->animIndex == SK_ANIM_OCARINA_JUGGLE) && (play->csCtx.frames < 700)) { + if ((this->animIndex == SK_ANIM_OCARINA_JUGGLE) && (play->csCtx.curFrame < 700)) { if (Animation_OnFrame(&this->skelAnime, 5.0f) || Animation_OnFrame(&this->skelAnime, 25.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA1); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA1); } else if (Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 40.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA2); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA2); } } - if (play->csCtx.frames >= 700) { + if (play->csCtx.curFrame >= 700) { if (sMoonCallTimer < 128) { if ((sMoonCallTimer & 0x1F) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL20_CALL_MOON); } else if ((sMoonCallTimer & 0x1F) == 16) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); } sMoonCallTimer++; @@ -621,9 +621,9 @@ void DmStk_PlaySfxForClockTowerIntroCutsceneVersion1(DmStk* this, PlayState* pla * Handles sound effects for the cutscene where Skull Kid drops the Ocarina of Time. */ void DmStk_PlaySfxForDroppingOcarinaCutscene(DmStk* this, PlayState* play) { - if (play->csCtx.frames == 3) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL06_SURPRISED); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); + if (play->csCtx.curFrame == 3) { + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL06_SURPRISED); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); } } @@ -631,8 +631,8 @@ void DmStk_PlaySfxForDroppingOcarinaCutscene(DmStk* this, PlayState* play) { * Handles sound effects for the cutscene where Skull Kid is shivering in the rain. */ void DmStk_PlaySfxForShiveringInRainCutscene(DmStk* this, PlayState* play) { - if ((play->csCtx.frames >= 642) && (play->csCtx.frames < 845)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_NE_STAL23_COLD - SFX_FLAG); + if ((play->csCtx.curFrame >= 642) && (play->csCtx.curFrame < 845)) { + Actor_PlaySfx(&this->actor, NA_SE_NE_STAL23_COLD - SFX_FLAG); } } @@ -641,23 +641,23 @@ void DmStk_PlaySfxForShiveringInRainCutscene(DmStk* this, PlayState* play) { * in Termina Field. */ void DmStk_PlaySfxForPlayingWithFairiesCutscene(DmStk* this, PlayState* play) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 58: case 61: case 68: case 72: case 77: case 79: - Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_WATER2); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_TALL_GRASS); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_WALK); break; case 186: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_UP); break; case 230: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL22_LAUGH_KID_L); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL22_LAUGH_KID_L); break; } } @@ -668,13 +668,13 @@ void DmStk_PlaySfxForPlayingWithFairiesCutscene(DmStk* this, PlayState* play) { * the Giants are walking away. */ void DmStk_PlaySfxForEndingCutsceneFirstPart(DmStk* this, PlayState* play) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 5: Audio_PlayAmbience(AMBIENCE_ID_0C); break; case 660: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); break; } } @@ -686,45 +686,45 @@ void DmStk_PlaySfxForEndingCutsceneFirstPart(DmStk* this, PlayState* play) { void DmStk_PlaySfxForEndingCutsceneSecondPart(DmStk* this, PlayState* play) { Player* player = GET_PLAYER(play); - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 5: Audio_PlayAmbience(AMBIENCE_ID_0C); break; case 45: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; case 93: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 245: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; case 269: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL11_LAUGH_SHY2); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL11_LAUGH_SHY2); break; case 327: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_SHAKEHEAD); break; case 455: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; case 1730: - Audio_QueueSeqCmd(0x141400FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_AMBIENCE, 20); break; case 1395: - func_800B8E58(player, NA_SE_VO_DUMMY_34); + Player_PlaySfx(player, NA_SE_VO_DUMMY_34); break; case 1850: - Audio_QueueSeqCmd(0x42320000); + SEQCMD_SET_SEQPLAYER_VOLUME(SEQ_PLAYER_SFX, 50, 0); break; case 2000: @@ -735,20 +735,20 @@ void DmStk_PlaySfxForEndingCutsceneSecondPart(DmStk* this, PlayState* play) { if (this->animIndex == SK_ANIM_SHAKE_HEAD) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } if (Animation_OnFrame(&this->skelAnime, 28.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_RIDE); } } else if (this->animIndex == SK_ANIM_LAUGH_AFTER_SNIFF) { 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)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } } else if ((this->animIndex == SK_ANIM_SNIFF) && (Animation_OnFrame(&this->skelAnime, 16.0f) || Animation_OnFrame(&this->skelAnime, 23.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_NOSE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_NOSE); } } @@ -760,31 +760,31 @@ void DmStk_PlaySfxForEndingCutsceneSecondPart(DmStk* this, PlayState* play) { void DmStk_PlaySfxForClockTowerIntroCutsceneVersion2(DmStk* this, PlayState* play) { static s32 sMoonCallTimer = 0; - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 40: func_801A479C(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 80); break; case 234: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_TURN); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL04_ANGER); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_TURN); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL04_ANGER); break; case 244: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_ROLL); break; case 388: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_STRETCH); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_STRETCH); break; } - if (play->csCtx.frames >= 408) { + if (play->csCtx.curFrame >= 408) { if (sMoonCallTimer < 128) { if ((sMoonCallTimer & 0x1F) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL20_CALL_MOON); } else if ((sMoonCallTimer & 0x1F) == 16) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); } sMoonCallTimer++; @@ -803,7 +803,7 @@ void DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder(DmStk* this, PlayState* pla this->oathToOrderCutsceneVoicePos.y = this->actor.projectedPos.y; this->oathToOrderCutsceneVoicePos.z = this->actor.projectedPos.z; - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 64: Audio_PlaySfxAtPos(&this->oathToOrderCutsceneVoicePos, NA_SE_EN_STAL06_SURPRISED); break; @@ -812,19 +812,19 @@ void DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder(DmStk* this, PlayState* pla case 332: case 335: case 344: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 367: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_BODY_LEV); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_BODY_LEV); break; case 470: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_HEADACHE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_HEADACHE); break; case 486: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); Audio_PlaySfxAtPos(&this->oathToOrderCutsceneVoicePos, NA_SE_EN_STAL08_CRY_BIG); break; @@ -833,11 +833,11 @@ void DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder(DmStk* this, PlayState* pla break; case 590: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 592: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_RIDE); break; case 594: @@ -847,23 +847,23 @@ void DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder(DmStk* this, PlayState* pla if (1) {} - if ((play->csCtx.frames >= 62) && (play->csCtx.frames < 273)) { + if ((play->csCtx.curFrame >= 62) && (play->csCtx.curFrame < 273)) { if ((Rand_ZeroOne() < 0.75f) && ((play->state.frames % 2) != 0)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_EARTHQUAKE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_EARTHQUAKE); } } - if ((play->csCtx.frames >= 498) && (play->csCtx.frames < 577)) { + if ((play->csCtx.curFrame >= 498) && (play->csCtx.curFrame < 577)) { if ((play->state.frames % 4) == 0) { if ((play->state.frames & 4) != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_BODY_LEV); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_BODY_LEV); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } } } - if (play->csCtx.frames >= 290) { + if (play->csCtx.curFrame >= 290) { func_8019F128(NA_SE_EV_KYOJIN_VOICE_SUCCESS - SFX_FLAG); } } @@ -874,18 +874,18 @@ void DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder(DmStk* this, PlayState* pla * moon, which is slightly longer. */ void DmStk_PlaySfxForMoonWarpCutsceneVersion1(DmStk* this, PlayState* play) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 551: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_PULLED); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_PULLED); break; case 711: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 716: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_ONGND); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_ONGND); break; } } @@ -896,18 +896,18 @@ void DmStk_PlaySfxForMoonWarpCutsceneVersion1(DmStk* this, PlayState* play) { * warps to the moon, which is slightly shorter. */ void DmStk_PlaySfxForMoonWarpCutsceneVersion2(DmStk* this, PlayState* play) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 311: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_PULLED); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_PULLED); break; case 365: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); break; case 372: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_ONGND); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_MASK_ON); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_ONGND); break; } } @@ -916,14 +916,14 @@ void DmStk_PlaySfxForMoonWarpCutsceneVersion2(DmStk* this, PlayState* play) { * Handles sound effects for all cutscenes. */ void DmStk_PlaySfxForCutscenes(DmStk* this, PlayState* play) { - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { switch (play->sceneId) { case SCENE_LOST_WOODS: if (gSaveContext.sceneLayer == 1) { DmStk_PlaySfxForIntroCutsceneFirstPart(this, play); } else if (gSaveContext.sceneLayer == 0) { DmStk_PlaySfxForIntroCutsceneSecondPart(this, play); - } else if ((gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) { + } else if ((gSaveContext.sceneLayer == 2) && (play->csCtx.scriptIndex == 0)) { DmStk_PlaySfxForObtainingMajorasMaskCutscene(this, play); } break; @@ -936,9 +936,9 @@ void DmStk_PlaySfxForCutscenes(DmStk* this, PlayState* play) { case SCENE_OPENINGDAN: if (gSaveContext.sceneLayer == 0) { - if (play->csCtx.currentCsIndex == 0) { + if (play->csCtx.scriptIndex == 0) { DmStk_PlaySfxForCurseCutsceneFirstPart(this, play); - } else if (play->csCtx.currentCsIndex == 1) { + } else if (play->csCtx.scriptIndex == 1) { DmStk_PlaySfxForCurseCutsceneSecondPart(this, play); } } @@ -946,19 +946,19 @@ void DmStk_PlaySfxForCutscenes(DmStk* this, PlayState* play) { case SCENE_OKUJOU: if (gSaveContext.sceneLayer == 0) { - if (play->csCtx.currentCsIndex == 0) { + if (play->csCtx.scriptIndex == 0) { DmStk_PlaySfxForClockTowerIntroCutsceneVersion1(this, play); - } else if (play->csCtx.currentCsIndex == 1) { + } else if (play->csCtx.scriptIndex == 1) { DmStk_PlaySfxForDroppingOcarinaCutscene(this, play); - } else if (play->csCtx.currentCsIndex == 2) { + } else if (play->csCtx.scriptIndex == 2) { DmStk_PlaySfxForClockTowerIntroCutsceneVersion2(this, play); - } else if (play->csCtx.currentCsIndex == 3) { + } else if (play->csCtx.scriptIndex == 3) { DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder(this, play); } } else if (gSaveContext.sceneLayer == 2) { - if (play->csCtx.currentCsIndex == 0) { + if (play->csCtx.scriptIndex == 0) { DmStk_PlaySfxForMoonWarpCutsceneVersion1(this, play); - } else if (play->csCtx.currentCsIndex == 1) { + } else if (play->csCtx.scriptIndex == 1) { DmStk_PlaySfxForMoonWarpCutsceneVersion2(this, play); } } @@ -966,15 +966,15 @@ void DmStk_PlaySfxForCutscenes(DmStk* this, PlayState* play) { case SCENE_00KEIKOKU: if (gSaveContext.sceneLayer == 3) { - if (play->csCtx.currentCsIndex == 0) { + if (play->csCtx.scriptIndex == 0) { DmStk_PlaySfxForShiveringInRainCutscene(this, play); - } else if (play->csCtx.currentCsIndex == 2) { + } else if (play->csCtx.scriptIndex == 2) { DmStk_PlaySfxForPlayingWithFairiesCutscene(this, play); } } else if (gSaveContext.sceneLayer == 7) { - if (play->csCtx.currentCsIndex == 0) { + if (play->csCtx.scriptIndex == 0) { DmStk_PlaySfxForEndingCutsceneFirstPart(this, play); - } else if (play->csCtx.currentCsIndex == 1) { + } else if (play->csCtx.scriptIndex == 1) { DmStk_PlaySfxForEndingCutsceneSecondPart(this, play); } } @@ -984,24 +984,24 @@ void DmStk_PlaySfxForCutscenes(DmStk* this, PlayState* play) { if (this->animIndex == SK_ANIM_WALK) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_WALK); } } else if (this->animIndex == SK_ANIM_SEARCH_LINK) { 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)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_CALM_HIT); + Actor_PlaySfx(&this->actor, NA_SE_PL_CALM_HIT); } } else if (this->animIndex == SK_ANIM_PICK_UP_OCARINA_AND_START_PLAYING) { if (Animation_OnFrame(&this->skelAnime, 3.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PUT_OUT_ITEM); + Actor_PlaySfx(&this->actor, NA_SE_PL_PUT_OUT_ITEM); } } else if (this->animIndex == SK_ANIM_PLAY_OCARINA_AND_LAUGH) { if (Animation_OnFrame(&this->skelAnime, 14.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_UNSKILLFUL_OCARINA); + Actor_PlaySfx(&this->actor, NA_SE_EV_UNSKILLFUL_OCARINA); } if (Animation_OnFrame(&this->skelAnime, 45.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL01_LAUGH); + Actor_PlaySfx(&this->actor, NA_SE_EN_STAL01_LAUGH); } } } @@ -1024,9 +1024,9 @@ void DmStk_Init(Actor* thisx, PlayState* play) { this->deflectCount = 0; this->maskType = SK_MASK_TYPE_NORMAL; this->animIndex = SK_ANIM_IDLE; - this->fogR = play->lightCtx.unk7; - this->fogG = play->lightCtx.unk8; - this->fogB = play->lightCtx.unk9; + this->fogR = play->lightCtx.fogColor.r; + this->fogG = play->lightCtx.fogColor.g; + this->fogB = play->lightCtx.fogColor.b; if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneLayer == 1)) { this->alpha = 0; @@ -1052,7 +1052,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { R_MOON_CRASH_TIMER_X = 115; } - if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] == ITEM_NONE) { sCylinderInit.base.colType = COLTYPE_WOOD; this->actionFunc = DmStk_ClockTower_StartIntroCutsceneVersion1; } else { @@ -1119,7 +1119,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { this->fadeOutTimer = 0; this->alpha = this->alpha; this->actor.targetArrowOffset = 1100.0f; - this->csAction = 99; + this->cueId = 99; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_InitFlex(play, &this->skelAnime, &gSkullKidSkel, NULL, NULL, NULL, 0); DmStk_ChangeAnim(this, play, &this->skelAnime, &sAnimationInfo[this->animIndex], 0); @@ -1127,7 +1127,7 @@ void DmStk_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); - if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 3) && (play->csCtx.currentCsIndex > 0)) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 3) && (play->csCtx.scriptIndex > 0)) { play->envCtx.unk_17 = 15; play->envCtx.unk_18 = 15; } @@ -1165,40 +1165,40 @@ void DmStk_WaitForTelescope(DmStk* this, PlayState* play) { * Plays the cutscene in the telescope where the Moon's Tear falls. */ void DmStk_StartTelescopeCutscene(DmStk* this, PlayState* play) { - s16 dayOneAndTwoCutscene = this->actor.cutscene; - s16 dayThreeCutscene = ActorCutscene_GetAdditionalCutscene(dayOneAndTwoCutscene); - s16 finalHoursCutscene = ActorCutscene_GetAdditionalCutscene(dayThreeCutscene); - s16 cutscene; + s16 dayOneAndTwoCsId = this->actor.csId; + s16 dayThreeCsId = CutsceneManager_GetAdditionalCsId(dayOneAndTwoCsId); + s16 finalHoursCsId = CutsceneManager_GetAdditionalCsId(dayThreeCsId); + s16 csId; if (gSaveContext.save.day < 3) { - cutscene = dayOneAndTwoCutscene; + csId = dayOneAndTwoCsId; } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_40) || ((CURRENT_DAY == 3) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { - cutscene = finalHoursCutscene; + csId = finalHoursCsId; } else { - cutscene = dayThreeCutscene; + csId = dayThreeCsId; } - if (ActorCutscene_GetCanPlayNext(cutscene)) { - ActorCutscene_Start(cutscene, &this->actor); + if (CutsceneManager_IsNext(csId)) { + CutsceneManager_Start(csId, &this->actor); Environment_StartTime(); this->actionFunc = DmStk_DoNothing; } else { - ActorCutscene_SetIntentToPlay(cutscene); + CutsceneManager_Queue(csId); } } void DmStk_ClockTower_StartIntroCutsceneVersion1(DmStk* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(9)) { - ActorCutscene_Start(9, &this->actor); + if (CutsceneManager_IsNext(9)) { + CutsceneManager_Start(9, &this->actor); this->actionFunc = DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd; } else { - ActorCutscene_SetIntentToPlay(9); + CutsceneManager_Queue(9); } } void DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd(DmStk* this, PlayState* play) { - if (play->csCtx.state == 0) { + if (play->csCtx.state == CS_STATE_IDLE) { this->animIndex = SK_ANIM_CALL_DOWN_MOON_LOOP; this->handType = SK_HAND_TYPE_HOLDING_OCARINA; DmStk_ChangeAnim(this, play, &this->skelAnime, &sAnimationInfo[this->animIndex], 0); @@ -1207,16 +1207,16 @@ void DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd(DmStk* this, PlayState* } void DmStk_ClockTower_StartIntroCutsceneVersion2(DmStk* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(11)) { - ActorCutscene_Start(11, &this->actor); + if (CutsceneManager_IsNext(11)) { + CutsceneManager_Start(11, &this->actor); this->actionFunc = DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd; } else { - ActorCutscene_SetIntentToPlay(11); + CutsceneManager_Queue(11); } } void DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd(DmStk* this, PlayState* play) { - if (play->csCtx.state == 0) { + if (play->csCtx.state == CS_STATE_IDLE) { this->animIndex = SK_ANIM_FLOATING_ARMS_CROSSED; DmStk_ChangeAnim(this, play, &this->skelAnime, &sAnimationInfo[this->animIndex], 0); this->actionFunc = DmStk_ClockTower_Idle; @@ -1224,21 +1224,21 @@ void DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd(DmStk* this, PlayState* } void DmStk_ClockTower_StartDropOcarinaCutscene(DmStk* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(10)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DAMAGE); - ActorCutscene_Start(10, &this->actor); + if (CutsceneManager_IsNext(10)) { + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_DAMAGE); + CutsceneManager_Start(10, &this->actor); this->actor.shape.rot.x = 0; this->actor.world.rot.x = this->actor.shape.rot.x; this->actor.shape.rot.y = this->actor.shape.rot.x; this->actor.world.rot.y = this->actor.shape.rot.x; this->actionFunc = DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd; } else { - ActorCutscene_SetIntentToPlay(10); + CutsceneManager_Queue(10); } } void DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd(DmStk* this, PlayState* play) { - if ((play->csCtx.state != 0) && (play->csCtx.frames > 20)) { + if ((play->csCtx.state != CS_STATE_IDLE) && (play->csCtx.curFrame > 20)) { this->actionFunc = DmStk_ClockTower_Idle; } } @@ -1254,7 +1254,7 @@ void DmStk_ClockTower_AdjustHeightAndRotation(DmStk* this, PlayState* play) { sin = Math_SinS(this->bobPhase) * 10.0f; Math_SmoothStepToF(&this->actor.world.pos.y, 160.0f + sin, 0.2f, 1.0f, 0.0001f); - this->actor.world.rot.y = Actor_YawBetweenActors(&this->actor, &player->actor); + this->actor.world.rot.y = Actor_WorldYawTowardActor(&this->actor, &player->actor); this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.world.rot.x = 0x1B58; @@ -1280,7 +1280,7 @@ void DmStk_ClockTower_DeflectHit(DmStk* this, PlayState* play) { this->animIndex = SK_ANIM_DEFLECT_ATTACK; DmStk_ChangeAnim(this, play, &this->skelAnime, &sAnimationInfo[this->animIndex], 0); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); this->actionFunc = DmStk_ClockTower_WaitForDeflectionToEnd; } @@ -1307,21 +1307,21 @@ void DmStk_ClockTower_WaitForDeflectionToEnd(DmStk* this, PlayState* play) { */ void DmStk_UpdateCutscenes(DmStk* this, PlayState* play) { s32 pad; - s32 actorActionIndex; + s32 cueChannel; - if (Cutscene_CheckActorAction(play, 107)) { - actorActionIndex = Cutscene_GetActorActionIndex(play, 107); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_107)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_107); - if (play->csCtx.frames == play->csCtx.actorActions[actorActionIndex]->startFrame) { - if (this->csAction != play->csCtx.actorActions[actorActionIndex]->action) { - this->csAction = play->csCtx.actorActions[actorActionIndex]->action; + if (play->csCtx.curFrame == play->csCtx.actorCues[cueChannel]->startFrame) { + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; if (play->sceneId == SCENE_CLOCKTOWER) { this->handType = SK_HAND_TYPE_HOLDING_FLUTE; } else { this->handType = SK_HAND_TYPE_DEFAULT; } - switch (play->csCtx.actorActions[actorActionIndex]->action) { + switch (play->csCtx.actorCues[cueChannel]->id) { case 0: case 1: this->animIndex = SK_ANIM_IDLE; @@ -1402,7 +1402,7 @@ void DmStk_UpdateCutscenes(DmStk* this, PlayState* play) { case 22: this->animIndex = SK_ANIM_PLAY_OCARINA_WHILE_FLOATING; - if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] == ITEM_NONE) { this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; @@ -1414,7 +1414,7 @@ void DmStk_UpdateCutscenes(DmStk* this, PlayState* play) { case 24: this->animIndex = SK_ANIM_CALL_DOWN_MOON_START; - if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] == ITEM_NONE) { this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; @@ -1425,14 +1425,14 @@ void DmStk_UpdateCutscenes(DmStk* this, PlayState* play) { case 26: this->animIndex = SK_ANIM_SMACK_FAIRY_START; - if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] == ITEM_NONE) { this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; case 27: this->animIndex = SK_ANIM_HIT_BY_BUBBLE; - if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] == ITEM_NONE) { this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; @@ -1581,9 +1581,9 @@ void DmStk_UpdateCutscenes(DmStk* this, PlayState* play) { } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actorActionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } else { - this->csAction = 99; + this->cueId = 99; } if (this->fadeInState == SK_FADE_IN_STATE_START) { @@ -1594,9 +1594,9 @@ void DmStk_UpdateCutscenes(DmStk* this, PlayState* play) { this->fadeInState++; } - this->fogR = play->lightCtx.unk7 * this->fogScale; - this->fogG = play->lightCtx.unk8 * this->fogScale; - this->fogB = play->lightCtx.unk9 * this->fogScale; + this->fogR = play->lightCtx.fogColor.r * this->fogScale; + this->fogG = play->lightCtx.fogColor.g * this->fogScale; + this->fogB = play->lightCtx.fogColor.b * this->fogScale; } else if (this->fadeInState == SK_FADE_IN_STATE_INCREASE_FOG) { if (this->fogN < 996) { this->fogN += 10; @@ -1714,7 +1714,7 @@ void DmStk_UpdateCollision(DmStk* this, PlayState* play) { void DmStk_ClockTower_IdleWithOcarina(DmStk* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (play->csCtx.state == 0) { + if (play->csCtx.state == CS_STATE_IDLE) { DmStk_ClockTower_AdjustHeightAndRotation(this, play); this->actor.flags |= ACTOR_FLAG_1; this->tatlMessageTimer++; @@ -1739,7 +1739,7 @@ void DmStk_ClockTower_IdleWithOcarina(DmStk* this, PlayState* play) { * If he is hit in this state, he will just deflect the attack. */ void DmStk_ClockTower_Idle(DmStk* this, PlayState* play) { - if (play->csCtx.state == 0) { + if (play->csCtx.state == CS_STATE_IDLE) { DmStk_ClockTower_AdjustHeightAndRotation(this, play); this->actor.flags |= ACTOR_FLAG_1; @@ -1794,17 +1794,17 @@ void DmStk_Update(Actor* thisx, PlayState* play) { break; case SK_DEKU_PIPES_CS_STATE_PLAYER_USED_OCARINA: - if (ActorCutscene_GetCanPlayNext(16)) { + if (CutsceneManager_IsNext(16)) { this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_START; - ActorCutscene_Start(16, &this->actor); + CutsceneManager_Start(16, &this->actor); this->actionFunc = DmStk_ClockTower_Idle; } else { - ActorCutscene_SetIntentToPlay(16); + CutsceneManager_Queue(16); } break; case SK_DEKU_PIPES_CS_STATE_START: - if (play->csCtx.state == 0) { + if (play->csCtx.state == CS_STATE_IDLE) { this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_END; } break; @@ -1814,8 +1814,8 @@ void DmStk_Update(Actor* thisx, PlayState* play) { // Skull Kid is always loaded in the scene, even if he isn't visible, hence why time always passes. if ((play->actorCtx.flags & ACTORCTX_FLAG_1) && (play->msgCtx.msgMode != 0) && (play->msgCtx.currentTextId == 0x5E6) && !FrameAdvance_IsEnabled(&play->state) && - (play->transitionTrigger == TRANS_TRIGGER_OFF) && (ActorCutscene_GetCurrentIndex() == -1) && - (play->csCtx.state == 0)) { + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE) && + (play->csCtx.state == CS_STATE_IDLE)) { gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)R_TIME_SPEED; if (R_TIME_SPEED != 0) { gSaveContext.save.time = @@ -1824,7 +1824,7 @@ void DmStk_Update(Actor* thisx, PlayState* play) { } } - if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 3) && (play->csCtx.currentCsIndex > 0)) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 3) && (play->csCtx.scriptIndex > 0)) { play->envCtx.unk_17 = 15; play->envCtx.unk_18 = 15; } @@ -1888,14 +1888,14 @@ void DmStk_PostLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot case SK_MASK_TYPE_NORMAL: if ((play->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneLayer == 1) && - (play->csCtx.frames < 1400)) { + (play->csCtx.curFrame < 1400)) { if (this->fogN == this->fogF) { this->fogF = this->fogN; } POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, this->fogR, this->fogG, this->fogB, this->fogA, this->fogN, this->fogF); gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); } else { gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); } @@ -1905,8 +1905,8 @@ void DmStk_PostLimbDraw2(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMaskEyesDL); - if (Cutscene_CheckActorAction(play, 513) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 513)]->action == 2) && + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_513) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_513)]->id == 2) && (this->objectStk2ObjectIndex >= 0)) { Matrix_Push(); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h index f55321ef7..0f58c534d 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h @@ -41,7 +41,7 @@ typedef struct DmStk { /* 0x32E */ u8 fadeInState; /* 0x32F */ u8 fadeOutState; /* 0x330 */ s32 fadeOutTimer; - /* 0x334 */ u8 csAction; + /* 0x334 */ u8 cueId; /* 0x335 */ u8 hasBeenHit; // set but never used /* 0x336 */ s8 objectStkObjectIndex; /* 0x337 */ s8 objectStk2ObjectIndex; diff --git a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c index ce1cc98f3..fd945787d 100644 --- a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c +++ b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c @@ -65,37 +65,37 @@ Actor* func_80C22350(DmTag* this, PlayState* play, u8 actorCat, s16 actorId) { return foundActor; } -s32 func_80C22400(DmTag* this, s16 arg1) { +s32 func_80C22400(DmTag* this, s16 csId) { s32 ret = false; - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(arg1); - } else if (ActorCutscene_GetCanPlayNext(arg1)) { - ActorCutscene_StartAndSetUnkLinkFields(arg1, &this->actor); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(csId); + } else if (CutsceneManager_IsNext(csId)) { + CutsceneManager_StartWithPlayerCs(csId, &this->actor); ret = true; } else { - ActorCutscene_SetIntentToPlay(arg1); + CutsceneManager_Queue(csId); } return ret; } -s16 func_80C2247C(DmTag* this, s32 arg1) { +s16 func_80C2247C(DmTag* this, s32 numCutscenes) { s32 i; - s16 cs = this->actor.cutscene; + s16 csId = this->actor.csId; - for (i = 0; i < arg1; i++) { - cs = ActorCutscene_GetAdditionalCutscene(cs); + for (i = 0; i < numCutscenes; i++) { + csId = CutsceneManager_GetAdditionalCsId(csId); } - return cs; + return csId; } s32 func_80C224D8(DmTag* this, PlayState* play) { s32 pad; Actor* sp30; Actor* sp2C; - s16 sp2A = this->actor.cutscene; + s16 csId = this->actor.csId; s32 ret = false; sp30 = func_80C22350(this, play, ACTORCAT_NPC, ACTOR_EN_AN); @@ -103,9 +103,9 @@ s32 func_80C224D8(DmTag* this, PlayState* play) { switch (this->unk_1A4) { case 0: - if (func_80C22400(this, sp2A)) { + if (func_80C22400(this, csId)) { if ((sp2C != NULL) && (sp2C->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), sp2C); + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)), sp2C); } this->unk_1A4++; ret = true; @@ -114,7 +114,7 @@ s32 func_80C224D8(DmTag* this, PlayState* play) { case 1: if ((sp30 != NULL) && (sp30->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(func_80C2247C(this, 0))), + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(func_80C2247C(this, 0))), sp30); } this->unk_1A4++; @@ -122,7 +122,7 @@ s32 func_80C224D8(DmTag* this, PlayState* play) { break; case 2: - ActorCutscene_Stop(func_80C2247C(this, 0)); + CutsceneManager_Stop(func_80C2247C(this, 0)); if (func_80C22400(this, func_80C2247C(this, 1))) { this->unk_1A4++; ret = true; @@ -130,7 +130,7 @@ s32 func_80C224D8(DmTag* this, PlayState* play) { break; case 3: - ActorCutscene_Stop(func_80C2247C(this, 1)); + CutsceneManager_Stop(func_80C2247C(this, 1)); if (func_80C22400(this, func_80C2247C(this, 2))) { this->unk_1A4++; ret = true; @@ -138,7 +138,7 @@ s32 func_80C224D8(DmTag* this, PlayState* play) { break; case 4: - ActorCutscene_Stop(func_80C2247C(this, 2)); + CutsceneManager_Stop(func_80C2247C(this, 2)); if (func_80C22400(this, func_80C2247C(this, 3))) { this->unk_1A4++; ret = true; @@ -146,7 +146,7 @@ s32 func_80C224D8(DmTag* this, PlayState* play) { break; case 5: - ActorCutscene_Stop(func_80C2247C(this, 3)); + CutsceneManager_Stop(func_80C2247C(this, 3)); if (func_80C22400(this, func_80C2247C(this, 4))) { this->unk_1A4++; ret = true; @@ -158,8 +158,8 @@ s32 func_80C224D8(DmTag* this, PlayState* play) { play->nextEntrance = ENTRANCE(STOCK_POT_INN, 5); gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_02; - gSaveContext.nextTransitionType = TRANS_TYPE_06; + play->transitionType = TRANS_TYPE_FADE_BLACK; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK_SLOW; this->unk_1A4++; break; } @@ -172,8 +172,8 @@ s32 func_80C227E8(DmTag* this, PlayState* play) { play->nextEntrance = ENTRANCE(STOCK_POT_INN, 4); gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_02; - gSaveContext.nextTransitionType = TRANS_TYPE_06; + play->transitionType = TRANS_TYPE_FADE_BLACK; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK_SLOW; this->unk_1A4++; } return false; diff --git a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c index a671fe3f2..4d2b4a54a 100644 --- a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c +++ b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c @@ -131,14 +131,14 @@ void DmZl_DoNothing(DmZl* this, PlayState* play) { } void DmZl_UpdateCutscene(DmZl* this, PlayState* play) { - s32 actionIndex; + s32 cueChannel; // reused as animIndex - if (Cutscene_CheckActorAction(play, 0x66)) { - actionIndex = Cutscene_GetActorActionIndex(play, 0x66); - if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_102)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_102); + if (play->csCtx.curFrame == play->csCtx.actorCues[cueChannel]->startFrame) { s16 nextAnimIndex = ZELDA_ANIM_FACING_AWAY; - switch (play->csCtx.actorActions[actionIndex]->action) { + switch (play->csCtx.actorCues[cueChannel]->id) { default: case 1: break; @@ -159,14 +159,14 @@ void DmZl_UpdateCutscene(DmZl* this, PlayState* play) { } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - actionIndex = this->animIndex; + cueChannel = this->animIndex; - if ((actionIndex == ZELDA_ANIM_TURNING_TOWARD_PLAYER) || (actionIndex == ZELDA_ANIM_GIVING_OCARINA_START) || - (actionIndex == ZELDA_ANIM_PLAYING_OCARINA_START)) { + if ((cueChannel == ZELDA_ANIM_TURNING_TOWARD_PLAYER) || (cueChannel == ZELDA_ANIM_GIVING_OCARINA_START) || + (cueChannel == ZELDA_ANIM_PLAYING_OCARINA_START)) { // these animations don't loop at the end, they lead into the next animation this->animIndex++; DmZl_ChangeAnimation(&this->skelAnime, &sAnimationInfo[this->animIndex], 0); 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 9086a052d..c889de158 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -100,7 +100,7 @@ void DoorAna_WaitClosed(DoorAna* this, PlayState* play) { if (grottoType == DOORANA_TYPE_HIDDEN_STORMS) { //! @bug Implementation from OoT is not updated for MM, grotto does not open on Song of Storms - if (this->actor.xyzDistToPlayerSq < SQ(200.0f) && EnvFlags_Get(play, 5)) { + if (this->actor.xyzDistToPlayerSq < SQ(200.0f) && CutsceneFlags_Get(play, 5)) { grottoIsOpen = true; this->actor.flags &= ~ACTOR_FLAG_10; // always update OFF } @@ -122,7 +122,7 @@ void DoorAna_WaitClosed(DoorAna* this, PlayState* play) { play_sound(NA_SE_SY_CORRECT_CHIME); } - func_800B8C50(&this->actor, play); + Actor_SetClosestSecretDistance(&this->actor, play); } void DoorAna_WaitOpen(DoorAna* this, PlayState* play) { @@ -176,11 +176,11 @@ void DoorAna_GrabLink(DoorAna* this, PlayState* play) { Player* player; s8 pad[2]; - if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (CutsceneManager_GetCurrentCsId() != this->actor.csId) { + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 0a477df7e..fe27f2d94 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -309,20 +309,20 @@ s32 func_808A0E28(DoorShutter* this, PlayState* play) { void func_808A0F88(DoorShutter* this, PlayState* play) { if (Flags_GetClear(play, this->actor.room) || Flags_GetClearTemp(play, this->actor.room)) { - this->unk_160 = this->actor.cutscene; + this->csId = this->actor.csId; if (this->doorType == 7) { - if (this->unk_160 != -1) { - this->unk_160 = ActorCutscene_GetAdditionalCutscene(this->unk_160); + if (this->csId != CS_ID_NONE) { + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); } } - if (ActorCutscene_GetCanPlayNext(this->unk_160)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_160, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); Flags_SetClear(play, this->actor.room); DoorShutter_SetupAction(this, func_808A1784); this->unk_167 = -1; } else { - ActorCutscene_SetIntentToPlay(this->unk_160); + CutsceneManager_Queue(this->csId); } } else if (func_808A0E28(this, play)) { Player* player = GET_PLAYER(play); @@ -344,10 +344,10 @@ void func_808A1090(DoorShutter* this, PlayState* play) { if (this->unk_166 != 0) { Flags_SetSwitch(play, DOORSHUTTER_GET_7F(&this->actor)); if (this->doorType != 5) { - gSaveContext.save.inventory.dungeonKeys[gSaveContext.mapIndex]--; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK); + gSaveContext.save.saveInfo.inventory.dungeonKeys[gSaveContext.mapIndex]--; + Actor_PlaySfx(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK_B); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK_B); } } } else { @@ -367,7 +367,7 @@ void func_808A1090(DoorShutter* this, PlayState* play) { } if (this->doorType == 6) { - if (gSaveContext.save.playerData.healthCapacity < (DOORSHUTTER_GET_1F(&this->actor) * 0x10)) { + if (gSaveContext.save.saveInfo.playerData.healthCapacity < (DOORSHUTTER_GET_1F(&this->actor) * 0x10)) { player->doorType = PLAYER_DOORTYPE_TALKING; this->actor.textId = 0x14FC; } @@ -415,7 +415,7 @@ s32 func_808A1340(DoorShutter* this, PlayState* play) { if (this->actor.velocity.y == 0.0f) { func_808A1288(this, play); if (this->unk_163 != 7) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIDE_DOOR_OPEN); + Actor_PlaySfx(&this->actor, NA_SE_EV_SLIDE_DOOR_OPEN); } } @@ -448,12 +448,12 @@ s32 func_808A1478(DoorShutter* this, PlayState* play, f32 arg2) { if (temp == this->unk_168) { if (arg2 == 1.0f) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_METALDOOR_CLOSE); + Actor_PlaySfx(&this->actor, NA_SE_EV_METALDOOR_CLOSE); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_METALDOOR_OPEN); + Actor_PlaySfx(&this->actor, NA_SE_EV_METALDOOR_OPEN); } - if ((this->unk_160 != -1) && (ActorCutscene_GetCurrentIndex() == this->unk_160)) { + if ((this->csId != CS_ID_NONE) && (CutsceneManager_GetCurrentCsId() == this->csId)) { func_800B724C(play, &this->actor, PLAYER_CSMODE_1); } } @@ -467,13 +467,13 @@ s32 func_808A1478(DoorShutter* this, PlayState* play, f32 arg2) { void func_808A1548(DoorShutter* this, PlayState* play) { if (func_808A1478(this, play, 1.0f)) { if (Flags_GetSwitch(play, DOORSHUTTER_GET_7F(&this->actor))) { - this->unk_160 = this->actor.cutscene; - if (ActorCutscene_GetCanPlayNext(this->unk_160)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_160, &this->actor); + this->csId = this->actor.csId; + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); DoorShutter_SetupAction(this, func_808A1784); this->unk_167 = -1; } else { - ActorCutscene_SetIntentToPlay(this->unk_160); + CutsceneManager_Queue(this->csId); } } else if (func_808A0E28(this, play)) { Player* player = GET_PLAYER(play); @@ -497,7 +497,7 @@ void func_808A1618(DoorShutter* this, PlayState* play) { void func_808A1684(DoorShutter* this, PlayState* play) { f32 phi_f0; - if ((DECR(this->unk_166) == 0) && (play->roomCtx.unk31 == 0) && func_808A1340(this, play)) { + if ((DECR(this->unk_166) == 0) && (play->roomCtx.status == 0) && func_808A1340(this, play)) { if (this->doorType == 5) { phi_f0 = 20.0f; } else { @@ -511,7 +511,7 @@ void func_808A1684(DoorShutter* this, PlayState* play) { if (DoorShutter_SetupDoor(this, play)) { this->actor.velocity.y = 30.0f; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + Actor_PlaySfx(&this->actor, NA_SE_EV_SLIDE_DOOR_CLOSE); } DoorShutter_SetupAction(this, func_808A1B48); } @@ -520,7 +520,7 @@ void func_808A1684(DoorShutter* this, PlayState* play) { void func_808A1784(DoorShutter* this, PlayState* play) { if (this->unk_167 != 0) { - if (func_800F22C4(this->unk_160, &this->actor)) { + if (func_800F22C4(this->csId, &this->actor) != 0) { if (this->unk_167 < 0) { if ((play->state.frames % 2) != 0) { this->unk_167++; @@ -568,9 +568,9 @@ void func_808A1884(DoorShutter* this, PlayState* play) { if (DoorShutter_SetupDoor(this, play) && !(player->stateFlags1 & PLAYER_STATE1_800)) { DoorShutter_SetupAction(this, func_808A1C50); - if (ActorCutscene_GetCurrentIndex() == 0x7D) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_DOOR) { func_801226E0(play, ((void)0, gSaveContext.respawn[RESPAWN_MODE_DOWN].data)); - player->unk_A86 = -1; + player->csId = CS_ID_NONE; func_800B7298(play, NULL, PLAYER_CSMODE_115); } } @@ -607,12 +607,12 @@ void func_808A1B48(DoorShutter* this, PlayState* play) { this->actor.floorHeight = this->actor.home.pos.y; Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 45.0f, 10, 8.0f, 500, 10, 0); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BIGWALL_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EV_BIGWALL_BOUND); - quakeIndex = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); + quakeIndex = Quake_Request(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, -32536); - Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 10); + Quake_SetPerturbations(quakeIndex, 2, 0, 0, 0); + Quake_SetDuration(quakeIndex, 10); Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); @@ -623,7 +623,7 @@ void func_808A1B48(DoorShutter* this, PlayState* play) { void func_808A1C50(DoorShutter* this, PlayState* play) { if (this->unk_167++ > 30) { if (GET_PLAYER(play)->csMode == PLAYER_CSMODE_115) { - func_800B7298(play, NULL, PLAYER_CSMODE_6); + func_800B7298(play, NULL, PLAYER_CSMODE_END); } DoorShutter_SetupDoor(this, play); } @@ -651,7 +651,7 @@ s32 func_808A1D68(DoorShutter* this, PlayState* play) { return true; } - temp_a0 = BINANG_SUB(Actor_YawToPoint(&this->actor, &play->view.eye), this->actor.shape.rot.y); + temp_a0 = BINANG_SUB(Actor_WorldYawTowardPoint(&this->actor, &play->view.eye), this->actor.shape.rot.y); temp_a1 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); temp_a0 = ABS_ALT(temp_a0); diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h index c64d3d523..7f18e0546 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h @@ -17,7 +17,7 @@ typedef struct DoorShutter { /* 0x0144 */ UNK_TYPE1 unk144[0x18]; /* 0x015C */ s16 unk_15C; /* 0x015E */ s16 unk_15E; - /* 0x0160 */ s16 unk_160; + /* 0x0160 */ s16 csId; /* 0x0162 */ u8 doorType; /* 0x0163 */ u8 unk_163; /* 0x0164 */ u8 unk_164; 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 d7f77944f..6c7d32152 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c @@ -16,58 +16,13 @@ #define THIS ((DoorSpiral*)thisx) -typedef enum { - /* 0 */ SPIRAL_OVERWORLD, // does not display anything as there is not a DL in GAMEPLAY_KEEP for it - /* 1 */ SPIRAL_DUNGEON, - /* 2 */ SPIRAL_WOODFALL_TEMPLE, - /* 3 */ SPIRAL_WOODFALL_TEMPLE_ALT, // SPIRAL_WOODFALL_TEMPLE but with positional lights enabled? - /* 4 */ SPIRAL_SNOWHEAD_TEMPLE, - /* 5 */ SPIRAL_STONE_TOWER, - /* 6 */ SPIRAL_IKANA_CASTLE, - /* 7 */ SPIRAL_DAMPES_HOUSE -} SpiralType; - -typedef enum { - /* 0 */ SPIRAL_OBJECT_OVERWORLD, - /* 1 */ SPIRAL_OBJECT_DUNGEON, - /* 2 */ SPIRAL_OBJECT_WOODFALL, - /* 3 */ SPIRAL_OBJECT_SNOWHEAD, - /* 4 */ SPIRAL_OBJECT_STONE_TOWER, - /* 5 */ SPIRAL_OBJECT_DAMPES_HOUSE, - /* 6 */ SPIRAL_OBJECT_IKANA_CASTLE -} SpiralObjectType; - -typedef struct { - /* 0x00 */ Gfx* spiralDL[2]; // one displaylist for downward spiral, and one for upward - /* 0x08 */ s32 unk8; // unused - /* 0x0C */ u8 unkC; // unused - /* 0x0D */ u8 unkD; // unused - /* 0x0E */ u8 spiralWidth; - /* 0x0F */ u8 spiralHeight; -} SpiralInfo; - -// Maps SpiralObjectType to SpiralType -typedef struct { - /* 0x00 */ s16 objectBankId; - /* 0x02 */ u8 spiralType; -} SpiralObjectInfo; - -// Maps scenes to SpiralObjectType -typedef struct { - /* 0x00 */ s16 sceneId; - /* 0x02 */ u8 objectType; -} SpiralSceneInfo; - void DoorSpiral_Init(Actor* thisx, PlayState* play); void DoorSpiral_Destroy(Actor* thisx, PlayState* play); void DoorSpiral_Update(Actor* thisx, PlayState* play); void DoorSpiral_Draw(Actor* thisx, PlayState* play); -void DoorSpiral_WaitForObject(DoorSpiral* this, PlayState* play); -void DoorSpiral_Wait(DoorSpiral* this, PlayState* play); -void DoorSpiral_PlayerClimb(DoorSpiral* this, PlayState* play); - -ActorInit Door_Spiral_InitVars = { +/* +const ActorInit Door_Spiral_InitVars = { ACTOR_DOOR_SPIRAL, ACTORCAT_DOOR, FLAGS, @@ -76,257 +31,30 @@ ActorInit Door_Spiral_InitVars = { (ActorFunc)DoorSpiral_Init, (ActorFunc)DoorSpiral_Destroy, (ActorFunc)DoorSpiral_Update, - (ActorFunc)DoorSpiral_Draw, + (ActorFunc)DoorSpiral_Draw }; +*/ -// Parameters for each staircase, indexed with SpiralType -static SpiralInfo sSpiralInfo[] = { - { { NULL, NULL }, 0, 130, 12, 50, 15 }, // SPIRAL_OVERWORLD - { { gameplay_dangeon_keep_DL_0219E0, gameplay_dangeon_keep_DL_01D980 }, 0, 130, 12, 50, 15 }, // SPIRAL_DUNGEON - { { object_numa_obj_DL_004448, object_numa_obj_DL_0007A8 }, 0, 130, 12, 50, 15 }, // SPIRAL_WOODFALL_TEMPLE - { { object_numa_obj_DL_0051B8, object_numa_obj_DL_0014C8 }, 0, 130, 12, 50, 15 }, // SPIRAL_WOODFALL_TEMPLE_ALT - { { object_hakugin_obj_DL_009278, object_hakugin_obj_DL_006128 }, 0, 130, 12, 50, 15 }, // SPIRAL_SNOWHEAD_TEMPLE - { { object_ikana_obj_DL_013EA8, object_ikana_obj_DL_012B70 }, 0, 130, 12, 50, 15 }, // SPIRAL_STONE_TOWER - { { object_ikninside_obj_DL_000EA0, object_ikninside_obj_DL_000590 }, 0, 130, 12, 50, 15 }, // SPIRAL_IKANA_CASTLE - { { object_danpei_object_DL_002110, object_danpei_object_DL_0012C0 }, 0, 130, 12, 50, 15 }, // SPIRAL_DAMPES_HOUSE -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Spiral/func_809A2B60.s") -// Defines which object bank a staircase should use, and its index to `sSpiralInfo` -static SpiralObjectInfo sSpiralObjectInfo[] = { - { GAMEPLAY_KEEP, SPIRAL_OVERWORLD }, { GAMEPLAY_DANGEON_KEEP, SPIRAL_DUNGEON }, - { OBJECT_NUMA_OBJ, SPIRAL_WOODFALL_TEMPLE }, { OBJECT_HAKUGIN_OBJ, SPIRAL_SNOWHEAD_TEMPLE }, - { OBJECT_IKANA_OBJ, SPIRAL_STONE_TOWER }, { OBJECT_DANPEI_OBJECT, SPIRAL_DAMPES_HOUSE }, - { OBJECT_IKNINSIDE_OBJ, SPIRAL_IKANA_CASTLE }, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Spiral/func_809A2B70.s") -/** - * Sets the actor's action function - */ -void DoorSpiral_SetupAction(DoorSpiral* this, DoorSpiralActionFunc actionFunc) { - this->actionFunc = actionFunc; - this->unk14A = 0; // set but never used -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Spiral/func_809A2BF8.s") -/** - * Sets this->spiralType, which is derived from `sSpiralObjectInfo`, and is used as an index to `sSpiralInfo`. - */ -s32 DoorSpiral_SetSpiralType(DoorSpiral* this, PlayState* play) { - SpiralObjectInfo* doorObjectInfo = &sSpiralObjectInfo[this->objectType]; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Spiral/DoorSpiral_Init.s") - this->spiralType = doorObjectInfo->spiralType; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Spiral/DoorSpiral_Destroy.s") - if ((this->spiralType == SPIRAL_DAMPES_HOUSE) || - ((this->spiralType == SPIRAL_WOODFALL_TEMPLE) && play->roomCtx.curRoom.enablePosLights)) { - if (this->spiralType == SPIRAL_WOODFALL_TEMPLE) { - this->spiralType = SPIRAL_WOODFALL_TEMPLE_ALT; - } +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Spiral/func_809A2DB0.s") - this->actor.flags |= ACTOR_FLAG_10000000; - } +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Spiral/func_809A2E08.s") - DoorSpiral_SetupAction(this, DoorSpiral_Wait); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Spiral/func_809A2EA0.s") - return 0; -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Spiral/func_809A2FF8.s") -/** - * Gets the object type to be used as an index to `sSpiralObjectInfo`. - * It first checks `sSpiralSceneInfo`, but if the current scene is not found it will fall back to the default spiral - * (overworld or dungeon). - */ -s32 DoorSpiral_GetObjectType(PlayState* play) { - // Defines which object type should be used for specific scenes - static SpiralSceneInfo spiralSceneInfo[] = { - { SCENE_MITURIN, SPIRAL_OBJECT_WOODFALL }, { SCENE_HAKUGIN, SPIRAL_OBJECT_SNOWHEAD }, - { SCENE_INISIE_N, SPIRAL_OBJECT_STONE_TOWER }, { SCENE_INISIE_R, SPIRAL_OBJECT_STONE_TOWER }, - { SCENE_DANPEI2TEST, SPIRAL_OBJECT_DAMPES_HOUSE }, { SCENE_IKNINSIDE, SPIRAL_OBJECT_IKANA_CASTLE }, - { SCENE_CASTLE, SPIRAL_OBJECT_IKANA_CASTLE }, - }; - SpiralSceneInfo* sceneInfo = spiralSceneInfo; - s32 i; - s32 type; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Spiral/func_809A3098.s") - for (i = 0; i < ARRAY_COUNT(spiralSceneInfo); sceneInfo++, i++) { - if (play->sceneId == sceneInfo->sceneId) { - break; - } - } +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Spiral/DoorSpiral_Update.s") - type = i; - - if (type < ARRAY_COUNT(spiralSceneInfo)) { - type = sceneInfo->objectType; - } else { - // Set the type based on if link is in a dungeon scene, or the overworld - type = (Object_GetIndex(&play->objectCtx, GAMEPLAY_DANGEON_KEEP) >= 0) ? SPIRAL_OBJECT_DUNGEON - : SPIRAL_OBJECT_OVERWORLD; - } - - return type; -} - -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP), -}; - -void DoorSpiral_Init(Actor* thisx, PlayState* play) { - DoorSpiral* this = THIS; - s32 pad; - s32 transition = DOORSPIRAL_GET_TRANSITION_ID(thisx); - s8 objBankId; - - if (this->actor.room != play->transitionActors.list[transition].sides[0].room) { - Actor_Kill(&this->actor); - return; - } - - Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk145 = DOORSPIRAL_GET_UNK145(thisx); // set but never used - this->orientation = DOORSPIRAL_GET_ORIENTATION(thisx); - this->objectType = DoorSpiral_GetObjectType(play); - objBankId = Object_GetIndex(&play->objectCtx, sSpiralObjectInfo[this->objectType].objectBankId); - this->bankIndex = objBankId; - - if (objBankId < 0) { - Actor_Kill(&this->actor); - return; - } - - DoorSpiral_SetupAction(this, DoorSpiral_WaitForObject); - Actor_SetFocus(&this->actor, 60.0f); -} - -void DoorSpiral_Destroy(Actor* thisx, PlayState* play) { - s32 transition = DOORSPIRAL_GET_TRANSITION_ID(thisx); - - play->transitionActors.list[transition].id *= -1; -} - -/** - * Waits for the required object to be loaded. - */ -void DoorSpiral_WaitForObject(DoorSpiral* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { - this->actor.objBankIndex = this->bankIndex; - DoorSpiral_SetSpiralType(this, play); - } -} - -/** - * Finds the distance between the stairs and the player. - */ -f32 DoorSpiral_GetDistFromPlayer(PlayState* play, DoorSpiral* this, f32 yOffset, f32 spiralWidth, f32 spiralHeight) { - Player* player = GET_PLAYER(play); - Vec3f target; - Vec3f offset; - - target.x = player->actor.world.pos.x; - target.y = player->actor.world.pos.y + yOffset; - target.z = player->actor.world.pos.z; - - Actor_OffsetOfPointInActorCoords(&this->actor, &offset, &target); - - if ((spiralWidth < fabsf(offset.x)) || (spiralHeight < fabsf(offset.y))) { - return FLT_MAX; - } - - return offset.z; -} - -/** - * Checks if the player should climb the stairs. - */ -s32 DoorSpiral_PlayerShouldClimb(DoorSpiral* this, PlayState* play) { - Player* player = GET_PLAYER(play); - - if (!Player_InCsMode(play)) { - SpiralInfo* spiralInfo = &sSpiralInfo[this->spiralType]; - f32 dist = DoorSpiral_GetDistFromPlayer(play, this, 0.0f, spiralInfo->spiralWidth, spiralInfo->spiralHeight); - - if (fabsf(dist) < 64.0f) { - s16 angle = player->actor.shape.rot.y - this->actor.shape.rot.y; - - if (dist > 0.0f) { - angle = 0x8000 - angle; - } - - if (ABS_ALT(angle) < 0x3000) { - return (dist >= 0.0f) ? 1.0f : -1.0f; - } - } - } - - return 0; -} - -/** - * Wait for the player to interact with the stairs. - */ -void DoorSpiral_Wait(DoorSpiral* this, PlayState* play) { - Player* player; - s32 transition; - - if (this->shouldClimb) { - DoorSpiral_SetupAction(this, DoorSpiral_PlayerClimb); - } else if (DoorSpiral_PlayerShouldClimb(this, play)) { - player = GET_PLAYER(play); - - player->doorType = PLAYER_DOORTYPE_STAIRCASE; - player->doorDirection = this->orientation; - player->doorActor = &this->actor; - transition = DOORSPIRAL_GET_TRANSITION_ID(&this->actor); - player->doorNext = ((u16)play->transitionActors.list[transition].params) >> 10; - - func_80122F28(player); - } -} - -/** - * Player is climbing the stairs. - */ -void DoorSpiral_PlayerClimb(DoorSpiral* this, PlayState* play) { - Player* player = GET_PLAYER(play); - - if (!(player->stateFlags1 & PLAYER_STATE1_20000000)) { - DoorSpiral_SetupAction(this, DoorSpiral_WaitForObject); - this->shouldClimb = 0; - } -} - -void DoorSpiral_Update(Actor* thisx, PlayState* play) { - DoorSpiral* this = THIS; - s32 pad; - Player* player = GET_PLAYER(play); - - if (!(player->stateFlags1 & (PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_400 | PLAYER_STATE1_10000000)) || - (this->actionFunc == DoorSpiral_WaitForObject)) { - this->actionFunc(this, play); - } -} - -void DoorSpiral_Draw(Actor* thisx, PlayState* play) { - s32 pad; - DoorSpiral* this = THIS; - - if (this->actor.objBankIndex == this->bankIndex) { - SpiralInfo* spiralInfo = &sSpiralInfo[this->spiralType]; - Gfx* dList; - - // Set the model to render based on the orientation of the stairs (upward or downward) - dList = spiralInfo->spiralDL[this->orientation]; - - if (dList != NULL) { - OPEN_DISPS(play->state.gfxCtx); - - func_8012C28C(play->state.gfxCtx); - - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, spiralInfo->spiralDL[this->orientation]); - - CLOSE_DISPS(play->state.gfxCtx); - } - } -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Spiral/DoorSpiral_Draw.s") diff --git a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.h b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.h index 0f3e32a39..701b38639 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.h +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.h @@ -5,22 +5,9 @@ struct DoorSpiral; -#define DOORSPIRAL_GET_ORIENTATION(thisx) (((thisx)->params >> 7) & 0x1) -#define DOORSPIRAL_GET_UNK145(thisx) (((thisx)->params >> 8) & 0x3) -#define DOORSPIRAL_GET_TRANSITION_ID(thisx) ((u16)(thisx)->params >> 10) - -typedef void (*DoorSpiralActionFunc)(struct DoorSpiral*, PlayState*); - typedef struct DoorSpiral { /* 0x000 */ Actor actor; - /* 0x144 */ u8 shouldClimb; // Flag used to determine if the player should climb the stairs - /* 0x145 */ u8 unk145; - /* 0x146 */ u8 orientation; // Upward or downward staircase - /* 0x147 */ u8 objectType; // Index to list of objects - /* 0x148 */ u8 spiralType; // Type of skin the staircase should use - /* 0x149 */ s8 bankIndex; // Object bank to use - /* 0x14A */ s8 unk14A; - /* 0x14C */ DoorSpiralActionFunc actionFunc; + /* 0x144 */ char unk_144[0xC]; } DoorSpiral; // size = 0x150 #endif // Z_DOOR_SPIRAL_H 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 bc168d534..0b4b59f1c 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -4,6 +4,7 @@ * Description: Blue warp portal and crystal, and the Majora's Mask-shaped boss warp platform */ +#include "prevent_bss_reordering.h" #include "z_door_warp1.h" #include "objects/object_warp1/object_warp1.h" @@ -46,8 +47,8 @@ void func_808BAAF4(DoorWarp1* this, PlayState* play); void func_808BABF4(DoorWarp1* this, PlayState* play); void func_808BB8D4(DoorWarp1* this, PlayState* play, s32 arg2); -static s16 D_808BC000; -static f32 D_808BC004; +s16 D_808BC000; +f32 D_808BC004; ActorInit Door_Warp1_InitVars = { ACTOR_DOOR_WARP1, @@ -279,15 +280,15 @@ void func_808B8E78(DoorWarp1* this, PlayState* play) { } s32 func_808B900C(DoorWarp1* this, PlayState* play) { - s32 index; + s32 cueChannel; u8 ret = false; - if (Cutscene_CheckActorAction(play, 569)) { - index = Cutscene_GetActorActionIndex(play, 569); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_569)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_569); - if (this->unk_208 != play->csCtx.actorActions[index]->action) { - this->unk_208 = play->csCtx.actorActions[index]->action; - if (play->csCtx.actorActions[index]->action == 2) { + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; + if (play->csCtx.actorCues[cueChannel]->id == 2) { ret = true; } } @@ -328,7 +329,7 @@ void func_808B90CC(DoorWarp1* this, PlayState* play) { DoorWarp1_SetupAction(this, func_808B921C); } - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE_ENERGY - SFX_FLAG); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_WARP_HOLE_ENERGY - SFX_FLAG); } void func_808B921C(DoorWarp1* this, PlayState* play) { @@ -344,12 +345,12 @@ void func_808B921C(DoorWarp1* this, PlayState* play) { } if (func_808B866C(this, play) && !Play_InCsMode(play)) { - func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_7); + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_WAIT); Message_StartTextbox(play, 0xF2, &this->dyna.actor); DoorWarp1_SetupAction(this, func_808B93A0); } - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); } void func_808B93A0(DoorWarp1* this, PlayState* play) { @@ -357,7 +358,7 @@ void func_808B93A0(DoorWarp1* this, PlayState* play) { Player* player = GET_PLAYER(play); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); if (play->msgCtx.choiceIndex == 0) { func_8019F208(); func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_9); @@ -367,27 +368,27 @@ void func_808B93A0(DoorWarp1* this, PlayState* play) { DoorWarp1_SetupAction(this, func_808B9524); } else { func_8019F230(); - func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_6); + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_END); DoorWarp1_SetupAction(this, func_808B94A4); } } func_808BB8D4(this, play, 1); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); } void func_808B94A4(DoorWarp1* this, PlayState* play) { - if (!func_808B866C(this, play) && (ActorCutscene_GetCurrentIndex() != play->playerActorCsIds[8])) { + if (!func_808B866C(this, play) && (CutsceneManager_GetCurrentCsId() != play->playerCsIds[PLAYER_CS_ID_SONG_WARP])) { DoorWarp1_SetupAction(this, func_808B921C); } func_808BB8D4(this, play, 1); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BOSS_WARP_HOLE - SFX_FLAG); } void func_808B9524(DoorWarp1* this, PlayState* play) { - if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[9])) { - ActorCutscene_SetIntentToPlay(play->playerActorCsIds[9]); + if (!CutsceneManager_IsNext(play->playerCsIds[PLAYER_CS_ID_WARP_PAD_ENTRANCE])) { + CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_WARP_PAD_ENTRANCE]); } else { - ActorCutscene_Start(play->playerActorCsIds[9], NULL); + CutsceneManager_Start(play->playerCsIds[PLAYER_CS_ID_WARP_PAD_ENTRANCE], NULL); DoorWarp1_SetupAction(this, func_808B958C); } } @@ -410,19 +411,19 @@ void func_808B958C(DoorWarp1* this, PlayState* play) { this->unk_1D0++; if ((this->unk_1D0 > 120) && (gSaveContext.nextCutsceneIndex == 0xFFEF)) { func_808BA10C(this, play); - play->transitionType = TRANS_TYPE_03; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } Math_SmoothStepToF(&this->unk_1A8, 6.0f, 0.2f, 0.02f, 0.01f); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_LINK_WARP - SFX_FLAG); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_LINK_WARP - SFX_FLAG); } void func_808B96A0(DoorWarp1* this, PlayState* play) { } void func_808B96B0(DoorWarp1* this, PlayState* play) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + Actor_PlaySfx(&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); @@ -442,7 +443,7 @@ void func_808B96B0(DoorWarp1* this, PlayState* play) { } void func_808B977C(DoorWarp1* this, PlayState* play) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); if (func_808B866C(this, play) && !Play_InCsMode(play)) { Player* player = GET_PLAYER(play); @@ -457,10 +458,10 @@ void func_808B977C(DoorWarp1* this, PlayState* play) { } void func_808B9840(DoorWarp1* this, PlayState* play) { - if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[9])) { - ActorCutscene_SetIntentToPlay(play->playerActorCsIds[9]); + if (!CutsceneManager_IsNext(play->playerCsIds[PLAYER_CS_ID_WARP_PAD_ENTRANCE])) { + CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_WARP_PAD_ENTRANCE]); } else { - ActorCutscene_Start(play->playerActorCsIds[9], NULL); + CutsceneManager_Start(play->playerCsIds[PLAYER_CS_ID_WARP_PAD_ENTRANCE], NULL); DoorWarp1_SetupAction(this, func_808B98A8); } } @@ -515,7 +516,7 @@ void func_808B9B30(DoorWarp1* this, PlayState* play) { } void func_808B9BE8(DoorWarp1* this, PlayState* play) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + Actor_PlaySfx(&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) { @@ -547,34 +548,34 @@ void func_808B9CE8(DoorWarp1* this, PlayState* play) { } if (!Actor_HasParent(&this->dyna.actor, play)) { - Actor_PickUp(&this->dyna.actor, play, (GI_REMAINS_ODOLWA - 1) + func_808B849C(this, play), 30.0f, 80.0f); + Actor_OfferGetItem(&this->dyna.actor, play, (GI_REMAINS_ODOLWA - 1) + func_808B849C(this, play), 30.0f, 80.0f); return; } switch (play->sceneId) { case SCENE_MITURIN_BS: - gSaveContext.save.unk_ECC[0] = - (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFFFFFF00) | (((u8)gSaveContext.save.unk_ECC[1]) & 0xFF); + gSaveContext.save.saveInfo.unk_EA8[0] = (((void)0, gSaveContext.save.saveInfo.unk_EA8[0]) & 0xFFFFFF00) | + (((u8)gSaveContext.save.saveInfo.unk_EA8[1]) & 0xFF); break; case SCENE_HAKUGIN_BS: - gSaveContext.save.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFFFF00FF) | - ((((u8)gSaveContext.save.unk_ECC[1]) & 0xFF) << 8); + gSaveContext.save.saveInfo.unk_EA8[0] = (((void)0, gSaveContext.save.saveInfo.unk_EA8[0]) & 0xFFFF00FF) | + ((((u8)gSaveContext.save.saveInfo.unk_EA8[1]) & 0xFF) << 8); break; case SCENE_INISIE_BS: - gSaveContext.save.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFF00FFFF) | - ((((u8)gSaveContext.save.unk_ECC[1]) & 0xFF) << 0x10); + gSaveContext.save.saveInfo.unk_EA8[0] = (((void)0, gSaveContext.save.saveInfo.unk_EA8[0]) & 0xFF00FFFF) | + ((((u8)gSaveContext.save.saveInfo.unk_EA8[1]) & 0xFF) << 0x10); break; case SCENE_SEA_BS: - gSaveContext.save.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0x00FFFFFF) | - ((((u8)gSaveContext.save.unk_ECC[1]) & 0xFF) << 0x18); + gSaveContext.save.saveInfo.unk_EA8[0] = (((void)0, gSaveContext.save.saveInfo.unk_EA8[0]) & 0x00FFFFFF) | + ((((u8)gSaveContext.save.saveInfo.unk_EA8[1]) & 0xFF) << 0x18); break; } - gSaveContext.save.unk_ECC[1] = - (gSaveContext.save.unk_ECC[1] & 0xFFFFFF00) | ((((u8)gSaveContext.save.unk_ECC[1]) + 1) & 0xFF); + gSaveContext.save.saveInfo.unk_EA8[1] = (gSaveContext.save.saveInfo.unk_EA8[1] & 0xFFFFFF00) | + ((((u8)gSaveContext.save.saveInfo.unk_EA8[1]) + 1) & 0xFF); Item_Give(play, func_808B849C(this, play) + (ITEM_REMAINS_ODOLWA - 1)); DoorWarp1_SetupAction(this, func_808B9E94); } @@ -594,7 +595,7 @@ void func_808B9ED8(DoorWarp1* this, PlayState* play) { } void func_808B9F10(DoorWarp1* this, PlayState* play) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); if ((this->unk_203 == 0) && func_808B866C(this, play) && !Play_InCsMode(play) && (this->unk_203 == 0)) { Player* player = GET_PLAYER(play); @@ -616,10 +617,10 @@ void func_808B9FD0(DoorWarp1* this, PlayState* play) { return; } - if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[9])) { - ActorCutscene_SetIntentToPlay(play->playerActorCsIds[9]); + if (!CutsceneManager_IsNext(play->playerCsIds[PLAYER_CS_ID_WARP_PAD_ENTRANCE])) { + CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_WARP_PAD_ENTRANCE]); } else { - ActorCutscene_Start(play->playerActorCsIds[9], NULL); + CutsceneManager_Start(play->playerCsIds[PLAYER_CS_ID_WARP_PAD_ENTRANCE], NULL); AudioSfx_PlaySfx(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); Animation_ChangeImpl(&this->skelAnime, &gWarpCrystalAnim, 1.0f, Animation_GetLastFrame(&gWarpCrystalAnim), @@ -637,7 +638,7 @@ void func_808BA10C(DoorWarp1* this, PlayState* play) { if ((play->sceneId == SCENE_MITURIN_BS) || (play->sceneId == SCENE_HAKUGIN_BS) || (play->sceneId == SCENE_INISIE_BS) || (play->sceneId == SCENE_SEA_BS)) { - D_801F4DE2 = play->sceneId; + gDungeonBossWarpSceneId = play->sceneId; if (play->sceneId == SCENE_MITURIN_BS) { phi_v0_2 = 0; } else if (play->sceneId == SCENE_HAKUGIN_BS) { @@ -652,24 +653,24 @@ void func_808BA10C(DoorWarp1* this, PlayState* play) { if (this->unk_202 != 0) { if (phi_v0_2 > 0) { - SET_WEEKEVENTREG(WEEKEVENTREG_07_80); + SET_WEEKEVENTREG(WEEKEVENTREG_ENTERED_WOODFALL_TEMPLE_PRISON); } switch (phi_v0_2) { case 0: - phi_a0 = gSaveContext.save.unk_ECC[0] & 0xFF; + phi_a0 = gSaveContext.save.saveInfo.unk_EA8[0] & 0xFF; break; case 1: - phi_a0 = (gSaveContext.save.unk_ECC[0] & 0xFF00) >> 8; + phi_a0 = (gSaveContext.save.saveInfo.unk_EA8[0] & 0xFF00) >> 8; break; case 2: - phi_a0 = (gSaveContext.save.unk_ECC[0] & 0xFF0000) >> 0x10; + phi_a0 = (gSaveContext.save.saveInfo.unk_EA8[0] & 0xFF0000) >> 0x10; break; case 3: - phi_a0 = (gSaveContext.save.unk_ECC[0] & 0xFF000000) >> 0x18; + phi_a0 = (gSaveContext.save.saveInfo.unk_EA8[0] & 0xFF000000) >> 0x18; break; default: @@ -705,64 +706,65 @@ void func_808BA10C(DoorWarp1* this, PlayState* play) { } play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } else { switch (phi_v0_2) { case 0: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { - SET_WEEKEVENTREG(WEEKEVENTREG_07_80); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE)) { + // Skips the entrance cutscene as this flag is attached to `ENTRANCE(WOODFALL_TEMPLE, 1)` + SET_WEEKEVENTREG(WEEKEVENTREG_ENTERED_WOODFALL_TEMPLE_PRISON); play->nextEntrance = ENTRANCE(WOODFALL_TEMPLE, 1); play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } else { play->nextEntrance = ENTRANCE(WOODFALL, 0); gSaveContext.nextCutsceneIndex = 0xFFF0; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } break; case 1: - SET_WEEKEVENTREG(WEEKEVENTREG_33_80); + SET_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE); play->nextEntrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 7); play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; break; case 3: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { play->nextEntrance = ENTRANCE(ZORA_CAPE, 9); gSaveContext.nextCutsceneIndex = 0xFFF0; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } else { - SET_WEEKEVENTREG(WEEKEVENTREG_55_80); + SET_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE); play->nextEntrance = ENTRANCE(ZORA_CAPE, 8); gSaveContext.nextCutsceneIndex = 0xFFF0; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } break; case 2: - SET_WEEKEVENTREG(WEEKEVENTREG_52_20); + SET_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE); play->nextEntrance = ENTRANCE(IKANA_CANYON, 15); gSaveContext.nextCutsceneIndex = 0xFFF2; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; break; } } } else if (DOORWARP1_GET_FF00_1(&this->dyna.actor) != 0xFF) { if (DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_6) { - gSaveContext.respawnFlag = ~1; + gSaveContext.respawnFlag = -2; } play->nextEntrance = play->setupExitList[DOORWARP1_GET_FF00_3(&this->dyna.actor)]; Scene_SetExitFade(play); @@ -833,7 +835,7 @@ void func_808BA550(DoorWarp1* this, PlayState* play) { } if (this->unk_1D0 > 140) { - play->envCtx.fillScreen = 1; + play->envCtx.fillScreen = true; temp_f0 = (this->unk_1D0 - 140) / 20.0f; if (temp_f0 > 1.0f) { temp_f0 = 1.0f; @@ -878,7 +880,7 @@ void func_808BA550(DoorWarp1* this, PlayState* play) { void func_808BAAF4(DoorWarp1* this, PlayState* play) { Player* player = GET_PLAYER(play); - s16 cutscene; + s16 csId; f32 phi_f2; phi_f2 = 200.0f; @@ -889,14 +891,14 @@ void func_808BAAF4(DoorWarp1* this, PlayState* play) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_86_80) && (fabsf(this->dyna.actor.xzDistToPlayer) < phi_f2) && ((player->actor.world.pos.y - 20.0f) < this->dyna.actor.world.pos.y) && (this->dyna.actor.world.pos.y < (player->actor.world.pos.y + 20.0f))) { - cutscene = this->dyna.actor.cutscene; + csId = this->dyna.actor.csId; - if (ActorCutscene_GetCanPlayNext(cutscene)) { - ActorCutscene_Start(cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(csId)) { + CutsceneManager_Start(csId, &this->dyna.actor); SET_WEEKEVENTREG(WEEKEVENTREG_86_80); DoorWarp1_SetupAction(this, func_808BABF4); } else { - ActorCutscene_SetIntentToPlay(cutscene); + CutsceneManager_Queue(csId); } } } diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h index 076999e57..1bc7e13bc 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.h @@ -53,7 +53,7 @@ typedef struct DoorWarp1 { /* 0x202 */ u8 unk_202; /* 0x203 */ u8 unk_203; /* 0x204 */ f32 unk_204; - /* 0x208 */ u8 unk_208; + /* 0x208 */ u8 cueId; } DoorWarp1; // size = 0x20C #endif // Z_DOOR_WARP1_H diff --git a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c index 9174fafc0..65fb8da2f 100644 --- a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c +++ b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c @@ -56,7 +56,7 @@ void EffChange_Init(Actor* thisx, PlayState* play) { this->step = 0; this->actor.shape.rot.y = 0; this->skeletonInfo.frameCtrl.unk_C = (2.0f / 3.0f); - ActorCutscene_SetIntentToPlay(0x7B); + CutsceneManager_Queue(CS_ID_GLOBAL_ELEGY); } void EffChange_Destroy(Actor* thisx, PlayState* play) { @@ -80,7 +80,7 @@ void func_80A4C5CC(EffChange* this, PlayState* play) { if (func_80183DE0(&this->skeletonInfo)) { Actor_Kill(&this->actor); - ActorCutscene_Stop(0x7B); + CutsceneManager_Stop(CS_ID_GLOBAL_ELEGY); func_800FD2B4(play, 0.0f, 850.0f, 0.2f, 0.0f); return; } @@ -109,11 +109,11 @@ void func_80A4C5CC(EffChange* this, PlayState* play) { phi_fv0 = 0.0f; } func_800FD2B4(play, phi_fv0, 850.0f, 0.2f, 0.0f); - if (ActorCutscene_GetCurrentIndex() != 0x7B) { - if (ActorCutscene_GetCanPlayNext(0x7B)) { - ActorCutscene_Start(0x7B, &this->actor); + if (CutsceneManager_GetCurrentCsId() != CS_ID_GLOBAL_ELEGY) { + if (CutsceneManager_IsNext(CS_ID_GLOBAL_ELEGY)) { + CutsceneManager_Start(CS_ID_GLOBAL_ELEGY, &this->actor); } else { - ActorCutscene_SetIntentToPlay(0x7B); + CutsceneManager_Queue(CS_ID_GLOBAL_ELEGY); } } } diff --git a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c index 75ff275a1..fbe4c27cf 100644 --- a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c +++ b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c @@ -82,15 +82,15 @@ void func_80BCEBC0(EffKamejimaWave* this, PlayState* play) { } void func_80BCEC6C(EffKamejimaWave* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 0x1E0)) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 0x1E0)); - if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x1E0)]->action == 2) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_480)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_480)); + if (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_480)]->id == 2) { this->scaleOffset = 0.05f; this->actionFunc = func_80BCEBC0; this->actor.draw = EffKamejimaWave_Draw; sVtxAlpha = 255; this->actor.shape.rot.x = 0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TORTOISE_WAKE_UP); + Actor_PlaySfx(&this->actor, NA_SE_EV_TORTOISE_WAKE_UP); } } else { this->actor.draw = NULL; @@ -117,9 +117,9 @@ void func_80BCED34(EffKamejimaWave* this, PlayState* play) { } void func_80BCEDE0(EffKamejimaWave* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 0x1F6)) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 0x1F6)); - if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x1F6)]->action == 2) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_502)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_502)); + if (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_502)]->id == 2) { this->scaleOffset = 0.03f; this->actor.scale.x = 0.35f; this->actionFunc = func_80BCED34; diff --git a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c index 0041f1e99..a37f4ec07 100644 --- a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c +++ b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c @@ -49,7 +49,7 @@ void EffLastday_Init(Actor* thisx, PlayState* play2) { case EFFLASTDAY_PARAMS_1: this->dList = object_lastday_DL_000510; this->matAnim = Lib_SegmentedToVirtual(object_lastday_Matanimheader_000608); - this->csActionCmd = 0x1FC; + this->cueType = CS_CMD_ACTOR_CUE_508; this->actionFunc = func_80BEBDF8; Actor_SetScale(&this->actor, 1.0f); break; @@ -57,7 +57,7 @@ void EffLastday_Init(Actor* thisx, PlayState* play2) { case EFFLASTDAY_PARAMS_2: this->dList = object_lastday_DL_000210; this->matAnim = Lib_SegmentedToVirtual(object_lastday_Matanimheader_000308); - this->csActionCmd = 0x1FD; + this->cueType = CS_CMD_ACTOR_CUE_509; this->actionFunc = func_80BEBEB8; Actor_SetScale(&this->actor, 0.5f); break; @@ -65,7 +65,7 @@ void EffLastday_Init(Actor* thisx, PlayState* play2) { case EFFLASTDAY_PARAMS_3: this->dList = object_lastday_DL_000060; this->matAnim = Lib_SegmentedToVirtual(object_lastday_Matanimheader_000148); - this->csActionCmd = 0x1FE; + this->cueType = CS_CMD_ACTOR_CUE_510; this->actionFunc = func_80BEBF78; Actor_SetScale(&this->actor, 0.2f); this->actor.home.rot.z = 0; @@ -74,7 +74,7 @@ void EffLastday_Init(Actor* thisx, PlayState* play2) { default: this->dList = object_lastday_DL_000370; this->matAnim = Lib_SegmentedToVirtual(object_lastday_Matanimheader_000448); - this->csActionCmd = 0x1FB; + this->cueType = CS_CMD_ACTOR_CUE_507; this->actionFunc = func_80BEBD0C; Actor_SetScale(&this->actor, 1.0f); Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EFF_LASTDAY, this->actor.world.pos.x, @@ -94,12 +94,12 @@ void EffLastday_Destroy(Actor* thisx, PlayState* play) { } void func_80BEBD0C(EffLastday* this, PlayState* play) { - u16 csAction; + u16 cueId; - if ((Cutscene_CheckActorAction(play, this->csActionCmd))) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csActionCmd)); - csAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionCmd)]->action; - switch (csAction) { + if ((Cutscene_IsCueInChannel(play, this->cueType))) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); + cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; + switch (cueId) { default: this->actor.draw = NULL; this->alpha = 0; @@ -128,12 +128,12 @@ void func_80BEBD0C(EffLastday* this, PlayState* play) { } void func_80BEBDF8(EffLastday* this, PlayState* play) { - u16 csAction; + u16 cueId; - if (Cutscene_CheckActorAction(play, this->csActionCmd)) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csActionCmd)); - csAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionCmd)]->action; - switch (csAction) { + if (Cutscene_IsCueInChannel(play, this->cueType)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); + cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; + switch (cueId) { default: this->actor.draw = NULL; this->step = 0; @@ -154,12 +154,12 @@ void func_80BEBDF8(EffLastday* this, PlayState* play) { } void func_80BEBEB8(EffLastday* this, PlayState* play) { - u16 csAction; + u16 cueId; - if (Cutscene_CheckActorAction(play, this->csActionCmd)) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csActionCmd)); - csAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionCmd)]->action; - switch (csAction) { + if (Cutscene_IsCueInChannel(play, this->cueType)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); + cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; + switch (cueId) { default: this->actor.draw = NULL; this->step = 0; @@ -180,12 +180,12 @@ void func_80BEBEB8(EffLastday* this, PlayState* play) { } void func_80BEBF78(EffLastday* this, PlayState* play) { - u16 csAction; + u16 cueId; - if (Cutscene_CheckActorAction(play, this->csActionCmd)) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csActionCmd)); - csAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionCmd)]->action; - switch (csAction) { + if (Cutscene_IsCueInChannel(play, this->cueType)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); + cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; + switch (cueId) { default: this->actor.draw = NULL; this->alpha = 0; @@ -195,7 +195,7 @@ void func_80BEBF78(EffLastday* this, PlayState* play) { case EFFLASTDAY_ACTION_2: if (!this->actor.home.rot.z) { this->actor.home.rot.z = true; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_COMING_FIRE); + Actor_PlaySfx(&this->actor, NA_SE_EV_COMING_FIRE); } this->actor.draw = EffLastday_Draw; if (this->alpha < 255) { diff --git a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.h b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.h index 89266d744..0b5002863 100644 --- a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.h +++ b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.h @@ -15,7 +15,7 @@ typedef struct EffLastday { /* 0x148 */ AnimatedMaterial* matAnim; /* 0x14C */ s16 step; /* 0x14E */ s16 alpha; - /* 0x150 */ s16 csActionCmd; + /* 0x150 */ s16 cueType; /* 0x154 */ EffLastdayActionFunc actionFunc; } EffLastday; // size = 0x158 diff --git a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c index 842ae4b9e..2b1c01c59 100644 --- a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c +++ b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c @@ -43,12 +43,12 @@ void EffZoraband_Destroy(Actor* thisx, PlayState* play) { } void EffZoraband_MikauFadeOut(EffZoraband* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 0x20F)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_527)) { if ((EFFZORABAND_GET_F(&this->actor) + 2) == - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x20F)]->action) { + play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_527)]->id) { this->stateFlags |= 2; } - if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x20F)]->action == 7) { + if (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_527)]->id == 7) { this->actor.draw = NULL; } else { this->actor.draw = EffZoraband_Draw; diff --git a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c index 3d7df7c27..c88835373 100644 --- a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c +++ b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c @@ -111,21 +111,21 @@ void func_8092E284(ElfMsg* this, PlayState* play) { if ((player->tatlActor != NULL) && ((func_8092E1FC(this)))) { player->tatlTextId = func_8092E1D0(this); - ActorCutscene_SetIntentToPlay(0x7C); + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); tatl->elfMsg = &this->actor; - if (this->actor.cutscene == -1) { - this->actor.cutscene = 0x7C; + if (this->actor.csId == CS_ID_NONE) { + this->actor.csId = CS_ID_GLOBAL_TALK; } if ((player->tatlTextId < 0) && (this->actor.home.rot.x < 0)) { - if (ActorCutscene_GetCurrentIndex() == 0x7D) { - ActorCutscene_Stop(0x7D); - ActorCutscene_SetIntentToPlay(this->actor.cutscene); - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_DOOR) { + CutsceneManager_Stop(CS_ID_GLOBAL_DOOR); + CutsceneManager_Queue(this->actor.csId); + } else if (CutsceneManager_IsNext(this->actor.csId)) { this->actor.home.rot.x = 0; - ActorCutscene_Start(this->actor.cutscene, &this->actor); + CutsceneManager_Start(this->actor.csId, &this->actor); func_800E0348(play->cameraPtrs[CAM_ID_MAIN]); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } } diff --git a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c index a29b226b0..8244c7fb6 100644 --- a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c +++ b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c @@ -100,9 +100,9 @@ s32 func_8096EE50(ElfMsg2* this) { void func_8096EE64(ElfMsg2* this, PlayState* play) { if (Actor_TextboxIsClosing(&this->actor, play)) { - if (this->actor.cutscene != -1) { - if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { - ActorCutscene_Stop(this->actor.cutscene); + if (this->actor.csId != CS_ID_NONE) { + if (CutsceneManager_GetCurrentCsId() == this->actor.csId) { + CutsceneManager_Stop(this->actor.csId); } } @@ -115,14 +115,14 @@ void func_8096EE64(ElfMsg2* this, PlayState* play) { } ElfMsg2_SetupAction(this, func_8096EF98); - } else if ((this->actor.cutscene != -1) && (ActorCutscene_GetCurrentIndex() != this->actor.cutscene)) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actor.cutscene); - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); + } else if ((this->actor.csId != CS_ID_NONE) && (CutsceneManager_GetCurrentCsId() != this->actor.csId)) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->actor.csId); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } } diff --git a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c index da6b29180..e3e8b7bc5 100644 --- a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c +++ b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c @@ -110,20 +110,20 @@ void func_80A2CF7C(ElfMsg3* this, PlayState* play) { ((player->actor.world.pos.y - this->actor.world.pos.y) < (100.0f * this->actor.scale.y))) && (fabsf(player->actor.world.pos.z - this->actor.world.pos.z) < (100.0f * this->actor.scale.z))) { player->tatlTextId = func_80A2CF50(this); - ActorCutscene_SetIntentToPlay(0x7C); + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); tatl->elfMsg = &this->actor; - if (this->actor.cutscene == -1) { - this->actor.cutscene = 0x7C; + if (this->actor.csId == CS_ID_NONE) { + this->actor.csId = CS_ID_GLOBAL_TALK; } if ((player->tatlTextId < 0) && (this->actor.home.rot.x < 0)) { - if (ActorCutscene_GetCurrentIndex() == 0x7D) { - ActorCutscene_Stop(0x7D); - ActorCutscene_SetIntentToPlay(this->actor.cutscene); - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_DOOR) { + CutsceneManager_Stop(CS_ID_GLOBAL_DOOR); + CutsceneManager_Queue(this->actor.csId); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); func_800E0348(play->cameraPtrs[CAM_ID_MAIN]); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } } diff --git a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c index 7fbf402fa..c917f01a7 100644 --- a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c +++ b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c @@ -115,20 +115,20 @@ void func_80AFD668(ElfMsg4* this, PlayState* play) { if ((player->tatlActor != NULL) && func_80AFD5E0(this)) { player->tatlTextId = ElfMsg4_GetTextId(this); - ActorCutscene_SetIntentToPlay(0x7C); + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); tatl->elfMsg = this->elfMsg5; - if (this->actor.cutscene == -1) { - this->actor.cutscene = 0x7C; + if (this->actor.csId == CS_ID_NONE) { + this->actor.csId = CS_ID_GLOBAL_TALK; } if ((player->tatlTextId < 0) && (this->actor.home.rot.x < 0)) { - if (ActorCutscene_GetCurrentIndex() == 0x7D) { - ActorCutscene_Stop(0x7D); - ActorCutscene_SetIntentToPlay((s16)this->actor.cutscene); - } else if (ActorCutscene_GetCanPlayNext((s16)this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_DOOR) { + CutsceneManager_Stop(CS_ID_GLOBAL_DOOR); + CutsceneManager_Queue(this->actor.csId); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); func_800E0348(play->cameraPtrs[CAM_ID_MAIN]); } else { - ActorCutscene_SetIntentToPlay((s16)this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } } @@ -139,7 +139,7 @@ void func_80AFD770(ElfMsg4* this, PlayState* play) { while (bgActor != NULL) { if ((bgActor->id != ACTOR_ELF_MSG5) || (ELFMSG4_GET_TEXT(&this->actor) != ELFMSG5_GET_FF(bgActor)) || - (this->actor.cutscene != bgActor->cutscene)) { + (this->actor.csId != bgActor->csId)) { bgActor = bgActor->next; } else { this->elfMsg5 = bgActor; diff --git a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c index 0ffb5c758..89fbd9f6b 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c @@ -154,15 +154,15 @@ void ElfMsg6_Init(Actor* thisx, PlayState* play) { case 1: this->actionFunc = func_80BA1F80; - if ((this->actor.cutscene == -1) || ((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && - Flags_GetSwitch(play, ELFMSG6_SWITCHFLAG(&this->actor)))) { + if ((this->actor.csId == CS_ID_NONE) || ((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && + Flags_GetSwitch(play, ELFMSG6_SWITCHFLAG(&this->actor)))) { Actor_Kill(&this->actor); return; } switch (ELFMSG6_GET_F0(&this->actor)) { case 0: - if (gSaveContext.save.inventory.items[ITEM_HOOKSHOT] != ITEM_HOOKSHOT) { + if (gSaveContext.save.saveInfo.inventory.items[ITEM_HOOKSHOT] != ITEM_HOOKSHOT) { Actor_Kill(&this->actor); return; } @@ -246,10 +246,10 @@ void func_80BA1C88(ElfMsg6* this, PlayState* play, s16 arg2) { if (player->tatlActor != NULL) { player->tatlTextId = arg2; - ActorCutscene_SetIntentToPlay(0x7C); + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); sp20->elfMsg = &this->actor; - if (this->actor.cutscene == -1) { - this->actor.cutscene = 0x7C; + if (this->actor.csId == CS_ID_NONE) { + this->actor.csId = CS_ID_GLOBAL_TALK; } } } @@ -278,12 +278,12 @@ void func_80BA1CF8(ElfMsg6* this, PlayState* play) { if ((this->actor.textId == 0x224) && CHECK_WEEKEVENTREG(WEEKEVENTREG_08_40)) { this->actor.textId = 0x25B; - } else if (func_80BA1C00(this) && (player->actor.speedXZ > 1.0f)) { + } else if (func_80BA1C00(this) && (player->actor.speed > 1.0f)) { player->tatlTextId = -this->actor.textId; - ActorCutscene_SetIntentToPlay(0x7C); + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); sp20->elfMsg = &this->actor; - if (this->actor.cutscene == -1) { - this->actor.cutscene = 0x7C; + if (this->actor.csId == CS_ID_NONE) { + this->actor.csId = CS_ID_GLOBAL_TALK; } } } @@ -319,12 +319,12 @@ void func_80BA1E30(ElfMsg6* this, PlayState* play) { return; } - if (func_80BA1C00(this) && (player->actor.speedXZ > 1.0f)) { + if (func_80BA1C00(this) && (player->actor.speed > 1.0f)) { player->tatlTextId = -this->actor.textId; - ActorCutscene_SetIntentToPlay(0x7C); + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); sp20->elfMsg = &this->actor; - if (this->actor.cutscene == -1) { - this->actor.cutscene = 0x7C; + if (this->actor.csId == CS_ID_NONE) { + this->actor.csId = CS_ID_GLOBAL_TALK; } } } @@ -336,14 +336,14 @@ void func_80BA1F80(ElfMsg6* this, PlayState* play) { } if (func_80BA1C00(this)) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, NULL); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, NULL); Flags_SetSwitch(play, ELFMSG6_SWITCHFLAG(&this->actor)); Actor_Kill(&this->actor); return; } - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index 5ea851023..d9fbeb6f0 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -557,7 +557,7 @@ void EnAh_Update(Actor* thisx, PlayState* play) { func_8013C964(&this->actor, play, radius, height, PLAYER_IA_NONE, this->unk_2D8 & 7); if (!(this->unk_2D8 & 0x10)) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } func_80BD2BA4(this, play); } 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 d2bdf0cee..41dba0aab 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -129,10 +129,10 @@ static InitChainEntry sInitChain[] = { }; void func_80BECBE0(EnAkindonuts* this, s16 arg1) { - f32 sp24 = Math_CosS(this->actor.world.rot.x) * this->actor.speedXZ; + f32 sp24 = Math_CosS(this->actor.world.rot.x) * this->actor.speed; this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * sp24; - this->actor.velocity.y = Math_SinS(this->actor.world.rot.x) * this->actor.speedXZ; + this->actor.velocity.y = Math_SinS(this->actor.world.rot.x) * this->actor.speed; this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * sp24; if (arg1) { @@ -150,7 +150,7 @@ void func_80BECC7C(EnAkindonuts* this, PlayState* play) { } if (this->unk_32C & 2) { - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } } @@ -179,7 +179,7 @@ s32 func_80BECD10(EnAkindonuts* this, Path* path, s32 arg2) { phi_f14 = sp5C[idx + 1].z - sp5C[idx - 1].z; } - func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RAD_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { sp50 = true; } @@ -300,7 +300,7 @@ s32 func_80BED208(EnAkindonuts* this) { return 0; } - if (gSaveContext.save.playerData.rupees < 10) { + if (gSaveContext.save.saveInfo.playerData.rupees < 10) { return 1; } @@ -322,7 +322,7 @@ s32 func_80BED27C(EnAkindonuts* this) { return 0; } - if (gSaveContext.save.playerData.rupees < 200) { + if (gSaveContext.save.saveInfo.playerData.rupees < 200) { return 1; } @@ -336,7 +336,7 @@ s32 func_80BED2FC(EnAkindonuts* this) { return 2; } - if (gSaveContext.save.playerData.rupees < 40) { + if (gSaveContext.save.saveInfo.playerData.rupees < 40) { return 1; } @@ -350,7 +350,7 @@ s32 func_80BED35C(EnAkindonuts* this) { return 2; } - if (gSaveContext.save.playerData.rupees < 100) { + if (gSaveContext.save.saveInfo.playerData.rupees < 100) { return 1; } @@ -1084,10 +1084,10 @@ void func_80BEE73C(EnAkindonuts* this, PlayState* play) { this->unk_33C = player->actor.textId; this->actionFunc = func_80BEF18C; } - func_801477B4(play); + Message_CloseTextbox(play); } else if (itemAction <= PLAYER_IA_MINUS1) { this->unk_33C = D_80BF04AC[params]; - func_80151938(play, this->unk_33C); + Message_ContinueTextbox(play, this->unk_33C); this->actionFunc = func_80BEF18C; } } @@ -1173,7 +1173,7 @@ void func_80BEEB20(EnAkindonuts* this, PlayState* play) { } if (phi_v0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80BEEDC0; this->unk_338 = 3; this->collider.dim.height = 64; @@ -1186,12 +1186,12 @@ void func_80BEEB20(EnAkindonuts* this, PlayState* play) { if ((this->unk_338 == 4) || (this->unk_338 == 18)) { this->unk_338 = 17; this->collider.dim.height = 0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DOWN); SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 17); } else if (this->unk_338 == 2) { this->unk_338 = 16; this->collider.dim.height = 32; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_UP); SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 16); } else if (this->unk_338 == 17) { phi_v0 = DECR(this->unk_33A); @@ -1330,19 +1330,19 @@ void func_80BEF360(EnAkindonuts* this, PlayState* play) { this->unk_32C &= ~0x40; this->actionFunc = func_80BEF450; } else { - Actor_PickUp(&this->actor, play, func_80BED034(this), 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, func_80BED034(this), 300.0f, 300.0f); } } else if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; this->actionFunc = func_80BEF450; } else { - Actor_PickUp(&this->actor, play, func_80BECFBC(this), 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, func_80BECFBC(this), 300.0f, 300.0f); } } void func_80BEF450(EnAkindonuts* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { - func_800B85E0(&this->actor, play, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); this->actionFunc = func_80BEF4B8; } } @@ -1352,7 +1352,7 @@ void func_80BEF4B8(EnAkindonuts* this, PlayState* play) { this->unk_2DC(this, play); this->actionFunc = func_80BEEFA8; } else { - func_800B85E0(&this->actor, play, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); } } @@ -1417,14 +1417,14 @@ void func_80BEF518(EnAkindonuts* this, PlayState* play) { } if (this->unk_35E == 0) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); this->unk_35E = 1; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); return; } } @@ -1433,7 +1433,7 @@ void func_80BEF518(EnAkindonuts* this, PlayState* play) { this->unk_33E = 3; this->unk_338 = 19; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_338); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_32C &= ~2; this->unk_32C |= 0x80; this->unk_358 = this->actor.world.pos.y; @@ -1492,7 +1492,7 @@ void func_80BEF83C(EnAkindonuts* this, PlayState* play) { this->unk_34C = 0.3f; this->unk_338 = 9; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_338); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80BEF9F0; } } @@ -1529,7 +1529,7 @@ void func_80BEFAF0(EnAkindonuts* this, PlayState* play) { if (this->path != NULL) { sp34 = func_80BECEAC(this->path, this->unk_334, &this->actor.world.pos, &sp38); - if (this->actor.bgCheckFlags & 0x8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { sp38.y = this->actor.wallYaw; } @@ -1546,14 +1546,14 @@ void func_80BEFAF0(EnAkindonuts* this, PlayState* play) { if (func_80BECD10(this, this->path, this->unk_334) && (sp34 < 10.0f)) { if (this->unk_334 >= (this->path->count - 1)) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->actionFunc = func_80BEFD74; } else { this->unk_334++; } } } else if (this->actor.playerHeightRel > 500.0f) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->actionFunc = func_80BEFD74; } @@ -1561,25 +1561,25 @@ void func_80BEFAF0(EnAkindonuts* this, PlayState* play) { if (this->unk_334 >= 3) { sp32 = true; } - Math_ApproachF(&this->actor.speedXZ, 1.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 1.5f, 0.2f, 1.0f); } else { - Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 2.0f, 0.2f, 1.0f); } func_80BECBE0(this, sp32); if (this->unk_35E == 2) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); this->unk_35E = 3; } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); return; } } else if ((this->unk_35E == 1) && (this->unk_356 == 20)) { - ActorCutscene_Stop(this->cutscene); - this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Stop(this->csId); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); + CutsceneManager_Queue(this->csId); this->unk_35E = 2; } this->unk_356++; @@ -1617,7 +1617,7 @@ void EnAkindonuts_Init(Actor* thisx, PlayState* play) { this->unk_32C |= 0x2; this->unk_32C |= 0x4; this->unk_338 = 4; - this->cutscene = this->actor.cutscene; + this->csId = this->actor.csId; func_80BEE938(this, play); this->actionFunc = func_80BEEB20; } diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.h b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.h index 72c932d0c..180d73ed4 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.h +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.h @@ -43,7 +43,7 @@ typedef struct EnAkindonuts { /* 0x358 */ f32 unk_358; /* 0x35C */ s16 unk_35C; /* 0x35E */ s16 unk_35E; - /* 0x360 */ s16 cutscene; + /* 0x360 */ s16 csId; /* 0x362 */ s16 unk_362; /* 0x364 */ s16 unk_364; /* 0x366 */ s8 unk_366; diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index da1cc7d7e..87b83e670 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -219,30 +219,30 @@ Actor* func_80BDE384(EnAl* this, PlayState* play) { return actor; } -s32 func_80BDE408(EnAl* this, s16 arg1) { +s32 func_80BDE408(EnAl* this, s16 csId) { s32 ret = false; - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(arg1); - } else if (ActorCutscene_GetCanPlayNext(arg1)) { - ActorCutscene_StartAndSetUnkLinkFields(arg1, &this->actor); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(csId); + } else if (CutsceneManager_IsNext(csId)) { + CutsceneManager_StartWithPlayerCs(csId, &this->actor); ret = true; } else { - ActorCutscene_SetIntentToPlay(arg1); + CutsceneManager_Queue(csId); } return ret; } -s16 func_80BDE484(EnAl* this, s32 arg1) { - s16 cs = this->actor.cutscene; +s16 func_80BDE484(EnAl* this, s32 numCutscenes) { + s16 csId = this->actor.csId; s32 i; - for (i = 0; i < arg1; i++) { - cs = ActorCutscene_GetAdditionalCutscene(cs); + for (i = 0; i < numCutscenes; i++) { + csId = CutsceneManager_GetAdditionalCsId(csId); } - return cs; + return csId; } s32 func_80BDE4E0(EnAl* this, s16* arg1, s16 arg2) { @@ -257,7 +257,7 @@ s32 func_80BDE4E0(EnAl* this, s16* arg1, s16 arg2) { } if (arg2 == *arg1) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHAIR_ROLL); func_80BDE27C(this, 3); this->unk_4E8 = 0; (*arg1)++; @@ -292,7 +292,7 @@ s32 func_80BDE678(EnAl* this, s16* arg1, s16 arg2) { } if (arg2 == *arg1) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHAIR_ROLL); func_80BDE27C(this, 4); this->unk_4E8 = 0; (*arg1)++; @@ -317,13 +317,13 @@ s32 func_80BDE678(EnAl* this, s16* arg1, s16 arg2) { s32 func_80BDE7FC(EnAl* this, PlayState* play) { s32 pad; - s16 sp2A = func_80BDE484(this, 0); + s16 csId = func_80BDE484(this, 0); s32 pad2; s32 sp20 = false; switch (this->unk_4E6) { case 0: - if (!func_80BDE408(this, sp2A)) { + if (!func_80BDE408(this, csId)) { break; } @@ -332,7 +332,8 @@ s32 func_80BDE7FC(EnAl* this, PlayState* play) { case 6: case 8: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)), + this->actor.child); } this->unk_4E6++; sp20 = true; @@ -342,13 +343,13 @@ s32 func_80BDE7FC(EnAl* this, PlayState* play) { case 3: case 5: case 7: - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)), &this->actor); this->unk_4E6++; sp20 = true; break; case 9: - ActorCutscene_Stop(sp2A); + CutsceneManager_Stop(csId); this->unk_4E6++; sp20 = true; break; diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index f76ebc4f3..31d137299 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -198,7 +198,7 @@ void EnAm_SpawnEffects(EnAm* this, PlayState* play) { effectPos.z = randPlusMinusPoint5Scaled(65.0f) + this->actor.world.pos.z; EffectSsKirakira_SpawnSmall(play, &effectPos, &sVelocity, &sAccel, &D_808B1118, &D_808B111C); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_AMOS_WALK); Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 4.0f, 3, 8.0f, 300, 15, 0); } @@ -231,8 +231,8 @@ void EnAm_RemoveEnemyTexture(EnAm* this, PlayState* play) { } void EnAm_WakeUp(EnAm* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_WAVE); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_VOICE); + Actor_PlaySfx(&this->actor, NA_SE_EN_AMOS_WAVE); + Actor_PlaySfx(&this->actor, NA_SE_EN_AMOS_VOICE); this->returnHomeTimer = 300; this->actionFunc = EnAm_ApplyEnemyTexture; } @@ -265,22 +265,22 @@ void EnAm_ApplyEnemyTexture(EnAm* this, PlayState* play) { void func_808B0208(EnAm* this, PlayState* play) { // If the armos is against a wall, rotate and turn away from it - if ((this->actor.speedXZ > 0.0f) && (this->actor.bgCheckFlags & 8)) { + if ((this->actor.speed > 0.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_WALL)) { this->actor.world.rot.y = (this->actor.wallYaw * 2) - this->actor.world.rot.y; - this->actor.world.pos.x += this->actor.speedXZ * Math_SinS(this->actor.world.rot.y); - this->actor.world.pos.z += this->actor.speedXZ * Math_CosS(this->actor.world.rot.y); + this->actor.world.pos.x += this->actor.speed * Math_SinS(this->actor.world.rot.y); + this->actor.world.pos.z += this->actor.speed * Math_CosS(this->actor.world.rot.y); } SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 8.0f) != 0) { - this->actor.speedXZ = this->speed; + this->actor.speed = this->speed; this->actor.velocity.y = 12.0f; } else if (this->skelAnime.curFrame > 11.0f) { - if (!(this->actor.bgCheckFlags & 1)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->skelAnime.curFrame = 11.0f; } else { Math_ScaledStepToS(&this->actor.world.rot.y, this->armosYaw, 0x1F40); - this->actor.speedXZ = 0.0f; - if (this->actor.bgCheckFlags & 2) { + this->actor.speed = 0.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { EnAm_SpawnEffects(this, play); } } @@ -293,7 +293,7 @@ void func_808B0208(EnAm* this, PlayState* play) { void func_808B0358(EnAm* this) { Animation_PlayLoopSetSpeed(&this->skelAnime, &gArmosHopAnim, 4.0f); this->explodeTimer = 3; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->speed = 6.0f; this->actionFunc = func_808B03C0; @@ -302,12 +302,12 @@ void func_808B0358(EnAm* this) { void func_808B03C0(EnAm* this, PlayState* play) { this->armosYaw = this->actor.yawTowardsPlayer; func_808B0208(this, play); - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { this->explodeTimer--; } if (this->explodeTimer == 0) { func_808B0640(this); - } else if ((this->returnHomeTimer == 0) || Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 240.0f) { + } else if ((this->returnHomeTimer == 0) || Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 240.0f) { func_808B0460(this); } } @@ -315,7 +315,7 @@ void func_808B03C0(EnAm* this, PlayState* play) { void func_808B0460(EnAm* this) { this->actor.world.rot.y = this->actor.shape.rot.y; this->speed = 0.0f; - this->armosYaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->armosYaw = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); this->actionFunc = func_808B04A8; } @@ -334,7 +334,7 @@ void func_808B04E4(EnAm* this) { void func_808B0508(EnAm* this, PlayState* play) { func_808B0208(this, play); - if (!(this->actor.bgCheckFlags & 1)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { Math_StepToF(&this->actor.world.pos.x, this->actor.home.pos.x, 2.0f); Math_StepToF(&this->actor.world.pos.z, this->actor.home.pos.z, 2.0f); } @@ -345,15 +345,15 @@ void func_808B0508(EnAm* this, PlayState* play) { void func_808B057C(EnAm* this) { this->speed = 6.0f; - this->armosYaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->armosYaw = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); this->explodeTimer = 1; this->actionFunc = func_808B05C8; } void func_808B05C8(EnAm* this, PlayState* play) { - this->armosYaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->armosYaw = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); func_808B0208(this, play); - if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 8.0f) { + if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) < 8.0f) { func_808B04E4(this); } } @@ -372,7 +372,7 @@ void func_808B066C(EnAm* this, PlayState* play) { this->armosYaw = this->actor.yawTowardsPlayer; func_808B0208(this, play); if (this->armosYaw == this->actor.shape.rot.y) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_VOICE); + Actor_PlaySfx(&this->actor, NA_SE_EN_AMOS_VOICE); func_808B0358(this); } } @@ -382,16 +382,17 @@ void EnAm_TakeDamage(EnAm* this, PlayState* play) { Animation_Change(&this->skelAnime, &gArmosTakeDamageAnim, 1.0f, 4.0f, Animation_GetLastFrame(&gArmosTakeDamageAnim) - 6, ANIMMODE_ONCE, 0.0f); func_800BE504(&this->actor, &this->enemyCollider); - this->actor.speedXZ = 6.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, Animation_GetLastFrame(&gArmosTakeDamageAnim) - 10); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DAMAGE); + this->actor.speed = 6.0f; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, + Animation_GetLastFrame(&gArmosTakeDamageAnim) - 10); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_DAMAGE); this->enemyCollider.base.acFlags &= ~AC_ON; this->textureBlend = 255; this->actionFunc = func_808B07A8; } void func_808B07A8(EnAm* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.colChkInfo.health == 0) { func_808B0820(this); @@ -407,7 +408,7 @@ void func_808B0820(EnAm* this) { this->explodeTimer = 64; this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.flags |= ACTOR_FLAG_10; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->speed = 6.0f; this->actionFunc = func_808B0894; } @@ -426,7 +427,7 @@ void func_808B0894(EnAm* this, PlayState* play) { if (bomb != NULL) { bomb->timer = 0; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_DEAD); Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0xB0); for (i = 0; i < 8; i++) { @@ -440,7 +441,7 @@ void func_808B0894(EnAm* this, PlayState* play) { Actor_Kill(&this->actor); return; } else if (!(this->explodeTimer & 3)) { - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 4); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 4); } if (this->actor.world.rot.z < 0x1F40) { this->actor.world.rot.z += 0x320; @@ -451,12 +452,12 @@ void func_808B0894(EnAm* this, PlayState* play) { void func_808B0AD0(EnAm* this, PlayState* play) { Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 1.0f, 0.0f, 8.0f, ANIMMODE_ONCE, 0.0f); this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actor.speedXZ = -6.0f; + this->actor.speed = -6.0f; this->actionFunc = func_808B0B4C; } void func_808B0B4C(EnAm* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); if (SkelAnime_Update(&this->skelAnime)) { func_808B0358(this); } @@ -508,7 +509,9 @@ void EnAm_Update(Actor* thisx, PlayState* play) { } this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 30.0f, 100.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 30.0f, 100.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); Actor_SetFocus(&this->actor, 64.0f); Collider_UpdateCylinder(&this->actor, &this->enemyCollider); Collider_UpdateCylinder(&this->actor, &this->interactCollider); diff --git a/src/overlays/actors/ovl_En_And/z_en_and.c b/src/overlays/actors/ovl_En_And/z_en_and.c index 5c888ba45..c1f229751 100644 --- a/src/overlays/actors/ovl_En_And/z_en_and.c +++ b/src/overlays/actors/ovl_En_And/z_en_and.c @@ -10,14 +10,13 @@ #define THIS ((EnAnd*)thisx) +#define EYE_TEXTURES_COUNT 4 + void EnAnd_Init(Actor* thisx, PlayState* play); void EnAnd_Destroy(Actor* thisx, PlayState* play); void EnAnd_Update(Actor* thisx, PlayState* play); void EnAnd_Draw(Actor* thisx, PlayState* play); -void func_80C18C50(EnAnd* this, PlayState* play); - -#if 0 ActorInit En_And_InitVars = { ACTOR_EN_AND, ACTORCAT_NPC, @@ -30,22 +29,163 @@ ActorInit En_And_InitVars = { (ActorFunc)EnAnd_Draw, }; -#endif +static AnimationInfoS sAnimationInfo[] = { + { &gAndStaticAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gAndIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gAndWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gAndRaiseHeadAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAndRaisedHeadLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gAndRaiseHandAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAndRaisedHandLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gAndRaisedHandWalkAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, +}; -extern UNK_TYPE D_0600B380; +s32 EnAnd_ChangeAnim(EnAnd* this, s32 animIndex) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_And/func_80C18B90.s") + if (this->animIndex != animIndex) { + this->animIndex = animIndex; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_And/func_80C18BD8.s") +void EnAnd_Blink(EnAnd* this) { + if (DECR(this->blinkTimer) == 0) { + this->eyeTexIndex++; + if (this->eyeTexIndex >= EYE_TEXTURES_COUNT) { + this->blinkTimer = Rand_S16Offset(30, 30); + this->eyeTexIndex = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_And/func_80C18C50.s") +void EnAnd_HandleCutscene(EnAnd* this, PlayState* play) { + s32 csAnimations[] = { 0, 1, 2, 3, 5, 7 }; + u16 cueType; + s32 cueChannel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_And/EnAnd_Init.s") + if (play->csCtx.state != CS_STATE_IDLE) { + if (!this->isCutscenePlaying) { + // Cutscene is starting + this->cueId = 255; + this->isCutscenePlaying = true; + this->prevAnimIndex = this->animIndex; + } + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_565)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_565); + cueType = play->csCtx.actorCues[cueChannel]->id; + if (this->cueId != (u8)cueType) { + this->cueId = cueType; + EnAnd_ChangeAnim(this, csAnimations[cueType]); + } + switch (this->cueId) { + case 3: + case 4: + if ((this->animIndex == 3) || (this->animIndex == 5)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + EnAnd_ChangeAnim(this, this->animIndex + 1); + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_And/EnAnd_Destroy.s") + default: + break; + } + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); + } + } else if (this->isCutscenePlaying) { + this->isCutscenePlaying = false; + EnAnd_ChangeAnim(this, this->prevAnimIndex); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_And/EnAnd_Update.s") +void EnAnd_Init(Actor* thisx, PlayState* play) { + EnAnd* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_And/func_80C18ED0.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 14.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gAndSkel, NULL, this->jointTable, this->morphTable, + OBJECT_AND_LIMB_MAX); + this->animIndex = -1; + EnAnd_ChangeAnim(this, 0); + Actor_SetScale(&this->actor, 0.01f); + this->actor.flags &= ~ACTOR_FLAG_1; + this->flags |= 8; + this->actionFunc = EnAnd_HandleCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_And/EnAnd_Draw.s") +void EnAnd_Destroy(Actor* thisx, PlayState* play) { +} + +void EnAnd_Update(Actor* thisx, PlayState* play) { + EnAnd* this = THIS; + + this->actionFunc(this, play); + SkelAnime_Update(&this->skelAnime); + EnAnd_Blink(this); +} + +void EnAnd_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { + EnAnd* this = THIS; + s32 stepRot; + s32 overrideRot; + + stepRot = this->flags & 8 ? false : true; + overrideRot = this->flags & 2 ? true : false; + if (!stepRot) { + overrideRot = false; + } + + switch (limbIndex) { + case OBJECT_AND_LIMB_HEAD: + SubS_UpdateLimb(this->headRotZ + this->torsoRotZ + 0x4000, + this->headRotY + this->torsoRotY + this->actor.shape.rot.y + 0x4000, &this->headComputedPos, + &this->headComputedRot, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->headComputedPos.x, this->headComputedPos.y, this->headComputedPos.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->headComputedRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headComputedRot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->headComputedRot.z, MTXMODE_APPLY); + Matrix_Push(); + break; + + case OBJECT_AND_LIMB_TORSO: + SubS_UpdateLimb(this->torsoRotZ + 0x4000, this->torsoRotY + this->actor.shape.rot.y + 0x4000, + &this->torsoComputedPos, &this->torsoComputedRot, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->torsoComputedPos.x, this->torsoComputedPos.y, this->torsoComputedPos.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->torsoComputedRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->torsoComputedRot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->torsoComputedRot.z, MTXMODE_APPLY); + Matrix_Push(); + break; + + default: + break; + } +} + +void EnAnd_Draw(Actor* thisx, PlayState* play) { + static TexturePtr sMouthTextures[] = { gAndMouthNeutralTex, gAndMouthSmileTex }; + static TexturePtr sEyeTextures[EYE_TEXTURES_COUNT] = { + gAndEyeOpenTex, + gAndEyeClosingTex, + gAndEyeClosedTex, + gAndEyeOpeningTex, + }; + EnAnd* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sMouthTextures[0])); + + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, EnAnd_TransformLimbDraw, &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_And/z_en_and.h b/src/overlays/actors/ovl_En_And/z_en_and.h index a0610a408..6b5a0bb7d 100644 --- a/src/overlays/actors/ovl_En_And/z_en_and.h +++ b/src/overlays/actors/ovl_En_And/z_en_and.h @@ -2,6 +2,7 @@ #define Z_EN_AND_H #include "global.h" +#include "objects/object_and/object_and.h" struct EnAnd; @@ -9,9 +10,29 @@ typedef void (*EnAndActionFunc)(struct EnAnd*, PlayState*); typedef struct EnAnd { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x44]; + /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnAndActionFunc actionFunc; - /* 0x18C */ char unk_18C[0x188]; + /* 0x18C */ u8 cueId; + /* 0x18D */ UNK_TYPE1 pad18D[0x7]; + /* 0x194 */ Vec3f headComputedPos; + /* 0x1A0 */ Vec3f torsoComputedPos; + /* 0x1AC */ Vec3s headComputedRot; + /* 0x1B2 */ Vec3s torsoComputedRot; + /* 0x1B8 */ Vec3s jointTable[OBJECT_AND_LIMB_MAX]; + /* 0x254 */ Vec3s morphTable[OBJECT_AND_LIMB_MAX]; + /* 0x2F0 */ u16 flags; + /* 0x2F2 */ UNK_TYPE1 pad2F2[0x4]; + /* 0x2F6 */ s16 headRotZ; + /* 0x2F8 */ s16 headRotY; + /* 0x2FA */ s16 torsoRotZ; + /* 0x2FC */ s16 torsoRotY; + /* 0x2FE */ UNK_TYPE1 pad2FE[0x2]; + /* 0x300 */ s16 blinkTimer; + /* 0x302 */ s16 eyeTexIndex; + /* 0x304 */ s32 animIndex; + /* 0x308 */ s32 prevAnimIndex; + /* 0x30C */ s32 isCutscenePlaying; + /* 0x310 */ UNK_TYPE1 pad310[4]; } EnAnd; // size = 0x314 #endif // Z_EN_AND_H diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c index 8e98ae8a3..d978d8380 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -211,7 +211,7 @@ void EnAni_FallToGround(EnAni* this, PlayState* play) { s32 pad; s16 quakeIndex; - if (this->actor.bgCheckFlags & 1) { // hit the ground + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->actor.flags &= ~ACTOR_FLAG_10; this->actionFunc = EnAni_LandOnFoot; this->actor.velocity.x = 0.0f; @@ -220,12 +220,12 @@ void EnAni_FallToGround(EnAni* this, PlayState* play) { Animation_Change(&this->skelAnime, &gAniLandingThenStandingUpAnim, 1.0f, 0.0f, 16.0f, ANIMMODE_ONCE, 0.0f); this->stateFlags |= ANI_STATE_WRITHING; - quakeIndex = Quake_Add(play->cameraPtrs[CAM_ID_MAIN], QUAKE_TYPE_3); + quakeIndex = Quake_Request(play->cameraPtrs[CAM_ID_MAIN], QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 27000); - Quake_SetQuakeValues(quakeIndex, 7, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 20); + Quake_SetPerturbations(quakeIndex, 7, 0, 0, 0); + Quake_SetDuration(quakeIndex, 20); - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_HAMMER_HIT); + Actor_PlaySfx(&this->actor, NA_SE_IT_HAMMER_HIT); } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2, 0x7D0, 0x100); @@ -291,7 +291,7 @@ void EnAni_Update(Actor* thisx, PlayState* play) { } Actor_UpdatePos(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); if (this->actor.xzDistToPlayer < 100.0f && !(this->stateFlags & ANI_STATE_CLIMBING)) { Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->chestRot, this->actor.focus.pos); @@ -305,15 +305,15 @@ void EnAni_Update(Actor* thisx, PlayState* play) { this->blinkFunc(this); if (this->stateFlags & ANI_STATE_FALLING) { - if (this->actor.cutscene == -1) { + if (this->actor.csId == CS_ID_NONE) { this->stateFlags &= ~ANI_STATE_FALLING; - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); - this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); - Camera_SetToTrackActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(this->actor.cutscene)), - &this->actor); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); + this->actor.csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); + Camera_SetFocalActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(this->actor.csId)), + &this->actor); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } } 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 a6624dc38..45a413c26 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 @@ -12,27 +12,25 @@ #define THIS ((EnAob01*)thisx) -//! TODO: this file require macros for its uses of weekEventReg - void EnAob01_Init(Actor* thisx, PlayState* play); void EnAob01_Destroy(Actor* thisx, PlayState* play); void EnAob01_Update(Actor* thisx, PlayState* play); void EnAob01_Draw(Actor* thisx, PlayState* play); -void func_809C1C9C(EnAob01* this, PlayState* play); -void func_809C1D64(EnAob01* this, PlayState* play); -void func_809C2060(EnAob01* this, PlayState* play); -void func_809C21E0(EnAob01* this, PlayState* play); -void func_809C26E4(EnAob01* this, PlayState* play); -void func_809C2730(EnAob01* this, PlayState* play); -void func_809C2788(EnAob01* this, PlayState* play); -void func_809C2824(EnAob01* this, PlayState* play); -void func_809C28B8(EnAob01* this, PlayState* play); -void func_809C2A64(EnAob01* this, PlayState* play); -void func_809C2BE4(EnAob01* this, PlayState* play); -void func_809C2C9C(EnAob01* this, PlayState* play); -void func_809C2D0C(EnAob01* this, PlayState* play); -s32 func_809C2EC4(EnAob01* this, PlayState* play); +void EnAob01_BeforeRace_StartRace(EnAob01* this, PlayState* play); +void EnAob01_BeforeRace_RespondToPlayAgainQuestion(EnAob01* this, PlayState* play); +void EnAob01_BeforeRace_Idle(EnAob01* this, PlayState* play); +void EnAob01_BeforeRace_Talk(EnAob01* this, PlayState* play); +void EnAob01_Race_SkipNonRaceCutscene(EnAob01* this, PlayState* play); +void EnAob01_Race_HandleRaceCutscene(EnAob01* this, PlayState* play); +void EnAob01_Race_HandleRaceEndCutscene(EnAob01* this, PlayState* play); +void EnAob01_Race_StartCutscene(EnAob01* this, PlayState* play); +void EnAob01_AfterRace_GiveRaceResult(EnAob01* this, PlayState* play); +void EnAob01_AfterRace_GiveReward(EnAob01* this, PlayState* play); +void EnAob01_AfterRace_AfterGivingReward(EnAob01* this, PlayState* play); +void EnAob01_AfterRace_AskToPlayAgain(EnAob01* this, PlayState* play); +void EnAob01_AfterRace_Talk(EnAob01* this, PlayState* play); +s32 EnAob01_PlayerIsHoldingDog(EnAob01* this, PlayState* play); ActorInit En_Aob_01_InitVars = { ACTOR_EN_AOB_01, @@ -46,6 +44,22 @@ ActorInit En_Aob_01_InitVars = { (ActorFunc)EnAob01_Draw, }; +typedef enum { + /* 0 */ EN_AOB01_ANIM_IDLE_1, + /* 1 */ EN_AOB01_ANIM_LAUGH_START, + /* 2 */ EN_AOB01_ANIM_LAUGH_LOOP, + /* 3 */ EN_AOB01_ANIM_SURPRISE_START, + /* 4 */ EN_AOB01_ANIM_SURPRISE_LOOP, + /* 5 */ EN_AOB01_ANIM_IDLE_2, +} EnAob01Animation; + +typedef enum { + /* 0 */ EN_AOB01_EYE_OPEN, + /* 1 */ EN_AOB01_EYE_HALF, + /* 2 */ EN_AOB01_EYE_CLOSED, + /* 3 */ EN_AOB01_EYE_MAX, +} EnAob01EyeTexture; + static AnimationInfo sAnimationInfo[] = { { &gMamamuYanIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, { &gMamamuYanLaughStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, @@ -76,12 +90,16 @@ static ColliderCylinderInit sCylinderInit = { }; typedef struct { - Vec3f unk_00; - s16 unk_04; - s16 unk_06; -} EnAobStruct; + /* 0x0 */ Vec3f pos; + /* 0xC */ s16 rotY; + /* 0xE */ s16 pathIndex; +} DogInfo; // size = 0x10 -static EnAobStruct D_809C384C[] = { +/** + * Stores the starting position, y-rotation, and path index for all 14 dogs in the racetrack. + * This actor is responsible for spawning these dogs; they are not spawned as part of the scene. + */ +static DogInfo sDogInfo[RACEDOG_COUNT] = { { { -4130.0f, 150.0f, 1367.0f }, 84, 0 }, { { -4861.0f, 172.0f, 1606.0f }, 94, 4 }, { { -4139.0f, 155.0f, 2133.0f }, 73, 6 }, { { -4406.0f, 144.0f, 1416.0f }, 88, 2 }, { { -4156.0f, 155.0f, 1731.0f }, 42, 0 }, { { -4033.0f, 157.0f, 1994.0f }, -65, 1 }, @@ -91,105 +109,137 @@ static EnAobStruct D_809C384C[] = { { { -4827.0f, 168.0f, 1328.0f }, 115, 4 }, { { -4130.0f, 150.0f, 1367.0f }, 112, 0 }, }; -void func_809C10B0(EnAob01* this, s32 arg1) { +void EnAob01_Blink(EnAob01* this, s32 maxEyeIndex) { if (DECR(this->blinkTimer) == 0) { this->eyeIndex++; - if (this->eyeIndex >= arg1) { - this->eyeIndex = 0; + if (this->eyeIndex >= maxEyeIndex) { + this->eyeIndex = EN_AOB01_EYE_OPEN; this->blinkTimer = Rand_S16Offset(30, 30); } } } -void func_809C1124(void) { +/** + * Called every frame during the race in order to make in-game time pass. + */ +void EnAob01_AdvanceTime(void) { gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)R_TIME_SPEED; gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.timeSpeedOffset); } -void func_809C1158(EnAob01* this, PlayState* play) { - s32 temp_s0 = ENAOB01_GET_7E00_2(&this->actor); +/** + * Initializes all the paths that the dogs follow. + */ +void EnAob01_InitializeDogPaths(EnAob01* this, PlayState* play) { + s32 pathIndex = ENAOB01_GET_STARTING_DOG_PATH_INDEX(&this->actor); s16 i = 0; - if (temp_s0 != 0x3F) { + if (pathIndex != 0x3F) { do { - this->unk_1D8[i] = SubS_GetPathByIndex(play, temp_s0, 0x3F); - temp_s0 = this->unk_1D8[i]->unk1; + this->dogPaths[i] = SubS_GetPathByIndex(play, pathIndex, 0x3F); + pathIndex = this->dogPaths[i]->unk1; i++; - } while (temp_s0 != 0xFF); + } while (pathIndex != 0xFF); } } -void func_809C11EC(EnAob01* this, PlayState* play) { +/** + * Spawns the dogs that mill about the racetrack before and after each race. + */ +void EnAob01_SpawnDogs(EnAob01* this, PlayState* play) { s32 enDgParams; s16 i; - func_809C1158(this, play); + EnAob01_InitializeDogPaths(this, play); - for (i = 0; i < ARRAY_COUNT(D_809C384C); i++) { - enDgParams = ENDG_PARAMS(this->unk_1D8[D_809C384C[i].unk_06]->unk1, i); + for (i = 0; i < RACEDOG_COUNT; i++) { + enDgParams = ENDG_PARAMS(this->dogPaths[sDogInfo[i].pathIndex]->unk1, i); - this->unk_3F8[i] = Actor_SpawnAsChildAndCutscene( - &play->actorCtx, play, ACTOR_EN_DG, D_809C384C[i].unk_00.x, D_809C384C[i].unk_00.y, D_809C384C[i].unk_00.z, - 0, D_809C384C[i].unk_04 * 182.04445f, 0, enDgParams, 0xFFFF, this->actor.unk20, NULL); + this->dogs[i] = Actor_SpawnAsChildAndCutscene( + &play->actorCtx, play, ACTOR_EN_DG, sDogInfo[i].pos.x, sDogInfo[i].pos.y, sDogInfo[i].pos.z, 0, + DEG_TO_BINANG(sDogInfo[i].rotY), 0, enDgParams, (u16)CS_ID_NONE, this->actor.halfDaysBits, NULL); } } -void func_809C1304(EnAob01* this, PlayState* play) { +/** + * Spawns the dogs that run around the track during each race. + */ +void EnAob01_SpawnRacedogs(EnAob01* this, PlayState* play) { s16 i; - for (i = 0; i < ARRAY_COUNT(this->unk_3F8); i++) { - this->unk_3F8[i] = Actor_SpawnAsChildAndCutscene( - &play->actorCtx, play, ACTOR_EN_RACEDOG, (i * 15.0f) + -3897.0f, 130.0f, 1290.0f - (i * 10.0f), 0, 0x1555, - 0, (i << 5) | ENAOB01_GET_7E00_1(&this->actor), 0xFFFF, this->actor.unk20, NULL); + for (i = 0; i < RACEDOG_COUNT; i++) { + this->dogs[i] = Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_RACEDOG, (i * 15.0f) + -3897.0f, + 130.0f, 1290.0f - (i * 10.0f), 0, 0x1555, 0, + ENRACEDOG_PARAMS(i, ENAOB01_GET_RACEDOG_PATH_INDEX(&this->actor)), + (u16)CS_ID_NONE, this->actor.halfDaysBits, NULL); } } -s32 func_809C1424(EnAob01* this) { +/** + * If the racetrack owner is at the end of her laugh start animation, this function will + * transition her to her laugh loop animation. This function will return true if she is + * *either* in her laugh start or laugh loop animation, false otherwise. + */ +s32 EnAob01_ProcessLaughAnim(EnAob01* this) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_43C].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if (this->unk_43C == 1) { + if (this->animIndex == EN_AOB01_ANIM_LAUGH_START) { if (curFrame == lastFrame) { - this->unk_43C = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + this->animIndex = EN_AOB01_ANIM_LAUGH_LOOP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_AOB01_ANIM_LAUGH_LOOP); return true; } - } else if (this->unk_43C == 2) { + } else if (this->animIndex == EN_AOB01_ANIM_LAUGH_LOOP) { return true; } + return false; } -s32 func_809C14D0(EnAob01* this) { +/** + * If the racetrack owner is at the end of her idle animation, this function will + * transition her to her surprise start animation. If the racetrack owner is at the + * end of her surprise start animation, this function will transition her to her + * surprise loop animation. This function will return true if she is *either* in + * her surprise start or surprise loop animation, false otherwise. + */ +s32 EnAob01_ProcessSurpriseAnim(EnAob01* this) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_43C].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if ((this->unk_43C == 0) || (this->unk_43C == 5)) { + if ((this->animIndex == EN_AOB01_ANIM_IDLE_1) || (this->animIndex == EN_AOB01_ANIM_IDLE_2)) { if (curFrame == lastFrame) { - this->unk_43C = 3; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); + this->animIndex = EN_AOB01_ANIM_SURPRISE_START; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_AOB01_ANIM_SURPRISE_START); return true; } - } else if (this->unk_43C == 3) { + } else if (this->animIndex == EN_AOB01_ANIM_SURPRISE_START) { if (curFrame == lastFrame) { - this->unk_43C = 4; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); + this->animIndex = EN_AOB01_ANIM_SURPRISE_LOOP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_AOB01_ANIM_SURPRISE_LOOP); return true; } - } else if (this->unk_43C == 4) { + } else if (this->animIndex == EN_AOB01_ANIM_SURPRISE_LOOP) { return true; } + return false; } -s32 func_809C15BC(EnAob01* this) { +/** + * If the racetrack owner is at the end of her current animation, this function will + * transition her to her the idle animation. This function will return true if she is + * in her idle animation, false otherwise. + */ +s32 EnAob01_ProcessIdleAnim(EnAob01* this) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_43C].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if ((this->unk_43C != 0) && (this->unk_43C != 5)) { + if ((this->animIndex != EN_AOB01_ANIM_IDLE_1) && (this->animIndex != EN_AOB01_ANIM_IDLE_2)) { if (curFrame == lastFrame) { - this->unk_43C = 5; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); + this->animIndex = EN_AOB01_ANIM_IDLE_2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_AOB01_ANIM_IDLE_2); return true; } } else { @@ -199,7 +249,7 @@ s32 func_809C15BC(EnAob01* this) { return false; } -void func_809C165C(EnAob01* this, PlayState* play) { +void EnAob01_UpdateCollision(EnAob01* this, PlayState* play) { 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; @@ -207,263 +257,278 @@ void func_809C165C(EnAob01* this, PlayState* play) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void func_809C16DC(EnAob01* this, PlayState* play) { +/** + * Handles all parts of the conversation with the racetrack owner before the race begins. + */ +void EnAob01_BeforeRace_HandleConversation(EnAob01* this, PlayState* play) { Player* player = GET_PLAYER(play); - switch (this->unk_210) { + switch (this->textId) { case 0: - case 0x3524: - case 0x3535: - case 0x3548: - case 0x3549: - case 0x354A: + case 0x3524: // You can't play if you can't pay! + case 0x3535: // Really? + case 0x3548: // I can't let you play. (Goron) + case 0x3549: // I can't let you play. (Zora) + case 0x354A: // I can't let you play. (Deku) switch (gSaveContext.save.day) { case 1: if (!gSaveContext.save.isNight) { - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_64_80)) { - SET_WEEKEVENTREG(WEEKEVENTREG_64_80); - this->unk_210 = 0x3520; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_DAY_1)) { + SET_WEEKEVENTREG(WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_DAY_1); + this->textId = 0x3520; // This is the Doggy Racetrack. (Day 1) } else { - this->unk_210 = 0x352F; + this->textId = 0x352F; // What do you want? } } else { - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_65_01)) { - SET_WEEKEVENTREG(WEEKEVENTREG_65_01); - this->unk_210 = 0x3530; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_NIGHT_1)) { + SET_WEEKEVENTREG(WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_NIGHT_1); + this->textId = 0x3530; // This is the Doggy Racetrack. (Night 1) } else { - this->unk_210 = 0x352F; + this->textId = 0x352F; // What do you want? } } break; case 2: if (!gSaveContext.save.isNight) { - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_65_02)) { - SET_WEEKEVENTREG(WEEKEVENTREG_65_02); - this->unk_210 = 0x3531; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_DAY_2)) { + SET_WEEKEVENTREG(WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_DAY_2); + this->textId = 0x3531; // This is the Doggy Racetrack. (Day 2) } else { - this->unk_210 = 0x352F; + this->textId = 0x352F; // What do you want? } } else { - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_65_04)) { - SET_WEEKEVENTREG(WEEKEVENTREG_65_04); - this->unk_210 = 0x3532; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_NIGHT_2)) { + SET_WEEKEVENTREG(WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_NIGHT_2); + this->textId = 0x3532; // This is the Doggy Racetrack. (Night 2) } else { - this->unk_210 = 0x352F; + this->textId = 0x352F; // What do you want? } } break; case 3: if (!gSaveContext.save.isNight) { - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_65_08)) { - SET_WEEKEVENTREG(WEEKEVENTREG_65_08); - this->unk_210 = 0x3533; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_DAY_3)) { + SET_WEEKEVENTREG(WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_DAY_3); + this->textId = 0x3533; // This is the Doggy Racetrack. (Day 3) } else { - this->unk_210 = 0x352F; + this->textId = 0x352F; // What do you want? } } else { - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_65_10)) { - SET_WEEKEVENTREG(WEEKEVENTREG_65_10); - this->unk_210 = 0x3534; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_NIGHT_3)) { + SET_WEEKEVENTREG(WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_NIGHT_3); + this->textId = 0x3534; // This is the Doggy Racetrack. (Night 3) } else { - this->unk_210 = 0x352F; + this->textId = 0x352F; // What do you want? } } break; } break; - case 0x3520: - case 0x352F: - case 0x3530: - case 0x3531: - case 0x3532: - case 0x3533: - case 0x3534: - this->unk_210 = 0x3521; + case 0x3520: // This is the Doggy Racetrack. (Day 1) + case 0x352F: // What do you want? + case 0x3530: // This is the Doggy Racetrack. (Night 1) + case 0x3531: // This is the Doggy Racetrack. (Day 2) + case 0x3532: // This is the Doggy Racetrack. (Night 2) + case 0x3533: // This is the Doggy Racetrack. (Day 3) + case 0x3534: // This is the Doggy Racetrack. (Night 3) + this->textId = 0x3521; // Do you want to try the dog race? break; - case 0x3521: - if (this->unk_2D2 & 2) { - this->unk_2D2 &= ~2; + case 0x3521: // Do you want to try the dog race? + if (this->stateFlags & ENAOB01_FLAG_PLAYER_CONFIRMED_CHOICE) { + this->stateFlags &= ~ENAOB01_FLAG_PLAYER_CONFIRMED_CHOICE; switch (player->transformation) { case PLAYER_FORM_GORON: - this->unk_210 = 0x3548; - this->unk_2D2 |= 0x10; + this->textId = 0x3548; // I can't let you play. (Goron) + this->stateFlags |= ENAOB01_FLAG_CONVERSATION_OVER; break; case PLAYER_FORM_ZORA: - this->unk_210 = 0x3549; - this->unk_2D2 |= 0x10; + this->textId = 0x3549; // I can't let you play. (Zora) + this->stateFlags |= ENAOB01_FLAG_CONVERSATION_OVER; break; case PLAYER_FORM_DEKU: - this->unk_210 = 0x354A; - this->unk_2D2 |= 0x10; + this->textId = 0x354A; // I can't let you play. (Deku) + this->stateFlags |= ENAOB01_FLAG_CONVERSATION_OVER; break; case PLAYER_FORM_HUMAN: - if (gSaveContext.save.playerData.rupees < 10) { - this->unk_210 = 0x3524; - this->unk_2D2 |= 0x10; + if (gSaveContext.save.saveInfo.playerData.rupees < 10) { + this->textId = 0x3524; // You can't play if you can't pay! + this->stateFlags |= ENAOB01_FLAG_CONVERSATION_OVER; } else { - this->unk_210 = 0x3522; - this->unk_2D2 |= 4; - this->unk_2D2 |= 0x10; + this->textId = 0x3522; // Bring me the fastest dog! + this->stateFlags |= ENAOB01_FLAG_PLAYER_TOLD_TO_PICK_A_DOG; + this->stateFlags |= ENAOB01_FLAG_CONVERSATION_OVER; } } } else { - this->unk_2D2 |= 0x10; - this->unk_210 = 0x3535; + this->stateFlags |= ENAOB01_FLAG_CONVERSATION_OVER; + this->textId = 0x3535; // Is that dog fine? } break; - case 0x3522: - case 0x3523: - if (this->unk_2D2 & 8) { - this->unk_210 = 0x3525; + case 0x3522: // Bring me the fastest dog! + case 0x3523: // Hurry up and bring me a dog! + if (this->stateFlags & ENAOB01_FLAG_TALKING_TO_PLAYER_HOLDING_DOG) { + this->textId = 0x3525; // Is that dog okay? break; } - this->unk_210 = 0x3523; - this->unk_2D2 |= 0x40; - this->unk_2D2 |= 0x10; - this->unk_43C = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + this->textId = 0x3523; // Hurry up and bring me a dog! + this->stateFlags |= ENAOB01_FLAG_LAUGH; + this->stateFlags |= ENAOB01_FLAG_CONVERSATION_OVER; + this->animIndex = EN_AOB01_ANIM_LAUGH_START; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_AOB01_ANIM_LAUGH_START); break; - case 0x3525: - case 0x3526: - if (this->unk_2D2 & 4) { - if (this->unk_2D2 & 8) { - this->unk_210 = 0x3525; + case 0x3525: // Is that dog okay? + case 0x3526: // Don't wait! Hurry up and choose! + if (this->stateFlags & ENAOB01_FLAG_PLAYER_TOLD_TO_PICK_A_DOG) { + if (this->stateFlags & ENAOB01_FLAG_TALKING_TO_PLAYER_HOLDING_DOG) { + this->textId = 0x3525; // Is that dog okay? break; } - this->unk_210 = 0x3523; - this->unk_2D2 |= 0x40; - this->unk_2D2 |= 0x10; - this->unk_43C = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + this->textId = 0x3523; // Hurry up and bring me a dog! + this->stateFlags |= ENAOB01_FLAG_LAUGH; + this->stateFlags |= ENAOB01_FLAG_CONVERSATION_OVER; + this->animIndex = EN_AOB01_ANIM_LAUGH_START; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_AOB01_ANIM_LAUGH_START); break; } - if (this->unk_2D2 & 2) { - this->unk_2D2 &= ~2; - this->unk_210 = 0x3527; + if (this->stateFlags & ENAOB01_FLAG_PLAYER_CONFIRMED_CHOICE) { + this->stateFlags &= ~ENAOB01_FLAG_PLAYER_CONFIRMED_CHOICE; + this->textId = 0x3527; // If you win, you'll get more than you bet. break; } - this->unk_210 = 0x3526; - this->unk_2D2 |= 0x40; - this->unk_2D2 |= 4; - this->unk_2D2 |= 0x10; - this->unk_43C = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + this->textId = 0x3526; // Don't wait! Hurry up and choose! + this->stateFlags |= ENAOB01_FLAG_LAUGH; + this->stateFlags |= ENAOB01_FLAG_PLAYER_TOLD_TO_PICK_A_DOG; + this->stateFlags |= ENAOB01_FLAG_CONVERSATION_OVER; + this->animIndex = EN_AOB01_ANIM_LAUGH_START; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_AOB01_ANIM_LAUGH_START); break; - case 0x3527: - this->unk_210 = 0x3528; + case 0x3527: // If you win, you'll get more than you bet. + this->textId = 0x3528; // How much will you bet? break; - case 0x3528: - if (gSaveContext.save.playerData.rupees < this->unk_434) { - this->unk_210 = 0x3536; - this->unk_2D2 |= 0x40; - this->unk_43C = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + case 0x3528: // How much will you bet? + if (gSaveContext.save.saveInfo.playerData.rupees < this->rupeesBet) { + this->textId = 0x3536; // You don't have enough rupees for that bet. + this->stateFlags |= ENAOB01_FLAG_LAUGH; + this->animIndex = EN_AOB01_ANIM_LAUGH_START; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_AOB01_ANIM_LAUGH_START); break; } - if (this->unk_434 == 0) { - this->unk_210 = 0x3537; - this->unk_2D2 |= 0x40; - this->unk_43C = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + if (this->rupeesBet == 0) { + this->textId = 0x3537; // You can't race if you don't bet. + this->stateFlags |= ENAOB01_FLAG_LAUGH; + this->animIndex = EN_AOB01_ANIM_LAUGH_START; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_AOB01_ANIM_LAUGH_START); break; } - gSaveContext.unk_3F5C = this->unk_434; - play->msgCtx.bankRupees = this->unk_434; - this->unk_210 = 0x3529; + gSaveContext.unk_3F5C = this->rupeesBet; + play->msgCtx.bankRupees = this->rupeesBet; + this->textId = 0x3529; // Is that bet okay? break; - case 0x3529: - if (this->unk_2D2 & 2) { - this->unk_2D2 &= ~2; - Rupees_ChangeBy(-this->unk_434); - func_800B7298(play, NULL, PLAYER_CSMODE_7); + case 0x3529: // Is that bet okay? + if (this->stateFlags & ENAOB01_FLAG_PLAYER_CONFIRMED_CHOICE) { + this->stateFlags &= ~ENAOB01_FLAG_PLAYER_CONFIRMED_CHOICE; + Rupees_ChangeBy(-this->rupeesBet); + func_800B7298(play, NULL, PLAYER_CSMODE_WAIT); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; - this->actionFunc = func_809C1C9C; + this->actionFunc = EnAob01_BeforeRace_StartRace; return; } - this->unk_210 = 0x3528; + this->textId = 0x3528; // How much will you bet? break; - case 0x3536: - case 0x3537: - this->unk_210 = 0x3528; + case 0x3536: // You don't have enough rupees for that bet. + case 0x3537: // You can't race if you don't bet. + this->textId = 0x3528; // How much will you bet? break; } - Message_StartTextbox(play, this->unk_210, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); } -void func_809C1C9C(EnAob01* this, PlayState* play) { +/** + * Once the player's rupees are done counting down, this function will + * reload the racetrack to start the race. + */ +void EnAob01_BeforeRace_StartRace(EnAob01* this, PlayState* play) { if (gSaveContext.rupeeAccumulator == 0) { - SET_WEEKEVENTREG(WEEKEVENTREG_63_01); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); - this->unk_2D2 |= 0x20; - func_800FD750(0x40); + SET_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); + this->stateFlags |= ENAOB01_FLAG_STARTED_RACE; + func_800FD750(NA_BGM_HORSE); play->nextEntrance = ENTRANCE(DOGGY_RACETRACK, 1); play->transitionType = TRANS_TYPE_64; gSaveContext.nextTransitionType = TRANS_TYPE_64; - gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 2; - gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (this->unk_432 * 8); + SET_EVENTINF_DOG_RACE_STATE(EVENTINF_DOG_RACE_STATE_STARTED); + SET_EVENTINF_DOG_RACE_SELECTED_DOG_INDEX(this->selectedDogIndex); play->transitionTrigger = TRANS_TRIGGER_START; } } -void func_809C1D64(EnAob01* this, PlayState* play) { +/** + * Handles the player's response to the question of whether or not they want to play again. + * Once the textbox closes, the racetrack owner will go back to being idle. + */ +void EnAob01_BeforeRace_RespondToPlayAgainQuestion(EnAob01* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); if (talkState == TEXT_STATE_CHOICE) { if (Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: - if (gSaveContext.save.playerData.rupees < 10) { + if (gSaveContext.save.saveInfo.playerData.rupees < 10) { play_sound(NA_SE_SY_ERROR); - this->unk_210 = 0x3524; - Message_StartTextbox(play, this->unk_210, &this->actor); + this->textId = 0x3524; // You can't play if you can't pay! + Message_StartTextbox(play, this->textId, &this->actor); } else { func_8019F208(); - this->unk_2D2 |= 4; - this->unk_2D2 |= 0x10; - this->unk_210 = 0x3522; - Message_StartTextbox(play, this->unk_210, &this->actor); - this->actionFunc = func_809C21E0; + this->stateFlags |= ENAOB01_FLAG_PLAYER_TOLD_TO_PICK_A_DOG; + this->stateFlags |= ENAOB01_FLAG_CONVERSATION_OVER; + this->textId = 0x3522; // Bring me the fastest dog! + Message_StartTextbox(play, this->textId, &this->actor); + this->actionFunc = EnAob01_BeforeRace_Talk; } break; case 1: func_8019F230(); - this->unk_210 = 0x3535; - Message_StartTextbox(play, this->unk_210, &this->actor); + this->textId = 0x3535; // Really? + Message_StartTextbox(play, this->textId, &this->actor); break; } } } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; - this->unk_210 = 0; - this->actionFunc = func_809C2060; + this->textId = 0; + this->actionFunc = EnAob01_BeforeRace_Idle; } } -void func_809C1EC8(EnAob01* this, PlayState* play) { +/** + * Handles various things that are common to all action functions, like tracking the + * player, blinking, handling collision, etc. + */ +void EnAob01_UpdateCommon(EnAob01* this, PlayState* play) { static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, @@ -474,6 +539,7 @@ void func_809C1EC8(EnAob01* this, PlayState* play) { Vec3f point; SkelAnime_Update(&this->skelAnime); + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer)) { point.x = player->actor.world.pos.x; point.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; @@ -488,124 +554,153 @@ void func_809C1EC8(EnAob01* this, PlayState* play) { Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); } - func_809C10B0(this, 3); - SubS_FillLimbRotTables(play, this->unk_2F8, this->unk_318, ARRAY_COUNT(this->unk_2F8)); - func_809C165C(this, play); + + EnAob01_Blink(this, EN_AOB01_EYE_MAX); + SubS_FillLimbRotTables(play, this->limbRotTableY, this->limbRotTableZ, ARRAY_COUNT(this->limbRotTableY)); + EnAob01_UpdateCollision(this, play); + + // This specific code ensures that in-game time passes during the race. if (player->stateFlags1 & PLAYER_STATE1_20) { - func_809C1124(); + EnAob01_AdvanceTime(); } } -void func_809C2060(EnAob01* this, PlayState* play) { - if (func_809C15BC(this)) { - if (func_809C2EC4(this, play) && !(this->unk_2D2 & 0x100)) { +/** + * Stand around and wait until either the player talks to the racetrack owner or until + * the player bumps into them while holding a dog. In either case, the racetrack owner + * will then start talking with the player. + */ +void EnAob01_BeforeRace_Idle(EnAob01* this, PlayState* play) { + if (EnAob01_ProcessIdleAnim(this)) { + if (EnAob01_PlayerIsHoldingDog(this, play) && !(this->stateFlags & ENAOB01_FLAG_PLAYER_CAN_TALK)) { if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, play, 100.0f); - this->unk_2D2 |= 8; - this->actionFunc = func_809C21E0; + this->stateFlags |= ENAOB01_FLAG_TALKING_TO_PLAYER_HOLDING_DOG; + this->actionFunc = EnAob01_BeforeRace_Talk; } - } else if (Actor_ProcessTalkRequest(&this->actor, &play->state) && (this->unk_2D2 & 0x100)) { - this->unk_2D2 &= ~0x100; - this->unk_2E6 = this->trackTarget; - this->unk_2EC = this->headRot; - this->unk_2F2 = this->torsoRot; - func_809C16DC(this, play); - this->actionFunc = func_809C21E0; + } else if (Actor_ProcessTalkRequest(&this->actor, &play->state) && + (this->stateFlags & ENAOB01_FLAG_PLAYER_CAN_TALK)) { + this->stateFlags &= ~ENAOB01_FLAG_PLAYER_CAN_TALK; + this->prevTrackTarget = this->trackTarget; + this->prevHeadRot = this->headRot; + this->prevTorsoRot = this->torsoRot; + EnAob01_BeforeRace_HandleConversation(this, play); + this->actionFunc = EnAob01_BeforeRace_Talk; } else { - this->unk_2D2 &= ~0x100; + this->stateFlags &= ~ENAOB01_FLAG_PLAYER_CAN_TALK; if ((this->actor.xzDistToPlayer < 100.0f) && !(this->collider.base.ocFlags2 & OC2_HIT_PLAYER)) { - this->unk_2D2 |= 0x100; + this->stateFlags |= ENAOB01_FLAG_PLAYER_CAN_TALK; func_800B8614(&this->actor, play, 100.0f); } } } } -void func_809C21E0(EnAob01* this, PlayState* play) { +/** + * Handles the actual action of talking with the player before the race begins. + */ +void EnAob01_BeforeRace_Talk(EnAob01* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 4000, 1); - if ((this->unk_2D2 & 8) && !func_809C2EC4(this, play)) { - if ((this->unk_210 != 0) && (this->unk_210 != 0x3535) && (this->unk_210 != 0x3524) && - (this->unk_210 != 0x3548) && (this->unk_210 != 0x3549) && (this->unk_210 != 0x354A)) { - this->unk_210 = 0x3523; + //! @bug: This block of code acts as a failsafe for when the player triggered this conversation by + //! bumping into the racetrack owner while holding the dog and, at the same time, threw or dropped + //! the dog frame-perfectly by pressing A. In this case, the code successfully returns the racetrack + //! owner to her idle state. Unfortunately, the player can also drop the dog by shielding. If this + //! shield drop is done frame-perfectly, then the below code will not function properly and will + //! instead softlock the game. + if ((this->stateFlags & ENAOB01_FLAG_TALKING_TO_PLAYER_HOLDING_DOG) && !EnAob01_PlayerIsHoldingDog(this, play)) { + if ((this->textId != 0) && (this->textId != 0x3535) && (this->textId != 0x3524) && (this->textId != 0x3548) && + (this->textId != 0x3549) && (this->textId != 0x354A)) { + this->textId = 0x3523; // Hurry up and bring me a dog! } + this->actor.textId = 0; - this->unk_2D2 &= ~8; + this->stateFlags &= ~ENAOB01_FLAG_TALKING_TO_PLAYER_HOLDING_DOG; this->actor.flags &= ~ACTOR_FLAG_10000; - this->actionFunc = func_809C2060; + this->actionFunc = EnAob01_BeforeRace_Idle; return; } - if (this->unk_2D2 & 0x40) { - if (!func_809C1424(this)) { + if (this->stateFlags & ENAOB01_FLAG_LAUGH) { + if (!EnAob01_ProcessLaughAnim(this)) { return; } - } else if (!func_809C15BC(this)) { + } else if (!EnAob01_ProcessIdleAnim(this)) { return; } - if (this->unk_2D2 & 8) { + if (this->stateFlags & ENAOB01_FLAG_TALKING_TO_PLAYER_HOLDING_DOG) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; func_80123E90(play, &this->actor); - if (this->unk_2D2 & 4) { - func_809C16DC(this, play); - this->unk_2D2 &= ~4; + if (this->stateFlags & ENAOB01_FLAG_PLAYER_TOLD_TO_PICK_A_DOG) { + EnAob01_BeforeRace_HandleConversation(this, play); + this->stateFlags &= ~ENAOB01_FLAG_PLAYER_TOLD_TO_PICK_A_DOG; } else { - this->unk_2D2 |= 0x10; - this->unk_2D2 |= 0x40; - this->unk_43C = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + this->stateFlags |= ENAOB01_FLAG_CONVERSATION_OVER; + this->stateFlags |= ENAOB01_FLAG_LAUGH; + this->animIndex = EN_AOB01_ANIM_LAUGH_START; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_AOB01_ANIM_LAUGH_START); + // Put my dog down! Message_StartTextbox(play, 0x354B, &this->actor); } - this->unk_2D2 &= ~8; + + this->stateFlags &= ~ENAOB01_FLAG_TALKING_TO_PLAYER_HOLDING_DOG; } } else if (talkState == TEXT_STATE_CHOICE) { if (Message_ShouldAdvance(play)) { - this->unk_2D2 &= ~0x40; + this->stateFlags &= ~ENAOB01_FLAG_LAUGH; switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - this->unk_2D2 |= 2; - func_809C16DC(this, play); + this->stateFlags |= ENAOB01_FLAG_PLAYER_CONFIRMED_CHOICE; + EnAob01_BeforeRace_HandleConversation(this, play); break; case 1: func_8019F230(); - func_809C16DC(this, play); + EnAob01_BeforeRace_HandleConversation(this, play); break; } } } else if (talkState == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { - this->unk_2D2 &= ~0x40; - if (this->unk_2D2 & 0x10) { - this->unk_2D2 &= ~0x10; + this->stateFlags &= ~ENAOB01_FLAG_LAUGH; + if (this->stateFlags & ENAOB01_FLAG_CONVERSATION_OVER) { + this->stateFlags &= ~ENAOB01_FLAG_CONVERSATION_OVER; play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; - this->actionFunc = func_809C2060; + this->actionFunc = EnAob01_BeforeRace_Idle; } else { - func_809C16DC(this, play); + EnAob01_BeforeRace_HandleConversation(this, play); } } } else if ((talkState == TEXT_STATE_14) && Message_ShouldAdvance(play)) { - this->unk_2D2 &= ~0x40; - this->unk_434 = play->msgCtx.bankRupeesSelected; - func_809C16DC(this, play); + this->stateFlags &= ~ENAOB01_FLAG_LAUGH; + this->rupeesBet = play->msgCtx.bankRupeesSelected; + EnAob01_BeforeRace_HandleConversation(this, play); } } -s32 func_809C2504(EnAob01* this, PlayState* play) { +/** + * Checks all dog instances to see if any of them have reached a certain point along the racetrack, + * as specified by the cutscene's custom value. Once one of them has reached that point, this function + * will switch to following that dog and set the csId to correspond to the next cutscene in the race + * sequence; this usually appears to the user as a cut to a different camera angle. Returns true if any + * dog has reached the specified point, false otherwise. + */ +s32 EnAob01_Race_DogHasReachedNextCutsceneTrigger(EnAob01* this, PlayState* play) { Actor* npc = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (npc != NULL) { - if ((npc->id == ACTOR_EN_RACEDOG) && (func_800F2178(this->unk_430) == ((EnRacedog*)npc)->currentPoint)) { - ActorCutscene_Stop(this->unk_430); - this->unk_3F4 = npc; - this->unk_430 = ActorCutscene_GetAdditionalCutscene(this->unk_430); + if ((npc->id == ACTOR_EN_RACEDOG) && + (CutsceneManager_GetCutsceneCustomValue(this->csId) == ((EnRacedog*)npc)->currentPoint)) { + CutsceneManager_Stop(this->csId); + this->dogToFollow = npc; + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); return true; } npc = npc->next; @@ -614,12 +709,17 @@ s32 func_809C2504(EnAob01* this, PlayState* play) { return false; } -s32 func_809C2594(EnAob01* this, PlayState* play) { +/** + * Finds the dog that the player selected and starts following it. Returns true if it finds the player's + * selected dog and false otherwise, though nothing actually cares about this return value, and it should + * always be true in normal function (it is impossible to start a race without selecting a dog). + */ +s32 EnAob01_Race_FollowSelectedDog(EnAob01* this, PlayState* play) { Actor* npc = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (npc != NULL) { if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->index == ((EnRacedog*)npc)->selectedDogIndex)) { - this->unk_3F4 = npc; + this->dogToFollow = npc; return true; } npc = npc->next; @@ -628,250 +728,316 @@ s32 func_809C2594(EnAob01* this, PlayState* play) { return false; } -s32 func_809C25E4(EnAob01* this, PlayState* play) { +/** + * Returns true if the race should be ended, which can happen in either of the following circumstances: + * - All `RACEDOG_COUNT` dogs have finished the race. + * - At least 10 dogs have finished the race, and at least 500 frames have passed since the 10th place + * dog finished. This is controlled by the forceRaceEndTimer, which is set in EnAob01_Init. + */ +s32 EnAob01_Race_IsRaceOver(EnAob01* this, PlayState* play) { Actor* npc = play->actorCtx.actorLists[ACTORCAT_NPC].first; - s16 count = 0; + s16 finishedCount = 0; while (npc != NULL) { if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->raceStatus == RACEDOG_RACE_STATUS_FINISHED)) { - count++; + finishedCount++; } npc = npc->next; } - if (count >= 14) { + if (finishedCount >= RACEDOG_COUNT) { return true; } - if ((count >= 10) && (DECR(this->unk_440) == 0)) { + if ((finishedCount >= 10) && (DECR(this->forceRaceEndTimer) == 0)) { + return true; + } + + return false; +} + +/** + * If the current cutscene has a positive length, and if the current cutscene is over (in other words, + * if the length has elapsed), this function will set the csId to the next cutscene in the race sequence + * and return true. In all other cases, it will return false. Note that *all* of the race cutscenes have + * a length of -1, so in practice, this function never does anything and always returns false. + */ +s32 EnAob01_Race_CurrentCutsceneHasEnded(EnAob01* this) { + if ((CutsceneManager_GetLength(this->csId) > 0) && (CutsceneManager_GetCurrentCsId() != this->csId)) { + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); return true; } return false; } -s32 func_809C2680(EnAob01* this) { - if ((ActorCutscene_GetLength(this->unk_430) > 0) && (ActorCutscene_GetCurrentIndex() != this->unk_430)) { - this->unk_430 = ActorCutscene_GetAdditionalCutscene(this->unk_430); - return true; - } - return false; +/** + * The only way we end up inside this function is if we tried to start a cutscene with a custom + * value of 255. This does not correspond to a point on the racetrack, nor is it the special value + * of 99, which is used to signal the race ending cutscene. Thus, whatever cutscene we're trying + * to play here is almost certainly not a race cutscene, so this function just skips it and tries + * to play the next cutscene. + */ +void EnAob01_Race_SkipNonRaceCutscene(EnAob01* this, PlayState* play) { + CutsceneManager_Stop(this->csId); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); + this->actionFunc = EnAob01_Race_StartCutscene; } -void func_809C26E4(EnAob01* this, PlayState* play) { - ActorCutscene_Stop(this->unk_430); - this->unk_430 = ActorCutscene_GetAdditionalCutscene(this->unk_430); - this->actionFunc = func_809C2824; -} - -void func_809C2730(EnAob01* this, PlayState* play) { - if (func_809C2504(this, play) || func_809C2680(this)) { - ActorCutscene_SetIntentToPlay(this->unk_430); - this->actionFunc = func_809C2824; +/** + * Wait around doing nothing until the next cutscene is triggered (in practice, this only happens + * when a dog reaches the next cutscene trigger), at which point we queue up the next cutscene. + */ +void EnAob01_Race_HandleRaceCutscene(EnAob01* this, PlayState* play) { + if (EnAob01_Race_DogHasReachedNextCutsceneTrigger(this, play) || EnAob01_Race_CurrentCutsceneHasEnded(this)) { + CutsceneManager_Queue(this->csId); + this->actionFunc = EnAob01_Race_StartCutscene; } } -void func_809C2788(EnAob01* this, PlayState* play) { - this->unk_2D2 |= 0x20; - if (func_809C25E4(this, play)) { - if (Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) != NA_BGM_HORSE_GOAL) { +/** + * Waits until the race is over, then reloads the racetrack to return it + * to its regular playable state. + */ +void EnAob01_Race_HandleRaceEndCutscene(EnAob01* this, PlayState* play) { + this->stateFlags |= ENAOB01_FLAG_STARTED_RACE; + if (EnAob01_Race_IsRaceOver(this, play)) { + if (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_HORSE_GOAL) { play->nextEntrance = ENTRANCE(DOGGY_RACETRACK, 1); - gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 3; + SET_EVENTINF_DOG_RACE_STATE(EVENTINF_DOG_RACE_STATE_ENDED); play->transitionType = TRANS_TYPE_64; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; play->transitionTrigger = TRANS_TRIGGER_START; } } } -void func_809C2824(EnAob01* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->unk_430)) { - ActorCutscene_Start(this->unk_430, this->unk_3F4); - switch (func_800F2178(this->unk_430)) { +/** + * Starts the cutscene specified by the csId and switches to an appropriate + * action function based on the cutscene's custom value. + */ +void EnAob01_Race_StartCutscene(EnAob01* this, PlayState* play) { + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Start(this->csId, this->dogToFollow); + switch (CutsceneManager_GetCutsceneCustomValue(this->csId)) { case 255: - this->actionFunc = func_809C26E4; + this->actionFunc = EnAob01_Race_SkipNonRaceCutscene; break; case 99: - this->actionFunc = func_809C2788; + this->actionFunc = EnAob01_Race_HandleRaceEndCutscene; break; default: - this->actionFunc = func_809C2730; + this->actionFunc = EnAob01_Race_HandleRaceCutscene; } } else { - ActorCutscene_SetIntentToPlay(this->unk_430); + CutsceneManager_Queue(this->csId); } } -void func_809C28B8(EnAob01* this, PlayState* play) { +/** + * Tells the player how their selected dog did in the race and gives the player + * rupees depending on their performance. If their dog placed 1st, they will + * receive triple the rupees they bet. If their dog places 2nd, they will receive + * double the rupees they bet. If their dog places 3rd through 5th, they will + * receive the same number of rupees they bet. + */ +void EnAob01_AfterRace_GiveRaceResult(EnAob01* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; func_80123E90(play, &this->actor); - this->unk_434 = gSaveContext.unk_3F5C; - switch ((gSaveContext.eventInf[0] & 0xF8) >> 3) { + this->rupeesBet = gSaveContext.unk_3F5C; + switch (GET_EVENTINF_DOG_RACE_RACE_STANDING) { case 1: - this->unk_210 = 0x352A; - this->unk_2D2 |= 0x80; - this->unk_434 *= 3; - Rupees_ChangeBy(this->unk_434); - play->msgCtx.bankRupees = this->unk_434; + this->textId = 0x352A; // You took 1st place! + this->stateFlags |= ENAOB01_FLAG_SURPRISE; + this->rupeesBet *= 3; + Rupees_ChangeBy(this->rupeesBet); + play->msgCtx.bankRupees = this->rupeesBet; break; case 2: - this->unk_210 = 0x352B; - this->unk_2D2 |= 0x80; - this->unk_434 *= 2; - Rupees_ChangeBy(this->unk_434); - play->msgCtx.bankRupees = this->unk_434; + this->textId = 0x352B; // You took 2nd place! + this->stateFlags |= ENAOB01_FLAG_SURPRISE; + this->rupeesBet *= 2; + Rupees_ChangeBy(this->rupeesBet); + play->msgCtx.bankRupees = this->rupeesBet; break; case 3: case 4: case 5: - this->unk_210 = 0x352C; - Rupees_ChangeBy(this->unk_434); + this->textId = 0x352C; // I'll give you back what you bet. + Rupees_ChangeBy(this->rupeesBet); break; default: - this->unk_210 = 0x352D; - this->unk_2D2 |= 0x40; - this->unk_43C = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + this->textId = 0x352D; // Bad choice! + this->stateFlags |= ENAOB01_FLAG_LAUGH; + this->animIndex = EN_AOB01_ANIM_LAUGH_START; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_AOB01_ANIM_LAUGH_START); break; } - Message_StartTextbox(play, this->unk_210, &this->actor); - this->actionFunc = func_809C2D0C; + Message_StartTextbox(play, this->textId, &this->actor); + this->actionFunc = EnAob01_AfterRace_Talk; } else if (this->actor.xzDistToPlayer < 100.0f) { func_800B8614(&this->actor, play, 100.0f); } } -void func_809C2A64(EnAob01* this, PlayState* play) { +/** + * Gives the player the reward for winning 150 or more rupees from the dog race. The first + * time this happens, the player will receive a Heart Piece; any other time, they will + * instead receive a Red Rupee. + */ +void EnAob01_AfterRace_GiveReward(EnAob01* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); - if (func_809C15BC(this)) { + if (EnAob01_ProcessIdleAnim(this)) { if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - this->unk_434 = 0; + this->rupeesBet = 0; play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; } if (Actor_HasParent(&this->actor, play)) { - this->trackTarget = this->unk_2E6; - this->headRot = this->unk_2EC; - this->torsoRot = this->unk_2F2; + this->trackTarget = this->prevTrackTarget; + this->headRot = this->prevHeadRot; + this->torsoRot = this->prevTorsoRot; this->actor.parent = NULL; this->actor.shape.rot.y = this->actor.world.rot.y; - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_20)) { - this->actionFunc = func_809C2BE4; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_RECEIVED_DOGGY_RACETRACK_HEART_PIECE)) { + this->actionFunc = EnAob01_AfterRace_AfterGivingReward; } else { - SET_WEEKEVENTREG(WEEKEVENTREG_08_20); - this->actionFunc = func_809C2BE4; + SET_WEEKEVENTREG(WEEKEVENTREG_RECEIVED_DOGGY_RACETRACK_HEART_PIECE); + this->actionFunc = EnAob01_AfterRace_AfterGivingReward; } - } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_20)) { - Actor_PickUp(&this->actor, play, GI_RUPEE_RED, 300.0f, 300.0f); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_RECEIVED_DOGGY_RACETRACK_HEART_PIECE)) { + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_RED, 300.0f, 300.0f); } else { - Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 300.0f, 300.0f); } } } -void func_809C2BE4(EnAob01* this, PlayState* play) { +/** + * If the current time is after the racetrack closes, kick the player out. + * Otherwise, ask the player if they want to play again. This function is + * only used when the player has won the 150 rupee reward. + */ +void EnAob01_AfterRace_AfterGivingReward(EnAob01* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); if (((talkState == TEXT_STATE_5) || (talkState == TEXT_STATE_DONE)) && Message_ShouldAdvance(play)) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); } - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_01)) { - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); } - this->unk_210 = 0; - func_800B85E0(&this->actor, play, 400.0f, -1); - gSaveContext.eventInf[0] &= (u8)~7; - this->actionFunc = func_809C2C9C; + this->textId = 0; + func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); + SET_EVENTINF_DOG_RACE_STATE(EVENTINF_DOG_RACE_STATE_NOT_STARTED); + this->actionFunc = EnAob01_AfterRace_AskToPlayAgain; } } -void func_809C2C9C(EnAob01* this, PlayState* play) { +/** + * Ask if the player wants to play again. This function is only used when + * the player has won the 150 rupee reward. + */ +void EnAob01_AfterRace_AskToPlayAgain(EnAob01* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - this->unk_210 = 0x354C; - func_80151938(play, this->unk_210); - this->actionFunc = func_809C1D64; + this->textId = 0x354C; // Want to play again? + Message_ContinueTextbox(play, this->textId); + this->actionFunc = EnAob01_BeforeRace_RespondToPlayAgainQuestion; } else { - func_800B85E0(&this->actor, play, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); } } -void func_809C2D0C(EnAob01* this, PlayState* play) { +/** + * Handles the conversation the racetrack owner has with the player after the race + * is over. If the player won 150 or more rupees, this function will transition to + * the action function that gives them the reward. If the player did *not* win 150 + * or more rupees, then if the current time is after the racetrack closes, this + * kicks the player out. Otherwise, this asks the player if they want to play again. + * Much of the logic here is duplicated in the above two functions. + */ +void EnAob01_AfterRace_Talk(EnAob01* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 4000, 1); - if (this->unk_2D2 & 0x40) { - if (!func_809C1424(this)) { + if (this->stateFlags & ENAOB01_FLAG_LAUGH) { + if (!EnAob01_ProcessLaughAnim(this)) { return; } - } else if (this->unk_2D2 & 0x80) { - if (!func_809C14D0(this)) { + } else if (this->stateFlags & ENAOB01_FLAG_SURPRISE) { + if (!EnAob01_ProcessSurpriseAnim(this)) { return; } } if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - this->unk_2D2 &= ~0x40; - this->unk_2D2 &= ~0x80; - if (this->unk_434 >= 150) { - this->unk_210 = 0x352E; - Message_StartTextbox(play, this->unk_210, &this->actor); - this->actionFunc = func_809C2A64; + this->stateFlags &= ~ENAOB01_FLAG_LAUGH; + this->stateFlags &= ~ENAOB01_FLAG_SURPRISE; + if (this->rupeesBet >= 150) { + this->textId = 0x352E; // You won over 150 rupees! + Message_StartTextbox(play, this->textId, &this->actor); + this->actionFunc = EnAob01_AfterRace_GiveReward; } else { - this->trackTarget = this->unk_2E6; - this->headRot = this->unk_2EC; - this->torsoRot = this->unk_2F2; + this->trackTarget = this->prevTrackTarget; + this->headRot = this->prevHeadRot; + this->torsoRot = this->prevTorsoRot; - this->unk_434 = 0; + this->rupeesBet = 0; this->actor.shape.rot.y = this->actor.world.rot.y; - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); } - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_01)) { - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); } - this->unk_210 = 0x354C; - Message_StartTextbox(play, this->unk_210, &this->actor); - this->actionFunc = func_809C1D64; - gSaveContext.eventInf[0] &= (u8)~7; + this->textId = 0x354C; // Want to play again? + Message_StartTextbox(play, this->textId, &this->actor); + this->actionFunc = EnAob01_BeforeRace_RespondToPlayAgainQuestion; + SET_EVENTINF_DOG_RACE_STATE(EVENTINF_DOG_RACE_STATE_NOT_STARTED); } } } -s32 func_809C2EC4(EnAob01* this, PlayState* play) { +s32 EnAob01_PlayerIsHoldingDog(EnAob01* this, PlayState* play) { Actor* dog = play->actorCtx.actorLists[ACTORCAT_ENEMY].first; while (dog != NULL) { if (dog->id == ACTOR_EN_DG) { - this->unk_432 = ((EnDg*)dog)->selectedDogIndex; - if (this->unk_432 == -1) { + this->selectedDogIndex = ((EnDg*)dog)->selectedDogIndex; + if (this->selectedDogIndex == -1) { return false; } - if (this->unk_432 == ENDG_GET_INDEX(dog)) { + if (this->selectedDogIndex == ENDG_GET_INDEX(dog)) { return true; } } + dog = dog->next; } return false; } -void func_809C2F34(EnAob01* this, PlayState* play) { +/** + * Moves the player and racetrack owner to the center of the racetrack + * (out of the way of the dogs) and stops drawing the player. + */ +void EnAob01_Race_HidePlayer(EnAob01* this, PlayState* play) { Player* player = GET_PLAYER(play); player->actor.world.pos.x = -4134.0f; @@ -884,40 +1050,48 @@ void func_809C2F34(EnAob01* this, PlayState* play) { this->actor.prevPos = this->actor.world.pos; } -void func_809C2FA0(void) { +/** + * Generates a randomized list of dog text offsets and stores them in weekEventRegs. + * EnDg uses these text offsets to determine what text to show when the player picks + * the dog up while equipped with the Mask of Truth, and EnRacedog uses them to + * determine what condition the dog is in. + */ +void EnAob01_InitializeDogTextOffsets(void) { u8 i; u8 rand; - u8 index; - u8 orig; - u8 orig2; - u8 sp44[7]; - u8 sp34[] = { + u8 dogTextOffsetsTemp; + u8 packedDogTextOffsets[(RACEDOG_COUNT + 1) / 2]; + u8 dogTextOffsets[RACEDOG_COUNT] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, }; - for (i = 0; i < ARRAY_COUNT(sp34); i++) { - rand = Rand_ZeroFloat(14.0f); - orig = sp34[i]; + // Swap around the dog text offsets randomly 14 times. + for (i = 0; i < RACEDOG_COUNT; i++) { + rand = Rand_ZeroFloat(RACEDOG_COUNT); - sp34[i] = sp34[rand]; - sp34[rand] = orig; + dogTextOffsetsTemp = dogTextOffsets[i]; + dogTextOffsets[i] = dogTextOffsets[rand]; + dogTextOffsets[rand] = dogTextOffsetsTemp; } - for (i = 0; i < ARRAY_COUNT(sp44); i++) { - gSaveContext.save.weekEventReg[42 + i] = 0; - sp44[i] = 0; + // Clear out all weekEventRegs related to the dog text offsets. + for (i = 0; i < ARRAY_COUNT(packedDogTextOffsets); i++) { + CLEAR_WEEKEVENTREG_DOG_RACE_TEXT_OFFSETS(i); + packedDogTextOffsets[i] = 0; } - for (i = 0; i < ARRAY_COUNT(sp34); i++) { - orig2 = sp34[i]; - index = i / 2; + // Go through all the dog text offsets and pack them into weekEventRegs. + for (i = 0; i < RACEDOG_COUNT; i++) { + u8 dogTextOffsetsTemp = dogTextOffsets[i]; + u8 j = i / 2; if (i % 2) { - sp44[index] |= orig2 << 0x4; - gSaveContext.save.weekEventReg[42 + index] = - ((void)0, gSaveContext.save.weekEventReg[42 + index]) | sp44[index]; + //! @note sets text offsets for both even and odd entry. + //! Requires `RACEDOG_COUNT` to be even to work properly. + packedDogTextOffsets[j] |= dogTextOffsetsTemp << 4; + SET_WEEKEVENTREG_DOG_RACE_TEXT_OFFSETS(j, packedDogTextOffsets[j]); } else { - sp44[index] |= orig2; + packedDogTextOffsets[j] |= dogTextOffsetsTemp; } } } @@ -931,36 +1105,36 @@ void EnAob01_Init(Actor* thisx, PlayState* play) { MAMAMU_YAN_LIMB_MAX); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - this->unk_43C = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + this->animIndex = EN_AOB01_ANIM_IDLE_1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_AOB01_ANIM_IDLE_1); Actor_SetScale(&this->actor, 0.01f); - switch (gSaveContext.eventInf[0] & 7) { - case 0: - func_809C2FA0(); - func_809C11EC(this, play); + switch (GET_EVENTINF_DOG_RACE_STATE) { + case EVENTINF_DOG_RACE_STATE_NOT_STARTED: + EnAob01_InitializeDogTextOffsets(); + EnAob01_SpawnDogs(this, play); this->actor.flags |= ACTOR_FLAG_1; - this->actionFunc = func_809C2060; + this->actionFunc = EnAob01_BeforeRace_Idle; break; - case 2: - this->unk_440 = 500; - func_809C1304(this, play); + case EVENTINF_DOG_RACE_STATE_STARTED: + this->forceRaceEndTimer = 500; + EnAob01_SpawnRacedogs(this, play); this->actor.draw = NULL; - this->unk_430 = this->actor.cutscene; - func_809C2594(this, play); - ActorCutscene_SetIntentToPlay(this->unk_430); + this->csId = this->actor.csId; + EnAob01_Race_FollowSelectedDog(this, play); + CutsceneManager_Queue(this->csId); this->actor.flags &= ~ACTOR_FLAG_1; - func_809C2F34(this, play); - this->actionFunc = func_809C2824; + EnAob01_Race_HidePlayer(this, play); + this->actionFunc = EnAob01_Race_StartCutscene; break; - case 3: - func_809C2FA0(); - func_809C11EC(this, play); + case EVENTINF_DOG_RACE_STATE_ENDED: + EnAob01_InitializeDogTextOffsets(); + EnAob01_SpawnDogs(this, play); this->actor.flags |= ACTOR_FLAG_1; this->actor.flags |= ACTOR_FLAG_10000; - this->actionFunc = func_809C28B8; + this->actionFunc = EnAob01_AfterRace_GiveRaceResult; break; } } @@ -968,9 +1142,10 @@ void EnAob01_Init(Actor* thisx, PlayState* play) { void EnAob01_Destroy(Actor* thisx, PlayState* play) { EnAob01* this = THIS; - if (!(this->unk_2D2 & 0x20)) { - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + if (!(this->stateFlags & ENAOB01_FLAG_STARTED_RACE)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); } + Collider_DestroyCylinder(play, &this->collider); } @@ -978,7 +1153,7 @@ void EnAob01_Update(Actor* thisx, PlayState* play) { EnAob01* this = THIS; this->actionFunc(this, play); - func_809C1EC8(this, play); + EnAob01_UpdateCommon(this, play); } s32 EnAob01_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { @@ -1013,18 +1188,19 @@ s32 EnAob01_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* if ((limbIndex == MAMAMU_YAN_LIMB_TORSO) || (limbIndex == MAMAMU_YAN_LIMB_LEFT_UPPER_ARM) || (limbIndex == MAMAMU_YAN_LIMB_RIGHT_UPPER_ARM)) { - rot->y += (s16)Math_SinS(this->unk_2F8[limbIndex]) * 200; - rot->z += (s16)Math_CosS(this->unk_318[limbIndex]) * 200; + rot->y += (s16)Math_SinS(this->limbRotTableY[limbIndex]) * 200; + rot->z += (s16)Math_CosS(this->limbRotTableZ[limbIndex]) * 200; } + return false; } void EnAob01_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - static Vec3f D_809C3968 = { 0.0f, 0.0f, 0.0f }; + static Vec3f sFocusOffset = { 0.0f, 0.0f, 0.0f }; EnAob01* this = THIS; if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { - Matrix_MultVec3f(&D_809C3968, &this->actor.focus.pos); + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); } } @@ -1034,8 +1210,8 @@ void EnAob01_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { void EnAob01_Draw(Actor* thisx, PlayState* play) { s32 pad; EnAob01* this = THIS; - Vec3f sp5C; - Vec3f sp50; + Vec3f pos; + Vec3f scale; OPEN_DISPS(play->state.gfxCtx); @@ -1051,11 +1227,11 @@ void EnAob01_Draw(Actor* thisx, PlayState* play) { if (this->actor.draw != NULL) { func_8012C2DC(play->state.gfxCtx); - sp5C = this->actor.world.pos; - sp50.x = 0.5f; - sp50.y = 0.5f; - sp50.z = 0.5f; - func_800BC620(&sp5C, &sp50, 0xFF, play); + pos = this->actor.world.pos; + scale.x = 0.5f; + scale.y = 0.5f; + scale.z = 0.5f; + func_800BC620(&pos, &scale, 255, play); } CLOSE_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h index 2507b1728..a550fd0d3 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h @@ -8,38 +8,56 @@ struct EnAob01; typedef void (*EnAob01ActionFunc)(struct EnAob01*, PlayState*); -#define ENAOB01_GET_7E00_1(thisx) ((thisx)->params & 0x7E00) -#define ENAOB01_GET_7E00_2(thisx) (((thisx)->params & 0x7E00) >> 9) +// This needs to be kept in sync with the number of weekEventRegs used to store the text ID offsets for +// the race dogs. In particular, there needs to be one weekEventReg for every two dogs. This needs to be +// an even number to ensure that all text ID offsets are created (see EnAob01_InitializeDogTextOffsets). +#define RACEDOG_COUNT 14 + +#define ENAOB01_GET_STARTING_DOG_PATH_INDEX(thisx) (((thisx)->params & 0x7E00) >> 9) + +//! @bug This should be shifted up by 1 to match how EnRacedog expects the path index to be supplied. +//! It doesn't cause any problems in the final game because every time EnAob01 is spawned, all the +//! bits here are zero. +#define ENAOB01_GET_RACEDOG_PATH_INDEX(thisx) ((thisx)->params & 0x7E00) + +#define ENAOB01_FLAG_PLAYER_CONFIRMED_CHOICE (1 << 1) +#define ENAOB01_FLAG_PLAYER_TOLD_TO_PICK_A_DOG (1 << 2) +#define ENAOB01_FLAG_TALKING_TO_PLAYER_HOLDING_DOG (1 << 3) +#define ENAOB01_FLAG_CONVERSATION_OVER (1 << 4) +#define ENAOB01_FLAG_STARTED_RACE (1 << 5) +#define ENAOB01_FLAG_LAUGH (1 << 6) +#define ENAOB01_FLAG_SURPRISE (1 << 7) +#define ENAOB01_FLAG_PLAYER_CAN_TALK (1 << 8) typedef struct EnAob01 { /* 0x000 */ Actor actor; /* 0x144 */ EnAob01ActionFunc actionFunc; /* 0x148 */ SkelAnime skelAnime; /* 0x18C */ ColliderCylinder collider; - /* 0x1D8 */ Path* unk_1D8[14]; - /* 0x210 */ u16 unk_210; + /* 0x1D8 */ Path* dogPaths[RACEDOG_COUNT]; + /* 0x210 */ u16 textId; /* 0x212 */ Vec3s jointTable[MAMAMU_YAN_LIMB_MAX]; /* 0x272 */ Vec3s morphTable[MAMAMU_YAN_LIMB_MAX]; - /* 0x2D2 */ u16 unk_2D2; + /* 0x2D2 */ u16 stateFlags; /* 0x2D4 */ Vec3s trackTarget; /* 0x2DA */ Vec3s headRot; /* 0x2E0 */ Vec3s torsoRot; - /* 0x2E6 */ Vec3s unk_2E6; - /* 0x2EC */ Vec3s unk_2EC; - /* 0x2F2 */ Vec3s unk_2F2; - /* 0x2F8 */ s16 unk_2F8[MAMAMU_YAN_LIMB_MAX]; - /* 0x318 */ s16 unk_318[MAMAMU_YAN_LIMB_MAX]; + /* 0x2E6 */ Vec3s prevTrackTarget; + /* 0x2EC */ Vec3s prevHeadRot; + /* 0x2F2 */ Vec3s prevTorsoRot; + /* 0x2F8 */ s16 limbRotTableY[MAMAMU_YAN_LIMB_MAX]; + /* 0x318 */ s16 limbRotTableZ[MAMAMU_YAN_LIMB_MAX]; /* 0x338 */ UNK_TYPE1 unk338[0xB6]; /* 0x3EE */ s16 eyeIndex; /* 0x3F0 */ s16 blinkTimer; - /* 0x3F4 */ Actor* unk_3F4; - /* 0x3F8 */ Actor* unk_3F8[14]; - /* 0x430 */ s16 unk_430; - /* 0x432 */ s16 unk_432; - /* 0x434 */ s32 unk_434; + /* 0x3F4 */ Actor* dogToFollow; + /* 0x3F8 */ Actor* dogs[RACEDOG_COUNT]; + /* 0x430 */ s16 csId; + /* 0x432 */ s16 selectedDogIndex; + /* 0x434 */ s32 rupeesBet; // Also used for determining how many rupees to give to the player if they place 1st-5th in the race. /* 0x438 */ UNK_TYPE1 unk438[4]; - /* 0x43C */ s32 unk_43C; - /* 0x440 */ s16 unk_440; + /* 0x43C */ s32 animIndex; + /* 0x440 */ s16 forceRaceEndTimer; } EnAob01; // size = 0x444 #endif // Z_EN_AOB_01_H 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 b07e65de3..b94e3ecb5 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -78,9 +78,9 @@ void EnArrow_Init(Actor* thisx, PlayState* play) { EnArrow* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - if (this->actor.params == ENARROW_MINUS8) { + if (this->actor.params == -ENARROW_8) { this->unk_263 = 1; - this->actor.params = 8; + this->actor.params = ENARROW_8; } if (this->actor.params < ENARROW_6) { @@ -113,7 +113,7 @@ void EnArrow_Init(Actor* thisx, PlayState* play) { if (this->actor.params < ENARROW_0) { this->collider.base.atFlags = (AT_TYPE_ENEMY | AT_ON); } else { - this->collider.info.toucher.dmgFlags = func_800BC188(this->actor.params); + this->collider.info.toucher.dmgFlags = Actor_GetArrowDmgFlags(this->actor.params); if (this->actor.params == ENARROW_8) { this->collider.info.toucher.damage = 1; } @@ -176,22 +176,22 @@ void func_8088A594(EnArrow* this, PlayState* play) { switch (this->actor.params) { case ENARROW_6: - func_800B8E58(player, NA_SE_IT_SLING_SHOT); + Player_PlaySfx(player, NA_SE_IT_SLING_SHOT); break; case ENARROW_0: case ENARROW_1: case ENARROW_2: - func_800B8E58(player, NA_SE_IT_ARROW_SHOT); + Player_PlaySfx(player, NA_SE_IT_ARROW_SHOT); break; case ENARROW_3: case ENARROW_4: case ENARROW_5: - func_800B8E58(player, NA_SE_IT_MAGIC_ARROW_SHOT); + Player_PlaySfx(player, NA_SE_IT_MAGIC_ARROW_SHOT); case ENARROW_7: - func_800B8E58(player, NA_SE_PL_DEKUNUTS_FIRE); + Player_PlaySfx(player, NA_SE_PL_DEKUNUTS_FIRE); break; } @@ -225,7 +225,7 @@ void func_8088A7D8(PlayState* play, EnArrow* this) { this->actionFunc = func_8088B6B0; Animation_PlayOnce(&this->arrow.skelAnime, &gameplay_keep_Anim_012860); this->actor.world.rot.y += (s32)(0x6000 * (Rand_ZeroOne() - 0.5f)) + 0x8000; - this->actor.speedXZ *= 0.02f + (0.02f * Rand_ZeroOne()); + this->actor.speed *= 0.02f + (0.02f * Rand_ZeroOne()); this->actor.gravity = -1.5f; this->unk_260 = 50; this->unk_263 = 1; @@ -273,8 +273,8 @@ void func_8088AA98(EnArrow* this, PlayState* play) { f32 temp_f0; if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, &sp54) && - (this->actor.world.pos.y < sp50) && !(this->actor.bgCheckFlags & 0x20)) { - this->actor.bgCheckFlags |= 0x20; + (this->actor.world.pos.y < sp50) && !(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { + this->actor.bgCheckFlags |= BGCHECKFLAG_WATER; Math_Vec3f_Diff(&this->actor.world.pos, &this->actor.home.pos, &sp44); @@ -289,7 +289,7 @@ void func_8088AA98(EnArrow* this, PlayState* play) { EffectSsGSplash_Spawn(play, &sp44, NULL, NULL, 0, 300); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); + Actor_PlaySfx(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); EffectSsGRipple_Spawn(play, &sp44, 100, 500, 0); EffectSsGRipple_Spawn(play, &sp44, 100, 500, 4); @@ -373,9 +373,9 @@ void func_8088ACE0(EnArrow* this, PlayState* play) { } if (this->actor.params == ENARROW_8) { - iREG(50) = -1; + R_TRANS_FADE_FLASH_ALPHA_STEP = -1; Actor_Spawn(&play->actorCtx, play, ACTOR_EN_M_FIRE1, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, this->actor.speedXZ == 0.0f); + this->actor.world.pos.z, 0, 0, 0, this->actor.speed == 0.0f); sp82 = NA_SE_IT_DEKU; } else { sp82 = NA_SE_IT_SLING_REFLECT; @@ -396,14 +396,14 @@ void func_8088ACE0(EnArrow* this, PlayState* play) { Math_Vec3f_Diff(&sp7C->world.pos, &this->actor.world.pos, &this->unk_268); sp7C->flags |= ACTOR_FLAG_8000; this->collider.base.atFlags &= ~AT_HIT; - this->actor.speedXZ *= 0.5f; + this->actor.speed *= 0.5f; this->actor.velocity.y *= 0.5f; } else { this->unk_261 |= 1; this->unk_261 |= 2; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); func_8088A7D8(play, this); - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_HOOKSHOT_STICK_CRE); + Actor_PlaySfx(&this->actor, NA_SE_IT_HOOKSHOT_STICK_CRE); } } else if (this->unk_262 != 0) { this->actionFunc = func_8088B630; @@ -416,7 +416,7 @@ void func_8088ACE0(EnArrow* this, PlayState* play) { if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6)) { this->actor.draw = NULL; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_ARROW_STICK_OBJ); + Actor_PlaySfx(&this->actor, NA_SE_IT_ARROW_STICK_OBJ); this->unk_261 |= 1; } } @@ -424,9 +424,9 @@ void func_8088ACE0(EnArrow* this, PlayState* play) { func_8088AA98(this, play); if (this->actor.params == ENARROW_7) { if (this->bubble.unk_149 == 0) { - sp78 = sqrtf(SQ(this->actor.speedXZ) + SQ(this->actor.velocity.y)); - sp74 = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; - temp_f12_2 = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; + sp78 = sqrtf(SQ(this->actor.speed) + SQ(this->actor.velocity.y)); + sp74 = Math_SinS(this->actor.world.rot.y) * this->actor.speed; + temp_f12_2 = Math_CosS(this->actor.world.rot.y) * this->actor.speed; this->actor.prevPos.x = this->actor.world.pos.x - (sp74 * (10.0f / sp78)); this->actor.prevPos.y = this->actor.world.pos.y - (this->actor.velocity.y * (10.0f / sp78)); @@ -456,7 +456,7 @@ void func_8088ACE0(EnArrow* this, PlayState* play) { Math_Vec3f_Copy(&this->unk_228, &this->actor.world.pos); - if (this->actor.speedXZ == 0.0f) { + if (this->actor.speed == 0.0f) { this->actor.velocity.y -= 1.0f; if (this->actor.velocity.y < this->actor.terminalVelocity) { this->actor.velocity.y = this->actor.terminalVelocity; @@ -474,7 +474,7 @@ void func_8088ACE0(EnArrow* this, PlayState* play) { } if (this->actor.params < ENARROW_6) { - this->actor.shape.rot.x = Math_Atan2S_XY(this->actor.speedXZ, -this->actor.velocity.y); + this->actor.shape.rot.x = Math_Atan2S_XY(this->actor.speed, -this->actor.velocity.y); } } @@ -512,7 +512,7 @@ void func_8088B630(EnArrow* this, PlayState* play) { SkelAnime_Update(&this->arrow.skelAnime); if (this->actor.wallBgId != BG_ACTOR_MAX) { - BgCheck2_UpdateActorAttachedToMesh(&play->colCtx, this->actor.wallBgId, &this->actor); + DynaPolyActor_TransformCarriedActor(&play->colCtx, this->actor.wallBgId, &this->actor); } if (DECR(this->unk_260) == 0) { @@ -641,7 +641,7 @@ void EnArrow_Draw(Actor* thisx, PlayState* play) { &this->actor, this->actor.projectedPos.z < 160.0f ? 0 : 1); } else if (this->actor.params == ENARROW_7) { s32 spA4 = 255 - (s32)(this->bubble.unk_144 * 4.0f); - f32 spA0 = (this->actor.speedXZ * 0.1f) + 1.0f; + f32 spA0 = (this->actor.speed * 0.1f) + 1.0f; f32 sp9C = (1.0f / spA0); OPEN_DISPS(play->state.gfxCtx); @@ -659,7 +659,7 @@ void EnArrow_Draw(Actor* thisx, PlayState* play) { MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, 460.0f, MTXMODE_APPLY); - if (this->actor.speedXZ == 0.0f) { + if (this->actor.speed == 0.0f) { func_800B8118(&this->actor, play, MTXMODE_NEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_06F380); @@ -674,7 +674,7 @@ void EnArrow_Draw(Actor* thisx, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_06F9F0); } else { - func_800B8050(&this->actor, play, MTXMODE_NEW); + func_800B8050(&this->actor, play, 0); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06F380); gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL1, 0, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, @@ -687,7 +687,7 @@ void EnArrow_Draw(Actor* thisx, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); return; - } else if (this->actor.speedXZ != 0.0f) { + } else if (this->actor.speed != 0.0f) { u8 sp63 = (Math_CosS(this->unk_260 * 5000) * 127.5f) + 127.5f; f32 sp5C; @@ -710,7 +710,7 @@ void EnArrow_Draw(Actor* thisx, PlayState* play) { Matrix_Push(); Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - if (this->actor.speedXZ == 0.0f) { + if (this->actor.speed == 0.0f) { phi_v0 = 0; } else { phi_v0 = (play->gameplayFrames % 256) * 4000; diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h index d16dbd380..313dd86bb 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h @@ -8,16 +8,15 @@ struct EnArrow; typedef void (*EnArrowActionFunc)(struct EnArrow*, PlayState*); enum { - /* -8 */ ENARROW_MINUS8 = -8, - /* 0 */ ENARROW_0 = 0, - /* 1 */ ENARROW_1, - /* 2 */ ENARROW_2, - /* 3 */ ENARROW_3, - /* 4 */ ENARROW_4, - /* 5 */ ENARROW_5, - /* 6 */ ENARROW_6, - /* 7 */ ENARROW_7, - /* 8 */ ENARROW_8, + /* 0 */ ENARROW_0, // Lit arrow + /* 1 */ ENARROW_1, // Horse arrow + /* 2 */ ENARROW_2, // Normal arrow + /* 3 */ ENARROW_3, // Fire arrow + /* 4 */ ENARROW_4, // Ice arrow + /* 5 */ ENARROW_5, // Light arrow + /* 6 */ ENARROW_6, // ? + /* 7 */ ENARROW_7, // Deku bubble + /* 8 */ ENARROW_8, // Deku Nut }; typedef struct { diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c index b4501ffa0..bb3e2f23a 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c @@ -213,7 +213,7 @@ void EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, PlayState* play) { Vec3f flightTarget; s32 pad; - this->actor.speedXZ = 10.0f; + this->actor.speed = 10.0f; // randomTargetCenterOffset is set in _Init, only needs to be set once // but the view is moving, so now we need to re-calculate the spot in space @@ -236,7 +236,7 @@ void EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, PlayState* play) { Actor_SetFocus(&this->actor, this->targetHeight); Actor_GetScreenPos(play, &this->actor, &posX, &posY); - if (this->actor.bgCheckFlags & 8) { // touching a wall + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->targetRotY = this->actor.yawTowardsPlayer; this->targetRotX = this->actor.world.rot.x - 3000.0f; this->hopTimer = 0; @@ -255,7 +255,7 @@ void EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, PlayState* play) { } else if (((this->actor.projectedPos.z > 0.0f) && (fabsf(flightTarget.x - this->actor.world.pos.x) < 50.0f) && (fabsf(flightTarget.y - this->actor.world.pos.y) < 50.0f) && (fabsf(flightTarget.z - this->actor.world.pos.z) < 50.0f)) || - (this->actor.bgCheckFlags & 1)) { // touching ground or with close distance of target + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { // reset state this->hopTimer = 0; this->unkTimer250 = this->hopTimer; @@ -286,7 +286,7 @@ void EnAttackNiw_AimAtPlayer(EnAttackNiw* this, PlayState* play) { return; } - if (this->actor.bgCheckFlags & 1) { // touching floor + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (this->hopTimer == 0) { this->hopTimer = 3; this->actor.velocity.y = 3.5f; @@ -314,19 +314,18 @@ void EnAttackNiw_AimAtPlayer(EnAttackNiw* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRotY, 2, this->rotStep, 0); Math_SmoothStepToS(&this->actor.world.rot.x, this->targetRotX, 2, this->rotStep, 0); Math_ApproachF(&this->rotStep, 10000.0f, 1.0f, 1000.0f); - Math_ApproachF(&this->actor.speedXZ, this->targetXZSpeed, 0.9f, 1.0f); + Math_ApproachF(&this->actor.speed, this->targetXZSpeed, 0.9f, 1.0f); - if (this->actor.gravity == -2.0f && this->unkTimer25A == 0 && - (this->actor.bgCheckFlags & 8 || this->randomAngleChangeTimer == 0)) { + if ((this->actor.gravity == -2.0f) && (this->unkTimer25A == 0) && + ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || (this->randomAngleChangeTimer == 0))) { this->targetXZSpeed = 0.0f; this->actor.gravity = 0.0f; this->rotStep = 0.0f; this->targetRotX = this->actor.world.rot.x - 5000.0f; this->actionFunc = EnAttackNiw_FlyAway; - } else if (this->actor.bgCheckFlags & 1) { // touching floor + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { EnAttackNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_SLOW_FORFLAPPING); - } else { EnAttackNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_AND_WAVING); } @@ -367,7 +366,9 @@ void EnAttackNiw_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 60.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); if (this->actionFunc == EnAttackNiw_EnterViewFromOffscreen) { Actor_MoveWithoutGravity(&this->actor); @@ -380,8 +381,7 @@ void EnAttackNiw_Update(Actor* thisx, PlayState* play) { return; } - if ((this->actor.bgCheckFlags & 0x20) && // on or below water - (this->actionFunc != EnAttackNiw_FlyAway)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER) && (this->actionFunc != EnAttackNiw_FlyAway)) { Math_Vec3f_Copy(&splashPos, &this->actor.world.pos); splashPos.y += this->actor.depthInWater; EffectSsGSplash_Spawn(play, &splashPos, NULL, NULL, 0, 400); @@ -408,12 +408,12 @@ void EnAttackNiw_Update(Actor* thisx, PlayState* play) { if (this->crySfxTimer == 0) { this->crySfxTimer = 30; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_A); } if (this->flutterSfxTimer == 0) { this->flutterSfxTimer = 7; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); + Actor_PlaySfx(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); } } } diff --git a/src/overlays/actors/ovl_En_Az/z_en_az.c b/src/overlays/actors/ovl_En_Az/z_en_az.c index bfefb5a85..1c2cdf533 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -151,8 +151,8 @@ void func_80A94AB8(EnAz* this, PlayState* play, s32 spawnIndex) { play->nextEntrance = Entrance_CreateFromSpawn(spawnIndex); gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } void func_80A94B20(PlayState* play) { @@ -253,7 +253,7 @@ void EnAz_Init(Actor* thisx, PlayState* play2) { if (this->unk_2F8 == 0) { this->unk_374 |= 2; } - SubS_FillCutscenesList(&this->actor, this->unk_3D0, ARRAY_COUNT(this->unk_3D0)); + SubS_FillCutscenesList(&this->actor, this->csIdList, ARRAY_COUNT(this->csIdList)); if (D_80A9913C == NULL) { D_80A9913C = THIS; this->unk_374 |= 1; @@ -273,8 +273,8 @@ void EnAz_Init(Actor* thisx, PlayState* play2) { this->collider.dim.height *= 1.2f; this->collider.dim.yShift *= 1.2f; } - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 5); - if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 22.0f)) { + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER) && (this->actor.depthInWater > 22.0f)) { this->unk_374 |= 0x100; this->unk_376 |= 0x100; } @@ -437,9 +437,9 @@ s32 func_80A95534(PlayState* play, ActorPathing* actorPathing) { this->unk_36C = actorPathing->distSqToCurPointXZ; } } - Math_SmoothStepToF(&this->actor.speedXZ, this->unk_36C, 0.8f, 2.0f, 0.0f); + Math_SmoothStepToF(&this->actor.speed, this->unk_36C, 0.8f, 2.0f, 0.0f); actorPathing->moveFunc = SubS_ActorPathing_MoveWithGravity; - if (actorPathing->distSqToCurPointXZ <= this->actor.speedXZ) { + if (actorPathing->distSqToCurPointXZ <= this->actor.speed) { ret = true; } return ret; @@ -454,11 +454,11 @@ s32 func_80A9565C(PlayState* play, ActorPathing* actorPathing) { actorPathing->moveFunc = func_80A94A90; this->unk_374 |= 0x2000; temp_f0 = func_80A954AC(this); - if ((actorPathing->distSqToCurPointXZ < SQ(this->actor.speedXZ)) || (temp_f0 <= 0.0f)) { + if ((actorPathing->distSqToCurPointXZ < SQ(this->actor.speed)) || (temp_f0 <= 0.0f)) { ret = true; } else { this->unk_39E = this->actor.world.rot.x = - Math_Atan2S(-this->actor.velocity.y, Math_CosS(-this->actor.world.rot.x) * this->actor.speedXZ); + Math_Atan2S(-this->actor.velocity.y, Math_CosS(-this->actor.world.rot.x) * this->actor.speed); } return ret; } @@ -474,10 +474,10 @@ s32 func_80A95730(PlayState* play, ActorPathing* actorPathing) { this->actor.gravity = 0.0f; temp_f0 = func_80A954AC(this); - if ((actorPathing->distSqToCurPointXZ < SQ(this->actor.speedXZ)) || (temp_f0 <= 0.0f)) { + if ((actorPathing->distSqToCurPointXZ < SQ(this->actor.speed)) || (temp_f0 <= 0.0f)) { ret = true; } else { - sp40 = SQ(this->actor.speedXZ) / actorPathing->distSqToCurPoint; + sp40 = SQ(this->actor.speed) / actorPathing->distSqToCurPoint; sp34 = ABS(actorPathing->rotToCurPoint.x - this->actor.world.rot.x); sp3C = (s32)(sp34 * sp40) + 0xAAA; @@ -521,12 +521,12 @@ s32 func_80A958B0(PlayState* play, ActorPathing* actorPathing) { } else { Math_SmoothStepToF(&this->unk_36C, 26.0f, 0.5f, 1.0f, 0.01f); } - Math_SmoothStepToF(&this->actor.speedXZ, this->unk_36C, 0.8f, 2.0f, 0.0f); + Math_SmoothStepToF(&this->actor.speed, this->unk_36C, 0.8f, 2.0f, 0.0f); temp1 = func_80A954AC(this); - if ((actorPathing->distSqToCurPointXZ < SQ(this->actor.speedXZ)) || (temp1 <= 0.0f)) { + if ((actorPathing->distSqToCurPointXZ < SQ(this->actor.speed)) || (temp1 <= 0.0f)) { ret = true; } else { - sp3C = SQ(this->actor.speedXZ) / actorPathing->distSqToCurPoint; + sp3C = SQ(this->actor.speed) / actorPathing->distSqToCurPoint; sp30 = ABS(actorPathing->rotToCurPoint.x - this->actor.world.rot.x); sp2C = (s32)(sp30 * sp3C) + 0xAAA; sp30 = ABS(actorPathing->rotToCurPoint.y - this->actor.world.rot.y); @@ -560,7 +560,7 @@ s32 func_80A95B34(PlayState* play, ActorPathing* actorPathing) { } else { ret = func_80A958B0(play, actorPathing); } - } else if (this->actor.bgCheckFlags & 1) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (this->unk_374 & 8) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_WALK, &this->animIndex); this->unk_374 &= ~8; @@ -578,24 +578,24 @@ void func_80A95C5C(EnAz* this, PlayState* play) { this->actor.gravity = -1.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, &this->animIndex); this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); - this->actor.bgCheckFlags &= ~0x21; + this->actor.bgCheckFlags &= ~(BGCHECKFLAG_GROUND | BGCHECKFLAG_WATER); this->unk_3C0 = 0; this->actionFunc = func_80A95CEC; } void func_80A95CEC(EnAz* this, PlayState* play) { if (this->unk_374 & 0x8000) { - if (!(this->actor.bgCheckFlags & 1)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.draw = EnAz_Draw; Actor_MoveWithGravity(&this->actor); func_800B9010(&this->actor, NA_SE_EV_HONEYCOMB_FALL - SFX_FLAG); } else { - if (this->actor.bgCheckFlags & 2) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + Actor_PlaySfx(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } - if (SubS_StartActorCutscene(&this->actor, 0x7C, this->unk_3D0[0], SUBS_CUTSCENE_NORMAL)) { + if (SubS_StartCutscene(&this->actor, CS_ID_GLOBAL_TALK, this->csIdList[0], SUBS_CUTSCENE_NORMAL)) { func_80A97C0C(this, play); } } @@ -608,12 +608,12 @@ void func_80A95DA0(EnAz* this, PlayState* play) { SubS_ActorPathing_Init(play, &this->actor.world.pos, &this->actor, sp40, play->setupPathList, BEAVER_GET_PARAM_FF(&this->actor), 0, 0, 1, 1); this->unk_36C = 4.0f; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; this->actor.gravity = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_SWIM_WITH_SPINNING_TAIL, &this->animIndex); this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); - this->actor.bgCheckFlags &= ~0x21; + this->actor.bgCheckFlags &= ~(BGCHECKFLAG_GROUND | BGCHECKFLAG_WATER); this->unk_374 |= 0x1000; Math_Vec3f_Copy(&this->actor.world.pos, &sp40->curPoint); this->actionFunc = func_80A95E88; @@ -625,7 +625,7 @@ void func_80A95E88(EnAz* this, PlayState* play) { if (this->actor.depthInWater > 8.0f) { if (this->unk_374 & 2) { if ((this->skelAnime.curFrame < this->skelAnime.playSpeed) && (this->skelAnime.curFrame >= 0.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BEAVER_SWIM_HAND); + Actor_PlaySfx(&this->actor, NA_SE_EV_BEAVER_SWIM_HAND); } } else { func_800B9010(&this->actor, NA_SE_EV_BEAVER_SWIM_MOTOR - SFX_FLAG); @@ -641,7 +641,7 @@ void func_80A95E88(EnAz* this, PlayState* play) { } void func_80A95F94(EnAz* this, PlayState* play) { - func_800BE33C(&this->actor.world.pos, &this->actor.home.pos, &this->actor.world.rot, 0); + func_800BE33C(&this->actor.world.pos, &this->actor.home.pos, &this->actor.world.rot, false); this->unk_39E = 0; this->actor.shape.rot.y = this->actor.world.rot.y; this->actionFunc = func_80A95FE8; @@ -649,14 +649,14 @@ void func_80A95F94(EnAz* this, PlayState* play) { void func_80A95FE8(EnAz* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (ActorCutscene_GetCanPlayNext(this->unk_3D0[0])) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_3D0[0], &this->actor); + if (CutsceneManager_IsNext(this->csIdList[0])) { + CutsceneManager_StartWithPlayerCs(this->csIdList[0], &this->actor); } else { - ActorCutscene_SetIntentToPlay(this->unk_3D0[0]); + CutsceneManager_Queue(this->csIdList[0]); } - if (Actor_DistanceToPoint(&this->actor, &this->actor.home.pos) > 20.0f) { + if (Actor_WorldDistXYZToPoint(&this->actor, &this->actor.home.pos) > 20.0f) { func_800B9010(&this->actor, NA_SE_EV_BEAVER_SWIM_MOTOR - SFX_FLAG); - func_800BE33C(&this->actor.world.pos, &this->actor.home.pos, &this->actor.world.rot, 0); + func_800BE33C(&this->actor.world.pos, &this->actor.home.pos, &this->actor.world.rot, false); Math_SmoothStepToS(&this->actor.shape.rot.x, this->actor.world.rot.x, 3, 0xE38, 0x38E); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0xE38, 0x38E); this->actor.shape.rot.z = 0; @@ -665,14 +665,14 @@ void func_80A95FE8(EnAz* this, PlayState* play) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, &this->animIndex); this->unk_374 &= ~0x1000; this->actor.gravity = -1.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 3, 0x1000, 0x100); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x1038, 0x100); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->actor.shape.rot.x = 0; this->actor.gravity = 0.0f; func_80A97C0C(this, play); - ActorCutscene_Stop(this->unk_3D0[0]); + CutsceneManager_Stop(this->csIdList[0]); } Actor_MoveWithGravity(&this->actor); } @@ -688,7 +688,8 @@ s32 func_80A9617C(EnAz* this, PlayState* play) { case TEXT_STATE_5: case TEXT_STATE_DONE: if ((play->msgCtx.currentTextId == 0x10DD) && (this->unk_374 & 0x8000)) { - if (SubS_StartActorCutscene(&brother->actor, brother->unk_3D0[0], 0x7C, SUBS_CUTSCENE_NORMAL)) { + if (SubS_StartCutscene(&brother->actor, brother->csIdList[0], CS_ID_GLOBAL_TALK, + SUBS_CUTSCENE_NORMAL)) { brother->unk_374 |= 0x8000; play->msgCtx.msgMode = 0x44; ret = 0; @@ -1293,7 +1294,7 @@ void func_80A97410(EnAz* this, PlayState* play) { } } if (this->unk_378 == 3) { - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); this->unk_378 = 2; } else if (this->unk_378 == 5) { Message_StartTextbox(play, this->actor.textId, &this->actor); @@ -1309,8 +1310,8 @@ void func_80A97410(EnAz* this, PlayState* play) { this->unk_378 = 0; } } else { - Actor_PickUp(&this->actor, play, this->getItemId, this->actor.xzDistToPlayer, - this->actor.playerHeightRel); + Actor_OfferGetItem(&this->actor, play, this->getItemId, this->actor.xzDistToPlayer, + this->actor.playerHeightRel); } } if (this->unk_378 == 9) { @@ -1370,7 +1371,7 @@ void func_80A97410(EnAz* this, PlayState* play) { } else { Actor_GetScreenPos(play, &this->actor, &sp56, &sp54); if ((sp56 >= 0) && (sp56 <= SCREEN_WIDTH) && (sp54 >= 0) && (sp54 <= SCREEN_HEIGHT) && - func_800B8500(&this->actor, play, 120.0f, 120.0f, 0)) { + func_800B8500(&this->actor, play, 120.0f, 120.0f, PLAYER_IA_NONE)) { this->unk_3D2 = func_80A97274(this, play); if ((this->unk_3D2 == 0x10CE) || (this->unk_3D2 == 0x10D4)) { this->actor.textId = 0; @@ -1398,7 +1399,7 @@ void func_80A97A28(EnAz* this, PlayState* play) { } void func_80A97A40(EnAz* this, PlayState* play) { - if (SubS_StartActorCutscene(&this->actor, 0, -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + if (SubS_StartCutscene(&this->actor, 0, CS_ID_NONE, SUBS_CUTSCENE_WITH_PLAYER)) { play->msgCtx.msgMode = 0; play->msgCtx.msgLength = 0; func_80A97A9C(this, play); @@ -1420,7 +1421,7 @@ void func_80A97AB4(EnAz* this, PlayState* play) { if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x10D7: - func_80151938(play, 0x10D8); + Message_ContinueTextbox(play, 0x10D8); break; case 0x10D8: if (play->msgCtx.choiceIndex == 0) { @@ -1434,7 +1435,7 @@ void func_80A97AB4(EnAz* this, PlayState* play) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_24_04)) { CLEAR_WEEKEVENTREG(WEEKEVENTREG_24_04); } - func_80151938(play, 0x10D9); + Message_ContinueTextbox(play, 0x10D9); } break; case 0x10D9: @@ -1471,7 +1472,7 @@ void func_80A97C4C(EnAz* this, PlayState* play) { gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_80; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; func_80A979DC(this, play); } else { Actor_MoveWithGravity(&this->actor); @@ -1510,14 +1511,14 @@ void func_80A97EAC(EnAz* this, PlayState* play) { SubS_ActorPathing_Init(play, &this->actor.world.pos, &this->actor, &this->unk_300, play->setupPathList, BEAVER_GET_PARAM_FF(&this->actor), 0, 0, 1, 0); this->unk_36C = 8.0f; - this->actor.speedXZ = 8.0f; + this->actor.speed = 8.0f; this->actor.gravity = 0.0f; this->actor.velocity.y = 6.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_SWIM_WITH_SPINNING_TAIL, &this->animIndex); - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); - this->actor.bgCheckFlags &= ~0x21; + this->actor.bgCheckFlags &= ~(BGCHECKFLAG_GROUND | BGCHECKFLAG_WATER); this->unk_374 |= 0x1000; this->unk_3C2 = 0; this->unk_3C4 = 0; @@ -1552,9 +1553,9 @@ void func_80A97F9C(EnAz* this, PlayState* play) { play->nextEntrance = Entrance_CreateFromSpawn(2); gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; - gSaveContext.nextTransitionType = TRANS_TYPE_03; - this->actor.speedXZ = 0.0f; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; + this->actor.speed = 0.0f; func_80A979DC(this, play); } else { if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] == SECONDS_TO_TIMER(0)) { @@ -1574,7 +1575,7 @@ void func_80A97F9C(EnAz* this, PlayState* play) { if (this->actor.depthInWater > 8.0f) { if (this->unk_374 & 2) { if ((this->skelAnime.curFrame < this->skelAnime.playSpeed) && (this->skelAnime.curFrame >= 0.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BEAVER_SWIM_HAND); + Actor_PlaySfx(&this->actor, NA_SE_EV_BEAVER_SWIM_HAND); } } else { func_800B9010(&this->actor, NA_SE_EV_BEAVER_SWIM_MOTOR - SFX_FLAG); @@ -1589,7 +1590,7 @@ void func_80A982E0(PlayState* play, ActorPathing* actorPathing) { Vec3f sp28; actorPathing->curPoint.x = actorPathing->points[actorPathing->curPointIndex].x; - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { actorPathing->curPoint.y = actorPathing->points[actorPathing->curPointIndex].y; } else { actorPathing->curPoint.y = actorPathing->points[actorPathing->curPointIndex].y - this->unk_3A4; @@ -1615,7 +1616,7 @@ void func_80A98414(EnAz* this, PlayState* play) { if ((fish->actor.params < 0) && (fish->actor.room == this->actor.room) && (Math3D_Vec3fDistSq(&this->actor.world.pos, &fish->actor.world.pos) < SQ(200.0f))) { fish->unk_276 = 0x14; - fish->unk_274 = Actor_YawBetweenActors(&fish->actor, &this->actor); + fish->unk_274 = Actor_WorldYawTowardActor(&fish->actor, &this->actor); } } itemAction = itemAction->next; @@ -1627,7 +1628,7 @@ void EnAz_Update(Actor* thisx, PlayState* play2) { EnAz* this = THIS; this->unk_374 &= ~0x100; - if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 22.0f)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER) && (this->actor.depthInWater > 22.0f)) { if (!(this->unk_376 & 0x100)) { this->unk_374 |= 0x200; } @@ -1638,10 +1639,10 @@ void EnAz_Update(Actor* thisx, PlayState* play2) { this->actionFunc(this, play); Actor_SetFocus(&this->actor, 40.0f); if (this->unk_374 & 0x200) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EV_DIVE_INTO_WATER); } if (this->unk_374 & 0x400) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_JUMP_OUT_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EV_JUMP_OUT_WATER); } this->unk_37E++; if (this->unk_37E >= 4) { @@ -1660,9 +1661,9 @@ void EnAz_Update(Actor* thisx, PlayState* play2) { this->unk_39C = 0; } if (!(this->unk_374 & 0x1000)) { - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } else { - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 0x400); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, UPDBGCHECKINFO_FLAG_400); this->unk_374 &= ~0x1000; } Collider_UpdateCylinder(&this->actor, &this->collider); @@ -1798,7 +1799,7 @@ void EnAz_Draw(Actor* thisx, PlayState* play2) { CLOSE_DISPS(play->state.gfxCtx); } OPEN_DISPS(play->state.gfxCtx); - if ((this->actor.depthInWater >= 28.0f) && (this->actor.speedXZ > 0.5f)) { + if ((this->actor.depthInWater >= 28.0f) && (this->actor.speed > 0.5f)) { Matrix_Translate(this->unk_3B4.x, this->unk_3B4.y, this->unk_3B4.z, MTXMODE_NEW); Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); @@ -1835,7 +1836,7 @@ void EnAz_Draw(Actor* thisx, PlayState* play2) { } else { Matrix_Push(); Matrix_Translate(0.0f, 2000.0f, -2000.0f, MTXMODE_APPLY); - Matrix_RotateZS(D_80A993D0[this->unk_384].z * (0x10000 / 360.0f), MTXMODE_APPLY); + Matrix_RotateZS(DEG_TO_BINANG(D_80A993D0[this->unk_384].z), MTXMODE_APPLY); Matrix_Scale(D_80A993AC[this->unk_384].x, D_80A993AC[this->unk_384].y, 0.0f, MTXMODE_APPLY); if (this->unk_374 & 0x800) { gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_PrimColor(play->state.gfxCtx, 0x80, 255, 255, 255, 255)); @@ -1846,7 +1847,7 @@ void EnAz_Draw(Actor* thisx, PlayState* play2) { gSPDisplayList(POLY_XLU_DISP++, gBeaverYoungerBrotherTailVortexDL); Matrix_Pop(); Matrix_Translate(0.0f, 2000.0f, -2100.0f, MTXMODE_APPLY); - Matrix_RotateZS(D_80A993D0[this->unk_384].z * (0x10000 / 360.0f), MTXMODE_APPLY); + Matrix_RotateZS(DEG_TO_BINANG(D_80A993D0[this->unk_384].z), MTXMODE_APPLY); Matrix_Scale(D_80A993D0[this->unk_384].x, D_80A993D0[this->unk_384].y, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gBeaverYoungerBrotherTailSplashDL); diff --git a/src/overlays/actors/ovl_En_Az/z_en_az.h b/src/overlays/actors/ovl_En_Az/z_en_az.h index 2a219eb24..a4c1785fe 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.h +++ b/src/overlays/actors/ovl_En_Az/z_en_az.h @@ -45,7 +45,7 @@ typedef struct EnAz { /* 0x3C4 */ s16 unk_3C4; /* 0x3C6 */ UNK_TYPE1 unk3C6[6]; /* 0x3CC */ s32 getItemId; - /* 0x3D0 */ s16 unk_3D0[1]; + /* 0x3D0 */ s16 csIdList[1]; /* 0x3D2 */ u16 unk_3D2; /* 0x3D4 */ s16 unk_3D4; /* 0x3D6 */ s16 unk_3D6; diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 6040076f4..5296260f9 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -320,8 +320,8 @@ s32 EnBaba_MoveForward(EnBaba* this, f32 speedTarget) { s32 reachedEnd = false; Vec3f point; - Math_SmoothStepToF(&this->actor.speedXZ, speedTarget, 0.4f, 1000.0f, 0.0f); - rotStep = this->actor.speedXZ * 400.0f; + Math_SmoothStepToF(&this->actor.speed, speedTarget, 0.4f, 1000.0f, 0.0f); + rotStep = this->actor.speed * 400.0f; if (SubS_CopyPointFromPath(this->path, this->waypoint, &point) && SubS_MoveActorToPoint(&this->actor, &point, rotStep)) { this->waypoint++; @@ -485,7 +485,7 @@ void EnBaba_HandleSchedule(EnBaba* this, PlayState* play) { this->animIndex = BOMB_SHOP_LADY_ANIM_KNOCKED_OVER; // Ouch this->textId = 0x2A30; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Enemy_StartFinishingBlow(play, &this->actor); this->stateFlags |= BOMB_SHOP_LADY_STATE_KNOCKED_OVER; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); @@ -638,7 +638,7 @@ void EnBaba_GiveBlastMask(EnBaba* this, PlayState* play) { this->stateFlags |= BOMB_SHOP_LADY_STATE_GAVE_BLAST_MASK; this->actionFunc = EnBaba_GaveBlastMask; } else { - Actor_PickUp(&this->actor, play, GI_MASK_BLAST, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_MASK_BLAST, 300.0f, 300.0f); } } @@ -690,7 +690,7 @@ void EnBaba_KnockedOver(EnBaba* this, PlayState* play) { if (this->animIndex == BOMB_SHOP_LADY_ANIM_KNOCKED_OVER) { if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_BBVO00); + Actor_PlaySfx(&this->actor, NA_SE_VO_BBVO00); } if (curFrame == endFrame) { @@ -699,7 +699,7 @@ void EnBaba_KnockedOver(EnBaba* this, PlayState* play) { } } else { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_40) && (DECR(this->sakonDeadTimer) == 0)) { - Audio_QueueSeqCmd(0x101400FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20); EnBaba_TriggerTransition(play, ENTRANCE(NORTH_CLOCK_TOWN, 7)); } else { Actor_MoveWithGravity(&this->actor); @@ -748,7 +748,7 @@ void EnBaba_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); EnBaba_UpdateModel(this, play); } 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 9017e0f89..14f4112eb 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c @@ -144,7 +144,7 @@ void EnBaguo_Init(Actor* thisx, PlayState* play) { this->actor.shape.yOffset = -3000.0f; this->actor.gravity = -3.0f; this->actor.colChkInfo.damageTable = &sDamageTable; - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~ACTOR_FLAG_1; this->collider.base.acFlags |= AC_HARD; this->actionFunc = EnBaguo_UndergroundIdle; @@ -160,10 +160,10 @@ void EnBaguo_UndergroundIdle(EnBaguo* this, PlayState* play) { this->action = NEJIRON_ACTION_INACTIVE; if (this->actor.xzDistToPlayer < 200.0f && Player_GetMask(play) != PLAYER_MASK_STONE) { this->actor.draw = EnBaguo_DrawBody; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_APPEAR); + Actor_PlaySfx(&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 &= ~ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = EnBaguo_EmergeFromUnderground; } @@ -205,7 +205,7 @@ void EnBaguo_Idle(EnBaguo* this, PlayState* play) { if ((play->gameplayFrames % 8) == 0) { Actor_SpawnFloorDustRing(play, &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); + Actor_PlaySfx(&this->actor, NA_SE_EN_BAKUO_VOICE); } } } @@ -244,17 +244,17 @@ void EnBaguo_Roll(EnBaguo* this, PlayState* play) { this->timer = 100; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = EnBaguo_Idle; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { if (!this->bouncedFlag && this->collider.base.atFlags & AT_BOUNCED) { this->zRollDirection ^= 1; this->bouncedFlag = 1; - this->actor.speedXZ = -7.0f; + this->actor.speed = -7.0f; } Math_ApproachF(&this->currentRotation.x, this->targetRotation.x, 0.2f, 1000.0f); Math_ApproachF(&this->currentRotation.z, this->targetRotation.z, 0.2f, 1000.0f); - Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.3f, 0.5f); + Math_ApproachF(&this->actor.speed, 5.0f, 0.3f, 0.5f); this->actor.world.rot.x += (s16)this->currentRotation.x; if (this->currentRotation.z != 0.0f) { @@ -265,14 +265,14 @@ void EnBaguo_Roll(EnBaguo* this, PlayState* play) { } } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_ROLL - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_BAKUO_ROLL - SFX_FLAG); } } void EnBaguo_SetupRetreatUnderground(EnBaguo* this) { this->action = NEJIRON_ACTION_RETREATING; this->actionFunc = EnBaguo_RetreatUnderground; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void EnBaguo_RetreatUnderground(EnBaguo* this, PlayState* play) { @@ -290,8 +290,8 @@ void EnBaguo_RetreatUnderground(EnBaguo* this, PlayState* play) { this->actor.shape.yOffset = -3000.0f; this->actor.draw = EnBaguo_DrawBody; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_APPEAR); - this->actor.flags |= ACTOR_FLAG_8000000; + Actor_PlaySfx(&this->actor, NA_SE_EN_BAKUO_APPEAR); + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = EnBaguo_UndergroundIdle; } @@ -316,21 +316,23 @@ void EnBaguo_CheckForDetonation(EnBaguo* this, PlayState* play) { // the Nejiron should forcibly explode and as a loop index. i = false; if (this->action != NEJIRON_ACTION_EXPLODING && this->action != NEJIRON_ACTION_RETREATING) { - if (!(this->actor.bgCheckFlags & 1) && this->actor.world.pos.y < (this->actor.home.pos.y - 100.0f)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + this->actor.world.pos.y < (this->actor.home.pos.y - 100.0f)) { // Force a detonation if we're off the ground and have fallen // below our home position (e.g., we rolled off a ledge). i = true; } - if (this->actor.bgCheckFlags & 0x60 && this->actor.depthInWater >= 40.0f) { + if ((this->actor.bgCheckFlags & (BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH)) && + (this->actor.depthInWater >= 40.0f)) { // Force a detonation if we're too far below the water's surface. i = true; } if ((this->collider.base.acFlags & AC_HIT || i)) { this->collider.base.acFlags &= ~AC_HIT; if (i || this->actor.colChkInfo.damageEffect == NEJIRON_DMGEFF_KILL) { - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); this->action = NEJIRON_ACTION_EXPLODING; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.shape.shadowScale = 0.0f; for (i = 0; i < ARRAY_COUNT(this->effects); i++) { @@ -346,11 +348,11 @@ void EnBaguo_CheckForDetonation(EnBaguo* this, PlayState* play) { Actor_Spawn(&play->actorCtx, play, 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); - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfx(&this->actor, NA_SE_EN_BAKUO_DEAD); this->timer = 30; - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.0f); this->collider.elements->dim.scale = 3.0f; @@ -390,7 +392,9 @@ void EnBaguo_Update(Actor* thisx, PlayState* play) { } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 60.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); if (this->action != NEJIRON_ACTION_INACTIVE) { CollisionCheck_SetAC(play, &play->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 8812ae6d3..5479d6c1e 100644 --- a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c +++ b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c @@ -221,10 +221,10 @@ void func_80BE8AAC(EnBaisen* this, PlayState* play) { } } if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); this->textIdIndex++; if (this->textIdIndex < 6) { - func_80151938(play, sTextIds[this->textIdIndex]); + Message_ContinueTextbox(play, sTextIds[this->textIdIndex]); if ((this->textIdIndex % 2) == 0) { this->unk2A4 = this->heishiPointer; } else { @@ -252,7 +252,9 @@ void EnBaisen_Update(Actor* thisx, PlayState* play) { } this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); Actor_SetScale(&this->actor, 0.01f); if (this->unk290) { func_80BE871C(this); diff --git a/src/overlays/actors/ovl_En_Bat/z_en_bat.c b/src/overlays/actors/ovl_En_Bat/z_en_bat.c index cee109c70..138b7287b 100644 --- a/src/overlays/actors/ovl_En_Bat/z_en_bat.c +++ b/src/overlays/actors/ovl_En_Bat/z_en_bat.c @@ -7,7 +7,7 @@ #include "z_en_bat.h" #include "objects/object_bat/object_bat.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_4000) #define THIS ((EnBat*)thisx) @@ -164,8 +164,8 @@ void EnBat_Init(Actor* thisx, PlayState* play) { &play->actorCtx, play, ACTOR_EN_BAT, thisx->world.pos.x + randPlusMinusPoint5Scaled(200.0f), thisx->world.pos.y + randPlusMinusPoint5Scaled(100.0f), thisx->world.pos.z + randPlusMinusPoint5Scaled(200.0f), randPlusMinusPoint5Scaled(0x2000), - 0xFFFF * Rand_ZeroOne(), 0, BAD_BAT_PARAMS(this->switchFlag, this->paramFlags, 0), -1, thisx->unk20, - NULL); + 0xFFFF * Rand_ZeroOne(), 0, BAD_BAT_PARAMS(this->switchFlag, this->paramFlags, 0), CS_ID_NONE, + thisx->halfDaysBits, NULL); BAD_BAT_GET_NUMBER_TO_SPAWN(thisx)--; } } @@ -193,7 +193,7 @@ void EnBat_StepAnimation(EnBat* this, s32 frameStep) { this->animationFrame -= ARRAY_COUNT(sWingsDLs); } if ((prevFrame < BAD_BAT_FLAP_FRAME) && (this->animationFrame >= BAD_BAT_FLAP_FRAME)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_FLY); + Actor_PlaySfx(&this->actor, NA_SE_EN_FFLY_FLY); } } @@ -203,7 +203,7 @@ void EnBat_SetupPerch(EnBat* this) { this->collider.dim.worldSphere.center.x = this->actor.focus.pos.x; this->collider.dim.worldSphere.center.y = this->actor.focus.pos.y; this->collider.dim.worldSphere.center.z = this->actor.focus.pos.z; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnBat_Perch; } @@ -214,7 +214,7 @@ void EnBat_Perch(EnBat* this, PlayState* play) { void EnBat_SetupFlyIdle(EnBat* this) { this->timer = 100; this->collider.base.acFlags |= AC_ON; - this->actor.speedXZ = 3.5f; + this->actor.speed = 3.5f; this->actionFunc = EnBat_FlyIdle; } @@ -225,12 +225,12 @@ void EnBat_FlyIdle(EnBat* this, PlayState* play) { finishedRotStep = Math_ScaledStepToS(&this->actor.shape.rot.y, this->yawTarget, 0x300); - if (this->actor.bgCheckFlags & 8) { - this->actor.bgCheckFlags &= ~8; + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WALL; this->yawTarget = this->actor.wallYaw; } else if (Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, this->actor.home.pos.x, this->actor.home.pos.z) > SQ(300.0f)) { - this->yawTarget = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->yawTarget = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); } else if (finishedRotStep && (Rand_ZeroOne() < 0.015f)) { this->yawTarget = this->actor.shape.rot.y + (((s32)(0x1000 * Rand_ZeroOne()) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); @@ -238,7 +238,7 @@ void EnBat_FlyIdle(EnBat* this, PlayState* play) { finishedRotStep = Math_ScaledStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0x100); - if ((this->actor.bgCheckFlags & 1) || (this->actor.depthInWater > -40.0f)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->actor.depthInWater > -40.0f)) { this->pitchTarget = -0x1000; } else if (this->actor.world.pos.y < (this->actor.home.pos.y - 100.0f)) { this->pitchTarget = -((s32)(0x800 * Rand_ZeroOne()) + 0x800); @@ -262,7 +262,7 @@ void EnBat_FlyIdle(EnBat* this, PlayState* play) { void EnBat_SetupDiveAttack(EnBat* this) { this->collider.base.atFlags |= AT_ON; this->timer = 300; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; sNumberAttacking++; this->actionFunc = EnBat_DiveAttack; } @@ -282,7 +282,7 @@ void EnBat_DiveAttack(EnBat* this, PlayState* play) { preyPos.y = player->actor.world.pos.y + 20.0f; preyPos.z = player->actor.world.pos.z; - pitchTarget = Actor_PitchToPoint(&this->actor, &preyPos); + pitchTarget = Actor_WorldPitchTowardPoint(&this->actor, &preyPos); pitchTarget = CLAMP(pitchTarget, -0x3000, 0x3000); Math_SmoothStepToS(&this->actor.shape.rot.x, pitchTarget, 2, 0x400, 0x40); } else { @@ -295,20 +295,20 @@ void EnBat_DiveAttack(EnBat* this, PlayState* play) { this->timer--; if ((this->timer == 0) || (this->collider.base.atFlags & AT_HIT) || (Player_GetMask(play) == PLAYER_MASK_STONE) || - (this->actor.bgCheckFlags & 1) || (player->stateFlags1 & PLAYER_STATE1_800000) || + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (player->stateFlags1 & PLAYER_STATE1_800000) || (this->actor.depthInWater > -40.0f)) { if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_FFLY_ATTACK); } this->collider.base.atFlags &= ~AT_ON; sNumberAttacking--; EnBat_SetupFlyIdle(this); - } else if ((this->actor.bgCheckFlags & 8) && + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && (ABS_ALT(BINANG_SUB(this->actor.wallYaw, this->actor.yawTowardsPlayer)) > 0x6800)) { sNumberAttacking--; this->collider.base.atFlags &= ~AT_ON; - this->actor.bgCheckFlags &= ~8; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WALL; this->yawTarget = this->actor.wallYaw; EnBat_SetupFlyIdle(this); } @@ -317,10 +317,10 @@ void EnBat_DiveAttack(EnBat* this, PlayState* play) { void EnBat_SetupDie(EnBat* this, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_1; Enemy_StartFinishingBlow(play, &this->actor); - this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); - this->actor.bgCheckFlags &= ~1; + this->actor.speed *= Math_CosS(this->actor.world.rot.x); + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->actor.velocity.y = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_FFLY_DEAD); if (this->actor.colChkInfo.damageEffect == BAD_BAT_DMGEFF_ICE) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; @@ -340,10 +340,10 @@ void EnBat_SetupDie(EnBat* this, PlayState* play) { this->drawDmgEffScale = 0.45f; } - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 40); if (this->actor.flags & ACTOR_FLAG_8000) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } this->collider.base.acFlags &= ~AC_ON; @@ -352,7 +352,7 @@ void EnBat_SetupDie(EnBat* this, PlayState* play) { } void EnBat_Die(EnBat* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); this->actor.colorFilterTimer = 40; if (!(this->actor.flags & ACTOR_FLAG_8000)) { // Carried by arrow @@ -361,7 +361,7 @@ void EnBat_Die(EnBat* this, PlayState* play) { this->actor.shape.rot.z += 0x1780; } - if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { Actor_SpawnIceEffects(play, &this->actor, this->bodyPartPoss, ARRAY_COUNT(this->bodyPartPoss), 2, 0.2f, 0.2f); @@ -397,17 +397,18 @@ void EnBat_SetupStunned(EnBat* this) { if (this->actionFunc != EnBat_Stunned) { this->actor.shape.yOffset = 700.0f; this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.pos.y += 13.0f; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - Actor_SetColorFilter(&this->actor, 0, 255, 0, this->timer); + + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, this->timer); this->actionFunc = EnBat_Stunned; } void EnBat_Stunned(EnBat* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x100); - if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { if (this->timer != 0) { this->timer--; } @@ -478,13 +479,15 @@ void EnBat_Update(Actor* thisx, PlayState* play) { } if (this->actionFunc == EnBat_DiveAttack) { - Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 15.0f, 50.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 15.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } else if ((this->actionFunc != EnBat_FlyIdle) || ((this->actor.xzDistToPlayer < 400.0f) && (this->actor.projectedPos.z > 0.0f))) { if (this->paramFlags & BAD_BAT_PARAMFLAG_0) { - Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 15.0f, 50.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 15.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } else { - Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 15.0f, 50.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 15.0f, 50.0f, UPDBGCHECKINFO_FLAG_4); } } else { Math_Vec3f_Copy(&this->actor.prevPos, &prevPos); diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index c5657e385..071515919 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -171,14 +171,14 @@ void EnBb_Destroy(Actor* thisx, PlayState* play) { void EnBb_CheckForWall(EnBb* this) { s16 yawDiff; - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { yawDiff = this->actor.shape.rot.y - this->actor.wallYaw; if (ABS_ALT(yawDiff) > 0x4000) { this->actor.shape.rot.y = ((this->actor.wallYaw * 2) - this->actor.shape.rot.y) - 0x8000; } this->targetYRotation = this->actor.shape.rot.y; - this->actor.bgCheckFlags &= ~8; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WALL; } } @@ -189,7 +189,7 @@ void EnBb_Freeze(EnBb* this) { this->timer = 80; this->drawDmgEffAlpha = 1.0f; this->actor.flags &= ~ACTOR_FLAG_200; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 80); } void EnBb_Thaw(EnBb* this, PlayState* play) { @@ -216,7 +216,7 @@ void EnBb_UpdateStateForFlying(EnBb* this) { Math_StepToF(&this->flameScaleY, 0.8f, 0.1f); Math_StepToF(&this->flameScaleX, 1.0f, 0.1f); EnBb_CheckForWall(this); - Math_StepToF(&this->actor.speedXZ, this->maxSpeed, 0.5f); + Math_StepToF(&this->actor.speed, this->maxSpeed, 0.5f); Math_ApproachS(&this->actor.shape.rot.y, this->targetYRotation, 5, 0x3E8); this->actor.world.rot.y = this->actor.shape.rot.y; } @@ -236,10 +236,10 @@ void EnBb_SetupFlyIdle(EnBb* this) { this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; this->flyHeightMod = (Math_CosS(this->bobPhase) * 10.0f) + 30.0f; - this->targetYRotation = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->targetYRotation = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); if ((this->actor.xzDistToPlayer < (this->attackRange + 120.0f)) || - (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 300.0f)) { + (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) < 300.0f)) { this->targetYRotation += (s16)((s32)Rand_Next() >> 0x11); } @@ -255,9 +255,9 @@ void EnBb_FlyIdle(EnBb* this, PlayState* play) { EnBb_UpdateStateForFlying(this); if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_WING); } else if ((Animation_OnFrame(&this->skelAnime, 0.0f)) && (Rand_ZeroOne() < 0.1f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_LAUGH); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_LAUGH); } DECR(this->attackWaitTimer); @@ -288,18 +288,18 @@ void EnBb_Attack(EnBb* this, PlayState* play) { EnBb_UpdateStateForFlying(this); if ((Animation_OnFrame(&this->skelAnime, 0.0f)) || (Animation_OnFrame(&this->skelAnime, 5.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_MOUTH); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_MOUTH); } else if ((Animation_OnFrame(&this->skelAnime, 2.0f)) || (Animation_OnFrame(&this->skelAnime, 7.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_WING); } else if ((Animation_OnFrame(&this->skelAnime, 0.0f)) && (Rand_ZeroOne() < 0.1f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_LAUGH); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_LAUGH); } this->timer--; if (((this->attackRange + 120.0f) < this->actor.xzDistToPlayer) || (this->timer == 0) || (Player_GetMask(play) == PLAYER_MASK_STONE) || - (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 400.0f)) { + (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 400.0f)) { EnBb_SetupFlyIdle(this); } } @@ -309,11 +309,11 @@ void EnBb_SetupDown(EnBb* this) { this->collider.base.atFlags |= AT_ON; this->timer = 140; this->collider.base.acFlags |= AC_ON; - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; this->flameScaleY = 0.0f; this->flameScaleX = 0.0f; this->actor.gravity = -2.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_DOWN); this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = EnBb_Down; } @@ -325,10 +325,10 @@ void EnBb_Down(EnBb* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); EnBb_CheckForWall(this); - if (this->actor.bgCheckFlags & 1) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); if (this->timer == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_UP); EnBb_SetupFlyIdle(this); return; } @@ -339,14 +339,14 @@ void EnBb_Down(EnBb* this, PlayState* play) { this->actor.velocity.y = 10.0f; } - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); Math_ScaledStepToS(&this->actor.shape.rot.y, BINANG_ADD(this->actor.yawTowardsPlayer, 0x8000), 0xBB8); } this->actor.world.rot.y = this->actor.shape.rot.y; if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_WING); } if (this->timer > 0) { @@ -363,11 +363,11 @@ void EnBb_SetupDead(EnBb* this, PlayState* play) { func_800BE568(&this->actor, &this->collider); this->timer = 15; this->actor.shape.rot.x += 0x4E20; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_BUBLE_DEAD); Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x70); this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->bodyPartDrawStatus = BB_BODY_PART_DRAW_STATUS_DEAD; this->actor.gravity = -1.5f; @@ -412,22 +412,22 @@ void EnBb_Dead(EnBb* this, PlayState* play) { void EnBb_SetupDamage(EnBb* this) { this->collider.base.acFlags &= ~AC_ON; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_DAMAGE); func_800BE568(&this->actor, &this->collider); if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_ZORA_MAGIC) { - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; this->drawDmgEffAlpha = 2.0f; this->drawDmgEffScale = 0.4f; } else if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_STUN) { - Actor_SetColorFilter(&this->actor, 0, 255, 0, 20); - this->actor.speedXZ = 0.0f; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 20); + this->actor.speed = 0.0f; } else if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_HOOKSHOT) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); - this->actor.speedXZ = 7.0f; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 20); + this->actor.speed = 7.0f; } this->actor.gravity = -1.0f; @@ -435,14 +435,14 @@ void EnBb_SetupDamage(EnBb* this) { } void EnBb_Damage(EnBb* this, PlayState* play) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ < 0.1f)) { + Math_SmoothStepToF(&this->actor.speed, 0.0f, 1.0f, 0.5f, 0.0f); + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.speed < 0.1f)) { EnBb_SetupDown(this); } } void EnBb_SetupFrozen(EnBb* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->actor.velocity.y > 0.0f) { this->actor.velocity.y = 0.0f; } @@ -472,7 +472,7 @@ void EnBb_SetupWaitForRevive(EnBb* this) { this->actor.shape.rot.x = 0; this->actor.world.pos.y += 50.0f; this->timer = 200; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; this->actionFunc = EnBb_WaitForRevive; @@ -565,7 +565,7 @@ void EnBb_UpdateDamage(EnBb* this, PlayState* play) { this->collider.base.atFlags &= ~AT_HIT; this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; this->actor.shape.rot.y = this->actor.world.rot.y; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_BITE); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_BITE); if (this->flameScaleX > 0.0f) { gSaveContext.jinxTimer = 1200; @@ -585,7 +585,8 @@ void EnBb_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); if ((this->actionFunc != EnBb_Dead) && (this->actionFunc != EnBb_WaitForRevive)) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 25.0f, 40.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 25.0f, 40.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; this->collider.dim.worldSphere.center.y = this->actor.world.pos.y + 15.0f; diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index 1b9538146..b751a50d5 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -244,7 +244,7 @@ void EnBba01_Update(Actor* thisx, PlayState* play) { EnBba01_TestIsTalking(this, play); this->enHy.actionFunc(&this->enHy, play); - Actor_UpdateBgCheckInfo(play, &this->enHy.actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->enHy.actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); EnBba01_UpdateModel(this, play); func_809CC270(this, play); } diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c index 1dfc74a22..a1e2798df 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -194,7 +194,7 @@ void EnBbfall_Freeze(EnBbfall* this) { this->timer = 80; this->drawDmgEffAlpha = 1.0f; this->actor.flags &= ~ACTOR_FLAG_200; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 80); } void EnBbfall_Thaw(EnBbfall* this, PlayState* play) { @@ -211,9 +211,9 @@ void EnBbfall_Thaw(EnBbfall* this, PlayState* play) { */ s32 EnBbfall_IsTouchingLava(EnBbfall* this, PlayState* play) { if (!SurfaceType_IsWallDamage(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { - u32 floorType = func_800C99D4(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + FloorType floorType = SurfaceType_GetFloorType(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); - if ((floorType == 2) || (floorType == 3) || (floorType == 9)) { + if ((floorType == FLOOR_TYPE_2) || (floorType == FLOOR_TYPE_3) || (floorType == FLOOR_TYPE_9)) { return true; } } @@ -223,7 +223,7 @@ s32 EnBbfall_IsTouchingLava(EnBbfall* this, PlayState* play) { void EnBbfall_PlaySfx(EnBbfall* this) { if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_MOUTH); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_MOUTH); } func_800B9010(&this->actor, NA_SE_EN_BUBLEFALL_FIRE - SFX_FLAG); @@ -237,14 +237,14 @@ void EnBbfall_PlaySfx(EnBbfall* this) { void EnBbfall_CheckForWall(EnBbfall* this) { s16 yawDiff; - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { yawDiff = this->actor.shape.rot.y - this->actor.wallYaw; if (ABS_ALT(yawDiff) > 0x4000) { this->actor.shape.rot.y = ((this->actor.wallYaw * 2) - this->actor.shape.rot.y) - 0x8000; } - this->actor.bgCheckFlags &= ~8; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WALL; } } @@ -273,7 +273,7 @@ void EnBbfall_SetupWaitForPlayer(EnBbfall* this) { this->actor.colChkInfo.health = sColChkInfoInit.health; this->actor.colorFilterTimer = 0; this->isBgCheckCollisionEnabled = false; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); @@ -283,7 +283,7 @@ void EnBbfall_SetupWaitForPlayer(EnBbfall* this) { this->flamePos[i].y -= 47.0f; } - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = EnBbfall_WaitForPlayer; } @@ -306,7 +306,7 @@ void EnBbfall_SetupEmerge(EnBbfall* this) { this->actor.velocity.y = 17.0f; EnBbfall_EnableColliders(this); this->actor.flags |= ACTOR_FLAG_1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEFALL_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLEFALL_APPEAR); this->actionFunc = EnBbfall_Emerge; } @@ -322,8 +322,8 @@ void EnBbfall_Emerge(EnBbfall* this, PlayState* play) { void EnBbfall_SetupFly(EnBbfall* this) { this->flameOpacity = 255; this->isBgCheckCollisionEnabled = true; - this->actor.bgCheckFlags &= ~1; - this->actor.speedXZ = 5.0f; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; + this->actor.speed = 5.0f; this->actor.gravity = -1.0f; this->actionFunc = EnBbfall_Fly; } @@ -333,7 +333,7 @@ void EnBbfall_Fly(EnBbfall* this, PlayState* play) { Math_StepToF(&this->flameScaleY, 0.8f, 0.1f); Math_StepToF(&this->flameScaleX, 1.0f, 0.1f); EnBbfall_CheckForWall(this); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (EnBbfall_IsTouchingLava(this, play)) { EnBbfall_SetupSinkIntoLava(this); } else { @@ -343,7 +343,7 @@ void EnBbfall_Fly(EnBbfall* this, PlayState* play) { this->actor.shape.rot.y += (s16)randPlusMinusPoint5Scaled(73728.0f); } - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; } this->actor.world.rot.y = this->actor.shape.rot.y; @@ -372,11 +372,11 @@ void EnBbfall_SetupDown(EnBbfall* this) { this->timer = 200; this->flameOpacity = 0; this->collider.base.acFlags |= AC_ON; - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; this->flameScaleY = 0.0f; this->flameScaleX = 0.0f; this->actor.gravity = -2.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_DOWN); this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = EnBbfall_Down; } @@ -385,15 +385,15 @@ void EnBbfall_Down(EnBbfall* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); EnBbfall_CheckForWall(this); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (EnBbfall_IsTouchingLava(this, play)) { EnBbfall_SetupSinkIntoLava(this); return; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); if (this->timer == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_UP); EnBbfall_EnableColliders(this); this->actor.velocity.y = 8.0f; EnBbfall_SetupFly(this); @@ -406,14 +406,14 @@ void EnBbfall_Down(EnBbfall* this, PlayState* play) { this->actor.velocity.y = 10.0f; } - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); Math_ScaledStepToS(&this->actor.shape.rot.y, BINANG_ADD(this->actor.yawTowardsPlayer, 0x8000), 0xBB8); } this->actor.world.rot.y = this->actor.shape.rot.y; if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_WING); } if (this->timer > 0) { @@ -430,11 +430,11 @@ void EnBbfall_SetupDead(EnBbfall* this, PlayState* play) { func_800BE5CC(&this->actor, &this->collider, 0); this->timer = 15; this->actor.shape.rot.x += 0x4E20; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_BUBLE_DEAD); Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x70); this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->bodyPartDrawStatus = BBFALL_BODY_PART_DRAW_STATUS_DEAD; this->actor.gravity = -1.5f; @@ -478,30 +478,30 @@ void EnBbfall_Dead(EnBbfall* this, PlayState* play) { void EnBbfall_SetupDamage(EnBbfall* this) { this->collider.base.acFlags &= ~AC_ON; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLE_DAMAGE); func_800BE5CC(&this->actor, &this->collider, 0); if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_ZORA_MAGIC) { - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; this->drawDmgEffAlpha = 2.0f; this->drawDmgEffScale = 0.4f; } else if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_STUN) { - Actor_SetColorFilter(&this->actor, 0, 255, 0, 20); - this->actor.speedXZ = 0.0f; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 20); + this->actor.speed = 0.0f; } else if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_HOOKSHOT) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); - this->actor.speedXZ = 7.0f; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 20); + this->actor.speed = 7.0f; } this->actionFunc = EnBbfall_Damage; } void EnBbfall_Damage(EnBbfall* this, PlayState* play) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ < 0.1f)) { + Math_SmoothStepToF(&this->actor.speed, 0.0f, 1.0f, 0.5f, 0.0f); + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.speed < 0.1f)) { if (EnBbfall_IsTouchingLava(this, play)) { EnBbfall_SetupSinkIntoLava(this); } else { @@ -511,7 +511,7 @@ void EnBbfall_Damage(EnBbfall* this, PlayState* play) { } void EnBbfall_SetupFrozen(EnBbfall* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->actor.velocity.y > 0.0f) { this->actor.velocity.y = 0.0f; } @@ -600,7 +600,8 @@ void EnBbfall_Update(Actor* thisx, PlayState* play) { if (this->actionFunc != EnBbfall_Dead) { Actor_MoveWithGravity(&this->actor); if (this->isBgCheckCollisionEnabled) { - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 25.0f, 20.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 25.0f, 20.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); } for (i = ARRAY_COUNT(this->flamePos) - 1; i >= 2; i--) { diff --git a/src/overlays/actors/ovl_En_Bee/z_en_bee.c b/src/overlays/actors/ovl_En_Bee/z_en_bee.c index cf8c5f68a..f93d18bf5 100644 --- a/src/overlays/actors/ovl_En_Bee/z_en_bee.c +++ b/src/overlays/actors/ovl_En_Bee/z_en_bee.c @@ -104,7 +104,7 @@ void EnBee_Init(Actor* thisx, PlayState* play) { sNumLoadedBees++; this->actor.shape.shadowScale = 12.0f; - if (ActorCutscene_GetCurrentIndex() != -1) { + if (CutsceneManager_GetCurrentCsId() != CS_ID_NONE) { func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_ITEMACTION); } @@ -149,7 +149,7 @@ void EnBee_FlyIdle(EnBee* this, PlayState* play) { Vec3f nextPos; s32 pad[2]; - if ((this->actor.category != ACTORCAT_ENEMY) && (ActorCutscene_GetCurrentIndex() == -1)) { + if ((this->actor.category != ACTORCAT_ENEMY) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE)) { func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_ENEMY); } @@ -173,7 +173,7 @@ void EnBee_FlyIdle(EnBee* this, PlayState* play) { } Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &nextPos), 1, 0x7D0, 0); - Math_ApproachF(&this->actor.speedXZ, 3.0f, 0.3f, 1.0f); + Math_ApproachF(&this->actor.speed, 3.0f, 0.3f, 1.0f); if ((this->attackDelayTimer == 0) && (this->actor.params != BEE_BEHAVIOR_IDLE)) { EnBee_SetupAttack(this); @@ -227,7 +227,7 @@ void EnBee_Attack(EnBee* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &nextPos), 1, 0x1388, 0); Math_ApproachF(&this->actor.world.pos.y, nextPos.y, 0.3f, 3.0f); - Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.3f, 1.0f); + Math_ApproachF(&this->actor.speed, 5.0f, 0.3f, 1.0f); } void EnBee_UpdateDamage(EnBee* this, PlayState* play) { @@ -238,7 +238,7 @@ void EnBee_UpdateDamage(EnBee* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { Enemy_StartFinishingBlow(play, &this->actor); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 10, NA_SE_EN_CUTBODY); this->actor.colChkInfo.health = 0; SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EN_EXTINCT); @@ -262,7 +262,7 @@ void EnBee_Update(Actor* thisx, PlayState* play) { } } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BEE_FLY - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_BEE_FLY - SFX_FLAG); EnBee_UpdateDamage(this, play); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); Actor_SetFocus(&this->actor, 0.0f); @@ -271,7 +271,9 @@ void EnBee_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 40.0f, 40.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 40.0f, 40.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); diff --git a/src/overlays/actors/ovl_En_Bh/z_en_bh.c b/src/overlays/actors/ovl_En_Bh/z_en_bh.c index 2aff9891d..da6bc06a3 100644 --- a/src/overlays/actors/ovl_En_Bh/z_en_bh.c +++ b/src/overlays/actors/ovl_En_Bh/z_en_bh.c @@ -52,7 +52,7 @@ void func_80C22DEC(EnBh* this, PlayState* play) { s16 yRot; s16 zRot; - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; xDiff = this->pos.x - this->actor.world.pos.x; yDiff = this->pos.y - this->actor.world.pos.y; zDiff = this->pos.z - this->actor.world.pos.z; diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c index b995d77ea..f331666d3 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -102,9 +102,9 @@ void EnBigokuta_Init(Actor* thisx, PlayState* play) { Collider_InitAndSetCylinder(play, &this->shellCollider, &this->picto.actor, &sShellCylinderInit); Collider_InitAndSetCylinder(play, &this->bodyCollider, &this->picto.actor, &sBodyCylinderInit); CollisionCheck_SetInfo(&this->picto.actor.colChkInfo, NULL, &sColChkInfoInit); - this->cutscene = ActorCutscene_GetAdditionalCutscene(this->picto.actor.cutscene); + this->csId = CutsceneManager_GetAdditionalCsId(this->picto.actor.csId); - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02) || + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE) || ((this->picto.actor.params != 0xFF) && Flags_GetSwitch(play, this->picto.actor.params))) { Actor_Kill(&this->picto.actor); } else { @@ -129,11 +129,11 @@ void EnBigokuta_Destroy(Actor* thisx, PlayState* play) { void EnBigokuta_SetupCutsceneCamera(EnBigokuta* this, PlayState* play, Vec3f* subCamAt, Vec3f* subCamEye) { s16 angle; - ActorCutscene_Start(this->picto.actor.cutscene, &this->picto.actor); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + CutsceneManager_Start(this->picto.actor.csId, &this->picto.actor); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->picto.actor.csId); Play_SetCameraAtEye(play, this->subCamId, subCamAt, subCamEye); - angle = BINANG_SUB(Actor_YawToPoint(&this->picto.actor, subCamEye), this->picto.actor.home.rot.y); + angle = BINANG_SUB(Actor_WorldYawTowardPoint(&this->picto.actor, subCamEye), this->picto.actor.home.rot.y); if (angle > 0) { angle = BINANG_ADD(this->picto.actor.home.rot.y, 0x1800); } else { @@ -160,7 +160,7 @@ void EnBigokuta_ResetCamera(EnBigokuta* this, PlayState* play) { subCam = Play_GetCamera(play, this->subCamId); Play_SetCameraAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye); this->subCamId = SUB_CAM_ID_DONE; - ActorCutscene_Stop(this->picto.actor.cutscene); + CutsceneManager_Stop(this->picto.actor.csId); } } @@ -179,7 +179,7 @@ void EnBigokuta_ShootPlayer(EnBigokuta* this, PlayState* play) { } s32 EnBigokuta_ValidatePictograph(PlayState* play, Actor* thisx) { - return Snap_ValidatePictograph(play, thisx, PICTOGRAPH_BIG_OCTO, &thisx->focus.pos, &thisx->shape.rot, 280.0f, + return Snap_ValidatePictograph(play, thisx, PICTO_VALID_BIG_OCTO, &thisx->focus.pos, &thisx->shape.rot, 280.0f, 1800.0f, -1); } @@ -237,7 +237,7 @@ void EnBigokuta_SetupRise(EnBigokuta* this, PlayState* play) { EffectSsGSplash_Spawn(play, &splashPos, NULL, NULL, 0, Rand_S16Offset(1000, 200)); angle = BINANG_ADD(angle, 0x2000); } - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_DAIOCTA_LAND); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_DAIOCTA_LAND); this->actionFunc = EnBigokuta_RiseOutOfWater; } @@ -259,7 +259,7 @@ void EnBigokuta_IdleAboveWater(EnBigokuta* this, PlayState* play) { Math_ApproachS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 5, 0x1000); if ((this->picto.actor.xzDistToPlayer > 400.0f) || (this->picto.actor.playerHeightRel > 200.0f)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_DAIOCTA_SINK); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_DAIOCTA_SINK); EnBigokuta_SetupIdle(this); } else if ((this->picto.actor.xzDistToPlayer < 200.0f) && play->grabPlayer(play, GET_PLAYER(play))) { EnBigokuta_SetupSuckInPlayer(this, play); @@ -267,15 +267,15 @@ void EnBigokuta_IdleAboveWater(EnBigokuta* this, PlayState* play) { } void EnBigokuta_UpdateOrSetupCam(EnBigokuta* this, PlayState* play) { - if (this->picto.actor.cutscene != -1) { + if (this->picto.actor.csId != CS_ID_NONE) { if (this->subCamId != SUB_CAM_ID_DONE) { EnBigokuta_MoveCamera(this, play); - } else if (ActorCutscene_GetCanPlayNext(this->picto.actor.cutscene)) { + } else if (CutsceneManager_IsNext(this->picto.actor.csId)) { Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); EnBigokuta_SetupCutsceneCamera(this, play, &mainCam->at, &mainCam->eye); } else { - ActorCutscene_SetIntentToPlay(this->picto.actor.cutscene); + CutsceneManager_Queue(this->picto.actor.csId); } } } @@ -289,13 +289,13 @@ void EnBigokuta_SetupSuckInPlayer(EnBigokuta* this, PlayState* play) { this->timer = 0; Animation_Change(&this->skelAnime, &gBigOctoIdleAnim, 1.0f, 12.0f, 12.0f, ANIMMODE_ONCE, -3.0f); - ActorCutscene_SetIntentToPlay(this->picto.actor.cutscene); + CutsceneManager_Queue(this->picto.actor.csId); this->playerHoldPos.x = (Math_SinS(this->picto.actor.shape.rot.y) * 66.0f) + this->picto.actor.world.pos.x; this->playerHoldPos.y = (this->picto.actor.home.pos.y - 49.5f) + 42.899998f; this->playerHoldPos.z = (Math_CosS(this->picto.actor.shape.rot.y) * 66.0f) + this->picto.actor.world.pos.z; - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_SLIME_DEAD); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_SLIME_DEAD); this->actionFunc = EnBigokuta_SuckInPlayer; } @@ -347,7 +347,7 @@ void EnBigokuta_HoldPlayer(EnBigokuta* this, PlayState* play) { if (this->timer == 0) { EnBigokuta_ShootPlayer(this, play); - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_DAIOCTA_REVERSE); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_DAIOCTA_REVERSE); } } else if (this->timer == -24) { EnBigokuta_SetupIdleAboveWater(this); @@ -355,7 +355,7 @@ void EnBigokuta_HoldPlayer(EnBigokuta* this, PlayState* play) { } void EnBigokuta_SetupDeathCutscene(EnBigokuta* this) { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); this->timer = 0; this->bodyCollider.base.acFlags &= ~AC_ON; this->actionFunc = EnBigokuta_PlayDeathCutscene; @@ -374,11 +374,11 @@ void EnBigokuta_PlayDeathCutscene(EnBigokuta* this, PlayState* play) { Actor_SpawnIceEffects(play, &this->picto.actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.5f, 0.35f); EnBigokuta_SetupDeathEffects(this); } - } else if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_Start(this->cutscene, &this->picto.actor); + } else if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Start(this->csId, &this->picto.actor); if (!CHECK_EVENTINF(EVENTINF_41) && !CHECK_EVENTINF(EVENTINF_35)) { - func_800B724C(play, &this->picto.actor, PLAYER_CSMODE_7); + func_800B724C(play, &this->picto.actor, PLAYER_CSMODE_WAIT); } else { player = GET_PLAYER(play); player->stateFlags1 |= PLAYER_STATE1_20; @@ -390,13 +390,13 @@ void EnBigokuta_PlayDeathCutscene(EnBigokuta* this, PlayState* play) { EnBigokuta_SetupDeathEffects(this); } } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } void EnBigokuta_SetupDeathEffects(EnBigokuta* this) { Animation_MorphToPlayOnce(&this->skelAnime, &gBigOctoDeathAnim, -5.0f); - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_DAIOCTA_DEAD2); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_DAIOCTA_DEAD2); this->picto.actor.flags &= ~1; this->timer = 10; this->actionFunc = EnBigokuta_PlayDeathEffects; @@ -422,7 +422,7 @@ void EnBigokuta_PlayDeathEffects(EnBigokuta* this, PlayState* play) { dustPos.z = this->picto.actor.world.pos.z; func_800B0DE0(play, &dustPos, &gZeroVec3f, &gZeroVec3f, &D_80AC45B0, &D_80AC45B4, 1200, 20); - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_OCTAROCK_DEAD2); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_OCTAROCK_DEAD2); } } else { this->picto.actor.world.pos.y -= 0.2f; @@ -450,11 +450,11 @@ void EnBigokuta_PlayDeathEffects(EnBigokuta* this, PlayState* play) { Flags_SetSwitch(play, this->picto.actor.params); } - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); Actor_Kill(&this->picto.actor); if (!CHECK_EVENTINF(EVENTINF_41) && !CHECK_EVENTINF(EVENTINF_35)) { - func_800B724C(play, &this->picto.actor, PLAYER_CSMODE_6); + func_800B724C(play, &this->picto.actor, PLAYER_CSMODE_END); } else { Player* player = GET_PLAYER(play); @@ -475,7 +475,7 @@ s32 EnBigokuta_IsNearSwampBoat(EnBigokuta* this, PlayState* play) { this->picto.actor.child = SubS_FindActor(play, NULL, ACTORCAT_BG, ACTOR_BG_INGATE); if ((this->picto.actor.child != NULL) && - (Actor_XZDistanceBetweenActors(&this->picto.actor, this->picto.actor.child) < 250.0f)) { + (Actor_WorldDistXZToActor(&this->picto.actor, this->picto.actor.child) < 250.0f)) { return true; } else { return false; @@ -506,7 +506,8 @@ void EnBigokuta_CheckOneHitKill(EnBigokuta* this, PlayState* play) { } this->bodyCollider.base.acFlags &= ~AC_HIT; - Actor_SetColorFilter(&this->picto.actor, 0x4000, 255, 0, Animation_GetLastFrame(&gBigOctoDeathAnim)); + Actor_SetColorFilter(&this->picto.actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, + Animation_GetLastFrame(&gBigOctoDeathAnim)); EnBigokuta_ShootPlayer(this, play); EnBigokuta_SetupDeathCutscene(this); } diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h index 6bcfa79fb..41ae325e0 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h @@ -16,7 +16,7 @@ typedef struct EnBigokuta { /* 0x190 */ u8 drawDmgEffType; /* 0x192 */ s16 timer; /* 0x194 */ s16 subCamId; - /* 0x196 */ s16 cutscene; + /* 0x196 */ s16 csId; /* 0x198 */ Vec3s jointTable[BIGOKUTA_LIMB_MAX]; /* 0x210 */ Vec3s morphTable[BIGOKUTA_LIMB_MAX]; /* 0x288 */ f32 drawDmgEffAlpha; diff --git a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c index 2c27a1801..915bf85ba 100644 --- a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c +++ b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c @@ -219,7 +219,7 @@ void func_80A2778C(EnBigpamet* this) { ptr->unk_20 = Rand_ZeroFloat(0.0025000002f) + 0.002f; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_PAMET_BREAK); + Actor_PlaySfx(&this->actor, NA_SE_EN_B_PAMET_BREAK); } void func_80A27970(EnBigpamet* this, PlayState* play2) { @@ -295,7 +295,7 @@ void func_80A27B58(EnBigpamet* this) { ptr->unk_20 = Rand_ZeroFloat(0.0025000002f) + 0.002f; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_PAMET_BREAK); + Actor_PlaySfx(&this->actor, NA_SE_EN_B_PAMET_BREAK); } void func_80A27DD8(EnBigpamet* this, PlayState* play) { @@ -408,7 +408,7 @@ void func_80A282C8(EnBigpamet* this, PlayState* play) { void func_80A28378(EnBigpamet* this) { this->actor.parent->params = GEKKO_INIT_SNAPPER; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_80A283A0; } @@ -421,7 +421,7 @@ void func_80A283A0(EnBigpamet* this, PlayState* play) { void func_80A283F0(EnBigpamet* this) { Animation_PlayLoop(&this->skelAnime2, &object_tl_Anim_00823C); - this->actor.speedXZ = 1.0f; + this->actor.speed = 1.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.params = ENBIGPAMET_1; this->actionFunc = func_80A2844C; @@ -431,10 +431,11 @@ void func_80A2844C(EnBigpamet* this, PlayState* play) { SkelAnime_Update(&this->skelAnime2); if (this->actor.parent->params == GEKKO_RETURN_TO_SNAPPER) { - Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->actor.parent), 0x400); + Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardActor(&this->actor, this->actor.parent), + 0x400); this->actor.world.rot.y = this->actor.shape.rot.y; } else if (this->actor.parent->params == GEKKO_JUMP_ON_SNAPPER) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else if (this->actor.parent->params == GEKKO_ON_SNAPPER) { func_80A28E40(this); } @@ -445,9 +446,9 @@ void func_80A284E4(EnBigpamet* this) { this->unk_29E = 0; this->unk_2A8 = 1.0f; this->unk_2A4 = 1.0f; - this->actor.speedXZ = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_PAMET_VOICE); - Actor_PlaySfxAtPos(this->actor.parent, NA_SE_EN_FROG_VOICE1); + this->actor.speed = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_B_PAMET_VOICE); + Actor_PlaySfx(this->actor.parent, NA_SE_EN_FROG_VOICE1); this->actionFunc = func_80A2855C; } @@ -467,8 +468,8 @@ void func_80A2855C(EnBigpamet* this, PlayState* play) { void func_80A28618(EnBigpamet* this) { this->actor.draw = func_80A2966C; this->unk_2A8 = 0.5f; - this->actor.speedXZ = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_CUTTER_ON); + this->actor.speed = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_PAMET_CUTTER_ON); this->actionFunc = func_80A2866C; } @@ -498,11 +499,11 @@ void func_80A28708(EnBigpamet* this, PlayState* play) { } void func_80A28760(EnBigpamet* this) { - this->actor.speedXZ = 15.0f; - if (this->actor.bgCheckFlags & 8) { + this->actor.speed = 15.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.wallYaw; - this->actor.bgCheckFlags &= ~8; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WALL; if (temp_v1 > 0x3C00) { this->actor.world.rot.y = this->actor.wallYaw + 0x3C00; @@ -538,14 +539,14 @@ void func_80A287E8(EnBigpamet* this, PlayState* play) { func_80A27FE8(this, play); } - if (this->actor.bgCheckFlags & 8) { - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); this->actor.velocity.y = this->unk_29E * 0.375f; Quake_SetSpeed(quakeIndex, 20000); - Quake_SetQuakeValues(quakeIndex, 15, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 10); + Quake_SetPerturbations(quakeIndex, 15, 0, 0, 0); + Quake_SetDuration(quakeIndex, 10); Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); @@ -556,11 +557,11 @@ void func_80A287E8(EnBigpamet* this, PlayState* play) { } void func_80A28970(EnBigpamet* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_CUTTER_OFF); + Actor_PlaySfx(&this->actor, NA_SE_EN_PAMET_CUTTER_OFF); this->actor.shape.rot.z = 0; this->collider.base.atFlags &= ~AT_ON; this->collider.info.bumper.dmgFlags = 0xF7CFFFFF; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_80A289C8; } @@ -617,16 +618,16 @@ void func_80A28B98(EnBigpamet* this, PlayState* play) { this->collider.base.acFlags &= ~AC_ON; this->actor.velocity.y = 22.0f; - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; if ((this->actor.draw == func_80A2966C) && (this->actionFunc != func_80A28DC0)) { this->actor.draw = EnBigpamet_Draw; } else if (this->collider.base.ac != NULL) { - this->actor.world.rot.y = BINANG_ROT180(Actor_YawBetweenActors(&this->actor, this->collider.base.ac)); + this->actor.world.rot.y = BINANG_ROT180(Actor_WorldYawTowardActor(&this->actor, this->collider.base.ac)); } this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->actor.flags &= ~ACTOR_FLAG_1; this->actor.params = ENBIGPAMET_0; @@ -638,17 +639,17 @@ void func_80A28B98(EnBigpamet* this, PlayState* play) { collectible = Item_DropCollectible(play, &this->actor.world.pos, ITEM00_ARROWS_10); if (collectible != NULL) { collectible->velocity.y = 15.0f; - collectible->world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + collectible->world.rot.y = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_PAMET_REVERSE); + Actor_PlaySfx(&this->actor, NA_SE_EN_B_PAMET_REVERSE); this->actionFunc = func_80A28D0C; } void func_80A28D0C(EnBigpamet* this, PlayState* play) { SkelAnime_Update(&this->skelAnime2); - if (this->actor.bgCheckFlags & 1) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_LAND); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + Actor_PlaySfx(&this->actor, NA_SE_EN_HIPLOOP_LAND); func_80A27FE8(this, play); func_80A28D80(this); } @@ -658,7 +659,7 @@ void func_80A28D0C(EnBigpamet* this, PlayState* play) { void func_80A28D80(EnBigpamet* this) { this->actor.draw = func_80A2966C; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.shape.rot.x = 0; this->actor.shape.rot.z = 0; this->unk_2A8 = 0.0f; @@ -680,7 +681,7 @@ void func_80A28DC0(EnBigpamet* this, PlayState* play) { void func_80A28E40(EnBigpamet* this) { Animation_MorphToPlayOnce(&this->skelAnime2, &object_tl_Anim_000440, -2.0f); this->actor.flags |= ACTOR_FLAG_1; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_80A28E98; } @@ -758,7 +759,9 @@ void EnBigpamet_Update(Actor* thisx, PlayState* play) { if ((this->actionFunc != func_80A281DC) && (this->actionFunc != func_80A282C8)) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 50.0f, 60.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 50.0f, 60.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); func_80A276F4(this); Actor_SetFocus(&this->actor, 25.0f); 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 5398418f2..f6061d096 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -8,7 +8,7 @@ #include "objects/object_bigpo/object_bigpo.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200 | ACTOR_FLAG_1000) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200 | ACTOR_FLAG_IGNORE_QUAKE) #define THIS ((EnBigpo*)thisx) @@ -206,7 +206,7 @@ void EnBigpo_Init(Actor* thisx, PlayState* play2) { } ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 45.0f); - thisx->bgCheckFlags |= 0x400; + thisx->bgCheckFlags |= BGCHECKFLAG_PLAYER_400; this->savedHeight = thisx->home.pos.y + 100.0f; this->mainColor.r = 255; this->mainColor.g = 255; @@ -259,7 +259,7 @@ void EnBigpo_UpdateSpin(EnBigpo* this) { this->actor.shape.rot.y += this->rotVelocity; if ((oldYaw < 0) && (this->actor.shape.rot.y > 0)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); // spinning sfx during spin attack + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_ROLL); // spinning sfx during spin attack } } @@ -293,22 +293,22 @@ void EnBigpo_WellWaitForProximity(EnBigpo* this, PlayState* play) { } void EnBigpo_SetupSpawnCutscene(EnBigpo* this) { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); this->actionFunc = EnBigpo_WaitCutsceneQueue; } void EnBigpo_WaitCutsceneQueue(EnBigpo* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); - func_800B724C(play, &this->actor, PLAYER_CSMODE_7); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); + func_800B724C(play, &this->actor, PLAYER_CSMODE_WAIT); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->actor.csId); if (this->actor.params == ENBIGPO_REGULAR) { // and SUMMONED, got switched earlier EnBigpo_SpawnCutsceneStage1(this, play); } else { // ENBIGPO_REVEALEDFIRE EnBigpo_SetupFlameCirclePositions(this, play); } } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -395,7 +395,7 @@ void EnBigpo_SpawnCutsceneStage5(EnBigpo* this) { Animation_PlayLoop(&this->skelAnime, &gBigpoAwakenStretchAnim); this->actor.draw = EnBigpo_DrawMainBigpo; Actor_SetScale(&this->actor, 0.014f); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_APPEAR); this->actionFunc = EnBigpo_SpawnCutsceneStage6; } @@ -464,14 +464,14 @@ void EnBigpo_SpawnCutsceneStage8(EnBigpo* this, PlayState* play) { dampe = SubS_FindActor(play, NULL, ACTORCAT_NPC, ACTOR_EN_TK); if (dampe != NULL) { // if dampe exists, switch to viewing his running away cutscene - dampe->params = this->actor.cutscene; + dampe->params = this->actor.csId; } else { - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); } } else { // ENBIGPO_REGULAR - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); } - func_800B724C(play, &this->actor, PLAYER_CSMODE_6); + func_800B724C(play, &this->actor, PLAYER_CSMODE_END); EnBigpo_SetupIdleFlying(this); // setup idle flying } } @@ -482,8 +482,8 @@ void EnBigpo_SetupWarpOut(EnBigpo* this) { this->rotVelocity = 0x2000; this->idleTimer = 32; this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF - this->actor.speedXZ = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DISAPPEAR); + this->actor.speed = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_DISAPPEAR); this->actionFunc = EnBigpo_WarpingOut; } @@ -505,7 +505,7 @@ void EnBigpo_SetupWarpIn(EnBigpo* this, PlayState* play) { f32 distance = CLAMP_MIN(this->actor.xzDistToPlayer, 200.0f); s16 randomYaw = ((s32)Rand_Next() >> 0x14) + this->actor.yawTowardsPlayer; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfx(&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; @@ -556,10 +556,10 @@ void EnBigpo_IdleFlying(EnBigpo* this, PlayState* play) { this->hoverHeightCycleTimer = (this->hoverHeightCycleTimer == 0) ? 40 : (this->hoverHeightCycleTimer - 1); Math_StepToF(&this->savedHeight, player->actor.world.pos.y + 100.0f, 1.5f); this->actor.world.pos.y = (sin_rad(this->hoverHeightCycleTimer * (M_PI / 20)) * 10.0f) + this->savedHeight; - Math_StepToF(&this->actor.speedXZ, 3.0f, 0.2f); + Math_StepToF(&this->actor.speed, 3.0f, 0.2f); func_800B9010(&this->actor, NA_SE_EN_PO_FLY - SFX_FLAG); - if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 300.0f) { - this->unk208 = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 300.0f) { + this->unk208 = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); } if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->unk208, 0x200) && (Rand_ZeroOne() < 0.075f)) { @@ -580,7 +580,7 @@ void EnBigpo_SetupSpinUp(EnBigpo* this) { this->collider.base.atFlags |= AT_ON; this->rotVelocity = 0x800; this->actionFunc = EnBigpo_SpinningUp; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void EnBigpo_SpinningUp(EnBigpo* this, PlayState* play) { @@ -603,7 +603,7 @@ void EnBigpo_SpinAttack(EnBigpo* this, PlayState* play) { s16 yawDiff; SkelAnime_Update(&this->skelAnime); - Math_StepToF(&this->actor.speedXZ, 10.0f, 1.0f); + Math_StepToF(&this->actor.speed, 10.0f, 1.0f); Math_SmoothStepToF(&this->actor.world.pos.y, player->actor.world.pos.y, 0.3f, 7.5f, 1.0f); EnBigpo_UpdateSpin(this); yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; @@ -628,7 +628,7 @@ void EnBigpo_SpinningDown(EnBigpo* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_SmoothStepToF(&this->actor.world.pos.y, player->actor.world.pos.y + 100.0f, 0.3f, 5.0f, 1.0f); - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); + Math_StepToF(&this->actor.speed, 0.0f, 0.2f); if (Math_ScaledStepToS(&this->rotVelocity, 0, 0x200)) { // spin down complete, re-allow hittable this->collider.base.colType = COLTYPE_HIT3; @@ -645,18 +645,18 @@ void EnBigpo_SpinningDown(EnBigpo* this, PlayState* play) { */ void EnBigpo_HitStun(EnBigpo* this) { Animation_MorphToPlayOnce(&this->skelAnime, &gBigpoShockAnim, -6.0f); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0x10); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 16); this->collider.base.acFlags &= ~AC_ON; func_800BE504(&this->actor, &this->collider); this->actionFunc = EnBigpo_CheckHealth; - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; } /* * check if just damaged or dead */ void EnBigpo_CheckHealth(EnBigpo* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.colChkInfo.health == 0) { EnBigpo_SetupDeath(this); @@ -668,7 +668,7 @@ void EnBigpo_CheckHealth(EnBigpo* this, PlayState* play) { void EnBigpo_SetupDeath(EnBigpo* this) { this->idleTimer = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.hintId = TATL_HINT_ID_NONE; this->collider.base.ocFlags1 &= ~OC1_ON; @@ -725,7 +725,7 @@ void EnBigpo_BurnAwayDeath(EnBigpo* this, PlayState* play) { func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); // burning sfx } if (this->idleTimer == 18) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); } } @@ -744,12 +744,12 @@ void EnBigpo_SetupLanternDrop(EnBigpo* this, PlayState* play) { this->actor.world.pos.y -= 15.0f; func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_MISC); this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); // targetable OFF, enemy music OFF - this->actor.bgCheckFlags &= ~0x400; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_PLAYER_400; this->actionFunc = EnBigpo_LanternFalling; } void EnBigpo_LanternFalling(EnBigpo* this, PlayState* play) { - if (this->actor.bgCheckFlags & 1 || this->actor.floorHeight == BGCHECK_Y_MIN) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND || this->actor.floorHeight == BGCHECK_Y_MIN) { if (this->switchFlags != 0xFF) { Flags_SetSwitch(play, this->switchFlags); } @@ -795,7 +795,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; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_METAL_BOX_BOUND); // misnamed? + Actor_PlaySfx(&this->actor, NA_SE_EV_METAL_BOX_BOUND); // misnamed? this->actionFunc = EnBigpo_ScoopSoulAppearing; } @@ -824,10 +824,10 @@ void EnBigpo_ScoopSoulIdle(EnBigpo* this, PlayState* play) { if (this->idleTimer == 0) { // took too long, soul is leaving - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_LAUGH); EnBigpo_SetupScoopSoulLeaving(this); } else { - Actor_PickUp(&this->actor, play, GI_MAX, 35.0f, 60.0f); + Actor_OfferGetItem(&this->actor, play, GI_MAX, 35.0f, 60.0f); this->actor.world.pos.y = (sin_rad(this->idleTimer * (M_PI / 20)) * 5.0f) + this->savedHeight; } } @@ -1123,13 +1123,13 @@ s32 EnBigpo_ApplyDamage(EnBigpo* this, PlayState* play) { if (Actor_ApplyDamage(&this->actor) == 0) { this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_DEAD); Enemy_StartFinishingBlow(play, &this->actor); if (this->actor.params == ENBIGPO_SUMMONED) { // dampe type Audio_RestorePrevBgm(); } } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_DAMAGE); } // light arrows @@ -1164,7 +1164,7 @@ void EnBigpo_Update(Actor* thisx, PlayState* play) { this->unk20C = 0; } if (this->unk20C == 40) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_LAUGH); EnBigpo_SetupWarpOut(this); } } @@ -1174,7 +1174,7 @@ void EnBigpo_Update(Actor* thisx, PlayState* play) { Actor_MoveWithGravity(&this->actor); } if (this->actionFunc == EnBigpo_LanternFalling) { - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 27.0f, 60.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 27.0f, 60.0f, UPDBGCHECKINFO_FLAG_4); } if (this->actor.draw == EnBigpo_DrawScoopSoul) { 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 9cf4b425b..3992cd02a 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -347,7 +347,7 @@ void EnBigslime_Init(Actor* thisx, PlayState* play2) { return; } - this->cutscene = this->actor.cutscene; + this->csId = this->actor.csId; this->actor.scale.x = this->actor.scale.z = 0.15f; this->actor.scale.y = 0.075f; this->vtxScaleX = this->vtxScaleZ = 0.015000001f; @@ -536,47 +536,47 @@ void EnBigslime_CheckRoomBoundaries(EnBigslime* this, Vec3f* vtxMax, Vec3f* vtxM f32 vtxMaxZ; f32 vtxMinZ; - this->actor.bgCheckFlags &= ~(0x2 | 0x8 | 0x10); + this->actor.bgCheckFlags &= ~(BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_WALL | BGCHECKFLAG_CEILING); if ((this->actor.world.pos.y + vtxMax->y) > GBT_ROOM_5_MAX_Y) { this->actor.world.pos.y = GBT_ROOM_5_MAX_Y - vtxMax->y; - this->actor.bgCheckFlags |= 0x10; + this->actor.bgCheckFlags |= BGCHECKFLAG_CEILING; } if ((this->actor.world.pos.y + vtxMin->y) <= GBT_ROOM_5_MIN_Y) { this->actor.world.pos.y = GBT_ROOM_5_MIN_Y - vtxMin->y; - if (!(this->actor.bgCheckFlags & 1)) { - this->actor.bgCheckFlags |= 2; + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + this->actor.bgCheckFlags |= BGCHECKFLAG_GROUND_TOUCH; } - this->actor.bgCheckFlags |= 1; + this->actor.bgCheckFlags |= BGCHECKFLAG_GROUND; } else { - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; } - if ((this->actionFunc != EnBigslime_Freeze) || !(this->actor.bgCheckFlags & 1)) { + if ((this->actionFunc != EnBigslime_Freeze) || !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { worldPosX = this->actor.world.pos.x; vtxMaxX = vtxMax->x; if (GBT_ROOM_5_MAX_X < (worldPosX + vtxMaxX)) { - this->actor.bgCheckFlags |= 8; + this->actor.bgCheckFlags |= BGCHECKFLAG_WALL; this->actor.world.pos.x = GBT_ROOM_5_MAX_X - vtxMaxX; } else { vtxMinX = vtxMin->x; if ((worldPosX + vtxMinX) < GBT_ROOM_5_MIN_X) { this->actor.world.pos.x = GBT_ROOM_5_MIN_X - vtxMinX; - this->actor.bgCheckFlags |= 8; + this->actor.bgCheckFlags |= BGCHECKFLAG_WALL; } } worldPosZ = this->actor.world.pos.z; vtxMaxZ = vtxMax->z; if (GBT_ROOM_5_MAX_Z < (worldPosZ + vtxMaxZ)) { - this->actor.bgCheckFlags |= 8; + this->actor.bgCheckFlags |= BGCHECKFLAG_WALL; this->actor.world.pos.z = GBT_ROOM_5_MAX_Z - vtxMaxZ; } else { vtxMinZ = vtxMin->z; if ((worldPosZ + vtxMinZ) < GBT_ROOM_5_MIN_Z) { this->actor.world.pos.z = GBT_ROOM_5_MIN_Z - vtxMinZ; - this->actor.bgCheckFlags |= 8; + this->actor.bgCheckFlags |= BGCHECKFLAG_WALL; } } } @@ -742,11 +742,11 @@ void EnBigslime_EndThrowMinislime(EnBigslime* this) { void EnBigslime_BreakIntoMinislime(EnBigslime* this, PlayState* play) { s32 i; - s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 20000); - Quake_SetQuakeValues(quakeIndex, 15, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 15); + Quake_SetPerturbations(quakeIndex, 15, 0, 0, 0); + Quake_SetDuration(quakeIndex, 15); Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); @@ -769,10 +769,10 @@ void EnBigslime_BreakIntoMinislime(EnBigslime* this, PlayState* play) { this->actor.hintId = TATL_HINT_ID_GEKKO_GIANT_SLIME; this->gekkoRot.x = 0; this->gekkoRot.y = 0; - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->formBigslimeTimer = 2; EnBigslime_AddIceShardEffect(this, play); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_BREAK); + Actor_PlaySfx(&this->actor, NA_SE_EN_B_SLIME_BREAK); EnBigslime_SetupJumpGekko(this); } @@ -847,9 +847,9 @@ void EnBigslime_EndCutscene(EnBigslime* this, PlayState* play) { subCam = Play_GetCamera(play, this->subCamId); Play_SetCameraAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye); this->subCamId = SUB_CAM_ID_DONE; - ActorCutscene_Stop(this->cutscene); - this->cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); - func_800B724C(play, &this->actor, PLAYER_CSMODE_6); + CutsceneManager_Stop(this->csId); + this->csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); + func_800B724C(play, &this->actor, PLAYER_CSMODE_END); } } @@ -986,7 +986,7 @@ void EnBigslime_SetupCallMinislime(EnBigslime* this, PlayState* play) { Animation_MorphToPlayOnce(&this->skelAnime, &gGekkoCallAnim, 5.0f); EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_GREET); this->callTimer = 0; - func_800B7298(play, &this->actor, PLAYER_CSMODE_7); + func_800B7298(play, &this->actor, PLAYER_CSMODE_WAIT); this->actionFunc = EnBigslime_CallMinislime; } @@ -1020,11 +1020,11 @@ void EnBigslime_SetupMoveOnCeiling(EnBigslime* this) { this->actor.velocity.y = 20.0f; if (this->subCamId != SUB_CAM_ID_DONE) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->ceilingMoveTimer = 20; } else { this->ceilingMoveTimer = 320; - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; } this->wavySurfaceTimer = 0; @@ -1051,7 +1051,7 @@ void EnBigslime_MoveOnCeiling(EnBigslime* this, PlayState* play) { } else if ((this->actor.xzDistToPlayer < 250.0f) || (this->ceilingMoveTimer == 0)) { EnBigslime_SetupDrop(this); } else { - this->actor.speedXZ = (fabsf(Math_SinS(pitch)) * 3.0f) + 5.0f; + this->actor.speed = (fabsf(Math_SinS(pitch)) * 3.0f) + 5.0f; Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 10, 0x800, 0x80); this->gekkoRot.y = this->actor.world.rot.y; } @@ -1060,7 +1060,7 @@ void EnBigslime_MoveOnCeiling(EnBigslime* this, PlayState* play) { void EnBigslime_SetupDrop(EnBigslime* this) { this->actor.velocity.y = 0.0f; this->ceilingDropTimer = 30; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnBigslime_Drop; } @@ -1083,7 +1083,7 @@ void EnBigslime_Drop(EnBigslime* this, PlayState* play) { EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_DOWN); this->rotation = 0; } - } else if (this->actor.bgCheckFlags & 1) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { EnBigslime_SetupSquishFlat(this); } else { Math_StepToF(&this->actor.scale.x, 0.15f, 0.0025f); @@ -1213,7 +1213,7 @@ void EnBigslime_SetTargetVtxToWideCone(EnBigslime* this) { } void EnBigslime_SetupSquishFlat(EnBigslime* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_JUMP2); + Actor_PlaySfx(&this->actor, NA_SE_EN_B_SLIME_JUMP2); this->squishFlatTimer = 20; this->actor.scale.x = 0.2f; this->actor.scale.z = 0.2f; @@ -1412,7 +1412,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); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_JUMP1); + Actor_PlaySfx(&this->actor, NA_SE_EN_B_SLIME_JUMP1); this->riseCounter = 0; this->bigslimeCollider[0].base.atFlags &= ~AT_ON; this->actor.gravity = 0.0f; @@ -1500,7 +1500,7 @@ void EnBigslime_SetupCutsceneGrabPlayer(EnBigslime* this, PlayState* play) { this->grabPlayerTimer = 15; this->wavySurfaceTimer = 0; this->bigslimeCollider[0].base.atFlags &= ~AT_ON; - this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->actor.world.rot.y = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); yaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) - this->actor.world.rot.y; if (yaw > 0x4000) { @@ -1515,7 +1515,7 @@ void EnBigslime_SetupCutsceneGrabPlayer(EnBigslime* this, PlayState* play) { this->subCamYawGrabPlayer += this->actor.world.rot.y; Animation_PlayLoop(&this->skelAnime, &gGekkoBoxingStanceAnim); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_EAT); + Actor_PlaySfx(&this->actor, NA_SE_EN_B_SLIME_EAT); this->actionFunc = EnBigslime_CutsceneGrabPlayer; } @@ -1614,7 +1614,7 @@ void EnBigslime_AttackPlayerInBigslime(EnBigslime* this, PlayState* play) { if (this->numGekkoMeleeAttacks == 0) { this->numGekkoPosGrabPlayer--; - if ((gSaveContext.save.playerData.health < 5) || (this->numGekkoPosGrabPlayer == 0)) { + if ((gSaveContext.save.saveInfo.playerData.health < 5) || (this->numGekkoPosGrabPlayer == 0)) { this->numGekkoPosGrabPlayer = 0; this->gekkoRot.y = this->actor.world.rot.y; this->gekkoPosOffset.x = Math_SinS(this->gekkoRot.y) * -50.0f; @@ -1624,7 +1624,7 @@ void EnBigslime_AttackPlayerInBigslime(EnBigslime* this, PlayState* play) { } play->damagePlayer(play, -4); - func_800B8E58(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S); + Player_PlaySfx(player, player->ageProperties->voiceSfxIdOffset + 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; @@ -1701,7 +1701,7 @@ void EnBigslime_WindupThrowPlayer(EnBigslime* this, PlayState* play) { this->gekkoPosOffset.z = Math_CosS(this->gekkoRot.y) * -50.0f; } else { if (this->windupPunchTimer == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_REVERSE); + Actor_PlaySfx(&this->actor, NA_SE_EN_B_SLIME_REVERSE); EnBigslime_GekkoSfxInsideBigslime(this, NA_SE_EN_FROG_PUNCH1); } @@ -1818,9 +1818,9 @@ void EnBigslime_SetupFreeze(EnBigslime* this) { s32 i; s32 j; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->freezeTimer = 40; - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; } else if ((this->actionFunc == EnBigslime_Rise) && (this->riseCounter < 2)) { @@ -1898,7 +1898,7 @@ void EnBigslime_Freeze(EnBigslime* this, PlayState* play) { } func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { if (this->freezeTimer == 0) { EnBigslime_BreakIntoMinislime(this, play); } else { @@ -1907,7 +1907,7 @@ void EnBigslime_Freeze(EnBigslime* this, PlayState* play) { EnBigslime_SetupSquishFlat(this); } } else if (this->freezeTimer == 0) { - if (!(this->actor.bgCheckFlags & 1)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { EnBigslime_SetupFrozenFall(this); } else { EnBigslime_SetupFrozenGround(this); @@ -2019,14 +2019,14 @@ void EnBigslime_FrozenFall(EnBigslime* this, PlayState* play) { func_800B8D50(play, &this->actor, 7.0f, this->actor.yawTowardsPlayer, 5.0f, 0x10); } - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { EnBigslime_BreakIntoMinislime(this, play); } } void EnBigslime_SetupJumpGekko(EnBigslime* this) { Animation_PlayLoop(&this->skelAnime, &gGekkoJumpForwardAnim); - this->actor.speedXZ = 8.0f; + this->actor.speed = 8.0f; this->jumpTimer = 100; this->actor.world.rot.y = this->gekkoRot.y; this->gekkoYaw = this->actor.yawTowardsPlayer + 0x8000; @@ -2037,7 +2037,7 @@ void EnBigslime_JumpGekko(EnBigslime* this, PlayState* play) { s16 yaw; s16 yawDiff; - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->gekkoCollider.base.acFlags |= AC_ON; this->actor.flags |= ACTOR_FLAG_1; } @@ -2049,15 +2049,16 @@ void EnBigslime_JumpGekko(EnBigslime* this, PlayState* play) { EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EV_WALK_WATER); } - if (!(this->actor.bgCheckFlags & 1) || ((this->skelAnime.curFrame > 1.0f) && (this->skelAnime.curFrame < 12.0f))) { - this->actor.speedXZ = 8.0f; + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || + ((this->skelAnime.curFrame > 1.0f) && (this->skelAnime.curFrame < 12.0f))) { + this->actor.speed = 8.0f; } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } if (Math_SmoothStepToS(&this->actor.world.rot.y, this->gekkoYaw, 5, 0x1000, 0x80) == 0) { - if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 240.0f) { - yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 240.0f) { + yaw = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); yawDiff = yaw - (s16)(this->actor.yawTowardsPlayer + 0x8000); this->gekkoYaw = ABS_ALT(yawDiff) < 0x3000 ? yaw : (yawDiff / 2) + (s16)(this->actor.yawTowardsPlayer + 0x8000); @@ -2087,8 +2088,8 @@ void EnBigslime_JumpGekko(EnBigslime* this, PlayState* play) { void EnBigslime_SetupIdleLookAround(EnBigslime* this) { Animation_PlayOnce(&this->skelAnime, &gGekkoNervousIdleAnim); this->idleTimer = 60; - this->actor.speedXZ = 0.0f; - if (BINANG_SUB(Actor_YawToPoint(&this->actor, &this->actor.home.pos), this->gekkoRot.y) > 0) { + this->actor.speed = 0.0f; + if (BINANG_SUB(Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), this->gekkoRot.y) > 0) { this->gekkoYaw = this->gekkoRot.y + (Rand_Next() >> 20) + 0x2000; } else { this->gekkoYaw = this->gekkoRot.y - (Rand_Next() >> 20) - 0x2000; @@ -2110,7 +2111,7 @@ void EnBigslime_IdleLookAround(EnBigslime* this, PlayState* play) { if ((this->skelAnime.animation == &gGekkoNervousIdleAnim) && Math_ScaledStepToS(&this->gekkoRot.y, this->gekkoYaw, 0x400)) { - if (BINANG_SUB(Actor_YawToPoint(&this->actor, &this->actor.home.pos), this->gekkoRot.y) > 0) { + if (BINANG_SUB(Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), this->gekkoRot.y) > 0) { this->gekkoYaw = this->gekkoRot.y + (Rand_Next() >> 20) + 0x2000; } else { this->gekkoYaw = this->gekkoRot.y - (Rand_Next() >> 20) - 0x2000; @@ -2144,7 +2145,7 @@ void EnBigslime_IdleNoticePlayer(EnBigslime* this, PlayState* play) { void EnBigslime_SetupThrowMinislime(EnBigslime* this) { Animation_PlayOnce(&this->skelAnime, &gGekkoWindupPunchAnim); EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_HOLD_SLIME); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnBigslime_ThrowMinislime; } @@ -2168,7 +2169,7 @@ void EnBigslime_SetupDamageGekko(EnBigslime* this, s32 isNotFrozen) { Animation_MorphToPlayOnce(&this->skelAnime, &gGekkoDamagedAnim, -3.0f); this->gekkoCollider.base.acFlags &= ~AC_ON; this->damageSpinTimer = 20; - this->actor.speedXZ = 10.0f; + this->actor.speed = 10.0f; this->actor.gravity = -2.0f; this->actor.velocity.y = 0.0f; if (isNotFrozen) { @@ -2192,7 +2193,7 @@ void EnBigslime_DamageGekko(EnBigslime* this, PlayState* play) { this->damageSpinTimer--; damageSpinTimer = CLAMP_MAX(this->damageSpinTimer, 10); this->gekkoRot.y += 0x300 * damageSpinTimer; - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); if (this->damageSpinTimer == 0) { EnBigslime_SetupCutscene(this); } @@ -2205,7 +2206,7 @@ void EnBigslime_SetupStunGekko(EnBigslime* this) { } this->actionFunc = EnBigslime_StunGekko; this->skelAnime.playSpeed = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void EnBigslime_StunGekko(EnBigslime* this, PlayState* play) { @@ -2224,10 +2225,10 @@ void EnBigslime_StunGekko(EnBigslime* this, PlayState* play) { void EnBigslime_SetupCutsceneFormBigslime(EnBigslime* this) { Animation_PlayOnce(&this->skelAnime, &gGekkoJumpUpAnim); this->gekkoCollider.base.acFlags &= ~AC_ON; - this->actor.world.rot.x = -Actor_PitchToPoint(&this->actor, &this->actor.home.pos); - this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->actor.world.rot.x = -Actor_WorldPitchTowardPoint(&this->actor, &this->actor.home.pos); + this->actor.world.rot.y = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); this->actionFunc = EnBigslime_CutsceneFormBigslime; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void EnBigslime_CutsceneFormBigslime(EnBigslime* this, PlayState* play) { @@ -2245,7 +2246,7 @@ void EnBigslime_SetupFormBigslime(EnBigslime* this) { this->gekkoRot.x = 0x4000 - this->actor.world.rot.x; this->formBigslimeTimer = 0; this->wavySurfaceTimer = 0; - this->actor.speedXZ = 25.0f; + this->actor.speed = 25.0f; this->gekkoRot.y = this->actor.world.rot.y; this->formBigslimeCutsceneTimer = 2; @@ -2281,10 +2282,10 @@ void EnBigslime_FormBigslime(EnBigslime* this, PlayState* play) { Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Animation_PlayLoop(&this->skelAnime, &gGekkoSwimForwardAnim); this->formBigslimeCutsceneTimer--; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_COMBINE); + Actor_PlaySfx(&this->actor, NA_SE_EN_B_SLIME_COMBINE); } else if (this->isAnimUpdate) { this->formBigslimeCutsceneTimer--; if (this->formBigslimeCutsceneTimer == 0) { @@ -2324,7 +2325,7 @@ void EnBigslime_SetupCutsceneDefeat(EnBigslime* this, PlayState* play) { Animation_GetLastFrame(&gGekkoDamagedAnim.common), ANIMMODE_ONCE_INTERP, 0.0f); this->gekkoCollider.base.acFlags &= ~AC_ON; this->defeatTimer = 60; - this->actor.speedXZ = 10.0f; + this->actor.speed = 10.0f; this->actor.gravity = -2.0f; this->actor.velocity.y = 0.0f; EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_DEAD); @@ -2334,7 +2335,7 @@ void EnBigslime_SetupCutsceneDefeat(EnBigslime* this, PlayState* play) { subCamAt.y = this->actor.world.pos.y + 40.0f; subCamAt.z = this->actor.world.pos.z; - if (BINANG_SUB(Actor_YawToPoint(&this->actor, &this->actor.home.pos), this->actor.world.rot.y) > 0) { + if (BINANG_SUB(Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), this->actor.world.rot.y) > 0) { yawOffset = this->actor.world.rot.y + 0x4000; } else { yawOffset = this->actor.world.rot.y - 0x4000; @@ -2363,7 +2364,7 @@ void EnBigslime_CutsceneDefeat(EnBigslime* this, PlayState* play) { this->defeatTimer--; defeatTimer = CLAMP_MAX(this->defeatTimer, 10); this->gekkoRot.y += 0x300 * defeatTimer; - if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f)) { + if (Math_StepToF(&this->actor.speed, 0.0f, 0.5f)) { EnBigslime_SetupGekkoDespawn(this, play); } else { // Continue for the camera to follow Gekko as it spins in defeat @@ -2522,31 +2523,31 @@ void EnBigslime_InitEntrance(EnBigslime* this, PlayState* play) { } void EnBigslime_SetupCutscene(EnBigslime* this) { - if (ActorCutscene_GetCurrentIndex() == 0x7D) { - ActorCutscene_Stop(0x7D); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_DOOR) { + CutsceneManager_Stop(CS_ID_GLOBAL_DOOR); } if (this->actor.colChkInfo.health == 0) { - this->cutscene = this->actor.cutscene; + this->csId = this->actor.csId; } - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); this->actionFuncStored = this->actionFunc; this->actionFunc = EnBigslime_PlayCutscene; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void EnBigslime_PlayCutscene(EnBigslime* this, PlayState* play) { - if (ActorCutscene_GetCurrentIndex() == 0x7D) { - ActorCutscene_Stop(0x7D); - ActorCutscene_SetIntentToPlay(this->cutscene); - } else if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_Start(this->cutscene, &this->actor); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_DOOR) { + CutsceneManager_Stop(CS_ID_GLOBAL_DOOR); + CutsceneManager_Queue(this->csId); + } else if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Start(this->csId, &this->actor); if (this->actionFuncStored != EnBigslime_SquishFlat) { - func_800B724C(play, &this->actor, PLAYER_CSMODE_7); + func_800B724C(play, &this->actor, PLAYER_CSMODE_WAIT); } - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->cutscene); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->csId); if (this->actor.colChkInfo.health == 0) { EnBigslime_SetupCutsceneDefeat(this, play); } else if ((this->actionFuncStored == EnBigslime_DamageGekko) || @@ -2559,7 +2560,7 @@ void EnBigslime_PlayCutscene(EnBigslime* this, PlayState* play) { EnBigslime_SetupCutsceneStartBattle(this, play); } } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } @@ -2644,7 +2645,7 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, PlayState* play) { EnBigslime_SetupCutscene(this); } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ELECTRIC_STUN) { this->stunTimer = 40; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; this->gekkoDrawDmgEffScale = 0.75f; this->gekkoDrawDmgEffAlpha = 2.0f; @@ -2652,7 +2653,7 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, PlayState* play) { } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_STUN || this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_DEKU_STUN) { this->stunTimer = 40; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); EnBigslime_SetupStunGekko(this); } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ICE) { EnBigslime_GekkoFreeze(this); @@ -2722,7 +2723,7 @@ void EnBigslime_AddIceShardEffect(EnBigslime* this, PlayState* play) { } } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); + Actor_PlaySfx(&this->actor, NA_SE_EV_ICE_BROKEN); EnBigslime_InitShockwave(this, play); } @@ -2837,7 +2838,9 @@ void EnBigslime_UpdateGekko(Actor* thisx, PlayState* play) { Actor_MoveWithoutGravity(&this->actor); } - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 40.0f, 80.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 40.0f, 80.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); this->gekkoCollider.dim.pos.x = (s16)this->actor.world.pos.x; this->gekkoCollider.dim.pos.z = (s16)this->actor.world.pos.z; if (this->gekkoCollider.base.acFlags & AC_ON) { diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h index 52a29013c..f10938b37 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h @@ -66,7 +66,7 @@ typedef struct EnBigslime { /* 0x02B4 */ u8 shockwaveAlpha; /* 0x02B5 */ u8 gekkoDrawDmgEffType; /* 0x02B6 */ s16 gekkoYaw; - /* 0x02B8 */ s16 cutscene; + /* 0x02B8 */ s16 csId; /* 0x02BA */ union { // multi-use timer s16 idleTimer; s16 noticeTimer; 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 ed7b8c194..43e87a90a 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 @@ -208,21 +208,21 @@ void EnBji01_DialogueHandler(EnBji01* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - func_801477B4(play); + Message_CloseTextbox(play); func_809CD634(this, play); break; case 1: func_8019F230(); switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: - func_80151938(play, 0x5F0); + Message_ContinueTextbox(play, 0x5F0); break; case PLAYER_FORM_HUMAN: - func_80151938(play, 0x5F8); + Message_ContinueTextbox(play, 0x5F8); break; case PLAYER_FORM_GORON: case PLAYER_FORM_ZORA: - func_80151938(play, 0x5E1); + Message_ContinueTextbox(play, 0x5E1); break; } break; @@ -235,16 +235,16 @@ void EnBji01_DialogueHandler(EnBji01* this, PlayState* play) { switch (play->msgCtx.currentTextId) { case 0x5DE: SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 3, &this->animIndex); - func_80151938(play, 0x5DF); + Message_ContinueTextbox(play, 0x5DF); break; case 0x5E4: - func_80151938(play, 0x5E7); + Message_ContinueTextbox(play, 0x5E7); break; case 0x5E5: - func_80151938(play, 0x5E0); + Message_ContinueTextbox(play, 0x5E0); break; case 0x5E7: - func_80151938(play, 0x5E5); + Message_ContinueTextbox(play, 0x5E5); break; case 0x5DC: case 0x5DD: @@ -254,11 +254,11 @@ void EnBji01_DialogueHandler(EnBji01* this, PlayState* play) { case 0x5EE: case 0x5F2: case 0x5F5: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x5F0: case 0x5F6: - func_80151938(play, 0x5EF); + Message_ContinueTextbox(play, 0x5EF); break; case 0x5E1: case 0x5E8: @@ -270,7 +270,7 @@ void EnBji01_DialogueHandler(EnBji01* this, PlayState* play) { case 0x5F4: case 0x5F7: case 0x5F8: - func_801477B4(play); + Message_CloseTextbox(play); this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.params = SHIKASHI_TYPE_FINISHED_CONVERSATION; func_809CCE98(this, play); @@ -292,7 +292,7 @@ void EnBji01_DialogueHandler(EnBji01* this, PlayState* play) { void func_809CD634(EnBji01* this, PlayState* play) { AudioSfx_MuteBanks((1 << BANK_PLAYER) | (1 << BANK_ITEM) | (1 << BANK_ENV) | (1 << BANK_ENEMY) | (1 << BANK_OCARINA) | (1 << BANK_VOICE)); - Audio_QueueSeqCmd(0xE0000101); + SEQCMD_DISABLE_PLAY_SEQUENCES(true); play->nextEntrance = ENTRANCE(TERMINA_FIELD, 10); /* Telescope entrance */ gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance = play->nextEntrance; func_80169EFC(&play->state); /* Load new entrance? */ @@ -337,7 +337,7 @@ void EnBji01_Init(Actor* thisx, PlayState* play) { this->animIndex = -1; Actor_SetScale(&this->actor, 0.01f); - SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_FillCutscenesList(&this->actor, this->csIdList, ARRAY_COUNT(this->csIdList)); this->moonsTear = (ObjMoonStone*)SubS_FindActor(play, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); switch (gSaveContext.save.entrance) { @@ -346,13 +346,15 @@ void EnBji01_Init(Actor* thisx, PlayState* play) { this->actor.params = SHIKASHI_TYPE_DEFAULT; func_809CCE98(this, play); break; + case ENTRANCE(ASTRAL_OBSERVATORY, 2): /* Telescope entrance */ this->actor.flags |= ACTOR_FLAG_10000; AudioSfx_MuteBanks(0); - Audio_QueueSeqCmd(0xE0000100); + SEQCMD_DISABLE_PLAY_SEQUENCES(false); this->actor.params = SHIKASHI_TYPE_LOOKED_THROUGH_TELESCOPE; func_809CCE98(this, play); break; + default: Actor_Kill(&this->actor); break; @@ -371,7 +373,7 @@ void EnBji01_Update(Actor* thisx, PlayState* play) { s32 pad; this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); SkelAnime_Update(&this->skelAnime); if (this->blinkTimer-- <= 0) { diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h index 29afaf533..84c346a1c 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h @@ -31,7 +31,7 @@ typedef struct EnBji01 { /* 0x2A6 */ s16 headZRotStep; /* 0x2A8 */ s16 headXRotStep; /* 0x2AA */ u16 textId; - /* 0x2AC */ s16 cutscenes[1]; + /* 0x2AC */ s16 csIdList[1]; /* 0x2B0 */ ObjMoonStone* moonsTear; } EnBji01; // size = 0x2B4 diff --git a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c index 08070b61d..5ebfca40f 100644 --- a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c +++ b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c @@ -182,7 +182,7 @@ s32 EnBjt_Appear(EnBjt* this) { s32 finished = false; if (!this->playedSfx) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TOILET_HAND_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EV_TOILET_HAND_APPEAR); this->playedSfx = true; } @@ -207,7 +207,7 @@ s32 EnBjt_Vanish(EnBjt* this) { s32 finished = false; if (!this->playedSfx) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TOILET_HAND_VANISH); + Actor_PlaySfx(&this->actor, NA_SE_EV_TOILET_HAND_VANISH); this->playedSfx = true; } @@ -292,7 +292,7 @@ s32 EnBjt_ChooseBehaviour(Actor* thisx, PlayState* play) { this->playedSfx = false; this->behaviour++; } else if (this->timer == 10) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TOILET_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EV_TOILET_WATER); } break; @@ -363,7 +363,7 @@ void EnBjt_Talk(EnBjt* this, PlayState* play) { s16 yaw = this->actor.yawTowardsPlayer; if (func_8010BF58(&this->actor, play, sMsgEventScript, this->msgEventCallback, &this->msgEventArg4)) { - this->actor.flags &= ~ACTOR_FLAG_100; + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; SubS_UpdateFlags(&this->stateFlags, 3, 7); this->stateFlags &= ~TOILET_HAND_STATE_TALKING; this->msgEventArg4 = 0; @@ -406,7 +406,7 @@ void EnBjt_FollowSchedule(EnBjt* this, PlayState* play) { } this->scheduleResult = scheduleOutput.result; } else { - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; Actor_SetScale(&this->actor, 0.0f); this->stateFlags = 0; this->msgEventCallback = NULL; @@ -426,7 +426,7 @@ void EnBjt_Init(Actor* thisx, PlayState* play) { Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; Actor_SetScale(&this->actor, 0.0f); this->scheduleResult = TOILET_HAND_SCH_NONE; diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index a25a33904..17ebe10f7 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -17,11 +17,12 @@ void EnBom_Destroy(Actor* thisx, PlayState* play); void EnBom_Update(Actor* thisx, PlayState* play); void EnBom_Draw(Actor* thisx, PlayState* play); -void func_80871058(EnBom* this, PlayState* play); -void func_808714D4(EnBom* this, PlayState* play); +void EnBom_Move(EnBom* this, PlayState* play); +void EnBom_WaitForRelease(EnBom* this, PlayState* play); + void func_80872648(PlayState* play, Vec3f* arg1); void func_808726DC(PlayState* play, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, s32 arg4); -void func_80872BC0(PlayState* play, s32 arg1); +void EnBom_DrawKeg(PlayState* play, s32 arg1); typedef struct { /* 0x00 */ Vec3f pos; @@ -30,7 +31,7 @@ typedef struct { /* 0x1A */ s16 rotX; } PowderKegFuseSegment; // size = 0x1C -static PowderKegFuseSegment sPowderKegFuseSegments[16]; +PowderKegFuseSegment sPowderKegFuseSegments[16]; ActorInit En_Bom_InitVars = { ACTOR_EN_BOM, @@ -173,11 +174,11 @@ void EnBom_Init(Actor* thisx, PlayState* play) { this->actor.flags |= ACTOR_FLAG_100000; if (Actor_HasParent(&this->actor, play)) { - this->actionFunc = func_808714D4; + this->actionFunc = EnBom_WaitForRelease; this->actor.room = -1; Actor_SetScale(&this->actor, enBomScales[this->isPowderKeg]); } else { - this->actionFunc = func_80871058; + this->actionFunc = EnBom_Move; gSaveContext.powderKegTimer = 0; } } @@ -192,24 +193,26 @@ void EnBom_Destroy(Actor* thisx, PlayState* play) { } } -void func_80871058(EnBom* this, PlayState* play) { +void EnBom_Move(EnBom* this, PlayState* play) { static Vec3f D_80872E68[] = { { 2.0f, -6.0f, -0.3f }, { 1.5f, -5.0f, -0.6f }, { 0.2f, -6.0f, -0.1f }, }; + // if bomb has a parent actor, the bomb hasnt been released yet if (Actor_HasParent(&this->actor, play)) { - this->actionFunc = func_808714D4; + this->actionFunc = EnBom_WaitForRelease; this->actor.room = -1; return; } - if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & 0x10)) { + if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_CEILING)) { this->actor.velocity.y = -this->actor.velocity.y; } - if ((this->actor.speedXZ != 0.0f) && (this->actor.bgCheckFlags & 8)) { + // rebound bomb off the wall it hits + if ((this->actor.speed != 0.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_WALL)) { s16 yDiff = BINANG_SUB(this->actor.wallYaw, this->actor.world.rot.y); if (ABS_ALT(yDiff) > 0x4000) { @@ -217,17 +220,17 @@ void func_80871058(EnBom* this, PlayState* play) { BINANG_SUB(this->actor.wallYaw - this->actor.world.rot.y + this->actor.wallYaw, 0x8000); } - Actor_PlaySfxAtPos(&this->actor, this->isPowderKeg ? NA_SE_EV_PUT_DOWN_WOODBOX : NA_SE_EV_BOMB_BOUND); + Actor_PlaySfx(&this->actor, this->isPowderKeg ? NA_SE_EV_PUT_DOWN_WOODBOX : NA_SE_EV_BOMB_BOUND); Actor_MoveWithGravity(&this->actor); - this->actor.speedXZ *= 0.7f; - this->actor.bgCheckFlags &= ~8; + this->actor.speed *= 0.7f; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WALL; } - if (!(this->actor.bgCheckFlags & 1)) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.08f); + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + Math_StepToF(&this->actor.speed, 0.0f, 0.08f); } else { Vec3f* sp58; - u32 sp54 = func_800C99D4(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + FloorType floorType = SurfaceType_GetFloorType(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); Vec3f slopeNormal; s16 downwardSlopeYaw; f32 sp40; @@ -236,11 +239,11 @@ void func_80871058(EnBom* this, PlayState* play) { sp58 = &D_80872E68[this->isPowderKeg]; - if (sp54 == 5) { + if (floorType == FLOOR_TYPE_5) { sp58 = &D_80872E68[2]; } - if ((sp54 == 4) || (sp54 == 14) || (sp54 == 15)) { + if ((floorType == FLOOR_TYPE_4) || (floorType == FLOOR_TYPE_14) || (floorType == FLOOR_TYPE_15)) { s16 sp36; Math_ApproachF(&this->actor.shape.yOffset, 0.0f, 0.1f, 50.0f); @@ -251,64 +254,65 @@ void func_80871058(EnBom* this, PlayState* play) { Math_ApproachF(&this->actor.shape.yOffset, 700.0f, 1.0f, 700.0f); } - sp40 = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; - sp3C = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; + sp40 = Math_SinS(this->actor.world.rot.y) * this->actor.speed; + sp3C = Math_CosS(this->actor.world.rot.y) * this->actor.speed; Actor_GetSlopeDirection(this->actor.floorPoly, &slopeNormal, &downwardSlopeYaw); sp40 += 3.0f * slopeNormal.x; sp3C += 3.0f * slopeNormal.z; sp38 = sqrtf(SQ(sp40) + SQ(sp3C)); - if ((sp38 < this->actor.speedXZ) || - (SurfaceType_GetSlope(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 1)) { + if ((sp38 < this->actor.speed) || (SurfaceType_GetFloorEffect(&play->colCtx, this->actor.floorPoly, + this->actor.floorBgId) == FLOOR_EFFECT_1)) { if (sp38 > 16.0f) { - this->actor.speedXZ = 16.0f; + this->actor.speed = 16.0f; } else { - this->actor.speedXZ = sp38; + this->actor.speed = sp38; } this->actor.world.rot.y = Math_Atan2S_XY(sp3C, sp40); } - if (!Math_StepToF(&this->actor.speedXZ, 0.0f, sp58->x)) { + if (!Math_StepToF(&this->actor.speed, 0.0f, sp58->x)) { s16 temp = this->actor.world.rot.y; s32 pad; if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->actor.shape.rot.y)) > 0x4000) { temp = BINANG_ROT180(temp); } - Math_ScaledStepToS(&this->actor.shape.rot.y, temp, this->actor.speedXZ * 100.0f); - this->unk_1FA += (s16)(this->actor.speedXZ * 800.0f); + Math_ScaledStepToS(&this->actor.shape.rot.y, temp, this->actor.speed * 100.0f); + this->unk_1FA += (s16)(this->actor.speed * 800.0f); } - if (this->actor.bgCheckFlags & 2) { - Actor_PlaySfxAtPos(&this->actor, this->isPowderKeg ? NA_SE_EV_TRE_BOX_BOUND : NA_SE_EV_BOMB_BOUND); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + Actor_PlaySfx(&this->actor, this->isPowderKeg ? NA_SE_EV_TRE_BOX_BOUND : NA_SE_EV_BOMB_BOUND); if (this->actor.velocity.y < sp58->y) { - if ((sp54 == 4) || (sp54 == 14) || (sp54 == 15)) { + if ((floorType == FLOOR_TYPE_4) || (floorType == FLOOR_TYPE_14) || (floorType == FLOOR_TYPE_15)) { this->actor.velocity.y = 0.0f; } else { this->actor.velocity.y = this->actor.velocity.y * sp58->z; } - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; } } else if (this->timer >= 4) { - Actor_LiftActor(&this->actor, play); + Actor_OfferCarry(&this->actor, play); } } Actor_MoveWithGravity(&this->actor); } -void func_808714D4(EnBom* this, PlayState* play) { +void EnBom_WaitForRelease(EnBom* this, PlayState* play) { + // if parent is NULL bomb has been released if (Actor_HasNoParent(&this->actor, play)) { - this->actionFunc = func_80871058; + this->actionFunc = EnBom_Move; this->actor.room = play->roomCtx.curRoom.num; this->actor.flags &= ~ACTOR_FLAG_100000; - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; Math_Vec3s_ToVec3f(&this->actor.prevPos, &this->actor.home.rot); if (this->isPowderKeg) { gSaveContext.powderKegTimer = 0; } - func_80871058(this, play); + EnBom_Move(this, play); } else { Math_Vec3f_ToVec3s(&this->actor.home.rot, &this->actor.parent->world.pos); if (this->isPowderKeg) { @@ -318,12 +322,12 @@ void func_808714D4(EnBom* this, PlayState* play) { Math_ScaledStepToS(&this->unk_1FA, 0, 2000); } -void func_808715B8(EnBom* this, PlayState* play) { +void EnBom_Explode(EnBom* this, PlayState* play) { static s16 D_80872E8C[] = { 100, 200 }; static Color_RGBA8 D_80872E90 = { 185, 140, 70, 255 }; static Color_RGBA8 D_80872E94 = { 255, 255, 255, 255 }; s32 i; - s32 temp_s0; + FloorType floorType; f32 temp_f20; s32 pad; f32 spCC; @@ -347,7 +351,7 @@ void func_808715B8(EnBom* this, PlayState* play) { this->collider2.base.atFlags &= ~OC1_TYPE_1; } - if (this->actor.params == ENBOM_1) { + if (this->actor.params == BOMB_TYPE_EXPLOSION) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider2.base); } @@ -390,11 +394,11 @@ void func_808715B8(EnBom* this, PlayState* play) { spB4.y = this->actor.world.pos.y + 500.0f; spB4.z = this->actor.world.pos.z + spC0.z; if (BgCheck_EntityRaycastFloor3(&play->colCtx, &spB0, &spAC, &spB4) != BGCHECK_Y_MIN) { - temp_s0 = func_800C99D4(&play->colCtx, spB0, spAC); + floorType = SurfaceType_GetFloorType(&play->colCtx, spB0, spAC); temp_f20 = BgCheck_EntityRaycastFloor1(&play->colCtx, &spB0, &spB4); - if ((temp_s0 == 4) || (temp_s0 == 15) || (temp_s0 == 14)) { - if (temp_s0 == 4) { + if ((floorType == FLOOR_TYPE_4) || (floorType == FLOOR_TYPE_15) || (floorType == FLOOR_TYPE_14)) { + if (floorType == FLOOR_TYPE_4) { sp84 = D_80872E90; sp80 = D_80872E90; } else { @@ -419,16 +423,16 @@ void func_808715B8(EnBom* this, PlayState* play) { } } -static s16 D_80872E98[] = { 3, 5 }; -static s16 D_80872E9C[] = { 10, 15 }; +static s16 sQuakeY[] = { 3, 5 }; +static s16 sQuakeDurations[] = { 10, 15 }; void EnBom_Update(Actor* thisx, PlayState* play) { - Vec3f spA4 = { 0.0f, 0.0f, 0.0f }; - Vec3f sp98 = { 0.0f, 0.1f, 0.0f }; - Vec3f sp8C = { 0.0f, 0.0f, 0.0f }; - Vec3f sp80; - Vec3f sp74 = { 0.0f, 0.6f, 0.0f }; - Color_RGBA8 sp70 = { 255, 255, 255, 255 }; + Vec3f effVelocity = { 0.0f, 0.0f, 0.0f }; + Vec3f bomb2Accel = { 0.0f, 0.1f, 0.0f }; // unused + Vec3f effAccel = { 0.0f, 0.0f, 0.0f }; + Vec3f effPos; + Vec3f dustAccel = { 0.0f, 0.6f, 0.0f }; + Color_RGBA8 dustColor = { 255, 255, 255, 255 }; EnBom* this = THIS; s32 pad; Player* player = GET_PLAYER(play); @@ -444,9 +448,9 @@ void EnBom_Update(Actor* thisx, PlayState* play) { if (this->unk_1FC != 0) { this->unk_1FC--; - Math_ApproachZeroF(&thisx->speedXZ, 1.0f, 1.0f); + Math_ApproachZeroF(&thisx->speed, 1.0f, 1.0f); Actor_MoveWithGravity(thisx); - Actor_UpdateBgCheckInfo(play, thisx, 35.0f, 10.0f, 36.0f, 4); + Actor_UpdateBgCheckInfo(play, thisx, 35.0f, 10.0f, 36.0f, UPDBGCHECKINFO_FLAG_4); if (this->unk_1FC == 0) { if (this->isPowderKeg) { gSaveContext.powderKegTimer = 0; @@ -456,13 +460,13 @@ void EnBom_Update(Actor* thisx, PlayState* play) { } else { thisx->gravity = -1.2f; if (this->timer != 0) { - if (!this->isPowderKeg || (func_808715B8 == this->actionFunc) || !Play_InCsMode(play)) { + if (!this->isPowderKeg || (EnBom_Explode == this->actionFunc) || !Play_InCsMode(play)) { this->timer--; } } if ((!this->isPowderKeg && (this->timer == 67)) || (this->isPowderKeg && (this->timer <= 2400))) { - Actor_PlaySfxAtPos(thisx, NA_SE_PL_TAKE_OUT_SHIELD); + Actor_PlaySfx(thisx, NA_SE_PL_TAKE_OUT_SHIELD); Actor_SetScale(thisx, enBomScales[this->isPowderKeg]); } @@ -472,18 +476,21 @@ void EnBom_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(play, thisx, 35.0f, 10.0f, 36.0f, 0x1F); - if (thisx->params == ENBOM_0) { + Actor_UpdateBgCheckInfo(play, thisx, 35.0f, 10.0f, 36.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); + if (thisx->params == BOMB_TYPE_BODY) { static Vec3us D_80872ED4[] = { { 40, 20, 100 }, { 300, 60, 600 }, }; Vec3us* sp60 = &D_80872ED4[this->isPowderKeg]; - sp74.y = 0.2f; - Math_Vec3f_Copy(&sp80, &thisx->home.pos); + // spawn spark effect on even frames + dustAccel.y = 0.2f; + Math_Vec3f_Copy(&effPos, &thisx->home.pos); if ((play->gameplayFrames % 2) == 0) { - EffectSsGSpk_SpawnFuse(play, thisx, &sp80, &spA4, &sp8C); + EffectSsGSpk_SpawnFuse(play, thisx, &effPos, &effVelocity, &effAccel); } if (this->isPowderKeg) { func_801A0810(&thisx->projectedPos, NA_SE_IT_BIG_BOMB_IGNIT - SFX_FLAG, @@ -491,25 +498,30 @@ void EnBom_Update(Actor* thisx, PlayState* play) { : (this->flashSpeedScale == 3) ? 1 : 2); } else { - Actor_PlaySfxAtPos(thisx, NA_SE_IT_BOMB_IGNIT - SFX_FLAG); + Actor_PlaySfx(thisx, NA_SE_IT_BOMB_IGNIT - SFX_FLAG); } - sp80.y += 3.0f; - func_800B0DE0(play, &sp80, &spA4, &sp74, &sp70, &sp70, 50, 5); + effPos.y += 3.0f; + func_800B0DE0(play, &effPos, &effVelocity, &dustAccel, &dustColor, &dustColor, 50, 5); if ((this->collider1.base.acFlags & AC_HIT) || ((this->collider1.base.ocFlags1 & OC1_HIT) && ((this->collider1.base.oc->category == ACTORCAT_ENEMY) || (this->collider1.base.oc->category == ACTORCAT_BOSS)))) { this->timer = 0; thisx->shape.rot.z = 0; - } else if ((this->timer > 100) && (Player_IsBurningStickInRange(play, &thisx->world.pos, 30.0f, 50.0f))) { - this->timer = 100; + } else { + // if a lit stick touches the bomb, set timer to 100 + // these bombs never have a timer over 70, so this isn't used + if ((this->timer > 100) && Player_IsBurningStickInRange(play, &thisx->world.pos, 30.0f, 50.0f)) { + this->timer = 100; + } } - sp74.y = 0.2f; - sp80 = thisx->world.pos; - sp80.y += 10.0f; + dustAccel.y = 0.2f; + effPos = thisx->world.pos; + effPos.y += 10.0f; + // double bomb flash speed and adjust red color at certain times during the countdown if ((this->timer == sp60->x) || (this->timer == sp60->y) || (this->timer == 3)) { thisx->shape.rot.z = 0; this->flashSpeedScale >>= 1; @@ -526,43 +538,46 @@ void EnBom_Update(Actor* thisx, PlayState* play) { } if (this->timer == 0) { - sp80 = thisx->world.pos; - sp80.y += 10.0f; + effPos = thisx->world.pos; + effPos.y += 10.0f; if (Actor_HasParent(thisx, play)) { - sp80.y += 30.0f; + effPos.y += 30.0f; } - Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, sp80.x, sp80.y - 10.0f, sp80.z, 0, 0, 0, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, effPos.x, effPos.y - 10.0f, effPos.z, 0, 0, 0, this->isPowderKeg); - func_800BC848(thisx, play, D_80872E98[this->isPowderKeg], D_80872E9C[this->isPowderKeg]); + Actor_RequestQuakeAndRumble(thisx, play, sQuakeY[this->isPowderKeg], + sQuakeDurations[this->isPowderKeg]); play->envCtx.lightSettings.diffuseColor1[0] = play->envCtx.lightSettings.diffuseColor1[1] = play->envCtx.lightSettings.diffuseColor1[2] = 250; play->envCtx.lightSettings.ambientColor[0] = play->envCtx.lightSettings.ambientColor[1] = play->envCtx.lightSettings.ambientColor[2] = 250; Camera_AddQuake(&play->mainCamera, 2, 11, 8); - thisx->params = ENBOM_1; + thisx->params = BOMB_TYPE_EXPLOSION; this->timer = 10; thisx->flags |= (ACTOR_FLAG_20 | ACTOR_FLAG_100000); - this->actionFunc = func_808715B8; + this->actionFunc = EnBom_Explode; if (this->isPowderKeg) { gSaveContext.powderKegTimer = 0; - Actor_PlaySfxAtPos(thisx, NA_SE_IT_BIG_BOMB_EXPLOSION); + Actor_PlaySfx(thisx, NA_SE_IT_BIG_BOMB_EXPLOSION); } else { - Actor_PlaySfxAtPos(thisx, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfx(thisx, NA_SE_IT_BOMB_EXPLOSION); } } } Actor_SetFocus(thisx, 20.0f); - if (thisx->params <= ENBOM_0) { + if (thisx->params <= BOMB_TYPE_BODY) { Collider_UpdateCylinder(thisx, &this->collider1); + + // if link is not holding the bomb anymore and bump conditions are met, subscribe to OC if (!Actor_HasParent(thisx, play) && (this->unk_1F8 != 0)) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); } CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider1.base); } - if ((enBomScales[this->isPowderKeg] <= thisx->scale.x) && (thisx->params != ENBOM_1)) { + if ((enBomScales[this->isPowderKeg] <= thisx->scale.x) && (thisx->params != BOMB_TYPE_EXPLOSION)) { if (thisx->depthInWater >= 20.0f) { Vec3f sp54; @@ -579,9 +594,9 @@ void EnBom_Update(Actor* thisx, PlayState* play) { thisx->velocity.y = (KREG(83) * 0.1f) + -2.0f; thisx->gravity = (KREG(84) * 0.1f) + -0.5f; this->unk_1FC = KREG(81) + 10; - } else if (thisx->bgCheckFlags & 0x40) { - thisx->bgCheckFlags &= ~0x40; - Actor_PlaySfxAtPos(thisx, NA_SE_EV_BOMB_DROP_WATER); + } else if (thisx->bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { + thisx->bgCheckFlags &= ~BGCHECKFLAG_WATER_TOUCH; + Actor_PlaySfx(thisx, NA_SE_EV_BOMB_DROP_WATER); } } } @@ -600,7 +615,7 @@ void EnBom_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); - if (this->actor.params == ENBOM_0) { + if (this->actor.params == BOMB_TYPE_BODY) { func_8012C28C(play->state.gfxCtx); Collider_UpdateSpheres(0, &this->collider2); @@ -644,7 +659,7 @@ void EnBom_Draw(Actor* thisx, PlayState* play) { gSPDisplayList(POLY_OPA_DISP++, gPowderKegGoronSkullDL); func_808726DC(play, &this->actor.home.pos, &sp58, &sp4C, this->timer); - func_80872BC0(play, this->timer); + EnBom_DrawKeg(play, this->timer); } } @@ -768,7 +783,7 @@ void func_808726DC(PlayState* play, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, s32 a Math_Vec3f_Copy(arg1, &fuseSegmentPtr->pos); } -void func_80872BC0(PlayState* play, s32 arg1) { +void EnBom_DrawKeg(PlayState* play, s32 arg1) { s32 temp_s5; s32 i; PowderKegFuseSegment* fuseSegmentPtr = &sPowderKegFuseSegments[0]; diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.h b/src/overlays/actors/ovl_En_Bom/z_en_bom.h index 23218a183..bf568cd6a 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.h +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.h @@ -11,10 +11,10 @@ typedef void (*EnBomActionFunc)(struct EnBom*, PlayState*); #define ENBOM_GETZ_80(thisx) ((thisx)->shape.rot.z & 0x80) #define ENBOM_GETZ_FF00(thisx) (((thisx)->shape.rot.z & 0xFF00) >> 8) -enum { - /* 0 */ ENBOM_0, - /* 1 */ ENBOM_1, -}; +typedef enum { + /* 0 */ BOMB_TYPE_BODY, + /* 1 */ BOMB_TYPE_EXPLOSION, +} BombType; typedef struct EnBom { /* 0x000 */ Actor actor; diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index 4a9876c79..ae45b0cc5 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -99,8 +99,8 @@ void EnBomBowlMan_Init(Actor* thisx, PlayState* play) { if ((gSaveContext.save.entrance == ENTRANCE(EAST_CLOCK_TOWN, 2)) && CHECK_WEEKEVENTREG(WEEKEVENTREG_73_80) && !CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { - this->unk_2D6 = this->actor.cutscene; - if (this->unk_2D6 == 0) { + this->csId3 = this->actor.csId; + if (this->csId3 == 0) { Actor_Kill(&this->actor); } func_809C52B4(this); @@ -123,27 +123,27 @@ void func_809C49CC(EnBomBowlMan* this) { if ((this->unk_2F8 == 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); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_WALK); } if ((this->unk_2F8 == 0xB) && (Animation_OnFrame(&this->skelAnime, 4.0f) || Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 12.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_WALK); } if ((this->unk_2F8 == 0x12) && (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); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_WALK); } if ((this->unk_2F8 == 0xF) && Animation_OnFrame(&this->skelAnime, 15.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_LAND); } if ((this->unk_2F8 == 6) && Animation_OnFrame(&this->skelAnime, 8.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_LAND); } } @@ -173,9 +173,9 @@ void func_809C4BC4(EnBomBowlMan* this, PlayState* play) { func_809C4B50(this); func_809C493C(this, 0, 1.0f); - for (i = 0; i < ARRAY_COUNT(gSaveContext.save.bomberCode); i++) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.saveInfo.bomberCode); i++) { Math_Vec3f_Copy(&sp7C, &this->actor.home.pos); - code = gSaveContext.save.bomberCode[i]; + code = gSaveContext.save.saveInfo.bomberCode[i]; if (code == 1) { Math_Vec3f_Copy(&this->actor.world.pos, &D_809C61A0[i]); this->unk_2D8[code] = this; @@ -192,11 +192,11 @@ void func_809C4BC4(EnBomBowlMan* this, PlayState* play) { } } - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_2D0); - } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D0)) { - ActorCutscene_SetIntentToPlay(this->unk_2D0); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csId1); + } else if (!CutsceneManager_IsNext(this->csId1)) { + CutsceneManager_Queue(this->csId1); } func_809C493C(this, 3, 1.0f); @@ -214,18 +214,18 @@ void func_809C4DA4(EnBomBowlMan* this, PlayState* play) { if (this->unk_2B8 == 0) { Player* player = GET_PLAYER(play); - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_2D0); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csId1); return; } - if (!ActorCutscene_GetCanPlayNext(this->unk_2D0)) { - ActorCutscene_SetIntentToPlay(this->unk_2D0); + if (!CutsceneManager_IsNext(this->csId1)) { + CutsceneManager_Queue(this->csId1); return; } - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D0, &this->actor); + CutsceneManager_StartWithPlayerCs(this->csId1, &this->actor); this->unk_2B8 = 1; this->unk_2C0 = 0; this->unk_2D4 = this->actor.yawTowardsPlayer; @@ -242,13 +242,13 @@ void func_809C4DA4(EnBomBowlMan* this, PlayState* play) { s32 pad; s32 sp28 = false; - func_801477B4(play); + Message_CloseTextbox(play); switch (this->unk_2C0) { case 0: this->unk_2C0 = 1; D_809C6104 = 1; - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(this->unk_2D0)), + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(this->csId1)), &this->unk_2D8[0]->actor); this->unk_2D4 = 0; this->unk_2BC = 10; @@ -268,7 +268,7 @@ void func_809C4DA4(EnBomBowlMan* this, PlayState* play) { case 2: if (player->transformation == PLAYER_FORM_HUMAN) { this->unk_2B8 = 2; - ActorCutscene_Stop(this->unk_2D0); + CutsceneManager_Stop(this->csId1); func_809C59A4(this, play); sp28 = true; } else { @@ -276,13 +276,13 @@ void func_809C4DA4(EnBomBowlMan* this, PlayState* play) { play->msgCtx.msgLength = 0; func_809C493C(this, 1, 1.0f); D_809C6100 = 1; - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_2D2); - } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D2)) { - ActorCutscene_SetIntentToPlay(this->unk_2D2); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csId2); + } else if (!CutsceneManager_IsNext(this->csId2)) { + CutsceneManager_Queue(this->csId2); } - ActorCutscene_Stop(this->unk_2D0); + CutsceneManager_Stop(this->csId1); this->actionFunc = func_809C5B1C; sp28 = true; } @@ -299,7 +299,7 @@ void func_809C4DA4(EnBomBowlMan* this, PlayState* play) { case 4: if (this->unk_2B8 != 2) { - ActorCutscene_Stop(this->unk_2D0); + CutsceneManager_Stop(this->csId1); } play->msgCtx.msgLength = 0; func_809C493C(this, 1, 1.0f); @@ -319,9 +319,9 @@ void func_809C4DA4(EnBomBowlMan* this, PlayState* play) { if (!sp28) { if (player->transformation == PLAYER_FORM_HUMAN) { - func_80151938(play, D_809C618C[this->unk_2C0]); + Message_ContinueTextbox(play, D_809C618C[this->unk_2C0]); } else { - func_80151938(play, D_809C6198[this->unk_2C0]); + Message_ContinueTextbox(play, D_809C6198[this->unk_2C0]); } } } @@ -336,7 +336,7 @@ void func_809C51B4(EnBomBowlMan* this, PlayState* play) { gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_86; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; CLEAR_WEEKEVENTREG(WEEKEVENTREG_75_40); if (player->transformation == PLAYER_FORM_HUMAN) { SET_WEEKEVENTREG(WEEKEVENTREG_84_80); @@ -351,7 +351,7 @@ void func_809C51B4(EnBomBowlMan* this, PlayState* play) { void func_809C52B4(EnBomBowlMan* this) { this->actor.draw = NULL; this->actor.flags |= ACTOR_FLAG_10; - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~ACTOR_FLAG_1; this->actor.world.pos.x = 1340.0f; this->actor.world.pos.z = -1795.0f; @@ -365,7 +365,7 @@ void func_809C5310(EnBomBowlMan* this, PlayState* play) { if (player->actor.world.pos.x < 1510.0f) { if (player->transformation != PLAYER_FORM_DEKU) { if (this->actor.xzDistToPlayer < this->unk_2C8) { - func_800B7298(play, &this->actor, PLAYER_CSMODE_7); + func_800B7298(play, &this->actor, PLAYER_CSMODE_WAIT); func_809C53A4(this); } } else { @@ -411,7 +411,7 @@ void func_809C5524(EnBomBowlMan* this, PlayState* play) { void func_809C5598(EnBomBowlMan* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); if ((this->actor.textId == 0x72F) || (this->actor.textId == 0x730)) { this->actor.textId = 0x731; } else if (this->actor.textId == 0x731) { @@ -423,7 +423,7 @@ void func_809C5598(EnBomBowlMan* this, PlayState* play) { } else if (this->actor.textId == 0x734) { this->actor.textId = 0x715; } else if (this->actor.textId == 0x715) { - func_800B7298(play, &this->actor, PLAYER_CSMODE_6); + func_800B7298(play, &this->actor, PLAYER_CSMODE_END); func_809C493C(this, 17, 1.0f); func_809C59A4(this, play); return; @@ -435,11 +435,11 @@ void func_809C5598(EnBomBowlMan* this, PlayState* play) { func_80151BB4(play, 0x24); func_80151BB4(play, 0x25); func_80151BB4(play, 0); - func_800B7298(play, &this->actor, PLAYER_CSMODE_7); + func_800B7298(play, &this->actor, PLAYER_CSMODE_WAIT); this->actionFunc = func_809C5738; return; } - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); } } @@ -452,25 +452,25 @@ void func_809C5738(EnBomBowlMan* this, PlayState* play) { ((play->msgCtx.msgMode == 0) || (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE))) { this->unk_2C2 = 1; func_809C4B6C(this); - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_2D6); - } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { - ActorCutscene_SetIntentToPlay(this->unk_2D6); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csId3); + } else if (!CutsceneManager_IsNext(this->csId3)) { + CutsceneManager_Queue(this->csId3); } else { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->actor); + CutsceneManager_StartWithPlayerCs(this->csId3, &this->actor); this->unk_2C2 = 2; func_809C493C(this, 18, 1.0f); } } } else if (this->unk_2C2 == 1) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_2D6); - } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { - ActorCutscene_SetIntentToPlay(this->unk_2D6); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csId3); + } else if (!CutsceneManager_IsNext(this->csId3)) { + CutsceneManager_Queue(this->csId3); } else { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->actor); + CutsceneManager_StartWithPlayerCs(this->csId3, &this->actor); this->unk_2C2 = 2; func_809C493C(this, 18, 1.0f); } @@ -485,7 +485,7 @@ void func_809C5738(EnBomBowlMan* this, PlayState* play) { if (this->unk_298 >= this->path->count) { SET_WEEKEVENTREG(WEEKEVENTREG_84_80); CLEAR_WEEKEVENTREG(WEEKEVENTREG_83_04); - ActorCutscene_Stop(this->unk_2D6); + CutsceneManager_Stop(this->csId3); Actor_Kill(&this->actor); return; } @@ -496,7 +496,7 @@ void func_809C5738(EnBomBowlMan* this, PlayState* play) { } void func_809C59A4(EnBomBowlMan* this, PlayState* play) { - Actor_PickUp(&this->actor, play, GI_BOMBERS_NOTEBOOK, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_BOMBERS_NOTEBOOK, 300.0f, 300.0f); this->unk_29C = 1; this->actionFunc = func_809C59F0; } @@ -513,7 +513,7 @@ void func_809C59F0(EnBomBowlMan* this, PlayState* play) { func_800B8500(&this->actor, play, 400.0f, 400.0f, PLAYER_IA_MINUS1); this->actionFunc = func_809C5AA4; } else { - Actor_PickUp(&this->actor, play, GI_BOMBERS_NOTEBOOK, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_BOMBERS_NOTEBOOK, 300.0f, 300.0f); } } @@ -530,13 +530,13 @@ void func_809C5AA4(EnBomBowlMan* this, PlayState* play) { } void func_809C5B1C(EnBomBowlMan* this, PlayState* play) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_2D2); - } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D2)) { - ActorCutscene_SetIntentToPlay(this->unk_2D2); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csId2); + } else if (!CutsceneManager_IsNext(this->csId2)) { + CutsceneManager_Queue(this->csId2); } else { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D2, &this->actor); + CutsceneManager_StartWithPlayerCs(this->csId2, &this->actor); func_809C5BA0(this); } } @@ -574,12 +574,12 @@ void func_809C5BF4(EnBomBowlMan* this, PlayState* play) { } if (this->unk_2F4 == 0) { - subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(this->unk_2D2)); + subCam = Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(this->csId2)); if (D_809C6100 > 5) { Player* player = GET_PLAYER(play); - func_801477B4(play); + Message_CloseTextbox(play); Camera_SetTargetActor(subCam, &this->unk_2D8[0]->actor); func_809C493C(this, 13, 1.0f); D_809C6100 = 0; @@ -630,7 +630,9 @@ void EnBomBowlMan_Update(Actor* thisx, PlayState* play) { this->unk_2F2 = (s32)Rand_ZeroFloat(60.0f) + 20; } } - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } s32 EnBomBowlMan_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h index fc911dd04..e958b84a1 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h @@ -17,44 +17,44 @@ typedef void (*EnBomBowlManActionFunc)(struct EnBomBowlMan*, PlayState*); #define ENBOMBOWLMAN_FF00_MINUS1 -1 typedef struct EnBomBowlMan { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[21]; - /* 0x0206 */ Vec3s morphTable[21]; - /* 0x0284 */ EnBomBowlManActionFunc actionFunc; - /* 0x0288 */ s16 unk_288; - /* 0x028A */ s16 unk_28A; - /* 0x028C */ UNK_TYPE1 unk28C[2]; - /* 0x028E */ s16 unk_28E; - /* 0x0290 */ s16 unk_290; - /* 0x0292 */ UNK_TYPE1 unk292[2]; - /* 0x0294 */ Path* path; - /* 0x0298 */ s16 unk_298; - /* 0x029A */ s16 unk_29A; - /* 0x029C */ s16 unk_29C; - /* 0x029E */ s16 unk_29E; - /* 0x02A0 */ Vec3f unk_2A0; - /* 0x02AC */ UNK_TYPE1 unk2AC[0xC]; - /* 0x02B8 */ s16 unk_2B8; - /* 0x02BA */ s16 unk_2BA; - /* 0x02BC */ s16 unk_2BC; - /* 0x02BE */ UNK_TYPE1 unk2BE[2]; - /* 0x02C0 */ s16 unk_2C0; - /* 0x02C2 */ s16 unk_2C2; - /* 0x02C4 */ f32 unk_2C4; - /* 0x02C8 */ f32 unk_2C8; - /* 0x02CC */ s16 unk_2CC[2]; - /* 0x02D0 */ s16 unk_2D0; - /* 0x02D2 */ s16 unk_2D2; - /* 0x02D4 */ s16 unk_2D4; - /* 0x02D6 */ s16 unk_2D6; - /* 0x02D8 */ struct EnBomBowlMan* unk_2D8[5]; - /* 0x02EC */ UNK_TYPE1 unk2EC[0x4]; - /* 0x02F0 */ s16 unk_2F0; - /* 0x02F2 */ s16 unk_2F2; - /* 0x02F4 */ s16 unk_2F4; - /* 0x02F6 */ s16 unk_2F6; - /* 0x02F8 */ s32 unk_2F8; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[21]; + /* 0x206 */ Vec3s morphTable[21]; + /* 0x284 */ EnBomBowlManActionFunc 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 */ Path* path; + /* 0x298 */ s16 unk_298; + /* 0x29A */ s16 unk_29A; + /* 0x29C */ s16 unk_29C; + /* 0x29E */ s16 unk_29E; + /* 0x2A0 */ Vec3f unk_2A0; + /* 0x2AC */ UNK_TYPE1 unk2AC[0xC]; + /* 0x2B8 */ s16 unk_2B8; + /* 0x2BA */ s16 unk_2BA; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ UNK_TYPE1 unk2BE[2]; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C2 */ s16 unk_2C2; + /* 0x2C4 */ f32 unk_2C4; + /* 0x2C8 */ f32 unk_2C8; + /* 0x2CC */ s16 csIdList[2]; + /* 0x2D0 */ s16 csId1; + /* 0x2D2 */ s16 csId2; + /* 0x2D4 */ s16 unk_2D4; + /* 0x2D6 */ s16 csId3; + /* 0x2D8 */ struct EnBomBowlMan* unk_2D8[5]; + /* 0x2EC */ UNK_TYPE1 unk2EC[0x4]; + /* 0x2F0 */ s16 unk_2F0; + /* 0x2F2 */ s16 unk_2F2; + /* 0x2F4 */ s16 unk_2F4; + /* 0x2F6 */ s16 unk_2F6; + /* 0x2F8 */ s32 unk_2F8; } EnBomBowlMan; // size = 0x2FC #endif // Z_EN_BOM_BOWL_MAN_H diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index cbcc40211..a2246b442 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -177,14 +177,14 @@ void EnBomChu_WaitForRelease(EnBomChu* this, PlayState* play) { } else if (Actor_HasNoParent(&this->actor, play)) { player = GET_PLAYER(play); Math_Vec3f_Copy(&this->actor.world.pos, &player->actor.world.pos); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); this->actor.shape.rot.y = player->actor.shape.rot.y; this->actor.flags |= ACTOR_FLAG_1; func_800B8EF4(play, &this->actor); this->isMoving = true; - this->actor.speedXZ = 8.0f; + this->actor.speed = 8.0f; this->movingSpeed = 8.0f; EnBomChu_SetupMove(this); } @@ -193,7 +193,7 @@ void EnBomChu_WaitForRelease(EnBomChu* this, PlayState* play) { s32 EnBomChu_IsOnCollisionPoly(PlayState* play, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** poly, s32* bgId) { if ((BgCheck_EntityLineTest1(&play->colCtx, posA, posB, posResult, poly, true, true, true, true, bgId)) && - (!(func_800C9A4C(&play->colCtx, *poly, *bgId) & 0x30))) { + !(SurfaceType_GetWallFlags(&play->colCtx, *poly, *bgId) & (WALL_FLAG_4 | WALL_FLAG_5))) { return true; } @@ -233,7 +233,7 @@ void EnBomChu_Move(EnBomChu* this, PlayState* play) { bgIdUpDown = bgIdSide = BGCHECK_SCENE; isFloorPolyValid = false; - this->actor.speedXZ = this->movingSpeed; + this->actor.speed = this->movingSpeed; lineLength = 2.0f * this->movingSpeed; if ((this->timer == 0) || (this->collider.base.acFlags & AC_HIT) || (this->collider.base.ocFlags1 & OC1_HIT)) { @@ -259,7 +259,7 @@ void EnBomChu_Move(EnBomChu* this, PlayState* play) { isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polySide, play); Math_Vec3f_Copy(&this->actor.world.pos, &posSide); this->actor.floorBgId = bgIdSide; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { if (this->actor.floorPoly != polyUpDown) { isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polyUpDown, play); @@ -269,7 +269,7 @@ void EnBomChu_Move(EnBomChu* this, PlayState* play) { this->actor.floorBgId = bgIdUpDown; } } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; lineLength *= 3.0f; Math_Vec3f_Copy(&posA, &posB); @@ -316,8 +316,8 @@ void EnBomChu_Move(EnBomChu* this, PlayState* play) { func_800B8F98(&this->actor, NA_SE_IT_BOMBCHU_MOVE - SFX_FLAG); } - if (this->actor.speedXZ != 0.0f) { - this->movingSpeed = this->actor.speedXZ; + if (this->actor.speed != 0.0f) { + this->movingSpeed = this->actor.speed; } } @@ -336,7 +336,7 @@ void EnBomChu_Explode(EnBomChu* this, PlayState* play) { } this->timer = 1; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->actor.depthInWater > 0.0f) { for (i = 0; i < 40; i++) { @@ -408,7 +408,7 @@ void EnBomChu_HandleNonSceneCollision(EnBomChu* this, PlayState* play) { Math_Vec3f_Copy(&originalWorldPos, &this->actor.world.pos); Math_Vec3f_Copy(&originalAxisUp, &this->axisUp); yaw = this->actor.shape.rot.y; - BgCheck2_UpdateActorAttachedToMesh(&play->colCtx, this->actor.floorBgId, &this->actor); + DynaPolyActor_TransformCarriedActor(&play->colCtx, this->actor.floorBgId, &this->actor); if (yaw != this->actor.shape.rot.y) { yaw = this->actor.shape.rot.y - yaw; @@ -441,7 +441,7 @@ void EnBomChu_HandleNonSceneCollision(EnBomChu* this, PlayState* play) { isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, poly, play); Math_Vec3f_Copy(&this->actor.world.pos, &originalWorldPos); this->actor.floorBgId = bgId; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (isFloorPolyValid) { EnBomChu_UpdateRotation(this); @@ -512,23 +512,23 @@ void EnBomChu_Update(Actor* thisx, PlayState* play) { this->actor.depthInWater = waterY - this->actor.world.pos.y; if (this->actor.depthInWater < 0.0f) { - if (this->actor.bgCheckFlags & 0x20) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { EnBomChu_SpawnRipplesAndSplashes(this, play, waterY, true); } - this->actor.bgCheckFlags &= ~0x20; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER; return; } - if (!(this->actor.bgCheckFlags & 0x20) && (this->timer != 120)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER) && (this->timer != 120)) { EnBomChu_SpawnRipplesAndSplashes(this, play, waterY, true); } else { EffectSsBubble_Spawn(play, &this->actor.world.pos, 0.0f, 3.0f, 15.0f, 0.25f); } - this->actor.bgCheckFlags |= 0x20; + this->actor.bgCheckFlags |= BGCHECKFLAG_WATER; } else { - this->actor.bgCheckFlags &= ~0x20; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER; this->actor.depthInWater = BGCHECK_Y_MIN; } } diff --git a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c index bcb7cb534..b67ca6820 100644 --- a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c +++ b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c @@ -66,7 +66,7 @@ void EnBombal_Init(Actor* thisx, PlayState* play) { this->actor.targetMode = 6; this->actor.colChkInfo.health = 1; this->scale = 0.1f; - this->cutscene = this->actor.cutscene; + this->csId = this->actor.csId; func_80C05B24(this); } @@ -109,16 +109,16 @@ void func_80C05C44(EnBombal* this, PlayState* play) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_75_40) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_73_10) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_85_02)) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->cutscene); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csId); return; } - if (!ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_SetIntentToPlay(this->cutscene); + if (!CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Queue(this->csId); } else { - ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); phi_s0 = true; } } else { @@ -136,7 +136,7 @@ void func_80C05C44(EnBombal* this, PlayState* play) { } SET_WEEKEVENTREG(WEEKEVENTREG_83_04); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MUJURA_BALLOON_BROKEN); + Actor_PlaySfx(&this->actor, NA_SE_EV_MUJURA_BALLOON_BROKEN); this->timer = 30; this->isPopped = true; this->actionFunc = func_80C05DE8; @@ -147,7 +147,7 @@ void func_80C05DE8(EnBombal* this, PlayState* play) { if (this->timer == 0) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_75_40) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_73_10) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_85_02)) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); } Actor_Kill(&this->actor); return; @@ -269,7 +269,7 @@ void EnBombal_DrawEffects(EnBombal* this, PlayState* play) { gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, sPtr->alpha); Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZF(DEGF_TO_RADF(play->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_RotateZF(DEG_TO_RAD(play->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gSunSparkleModelDL); 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 7c72f3eea..67550c59b 100644 --- a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h +++ b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h @@ -23,7 +23,7 @@ typedef struct EnBombal { /* 0x144 */ EnBombalActionFunc actionFunc; /* 0x148 */ s16 timer; /* 0x14A */ s16 isPopped; - /* 0x14C */ s16 cutscene; + /* 0x14C */ s16 csId; /* 0x150 */ f32 scale; /* 0x154 */ f32 oscillationAngle; /* 0x158 */ ColliderCylinder collider; diff --git a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c index 2ca62ef0a..64f900f32 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -124,11 +124,11 @@ void EnBombers_Init(Actor* thisx, PlayState* play) { this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, 0); if (bomBowlMan != NULL) { - s32 cs = this->actor.cutscene; + s32 csId = this->actor.csId; s32 i = 0; // clang-format off - while (cs != -1) { bomBowlMan->unk_2CC[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; } + while (csId != CS_ID_NONE) { bomBowlMan->csIdList[i] = csId; csId = CutsceneManager_GetAdditionalCsId(csId); i++; } // clang-format on CLEAR_WEEKEVENTREG(WEEKEVENTREG_76_01); @@ -165,13 +165,13 @@ void func_80C038B4(EnBombers* this) { if ((this->unk_2C4 == 2) && (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); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_WALK); } if ((this->unk_2C4 == 15) && (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); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_WALK); } } @@ -338,7 +338,7 @@ void func_80C03FAC(EnBombers* this, PlayState* play) { if ((this->unk_2A6 == Message_GetState(&play->msgCtx)) && Message_ShouldAdvance(play)) { sp2A = 0; - func_801477B4(play); + Message_CloseTextbox(play); this->unk_2A6 = TEXT_STATE_5; if ((this->actor.textId == 0x73D) || (this->actor.textId == 0x73E) || (this->actor.textId == 0x73F)) { @@ -420,7 +420,7 @@ void func_80C03FAC(EnBombers* this, PlayState* play) { break; case 1: - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); break; } } @@ -449,7 +449,7 @@ void func_80C04354(EnBombers* this, PlayState* play) { void func_80C043C8(EnBombers* this, PlayState* play) { Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); func_80C042F8(this); } } @@ -487,7 +487,9 @@ void EnBombers_Update(Actor* thisx, PlayState* play) { } } - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); this->actor.uncullZoneForward = 500.0f; Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c index 74575628f..b47a9630f 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c @@ -101,8 +101,8 @@ void EnBombers2_Init(Actor* thisx, PlayState* play) { this->unk_2AC = 1; this->actor.world.pos.z += cos; } - this->cutscene = this->actor.cutscene; - if (this->cutscene == 0) { + this->csId = this->actor.csId; + if (this->csId == 0) { Actor_Kill(&this->actor); } func_80C04B40(this); @@ -220,7 +220,8 @@ void func_80C04D8C(EnBombers2* this, PlayState* play) { s32 correctDigits; for (i = 0; i < ARRAY_COUNT(this->correctDigitSlots); i++) { - if (!(this->correctDigitSlots[i]) && (play->msgCtx.unk12054[i] == gSaveContext.save.bomberCode[i])) { + if (!(this->correctDigitSlots[i]) && + (play->msgCtx.unk12054[i] == gSaveContext.save.saveInfo.bomberCode[i])) { this->correctDigitSlots[i] = true; } } @@ -233,15 +234,15 @@ void func_80C04D8C(EnBombers2* this, PlayState* play) { if (correctDigits >= 5) { this->textIdIndex = 6; this->actor.textId = sTextIds[this->textIdIndex]; - func_80151938(play, this->actor.textId); - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); + Message_ContinueTextbox(play, this->actor.textId); + Actor_PlaySfx(&this->actor, NA_SE_SY_PIECE_OF_HEART); this->talkState = TEXT_STATE_5; return; } } if (Text_GetFaceReaction(play, 0x15) != 0) { this->unk_28E = 0; - func_801477B4(play); + Message_CloseTextbox(play); func_80C04B40(this); } else { s32 j; @@ -252,13 +253,13 @@ void func_80C04D8C(EnBombers2* this, PlayState* play) { case 5: case 7: this->unk_28E = 0; - func_801477B4(play); + Message_CloseTextbox(play); func_80C04B40(this); break; case 2: this->textIdIndex = 3; this->actor.textId = sTextIds[this->textIdIndex]; - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); this->talkState = TEXT_STATE_15; break; case 3: @@ -266,15 +267,15 @@ void func_80C04D8C(EnBombers2* this, PlayState* play) { this->correctDigitSlots[j] = false; } this->textIdIndex = 4; - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + Actor_PlaySfx(&this->actor, NA_SE_SY_ERROR); this->actor.textId = sTextIds[this->textIdIndex]; - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); this->talkState = TEXT_STATE_5; break; case 4: this->textIdIndex = 5; this->actor.textId = sTextIds[this->textIdIndex]; - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); this->talkState = TEXT_STATE_5; break; case 6: @@ -308,13 +309,13 @@ void func_80C050B8(EnBombers2* this, PlayState* play) { void func_80C0520C(EnBombers2* this, PlayState* play) { if (this->unk_2A8 == 0) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->cutscene); - } else if (ActorCutscene_GetCanPlayNext(this->cutscene) == 0) { - ActorCutscene_SetIntentToPlay(this->cutscene); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csId); + } else if (!CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Queue(this->csId); } else { - ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); this->unk_2A8 = 1; } } else { @@ -322,16 +323,16 @@ void func_80C0520C(EnBombers2* this, PlayState* play) { if ((fabsf(this->unk_29C.x - this->actor.world.pos.x) < 3.0f) && (fabsf(this->unk_29C.z - this->actor.world.pos.z) < 3.0f)) { this->unk_2B6 = this->actor.yawTowardsPlayer; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (fabsf(this->actor.world.rot.y - this->actor.yawTowardsPlayer) < 100.0f) { - func_801477B4(play); + Message_CloseTextbox(play); this->talkState = TEXT_STATE_5; this->textIdIndex = 7; EnBombers2_ChangeAnim(this, 6, 1.0f); this->unk_2A8 = 0; this->unk_2C0 = 1; SET_WEEKEVENTREG(WEEKEVENTREG_73_80); - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->unk_2AC = 1; this->actor.textId = sTextIds[this->textIdIndex]; Message_StartTextbox(play, this->actor.textId, &this->actor); @@ -357,7 +358,7 @@ void EnBombers2_Update(Actor* thisx, PlayState* play) { if ((this->animIndex == 2) && (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); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_WALK); } this->actor.shape.rot.y = this->actor.world.rot.y; if (this->unk_2C0 != 2) { @@ -400,7 +401,9 @@ void EnBombers2_Update(Actor* thisx, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->unk_2AC == 0) { - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } Math_Vec3f_Copy(&this->actor.world.pos, &sp34); } diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h index 4a79e6615..9e6f6b577 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h @@ -27,7 +27,7 @@ typedef struct EnBombers2 { /* 0x2A8 */ s32 unk_2A8; /* 0x2AC */ u8 unk_2AC; /* 0x2AE */ s16 animIndex; - /* 0x2B0 */ s16 cutscene; + /* 0x2B0 */ s16 csId; /* 0x2B2 */ s16 unk_2B2; /* 0x2B4 */ s16 unk_2B4; /* 0x2B6 */ s16 unk_2B6; diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index 0b5ffff54..2493d819b 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -156,7 +156,7 @@ void func_808AEAE0(EnBombf* this, PlayState* play) { func_800B8C20(&this->actor, &bombf->actor, play); this->timer = 180; this->unk_204 = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PULL_UP_ROCK); + Actor_PlaySfx(&this->actor, NA_SE_PL_PULL_UP_ROCK); this->actor.flags &= ~ACTOR_FLAG_1; } else { player->actor.child = NULL; @@ -168,7 +168,7 @@ void func_808AEAE0(EnBombf* this, PlayState* play) { } else if ((this->colliderCylinder.base.acFlags & AC_HIT) && ((this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0x13828) || ((this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0x200) && - (player->transformation == PLAYER_FORM_GORON) && (player->actor.speedXZ > 15.0f)))) { + (player->transformation == PLAYER_FORM_GORON) && (player->actor.speed > 15.0f)))) { this->colliderCylinder.base.acFlags &= ~AC_HIT; if (this->colliderCylinder.base.ac->category != ACTORCAT_BOSS) { bombf = (EnBombf*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOMBF, this->actor.world.pos.x, @@ -193,7 +193,7 @@ void func_808AEAE0(EnBombf* this, PlayState* play) { } } else { if (!Actor_HasParent(&this->actor, play)) { - Actor_LiftActor(&this->actor, play); + Actor_OfferCarry(&this->actor, play); return; } player->actor.child = NULL; @@ -232,27 +232,27 @@ void func_808AEE3C(EnBombf* this, PlayState* play) { } this->unk_204 = 1.0f; - if (!(this->actor.bgCheckFlags & 1)) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.025f, 0.0f); + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + Math_SmoothStepToF(&this->actor.speed, 0.0f, 1.0f, 0.025f, 0.0f); return; } - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 1.5f, 0.0f); - if (this->actor.bgCheckFlags & 2) { + Math_SmoothStepToF(&this->actor.speed, 0.0f, 1.0f, 1.5f, 0.0f); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { func_800B8EF4(play, &this->actor); if (this->actor.velocity.y < -6.0f) { this->actor.velocity.y *= -0.3f; - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; } } else if (this->timer >= 4) { - Actor_LiftActor(&this->actor, play); + Actor_OfferCarry(&this->actor, play); } } void func_808AEF68(EnBombf* this, PlayState* play) { if (Actor_HasNoParent(&this->actor, play)) { EnBombf_SetupAction(this, func_808AEE3C); - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; func_808AEE3C(this, play); } else { this->actor.velocity.y = 0.0f; @@ -336,29 +336,33 @@ void EnBombf_Update(Actor* thisx, PlayState* play) { if (this->actor.gravity != 0.0f) { DREG(6) = 1; - Actor_UpdateBgCheckInfo(play, &this->actor, 5.0f, 10.0f, 0.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 5.0f, 10.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); DREG(6) = 0; } if (ENBOMBF_GET(&this->actor) == ENBOMBF_0) { - if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & 0x10)) { + if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_CEILING)) { this->actor.velocity.y = -this->actor.velocity.y; } - if ((this->actor.speedXZ != 0.0f) && (this->actor.bgCheckFlags & 8)) { + if ((this->actor.speed != 0.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_WALL)) { s16 yDiff = BINANG_SUB(this->actor.wallYaw, this->actor.world.rot.y); if (ABS_ALT(yDiff) > 0x4000) { this->actor.world.rot.y = BINANG_SUB(this->actor.wallYaw - this->actor.world.rot.y + this->actor.wallYaw, 0x8000); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMB_BOUND); Actor_MoveWithGravity(&this->actor); DREG(6) = 1; - Actor_UpdateBgCheckInfo(play, &this->actor, 5.0f, 10.0f, 0.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 5.0f, 10.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); DREG(6) = 0; - this->actor.speedXZ *= 0.7f; - this->actor.bgCheckFlags &= ~8; + this->actor.speed *= 0.7f; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WALL; } if ((this->colliderCylinder.base.acFlags & AC_HIT) || @@ -378,7 +382,7 @@ void EnBombf_Update(Actor* thisx, PlayState* play) { if ((play->gameplayFrames % 2) == 0) { EffectSsGSpk_SpawnFuse(play, &this->actor, &sp68, &sp8C, &sp74); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_IGNIT - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_IT_BOMB_IGNIT - SFX_FLAG); sp68.y += 3.0f; func_800B0DE0(play, &sp68, &sp8C, &sp5C, &sp58, &sp58, 0x32, 5); } @@ -407,7 +411,7 @@ void EnBombf_Update(Actor* thisx, PlayState* play) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, sp68.x, sp68.y, sp68.z, 0, 0, 0, CLEAR_TAG_SMALL_EXPLOSION); - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfx(&this->actor, NA_SE_IT_BOMB_EXPLOSION); play->envCtx.lightSettings.diffuseColor1[0] = play->envCtx.lightSettings.diffuseColor1[1] = play->envCtx.lightSettings.diffuseColor1[2] = 250; @@ -443,9 +447,9 @@ void EnBombf_Update(Actor* thisx, PlayState* play) { return; } - if (this->actor.bgCheckFlags & 0x40) { - this->actor.bgCheckFlags &= ~0x40; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER_TOUCH; + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMB_DROP_WATER); } } } 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 126c293c3..aad6d9bc3 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -119,7 +119,7 @@ s16 D_80C00AF8[] = { void EnBomjima_Init(Actor* thisx, PlayState* play) { EnBomjima* this = THIS; - s32 cs; + s32 csId; s32 i; this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -135,12 +135,12 @@ void EnBomjima_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); if (this->unk_2E6 == 0) { - cs = this->actor.cutscene; + csId = this->actor.csId; i = 0; - while (cs != -1) { + while (csId != CS_ID_NONE) { // clang-format off - this->cutscenes[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); + this->csIdList[i] = csId; csId = CutsceneManager_GetAdditionalCsId(csId); // clang-format on i++; } @@ -219,21 +219,21 @@ void func_80BFE524(EnBomjima* this) { if ((this->animIndex == 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); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_WALK); } if ((this->animIndex == 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); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_WALK); } if ((this->animIndex == 15) && Animation_OnFrame(&this->skelAnime, 15.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_LAND); } if ((this->animIndex == 6) && Animation_OnFrame(&this->skelAnime, 8.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_LAND); } } @@ -340,8 +340,8 @@ void func_80BFEA94(EnBomjima* this, PlayState* play) { this->bombal = (EnBombal*)actor; Math_Vec3f_Copy(&this->unk_2B0, &actor->world.pos); - if (this->bombalCutscene == 0) { - this->bombalCutscene = this->bombal->actor.cutscene; + if (this->bombalCsId == 0) { + this->bombalCsId = this->bombal->actor.csId; } func_80BFEB1C(this); break; @@ -389,7 +389,7 @@ void func_80BFEB64(EnBomjima* this, PlayState* play) { return; } - if (ActorCutscene_GetCurrentIndex() == -1) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_NONE) { func_800B8614(&this->actor, play, 70.0f); } @@ -409,7 +409,7 @@ void func_80BFEB64(EnBomjima* this, PlayState* play) { this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->bombal->actor.world.pos); if (Animation_OnFrame(&this->skelAnime, 19.0f)) { this->unk_2C0 = 5; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_SHOT_BREATH); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_SHOT_BREATH); } if (this->unk_2C0 == 1) { @@ -465,17 +465,17 @@ void func_80BFEFF0(EnBomjima* this) { void func_80BFF03C(EnBomjima* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->cutscenes[0]); - } else if (!ActorCutscene_GetCanPlayNext(this->cutscenes[0])) { - ActorCutscene_SetIntentToPlay(this->cutscenes[0]); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csIdList[0]); + } else if (!CutsceneManager_IsNext(this->csIdList[0])) { + CutsceneManager_Queue(this->csIdList[0]); } else { player->stateFlags1 &= ~PLAYER_STATE1_20; CLEAR_WEEKEVENTREG(WEEKEVENTREG_83_04); this->actor.world.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)); this->unk_2DC = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)); - ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[0], &this->actor); + CutsceneManager_StartWithPlayerCs(this->csIdList[0], &this->actor); func_80BFF120(this); } } @@ -494,7 +494,7 @@ void func_80BFF174(EnBomjima* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->cutsceneTimer == 1) { - ActorCutscene_Stop(this->cutscenes[0]); + CutsceneManager_Stop(this->csIdList[0]); this->cutsceneEnded = true; } @@ -576,11 +576,11 @@ void func_80BFF430(EnBomjima* this, PlayState* play) { if (bombal != NULL) { bombal->scale = 0.0f; - bombal->cutscene = this->bombalCutscene; + bombal->csId = this->bombalCsId; Actor_ChangeFocus(&this->actor, play, &bombal->actor); CLEAR_WEEKEVENTREG(WEEKEVENTREG_83_04); func_80BFE65C(this); - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BFEA94; } } @@ -594,7 +594,7 @@ void func_80BFF4F4(EnBomjima* this) { void func_80BFF52C(EnBomjima* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); if (play->msgCtx.choiceIndex == 0) { Player* player = GET_PLAYER(play); @@ -608,7 +608,7 @@ void func_80BFF52C(EnBomjima* this, PlayState* play) { } else { this->actor.textId = D_80C00A70[this->unk_2C8]; } - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); play_sound(NA_SE_SY_FOUND); func_80BFE494(this, 15, 1.0f); this->action = EN_BOMJIMA_ACTION_5; @@ -626,7 +626,7 @@ void func_80BFF52C(EnBomjima* this, PlayState* play) { this->actor.textId = D_80C00A70[this->unk_2C8]; this->unk_2EA = 1; } - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); func_80C00234(this); } } @@ -637,7 +637,7 @@ void func_80BFF6CC(EnBomjima* this, PlayState* play) { if (this->animLastFrame <= curFrame) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); func_80BFE494(this, 1, 1.0f); this->actionFunc = func_80BFF754; } @@ -653,14 +653,14 @@ void func_80BFF754(EnBomjima* this, PlayState* play) { f32 y; f32 z; - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->cutscenes[1]); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csIdList[1]); return; } - if (!ActorCutscene_GetCanPlayNext(this->cutscenes[1])) { - ActorCutscene_SetIntentToPlay(this->cutscenes[1]); + if (!CutsceneManager_IsNext(this->csIdList[1])) { + CutsceneManager_Queue(this->csIdList[1]); return; } @@ -690,7 +690,7 @@ void func_80BFF754(EnBomjima* this, PlayState* play) { } D_80C009F0 = 0; - ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[1], &this->actor); + CutsceneManager_StartWithPlayerCs(this->csIdList[1], &this->actor); this->actionFunc = func_80BFF9B0; } @@ -720,12 +720,12 @@ void func_80BFF9B0(EnBomjima* this, PlayState* play) { CLEAR_WEEKEVENTREG(WEEKEVENTREG_76_08); CLEAR_WEEKEVENTREG(WEEKEVENTREG_76_10); - gSaveContext.save.bombersCaughtNum = 0; - gSaveContext.save.bombersCaughtOrder[0] = 0; - gSaveContext.save.bombersCaughtOrder[1] = 0; - gSaveContext.save.bombersCaughtOrder[2] = 0; - gSaveContext.save.bombersCaughtOrder[3] = 0; - gSaveContext.save.bombersCaughtOrder[4] = 0; + gSaveContext.save.saveInfo.bombersCaughtNum = 0; + gSaveContext.save.saveInfo.bombersCaughtOrder[0] = 0; + gSaveContext.save.saveInfo.bombersCaughtOrder[1] = 0; + gSaveContext.save.saveInfo.bombersCaughtOrder[2] = 0; + gSaveContext.save.saveInfo.bombersCaughtOrder[3] = 0; + gSaveContext.save.saveInfo.bombersCaughtOrder[4] = 0; func_80BFE494(this, 3, 1.0f); this->unk_2C8 = 9; @@ -735,14 +735,14 @@ void func_80BFF9B0(EnBomjima* this, PlayState* play) { } else { this->actor.textId = D_80C00A70[this->unk_2C8]; } - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); this->actionFunc = func_80BFFB40; } } void func_80BFFB40(EnBomjima* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); func_80BFE494(this, 15, 1.0f); D_80C009F0 = 100; this->unk_2DC = 0; @@ -768,13 +768,13 @@ void func_80BFFBC4(EnBomjima* this, PlayState* play) { Math_SmoothStepToS(&this->unk_290, this->unk_2DC, 1, 5000, 0); if (D_80C009F0 >= 104) { D_80C009F0 = 0; - func_801477B4(play); + Message_CloseTextbox(play); play->nextEntrance = Entrance_CreateFromSpawn(6); gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_86; - gSaveContext.nextTransitionType = TRANS_TYPE_03; - ActorCutscene_Stop(this->cutscenes[1]); + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; + CutsceneManager_Stop(this->csIdList[1]); } } @@ -848,7 +848,7 @@ void func_80BFFF54(EnBomjima* this, PlayState* play) { if (this->animIndex == 8) { if ((D_80C009F4 == 1) && Animation_OnFrame(&this->skelAnime, 7.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EV_HUMAN_BOUND); D_80C009F4 = 2; } @@ -944,13 +944,13 @@ void func_80C00284(EnBomjima* this, PlayState* play) { func_80BFF3F0(this); } else { func_80BFE65C(this); - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BFEA94; } return; } - func_801477B4(play); + Message_CloseTextbox(play); switch (this->unk_2CA) { case 0: @@ -984,7 +984,7 @@ void func_80C00284(EnBomjima* this, PlayState* play) { } this->actor.textId = D_80C00A70[this->unk_2C8]; } - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); if ((this->unk_2C8 == 7) || (this->unk_2C8 == 12)) { func_80BFF4F4(this); } @@ -993,7 +993,7 @@ void func_80C00284(EnBomjima* this, PlayState* play) { case 3: this->unk_2C8++; this->actor.textId = D_80C00A8C[this->unk_2C8]; - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); if (this->unk_2C8 >= 2) { func_80BFE494(this, 17, 1.0f); } @@ -1044,7 +1044,9 @@ void EnBomjima_Update(Actor* thisx, PlayState* play) { } } - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); this->actor.uncullZoneForward = 500.0f; Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); 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 6a434be42..b8196b344 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.h @@ -40,7 +40,7 @@ typedef struct EnBomjima { /* 0x2CA */ s16 unk_2CA; /* 0x2CC */ f32 animLastFrame; /* 0x2D0 */ f32 unk_2D0; - /* 0x2D4 */ s16 cutscenes[2]; + /* 0x2D4 */ s16 csIdList[2]; /* 0x2D8 */ UNK_TYPE1 unk2D8[4]; // maybe a part of the above? /* 0x2DC */ s16 unk_2DC; /* 0x2DE */ s16 cutsceneEnded; @@ -52,7 +52,7 @@ typedef struct EnBomjima { /* 0x2EA */ s16 unk_2EA; /* 0x2EC */ s32 animIndex; /* 0x2F0 */ EnBombal* bombal; - /* 0x2F4 */ s16 bombalCutscene; + /* 0x2F4 */ s16 bombalCsId; /* 0x2F8 */ ColliderCylinder collider; } EnBomjima; // size = 0x344 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 c0033b103..7cc78d9cf 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -185,20 +185,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))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_WALK); } if ((this->unk_2DC == 19) && (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_WALK); } if ((this->unk_2DC == 18) && Animation_OnFrame(&this->skelAnime, 15.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_LAND); } if ((this->unk_2DC == 7) && Animation_OnFrame(&this->skelAnime, 8.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMBERS_LAND); } } @@ -215,7 +215,7 @@ s32 func_80C012FC(EnBomjimb* this, PlayState* play) { if (!Play_InCsMode(play) && (this->actor.xzDistToPlayer < 40.0f) && (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 50.0f) && (play->msgCtx.msgLength == 0)) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; func_80C02740(this, play); return true; } @@ -368,7 +368,7 @@ void func_80C01A24(EnBomjimb* this, PlayState* play) { if ((this->unk_2E4 != NULL) && (this->unk_2E4->update != NULL)) { ((EnNiw*)this->unk_2E4)->unk2BC.z = 90000.0f; } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_2E4 = NULL; this->actor.gravity = -2.0f; func_80C02108(this); @@ -380,10 +380,10 @@ void func_80C01A24(EnBomjimb* this, PlayState* play) { } if (this->unk_2C0 != 0) { - Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.5f, 2.0f); + Math_ApproachF(&this->actor.speed, 6.0f, 0.5f, 2.0f); } - if ((this->unk_2C0 != 0) && !(this->actor.bgCheckFlags & 1)) { + if ((this->unk_2C0 != 0) && !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { func_80C01B40(this); } } @@ -395,13 +395,13 @@ void func_80C01B40(EnBomjimb* this) { } void func_80C01B74(EnBomjimb* this, PlayState* play) { - Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.5f, 2.0f); - if ((this->collider.base.acFlags & AC_HIT) || (this->actor.bgCheckFlags & 1)) { + Math_ApproachF(&this->actor.speed, 6.0f, 0.5f, 2.0f); + if ((this->collider.base.acFlags & AC_HIT) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->collider.base.acFlags &= ~AC_HIT; if ((this->unk_2E4 != NULL) && (this->unk_2E4->update != NULL)) { ((EnNiw*)this->unk_2E4)->unk2BC.z = 90000.0f; } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_2E4 = NULL; this->actor.gravity = -2.0f; func_80C02108(this); @@ -419,7 +419,7 @@ void func_80C01C18(EnBomjimb* this, PlayState* play) { this->unk_294.z = this->unk_2E4->world.pos.z; } } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_2CA = 2; this->actionFunc = func_80C01CD0; } @@ -450,8 +450,8 @@ void func_80C01CD0(EnBomjimb* this, PlayState* play) { this->actor.draw = NULL; } - if ((this->unk_2C0 == 0) && (this->unk_2E4->bgCheckFlags & 1)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PUT_DOWN_WOODBOX); + if ((this->unk_2C0 == 0) && (this->unk_2E4->bgCheckFlags & BGCHECKFLAG_GROUND)) { + Actor_PlaySfx(&this->actor, NA_SE_EV_PUT_DOWN_WOODBOX); this->unk_2C0 = 1; } @@ -553,7 +553,7 @@ void func_80C0217C(EnBomjimb* this, PlayState* play) { return; } - Math_ApproachF(&this->actor.speedXZ, 8.0f, 0.5f, 2.0f); + Math_ApproachF(&this->actor.speed, 8.0f, 0.5f, 2.0f); Math_Vec3f_Copy(&sp74, &this->actor.world.pos); sp74.x += Math_SinS(this->actor.world.rot.y) * 50.0f; @@ -611,7 +611,7 @@ void func_80C0217C(EnBomjimb* this, PlayState* play) { void func_80C0250C(EnBomjimb* this) { func_80C0113C(this, 15, 1.0f); this->unk_2D4 = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_2D6 = BINANG_ROT180(this->actor.yawTowardsPlayer); func_80C012E0(this); this->unk_2CA = 6; @@ -640,7 +640,7 @@ void func_80C02570(EnBomjimb* this, PlayState* play) { void func_80C0267C(EnBomjimb* this) { func_80C012E0(this); func_80C0113C(this, 8, 1.0f); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->unk_2AE = 40; this->unk_2C2 = 0; @@ -686,14 +686,15 @@ void func_80C02740(EnBomjimb* this, PlayState* play) { return; } - Message_StartTextbox(play, D_80C03230[((void)0, gSaveContext.save.bombersCaughtNum)], &this->actor); - gSaveContext.save.bombersCaughtOrder[((void)0, gSaveContext.save.bombersCaughtNum)] = this->unk_2C8 + 1; - gSaveContext.save.bombersCaughtNum++; + Message_StartTextbox(play, D_80C03230[((void)0, gSaveContext.save.saveInfo.bombersCaughtNum)], &this->actor); + gSaveContext.save.saveInfo.bombersCaughtOrder[((void)0, gSaveContext.save.saveInfo.bombersCaughtNum)] = + this->unk_2C8 + 1; + gSaveContext.save.saveInfo.bombersCaughtNum++; - if (gSaveContext.save.bombersCaughtNum > 4) { + if (gSaveContext.save.saveInfo.bombersCaughtNum > 4) { Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); + Actor_PlaySfx(&this->actor, NA_SE_SY_PIECE_OF_HEART); } switch (this->unk_2C8) { @@ -749,7 +750,7 @@ void func_80C02A14(EnBomjimb* this, PlayState* play) { player->actor.freezeTimer = 3; if (this->unk_2E0 == 0) { if (Animation_OnFrame(&this->skelAnime, 7.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EV_HUMAN_BOUND); this->unk_2E0 = 1; } } @@ -760,8 +761,8 @@ void func_80C02A14(EnBomjimb* this, PlayState* play) { } if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); - if ((this->unk_2CA == 8) && (gSaveContext.save.bombersCaughtNum >= 5)) { + Message_CloseTextbox(play); + if ((this->unk_2CA == 8) && (gSaveContext.save.saveInfo.bombersCaughtNum >= 5)) { func_80C02CA4(this, play); } else { if (this->unk_2CA == 8) { @@ -779,7 +780,7 @@ void func_80C02BCC(EnBomjimb* this, PlayState* play) { if (this->unk_2C0 == 0) { player->actor.freezeTimer = 3; if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); this->unk_2C0 = 1; player->stateFlags1 &= ~PLAYER_STATE1_10000000; } @@ -799,7 +800,7 @@ void func_80C02CA4(EnBomjimb* this, PlayState* play) { gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_86; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } SET_WEEKEVENTREG(WEEKEVENTREG_75_40); SET_WEEKEVENTREG(WEEKEVENTREG_83_04); @@ -840,7 +841,7 @@ void EnBomjimb_Update(Actor* thisx, PlayState* play2) { if (this->unk_2CA == 0) { if ((this->unk_2E4 != NULL) && (this->unk_2E4->update != NULL)) { Math_Vec3f_Copy(&this->unk_2E4->world.pos, &this->actor.world.pos); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->unk_2E4->world.pos.y = this->actor.world.pos.y + 35.0f; } else { this->unk_2E4->world.pos.y = this->actor.world.pos.y + 25.0f; @@ -858,7 +859,9 @@ void EnBomjimb_Update(Actor* thisx, PlayState* play2) { } } - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.c b/src/overlays/actors/ovl_En_Boom/z_en_boom.c index 33af85b3e..4abfad7b1 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -63,22 +63,23 @@ void EnBoom_SetupAction(EnBoom* this, EnBoomActionFunc actionFunc) { void func_808A24DC(EnBoom* this, PlayState* play) { WaterBox* sp54; f32 sp50 = this->actor.world.pos.y; - u16 sp4E = this->actor.bgCheckFlags & 0x20; + u16 sp4E = this->actor.bgCheckFlags & BGCHECKFLAG_WATER; if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, &sp54) && (this->actor.world.pos.y < sp50)) { Vec3f sp40; - this->actor.bgCheckFlags |= 0x20; + this->actor.bgCheckFlags |= BGCHECKFLAG_WATER; sp40.x = this->actor.world.pos.x; sp40.y = this->actor.world.pos.y - 20.0f; sp40.z = this->actor.world.pos.z; EffectSsBubble_Spawn(play, &sp40, 20.0f, 10.0f, 20.0f, 0.13f); } else { - this->actor.bgCheckFlags &= ~0x20; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER; } - if ((this->actor.bgCheckFlags & 0x40) && ((this->actor.bgCheckFlags & 0x20) != sp4E)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) && + ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER) != sp4E)) { Vec3f sp34; Math_Vec3f_Diff(&this->actor.world.pos, &this->actor.prevPos, &sp34); @@ -95,14 +96,14 @@ void func_808A24DC(EnBoom* this, PlayState* play) { EffectSsGSplash_Spawn(play, &sp34, NULL, NULL, 0, 300); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); + Actor_PlaySfx(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); EffectSsGRipple_Spawn(play, &sp34, 100, 500, 0); EffectSsGRipple_Spawn(play, &sp34, 100, 500, 4); EffectSsGRipple_Spawn(play, &sp34, 100, 500, 8); } - this->actor.bgCheckFlags |= 0x40; + this->actor.bgCheckFlags |= BGCHECKFLAG_WATER_TOUCH; } void EnBoom_Init(Actor* thisx, PlayState* play) { @@ -177,9 +178,9 @@ void func_808A2918(EnBoom* this, PlayState* play) { sp7C = this->player; if (sp7C != NULL) { - sp72 = Actor_YawToPoint(&this->actor, &sp7C->focus.pos); + sp72 = Actor_WorldYawTowardPoint(&this->actor, &sp7C->focus.pos); sp70 = this->actor.world.rot.y - sp72; - sp6E = Actor_PitchToPoint(&this->actor, &sp7C->focus.pos); + sp6E = Actor_WorldPitchTowardPoint(&this->actor, &sp7C->focus.pos); sp6C = this->actor.world.rot.x - sp6E; sp64 = (200.0f - Math_Vec3f_DistXYZ(&this->actor.world.pos, &sp7C->focus.pos)) * 0.005f; @@ -262,7 +263,7 @@ void func_808A2918(EnBoom* this, PlayState* play) { Math_Vec3f_Copy(&sp7C->world.pos, &player->actor.world.pos); if (sp7C->id == ACTOR_EN_ITEM00) { sp7C->gravity = -0.9f; - sp7C->bgCheckFlags &= ~3; + sp7C->bgCheckFlags &= ~(BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH); } else { sp7C->flags &= ~ACTOR_FLAG_2000; } diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.c b/src/overlays/actors/ovl_En_Box/z_en_box.c index 33dd4f69f..302547c26 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -187,7 +187,7 @@ void EnBox_ClipToGround(EnBox* this, PlayState* play) { void EnBox_Init(Actor* thisx, PlayState* play) { s32 pad; EnBox* this = THIS; - s16 cutsceneIdx; + s16 csId; CollisionHeader* colHeader; f32 animFrame; f32 animFrameEnd; @@ -213,7 +213,7 @@ void EnBox_Init(Actor* thisx, PlayState* play) { this->dyna.actor.world.rot.x = 0x7FFF; this->collectableFlag = 0; } else { - func_800C636C(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCeilingCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->collectableFlag = (this->dyna.actor.world.rot.x & 0x7F); this->dyna.actor.world.rot.x = 0; } @@ -228,7 +228,7 @@ void EnBox_Init(Actor* thisx, PlayState* play) { animFrame = animFrameEnd; } else if (((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG_FALL) || (this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG_FALL)) && !Flags_GetSwitch(play, this->switchFlag)) { - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); if (Rand_ZeroOne() < 0.5f) { this->movementFlags |= ENBOX_MOVE_FALL_ANGLE_SIDE; } @@ -240,7 +240,7 @@ void EnBox_Init(Actor* thisx, PlayState* play) { } else if (((this->type == ENBOX_TYPE_BIG_ROOM_CLEAR) || (this->type == ENBOX_TYPE_SMALL_ROOM_CLEAR)) && !Flags_GetClear(play, this->dyna.actor.room)) { EnBox_SetupAction(this, EnBox_AppearOnRoomClear); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); if (this->movementFlags & ENBOX_MOVE_0x80) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 50.0f; } else { @@ -254,7 +254,7 @@ void EnBox_Init(Actor* thisx, PlayState* play) { } else if (((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG) || (this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG)) && !Flags_GetSwitch(play, this->switchFlag)) { EnBox_SetupAction(this, EnBox_AppearSwitchFlag); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); if (this->movementFlags & ENBOX_MOVE_0x80) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 50.0f; } else { @@ -265,7 +265,7 @@ void EnBox_Init(Actor* thisx, PlayState* play) { this->dyna.actor.flags |= ACTOR_FLAG_10; } else { if ((this->type == ENBOX_TYPE_BIG_INVISIBLE) || (this->type == ENBOX_TYPE_SMALL_INVISIBLE)) { - this->dyna.actor.flags |= ACTOR_FLAG_80; + this->dyna.actor.flags |= ACTOR_FLAG_REACT_TO_LENS; } EnBox_SetupAction(this, EnBox_WaitOpen); this->movementFlags |= ENBOX_MOVE_IMMOBILE; @@ -290,17 +290,17 @@ void EnBox_Init(Actor* thisx, PlayState* play) { Actor_SetFocus(&this->dyna.actor, 40.0f); } - this->cutsceneIdxA = -1; - this->cutsceneIdxB = -1; - cutsceneIdx = this->dyna.actor.cutscene; + this->csId1 = CS_ID_NONE; + this->csId2 = CS_ID_NONE; + csId = this->dyna.actor.csId; - while (cutsceneIdx != -1) { - if (func_800F2178(cutsceneIdx) == 1) { - this->cutsceneIdxB = cutsceneIdx; + while (csId != CS_ID_NONE) { + if (CutsceneManager_GetCutsceneCustomValue(csId) == 1) { + this->csId2 = csId; } else { - this->cutsceneIdxA = cutsceneIdx; + this->csId1 = csId; } - cutsceneIdx = ActorCutscene_GetAdditionalCutscene(cutsceneIdx); + csId = CutsceneManager_GetAdditionalCsId(csId); } func_80867BDC(&this->unk_1F4, play, &this->dyna.actor.home.pos); } @@ -345,7 +345,7 @@ void EnBox_Fall(EnBox* this, PlayState* play) { this->alpha = 255; this->movementFlags &= ~ENBOX_MOVE_IMMOBILE; - if (this->dyna.actor.bgCheckFlags & 1) { + if (this->dyna.actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->movementFlags |= ENBOX_MOVE_UNUSED; if (this->movementFlags & ENBOX_MOVE_FALL_ANGLE_SIDE) { this->movementFlags &= ~ENBOX_MOVE_FALL_ANGLE_SIDE; @@ -374,10 +374,10 @@ void EnBox_Fall(EnBox* this, PlayState* play) { } void EnBox_FallOnSwitchFlag(EnBox* this, PlayState* play) { - func_800B8C50(&this->dyna.actor, play); + Actor_SetClosestSecretDistance(&this->dyna.actor, play); if (this->unk_1A0 >= 0) { EnBox_SetupAction(this, EnBox_Fall); - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } else if (this->unk_1A0 >= -11) { this->unk_1A0++; } else if (Flags_GetSwitch(play, this->switchFlag)) { @@ -386,34 +386,34 @@ void EnBox_FallOnSwitchFlag(EnBox* this, PlayState* play) { } void EnBox_AppearSwitchFlag(EnBox* this, PlayState* play) { - func_800B8C50(&this->dyna.actor, play); + Actor_SetClosestSecretDistance(&this->dyna.actor, play); if (Flags_GetSwitch(play, this->switchFlag)) { - if (ActorCutscene_GetCanPlayNext(this->cutsceneIdxA)) { - ActorCutscene_StartAndSetUnkLinkFields(this->cutsceneIdxA, &this->dyna.actor); + if (CutsceneManager_IsNext(this->csId1)) { + CutsceneManager_StartWithPlayerCs(this->csId1, &this->dyna.actor); EnBox_SetupAction(this, func_80868AFC); this->unk_1A0 = -30; } else { - ActorCutscene_SetIntentToPlay(this->cutsceneIdxA); + CutsceneManager_Queue(this->csId1); } } } void EnBox_AppearOnRoomClear(EnBox* this, PlayState* play) { - func_800B8C50(&this->dyna.actor, play); + Actor_SetClosestSecretDistance(&this->dyna.actor, play); if (Flags_GetClearTemp(play, this->dyna.actor.room)) { - if (ActorCutscene_GetCanPlayNext(this->cutsceneIdxA)) { - ActorCutscene_StartAndSetUnkLinkFields(this->cutsceneIdxA, &this->dyna.actor); + if (CutsceneManager_IsNext(this->csId1)) { + CutsceneManager_StartWithPlayerCs(this->csId1, &this->dyna.actor); Flags_SetClear(play, this->dyna.actor.room); EnBox_SetupAction(this, func_80868AFC); this->unk_1A0 = -30; } else { - ActorCutscene_SetIntentToPlay(this->cutsceneIdxA); + CutsceneManager_Queue(this->csId1); } } } void func_80868AFC(EnBox* this, PlayState* play) { - if ((func_800F22C4(this->cutsceneIdxA, &this->dyna.actor) != 0) || (this->unk_1A0 != 0)) { + if ((func_800F22C4(this->csId1, &this->dyna.actor) != 0) || (this->unk_1A0 != 0)) { EnBox_SetupAction(this, func_80868B74); this->unk_1A0 = 0; func_80867FBC(&this->unk_1F4, play, (this->movementFlags & ENBOX_MOVE_0x80) != 0); @@ -422,7 +422,7 @@ void func_80868AFC(EnBox* this, PlayState* play) { } void func_80868B74(EnBox* this, PlayState* play) { - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); if (this->unk_1A0 < 0) { this->unk_1A0++; } else if (this->unk_1A0 < 40) { @@ -432,7 +432,7 @@ void func_80868B74(EnBox* this, PlayState* play) { this->dyna.actor.world.pos.y += 1.25f; } this->unk_1A0++; - if ((this->cutsceneIdxA != -1) && ActorCutscene_GetCurrentIndex() == this->cutsceneIdxA) { + if ((this->csId1 != -1) && CutsceneManager_GetCurrentCsId() == this->csId1) { if (this->unk_1A0 == 2) { func_800B724C(play, &this->dyna.actor, PLAYER_CSMODE_4); } else if (this->unk_1A0 == 22) { @@ -445,7 +445,7 @@ void func_80868B74(EnBox* this, PlayState* play) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; } else { EnBox_SetupAction(this, EnBox_WaitOpen); - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); } } @@ -460,8 +460,8 @@ void EnBox_WaitOpen(EnBox* this, PlayState* play) { this->alpha = 255; this->movementFlags |= ENBOX_MOVE_IMMOBILE; - if ((this->unk_1EC != 0) && ((this->cutsceneIdxB < 0) || (ActorCutscene_GetCurrentIndex() == this->cutsceneIdxB) || - (ActorCutscene_GetCurrentIndex() == -1))) { + if ((this->unk_1EC != 0) && ((this->csId2 < 0) || (CutsceneManager_GetCurrentCsId() == this->csId2) || + (CutsceneManager_GetCurrentCsId() == CS_ID_NONE))) { if (this->unk_1EC < 0) { animHeader = &gBoxChestOpenAnim; playbackSpeed = 1.5f; @@ -508,7 +508,7 @@ void EnBox_WaitOpen(EnBox* this, PlayState* play) { if ((this->getItemId == GI_MASK_GIANT) && (INV_CONTENT(ITEM_MASK_GIANT) == ITEM_MASK_GIANT)) { this->getItemId = GI_RECOVERY_HEART; } - Actor_PickUpNearby(&this->dyna.actor, play, -this->getItemId); + Actor_OfferGetItemNearby(&this->dyna.actor, play, -this->getItemId); } if (Flags_GetTreasure(play, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { EnBox_SetupAction(this, EnBox_Open); @@ -519,7 +519,7 @@ void EnBox_WaitOpen(EnBox* this, PlayState* play) { void EnBox_Open(EnBox* this, PlayState* play) { s32 pad; - this->dyna.actor.flags &= ~ACTOR_FLAG_80; + this->dyna.actor.flags &= ~ACTOR_FLAG_REACT_TO_LENS; if (SkelAnime_Update(&this->skelAnime)) { if (this->unk_1EC > 0) { @@ -612,7 +612,8 @@ void EnBox_Update(Actor* thisx, PlayState* play) { } if (!(this->movementFlags & ENBOX_MOVE_IMMOBILE)) { Actor_MoveWithGravity(&this->dyna.actor); - Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x1C); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, + UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); } Actor_SetFocus(&this->dyna.actor, 40.0f); if ((this->getItemId == GI_ICE_TRAP) && (this->actionFunc == EnBox_Open) && (this->skelAnime.curFrame > 45.0f) && @@ -698,7 +699,7 @@ void EnBox_Draw(Actor* thisx, PlayState* play) { } if (((this->alpha == 255) && (this->type != ENBOX_TYPE_BIG_INVISIBLE) && (this->type != ENBOX_TYPE_SMALL_INVISIBLE)) || - (!CHECK_FLAG_ALL(this->dyna.actor.flags, ACTOR_FLAG_80) && + (!CHECK_FLAG_ALL(this->dyna.actor.flags, ACTOR_FLAG_REACT_TO_LENS) && ((this->type == ENBOX_TYPE_BIG_INVISIBLE) || (this->type == ENBOX_TYPE_SMALL_INVISIBLE)))) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); 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 9cb5af18d..75d9f09c9 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.h +++ b/src/overlays/actors/ovl_En_Box/z_en_box.h @@ -60,8 +60,8 @@ typedef struct EnBox { /* 0x1F2 */ u8 iceSmokeTimer; /* 0x1F3 */ s8 unk_1F3; /* 0x1F4 */ struct_80867BDC_a0 unk_1F4; - /* 0x218 */ s16 cutsceneIdxA; - /* 0x21A */ s16 cutsceneIdxB; + /* 0x218 */ s16 csId1; + /* 0x21A */ s16 csId2; /* 0x21C */ s32 getItemId; /* 0x220 */ s32 collectableFlag; } EnBox; // size = 0x224 diff --git a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c index cbf9e9f3c..1c0c2cfc4 100644 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c @@ -247,10 +247,10 @@ void EnBubble_Fly(EnBubble* this, PlayState* play) { this->velocityFromBounce.y = this->bounceDirection.y * bounceSpeed; this->velocityFromBounce.z = this->bounceDirection.z * bounceSpeed; this->yVelocity = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AWA_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EN_AWA_BOUND); this->modelRotSpeed = 128.0f; this->modelEllipticity = 0.48f; - } else if ((this->actor.bgCheckFlags & 0x20) && (bounceDirection.y < 0.0f)) { + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER) && (bounceDirection.y < 0.0f)) { normal.x = normal.z = 0.0f; normal.y = 1.0f; EnBubble_Vec3fNormalizedReflect(&bounceDirection, &normal, &bounceDirection); @@ -266,7 +266,7 @@ void EnBubble_Fly(EnBubble* this, PlayState* play) { this->velocityFromBounce.y = (this->bounceDirection.y * bounceSpeed); this->velocityFromBounce.z = (this->bounceDirection.z * bounceSpeed); this->yVelocity = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AWA_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EN_AWA_BOUND); this->modelRotSpeed = 128.0f; this->modelEllipticity = 0.48f; } @@ -392,7 +392,8 @@ void EnBubble_Update(Actor* thisx, PlayState* play) { EnBubble* this = (EnBubble*)thisx; Actor_UpdatePos(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 16.0f, 16.0f, 0.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 16.0f, 16.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); Actor_SetFocus(&this->actor, this->actor.shape.yOffset); } @@ -409,9 +410,9 @@ void EnBubble_Draw(Actor* thisx, PlayState* play) { Math_SmoothStepToF(&this->modelEllipticity, 0.08f, 0.2f, 1000.0f, 0.0f); Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Scale(this->modelWidth + 1.0f, this->modelHeight + 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateZF(DEGF_TO_RADF((f32)play->state.frames) * this->modelRotSpeed, MTXMODE_APPLY); + Matrix_RotateZF(DEG_TO_RAD((f32)play->state.frames) * this->modelRotSpeed, MTXMODE_APPLY); Matrix_Scale(this->modelEllipticity + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateZF(DEGF_TO_RADF(-(f32)play->state.frames) * this->modelRotSpeed, MTXMODE_APPLY); + Matrix_RotateZF(DEG_TO_RAD(-(f32)play->state.frames) * this->modelRotSpeed, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gBubbleDL); diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.c b/src/overlays/actors/ovl_En_Butte/z_en_butte.c index eb3365b83..05072da72 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.c @@ -241,7 +241,7 @@ void func_8091C794(EnButte* this, PlayState* play) { s16 yaw; func_8091C524(this); - Math_SmoothStepToF(&this->actor.speedXZ, sp4C->unk_04, sp4C->unk_08, sp4C->unk_0C, 0.0f); + Math_SmoothStepToF(&this->actor.speed, sp4C->unk_04, sp4C->unk_08, sp4C->unk_0C, 0.0f); if (this->unk_24F == 1) { distSq = SQ(100.0f); @@ -276,9 +276,8 @@ void func_8091C794(EnButte* this, PlayState* play) { func_8091C6B4(this); - playSpeed = - (((this->actor.speedXZ * 0.5f) + (Rand_ZeroOne() * 0.2f)) + ((1.0f - Math_SinS(this->unk_258)) * 0.15f)) + - ((1.0f - Math_SinS(this->unk_256)) * 0.3f) + sp38; + playSpeed = (((this->actor.speed * 0.5f) + (Rand_ZeroOne() * 0.2f)) + ((1.0f - Math_SinS(this->unk_258)) * 0.15f)) + + ((1.0f - Math_SinS(this->unk_256)) * 0.3f) + sp38; this->skelAnime.playSpeed = CLAMP(playSpeed, 0.2f, 1.5f); SkelAnime_Update(&this->skelAnime); @@ -318,7 +317,7 @@ void func_8091CBB4(EnButte* this, PlayState* play) { s16 yaw; func_8091C5EC(this); - Math_SmoothStepToF(&this->actor.speedXZ, sp5C->unk_04, sp5C->unk_08, sp5C->unk_0C, 0.0f); + Math_SmoothStepToF(&this->actor.speed, sp5C->unk_04, sp5C->unk_08, sp5C->unk_0C, 0.0f); sp40 = 0.0f; if ((this->unk_24E != 0) && (this->unk_24C < 12)) { @@ -344,7 +343,7 @@ void func_8091CBB4(EnButte* this, PlayState* play) { func_8091C6B4(this); - playSpeed = ((this->actor.speedXZ * 0.5f) + (Rand_ZeroOne() * 0.2f) + ((1.0f - Math_SinS(this->unk_258)) * 0.15f)) + + playSpeed = ((this->actor.speed * 0.5f) + (Rand_ZeroOne() * 0.2f) + ((1.0f - Math_SinS(this->unk_258)) * 0.15f)) + ((1.0f - Math_SinS(this->unk_256)) * 0.3f) + sp40; this->skelAnime.playSpeed = CLAMP(playSpeed, 0.2f, 1.5f); SkelAnime_Update(&this->skelAnime); @@ -356,7 +355,7 @@ void func_8091CBB4(EnButte* this, PlayState* play) { distSq = Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, this->actor.home.pos.x, this->actor.home.pos.z); - if ((player->heldItemAction != PLAYER_IA_STICK) || !(fabsf(player->actor.speedXZ) < 1.8f) || (this->unk_252 > 0) || + if ((player->heldItemAction != PLAYER_IA_STICK) || !(fabsf(player->actor.speed) < 1.8f) || (this->unk_252 > 0) || !(distSq < SQ(320.0f))) { func_8091C748(this); } else if ((distSq > SQ(240.0f)) && 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 d32fe32ac..cbe96e0f0 100644 --- a/src/overlays/actors/ovl_En_Cha/z_en_cha.c +++ b/src/overlays/actors/ovl_En_Cha/z_en_cha.c @@ -72,24 +72,24 @@ void EnCha_Destroy(Actor* thisx, PlayState* play) { void EnCha_Ring(EnCha* this, PlayState* play) { EnCha_Idle(this, play); - if (this->actor.cutscene == -1) { + if (this->actor.csId == CS_ID_NONE) { this->actionFunc = EnCha_Idle; - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); this->actionFunc = EnCha_Idle; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } void EnCha_Idle(EnCha* this, PlayState* play) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_60_04)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); + Actor_PlaySfx(&this->actor, NA_SE_EV_DOOR_BELL); CLEAR_WEEKEVENTREG(WEEKEVENTREG_60_04); this->actor.home.rot.z = 0x7D0; } if (this->collider.base.acFlags & AC_HIT) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); + Actor_PlaySfx(&this->actor, NA_SE_EV_DOOR_BELL); this->actor.home.rot.z = 0x7D0; if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_51_04)) { SET_WEEKEVENTREG(WEEKEVENTREG_51_04); 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 bfc828194..21278af9f 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 @@ -463,12 +463,12 @@ void EnClearTag_Init(Actor* thisx, PlayState* play) { } // Initialize flash effect - Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 30.0f, 100.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 30.0f, 100.0f, UPDBGCHECKINFO_FLAG_4); pos = this->actor.world.pos; EnClearTag_CreateFlashEffect(this, &pos, sFlashMaxScale[thisx->params], this->actor.floorHeight); // Is not underwater - if (!(this->actor.bgCheckFlags & 0x20)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { if (thisx->params < 10) { pos.y = this->actor.world.pos.y - 40.0f; @@ -549,14 +549,14 @@ void EnClearTag_UpdateCamera(EnClearTag* this, PlayState* play) { player->actor.world.pos.z = -950.0f; } - player->actor.speedXZ = 0.0f; + player->actor.speed = 0.0f; if (this->activeTimer == 0) { this->cameraState = 1; } } break; case 1: - Cutscene_Start(play, &play->csCtx); + Cutscene_StartManual(play, &play->csCtx); this->subCamId = Play_CreateSubCamera(play); Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_ACTIVE); @@ -578,15 +578,15 @@ void EnClearTag_UpdateCamera(EnClearTag* this, PlayState* play) { player->actor.world.pos.z = -950.0f; } - player->actor.speedXZ = 0.0f; + player->actor.speed = 0.0f; if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { mainCam = Play_GetCamera(play, CAM_ID_MAIN); mainCam->eye = this->subCamEye; mainCam->eyeNext = this->subCamEye; mainCam->at = this->subCamAt; func_80169AFC(play, this->subCamId, 0); - Cutscene_End(play, &play->csCtx); - func_800B7298(play, &this->actor, PLAYER_CSMODE_6); + Cutscene_StopManual(play, &play->csCtx); + func_800B7298(play, &this->actor, PLAYER_CSMODE_END); this->cameraState = 0; this->subCamId = SUB_CAM_ID_DONE; this->activeTimer = 20; diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index 876914a2a..7fc741ebe 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -234,7 +234,7 @@ void EnCne01_Update(Actor* thisx, PlayState* play) { EnCne01_TestIsTalking(this, play); this->enHy.actionFunc(&this->enHy, play); - Actor_UpdateBgCheckInfo(play, &this->enHy.actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->enHy.actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); EnCne01_UpdateModel(this, play); func_809CB4A0(this, play); } 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 63c83f0ea..6f7d32de1 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 @@ -114,13 +114,13 @@ void func_80AFDD60(EnColMan* this) { } void func_80AFDE00(EnColMan* this, PlayState* play) { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (this->actor.params == EN_COL_MAN_HEART_PIECE) { this->actor.params = EN_COL_MAN_RECOVERY_HEART; - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; this->actor.velocity.y = 8.0f; } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } } if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_56_02)) { @@ -131,9 +131,9 @@ void func_80AFDE00(EnColMan* this, PlayState* play) { this->actor.draw = NULL; this->actionFunc = EnColMan_SetHeartPieceCollectedAndKill; } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_56_02)) { - Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 40.0f, 40.0f); + Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 40.0f, 40.0f); } else { - Actor_PickUp(&this->actor, play, GI_RECOVERY_HEART, 40.0f, 40.0f); + Actor_OfferGetItem(&this->actor, play, GI_RECOVERY_HEART, 40.0f, 40.0f); } } @@ -161,13 +161,13 @@ void func_80AFDFB4(EnColMan* this, PlayState* play) { this->scale = (BREG(55) / 10000.0f) + 0.0015f; - if ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (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.speed = 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); + Actor_PlaySfx(&this->actor, NA_SE_EN_ANSATSUSYA_ROCK); return; } @@ -210,7 +210,7 @@ void func_80AFE25C(EnColMan* this, PlayState* play) { } } - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfx(&this->actor, NA_SE_IT_BOMB_EXPLOSION); Actor_Kill(&this->actor); } } @@ -222,7 +222,9 @@ void EnColMan_Update(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, this->scale); this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 30.0f, 30.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 30.0f, 30.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } @@ -244,7 +246,7 @@ void func_80AFE4AC(Actor* thisx, PlayState* play) { func_8012C2DC(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); OPEN_DISPS(play->state.gfxCtx); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gDropRecoveryHeartTex)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -266,7 +268,7 @@ void func_80AFE584(Actor* thisx, PlayState* play) { void func_80AFE650(Actor* thisx, PlayState* play) { func_8012C28C(play->state.gfxCtx); OPEN_DISPS(play->state.gfxCtx); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gDropBombTex)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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 4e9040d83..beed3fb26 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -202,7 +202,7 @@ void EnCow_UpdateAnimation(EnCow* this, PlayState* play) { void EnCow_TalkEnd(EnCow* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = EnCow_Idle; } } @@ -219,26 +219,26 @@ void EnCow_GiveMilkWait(EnCow* this, PlayState* play) { this->actor.parent = NULL; this->actionFunc = EnCow_GiveMilkEnd; } else { - Actor_PickUp(&this->actor, play, GI_MILK, 10000.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_MILK, 10000.0f, 100.0f); } } void EnCow_GiveMilk(EnCow* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = EnCow_GiveMilkWait; - Actor_PickUp(&this->actor, play, GI_MILK, 10000.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_MILK, 10000.0f, 100.0f); } } void EnCow_CheckForEmptyBottle(EnCow* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (Inventory_HasEmptyBottle()) { - func_80151938(play, 0x32C9); // Text to give milk. + Message_ContinueTextbox(play, 0x32C9); // Text to give milk. this->actionFunc = EnCow_GiveMilk; } else { - func_80151938(play, 0x32CA); // Text if you don't have an empty bottle. + Message_ContinueTextbox(play, 0x32CA); // Text if you don't have an empty bottle. this->actionFunc = EnCow_TalkEnd; } } @@ -340,11 +340,11 @@ void EnCow_Update(Actor* thisx, PlayState* play2) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); if (SkelAnime_Update(&this->skelAnime)) { if (this->skelAnime.animation == &gCowChewAnim) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_COW_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EV_COW_CRY); Animation_Change(&this->skelAnime, &gCowMooAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowMooAnim), ANIMMODE_ONCE, 1.0f); } else { diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.c b/src/overlays/actors/ovl_En_Crow/z_en_crow.c index b9e1071fe..3238069cc 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -6,7 +6,7 @@ #include "z_en_crow.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_4000) #define THIS ((EnCrow*)thisx) @@ -163,36 +163,36 @@ void EnCrow_FlyIdle(EnCrow* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); onInitialAnimFrame = Animation_OnFrame(&this->skelAnime, 0.0f); - this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 3.0f; + this->actor.speed = (Rand_ZeroOne() * 1.5f) + 3.0f; if ((this->actor.parent != NULL) && (this->actor.parent->home.rot.z == 0)) { this->actor.home.pos.x = this->actor.parent->world.pos.x; this->actor.home.pos.z = this->actor.parent->world.pos.z; - dist = Actor_XZDistanceToPoint(&this->actor, &this->actor.parent->world.pos); + dist = Actor_WorldDistXZToPoint(&this->actor, &this->actor.parent->world.pos); } else { dist = 450.0f; this->actor.flags |= ACTOR_FLAG_1; } - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->yawTarget = this->actor.wallYaw; - } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 300.0f) { - this->yawTarget = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + } else if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 300.0f) { + this->yawTarget = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); } if ((Math_SmoothStepToS(&this->actor.shape.rot.y, this->yawTarget, 5, 0x300, 0x10) == 0) && onInitialAnimFrame && (Rand_ZeroOne() < 0.1f)) { - yaw = (Actor_YawToPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y); + yaw = (Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y); if (yaw > 0) { this->yawTarget += Rand_S16Offset(0x1000, 0x1000); } else { this->yawTarget -= Rand_S16Offset(0x1000, 0x1000); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_KAICHO_CRY); } - if ((this->actor.depthInWater > -40.0f) || (this->actor.bgCheckFlags & 1)) { + if ((this->actor.depthInWater > -40.0f) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->pitchTarget = -0x1000; } else if (this->actor.world.pos.y < (this->actor.home.pos.y - 50.0f)) { this->pitchTarget = -Rand_S16Offset(0x800, 0x800); @@ -211,7 +211,7 @@ void EnCrow_FlyIdle(EnCrow* this, PlayState* play) { this->pitchTarget = CLAMP(this->pitchTarget, -0x1000, 0x1000); } - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { Math_ScaledStepToS(&this->actor.shape.rot.x, -0x100, 0x400); } @@ -233,7 +233,7 @@ void EnCrow_FlyIdle(EnCrow* this, PlayState* play) { void EnCrow_SetupDiveAttack(EnCrow* this) { this->timer = 300; this->actionFunc = EnCrow_DiveAttack; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; this->skelAnime.playSpeed = 2.0f; } @@ -258,27 +258,28 @@ void EnCrow_DiveAttack(EnCrow* this, PlayState* play) { } targetPos.x = this->actor.child->world.pos.x; targetPos.z = this->actor.child->world.pos.z; - pitchTarget = Actor_PitchToPoint(&this->actor, &targetPos); + pitchTarget = Actor_WorldPitchTowardPoint(&this->actor, &targetPos); pitchTarget = CLAMP(pitchTarget, -0x3000, 0x3000); Math_SmoothStepToS(&this->actor.shape.rot.x, pitchTarget, 2, 0x400, 0x40); } else { Math_SmoothStepToS(&this->actor.shape.rot.x, -0x800, 2, 0x100, 0x10); } - if (isFacingActor || (Actor_XZDistanceBetweenActors(&this->actor, this->actor.child) > 80.0f)) { - Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->actor.child), 4, 0xC00, - 0xC0); + if (isFacingActor || (Actor_WorldDistXZToActor(&this->actor, this->actor.child) > 80.0f)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardActor(&this->actor, this->actor.child), 4, + 0xC00, 0xC0); } if (((this->timer == 0) || ((&player->actor != this->actor.child) && (this->actor.child->home.rot.z != 0)) || ((&player->actor == this->actor.child) && ((Player_GetMask(play) == PLAYER_MASK_STONE) || (player->stateFlags1 & PLAYER_STATE1_800000))) || - ((this->collider.base.atFlags & AT_HIT) || (this->actor.bgCheckFlags & 9))) || + ((this->collider.base.atFlags & AT_HIT) || + (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_WALL)))) || (this->actor.depthInWater > -40.0f)) { if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_KAICHO_ATTACK); } EnCrow_SetupFlyIdle(this); } @@ -295,15 +296,15 @@ void EnCrow_CheckIfFrozen(EnCrow* this, PlayState* play) { void EnCrow_SetupDamaged(EnCrow* this, PlayState* play) { f32 scale; - this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); + this->actor.speed *= Math_CosS(this->actor.world.rot.x); this->actor.velocity.y = 0.0f; Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); this->actor.shape.yOffset = 0.0f; this->actor.targetArrowOffset = 0.0f; - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; scale = (this->actor.scale.x * 100.0f); this->actor.world.pos.y += 20.0f * scale; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_KAICHO_DEAD); if (this->actor.colChkInfo.damageEffect == GUAY_DMGEFF_ICE) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; @@ -323,9 +324,9 @@ void EnCrow_SetupDamaged(EnCrow* this, PlayState* play) { this->drawDmgEffFrozenSteamScale = 0.5f; } - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 40); if (this->actor.flags & ACTOR_FLAG_8000) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } this->collider.base.acFlags &= ~AC_ON; @@ -335,7 +336,7 @@ void EnCrow_SetupDamaged(EnCrow* this, PlayState* play) { } void EnCrow_Damaged(EnCrow* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); this->actor.colorFilterTimer = 40; if (!(this->actor.flags & ACTOR_FLAG_8000)) { @@ -343,7 +344,7 @@ void EnCrow_Damaged(EnCrow* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); this->actor.shape.rot.z += 0x1780; } - if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { EnCrow_CheckIfFrozen(this, play); func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, this->actor.scale.x * 10000.0f, 0, 0); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); @@ -385,22 +386,22 @@ void EnCrow_Die(EnCrow* this, PlayState* play) { void EnCrow_SetupTurnAway(EnCrow* this) { this->timer = 100; this->pitchTarget = -0x1000; - this->actor.speedXZ = 3.5f; + this->actor.speed = 3.5f; this->yawTarget = this->actor.yawTowardsPlayer + 0x8000; this->skelAnime.playSpeed = 2.0f; if (this->actor.colChkInfo.damageEffect == GUAY_DMGEFF_STUN) { - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); } else { - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = EnCrow_TurnAway; } void EnCrow_TurnAway(EnCrow* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->yawTarget = this->actor.wallYaw; } else { this->yawTarget = this->actor.yawTowardsPlayer + 0x8000; @@ -506,7 +507,8 @@ void EnCrow_Update(Actor* thisx, PlayState* play) { height = 0.0f; Actor_MoveWithGravity(&this->actor); } - Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f * scale, 25.0f * scale, 50.0f * scale, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f * scale, 25.0f * scale, 50.0f * scale, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); } else { height = 0.0f; } @@ -528,7 +530,7 @@ void EnCrow_Update(Actor* thisx, PlayState* play) { Actor_SetFocus(&this->actor, height); if ((this->actor.colChkInfo.health != 0) && (Animation_OnFrame(&this->skelAnime, 3.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_FLUTTER); + Actor_PlaySfx(&this->actor, NA_SE_EN_KAICHO_FLUTTER); } if (this->drawDmgEffAlpha > 0.0f) { if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { 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 2f2496f57..7b3f97ded 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -176,13 +176,13 @@ s32 func_80B3E5DC(EnDai* this, s32 arg1) { s32 func_80B3E69C(EnDai* this, PlayState* play) { s32 ret = false; - if ((play->csCtx.state != CS_STATE_0) && (play->sceneId == SCENE_12HAKUGINMAE) && - (play->csCtx.currentCsIndex == 0) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_30_01)) { + if ((play->csCtx.state != CS_STATE_IDLE) && (play->sceneId == SCENE_12HAKUGINMAE) && + (play->csCtx.scriptIndex == 0) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_30_01)) { if (!(this->unk_1CE & 0x10)) { Flags_SetSwitch(play, 20); this->unk_1CE |= (0x80 | 0x10); this->unk_1CE &= ~(0x100 | 0x20); - this->unk_1CC = 0xFF; + this->cueId = 255; this->unk_1DC = 0; this->unk_1CD = 0; this->unk_1F0 = D_80B3FBF0; @@ -240,7 +240,7 @@ static s32 D_80B3FC8C[] = { 0x920C0F0C, 0x930C1211, 0x5520100E, 0x0C940C12, 0x10000000, }; -s16 func_80B3E8BC(EnDai* this, s32 arg1) { +s16 func_80B3E8BC(EnDai* this, s32 cueId) { static f32 D_80B3FCB4[] = { 1.0f, 6.0f, 16.0f, 19.0f, 46.0f, 48.0f, 50.0f, 52.0f, 54.0f, 1.0f, 6.0f, 36.0f, }; @@ -256,10 +256,10 @@ s16 func_80B3E8BC(EnDai* this, s32 arg1) { s32 i; s32 end; - if (arg1 == 3) { + if (cueId == 3) { end = 9; i = 0; - } else if (arg1 == 4) { + } else if (cueId == 4) { end = 12; i = 9; } else { @@ -291,7 +291,7 @@ s32 func_80B3E96C(EnDai* this, PlayState* play) { break; case 1: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SNOWSTORM_HARD); + Actor_PlaySfx(&this->actor, NA_SE_EV_SNOWSTORM_HARD); Actor_Spawn(&play->actorCtx, play, 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); @@ -351,8 +351,8 @@ s32 func_80B3EC84(EnDai* this) { }; static Vec3f D_80B3FD7C[] = { - { 1.0f, 1.0f, 1.0f }, { 1.0f, 0.8, 0.8 }, { 1.0f, 1.1f, 1.1f }, { 1.0f, 1.3f, 1.3f }, { 1.0f, 0.7f, 0.9f }, - { 1.0f, 0.8, 0.9f }, { 1.0f, 0.7f, 0.9f }, { 1.0f, 0.8, 0.9f }, { 1.0f, 1.0f, 1.0f }, + { 1.0f, 1.0f, 1.0f }, { 1.0f, 0.8f, 0.8f }, { 1.0f, 1.1f, 1.1f }, { 1.0f, 1.3f, 1.3f }, { 1.0f, 0.7f, 0.9f }, + { 1.0f, 0.8f, 0.9f }, { 1.0f, 0.7f, 0.9f }, { 1.0f, 0.8f, 0.9f }, { 1.0f, 1.0f, 1.0f }, }; s32 i; @@ -379,7 +379,10 @@ s32 func_80B3ED88(EnDai* this) { static s16 D_80B3FE00[] = { 1, 2, 3 }; static Vec3f D_80B3FE08[] = { - 1.0f, 1.0f, 1.0f, 1.0f, 1.2f, 1.2f, 1.0f, 0.7f, 0.8f, 1.0f, 1.0f, 1.0f, + { 1.0f, 1.0f, 1.0f }, + { 1.0f, 1.2f, 1.2f }, + { 1.0f, 0.7f, 0.8f }, + { 1.0f, 1.0f, 1.0f }, }; s32 i; @@ -399,12 +402,12 @@ s32 func_80B3ED88(EnDai* this) { } void func_80B3EE8C(EnDai* this, PlayState* play) { - s16 cutscene = this->actor.cutscene; + s16 csId = this->actor.csId; - if (ActorCutscene_GetCanPlayNext(cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(cutscene, &this->actor); + if (CutsceneManager_IsNext(csId)) { + CutsceneManager_StartWithPlayerCs(csId, &this->actor); } else { - ActorCutscene_SetIntentToPlay(cutscene); + CutsceneManager_Queue(csId); } } @@ -442,21 +445,21 @@ void func_80B3F044(EnDai* this, PlayState* play) { static s32 D_80B3FE38[] = { 0, 0, 6, 7, 8, }; - s32 sp2C = 0; - s32 sp28; + s32 cueChannel = 0; + s32 cueId; - if (Cutscene_CheckActorAction(play, 472)) { - sp2C = Cutscene_GetActorActionIndex(play, 472); - sp28 = play->csCtx.actorActions[sp2C]->action; - if (this->unk_1CC != (u8)sp28) { - func_80B3E5DC(this, D_80B3FE38[sp28]); - switch (sp28) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_472)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_472); + cueId = play->csCtx.actorCues[cueChannel]->id; + if (this->cueId != (u8)cueId) { + func_80B3E5DC(this, D_80B3FE38[cueId]); + switch (cueId) { case 1: this->unk_1E0 = 0.0f; break; case 2: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROLL_AND_FALL); + Actor_PlaySfx(&this->actor, NA_SE_EV_ROLL_AND_FALL); break; case 3: @@ -464,10 +467,10 @@ void func_80B3F044(EnDai* this, PlayState* play) { break; } } - this->unk_1CC = sp28; + this->cueId = cueId; } - switch (this->unk_1CC) { + switch (this->cueId) { case 1: this->unk_1E0 += 1.0f; if (this->unk_1E0 < 30.0f) { @@ -478,34 +481,34 @@ void func_80B3F044(EnDai* this, PlayState* play) { break; case 2: - if (play->csCtx.frames == 360) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIGOLON_SLEEP3 - SFX_FLAG); + if (play->csCtx.curFrame == 360) { + Actor_PlaySfx(&this->actor, NA_SE_EN_DAIGOLON_SLEEP3 - SFX_FLAG); } if (Animation_OnFrame(&this->skelAnime, 43.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_BOUND_1); + Actor_PlaySfx(&this->actor, NA_SE_EV_GORON_BOUND_1); } - this->unk_1D6 = func_80B3E8BC(this, this->unk_1CC); + this->unk_1D6 = func_80B3E8BC(this, this->cueId); break; case 3: if (Animation_OnFrame(&this->skelAnime, 6.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIGOLON_SLEEP1); + Actor_PlaySfx(&this->actor, NA_SE_EN_DAIGOLON_SLEEP1); } - this->unk_1D6 = func_80B3E8BC(this, this->unk_1CC); + this->unk_1D6 = func_80B3E8BC(this, this->cueId); break; case 4: if (Animation_OnFrame(&this->skelAnime, 30.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIGOLON_SLEEP2); + Actor_PlaySfx(&this->actor, NA_SE_EN_DAIGOLON_SLEEP2); } if (Animation_OnFrame(&this->skelAnime, 35.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_BOUND_0); + Actor_PlaySfx(&this->actor, NA_SE_EV_GORON_BOUND_0); } - this->unk_1D6 = func_80B3E8BC(this, this->unk_1CC); + this->unk_1D6 = func_80B3E8BC(this, this->cueId); break; } - Cutscene_ActorTranslateAndYaw(&this->actor, play, sp2C); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } void EnDai_Init(Actor* thisx, PlayState* play) { @@ -522,7 +525,7 @@ void EnDai_Init(Actor* thisx, PlayState* play) { this->unk_1CE = 0; this->unk_1D6 = 0; - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE)) { SubS_UpdateFlags(&this->unk_1CE, 3, 7); this->unk_1CE |= 0x80; this->unk_1CD = 0xFF; @@ -642,7 +645,7 @@ void func_80B3F78C(EnDai* this, PlayState* play) { if (play->actorCtx.lensActorsDrawn) { this->unk_1CE |= 0x40; } else { - Actor_RecordUndrawnActor(play, &this->actor); + Actor_AddToLensActors(play, &this->actor); this->unk_1CE &= ~0x40; } diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.h b/src/overlays/actors/ovl_En_Dai/z_en_dai.h index 4dc059c39..35928388f 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.h +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.h @@ -26,7 +26,7 @@ typedef struct EnDai { /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnDaiActionFunc actionFunc; /* 0x18C */ MtxF unk_18C; - /* 0x1CC */ u8 unk_1CC; + /* 0x1CC */ u8 cueId; /* 0x1CD */ u8 unk_1CD; /* 0x1CE */ u16 unk_1CE; /* 0x1D0 */ s32 unk_1D0; 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 263b22ada..b988155c7 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -87,7 +87,7 @@ void EnDaiku_Init(Actor* thisx, PlayState* play) { this->collider.dim.radius = 30; this->collider.dim.height = 60; this->collider.dim.yShift = 0; - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_80) || ((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { Actor_Kill(&this->actor); } @@ -244,7 +244,7 @@ void func_80943BDC(EnDaiku* this, PlayState* play) { } if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); func_80943820(this); } } @@ -278,7 +278,9 @@ void EnDaiku_Update(Actor* thisx, PlayState* play) { 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(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); this->actor.uncullZoneForward = 650.0f; Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h index fa161e9fd..4a3c9b444 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h @@ -7,8 +7,8 @@ struct EnDaiku; typedef void (*EnDaikuActionFunc)(struct EnDaiku*, PlayState*); -#define ENDAIKU_GET_FF(thisx) ((thisx)->params & 0xFF); -#define ENDAIKU_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF); +#define ENDAIKU_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENDAIKU_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) enum { /* 0x0 */ ENDAIKU_PARAMS_FF_0, 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 0e5e7a3ea..d8a8a78e8 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -234,7 +234,7 @@ void func_80BE66E4(EnDaiku2* this, PlayState* play) { func_800B8614(&this->actor, play, 80.0f); if ((this->unk_276 == 8) && Animation_OnFrame(&this->skelAnime, 6.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROCK_BROKEN); + Actor_PlaySfx(&this->actor, NA_SE_EV_ROCK_BROKEN); for (i = 0; i < 10; i++) { Math_Vec3f_Copy(&sp70, &this->actor.world.pos); @@ -297,7 +297,7 @@ void func_80BE6BC0(EnDaiku2* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { s32 day = gSaveContext.save.day - 1; - func_801477B4(play); + Message_CloseTextbox(play); if (this->unk_288 == 2) { this->actionFunc = func_80BE6D40; @@ -305,7 +305,7 @@ void func_80BE6BC0(EnDaiku2* this, PlayState* play) { this->actionFunc = func_80BE6EF0; } else if ((this->unk_28A == 0) || (this->unk_28A == 2)) { this->unk_28A++; - func_80151938(play, sTextIds[this->unk_28A]); + Message_ContinueTextbox(play, sTextIds[this->unk_28A]); } else { switch (day) { case 0: @@ -453,7 +453,9 @@ void EnDaiku2_Update(Actor* thisx, PlayState* play) { Actor_SetFocus(&this->actor, 65.0f); Actor_MoveWithGravity(&this->actor); Math_ApproachF(&this->unk_260, this->unk_264, 0.3f, 2.0f); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); func_80BE7600(this, play); diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h index f13b89611..130a06a23 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h @@ -7,9 +7,9 @@ struct EnDaiku2; typedef void (*EnDaiku2ActionFunc)(struct EnDaiku2*, PlayState*); -#define ENDAIKU2_GET_7F(thisx) ((thisx)->params & 0x7F); -#define ENDAIKU2_GET_1F80(thisx) (((thisx)->params >> 7) & 0x3F); -#define ENDAIKU2_GET_8000(thisx) (((thisx)->params >> 15) & 0x1); +#define ENDAIKU2_GET_7F(thisx) ((thisx)->params & 0x7F) +#define ENDAIKU2_GET_1F80(thisx) (((thisx)->params >> 7) & 0x3F) +#define ENDAIKU2_GET_8000(thisx) (((thisx)->params >> 15) & 0x1) enum { /* -1 */ ENDAIKU2_GET_7F_MINUS1 = -1, diff --git a/src/overlays/actors/ovl_En_Death/z_en_death.c b/src/overlays/actors/ovl_En_Death/z_en_death.c index dd05c2d48..de02f44ad 100644 --- a/src/overlays/actors/ovl_En_Death/z_en_death.c +++ b/src/overlays/actors/ovl_En_Death/z_en_death.c @@ -7,7 +7,7 @@ #include "z_en_death.h" #include "z64rumble.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_1000) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_IGNORE_QUAKE) #define THIS ((EnDeath*)thisx) diff --git a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c index 93d495267..e969abffa 100644 --- a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c +++ b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c @@ -5,6 +5,8 @@ */ #include "z_en_dekubaba.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) @@ -15,23 +17,31 @@ void EnDekubaba_Destroy(Actor* thisx, PlayState* play); void EnDekubaba_Update(Actor* thisx, PlayState* play); void EnDekubaba_Draw(Actor* thisx, PlayState* play); -void func_808B1B14(EnDekubaba* this, PlayState* play); -void func_808B1CF0(EnDekubaba* this, PlayState* play); -void func_808B2240(EnDekubaba* this, PlayState* play); -void func_808B2660(EnDekubaba* this, PlayState* play); -void func_808B28B4(EnDekubaba* this, PlayState* play); -void func_808B29C4(EnDekubaba* this, PlayState* play); -void func_808B2CB8(EnDekubaba* this, PlayState* play); -void func_808B3078(EnDekubaba* this, PlayState* play); -void func_808B3280(EnDekubaba* this, PlayState* play); -void func_808B3404(EnDekubaba* this, PlayState* play); -void func_808B37E8(EnDekubaba* this, PlayState* play); -void func_808B3B48(EnDekubaba* this, PlayState* play); -void func_808B3C50(EnDekubaba* this, PlayState* play); -void func_808B3DA8(EnDekubaba* this, PlayState* play); -void func_808B3EE8(EnDekubaba* this, PlayState* play); +void EnDekubaba_SetupWait(EnDekubaba* this); +void EnDekubaba_Wait(EnDekubaba* this, PlayState* play); +void EnDekubaba_SetupGrow(EnDekubaba* this); +void EnDekubaba_Grow(EnDekubaba* this, PlayState* play); +void EnDekubaba_SetupRetract(EnDekubaba* this); +void EnDekubaba_Retract(EnDekubaba* this, PlayState* play); +void EnDekubaba_DecideLunge(EnDekubaba* this, PlayState* play); +void EnDekubaba_SetupPrepareLunge(EnDekubaba* this); +void EnDekubaba_PrepareLunge(EnDekubaba* this, PlayState* play); +void EnDekubaba_SetupLunge(EnDekubaba* this); +void EnDekubaba_Lunge(EnDekubaba* this, PlayState* play); +void EnDekubaba_SetupPullBack(EnDekubaba* this); +void EnDekubaba_PullBack(EnDekubaba* this, PlayState* play); +void EnDekubaba_Recover(EnDekubaba* this, PlayState* play); +void EnDekubaba_Hit(EnDekubaba* this, PlayState* play); +void EnDekubaba_PrunedSomersaultDie(EnDekubaba* this, PlayState* play); +void EnDekubaba_SetupShrinkDie(EnDekubaba* this); +void EnDekubaba_ShrinkDie(EnDekubaba* this, PlayState* play); +void EnDekubaba_SetupStunnedVertical(EnDekubaba* this); +void EnDekubaba_StunnedVertical(EnDekubaba* this, PlayState* play); +void EnDekubaba_Sway(EnDekubaba* this, PlayState* play); +void EnDekubaba_Frozen(EnDekubaba* this, PlayState* play); +void EnDekubaba_SetupDeadStickDrop(EnDekubaba* this, PlayState* play); +void EnDekubaba_DeadStickDrop(EnDekubaba* this, PlayState* play); -#if 0 ActorInit En_Dekubaba_InitVars = { ACTOR_EN_DEKUBABA, ACTORCAT_ENEMY, @@ -44,188 +54,1334 @@ ActorInit En_Dekubaba_InitVars = { (ActorFunc)EnDekubaba_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[7] = { -static ColliderJntSphElementInit D_808B4D60[7] = { +static ColliderJntSphElementInit sJntSphElementsInit[7] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 1, { { 0, 100, 1000 }, 15 }, 100 }, }, { - { 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, + }, { 51, { { 0, 0, 1500 }, 8 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 52, { { 0, 0, 500 }, 8 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 53, { { 0, 0, 1500 }, 8 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 54, { { 0, 0, 500 }, 8 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 55, { { 0, 0, 1500 }, 8 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 56, { { 0, 0, 500 }, 8 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808B4E5C = { - { COLTYPE_HIT6, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - ARRAY_COUNT(sJntSphElementsInit), D_808B4D60, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808B4E6C = { 2, 25, 25, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 25, 25, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_808B4E74 = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(3, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0xF), - /* Normal arrow */ DMG_ENTRY(3, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xD), - /* Goron punch */ DMG_ENTRY(2, 0x0), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(4, 0x0), - /* Fire arrow */ DMG_ENTRY(1, 0x2), - /* Ice arrow */ DMG_ENTRY(3, 0x3), - /* Light arrow */ DMG_ENTRY(3, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0xF), - /* Deku bubble */ DMG_ENTRY(3, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0xF), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ DEKUBABA_DMGEFF_NONE, + /* 0x1 */ DEKUBABA_DMGEFF_NUT, + /* 0x2 */ DEKUBABA_DMGEFF_FIRE, + /* 0x3 */ DEKUBABA_DMGEFF_ICE, + /* 0x4 */ DEKUBABA_DMGEFF_LIGHT, + /* 0x5 */ DEKUBABA_DMGEFF_ELECTRIC, + /* 0xD */ DEKUBABA_DMGEFF_HOOKSHOT = 0xD, + /* 0xF */ DEKUBABA_DMGEFF_CUT = 0xF +} DekuBabaDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NUT), + /* Deku Stick */ DMG_ENTRY(3, DEKUBABA_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, DEKUBABA_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, DEKUBABA_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, DEKUBABA_DMGEFF_CUT), + /* Normal arrow */ DMG_ENTRY(3, DEKUBABA_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, DEKUBABA_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, DEKUBABA_DMGEFF_CUT), + /* Goron pound */ DMG_ENTRY(4, DEKUBABA_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(1, DEKUBABA_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(3, DEKUBABA_DMGEFF_ICE), + /* Light arrow */ DMG_ENTRY(3, DEKUBABA_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, DEKUBABA_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, DEKUBABA_DMGEFF_CUT), + /* Deku bubble */ DMG_ENTRY(3, DEKUBABA_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, DEKUBABA_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NUT), + /* Zora barrier */ DMG_ENTRY(0, DEKUBABA_DMGEFF_ELECTRIC), + /* Normal shield */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, DEKUBABA_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, DEKUBABA_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, DEKUBABA_DMGEFF_CUT), + /* Sword beam */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, DEKUBABA_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, DEKUBABA_DMGEFF_NONE), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808B4E94[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 1500, ICHAIN_STOP), }; -#endif +void EnDekubaba_Init(Actor* thisx, PlayState* play) { + EnDekubaba* this = THIS; + s32 i; -extern ColliderJntSphElementInit D_808B4D60[7]; -extern ColliderJntSphInit D_808B4E5C; -extern CollisionCheckInfoInit D_808B4E6C; -extern DamageTable D_808B4E74; -extern InitChainEntry D_808B4E94[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 22.0f); + SkelAnime_Init(play, &this->skelAnime, &gDekuBabaSkel, &gDekuBabaFastChompAnim, this->jointTable, this->morphTable, + DEKUBABA_LIMB_MAX); + Collider_InitAndSetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -extern UNK_TYPE D_06000208; -extern UNK_TYPE D_060002B8; -extern UNK_TYPE D_060010F0; -extern UNK_TYPE D_06001330; -extern UNK_TYPE D_06001828; + if (this->actor.params == DEKUBABA_BIG) { + this->size = 2.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/EnDekubaba_Init.s") + for (i = 0; i < sJntSphInit.count; i++) { + this->collider.elements[i].dim.worldSphere.radius = this->collider.elements[i].dim.modelSphere.radius = + (sJntSphElementsInit[i].dim.modelSphere.radius * 2.50f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/EnDekubaba_Destroy.s") + this->actor.colChkInfo.health = 4; + // Big Deku Baba hint does not exist in MM + this->actor.hintId = TATL_HINT_ID_BIO_DEKU_BABA; + this->actor.targetMode = 2; + } else { + this->size = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B1530.s") + for (i = 0; i < sJntSphInit.count; i++) { + this->collider.elements[i].dim.worldSphere.radius = this->collider.elements[i].dim.modelSphere.radius; + } + this->actor.hintId = TATL_HINT_ID_DEKU_BABA; + this->actor.targetMode = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B15B8.s") + EnDekubaba_SetupWait(this); + this->timer = 0; + this->boundFloor = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B16BC.s") +void EnDekubaba_Destroy(Actor* thisx, PlayState* play) { + EnDekubaba* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B1798.s") + Collider_DestroyJntSph(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B1814.s") +void EnDekubaba_DisableHitboxes(EnDekubaba* this) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B18A8.s") + for (i = 1; i < ARRAY_COUNT(this->colliderElements); i++) { + this->collider.elements[i].info.bumperFlags &= ~BUMP_ON; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B1B14.s") +void EnDekubaba_UpdateHeadPosition(EnDekubaba* this) { + f32 horizontalHeadShift = (Math_CosS(this->stemSectionAngle[0]) + Math_CosS(this->stemSectionAngle[1]) + + Math_CosS(this->stemSectionAngle[2])) * + 20.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B1BC0.s") + this->actor.world.pos.x = + this->actor.home.pos.x + Math_SinS(this->actor.shape.rot.y) * (horizontalHeadShift * this->size); + this->actor.world.pos.y = + this->actor.home.pos.y - (Math_SinS(this->stemSectionAngle[0]) + Math_SinS(this->stemSectionAngle[1]) + + Math_SinS(this->stemSectionAngle[2])) * + 20.0f * this->size; + this->actor.world.pos.z = + this->actor.home.pos.z + Math_CosS(this->actor.shape.rot.y) * (horizontalHeadShift * this->size); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B1CF0.s") +void EnDekubaba_SetFireLightEffects(EnDekubaba* this, PlayState* play, s32 index) { + ColliderJntSphElement* sphElement; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B2158.s") + if (this->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_FIRE) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; + } else if (this->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_LIGHT) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; + sphElement = &this->collider.elements[index]; + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, sphElement->info.bumper.hitPos.x, + sphElement->info.bumper.hitPos.y, sphElement->info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_SMALL_LIGHT_RAYS); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B2240.s") +void EnDekubaba_SetFrozenEffects(EnDekubaba* this) { + this->drawDmgEffScale = 0.75f; + this->drawDmgEffFrozenSteamScale = 1.125f; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->collider.base.colType = COLTYPE_HIT3; + this->timer = 80; + this->actor.flags &= ~ACTOR_FLAG_400; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B2608.s") +void EnDekubaba_SpawnIceEffects(EnDekubaba* this, PlayState* play) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->collider.base.colType = COLTYPE_HIT6; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 4, + this->size * 0.3f, this->size * 0.2f); + this->actor.flags |= ACTOR_FLAG_400; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B2660.s") +void EnDekubaba_SetupWait(EnDekubaba* this) { + s32 i; + ColliderJntSphElement* element; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B2890.s") + this->actor.shape.rot.x = -0x4000; + this->stemSectionAngle[0] = this->stemSectionAngle[1] = this->stemSectionAngle[2] = this->actor.shape.rot.x; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B28B4.s") + this->actor.world.pos.x = this->actor.home.pos.x; + this->actor.world.pos.z = this->actor.home.pos.z; + this->actor.world.pos.y = this->actor.home.pos.y + 14.0f * this->size; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B2980.s") + Actor_SetScale(&this->actor, this->size * 0.01f * 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B29C4.s") + this->collider.base.colType = COLTYPE_HARD; + this->collider.base.acFlags |= AC_HARD; + this->timer = 45; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B2C40.s") + for (i = 1; i < ARRAY_COUNT(this->colliderElements); i++) { + element = &this->collider.elements[i]; + element->dim.worldSphere.center.x = this->actor.world.pos.x; + element->dim.worldSphere.center.y = (s32)this->actor.world.pos.y - 7; + element->dim.worldSphere.center.z = this->actor.world.pos.z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B2CB8.s") + this->actionFunc = EnDekubaba_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B3044.s") +void EnDekubaba_Wait(EnDekubaba* this, PlayState* play) { + if (this->timer != 0) { + this->timer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B3078.s") + this->actor.world.pos.x = this->actor.home.pos.x; + this->actor.world.pos.z = this->actor.home.pos.z; + this->actor.world.pos.y = this->actor.home.pos.y + 14.0f * this->size; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B3170.s") + if ((this->timer == 0) && (this->actor.xzDistToPlayer < 200.0f * this->size) && + (fabsf(this->actor.playerHeightRel) < 30.0f * this->size)) { + EnDekubaba_SetupGrow(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B3280.s") +void EnDekubaba_SetupGrow(EnDekubaba* this) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B3390.s") + Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, + Animation_GetLastFrame(&gDekuBabaFastChompAnim) * (1.0f / 15), 0.0f, + Animation_GetLastFrame(&gDekuBabaFastChompAnim), ANIMMODE_ONCE, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B3404.s") + this->timer = 15; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B3768.s") + for (i = 2; i < ARRAY_COUNT(this->colliderElements); i++) { + this->collider.elements[i].info.ocElemFlags |= OCELEM_ON; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B37E8.s") + this->collider.base.colType = COLTYPE_HIT6; + this->collider.base.acFlags &= ~AC_HARD; + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKU_WAKEUP); + this->actionFunc = EnDekubaba_Grow; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B39AC.s") +void EnDekubaba_Grow(EnDekubaba* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 headDistHorizontal; + f32 headDistVertical; + f32 headShiftX; + f32 headShiftZ; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B3B48.s") + if (this->timer != 0) { + this->timer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B3BE4.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B3C50.s") + this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = + this->size * 0.01f * (0.5f + (15 - this->timer) * 0.5f / 15.0f); + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x1800, 0x800); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B3D74.s") + headDistVertical = sin_rad(CLAMP_MAX((15 - this->timer) * (1.0f / 15), 0.7f) * M_PI) * 32.0f + 14.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B3DA8.s") + if (this->actor.shape.rot.x < -0x38E3) { + headDistHorizontal = 0.0f; + } else if (this->actor.shape.rot.x < -0x238E) { + Math_ScaledStepToS(&this->stemSectionAngle[0], -0x5555, 0x38E); + headDistHorizontal = Math_CosS(this->stemSectionAngle[0]) * 20.0f; + } else if (this->actor.shape.rot.x < -0xE38) { + Math_ScaledStepToS(&this->stemSectionAngle[0], -0xAAA, 0x38E); + Math_ScaledStepToS(&this->stemSectionAngle[1], -0x5555, 0x38E); + Math_ScaledStepToS(&this->stemSectionAngle[2], -0x5555, 0x222); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B3E40.s") + headDistHorizontal = 20.0f * (Math_CosS(this->stemSectionAngle[0]) + Math_CosS(this->stemSectionAngle[1])) + + (headDistVertical - + 20.0f * (-Math_SinS(this->stemSectionAngle[0]) - Math_SinS(this->stemSectionAngle[1]))) * + Math_CosS(this->stemSectionAngle[2]) / -Math_SinS(this->stemSectionAngle[2]); + } else { + Math_ScaledStepToS(&this->stemSectionAngle[0], -0xAAA, 0x38E); + Math_ScaledStepToS(&this->stemSectionAngle[1], -0x31C7, 0x222); + Math_ScaledStepToS(&this->stemSectionAngle[2], -0x5555, 0x222); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B3EE8.s") + headDistHorizontal = 20.0f * (Math_CosS(this->stemSectionAngle[0]) + Math_CosS(this->stemSectionAngle[1])) + + (headDistVertical - + 20.0f * (-Math_SinS(this->stemSectionAngle[0]) - Math_SinS(this->stemSectionAngle[1]))) * + Math_CosS(this->stemSectionAngle[2]) / -Math_SinS(this->stemSectionAngle[2]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B3F50.s") + if (this->timer < 10) { + Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos), 2, + 0xE38); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/EnDekubaba_Update.s") + this->actor.world.pos.y = this->actor.home.pos.y + (headDistVertical * this->size); + //! FAKE: + headShiftX = headDistHorizontal; + headShiftX = headShiftX * this->size * Math_SinS(this->actor.shape.rot.y); + headShiftZ = headDistHorizontal; + headShiftZ = headShiftZ * this->size * Math_CosS(this->actor.shape.rot.y); + this->actor.world.pos.x = this->actor.home.pos.x + headShiftX; + this->actor.world.pos.z = this->actor.home.pos.z + headShiftZ; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B4548.s") + EffectSsHahen_SpawnBurst(play, &this->actor.home.pos, this->size * 3.0f, 0, this->size * 12.0f, this->size * 5.0f, + 1, HAHEN_OBJECT_DEFAULT, 10, NULL); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B465C.s") + if (this->timer == 0) { + if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 240.0f * this->size) { + EnDekubaba_SetupPrepareLunge(this); + } else { + EnDekubaba_SetupRetract(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B48FC.s") +void EnDekubaba_SetupRetract(EnDekubaba* this) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B49C8.s") + Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, -1.5f, Animation_GetLastFrame(&gDekuBabaFastChompAnim), + 0.0f, ANIMMODE_ONCE, -3.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/func_808B4ABC.s") + this->timer = 15; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dekubaba/EnDekubaba_Draw.s") + for (i = 2; i < ARRAY_COUNT(this->colliderElements); i++) { + this->collider.elements[i].info.ocElemFlags &= ~OCELEM_ON; + } + + this->actionFunc = EnDekubaba_Retract; +} + +void EnDekubaba_Retract(EnDekubaba* this, PlayState* play) { + f32 headDistHorizontal; + f32 headDistVertical; + f32 xShift; + f32 zShift; + + if (this->timer != 0) { + this->timer--; + } + + SkelAnime_Update(&this->skelAnime); + + this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = + this->size * 0.01f * (0.5f + this->timer * (1.0f / 30)); + Math_ScaledStepToS(&this->actor.shape.rot.x, -0x4000, 0x300); + + headDistVertical = (sin_rad(CLAMP_MAX(this->timer * 0.033f, 0.7f) * M_PI) * 32.0f) + 14.0f; + + if (this->actor.shape.rot.x < -0x38E3) { + headDistHorizontal = 0.0f; + } else if (this->actor.shape.rot.x < -0x238E) { + Math_ScaledStepToS(&this->stemSectionAngle[0], -0x4000, 0x555); + headDistHorizontal = Math_CosS(this->stemSectionAngle[0]) * 20.0f; + } else if (this->actor.shape.rot.x < -0xE38) { + Math_ScaledStepToS(&this->stemSectionAngle[0], -0x5555, 0x555); + Math_ScaledStepToS(&this->stemSectionAngle[1], -0x4000, 0x555); + Math_ScaledStepToS(&this->stemSectionAngle[2], -0x4000, 0x333); + + headDistHorizontal = 20.0f * (Math_CosS(this->stemSectionAngle[0]) + Math_CosS(this->stemSectionAngle[1])) + + (headDistVertical - + 20.0f * (-Math_SinS(this->stemSectionAngle[0]) - Math_SinS(this->stemSectionAngle[1]))) * + Math_CosS(this->stemSectionAngle[2]) / -Math_SinS(this->stemSectionAngle[2]); + } else { + Math_ScaledStepToS(&this->stemSectionAngle[0], -0x5555, 0x555); + Math_ScaledStepToS(&this->stemSectionAngle[1], -0x5555, 0x333); + Math_ScaledStepToS(&this->stemSectionAngle[2], -0x4000, 0x333); + + headDistHorizontal = 20.0f * (Math_CosS(this->stemSectionAngle[0]) + Math_CosS(this->stemSectionAngle[1])) + + (headDistVertical - + 20.0f * (-Math_SinS(this->stemSectionAngle[0]) - Math_SinS(this->stemSectionAngle[1]))) * + Math_CosS(this->stemSectionAngle[2]) / -Math_SinS(this->stemSectionAngle[2]); + } + + this->actor.world.pos.y = this->actor.home.pos.y + (headDistVertical * this->size); + xShift = headDistHorizontal * this->size * Math_SinS(this->actor.shape.rot.y); + zShift = headDistHorizontal * this->size * Math_CosS(this->actor.shape.rot.y); + this->actor.world.pos.x = this->actor.home.pos.x + xShift; + this->actor.world.pos.z = this->actor.home.pos.z + zShift; + + EffectSsHahen_SpawnBurst(play, &this->actor.home.pos, this->size * 3.0f, 0, this->size * 12.0f, this->size * 5.0f, + 1, HAHEN_OBJECT_DEFAULT, 10, NULL); + if (this->timer == 0) { + EnDekubaba_SetupWait(this); + } +} + +void EnDekubaba_SetupDecideLunge(EnDekubaba* this) { + this->timer = Animation_GetLastFrame(&gDekuBabaFastChompAnim) * 2; + Animation_MorphToLoop(&this->skelAnime, &gDekuBabaFastChompAnim, -3.0f); + this->actionFunc = EnDekubaba_DecideLunge; +} + +void EnDekubaba_DecideLunge(EnDekubaba* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f)) { + if (this->actor.params == DEKUBABA_BIG) { + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKU_MOUTH); + } else { + Actor_PlaySfx(&this->actor, NA_SE_EN_MIZUBABA1_MOUTH); + } + } + + if (this->timer != 0) { + this->timer--; + } + + Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos), 2, + (this->timer % 5) * 0x222); + + if (this->timer < 10) { + this->stemSectionAngle[0] += 0x16C; + this->stemSectionAngle[1] += 0x16C; + this->stemSectionAngle[2] += 0xB6; + this->actor.shape.rot.x += 0x222; + } else if (this->timer < 20) { + this->stemSectionAngle[0] -= 0x16C; + this->stemSectionAngle[1] += 0x111; + this->actor.shape.rot.x += 0x16C; + } else if (this->timer < 30) { + this->stemSectionAngle[1] -= 0x111; + this->actor.shape.rot.x -= 0xB6; + } else { + this->stemSectionAngle[1] -= 0xB6; + this->stemSectionAngle[2] += 0xB6; + this->actor.shape.rot.x -= 0x16C; + } + + EnDekubaba_UpdateHeadPosition(this); + + if ((240.0f * this->size) < Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos)) { + EnDekubaba_SetupRetract(this); + } else if ((this->timer == 0) || (this->actor.xzDistToPlayer < (80.0f * this->size))) { + EnDekubaba_SetupPrepareLunge(this); + } +} + +void EnDekubaba_SetupPrepareLunge(EnDekubaba* this) { + this->timer = 8; + this->skelAnime.playSpeed = 0.0f; + this->actionFunc = EnDekubaba_PrepareLunge; +} + +void EnDekubaba_PrepareLunge(EnDekubaba* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (this->timer != 0) { + this->timer--; + } + + Math_SmoothStepToS(&this->actor.shape.rot.x, 0x1800, 2, 0xE38, 0x71C); + Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos), 2, 0xE38); + Math_ScaledStepToS(this->stemSectionAngle, 0xAAA, 0x444); + Math_ScaledStepToS(&this->stemSectionAngle[1], -0x4718, 0x888); + Math_ScaledStepToS(&this->stemSectionAngle[2], -0x6AA4, 0x888); + + if (this->timer == 0) { + EnDekubaba_SetupLunge(this); + } + + EnDekubaba_UpdateHeadPosition(this); +} + +void EnDekubaba_SetupLunge(EnDekubaba* this) { + Animation_PlayOnce(&this->skelAnime, &gDekuBabaPauseChompAnim); + this->timer = 0; + this->actionFunc = EnDekubaba_Lunge; +} + +void EnDekubaba_Lunge(EnDekubaba* this, PlayState* play) { + static Color_RGBA8 sDustPrimColor = { 105, 255, 105, 255 }; + static Color_RGBA8 sDustEnvColor = { 150, 250, 150, 0 }; + s32 allStepsDone; + s16 curFrame10; + Vec3f velocity; + + SkelAnime_Update(&this->skelAnime); + + if (this->timer == 0) { + if (Animation_OnFrame(&this->skelAnime, 1.0f)) { + if (this->actor.params == DEKUBABA_BIG) { + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKU_ATTACK); + } else { + Actor_PlaySfx(&this->actor, NA_SE_EN_MIZUBABA1_ATTACK); + } + } + + Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x222); + + curFrame10 = (s32)(this->skelAnime.curFrame * 10.0f); + + allStepsDone = true; + allStepsDone &= Math_ScaledStepToS(&this->stemSectionAngle[0], -0xE38, curFrame10 + 0x38E); + allStepsDone &= Math_ScaledStepToS(&this->stemSectionAngle[1], -0xE38, curFrame10 + 0x71C); + allStepsDone &= Math_ScaledStepToS(&this->stemSectionAngle[2], -0xE38, curFrame10 + 0xE38); + if (allStepsDone) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &gDekuBabaFastChompAnim, 4.0f); + velocity.x = Math_SinS(this->actor.shape.rot.y) * 5.0f; + velocity.y = 0.0f; + velocity.z = Math_CosS(this->actor.shape.rot.y) * 5.0f; + func_800B0DE0(play, &this->actor.world.pos, &velocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 1, + (s32)(this->size * 100.0f)); + this->timer = 1; + } + } else if (this->timer > 10) { + EnDekubaba_SetupPullBack(this); + } else { + this->timer++; + + if ((this->timer >= 4) && !Actor_IsFacingPlayer(&this->actor, 0x16C)) { + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xF, 0x71C); + } + + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f)) { + if (this->actor.params == DEKUBABA_BIG) { + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKU_MOUTH); + } else { + Actor_PlaySfx(&this->actor, NA_SE_EN_MIZUBABA1_MOUTH); + } + } + } + + EnDekubaba_UpdateHeadPosition(this); +} + +void EnDekubaba_SetupPullBack(EnDekubaba* this) { + Animation_Change(&this->skelAnime, &gDekuBabaPauseChompAnim, 1.0f, 15.0f, + Animation_GetLastFrame(&gDekuBabaPauseChompAnim), ANIMMODE_ONCE, -3.0f); + this->timer = 0; + this->actionFunc = EnDekubaba_PullBack; +} + +void EnDekubaba_PullBack(EnDekubaba* this, PlayState* play) { + Vec3f dustPos; + f32 xIncr; + f32 zIncr; + s32 i; + + SkelAnime_Update(&this->skelAnime); + + if (this->timer == 0) { + Math_ScaledStepToS(&this->actor.shape.rot.x, -0x93E, 0x38E); + Math_ScaledStepToS(&this->stemSectionAngle[0], -0x888, 0x16C); + Math_ScaledStepToS(&this->stemSectionAngle[1], -0x888, 0x16C); + + if (Math_ScaledStepToS(&this->stemSectionAngle[2], -0x888, 0x16C)) { + xIncr = Math_SinS(this->actor.shape.rot.y) * 30.0f * this->size; + zIncr = Math_CosS(this->actor.shape.rot.y) * 30.0f * this->size; + dustPos = this->actor.home.pos; + + for (i = 0; i < 3; i++) { + func_800B1210(play, &dustPos, &gZeroVec3f, &gZeroVec3f, (s32)(this->size * 500.0f), + (s32)(this->size * 50.0f)); + dustPos.x += xIncr; + dustPos.z += zIncr; + } + + this->timer = 1; + } + } else if (this->timer == 11) { + Math_ScaledStepToS(&this->actor.shape.rot.x, -0x93E, 0x200); + Math_ScaledStepToS(this->stemSectionAngle, -0xAAA, 0x200); + Math_ScaledStepToS(&this->stemSectionAngle[2], -0x5C71, 0x200); + + if (Math_ScaledStepToS(&this->stemSectionAngle[1], 0x238C, 0x200)) { + this->timer = 12; + } + } else if (this->timer == 18) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x2AA8, 0xAAA); + + if (Math_ScaledStepToS(&this->stemSectionAngle[0], 0x1554, 0x5B0)) { + this->timer = 25; + } + + Math_ScaledStepToS(&this->stemSectionAngle[1], -0x38E3, 0xAAA); + Math_ScaledStepToS(&this->stemSectionAngle[2], -0x5C71, 0x2D8); + } else if (this->timer == 25) { + Math_ScaledStepToS(&this->actor.shape.rot.x, -0x5550, 0xAAA); + + if (Math_ScaledStepToS(&this->stemSectionAngle[0], -0x6388, 0x93E)) { + this->timer = 26; + } + + Math_ScaledStepToS(&this->stemSectionAngle[1], -0x3FFC, 0x4FA); + Math_ScaledStepToS(&this->stemSectionAngle[2], -0x238C, 0x444); + } else if (this->timer == 26) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x1800, 0x93E); + + if (Math_ScaledStepToS(&this->stemSectionAngle[0], -0x1555, 0x71C)) { + this->timer = 27; + } + + Math_ScaledStepToS(&this->stemSectionAngle[1], -0x38E3, 0x2D8); + Math_ScaledStepToS(&this->stemSectionAngle[2], -0x5C71, 0x5B0); + } else if (this->timer >= 27) { + this->timer++; + if (this->timer > 30) { + if (this->actor.xzDistToPlayer < (80.0f * this->size)) { + EnDekubaba_SetupPrepareLunge(this); + } else { + EnDekubaba_SetupDecideLunge(this); + } + } + } else { + this->timer++; + if (this->timer == 10) { + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKU_SCRAPE); + } + + if (this->timer >= 12) { + Math_ScaledStepToS(&this->stemSectionAngle[2], -0x5C71, 0x88); + } + } + + EnDekubaba_UpdateHeadPosition(this); +} + +void EnDekubaba_SetupRecover(EnDekubaba* this) { + this->timer = 9; + this->collider.base.acFlags |= AC_ON; + this->skelAnime.playSpeed = -1.0f; + this->actionFunc = EnDekubaba_Recover; +} + +void EnDekubaba_Recover(EnDekubaba* this, PlayState* play) { + s32 anyStepsDone; + + SkelAnime_Update(&this->skelAnime); + + if (this->timer > 8) { + anyStepsDone = Math_SmoothStepToS(&this->actor.shape.rot.x, 0x1800, 1, 0x11C6, 0x71C); + anyStepsDone |= Math_SmoothStepToS(&this->stemSectionAngle[0], -0x1555, 1, 0xAAA, 0x71C); + anyStepsDone |= Math_SmoothStepToS(&this->stemSectionAngle[1], -0x38E3, 1, 0xE38, 0x71C); + anyStepsDone |= Math_SmoothStepToS(&this->stemSectionAngle[2], -0x5C71, 1, 0x11C6, 0x71C); + if (!anyStepsDone) { + this->timer = 8; + } + } else { + if (this->timer != 0) { + this->timer--; + } + + if (this->timer == 0) { + EnDekubaba_SetupDecideLunge(this); + } + } + + EnDekubaba_UpdateHeadPosition(this); +} + +typedef enum { + /* 0 */ DEKUBABA_HIT_NO_STUN, + /* 1 */ DEKUBABA_HIT_STUN_OTHER, + /* 2 */ DEKUBABA_HIT_STUN_NUT, + /* 3 */ DEKUBABA_HIT_STUN_ELECTRIC +} DekuBabaHitType; + +void EnDekubaba_SetupHit(EnDekubaba* this, s32 hitType) { + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuBabaPauseChompAnim, -5.0f); + this->timer = hitType; + this->collider.base.acFlags &= ~AC_ON; + Actor_SetScale(&this->actor, this->size * 0.01f); + + if (hitType == DEKUBABA_HIT_STUN_NUT) { + Actor_SetColorFilter(&this->actor, 0, 155, 0, 42); + } else if (hitType == DEKUBABA_HIT_STUN_ELECTRIC) { + Actor_SetColorFilter(&this->actor, 0, 155, 0, 42); + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 2.0f; + } else { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 42); + } + this->actionFunc = EnDekubaba_Hit; +} + +/** + * Hit by a weapon or hit something when lunging. + */ +void EnDekubaba_Hit(EnDekubaba* this, PlayState* play) { + s32 allStepsDone; + + SkelAnime_Update(&this->skelAnime); + allStepsDone = true; + allStepsDone &= Math_ScaledStepToS(&this->actor.shape.rot.x, -0x4000, 0xE38); + allStepsDone &= Math_ScaledStepToS(this->stemSectionAngle, -0x4000, 0xE38); + allStepsDone &= Math_ScaledStepToS(&this->stemSectionAngle[1], -0x4000, 0xE38); + allStepsDone &= Math_ScaledStepToS(&this->stemSectionAngle[2], -0x4000, 0xE38); + if (allStepsDone) { + if (this->actor.colChkInfo.health == 0) { + EnDekubaba_SetupShrinkDie(this); + } else { + this->collider.base.acFlags |= AC_ON; + + if (this->timer == DEKUBABA_HIT_NO_STUN) { + if (this->actor.xzDistToPlayer < (80.0f * this->size)) { + EnDekubaba_SetupPrepareLunge(this); + } else { + EnDekubaba_SetupRecover(this); + } + } else { + EnDekubaba_SetupStunnedVertical(this); + } + } + } + + EnDekubaba_UpdateHeadPosition(this); +} + +void EnDekubaba_SetupPrunedSomersaultDie(EnDekubaba* this) { + this->timer = 0; + this->skelAnime.playSpeed = 0.0f; + this->actor.gravity = -0.8f; + this->actor.velocity.y = 4.0f; + this->actor.world.rot.y = this->actor.shape.rot.y + 0x8000; + this->actor.speed = this->size * 3.0f; + this->collider.base.acFlags &= ~AC_ON; + this->actor.flags |= ACTOR_FLAG_10 | ACTOR_FLAG_20; + this->actionFunc = EnDekubaba_PrunedSomersaultDie; +} + +void EnDekubaba_PrunedSomersaultDie(EnDekubaba* this, PlayState* play) { + s32 i; + Vec3f dustPos; + f32 deltaX; + f32 deltaY; + f32 deltaZ; + + Math_StepToF(&this->actor.speed, 0.0f, this->size * 0.1f); + + if (this->timer == 0) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4800, 0x71C); + Math_ScaledStepToS(this->stemSectionAngle, 0x4800, 0x71C); + Math_ScaledStepToS(&this->stemSectionAngle[1], 0x4800, 0x71C); + + EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, this->size * 3.0f, 0, (s32)(this->size * 12.0f), + (s32)(this->size * 5.0f), 1, HAHEN_OBJECT_DEFAULT, 10, NULL); + + if ((this->actor.scale.x > 0.005f) && + ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) || (this->actor.bgCheckFlags & BGCHECKFLAG_WALL))) { + this->actor.scale.z = 0.0f; + this->actor.scale.y = 0.0f; + this->actor.scale.x = 0.0f; + this->actor.speed = 0.0f; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, this->size * 3.0f, 0, (s32)(this->size * 12.0f), + (s32)(this->size * 5.0f), 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + } + + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + this->timer = 1; + } + } else if (this->timer == 1) { + dustPos = this->actor.world.pos; + + deltaY = 20.0f * Math_SinS(this->actor.shape.rot.x); + deltaX = -20.0f * Math_CosS(this->actor.shape.rot.x) * Math_SinS(this->actor.shape.rot.y); + deltaZ = -20.0f * Math_CosS(this->actor.shape.rot.x) * Math_CosS(this->actor.shape.rot.y); + + for (i = 0; i < 4; i++) { + func_800B1210(play, &dustPos, &gZeroVec3f, &gZeroVec3f, 500, 50); + dustPos.x += deltaX; + dustPos.y += deltaY; + dustPos.z += deltaZ; + } + + func_800B1210(play, &this->actor.home.pos, &gZeroVec3f, &gZeroVec3f, (s32)(this->size * 500.0f), + (s32)(this->size * 100.0f)); + EnDekubaba_SetupDeadStickDrop(this, play); + } +} + +void EnDekubaba_SetupShrinkDie(EnDekubaba* this) { + Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, -1.5f, Animation_GetLastFrame(&gDekuBabaFastChompAnim), + 0.0f, ANIMMODE_ONCE, -3.0f); + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = EnDekubaba_ShrinkDie; +} + +/** + * Die and drop Deku Nuts (Deku Stick drop is handled elsewhere). + */ +void EnDekubaba_ShrinkDie(EnDekubaba* this, PlayState* play) { + Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, this->size * 5.0f); + + if (Math_StepToF(&this->actor.scale.x, this->size * 0.1f * 0.01f, this->size * 0.1f * 0.01f)) { + func_800B1210(play, &this->actor.home.pos, &gZeroVec3f, &gZeroVec3f, (s32)(this->size * 500.0f), + (s32)(this->size * 100.0f)); + + if (!this->actor.dropFlag) { + Item_DropCollectible(play, &this->actor.world.pos, ITEM00_NUTS_1); + if (this->actor.params == DEKUBABA_BIG) { + Item_DropCollectible(play, &this->actor.world.pos, ITEM00_NUTS_1); + Item_DropCollectible(play, &this->actor.world.pos, ITEM00_NUTS_1); + } + } else { + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x30); + } + Actor_Kill(&this->actor); + } + + this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; + this->actor.shape.rot.z += 0x1C70; + EffectSsHahen_SpawnBurst(play, &this->actor.home.pos, this->size * 3.0f, 0, (s32)(this->size * 12.0f), + (s32)(this->size * 5.0f), 1, HAHEN_OBJECT_DEFAULT, 10, NULL); +} + +void EnDekubaba_SetupStunnedVertical(EnDekubaba* this) { + s32 i; + + for (i = 1; i < ARRAY_COUNT(this->colliderElements); i++) { + this->collider.elements[i].info.bumperFlags |= BUMP_ON; + } + + if (this->timer == 1) { + Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, 4.0f, 0.0f, + Animation_GetLastFrame(&gDekuBabaFastChompAnim), ANIMMODE_LOOP, -3.0f); + this->timer = 0x28; + } else { + Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, 0.0f, 0.0f, + Animation_GetLastFrame(&gDekuBabaFastChompAnim), ANIMMODE_LOOP, -3.0f); + if (this->timer == 2) { + this->timer = 40; + } else { + this->timer = 40; + } + } + + this->actor.world.pos.x = this->actor.home.pos.x; + this->actor.world.pos.y = this->actor.home.pos.y + (60.0f * this->size); + this->actor.world.pos.z = this->actor.home.pos.z; + this->actionFunc = EnDekubaba_StunnedVertical; +} + +void EnDekubaba_StunnedVertical(EnDekubaba* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + + if (this->timer != 0) { + this->timer--; + } + + if (this->timer == 0) { + EnDekubaba_DisableHitboxes(this); + + if (this->actor.xzDistToPlayer < (80.0f * this->size)) { + EnDekubaba_SetupPrepareLunge(this); + } else { + EnDekubaba_SetupRecover(this); + } + } +} + +void EnDekubaba_SetupSway(EnDekubaba* this) { + this->targetSwayAngle = -0x6000; + this->stemSectionAngle[2] = -0x5000; + this->stemSectionAngle[1] = -0x4800; + EnDekubaba_DisableHitboxes(this); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 35); + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = EnDekubaba_Sway; +} + +/** + * Sway back and forth with decaying amplitude until close enough to vertical. + */ +void EnDekubaba_Sway(EnDekubaba* this, PlayState* play) { + s16 angleToVertical; + + SkelAnime_Update(&this->skelAnime); + Math_ScaledStepToS(&this->actor.shape.rot.x, this->stemSectionAngle[0], 0x71C); + Math_ScaledStepToS(this->stemSectionAngle, this->stemSectionAngle[1], 0x71C); + Math_ScaledStepToS(&this->stemSectionAngle[1], this->stemSectionAngle[2], 0x71C); + if (Math_ScaledStepToS(&this->stemSectionAngle[2], this->targetSwayAngle, 0x71C) != 0) { + this->targetSwayAngle = -0x4000 - (s32)((this->targetSwayAngle + 0x4000) * 0.8f); + } + + angleToVertical = this->targetSwayAngle + 0x4000; + + if (ABS_ALT(angleToVertical) < 0x100) { + this->collider.base.acFlags |= AC_ON; + if (this->actor.xzDistToPlayer < (80.0f * this->size)) { + EnDekubaba_SetupPrepareLunge(this); + } else { + EnDekubaba_SetupRecover(this); + } + } + EnDekubaba_UpdateHeadPosition(this); +} + +void EnDekubaba_SetupFrozen(EnDekubaba* this) { + EnDekubaba_SetFrozenEffects(this); + this->actionFunc = EnDekubaba_Frozen; +} + +void EnDekubaba_Frozen(EnDekubaba* this, PlayState* play) { + if (this->timer != 0) { + this->timer--; + } + if (this->timer == 0) { + EnDekubaba_SpawnIceEffects(this, play); + + if (this->actor.colChkInfo.health == 0) { + EnDekubaba_SetupShrinkDie(this); + } else if (this->actor.xzDistToPlayer < (80.0f * this->size)) { + EnDekubaba_SetupPrepareLunge(this); + } else { + EnDekubaba_SetupRecover(this); + } + } +} + +void EnDekubaba_SetupDeadStickDrop(EnDekubaba* this, PlayState* play) { + Actor_SetScale(&this->actor, 0.03f); + this->actor.shape.rot.x -= 0x4000; + this->actor.shape.yOffset = 1000.0f; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.shape.shadowScale = 3.0f; + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_MISC); + this->actor.flags &= ~ACTOR_FLAG_20; + this->timer = 200; + this->drawDmgEffAlpha = 0.0f; + this->actionFunc = EnDekubaba_DeadStickDrop; +} + +void EnDekubaba_DeadStickDrop(EnDekubaba* this, PlayState* play) { + if (this->timer != 0) { + this->timer--; + } + + if (Actor_HasParent(&this->actor, play) || (this->timer == 0)) { + Actor_Kill(&this->actor); + return; + } + + Actor_OfferGetItemNearby(&this->actor, play, GI_STICKS_1); +} + +/* Update and associated functions */ + +void EnDekubaba_UpdateDamage(EnDekubaba* this, PlayState* play) { + s32 newHealth; + s32 i; + ColliderJntSphElement* sphElement; + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlagJntSph(&this->actor, &this->collider); + + if ((this->collider.base.colType != COLTYPE_HARD) && + (this->actor.colChkInfo.damageEffect != DEKUBABA_DMGEFF_HOOKSHOT)) { + sphElement = &this->collider.elements[0]; + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++, sphElement++) { + if (sphElement->info.bumperFlags & BUMP_HIT) { + break; + } + } + + if ((i != ARRAY_COUNT(this->colliderElements)) && + ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + (!(sphElement->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)))) { + EnDekubaba_SpawnIceEffects(this, play); + newHealth = this->actor.colChkInfo.health - this->actor.colChkInfo.damage; + + if (this->actionFunc != EnDekubaba_StunnedVertical) { + if (this->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_ICE) { + EnDekubaba_SetupFrozen(this); + } else if (this->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_ELECTRIC) { + EnDekubaba_SetupHit(this, DEKUBABA_HIT_STUN_ELECTRIC); + } else if (this->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_NUT) { + EnDekubaba_SetupHit(this, DEKUBABA_HIT_STUN_NUT); + } else { + EnDekubaba_SetFireLightEffects(this, play, i); + + if (this->actionFunc == EnDekubaba_PullBack) { + if (newHealth <= 0) { + newHealth = 1; + } + + EnDekubaba_SetupHit(this, DEKUBABA_HIT_STUN_OTHER); + } else { + EnDekubaba_SetupHit(this, DEKUBABA_HIT_NO_STUN); + } + } + } else { + if (this->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_CUT) { + if (newHealth > 0) { + EnDekubaba_SetupSway(this); + } else { + EnDekubaba_SetupPrunedSomersaultDie(this); + } + } else if (this->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_ELECTRIC) { + EnDekubaba_SetupHit(this, DEKUBABA_HIT_STUN_ELECTRIC); + } else if (this->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_NUT) { + EnDekubaba_SetupHit(this, DEKUBABA_HIT_STUN_NUT); + } else if (this->actor.colChkInfo.damageEffect == DEKUBABA_DMGEFF_ICE) { + EnDekubaba_SetupFrozen(this); + } else { + EnDekubaba_SetFireLightEffects(this, play, i); + EnDekubaba_SetupHit(this, DEKUBABA_HIT_NO_STUN); + } + } + + if (newHealth < 0) { + this->actor.colChkInfo.health = 0; + } else { + this->actor.colChkInfo.health = newHealth; + } + } else { + return; + } + } else { + return; + } + } else if ((play->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < SQ(200.0f)) && + (this->collider.base.colType != COLTYPE_HARD) && (this->actionFunc != EnDekubaba_StunnedVertical) && + (this->actionFunc != EnDekubaba_Hit) && (this->actor.colChkInfo.health != 0)) { + this->actor.colChkInfo.health--; + this->actor.dropFlag = 0; + EnDekubaba_SetupHit(this, DEKUBABA_HIT_STUN_OTHER); + } else { + return; + } + + if (this->actor.colChkInfo.health != 0) { + if ((this->timer == 2) || (this->timer == 3)) { + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); + } else { + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKU_DAMAGE); + } + } else { + Enemy_StartFinishingBlow(play, &this->actor); + + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->timer = 3; + this->collider.base.acFlags &= ~AC_ON; + } else if (this->drawDmgEffAlpha > 1.5f) { + this->drawDmgEffAlpha = 1.5f; + } + + if (this->actor.params == DEKUBABA_BIG) { + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKU_DEAD); + } else { + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKU_JR_DEAD); + } + } +} + +void EnDekubaba_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnDekubaba* this = THIS; + + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + EnDekubaba_SetupRecover(this); + } + + EnDekubaba_UpdateDamage(this, play); + this->actionFunc(this, play); + + if (this->actionFunc == EnDekubaba_PrunedSomersaultDie) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, this->size * 15.0f, 10.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); + } else if (this->actionFunc != EnDekubaba_DeadStickDrop) { + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); + if (this->boundFloor == NULL) { + this->boundFloor = this->actor.floorPoly; + } + } + + if (this->actionFunc == EnDekubaba_Lunge) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + this->actor.flags |= ACTOR_FLAG_1000000; + } + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } + + if (this->actionFunc != EnDekubaba_DeadStickDrop) { + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.375f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.75f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, 0.75f / 40)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +/* Draw functions */ + +void EnDekubaba_DrawStemRetracted(EnDekubaba* this, PlayState* play) { + f32 horizontalScale; + s32 i; + + OPEN_DISPS(play->state.gfxCtx); + + horizontalScale = this->size * 0.01f; + + Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y + (-6.0f * this->size), this->actor.home.pos.z, + MTXMODE_NEW); + Matrix_RotateZYX(this->stemSectionAngle[0], this->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_Scale(horizontalScale, horizontalScale, horizontalScale, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDekuBabaStemTopDL); + + for (i = 1; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + Matrix_MultZero(&this->bodyPartsPos[i]); + } + + Actor_SetFocus(&this->actor, 0.0f); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void EnDekubaba_DrawStemExtended(EnDekubaba* this, PlayState* play) { + static Gfx* sStemDLists[] = { gDekuBabaStemTopDL, gDekuBabaStemMiddleDL, gDekuBabaStemBaseDL }; + MtxF mf; + s32 i; + f32 scale; + f32 horizontalStepSize; + s32 stemSections; + + OPEN_DISPS(play->state.gfxCtx); + + if (this->actionFunc == EnDekubaba_PrunedSomersaultDie) { + stemSections = 2; + } else { + stemSections = 3; + } + + scale = this->size * 0.01f; + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_Get(&mf); + + for (i = 0; i < stemSections; i++) { + mf.yw += 20.0f * Math_SinS(this->stemSectionAngle[i]) * this->size; + horizontalStepSize = Math_CosS(this->stemSectionAngle[i]) * 20.0f * this->size; + mf.xw -= horizontalStepSize * Math_SinS(this->actor.shape.rot.y); + mf.zw -= horizontalStepSize * Math_CosS(this->actor.shape.rot.y); + + Matrix_Put(&mf); + Matrix_RotateZYX(this->stemSectionAngle[i], this->actor.shape.rot.y, 0, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sStemDLists[i]); + + Collider_UpdateSpheres(51 + 2 * i, &this->collider); + Collider_UpdateSpheres(52 + 2 * i, &this->collider); + + if (i == 0) { + if (this->actionFunc != EnDekubaba_Sway) { + this->actor.focus.pos.x = mf.xw; + this->actor.focus.pos.y = mf.yw; + this->actor.focus.pos.z = mf.zw; + } else { + this->actor.focus.pos.x = this->actor.home.pos.x; + this->actor.focus.pos.y = this->actor.home.pos.y + (40.0f * this->size); + this->actor.focus.pos.z = this->actor.home.pos.z; + } + } + + Matrix_MultZero(&this->bodyPartsPos[i + 1]); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +void EnDekubaba_DrawStemBasePruned(EnDekubaba* this, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + + Matrix_RotateZYX(this->stemSectionAngle[2], this->actor.shape.rot.y, 0, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDekuBabaStemBaseDL); + + Collider_UpdateSpheres(55, &this->collider); + Collider_UpdateSpheres(56, &this->collider); + + Matrix_MultZero(&this->bodyPartsPos[3]); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void EnDekubaba_DrawShadow(EnDekubaba* this, PlayState* play) { + MtxF mf; + f32 horizontalScale; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C448(play->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); + + func_800C0094(this->boundFloor, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, &mf); + Matrix_Mult(&mf, MTXMODE_NEW); + horizontalScale = this->size * 0.15f; + Matrix_Scale(horizontalScale, 1.0f, horizontalScale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void EnDekubaba_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnDekubaba* this = THIS; + + if (limbIndex == DEKUBABA_LIMB_ROOT) { + Collider_UpdateSpheres(limbIndex, &this->collider); + } +} + +void EnDekubaba_Draw(Actor* thisx, PlayState* play) { + EnDekubaba* this = THIS; + f32 scale; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + Math_Vec3f_Copy(&this->bodyPartsPos[0], &this->actor.world.pos); + + if (this->actionFunc != EnDekubaba_DeadStickDrop) { + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnDekubaba_PostLimbDraw, + &this->actor); + if (this->actionFunc == EnDekubaba_Wait) { + EnDekubaba_DrawStemRetracted(this, play); + } else { + EnDekubaba_DrawStemExtended(this, play); + } + + scale = this->size * 0.01f; + Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.home.rot.y, MTXMODE_APPLY); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDekuBabaBaseLeavesDL); + + if (this->actionFunc == EnDekubaba_PrunedSomersaultDie) { + EnDekubaba_DrawStemBasePruned(this, play); + } + if (this->boundFloor != NULL) { + EnDekubaba_DrawShadow(this, play); + } + + // Display solid until 40 frames left, then blink until killed. + } else if ((this->timer > 40) || ((this->timer % 2) != 0)) { + Matrix_Translate(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDekuBabaStickDropDL); + } + + CLOSE_DISPS(play->state.gfxCtx); + Actor_DrawDamageEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale * this->size, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); +} diff --git a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.h b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.h index 848f056bf..b1c7f98bc 100644 --- a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.h +++ b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.h @@ -2,16 +2,35 @@ #define Z_EN_DEKUBABA_H #include "global.h" +#include "objects/object_dekubaba/object_dekubaba.h" struct EnDekubaba; typedef void (*EnDekubabaActionFunc)(struct EnDekubaba*, PlayState*); +typedef enum { + /* 0 */ DEKUBABA_NORMAL, + /* 1 */ DEKUBABA_BIG +} DekuBabaType; + typedef struct EnDekubaba { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x44]; + /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnDekubabaActionFunc actionFunc; - /* 0x18C */ char unk_18C[0x290]; + /* 0x18C */ u8 drawDmgEffType; + /* 0x18E */ s16 timer; + /* 0x190 */ s16 targetSwayAngle; + /* 0x192 */ s16 stemSectionAngle[3]; + /* 0x198 */ Vec3s jointTable[DEKUBABA_LIMB_MAX]; + /* 0x1C8 */ Vec3s morphTable[DEKUBABA_LIMB_MAX]; + /* 0x1F8 */ f32 size; + /* 0x1FC */ f32 drawDmgEffAlpha; + /* 0x200 */ f32 drawDmgEffScale; + /* 0x204 */ f32 drawDmgEffFrozenSteamScale; + /* 0x208 */ Vec3f bodyPartsPos[4]; + /* 0x238 */ CollisionPoly* boundFloor; + /* 0x23C */ ColliderJntSph collider; + /* 0x25C */ ColliderJntSphElement colliderElements[7]; } EnDekubaba; // size = 0x41C #endif // Z_EN_DEKUBABA_H 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 6bc0fd8d1..2496a4cc2 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -153,7 +153,7 @@ void func_808BD348(EnDekunuts* this) { this->drawDmgEffAlpha = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_190 = 80; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 80); } void func_808BD3B4(EnDekunuts* this, PlayState* play) { @@ -188,7 +188,7 @@ void func_808BD49C(EnDekunuts* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 9.0f)) { this->collider.base.acFlags |= AC_ON; } else if (Animation_OnFrame(&this->skelAnime, 8.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfx(&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; @@ -299,7 +299,7 @@ void func_808BDA4C(EnDekunuts* this, PlayState* play) { sp58.x = player->actor.world.pos.x; sp58.z = player->actor.world.pos.z; sp58.y = player->actor.world.pos.y + 40.0f; - pitch = Actor_PitchToPoint(&this->actor, &sp58); + pitch = Actor_WorldPitchTowardPoint(&this->actor, &sp58); pitch = CLAMP(pitch, -0x3800, -0x2000); if (this->skelAnime.curFrame < 7.0f) { Math_ScaledStepToS(&this->actor.world.rot.x, pitch, 0x800); @@ -320,7 +320,7 @@ void func_808BDA4C(EnDekunuts* this, PlayState* play) { if (Actor_Spawn(&play->actorCtx, play, ACTOR_EN_NUTSBALL, pos.x, pos.y, pos.z, this->actor.world.rot.x, this->actor.shape.rot.y, 0, params) != NULL) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_THROW); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_THROW); } } else if ((this->unk_190 >= 2) && Animation_OnFrame(&this->skelAnime, 12.0f)) { Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubSpitAnim, -3.0f); @@ -333,7 +333,7 @@ void func_808BDA4C(EnDekunuts* this, PlayState* play) { void func_808BDC9C(EnDekunuts* this) { Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubBurrowAnim, -5.0f); this->unk_190 = 0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DOWN); this->actionFunc = func_808BDD54; } @@ -341,7 +341,7 @@ void func_808BDCF0(EnDekunuts* this) { Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubBurrowAnim, -5.0f); this->collider.base.acFlags &= ~AC_ON; this->unk_190 = 80; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DOWN); this->actionFunc = func_808BDD54; } @@ -369,7 +369,7 @@ void func_808BDE7C(EnDekunuts* this) { Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubUnburrowAnim, -3.0f); this->collider.dim.height = 37; this->actor.colChkInfo.mass = 50; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DAMAGE); this->actor.world.rot.x = 0; this->actor.flags |= ACTOR_FLAG_20; this->collider.base.acFlags &= ~AC_ON; @@ -405,20 +405,20 @@ void func_808BDFB8(EnDekunuts* this, PlayState* play) { } if (this->unk_18C != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_WALK); this->unk_18C = 0; } else { this->unk_18C = 1; } - Math_StepToF(&this->actor.speedXZ, 7.5f, 1.0f); + Math_StepToF(&this->actor.speed, 7.5f, 1.0f); if (!Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_192, 1, 0xE38, 0xB6)) { - if (this->actor.bgCheckFlags & 0x20) { - this->unk_192 = Actor_YawToPoint(&this->actor, &this->actor.home.pos); - } else if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { + this->unk_192 = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->unk_192 = this->actor.wallYaw; } else if (this->unk_18D == 0) { - yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + yaw = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); yaw2 = yaw - this->actor.yawTowardsPlayer; if (ABS_ALT(yaw2) > 0x2000) { this->unk_192 = yaw; @@ -431,11 +431,11 @@ void func_808BDFB8(EnDekunuts* this, PlayState* play) { } this->actor.shape.rot.y = BINANG_ROT180(this->actor.world.rot.y); - if ((this->unk_18D == 0) && (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 20.0f) && + if ((this->unk_18D == 0) && (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) < 20.0f) && (fabsf(this->actor.world.pos.y - this->actor.home.pos.y) < 2.0f)) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.flags &= ~ACTOR_FLAG_20; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; func_808BDC9C(this); } else if (this->unk_190 == 0) { func_808BE1CC(this); @@ -445,7 +445,7 @@ void func_808BDFB8(EnDekunuts* this, PlayState* play) { void func_808BE1CC(EnDekunuts* this) { Animation_PlayLoop(&this->skelAnime, &gDekuScrubPantingAnim); this->unk_190 = 3; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->unk_18D != 0) { this->unk_18D--; } @@ -468,7 +468,7 @@ void func_808BE22C(EnDekunuts* this, PlayState* play) { void func_808BE294(EnDekunuts* this, s32 arg1) { Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubDamageAnim, -3.0f); if (this->actor.params == ENDEKUNUTS_GET_FF00_0) { - this->actor.speedXZ = 10.0f; + this->actor.speed = 10.0f; if (arg1 != 0) { func_800BE504(&this->actor, &this->collider); } @@ -477,20 +477,21 @@ void func_808BE294(EnDekunuts* this, s32 arg1) { this->actor.world.rot.x = 0; this->collider.base.acFlags &= ~AC_ON; this->actionFunc = func_808BE358; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CUTBODY); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, Animation_GetLastFrame(&gDekuScrubDamageAnim)); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_CUTBODY); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, + Animation_GetLastFrame(&gDekuScrubDamageAnim)); } void func_808BE358(EnDekunuts* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); + Math_StepToF(&this->actor.speed, 0.0f, 1.0f); if (SkelAnime_Update(&this->skelAnime)) { func_808BE484(this); } } void func_808BE3A8(EnDekunuts* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->actor.velocity.y > 0.0f) { this->actor.velocity.y = 0.0f; } @@ -520,8 +521,8 @@ void func_808BE3FC(EnDekunuts* this, PlayState* play) { void func_808BE484(EnDekunuts* this) { Animation_PlayOnce(&this->skelAnime, &gDekuScrubDieAnim); this->actionFunc = func_808BE4D4; - this->actor.speedXZ = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); + this->actor.speed = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DEAD); } void func_808BE4D4(EnDekunuts* this, PlayState* play) { @@ -593,8 +594,8 @@ void func_808BE73C(EnDekunuts* this, PlayState* play) { if (this->actor.colChkInfo.damageEffect == 1) { this->unk_190 = 40; - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); func_808BE3A8(this); return; } @@ -642,7 +643,9 @@ void EnDekunuts_Update(Actor* thisx, PlayState* play) { func_808BE73C(this, play); this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, this->collider.dim.radius, this->collider.dim.height, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, this->collider.dim.radius, this->collider.dim.height, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); Collider_UpdateCylinder(&this->actor, &this->collider); if (this->collider.base.acFlags & AC_ON) { diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h index c6672b06e..59b6677a0 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h @@ -8,13 +8,13 @@ struct EnDekunuts; typedef void (*EnDekunutsActionFunc)(struct EnDekunuts*, PlayState*); -#define ENDEKUNUTS_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF); +#define ENDEKUNUTS_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) enum { - /* 0x0 */ ENDEKUNUTS_GET_FF00_0, - /* 0x1 */ ENDEKUNUTS_GET_FF00_1, - /* 0x2 */ ENDEKUNUTS_GET_FF00_2, - /* 0xFF*/ ENDEKUNUTS_GET_FF00_FF = 0xFF, + /* 0x00 */ ENDEKUNUTS_GET_FF00_0, + /* 0x01 */ ENDEKUNUTS_GET_FF00_1, + /* 0x02 */ ENDEKUNUTS_GET_FF00_2, + /* 0xFF */ ENDEKUNUTS_GET_FF00_FF = 0xFF }; typedef struct EnDekunuts { diff --git a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c index 2a4eb1553..986953d0f 100644 --- a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c +++ b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c @@ -125,7 +125,7 @@ void EnDemoheishi_Idle(EnDemoheishi* this, PlayState* play) { s32 absYawDiff; s16 yawDiff; - this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_CANT_LOCK_ON; yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; absYawDiff = ABS_ALT(yawDiff); @@ -143,7 +143,7 @@ void EnDemoheishi_SetupTalk(EnDemoheishi* this) { void EnDemoheishi_Talk(EnDemoheishi* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); EnDemoheishi_SetupIdle(this); } } @@ -160,7 +160,9 @@ void EnDemoheishi_Update(Actor* thisx, PlayState* play) { this->actor.shape.rot.y = this->actor.world.rot.y; this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); Actor_SetScale(&this->actor, 0.01f); EnDemoheishi_SetHeadRotation(this); 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 d9bebb404..8a6ae63e8 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -5,13 +5,12 @@ */ #include "z_en_dg.h" +#include "overlays/actors/ovl_En_Aob_01/z_en_aob_01.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnDg*)thisx) -//! TODO: this file require macros for its uses of weekEventReg - void EnDg_Init(Actor* thisx, PlayState* play); void EnDg_Destroy(Actor* thisx, PlayState* play); void EnDg_Update(Actor* thisx, PlayState* play); @@ -237,7 +236,7 @@ void EnDg_UpdateCollision(EnDg* this, PlayState* play) { Collider_ResetCylinderOC(play, &this->collider.base); } - Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 10.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 10.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } void EnDg_GetFloorRot(EnDg* this, Vec3f* floorRot) { @@ -281,7 +280,7 @@ s32 EnDg_HasReachedPoint(EnDg* this, Path* path, s32 pointIndex) { diffZ = points[currentPoint + 1].z - points[currentPoint - 1].z; } - func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + func_8017B7F8(&point, RAD_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; @@ -310,7 +309,7 @@ s16 EnDg_GetYRotation(Path* path, s32 index, Vec3f* pos, f32* distSq) { *distSq = SQ(diffX) + SQ(diffZ); - return RADF_TO_BINANG(Math_Atan2F_XY(diffZ, diffX)); + return RAD_TO_BINANG(Math_Atan2F_XY(diffZ, diffX)); } /** @@ -322,7 +321,7 @@ void EnDg_MoveAlongPath(EnDg* this, PlayState* play) { if (this->path != NULL) { yRotation = EnDg_GetYRotation(this->path, this->currentPoint, &this->actor.world.pos, &distSq); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { yRotation = this->actor.wallYaw; } @@ -338,15 +337,15 @@ void EnDg_MoveAlongPath(EnDg* this, PlayState* play) { if ((this->index == ENDG_INDEX_SWAMP_SPIDER_HOUSE) || ((this->index == ENDG_INDEX_ROMANI_RANCH) && (play->sceneId == SCENE_OMOYA))) { - Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 1.0f, 0.2f, 1.0f); } else if (this->index == ENDG_INDEX_ROMANI_RANCH) { - Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 3.5f, 0.2f, 1.0f); } else if (play->sceneId == SCENE_CLOCKTOWER) { - Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 3.5f, 0.2f, 1.0f); } else if (sRacetrackDogInfo[this->index].textId & 0x11) { - Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 1.0f, 0.2f, 1.0f); } else { - Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 3.5f, 0.2f, 1.0f); } } else { Actor_Kill(&this->actor); @@ -355,7 +354,7 @@ void EnDg_MoveAlongPath(EnDg* this, PlayState* play) { void EnDg_SpawnFloorDustRing(EnDg* this, PlayState* play) { s16 curFrame = this->skelAnime.curFrame; - s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; + s16 mod = (this->actor.speed > 6.0f) ? 2 : 3; Vec3f pos; if (((this->index + curFrame) % mod) == 0) { @@ -368,36 +367,36 @@ void EnDg_SpawnFloorDustRing(EnDg* this, PlayState* play) { void EnDg_PlaySfxWalk(EnDg* this) { if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 7.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_MONKEY_WALK); } } void EnDg_PlaySfxBark(EnDg* this, f32 frame) { if (Animation_OnFrame(&this->skelAnime, frame)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); + Actor_PlaySfx(&this->actor, NA_SE_EV_SMALL_DOG_BARK); } } void EnDg_PlaySfxAngryBark(EnDg* this, f32 frame) { if (Animation_OnFrame(&this->skelAnime, frame)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); + Actor_PlaySfx(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); } } void EnDg_PlaySfxWhine(EnDg* this) { if (Animation_OnFrame(&this->skelAnime, 23.0f) || Animation_OnFrame(&this->skelAnime, 28.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_WHINE); + Actor_PlaySfx(&this->actor, NA_SE_EV_SMALL_DOG_WHINE); } } void EnDg_PlaySfxGrowl(EnDg* this, f32 frame) { if (Animation_OnFrame(&this->skelAnime, frame)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); + Actor_PlaySfx(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); } } void EnDg_SetupIdleMove(EnDg* this, PlayState* play) { - if (!(this->actor.bgCheckFlags & 0x20)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { if ((this->index == ENDG_INDEX_SWAMP_SPIDER_HOUSE) || ((this->index == ENDG_INDEX_ROMANI_RANCH) && (play->sceneId == SCENE_OMOYA))) { EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK); @@ -417,20 +416,13 @@ void EnDg_SetupIdleMove(EnDg* this, PlayState* play) { /** * Updates the text ID in sRacetrackDogInfo based on what was set in the weekEventRegs by - * En_Aob_01. This makes it sp the proper message can be displayed when the player picks up + * En_Aob_01. This makes it so the proper message can be displayed when the player picks up * the dog with the Mask of Truth equipped. */ void EnDg_UpdateTextId(EnDg* this) { - if (this->index < 14) { - // Assuming that the weekEventRegs haven't been tampered with, then this will produce a text ID in - // the range of 0x3538 to 0x3545. - if (this->index % 2) { - sRacetrackDogInfo[this->index].textId = - 0x3538 + ((gSaveContext.save.weekEventReg[42 + (this->index / 2)] & 0xF0) >> 4); - } else { - sRacetrackDogInfo[this->index].textId = - 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->index / 2)] & 0x0F); - } + if (this->index < RACEDOG_COUNT) { + // This will produce a text ID in the range of 0x3538 to 0x3545. + sRacetrackDogInfo[this->index].textId = GET_WEEKEVENTREG_DOG_RACE_TEXT(this->index, 0x3538); } else { Actor_Kill(&this->actor); } @@ -473,26 +465,26 @@ void EnDg_StartTextBox(EnDg* this, PlayState* play) { */ void EnDg_TryPickUp(EnDg* this, PlayState* play) { if (sIsAnyDogHeld && !(this->dogFlags & DOG_FLAG_HELD)) { - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->dogFlags |= DOG_FLAG_HELD; } else if (!sIsAnyDogHeld && (this->dogFlags & DOG_FLAG_HELD)) { - this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_CANT_LOCK_ON; this->dogFlags &= ~DOG_FLAG_HELD; } if (Actor_HasParent(&this->actor, play)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); + Actor_PlaySfx(&this->actor, NA_SE_EV_SMALL_DOG_BARK); this->grabState = DOG_GRAB_STATE_HELD; sSelectedRacetrackDogInfo = sRacetrackDogInfo[this->index]; if (!sIsAnyDogHeld) { - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; sIsAnyDogHeld = true; this->dogFlags |= DOG_FLAG_HELD; } EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_SIT_DOWN); this->actor.flags &= ~ACTOR_FLAG_1; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (Player_GetMask(play) == PLAYER_MASK_TRUTH) { this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, play, 100.0f); @@ -501,7 +493,7 @@ void EnDg_TryPickUp(EnDg* this, PlayState* play) { this->actionFunc = EnDg_Held; } } else { - Actor_LiftActor(&this->actor, play); + Actor_OfferCarry(&this->actor, play); } } @@ -562,7 +554,7 @@ void EnDg_CheckForBremenMaskMarch(EnDg* this, PlayState* play) { } else if ((this->actionFunc == EnDg_ApproachPlayer) || (this->actionFunc == EnDg_SitNextToPlayer)) { if (DECR(this->bremenBarkTimer) == 0) { this->bremenBarkTimer = 10; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); + Actor_PlaySfx(&this->actor, NA_SE_EV_SMALL_DOG_BARK); } } } @@ -608,7 +600,7 @@ s32 EnDg_ShouldReactToNonHumanPlayer(EnDg* this, PlayState* play) { void EnDg_ChooseActionForForm(EnDg* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (!(this->actor.bgCheckFlags & 0x20)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { switch (player->transformation) { case PLAYER_FORM_HUMAN: if (this->behavior != DOG_BEHAVIOR_HUMAN) { @@ -620,7 +612,7 @@ void EnDg_ChooseActionForForm(EnDg* this, PlayState* play) { case PLAYER_FORM_ZORA: this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; - if ((this->behavior != DOG_BEHAVIOR_ZORA) && (player->actor.speedXZ > 1.0f)) { + if ((this->behavior != DOG_BEHAVIOR_ZORA) && (player->actor.speed > 1.0f)) { this->behavior = DOG_BEHAVIOR_ZORA; EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); this->actionFunc = EnDg_ApproachPlayer; @@ -634,7 +626,7 @@ void EnDg_ChooseActionForForm(EnDg* this, PlayState* play) { case PLAYER_FORM_GORON: this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; - if ((this->behavior != DOG_BEHAVIOR_GORON) && (player->actor.speedXZ > 1.0f)) { + if ((this->behavior != DOG_BEHAVIOR_GORON) && (player->actor.speed > 1.0f)) { this->behavior = DOG_BEHAVIOR_GORON; EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_WALK_BACKWARDS); this->timer = 50; @@ -649,7 +641,7 @@ void EnDg_ChooseActionForForm(EnDg* this, PlayState* play) { case PLAYER_FORM_DEKU: this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; - if ((this->behavior != DOG_BEHAVIOR_DEKU) && (player->actor.speedXZ > 1.0f)) { + if ((this->behavior != DOG_BEHAVIOR_DEKU) && (player->actor.speed > 1.0f)) { this->behavior = DOG_BEHAVIOR_DEKU; EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); this->actionFunc = EnDg_ApproachPlayerToAttack; @@ -680,7 +672,7 @@ void EnDg_IdleMove(EnDg* this, PlayState* play) { EnDg_CheckForBremenMaskMarch(this, play); EnDg_PlaySfxWalk(this); - if (!(this->actor.bgCheckFlags & 1)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->actionFunc = EnDg_Fall; } @@ -704,7 +696,7 @@ void EnDg_IdleBark(EnDg* this, PlayState* play) { EnDg_PlaySfxBark(this, 13.0f); EnDg_PlaySfxBark(this, 19.0f); - if (!(this->actor.bgCheckFlags & 1)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->actionFunc = EnDg_Fall; } @@ -728,12 +720,12 @@ void EnDg_BackAwayFromGoron(EnDg* this, PlayState* play) { this->actionFunc = EnDg_RunAwayFromGoron; } else { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0x3E8, 1); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->actor.shape.rot.y = this->actor.wallYaw; } this->actor.world.rot.y = this->actor.shape.rot.y; - Math_ApproachF(&this->actor.speedXZ, -1.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, -1.5f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); } @@ -752,7 +744,7 @@ void EnDg_RunAwayFromGoron(EnDg* this, PlayState* play) { if (this->actor.xzDistToPlayer < 250.0f) { Math_ApproachS(&this->actor.shape.rot.y, -this->actor.yawTowardsPlayer, 4, 0xC00); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { yRotation = this->actor.wallYaw; } else { yRotation = 0; @@ -760,27 +752,27 @@ void EnDg_RunAwayFromGoron(EnDg* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); this->actor.world.rot.y = this->actor.shape.rot.y; - if (player->actor.speedXZ != 0.0f) { - Math_ApproachF(&this->actor.speedXZ, player->actor.speedXZ, 0.2f, 1.0f); + if (player->actor.speed != 0.0f) { + Math_ApproachF(&this->actor.speed, player->actor.speed, 0.2f, 1.0f); } else { - Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 3.5f, 0.2f, 1.0f); } } else { EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_BARK); this->actionFunc = EnDg_BarkAtGoron; } - if (this->actor.speedXZ > 7.0f) { - this->actor.speedXZ = 7.0f; + if (this->actor.speed > 7.0f) { + this->actor.speed = 7.0f; } Actor_MoveWithGravity(&this->actor); EnDg_PlaySfxWalk(this); if (Animation_OnFrame(&this->skelAnime, 3.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EV_SMALL_DOG_CRY); } else if (Animation_OnFrame(&this->skelAnime, 6.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_MONKEY_WALK); } } @@ -805,13 +797,13 @@ void EnDg_ApproachPlayerToAttack(EnDg* this, PlayState* play) { this->actor.velocity.y = 0.0f; this->actor.gravity = -3.0f; - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->actor.shape.rot.y = this->actor.wallYaw; } this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.xzDistToPlayer < 70.0f) { - Math_ApproachZeroF(&this->actor.speedXZ, 0.2f, 1.0f); + Math_ApproachZeroF(&this->actor.speed, 0.2f, 1.0f); if (Animation_OnFrame(&this->skelAnime, 7.0f)) { s16 yawDiff = ABS_ALT(player->actor.shape.rot.y - this->actor.shape.rot.y); @@ -827,7 +819,7 @@ void EnDg_ApproachPlayerToAttack(EnDg* this, PlayState* play) { } } else { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xC00); - Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 5.0f, 0.2f, 1.0f); } Actor_MoveWithGravity(&this->actor); @@ -841,7 +833,7 @@ void EnDg_ApproachPlayerToAttack(EnDg* this, PlayState* play) { */ void EnDg_RunAfterAttacking(EnDg* this, PlayState* play) { this->dogFlags &= ~DOG_FLAG_BOUNCED; - Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.1f, 0.5f); + Math_ApproachF(&this->actor.speed, 3.5f, 0.1f, 0.5f); Actor_MoveWithGravity(&this->actor); if (DECR(this->attackTimer) == 0) { this->attackTimer = 20; @@ -859,7 +851,7 @@ void EnDg_RunAfterAttacking(EnDg* this, PlayState* play) { void EnDg_SitNextToPlayer(EnDg* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (!(this->actor.bgCheckFlags & 1)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->actionFunc = EnDg_Fall; } @@ -893,7 +885,7 @@ void EnDg_JumpAttack(EnDg* this, PlayState* play) { this->dogFlags &= ~DOG_FLAG_JUMP_ATTACKING; this->dogFlags |= DOG_FLAG_BOUNCED; this->collider.base.atFlags &= ~AT_BOUNCED; - this->actor.speedXZ *= -1.0f; + this->actor.speed *= -1.0f; EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); this->actionFunc = EnDg_RunAfterAttacking; return; @@ -919,9 +911,9 @@ void EnDg_JumpAttack(EnDg* this, PlayState* play) { sAnimationInfo[DOG_ANIM_JUMP_ATTACK].playSpeed = 1.2f; this->actor.velocity.y = 2.0f * rand + 3.0f; - this->actor.speedXZ = 8.0f + rand; + this->actor.speed = 8.0f + rand; } else if (curFrame > 20) { - Math_ApproachF(&this->actor.speedXZ, 2.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 2.5f, 0.2f, 1.0f); } if (curFrame > 23) { @@ -949,7 +941,7 @@ void EnDg_WalkToPlayer(EnDg* this, PlayState* play) { } else { 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); + Math_ApproachF(&this->actor.speed, 2.0f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); } @@ -960,13 +952,13 @@ void EnDg_WalkToPlayer(EnDg* this, PlayState* play) { void EnDg_SetupBremenMaskApproachPlayer(EnDg* this, PlayState* play) { if (func_801A46F8() == 1) { this->bremenBarkTimer = 10; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); + Actor_PlaySfx(&this->actor, NA_SE_EV_SMALL_DOG_BARK); this->actionFunc = EnDg_ApproachPlayer; } } void EnDg_Fall(EnDg* this, PlayState* play) { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); this->actionFunc = EnDg_IdleMove; } @@ -996,12 +988,12 @@ void EnDg_ApproachPlayer(EnDg* this, PlayState* play) { this->actionFunc = EnDg_SitNextToPlayer; } else if (player->stateFlags3 & PLAYER_STATE3_20000000) { if ((this->actor.xzDistToPlayer > 40.0f) && (player->linearVelocity == 0.0f)) { - Math_ApproachF(&this->actor.speedXZ, 1.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 1.5f, 0.2f, 1.0f); } else { - Math_ApproachF(&this->actor.speedXZ, player->actor.speedXZ, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, player->actor.speed, 0.2f, 1.0f); } } else { - Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 3.5f, 0.2f, 1.0f); } EnDg_CheckForBremenMaskMarch(this, play); @@ -1026,14 +1018,14 @@ void EnDg_SlowlyBackUpBeforeAttacking(EnDg* this, PlayState* play) { } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0x3E8, 1); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->actor.shape.rot.y = this->actor.wallYaw; EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_JUMP_ATTACK); this->actionFunc = EnDg_JumpAttack; } this->actor.world.rot.y = this->actor.shape.rot.y; - Math_ApproachF(&this->actor.speedXZ, -1.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, -1.0f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); EnDg_PlaySfxWalk(this); EnDg_PlaySfxGrowl(this, 4.0f); @@ -1054,17 +1046,17 @@ void EnDg_BackAwayFromPlayer(EnDg* this, PlayState* play) { this->actionFunc = EnDg_BarkAtPlayer; } else { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0x3E8, 1); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->actor.shape.rot.y = this->actor.wallYaw; } this->actor.world.rot.y = this->actor.shape.rot.y; - Math_ApproachF(&this->actor.speedXZ, -2.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, -2.0f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); } EnDg_PlaySfxWalk(this); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); + Actor_PlaySfx(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); } /** @@ -1106,11 +1098,11 @@ void EnDg_SetupSwim(EnDg* this, PlayState* play) { this->actor.gravity = 0.0f; this->actor.velocity.y = -3.0f; this->swimTimer = 10; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMB_DROP_WATER); this->actionFunc = EnDg_Swim; } - Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 1.0f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); } @@ -1138,7 +1130,7 @@ void EnDg_Swim(EnDg* this, PlayState* play) { if (DECR(this->swimTimer) == 0) { if (!(this->dogFlags & DOG_FLAG_SWIMMING)) { this->dogFlags |= DOG_FLAG_SWIMMING; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EV_OUT_OF_WATER); } this->swimTimer = 5; @@ -1158,7 +1150,7 @@ void EnDg_Swim(EnDg* this, PlayState* play) { // over. For example, if the player throws the dog at a tall wall next to some water, // this code will make the dog "skip" along the water's surface, assuming the floor // height is low enough to make it try to jump out. - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { if (!WaterBox_GetSurface1(play, &play->colCtx, pos.x, pos.z, &waterSurface, &waterBox)) { if (floorHeight > -100.0f) { this->dogFlags &= ~DOG_FLAG_SWIMMING; @@ -1176,20 +1168,20 @@ void EnDg_Swim(EnDg* this, PlayState* play) { } else { yRotation = this->actor.wallYaw; } - } else if ((this->actor.bgCheckFlags & 1) && !(this->actor.bgCheckFlags & 0x20)) { + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && !(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { this->actor.gravity = -3.0f; this->dogFlags &= ~DOG_FLAG_SWIMMING; this->behavior = DOG_BEHAVIOR_DEFAULT; this->timer = Rand_S16Offset(60, 60); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EV_OUT_OF_WATER); EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); - Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 3.5f, 0.2f, 1.0f); this->actionFunc = EnDg_IdleMove; } Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; - Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 0.5f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); } @@ -1216,23 +1208,23 @@ void EnDg_JumpOutOfWater(EnDg* this, PlayState* play) { this->actor.velocity.y = -1.0f; } - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->actor.world.pos.y = pos.y; this->actor.velocity.y = 10.0f; EffectSsGSplash_Spawn(play, &pos, NULL, NULL, 0, 800); } - if (!(this->actor.bgCheckFlags & 0x20)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { this->behavior = DOG_BEHAVIOR_DEFAULT; this->actor.velocity.y = 10.0f; this->actor.gravity = -3.0f; this->timer = Rand_S16Offset(60, 60); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EV_OUT_OF_WATER); EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); this->actionFunc = EnDg_IdleMove; - Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 3.5f, 0.2f, 1.0f); } else { - Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 0.5f, 0.2f, 1.0f); } Actor_MoveWithGravity(&this->actor); @@ -1243,7 +1235,7 @@ void EnDg_Held(EnDg* this, PlayState* play) { this->grabState = DOG_GRAB_STATE_THROWN_OR_SITTING_AFTER_THROW; this->actor.flags |= ACTOR_FLAG_1; if (sIsAnyDogHeld) { - this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_CANT_LOCK_ON; sIsAnyDogHeld = false; this->dogFlags &= ~DOG_FLAG_HELD; } @@ -1260,13 +1252,13 @@ void EnDg_Held(EnDg* this, PlayState* play) { void EnDg_Thrown(EnDg* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (this->dogFlags & DOG_FLAG_THROWN) { this->dogFlags &= ~DOG_FLAG_THROWN; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_MONKEY_WALK); } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.gravity = -3.0f; if (player->transformation == PLAYER_FORM_HUMAN) { EnDg_TryPickUp(this, play); @@ -1350,7 +1342,7 @@ void EnDg_Update(Actor* thisx, PlayState* play) { EnDg_SetupIdleMove(this, play); } - if ((this->actor.bgCheckFlags & 0x40) && Actor_HasNoParent(&this->actor, play)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) && Actor_HasNoParent(&this->actor, play)) { EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_SWIM); this->actionFunc = EnDg_SetupSwim; } 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 643c167f0..535b0d65f 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -248,7 +248,7 @@ static TexturePtr D_8089E33C[] = { object_dinofos_Tex_009030, }; -static s16 D_8089E34C = -1; +static s16 sCsId = CS_ID_NONE; static s32 D_8089E350 = 0; static InitChainEntry sInitChain[] = { @@ -291,13 +291,13 @@ void EnDinofos_Init(Actor* thisx, PlayState* play) { } this->unk_28B = 0; - if (thisx->cutscene == -1) { + if (thisx->csId == CS_ID_NONE) { func_8089B7B0(this); } else { this->actor.flags |= ACTOR_FLAG_100000; this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; - D_8089E34C = thisx->cutscene; + sCsId = thisx->csId; func_8089D2E0(this); } @@ -367,9 +367,9 @@ void func_8089ABF4(EnDinofos* this, PlayState* play) { Play_SetCameraAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye); this->subCamId = SUB_CAM_ID_DONE; - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); if (this->actor.colChkInfo.health == 0) { - func_800B724C(play, &this->actor, PLAYER_CSMODE_6); + func_800B724C(play, &this->actor, PLAYER_CSMODE_END); } } } @@ -382,7 +382,7 @@ void func_8089AC70(EnDinofos* this) { this->drawDmgEffAlpha = 1.0f; this->unk_290 = 80; this->actor.flags &= ~ACTOR_FLAG_400; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 80); } void func_8089ACEC(EnDinofos* this, PlayState* play) { @@ -415,20 +415,20 @@ s32 func_8089AE00(EnDinofos* this, PlayState* play) { temp_v0 = func_800BC270(play, &this->actor, 80.0f, 0x138B0); if (temp_v0 != NULL) { - temp_v1 = (Actor_YawBetweenActors(&this->actor, temp_v0) - this->actor.shape.rot.y) - this->unk_28E; + temp_v1 = (Actor_WorldYawTowardActor(&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); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WARAU); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_WARAU); return true; } } temp_v0 = func_800BC444(play, &this->actor, 80.0f); if ((temp_v0 != NULL) && (temp_v0->id == ACTOR_EN_BOM_CHU)) { - temp_v1_2 = (Actor_YawBetweenActors(&this->actor, temp_v0) - this->actor.shape.rot.y) - this->unk_28E; + temp_v1_2 = (Actor_WorldYawTowardActor(&this->actor, temp_v0) - this->actor.shape.rot.y) - this->unk_28E; if (ABS_ALT(temp_v1_2) < 0x3000) { func_8089C024(this, 1); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WARAU); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_WARAU); return true; } } @@ -445,7 +445,7 @@ s32 func_8089AE00(EnDinofos* this, PlayState* play) { } else { func_8089C024(this, 3); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WARAU); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_WARAU); return true; } @@ -496,7 +496,7 @@ void func_8089B288(EnDinofos* this, PlayState* play) { void func_8089B320(EnDinofos* this) { this->actor.gravity = -2.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_CRY); + Actor_PlaySfx(&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; @@ -523,7 +523,7 @@ void func_8089B3D4(EnDinofos* this, PlayState* play) { } Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCam->eye); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { func_8089B4A4(this); } } @@ -536,7 +536,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; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_BOMCHU_WALK); this->unk_290 = 0; this->unk_292 = -1; this->actionFunc = func_8089B580; @@ -578,13 +578,13 @@ void func_8089B6E8(EnDinofos* this) { void func_8089B72C(EnDinofos* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 2.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_ATTACK); } if (SkelAnime_Update(&this->skelAnime)) { func_8089ABF4(this, play); this->actor.flags &= ~ACTOR_FLAG_100000; - this->actor.cutscene = -1; + this->actor.csId = CS_ID_NONE; func_8089B7B0(this); } } @@ -593,7 +593,7 @@ void func_8089B7B0(EnDinofos* this) { Animation_MorphToLoop(&this->skelAnime, &object_dinofos_Anim_002E40, -4.0f); this->unk_290 = (s32)Rand_ZeroFloat(20.0f) + 40; this->unk_292 = 30; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; func_8089AD70(this); this->actionFunc = func_8089B834; @@ -625,9 +625,9 @@ void func_8089B8B0(EnDinofos* this, PlayState* play) { phi_f0 = 70.0f; } if (this->actor.xzDistToPlayer <= phi_f0) { - this->actor.speedXZ = -3.5f; + this->actor.speed = -3.5f; } else { - this->actor.speedXZ = 3.5f; + this->actor.speed = 3.5f; } } @@ -650,9 +650,9 @@ void func_8089B98C(EnDinofos* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.xzDistToPlayer <= phi_f0) { - Math_StepToF(&this->actor.speedXZ, -7.0f, 0.5f); + Math_StepToF(&this->actor.speed, -7.0f, 0.5f); } else { - Math_StepToF(&this->actor.speedXZ, 7.0f, 0.5f); + Math_StepToF(&this->actor.speed, 7.0f, 0.5f); } if (this->actor.xzDistToPlayer < 80.0f) { @@ -666,7 +666,7 @@ void func_8089B98C(EnDinofos* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_WALK); } } } @@ -674,7 +674,7 @@ void func_8089B98C(EnDinofos* this, PlayState* play) { void func_8089BAC0(EnDinofos* this) { if (this->actionFunc != func_8089BB60) { Animation_MorphToLoop(&this->skelAnime, &object_dinofos_Anim_000580, -4.0f); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } if (BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y) > 0) { this->unk_28C = BINANG_ADD(this->actor.shape.rot.y, 0x4000); @@ -701,20 +701,20 @@ void func_8089BBB4(EnDinofos* this, PlayState* play) { s16 rotY = player->actor.shape.rot.y - this->actor.shape.rot.y; if (ABS_ALT(rotY) > 0x7800) { if (Rand_ZeroOne() < 0.5f) { - this->actor.speedXZ = 6.0f; + this->actor.speed = 6.0f; } else { - this->actor.speedXZ = -6.0f; + this->actor.speed = -6.0f; } } else if (rotY >= 0) { - this->actor.speedXZ = 6.0f; + this->actor.speed = 6.0f; } else { - this->actor.speedXZ = -6.0f; + this->actor.speed = -6.0f; } if (this->actionFunc == func_8089D1E0) { - this->skelAnime.playSpeed = this->actor.speedXZ * 0.166666671634f; + this->skelAnime.playSpeed = this->actor.speed * 0.166666671634f; } else { - Animation_Change(&this->skelAnime, &object_dinofos_Anim_00D62C, this->actor.speedXZ * 0.166666671634f, 0.0f, + Animation_Change(&this->skelAnime, &object_dinofos_Anim_00D62C, this->actor.speed * 0.166666671634f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f); } @@ -733,8 +733,8 @@ void func_8089BD28(EnDinofos* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xBB8); if (!func_8089AE00(this, play)) { - if (this->actor.bgCheckFlags & 8) { - if (this->actor.speedXZ >= 0.0f) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { + if (this->actor.speed >= 0.0f) { phi_v0 = BINANG_ADD(this->actor.shape.rot.y, 0x4000); } else { phi_v0 = BINANG_SUB(this->actor.shape.rot.y, 0x4000); @@ -742,23 +742,23 @@ void func_8089BD28(EnDinofos* this, PlayState* play) { phi_v0 = this->actor.wallYaw - phi_v0; if (ABS_ALT(phi_v0) > 0x4000) { - this->actor.speedXZ *= -0.8f; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ -= 0.5f; + this->actor.speed *= -0.8f; + if (this->actor.speed < 0.0f) { + this->actor.speed -= 0.5f; } else { - this->actor.speedXZ += 0.5f; + this->actor.speed += 0.5f; } } } phi_v0 = BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y); if ((phi_v0 >= 0) && (phi_v0 < 0x7800)) { - this->actor.speedXZ += 0.125f; + this->actor.speed += 0.125f; } else if ((phi_v0 < 0) && (phi_v0 > -0x7800)) { - this->actor.speedXZ -= 0.125f; + this->actor.speed -= 0.125f; } - if (this->actor.speedXZ > 0.0f) { + if (this->actor.speed > 0.0f) { this->skelAnime.playSpeed = 1.0f; } else { this->skelAnime.playSpeed = -1.0f; @@ -787,7 +787,7 @@ void func_8089BD28(EnDinofos* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_WALK); } } } @@ -804,7 +804,7 @@ void func_8089C024(EnDinofos* this, s32 arg1) { } } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_290 = arg1; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_8089C0DC; @@ -825,33 +825,33 @@ void func_8089C0DC(EnDinofos* this, PlayState* play) { void func_8089C164(EnDinofos* this) { if (this->unk_290 == 2) { - this->actor.speedXZ = -10.0f; + this->actor.speed = -10.0f; this->actor.velocity.y = 9.0f; this->colliderJntSph.base.acFlags |= AC_ON; } else { this->actor.velocity.y = 12.5f; if (this->unk_290 == 0) { - this->actor.speedXZ = 4.5f; + this->actor.speed = 4.5f; } } - this->actor.bgCheckFlags &= ~1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_JUMP); + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_JUMP); this->actionFunc = func_8089C1F8; } void func_8089C1F8(EnDinofos* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { func_8089C398(this); } } void func_8089C244(EnDinofos* this) { - this->actor.bgCheckFlags &= ~1; - this->actor.speedXZ = 8.0f; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; + this->actor.speed = 8.0f; this->actor.velocity.y = 16.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_JUMP); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_JUMP); this->unk_290 = 0; this->unk_292 = -1; this->actionFunc = func_8089C2A8; @@ -867,7 +867,7 @@ void func_8089C2A8(EnDinofos* this, PlayState* play) { Animation_Change(&this->skelAnime, &object_dinofos_Anim_0025B4, 1.0f, 7.0f, 13.0f, ANIMMODE_ONCE, -2.0f); } - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->colliderQuad.base.atFlags &= ~AT_ON; func_8089C398(this); } @@ -880,15 +880,15 @@ void func_8089C398(EnDinofos* this) { this->skelAnime.endFrame = Animation_GetLastFrame(&object_dinofos_Anim_0025B4); } - if (this->actor.speedXZ < 0.0f) { + if (this->actor.speed < 0.0f) { this->unk_290 = 1; } else { this->unk_290 = 0; } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; func_8089AD70(this); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_BOMCHU_WALK); this->actionFunc = func_8089C44C; } @@ -906,10 +906,10 @@ void func_8089C44C(EnDinofos* this, PlayState* play) { void func_8089C4F8(EnDinofos* this) { Animation_PlayOnce(&this->skelAnime, &object_dinofos_Anim_0025B4); this->colliderQuad.base.atFlags &= ~AT_BOUNCED; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_CRY); this->unk_290 = 0; this->unk_292 = -1; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_8089C56C; } @@ -928,7 +928,7 @@ void func_8089C56C(EnDinofos* this, PlayState* play) { } else if (Animation_OnFrame(&this->skelAnime, 13.0f)) { this->colliderQuad.base.atFlags &= ~AT_ON; } else if (Animation_OnFrame(&this->skelAnime, 11.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_ATTACK); } else if (this->skelAnime.curFrame < 7.0f) { func_8089AE00(this, play); } @@ -941,14 +941,14 @@ void func_8089C690(EnDinofos* this) { if (this->actionFunc != func_8089C2A8) { this->actor.world.rot.y = this->actor.shape.rot.y; } else { - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; } this->actionFunc = func_8089C724; } void func_8089C724(EnDinofos* this, PlayState* play) { - if (this->actor.bgCheckFlags & 1) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); } if (SkelAnime_Update(&this->skelAnime)) { @@ -957,7 +957,7 @@ void func_8089C724(EnDinofos* this, PlayState* play) { } void func_8089C784(EnDinofos* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->actor.velocity.y > 0.0f) { this->actor.velocity.y = 0.0f; } @@ -972,7 +972,7 @@ void func_8089C7B8(EnDinofos* this, PlayState* play) { if (this->unk_290 == 0) { func_8089ACEC(this, play); if (this->actor.colChkInfo.health == 0) { - if (this->actor.cutscene == -1) { + if (this->actor.csId == CS_ID_NONE) { func_8089CFAC(this); } else { func_8089D2E0(this); @@ -989,22 +989,22 @@ void func_8089C87C(EnDinofos* this, s32 arg1) { Animation_PlayOnce(&this->skelAnime, &object_dinofos_Anim_00D21C); func_800BE5CC(&this->actor, &this->colliderJntSph, arg1); this->actor.shape.rot.y = BINANG_ROT180(this->actor.world.rot.y); - this->actor.speedXZ = 10.0f; + this->actor.speed = 10.0f; if (this->actor.velocity.y > 0.0f) { this->actor.velocity.y = 0.0f; } this->unk_28E = 0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_DAMAGE); this->colliderJntSph.base.acFlags &= ~AC_ON; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 18); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 18); this->actionFunc = func_8089C938; } void func_8089C938(EnDinofos* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); - if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & 1)) { + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); + if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { if (this->actor.colChkInfo.health == 0) { - if (this->actor.cutscene == -1) { + if (this->actor.csId == CS_ID_NONE) { func_8089CFAC(this); } else { func_8089D2E0(this); @@ -1021,18 +1021,18 @@ void func_8089C938(EnDinofos* this, PlayState* play) { void func_8089CA14(EnDinofos* this) { Animation_MorphToPlayOnce(&this->skelAnime, &object_dinofos_Anim_001040, -5.0f); this->colliderJntSph.base.acFlags |= AC_ON; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_8089CA74; } void func_8089CA74(EnDinofos* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x800); - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); if (SkelAnime_Update(&this->skelAnime)) { func_8089CB10(this, play); } else if (!func_8089AE00(this, play) && Animation_OnFrame(&this->skelAnime, 12.0f)) { - this->actor.speedXZ = 8.0f; + this->actor.speed = 8.0f; } } @@ -1042,7 +1042,7 @@ void func_8089CB10(EnDinofos* this, PlayState* play) { Animation_PlayLoop(&this->skelAnime, &object_dinofos_Anim_0013C0); this->unk_290 = 20; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->colliderJntSph.base.atFlags |= AT_ON; func_8089AD70(this); @@ -1129,8 +1129,8 @@ void func_8089CF70(EnDinofos* this, PlayState* play) { void func_8089CFAC(EnDinofos* this) { Animation_PlayOnce(&this->skelAnime, &object_dinofos_Anim_00ABD0); this->actor.flags &= ~ACTOR_FLAG_1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_DEAD); - this->actor.speedXZ = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_DEAD); + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_8089D018; } @@ -1157,17 +1157,17 @@ void func_8089D018(EnDinofos* this, PlayState* play) { this->actor.shape.shadowAlpha = this->unk_288; } else if (Animation_OnFrame(&this->skelAnime, 26.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } } void func_8089D11C(EnDinofos* this, s16 arg1) { if (arg1 >= 0) { - this->actor.speedXZ = -15.0f; + this->actor.speed = -15.0f; } else { - this->actor.speedXZ = 15.0f; + this->actor.speed = 15.0f; } - Animation_Change(&this->skelAnime, &object_dinofos_Anim_00D62C, this->actor.speedXZ * (1.0f / 7.5f), 0.0f, 0.0f, + Animation_Change(&this->skelAnime, &object_dinofos_Anim_00D62C, this->actor.speed * (1.0f / 7.5f), 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f); this->actor.world.rot.y = BINANG_ADD(this->actor.shape.rot.y, 0x4000); this->unk_292 = 10; @@ -1178,10 +1178,10 @@ void func_8089D11C(EnDinofos* this, s16 arg1) { void func_8089D1E0(EnDinofos* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xBB8); - Math_StepToF(&this->actor.speedXZ, 0.0f, 2.0f); + Math_StepToF(&this->actor.speed, 0.0f, 2.0f); this->skelAnime.playSpeed = - (1.0f + fabsf(this->actor.speedXZ * (1.0f / 15.0f))) * ((this->actor.speedXZ >= 0.0f) ? 1.0f : -1.0f); + (1.0f + fabsf(this->actor.speed * (1.0f / 15.0f))) * ((this->actor.speed >= 0.0f) ? 1.0f : -1.0f); this->actor.world.rot.y = BINANG_ADD(this->actor.shape.rot.y, 0x4000); SkelAnime_Update(&this->skelAnime); if (this->unk_292 != 0) { @@ -1191,26 +1191,26 @@ void func_8089D1E0(EnDinofos* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_WALK); } } void func_8089D2E0(EnDinofos* this) { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); this->actionFunc = func_8089D318; } void func_8089D318(EnDinofos* this, PlayState* play) { Vec3f subCamEye; - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + if (CutsceneManager_IsNext(this->actor.csId)) { if (this->actor.colChkInfo.health == 0) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); - func_800B724C(play, &this->actor, PLAYER_CSMODE_7); + CutsceneManager_Start(this->actor.csId, &this->actor); + func_800B724C(play, &this->actor, PLAYER_CSMODE_WAIT); } else { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); } - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->actor.csId); if (this->actor.colChkInfo.health == 0) { subCamEye.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + this->actor.focus.pos.x; subCamEye.y = this->actor.focus.pos.y; @@ -1221,7 +1221,7 @@ void func_8089D318(EnDinofos* this, PlayState* play) { func_8089B100(this, play); } } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -1273,12 +1273,12 @@ s32 func_8089D60C(EnDinofos* this, PlayState* play) { Enemy_StartFinishingBlow(play, &this->actor); D_8089E350--; if (D_8089E350 == 0) { - if (D_8089E34C != -1) { - this->actor.cutscene = D_8089E34C; + if (sCsId != CS_ID_NONE) { + this->actor.csId = sCsId; } } - if (this->actor.cutscene != -1) { + if (this->actor.csId != CS_ID_NONE) { Audio_RestorePrevBgm(); } } @@ -1303,19 +1303,19 @@ s32 func_8089D60C(EnDinofos* this, PlayState* play) { if (this->actor.colChkInfo.damageEffect == 1) { this->unk_290 = 40; - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); func_8089C784(this); return true; } if (this->actor.colChkInfo.damageEffect == 5) { this->unk_290 = 40; - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); this->drawDmgEffScale = 0.55f; this->drawDmgEffAlpha = 2.0f; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); func_8089C784(this); return true; } @@ -1356,7 +1356,9 @@ void EnDinofos_Update(Actor* thisx, PlayState* play2) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 25.0f, 30.0f, 60.0f, 0x5D); + Actor_UpdateBgCheckInfo(play, &this->actor, 25.0f, 30.0f, 60.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10 | UPDBGCHECKINFO_FLAG_40); if (this->actionFunc != func_8089C7B8) { if ((this->actor.depthInWater > 0.0f) && (this->actor.depthInWater < 10.0f)) { if (!((play->gameplayFrames % 4) & 1)) { diff --git a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c index 615383a27..8edd1b580 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -8,7 +8,7 @@ #include "objects/object_hanareyama_obj/object_hanareyama_obj.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_80) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_REACT_TO_LENS) #define THIS ((EnDnb*)thisx) @@ -104,7 +104,7 @@ void EnDnb_Init(Actor* thisx, PlayState* play) { s32 i; s16* alloc; - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_hanareyama_obj_Colheader_004D8C); alloc = Lib_SegmentedToVirtual(object_hanareyama_obj_Vec_004710); @@ -275,7 +275,9 @@ s32 func_80A50950(EnDnbUnkStruct* arg0, PlayState* play2) { } Matrix_Push(); - if (1) {}; + //! FAKE: + if (1) {} + arg0->unk_24 = (arg0->unk_01 / (f32)arg0->unk_02) * 255.0f; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)arg0->unk_24); 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 ee035f06b..7d59ebeec 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -213,8 +213,8 @@ void func_80A51648(EnDnk* this, PlayState* play) { } void func_80A51890(EnDnk* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 126)) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 126)); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_126)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_126)); } } @@ -423,7 +423,7 @@ void func_80A52018(Actor* thisx, PlayState* play) { } void func_80A52074(EnDnk* this, PlayState* play) { - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 80: func_8019F128(NA_SE_EN_DEKNUTS_DANCE1); break; @@ -433,21 +433,21 @@ void func_80A52074(EnDnk* this, PlayState* play) { break; case 438: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKNUTS_DANCE_BIG); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKNUTS_DANCE_BIG); break; case 493: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_APPEAR); break; } - if ((play->csCtx.frames >= 198) && (play->csCtx.frames < 438)) { + if ((play->csCtx.curFrame >= 198) && (play->csCtx.curFrame < 438)) { func_8019F128(NA_SE_EN_DEKNUTS_DANCE - SFX_FLAG); } } void func_80A52134(EnDnk* this, PlayState* play) { - if ((play->csCtx.state != 0) && (ENDNK_GET_3C(&this->actor) == 4) && (play->sceneId == SCENE_SPOT00) && + if ((play->csCtx.state != CS_STATE_IDLE) && (ENDNK_GET_3C(&this->actor) == 4) && (play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 2)) { func_80A52074(this, play); } 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 12e048955..a9128b1bd 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -235,7 +235,7 @@ void EnDno_Init(Actor* thisx, PlayState* play) { this->morphTable, DEKU_BUTLER_LIMB_MAX); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, thisx, &sCylinderInit); - Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); Animation_Change(&this->skelAnime, sAnimations[EN_DNO_ANIM_IDLE_WITH_CANDLE].animation, 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[EN_DNO_ANIM_IDLE_WITH_CANDLE].animation), sAnimations[EN_DNO_ANIM_IDLE_WITH_CANDLE].mode, @@ -243,7 +243,7 @@ void EnDno_Init(Actor* thisx, PlayState* play) { this->unk_3BE = 0x3E93; this->unk_3C0 = 60.0f; this->unk_3B0 = 0; - this->unk_468 = 99; + this->cueId = 99; this->skelAnime.playSpeed = 0.0f; switch (EN_DNO_GET_C000(thisx)) { @@ -311,7 +311,7 @@ void func_80A71B68(EnDno* this, PlayState* play) { if (!(this->unk_3B0 & 0x20)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_LOOP, &this->animIndex); - this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->unk_460); + this->actor.shape.rot.y = Actor_WorldYawTowardActor(&this->actor, this->unk_460); } } else { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, &this->animIndex); @@ -347,8 +347,8 @@ void func_80A71C3C(EnDno* this, PlayState* play) { } case EN_DNO_ANIM_PRAYER_LOOP: - Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->unk_460), 2, 0xE38, - 0x222); + Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardActor(&this->actor, this->unk_460), 2, + 0xE38, 0x222); break; } @@ -436,12 +436,12 @@ void func_80A71F18(EnDno* this, PlayState* play) { &this->animIndex); } Math_ScaledStepToS(&this->actor.shape.rot.y, - Actor_YawBetweenActors(&this->actor, this->unk_460), 0x71C); + Actor_WorldYawTowardActor(&this->actor, this->unk_460), 0x71C); break; case EN_DNO_ANIM_IMPLORE_END: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_801477B4(play); + Message_CloseTextbox(play); SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, &this->animIndex); func_80A71B68(this, play); @@ -474,7 +474,7 @@ void func_80A71F18(EnDno* this, PlayState* play) { case EN_DNO_ANIM_IMPLORE_END: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_801477B4(play); + Message_CloseTextbox(play); SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, &this->animIndex); func_80A71B68(this, play); @@ -485,13 +485,13 @@ void func_80A71F18(EnDno* this, PlayState* play) { case 0x80C: if (Message_ShouldAdvance(play)) { - func_80151938(play, 0x80D); + Message_ContinueTextbox(play, 0x80D); } break; case 0x80D: if (Message_ShouldAdvance(play)) { - func_80151938(play, 0x80E); + Message_ContinueTextbox(play, 0x80E); } break; @@ -505,21 +505,21 @@ void func_80A71F18(EnDno* this, PlayState* play) { &this->animIndex); } } else if ((this->animIndex == EN_DNO_ANIM_IDLE) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); func_80A71B68(this, play); } break; case 0x80F: if (Message_ShouldAdvance(play)) { - func_80151938(play, 0x810); + Message_ContinueTextbox(play, 0x810); } break; case 0x810: if (Message_ShouldAdvance(play)) { this->unk_3B0 |= 0x20; - func_801477B4(play); + Message_CloseTextbox(play); func_80A71B68(this, play); break; } @@ -541,7 +541,7 @@ void func_80A71F18(EnDno* this, PlayState* play) { case 0x811: if (Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); func_80A71B68(this, play); } break; @@ -637,7 +637,7 @@ void func_80A725F8(EnDno* this, PlayState* play) { if (this->skelAnime.curFrame <= 23.0f) { this->unk_452 = 3; if (Animation_OnFrame(&this->skelAnime, 23.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OPEN_AMBRELLA); + Actor_PlaySfx(&this->actor, NA_SE_EV_OPEN_AMBRELLA); } } else if (this->skelAnime.curFrame <= 24.0f) { this->unk_452 = 4; @@ -675,8 +675,8 @@ void func_80A725F8(EnDno* this, PlayState* play) { } else { this->getItemId = GI_MASK_SCENTS; } - Actor_PickUp(&this->actor, play, this->getItemId, 60.0f, 60.0f); - func_801477B4(play); + Actor_OfferGetItem(&this->actor, play, this->getItemId, 60.0f, 60.0f); + Message_CloseTextbox(play); func_80A72B84(this, play); } break; @@ -699,14 +699,14 @@ void func_80A725F8(EnDno* this, PlayState* play) { } } else if ((this->animIndex == EN_DNO_ANIM_GREETING_WITH_CANDLE) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { - func_801477B4(play); + Message_CloseTextbox(play); func_80A72438(this, play); } break; case 0x806: if (Message_ShouldAdvance(play)) { - func_80151938(play, 0x800); + Message_ContinueTextbox(play, 0x800); } break; @@ -741,13 +741,13 @@ void func_80A72BA4(EnDno* this, PlayState* play) { this->actor.parent = NULL; this->actionFunc = func_80A72598; } else { - Actor_PickUp(&this->actor, play, this->getItemId, 60.0f, 60.0f); + Actor_OfferGetItem(&this->actor, play, this->getItemId, 60.0f, 60.0f); } } void func_80A72C04(EnDno* this, PlayState* play) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_START_RACE_START, &this->animIndex); - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Math_Vec3f_Copy(&this->unk_334, &this->actor.world.pos); SubS_ActorPathing_Init(play, &this->unk_334, &this->actor, &this->actorPath, play->setupPathList, @@ -762,7 +762,7 @@ void func_80A72C04(EnDno* this, PlayState* play) { } void func_80A72CF8(EnDno* this, PlayState* play) { - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_WARP1, this->actor.world.pos.x + 80.0f, this->actor.floorHeight, this->actor.world.pos.z, 0, 0, 0, 0x201); } @@ -779,21 +779,21 @@ s32 EnDno_ActorPathing_UpdateActorInfo(PlayState* play, ActorPathing* actorPath) thisx->gravity = 0.0f; temp_v0 = thisx->yawTowardsPlayer - thisx->world.rot.y; if ((temp_v0 <= 0x4000) && (temp_v0 >= -0x4000)) { - Math_SmoothStepToF(&thisx->speedXZ, 15.0f, 0.8f, 1.0f, 0.01f); + Math_SmoothStepToF(&thisx->speed, 15.0f, 0.8f, 1.0f, 0.01f); } else { if (thisx->xzDistToPlayer <= 80.0f) { - Math_SmoothStepToF(&thisx->speedXZ, 8.0f, 0.5f, 0.5f, 0.01f); + Math_SmoothStepToF(&thisx->speed, 8.0f, 0.5f, 0.5f, 0.01f); } else if (thisx->xzDistToPlayer <= 360.0f) { - Math_SmoothStepToF(&thisx->speedXZ, 7.0f, 0.5f, 0.5f, 0.01f); + Math_SmoothStepToF(&thisx->speed, 7.0f, 0.5f, 0.5f, 0.01f); } else { - Math_SmoothStepToF(&thisx->speedXZ, 3.5f, 0.5f, 0.5f, 0.01f); + Math_SmoothStepToF(&thisx->speed, 3.5f, 0.5f, 0.5f, 0.01f); } } - if (actorPath->distSqToCurPoint < SQ(thisx->speedXZ)) { + if (actorPath->distSqToCurPoint < SQ(thisx->speed)) { ret = true; } else { - sp38 = thisx->speedXZ / sqrtf(actorPath->distSqToCurPointXZ); + sp38 = thisx->speed / sqrtf(actorPath->distSqToCurPointXZ); sp2C = ABS(actorPath->rotToCurPoint.x - thisx->world.rot.x); temp_v0_2 = sp2C; temp_v0_2 *= sp38; @@ -810,11 +810,11 @@ s32 EnDno_ActorPathing_UpdateActorInfo(PlayState* play, ActorPathing* actorPath) s32 EnDno_ActorPathing_Move(PlayState* play, ActorPathing* actorPath) { Actor* thisx = actorPath->actor; EnDno* this = (EnDno*)thisx; - f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speedXZ; + f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speed; f32 sp20 = gFramerateDivisorHalf; thisx->velocity.x = Math_SinS(thisx->world.rot.y) * sp24; - thisx->velocity.y = Math_SinS(-thisx->world.rot.x) * thisx->speedXZ; + thisx->velocity.y = Math_SinS(-thisx->world.rot.x) * thisx->speed; thisx->velocity.z = Math_CosS(thisx->world.rot.y) * sp24; this->unk_334.x += (this->actor.velocity.x * sp20) + this->actor.colChkInfo.displacement.x; @@ -864,7 +864,7 @@ void func_80A730A0(EnDno* this, PlayState* play) { func_800B9010(&this->actor, NA_SE_EV_BUTLER_FRY - SFX_FLAG); if (this->actorPath.flags & ACTOR_PATHING_REACHED_END_PERMANENT) { Math_Vec3f_Copy(&this->actor.world.pos, &this->actorPath.curPoint); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.x = 0.0f; this->actor.velocity.y = 0.0f; this->actor.velocity.z = 0.0f; @@ -873,10 +873,10 @@ void func_80A730A0(EnDno* this, PlayState* play) { } void func_80A73244(EnDno* this, PlayState* play) { - this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->unk_328 = 2; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Flags_UnsetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&this->actor)); gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->unk_44E = 0; @@ -903,7 +903,7 @@ void func_80A732C8(EnDno* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 4.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOSE_AMBRELLA); + Actor_PlaySfx(&this->actor, NA_SE_EV_CLOSE_AMBRELLA); this->unk_452 = 4; } else if (Animation_OnFrame(&this->skelAnime, 5.0f)) { this->unk_452 = 3; @@ -916,12 +916,12 @@ void func_80A732C8(EnDno* this, PlayState* play) { void func_80A73408(EnDno* this, PlayState* play) { s32 phi_a2; u8 sp33 = true; - s32 temp_v0; + s32 cueChannel; - if (Cutscene_CheckActorAction(play, 475)) { - temp_v0 = Cutscene_GetActorActionIndex(play, 475); - if (this->unk_468 != play->csCtx.actorActions[temp_v0]->action) { - switch (play->csCtx.actorActions[temp_v0]->action) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_475)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_475); + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: phi_a2 = 13; break; @@ -940,12 +940,14 @@ void func_80A73408(EnDno* this, PlayState* play) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->animIndex); } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && (this->animIndex == EN_DNO_ANIM_SHOCK_START)) { - if (0) {}; + //! FAKE: + if (1) {} + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_SHOCK_LOOP, &this->animIndex); } } @@ -958,7 +960,7 @@ void EnDno_Update(Actor* thisx, PlayState* play) { func_80A73408(this, play); this->actionFunc(this, play); if (this->unk_3B0 & 4) { - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.h b/src/overlays/actors/ovl_En_Dno/z_en_dno.h index 470c82ee8..f9a55cd4e 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.h +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.h @@ -47,7 +47,7 @@ typedef struct EnDno { /* 0x460 */ Actor* unk_460; /* 0x464 */ u16 textId; /* 0x466 */ s16 unk_466; - /* 0x468 */ u8 unk_468; + /* 0x468 */ u8 cueId; } EnDno; // size = 0x46C #endif // Z_EN_DNO_H 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 b504e9a11..fd1557e3f 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -133,37 +133,38 @@ s32 func_80B3CA20(EnDnp* this) { if ((this->animIndex == EN_DNP_ANIM_CUTSCENE_HURRY) || (this->animIndex == EN_DNP_ANIM_RUN)) { 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)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_TURN); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKUHIME_TURN); } } else if ((this->animIndex == EN_DNP_ANIM_GLARE_START) || (this->animIndex == EN_DNP_ANIM_TURN_AROUND)) { if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_TURN); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKUHIME_TURN); } } else if (this->animIndex == EN_DNP_ANIM_GREETING) { if (Animation_OnFrame(&this->skelAnime, 7.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKUHIME_GREET); } if (Animation_OnFrame(&this->skelAnime, 22.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET2); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKUHIME_GREET2); } } else if (this->animIndex == EN_DNP_ANIM_BOW) { if (Animation_OnFrame(&this->skelAnime, 9.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKUHIME_GREET); } if (Animation_OnFrame(&this->skelAnime, 18.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET2); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKUHIME_GREET2); } } else if ((this->animIndex == EN_DNP_ANIM_UNUSED_WALK) && (this->animIndex == EN_DNP_ANIM_WALK)) { + //! @bug: Impossible to reach, && should be an || if (Animation_OnFrame(&this->skelAnime, 7.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKUHIME_WALK); } } else if (this->animIndex == EN_DNP_ANIM_JUMP) { if (Animation_OnFrame(&this->skelAnime, 17.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKUHIME_WALK); } } else if (this->animIndex == EN_DNP_ANIM_BOUNCE_LOOP) { if (Animation_OnFrame(&this->skelAnime, 3.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKUHIME_WALK); } } @@ -217,7 +218,8 @@ s32 func_80B3CDA4(EnDnp* this, PlayState* play) { pitch = Math_Vec3f_Pitch(&sp3C, &sp30); //! FAKE - if (1) {}; + if (1) {} + Math_SmoothStepToS(&this->unk_330, pitch, 3, 0x2AA8, 0x1); return 1; @@ -263,11 +265,11 @@ s32 func_80B3CF60(EnDnp* this, PlayState* play) { s32 func_80B3D044(EnDnp* this, PlayState* play) { s32 ret = false; - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { if (!(this->unk_322 & 0x200)) { this->unk_322 |= (0x200 | 0x10); this->actor.flags &= ~ACTOR_FLAG_1; - this->unk_324 = 0xFF; + this->cueId = 255; } SubS_UpdateFlags(&this->unk_322, 0, 7); this->actionFunc = func_80B3D11C; @@ -290,20 +292,19 @@ void func_80B3D11C(EnDnp* this, PlayState* play) { EN_DNP_ANIM_ANGRY_START, EN_DNP_ANIM_JUMP, EN_DNP_ANIM_BOUNCE_START, EN_DNP_ANIM_GLARE_START, EN_DNP_ANIM_BOW, }; - s32 temp_v0; - s32 val; + s32 cueChannel; + s32 cueId; - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_29_40) && (play->sceneId == SCENE_MITURIN) && - (play->csCtx.currentCsIndex == 0)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_29_40) && (play->sceneId == SCENE_MITURIN) && (play->csCtx.scriptIndex == 0)) { this->unk_322 |= 0x20; SET_WEEKEVENTREG(WEEKEVENTREG_29_40); } - if (Cutscene_CheckActorAction(play, 101)) { - temp_v0 = Cutscene_GetActorActionIndex(play, 101); - val = play->csCtx.actorActions[temp_v0]->action; - if (this->unk_324 != (u8)val) { - EnDnp_ChangeAnim(this, sCsAnimations[val]); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_101)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_101); + cueId = play->csCtx.actorCues[cueChannel]->id; + if (this->cueId != (u8)cueId) { + EnDnp_ChangeAnim(this, sCsAnimations[cueId]); if (this->animIndex == EN_DNP_ANIM_CUTSCENE_IDLE) { this->unk_322 |= 8; } else { @@ -311,7 +312,7 @@ void func_80B3D11C(EnDnp* this, PlayState* play) { } if (this->animIndex == EN_DNP_ANIM_ANGRY_START) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_DHVO04); + Actor_PlaySfx(&this->actor, NA_SE_VO_DHVO04); } if (this->animIndex == EN_DNP_ANIM_GLARE_START) { @@ -321,14 +322,14 @@ void func_80B3D11C(EnDnp* this, PlayState* play) { } } - this->unk_324 = val; + this->cueId = cueId; if (((this->animIndex == EN_DNP_ANIM_THINK_START) || (this->animIndex == EN_DNP_ANIM_ARMS_TOGETHER_START) || (this->animIndex == EN_DNP_ANIM_LAUGH_START) || (this->animIndex == EN_DNP_ANIM_ANGRY_START) || (this->animIndex == EN_DNP_ANIM_BOUNCE_START) || (this->animIndex == EN_DNP_ANIM_GLARE_START)) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { EnDnp_ChangeAnim(this, this->animIndex + 1); } - Cutscene_ActorTranslateAndYaw(&this->actor, play, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } } @@ -370,7 +371,7 @@ void func_80B3D3F8(EnDnp* this, PlayState* play) { } void func_80B3D47C(EnDnp* this, PlayState* play) { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { Math_SmoothStepToF(&this->actor.scale.x, 0.0085f, 0.1f, 0.01f, 0.001f); if ((s32)(this->actor.scale.x * 10000.0f) >= 85) { this->actor.flags |= ACTOR_FLAG_1; @@ -385,11 +386,11 @@ void func_80B3D47C(EnDnp* this, PlayState* play) { } void func_80B3D558(EnDnp* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); SET_WEEKEVENTREG(WEEKEVENTREG_23_20); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -413,7 +414,7 @@ void EnDnp_Init(Actor* thisx, PlayState* play) { SubS_UpdateFlags(&this->unk_322, 0, 7); this->actor.shape.rot.x = 0; this->actor.world.rot.x = this->actor.shape.rot.x; - this->actor.cutscene = 0x10; + this->actor.csId = 16; this->actionFunc = func_80B3D47C; } else if (((EN_DNP_GET_TYPE(&this->actor) == EN_DNP_TYPE_WOODFALL_TEMPLE) && !Inventory_HasItemInBottle(ITEM_DEKU_PRINCESS) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20)) || @@ -455,11 +456,11 @@ void EnDnp_Update(Actor* thisx, PlayState* play) { func_80B3CD1C(this); func_80B3CEC0(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); sp2C = this->collider.dim.radius + 50; sp28 = this->collider.dim.height + 30; if ((this->unk_322 & 0x400) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20)) { - Actor_PickUp(&this->actor, play, GI_MAX, sp2C, sp28); + Actor_OfferGetItem(&this->actor, play, GI_MAX, sp2C, sp28); } func_8013C964(&this->actor, play, sp2C, sp28, PLAYER_IA_NONE, this->unk_322 & 7); Actor_SetFocus(&this->actor, 30.0f); diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.h b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.h index a41a63615..64f0baf93 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.h +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.h @@ -26,7 +26,7 @@ typedef struct EnDnp { /* 0x1EA */ Vec3s jointTable[DEKU_PRINCESS_LIMB_MAX]; /* 0x286 */ Vec3s morphTable[DEKU_PRINCESS_LIMB_MAX]; /* 0x322 */ u16 unk_322; - /* 0x324 */ u8 unk_324; + /* 0x324 */ u8 cueId; /* 0x328 */ s32 unk_328; /* 0x32C */ UNK_TYPE1 unk_32C[0x2]; /* 0x32E */ s16 unk_32E; 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 021b94476..c328b02d6 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -83,7 +83,7 @@ static AnimationInfoS sAnimationInfo[] = { }; s32 EnDnq_ValidatePictograph(PlayState* play, Actor* thisx) { - return Snap_ValidatePictograph(play, thisx, PICTOGRAPH_DEKU_KING, &thisx->focus.pos, &thisx->world.rot, 120.0f, + return Snap_ValidatePictograph(play, thisx, PICTO_VALID_DEKU_KING, &thisx->focus.pos, &thisx->world.rot, 120.0f, 480.0f, 0x38E3); } @@ -121,10 +121,10 @@ void func_80A52604(EnDnq* this, PlayState* play) { s32 func_80A52648(EnDnq* this, PlayState* play) { s32 ret = false; - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { if (!(this->unk_37C & 0x20)) { this->picto.actor.flags &= ~ACTOR_FLAG_1; - this->unk_1DC = 0xFF; + this->cueId = 255; this->unk_37C |= 0x20; } SubS_UpdateFlags(&this->unk_37C, 0, 7); @@ -132,7 +132,7 @@ s32 func_80A52648(EnDnq* this, PlayState* play) { } else { if (this->unk_37C & 0x20) { this->picto.actor.flags |= ACTOR_FLAG_1; - this->unk_1DC = 0xFF; + this->cueId = 255; this->unk_37C &= ~0x20; SubS_UpdateFlags(&this->unk_37C, 3, 7); } @@ -346,7 +346,7 @@ void func_80A52DC8(EnDnq* this, PlayState* play) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20)) { this->unk_390 = 70.0f; if (Inventory_HasItemInBottle(ITEM_DEKU_PRINCESS) && !Play_InCsMode(play) && - (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) && (ActorCutscene_GetCurrentIndex() == -1)) { + (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE)) { if ((DECR(this->unk_384) == 0) && CHECK_WEEKEVENTREG(WEEKEVENTREG_29_40)) { Message_StartTextbox(play, 0x969, NULL); this->unk_384 = 200; @@ -391,19 +391,19 @@ void func_80A53038(EnDnq* this, PlayState* play) { static s32 D_80A535FC[] = { 0, 1, 2, 3, 5, 6, }; - s32 temp_v0; - u32 temp_v1; + s32 cueChannel; + u32 cueId; - if (Cutscene_CheckActorAction(play, 105)) { - temp_v0 = Cutscene_GetActorActionIndex(play, 105); - temp_v1 = play->csCtx.actorActions[temp_v0]->action; - if (this->unk_1DC != (u8)temp_v1) { - func_80A5257C(this, D_80A535FC[temp_v1]); - this->unk_1DC = temp_v1; + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_105)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_105); + cueId = play->csCtx.actorCues[cueChannel]->id; + if (this->cueId != (u8)cueId) { + func_80A5257C(this, D_80A535FC[cueId]); + this->cueId = cueId; } if ((this->unk_398 == 4) && Animation_OnFrame(&this->skelAnime, 2.0f)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_KINGNUTS_DAMAGE); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_KINGNUTS_DAMAGE); } if (((this->unk_398 == 3) || (this->unk_398 == 6)) && @@ -411,7 +411,7 @@ void func_80A53038(EnDnq* this, PlayState* play) { func_80A5257C(this, this->unk_398 + 1); } - Cutscene_ActorTranslateAndYaw(&this->picto.actor, play, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->picto.actor, play, cueChannel); } } @@ -455,7 +455,7 @@ void EnDnq_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); func_80A52B68(this, play); SkelAnime_Update(&this->skelAnime); - Actor_UpdateBgCheckInfo(play, &this->picto.actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->picto.actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); this->unk_394 = this->picto.actor.xzDistToPlayer; func_80A52C6C(this, play); func_8013C964(&this->picto.actor, play, this->unk_390, fabsf(this->picto.actor.playerHeightRel) + 1.0f, diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.h b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.h index 5afb8bdf8..6ede37a55 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.h +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.h @@ -14,7 +14,7 @@ typedef struct EnDnq { /* 0x148 */ SkelAnime skelAnime; /* 0x18C */ EnDnqActionFunc actionFunc; /* 0x190 */ ColliderCylinder collider; - /* 0x1DC */ u8 unk_1DC; + /* 0x1DC */ u8 cueId; /* 0x1E0 */ s32 unk_1E0; /* 0x1E4 */ Vec3s jointTable[DEKU_KING_LIMB_MAX]; /* 0x2AA */ Vec3s morphTable[DEKU_KING_LIMB_MAX]; 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 714235b17..1f754f1d5 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -92,7 +92,7 @@ void func_8092C5C0(EnDns* this) { if (((this->animIndex == EN_DNS_ANIM_WALK_1) || (this->animIndex == EN_DNS_ANIM_WALK_2) || (this->animIndex == EN_DNS_ANIM_RUN_START) || (this->animIndex == EN_DNS_ANIM_RUN_LOOP)) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 3.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_WALK); } } @@ -205,19 +205,19 @@ s32* func_8092C9BC(EnDns* this, PlayState* play) { return 0; } -s32 func_8092CA74(EnDns* this) { +s32 EnDns_GetCueType(EnDns* this) { switch (ENDNS_GET_7(&this->actor)) { case ENDNS_GET_7_0: - return 465; + return CS_CMD_ACTOR_CUE_465; case ENDNS_GET_7_1: - return 466; + return CS_CMD_ACTOR_CUE_466; case ENDNS_GET_7_2: - return 467; + return CS_CMD_ACTOR_CUE_467; case ENDNS_GET_7_3: - return 468; + return CS_CMD_ACTOR_CUE_468; } return 0; @@ -249,13 +249,13 @@ s32 func_8092CAD0(EnDns* this, PlayState* play) { s32 func_8092CB98(EnDns* this, PlayState* play) { s32 phi_v1 = 0; - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { if (!(this->unk_2C6 & 0x80)) { - this->unk_2C8 = func_8092CA74(this); + this->cueType = EnDns_GetCueType(this); this->actor.flags &= ~ACTOR_FLAG_1; SubS_UpdateFlags(&this->unk_2C6, 0, 7); this->unk_2C6 |= 0x80; - this->unk_1D8 = 0xFF; + this->cueId = 255; } phi_v1 = 1; } else if (this->unk_2C6 & 0x80) { @@ -272,7 +272,8 @@ s32 func_8092CC68(PlayState* play) { s32 ret = false; s16 bgId; - if (!Play_InCsMode(play) && (player->actor.bgCheckFlags & 1) && (player->transformation != PLAYER_FORM_DEKU)) { + if (!Play_InCsMode(play) && (player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + (player->transformation != PLAYER_FORM_DEKU)) { bgId = player->actor.floorBgId; if (SurfaceType_GetSceneExitIndex(&play->colCtx, player->actor.floorPoly, bgId) != 4) { ret = true; @@ -315,7 +316,7 @@ s32 func_8092CE38(EnDns* this) { this->unk_2C6 &= ~0x200; this->skelAnime.curFrame = 0.0f; if (this->unk_2D2 == 2) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_JUMP); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_JUMP); } this->unk_2D2++; if (this->unk_2D2 >= 3) { @@ -328,7 +329,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; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_JUMP); + Actor_PlaySfx(&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; @@ -339,7 +340,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)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_WALK); } if (this->skelAnime.curFrame > 7.0f) { @@ -440,8 +441,8 @@ void func_8092D330(EnDns* this, PlayState* play) { play->nextEntrance = ENTRANCE(DEKU_PALACE, 1); gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } } @@ -478,15 +479,15 @@ void func_8092D5E8(EnDns* this, PlayState* play) { EN_DNS_ANIM_SURPRISE_START, EN_DNS_ANIM_RUN_START, }; - s32 temp_v0; - u32 temp_v1; + s32 cueChannel; + u32 cueId; - if (Cutscene_CheckActorAction(play, this->unk_2C8)) { - temp_v0 = Cutscene_GetActorActionIndex(play, this->unk_2C8); - temp_v1 = play->csCtx.actorActions[temp_v0]->action; - if (this->unk_1D8 != (u8)temp_v1) { - func_8092C63C(this, D_8092DE0C[temp_v1]); - this->unk_1D8 = temp_v1; + if (Cutscene_IsCueInChannel(play, this->cueType)) { + cueChannel = Cutscene_GetCueChannel(play, this->cueType); + cueId = play->csCtx.actorCues[cueChannel]->id; + if (this->cueId != (u8)cueId) { + func_8092C63C(this, D_8092DE0C[cueId]); + this->cueId = cueId; } if (((this->animIndex == EN_DNS_ANIM_SURPRISE_START) || (this->animIndex == EN_DNS_ANIM_RUN_START)) && @@ -494,7 +495,7 @@ void func_8092D5E8(EnDns* this, PlayState* play) { func_8092C63C(this, this->animIndex + 1); } - Cutscene_ActorTranslateAndYaw(&this->actor, play, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } } @@ -549,7 +550,7 @@ void EnDns_Update(Actor* thisx, PlayState* play) { SkelAnime_Update(&this->skelAnime); func_8092C934(this); func_8092C86C(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); func_8013C964(&this->actor, play, 80.0f, 40.0f, PLAYER_IA_NONE, this->unk_2C6 & 7); Actor_SetFocus(&this->actor, 34.0f); func_8092C6FC(this, play); diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.h b/src/overlays/actors/ovl_En_Dns/z_en_dns.h index b54e49a6a..4b730abd3 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.h +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.h @@ -25,8 +25,7 @@ typedef struct EnDns { /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnDnsActionFunc actionFunc; /* 0x18C */ ColliderCylinder collider; - /* 0x1D8 */ u8 unk_1D8; - /* 0x1D9 */ UNK_TYPE1 unk_1D9[0x3]; + /* 0x1D8 */ u8 cueId; /* 0x1DC */ s32 unk_1DC; /* 0x1E0 */ s32* unk_1E0; /* 0x1E4 */ Gfx* unk_1E4[13]; @@ -35,7 +34,7 @@ typedef struct EnDns { /* 0x22A */ Vec3s jointTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; /* 0x278 */ Vec3s morphTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; /* 0x2C6 */ u16 unk_2C6; - /* 0x2C8 */ u16 unk_2C8; + /* 0x2C8 */ u16 cueType; /* 0x2CA */ UNK_TYPE1 unk_2CA[0x2]; /* 0x2CC */ s16 unk_2CC; /* 0x2CE */ s16 unk_2CE; 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 d1ec4ea70..a57814337 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -358,7 +358,7 @@ void func_80876930(EnDodongo* this, PlayState* play, Vec3f* arg2) { s16 temp2; f32 temp3; - if (func_800C9BB8(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == COLPOLY_SURFACE_SNOW) { + if (SurfaceType_GetMaterial(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == SURFACE_MATERIAL_SNOW) { sp80 = &D_8087932C; sp7C = &D_80879330; } else { @@ -420,7 +420,7 @@ void func_80876CAC(EnDodongo* this) { this->drawDmgEffAlpha = 1.0f; this->timer = 80; this->actor.flags &= ~ACTOR_FLAG_400; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 80); } void func_80876D28(EnDodongo* this, PlayState* play) { @@ -536,7 +536,7 @@ s32 func_80877278(EnDodongo* this, PlayState* play) { void func_808773C4(EnDodongo* this) { Animation_MorphToLoop(&this->skelAnime, &object_dodongo_Anim_004C20, -4.0f); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->timer = Rand_S16Offset(30, 50); this->actionFunc = func_80877424; } @@ -556,7 +556,7 @@ void func_80877424(EnDodongo* this, PlayState* play) { void func_80877494(EnDodongo* this) { Animation_MorphToLoop(&this->skelAnime, &object_dodongo_Anim_008B1C, -4.0f); - this->actor.speedXZ = this->unk_334 * 1.5f; + this->actor.speed = this->unk_334 * 1.5f; this->timer = Rand_S16Offset(50, 70); this->actionFunc = func_80877500; } @@ -568,13 +568,13 @@ void func_80877500(EnDodongo* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 19.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_WALK); + Actor_PlaySfx(&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, play, &sp30); } else if (Animation_OnFrame(&this->skelAnime, 39.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_WALK); + Actor_PlaySfx(&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; @@ -592,9 +592,10 @@ void func_80877500(EnDodongo* this, PlayState* play) { } } } else { - if ((Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 150.0f) || + if ((Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 150.0f) || (Player_GetMask(play) == PLAYER_MASK_STONE)) { - Math_ScaledStepToS(&this->actor.world.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x1F4); + Math_ScaledStepToS(&this->actor.world.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), + 0x1F4); } this->timer--; @@ -615,7 +616,7 @@ void func_808777A8(EnDodongo* this) { Sphere16* sph; Animation_MorphToPlayOnce(&this->skelAnime, &object_dodongo_Anim_0028F0, -4.0f); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; for (i = 0; i < ARRAY_COUNT(this->collider3Elements); i++) { sph = &this->collider3.elements[i].dim.worldSphere; @@ -640,7 +641,7 @@ void func_8087784C(EnDodongo* this, PlayState* play) { f32 temp_f12; if (Animation_OnFrame(&this->skelAnime, 24.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_J_CRY); } if (func_8087721C(this)) { @@ -695,7 +696,7 @@ void func_80877DE0(EnDodongo* this) { this->actor.flags |= ACTOR_FLAG_10; this->timer = 25; this->actionFunc = func_80877E60; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void func_80877E60(EnDodongo* this, PlayState* play) { @@ -727,7 +728,7 @@ void func_80877E60(EnDodongo* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 28.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_EAT); + Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_J_EAT); if (this->actor.child != NULL) { Actor_Kill(this->actor.child); this->actor.child = NULL; @@ -750,14 +751,14 @@ void func_80877E60(EnDodongo* this, PlayState* play) { this->unk_334 * 10.0f, 10); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfx(&this->actor, NA_SE_IT_BOMB_EXPLOSION); if (this->actor.colChkInfo.health <= 4) { this->actor.colChkInfo.health = 0; Enemy_StartFinishingBlow(play, &this->actor); } else { this->actor.colChkInfo.health -= 4; } - Actor_SetColorFilter(&this->actor, 0x4000, 0x78, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 120, COLORFILTER_BUFFLAG_OPA, 8); } } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { this->timer--; @@ -809,7 +810,7 @@ void func_80878354(EnDodongo* this) { sp18 = &object_dodongo_Anim_003B14; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_TAIL); + Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_J_TAIL); Animation_PlayOnceSetSpeed(&this->skelAnime, sp18, 2.0f); this->timer = 0; this->collider1.base.atFlags |= AT_ON; @@ -848,7 +849,7 @@ void func_80878424(EnDodongo* this, PlayState* play) { void func_80878594(EnDodongo* this) { this->actionFunc = func_808785B0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void func_808785B0(EnDodongo* this, PlayState* play) { @@ -870,11 +871,11 @@ void func_808785B0(EnDodongo* this, PlayState* play) { void func_8087864C(EnDodongo* this) { Animation_MorphToPlayOnce(&this->skelAnime, &object_dodongo_Anim_001A44, -4.0f); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_J_DAMAGE); this->timer = 0; this->unk_304 = 0; - this->actor.speedXZ = 0.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); + this->actor.speed = 0.0f; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); this->actionFunc = func_808786C8; } @@ -892,10 +893,10 @@ void func_80878724(EnDodongo* this) { Animation_MorphToPlayOnce(&this->skelAnime, &object_dodongo_Anim_0013C4, -8.0f); this->timer = 0; this->unk_304 = 0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_J_DEAD); this->actor.flags &= ~ACTOR_FLAG_1; - this->actor.speedXZ = 0.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); + this->actor.speed = 0.0f; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); this->actionFunc = func_808787B0; } @@ -907,7 +908,7 @@ void func_808787B0(EnDodongo* this, PlayState* play) { func_80876DC4(this, play); } } else if (this->actor.colorFilterTimer == 0) { - Actor_SetColorFilter(&this->actor, 0x4000, 0x78, 0, 4); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 120, COLORFILTER_BUFFLAG_OPA, 4); } if (SkelAnime_Update(&this->skelAnime)) { @@ -920,7 +921,7 @@ void func_808787B0(EnDodongo* this, PlayState* play) { this->timer = 8; } } else if (Animation_OnFrame(&this->skelAnime, 52.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } if (this->timer != 0) { @@ -993,13 +994,13 @@ void EnDodongo_UpdateDamage(EnDodongo* this, PlayState* play) { } } else if (this->actor.colChkInfo.damageEffect == 1) { this->timer = 40; - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); func_80878594(this); } else if (this->actor.colChkInfo.damageEffect == 5) { this->timer = 40; - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; this->drawDmgEffScale = 0.75f; this->drawDmgEffAlpha = 2.0f; @@ -1023,9 +1024,11 @@ void EnDodongo_Update(Actor* thisx, PlayState* play2) { EnDodongo_UpdateDamage(this, play); this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 75.0f, 60.0f, 70.0f, 0x1D); - if (this->actor.bgCheckFlags & 2) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + Actor_UpdateBgCheckInfo(play, &this->actor, 75.0f, 60.0f, 70.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + Actor_PlaySfx(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index 03da874f5..831ff3d36 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -240,7 +240,7 @@ u8 D_80867744[] = { }; u8 D_8086775C[] = { - /* 0x00 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_52_20, 0x1B - 0x04), + /* 0x00 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE, 0x1B - 0x04), /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_75_20, 0x1B - 0x08), /* 0x08 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_14_04, 0x0E - 0x0C), /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(29), @@ -457,7 +457,7 @@ void func_80866A5C(EnDoor* this, PlayState* play) { this->unk_1A6 = 10; } } else if ((this->unk_1A4 == 4) && - (Actor_XZDistanceBetweenActors(&this->dyna.actor, &GET_PLAYER(play)->actor) > 120.0f)) { + (Actor_WorldDistXZToActor(&this->dyna.actor, &GET_PLAYER(play)->actor) > 120.0f)) { this->actionFunc = func_8086704C; this->dyna.actor.world.rot.y = -0x1800; } @@ -467,12 +467,6 @@ void func_80866A5C(EnDoor* this, PlayState* play) { void func_80866B20(EnDoor* this, PlayState* play) { static s32 D_80867BC0; Player* player = GET_PLAYER(play); - Vec3f playerPosRelToDoor; - s16 temp_a2; - s16 yawDiff; - s32 temp_a1_2; - s32 temp_t0; - u8 temp_a1; if (Actor_ProcessTalkRequest(&this->dyna.actor, &play->state) && (this->dyna.actor.textId == 0x1821)) { D_80867BC0 = true; @@ -482,18 +476,21 @@ void func_80866B20(EnDoor* this, PlayState* play) { Animation_PlayOnceSetSpeed(&this->skelAnime, sAnimations[this->animIndex], (player->stateFlags1 & PLAYER_STATE1_8000000) ? 0.75f : 1.5f); if (this->unk_1A6 != 0) { - gSaveContext.save.inventory.dungeonKeys[gSaveContext.mapIndex]--; + gSaveContext.save.saveInfo.inventory.dungeonKeys[gSaveContext.mapIndex]--; Flags_SetSwitch(play, this->switchFlag); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK); } } else if (this->unk_1A7 != 0) { this->actionFunc = func_80866F94; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_OPEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_DOOR_OPEN); } else if (!Player_InCsMode(play)) { + Vec3f playerPosRelToDoor; + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &playerPosRelToDoor, &player->actor.world.pos); if (D_80867BC0 || ((fabsf(playerPosRelToDoor.y) < 20.0f) && (fabsf(playerPosRelToDoor.x) < 20.0f) && (fabsf(playerPosRelToDoor.z) < 50.0f))) { - yawDiff = player->actor.shape.rot.y - this->dyna.actor.shape.rot.y; + s16 yawDiff = player->actor.shape.rot.y - this->dyna.actor.shape.rot.y; + if (playerPosRelToDoor.z > 0.0f) { yawDiff = (0x8000 - yawDiff); } @@ -502,7 +499,7 @@ void func_80866B20(EnDoor* this, PlayState* play) { player->doorDirection = playerPosRelToDoor.z >= 0.0f ? 1.0f : -1.0f; player->doorActor = &this->dyna.actor; if (this->unk_1A6 != 0) { - if (gSaveContext.save.inventory.dungeonKeys[((void)0, gSaveContext.mapIndex)] <= 0) { + if (gSaveContext.save.saveInfo.inventory.dungeonKeys[((void)0, gSaveContext.mapIndex)] <= 0) { player->doorType = PLAYER_DOORTYPE_TALKING; this->dyna.actor.textId = 0x1802; } else { @@ -512,15 +509,14 @@ void func_80866B20(EnDoor* this, PlayState* play) { player->doorType = PLAYER_DOORTYPE_TALKING; this->dyna.actor.textId = 0x1800; } else if ((this->unk_1A4 == 0) || (this->unk_1A4 == 2) || (this->unk_1A4 == 3)) { - s32 textIdOffset; + s32 halfDaysDayBit = (play->actorCtx.halfDaysBit & HALFDAYBIT_DAWNS) >> 1; + s32 halfDaysNightBit = play->actorCtx.halfDaysBit & HALFDAYBIT_NIGHTS; + s16 temp_a2 = D_801AED48[this->switchFlag & 7]; + s32 textIdOffset = (this->switchFlag >> 3) & 0xF; - temp_t0 = (play->actorCtx.unkC & 0x2AA) >> 1; - temp_a2 = D_801AED48[this->switchFlag & 7]; - temp_a1_2 = play->actorCtx.unkC & 0x155; - textIdOffset = (this->switchFlag >> 3) & 0xF; - if (((this->unk_1A4 == 0) && (((temp_t0 | temp_a1_2) & temp_a2) == 0)) || - ((this->unk_1A4 == 2) && ((temp_a2 & temp_a1_2) == 0)) || - ((this->unk_1A4 == 3) && ((temp_a2 & temp_t0) == 0))) { + if (((this->unk_1A4 == 0) && !((halfDaysDayBit | halfDaysNightBit) & temp_a2)) || + ((this->unk_1A4 == 2) && !(halfDaysNightBit & temp_a2)) || + ((this->unk_1A4 == 3) && !(halfDaysDayBit & temp_a2))) { s16 baseTextId = 0x182D; if (this->unk_1A4 == 3) { @@ -532,10 +528,10 @@ void func_80866B20(EnDoor* this, PlayState* play) { this->dyna.actor.textId = baseTextId + textIdOffset; } } else if ((this->unk_1A4 == 5) && (playerPosRelToDoor.z > 0.0f)) { - ScheduleOutput sp30; + ScheduleOutput scheduleOutput; - if (Schedule_RunScript(play, D_8086778C[this->switchFlag], &sp30)) { - this->dyna.actor.textId = sp30.result + 0x1800; + if (Schedule_RunScript(play, D_8086778C[this->switchFlag], &scheduleOutput)) { + this->dyna.actor.textId = scheduleOutput.result + 0x1800; player->doorType = ((this->dyna.actor.textId == 0x1821) && D_80867BC0) ? PLAYER_DOORTYPE_PROXIMITY @@ -545,7 +541,7 @@ void func_80866B20(EnDoor* this, PlayState* play) { func_80122F28(player); } } else if ((this->unk_1A4 == 4) && (this->dyna.actor.xzDistToPlayer > 240.0f)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_OPEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_DOOR_OPEN); this->actionFunc = func_80867080; } } @@ -566,7 +562,7 @@ void func_80866F94(EnDoor* this, PlayState* play) { } else { if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, 0, 0x7D0)) { this->actionFunc = func_80866B20; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_AUTO_DOOR_CLOSE); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_AUTO_DOOR_CLOSE); } } } @@ -587,7 +583,7 @@ void func_80867080(EnDoor* this, PlayState* play) { void func_808670F0(EnDoor* this, PlayState* play) { if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, 0, 0x700)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_CLOSE); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_DOOR_CLOSE); this->actionFunc = func_80866B20; } } @@ -601,7 +597,7 @@ void func_80867144(EnDoor* this, PlayState* play) { this->actionFunc = func_80866B20; this->unk_1A1 = 0; } else if (Animation_OnFrame(&this->skelAnime, sAnimOpenFrames[this->animIndex])) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_OC_DOOR_OPEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_OC_DOOR_OPEN); if (this->skelAnime.playSpeed < 1.5f) { numEffects = (s32)(Rand_ZeroOne() * 30.0f) + 50; for (i = 0; i < numEffects; i++) { @@ -609,7 +605,7 @@ void func_80867144(EnDoor* this, PlayState* play) { } } } else if (Animation_OnFrame(&this->skelAnime, sAnimCloseFrames[this->animIndex])) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_CLOSE); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_DOOR_CLOSE); } } } diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c index 83b93cf52..9efb11474 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -244,7 +244,7 @@ void EnDragon_Init(Actor* thisx, PlayState* play) { this->action = DEEP_PYTHON_ACTION_IDLE; this->actor.hintId = TATL_HINT_ID_DEEP_PYTHON; this->scale = 0.5f; - this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_CANT_LOCK_ON; EnDragon_SetupRetreatOrIdle(this); } @@ -345,9 +345,9 @@ void EnDragon_RetreatOrIdle(EnDragon* this, PlayState* play) { EnDragon_SetupExtend(this); } else if ((this->timer != 0) && (fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 101.0f) && (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 101.0f)) { - this->actor.speedXZ = -100.0f; + this->actor.speed = -100.0f; } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if ((fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 4.0f) && (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 4.0f)) { @@ -362,7 +362,7 @@ void EnDragon_RetreatOrIdle(EnDragon* this, PlayState* play) { void EnDragon_SetupExtend(EnDragon* this) { this->state = 0; this->behindJawRetreatTimer = this->state; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_APPEAR_TRG); + Actor_PlaySfx(&this->actor, NA_SE_EN_UTSUBO_APPEAR_TRG); this->retreatTimer = 250; this->actionFunc = EnDragon_Extend; } @@ -375,25 +375,25 @@ void EnDragon_Extend(EnDragon* this, PlayState* play) { EnDragon_SpawnBubbles(this, play, this->jawPos); if (this->action >= DEEP_PYTHON_ACTION_DAMAGE) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_UTSUBO_BACK); EnDragon_SetupRetreatOrIdle(this); } else if (this->retreatTimer == 0) { this->action = DEEP_PYTHON_ACTION_RETREAT; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_UTSUBO_BACK); EnDragon_SetupRetreatOrIdle(this); } else if (this->state == DEEP_PYTHON_EXTEND_STATE_NOT_FULLY_EXTENDED) { Vec3f extendedPos; Math_Vec3f_Copy(&extendedPos, &this->burrowEntrancePos); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_APPEAR - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_UTSUBO_APPEAR - SFX_FLAG); extendedPos.x += Math_SinS(this->actor.world.rot.y) * -530.0f; extendedPos.z += Math_CosS(this->actor.world.rot.y) * -530.0f; - this->actor.speedXZ = 40.0f; + this->actor.speed = 40.0f; Math_SmoothStepToS(&this->jawZRotation, 0xFA0, 5, 0xBB8, 0x14); if ((fabsf(this->actor.world.pos.x - extendedPos.x) < 51.0f) && (fabsf(this->actor.world.pos.z - extendedPos.z) < 51.0f)) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Math_ApproachF(&this->actor.world.pos.x, extendedPos.x, 0.3f, 50.0f); Math_ApproachF(&this->actor.world.pos.z, extendedPos.z, 0.3f, 50.0f); if ((fabsf(this->actor.world.pos.x - extendedPos.x) < 4.0f) && @@ -439,7 +439,7 @@ void EnDragon_Extend(EnDragon* this, PlayState* play) { this->behindJawRetreatTimer++; if (this->behindJawRetreatTimer > 60) { this->action = DEEP_PYTHON_ACTION_RETREAT; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_UTSUBO_BACK); EnDragon_SetupRetreatOrIdle(this); } } @@ -447,7 +447,7 @@ void EnDragon_Extend(EnDragon* this, PlayState* play) { } void EnDragon_SetSubCamEyeAt(EnDragon* this, PlayState* play, Vec3f subCamEye, Vec3f subCamAt) { - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->actor.csId); Math_Vec3f_Copy(&this->subCamEye, &subCamEye); Math_Vec3f_Copy(&this->subCamAt, &subCamAt); Play_SetCameraAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); @@ -458,10 +458,10 @@ void EnDragon_SetupGrab(EnDragon* this, PlayState* play) { Vec3f extendedPos; s16 yaw; - if (!ActorCutscene_GetCanPlayNext(this->grabCutsceneIndex)) { - ActorCutscene_SetIntentToPlay(this->grabCutsceneIndex); + if (!CutsceneManager_IsNext(this->grabCsId)) { + CutsceneManager_Queue(this->grabCsId); } else { - ActorCutscene_StartAndSetUnkLinkFields(this->grabCutsceneIndex, &this->actor); + CutsceneManager_StartWithPlayerCs(this->grabCsId, &this->actor); Math_Vec3f_Copy(&extendedPos, &this->burrowEntrancePos); extendedPos.x += Math_SinS(this->actor.world.rot.y) * -530.0f; extendedPos.z += Math_CosS(this->actor.world.rot.y) * -530.0f; @@ -496,7 +496,7 @@ void EnDragon_Grab(EnDragon* this, PlayState* play) { Vec3f pos; // used as both the extended position and the camera eye Vec3f subCamAt; - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->actor.csId); SkelAnime_Update(&this->skelAnime); if (this->grabTimer == 0) { @@ -513,7 +513,7 @@ void EnDragon_Grab(EnDragon* this, PlayState* play) { pos.z += Math_CosS(this->actor.world.rot.y) * -930.0f; Math_Vec3f_Copy(&this->actor.world.pos, &pos); this->jawZRotation = 0x1450; - this->actor.speedXZ = 60.0f; + this->actor.speed = 60.0f; } this->grabTimer++; @@ -535,7 +535,7 @@ void EnDragon_Grab(EnDragon* this, PlayState* play) { if (this->grabTimer > sMaxGrabTimerPerPython[this->pythonIndex]) { if (this->state == DEEP_PYTHON_GRAB_STATE_START) { - func_800B7298(play, &this->actor, PLAYER_CSMODE_6); + func_800B7298(play, &this->actor, PLAYER_CSMODE_END); this->state = DEEP_PYTHON_GRAB_STATE_GRABBED; } @@ -543,7 +543,7 @@ void EnDragon_Grab(EnDragon* this, PlayState* play) { player->actor.parent = &this->actor; player->unk_AE8 = 50; this->action = DEEP_PYTHON_ACTION_GRAB; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_EAT); + Actor_PlaySfx(&this->actor, NA_SE_EN_UTSUBO_EAT); EnDragon_SetupAttack(this); } } @@ -572,8 +572,8 @@ void EnDragon_Attack(EnDragon* this, PlayState* play) { //! @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 skelAnime - func_800B8E58((Player*)this, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BITE); + Player_PlaySfx((Player*)&this->actor, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S); + Actor_PlaySfx(&this->actor, NA_SE_EN_UTSUBO_BITE); CollisionCheck_GreenBlood(play, NULL, &player->actor.world.pos); } @@ -603,7 +603,7 @@ void EnDragon_Attack(EnDragon* this, PlayState* play) { Math_ApproachF(&this->actor.world.pos.z, pos.z, 0.3f, 200.0f); if ((this->state <= DEEP_PYTHON_ATTACK_STATE_START) && (this->endFrame <= currentFrame)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BITE); + Actor_PlaySfx(&this->actor, NA_SE_EN_UTSUBO_BITE); if (this->animIndex != DEEP_PYTHON_ANIM_LARGE_SIDE_SWAY) { EnDragon_ChangeAnim(this, DEEP_PYTHON_ANIM_LARGE_SIDE_SWAY); } @@ -617,7 +617,7 @@ void EnDragon_Attack(EnDragon* this, PlayState* play) { (this->collider.elements[2].info.bumperFlags & BUMP_HIT)) { player->actor.parent = NULL; this->grabWaitTimer = 30; - ActorCutscene_Stop(this->grabCutsceneIndex); + CutsceneManager_Stop(this->grabCsId); if (player->stateFlags2 & PLAYER_STATE2_80) { player->unk_AE8 = 100; } @@ -634,10 +634,10 @@ void EnDragon_Attack(EnDragon* this, PlayState* play) { } void EnDragon_SetupDead(EnDragon* this, PlayState* play) { - if (!ActorCutscene_GetCanPlayNext(this->deathCutsceneIndex)) { - ActorCutscene_SetIntentToPlay(this->deathCutsceneIndex); + if (!CutsceneManager_IsNext(this->deathCsId)) { + CutsceneManager_Queue(this->deathCsId); } else { - ActorCutscene_StartAndSetUnkLinkFields(this->deathCutsceneIndex, &this->actor); + CutsceneManager_StartWithPlayerCs(this->deathCsId, &this->actor); this->endFrame = Animation_GetLastFrame(&gDeepPythonSmallSideSwayAnim); Animation_Change(&this->skelAnime, &gDeepPythonSmallSideSwayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); this->timer = 20; @@ -655,7 +655,7 @@ void EnDragon_Dead(EnDragon* this, PlayState* play) { if ((this->timer != 0) && (fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 121.0f) && (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 121.0f)) { - this->actor.speedXZ = -120.0f; + this->actor.speed = -120.0f; if (((this->pythonIndex & 1) == 0) && (Rand_ZeroOne() < 0.5f)) { //! @bug: !play->gameplayFrames is 0 essentially all the time, so this code never runs. if (((!play->gameplayFrames) & 0x1F)) { @@ -667,7 +667,7 @@ void EnDragon_Dead(EnDragon* this, PlayState* play) { return; } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if ((fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 20.0f) && (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 20.0f)) { Math_ApproachF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.3f, 300.0f); @@ -682,8 +682,8 @@ void EnDragon_Dead(EnDragon* this, PlayState* play) { seahorsePos.y += -100.0f + BREG(33); seahorsePos.z += (Math_CosS((this->actor.parent->world.rot.y + 0x8000)) * (500.0f + BREG(38))); if (Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_OT, seahorsePos.x, seahorsePos.y, - seahorsePos.z, 0, this->actor.shape.rot.y, 0, 0x4000, this->actor.cutscene, - this->actor.unk20, NULL)) { + seahorsePos.z, 0, this->actor.shape.rot.y, 0, 0x4000, this->actor.csId, + this->actor.halfDaysBits, NULL)) { SET_WEEKEVENTREG(WEEKEVENTREG_13_01); switch (this->pythonIndex) { case 0: @@ -725,7 +725,7 @@ void EnDragon_Dead(EnDragon* this, PlayState* play) { void EnDragon_UpdateDamage(EnDragon* this, PlayState* play) { Player* player = GET_PLAYER(play); - u32 sp30; + PlayerImpactType playerImpactType; if (this->action == DEEP_PYTHON_ACTION_EXTEND) { if ((this->collider.elements[2].info.bumperFlags & BUMP_HIT) || @@ -735,14 +735,14 @@ void EnDragon_UpdateDamage(EnDragon* this, PlayState* play) { (this->collider.elements[6].info.bumperFlags & BUMP_HIT) || (this->collider.elements[7].info.bumperFlags & BUMP_HIT)) { Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 25); if (this->actor.colChkInfo.health > 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_UTSUBO_DAMAGE); this->action = DEEP_PYTHON_ACTION_DAMAGE; } else { Enemy_StartFinishingBlow(play, &this->actor); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_DEAD); - this->actor.flags |= ACTOR_FLAG_8000000; + Actor_PlaySfx(&this->actor, NA_SE_EN_UTSUBO_DEAD); + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~ACTOR_FLAG_1; this->actor.flags |= ACTOR_FLAG_100000; this->action = DEEP_PYTHON_ACTION_SETUP_DEAD; @@ -753,8 +753,9 @@ void EnDragon_UpdateDamage(EnDragon* this, PlayState* play) { if ((this->action == DEEP_PYTHON_ACTION_EXTEND) && (this->grabWaitTimer == 0) && (player->invincibilityTimer == 0) && (this->collider.elements[0].info.ocElemFlags & OCELEM_HIT) && - (!(func_800B64FC(play, 1000.0f, &this->actor.world.pos, &sp30) >= 0.0f) || (sp30 != 1))) { - this->actor.speedXZ = 0.0f; + !((Actor_GetPlayerImpact(play, 1000.0f, &this->actor.world.pos, &playerImpactType) >= 0.0f) && + (playerImpactType == PLAYER_IMPACT_ZORA_BARRIER))) { + this->actor.speed = 0.0f; this->action = DEEP_PYTHON_ACTION_GRAB; this->actor.flags |= ACTOR_FLAG_100000; this->actionFunc = EnDragon_SetupGrab; diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h index cb2ab9490..2d5f31b54 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h @@ -47,8 +47,8 @@ typedef struct EnDragon { /* 0x2BA */ s16 action; /* 0x2BC */ UNK_TYPE1 unk_2BC[0x2]; /* 0x2BE */ s16 state; - /* 0x2C0 */ s16 grabCutsceneIndex; - /* 0x2C2 */ s16 deathCutsceneIndex; + /* 0x2C0 */ s16 grabCsId; + /* 0x2C2 */ s16 deathCsId; /* 0x2C4 */ UNK_TYPE1 unk_2C4[0x4]; /* 0x2C8 */ s16 subCamId; /* 0x2CA */ s16 grabTimer; // Counts up from the time a grab starts until the time the actor begins attacking 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 dfd97196a..b25e4eb47 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 @@ -80,7 +80,7 @@ void EnDyExtra_Update(Actor* thisx, PlayState* play) { EnDyExtra* this = THIS; DECR(this->unk14C); - Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_SPIRAL_HEAL_BEAM - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_PL_SPIRAL_HEAL_BEAM - SFX_FLAG); this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); } diff --git a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c index de26515fa..509e4fa9a 100644 --- a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c +++ b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c @@ -7,7 +7,7 @@ #include "z_en_egblock.h" #include "objects/object_eg/object_eg.h" -#define FLAGS (ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnEgblock*)thisx) diff --git a/src/overlays/actors/ovl_En_Egol/z_en_egol.c b/src/overlays/actors/ovl_En_Egol/z_en_egol.c index 731497436..2c7fdc030 100644 --- a/src/overlays/actors/ovl_En_Egol/z_en_egol.c +++ b/src/overlays/actors/ovl_En_Egol/z_en_egol.c @@ -328,19 +328,19 @@ void EnEgol_FootstepEffects(EnEgol* this, PlayState* play, f32 leftFootFrame, f3 if (Animation_OnFrame(&this->skelAnime, leftFootFrame) || Animation_OnFrame(&this->skelAnime, rightFootFrame)) { Vec3f spawnPos; Player* player = GET_PLAYER(play); - s32 quakeSize; + s32 quakeYOffset; s32 pad; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_WALK); - quakeSize = 4 - (s32)(fabsf(player->actor.world.pos.y - this->actor.world.pos.y) * 0.02f); - if (quakeSize > 4) { - quakeSize = 4; - } else if (quakeSize < 1) { - quakeSize = 1; + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_WALK); + quakeYOffset = 4 - (s32)(fabsf(player->actor.world.pos.y - this->actor.world.pos.y) * 0.02f); + if (quakeYOffset > 4) { + quakeYOffset = 4; + } else if (quakeYOffset < 1) { + quakeYOffset = 1; } if (player->stateFlags3 != PLAYER_STATE3_1000000) { - func_800BC848(&this->actor, play, quakeSize, 2); + Actor_RequestQuakeAndRumble(&this->actor, play, quakeYOffset, 2); } if (Animation_OnFrame(&this->skelAnime, leftFootFrame)) { Math_Vec3f_Copy(&spawnPos, &this->leftFootPos); @@ -384,7 +384,7 @@ void EnEgol_DestroyBlocks(EnEgol* this, PlayState* play, Vec3f pos1, Vec3f pos2) dist2 = sqrtf(SQ(blockTo2.y)); if ((dist1 < 40.0f) || (dist2 < 40.0f)) { prop->colChkInfo.health = 0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALL_BROKEN); + Actor_PlaySfx(&this->actor, NA_SE_EV_WALL_BROKEN); break; } } @@ -476,7 +476,7 @@ void EnEgol_Destroy(Actor* thisx, PlayState* play) { } void EnEgol_SetupWait(EnEgol* this) { - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->action = EYEGORE_ACTION_WAIT; this->actionFunc = EnEgol_Wait; } @@ -493,9 +493,9 @@ void EnEgol_Wait(EnEgol* this, PlayState* play) { void EnEgol_SetupStand(EnEgol* this) { EnEgol_ChangeAnim(this, EYEGORE_ANIM_STAND); - this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_CANT_LOCK_ON; this->action = EYEGORE_ACTION_STAND; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_STAND); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_STAND); this->actionFunc = EnEgol_Stand; } @@ -741,7 +741,7 @@ void EnEgol_Laser(EnEgol* this, PlayState* play) { this->laserCount++; } } else if (this->laserState >= EYEGORE_LASER_FIRE) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_BEAM - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_BEAM - SFX_FLAG); if (this->laserState != EYEGORE_LASER_OFF) { EnEgol_DestroyBlocks(this, play, this->laserCollider.dim.quad[0], this->laserCollider.dim.quad[1]); } @@ -755,7 +755,7 @@ void EnEgol_Laser(EnEgol* this, PlayState* play) { f32 nz; s32 pad3; s32 i; - s32 quakeSize; + s32 quakeYOffset; Player* player = GET_PLAYER(play); nx = COLPOLY_GET_NORMAL(colPoly->normal.x); @@ -767,22 +767,22 @@ void EnEgol_Laser(EnEgol* this, PlayState* play) { * rotToNorm.x = func_80086B30(nz, ny) * 0x8000 / M_PI; * rotToNorm.z = func_80086B30(-nx, sqrtf(1.0f - SQ(nx))) * 0x8000 / M_PI; */ - rotToNorm.x = -func_80086B30(-nz * ny, 1.0f) * 0x8000 / M_PI; - rotToNorm.z = func_80086B30(-nx * ny, 1.0f) * 0x8000 / M_PI; + rotToNorm.x = RAD_TO_BINANG_ALT2(-func_80086B30(-nz * ny, 1.0f)); + rotToNorm.z = RAD_TO_BINANG_ALT2(func_80086B30(-nx * ny, 1.0f)); if ((this->actor.world.pos.y - 50.0f) <= player->actor.world.pos.y) { EnEgol_SpawnEffect(this, &hitPos, &rotToNorm, 100, 0.02f, EYEGORE_EFFECT_IMPACT); } - quakeSize = 4 - (s32)(fabsf(player->actor.world.pos.y - this->actor.world.pos.y) * 0.02f); - if (quakeSize > 4) { - quakeSize = 4; - } else if (quakeSize < 1) { - quakeSize = 1; + quakeYOffset = 4 - (s32)(fabsf(player->actor.world.pos.y - this->actor.world.pos.y) * 0.02f); + if (quakeYOffset > 4) { + quakeYOffset = 4; + } else if (quakeYOffset < 1) { + quakeYOffset = 1; } if (player->stateFlags3 != PLAYER_STATE3_1000000) { - func_800BC848(&this->actor, play, quakeSize, 2); + Actor_RequestQuakeAndRumble(&this->actor, play, quakeYOffset, 2); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_EXPLOSION); + Actor_PlaySfx(&this->actor, NA_SE_EV_EXPLOSION); func_800B31BC(play, &hitPos, 40, -2, 255, 20); func_800BBFB0(play, &hitPos, 6.0f, 2, 120, 20, true); @@ -855,7 +855,7 @@ void EnEgol_Stop(EnEgol* this, PlayState* play) { this->isRetreating ^= true; if (!this->isRetreating) { EnEgol_ChangeAnim(this, EYEGORE_ANIM_SIT); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_SIT); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_SIT); this->laserCount = 0; this->actionFunc = EnEgol_Wait; } else { @@ -880,16 +880,16 @@ void EnEgol_Slam(EnEgol* this, PlayState* play) { Player* player = GET_PLAYER(play); Vec3f spawnPos; f32 dyToPlayer = fabsf(player->actor.world.pos.y - this->actor.world.pos.y); - s32 quakeSize; + s32 quakeYOffset; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_EXPLOSION); - quakeSize = 4 - (s32)(dyToPlayer * 0.02f); - if (quakeSize > 4) { - quakeSize = 4; - } else if (quakeSize < 1) { - quakeSize = 1; + Actor_PlaySfx(&this->actor, NA_SE_EV_EXPLOSION); + quakeYOffset = 4 - (s32)(dyToPlayer * 0.02f); + if (quakeYOffset > 4) { + quakeYOffset = 4; + } else if (quakeYOffset < 1) { + quakeYOffset = 1; } - func_800BC848(&this->actor, play, quakeSize, 2); + Actor_RequestQuakeAndRumble(&this->actor, play, quakeYOffset, 2); if (this->actor.floorBgId == BGCHECK_SCENE) { Math_Vec3f_Copy(&spawnPos, &this->actor.world.pos); spawnPos.x += Math_SinS(this->actor.world.rot.y) * 60.0f; @@ -1033,8 +1033,8 @@ void EnEgol_Damaged(EnEgol* this, PlayState* play) { EnEgol_SetupWalk(this); } else { Enemy_StartFinishingBlow(play, &this->actor); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEAD); - this->actor.flags |= ACTOR_FLAG_8000000; + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_DEAD); + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~ACTOR_FLAG_1; this->actor.flags |= ACTOR_FLAG_100000; this->actionFunc = EnEgol_StartDeathCutscene; @@ -1043,11 +1043,11 @@ void EnEgol_Damaged(EnEgol* this, PlayState* play) { } void EnEgol_StartDeathCutscene(EnEgol* this, PlayState* play) { - if (!ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + if (!CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Queue(this->actor.csId); } else { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->actor.csId); this->subCamFovTarget = 60.0f; EnEgol_ChangeAnim(this, EYEGORE_ANIM_DEATH); this->action = EYEGORE_ACTION_DYING; @@ -1064,7 +1064,7 @@ void EnEgol_Death(EnEgol* this, PlayState* play) { this->subCamAt.y = 60.0f; this->subCamAt.z = 260.0f; Math_Vec3f_Copy(&atOffset, &this->subCamAt); - OLib_DbCameraVec3fSum(&this->actor.world, &atOffset, &this->subCamAt, 1); + OLib_Vec3fAdd(&this->actor.world, &atOffset, &this->subCamAt, OLIB_ADD_OFFSET); this->subCamEye.x = this->actor.world.pos.x; this->subCamEye.y = this->actor.world.pos.y + 70.0f; this->subCamEye.z = this->actor.world.pos.z; @@ -1075,12 +1075,12 @@ void EnEgol_Death(EnEgol* this, PlayState* play) { if (this->switchFlag > -1) { Flags_SetSwitch(play, this->switchFlag); } - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); Actor_Kill(&this->actor); } else { if (Animation_OnFrame(&this->skelAnime, 46.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_EXPLOSION); - func_800BC848(&this->actor, play, 10, 5); + Actor_PlaySfx(&this->actor, NA_SE_EV_EXPLOSION); + Actor_RequestQuakeAndRumble(&this->actor, play, 10, 5); } if ((curFrame >= this->animEndFrame) && (this->action != EYEGORE_ACTION_DEAD)) { s32 i; @@ -1088,7 +1088,7 @@ void EnEgol_Death(EnEgol* this, PlayState* play) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_SMALL_EXPLOSION); this->waitTimer = 30; - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfx(&this->actor, NA_SE_IT_BOMB_EXPLOSION); this->action = EYEGORE_ACTION_DEAD; for (i = 0; i < 20; i++) { EnEgol_SpawnEffect(this, &this->actor.world.pos, &gZeroVec3s, 10.0f + Rand_ZeroFloat(20.0f), @@ -1145,8 +1145,9 @@ void EnEgol_CollisionCheck(EnEgol* this, PlayState* play) { Math_Vec3f_Copy(&this->laserCollider.dim.quad[3], &this->laserBase); Math_Vec3f_Copy(&this->laserCollider.dim.quad[0], &this->laserBase); Math_Vec3f_Copy(&this->laserCollider.dim.quad[2], &this->laserBase); - Actor_SetColorFilter(&this->actor, 0, 120, false, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 120, COLORFILTER_BUFFLAG_OPA, + 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); EnEgol_SetupStunned(this); } } @@ -1167,8 +1168,8 @@ void EnEgol_CollisionCheck(EnEgol* this, PlayState* play) { CollisionCheck_BlueBlood(play, NULL, &this->eyePos); CollisionCheck_BlueBlood(play, NULL, &this->eyePos); CollisionCheck_BlueBlood(play, NULL, &this->eyePos); - Actor_SetColorFilter(&this->actor, 0x4000, 255, false, 25); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DAMAGE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 25); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_DAMAGE); EnEgol_SetupDamaged(this); } else if (reaction == EYEGORE_HIT_IMMUNE) { Vec3f hitPos; @@ -1176,7 +1177,7 @@ void EnEgol_CollisionCheck(EnEgol* this, PlayState* play) { hitPos.x = this->eyeCollider.elements[0].info.bumper.hitPos.x; hitPos.y = this->eyeCollider.elements[0].info.bumper.hitPos.y; hitPos.z = this->eyeCollider.elements[0].info.bumper.hitPos.z; - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SHIELD_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_IT_SHIELD_BOUND); EffectSsHitmark_SpawnFixedScale(play, EFFECT_HITMARK_METAL, &hitPos); CollisionCheck_SpawnShieldParticlesMetal(play, &hitPos); } @@ -1293,7 +1294,9 @@ void EnEgol_Update(Actor* thisx, PlayState* play) { Math_SmoothStepToS(&this->eyelidRot, this->eyelidRotTarget, 1, 0x7D0, 0); EnEgol_CollisionCheck(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 50.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 50.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); if (this->action != EYEGORE_ACTION_DEAD) { //! @bug This should be ||, not &&. As is, the check always succeeds. if (!((this->action == EYEGORE_ACTION_DAMAGED) && (this->action == EYEGORE_ACTION_DYING))) { @@ -1453,7 +1456,7 @@ void EnEgol_Draw(Actor* thisx, PlayState* play2) { AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gEyegoreEyeLaserTexAnim)); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnEgol_OverrideLimbDraw, EnEgol_PostLimbDraw, &this->actor); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); } if (this->dmgEffectTimer != 0) { f32 drawDmgEffAlpha = 0.05f * this->dmgEffectTimer; 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 54d5c3210..615d59196 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -233,7 +233,7 @@ void func_8088C9CC(EnElf* this, PlayState* play) { this->unk_244 = 2; this->unk_248 = 0x400; this->unk_254 = 2.0f; - this->actor.speedXZ = 1.5f; + this->actor.speed = 1.5f; this->unk_26C = func_8088C920; this->unk_25C = (s32)Rand_ZeroFloat(8.0f) + 4; } else { @@ -355,8 +355,9 @@ void EnElf_Init(Actor* thisx, PlayState* play2) { this->elfMsg = NULL; this->unk_234 = NULL; this->unk_269 = 20; - if ((gSaveContext.save.playerData.tatlTimer >= 25800) || (gSaveContext.save.playerData.tatlTimer < 3000)) { - gSaveContext.save.playerData.tatlTimer = 0; + if ((gSaveContext.save.saveInfo.playerData.tatlTimer >= 25800) || + (gSaveContext.save.saveInfo.playerData.tatlTimer < 3000)) { + gSaveContext.save.saveInfo.playerData.tatlTimer = 0; } this->unk_266 = QuestHint_GetTatlTextId(play); break; @@ -558,9 +559,9 @@ void func_8088D9BC(EnElf* this, PlayState* play) { Vec3f* vec = &this->unk_224; if (this->fairyFlags & 0x4000) { - Math_SmoothStepToF(&this->actor.speedXZ, 5.0f, 0.5f, 1.0f, 0.01f); + Math_SmoothStepToF(&this->actor.speed, 5.0f, 0.5f, 1.0f, 0.01f); } else { - Math_SmoothStepToF(&this->actor.speedXZ, this->unk_254, 0.2f, 0.5f, 0.01f); + Math_SmoothStepToF(&this->actor.speed, this->unk_254, 0.2f, 0.5f, 0.01f); } switch (this->unk_244) { @@ -606,7 +607,7 @@ void func_8088DB4C(EnElf* this, Vec3f* arg1, f32 arg2, f32 arg3, f32 arg4) { xzVelocity = sqrtf(SQ(xVelTarget) + SQ(zVelTarget)); clampedXZ = CLAMP(xzVelocity, arg2, arg3); - this->actor.speedXZ = clampedXZ; + this->actor.speed = clampedXZ; if ((xzVelocity != clampedXZ) && (xzVelocity != 0.0f)) { xzVelocity = clampedXZ / xzVelocity; @@ -700,7 +701,7 @@ void func_8088DD34(EnElf* this, PlayState* play) { } if (this->fairyFlags & 0x2000) { - Actor_PickUp(&this->actor, play, GI_MAX, 80.0f, 60.0f); + Actor_OfferGetItem(&this->actor, play, GI_MAX, 80.0f, 60.0f); } } @@ -768,7 +769,7 @@ void func_8088E0F0(EnElf* this, PlayState* play) { this->unk_258 = Math_Atan2S_XY(this->actor.velocity.z, this->actor.velocity.x); func_8088F5F4(this, play, 32); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); } void func_8088E304(EnElf* this, PlayState* play) { @@ -802,7 +803,7 @@ void func_8088E304(EnElf* this, PlayState* play) { func_8088D7F8(this, &player->bodyPartsPos[PLAYER_BODYPART_WAIST]); this->unk_258 = Math_Atan2S_XY(this->actor.velocity.z, this->actor.velocity.x); func_8088F5F4(this, play, 0x20); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); } void func_8088E484(EnElf* this, PlayState* play) { @@ -827,7 +828,7 @@ void func_8088E484(EnElf* this, PlayState* play) { Actor_SetScale(&this->actor, (1.0f - (SQ(this->unk_250) * SQ(1.0f / 9.0f))) * 0.008f); this->unk_258 = Math_Atan2S_XY(this->actor.velocity.z, this->actor.velocity.x); func_8088F5F4(this, play, 32); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); } void func_8088E5A8(EnElf* this, PlayState* play) { @@ -854,8 +855,8 @@ void func_8088E60C(EnElf* this, PlayState* play) { glowLightRadius = 0; } - if (Cutscene_CheckActorAction(play, 201)) { - if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 201)]->action == 6) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_201)) { + if (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_201)]->id == 6) { glowLightRadius = 0; } } @@ -882,18 +883,18 @@ void func_8088E850(EnElf* this, PlayState* play) { Actor* arrowPointedActor; f32 xScale; f32 distFromLinksHead; - u32 sp38; + u32 cueChannel; func_8088F214(this, play); func_8088E5A8(this, play); xScale = 0.0f; - if (Cutscene_CheckActorAction(play, 201)) { - sp38 = Cutscene_GetActorActionIndex(play, 201); - func_808908D0(&nextPos, play, sp38); - this->actor.shape.rot.y = play->csCtx.actorActions[sp38]->urot.y; - this->actor.shape.rot.x = play->csCtx.actorActions[sp38]->urot.x; - if (play->csCtx.actorActions[sp38]->action == 5) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_201)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_201); + func_808908D0(&nextPos, play, cueChannel); + this->actor.shape.rot.y = play->csCtx.actorCues[cueChannel]->rot.y; + this->actor.shape.rot.x = play->csCtx.actorCues[cueChannel]->rot.x; + if (play->csCtx.actorCues[cueChannel]->id == 5) { func_8088F5F4(this, play, 16); } @@ -903,15 +904,14 @@ void func_8088E850(EnElf* this, PlayState* play) { func_8088D660(this, &nextPos, 0.2f); } - if ((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 0) && - (play->csCtx.currentCsIndex == 0) && - ((play->csCtx.frames == 149) || (play->csCtx.frames == 381) || (play->csCtx.frames == 591))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + if ((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 0) && (play->csCtx.scriptIndex == 0) && + ((play->csCtx.curFrame == 149) || (play->csCtx.curFrame == 381) || (play->csCtx.curFrame == 591))) { + Actor_PlaySfx(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } - if ((play->sceneId == SCENE_SECOM) && (gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 4) && - (play->csCtx.frames == 95)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + if ((play->sceneId == SCENE_SECOM) && (gSaveContext.sceneLayer == 0) && (play->csCtx.scriptIndex == 4) && + (play->csCtx.curFrame == 95)) { + Actor_PlaySfx(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } } else { this->actor.shape.rot.x = 0; @@ -976,7 +976,7 @@ void func_8088E850(EnElf* this, PlayState* play) { if (arrowPointedActor != NULL) { func_8088DB4C(this, &nextPos, 0.0f, 30.0f, 0.2f); - if (this->actor.speedXZ >= 5.0f) { + if (this->actor.speed >= 5.0f) { func_8088F5F4(this, play, 0x10); } } else { @@ -994,7 +994,7 @@ void func_8088E850(EnElf* this, PlayState* play) { if (distFromLinksHead > 100.0f) { this->fairyFlags |= 2; if (this->unk_269 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); + Actor_PlaySfx(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); } this->unk_25C = 100; } @@ -1015,7 +1015,7 @@ void func_8088E850(EnElf* this, PlayState* play) { func_8088E60C(this, play); - if (!Cutscene_CheckActorAction(play, 0xC9)) { + if (!Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_201)) { this->actor.shape.rot.y = this->unk_258; } } @@ -1064,7 +1064,7 @@ void func_8088EFA4(EnElf* this, PlayState* play) { this->unk_268 = 0; this->unk_238 = 1.0f; if (!this->unk_269) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); + Actor_PlaySfx(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); } } else if (this->unk_268 == 0) { if ((arrayPointerActor == NULL) || @@ -1090,10 +1090,10 @@ void func_8088EFA4(EnElf* this, PlayState* play) { } } else if ((arrayPointerActor != NULL) && (player->targetedActor != NULL)) { u8 temp = this->unk_269; - u16 targetSfxId = this->unk_269 == 0 ? NA_SE_PL_WALK_GROUND - SFX_FLAG : NA_SE_PL_WALK_GROUND - SFX_FLAG; + u16 targetSfxId = (this->unk_269 == 0) ? NA_SE_NONE : NA_SE_NONE; if (!temp) { - Actor_PlaySfxAtPos(&this->actor, targetSfxId); + Actor_PlaySfx(&this->actor, targetSfxId); } this->fairyFlags |= 1; } @@ -1105,9 +1105,9 @@ void func_8088F214(EnElf* this, PlayState* play) { Player* player = GET_PLAYER(play); s32 pad; - if (play->csCtx.state != 0) { - if (Cutscene_CheckActorAction(play, 201)) { - switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 201)]->action) { + if (play->csCtx.state != CS_STATE_IDLE) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_201)) { + switch (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_201)]->id) { case 4: sp34 = 7; break; @@ -1149,7 +1149,7 @@ void func_8088F214(EnElf* this, PlayState* play) { sp34 = 0; } else if (!(player->stateFlags1 & PLAYER_STATE1_40)) { if (this->unk_269 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); + Actor_PlaySfx(&this->actor, NA_SE_EV_NAVY_VANISH); } sp34 = 5; } else { @@ -1198,7 +1198,7 @@ void func_8088F214(EnElf* this, PlayState* play) { if (!(player->stateFlags2 & PLAYER_STATE2_100000)) { sp34 = 5; if (this->unk_269 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); + Actor_PlaySfx(&this->actor, NA_SE_EV_NAVY_VANISH); } } break; @@ -1208,7 +1208,7 @@ void func_8088F214(EnElf* this, PlayState* play) { sp34 = 9; this->unk_25C = 0x2A; if (this->unk_269 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); + Actor_PlaySfx(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); } } else if (player->stateFlags1 & PLAYER_STATE1_40) { player->stateFlags2 |= PLAYER_STATE2_100000; @@ -1299,7 +1299,7 @@ void func_8088FA38(EnElf* this, PlayState* play) { refPos = this->actor.focus.pos; func_8088DB4C(this, &refPos, 0, 30.0f, 0.2f); - if (this->actor.speedXZ >= 5.0f) { + if (this->actor.speed >= 5.0f) { func_8088F5F4(this, play, 0x10); } @@ -1324,19 +1324,19 @@ void func_8088FC34(EnElf* this, PlayState* play) { } void func_8088FD04(EnElf* this) { - if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + if (CutsceneManager_GetCurrentCsId() == this->actor.csId) { this->unk_264 &= ~1; this->unk_264 |= 2; - } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->actor.csId); this->unk_264 |= 1; - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); this->unk_264 &= ~1; this->unk_264 |= 2; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); this->unk_264 |= 1; } } @@ -1347,8 +1347,8 @@ void func_8088FDCC(EnElf* this) { this->fairyFlags &= ~0x20; this->actor.focus.pos = this->actor.world.pos; this->unk_234 = NULL; - if ((this->unk_264 & 2) && (this->actor.cutscene != 0x7C)) { - ActorCutscene_Stop(this->actor.cutscene); + if ((this->unk_264 & 2) && (this->actor.csId != CS_ID_GLOBAL_TALK)) { + CutsceneManager_Stop(this->actor.csId); } this->unk_264 &= ~0x20; } @@ -1376,11 +1376,11 @@ void func_8088FE64(Actor* thisx, PlayState* play2) { switch (play->msgCtx.choiceIndex) { case 0: - func_80151938(play, play->msgCtx.currentTextId - 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId - 1); break; case 1: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; } } @@ -1390,7 +1390,7 @@ void func_8088FE64(Actor* thisx, PlayState* play2) { if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x240: - func_80151938(play, 0x245); + Message_ContinueTextbox(play, 0x245); break; case 0x21D: @@ -1407,28 +1407,28 @@ void func_8088FE64(Actor* thisx, PlayState* play2) { case 0x244: switch (CURRENT_DAY) { case 1: - func_80151938(play, 0x246); + Message_ContinueTextbox(play, 0x246); break; case 2: - func_80151938(play, 0x247); + Message_ContinueTextbox(play, 0x247); break; case 3: if (!gSaveContext.save.isNight) { - func_80151938(play, 0x248); + Message_ContinueTextbox(play, 0x248); } else if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && CHECK_WEEKEVENTREG(WEEKEVENTREG_74_20)) { - func_80151938(play, 0x225); + Message_ContinueTextbox(play, 0x225); } else { - func_80151938(play, 0x249); + Message_ContinueTextbox(play, 0x249); } break; } break; default: - func_801477B4(play); + Message_CloseTextbox(play); func_8088FDCC(this); break; } @@ -1455,11 +1455,12 @@ void func_8089010C(Actor* thisx, PlayState* play) { if (temp_v0 != this->unk_266) { this->unk_266 = temp_v0; - gSaveContext.save.playerData.tatlTimer = 0; + gSaveContext.save.saveInfo.playerData.tatlTimer = 0; } if ((player->tatlTextId == 0) && (player->targetedActor == NULL)) { - if ((gSaveContext.save.playerData.tatlTimer >= 600) && (gSaveContext.save.playerData.tatlTimer <= 3000)) { + if ((gSaveContext.save.saveInfo.playerData.tatlTimer >= 600) && + (gSaveContext.save.saveInfo.playerData.tatlTimer <= 3000)) { player->tatlTextId = QuestHint_GetTatlTextId(play); } } @@ -1474,7 +1475,7 @@ void func_8089010C(Actor* thisx, PlayState* play) { if (thisx->textId == QuestHint_GetTatlTextId(play)) { this->fairyFlags |= 0x80; - gSaveContext.save.playerData.tatlTimer = 3001; + gSaveContext.save.saveInfo.playerData.tatlTimer = 3001; } this->fairyFlags |= 0x10; @@ -1482,9 +1483,9 @@ void func_8089010C(Actor* thisx, PlayState* play) { thisx->update = func_8088FE64; func_8088C51C(this, 3); if (this->elfMsg != NULL) { - this->elfMsg->flags |= ACTOR_FLAG_100; - thisx->cutscene = this->elfMsg->cutscene; - if (thisx->cutscene != -1) { + this->elfMsg->flags |= ACTOR_FLAG_TALK_REQUESTED; + thisx->csId = this->elfMsg->csId; + if (thisx->csId != CS_ID_NONE) { func_8088FD04(this); } if (this->elfMsg->home.rot.x == -0x961) { @@ -1492,7 +1493,7 @@ void func_8089010C(Actor* thisx, PlayState* play) { Actor_ChangeFocus(thisx, play, this->elfMsg); } } else { - thisx->cutscene = -1; + thisx->csId = CS_ID_NONE; } thisx->flags &= ~ACTOR_FLAG_10000; } else if (this->unk_264 & 4) { @@ -1505,10 +1506,10 @@ void func_8089010C(Actor* thisx, PlayState* play) { this->actionFunc(this, play); if (!Play_InCsMode(play)) { - if (gSaveContext.save.playerData.tatlTimer < 25800) { - gSaveContext.save.playerData.tatlTimer++; + if (gSaveContext.save.saveInfo.playerData.tatlTimer < 25800) { + gSaveContext.save.saveInfo.playerData.tatlTimer++; } else if (!(this->fairyFlags & 0x80)) { - gSaveContext.save.playerData.tatlTimer = 0; + gSaveContext.save.saveInfo.playerData.tatlTimer = 0; } } } @@ -1525,7 +1526,7 @@ void func_8089010C(Actor* thisx, PlayState* play) { this->unk_269--; } - if (!this->unk_269 && (play->csCtx.state != 0)) { + if (!this->unk_269 && (play->csCtx.state != CS_STATE_IDLE)) { this->unk_269 = 1; } } @@ -1578,8 +1579,8 @@ void EnElf_Draw(Actor* thisx, PlayState* play) { if (player->currentMask != PLAYER_MASK_GIANT) { if (!(this->fairyFlags & 8) && - (!Cutscene_CheckActorAction(play, 201) || - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 201)]->action != 6)) && + (!Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_201) || + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_201)]->id != 6)) && (!(player->stateFlags1 & PLAYER_STATE1_100000) || (kREG(90) < this->actor.projectedPos.z))) { Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, 4 * sizeof(Gfx)); f32 alphaScale; @@ -1622,17 +1623,17 @@ void EnElf_Draw(Actor* thisx, PlayState* play) { void func_808908D0(Vec3f* vec, PlayState* play, u32 action) { Vec3f startPos; Vec3f endPos; - CsCmdActorAction* npcAction = play->csCtx.actorActions[action]; + CsCmdActorCue* cue = play->csCtx.actorCues[action]; f32 lerp; - startPos.x = npcAction->startPos.x; - startPos.y = npcAction->startPos.y; - startPos.z = npcAction->startPos.z; + startPos.x = cue->startPos.x; + startPos.y = cue->startPos.y; + startPos.z = cue->startPos.z; - endPos.x = npcAction->endPos.x; - endPos.y = npcAction->endPos.y; - endPos.z = npcAction->endPos.z; + endPos.x = cue->endPos.x; + endPos.y = cue->endPos.y; + endPos.z = cue->endPos.z; - lerp = Environment_LerpWeight(npcAction->endFrame, npcAction->startFrame, play->csCtx.frames); + lerp = Environment_LerpWeight(cue->endFrame, cue->startFrame, play->csCtx.curFrame); VEC3F_LERPIMPDST(vec, &startPos, &endPos, lerp); } diff --git a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c index 169d56fdd..a3f17f605 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c @@ -47,14 +47,14 @@ ActorInit En_Elfgrp_InitVars = { (ActorFunc)NULL, }; -void func_80A396B0(EnElfgrp* this, s32 arg1) { - while (arg1 > 0) { - if (this->actor.cutscene == -1) { +void func_80A396B0(EnElfgrp* this, s32 numCutscenes) { + while (numCutscenes > 0) { + if (this->actor.csId == CS_ID_NONE) { break; } - this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + this->actor.csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); - arg1--; + numCutscenes--; } } @@ -101,13 +101,13 @@ void EnElfgrp_Init(Actor* thisx, PlayState* play) { break; case ENELFGRP_2: - if (gSaveContext.save.playerData.isDoubleMagicAcquired == true) { + if (gSaveContext.save.saveInfo.playerData.isDoubleMagicAcquired == true) { func_80A396B0(this, 1); } break; case ENELFGRP_3: - if (gSaveContext.save.playerData.doubleDefense) { + if (gSaveContext.save.saveInfo.playerData.doubleDefense) { func_80A396B0(this, 1); } break; @@ -125,7 +125,7 @@ void EnElfgrp_Init(Actor* thisx, PlayState* play) { this->actor.textId = (this->unk_147 * 3) + 0x581; } else { this->actionFunc = func_80A3A8F8; - if ((gSaveContext.save.weekEventReg[9] & this->unk_146)) { + if ((gSaveContext.save.saveInfo.weekEventReg[9] & this->unk_146)) { this->actor.textId = (this->unk_147 * 3) + 0x580; } else { this->actor.textId = (this->unk_147 * 3) + 0x57F; @@ -158,13 +158,13 @@ void EnElfgrp_Init(Actor* thisx, PlayState* play) { func_80A396B0(this, 3); this->unk_14A |= 2; } - } else if (gSaveContext.save.playerData.isMagicAcquired == true) { + } else if (gSaveContext.save.saveInfo.playerData.isMagicAcquired == true) { func_80A396B0(this, 1); } } else { func_80A39DC8(this, play, 24, 0); this->actionFunc = func_80A3A8F8; - if ((gSaveContext.save.weekEventReg[9] & this->unk_146)) { + if ((gSaveContext.save.saveInfo.weekEventReg[9] & this->unk_146)) { this->actor.textId = 0x580; } else { this->actor.textId = 0x578; @@ -183,7 +183,7 @@ s32 func_80A39BD0(PlayState* play, s32 arg2) { return 0; } - return (((void)0, gSaveContext.save.inventory.strayFairies[arg2 - 1]) - func_80A39C1C(play, arg2)) + 10; + return (((void)0, gSaveContext.save.saveInfo.inventory.strayFairies[arg2 - 1]) - func_80A39C1C(play, arg2)) + 10; } s32 func_80A39C1C(PlayState* play, s32 arg1) { @@ -207,13 +207,13 @@ s32 func_80A39C1C(PlayState* play, s32 arg1) { } if (arg1 == 0) { - if (gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 1) { + if (gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 & 1) { return 25; } return 24; } - temp_v1 = (gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 >> (((arg1 - 1) * 5) + 1)) & 0x1F; + temp_v1 = (gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 >> (((arg1 - 1) * 5) + 1)) & 0x1F; if (temp_v1 < 10) { temp_v1 = 10; } else if (temp_v1 > 25) { @@ -229,13 +229,13 @@ void func_80A39CD4(PlayState* play, s32 arg1, s32 arg2) { if (arg1 == 0) { if (arg2 == 25) { - gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 |= 1; + gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 |= 1; } else { - gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 &= ~1; + gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 &= ~1; } } else { - gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 &= ~(0x1F << ((arg1 * 5) - 4)); - gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 |= arg2 << ((arg1 * 5) - 4); + gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 &= ~(0x1F << ((arg1 * 5) - 4)); + gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 |= arg2 << ((arg1 * 5) - 4); } } @@ -345,9 +345,9 @@ void func_80A3A044(PlayState* play) { } void func_80A3A0AC(EnElfgrp* this, PlayState* play) { - if (!Cutscene_CheckActorAction(play, 0x64)) { + if (!Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_100)) { this->actionFunc = func_80A3A600; - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); } } @@ -386,12 +386,12 @@ void func_80A3A210(EnElfgrp* this, PlayState* play) { } void func_80A3A274(EnElfgrp* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 0x64)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_100)) { if (this->unk_14A & 1) { func_800B9010(&this->actor, NA_SE_PL_CHIBI_FAIRY_HEAL - SFX_FLAG); } - switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x64)]->action) { + switch (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_100)]->id) { case 2: if (!(this->unk_14A & 1)) { if (this->unk_147 == ENELFGRP_0) { @@ -414,8 +414,8 @@ void func_80A3A274(EnElfgrp* this, PlayState* play) { } void func_80A3A398(EnElfgrp* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); this->actionFunc = func_80A3A274; Flags_UnsetSwitch(play, ENELFGRP_GET_FE00(&this->actor)); if (this->unk_14A & 2) { @@ -431,7 +431,7 @@ void func_80A3A398(EnElfgrp* this, PlayState* play) { } this->unk_14A &= ~8; } else if (this->actor.xzDistToPlayer < 350.0f) { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -443,9 +443,10 @@ void func_80A3A484(EnElfgrp* this, PlayState* play) { } void func_80A3A4AC(EnElfgrp* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 0x64)) { - s32 temp = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x64)]->action; - if (temp == 3) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_100)) { + s32 cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_100)]->id; + + if (cueId == 3) { this->actionFunc = func_80A3A484; this->unk_144 = 90; } @@ -453,10 +454,10 @@ void func_80A3A4AC(EnElfgrp* this, PlayState* play) { } void func_80A3A520(EnElfgrp* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 0x67)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_103)) { this->actionFunc = func_80A3A600; - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); this->actionFunc = func_80A3A4AC; Flags_SetSwitch(play, ENELFGRP_GET_FE00(&this->actor)); @@ -468,7 +469,7 @@ void func_80A3A520(EnElfgrp* this, PlayState* play) { Flags_SetSwitch(play, this->actor.home.rot.z); } } else if (this->actor.xzDistToPlayer < 350.0f) { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -486,7 +487,7 @@ void func_80A3A610(EnElfgrp* this, PlayState* play) { if (this->unk_144 > 0) { player->actor.freezeTimer = 100; player->stateFlags1 |= PLAYER_STATE1_20000000; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_GROUP_HEAL - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EV_FAIRY_GROUP_HEAL - SFX_FLAG); } else { player->actor.freezeTimer = 0; player->stateFlags1 &= ~PLAYER_STATE1_20000000; @@ -524,7 +525,7 @@ void func_80A3A7FC(EnElfgrp* this, PlayState* play) { s32 temp_s0; if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - gSaveContext.save.weekEventReg[9] |= this->unk_146; + gSaveContext.save.saveInfo.weekEventReg[9] |= this->unk_146; this->actionFunc = func_80A3A6F4; temp_s0 = func_80A39BD0(play, this->unk_147); func_80A39DC8(this, play, temp_s0, 1); @@ -544,7 +545,7 @@ void func_80A3A8F8(EnElfgrp* this, PlayState* play) { Player* player = GET_PLAYER(play); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - gSaveContext.save.weekEventReg[9] |= this->unk_146; + gSaveContext.save.saveInfo.weekEventReg[9] |= this->unk_146; this->actionFunc = func_80A3A6F4; return; } @@ -563,7 +564,7 @@ void func_80A3A8F8(EnElfgrp* this, PlayState* play) { player->stateFlags1 |= PLAYER_STATE1_20000000; Message_StartTextbox(play, this->actor.textId, &this->actor); this->actionFunc = func_80A3A77C; - gSaveContext.save.weekEventReg[9] |= this->unk_146; + gSaveContext.save.saveInfo.weekEventReg[9] |= this->unk_146; } else { this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, play, 100.0f); @@ -579,7 +580,7 @@ void EnElfgrp_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); if (this->unk_14A & 8) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_GROUP_FRY - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EV_FAIRY_GROUP_FRY - SFX_FLAG); } if (this->unk_144 != 0) { 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 803a66ac4..871665cc6 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -55,7 +55,7 @@ static ColliderCylinderInit sCylinderInit = { }; void EnElforg_InitializeParams(EnElforg* this) { - this->actor.speedXZ = 1.0f; + this->actor.speed = 1.0f; this->targetSpeedXZ = 1.0f; this->actor.velocity.y = 0.0f; this->actor.world.rot.y = randPlusMinusPoint5Scaled(0x10000); @@ -189,22 +189,22 @@ void EnElforg_SpawnSparkles(EnElforg* this, PlayState* play, s32 life) { void EnElforg_ApproachTargetYPosition(EnElforg* this, Vec3f* targetPos) { f32 yDifference = targetPos->y - this->actor.world.pos.y; - if (fabsf(yDifference) < this->actor.speedXZ) { + if (fabsf(yDifference) < this->actor.speed) { this->actor.world.pos.y = targetPos->y; } else if (yDifference > 0.0f) { - this->actor.world.pos.y += this->actor.speedXZ; + this->actor.world.pos.y += this->actor.speed; } else { - this->actor.world.pos.y -= this->actor.speedXZ; + this->actor.world.pos.y -= this->actor.speed; } } void EnElforg_ApproachTargetSpeedXZ(EnElforg* this) { - if (this->actor.speedXZ > this->targetSpeedXZ) { - this->actor.speedXZ *= 0.9f; - } else if (this->actor.speedXZ < (this->targetSpeedXZ - 0.1f)) { - this->actor.speedXZ += 0.1f; + if (this->actor.speed > this->targetSpeedXZ) { + this->actor.speed *= 0.9f; + } else if (this->actor.speed < (this->targetSpeedXZ - 0.1f)) { + this->actor.speed += 0.1f; } else { - this->actor.speedXZ = this->targetSpeedXZ; + this->actor.speed = this->targetSpeedXZ; } } @@ -292,7 +292,7 @@ void EnElforg_TurnInFairy(EnElforg* this, PlayState* play) { // flying towards the fountain's center. SkelAnime_Update(&this->skelAnime); this->actor.shape.yOffset *= 0.9f; - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; EnElforg_ApproachTargetYPosition(this, &player->bodyPartsPos[PLAYER_BODYPART_WAIST]); xzDistToPlayer = this->actor.xzDistToPlayer; @@ -431,16 +431,16 @@ void EnElforg_ClockTownFairyCollected(EnElforg* this, PlayState* play) { player->stateFlags1 &= ~PLAYER_STATE1_20000000; Actor_Kill(&this->actor); SET_WEEKEVENTREG(WEEKEVENTREG_08_80); - ActorCutscene_Stop(0x7C); + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); return; } func_800B9010(&this->actor, NA_SE_PL_CHIBI_FAIRY_HEAL - SFX_FLAG); - if (ActorCutscene_GetCurrentIndex() != 0x7C) { - if (ActorCutscene_GetCanPlayNext(0x7C)) { - ActorCutscene_Start(0x7C, &this->actor); + if (CutsceneManager_GetCurrentCsId() != CS_ID_GLOBAL_TALK) { + if (CutsceneManager_IsNext(CS_ID_GLOBAL_TALK)) { + CutsceneManager_Start(CS_ID_GLOBAL_TALK, &this->actor); } else { - ActorCutscene_SetIntentToPlay(0x7C); + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); } } } @@ -485,21 +485,22 @@ void EnElforg_FreeFloating(EnElforg* this, PlayState* play) { // Bring me back to North Clock Town! Message_StartTextbox(play, 0x579, NULL); this->actionFunc = EnElforg_ClockTownFairyCollected; - ActorCutscene_SetIntentToPlay(0x7C); + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); return; } if (Map_IsInDungeonOrBossArea(play)) { - gSaveContext.save.inventory.strayFairies[gSaveContext.dungeonIndex]++; + gSaveContext.save.saveInfo.inventory.strayFairies[gSaveContext.dungeonIndex]++; // You found a Stray Fairy! Message_StartTextbox(play, 0x11, NULL); - if (gSaveContext.save.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex] >= 15) { + if (gSaveContext.save.saveInfo.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex] >= 15) { Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); } } } - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); func_80ACCBB8(this, play); if (Player_GetMask(play) == PLAYER_MASK_GREAT_FAIRY) { if (!(this->strayFairyFlags & STRAY_FAIRY_FLAG_GREAT_FAIRYS_MASK_EQUIPPED)) { @@ -539,7 +540,7 @@ void EnElforg_TrappedByEnemy(EnElforg* this, PlayState* play) { EnElforg_InitializeParams(this); this->actionFunc = EnElforg_FreeFloating; this->actor.draw = EnElforg_Draw; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHIBI_FAIRY_SAVED); + Actor_PlaySfx(&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. @@ -573,7 +574,7 @@ void EnElforg_HiddenByCollider(EnElforg* this, PlayState* play) { this->actor.draw = EnElforg_Draw; this->actor.world.pos.y += 40.0f; this->actor.home.pos.y += 40.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHIBI_FAIRY_SAVED); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHIBI_FAIRY_SAVED); } else { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } diff --git a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c index 2e6a44b64..834a6449f 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c @@ -5,15 +5,18 @@ */ #include "z_en_encount1.h" +#include "overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h" +#include "overlays/actors/ovl_En_Wallmas/z_en_wallmas.h" +#include "overlays/actors/ovl_En_Pr2/z_en_pr2.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnEncount1*)thisx) void EnEncount1_Init(Actor* thisx, PlayState* play); void EnEncount1_Update(Actor* thisx, PlayState* play); -void func_808E0954(EnEncount1* this, PlayState* play); +void EnEncount1_SpawnActor(EnEncount1* this, PlayState* play); ActorInit En_Encount1_InitVars = { ACTOR_EN_ENCOUNT1, @@ -27,14 +30,19 @@ ActorInit En_Encount1_InitVars = { (ActorFunc)NULL, }; -static s16 sActorList[] = { - ACTOR_EN_GRASSHOPPER, - ACTOR_EN_WALLMAS, - ACTOR_EN_PR2, - ACTOR_EN_PR2, +static s16 sActorIds[] = { + ACTOR_EN_GRASSHOPPER, // EN_ENCOUNT1_GRASSHOPPER + ACTOR_EN_WALLMAS, // EN_ENCOUNT1_WALLMASTER + ACTOR_EN_PR2, // EN_ENCOUNT1_SKULLFISH + ACTOR_EN_PR2, // EN_ENCOUNT1_SKULLFISH_2 }; -static s16 sActorParams[] = { 1, 0, 1, 3 }; +static s16 sActorParams[] = { + EN_GRASSHOPPER_PARAMS(EN_GRASSHOPPER_TYPE_GROWS_WHEN_SPAWNED), // EN_ENCOUNT1_GRASSHOPPER + WALLMASTER_PARAMS(WALLMASTER_TYPE_TIMER_ONLY, 0, false), // EN_ENCOUNT1_WALLMASTER + ENPR2_PARAMS(1, 0), // EN_ENCOUNT1_SKULLFISH + ENPR2_PARAMS(3, 0) // EN_ENCOUNT1_SKULLFISH_2 +}; void EnEncount1_Init(Actor* thisx, PlayState* play) { EnEncount1* this = THIS; @@ -44,69 +52,72 @@ void EnEncount1_Init(Actor* thisx, PlayState* play) { return; } - this->actorType = ENENCOUNT1_GET_TYPE(&this->actor); - this->unk_14C = ENENCOUNT1_GET_7C0(&this->actor); - this->unk_154 = ENENCOUNT1_GET_PATH(&this->actor); - this->unk_158 = this->actor.world.rot.x; - this->unk_15C = this->actor.world.rot.y; - this->unk_160 = (this->actor.world.rot.z * 40.0f) + 120.0f; + this->type = ENENCOUNT1_GET_TYPE(&this->actor); + this->spawnActiveMax = ENENCOUNT1_GET_SPAWN_ACTIVE_MAX(&this->actor); + this->spawnTotalMax = ENENCOUNT1_GET_SPAWN_TOTAL_MAX(&this->actor); + this->spawnTimeMin = ENENCOUNT1_GET_SPAWN_TIME_MIN(&this->actor); + this->spawnUnusedProp = ENENCOUNT1_GET_SPAWN_UNUSED_PROP(&this->actor); + this->spawnDistanceMax = (ENENCOUNT1_GET_SPAWN_DISTANCE_MAX(&this->actor) * 40.0f) + 120.0f; - if (this->unk_154 >= 0x3F) { - this->unk_154 = -1; + if (this->spawnTotalMax >= ENENCOUNT1_SPAWNS_TOTAL_MAX_INFINITE) { + this->spawnTotalMax = -1; } - if (this->actor.world.rot.z < 0) { - this->unk_160 = -1.0f; + if (ENENCOUNT1_GET_SPAWN_DISTANCE_MAX(&this->actor) < 0) { + this->spawnDistanceMax = -1.0f; } - if (this->actorType == EN_ENCOUNT1_SKULLFISH_2) { - this->unk_15A = ENENCOUNT1_GET_PATH(&this->actor); - this->path = SubS_GetPathByIndex(play, this->unk_15A, 0x3F); - this->unk_154 = -1; - this->unk_160 = -1.0f; + if (this->type == EN_ENCOUNT1_SKULLFISH_2) { + this->pathIndex = ENENCOUNT1_GET_PATH_INDEX(&this->actor); + this->path = SubS_GetPathByIndex(play, this->pathIndex, 0x3F); + this->spawnTotalMax = -1; + this->spawnDistanceMax = -1.0f; } this->actor.flags &= ~ACTOR_FLAG_1; - this->actionFunc = func_808E0954; + this->actionFunc = EnEncount1_SpawnActor; } -void func_808E0954(EnEncount1* this, PlayState* play) { +void EnEncount1_SpawnActor(EnEncount1* this, PlayState* play) { Player* player = GET_PLAYER(play); Vec3f spawnPos; - f32 sp64; - f32 temp_fv0_2; - s16 sp5E; - s16 actorList; + f32 scale; + f32 floorHeight; + s16 rotY; + s16 actorId; s32 actorParams; - CollisionPoly* sp54; - s32 sp50; + CollisionPoly* floorPoly; + s32 bgId; - if (((this->unk_14E >= this->unk_14C) || ((this->unk_160 > 0.0f) && (this->unk_160 < this->actor.xzDistToPlayer)) || - ((this->unk_154 > 0) && (this->unk_154 <= this->unk_152)))) { + if (((this->spawnActiveCount >= this->spawnActiveMax) || + ((this->spawnDistanceMax > 0.0f) && (this->spawnDistanceMax < this->actor.xzDistToPlayer)) || + ((this->spawnTotalMax > 0) && (this->spawnTotalMax <= this->spawnTotalCount)))) { return; - } else if (this->unk_156 != 0) { - this->unk_156++; - if (this->unk_156 < this->unk_158) { + } + + if (this->timer != 0) { + this->timer++; + if (this->timer < this->spawnTimeMin) { return; } } - this->unk_156 = 0; - switch (this->actorType) { + this->timer = 0; + switch (this->type) { case EN_ENCOUNT1_GRASSHOPPER: - sp64 = randPlusMinusPoint5Scaled(40.0f) + 200.0f; - sp5E = player->actor.shape.rot.y; - if (this->unk_14E & 1) { - sp5E = -sp5E; - sp64 = randPlusMinusPoint5Scaled(20.0f) + 100.0f; + scale = randPlusMinusPoint5Scaled(40.0f) + 200.0f; + rotY = player->actor.shape.rot.y; + if (this->spawnActiveCount & 1) { + rotY = -rotY; + scale = randPlusMinusPoint5Scaled(20.0f) + 100.0f; } - spawnPos.x = player->actor.world.pos.x + (Math_SinS(sp5E) * sp64) + randPlusMinusPoint5Scaled(40.0f); + spawnPos.x = player->actor.world.pos.x + (Math_SinS(rotY) * scale) + randPlusMinusPoint5Scaled(40.0f); spawnPos.y = player->actor.floorHeight + 120.0f; - spawnPos.z = player->actor.world.pos.z + (Math_CosS(sp5E) * sp64) + randPlusMinusPoint5Scaled(40.0f); - temp_fv0_2 = BgCheck_EntityRaycastFloor5(&play->colCtx, &sp54, &sp50, &this->actor, &spawnPos); - if ((temp_fv0_2 <= BGCHECK_Y_MIN) || + spawnPos.z = player->actor.world.pos.z + (Math_CosS(rotY) * scale) + randPlusMinusPoint5Scaled(40.0f); + floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &floorPoly, &bgId, &this->actor, &spawnPos); + if ((floorHeight <= BGCHECK_Y_MIN) || ((player->actor.depthInWater != BGCHECK_Y_MIN) && - (temp_fv0_2 < (player->actor.world.pos.y - player->actor.depthInWater)))) { + (floorHeight < (player->actor.world.pos.y - player->actor.depthInWater)))) { return; } - spawnPos.y = temp_fv0_2; + spawnPos.y = floorHeight; break; case EN_ENCOUNT1_WALLMASTER: @@ -114,36 +125,36 @@ void func_808E0954(EnEncount1* this, PlayState* play) { break; case EN_ENCOUNT1_SKULLFISH: - sp64 = randPlusMinusPoint5Scaled(250.0f) + 500.0f; - sp5E = player->actor.shape.rot.y; - spawnPos.x = player->actor.world.pos.x + Math_SinS(sp5E) * sp64 + randPlusMinusPoint5Scaled(40.0f); + scale = randPlusMinusPoint5Scaled(250.0f) + 500.0f; + rotY = player->actor.shape.rot.y; + spawnPos.x = player->actor.world.pos.x + (Math_SinS(rotY) * scale) + randPlusMinusPoint5Scaled(40.0f); spawnPos.y = player->actor.world.pos.y - Rand_ZeroFloat(20.0f); - spawnPos.z = player->actor.world.pos.z + (Math_CosS(sp5E) * sp64) + randPlusMinusPoint5Scaled(40.0f); - temp_fv0_2 = BgCheck_EntityRaycastFloor5(&play->colCtx, &sp54, &sp50, &this->actor, &spawnPos); - if ((!(player->stateFlags1 & 0x8000000) || (temp_fv0_2 <= (BGCHECK_Y_MIN)) || - (player->actor.depthInWater < temp_fv0_2))) { + spawnPos.z = player->actor.world.pos.z + (Math_CosS(rotY) * scale) + randPlusMinusPoint5Scaled(40.0f); + floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &floorPoly, &bgId, &this->actor, &spawnPos); + if (!(player->stateFlags1 & PLAYER_STATE1_8000000) || (floorHeight <= BGCHECK_Y_MIN) || + (player->actor.depthInWater < floorHeight)) { return; } break; case EN_ENCOUNT1_SKULLFISH_2: - if ((this->path != NULL) && (!SubS_CopyPointFromPath(this->path, 0, &spawnPos))) { + if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, 0, &spawnPos)) { Actor_Kill(&this->actor); } break; } - actorList = sActorList[this->actorType]; - actorParams = sActorParams[this->actorType]; - if (Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, actorList, spawnPos.x, spawnPos.y, spawnPos.z, 0, 0, 0, + actorId = sActorIds[this->type]; + actorParams = sActorParams[this->type]; + if (Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, actorId, spawnPos.x, spawnPos.y, spawnPos.z, 0, 0, 0, actorParams) != NULL) { - this->unk_14E++; - if (this->unk_154 > 0) { - this->unk_152++; + this->spawnActiveCount++; + if (this->spawnTotalMax > 0) { + this->spawnTotalCount++; } - if ((this->unk_14E >= this->unk_14C) && (this->unk_158 != 0)) { - this->unk_156 = 1; + if ((this->spawnActiveCount >= this->spawnActiveMax) && (this->spawnTimeMin != 0)) { + this->timer = 1; } } } diff --git a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h index 52e0fb30c..5c8e6db83 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h @@ -3,15 +3,22 @@ #include "global.h" +#define ENENCOUNT1_SPAWNS_TOTAL_MAX_INFINITE 63 // aka 0x3F, All bits set + #define ENENCOUNT1_GET_TYPE(thisx) (((thisx)->params >> 11) & 0x1F) -#define ENENCOUNT1_GET_7C0(thisx) (((thisx)->params >> 6) & 0x1F) -#define ENENCOUNT1_GET_PATH(thisx) ((thisx)->params & 0x3F) +#define ENENCOUNT1_GET_SPAWN_ACTIVE_MAX(thisx) (((thisx)->params >> 6) & 0x1F) +#define ENENCOUNT1_GET_SPAWN_TOTAL_MAX(thisx) ((thisx)->params & 0x3F) +#define ENENCOUNT1_GET_PATH_INDEX(thisx) ((thisx)->params & 0x3F) // Used only by EN_ENCOUNT1_SKULLFISH_2 which doesn't use SpawnTotalMax + +#define ENENCOUNT1_GET_SPAWN_TIME_MIN(thisx) ((thisx)->world.rot.x) // Time to wait between spawning +#define ENENCOUNT1_GET_SPAWN_UNUSED_PROP(thisx) ((thisx)->world.rot.y) // Unused spawn property +#define ENENCOUNT1_GET_SPAWN_DISTANCE_MAX(thisx) ((thisx)->world.rot.z) // Negative means infinite distance typedef enum EnEncount1Enemy { - /* 0x0 */ EN_ENCOUNT1_GRASSHOPPER, - /* 0x1 */ EN_ENCOUNT1_WALLMASTER, - /* 0x2 */ EN_ENCOUNT1_SKULLFISH, - /* 0x3 */ EN_ENCOUNT1_SKULLFISH_2, + /* 0 */ EN_ENCOUNT1_GRASSHOPPER, + /* 1 */ EN_ENCOUNT1_WALLMASTER, + /* 2 */ EN_ENCOUNT1_SKULLFISH, + /* 3 */ EN_ENCOUNT1_SKULLFISH_2, } EnEncount1Enemy; struct EnEncount1; @@ -22,16 +29,16 @@ typedef struct EnEncount1 { /* 0x000 */ Actor actor; /* 0x144 */ EnEncount1ActionFunc actionFunc; /* 0x148 */ Path* path; - /* 0x14C */ s16 unk_14C; - /* 0x14E */ s16 unk_14E; - /* 0x150 */ s16 actorType; - /* 0x152 */ s16 unk_152; - /* 0x154 */ s16 unk_154; - /* 0x156 */ s16 unk_156; - /* 0x158 */ s16 unk_158; - /* 0x15A */ s16 unk_15A; - /* 0x15C */ s32 unk_15C; - /* 0x160 */ f32 unk_160; + /* 0x14C */ s16 spawnActiveMax; + /* 0x14E */ s16 spawnActiveCount; + /* 0x150 */ s16 type; + /* 0x152 */ s16 spawnTotalCount; + /* 0x154 */ s16 spawnTotalMax; + /* 0x156 */ s16 timer; + /* 0x158 */ s16 spawnTimeMin; + /* 0x15A */ s16 pathIndex; + /* 0x15C */ s32 spawnUnusedProp; + /* 0x160 */ f32 spawnDistanceMax; } EnEncount1; // size = 0x164 #endif // Z_EN_ENCOUNT1_H 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 656ec7936..7450e3427 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -113,7 +113,7 @@ void EnEncount2_Init(Actor* thisx, PlayState* play) { this->dyna.actor.targetMode = 6; this->dyna.actor.colChkInfo.health = 1; - this->scale = 0.1; + this->scale = 0.1f; this->switchFlag = ENCOUNT2_GET_SWITCH_FLAG(&this->dyna.actor); if (this->switchFlag == 0x7F) { @@ -171,7 +171,7 @@ void EnEncount2_Popped(EnEncount2* this, PlayState* play) { EnEncount2_InitEffects(this, &curPos, 10); } - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_MUJURA_BALLOON_BROKEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_MUJURA_BALLOON_BROKEN); this->deathTimer = 30; this->actionFunc = EnEncount2_Die; } @@ -284,7 +284,7 @@ void EnEncount2_DrawEffects(EnEncount2* this, PlayState* play) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, sPtr->alpha); Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZF(DEGF_TO_RADF(play->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_RotateZF(DEG_TO_RAD(play->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); } diff --git a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c index 869d8681e..b2d172cfc 100644 --- a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c +++ b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c @@ -6,7 +6,7 @@ #include "z_en_encount3.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnEncount3*)thisx) diff --git a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c index 311668bfe..8d9a18cf1 100644 --- a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c +++ b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c @@ -6,7 +6,7 @@ #include "z_en_encount4.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnEncount4*)thisx) 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 6cdf54d70..2996ccc23 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 @@ -68,16 +68,18 @@ void EnEndingHero_Update(Actor* thisx, PlayState* play) { } this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } -static TexturePtr D_80C1E970[] = { - object_dt_Tex_007350, object_dt_Tex_009590, object_dt_Tex_009F90, object_dt_Tex_00A790, object_dt_Tex_00AB90, +static TexturePtr sEyeTextures[] = { + gDotourEyeShockTex, gDotourEyeOpenTex, gDotourEyeClosedTex, gDotourEyeLookDownTex, gDotourEyeSquintTex, }; -static TexturePtr D_80C1E984[] = { - object_dt_Tex_007750, - object_dt_Tex_00A390, - object_dt_Tex_00A490, +static TexturePtr sEyebrowTextures[] = { + gDotourEyebrowHighTex, + gDotourEyebrowMidTex, + gDotourEyebrowLowTex, }; void EnEndingHero_Draw(Actor* thisx, PlayState* play) { @@ -88,13 +90,13 @@ void EnEndingHero_Draw(Actor* thisx, PlayState* play) { func_8012C28C(play->state.gfxCtx); func_8012C2DC(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C1E970[this->unk242])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->unk242])); if (this->unk242 < 3) { index = this->unk242; } - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C1E984[index])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyebrowTextures[index])); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, NULL, &this->actor); 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 2650ad156..0cc20358a 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 @@ -61,7 +61,9 @@ void EnEndingHero2_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } void EnEndingHero2_Draw(Actor* thisx, PlayState* play) { 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 8dcc12199..aba7c4488 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 @@ -61,7 +61,9 @@ void EnEndingHero3_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } void EnEndingHero3_Draw(Actor* thisx, PlayState* play) { 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 333bbc918..39e920b9e 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 @@ -61,7 +61,9 @@ void EnEndingHero4_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } void EnEndingHero4_Draw(Actor* thisx, PlayState* play) { 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 ee62798f1..ddf866f94 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 @@ -62,7 +62,9 @@ void EnEndingHero5_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } Gfx* D_80C23BF0[] = { object_daiku_DL_0070C0, object_daiku_DL_006FB0, object_daiku_DL_006E80, object_daiku_DL_006D70, 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 8f19fe9f8..5324518de 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 @@ -101,7 +101,9 @@ void EnEndingHero6_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } void EnEndingHero6_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { @@ -121,9 +123,9 @@ void EnEndingHero6_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec } void EnEndingHero6_Draw(Actor* thisx, PlayState* play) { - static TexturePtr D_80C24280[] = { object_dt_Tex_007350, object_dt_Tex_009590, object_dt_Tex_009F90, - object_dt_Tex_00A790, object_dt_Tex_00AB90 }; - static TexturePtr D_80C24294[] = { object_dt_Tex_007750, object_dt_Tex_00A390, object_dt_Tex_00A490 }; + static TexturePtr sEyeTextures[] = { gDotourEyeShockTex, gDotourEyeOpenTex, gDotourEyeClosedTex, + gDotourEyeLookDownTex, gDotourEyeSquintTex }; + static TexturePtr sEyebrowTextures[] = { gDotourEyebrowHighTex, gDotourEyebrowMidTex, gDotourEyebrowLowTex }; s32 pad; EnEndingHero6* this = THIS; s32 index = 0; @@ -156,13 +158,13 @@ void EnEndingHero6_Draw(Actor* thisx, PlayState* play) { } if (this->npcIndex == 0) { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C24280[this->eyeState])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); if (this->eyeState < 3) { index = this->eyeState; } - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C24294[index])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyebrowTextures[index])); } SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, diff --git a/src/overlays/actors/ovl_En_Estone/z_en_estone.c b/src/overlays/actors/ovl_En_Estone/z_en_estone.c index c55ab5272..4081bd8e7 100644 --- a/src/overlays/actors/ovl_En_Estone/z_en_estone.c +++ b/src/overlays/actors/ovl_En_Estone/z_en_estone.c @@ -71,12 +71,12 @@ void EnEstone_Init(Actor* thisx, PlayState* play) { this->actor.shape.rot.y = this->actor.world.rot.y; if (this->actor.params == ENESTONE_TYPE_LARGE) { - this->actor.speedXZ = Rand_ZeroFloat(5.0f) + 2.0f; + this->actor.speed = Rand_ZeroFloat(5.0f) + 2.0f; this->scale = (Rand_ZeroFloat(1.0f) * 0.005f) + 0.005f; this->actor.velocity.y = Rand_ZeroFloat(10.0f) + 15.0f; this->actor.gravity = -2.0f; } else { - this->actor.speedXZ = Rand_ZeroFloat(3.0f) + 1.0f; + this->actor.speed = Rand_ZeroFloat(3.0f) + 1.0f; this->scale = (Rand_ZeroFloat(1.0f) * 0.003f) + 0.003f; this->actor.velocity.y = Rand_ZeroFloat(5.0f) + 7.0f; this->actor.gravity = -1.0f; @@ -121,8 +121,9 @@ void EnEstone_Active(EnEstone* this, PlayState* play) { Actor_Kill(&this->actor); return; } - if (((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f)) || (this->collider.base.atFlags & 4)) { - this->collider.base.atFlags &= ~4; + if (((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.velocity.y < 0.0f)) || + (this->collider.base.atFlags & AT_BOUNCED)) { + this->collider.base.atFlags &= ~AT_BOUNCED; if (this->actor.params == ENESTONE_TYPE_LARGE) { for (i = 0; i < 2; i++) { accel.x = 2.0f * (Rand_ZeroOne() - 0.5f); @@ -139,11 +140,11 @@ void EnEstone_Active(EnEstone* this, PlayState* play) { velocity.y = this->actor.floorHeight; Actor_SpawnFloorDustRing(play, &this->actor, &velocity, 0.0f, 10, 6.0f, 50, 30, true); this->actor.velocity.y = this->actor.gravity = 0.0f; - this->actor.speedXZ *= 0.3f; + this->actor.speed *= 0.3f; this->actor.shape.shadowScale = 0.0f; this->inactive = true; this->timer = 50; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALL_BROKEN); + Actor_PlaySfx(&this->actor, NA_SE_EV_WALL_BROKEN); this->actionFunc = EnEstone_Inactive; } else { //! FAKE: https://decomp.me/scratch/YiPVN @@ -173,7 +174,8 @@ void EnEstone_Update(Actor* thisx, PlayState* play2) { Actor_MoveWithGravity(&this->actor); if ((this->timer == 0) && !this->inactive) { - Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 50.0f, 100.0f, 0x1C); + Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 50.0f, 100.0f, + UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); } if (!this->inactive) { Collider_UpdateCylinder(&this->actor, &this->collider); @@ -193,9 +195,9 @@ void EnEstone_Draw(Actor* thisx, PlayState* play2) { OPEN_DISPS(play->state.gfxCtx); Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateXFApply(this->rot.x * (M_PI / 180.0f)); - Matrix_RotateYF(this->rot.y * (M_PI / 180.0f), MTXMODE_APPLY); - Matrix_RotateZF(this->rot.z * (M_PI / 180.0f), MTXMODE_APPLY); + Matrix_RotateXFApply(DEG_TO_RAD(this->rot.x)); + Matrix_RotateYF(DEG_TO_RAD(this->rot.y), MTXMODE_APPLY); + Matrix_RotateZF(DEG_TO_RAD(this->rot.z), MTXMODE_APPLY); Matrix_Scale(this->scale, this->scale, this->scale, MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); 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 32a4b7c82..a43d39c7c 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -315,10 +315,10 @@ void EnFall_Setup(EnFall* this, PlayState* play) { void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, PlayState* play) { static s32 sGiantsCutsceneState = 0; - if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 1) && (play->csCtx.scriptIndex == 0)) { switch (sGiantsCutsceneState) { case 0: - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { sGiantsCutsceneState += 2; } break; @@ -327,31 +327,31 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, PlayState* play) { if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_93_04)) { - if (ActorCutscene_GetCanPlayNext(0xC)) { - ActorCutscene_Start(0xC, &this->actor); + if (CutsceneManager_IsNext(12)) { + CutsceneManager_Start(12, &this->actor); sGiantsCutsceneState++; } else { - ActorCutscene_SetIntentToPlay(0xC); + CutsceneManager_Queue(12); } - } else if (ActorCutscene_GetCanPlayNext(0xB)) { - ActorCutscene_Start(0xB, &this->actor); + } else if (CutsceneManager_IsNext(11)) { + CutsceneManager_Start(11, &this->actor); SET_WEEKEVENTREG(WEEKEVENTREG_93_04); sGiantsCutsceneState++; } else { - ActorCutscene_SetIntentToPlay(0xB); + CutsceneManager_Queue(11); } - } else if (play->csCtx.frames > 1600) { + } else if (play->csCtx.curFrame > 1600) { play->nextEntrance = ENTRANCE(CLOCK_TOWER_ROOFTOP, 0); gSaveContext.nextCutsceneIndex = 0xFFF2; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_02; - gSaveContext.nextTransitionType = TRANS_TYPE_02; + play->transitionType = TRANS_TYPE_FADE_BLACK; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; sGiantsCutsceneState = 9; } break; case 9: - play->csCtx.frames--; + play->csCtx.curFrame--; break; } } @@ -359,15 +359,15 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, PlayState* play) { void EnFall_CrashingMoon_PerformCutsceneActions(EnFall* this, PlayState* play) { EnFall_CrashingMoon_HandleGiantsCutscene(this, play); - if (Cutscene_CheckActorAction(play, 0x85)) { - if (Cutscene_CheckActorAction(play, 133) && - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 133)]->action == 1) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_133)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_133) && + play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_133)]->id == 1) { this->actor.draw = NULL; } else { this->actor.draw = EnFall_Moon_Draw; - if (Cutscene_CheckActorAction(play, 133) && - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 133)]->action == 2) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 133)); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_133) && + play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_133)]->id == 2) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_133)); } } } else { @@ -376,11 +376,11 @@ void EnFall_CrashingMoon_PerformCutsceneActions(EnFall* this, PlayState* play) { } void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 133)) { - switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 133)]->action) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_133)) { + switch (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_133)]->id) { case 3: if (this->eyeGlowIntensity == 0.0f) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MOON_EYE_FLASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_MOON_EYE_FLASH); } this->eyeGlowIntensity += 1 / 30.0f; if (this->eyeGlowIntensity > 1.0f) { @@ -396,10 +396,10 @@ void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, PlayState* } void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 133)) { - switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 133)]->action) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_133)) { + switch (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_133)]->id) { case 2: - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 133)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_133)); break; case 4: @@ -409,41 +409,41 @@ void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, PlayStat } if ((play->sceneId == SCENE_OKUJOU) && (gSaveContext.sceneLayer == 2)) { - switch (play->csCtx.currentCsIndex) { + switch (play->csCtx.scriptIndex) { case 0: - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 1060: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MOON_SCREAM1); + Actor_PlaySfx(&this->actor, NA_SE_EN_MOON_SCREAM1); break; case 1089: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MOON_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EV_MOON_CRY); break; case 1303: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIP_MOON); + Actor_PlaySfx(&this->actor, NA_SE_EV_SLIP_MOON); break; } - if (play->csCtx.frames >= 1145) { + if (play->csCtx.curFrame >= 1145) { func_800B9010(&this->actor, NA_SE_EV_FALL_POWER - SFX_FLAG); } break; case 1: - switch (play->csCtx.frames) { + switch (play->csCtx.curFrame) { case 561: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MOON_SCREAM1); + Actor_PlaySfx(&this->actor, NA_SE_EN_MOON_SCREAM1); break; case 590: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MOON_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EV_MOON_CRY); break; case 737: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIP_MOON); + Actor_PlaySfx(&this->actor, NA_SE_EV_SLIP_MOON); break; } - if (play->csCtx.frames >= 650) { + if (play->csCtx.curFrame >= 650) { func_800B9010(&this->actor, NA_SE_EV_FALL_POWER - SFX_FLAG); } break; @@ -452,7 +452,7 @@ void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, PlayStat } void EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions(EnFall* this, PlayState* play) { - if (play->csCtx.state != 0 && play->sceneId == SCENE_OKUJOU) { + if ((play->csCtx.state != CS_STATE_IDLE) && (play->sceneId == SCENE_OKUJOU)) { func_800B9010(&this->actor, NA_SE_EV_MOON_FALL - SFX_FLAG); } } @@ -463,16 +463,16 @@ void EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions(EnFall* this, Pla void EnFall_Moon_PerformDefaultActions(EnFall* this, PlayState* play) { u16 currentDay; - if (Cutscene_CheckActorAction(play, 133)) { - if (Cutscene_CheckActorAction(play, 133) && - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 133)]->action == 1) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_133)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_133) && + play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_133)]->id == 1) { this->actor.draw = NULL; } else { Actor_SetScale(&this->actor, this->scale * 3.6f); this->actor.draw = EnFall_Moon_Draw; - if (Cutscene_CheckActorAction(play, 133) && - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 133)]->action == 2) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 133)); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_133) && + play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_133)]->id == 2) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_133)); } } } else { @@ -499,7 +499,7 @@ void EnFall_MoonsTear_Initialize(EnFall* this) { } this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); this->actor.world.rot.x = Math_Vec3f_Pitch(&this->actor.world.pos, &this->actor.home.pos); - this->actor.speedXZ = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->actor.home.pos) / 82.0f; + this->actor.speed = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->actor.home.pos) / 82.0f; this->actor.shape.rot.x = this->actor.world.rot.x; this->actor.shape.rot.y = this->actor.world.rot.y; } @@ -510,14 +510,15 @@ void EnFall_MoonsTear_DoNothing(EnFall* this, PlayState* play) { void EnFall_MoonsTear_Fall(EnFall* this, PlayState* play) { s32 pad; - if (Cutscene_CheckActorAction(play, 517) && - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 517)]->action == 2 && this->actor.draw == NULL) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_517) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_517)]->id == 2) && + (this->actor.draw == NULL)) { EnFall_MoonsTear_Initialize(this); } if (this->actor.draw != NULL) { - if (Math_Vec3f_StepTo(&this->actor.world.pos, &this->actor.home.pos, this->actor.speedXZ) <= 0.0f) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_BOUND_1); + if (Math_Vec3f_StepTo(&this->actor.world.pos, &this->actor.home.pos, this->actor.speed) <= 0.0f) { + Actor_PlaySfx(&this->actor, NA_SE_EV_GORON_BOUND_1); SET_WEEKEVENTREG(WEEKEVENTREG_74_80); SET_WEEKEVENTREG(WEEKEVENTREG_74_20); Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_TEST, this->actor.world.pos.x, @@ -574,11 +575,11 @@ void EnFall_Fireball_SetPerVertexAlpha(f32 fireballAlpha) { void EnFall_Fireball_Update(Actor* thisx, PlayState* play) { EnFall* this = THIS; - if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 2)) { - play->skyboxCtx.rotY -= 0.05f; + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 0) && (play->csCtx.scriptIndex == 2)) { + play->skyboxCtx.rot.y -= 0.05f; } - if (Cutscene_CheckActorAction(play, 450)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_450)) { this->actor.draw = EnFall_Fireball_Draw; if (this->flags & FLAG_FIRE_BALL_INTENSIFIES) { this->fireballIntensity += 0.01f; @@ -586,9 +587,9 @@ void EnFall_Fireball_Update(Actor* thisx, PlayState* play) { this->fireballIntensity = 1.0f; } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 450)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, 450)); - switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 450)]->action) { + switch (play->csCtx.actorCues[Cutscene_GetCueChannel(play, 450)]->id) { default: this->actor.draw = NULL; this->fireballAlpha = 0; @@ -625,7 +626,7 @@ void EnFall_Fireball_Update(Actor* thisx, PlayState* play) { this->actor.draw = NULL; } - if (Cutscene_CheckActorAction(play, 0x1C2) && this->fireballAlpha > 0) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_450) && (this->fireballAlpha > 0)) { func_8019F128(NA_SE_EV_MOON_FALL_LAST - SFX_FLAG); } Actor_SetScale(&this->actor, this->scale * 1.74f); @@ -682,9 +683,9 @@ s32 EnFall_RisingDebris_InitializeEffect(EnFall* this) { void EnFall_RisingDebris_Update(Actor* thisx, PlayState* play) { EnFall* this = THIS; - if (Cutscene_CheckActorAction(play, 451)) { - if (Cutscene_CheckActorAction(play, 451) && - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 451)]->action == 2) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_451)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_451) && + play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_451)]->id == 2) { EnFall_RisingDebris_UpdateEffects(this); EnFall_RisingDebris_InitializeEffect(this); } else if (this->activeDebrisEffectCount != 0) { @@ -699,10 +700,10 @@ void EnFall_RisingDebris_Update(Actor* thisx, PlayState* play) { void EnFall_FireRing_Update(Actor* thisx, PlayState* play) { EnFall* this = THIS; - if (Cutscene_CheckActorAction(play, 450) && - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 450)]->action == 5) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_450) && + play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_450)]->id == 5) { if (!(this->flags & FLAG_FIRE_RING_APPEARS)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_DM_RING_EXPLOSION); + Actor_PlaySfx(&this->actor, NA_SE_IT_DM_RING_EXPLOSION); } this->flags |= FLAG_FIRE_RING_APPEARS; } @@ -784,7 +785,7 @@ void EnFall_LodMoon_Draw(Actor* thisx, PlayState* play) { gSPDisplayList(POLY_OPA_DISP++, gLodmoonEyesDL); gSPLoadGeometryMode(POLY_OPA_DISP++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH); gSPDisplayList(POLY_OPA_DISP++, gLodmoonMoonDL); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); CLOSE_DISPS(play->state.gfxCtx); } @@ -798,7 +799,7 @@ void EnFall_LodMoon_DrawWithoutLerp(Actor* thisx, PlayState* play) { * to be 9000 units away before drawing it. */ void EnFall_LodMoon_DrawWithLerp(Actor* thisx, PlayState* play) { - f32 distanceToEye = Actor_DistanceToPoint(thisx, &play->view.eye); + f32 distanceToEye = Actor_WorldDistXYZToPoint(thisx, &play->view.eye); f32 scale; Vec3f translation; diff --git a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c index 33cf9a64d..28a6cc74c 100644 --- a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c +++ b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c @@ -44,7 +44,7 @@ void EnFall2_Init(Actor* thisx, PlayState* play) { this->unk2DC = Lib_SegmentedToVirtual(object_fall2_Matanimheader_008840); Actor_SetScale(&this->actor, 0.02f); this->actionFunc = func_80C1B9D4; - this->csActionIndex = 0x231; + this->cueType = CS_CMD_ACTOR_CUE_561; this->alphaLevel = 0.0f; } @@ -92,13 +92,13 @@ void EnFall2_DoNothing(EnFall2* this, PlayState* play) { void func_80C1B8B4(EnFall2* this) { this->actor.draw = EnFall2_Draw; - if (this->csActorAction == 1) { + if (this->cueId == 1) { Actor_SetScale(&this->actor, 0.02f); } } void func_80C1B8F0(EnFall2* this) { - switch (this->csActorAction) { + switch (this->cueId) { case 1: if (this->alphaLevel < 1.0f) { this->alphaLevel += 1.0f / 30.0f; @@ -125,12 +125,10 @@ void func_80C1B8F0(EnFall2* this) { void func_80C1B9D4(EnFall2* this, PlayState* play) { func_80183DE0(&this->skeletonInfo); - if (Cutscene_CheckActorAction(play, this->csActionIndex)) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csActionIndex)); - if (this->csActorAction != - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionIndex)]->action) { - this->csActorAction = - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csActionIndex)]->action; + if (Cutscene_IsCueInChannel(play, this->cueType)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); + if (this->cueId != play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id) { + this->cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; func_80C1B8B4(this); } func_80C1B8F0(this); diff --git a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.h b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.h index 41f064498..3555595f3 100644 --- a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.h +++ b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.h @@ -15,8 +15,8 @@ typedef struct EnFall2 { /* 0x228 */ Vec3s unk228[30]; /* 0x2DC */ AnimatedMaterial* unk2DC; /* 0x2E0 */ f32 alphaLevel; - /* 0x2E4 */ s16 csActorAction; - /* 0x2E6 */ u16 csActionIndex; + /* 0x2E4 */ s16 cueId; + /* 0x2E6 */ u16 cueType; /* 0x2E8 */ EnFall2ActionFunc actionFunc; } EnFall2; // size = 0x2EC diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.c b/src/overlays/actors/ovl_En_Famos/z_en_famos.c index 27dcabc23..3d68d34d7 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -273,7 +273,7 @@ void EnFamos_SetupDeathDebris(EnFamos* this) { s32 EnFamos_IsPlayerSeen(EnFamos* this, PlayState* play) { if ((Player_GetMask(play) != PLAYER_MASK_STONE) && - (Actor_XZDistanceToPoint(&GET_PLAYER(play)->actor, &this->calmPos) < this->aggroDistance) && + (Actor_WorldDistXZToPoint(&GET_PLAYER(play)->actor, &this->calmPos) < this->aggroDistance) && Actor_IsFacingPlayer(&this->actor, 0x5000)) { return true; } else { @@ -308,12 +308,12 @@ void EnFamos_UpdateFlipStatus(EnFamos* this) { if (this->hasFinishedRotating == true) { if (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) { this->animatedMaterialIndex = FAMOS_ANIMATED_MAT_NORMAL; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FAMOS_REVERSE2); + Actor_PlaySfx(&this->actor, NA_SE_EN_FAMOS_REVERSE2); } else { this->animatedMaterialIndex = FAMOS_ANIMATED_MAT_FLIPPED; this->flippedTimer = 100; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FAMOS_REVERSE1); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_FAMOS_REVERSE1); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_DAMAGE); } this->hasFinishedRotating = false; } @@ -322,7 +322,7 @@ void EnFamos_UpdateFlipStatus(EnFamos* this) { this->flippedTimer--; if (this->flippedTimer == 0) { if (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FAMOS_REVERSE2); + Actor_PlaySfx(&this->actor, NA_SE_EN_FAMOS_REVERSE2); } this->animatedMaterialIndex = FAMOS_ANIMATED_MAT_NORMAL; @@ -347,7 +347,7 @@ void EnFamos_UpdateFlipStatus(EnFamos* this) { */ void EnFamos_SetupStillIdle(EnFamos* this) { this->actionFunc = EnFamos_StillIdle; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void EnFamos_StillIdle(EnFamos* this, PlayState* play) { @@ -374,9 +374,9 @@ void EnFamos_SetupPathingIdle(EnFamos* this) { } Math_Vec3s_ToVec3f(&this->targetDest, &this->pathPoints[this->currentPathNode]); - this->targetYaw = Actor_YawToPoint(&this->actor, &this->targetDest); + this->targetYaw = Actor_WorldYawTowardPoint(&this->actor, &this->targetDest); this->actionFunc = EnFamos_PathingIdle; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void EnFamos_PathingIdle(EnFamos* this, PlayState* play) { @@ -396,10 +396,10 @@ void EnFamos_PathingIdle(EnFamos* this, PlayState* play) { * Famos lost player; Turning to face back toward home. */ void EnFamos_SetupTurnHome(EnFamos* this) { - this->targetYaw = Actor_YawToPoint(&this->actor, &this->calmPos); + this->targetYaw = Actor_WorldYawTowardPoint(&this->actor, &this->calmPos); Math_Vec3f_Copy(&this->targetDest, &this->calmPos); this->actionFunc = EnFamos_TurnHome; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void EnFamos_TurnHome(EnFamos* this, PlayState* play) { @@ -416,14 +416,14 @@ void EnFamos_TurnHome(EnFamos* this, PlayState* play) { */ void EnFamos_SetupReturnHome(EnFamos* this) { this->actor.world.rot.y = this->actor.shape.rot.y; - this->actor.world.rot.x = -Actor_PitchToPoint(&this->actor, &this->targetDest); + this->actor.world.rot.x = -Actor_WorldPitchTowardPoint(&this->actor, &this->targetDest); this->actionFunc = EnFamos_ReturnHome; } void EnFamos_ReturnHome(EnFamos* this, PlayState* play) { - f32 distanceToHome = Actor_XZDistanceToPoint(&this->actor, &this->targetDest); + f32 distanceToHome = Actor_WorldDistXZToPoint(&this->actor, &this->targetDest); - this->actor.shape.rot.y = Actor_YawToPoint(&this->actor, &this->targetDest); + this->actor.shape.rot.y = Actor_WorldYawTowardPoint(&this->actor, &this->targetDest); this->actor.world.rot.y = this->actor.shape.rot.y; EnFamos_UpdateBobbingHeight(this); if (this->isCalm) { @@ -439,9 +439,9 @@ void EnFamos_ReturnHome(EnFamos* this, PlayState* play) { EnFamos_SetupStillIdle(this); } } else if (distanceToHome < 40.0f) { - Math_StepToF(&this->actor.speedXZ, 0.5f, 0.3f); + Math_StepToF(&this->actor.speed, 0.5f, 0.3f); } else { - Math_StepToF(&this->actor.speedXZ, 3.0f, 0.3f); + Math_StepToF(&this->actor.speed, 3.0f, 0.3f); } } @@ -451,7 +451,7 @@ void EnFamos_ReturnHome(EnFamos* this, PlayState* play) { void EnFamos_SetupAlert(EnFamos* this) { this->actor.world.rot.y = this->actor.shape.rot.y; this->stateTimer = 8; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->isCalm == true) { this->isCalm = false; @@ -497,16 +497,16 @@ void EnFamos_Chase(EnFamos* this, PlayState* play) { abovePlayerPos.x = player->actor.world.pos.x; abovePlayerPos.y = player->actor.world.pos.y + 100.0f; abovePlayerPos.z = player->actor.world.pos.z; - this->actor.world.rot.x = -Actor_PitchToPoint(&this->actor, &abovePlayerPos); - Math_StepToF(&this->actor.speedXZ, 6.0f, 0.5f); + this->actor.world.rot.x = -Actor_WorldPitchTowardPoint(&this->actor, &abovePlayerPos); + Math_StepToF(&this->actor.speed, 6.0f, 0.5f); - surfaceType = func_800C9B18(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + surfaceType = SurfaceType_GetFloorProperty2(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); if ((this->actor.xzDistToPlayer < 30.0f) && (this->actor.floorHeight > BGCHECK_Y_MIN) && // close enough (surfaceType != 0xC && surfaceType != 0xD)) { EnFamos_SetupAttackAim(this); } else if ((Player_GetMask(play) == PLAYER_MASK_STONE) || - (this->aggroDistance < Actor_XZDistanceToPoint(&GET_PLAYER(play)->actor, &this->calmPos)) || + (this->aggroDistance < Actor_WorldDistXZToPoint(&GET_PLAYER(play)->actor, &this->calmPos)) || !Actor_IsFacingPlayer(&this->actor, 0x6000)) { EnFamos_SetupScanForPlayer(this); } @@ -514,8 +514,8 @@ void EnFamos_Chase(EnFamos* this, PlayState* play) { void EnFamos_SetupAttackAim(EnFamos* this) { Animation_PlayOnce(&this->skelAnime, &gFamosShakeAnim); - this->actor.speedXZ = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_VOICE); + this->actor.speed = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_AMOS_VOICE); this->actionFunc = EnFamos_AttackAim; } @@ -537,14 +537,14 @@ void EnFamos_Attack(EnFamos* this, PlayState* play) { s32 hitFloor; u32 surfaceType; - Math_StepToF(&this->actor.speedXZ, 20.0f, 2.0f); + Math_StepToF(&this->actor.speed, 20.0f, 2.0f); this->stateTimer--; if (this->stateTimer == 0) { this->emblemCollider.base.acFlags &= ~AC_ON; } - surfaceType = func_800C9B18(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); - hitFloor = this->actor.bgCheckFlags & 1; + surfaceType = SurfaceType_GetFloorProperty2(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + hitFloor = this->actor.bgCheckFlags & BGCHECKFLAG_GROUND; if (hitFloor || (this->actor.floorHeight == BGCHECK_Y_MIN) || (surfaceType == 0xC) || (surfaceType == 0xD)) { this->collider1.base.atFlags &= ~AT_ON; this->collider2.base.atFlags |= AT_ON; @@ -585,8 +585,8 @@ void EnFamos_SetupFinishAttack(EnFamos* this) { SkelAnime_Update(&this->skelAnime); this->emblemCollider.base.acFlags |= AC_ON; this->stateTimer = 3; - this->actor.speedXZ = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_EXPLOSION); + this->actor.speed = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EV_EXPLOSION); this->actionFunc = EnFamos_FinishAttack; } @@ -604,12 +604,12 @@ void EnFamos_FinishAttack(EnFamos* this, PlayState* play) { void EnFamos_SetupAttackRebound(EnFamos* this) { this->actor.world.rot.x = 0x4000; this->actionFunc = EnFamos_AttackRebound; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void EnFamos_AttackRebound(EnFamos* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 5.0f, 0.3f); - if (this->actor.speedXZ > 1.0f) { + Math_StepToF(&this->actor.speed, 5.0f, 0.3f); + if (this->actor.speed > 1.0f) { if (ABS_ALT(this->flipRot) > 0x4000) { func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT_REVERSE - SFX_FLAG); } else { @@ -617,8 +617,8 @@ void EnFamos_AttackRebound(EnFamos* this, PlayState* play) { } } - if ((this->baseHeight < this->actor.world.pos.y) || (this->actor.bgCheckFlags & 0x10)) { // touching ceiling - this->actor.speedXZ = 0.0f; + if ((this->baseHeight < this->actor.world.pos.y) || (this->actor.bgCheckFlags & BGCHECKFLAG_CEILING)) { + this->actor.speed = 0.0f; EnFamos_SetupChase(this); } } @@ -629,7 +629,7 @@ void EnFamos_AttackRebound(EnFamos* this, PlayState* play) { void EnFamos_SetupScanForPlayer(EnFamos* this) { this->stateTimer = 60; this->actionFunc = EnFamos_ScanForPlayer; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void EnFamos_ScanForPlayer(EnFamos* this, PlayState* play) { @@ -651,11 +651,11 @@ void EnFamos_ScanForPlayer(EnFamos* this, PlayState* play) { void EnFamos_SetupDeathSlam(EnFamos* this) { this->emblemCollider.base.acFlags &= ~AC_ON; this->stateTimer = 20; - this->actor.speedXZ = 0.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->actor.speed = 0.0f; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 20); this->flippedTimer = -1; this->actor.world.pos.y = this->actor.floorHeight - 60.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_DEAD); this->actionFunc = EnFamos_DeathSlam; } @@ -673,7 +673,7 @@ void EnFamos_DeathSlam(EnFamos* this, PlayState* play) { void EnFamos_SetupDeathExplosion(EnFamos* this) { this->actor.world.rot.x = 0x4000; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, false, 4); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 4); this->stateTimer = 25; Math_Vec3f_Copy(&this->targetDest, &this->actor.world.pos); this->actor.flags |= ACTOR_FLAG_10; @@ -681,9 +681,9 @@ void EnFamos_SetupDeathExplosion(EnFamos* this) { } void EnFamos_DeathExplosion(EnFamos* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 3.0f, 0.3f); + Math_StepToF(&this->actor.speed, 3.0f, 0.3f); if (this->actor.colorFilterTimer == 0) { - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, false, 4); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 4); } this->actor.world.pos.x = randPlusMinusPoint5Scaled(5.0f) + this->targetDest.x; @@ -691,7 +691,7 @@ void EnFamos_DeathExplosion(EnFamos* this, PlayState* play) { if (this->stateTimer == 1) { EnBom* explosion = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, ENBOM_0); + this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, BOMB_TYPE_BODY); if (explosion != NULL) { explosion->timer = 0; // instant explosion } @@ -712,7 +712,7 @@ void EnFamos_SetupDeathFade(EnFamos* this) { this->actor.flags &= ~ACTOR_FLAG_1; this->actor.shape.shadowDraw = NULL; this->actionFunc = EnFamos_DeathFade; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void EnFamos_DeathFade(EnFamos* this, PlayState* play) { @@ -766,9 +766,11 @@ void EnFamos_Update(Actor* thisx, PlayState* play) { } if (this->flippedTimer >= 0) { - Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 30.0f, 80.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 30.0f, 80.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); if ((this->actionFunc == EnFamos_Attack) && (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) && - (this->actor.bgCheckFlags & 1)) { // touch floor + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->actor.world.pos.y -= 60.0f; } } 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 6a4c357d9..868c43533 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.c +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.c @@ -178,7 +178,7 @@ void EnFg_Idle(EnFg* this, PlayState* play) { switch (EnFg_GetDamageEffect(this)) { case FG_DMGEFFECT_DEKUSTICK: this->actor.flags &= ~ACTOR_FLAG_1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_1); + Actor_PlaySfx(&this->actor, NA_SE_EV_FROG_CRY_1); this->skelAnime.playSpeed = 0.0f; this->actor.shape.shadowDraw = NULL; this->actor.scale.x *= 1.5f; @@ -204,7 +204,7 @@ void EnFg_Idle(EnFg* this, PlayState* play) { break; case FG_DMGEFFECT_EXPLOSION: this->actor.flags &= ~ACTOR_FLAG_1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_0); + Actor_PlaySfx(&this->actor, NA_SE_EV_FROG_CRY_0); if (1) {} this->actor.params = FG_BLACK; this->skelAnime.playSpeed = 0.0f; @@ -212,7 +212,7 @@ void EnFg_Idle(EnFg* this, PlayState* play) { this->actor.world.rot.y = Math_Vec3f_Yaw(&ac->world.pos, &this->actor.world.pos); this->actor.shape.rot = this->actor.world.rot; this->actor.velocity.y = 10.0f; - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; this->actor.gravity = -0.8f; this->bounceCounter = 1; this->timer = 0; @@ -220,7 +220,7 @@ void EnFg_Idle(EnFg* this, PlayState* play) { break; default: if (DECR(this->timer) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_JUMP); + Actor_PlaySfx(&this->actor, NA_SE_EV_FROG_JUMP); EnFg_ChangeAnim(&this->skelAnime, 3); this->actor.velocity.y = 10.0f; this->timer = Rand_S16Offset(30, 30); @@ -255,7 +255,7 @@ void EnFg_Jump(EnFg* this, PlayState* play) { break; case FG_DMGEFFECT_EXPLOSION: this->actor.flags &= ~ACTOR_FLAG_1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_0); + Actor_PlaySfx(&this->actor, NA_SE_EV_FROG_CRY_0); EnFg_ChangeAnim(&this->skelAnime, 0); this->actor.params = FG_BLACK; this->skelAnime.playSpeed = 0.0f; @@ -263,7 +263,7 @@ void EnFg_Jump(EnFg* this, PlayState* play) { this->actor.world.rot.y = Math_Vec3f_Yaw(&ac->world.pos, &this->actor.world.pos); this->actor.shape.rot = this->actor.world.rot; this->actor.velocity.y = 10.0f; - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; this->actor.gravity = -0.8f; this->bounceCounter = 1; this->timer = 0; @@ -275,7 +275,7 @@ void EnFg_Jump(EnFg* this, PlayState* play) { this->skelAnime.playSpeed = 0.0f; } - if ((this->actor.velocity.y <= 0.0f) && (this->actor.bgCheckFlags & 1)) { + if ((this->actor.velocity.y <= 0.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { EnFg_ChangeAnim(&this->skelAnime, 0); this->actionFunc = EnFg_Idle; this->actor.velocity.y = 0.0f; @@ -289,7 +289,7 @@ void EnFg_DoNothing(EnFg* this, PlayState* play) { } void EnFg_Knockback(EnFg* this, PlayState* play) { - if ((this->actor.velocity.y <= 0.0f) && (this->actor.bgCheckFlags & 1)) { + if ((this->actor.velocity.y <= 0.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->bounceCounter++; if (this->bounceCounter < 4) { this->actor.shape.rot.x += 0x1000; @@ -298,7 +298,7 @@ void EnFg_Knockback(EnFg* this, PlayState* play) { this->actionFunc = EnFg_DoNothing; } } else { - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->actor.world.rot.y = this->actor.wallYaw; this->actor.shape.rot = this->actor.world.rot; } @@ -338,14 +338,15 @@ void EnFg_Update(Actor* thisx, PlayState* play) { s32 flagSet; flag = this->actor.flags; - flagSet = ((flag & 0x2000) == 0x2000); + flagSet = CHECK_FLAG_ALL(flag, ACTOR_FLAG_2000); if (1) {} if (!flagSet) { - flagSet = ((flag & 0x8000) == 0x8000); + flagSet = CHECK_FLAG_ALL(flag, ACTOR_FLAG_8000); if (1) {} if (!flagSet) { this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, BASE_REG(16, 0), BASE_REG(16, 1), 0.0f, 0x5); + Actor_UpdateBgCheckInfo(play, &this->actor, sREG(0), sREG(1), 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } } 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 5cdcd99fe..434ee1b86 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h" #include "objects/object_firefly/object_firefly.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_4000) #define THIS ((EnFirefly*)thisx) @@ -140,7 +140,7 @@ void EnFirefly_Init(Actor* thisx, PlayState* play) { CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (this->actor.params & KEESE_INVISIBLE) { - this->actor.flags |= ACTOR_FLAG_80; + this->actor.flags |= ACTOR_FLAG_REACT_TO_LENS; this->actor.params = KEESE_GET_MAIN_TYPE(thisx); this->isInvisible = true; } @@ -208,19 +208,20 @@ s32 EnFirefly_ReturnToPerch(EnFirefly* this, PlayState* play) { return false; } - if (Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos) > 300.0f) { - distFromHome = Actor_DistanceToPoint(&this->actor, &this->actor.home.pos); + if (Actor_WorldDistXZToPoint(&player->actor, &this->actor.home.pos) > 300.0f) { + distFromHome = Actor_WorldDistXYZToPoint(&this->actor, &this->actor.home.pos); if (distFromHome < 5.0f) { EnFirefly_SetupPerch(this); } else { if (distFromHome * 0.05f < 1.0f) { - this->actor.speedXZ *= distFromHome * 0.05f; + this->actor.speed *= distFromHome * 0.05f; } - Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x300); + Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), + 0x300); Math_ScaledStepToS(&this->actor.shape.rot.x, - Actor_PitchToPoint(&this->actor, &this->actor.home.pos) + 0x1554, 0x100); + Actor_WorldPitchTowardPoint(&this->actor, &this->actor.home.pos) + 0x1554, 0x100); } return true; @@ -242,7 +243,7 @@ s32 EnFirefly_SeekTorch(EnFirefly* this, PlayState* play) { while (findTorch != NULL) { if ((findTorch->actor.id == ACTOR_OBJ_SYOKUDAI) && (findTorch->snuffTimer != OBJ_SYOKUDAI_SNUFF_OUT)) { - currentDist = Actor_DistanceBetweenActors(&this->actor, &findTorch->actor); + currentDist = Actor_WorldDistXYZToActor(&this->actor, &findTorch->actor); if (currentDist < currentMinDist) { currentMinDist = currentDist; closestTorch = findTorch; @@ -256,12 +257,13 @@ s32 EnFirefly_SeekTorch(EnFirefly* this, PlayState* play) { flamePos.y = closestTorch->actor.world.pos.y + 52.0f + 30.0f; flamePos.z = closestTorch->actor.world.pos.z; - if (Actor_DistanceToPoint(&this->actor, &flamePos) < 15.0f) { + if (Actor_WorldDistXYZToPoint(&this->actor, &flamePos) < 15.0f) { EnFirefly_Ignite(this); } else { - Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, &closestTorch->actor), + Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardActor(&this->actor, &closestTorch->actor), 0x300); - Math_ScaledStepToS(&this->actor.shape.rot.x, Actor_PitchToPoint(&this->actor, &flamePos) + 0x1554, 0x100); + Math_ScaledStepToS(&this->actor.shape.rot.x, Actor_WorldPitchTowardPoint(&this->actor, &flamePos) + 0x1554, + 0x100); } return true; @@ -272,8 +274,8 @@ s32 EnFirefly_SeekTorch(EnFirefly* this, PlayState* play) { void EnFirefly_SetupFlyIdle(EnFirefly* this) { this->timer = Rand_S16Offset(70, 100); - this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 1.5f; - Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x300); + this->actor.speed = (Rand_ZeroOne() * 1.5f) + 1.5f; + Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), 0x300); this->pitchTarget = ((this->maxAltitude < this->actor.world.pos.y) ? 0xC00 : -0xC00) + 0x1554; this->skelAnime.playSpeed = 1.0f; this->actionFunc = EnFirefly_FlyIdle; @@ -289,15 +291,15 @@ void EnFirefly_FlyIdle(EnFirefly* this, PlayState* play) { } isSkelAnimeUpdated = Animation_OnFrame(&this->skelAnime, 0.0f); - this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 1.5f; + this->actor.speed = (Rand_ZeroOne() * 1.5f) + 1.5f; if (!EnFirefly_ReturnToPerch(this, play) && !EnFirefly_SeekTorch(this, play)) { if (isSkelAnimeUpdated) { rand = Rand_ZeroOne(); if (rand < 0.5f) { - Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), - 0x300); + Math_ScaledStepToS(&this->actor.shape.rot.y, + Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), 0x300); } else if (rand < 0.8f) { this->actor.shape.rot.y += (s16)randPlusMinusPoint5Scaled(1536.0f); } @@ -315,9 +317,10 @@ void EnFirefly_FlyIdle(EnFirefly* this, PlayState* play) { this->pitchTarget = 0x2154; } } else { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->pitchTarget = 0x954; - } else if ((this->actor.bgCheckFlags & 0x10) || (this->maxAltitude < this->actor.world.pos.y)) { + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_CEILING) || + (this->maxAltitude < this->actor.world.pos.y)) { this->pitchTarget = 0x2154; } } @@ -325,7 +328,7 @@ void EnFirefly_FlyIdle(EnFirefly* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0x100); } - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 2, 0xC00, 0x300); } @@ -338,13 +341,13 @@ void EnFirefly_SetupFall(EnFirefly* this, PlayState* play) { this->timer = 40; this->actor.velocity.y = 0.0f; Animation_Change(&this->skelAnime, &object_firefly_Anim_00017C, 0.0f, 6.0f, 6.0f, ANIMMODE_ONCE, 0.0f); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_FFLY_DEAD); this->actor.flags |= ACTOR_FLAG_10; if (this->isInvisible) { - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0x2000, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_XLU, 40); } else { - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 40); } if (this->actor.colChkInfo.damageEffect == KEESE_DMGEFF_ICE) { @@ -370,7 +373,7 @@ void EnFirefly_SetupFall(EnFirefly* this, PlayState* play) { } if (this->actor.flags & ACTOR_FLAG_8000) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } this->actionFunc = EnFirefly_Fall; @@ -379,7 +382,7 @@ void EnFirefly_SetupFall(EnFirefly* this, PlayState* play) { // Fall to the ground after being hit void EnFirefly_Fall(EnFirefly* this, PlayState* play) { this->actor.colorFilterTimer = 40; - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); if (!(this->actor.flags & ACTOR_FLAG_8000)) { if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { @@ -387,7 +390,7 @@ void EnFirefly_Fall(EnFirefly* this, PlayState* play) { this->actor.shape.rot.y -= 0x300; } - if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { EnFirefly_SpawnIceEffects(this, play); EnFirefly_SetupDie(this); } @@ -396,7 +399,7 @@ void EnFirefly_Fall(EnFirefly* this, PlayState* play) { void EnFirefly_SetupDie(EnFirefly* this) { this->timer = 15; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnFirefly_Die; } @@ -432,9 +435,9 @@ void EnFirefly_DiveAttack(EnFirefly* this, PlayState* play) { this->timer--; } - Math_StepToF(&this->actor.speedXZ, 4.0f, 0.5f); + Math_StepToF(&this->actor.speed, 4.0f, 0.5f); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 2, 0xC00, 0x300); Math_ScaledStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0x100); } else if (Actor_IsFacingPlayer(&this->actor, 0x2800)) { @@ -447,19 +450,19 @@ void EnFirefly_DiveAttack(EnFirefly* this, PlayState* play) { preyPos.x = player->actor.world.pos.x; preyPos.y = player->actor.world.pos.y + 20.0f; preyPos.z = player->actor.world.pos.z; - Math_SmoothStepToS(&this->actor.shape.rot.x, Actor_PitchToPoint(&this->actor, &preyPos) + 0x1554, 2, 0x400, - 0x100); + Math_SmoothStepToS(&this->actor.shape.rot.x, Actor_WorldPitchTowardPoint(&this->actor, &preyPos) + 0x1554, 2, + 0x400, 0x100); } else { this->skelAnime.playSpeed = 1.5f; if (this->actor.xzDistToPlayer > 80.0f) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xC00, 0x300); } - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->pitchTarget = 0x954; } - if ((this->actor.bgCheckFlags & 0x10) || (this->maxAltitude < this->actor.world.pos.y)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_CEILING) || (this->maxAltitude < this->actor.world.pos.y)) { this->pitchTarget = 0x2154; } else { this->pitchTarget = 0x954; @@ -478,7 +481,7 @@ void EnFirefly_SetupRebound(EnFirefly* this) { this->actor.world.rot.x = 0x7000; this->timer = 18; this->skelAnime.playSpeed = 1.0f; - this->actor.speedXZ = 2.5f; + this->actor.speed = 2.5f; this->actionFunc = EnFirefly_Rebound; } @@ -487,7 +490,7 @@ void EnFirefly_Rebound(EnFirefly* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x100); Math_StepToF(&this->actor.velocity.y, 0.0f, 0.4f); - if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.15f)) { + if (Math_StepToF(&this->actor.speed, 0.0f, 0.15f)) { if (this->timer != 0) { this->timer--; } @@ -519,20 +522,21 @@ void EnFirefly_FlyAway(EnFirefly* this, PlayState* play) { return; } - Math_StepToF(&this->actor.speedXZ, 3.0f, 0.3f); + Math_StepToF(&this->actor.speed, 3.0f, 0.3f); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->pitchTarget = 0x954; - } else if ((this->actor.bgCheckFlags & 0x10) || (this->maxAltitude < this->actor.world.pos.y)) { + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_CEILING) || (this->maxAltitude < this->actor.world.pos.y)) { this->pitchTarget = 0x2154; } else { this->pitchTarget = 0x954; } - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 2, 0xC00, 0x300); } else { - Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x300); + Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), + 0x300); } Math_ScaledStepToS(&this->actor.shape.rot.x, this->pitchTarget, 0x100); @@ -540,24 +544,24 @@ void EnFirefly_FlyAway(EnFirefly* this, PlayState* play) { void EnFirefly_SetupStunned(EnFirefly* this) { if (this->isInvisible) { - Actor_SetColorFilter(&this->actor, 0, 255, 0x2000, this->timer); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_XLU, this->timer); } else { - Actor_SetColorFilter(&this->actor, 0, 255, 0, this->timer); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, this->timer); } if (this->actionFunc != EnFirefly_Stunned) { this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } this->auraType = KEESE_AURA_NONE; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = EnFirefly_Stunned; } void EnFirefly_Stunned(EnFirefly* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0x1554, 0x100); - if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { if (this->timer != 0) { this->timer--; } @@ -583,7 +587,7 @@ void EnFirefly_Stunned(EnFirefly* this, PlayState* play) { void EnFirefly_SetupPerch(EnFirefly* this) { this->timer = 1; this->actionFunc = EnFirefly_Perch; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } // When perching, sit on collision and flap at random intervals @@ -608,7 +612,7 @@ void EnFirefly_SetupDisturbDiveAttack(EnFirefly* this) { this->actor.shape.rot.x = 0x1554; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->timer = 50; - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; this->actionFunc = EnFirefly_DisturbDiveAttack; } @@ -627,7 +631,8 @@ void EnFirefly_DisturbDiveAttack(EnFirefly* this, PlayState* play) { preyPos.x = player->actor.world.pos.x; preyPos.y = player->actor.world.pos.y + 20.0f; preyPos.z = player->actor.world.pos.z; - Math_ScaledStepToS(&this->actor.shape.rot.x, Actor_PitchToPoint(&this->actor, &preyPos) + 0x1554, 0x100); + Math_ScaledStepToS(&this->actor.shape.rot.x, Actor_WorldPitchTowardPoint(&this->actor, &preyPos) + 0x1554, + 0x100); Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x300); } @@ -672,7 +677,7 @@ void EnFirefly_Update(Actor* thisx, PlayState* play2) { if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_FFLY_ATTACK); if (this->currentType != KEESE_NORMAL) { EnFirefly_Extinguish(this); @@ -698,7 +703,8 @@ void EnFirefly_Update(Actor* thisx, PlayState* play2) { } } - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 15.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 15.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; this->collider.dim.worldSphere.center.y = (s32)this->actor.world.pos.y + 10; this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; @@ -712,7 +718,7 @@ void EnFirefly_Update(Actor* thisx, PlayState* play2) { this->actor.world.rot.y = this->actor.shape.rot.y; if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_FLY); + Actor_PlaySfx(&this->actor, NA_SE_EN_FFLY_FLY); } } diff --git a/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c b/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c index 6c105caa2..00a0d4d9d 100644 --- a/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c +++ b/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c @@ -6,7 +6,7 @@ #include "z_en_firefly2.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_4000) #define THIS ((EnFirefly2*)thisx) 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 5f9bbb2da..b70ce1ae7 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -264,7 +264,7 @@ void func_8091DEE4(EnFish* this) { 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->updBgCheckInfoFlags = 0; this->unk_26E = 400; this->unk_272 = 400; this->unk_268 = 0; @@ -278,12 +278,12 @@ void func_8091DF68(Actor* thisx, PlayState* play) { EnFish* this = THIS; func_8091DD48(this); - Math_SmoothStepToF(&thisx->speedXZ, 0.0f, 0.05f, 0.3f, 0.0f); + Math_SmoothStepToF(&thisx->speed, 0.0f, 0.05f, 0.3f, 0.0f); - if ((thisx->speedXZ * 1.4f) + 0.8f > 2.0f) { + if ((thisx->speed * 1.4f) + 0.8f > 2.0f) { this->skelAnime.playSpeed = 2.0f; } else { - this->skelAnime.playSpeed = (thisx->speedXZ * 1.4f) + 0.8f; + this->skelAnime.playSpeed = (thisx->speed * 1.4f) + 0.8f; } this->unk_270 >>= 1; @@ -314,7 +314,7 @@ void func_8091E070(EnFish* this) { phi_a1 = D_8091FAD4[this->unk_278]; } this->unk_240 = Rand_S16Offset(15, phi_a1); - this->unk_248 = 0; + this->updBgCheckInfoFlags = 0; this->unk_26E = 400; this->unk_272 = 400; this->unk_26C = 0; @@ -327,7 +327,7 @@ void func_8091E128(Actor* thisx, PlayState* play) { EnFish* this = THIS; func_8091DD48(this); - Math_SmoothStepToF(&thisx->speedXZ, 1.8f, 0.08f, 0.4f, 0.0f); + Math_SmoothStepToF(&thisx->speed, 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; @@ -342,10 +342,10 @@ void func_8091E128(Actor* thisx, PlayState* play) { this->unk_24C = 0.0f; } - if ((thisx->speedXZ * 1.5f) + 0.8f > 4.0f) { + if ((thisx->speed * 1.5f) + 0.8f > 4.0f) { this->skelAnime.playSpeed = 4.0f; } else { - this->skelAnime.playSpeed = (thisx->speedXZ * 1.5f) + 0.8f; + this->skelAnime.playSpeed = (thisx->speed * 1.5f) + 0.8f; } if (this->unk_240 <= 0) { @@ -361,7 +361,7 @@ 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->updBgCheckInfoFlags = 0; this->unk_26E = 400; this->unk_272 = 400; this->unk_268 = 0; @@ -378,7 +378,7 @@ void func_8091E34C(Actor* thisx, PlayState* play2) { s32 pad; func_8091DD48(this); - Math_SmoothStepToF(&thisx->speedXZ, 4.2f, 0.08f, 1.4f, 0.0f); + Math_SmoothStepToF(&thisx->speed, 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; @@ -418,10 +418,10 @@ void func_8091E34C(Actor* thisx, PlayState* play2) { this->unk_24C = 0.0f; } - if ((thisx->speedXZ * 1.5f) + 0.8f > 4.0f) { + if ((thisx->speed * 1.5f) + 0.8f > 4.0f) { this->skelAnime.playSpeed = 4.0f; } else { - this->skelAnime.playSpeed = (thisx->speedXZ * 1.5f) + 0.8f; + this->skelAnime.playSpeed = (thisx->speed * 1.5f) + 0.8f; } if ((this->unk_240 <= 0) || (!sp3C && (sp38 == 0))) { @@ -440,7 +440,7 @@ void func_8091E5EC(EnFish* this) { this->unk_26C = 0; func_8091D660(this); this->unk_240 = Rand_S16Offset(10, 30); - this->unk_248 = 0; + this->updBgCheckInfoFlags = 0; this->unkFunc = func_8091E658; } @@ -453,7 +453,7 @@ void func_8091E658(Actor* thisx, PlayState* play) { s16 sp32; func_8091DD48(this); - Math_SmoothStepToF(&thisx->speedXZ, 1.8f, 0.1f, 0.5f, 0.0f); + Math_SmoothStepToF(&thisx->speed, 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; @@ -475,10 +475,10 @@ void func_8091E658(Actor* thisx, PlayState* play) { this->unk_24C = 1.2f; } - if ((thisx->speedXZ * 1.5f) + 0.8f > 4.0f) { + if ((thisx->speed * 1.5f) + 0.8f > 4.0f) { this->skelAnime.playSpeed = 4.0f; } else { - this->skelAnime.playSpeed = (thisx->speedXZ * 1.5f) + 0.8f; + this->skelAnime.playSpeed = (thisx->speed * 1.5f) + 0.8f; } if (this->unk_240 <= 0) { @@ -493,7 +493,7 @@ void func_8091E810(EnFish* this) { this->actor.terminalVelocity = -10.0f; this->actor.shape.yOffset = 0.0f; func_8091D6C4(this); - this->unk_248 = 5; + this->updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4; this->unkFunc = func_8091E880; this->unk_24C = 0.0f; this->unk_240 = 300; @@ -502,16 +502,16 @@ void func_8091E810(EnFish* this) { void func_8091E880(Actor* thisx, PlayState* play) { EnFish* this = THIS; - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.1f, 0.0f); + Math_SmoothStepToF(&this->actor.speed, 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) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->unk_240 = 400; func_8091E9A4(this); - } else if (this->actor.bgCheckFlags & 0x20) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { + Actor_PlaySfx(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); func_8091D840(thisx, play, 10, 15.0f); if (func_8091DA14(this, play)) { func_8091EF30(this); @@ -551,10 +551,10 @@ void func_8091E9A4(EnFish* this) { this->actor.shape.yOffset = 300.0f; func_8091D6C4(this); this->unkFunc = func_8091EAF0; - this->unk_248 = 5; + this->updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4; this->unk_24C = 0.0f; if (sp24 && (this->actor.draw != NULL)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FISH_LEAP); + Actor_PlaySfx(&this->actor, NA_SE_EV_FISH_LEAP); } } @@ -563,7 +563,7 @@ void func_8091EAF0(Actor* thisx, PlayState* play) { s32 sp40 = play->state.frames; s16 phi_v1; - Math_SmoothStepToF(&this->actor.speedXZ, Rand_ZeroOne() * 0.2f, 0.1f, 0.1f, 0.0f); + Math_SmoothStepToF(&this->actor.speed, 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; @@ -592,13 +592,13 @@ void func_8091EAF0(Actor* thisx, PlayState* play) { } else { this->actor.draw = NULL; } - } else if (this->actor.bgCheckFlags & 0x20) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { if (func_8091DA14(this, play)) { func_8091EF30(this); } else { func_8091ECF4(this); } - } else if (this->actor.bgCheckFlags & 1) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { func_8091E9A4(this); } } @@ -612,7 +612,7 @@ void func_8091ECF4(EnFish* this) { this->unk_240 = 200; func_8091D660(this); this->unkFunc = func_8091ED70; - this->unk_248 = 5; + this->updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4; this->unk_24C = 0.0f; } @@ -625,12 +625,12 @@ void func_8091ED70(Actor* thisx, PlayState* play) { func_8091D840(thisx, play, 2, 25.0f); } - Math_SmoothStepToF(&thisx->speedXZ, 2.8f, 0.1f, 0.4f, 0.0f); + Math_SmoothStepToF(&thisx->speed, 2.8f, 0.1f, 0.4f, 0.0f); - if ((thisx->bgCheckFlags & 8) || !(thisx->bgCheckFlags & 0x20)) { + if ((thisx->bgCheckFlags & BGCHECKFLAG_WALL) || !(thisx->bgCheckFlags & BGCHECKFLAG_WATER)) { sp2E = Math_Vec3f_Yaw(&thisx->world.pos, &thisx->home.pos); thisx->home.rot.y = Rand_S16Offset(-100, 100) + sp2E; - thisx->speedXZ *= 0.5f; + thisx->speed *= 0.5f; } this->unk_268 = 0; @@ -640,7 +640,7 @@ void func_8091ED70(Actor* thisx, PlayState* play) { this->unk_270 = 2000; this->unk_272 = 0x29B; - if (thisx->bgCheckFlags & 1) { + if (thisx->bgCheckFlags & BGCHECKFLAG_GROUND) { 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); @@ -651,10 +651,10 @@ void func_8091ED70(Actor* thisx, PlayState* play) { func_8091D728(this); } - if ((thisx->speedXZ * 1.5f) + 1.0f > 4.8f) { + if ((thisx->speed * 1.5f) + 1.0f > 4.8f) { this->skelAnime.playSpeed = 4.8f; } else { - this->skelAnime.playSpeed = (thisx->speedXZ * 1.5f) + 1.0f; + this->skelAnime.playSpeed = (thisx->speed * 1.5f) + 1.0f; } if (this->unk_240 <= 0) { @@ -677,7 +677,7 @@ void func_8091EF30(EnFish* this) { this->unk_240 = 15; this->unk_279 = 10; this->unkFunc = func_8091EFE8; - this->unk_248 = 5; + this->updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4; this->unk_24C = 0.0f; } @@ -700,18 +700,19 @@ void func_8091EFE8(Actor* thisx, PlayState* play) { } if (this->unk_277 == 0) { - Math_SmoothStepToF(&this->actor.speedXZ, 2.8f, 0.1f, 0.4f, 0.0f); + Math_SmoothStepToF(&this->actor.speed, 2.8f, 0.1f, 0.4f, 0.0f); if (this->unk_240 < 6) { - this->actor.speedXZ *= 0.75f; + this->actor.speed *= 0.75f; } } - if ((this->actor.bgCheckFlags & 8) && !(this->actor.bgCheckFlags & 0x20)) { - this->actor.speedXZ *= 0.5f; + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && !(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { + this->actor.speed *= 0.5f; } - if (((Rand_Next() >> 0x1B) == 0) || ((this->actor.bgCheckFlags & 8) && ((Rand_Next() >> 0x1E) == 0)) || - !(this->actor.bgCheckFlags & 0x20)) { + if (((Rand_Next() >> 0x1B) == 0) || + ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && ((Rand_Next() >> 0x1E) == 0)) || + !(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { temp_f0 = Rand_ZeroOne(); sp34 = (1.0f - SQ(temp_f0)) * sp3C->home.rot.x; sp30 = Rand_ZeroOne() * sp3C->home.rot.z; @@ -760,10 +761,10 @@ void func_8091EFE8(Actor* thisx, PlayState* play) { } this->actor.velocity.y *= 0.8f; - if ((this->actor.speedXZ * 1.5f) + 1.0f > 4.8f) { + if ((this->actor.speed * 1.5f) + 1.0f > 4.8f) { this->skelAnime.playSpeed = 4.8f; } else { - this->skelAnime.playSpeed = (this->actor.speedXZ * 1.5f) + 1.0f; + this->skelAnime.playSpeed = (this->actor.speed * 1.5f) + 1.0f; } } @@ -771,7 +772,7 @@ 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->updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_1; this->unk_268 = 0; this->unk_26C = 0; this->unk_26E = 1500; @@ -804,7 +805,7 @@ void func_8091F3BC(Actor* thisx, PlayState* play) { 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); + Math_SmoothStepToF(&this->actor.speed, 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)) { @@ -820,7 +821,7 @@ void func_8091F3BC(Actor* thisx, PlayState* play) { phi_f0 = 0.0f; } - temp_f2 = this->actor.speedXZ + 0.4f + phi_f0; + temp_f2 = this->actor.speed + 0.4f + phi_f0; this->skelAnime.playSpeed = CLAMP(temp_f2, 0.5f, 1.6f); if (this->unk_240 <= 0) { @@ -855,7 +856,7 @@ void func_8091F5A4(Actor* thisx, PlayState* play) { SkelAnime_Update(&this->skelAnime); func_8091D7C4(this); Actor_MoveWithGravity(&this->actor); - if (this->unk_248 != 0) { + if (this->updBgCheckInfoFlags != 0) { u32 temp = (play->sceneId != SCENE_LABO); phi_f0 = BREG(1) + 10.0f; @@ -863,7 +864,7 @@ void func_8091F5A4(Actor* thisx, PlayState* play) { if (temp) { phi_f0 = 6.0f; } - Actor_UpdateBgCheckInfo(play, &this->actor, 17.5f, phi_f0, 0.0f, this->unk_248); + Actor_UpdateBgCheckInfo(play, &this->actor, 17.5f, phi_f0, 0.0f, this->updBgCheckInfoFlags); } if ((this->actor.xzDistToPlayer < 70.0f) && (this->unkFunc != func_8091EFE8)) { @@ -887,7 +888,7 @@ void func_8091F5A4(Actor* thisx, PlayState* play) { func_8091D904(this); } else if (func_8091DDF4(this, play)) { - Actor_PickUp(&this->actor, play, GI_MAX, 80.0f, 25.0f); + Actor_OfferGetItem(&this->actor, play, GI_MAX, 80.0f, 25.0f); } } } 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 528eeb40c..d3941906c 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.h +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.h @@ -26,7 +26,7 @@ typedef struct EnFish { /* 0x242 */ s16 unk_242; /* 0x244 */ s16 unk_244; /* 0x246 */ s16 unk_246; - /* 0x248 */ s32 unk_248; + /* 0x248 */ s32 updBgCheckInfoFlags; /* 0x24C */ f32 unk_24C; /* 0x250 */ f32 unk_250; /* 0x254 */ f32 unk_254; 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 c7dd18369..b7952c1bc 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -151,7 +151,7 @@ s32 func_80B28478(EnFish2* this) { void EnFish2_Init(Actor* thisx, PlayState* play) { EnFish2* this = THIS; s32 i; - s32 cs; + s32 csId; Math_Vec3f_Copy(&this->unk_324, &this->actor.home.pos); this->unk_344 = D_80B2B2F0; @@ -187,12 +187,12 @@ void EnFish2_Init(Actor* thisx, PlayState* play) { this->unk_2C0 = 3; } } - cs = this->actor.cutscene; + csId = this->actor.csId; this->unk_330 = D_80B2B370[this->unk_2C0]; i = 0; // clang-format off - while (cs != -1) { this->unk_2BA[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; } + while (csId != CS_ID_NONE) { this->csIdList[i] = csId; csId = CutsceneManager_GetAdditionalCsId(csId); i++; } // clang-format on Collider_InitAndSetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); @@ -211,7 +211,7 @@ void EnFish2_Init(Actor* thisx, PlayState* play) { } else if (this->actor.params != 0) { this->unk_2B4 = 10; this->actor.draw = NULL; - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actionFunc = func_80B2A01C; } } @@ -235,7 +235,7 @@ void func_80B287F4(EnFish2* this, s32 arg1) { if (arg1 == 0) { this->unk_338 = 410.0f - this->unk_2C4; } - Math_ApproachF(&this->unk_350->speedXZ, (D_80B2B380[0] - this->unk_330) * this->unk_338, 0.1f, 0.4f); + Math_ApproachF(&this->unk_350->speed, (D_80B2B380[0] - this->unk_330) * this->unk_338, 0.1f, 0.4f); } Math_Vec3f_Copy(&sp2C, &this->unk_350->world.pos); this->unk_34A = Math_Vec3f_Yaw(&this->actor.world.pos, &sp2C); @@ -377,14 +377,14 @@ void func_80B28C14(EnFish2* this, PlayState* play) { } if (this->unk_2B4 == 0) { - Math_ApproachF(&this->actor.speedXZ, (D_80B2B380[0] - this->unk_330) * 400.0f, 0.3f, 0.3f); - if (this->actor.speedXZ > 3.0f) { - this->actor.speedXZ = 3.0f; - } else if (this->actor.speedXZ < 1.5f) { - this->actor.speedXZ = 1.5f; + Math_ApproachF(&this->actor.speed, (D_80B2B380[0] - this->unk_330) * 400.0f, 0.3f, 0.3f); + if (this->actor.speed > 3.0f) { + this->actor.speed = 3.0f; + } else if (this->actor.speed < 1.5f) { + this->actor.speed = 1.5f; } } else { - Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 0.3f); + Math_ApproachZeroF(&this->actor.speed, 0.3f, 0.3f); } if ((D_80B2B2E8 == 0) && (D_80B2B2E0 != 2)) { @@ -404,7 +404,7 @@ void func_80B28C14(EnFish2* this, PlayState* play) { } else if ((itemAction->update != NULL) && (itemAction->params == 0) && (fabsf(itemAction->world.pos.x - this->actor.world.pos.x) < 100.0f) && (fabsf(itemAction->world.pos.z - this->actor.world.pos.z) < 100.0f) && - (itemAction->bgCheckFlags & 0x20)) { + (itemAction->bgCheckFlags & BGCHECKFLAG_WATER)) { this->unk_350 = itemAction; if (D_80B2B2E0 == 0) { EnFish2* fish; @@ -416,7 +416,7 @@ void func_80B28C14(EnFish2* this, PlayState* play) { if (this->unk_354 != NULL) { D_80B2B2E4 = 0; D_80B2B2E0 = 1; - fish->unk_2BA[0] = this->unk_2BA[0]; + fish->csIdList[0] = this->csIdList[0]; fish->unk_350 = this->unk_350; } } @@ -436,7 +436,7 @@ void func_80B29128(EnFish2* this) { void func_80B2913C(EnFish2* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); func_80B28B5C(this); } } @@ -448,7 +448,7 @@ void func_80B29194(EnFish2* this) { } this->unk_2C4 = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->unk_2C8 == 0) { this->unk_34C = 400; Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_324); @@ -463,12 +463,12 @@ void func_80B29194(EnFish2* this) { void func_80B29250(EnFish2* this, PlayState* play) { if (!func_80B28478(this)) { - Math_ApproachF(&this->actor.speedXZ, (D_80B2B380[0] - this->unk_330) * 1000.0f, 0.3f, 0.3f); + Math_ApproachF(&this->actor.speed, (D_80B2B380[0] - this->unk_330) * 1000.0f, 0.3f, 0.3f); - if (this->actor.speedXZ > 4.0f) { - this->actor.speedXZ = 4.0f; - } else if (this->actor.speedXZ < 2.0f) { - this->actor.speedXZ = 2.0f; + if (this->actor.speed > 4.0f) { + this->actor.speed = 4.0f; + } else if (this->actor.speed < 2.0f) { + this->actor.speed = 2.0f; } func_80B287F4(this, 0); @@ -492,12 +492,12 @@ void func_80B293C4(EnFish2* this, PlayState* play) { if (func_80B28478(this) == 0) { func_80B287F4(this, 1); - Math_ApproachF(&this->actor.speedXZ, (*D_80B2B380 - this->unk_330) * 1000.0f, 0.3f, 0.3f); + Math_ApproachF(&this->actor.speed, (*D_80B2B380 - this->unk_330) * 1000.0f, 0.3f, 0.3f); - if (this->actor.speedXZ > 3.0f) { - this->actor.speedXZ = 3.0f; - } else if (this->actor.speedXZ < 1.0f) { - this->actor.speedXZ = 1.0f; + if (this->actor.speed > 3.0f) { + this->actor.speed = 3.0f; + } else if (this->actor.speed < 1.0f) { + this->actor.speed = 1.0f; } if (this->unk_2CC <= currentFrame) { @@ -526,11 +526,11 @@ void func_80B2951C(EnFish2* this) { } this->unk_2B4 = 10; - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; Actor_Kill(this->unk_350); this->unk_350 = NULL; D_80B2B2F4 = &this->actor; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_M_EAT); + Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_M_EAT); this->actionFunc = func_80B295A4; } @@ -542,7 +542,7 @@ void func_80B295A4(EnFish2* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &play->view.eye), 1, 0x1388, 0); - Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 0.3f); + Math_ApproachZeroF(&this->actor.speed, 0.3f, 0.3f); if (this->unk_2B4 != 0) { Math_Vec3f_Copy(&sp60, &this->unk_318); sp60.x += randPlusMinusPoint5Scaled(100.0f); @@ -576,7 +576,7 @@ void func_80B29778(EnFish2* this) { } this->actionFunc = func_80B297FC; this->unk_324.y = this->unk_2D4; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void func_80B297FC(EnFish2* this, PlayState* play) { @@ -605,7 +605,7 @@ void func_80B297FC(EnFish2* this, PlayState* play) { if ((fabsf(this->actor.world.pos.x - this->unk_324.x) < 2.0f) && (this->actor.world.pos.y < (this->unk_2D4 + 3.0f)) && (fabsf(this->actor.world.pos.z - this->unk_324.z) < 2.0f)) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_34A = BINANG_ROT180(this->actor.home.rot.y); this->unk_2C4++; this->actor.velocity.y = 0.0f; @@ -638,7 +638,7 @@ void func_80B297FC(EnFish2* this, PlayState* play) { } this->unk_2B6 = 4; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FISH_GROW_UP); + Actor_PlaySfx(&this->actor, NA_SE_EV_FISH_GROW_UP); this->unk_2C4++; } break; @@ -770,8 +770,8 @@ void func_80B29EE4(EnFish2* this, PlayState* play) { this->unk_2C4++; } this->unk_338 = 410.0f - this->unk_2C4; - Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.3f, 0.3f); - Math_ApproachF(&this->unk_350->speedXZ, (D_80B2B380[0] - this->unk_330) * this->unk_338, 0.1f, 0.4f); + Math_ApproachF(&this->actor.speed, 2.0f, 0.3f, 0.3f); + Math_ApproachF(&this->unk_350->speed, (D_80B2B380[0] - this->unk_330) * this->unk_338, 0.1f, 0.4f); func_80B289DC(this, play); Math_Vec3f_Copy(&sp2C, &this->unk_350->world.pos); this->unk_34A = Math_Vec3f_Yaw(&this->actor.world.pos, &sp2C); @@ -784,11 +784,11 @@ void func_80B29EE4(EnFish2* this, PlayState* play) { void func_80B2A01C(EnFish2* this, PlayState* play) { if (this->unk_2B4 == 0) { - if (!ActorCutscene_GetCanPlayNext(this->unk_2BA[0])) { - ActorCutscene_SetIntentToPlay(this->unk_2BA[0]); + if (!CutsceneManager_IsNext(this->csIdList[0])) { + CutsceneManager_Queue(this->csIdList[0]); } else { this->unk_2B4 = 15; - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2BA[0], &this->actor); + CutsceneManager_StartWithPlayerCs(this->csIdList[0], &this->actor); this->actionFunc = func_80B2A094; } } @@ -801,13 +801,13 @@ void func_80B2A094(EnFish2* this, PlayState* play) { D_80B2B2E4 = 1; } - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->unk_2BA[0]); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->csIdList[0]); if (D_80B2B2EC != 0) { D_80B2B2EC++; if (D_80B2B2EC > 200) { Actor_Kill(&this->actor); - ActorCutscene_Stop(this->unk_2BA[0]); + CutsceneManager_Stop(this->csIdList[0]); return; } } @@ -862,7 +862,7 @@ void func_80B2A23C(EnFish2* this, PlayState* play) { if ((this->unk_2B4 == 0) && (D_80B2B2E4 == 3)) { D_80B2B2E0 = D_80B2B2EC = D_80B2B2E4 = 0; D_80B2B2F4 = NULL; - ActorCutscene_Stop(this->unk_2BA[0]); + CutsceneManager_Stop(this->csIdList[0]); Actor_Kill(&this->actor); } } @@ -887,9 +887,9 @@ void func_80B2A498(EnFish2* this, PlayState* play) { temp_v0 = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_COL_MAN, sp80.x, sp80.y, sp80.z, 0, this->actor.world.rot.y, 0, 0); if (temp_v0 != NULL) { - temp_v0->speedXZ = 4.0f; + temp_v0->speed = 4.0f; temp_v0->velocity.y = 15.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); + Actor_PlaySfx(&this->actor, NA_SE_SY_PIECE_OF_HEART); CLEAR_WEEKEVENTREG(WEEKEVENTREG_81_10); CLEAR_WEEKEVENTREG(WEEKEVENTREG_81_20); CLEAR_WEEKEVENTREG(WEEKEVENTREG_81_40); @@ -987,7 +987,8 @@ void EnFish2_Update(Actor* thisx, PlayState* play2) { this->unk_33C = 25.0f - ((this->unk_330 - 0.01f) * 1000.0f); Actor_SetScale(&this->actor, this->unk_330); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 0, 15.0f, 10.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 0, 15.0f, 10.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); if (this->actor.params != 2) { this->unk_2D4 = this->actor.floorHeight + (this->unk_330 * 1000.0f); diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h index 49941d67e..20b1ff21b 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.h @@ -28,7 +28,7 @@ typedef struct EnFish2 { /* 0x02B4 */ s16 unk_2B4; /* 0x02B6 */ s16 unk_2B6; /* 0x02B8 */ s16 unk_2B8; - /* 0x02BA */ s16 unk_2BA[3]; + /* 0x02BA */ s16 csIdList[3]; /* 0x02C0 */ s32 unk_2C0; /* 0x02C4 */ s32 unk_2C4; /* 0x02C8 */ u8 unk_2C8; 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 6d75abddb..306f1d94d 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -3,7 +3,6 @@ * Overlay: ovl_En_Fishing * Description: Fishing Pond Elements (Owner, Fish, Props, Effects...) */ - #include "prevent_bss_reordering.h" #include "z_en_fishing.h" #include "z64rumble.h" @@ -836,7 +835,7 @@ void EnFishing_Init(Actor* thisx, PlayState* play2) { if (sLinkAge != 1) { // HIGH_SCORE(HS_FISHING) from OoT - if (gSaveContext.save.unk_EE4 & 0x1000) { + if (gSaveContext.save.saveInfo.unk_EC0 & 0x1000) { D_8090CD08 = 0; } else { D_8090CD08 = 1; @@ -851,21 +850,21 @@ void EnFishing_Init(Actor* thisx, PlayState* play2) { D_809171FC = 0; D_809171F6 = 10; - Audio_QueueSeqCmd(0x100100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); if (sLinkAge == 1) { - if (gSaveContext.save.unk_EE4 & 0x7F) { - D_809171CC = gSaveContext.save.unk_EE4 & 0x7F; + if (gSaveContext.save.saveInfo.unk_EC0 & 0x7F) { + D_809171CC = gSaveContext.save.saveInfo.unk_EC0 & 0x7F; } else { D_809171CC = 40.0f; } - } else if (gSaveContext.save.unk_EE4 & 0x7F000000) { - D_809171CC = (gSaveContext.save.unk_EE4 & 0x7F000000) >> 0x18; + } else if (gSaveContext.save.saveInfo.unk_EC0 & 0x7F000000) { + D_809171CC = (gSaveContext.save.saveInfo.unk_EC0 & 0x7F000000) >> 0x18; } else { D_809171CC = 45.0f; } - D_809171D1 = (gSaveContext.save.unk_EE4 & 0xFF0000) >> 0x10; + D_809171D1 = (gSaveContext.save.saveInfo.unk_EC0 & 0xFF0000) >> 0x10; if ((D_809171D1 & 7) == 7) { play->roomCtx.unk7A[0] = 90; D_809171CA = 1; @@ -946,7 +945,7 @@ void EnFishing_Init(Actor* thisx, PlayState* play2) { return; } - thisx->bgCheckFlags |= 0x800; // Added in MM + thisx->bgCheckFlags |= BGCHECKFLAG_PLAYER_800; // Added in MM if ((thisx->params < 115) || (thisx->params == 200)) { SkelAnime_InitFlex(play, &this->skelAnime, &gFishingFishSkel, &gFishingFishAnim, NULL, NULL, 0); @@ -1131,7 +1130,7 @@ void EnFishing_UpdateEffects(FishingEffect* effect, PlayState* play) { if ((effect->unk_2C >= 100) && (Message_GetState(&play->msgCtx) == TEXT_STATE_5)) { if (Message_ShouldAdvance(play) || (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { - func_801477B4(play); + Message_CloseTextbox(play); Rupees_ChangeBy(-50); effect->unk_2C = -1; } @@ -1326,9 +1325,9 @@ void EnFishing_DrawEffects(FishingEffect* effect, PlayState* play) { effect = firstEffect; if (effect->type == FS_EFF_OWNER_HAT) { Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_RotateYF((sEffOwnerHatRot.y * M_PI) / 32768, MTXMODE_APPLY); - Matrix_RotateXFApply((sEffOwnerHatRot.x * M_PI) / 32768); - Matrix_RotateZF((sEffOwnerHatRot.z * M_PI) / 32768, MTXMODE_APPLY); + Matrix_RotateYF(BINANG_TO_RAD_ALT2(sEffOwnerHatRot.y), MTXMODE_APPLY); + Matrix_RotateXFApply(BINANG_TO_RAD_ALT2(sEffOwnerHatRot.x)); + Matrix_RotateZF(BINANG_TO_RAD_ALT2(sEffOwnerHatRot.z), MTXMODE_APPLY); Matrix_Scale(effect->unk_30, effect->unk_30, effect->unk_30, MTXMODE_APPLY); Matrix_Translate(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateXFApply(M_PI / 2); @@ -1574,7 +1573,7 @@ void EnFishing_DrawLureHook(PlayState* play, Vec3f* pos, Vec3f* refPos, u8 hookI Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_NEW); - if ((player->actor.speedXZ == 0.0f) && (D_809101B4 == 0.0f)) { + if ((player->actor.speed == 0.0f) && (D_809101B4 == 0.0f)) { Math_ApproachF(&sLureHookRotY[hookIndex], ry, 0.1f, 0.3f); } else { sLureHookRotY[hookIndex] = ry; @@ -1660,7 +1659,7 @@ void EnFishing_UpdateSinkingLure(PlayState* play) { } if (D_8090CD14 == 5) { - Matrix_RotateYF(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); + Matrix_RotateYF(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); sp94.x = 5.0f; sp94.y = 0.0f; sp94.z = 3.0f; @@ -1773,7 +1772,7 @@ void EnFishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) sLurePos = sFishingHookedFish->fishMouthPos; if ((D_8090CD14 == 5) && (D_80917206 == 2)) { - Matrix_RotateYF(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); + Matrix_RotateYF(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); posSrc.x = 2.0f; posSrc.y = 0.0f; posSrc.z = 0.0f; @@ -1785,7 +1784,7 @@ void EnFishing_DrawLureAndLine(PlayState* play, Vec3f* linePos, Vec3f* lineRot) 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)) { + if ((player->actor.speed == 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; @@ -2160,7 +2159,7 @@ void EnFishing_UpdateLure(EnFishing* this, PlayState* play) { if (D_80917204 == 0) { if ((D_80917200 == 0) && (player->unk_B28 == 1)) { D_80917204 = 37; - func_801477B4(play); + Message_CloseTextbox(play); } } else { sLureRot.x = sReelLineRot[LINE_SEG_COUNT - 2].x + M_PI; @@ -2169,7 +2168,7 @@ void EnFishing_UpdateLure(EnFishing* this, PlayState* play) { if (D_80917204 == 18) { D_8090CD14 = 1; sLurePos = sRodTipPos; - Matrix_RotateYF(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); + Matrix_RotateYF(BINANG_TO_RAD_ALT(player->actor.shape.rot.y), MTXMODE_NEW); sp90.x = 0.0f; sp90.y = 0.0f; sp90.z = 25.0f; @@ -2231,13 +2230,14 @@ void EnFishing_UpdateLure(EnFishing* this, PlayState* play) { Vec3f sp80 = this->actor.world.pos; this->actor.prevPos = this->actor.world.pos = sLurePos; - Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 30.0f, 0x43); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 30.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_40); this->actor.world.pos = sp80; - if (this->actor.bgCheckFlags & 0x10) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_CEILING) { D_80917238.y = -0.5f; } - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { if (D_80917238.y > 0.0f) { D_80917238.y = 0.0f; } @@ -2445,7 +2445,7 @@ void EnFishing_UpdateLure(EnFishing* this, PlayState* play) { sLureRot.x = 0.0f; if (CHECK_BTN_ALL(input->press.button, BTN_B)) { D_809101C0 += 6.0f; - Audio_PlaySfxAtPos(&D_8090D614, NA_SE_PL_WALK_SAND); + Audio_PlaySfxAtPos(&D_8090D614, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_SAND); } } else { if (D_809101C0 > 150.0f) { @@ -2457,9 +2457,9 @@ void EnFishing_UpdateLure(EnFishing* this, PlayState* play) { } Math_ApproachZeroF(&D_809101B4, 1.0f, 0.3f); - Math_ApproachS(&D_809101B8, (D_809101B0 * 32768.0f) / M_PI, 3, spDC); + Math_ApproachS(&D_809101B8, RAD_TO_BINANG_ALT2(D_809101B0), 3, spDC); - sLureRot.y = (D_809101B8 / 32768.0f) * M_PI; + sLureRot.y = BINANG_TO_RAD_ALT(D_809101B8); sp90.x = 0.0f; sp90.y = 0.0f; @@ -2495,7 +2495,8 @@ void EnFishing_UpdateLure(EnFishing* this, PlayState* play) { sp58 = this->actor.world.pos; this->actor.prevPos = this->actor.world.pos = sLurePos; - Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 30.0f, 0x44); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 30.0f, + UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40); this->actor.world.pos = sp58; D_80917278.y += -0.5f; @@ -2714,7 +2715,7 @@ void func_809038A4(EnFishing* this, Input* input) { sp24 = SQ(sp34.x) + SQ(sp34.y) + SQ(sp34.z); if ((D_8090CD14 == 3) && (this->unk_19A == 0) && (D_8090CD0C == 0)) { - Matrix_RotateYF((-this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + Matrix_RotateYF(BINANG_TO_RAD_ALT(-this->actor.shape.rot.y), MTXMODE_NEW); Matrix_MultVec3f(&sp34, &sp28); if ((sp28.z > 0.0f) || (this->unk_1A4 < 40.0f)) { @@ -2789,13 +2790,13 @@ void func_80903C60(EnFishing* this, u8 arg1) { } } - Actor_PlaySfxAtPos(&this->actor, sfxId); + Actor_PlaySfx(&this->actor, sfxId); } void EnFishing_HandleAquariumDialog(EnFishing* this, PlayState* play) { if (sLinkAge == 1) { - if (gSaveContext.save.unk_EE4 & 0x7F) { - if (gSaveContext.save.unk_EE4 & 0x80) { + if (gSaveContext.save.saveInfo.unk_EC0 & 0x7F) { + if (gSaveContext.save.saveInfo.unk_EC0 & 0x80) { this->actor.textId = 0x40B1; } else { this->actor.textId = 0x4089; @@ -2803,8 +2804,8 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, PlayState* play) { } else { this->actor.textId = 0x40AE; } - } else if (gSaveContext.save.unk_EE4 & 0x7F000000) { - if (gSaveContext.save.unk_EE4 & 0x80000000) { + } else if (gSaveContext.save.saveInfo.unk_EC0 & 0x7F000000) { + if (gSaveContext.save.saveInfo.unk_EC0 & 0x80000000) { this->actor.textId = 0x40B1; } else { this->actor.textId = 0x4089; @@ -2871,9 +2872,9 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { this->actor.uncullZoneScale = 50.0f; if (this->unk_148 == 0) { - sp118 = (player->actor.speedXZ * 0.15f) + 0.25f; + sp118 = (player->actor.speed * 0.15f) + 0.25f; } else { - sp118 = (player->actor.speedXZ * 0.3f) + 0.25f; + sp118 = (player->actor.speed * 0.3f) + 0.25f; } if ((D_80917200 != 0) || (sSubCamId != SUB_CAM_ID_DONE) || @@ -3018,7 +3019,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { case 10: this->unk_1AC = this->actor.home.pos; - Math_ApproachF(&this->actor.speedXZ, 2.0f, 1.0f, 0.5f); + Math_ApproachF(&this->actor.speed, 2.0f, 1.0f, 0.5f); Math_ApproachF(&this->unk_1A8, 4096.0f, 1.0f, 256.0f); if (sp124 < 40.0f) { @@ -3040,7 +3041,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { case 11: this->unk_1AC = this->actor.home.pos; - Math_ApproachF(&this->actor.speedXZ, 0.0f, 1.0f, 0.05f); + Math_ApproachF(&this->actor.speed, 0.0f, 1.0f, 0.05f); Math_ApproachF(&this->unk_1A8, 0.0f, 1.0f, 256.0f); if (sp124 >= 40.0f) { @@ -3070,7 +3071,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { break; case 0: - Math_ApproachF(&this->actor.speedXZ, 1.0f, 1.0f, 0.05f); + Math_ApproachF(&this->actor.speed, 1.0f, 1.0f, 0.05f); Math_ApproachF(&this->unk_1A8, 0.0f, 1.0f, 256.0f); if (this->unk_172[0] == 0) { @@ -3107,14 +3108,14 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { 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); + Math_ApproachF(&this->actor.speed, 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); + Math_ApproachF(&this->actor.speed, 1.5f, 1.0f, 0.1f); } if ((this->unk_172[0] == 0) || (sp124 < 50.0f)) { @@ -3136,7 +3137,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { 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); + Math_ApproachF(&this->actor.speed, 3.0f, 1.0f, 0.75); this->unk_188 = 1.0f; this->unk_172[0] = 20; this->unk_18C = 4000.0f; @@ -3150,12 +3151,12 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { } 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->actor.speed, 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_ApproachZeroF(&this->actor.speed, 1.0f, 0.02f); Math_ApproachF(&this->unk_1A8, 0.0f, 1.0f, 256.0f); } @@ -3184,11 +3185,11 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { Math_ApproachS(&this->unk_15E, -0x1000, 0x14, 0x100); if (this->actor.world.pos.y < (WATER_SURFACE_Y(play) - 20.0f)) { - Math_ApproachF(&this->actor.speedXZ, 0.5f, 1.0f, 0.1f); + Math_ApproachF(&this->actor.speed, 0.5f, 1.0f, 0.1f); } else { - Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.01f); + Math_ApproachZeroF(&this->actor.speed, 1.0f, 0.01f); - if ((this->actor.speedXZ == 0.0f) || (this->actor.world.pos.y > (WATER_SURFACE_Y(play) - 5.0f))) { + if ((this->actor.speed == 0.0f) || (this->actor.world.pos.y > (WATER_SURFACE_Y(play) - 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; @@ -3202,7 +3203,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { EnFishing_SpawnRipple(&this->actor.projectedPos, play->specialEffects, &spB8, 30.0f, 400.0f, 150, 90); - Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_CATCH_BOOMERANG); + Actor_PlaySfx(&this->actor, NA_SE_PL_CATCH_BOOMERANG); break; } } @@ -3222,7 +3223,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { 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->actor.speed, 0.5f, 1.0f, 0.01f); Math_ApproachF(&this->unk_1A8, 2048.0f, 1.0f, 128.0f); } else { this->unk_150 = -1; @@ -3285,7 +3286,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { 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); + Math_ApproachF(&this->actor.speed, -0.2f, 1.0f, 0.1f); this->unk_156 = 1; } else { if (this->unk_156 != 0) { @@ -3293,7 +3294,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { this->unk_1A8 = 0.0f; this->unk_18C = 3000.0f; } - Math_ApproachF(&this->actor.speedXZ, 3.0f, 1.0f, 0.15f); + Math_ApproachF(&this->actor.speed, 3.0f, 1.0f, 0.15f); this->unk_156 = 0; } @@ -3377,7 +3378,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { 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); + Math_ApproachF(&this->actor.speed, this->unk_180 * 0.8f, 1.0f, 1.0f); if ((D_8090CD14 != 3) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { @@ -3402,7 +3403,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { this->unk_149 = 50; sp134 = 2; this->unk_1AC = sLurePos; - Math_ApproachF(&this->actor.speedXZ, this->unk_180, 1.0f, 1.0f); + Math_ApproachF(&this->actor.speed, this->unk_180, 1.0f, 1.0f); if ((D_8090CD14 != 3) || (this->unk_172[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { @@ -3467,7 +3468,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { case -3: this->unk_149 = 50; this->unk_1AC = sLurePos; - Math_ApproachF(&this->actor.speedXZ, 2.0f, 1.0f, 1.0f); + Math_ApproachF(&this->actor.speed, 2.0f, 1.0f, 1.0f); if ((D_8090CD14 != 3) || (this->unk_172[0] == 0) || (sLurePos.y > (WATER_SURFACE_Y(play) + 5.0f)) || (sqrtf(SQ(sLurePos.x) + SQ(sLurePos.z)) > 800.0f)) { @@ -3478,7 +3479,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { this->unk_18C = 2000.0f; } else if (sp124 < 10.0f) { if (sLurePos.y > (WATER_SURFACE_Y(play) - 10.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_JUMP_OUT_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EV_JUMP_OUT_WATER); play_sound(NA_SE_PL_CATCH_BOOMERANG); } @@ -3540,7 +3541,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { this->unk_190 = 1.7f; this->unk_194 = 7000.0f; D_80917274 = 1; - Audio_QueueSeqCmd(0x881A); // Changed from 0x81A in OoT + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_ENEMY | 0x800 | SEQ_FLAG_ASYNC); D_809171F6 = 0; if (this->unk_148 == 1) { @@ -3599,8 +3600,8 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { for (spA2 = 0; spA2 < 100; spA2++) { - Matrix_RotateYF(randPlusMinusPoint5Scaled(2.3561945f) + - (((this->actor.yawTowardsPlayer + 0x8000) / 32768.0f) * M_PI), + Matrix_RotateYF(randPlusMinusPoint5Scaled(0.75f * M_PI) + + BINANG_TO_RAD_ALT(this->actor.yawTowardsPlayer + 0x8000), MTXMODE_NEW); Matrix_MultVec3f(&sp10C, &sp100); @@ -3641,17 +3642,17 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { 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_ApproachF(&this->actor.speed, 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); + Math_ApproachF(&this->actor.speed, 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); + Math_ApproachF(&this->actor.speed, 5.0f, 1.0f, 0.5f); } if (this->unk_148 == 0) { @@ -3676,7 +3677,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { D_8091726C = 1.3f - (this->unk_1A4 * 0.00899f * 1.4f); } - Math_ApproachF(&this->actor.speedXZ, 2.0f, 1.0f, 0.5f); + Math_ApproachF(&this->actor.speed, 2.0f, 1.0f, 0.5f); if (this->unk_172[1] == 0) { this->unk_14A = 0; @@ -3697,7 +3698,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { } if (D_80917274 || (D_80917206 != 2)) { - if (this->actor.speedXZ < 3.0f) { + if (this->actor.speed < 3.0f) { if (D_809171FE & 8) { sp100.x = -0.8f; } else { @@ -3720,11 +3721,11 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { 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)); + 2.0f * (this->actor.speed * 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); + 2.0f * (this->actor.speed * 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)); + 2.0f * (this->actor.speed * 1.5f)); } if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (input->rel.stick_y < -30)) { @@ -3744,14 +3745,14 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { if ((D_80917272 == 0) && (D_80917274 == 0)) { // Assignment of OoT's D_80B7E086 here removed in MM - if (((sLinkAge == 1) && (gSaveContext.save.unk_EE4 & 0x400)) || - ((sLinkAge != 1) && (gSaveContext.save.unk_EE4 & 0x800))) { + if (((sLinkAge == 1) && (gSaveContext.save.saveInfo.unk_EC0 & 0x400)) || + ((sLinkAge != 1) && (gSaveContext.save.saveInfo.unk_EC0 & 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 Rumble_Override(0.0f, 1, 3, 1); - Audio_QueueSeqCmd(0x100A00FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 10); } this->unk_150 = this->unk_152 = 0; @@ -3775,7 +3776,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { player->unk_B28 = 3; Rumble_Override(0.0f, 1, 3, 1); D_809171D8++; - Cutscene_Start(play, &play->csCtx); + Cutscene_StartManual(play, &play->csCtx); D_8090CD4C = 100; D_80911F48 = 45.0f; D_8090CD14 = 5; @@ -3804,7 +3805,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { sp10C.y = 10.0f; sp10C.z = 50.0f; } - Matrix_RotateYF((player->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + Matrix_RotateYF(BINANG_TO_RAD_ALT(player->actor.shape.rot.y), MTXMODE_NEW); Matrix_MultVec3f(&sp10C, &sSubCamEye); sSubCamEye.x += player->actor.world.pos.x; @@ -3819,7 +3820,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { } if (this->unk_172[0] == 90) { - Audio_QueueSeqCmd(0x8924); // changed from 0x924 in OoT + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_GET_HEART | 0x900 | SEQ_FLAG_ASYNC); D_8090CCFC = 40; if (this->unk_148 == 0) { @@ -3863,7 +3864,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) || Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if (Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); if (play->msgCtx.choiceIndex == 0) { if (D_8090CCF0 == 0.0f) { D_8090CCF0 = this->unk_1A4; @@ -3895,7 +3896,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) || Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if (Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); if (play->msgCtx.choiceIndex != 0) { f32 temp1 = D_8090CCF0; s16 temp2 = D_809171D0; @@ -3933,7 +3934,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { D_809101C4 = 520.0f; D_809101C0 = 195.0f; - Audio_QueueSeqCmd(0x100A00FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 10); D_809171F6 = 20; D_8090CD4C = 3; } @@ -3955,7 +3956,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { D_8090CF18 = 3; } - Math_ApproachF(&this->actor.speedXZ, 5.0f, 1.0f, 1.0f); + Math_ApproachF(&this->actor.speed, 5.0f, 1.0f, 1.0f); if (sp124 < 20.0f) { Math_ApproachS(&this->unk_168, 0x4E20, 2, 0xFA0); @@ -4014,7 +4015,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { spF6 = -0x1F40; } - if (this->actor.speedXZ >= 3.2f) { + if (this->actor.speed >= 3.2f) { Math_ApproachS(&this->unk_166, spF6, 2, 0x4E20); } else { Math_ApproachS(&this->unk_166, spF6, 3, 0xBB8); @@ -4050,7 +4051,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { 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) { + if (this->actor.speed <= 0.5f) { Math_ApproachS(&this->actor.shape.rot.x, 0, 10, this->unk_170); Math_ApproachS(&this->unk_170, 0x500, 1, 0x20); } else { @@ -4081,14 +4082,14 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { if ((this->actor.world.pos.y < WATER_SURFACE_Y(play)) && (this->actor.world.pos.y > (WATER_SURFACE_Y(play) - 10.0f)) && !(this->unk_154 & 1) && - (this->actor.speedXZ > 0.0f)) { + (this->actor.speed > 0.0f)) { Vec3f pos = this->actor.world.pos; pos.y = WATER_SURFACE_Y(play); EnFishing_SpawnRipple(&this->actor.projectedPos, play->specialEffects, &pos, 80.0f, 500.0f, 150, 90); } - if ((this->actor.speedXZ > 0.0f) || (this->unk_150 == 5)) { + if ((this->actor.speed > 0.0f) || (this->unk_150 == 5)) { f32 velocityY = this->actor.velocity.y; spD8 = this->unk_1A4 * 0.1f; @@ -4097,24 +4098,25 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { this->actor.prevPos.y -= spD8; this->actor.velocity.y = -1.0f; if (KREG(90) == 0) { // Check added in MM - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 30.0f, 100.0f, 0x45); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 30.0f, 100.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40); } this->actor.world.pos.y += spD8; this->actor.prevPos.y += spD8; this->actor.velocity.y = velocityY; - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->unk_198 = 20; } - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (this->actor.world.pos.y > WATER_SURFACE_Y(play)) { 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); + Actor_PlaySfx(&this->actor, NA_SE_EV_FISH_LEAP); func_809036BC(this, play); if (Rand_ZeroOne() < 0.5f) { @@ -4226,20 +4228,20 @@ void EnFishing_DrawFish(Actor* thisx, PlayState* play) { func_8012C28C(play->state.gfxCtx); Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateYF(((this->unk_15A + this->actor.shape.rot.y) / 32768.0f) * M_PI, MTXMODE_APPLY); - Matrix_RotateXFApply(((this->unk_158 + this->actor.shape.rot.x) / 32768.0f) * M_PI); - Matrix_RotateZF(((this->unk_15C + this->actor.shape.rot.z) / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_RotateYF(BINANG_TO_RAD_ALT(this->unk_15A + this->actor.shape.rot.y), MTXMODE_APPLY); + Matrix_RotateXFApply(BINANG_TO_RAD_ALT(this->unk_158 + this->actor.shape.rot.x)); + Matrix_RotateZF(BINANG_TO_RAD_ALT(this->unk_15C + this->actor.shape.rot.z), MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->unk_148 == 0) { - Matrix_RotateYF((this->unk_164 * (M_PI / 32768)) - (M_PI / 2), MTXMODE_APPLY); + Matrix_RotateYF(BINANG_TO_RAD(this->unk_164) - (M_PI / 2), MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, this->unk_164 * 10.0f * 0.01f, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnFishing_FishOverrideLimbDraw, EnFishing_FishPostLimbDraw, &this->actor); } else { Matrix_Translate(0.0f, 0.0f, 3000.0f, MTXMODE_APPLY); - Matrix_RotateYF(this->unk_164 * (M_PI / 32768), MTXMODE_APPLY); + Matrix_RotateYF(BINANG_TO_RAD(this->unk_164), MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, -3000.0f, MTXMODE_APPLY); Matrix_RotateYF(-(M_PI / 2), MTXMODE_APPLY); @@ -4409,7 +4411,7 @@ void EnFishing_DrawPondProps(PlayState* play) { if (prop->shouldDraw) { Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, 1.0f, prop->scale, MTXMODE_APPLY); - Matrix_RotateYF(prop->lilyPadAngle * (M_PI / 32768), MTXMODE_APPLY); + Matrix_RotateYF(BINANG_TO_RAD(prop->lilyPadAngle), MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, 20.0f, MTXMODE_APPLY); Matrix_RotateYF(prop->rotY, MTXMODE_APPLY); @@ -4661,8 +4663,8 @@ void EnFishing_DrawGroupFishes(PlayState* play) { if (fish->shouldDraw) { Matrix_Translate(fish->pos.x, fish->pos.y, fish->pos.z, MTXMODE_NEW); - Matrix_RotateYF(((f32)fish->unk_3E * M_PI) / 32768.0f, MTXMODE_APPLY); - Matrix_RotateXFApply((-(f32)fish->unk_3C * M_PI) / 32768.0f); + Matrix_RotateYF(BINANG_TO_RAD_ALT2(fish->unk_3E), MTXMODE_APPLY); + Matrix_RotateXFApply(BINANG_TO_RAD_ALT2(-(f32)fish->unk_3C)); Matrix_Scale(fish->unk_2C * scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), @@ -4683,7 +4685,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { case 0: if (D_809171FC == 0) { if (sLinkAge != 1) { - if ((gSaveContext.save.unk_EE4 & 0x100) && !(gSaveContext.save.unk_EE4 & 0x200)) { + if ((gSaveContext.save.saveInfo.unk_EC0 & 0x100) && !(gSaveContext.save.saveInfo.unk_EC0 & 0x200)) { this->actor.textId = 0x4093; } else { this->actor.textId = 0x407B; @@ -4701,9 +4703,9 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { if (D_809171FC == 0) { this->unk_154 = 1; if (sLinkAge != 1) { - gSaveContext.save.unk_EE4 |= 0x200; + gSaveContext.save.saveInfo.unk_EC0 |= 0x200; } else { - gSaveContext.save.unk_EE4 |= 0x100; + gSaveContext.save.saveInfo.unk_EC0 |= 0x100; } } else { this->unk_154 = 10; @@ -4715,26 +4717,26 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { case 1: if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); switch (play->msgCtx.choiceIndex) { case 0: - if (gSaveContext.save.playerData.rupees >= 20) { + if (gSaveContext.save.saveInfo.playerData.rupees >= 20) { Rupees_ChangeBy(-20); if (!Rumble_ControllerOneHasRumblePak()) { this->actor.textId = 0x407C; } else { this->actor.textId = 0x407D; } - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); this->unk_154 = 2; } else { - func_80151938(play, 0x407E); + Message_ContinueTextbox(play, 0x407E); this->unk_154 = 3; } break; case 1: - func_80151938(play, 0x2D); + Message_ContinueTextbox(play, 0x2D); this->unk_154 = 3; break; } @@ -4743,15 +4745,15 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { case 2: if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); - func_80151938(play, 0x407F); + Message_CloseTextbox(play); + Message_ContinueTextbox(play, 0x407F); this->unk_154 = 4; } break; case 3: if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); this->unk_154 = 0; } if (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) { @@ -4761,16 +4763,16 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { case 4: if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); switch (play->msgCtx.choiceIndex) { case 0: D_8090CCF8 = D_809171CC; - func_80151938(play, 0x4080); + Message_ContinueTextbox(play, 0x4080); this->unk_154 = 5; break; case 1: - func_80151938(play, 0x407F); + Message_ContinueTextbox(play, 0x407F); break; } } @@ -4778,7 +4780,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { case 5: if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); play->interfaceCtx.unk_27E = 1; play->startPlayerFishing(play); @@ -4786,8 +4788,8 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { D_8090CD04 = 20; this->unk_154 = 0; - if ((gSaveContext.save.unk_EE4 & 0xFF0000) < 0xFF0000) { - gSaveContext.save.unk_EE4 += 0x10000; + if ((gSaveContext.save.saveInfo.unk_EC0 & 0xFF0000) < 0xFF0000) { + gSaveContext.save.saveInfo.unk_EC0 += 0x10000; } } break; @@ -4795,11 +4797,11 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { case 10: if (D_8090CD0C != 0) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); switch (play->msgCtx.choiceIndex) { case 0: - func_80151938(play, 0x40B2); + Message_ContinueTextbox(play, 0x40B2); D_8090CD08 = 1; D_8090CD0C = 0; this->unk_154 = 20; @@ -4811,7 +4813,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { } } else { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); switch (play->msgCtx.choiceIndex) { case 0: @@ -4835,12 +4837,12 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { this->actor.textId = 0x409B; this->unk_154 = 11; } - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); break; case 1: if (D_8090CD00 > 36000) { D_8090CD00 = 30000; - func_80151938(play, 0x4088); + Message_ContinueTextbox(play, 0x4088); } else { if (D_809171CA == 0) { if (D_809171D6 == 0) { @@ -4849,9 +4851,9 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { } if ((D_80917206 == 2) && (D_8090D638[D_809171D6] == 0x408D)) { - func_80151938(play, 0x40AF); + Message_ContinueTextbox(play, 0x40AF); } else { - func_80151938(play, D_8090D638[D_809171D6]); + Message_ContinueTextbox(play, D_8090D638[D_809171D6]); } D_809171D6++; @@ -4870,9 +4872,9 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { break; case 2: if (D_809171D8 == 0) { - func_80151938(play, 0x4085); + Message_ContinueTextbox(play, 0x4085); } else if (sLinkAge == 1) { - func_80151938(play, 0x4092); + Message_ContinueTextbox(play, 0x4092); } this->unk_154 = 22; break; @@ -4887,7 +4889,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { Message_ShouldAdvance(play)) { s32 getItemId; - func_801477B4(play); + Message_CloseTextbox(play); if (D_809171D0 == 0) { D_809171CC = D_8090CCF0; @@ -4896,29 +4898,29 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { if (sLinkAge == 1) { f32 temp; - gSaveContext.save.unk_EE4 &= 0xFFFFFF00; - gSaveContext.save.unk_EE4 |= ((s16)D_809171CC & 0x7F); - temp = (gSaveContext.save.unk_EE4 & 0x7F000000) >> 0x18; + gSaveContext.save.saveInfo.unk_EC0 &= 0xFFFFFF00; + gSaveContext.save.saveInfo.unk_EC0 |= ((s16)D_809171CC & 0x7F); + temp = (gSaveContext.save.saveInfo.unk_EC0 & 0x7F000000) >> 0x18; if (temp < D_809171CC) { - gSaveContext.save.unk_EE4 &= 0xFFFFFF; - gSaveContext.save.unk_EE4 |= ((s16)D_809171CC & 0x7F) << 0x18; + gSaveContext.save.saveInfo.unk_EC0 &= 0xFFFFFF; + gSaveContext.save.saveInfo.unk_EC0 |= ((s16)D_809171CC & 0x7F) << 0x18; if (D_809171D2 == 2) { - gSaveContext.save.unk_EE4 |= 0x80000000; + gSaveContext.save.saveInfo.unk_EC0 |= 0x80000000; } } if (D_809171D2 == 2) { - gSaveContext.save.unk_EE4 |= 0x80; + gSaveContext.save.saveInfo.unk_EC0 |= 0x80; this->unk_154 = 0; break; } } else { - gSaveContext.save.unk_EE4 &= 0xFFFFFF; - gSaveContext.save.unk_EE4 |= ((s16)D_809171CC & 0x7F) << 0x18; + gSaveContext.save.saveInfo.unk_EC0 &= 0xFFFFFF; + gSaveContext.save.saveInfo.unk_EC0 |= ((s16)D_809171CC & 0x7F) << 0x18; if (D_809171D2 == 2) { - gSaveContext.save.unk_EE4 |= 0x80000000; + gSaveContext.save.saveInfo.unk_EC0 |= 0x80000000; this->unk_154 = 0; break; } @@ -4935,14 +4937,14 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { } if (sLinkAge == 1) { - if ((D_809171CC >= 50.0f) && !(gSaveContext.save.unk_EE4 & 0x400)) { - gSaveContext.save.unk_EE4 |= 0x400; + if ((D_809171CC >= 50.0f) && !(gSaveContext.save.saveInfo.unk_EC0 & 0x400)) { + gSaveContext.save.saveInfo.unk_EC0 |= 0x400; getItemId = GI_HEART_PIECE; sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; } } else { - if ((D_809171CC >= 60.0f) && !(gSaveContext.save.unk_EE4 & 0x800)) { - gSaveContext.save.unk_EE4 |= 0x800; + if ((D_809171CC >= 60.0f) && !(gSaveContext.save.saveInfo.unk_EC0 & 0x800)) { + gSaveContext.save.saveInfo.unk_EC0 |= 0x800; getItemId = GI_SKULL_TOKEN; sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; } @@ -4953,21 +4955,21 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { } this->actor.parent = NULL; - Actor_PickUp(&this->actor, play, getItemId, 2000.0f, 1000.0f); + Actor_OfferGetItem(&this->actor, play, getItemId, 2000.0f, 1000.0f); this->unk_154 = 23; } break; case 20: if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); this->unk_154 = 0; } break; case 21: if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); switch (play->msgCtx.choiceIndex) { case 0: @@ -4975,9 +4977,9 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { break; case 1: if (D_809171D8 == 0) { - func_80151938(play, 0x4085); + Message_ContinueTextbox(play, 0x4085); } else if (sLinkAge == 1) { - func_80151938(play, 0x4092); + Message_ContinueTextbox(play, 0x4092); } this->unk_154 = 22; break; @@ -5002,7 +5004,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { this->unk_154 = 24; } else { - Actor_PickUp(&this->actor, play, GI_SKULL_TOKEN, 2000.0f, 1000.0f); + Actor_OfferGetItem(&this->actor, play, GI_SKULL_TOKEN, 2000.0f, 1000.0f); } break; @@ -5105,9 +5107,9 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { } if (D_8090CD08 == 0) { - gSaveContext.save.unk_EE4 |= 0x1000; + gSaveContext.save.saveInfo.unk_EC0 |= 0x1000; } else if (D_8090CD08 == 1) { - gSaveContext.save.unk_EE4 &= ~0x1000; + gSaveContext.save.saveInfo.unk_EC0 &= ~0x1000; } if (D_8090CCFC != 0) { @@ -5133,7 +5135,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { 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; + player->actor.speed = 0.0f; if (D_8090CD50 == 0) { D_8090CD4C = 10; @@ -5148,7 +5150,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { D_8090CD4C = 20; Rumble_Override(0.0f, 150, 10, 10); play_sound(NA_SE_SY_TRE_BOX_APPEAR); - Audio_QueueSeqCmd(0x101400FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20); } if (D_8090CD50 != 0) { @@ -5276,7 +5278,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { mainCam->at = sSubCamAt; } func_80169AFC(play, sSubCamId, 0); - Cutscene_End(play, &play->csCtx); + Cutscene_StopManual(play, &play->csCtx); D_8090CD4C = 0; sSubCamId = SUB_CAM_ID_DONE; func_800F6834(play, 0); @@ -5286,7 +5288,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { break; case 10: - Cutscene_Start(play, &play->csCtx); + Cutscene_StartManual(play, &play->csCtx); sSubCamId = Play_CreateSubCamera(play); Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); Play_ChangeCameraStatus(play, sSubCamId, CAM_STATUS_ACTIVE); @@ -5306,7 +5308,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { // fallthrough case 11: player->actor.world.pos.z = 1360.0f; - player->actor.speedXZ = 0.0f; + player->actor.speed = 0.0f; if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); @@ -5316,8 +5318,8 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { mainCam->at = sSubCamAt; func_80169AFC(play, sSubCamId, 0); - Cutscene_End(play, &play->csCtx); - func_800B7298(play, &this->actor, PLAYER_CSMODE_6); + Cutscene_StopManual(play, &play->csCtx); + func_800B7298(play, &this->actor, PLAYER_CSMODE_END); D_8090CD4C = 0; sSubCamId = SUB_CAM_ID_DONE; D_8090CD50 = 30; @@ -5327,7 +5329,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { break; case 20: - Cutscene_Start(play, &play->csCtx); + Cutscene_StartManual(play, &play->csCtx); sSubCamId = Play_CreateSubCamera(play); Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STATUS_WAIT); Play_ChangeCameraStatus(play, sSubCamId, CAM_STATUS_ACTIVE); @@ -5356,13 +5358,13 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { case 22: if (D_8090CD50 == 30) { - Audio_QueueSeqCmd(0x8922); // changed from 0x922 to 0x8922 in MM + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_GET_ITEM | 0x900 | SEQ_FLAG_ASYNC); } D_8090CD54 = 1; Math_ApproachF(&D_80911F64, 71.0f, 0.5f, 3.0f); - Matrix_RotateYF(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); + Matrix_RotateYF(BINANG_TO_RAD_ALT(player->actor.shape.rot.y), MTXMODE_NEW); sp114.x = Math_SinS(play->gameplayFrames * 0x1000); sp114.y = D_80911F64; @@ -5407,7 +5409,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { if (Message_ShouldAdvance(play)) { Camera* mainCam = Play_GetCamera(play, CAM_ID_MAIN); - func_801477B4(play); + Message_CloseTextbox(play); if (play->msgCtx.choiceIndex == 0) { D_80917206 = 2; D_809171D6 = 0; @@ -5417,9 +5419,8 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { mainCam->eyeNext = sSubCamEye; mainCam->at = sSubCamAt; func_80169AFC(play, sSubCamId, 0); - Cutscene_End(play, &play->csCtx); - func_800B7298(play, &this->actor, - PLAYER_CSMODE_6); // arg2 changed from PLAYER_CSMODE_7 to PLAYER_CSMODE_6 in MM + Cutscene_StopManual(play, &play->csCtx); + func_800B7298(play, &this->actor, PLAYER_CSMODE_END); D_8090CD4C = 0; sSubCamId = SUB_CAM_ID_DONE; player->unk_B28 = -5; @@ -5455,7 +5456,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { } if ((player->actor.floorHeight < (WATER_SURFACE_Y(play) - 3.0f)) && - (player->actor.world.pos.y < (player->actor.floorHeight + 3.0f)) && (player->actor.speedXZ > 1.0f) && + (player->actor.world.pos.y < (player->actor.floorHeight + 3.0f)) && (player->actor.speed > 1.0f) && ((play->gameplayFrames % 2) == 0)) { Vec3f pos; @@ -5466,7 +5467,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) { } if ((player->actor.floorHeight < WATER_SURFACE_Y(play)) && - (player->actor.floorHeight > (WATER_SURFACE_Y(play) - 10.0f)) && (player->actor.speedXZ >= 4.0f) && + (player->actor.floorHeight > (WATER_SURFACE_Y(play) - 10.0f)) && (player->actor.speed >= 4.0f) && ((play->gameplayFrames % 4) == 0)) { s16 i; @@ -5638,15 +5639,15 @@ void EnFishing_DrawOwner(Actor* thisx, PlayState* play) { if (D_809171F6 == 0) { if (sLinkAge != 1) { - Audio_QueueSeqCmd(0x8019); // Changed from 0x19 in OoT + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_CLEAR_EVENT | SEQ_FLAG_ASYNC); } else { - Audio_QueueSeqCmd(0x8027); // Changed from 0x27 in OoT + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_MUSIC_BOX_HOUSE | SEQ_FLAG_ASYNC); } if (sLinkAge != 1) { - Audio_QueueSeqCmd(0x8019); // Changed from 0x19 in OoT + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_CLEAR_EVENT | SEQ_FLAG_ASYNC); } else { - Audio_QueueSeqCmd(0x8027); // Changed from 0x27 in OoT + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_MUSIC_BOX_HOUSE | SEQ_FLAG_ASYNC); } } } 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 3ad6809dc..ffd456af4 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -163,7 +163,7 @@ void EnFloormas_Init(Actor* thisx, PlayState* play2) { this->actor.params = ENFLOORMAS_GET_7FFF(&this->actor); if (params != 0) { - this->actor.flags |= ACTOR_FLAG_80; + this->actor.flags |= ACTOR_FLAG_REACT_TO_LENS; this->actor.draw = func_808D3754; } @@ -176,7 +176,7 @@ void EnFloormas_Init(Actor* thisx, PlayState* play2) { this->actor.parent = Actor_SpawnAsChildAndCutscene( &play->actorCtx, play, ACTOR_EN_FLOORMAS, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, params + 0x10, -1, this->actor.unk20, NULL); + this->actor.world.pos.z, 0, 0, 0, params + 0x10, CS_ID_NONE, this->actor.halfDaysBits, NULL); if (this->actor.parent == NULL) { Actor_Kill(&this->actor); return; @@ -184,7 +184,7 @@ void EnFloormas_Init(Actor* thisx, PlayState* play2) { this->actor.child = Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_FLOORMAS, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, - params + 0x10, -1, this->actor.unk20, NULL); + params + 0x10, CS_ID_NONE, this->actor.halfDaysBits, NULL); if (this->actor.child == NULL) { Actor_Kill(this->actor.parent); Actor_Kill(&this->actor); @@ -224,7 +224,7 @@ void func_808D0930(EnFloormas* this, PlayState* play) { func_808D19D4((EnFloormas*)this->actor.child); func_808D19D4((EnFloormas*)this->actor.parent); func_808D19D4(this); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_HIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_KUSAMUSHI_HIDE); } else { Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x90); func_808D1ED4(this, play); @@ -239,7 +239,7 @@ void func_808D09CC(EnFloormas* this) { this->collider.base.colType = COLTYPE_HIT3; this->unk_18E = 80; this->actor.flags &= ~(ACTOR_FLAG_200 | ACTOR_FLAG_400); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 80); } void func_808D0A48(EnFloormas* this, PlayState* play) { @@ -259,7 +259,7 @@ void func_808D0A48(EnFloormas* this, PlayState* play) { void func_808D0B08(EnFloormas* this) { Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_808D0B50; } @@ -301,7 +301,7 @@ void func_808D0CE4(EnFloormas* this) { } this->unk_18E = Rand_S16Offset(2, 4); - this->actor.speedXZ = 1.5f; + this->actor.speed = 1.5f; this->actionFunc = func_808D0D70; } @@ -316,12 +316,12 @@ void func_808D0D70(EnFloormas* this, PlayState* play) { if ((temp_v0 != 0) || Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 24.0f) || Animation_OnFrame(&this->skelAnime, 36.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_FALL_WALK); } if ((this->actor.xzDistToPlayer < 320.0f) && Actor_IsFacingPlayer(&this->actor, 0x4000)) { func_808D0F50(this); - } else if (this->actor.bgCheckFlags & 8) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->unk_190 = this->actor.wallYaw; func_808D108C(this); } else if ((this->actor.xzDistToPlayer < 400.0f) && !Actor_IsFacingPlayer(&this->actor, 0x4000)) { @@ -334,7 +334,7 @@ void func_808D0D70(EnFloormas* this, PlayState* play) { void func_808D0ECC(EnFloormas* this) { Animation_PlayOnce(&this->skelAnime, &gWallmasterStopWalkAnim); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_808D0F14; } @@ -346,7 +346,7 @@ void func_808D0F14(EnFloormas* this, PlayState* play) { void func_808D0F50(EnFloormas* this) { this->unk_18E = 0; - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; this->skelAnime.playSpeed = 3.0f; this->actionFunc = func_808D0F80; } @@ -355,12 +355,12 @@ void func_808D0F80(EnFloormas* this, PlayState* play) { 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)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_WALK); + Actor_PlaySfx(&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_IsFacingPlayer(&this->actor, 0x2000) && - !(this->actor.bgCheckFlags & 8)) { + !(this->actor.bgCheckFlags & BGCHECKFLAG_WALL)) { func_808D1380(this, play); } else if (this->actor.xzDistToPlayer > 400.0f) { func_808D0CE4(this); @@ -370,7 +370,7 @@ void func_808D0F80(EnFloormas* this, PlayState* play) { void func_808D108C(EnFloormas* this) { s16 sp36 = this->unk_190 - this->actor.shape.rot.y; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (sp36 > 0) { Animation_MorphToPlayOnce(&this->skelAnime, &gFloormasterTurnAnim, -3.0f); } else { @@ -400,9 +400,9 @@ void func_808D11BC(EnFloormas* this, PlayState* play) { 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) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_FALL_WALK); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); } } @@ -419,11 +419,11 @@ void func_808D11BC(EnFloormas* this, PlayState* play) { void func_808D1380(EnFloormas* this, PlayState* play) { Animation_Change(&this->skelAnime, &gWallmasterHoverAnim, 3.0f, 0.0f, Animation_GetLastFrame(&gWallmasterHoverAnim), ANIMMODE_ONCE, -3.0f); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.gravity = 0.0f; func_808D08D0(this); Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, 1); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_FLOORMASTER_ATTACK); this->actionFunc = func_808D1458; } @@ -460,7 +460,7 @@ void func_808D14DC(EnFloormas* this, PlayState* play) { void func_808D161C(EnFloormas* this) { this->unk_18E = 25; this->actor.gravity = -0.15f; - this->actor.speedXZ = 0.5f; + this->actor.speed = 0.5f; this->actionFunc = func_808D1650; } @@ -471,7 +471,7 @@ void func_808D1650(EnFloormas* this, PlayState* play) { this->unk_18E--; } - Math_StepToF(&this->actor.speedXZ, 15.0f, SQ(this->actor.speedXZ) * (1.0f / 3.0f)); + Math_StepToF(&this->actor.speed, 15.0f, SQ(this->actor.speed) * (1.0f / 3.0f)); Math_ScaledStepToS(&this->actor.shape.rot.x, -0x1680, 0x140); temp_f0_2 = this->actor.world.pos.y - this->actor.floorHeight; @@ -485,14 +485,14 @@ void func_808D1650(EnFloormas* this, PlayState* play) { func_808D14DC(this, play); } - if ((this->actor.bgCheckFlags & 8) || (this->unk_18E == 0)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || (this->unk_18E == 0)) { func_808D1740(this); } } void func_808D1740(EnFloormas* this) { Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, 42.0f, ANIMMODE_ONCE, 5.0f); - if ((this->actor.speedXZ < 0.0f) || (this->actionFunc != func_808D1650)) { + if ((this->actor.speed < 0.0f) || (this->actionFunc != func_808D1650)) { this->unk_18E = 30; } else { this->unk_18E = 45; @@ -502,31 +502,31 @@ void func_808D1740(EnFloormas* this) { } void func_808D17EC(EnFloormas* this, PlayState* play) { - s32 sp24 = this->actor.bgCheckFlags & 1; + s32 sp24 = this->actor.bgCheckFlags & BGCHECKFLAG_GROUND; - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { if (this->actor.params != ENFLOORMAS_GET_7FFF_40) { func_808D0908(this); } if (this->actor.velocity.y < -4.0f) { if (this->actor.scale.x > 0.009f) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_LAND); + Actor_PlaySfx(&this->actor, NA_SE_EN_FALL_LAND); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + Actor_PlaySfx(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); } } } - if (this->actor.bgCheckFlags & 8) { - this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { + this->actor.speed = 0.0f; } if (sp24 != 0) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 2.0f); + Math_StepToF(&this->actor.speed, 0.0f, 2.0f); } - if ((this->actor.speedXZ > 0.0f) && ((this->actor.world.pos.y - this->actor.floorHeight) < 12.0f)) { + if ((this->actor.speed > 0.0f) && ((this->actor.world.pos.y - this->actor.floorHeight) < 12.0f)) { func_808D14DC(this, play); } @@ -558,7 +558,7 @@ void func_808D19D4(EnFloormas* this) { this->drawDmgEffAlpha = 0.0f; Actor_SetScale(&this->actor, 0.004f); this->actor.flags |= ACTOR_FLAG_10; - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_REACT_TO_LENS)) { this->actor.draw = func_808D3754; } else { this->actor.draw = EnFloormas_Draw; @@ -575,28 +575,28 @@ void func_808D19D4(EnFloormas* this) { this->actor.flags &= ~ACTOR_FLAG_400; this->actor.flags |= ACTOR_FLAG_200; this->actor.colChkInfo.health = 1; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; this->actor.velocity.y = 7.0f; this->actionFunc = func_808D1B44; } void func_808D1B44(EnFloormas* this, PlayState* play) { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (SkelAnime_Update(&this->skelAnime)) { this->actor.flags |= ACTOR_FLAG_1; this->unk_194 = 50; func_808D0C14(this); } - Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); + Math_StepToF(&this->actor.speed, 0.0f, 1.0f); } - if (this->actor.bgCheckFlags & 2) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + Actor_PlaySfx(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); } } void func_808D1BCC(EnFloormas* this) { Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 4.5f); - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; this->actionFunc = func_808D1C1C; } @@ -607,12 +607,12 @@ void func_808D1C1C(EnFloormas* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); } if (this->unk_194 == 0) { func_808D1D0C(this); - } else if (this->actor.bgCheckFlags & 8) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->unk_190 = this->actor.wallYaw; func_808D108C(this); } else if (this->actor.xzDistToPlayer < 120.0f) { @@ -624,7 +624,7 @@ void func_808D1D0C(EnFloormas* this) { if (this->actionFunc != func_808D1C1C) { Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 4.5f); } - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; this->actionFunc = func_808D1D6C; } @@ -634,10 +634,10 @@ void func_808D1D6C(EnFloormas* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_FLOORMASTER_SM_WALK); } - flags = this->actor.bgCheckFlags & 8; + flags = this->actor.bgCheckFlags & BGCHECKFLAG_WALL; if (flags) { this->unk_190 = this->actor.wallYaw; func_808D108C(this); @@ -651,9 +651,9 @@ void func_808D1D6C(EnFloormas* this, PlayState* play) { return; } - Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, sp2C), 0x38E); + Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardActor(&this->actor, sp2C), 0x38E); - if (Actor_XZDistanceBetweenActors(&this->actor, sp2C) < 80.0f) { + if (Actor_WorldDistXZToActor(&this->actor, sp2C) < 80.0f) { func_808D2484(this); } } else { @@ -667,7 +667,7 @@ void func_808D1D6C(EnFloormas* this, PlayState* play) { void func_808D1ED4(EnFloormas* this, PlayState* play) { Vec3f sp34; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; sp34.x = this->actor.world.pos.x; sp34.y = this->actor.world.pos.y + 15.0f; @@ -686,7 +686,7 @@ void func_808D1F7C(EnFloormas* this, PlayState* play) { void func_808D1FD4(EnFloormas* this) { Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_808D2040; } @@ -697,12 +697,12 @@ void func_808D2040(EnFloormas* this, PlayState* play) { if (this->skelAnime.curFrame < 20.0f) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); } else if (Animation_OnFrame(&this->skelAnime, 20.0f)) { - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; this->actor.velocity.y = 7.0f; - } else if (this->actor.bgCheckFlags & 2) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { this->unk_18E = 50; - this->actor.speedXZ = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + this->actor.speed = 0.0f; + Actor_PlaySfx(&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)) { @@ -716,7 +716,7 @@ void func_808D217C(EnFloormas* this, Player* player) { Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 36.0f, 45.0f, ANIMMODE_ONCE, -3.0f); this->actor.flags &= ~ACTOR_FLAG_1; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; func_808D08D0(this); ptr = &D_808D3900[GET_PLAYER_FORM]; @@ -759,18 +759,18 @@ void func_808D22C8(EnFloormas* this, PlayState* play) { this->actor.shape.rot.x = 0; this->actor.velocity.y = 6.0f; this->actor.flags |= ACTOR_FLAG_1; - this->actor.speedXZ = -3.0f; + this->actor.speed = -3.0f; func_808D1740(this); } else if ((this->unk_190 % 20) == 0) { - func_800B8E58(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->voiceSfxIdOffset); + Player_PlaySfx(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->voiceSfxIdOffset); play->damagePlayer(play, -4); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_STICK - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_FLOORMASTER_SM_STICK - SFX_FLAG); } void func_808D2484(EnFloormas* this) { Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_808D24F0; } @@ -783,7 +783,7 @@ void func_808D24F0(EnFloormas* this, PlayState* play) { } else if (this->actor.child->params == ENFLOORMAS_GET_7FFF_40) { phi_s1 = this->actor.child; } else { - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { this->actor.params = ENFLOORMAS_GET_7FFF_10; func_808D1740(this); } @@ -791,24 +791,24 @@ void func_808D24F0(EnFloormas* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 20.0f)) { - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; this->actor.velocity.y = 7.0f; } else if (this->skelAnime.curFrame < 20.0f) { - Math_ApproachS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, phi_s1), 2, 0xE38); + Math_ApproachS(&this->actor.shape.rot.y, Actor_WorldYawTowardActor(&this->actor, phi_s1), 2, 0xE38); } else if (((phi_s1->world.pos.y - this->actor.world.pos.y) < -10.0f) && (fabsf(this->actor.world.pos.x - phi_s1->world.pos.x) < 10.0f) && (fabsf(this->actor.world.pos.z - phi_s1->world.pos.z) < 10.0f)) { func_808D2A20(this); this->collider.base.ocFlags1 |= OC1_ON; - } else if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + this->actor.speed = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_FLOORMASTER_SM_LAND); func_808D1740(this); } if ((fabsf(this->actor.world.pos.x - phi_s1->world.pos.x) < 5.0f) && (fabsf(this->actor.world.pos.z - phi_s1->world.pos.z) < 5.0f)) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 2.0f); + Math_StepToF(&this->actor.speed, 0.0f, 2.0f); } } @@ -817,7 +817,7 @@ void func_808D2700(EnFloormas* this) { this->unk_18E = 0; this->unk_194 = 1500; this->actor.params = ENFLOORMAS_GET_7FFF_40; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; func_808D08D0(this); this->actionFunc = func_808D2764; } @@ -862,7 +862,7 @@ void func_808D2764(EnFloormas* this, PlayState* play) { 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)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_EXPAND); + Actor_PlaySfx(&this->actor, NA_SE_EN_FLOORMASTER_EXPAND); } this->collider.dim.radius = sCylinderInit.dim.radius * 100.0f * this->actor.scale.x; @@ -923,8 +923,8 @@ void func_808D2AF4(EnFloormas* this, PlayState* play) { void func_808D2B18(EnFloormas* this) { Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterDamageAnim, -3.0f); func_800BE504(&this->actor, &this->collider); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); - this->actor.speedXZ = 5.0f; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 20); + this->actor.speed = 5.0f; this->actor.velocity.y = 5.5f; if (this->actor.params == ENFLOORMAS_GET_7FFF_40) { EnFloormas* parent = (EnFloormas*)this->actor.parent; @@ -944,7 +944,7 @@ void func_808D2B18(EnFloormas* this) { } void func_808D2C08(EnFloormas* this, PlayState* play) { - if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & 1)) { + if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { if (this->actor.colChkInfo.health == 0) { func_808D0930(this, play); } else { @@ -954,18 +954,18 @@ void func_808D2C08(EnFloormas* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 13.0f)) { if (this->actor.scale.x > 0.009f) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } } - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); + Math_StepToF(&this->actor.speed, 0.0f, 0.2f); } void func_808D2CDC(EnFloormas* this) { Animation_PlayOnce(&this->skelAnime, &gWallmasterRecoverFromDamageAnim); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_808D2D30; @@ -978,7 +978,7 @@ void func_808D2D30(EnFloormas* this, PlayState* play) { } void func_808D2D6C(EnFloormas* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->actor.velocity.y > 0.0f) { this->actor.velocity.y = 0.0f; } @@ -1022,14 +1022,14 @@ void func_808D2E34(EnFloormas* this, PlayState* play) { if (this->collider.base.colType != COLTYPE_HARD) { if (!Actor_ApplyDamage(&this->actor)) { if (this->actor.scale.x > 0.009f) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_REVERSE); + Actor_PlaySfx(&this->actor, NA_SE_EN_DAIOCTA_REVERSE); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_FLOORMASTER_SM_DEAD); } Enemy_StartFinishingBlow(play, &this->actor); this->actor.flags &= ~ACTOR_FLAG_1; } else if (this->actor.colChkInfo.damage != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_FALL_DAMAGE); } func_808D0A48(this, play); @@ -1044,13 +1044,15 @@ void func_808D2E34(EnFloormas* this, PlayState* play) { func_808D2D6C(this); } else if (this->actor.colChkInfo.damageEffect == 1) { this->unk_18E = 40; - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, + 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); func_808D2D6C(this); } else if (this->actor.colChkInfo.damageEffect == 5) { this->unk_18E = 40; - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, + 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->drawDmgEffScale = 0.55f; this->drawDmgEffAlpha = 2.0f; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; @@ -1085,8 +1087,8 @@ void EnFloormas_Update(Actor* thisx, PlayState* play) { if (this->actionFunc != func_808D2AA8) { if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; - this->actor.speedXZ *= -0.5f; - this->actor.speedXZ = CLAMP_MAX(this->actor.speedXZ, -5.0f); + this->actor.speed *= -0.5f; + this->actor.speed = CLAMP_MAX(this->actor.speed, -5.0f); this->actor.velocity.y = 5.0f; func_808D1740(this); } @@ -1102,7 +1104,9 @@ void EnFloormas_Update(Actor* thisx, PlayState* play) { Actor_MoveWithGravity(&this->actor); } - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, this->actor.scale.x * 3000.0f, 0.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, this->actor.scale.x * 3000.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); Collider_UpdateCylinder(&this->actor, &this->collider); if (this->actionFunc == func_808D1650) { this->actor.flags |= ACTOR_FLAG_1000000; 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 0fa23e71a..8130f3cc9 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -228,21 +228,21 @@ void EnFsn_UpdateCollider(EnFsn* this, PlayState* play) { } void EnFsn_HandleLookToShopkeeperBuyingCutscene(EnFsn* this) { - if ((this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) && - (this->lookToShopkeeperBuyingCutscene != this->cutscene) && (this->actor.textId == 0x29CE)) { - ActorCutscene_Stop(this->cutscene); - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if ((this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) && (this->lookToShopkeeperBuyingCsId != this->csId) && + (this->actor.textId == 0x29CE)) { + CutsceneManager_Stop(this->csId); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperBuyingCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperBuyingCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; } else if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_Start(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Start(this->csId, &this->actor); this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } } @@ -387,7 +387,7 @@ void EnFsn_SpawnShopItems(EnFsn* this, PlayState* play) { void EnFsn_EndInteraction(EnFsn* this, PlayState* play) { if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } Actor_ProcessTalkRequest(&this->actor, &play->state); @@ -417,7 +417,7 @@ s32 EnFsn_TestEndInteraction(EnFsn* this, PlayState* play, Input* input) { s32 EnFsn_TestCancelOption(EnFsn* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); return true; } return false; @@ -468,7 +468,7 @@ s32 EnFsn_HasPlayerSelectedItem(EnFsn* this, PlayState* play, Input* input) { if (EnFsn_TestItemSelected(play)) { if (!this->items[this->cursorIndex]->isOutOfStock) { this->prevActionFunc = this->actionFunc; - func_80151938(play, this->items[this->cursorIndex]->choiceTextId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->choiceTextId); play_sound(NA_SE_SY_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -737,11 +737,11 @@ void EnFsn_Idle(EnFsn* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; } this->actor.textId = EnFsn_GetWelcome(play); @@ -766,7 +766,7 @@ void EnFsn_Haggle(EnFsn* this, PlayState* play) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); } else { if (this->animIndex == FSN_ANIM_SLAM_COUNTER_LOOP && Animation_OnFrame(&this->skelAnime, 18.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); + Actor_PlaySfx(&this->actor, NA_SE_EV_HANKO); } if (this->flags & ENFSN_CALM_DOWN) { this->flags &= ~ENFSN_CALM_DOWN; @@ -783,7 +783,7 @@ void EnFsn_Haggle(EnFsn* this, PlayState* play) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); } else { if (Animation_OnFrame(&this->skelAnime, 28.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); + Actor_PlaySfx(&this->actor, NA_SE_EV_HANKO); } return; } @@ -797,8 +797,8 @@ void EnFsn_Haggle(EnFsn* this, PlayState* play) { void EnFsn_BeginInteraction(EnFsn* this, PlayState* play) { if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; if (Player_GetMask(play) == PLAYER_MASK_NONE) { func_8011552C(play, DO_ACTION_NEXT); @@ -812,7 +812,7 @@ void EnFsn_BeginInteraction(EnFsn* this, PlayState* play) { this->actionFunc = EnFsn_SetupEndInteractionImmediately; } } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } } @@ -933,7 +933,7 @@ void EnFsn_DeterminePrice(EnFsn* this, PlayState* play) { this->actionFunc = EnFsn_StartBuying; } this->actor.textId = player->actor.textId; - func_801477B4(play); + Message_CloseTextbox(play); } else if (itemAction <= PLAYER_IA_MINUS1) { if (CURRENT_DAY == 3) { this->actor.textId = 0x29DF; @@ -958,7 +958,7 @@ void EnFsn_MakeOffer(EnFsn* this, PlayState* play) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } switch (this->price) { @@ -997,13 +997,13 @@ void EnFsn_GiveItem(EnFsn* this, PlayState* play) { } this->actor.parent = NULL; if (ENFSN_IS_SHOP(&this->actor) && !this->isSelling) { - Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_BOTTLE); + Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_BOTTLE_EMPTY); } this->actionFunc = EnFsn_SetupResumeInteraction; } else if (this->isSelling == true) { - Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); } else { - Actor_PickUp(&this->actor, play, this->getItemId, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, this->getItemId, 300.0f, 300.0f); } } @@ -1021,17 +1021,17 @@ void EnFsn_ResumeInteraction(EnFsn* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (ENFSN_IS_SHOP(&this->actor)) { if (!this->isSelling) { - this->cutscene = this->lookToShopkeeperBuyingCutscene; + this->csId = this->lookToShopkeeperBuyingCsId; this->actor.textId = 0x29D0; } else { - this->cutscene = this->lookToShopkeeperCutscene; + this->csId = this->lookToShopkeeperCsId; this->actor.textId = (this->numSellingItems <= 0) ? 0x29DE : 0x29D6; } Message_StartTextbox(play, this->actor.textId, &this->actor); - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); this->actionFunc = EnFsn_ResumeShoppingInteraction; } else { EnFsn_HandleConversationBackroom(this, play); @@ -1044,8 +1044,8 @@ void EnFsn_ResumeInteraction(EnFsn* this, PlayState* play) { void EnFsn_ResumeShoppingInteraction(EnFsn* this, PlayState* play) { if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; if (!this->isSelling) { this->actionFunc = EnFsn_AskCanBuyMore; @@ -1058,33 +1058,33 @@ void EnFsn_ResumeShoppingInteraction(EnFsn* this, PlayState* play) { this->actionFunc = EnFsn_FaceShopkeeperSelling; } } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = !this->isSelling ? this->lookToShopkeeperBuyingCutscene : this->lookToShopkeeperCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = !this->isSelling ? this->lookToShopkeeperBuyingCsId : this->lookToShopkeeperCsId; + CutsceneManager_Queue(this->csId); } } } void EnFsn_LookToShelf(EnFsn* this, PlayState* play) { if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + CutsceneManager_Stop(this->csId); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShelfCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShelfCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; } else if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene) != 0) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; EnFsn_UpdateCursorPos(this, play); this->actionFunc = EnFsn_BrowseShelf; - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } } @@ -1108,7 +1108,7 @@ void EnFsn_BrowseShelf(EnFsn* this, PlayState* play) { EnFsn_CursorLeftRight(this); if (this->cursorIndex != prevCursorIdx) { play_sound(NA_SE_SY_CURSOR); - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); } } } @@ -1117,24 +1117,24 @@ void EnFsn_BrowseShelf(EnFsn* this, PlayState* play) { void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, PlayState* play) { if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + CutsceneManager_Stop(this->csId); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperFromShelfCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperFromShelfCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; } else if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; this->actor.textId = 0x29D6; - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); this->actionFunc = EnFsn_FaceShopkeeperSelling; } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } } @@ -1148,13 +1148,13 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, PlayState* play) { SET_WEEKEVENTREG(WEEKEVENTREG_33_04); case CANBUY_RESULT_SUCCESS_1: if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } func_8019F208(); item = this->items[this->cursorIndex]; item->buyFanfareFunc(play, item); - Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; Interface_SetHudVisibility(HUD_VISIBILITY_ALL); @@ -1173,12 +1173,12 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, PlayState* play) { break; case CANBUY_RESULT_NEED_RUPEES: play_sound(NA_SE_SY_ERROR); - func_80151938(play, 0x29F0); + Message_ContinueTextbox(play, 0x29F0); this->actionFunc = EnFsn_PlayerCannotBuy; break; case CANBUY_RESULT_CANNOT_GET_NOW: play_sound(NA_SE_SY_ERROR); - func_80151938(play, 0x29DD); + Message_ContinueTextbox(play, 0x29DD); this->actionFunc = EnFsn_PlayerCannotBuy; break; } @@ -1214,7 +1214,7 @@ void EnFsn_SelectItem(EnFsn* this, PlayState* play) { case 1: func_8019F230(); this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); } } } @@ -1223,7 +1223,7 @@ void EnFsn_SelectItem(EnFsn* this, PlayState* play) { void EnFsn_PlayerCannotBuy(EnFsn* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); } } @@ -1231,15 +1231,15 @@ void EnFsn_AskCanBuyMore(EnFsn* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperCsId; + CutsceneManager_Queue(this->csId); } } if (talkState == TEXT_STATE_CHOICE) { @@ -1277,15 +1277,15 @@ void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperCsId; + CutsceneManager_Queue(this->csId); } } if (talkState == TEXT_STATE_CHOICE) { @@ -1380,10 +1380,10 @@ void EnFsn_ConverseBackroom(EnFsn* this, PlayState* play) { } void EnFsn_GetCutscenes(EnFsn* this) { - this->lookToShopkeeperCutscene = this->actor.cutscene; - this->lookToShelfCutscene = ActorCutscene_GetAdditionalCutscene(this->lookToShopkeeperCutscene); - this->lookToShopkeeperFromShelfCutscene = ActorCutscene_GetAdditionalCutscene(this->lookToShelfCutscene); - this->lookToShopkeeperBuyingCutscene = ActorCutscene_GetAdditionalCutscene(this->lookToShopkeeperFromShelfCutscene); + this->lookToShopkeeperCsId = this->actor.csId; + this->lookToShelfCsId = CutsceneManager_GetAdditionalCsId(this->lookToShopkeeperCsId); + this->lookToShopkeeperFromShelfCsId = CutsceneManager_GetAdditionalCsId(this->lookToShelfCsId); + this->lookToShopkeeperBuyingCsId = CutsceneManager_GetAdditionalCsId(this->lookToShopkeeperFromShelfCsId); } void EnFsn_Blink(EnFsn* this) { diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h index 35b654c3d..f214dcbd9 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h @@ -33,11 +33,11 @@ typedef struct EnFsn { /* 0x364 */ s16 eyeTexIndex; /* 0x366 */ s16 blinkTimer; /* 0x368 */ s16 cutsceneState; - /* 0x36A */ s16 cutscene; - /* 0x36C */ s16 lookToShopkeeperCutscene; - /* 0x36E */ s16 lookToShelfCutscene; - /* 0x370 */ s16 lookToShopkeeperFromShelfCutscene; - /* 0x372 */ s16 lookToShopkeeperBuyingCutscene; + /* 0x36A */ s16 csId; + /* 0x36C */ s16 lookToShopkeeperCsId; + /* 0x36E */ s16 lookToShelfCsId; + /* 0x370 */ s16 lookToShopkeeperFromShelfCsId; + /* 0x372 */ s16 lookToShopkeeperBuyingCsId; /* 0x374 */ s16 price; /* 0x376 */ u16 textId; /* 0x378 */ u8 isSelling; 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 041cadaa7..97f996ff1 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -12,7 +12,7 @@ #include "objects/object_mu/object_mu.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnFu*)thisx) @@ -229,7 +229,7 @@ void EnFu_Init(Actor* thisx, PlayState* play) { void EnFu_Destroy(Actor* thisx, PlayState* play) { EnFu* this = THIS; - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); CLEAR_WEEKEVENTREG(WEEKEVENTREG_08_01); Collider_DestroyCylinder(play, &this->collider); } @@ -254,7 +254,7 @@ void func_80961D7C(PlayState* play) { Actor* explosive = play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (explosive != NULL) { - if ((explosive->id == ACTOR_EN_BOM) && (explosive->bgCheckFlags & 1)) { + if ((explosive->id == ACTOR_EN_BOM) && (explosive->bgCheckFlags & BGCHECKFLAG_GROUND)) { EnBom* bomb = (EnBom*)explosive; if (bomb->actor.floorBgId != BGCHECK_SCENE) { @@ -429,7 +429,7 @@ void func_80962588(EnFu* this, PlayState* play) { if (Message_ShouldAdvance(play) && (this->unk_552 == 0x2871)) { if (1) {} if (play->msgCtx.choiceIndex == 0) { - if (gSaveContext.save.playerData.rupees >= 10) { + if (gSaveContext.save.saveInfo.playerData.rupees >= 10) { func_8019F208(); Rupees_ChangeBy(-10); func_80963DE4(this, play); @@ -532,13 +532,13 @@ void func_80962660(EnFu* this, PlayState* play) { break; case 0x287D: - SET_WEEKEVENTREG(WEEKEVENTREG_63_01); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); - func_801477B4(play); + SET_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); + Message_CloseTextbox(play); player->stateFlags1 |= PLAYER_STATE1_20; this->unk_53C = 0; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); - func_801A2BB8(NA_BGM_TIMED_MINI_GAME); + Audio_PlaySubBgm(NA_BGM_TIMED_MINI_GAME); if (this->unk_542 == 0) { if (this->unk_546 == 1) { func_80961EC8(play); @@ -560,7 +560,7 @@ void func_80962660(EnFu* this, PlayState* play) { case 0x287E: case 0x2880: case 0x2883: - func_801477B4(play); + Message_CloseTextbox(play); func_80963540(this); func_80963560(this, play); break; @@ -605,8 +605,8 @@ void func_809628D0(EnFu* this, PlayState* play) { case 0x2884: case 0x2887: case 0x288A: - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); func_809622FC(this); break; @@ -652,7 +652,7 @@ void func_80962A10(EnFu* this, PlayState* play) { this->unk_546 = 1; } - if ((gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && gSaveContext.save.playerData.isMagicAcquired) { + if ((gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && gSaveContext.save.saveInfo.playerData.isMagicAcquired) { Magic_Add(play, MAGIC_FILL_TO_CAPACITY); } @@ -727,9 +727,9 @@ void func_80962D60(EnFu* this, PlayState* play) { void func_80962EBC(EnFu* this, PlayState* play) { if (this->unk_542 != 0) { - if (this->actor.cutscene != -1) { - Camera_ChangeDataIdx(play->cameraPtrs[CAM_ID_MAIN], - ActorCutscene_GetCutscene(this->actor.cutscene)->csCamSceneDataId); + if (this->actor.csId != CS_ID_NONE) { + Camera_ChangeActorCsCamIndex(play->cameraPtrs[CAM_ID_MAIN], + CutsceneManager_GetCutsceneEntry(this->actor.csId)->csCamId); } } } @@ -775,8 +775,8 @@ void func_80962F4C(EnFu* this, PlayState* play) { Message_StartTextbox(play, 0x288B, &this->actor); } - if ((!DynaPolyActor_IsInRidingRotatingState((DynaPolyActor*)this->actor.child) && - (player->actor.bgCheckFlags & 1)) || + if ((!DynaPolyActor_IsPlayerAbove((DynaPolyActor*)this->actor.child) && + (player->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) || (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] <= SECONDS_TO_TIMER(0)) || (this->unk_548 == this->unk_54C)) { player->stateFlags3 &= ~PLAYER_STATE3_400000; func_80961E88(play); @@ -789,14 +789,14 @@ void func_80962F4C(EnFu* this, PlayState* play) { Message_StartTextbox(play, 0x2888, &this->actor); this->unk_552 = 0x2888; } - func_801A2C20(); + Audio_StopSubBgm(); gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] = SECONDS_TO_TIMER(0); gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; this->unk_548 = 0; func_809632D0(this); } else { this->unk_548 = 0; - func_801A2C20(); + Audio_StopSubBgm(); gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] = SECONDS_TO_TIMER(0); gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); @@ -843,7 +843,7 @@ void func_80963350(EnFu* this, PlayState* play) { if ((this->unk_54A == 0) && (((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) || ((Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) && (play->msgCtx.stateTimer == 1)))) { - func_801477B4(play); + Message_CloseTextbox(play); this->unk_54A = 2; D_80964C24 = 1; } @@ -879,9 +879,9 @@ void func_80963560(EnFu* this, PlayState* play) { this->actor.parent = NULL; func_80963610(this); } else if ((this->unk_552 == 0x2880) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_22_80)) { - Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); } else { - Actor_PickUp(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); } this->actor.child->freezeTimer = 10; } @@ -1139,7 +1139,7 @@ void func_80963DE4(EnFu* this, PlayState* play) { } void func_80963EAC(EnFu* this, PlayState* play) { - if (gSaveContext.save.playerData.isMagicAcquired) { + if (gSaveContext.save.saveInfo.playerData.isMagicAcquired) { if (this->unk_540 == 1) { Message_StartTextbox(play, 0x2847, &this->actor); this->unk_552 = 0x2847; @@ -1176,7 +1176,7 @@ void func_80963FF8(EnFu* this, PlayState* play) { if (player->stateFlags1 & PLAYER_STATE1_100000) { play->actorCtx.unk268 = 1; - play->actorCtx.unk_26C.press.button = 0x8000; + play->actorCtx.unk_26C.press.button = BTN_A; } else { play->actorCtx.unk268 = 1; } @@ -1337,7 +1337,7 @@ void EnFu_Update(Actor* thisx, PlayState* play) { func_809642E0(this, play); Actor_MoveWithGravity(&this->actor); func_8096209C(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); SkelAnime_Update(&this->skelAnime); func_80961D7C(play); func_809640D8(this, play); @@ -1448,7 +1448,7 @@ void func_80964950(PlayState* play, EnFuUnkStruct* ptr, s32 len) { OPEN_DISPS(play->state.gfxCtx); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); for (i = 0; i < len; i++, ptr++) { diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c index b232210f5..e976e01dc 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c @@ -86,7 +86,7 @@ void EnFuKago_Init(Actor* thisx, PlayState* play) { CollisionHeader* sp34 = NULL; Actor* npc = play->actorCtx.actorLists[ACTORCAT_NPC].first; - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); CollisionHeader_GetVirtual(&object_fu_mato_Colheader_0015C0, &sp34); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp34); Actor_SetScale(&this->dyna.actor, 0.1f); @@ -136,7 +136,7 @@ s32 func_80ACF8B8(EnFuKago* this, PlayState* play) { return false; } - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfx(&this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); return true; } else { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); @@ -227,8 +227,8 @@ void func_80ACFA78(EnFuKago* this, PlayState* play) { this->unk_338 = 60; this->unk_33A = 1; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODBOX_BREAK); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_WOODBOX_BREAK); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->actionFunc = func_80AD0028; } diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c index 6f9706a2b..c42278805 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c @@ -75,7 +75,7 @@ void EnFuMato_Init(Actor* thisx, PlayState* play) { Actor* actor = play->actorCtx.actorLists[ACTORCAT_NPC].first; EnFu* fu; - DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); CollisionHeader_GetVirtual(&object_fu_mato_Colheader_0023D4, &sp2C); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp2C); Actor_SetScale(&this->dyna.actor, 0.1f); @@ -156,7 +156,7 @@ void func_80ACE51C(EnFuMato* this, PlayState* play) { } } - this->dyna.actor.speedXZ = 2.0f; + this->dyna.actor.speed = 2.0f; this->dyna.actor.shape.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &this->dyna.actor.parent->world.pos); Actor_MoveWithGravity(&this->dyna.actor); @@ -174,7 +174,7 @@ void func_80ACE680(EnFuMato* this) { this->unk_2FC.y = Rand_Next() & 0xFFF; this->unk_2FC.z = Rand_Next() & 0xFFF; this->unk_302 = 3; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODPLATE_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_WOODPLATE_BOUND); this->actionFunc = func_80ACE718; } @@ -185,9 +185,10 @@ void func_80ACE718(EnFuMato* this, PlayState* play) { this->dyna.actor.velocity.y += this->dyna.actor.gravity; Actor_UpdatePos(&this->dyna.actor); - Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 15.0f, 30.0f, 60.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 15.0f, 30.0f, 60.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); - if ((this->dyna.actor.bgCheckFlags & 1) || (this->dyna.actor.world.pos.y < -500.0f)) { + if ((this->dyna.actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->dyna.actor.world.pos.y < -500.0f)) { Vec3f sp3C = { 0.0f, 0.0f, 0.0f }; Vec3f sp30 = { 0.0f, 2.0f, 0.0f }; @@ -241,7 +242,7 @@ void func_80ACE850(EnFuMato* this, PlayState* play) { this->dyna.actor.freezeTimer = 2; EffectSsHahen_SpawnBurst(play, &this->dyna.actor.world.pos, 13.0f, 0, 7, 8, 20, HAHEN_OBJECT_DEFAULT, 10, NULL); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODPLATE_BROKEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_WOODPLATE_BROKEN); this->actionFunc = func_80ACECFC; } @@ -329,8 +330,9 @@ void func_80ACECFC(EnFuMato* this, PlayState* play) { } if (this->unk_302 == 1) { - Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 15.0f, 30.0f, 60.0f, 5); - if (this->dyna.actor.bgCheckFlags & 1) { + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 15.0f, 30.0f, 60.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); + if (this->dyna.actor.bgCheckFlags & BGCHECKFLAG_GROUND) { func_80ACEB2C(this); } } @@ -368,7 +370,7 @@ s32 func_80ACF04C(EnFuMato* this, PlayState* play) { this->collider.base.acFlags &= ~AC_HIT; this->collider.base.ocFlags1 &= ~OC1_HIT; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfx(&this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); fu->unk_548++; if ((fu->unk_542 == 2) || (gSaveContext.save.playerForm == PLAYER_FORM_DEKU)) { 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 f7d1d7cd1..fe4e6636b 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -188,7 +188,7 @@ void EnFz_Init(Actor* thisx, PlayState* play) { this->unk_BCE = 0; this->unk_BD7 = 1; this->unk_BD8 = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.uncullZoneScale = 400.0f; this->unk_BAC = this->actor.world.pos.y; this->unk_BB4 = this->actor.world.pos.y; @@ -359,12 +359,12 @@ void func_80932C98(EnFz* this, PlayState* play) { Vec3f sp3C; if (this->unk_BCD != 0) { - if ((this->actor.bgCheckFlags & 8) || + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || !Actor_TestFloorInDirection(&this->actor, play, 60.0f, this->actor.world.rot.y)) { - this->actor.bgCheckFlags &= ~0x8; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WALL; this->unk_BCD = 0; this->unk_BBC = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } } @@ -375,8 +375,8 @@ void func_80932C98(EnFz* this, PlayState* play) { if ((parent->update == NULL) || (parent->colChkInfo.health <= 0)) { this->actor.colChkInfo.health = 0; this->unk_BC4 = 5; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FREEZAD_DEAD); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); + Actor_PlaySfx(&this->actor, NA_SE_EN_FREEZAD_DEAD); + Actor_PlaySfx(&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; @@ -388,8 +388,8 @@ void func_80932C98(EnFz* this, PlayState* play) { if ((this->actor.colChkInfo.health != 0) && (this->unk_BC4 == 1)) { this->actor.colChkInfo.health = 0; this->unk_BC4 = 5; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FREEZAD_DEAD); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); + Actor_PlaySfx(&this->actor, NA_SE_EN_FREEZAD_DEAD); + Actor_PlaySfx(&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; @@ -405,7 +405,7 @@ void func_80932C98(EnFz* this, PlayState* play) { this->unk_BCD = 0; this->unk_BBC = 0.0f; this->collider1.base.acFlags &= ~AC_HIT; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_BCA = 10; func_809330D4(this); } else if (this->collider2.base.acFlags & AC_BOUNCED) { @@ -420,9 +420,9 @@ void func_80932C98(EnFz* this, PlayState* play) { case 15: Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_XLU, 8); if (this->actor.colChkInfo.health != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FREEZAD_DAMAGE); + Actor_PlaySfx(&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; @@ -430,8 +430,8 @@ void func_80932C98(EnFz* this, PlayState* play) { this->unk_BCF++; break; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FREEZAD_DEAD); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); + Actor_PlaySfx(&this->actor, NA_SE_EN_FREEZAD_DEAD); + Actor_PlaySfx(&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; @@ -440,7 +440,7 @@ void func_80932C98(EnFz* this, PlayState* play) { break; case 2: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FREEZAD_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_FREEZAD_DEAD); func_80933790(this); break; } @@ -572,7 +572,7 @@ void func_809333D8(EnFz* this, PlayState* play) { void func_80933414(EnFz* this) { this->unk_BD6 = 1; this->unk_BBC = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_BCA = 40; this->actionFunc = func_80933444; } @@ -649,7 +649,7 @@ void func_809336C0(EnFz* this, PlayState* play) { this->unk_BBC = 0.0f; this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_BCC = 1; this->unk_BCE = 0; this->unk_BD8 = 1; @@ -672,7 +672,7 @@ void func_80933790(EnFz* this) { this->unk_BCE = 0; this->unk_BD8 = 1; this->actor.flags &= ~ACTOR_FLAG_1; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_BBC = 0.0f; this->actionFunc = func_809337D4; } @@ -821,10 +821,10 @@ void EnFz_Update(Actor* thisx, PlayState* play) { } } - Math_StepToF(&this->actor.speedXZ, this->unk_BBC, 0.2f); + Math_StepToF(&this->actor.speed, this->unk_BBC, 0.2f); Actor_MoveWithGravity(&this->actor); if (this->unk_BCC != 0) { - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } D_809347AC[this->unk_BD6](this); diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c index 55dc23737..add0814bd 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c @@ -210,7 +210,7 @@ void EnGakufu_GiveReward(EnGakufu* this, PlayState* play) { play_sound(NA_SE_SY_CORRECT_CHIME); - hour = gSaveContext.save.time * (24.0f / 0x10000); // TIME_TO_HOURS_F + hour = TIME_TO_HOURS_F(gSaveContext.save.time); for (i = 0; i < 3; i++) { Item_DropCollectible(play, &sRewardDropsSpawnTerminaFieldPos, sRewardDrops[i + sRewardDropsIndex[hour]]); } @@ -219,13 +219,13 @@ void EnGakufu_GiveReward(EnGakufu* this, PlayState* play) { } void EnGakufu_PlayRewardCutscene(EnGakufu* this, PlayState* play) { - if (this->actor.cutscene == -1) { + if (this->actor.csId == CS_ID_NONE) { EnGakufu_GiveReward(this, play); - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); EnGakufu_GiveReward(this, play); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } diff --git a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c index 40c3d5c05..9f45748df 100644 --- a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c +++ b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c @@ -126,7 +126,7 @@ void func_80AF6994(EnGamelupy* this) { void func_80AF69A8(EnGamelupy* this, PlayState* play) { if (this->collider.base.ocFlags1 & OC1_HIT) { - *this->unk_198 += 0x32; + *this->unk_198 += 50; if (this->rupeeIndex == 1) { Rupees_ChangeBy(5); } else { @@ -140,7 +140,7 @@ void func_80AF69A8(EnGamelupy* this, PlayState* play) { void func_80AF6A38(EnGamelupy* this) { this->unk_19C = 0; this->actor.gravity = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_GET_RUPY); + Actor_PlaySfx(&this->actor, NA_SE_SY_GET_RUPY); this->actionFunc = func_80AF6A78; } @@ -171,7 +171,7 @@ void EnGamelupy_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 0.0f, 0xC); + Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 0.0f, UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8); func_80AF6B40(this, play); } 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 d6643dbeb..9c2d7fe37 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -163,7 +163,7 @@ u16 func_80B0F7FC(EnGb2* this) { return 0x14E4; } - if (gSaveContext.save.playerData.health > 48) { + if (gSaveContext.save.saveInfo.playerData.health > 48) { return 0x14D2; } @@ -171,7 +171,7 @@ u16 func_80B0F7FC(EnGb2* this) { return 0x14D3; case 0x14E4: - if (gSaveContext.save.playerData.health > 48) { + if (gSaveContext.save.saveInfo.playerData.health > 48) { return 0x14D2; } @@ -241,9 +241,9 @@ u16 func_80B0F97C(EnGb2* this) { } 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]); + this->csIdList[0] = this->actor.csId; + this->csIdList[1] = CutsceneManager_GetAdditionalCsId(this->csIdList[0]); + this->csIdList[2] = CutsceneManager_GetAdditionalCsId(this->csIdList[1]); } s32 func_80B0FA48(EnGb2* this, PlayState* play) { @@ -355,7 +355,7 @@ void func_80B0FD8C(EnGb2* this, PlayState* play) { } void func_80B0FE18(PlayState* play) { - func_800FD750(0x38); + func_800FD750(NA_BGM_MINI_BOSS); play->nextEntrance = ENTRANCE(GHOST_HUT, 1); play->transitionType = TRANS_TYPE_64; gSaveContext.nextTransitionType = TRANS_TYPE_64; @@ -407,7 +407,7 @@ void func_80B0FFA8(EnGb2* this, PlayState* play) { if (this->unk_26E == 0x14D5) { switch (play->msgCtx.choiceIndex) { case 0: - if (gSaveContext.save.playerData.rupees < this->unk_288) { + if (gSaveContext.save.saveInfo.playerData.rupees < this->unk_288) { play_sound(NA_SE_SY_ERROR); this->unk_26E = 0x14D7; this->unk_26C |= 2; @@ -433,7 +433,7 @@ void func_80B0FFA8(EnGb2* this, PlayState* play) { Rupees_ChangeBy(-this->unk_288); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; - func_800B7298(play, NULL, PLAYER_CSMODE_7); + func_800B7298(play, NULL, PLAYER_CSMODE_WAIT); this->actionFunc = func_80B11344; break; @@ -451,10 +451,10 @@ void func_80B0FFA8(EnGb2* this, PlayState* play) { void func_80B10240(EnGb2* this, PlayState* play) { 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->csIdList[0] = this->actor.csId; this->unk_268 = NULL; - if (ActorCutscene_GetCanPlayNext(this->unk_282[0])) { - ActorCutscene_Start(this->unk_282[0], &this->actor); + if (CutsceneManager_IsNext(this->csIdList[0])) { + CutsceneManager_Start(this->csIdList[0], &this->actor); Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, 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); @@ -463,7 +463,7 @@ void func_80B10240(EnGb2* this, PlayState* play) { } this->actionFunc = func_80B10344; } else { - ActorCutscene_SetIntentToPlay(this->unk_282[0]); + CutsceneManager_Queue(this->csIdList[0]); } } @@ -505,7 +505,7 @@ void func_80B10344(EnGb2* this, PlayState* play) { } } - if (gSaveContext.save.playerData.health < 49) { + if (gSaveContext.save.saveInfo.playerData.health < 49) { gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; SET_EVENTINF(EVENTINF_46); SET_EVENTINF(EVENTINF_45); @@ -575,7 +575,7 @@ void func_80B10634(EnGb2* this, PlayState* play) { } else if ((talkState == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: - if (gSaveContext.save.playerData.rupees < this->unk_288) { + if (gSaveContext.save.saveInfo.playerData.rupees < this->unk_288) { play_sound(NA_SE_SY_ERROR); this->unk_26E = 0x14D7; this->unk_26C |= 2; @@ -585,7 +585,7 @@ void func_80B10634(EnGb2* this, PlayState* play) { Rupees_ChangeBy(-this->unk_288); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; - func_800B7298(play, NULL, PLAYER_CSMODE_7); + func_800B7298(play, NULL, PLAYER_CSMODE_WAIT); this->actionFunc = func_80B11344; } break; @@ -601,16 +601,16 @@ void func_80B10634(EnGb2* this, PlayState* play) { } void func_80B10868(EnGb2* this, PlayState* play) { - if (ActorCutscene_GetCurrentIndex() != this->unk_282[2]) { - if (ActorCutscene_GetCanPlayNext(this->unk_282[this->unk_290])) { + if (CutsceneManager_GetCurrentCsId() != this->csIdList[2]) { + if (CutsceneManager_IsNext(this->csIdList[this->csIdIndex])) { this->actionFunc = func_80B10A48; - ActorCutscene_StartAndSetFlag(this->unk_282[this->unk_290], &this->actor); + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csIdList[this->csIdIndex], &this->actor); } else { - ActorCutscene_SetIntentToPlay(this->unk_282[this->unk_290]); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); } } else { - this->unk_290 = 1; - ActorCutscene_SetIntentToPlay(this->unk_282[this->unk_290]); + this->csIdIndex = 1; + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); } } @@ -632,7 +632,7 @@ void func_80B10924(EnGb2* this, PlayState* play) { } this->actionFunc = func_80B109DC; } else { - Actor_PickUp(&this->actor, play, sp24, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, sp24, 300.0f, 300.0f); } } @@ -641,7 +641,7 @@ void func_80B109DC(EnGb2* this, PlayState* play) { Message_StartTextbox(play, this->unk_26E, &this->actor); this->actionFunc = func_80B10634; } else { - func_800B85E0(&this->actor, play, 300.0f, -1); + func_800B85E0(&this->actor, play, 300.0f, PLAYER_IA_MINUS1); } } @@ -656,12 +656,12 @@ void func_80B10A48(EnGb2* this, PlayState* play) { break; case ENGB2_7_1: - ActorCutscene_Stop(this->unk_282[this->unk_290]); + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); Actor_Kill(&this->actor); break; case ENGB2_7_2: - ActorCutscene_Stop(this->unk_282[this->unk_290]); + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); if (this->unk_26E == 0x14FB) { Flags_SetSwitch(play, ENGB2_GET_7F8(&this->actor)); Actor_Kill(&this->actor); @@ -694,7 +694,7 @@ void func_80B10B5C(EnGb2* this, PlayState* play) { this->unk_26C |= 2; } Message_StartTextbox(play, this->unk_26E, &this->actor); - this->unk_290 = 1; + this->csIdIndex = 1; this->unk_26C &= ~0x40; this->actionFunc = func_80B10DAC; } else if ((this->actor.xzDistToPlayer < 300.0f) && this->actor.isTargeted) { @@ -712,7 +712,7 @@ void func_80B10B5C(EnGb2* this, PlayState* play) { SET_WEEKEVENTREG(WEEKEVENTREG_80_20); } this->unk_26C &= ~0x20; - this->unk_290 = 0; + this->csIdIndex = 0; this->unk_26C |= 0x80; this->actionFunc = func_80B10DAC; } else if (this->actor.xzDistToPlayer < 300.0f) { @@ -726,9 +726,9 @@ void func_80B10B5C(EnGb2* this, PlayState* play) { } void func_80B10DAC(EnGb2* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->unk_282[this->unk_290])) { + if (CutsceneManager_IsNext(this->csIdList[this->csIdIndex])) { if (ENGB2_GET_7(&this->actor) == ENGB2_7_1) { - if (this->unk_290 != 2) { + if (this->csIdIndex != 2) { this->actionFunc = func_80B10E98; } else { Flags_SetSwitch(play, ENGB2_GET_7F8(&this->actor)); @@ -737,12 +737,12 @@ void func_80B10DAC(EnGb2* this, PlayState* play) { } else { this->actionFunc = func_80B110F8; } - ActorCutscene_StartAndSetFlag(this->unk_282[this->unk_290], &this->actor); + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csIdList[this->csIdIndex], &this->actor); } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->unk_282[this->unk_290]); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); } } @@ -753,14 +753,14 @@ void func_80B10E98(EnGb2* this, PlayState* play) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; if ((this->unk_26E != 0x14E8) && (this->unk_26E != 0x14EA)) { - ActorCutscene_Stop(this->unk_282[this->unk_290]); + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); this->actionFunc = func_80B10B5C; } else if (Flags_GetSwitch(play, 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]); + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); + this->csIdIndex = 2; + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); this->actionFunc = func_80B10DAC; } } else { @@ -770,9 +770,9 @@ void func_80B10E98(EnGb2* this, PlayState* play) { Message_StartTextbox(play, 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]); + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); + this->csIdIndex = 1; + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); this->actionFunc = func_80B10DAC; } } @@ -832,15 +832,15 @@ void func_80B111AC(EnGb2* this, PlayState* play) { 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.world.rot.y = DEG_TO_BINANG(D_80B11A00[index][3]); this->actor.shape.rot.y = this->actor.world.rot.y; this->actionFunc = func_80B11268; } void func_80B11268(EnGb2* this, PlayState* play) { if (play->roomCtx.curRoom.num == 1) { - this->unk_290 = 0; - this->unk_282[0] = this->actor.cutscene; + this->csIdIndex = 0; + this->csIdList[0] = this->actor.csId; if (Flags_GetClear(play, 2) && Flags_GetClear(play, 3) && Flags_GetClear(play, 4) && Flags_GetClear(play, 5)) { this->unk_28A = 0xFF; this->unk_26C &= ~0x100; @@ -887,7 +887,7 @@ void EnGb2_Init(Actor* thisx, PlayState* play) { case ENGB2_7_0: if (CHECK_WEEKEVENTREG(WEEKEVENTREG_54_80)) { Actor_Kill(&this->actor); - } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20)) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE)) { Actor_Kill(&this->actor); } @@ -927,8 +927,8 @@ void EnGb2_Init(Actor* thisx, PlayState* play) { break; case ENGB2_7_2: - this->unk_290 = 0; - this->unk_282[0] = this->actor.cutscene; + this->csIdIndex = 0; + this->csIdList[0] = this->actor.csId; if (Flags_GetSwitch(play, ENGB2_GET_7F8(thisx))) { Actor_Kill(&this->actor); return; 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 ec3b379a1..87cee9e99 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h @@ -31,11 +31,11 @@ typedef struct EnGb2 { /* 0x27C */ s16 unk_27C; /* 0x27E */ s16 unk_27E; /* 0x280 */ s16 unk_280; - /* 0x282 */ s16 unk_282[3]; + /* 0x282 */ s16 csIdList[3]; /* 0x288 */ s16 unk_288; /* 0x28A */ u8 unk_28A; /* 0x28C */ s32 unk_28C; - /* 0x290 */ s16 unk_290; + /* 0x290 */ s16 csIdIndex; } EnGb2; // size = 0x294 #endif // Z_EN_GB2_H diff --git a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c index cbc8511b7..6cfbb4718 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c @@ -88,7 +88,7 @@ void EnGe1_Init(Actor* thisx, PlayState* play) { this->picto.actor.colChkInfo.mass = MASS_IMMOVABLE; this->picto.actor.targetMode = 6; Actor_SetScale(&this->picto.actor, 0.01f); - this->animIndex = this->csAction = -1; // GERUDO_WHITE_ANIM_NONE + this->animIndex = this->cueId = -1; // GERUDO_WHITE_ANIM_NONE this->stateFlags = 0; EnGe1_ChangeAnim(this, GERUDO_WHITE_ANIM_ARMS_FOLDED, ANIMMODE_LOOP, 0.0f); this->actionFunc = EnGe1_Wait; @@ -189,19 +189,20 @@ void EnGe1_SetupPath(EnGe1* this, PlayState* play) { Vec3s* point; Vec3f nextPoint; - this->curPoint = 0; + this->curPointIndex = 0; + if (GERUDO_WHITE_GET_PATH(&this->picto.actor) != 0x3F) { this->path = &play->setupPathList[GERUDO_WHITE_GET_PATH(&this->picto.actor)]; if (this->path != NULL) { point = Lib_SegmentedToVirtual(this->path->points); Math_Vec3s_ToVec3f(&this->picto.actor.world.pos, point); - this->curPoint++; + this->curPointIndex++; point++; Math_Vec3s_ToVec3f(&nextPoint, point); this->picto.actor.world.rot.y = Math_Vec3f_Yaw(&this->picto.actor.world.pos, &nextPoint); this->picto.actor.world.rot.x = Math_Vec3f_Pitch(&this->picto.actor.world.pos, &nextPoint); - this->picto.actor.speedXZ = 15.0f; + this->picto.actor.speed = 15.0f; } } else { this->path = NULL; @@ -214,7 +215,7 @@ void EnGe1_SetupPath(EnGe1* this, PlayState* play) { s32 EnGe1_FollowPath(EnGe1* this) { s32 pad; Path* path = this->path; - Vec3s* points; + Vec3s* curPoint; Vec3f point; s16 yawTarget; s16 pitchTarget; @@ -223,10 +224,10 @@ s32 EnGe1_FollowPath(EnGe1* this) { return true; } - points = Lib_SegmentedToVirtual(this->path->points); - points += this->curPoint; + curPoint = Lib_SegmentedToVirtual(this->path->points); + curPoint += this->curPointIndex; - Math_Vec3s_ToVec3f(&point, points); + Math_Vec3s_ToVec3f(&point, curPoint); yawTarget = Math_Vec3f_Yaw(&this->picto.actor.world.pos, &point); pitchTarget = Math_Vec3f_Pitch(&this->picto.actor.world.pos, &point); Math_SmoothStepToS(&this->picto.actor.world.rot.y, yawTarget, 0xA, 0x3E8, 0x64); @@ -242,9 +243,9 @@ s32 EnGe1_FollowPath(EnGe1* this) { void EnGe1_Scream(EnGe1* this) { if ((s32)Rand_ZeroFloat(2.0f) == 0) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_VO_FPVO00); + Actor_PlaySfx(&this->picto.actor, NA_SE_VO_FPVO00); } else { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_VO_FPVO01); + Actor_PlaySfx(&this->picto.actor, NA_SE_VO_FPVO01); } } @@ -254,16 +255,16 @@ void EnGe1_Wait(EnGe1* this, PlayState* play) { } void EnGe1_PerformCutsceneActions(EnGe1* this, PlayState* play) { - s16 csAction; + s16 cueId; - if (SkelAnime_Update(&this->skelAnime) && (this->csAction == 3)) { + if (SkelAnime_Update(&this->skelAnime) && (this->cueId == 3)) { EnGe1_ChangeAnim(this, GERUDO_WHITE_ANIM_STIFF_SHIVERING, ANIMMODE_LOOP, 0.0f); } - if (Cutscene_CheckActorAction(play, 0x79)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_121)) { this->picto.actor.draw = EnGe1_Draw; - csAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x79)]->action; - switch (csAction) { + cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_121)]->id; + switch (cueId) { case 8: this->stateFlags &= ~GERUDO_WHITE_STATE_DISABLE_MOVEMENT; break; @@ -274,14 +275,15 @@ void EnGe1_PerformCutsceneActions(EnGe1* this, PlayState* play) { default: this->stateFlags &= ~GERUDO_WHITE_STATE_DISABLE_MOVEMENT; - Cutscene_ActorTranslateAndYaw(&this->picto.actor, play, Cutscene_GetActorActionIndex(play, 0x79)); + Cutscene_ActorTranslateAndYaw(&this->picto.actor, play, + Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_121)); break; } - if (this->csAction != csAction) { - this->csAction = csAction; + if (this->cueId != cueId) { + this->cueId = cueId; - switch (this->csAction) { + switch (this->cueId) { // Aveil cutscene case 1: EnGe1_ChangeAnim(this, GERUDO_WHITE_ANIM_ARMS_FOLDED, ANIMMODE_LOOP, 0.0f); @@ -329,32 +331,37 @@ void EnGe1_PerformCutsceneActions(EnGe1* this, PlayState* play) { if ((this->animIndex == GERUDO_WHITE_ANIM_TRUDGING_OFF) && (Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 25.0f))) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EV_PIRATE_WALK); + Actor_PlaySfx(&this->picto.actor, NA_SE_EV_PIRATE_WALK); } if ((this->animIndex == GERUDO_WHITE_ANIM_SALUTE) && Animation_OnFrame(&this->skelAnime, 14.0f)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EV_PIRATE_WALK); + Actor_PlaySfx(&this->picto.actor, NA_SE_EV_PIRATE_WALK); } } else { this->picto.actor.draw = NULL; } - if (this->csAction == 9) { - if ((this->curPoint < this->path->count) && EnGe1_FollowPath(this)) { - this->curPoint++; - } + switch (this->cueId) { + case 9: + if ((this->curPointIndex < this->path->count) && EnGe1_FollowPath(this)) { + this->curPointIndex++; + } - // Tumble in the air - this->picto.actor.shape.rot.x += 0x3E8; - this->picto.actor.shape.rot.y += 0x7D0; - this->picto.actor.shape.rot.z += 0x1F4; + // Tumble in the air + this->picto.actor.shape.rot.x += 0x3E8; + this->picto.actor.shape.rot.y += 0x7D0; + this->picto.actor.shape.rot.z += 0x1F4; - if (this->screamTimer > 0) { - this->screamTimer--; - } else { - this->screamTimer = (s32)(Rand_ZeroFloat(10.0f) + 20.0f); - EnGe1_Scream(this); - } + if (this->screamTimer > 0) { + this->screamTimer--; + } else { + this->screamTimer = (s32)(Rand_ZeroFloat(10.0f) + 20.0f); + EnGe1_Scream(this); + } + break; + + default: + break; } } @@ -369,7 +376,8 @@ void EnGe1_Update(Actor* thisx, PlayState* play) { if (!(this->stateFlags & GERUDO_WHITE_STATE_DISABLE_MOVEMENT)) { Actor_MoveWithGravity(&this->picto.actor); } - Actor_UpdateBgCheckInfo(play, &this->picto.actor, 40.0f, 25.0f, 40.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->picto.actor, 40.0f, 25.0f, 40.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); this->torsoRot.x = this->torsoRot.y = this->torsoRot.z = 0; @@ -384,10 +392,10 @@ void EnGe1_Update(Actor* thisx, PlayState* play) { } s32 EnGe1_ValidatePictograph(PlayState* play, Actor* thisx) { - s32 ret = Snap_ValidatePictograph(play, thisx, PICTOGRAPH_PIRATE_GOOD, &thisx->focus.pos, &thisx->shape.rot, 10.0f, + s32 ret = Snap_ValidatePictograph(play, thisx, PICTO_VALID_PIRATE_GOOD, &thisx->focus.pos, &thisx->shape.rot, 10.0f, 400.0f, -1); - ret |= Snap_ValidatePictograph(play, thisx, PICTOGRAPH_PIRATE_TOO_FAR, &thisx->focus.pos, &thisx->shape.rot, 10.0f, + ret |= Snap_ValidatePictograph(play, thisx, PICTO_VALID_PIRATE_TOO_FAR, &thisx->focus.pos, &thisx->shape.rot, 10.0f, 1200.0f, -1); return ret; diff --git a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h index 5388a1186..63a2a3c7f 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h @@ -29,12 +29,12 @@ typedef struct EnGe1 { /* 0x2A4 */ Vec3s headRot; /* 0x2AA */ Vec3s torsoRot; /* 0x2B0 */ Path* path; - /* 0x2B4 */ s32 curPoint; + /* 0x2B4 */ s32 curPointIndex; /* 0x2B8 */ s16 eyeIndex; /* 0x2BA */ s16 blinkTimer; /* 0x2BC */ u16 stateFlags; /* 0x2BE */ s16 animIndex; - /* 0x2C0 */ s16 csAction; + /* 0x2C0 */ s16 cueId; /* 0x2C2 */ s16 screamTimer; /* 0x2C4 */ u8 hairstyle; /* 0x2C8 */ EnGe1ActionFunc actionFunc; diff --git a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c index 4659c4aa9..922472f9a 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c @@ -15,18 +15,14 @@ void EnGe2_Destroy(Actor* thisx, PlayState* play); void EnGe2_Update(Actor* thisx, PlayState* play); void EnGe2_Draw(Actor* thisx, PlayState* play); -void func_80B8BCEC(EnGe2* this, PlayState* play); -void func_80B8BD38(EnGe2* this, PlayState* play); -void func_80B8BE08(EnGe2* this, PlayState* play); -void func_80B8BF04(EnGe2* this, PlayState* play); -void func_80B8C048(EnGe2* this, PlayState* play); -void func_80B8C0B0(EnGe2* this, PlayState* play); -void func_80B8C45C(EnGe2* this, PlayState* play); -void func_80B8C59C(EnGe2* this, PlayState* play); -void func_80B8C644(EnGe2* this, PlayState* play); -void func_80B8C9B8(EnGe2* this, PlayState* play); +s32 EnGe2_SetupPath(EnGe2* this, PlayState* play); + +void EnGe2_LookAround(EnGe2* this, PlayState* play); +void EnGe2_Walk(EnGe2* this, PlayState* play); +void EnGe2_GuardStationary(EnGe2* this, PlayState* play); + +s32 EnGe2_ValidatePictograph(PlayState* play, Actor* thisx); -#if 0 ActorInit En_Ge2_InitVars = { ACTOR_EN_GE2, ACTORCAT_NPC, @@ -39,78 +35,743 @@ ActorInit En_Ge2_InitVars = { (ActorFunc)EnGe2_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B8CE40 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x038BFBB3, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +typedef enum { + /* 0 */ GERUDO_PURPLE_DETECTION_UNDETECTED, + /* 1 */ GERUDO_PURPLE_DETECTION_HEARD, + /* 2 */ GERUDO_PURPLE_DETECTION_PROXIMITY //!< Higher priority +} GerudoPurpleDetection; + +typedef enum { + /* 0 */ GERUDO_PURPLE_PATHSTATUS_NORMAL, //!< not near waypoint + /* 1 */ GERUDO_PURPLE_PATHSTATUS_AT_POINT, //!< no path or new waypoint + /* 2 */ GERUDO_PURPLE_PATHSTATUS_END //!< reached end of path +} GerudoPurplePathStatus; + +#define GERUDO_PURPLE_STATE_PATH_REVERSE (1 << 0) //!< Follow path backwards instead of forwards. +#define GERUDO_PURPLE_STATE_KO (1 << 1) +#define GERUDO_PURPLE_STATE_STUNNED (1 << 2) //!< Specifically by Deku Nuts +#define GERUDO_PURPLE_STATE_DISABLE_MOVEMENT \ + (1 << 3) //!< Disable normal movement to let pathing function control it completely. +#define GERUDO_PURPLE_STATE_CAPTURING (1 << 5) //!< Set but not used + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x038BFBB3, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 60, 0, { 0, 0, 0 } }, }; -#endif +void EnGe2_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnGe2* this = THIS; -extern ColliderCylinderInit D_80B8CE40; + ActorShape_Init(&this->picto.actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gGerudoPurpleSkel, NULL, this->jointTable, this->morphTable, + GERUDO_PURPLE_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gGerudoPurpleWalkingAnim); -extern UNK_TYPE D_06008DD8; -extern UNK_TYPE D_060091D0; -extern UNK_TYPE D_06009D1C; -extern UNK_TYPE D_0600A344; + Collider_InitAndSetCylinder(play, &this->collider, &this->picto.actor, &sCylinderInit); + this->picto.actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->picto.actor, 0.01f); + this->picto.actor.uncullZoneForward = 1200.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/EnGe2_Init.s") + if (this->picto.actor.world.rot.z == 0) { + this->verticalDetectRange = 40.0f; + } else { + this->verticalDetectRange = fabsf(this->picto.actor.world.rot.z * 20.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/EnGe2_Destroy.s") + this->picto.actor.world.rot.x = this->picto.actor.shape.rot.x = 0; + this->picto.actor.world.rot.z = this->picto.actor.shape.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8B514.s") + this->picto.actor.targetMode = 6; + this->stateFlags = 0; + this->detectedStatus = GERUDO_PURPLE_DETECTION_UNDETECTED; + this->cueId = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8B5AC.s") + this->picto.actor.terminalVelocity = -9.0f; + this->picto.actor.gravity = -1.0f; + this->picto.actor.speed = 1.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8B6B4.s") + this->actionFunc = EnGe2_Walk; + this->picto.validationFunc = EnGe2_ValidatePictograph; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8B7A8.s") + EnGe2_SetupPath(this, play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8B848.s") + this->picto.actor.flags |= ACTOR_FLAG_10; + if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + this->picto.actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8B90C.s") + switch (GERUDO_PURPLE_GET_TYPE(&this->picto.actor)) { + case GERUDO_PURPLE_TYPE_BOAT_SENTRY: + Animation_Change(&this->skelAnime, &gGerudoPurpleLookingAboutAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), 0, 0.0f); + this->actionFunc = EnGe2_GuardStationary; + this->picto.actor.speed = 0.0f; + this->picto.actor.uncullZoneForward = 4000.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8BA40.s") + case GERUDO_PURPLE_TYPE_AVEIL_GUARD: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_83_02)) { + Actor_Kill(&this->picto.actor); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8BB3C.s") + default: + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8BC1C.s") +void EnGe2_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8BC78.s") +// Detect Player through hearing or proximity +GerudoPurpleDetection EnGe2_DetectPlayer(PlayState* play, EnGe2* this) { + if (this->picto.actor.xzDistToPlayer > 250.0f) { + return GERUDO_PURPLE_DETECTION_UNDETECTED; + } else if ((Player_GetMask(play) != PLAYER_MASK_STONE) && (this->picto.actor.xzDistToPlayer < 50.0f)) { + return GERUDO_PURPLE_DETECTION_PROXIMITY; + } else if (func_800B715C(play)) { + return GERUDO_PURPLE_DETECTION_HEARD; + } else { + return GERUDO_PURPLE_DETECTION_UNDETECTED; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8BCEC.s") +/** + * Spotted Player with line-of-sight + * + * @param play PlayState + * @param thisx Actor to use for range and angle checks + * @param pos Position to check from + * @param yaw Center of yaw range to check + * @param yawRange Spread of angles from `yaw` to check. If 0, do not check yaw + * @param xzRange Horizontal range to check + * @param yRange Vertical range to check + * @return true if Player is visible with these settings + */ +s32 EnGe2_LookForPlayer(PlayState* play, Actor* actor, Vec3f* pos, s16 yaw, s16 yawRange, f32 xzRange, f32 yRange) { + s16 yawToPlayer; + Vec3f posResult; + CollisionPoly* outPoly; + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8BD38.s") + if (Player_GetMask(play) == PLAYER_MASK_STONE) { + return false; + } + if (actor->xzDistToPlayer > xzRange) { + return false; + } + if (fabsf(actor->playerHeightRel) > yRange) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8BD90.s") + yawToPlayer = actor->yawTowardsPlayer - yaw; + if ((yawRange > 0) && (yawRange < ABS_ALT(yawToPlayer))) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8BE08.s") + if (BgCheck_AnyLineTest1(&play->colCtx, pos, &player->bodyPartsPos[7], &posResult, &outPoly, false)) { + return false; + } else { + return true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8BF04.s") +/* Path functions */ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8BFC8.s") +/** + * Set up the path if it exists, choose the end and direction + * + * @return true if path is set up in reverse + */ +s32 EnGe2_SetupPath(EnGe2* this, PlayState* play) { + if (GERUDO_PURPLE_GET_PATH(&this->picto.actor) != GERUDO_PURPLE_PATH_NONE) { + this->path = &play->setupPathList[GERUDO_PURPLE_GET_PATH(&this->picto.actor)]; + if (this->path != NULL) { + Path* path = this->path; + Vec3s* points = Lib_SegmentedToVirtual(path->points); + f32 diffX = points[0].x - this->picto.actor.world.pos.x; + f32 diffZ = points[0].z - this->picto.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8C048.s") + if ((SQ(diffX) + SQ(diffZ)) < SQ(10.0f)) { + this->curPointIndex = 0; + this->stateFlags &= ~GERUDO_PURPLE_STATE_PATH_REVERSE; + } else { + this->curPointIndex = path->count - 1; + this->stateFlags |= GERUDO_PURPLE_STATE_PATH_REVERSE; + return true; + } + } + } else { + this->path = NULL; + this->curPointIndex = 0; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8C0B0.s") +void EnGe2_GetNextPath(EnGe2* this, PlayState* play) { + Path* curPath; + Path* nextPath; + Vec3s* points; + u8 unk1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8C13C.s") + this->curPointIndex = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8C45C.s") + if (GERUDO_PURPLE_GET_PATH(&this->picto.actor) != GERUDO_PURPLE_PATH_NONE) { + curPath = &play->setupPathList[GERUDO_PURPLE_GET_PATH(&this->picto.actor)]; + unk1 = curPath->unk1; + nextPath = &play->setupPathList[unk1]; + this->path = nextPath; + points = Lib_SegmentedToVirtual(nextPath->points); + this->picto.actor.world.pos.x = points[0].x; + this->picto.actor.world.pos.z = points[0].z; + } else { + this->path = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8C59C.s") +void EnGe2_SetupBlownAwayPath(EnGe2* this, PlayState* play) { + s32 pad; + Vec3s* points; + Vec3f nextPoint; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8C644.s") + this->curPointIndex = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8C9B8.s") + if (GERUDO_PURPLE_GET_PATH(&this->picto.actor) != GERUDO_PURPLE_PATH_NONE) { + this->path = &play->setupPathList[GERUDO_PURPLE_GET_PATH(&this->picto.actor)]; + if (this->path != NULL) { + points = Lib_SegmentedToVirtual(this->path->points); + Math_Vec3s_ToVec3f(&this->picto.actor.world.pos, points); + this->curPointIndex++; + points++; + Math_Vec3s_ToVec3f(&nextPoint, points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/EnGe2_Update.s") + this->picto.actor.world.rot.y = Math_Vec3f_Yaw(&this->picto.actor.world.pos, &nextPoint); + this->picto.actor.world.rot.x = Math_Vec3f_Pitch(&this->picto.actor.world.pos, &nextPoint); + this->picto.actor.speed = 15.0f; + } + } else { + this->path = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8CC0C.s") +GerudoPurplePathStatus EnGe2_FollowPath(EnGe2* this) { + Path* path = this->path; + Vec3s* curPoint; + f32 diffX; + f32 diffZ; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8CCB4.s") + if (path == NULL) { + return GERUDO_PURPLE_PATHSTATUS_AT_POINT; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/func_80B8CCFC.s") + curPoint = (Vec3s*)Lib_SegmentedToVirtual(path->points); + curPoint += this->curPointIndex; + diffX = curPoint->x - this->picto.actor.world.pos.x; + diffZ = curPoint->z - this->picto.actor.world.pos.z; + this->picto.actor.world.rot.y = Math_Atan2S(diffX, diffZ); + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.world.rot.y, 2, 0x7D0, 0xC8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ge2/EnGe2_Draw.s") + if ((SQ(diffX) + SQ(diffZ)) < SQ(10.0f)) { + if (this->stateFlags & GERUDO_PURPLE_STATE_PATH_REVERSE) { + this->curPointIndex--; + if (this->curPointIndex < 0) { + return GERUDO_PURPLE_PATHSTATUS_END; + } + } else { + this->curPointIndex++; + if (this->curPointIndex >= path->count) { + return GERUDO_PURPLE_PATHSTATUS_END; + } + } + return GERUDO_PURPLE_PATHSTATUS_AT_POINT; + } + + return GERUDO_PURPLE_PATHSTATUS_NORMAL; +} + +/** + * Used for Blown Away cutscene path. + */ +s32 EnGe2_FollowPathWithoutGravity(EnGe2* this) { + s32 pad; + Vec3s* curPoint; + Path* path = this->path; + Vec3f point; + s16 yawTarget; + s16 pitchTarget; + + if (this->path == NULL) { + return true; + } + + curPoint = Lib_SegmentedToVirtual(path->points); + curPoint += this->curPointIndex; + + Math_Vec3s_ToVec3f(&point, curPoint); + yawTarget = Math_Vec3f_Yaw(&this->picto.actor.world.pos, &point); + pitchTarget = Math_Vec3f_Pitch(&this->picto.actor.world.pos, &point); + Math_SmoothStepToS(&this->picto.actor.world.rot.y, yawTarget, 0xA, 0x3E8, 0x64); + Math_SmoothStepToS(&this->picto.actor.world.rot.x, pitchTarget, 6, 0x7D0, 0xC8); + this->picto.actor.speed = 15.0f; + + Actor_MoveWithoutGravityReverse(&this->picto.actor); + + if (Math_Vec3f_DistXYZ(&this->picto.actor.world.pos, &point) < 40.0f) { + return true; + } else { + return false; + } +} + +/* Action and helper functions */ + +void EnGe2_SpawnEffects(EnGe2* this, PlayState* play) { + static Vec3f effectVelocity = { 0.0f, -0.05f, 0.0f }; + static Vec3f effectAccel = { 0.0f, -0.025f, 0.0f }; + static Color_RGBA8 effectPrimColor = { 255, 255, 255, 0 }; + static Color_RGBA8 effectEnvColor = { 255, 150, 0, 0 }; + s16 effectAngle = play->state.frames * 0x2800; + Vec3f effectPos; + + effectPos.x = (Math_CosS(effectAngle) * 5.0f) + this->picto.actor.focus.pos.x; + effectPos.y = this->picto.actor.focus.pos.y + 10.0f; + effectPos.z = (Math_SinS(effectAngle) * 5.0f) + this->picto.actor.focus.pos.z; + EffectSsKirakira_SpawnDispersed(play, &effectPos, &effectVelocity, &effectAccel, &effectPrimColor, &effectEnvColor, + 1000, 16); +} + +void EnGe2_Scream(EnGe2* this) { + if ((s32)Rand_ZeroFloat(2.0f) == 0) { + Actor_PlaySfx(&this->picto.actor, NA_SE_VO_FPVO00); + } else { + Actor_PlaySfx(&this->picto.actor, NA_SE_VO_FPVO01); + } +} + +/** + * Wait for timer to finish, then set up the captured/thrown out transition. + */ +void EnGe2_ThrowPlayerOut(EnGe2* this, PlayState* play) { + if (this->timer > 0) { + this->timer--; + } else if (play->nextEntrance != play->setupExitList[GERUDO_PURPLE_GET_EXIT(&this->picto.actor)]) { + play->nextEntrance = play->setupExitList[GERUDO_PURPLE_GET_EXIT(&this->picto.actor)]; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_38; + } +} + +/** + * Used if Aveil spots Player. + */ +void EnGe2_TurnToPlayerFast(EnGe2* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 2, 0x1000, 0x200); +} + +void EnGe2_CapturePlayer(EnGe2* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 2, 0x400, 0x100); + EnGe2_ThrowPlayerOut(this, play); +} + +void EnGe2_SetupCapturePlayer(EnGe2* this) { + this->picto.actor.speed = 0.0f; + this->actionFunc = EnGe2_CapturePlayer; + Animation_Change(&this->skelAnime, &gGerudoPurpleLookingAboutAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), 0, -8.0f); +} + +void EnGe2_Charge(EnGe2* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 2, 0x400, 0x100); + this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y; + + if (this->picto.actor.xzDistToPlayer < 50.0f) { + EnGe2_SetupCapturePlayer(this); + } else if (!(this->picto.actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + this->picto.actor.world.pos = this->picto.actor.prevPos; + EnGe2_SetupCapturePlayer(this); + } + + if (this->timer > 0) { + this->timer--; + } else { + EnGe2_ThrowPlayerOut(this, play); + } + + if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { + Actor_PlaySfx(&this->picto.actor, NA_SE_EV_PIRATE_WALK); + } +} + +void EnGe2_SetupCharge(EnGe2* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 2, 0x400, 0x100); + this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y; + + if (this->picto.actor.shape.rot.y == this->picto.actor.yawTowardsPlayer) { + Animation_Change(&this->skelAnime, &gGerudoPurpleChargingAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGerudoPurpleChargingAnim), 0, -8.0f); + this->timer = 50; + this->picto.actor.speed = 4.0f; + this->actionFunc = EnGe2_Charge; + } +} + +void EnGe2_SetupLookAround(EnGe2* this) { + Animation_Change(&this->skelAnime, &gGerudoPurpleLookingAboutAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), 0, -8.0f); + this->timer = 60; + this->picto.actor.speed = 0.0f; + this->actionFunc = EnGe2_LookAround; +} + +void EnGe2_Stunned(EnGe2* this, PlayState* play) { + if (this->picto.actor.colorFilterTimer == 0) { + EnGe2_SetupLookAround(this); + this->detectedStatus = GERUDO_PURPLE_DETECTION_UNDETECTED; + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + this->stateFlags &= ~GERUDO_PURPLE_STATE_STUNNED; + } +} + +void EnGe2_KnockedOut(EnGe2* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + EnGe2_SpawnEffects(this, play); + + if (this->timer > 0) { + this->timer--; + } else { + EnGe2_SetupLookAround(this); + this->detectedStatus = GERUDO_PURPLE_DETECTION_UNDETECTED; + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + this->stateFlags &= ~GERUDO_PURPLE_STATE_KO; + this->picto.actor.flags |= ACTOR_FLAG_1; + } +} + +/** + * Carries out various patrol functions: + * - Turning to Player if being arrested + * - Turning to Player if spotted by Aveil + * - Looking for Player + * - Managing collisions and collider + */ +void EnGe2_PatrolDuties(EnGe2* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 visionRange = gSaveContext.save.isNight ? 200.0f : 280.0f; + + if (player->csMode == 0x1A) { + this->picto.actor.speed = 0.0f; + this->actionFunc = EnGe2_SetupCharge; + Animation_Change(&this->skelAnime, &gGerudoPurpleLookingAboutAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), 0, -8.0f); + this->stateFlags |= GERUDO_PURPLE_STATE_CAPTURING; + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_80_08)) { + this->picto.actor.speed = 0.0f; + this->actionFunc = EnGe2_TurnToPlayerFast; + Animation_Change(&this->skelAnime, &gGerudoPurpleLookingAboutAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), 0, -8.0f); + } else if (EnGe2_LookForPlayer(play, &this->picto.actor, &this->picto.actor.focus.pos, + this->picto.actor.shape.rot.y, 0x1800, visionRange, this->verticalDetectRange)) { + if ((GERUDO_PURPLE_GET_EXIT(&this->picto.actor) != GERUDO_PURPLE_EXIT_NONE) && !Play_InCsMode(play)) { + this->picto.actor.speed = 0.0f; + func_800B7298(play, &this->picto.actor, 0x1A); + func_801000A4(NA_SE_SY_FOUND); + Message_StartTextbox(play, 0x1194, &this->picto.actor); + this->actionFunc = EnGe2_SetupCharge; + Animation_Change(&this->skelAnime, &gGerudoPurpleLookingAboutAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), 0, -8.0f); + } + } else if (this->collider.base.acFlags & AC_HIT) { + if ((this->collider.info.acHitInfo != NULL) && + (this->collider.info.acHitInfo->toucher.dmgFlags & DMG_DEKU_NUT)) { + Actor_SetColorFilter(&this->picto.actor, 0, 120, 0, 400); + this->picto.actor.speed = 0.0f; + this->actionFunc = EnGe2_Stunned; + this->stateFlags |= GERUDO_PURPLE_STATE_STUNNED; + } else { + Animation_Change(&this->skelAnime, &gGerudoPurpleFallingToGroundAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGerudoPurpleFallingToGroundAnim), 2, -8.0f); + this->timer = 200; + this->picto.actor.speed = 0.0f; + this->actionFunc = EnGe2_KnockedOut; + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_DEAD); + this->picto.actor.flags &= ~ACTOR_FLAG_1; + this->stateFlags |= GERUDO_PURPLE_STATE_KO; + } + } else if (this->picto.actor.home.rot.x == 0) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } +} + +void EnGe2_LookAround(EnGe2* this, PlayState* play) { + u8 detectedStatus; + + SkelAnime_Update(&this->skelAnime); + + detectedStatus = EnGe2_DetectPlayer(play, this); + if (detectedStatus != GERUDO_PURPLE_DETECTION_UNDETECTED) { + this->timer = 100; + this->yawTarget = this->picto.actor.yawTowardsPlayer; + + if (this->detectedStatus < detectedStatus) { + this->detectedStatus = detectedStatus; + } + } + + if (this->timer > 0) { + this->timer--; + } else { + this->actionFunc = EnGe2_Walk; + Animation_Change(&this->skelAnime, &gGerudoPurpleWalkingAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGerudoPurpleWalkingAnim), 0, -8.0f); + this->headRot.y = 0; + this->detectedStatus = GERUDO_PURPLE_DETECTION_UNDETECTED; + } + + switch (this->detectedStatus) { + case GERUDO_PURPLE_DETECTION_HEARD: + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->yawTarget, 2, 0x3E8, 0x1F4); + break; + + case GERUDO_PURPLE_DETECTION_PROXIMITY: + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->yawTarget, 2, 0xBB8, 0x3E8); + break; + + default: + break; + } + + this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y; + EnGe2_PatrolDuties(this, play); +} + +void EnGe2_Walk(EnGe2* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + this->picto.actor.speed = 1.5f; + + switch (EnGe2_FollowPath(this)) { + case GERUDO_PURPLE_PATHSTATUS_END: + EnGe2_SetupPath(this, play); + break; + + case GERUDO_PURPLE_PATHSTATUS_AT_POINT: + EnGe2_SetupLookAround(this); + this->detectedStatus = GERUDO_PURPLE_DETECTION_UNDETECTED; + break; + + default: // GERUDO_PURPLE_PATHSTATUS_NORMAL + break; + } + + this->detectedStatus = EnGe2_DetectPlayer(play, this); + if (this->detectedStatus != GERUDO_PURPLE_DETECTION_UNDETECTED) { + EnGe2_SetupLookAround(this); + this->yawTarget = this->picto.actor.yawTowardsPlayer; + } + EnGe2_PatrolDuties(this, play); +} + +void EnGe2_PerformCutsceneActions(EnGe2* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_476)) { + s16 cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_476)]->id; + + if (this->cueId != cueId) { + this->cueId = cueId; + + switch (cueId) { + case ENGE2_CUEID_BEEHIVE_PATROL: + Animation_Change(&this->skelAnime, &gGerudoPurpleLookingAboutAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), 0, -8.0f); + EnGe2_GetNextPath(this, play); + break; + + case ENGE2_CUEID_BEEHIVE_RUN_AWAY: + Animation_Change(&this->skelAnime, &gGerudoPurpleRunningAwayCutsceneAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGerudoPurpleRunningAwayCutsceneAnim), 0, -5.0f); + this->screamTimer = (s32)(Rand_ZeroFloat(10.0f) + 20.0f); + break; + + case ENGE2_CUEID_BEEHIVE_EXIT: + Actor_Kill(&this->picto.actor); + break; + + case ENGE2_CUEID_GBT_ENTR_STAND_STILL: + Animation_Change(&this->skelAnime, &gGerudoPurpleGreatBayCutsceneAnim, 0.0f, 0.0f, 0.0f, 2, 0.0f); + break; + + case ENGE2_CUEID_GBT_ENTR_BLOWN_AWAY: + Animation_Change(&this->skelAnime, &gGerudoPurpleGreatBayCutsceneAnim, 0.0f, 1.0f, 1.0f, 2, 0.0f); + EnGe2_SetupBlownAwayPath(this, play); + this->stateFlags |= GERUDO_PURPLE_STATE_DISABLE_MOVEMENT; + this->screamTimer = (s32)(Rand_ZeroFloat(10.0f) + 20.0f); + break; + + default: + break; + } + } + } + + switch (this->cueId) { + case ENGE2_CUEID_BEEHIVE_RUN_AWAY: + EnGe2_FollowPath(this); + this->picto.actor.speed = 5.0f; + + if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { + Actor_PlaySfx(&this->picto.actor, NA_SE_EV_PIRATE_WALK); + } + + if (this->screamTimer > 0) { + this->screamTimer--; + } else { + this->screamTimer = (s32)(Rand_ZeroFloat(10.0f) + 20.0f); + EnGe2_Scream(this); + } + break; + + case ENGE2_CUEID_GBT_ENTR_BLOWN_AWAY: + if ((this->curPointIndex < this->path->count) && EnGe2_FollowPathWithoutGravity(this)) { + this->curPointIndex++; + } + + // Tumble in the air + this->picto.actor.shape.rot.x += 0x3E8; + this->picto.actor.shape.rot.y += 0x7D0; + this->picto.actor.shape.rot.z += 0x1F4; + + if (this->screamTimer > 0) { + this->screamTimer--; + } else { + this->screamTimer = (s32)(Rand_ZeroFloat(10.0f) + 20.0f); + EnGe2_Scream(this); + } + break; + + default: + break; + } +} + +// Used for those on boats +void EnGe2_GuardStationary(EnGe2* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + if (EnGe2_LookForPlayer(play, &this->picto.actor, &this->picto.actor.focus.pos, this->picto.actor.shape.rot.y, + 0x4000, 720.0f, this->verticalDetectRange)) { + if ((GERUDO_PURPLE_GET_EXIT(&this->picto.actor) != GERUDO_PURPLE_EXIT_NONE) && !Play_InCsMode(play)) { + func_800B7298(play, &this->picto.actor, 0x1A); + func_801000A4(NA_SE_SY_FOUND); + Message_StartTextbox(play, 0x1194, &this->picto.actor); + this->timer = 50; + EnGe2_SetupCapturePlayer(this); + } + } + + if (this->picto.actor.playerHeightRel < -150.0f) { + this->picto.actor.draw = NULL; + } else { + this->picto.actor.draw = EnGe2_Draw; + } +} + +void EnGe2_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnGe2* this = THIS; + + if (!(this->stateFlags & GERUDO_PURPLE_STATE_DISABLE_MOVEMENT)) { + Actor_MoveWithGravity(&this->picto.actor); + } + Actor_UpdateBgCheckInfo(play, &this->picto.actor, 40.0f, 25.0f, 40.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); + Collider_UpdateCylinder(&this->picto.actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_476)) { + this->actionFunc = EnGe2_PerformCutsceneActions; + this->stateFlags &= ~GERUDO_PURPLE_STATE_KO; + this->stateFlags &= ~GERUDO_PURPLE_STATE_PATH_REVERSE; + this->picto.actor.flags |= ACTOR_FLAG_20; + this->picto.actor.speed = 0.0f; + } + + this->actionFunc(this, play); + + // Blinking + if (this->stateFlags & GERUDO_PURPLE_STATE_KO) { + this->eyeIndex = 2; + } else if (!(this->stateFlags & GERUDO_PURPLE_STATE_STUNNED)) { + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(60, 60); + } + this->eyeIndex = this->blinkTimer; + if (this->eyeIndex >= 3) { + this->eyeIndex = 0; + } + } +} + +s32 EnGe2_ValidatePictograph(PlayState* play, Actor* thisx) { + s32 ret = Snap_ValidatePictograph(play, thisx, PICTO_VALID_PIRATE_GOOD, &thisx->focus.pos, &thisx->shape.rot, 10.0f, + 400.0f, -1); + + ret |= Snap_ValidatePictograph(play, thisx, PICTO_VALID_PIRATE_TOO_FAR, &thisx->focus.pos, &thisx->shape.rot, 10.0f, + 1200.0f, -1); + return ret; +} + +s32 EnGe2_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnGe2* this = THIS; + + if (limbIndex == GERUDO_PURPLE_NECK_LIMB) { + rot->x += this->headRot.y; + rot->z += this->headRot.x; + } + return false; +} + +void EnGe2_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f sFocusOffset = { 600.0f, 700.0f, 0.0f }; + + if (limbIndex == GERUDO_PURPLE_HEAD_LIMB) { + Matrix_MultVec3f(&sFocusOffset, &thisx->focus.pos); + } +} + +void EnGe2_Draw(Actor* thisx, PlayState* play) { + static TexturePtr sEyeTextures[] = { + gGerudoPurpleEyeOpenTex, + gGerudoPurpleEyeHalfTex, + gGerudoPurpleEyeClosedTex, + }; + s32 pad; + EnGe2* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C5B0(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex])); + func_800B8050(&this->picto.actor, play, 0); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnGe2_OverrideLimbDraw, EnGe2_PostLimbDraw, &this->picto.actor); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.h b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.h index 0558166db..0a85e3bfe 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.h +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.h @@ -2,14 +2,58 @@ #define Z_EN_GE2_H #include "global.h" +#include "z64snap.h" +#include "objects/object_gla/object_gla.h" struct EnGe2; typedef void (*EnGe2ActionFunc)(struct EnGe2*, PlayState*); +#define GERUDO_PURPLE_GET_EXIT(thisx) (((thisx)->params) & 0x1F) //!< Exit to send Player to when caught +#define GERUDO_PURPLE_GET_TYPE(thisx) (((thisx)->params & 0xE0) >> 5) +#define GERUDO_PURPLE_GET_PATH(thisx) ((((thisx)->params) & 0xFC00) >> 10) + +#define GERUDO_PURPLE_PARAMS(path, type, exit) (((path) & 0x1F) | (((type) & 7) << 5) | (((exit) & 0x3F) << 10)) + +#define GERUDO_PURPLE_EXIT_NONE 0x1F +#define GERUDO_PURPLE_PATH_NONE 0x3F + +typedef enum { + /* 0 */ GERUDO_PURPLE_TYPE_CUTSCENE, + /* 1 */ GERUDO_PURPLE_TYPE_BOAT_SENTRY, //!< on boats + /* 2 */ GERUDO_PURPLE_TYPE_AVEIL_GUARD, + /* 7 */ GERUDO_PURPLE_TYPE_FORTRESS = 7 //!< In both courtyard and rooms +} GerudoPurpleType; + +//! TODO: work out where to put this +typedef enum { + /* 1 */ ENGE2_CUEID_BEEHIVE_PATROL = 1, + /* 2 */ ENGE2_CUEID_BEEHIVE_RUN_AWAY, + /* 3 */ ENGE2_CUEID_BEEHIVE_EXIT, + /* 4 */ ENGE2_CUEID_GBT_ENTR_STAND_STILL, + /* 5 */ ENGE2_CUEID_GBT_ENTR_BLOWN_AWAY +} EnGe2CsAction; + typedef struct EnGe2 { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x1C4]; + /* 0x000 */ PictoActor picto; + /* 0x148 */ ColliderCylinder collider; + /* 0x194 */ SkelAnime skelAnime; + /* 0x1D8 */ Vec3s jointTable[GERUDO_PURPLE_LIMB_MAX]; + /* 0x25C */ Vec3s morphTable[GERUDO_PURPLE_LIMB_MAX]; + /* 0x2E0 */ s16 eyeIndex; + /* 0x2E2 */ s16 blinkTimer; + /* 0x2E4 */ Vec3s headRot; + /* 0x2E8 */ Vec3s torsoRot; // unused, inferred from similar usage in other actors + /* 0x2F0 */ Path* path; + /* 0x2F4 */ s32 curPointIndex; + /* 0x2F8 */ u16 stateFlags; + /* 0x2FA */ s16 yawTarget; //!< used when Player detected to fix the yaw to turn to + /* 0x2FC */ f32 verticalDetectRange; //!< vertical range to look for the player within + /* 0x300 */ u8 timer; + /* 0x301 */ u8 detectedStatus; + /* 0x302 */ s16 cueId; + /* 0x304 */ s16 unk304; // unused + /* 0x306 */ s16 screamTimer; /* 0x308 */ EnGe2ActionFunc actionFunc; } EnGe2; // size = 0x30C 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 1da6c1a61..4b5e8e311 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -217,18 +217,18 @@ void func_80BB178C(EnGeg* this, PlayState* play) { if (collider != NULL) { CollisionCheck_SetOC(play, &play->colChkCtx, collider); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } } s32 func_80BB18FC(EnGeg* this, Actor* actor) { - if (actor->bgCheckFlags & 1) { + if (actor->bgCheckFlags & BGCHECKFLAG_GROUND) { f32 sp24 = Math_Vec3f_DistXZ(&this->actor.world.pos, &actor->world.pos); f32 sp20 = Math_Vec3f_DiffY(&this->actor.world.pos, &actor->world.pos); if ((sp24 < 150.0f) && (fabsf(sp20) < 5.0f)) { this->unk_230 |= 0x20; - actor->speedXZ = 0.0f; + actor->speed = 0.0f; actor->velocity.y = 0.0f; this->actor.child = actor; actor->parent = &this->actor; @@ -304,10 +304,10 @@ u8 func_80BB1B14(EnGeg* this, PlayState* play) { void func_80BB1C1C(EnGeg* this) { u16 i; - this->unk_49C[0] = this->actor.cutscene; + this->csIdList[0] = this->actor.csId; - for (i = 1; i < ARRAY_COUNT(this->unk_49C); i++) { - this->unk_49C[i] = ActorCutscene_GetAdditionalCutscene(this->unk_49C[i - 1]); + for (i = 1; i < ARRAY_COUNT(this->csIdList); i++) { + this->csIdList[i] = CutsceneManager_GetAdditionalCsId(this->csIdList[i - 1]); } } @@ -432,15 +432,15 @@ void func_80BB221C(EnGeg* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state) && (this->unk_230 & 4)) { if (sp27 == 1) { this->unk_496 = 0xD66; - this->unk_49A = this->unk_49C[3]; + this->nextCsId = this->csIdList[3]; } else if (sp27 == 2) { this->unk_496 = 0xD64; - this->unk_49A = this->unk_49C[2]; + this->nextCsId = this->csIdList[2]; this->unk_230 &= ~4; } else if (sp27 == 3) { this->unk_230 |= 0x200; this->unk_496 = 0xD64; - this->unk_49A = this->unk_49C[2]; + this->nextCsId = this->csIdList[2]; this->unk_230 &= ~4; } Message_StartTextbox(play, this->unk_496, &this->actor); @@ -466,7 +466,7 @@ void func_80BB221C(EnGeg* this, PlayState* play) { } else if (Actor_ProcessTalkRequest(&this->actor, &play->state) && (this->unk_230 & 8)) { SET_WEEKEVENTREG(WEEKEVENTREG_35_40); this->unk_496 = 0xD5E; - this->unk_49A = this->unk_49C[0]; + this->nextCsId = this->csIdList[0]; Message_StartTextbox(play, this->unk_496, &this->actor); this->actionFunc = func_80BB2520; this->unk_230 &= ~8; @@ -481,18 +481,18 @@ void func_80BB221C(EnGeg* this, PlayState* play) { void func_80BB2520(EnGeg* this, PlayState* play) { if (this->unk_230 & 0x10) { - ActorCutscene_Stop(this->unk_498); + CutsceneManager_Stop(this->csId); this->unk_230 &= ~0x10; - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->unk_498 = this->unk_49A; - ActorCutscene_SetIntentToPlay(this->unk_498); + this->csId = this->nextCsId; + CutsceneManager_Queue(this->csId); return; } - if (ActorCutscene_GetCanPlayNext(this->unk_498)) { - ActorCutscene_StartAndSetFlag(this->unk_498, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->unk_230 |= 0x10; switch (this->unk_496) { @@ -517,7 +517,7 @@ void func_80BB2520(EnGeg* this, PlayState* play) { break; case 0xD67: - this->unk_498 = this->unk_49C[5]; + this->csId = this->csIdList[5]; this->actionFunc = func_80BB2B1C; break; @@ -534,11 +534,11 @@ void func_80BB2520(EnGeg* this, PlayState* play) { break; } } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->unk_498 = this->unk_49A; - ActorCutscene_SetIntentToPlay(this->unk_498); + this->csId = this->nextCsId; + CutsceneManager_Queue(this->csId); } } @@ -546,12 +546,12 @@ void func_80BB26EC(EnGeg* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (this->unk_496) { case 0xD5E: - this->unk_49A = this->unk_49C[1]; + this->nextCsId = this->csIdList[1]; this->actionFunc = func_80BB2520; break; case 0xD61: - ActorCutscene_Stop(this->unk_498); + CutsceneManager_Stop(this->csId); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; this->unk_230 &= ~0x10; @@ -574,7 +574,7 @@ void func_80BB27D4(EnGeg* this, PlayState* play) { break; case 0xD69: - this->unk_49A = this->unk_49C[6]; + this->nextCsId = this->csIdList[6]; play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; this->actionFunc = func_80BB2520; @@ -594,7 +594,7 @@ void func_80BB27D4(EnGeg* this, PlayState* play) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; this->unk_230 &= ~0x10; - this->unk_49A = this->unk_49C[7]; + this->nextCsId = this->csIdList[7]; this->actionFunc = func_80BB2520; break; @@ -620,11 +620,11 @@ void func_80BB2944(EnGeg* this, PlayState* play) { if (this->unk_496 == 0xD67) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; - this->unk_49A = this->unk_49C[4]; + this->nextCsId = this->csIdList[4]; this->actionFunc = func_80BB2520; } else { this->unk_496 = func_80BB16D0(this); - func_80151938(play, this->unk_496); + Message_ContinueTextbox(play, this->unk_496); } } } @@ -632,7 +632,7 @@ void func_80BB2944(EnGeg* this, PlayState* play) { void func_80BB2A54(EnGeg* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_496 == 0xD65) { - ActorCutscene_Stop(this->unk_498); + CutsceneManager_Stop(this->csId); this->unk_230 &= ~0x10; this->unk_244 = 65; play->msgCtx.msgMode = 0x43; @@ -654,16 +654,16 @@ void func_80BB2B1C(EnGeg* this, PlayState* play) { this->actor.child->world.pos = this->unk_4B4; this->actor.child->shape.rot = this->actor.shape.rot; - if (ActorCutscene_GetCurrentIndex() != this->unk_49C[4]) { - if (ActorCutscene_GetCanPlayNext(this->unk_498)) { + if (CutsceneManager_GetCurrentCsId() != this->csIdList[4]) { + if (CutsceneManager_IsNext(this->csId)) { SET_WEEKEVENTREG(WEEKEVENTREG_37_08); if (this->actor.child != NULL) { Actor_Kill(this->actor.child); } this->unk_230 |= 0x10; - ActorCutscene_StartAndSetFlag(this->unk_498, &this->actor); + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->unk_496 = 0xD68; - func_80151938(play, this->unk_496); + Message_ContinueTextbox(play, this->unk_496); this->unk_248 = Object_GetIndex(&play->objectCtx, OBJECT_TAISOU); if (this->unk_248 >= 0) { this->unk_4AC = 13; @@ -671,10 +671,10 @@ void func_80BB2B1C(EnGeg* this, PlayState* play) { } this->actionFunc = func_80BB27D4; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->unk_498); + CutsceneManager_Queue(this->csId); } } else { temp_f20 = this->unk_4E0 * 0.005f; @@ -711,12 +711,12 @@ void func_80BB2E00(EnGeg* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; if (sp2E == sp2C) { - ActorCutscene_Stop(this->unk_498); + CutsceneManager_Stop(this->csId); this->unk_4AC = 20; func_80BB2020(this, play); this->actionFunc = func_80BB30B4; } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_STAND_IMT); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_STAND_IMT); } } else if (this->unk_4AC == 4) { if (Animation_OnFrame(&this->skelAnime, 0.0f)) { @@ -729,7 +729,7 @@ void func_80BB2E00(EnGeg* this, PlayState* play) { this->actionFunc = func_80BB3318; } } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SIT_IMT); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_SIT_IMT); } } } @@ -739,24 +739,24 @@ void func_80BB2F7C(EnGeg* this, PlayState* play) { this->actor.shape.rot.y = this->actor.world.rot.y; if ((this->actor.xzDistToPlayer < 150.0f) && (fabsf(this->actor.playerHeightRel) < 10.0f) && - (this->actor.bgCheckFlags & 1)) { + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->unk_4AC = 2; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_230 &= ~1; this->actor.shape.yOffset = 0.0f; func_80BB2020(this, play); this->actionFunc = func_80BB2E00; } else { - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; Actor_MoveWithGravity(&this->actor); } - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (this->unk_230 & 0x80) { func_800B9010(&this->actor, NA_SE_EN_GOLON_SIRLOIN_ROLL - SFX_FLAG); } else { this->unk_230 |= 0x80; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } } } @@ -804,7 +804,7 @@ void func_80BB31B8(EnGeg* this, PlayState* play) { } this->actionFunc = func_80BB32AC; } else { - Actor_PickUp(&this->actor, play, getItemId, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, getItemId, 300.0f, 300.0f); } } @@ -813,7 +813,7 @@ void func_80BB32AC(EnGeg* this, PlayState* play) { Message_StartTextbox(play, this->unk_496, &this->actor); this->actionFunc = func_80BB27D4; } else { - func_800B85E0(&this->actor, play, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); } } @@ -837,11 +837,11 @@ void func_80BB3318(EnGeg* this, PlayState* play) { this->actor.shape.rot.y, this->actor.floorPoly, this->actor.floorBgId); } - if (ActorCutscene_GetCurrentIndex() != this->unk_49C[7]) { + if (CutsceneManager_GetCurrentCsId() != this->csIdList[7]) { func_800AEF44(Effect_GetByIndex(this->unk_4DC)); Actor_Kill(&this->actor); } else { - Math_ApproachF(&this->actor.speedXZ, 10.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 10.0f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); } @@ -1058,7 +1058,7 @@ void func_80BB3BE0(EnGeg* this, PlayState* play) { } void func_80BB3CB4(EnGeg* this, PlayState* play) { - f32 sp24 = play->state.frames * this->actor.speedXZ * 1400.0f; + f32 sp24 = play->state.frames * this->actor.speed * 1400.0f; OPEN_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Geg/z_en_geg.h b/src/overlays/actors/ovl_En_Geg/z_en_geg.h index ea29fd6cf..71639bdac 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.h +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.h @@ -33,9 +33,9 @@ typedef struct EnGeg { /* 0x484 */ Vec3f unk_484; /* 0x490 */ Vec3s unk_490; /* 0x496 */ u16 unk_496; - /* 0x498 */ s16 unk_498; - /* 0x49A */ s16 unk_49A; - /* 0x49C */ s16 unk_49C[8]; + /* 0x498 */ s16 csId; + /* 0x49A */ s16 nextCsId; + /* 0x49C */ s16 csIdList[8]; /* 0x4AC */ s32 unk_4AC; /* 0x4B0 */ s16 unk_4B0; /* 0x4B4 */ Vec3f unk_4B4; diff --git a/src/overlays/actors/ovl_En_Gg/z_en_gg.c b/src/overlays/actors/ovl_En_Gg/z_en_gg.c index a6c2a31ec..81d1c6bb6 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -8,7 +8,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_gg/object_gg.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_REACT_TO_LENS) #define THIS ((EnGg*)thisx) @@ -129,7 +129,7 @@ s32 func_80B34FB4(EnGg* this, PlayState* play) { pitch = Math_Vec3f_Pitch(&sp34, &sp40); if ((this->actor.xzDistToPlayer < 250.0f) && (this->actor.xzDistToPlayer > 50.0f) && - (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || CHECK_WEEKEVENTREG(WEEKEVENTREG_19_80))) { + (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_REACT_TO_LENS) || CHECK_WEEKEVENTREG(WEEKEVENTREG_19_80))) { Math_SmoothStepToS(&this->unk_2E8, pitch, 4, 0x2AA8, 1); } else { Math_SmoothStepToS(&this->unk_2E8, 0, 4, 0x2AA8, 1); @@ -144,7 +144,8 @@ void func_80B35108(EnGg* this, PlayState* play) { this->collider.dim.pos.z = this->actor.world.pos.z; CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 30.0f, 30.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 30.0f, 30.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); } void func_80B351A4(EnGg* this) { @@ -225,12 +226,12 @@ void func_80B352A4(EnGg* this, PlayState* play) { } void func_80B35450(EnGg* this, PlayState* play) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_91_10) && (play->csCtx.state == 0)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_91_10) && (play->csCtx.state == CS_STATE_IDLE)) { func_80B359DC(this, play); } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_REACT_TO_LENS)) { Actor_DeactivateLens(play); } this->unk_308 = 1; @@ -239,7 +240,7 @@ void func_80B35450(EnGg* this, PlayState* play) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_80)) { func_800B863C(&this->actor, play); this->actor.textId = 0xCEE; - } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_REACT_TO_LENS)) { func_800B863C(&this->actor, play); this->actor.textId = 0xCE5; } @@ -252,7 +253,7 @@ void func_80B3556C(EnGg* this, PlayState* play) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; this->unk_308 = 0; - this->actor.flags &= ~ACTOR_FLAG_80; + this->actor.flags &= ~ACTOR_FLAG_REACT_TO_LENS; func_80B35250(this); } else { this->actor.textId = func_80B357F0(this); @@ -264,15 +265,15 @@ void func_80B3556C(EnGg* this, PlayState* play) { void func_80B35634(EnGg* this, PlayState* play) { s32 pad; - s32 actionIndex; + s32 cueChannel; - if (Cutscene_CheckActorAction(play, 119)) { - actionIndex = Cutscene_GetActorActionIndex(play, 119); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_119)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_119); - if (this->unk_2DB != play->csCtx.actorActions[actionIndex]->action) { - this->unk_2DB = play->csCtx.actorActions[actionIndex]->action; + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; - switch (play->csCtx.actorActions[actionIndex]->action) { + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: this->unk_2DA = 0; this->unk_2E6 = 0; @@ -333,10 +334,10 @@ void func_80B35634(EnGg* this, PlayState* play) { func_80B358D8(this, play); } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); this->actor.shape.yOffset = 0.0f; } else { - this->unk_2DB = 99; + this->cueId = 99; } } @@ -406,16 +407,16 @@ void func_80B359DC(EnGg* this, PlayState* play) { this->unk_307 = true; } - if (ActorCutscene_GetCanPlayNext(this->unk_2DC)) { - ActorCutscene_Start(this->unk_2DC, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Start(this->csId, &this->actor); this->unk_307 = false; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } if (this->unk_307) { - ActorCutscene_SetIntentToPlay(this->unk_2DC); + CutsceneManager_Queue(this->csId); } } } else { @@ -652,7 +653,7 @@ void EnGg_Init(Actor* thisx, PlayState* play) { } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->actor.bgCheckFlags |= 0x400; + this->actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_400; SkelAnime_InitFlex(play, &this->skelAnime, &object_gg_Skel_00F6C0, &object_gg_Anim_00F578, this->jointTable, this->morphTable, 20); @@ -663,9 +664,9 @@ void EnGg_Init(Actor* thisx, PlayState* play) { CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_04); CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_08); CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_10); - this->actor.flags &= ~ACTOR_FLAG_80; + this->actor.flags &= ~ACTOR_FLAG_REACT_TO_LENS; this->unk_310 = this->actor.home.pos.y; - this->unk_2DC = this->actor.cutscene; + this->csId = this->actor.csId; this->actor.flags |= ACTOR_FLAG_2000000; this->unk_308 = 0; this->unk_309 = 0; @@ -683,22 +684,22 @@ void EnGg_Update(Actor* thisx, PlayState* play) { EnGg* this = THIS; if (play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) { - this->actor.flags |= ACTOR_FLAG_80; + this->actor.flags |= ACTOR_FLAG_REACT_TO_LENS; this->actor.flags |= ACTOR_FLAG_1; } else { - this->actor.flags &= ~ACTOR_FLAG_80; + this->actor.flags &= ~ACTOR_FLAG_REACT_TO_LENS; this->actor.flags &= ~ACTOR_FLAG_1; } if (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_80)) { - if (play->csCtx.state == 0) { + if (play->csCtx.state == CS_STATE_IDLE) { this->actor.flags |= ACTOR_FLAG_1; } else { this->actor.flags &= ~ACTOR_FLAG_1; } } - if ((play->csCtx.state == 0) && + if ((play->csCtx.state == CS_STATE_IDLE) && ((this->unk_2DA != 14) && (this->unk_2DA != 11) && (this->unk_2DA != 12) && (this->unk_2DA != 13))) { func_80B364D4(&this->unk_344, play); } @@ -709,7 +710,7 @@ void EnGg_Update(Actor* thisx, PlayState* play) { } if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_91_10) && - (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_80) || CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || + (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_80) || CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_REACT_TO_LENS) || (this->unk_308 == 1))) { SET_WEEKEVENTREG(WEEKEVENTREG_91_10); } @@ -722,7 +723,7 @@ void EnGg_Update(Actor* thisx, PlayState* play) { Actor_MoveWithoutGravity(&this->actor); SkelAnime_Update(&this->skelAnime); - if (play->csCtx.state == 0) { + if (play->csCtx.state == CS_STATE_IDLE) { func_80B3584C(this); } else { this->unk_2E8 = 0; @@ -797,7 +798,7 @@ void EnGg_Draw(Actor* thisx, PlayState* play) { POLY_OPA_DISP = SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnGg_OverrideLimbDraw, EnGg_PostLimbDraw, &this->actor, POLY_OPA_DISP); - } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (this->unk_308 == 1)) { + } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_REACT_TO_LENS) || (this->unk_308 == 1)) { func_8012C2DC(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B36DFC[this->unk_2E2])); diff --git a/src/overlays/actors/ovl_En_Gg/z_en_gg.h b/src/overlays/actors/ovl_En_Gg/z_en_gg.h index cb9f9e7cb..cc744cffa 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.h +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.h @@ -34,8 +34,8 @@ typedef struct EnGg { /* 0x25C */ Vec3s morphTable[20]; /* 0x2D4 */ UNK_TYPE1 unk_2D4[0x6]; /* 0x2DA */ u8 unk_2DA; - /* 0x2DB */ u8 unk_2DB; - /* 0x2DC */ s16 unk_2DC; + /* 0x2DB */ u8 cueId; + /* 0x2DC */ s16 csId; /* 0x2DE */ UNK_TYPE1 unk2DE[4]; /* 0x2E2 */ s16 unk_2E2; /* 0x2E4 */ s16 unk_2E4; diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c index 6da3b1378..fdd099fff 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -7,7 +7,7 @@ #include "z_en_gg2.h" #include "objects/object_gg/object_gg.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_REACT_TO_LENS) #define THIS ((EnGg2*)thisx) @@ -89,7 +89,7 @@ s32 func_80B3AC94(EnGg2* this, PlayState* play) { pitch = Math_Vec3f_Pitch(&sp34, &sp40); if ((this->actor.xzDistToPlayer < 250.0f) && (this->actor.xzDistToPlayer > 50.0f) && - CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_REACT_TO_LENS)) { Math_SmoothStepToS(&this->unk_2F4, pitch, 4, 0x2AA8, 1); } else { Math_SmoothStepToS(&this->unk_2F4, 0, 4, 0x2AA8, 1); @@ -159,14 +159,14 @@ void func_80B3AFB0(EnGg2* this, PlayState* play) { this->unk_2F0 = 1; this->actionFunc = func_80B3AE60; } else if ((this->actor.xzDistToPlayer < 100.0f) && (this->actor.xzDistToPlayer > 50.0f) && - CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_REACT_TO_LENS)) { func_800B863C(&this->actor, play); this->actor.textId = 0xCE4; } } void func_80B3B05C(EnGg2* this, PlayState* play) { - if ((this->actor.xzDistToPlayer < 100.0f) && CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + if ((this->actor.xzDistToPlayer < 100.0f) && CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_REACT_TO_LENS)) { this->actionFunc = func_80B3B5D4; } } @@ -192,19 +192,19 @@ void func_80B3B120(EnGg2* this, PlayState* play) { if (func_80B3B648(this, this->unk_1D8, this->unk_1DC) != 0) { if (this->unk_1DC >= (this->unk_1D8->count - 2)) { this->actionFunc = func_80B3AE60; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { this->unk_1DC++; } } - Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 5.0f, 0.2f, 1.0f); } } void func_80B3B21C(EnGg2* this, PlayState* play) { - this->actor.speedXZ = 0.0f; - if ((this->actor.xzDistToPlayer < 100.0f) && CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { - this->unk_2E4 = ActorCutscene_GetAdditionalCutscene(this->unk_2E4); + this->actor.speed = 0.0f; + if ((this->actor.xzDistToPlayer < 100.0f) && CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_REACT_TO_LENS)) { + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); this->actionFunc = func_80B3B5D4; } } @@ -256,7 +256,7 @@ void func_80B3B294(EnGg2* this, PlayState* play) { } } } - Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 5.0f, 0.2f, 1.0f); } void func_80B3B4B0(EnGg2* this, PlayState* play) { @@ -274,14 +274,14 @@ void func_80B3B4B0(EnGg2* this, PlayState* play) { } void func_80B3B5D4(EnGg2* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->unk_2E4)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2E4, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); this->actionFunc = func_80B3AE60; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->unk_2E4); + CutsceneManager_Queue(this->csId); } } @@ -310,7 +310,7 @@ s32 func_80B3B648(EnGg2* this, Path* path, s32 arg2_) { phi_f14 = points[arg2 + 1].z - points[arg2 - 1].z; } - func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RAD_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { ret = true; @@ -366,17 +366,17 @@ void EnGg2_Init(Actor* thisx, PlayState* play2) { } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->actor.bgCheckFlags |= 0x400; + this->actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_400; SkelAnime_InitFlex(play, &this->skelAnime, &object_gg_Skel_00F6C0, &object_gg_Anim_00F578, this->jointTable, this->morphTable, 20); this->unk_1D8 = SubS_GetPathByIndex(play, ENGG2_GET_FC00(&this->actor), 0x3F); - this->actor.flags &= ~ACTOR_FLAG_80; + this->actor.flags &= ~ACTOR_FLAG_REACT_TO_LENS; this->unk_2F0 = 0; this->unk_2F1 = 0; this->unk_2F2 = 0; this->unk_2F4 = 0; this->unk_2F6 = 0; - this->unk_2E4 = this->actor.cutscene; + this->csId = this->actor.csId; this->unk_2EC = 20; this->unk_2EA = 0; @@ -422,13 +422,13 @@ void EnGg2_Update(Actor* thisx, PlayState* play) { EnGg2* this = THIS; if (play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) { - this->actor.flags |= ACTOR_FLAG_80; + this->actor.flags |= ACTOR_FLAG_REACT_TO_LENS; this->actor.flags |= ACTOR_FLAG_1; if ((this->unk_2EE == 5) && (this->unk_2EE == 7)) { this->actor.flags &= ~ACTOR_FLAG_1; } } else { - this->actor.flags &= ~ACTOR_FLAG_80; + this->actor.flags &= ~ACTOR_FLAG_REACT_TO_LENS; this->actor.flags &= ~ACTOR_FLAG_1; } @@ -481,7 +481,7 @@ void EnGg2_Draw(Actor* thisx, PlayState* play) { func_8012C2DC(play->state.gfxCtx); - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (this->unk_2F0 == 1)) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_REACT_TO_LENS) || (this->unk_2F0 == 1)) { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B3C0AC[this->unk_2EA])); POLY_XLU_DISP = diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h index f91310775..ff7aec4a6 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h @@ -21,7 +21,7 @@ typedef struct EnGg2 { /* 0x1EC */ Vec3s jointTable[20]; /* 0x264 */ Vec3s morphTable[20]; /* 0x2DC */ UNK_TYPE1 unk2DC[0x8]; - /* 0x2E4 */ s16 unk_2E4; + /* 0x2E4 */ s16 csId; /* 0x2E6 */ UNK_TYPE1 unk2E6[4]; /* 0x2EA */ s16 unk_2EA; /* 0x2EC */ s16 unk_2EC; 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 dbd180359..07c01b288 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -51,26 +51,26 @@ typedef enum { } GiantAnimation; /** - * Used as values for csAction. The UNKNOWN ones are never used in-game. + * Used as values for cueId. The UNKNOWN ones are never used in-game. */ typedef enum { - /* 0 */ GIANT_CS_ACTION_NONE, - /* 1 */ GIANT_CS_ACTION_IDLE, - /* 2 */ GIANT_CS_ACTION_WALKING, - /* 3 */ GIANT_CS_ACTION_LOOKING_UP, - /* 4 */ GIANT_CS_ACTION_RAISING_ARMS, - /* 5 */ GIANT_CS_ACTION_STRUGGLING, - /* 6 */ GIANT_CS_ACTION_FALLING_OVER, - /* 7 */ GIANT_CS_ACTION_IDLE_FADE_IN, - /* 8 */ GIANT_CS_ACTION_TALKING, - /* 9 */ GIANT_CS_ACTION_DONE_TALKING, - /* 10 */ GIANT_CS_ACTION_TEACHING_OATH_TO_ORDER, - /* 11 */ GIANT_CS_ACTION_PLAYER_LEARNED_OATH_TO_ORDER, - /* 12 */ GIANT_CS_ACTION_UNKNOWN_12, - /* 13 */ GIANT_CS_ACTION_UNKNOWN_13, - /* 14 */ GIANT_CS_ACTION_UNKNOWN_14, - /* 15 */ GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER -} GiantCsActionIndex; + /* 0 */ GIANT_CUE_ID_NONE, + /* 1 */ GIANT_CUE_ID_IDLE, + /* 2 */ GIANT_CUE_ID_WALKING, + /* 3 */ GIANT_CUE_ID_LOOKING_UP, + /* 4 */ GIANT_CUE_ID_RAISING_ARMS, + /* 5 */ GIANT_CUE_ID_STRUGGLING, + /* 6 */ GIANT_CUE_ID_FALLING_OVER, + /* 7 */ GIANT_CUE_ID_IDLE_FADE_IN, + /* 8 */ GIANT_CUE_ID_TALKING, + /* 9 */ GIANT_CUE_ID_DONE_TALKING, + /* 10 */ GIANT_CUE_ID_TEACHING_OATH_TO_ORDER, + /* 11 */ GIANT_CUE_ID_PLAYER_LEARNED_OATH_TO_ORDER, + /* 12 */ GIANT_CUE_ID_UNKNOWN_12, + /* 13 */ GIANT_CUE_ID_UNKNOWN_13, + /* 14 */ GIANT_CUE_ID_UNKNOWN_14, + /* 15 */ GIANT_CUE_ID_HOLDING_UP_MOON_IN_CLOCK_TOWER +} GiantCueId; ActorInit En_Giant_InitVars = { ACTOR_EN_GIANT, @@ -154,31 +154,35 @@ void EnGiant_Init(Actor* thisx, PlayState* play) { SkelAnime_InitFlex(play, &this->skelAnime, &gGiantSkel, &gGiantLargeStrideAnim, this->jointTable, this->morphTable, GIANT_LIMB_MAX); EnGiant_ChangeAnim(this, GIANT_ANIM_IDLE_LOOP); - this->csAction = GIANT_CS_ACTION_NONE; + this->cueId = GIANT_CUE_ID_NONE; this->actionFunc = EnGiant_PerformCutsceneActions; this->actor.draw = NULL; this->alpha = 0; this->actor.velocity.y = -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->actorActionCommand = 454; + this->cueType = CS_CMD_ACTOR_CUE_454; break; + case GIANT_TYPE_SWAMP_TERMINA_FIELD: case GIANT_TYPE_SWAMP_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_SWAMP_GIANTS_CHAMBER_AND_ENDING: - this->actorActionCommand = 455; + this->cueType = CS_CMD_ACTOR_CUE_455; break; + case GIANT_TYPE_OCEAN_TERMINA_FIELD: case GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING: - this->actorActionCommand = 456; + this->cueType = CS_CMD_ACTOR_CUE_456; break; + default: - this->actorActionCommand = 453; + this->cueType = CS_CMD_ACTOR_CUE_453; break; } @@ -188,7 +192,7 @@ void EnGiant_Init(Actor* thisx, PlayState* play) { return; } - this->actorActionCommand = 0x1C5; + this->cueType = CS_CMD_ACTOR_CUE_453; Actor_SetScale(&this->actor, 0.32f); this->actionFunc = EnGiant_PerformClockTowerSuccessActions; Animation_Change(&this->skelAnime, &gGiantRaisedArmsStartAnim, 0.0f, @@ -259,65 +263,80 @@ void EnGiant_ChangeToStartOrLoopAnimation(EnGiant* this, s16 requestedAnimIndex) } /** - * Immediately switches to the specified animation for this cutscene action. + * Immediately switches to the specified animation for this cueId. */ -void EnGiant_ChangeAnimBasedOnCsAction(EnGiant* this) { - switch (this->csAction) { - case GIANT_CS_ACTION_IDLE: +void EnGiant_ChangeAnimBasedOnCueId(EnGiant* this) { + switch (this->cueId) { + case GIANT_CUE_ID_IDLE: EnGiant_ChangeAnim(this, GIANT_ANIM_IDLE_LOOP); break; - case GIANT_CS_ACTION_WALKING: + + case GIANT_CUE_ID_WALKING: EnGiant_ChangeAnim(this, GIANT_ANIM_WALKING_LOOP); break; - case GIANT_CS_ACTION_STRUGGLING: + + case GIANT_CUE_ID_STRUGGLING: EnGiant_ChangeAnim(this, GIANT_ANIM_STRUGGLE_START); break; - case GIANT_CS_ACTION_FALLING_OVER: + + case GIANT_CUE_ID_FALLING_OVER: EnGiant_ChangeAnim(this, GIANT_ANIM_FALLING_OVER); break; - case GIANT_CS_ACTION_IDLE_FADE_IN: + + case GIANT_CUE_ID_IDLE_FADE_IN: EnGiant_ChangeAnim(this, GIANT_ANIM_IDLE_LOOP); this->alpha = 0; break; - case GIANT_CS_ACTION_TALKING: + + case GIANT_CUE_ID_TALKING: EnGiant_ChangeAnim(this, GIANT_ANIM_BIG_CALL_START); break; - case GIANT_CS_ACTION_DONE_TALKING: + + case GIANT_CUE_ID_DONE_TALKING: EnGiant_ChangeAnim(this, GIANT_ANIM_BIG_CALL_END); break; - case GIANT_CS_ACTION_TEACHING_OATH_TO_ORDER: + + case GIANT_CUE_ID_TEACHING_OATH_TO_ORDER: EnGiant_ChangeAnim(this, GIANT_ANIM_SMALL_CALL_START); break; - case GIANT_CS_ACTION_PLAYER_LEARNED_OATH_TO_ORDER: + + case GIANT_CUE_ID_PLAYER_LEARNED_OATH_TO_ORDER: EnGiant_ChangeAnim(this, GIANT_ANIM_SMALL_CALL_END); break; - case GIANT_CS_ACTION_UNKNOWN_12: + + case GIANT_CUE_ID_UNKNOWN_12: EnGiant_ChangeAnim(this, GIANT_ANIM_IDLE_LOOP); break; - case GIANT_CS_ACTION_UNKNOWN_13: + + case GIANT_CUE_ID_UNKNOWN_13: EnGiant_ChangeAnim(this, GIANT_ANIM_WALKING_LOOP); break; - case GIANT_CS_ACTION_UNKNOWN_14: + + case GIANT_CUE_ID_UNKNOWN_14: if (this->animIndex != GIANT_ANIM_WALKING_LOOP) { EnGiant_ChangeAnim(this, GIANT_ANIM_WALKING_LOOP); } break; - case GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER: + + case GIANT_CUE_ID_HOLDING_UP_MOON_IN_CLOCK_TOWER: Animation_Change(&this->skelAnime, &gGiantRaisedArmsStartAnim, 0.0f, Animation_GetLastFrame(&gGiantRaisedArmsStartAnim) - 1.0f, Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), ANIMMODE_ONCE, 0.0f); break; + + default: + break; } } void EnGiant_UpdateAlpha(EnGiant* this) { - switch (this->csAction) { - case GIANT_CS_ACTION_FALLING_OVER: + switch (this->cueId) { + case GIANT_CUE_ID_FALLING_OVER: if (this->skelAnime.curFrame >= 90.0f && this->alpha > 0) { this->alpha -= 12; } break; - case GIANT_CS_ACTION_UNKNOWN_14: + case GIANT_CUE_ID_UNKNOWN_14: this->alpha -= 12; break; default: @@ -336,30 +355,30 @@ void EnGiant_UpdateAlpha(EnGiant* this) { */ void EnGiant_PlayAndUpdateAnimation(EnGiant* this) { if (SkelAnime_Update(&this->skelAnime) && - (this->animIndex != GIANT_ANIM_FALLING_OVER || this->csAction != GIANT_CS_ACTION_FALLING_OVER)) { + (this->animIndex != GIANT_ANIM_FALLING_OVER || this->cueId != GIANT_CUE_ID_FALLING_OVER)) { EnGiant_ChangeAnim(this, this->animIndex); - switch (this->csAction) { - case GIANT_CS_ACTION_LOOKING_UP: + switch (this->cueId) { + case GIANT_CUE_ID_LOOKING_UP: EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIM_LOOK_UP_START); break; - case GIANT_CS_ACTION_RAISING_ARMS: + case GIANT_CUE_ID_RAISING_ARMS: EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIM_RAISED_ARMS_START); break; - case GIANT_CS_ACTION_STRUGGLING: + case GIANT_CUE_ID_STRUGGLING: EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIM_STRUGGLE_START); break; - case GIANT_CS_ACTION_FALLING_OVER: + case GIANT_CUE_ID_FALLING_OVER: // Unused EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIM_FALLING_OVER); break; - case GIANT_CS_ACTION_TALKING: + case GIANT_CUE_ID_TALKING: EnGiant_ChangeAnim(this, GIANT_ANIM_BIG_CALL_LOOP); break; - case GIANT_CS_ACTION_DONE_TALKING: - case GIANT_CS_ACTION_PLAYER_LEARNED_OATH_TO_ORDER: + case GIANT_CUE_ID_DONE_TALKING: + case GIANT_CUE_ID_PLAYER_LEARNED_OATH_TO_ORDER: EnGiant_ChangeAnim(this, GIANT_ANIM_IDLE_LOOP); break; - case GIANT_CS_ACTION_TEACHING_OATH_TO_ORDER: + case GIANT_CUE_ID_TEACHING_OATH_TO_ORDER: EnGiant_ChangeAnim(this, GIANT_ANIM_SMALL_CALL_LOOP); break; } @@ -371,10 +390,10 @@ void EnGiant_PlaySound(EnGiant* this) { if (this->actor.draw != NULL && this->alpha > 0) { if (this->animIndex == GIANT_ANIM_WALKING_LOOP && (Animation_OnFrame(&this->skelAnime, 40.0f) || Animation_OnFrame(&this->skelAnime, 100.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_KYOJIN_WALK); } if (this->animIndex == GIANT_ANIM_FALLING_OVER && Animation_OnFrame(&this->skelAnime, 40.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_VOICE_FAIL); + Actor_PlaySfx(&this->actor, NA_SE_EV_KYOJIN_VOICE_FAIL); } if (this->sfxId != 0xFFFF && ((this->animIndex == GIANT_ANIM_BIG_CALL_START && this->skelAnime.curFrame >= 18.0f) || @@ -388,30 +407,28 @@ void EnGiant_PlaySound(EnGiant* this) { } } -void EnGiant_UpdatePosition(EnGiant* this, PlayState* play, u32 actionIndex) { - CsCmdActorAction* actorAction = play->csCtx.actorActions[actionIndex]; - f32 startPosY = actorAction->startPos.y; +void EnGiant_UpdatePosition(EnGiant* this, PlayState* play, u32 cueChannel) { + CsCmdActorCue* cue = play->csCtx.actorCues[cueChannel]; + f32 startPosY = cue->startPos.y; s32 pad[2]; - f32 endPosY = actorAction->endPos.y; - f32 scale = Environment_LerpWeight(actorAction->endFrame, actorAction->startFrame, play->csCtx.frames); + f32 endPosY = cue->endPos.y; + f32 scale = Environment_LerpWeight(cue->endFrame, cue->startFrame, play->csCtx.curFrame); this->actor.world.pos.y = ((endPosY - startPosY) * scale) + startPosY; } void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, this->actorActionCommand)) { - EnGiant_UpdatePosition(this, play, Cutscene_GetActorActionIndex(play, this->actorActionCommand)); - if (this->csAction != - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->actorActionCommand)]->action) { - this->csAction = - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->actorActionCommand)]->action; - EnGiant_ChangeAnimBasedOnCsAction(this); + if (Cutscene_IsCueInChannel(play, this->cueType)) { + EnGiant_UpdatePosition(this, play, Cutscene_GetCueChannel(play, this->cueType)); + if (this->cueId != play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id) { + this->cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; + EnGiant_ChangeAnimBasedOnCueId(this); } EnGiant_UpdateAlpha(this); } EnGiant_PlaySound(this); - if (this->csAction == GIANT_CS_ACTION_STRUGGLING) { + if (this->cueId == GIANT_CUE_ID_STRUGGLING) { func_800B9010(&this->actor, NA_SE_IT_KYOJIN_BEARING - SFX_FLAG); } EnGiant_PlayAndUpdateAnimation(this); @@ -424,13 +441,11 @@ void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, PlayState* play) { void EnGiant_PerformCutsceneActions(EnGiant* this, PlayState* play) { this->actor.draw = EnGiant_Draw; - if (Cutscene_CheckActorAction(play, this->actorActionCommand)) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->actorActionCommand)); - if (this->csAction != - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->actorActionCommand)]->action) { - this->csAction = - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->actorActionCommand)]->action; - EnGiant_ChangeAnimBasedOnCsAction(this); + if (Cutscene_IsCueInChannel(play, this->cueType)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); + if (this->cueId != play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id) { + this->cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; + EnGiant_ChangeAnimBasedOnCueId(this); } EnGiant_UpdateAlpha(this); } @@ -449,7 +464,7 @@ void EnGiant_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); if (this->blinkTimer == 0) { blinkTimerTemp = 0; 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 9ce182a98..45e89dd55 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.h +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.h @@ -48,8 +48,8 @@ typedef struct EnGiant { /* 0x188 */ Vec3s jointTable[GIANT_LIMB_MAX]; /* 0x1E8 */ Vec3s morphTable[GIANT_LIMB_MAX]; /* 0x248 */ s16 animIndex; - /* 0x24A */ u16 actorActionCommand; - /* 0x24C */ u16 csAction; + /* 0x24A */ u16 cueType; + /* 0x24C */ u16 cueId; /* 0x24E */ s16 alpha; /* 0x250 */ u16 sfxId; /* 0x254 */ MtxF headDrawMtxF; 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 88d55dc14..fba0c1118 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 @@ -89,7 +89,7 @@ void EnGinkoMan_Idle(EnGinkoMan* this, PlayState* play) { EnGinkoMan_SwitchAnimation(this, play); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { + if ((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) == 0) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_LEGSMACKING); Message_StartTextbox(play, 0x44C, &this->actor); this->curTextId = 0x44C; // would you like to make an account @@ -153,7 +153,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, PlayState* play) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_LEGSMACKING); } - play->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; + play->msgCtx.bankRupees = gSaveContext.save.saveInfo.bankRupees & 0xFFFF; Message_StartTextbox(play, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" } @@ -164,22 +164,22 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, PlayState* play) { this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" break; case 0x45A: // "All right, little guy, now I've got a total of [rupees] from you!" - if (((gSaveContext.save.bankRupees & 0xFFFF) >= 200) && (this->previousBankValue < 200) && + if (((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) >= 200) && (this->previousBankValue < 200) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_40)) { SET_WEEKEVENTREG(WEEKEVENTREG_59_40); Message_StartTextbox(play, 0x45B, &this->actor); this->curTextId = 0x45B; // "What's this? You've already saved up 200 Rupees!?! - } else if (((gSaveContext.save.bankRupees & 0xFFFF) >= 1000) && ((this->previousBankValue) < 1000) && - !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_80)) { + } else if (((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) >= 1000) && + ((this->previousBankValue) < 1000) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_80)) { SET_WEEKEVENTREG(WEEKEVENTREG_59_80); Message_StartTextbox(play, 0x45C, &this->actor); this->curTextId = 0x45C; // "What's this? You've already saved up 1000 Rupees!?! - } else if ((gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { + } else if ((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) >= 5000) { if ((this->previousBankValue < 5000) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_60_01)) { SET_WEEKEVENTREG(WEEKEVENTREG_60_01); Message_StartTextbox(play, 0x45D, &this->actor); this->curTextId = 0x45D; // "What's this? You've already saved up 5000 Rupees?! - } else if (this->previousBankValue < (s16)(gSaveContext.save.bankRupees & 0xFFFF)) { + } else if (this->previousBankValue < (s16)(gSaveContext.save.saveInfo.bankRupees & 0xFFFF)) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); Message_StartTextbox(play, 0x45E, &this->actor); this->curTextId = @@ -199,7 +199,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, PlayState* play) { case 0x45C: // given 1000 reward case 0x45D: // given 5000 reward this->isStampChecked = false; - func_801477B4(play); + Message_CloseTextbox(play); EnGinkoMan_SetupBankAward(this); EnGinkoMan_BankAward(this, play); break; @@ -221,7 +221,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, PlayState* play) { break; case 0x465: // "There! Now I'll know you when I see you!" Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_LEGSMACKING); - play->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; + play->msgCtx.bankRupees = gSaveContext.save.saveInfo.bankRupees & 0xFFFF; Message_StartTextbox(play, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" break; @@ -237,10 +237,10 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, PlayState* play) { case 0x46C: // "Ah, yes...[Link], right? If I remember, you're the little guy who deposited [rupees]." case 0x47E: // "Your deposits total [rupees]." if (this->choiceDepositWithdrawl == GINKOMAN_CHOICE_DEPOSIT) { - if ((u32)(gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { + if ((u32)(gSaveContext.save.saveInfo.bankRupees & 0xFFFF) >= 5000) { Message_StartTextbox(play, 0x45F, &this->actor); this->curTextId = 0x45F; // "Excuuuse me! But I can't take anymore deposits! - } else if (gSaveContext.save.playerData.rupees == 0) { + } else if (gSaveContext.save.saveInfo.playerData.rupees == 0) { Message_StartTextbox(play, 0x458, &this->actor); this->curTextId = 0x458; // "Hmm...You play mean jokes, little guy! You haven't even got a single Rupee! @@ -270,7 +270,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, PlayState* play) { break; case 0x470: // "Is that so? Come back and deposit some after saving up a bunch!" if (Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); this->isStampChecked = false; EnGinkoMan_SetupIdle(this); // change to waiting for approach } @@ -288,12 +288,12 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, PlayState* play) { case 0x473: // Use it wisely... case 0x474: // "Aw, you're taking out all that? If you spend it like that, it'll all be gone before you know // it!" - if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { + if ((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) == 0) { Message_StartTextbox(play, 0x478, &this->actor); // "Look, little guy, all the Rupees you deposited are gone, so you can't use that stamp anymore." this->curTextId = 0x478; } else { - play->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; + play->msgCtx.bankRupees = gSaveContext.save.saveInfo.bankRupees & 0xFFFF; Message_StartTextbox(play, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" } @@ -319,12 +319,12 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, PlayState* play) { switch (this->curTextId) { case 0x44E: // "...So, what'll it be? if (play->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { - if ((gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { + if ((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) >= 5000) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x45F, &this->actor); this->curTextId = 0x45F; // bank full, cannot accept more } else { - if (gSaveContext.save.playerData.rupees > 0) { + if (gSaveContext.save.saveInfo.playerData.rupees > 0) { func_8019F208(); Message_StartTextbox(play, 0x44F, &this->actor); this->curTextId = 0x44F; // "All right! so..." @@ -342,7 +342,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, PlayState* play) { break; case 0x452: // Really? are you really depositing rupees? if (play->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { - if (gSaveContext.save.playerData.rupees < play->msgCtx.bankRupeesSelected) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.bankRupeesSelected) { play_sound(NA_SE_SY_ERROR); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); Message_StartTextbox(play, 0x459, &this->actor); @@ -361,20 +361,20 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, PlayState* play) { this->curTextId = 0x453; // That's it? That aint nothing at all } - if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { + if ((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) == 0) { this->isNewAccount = true; } Rupees_ChangeBy(-play->msgCtx.bankRupeesSelected); - this->previousBankValue = gSaveContext.save.bankRupees & 0xFFFF; - gSaveContext.save.bankRupees = - ((gSaveContext.save.bankRupees & 0xFFFF) + play->msgCtx.bankRupeesSelected) | - (gSaveContext.save.bankRupees & 0xFFFF0000); + this->previousBankValue = gSaveContext.save.saveInfo.bankRupees & 0xFFFF; + gSaveContext.save.saveInfo.bankRupees = + ((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) + play->msgCtx.bankRupeesSelected) | + (gSaveContext.save.saveInfo.bankRupees & 0xFFFF0000); } } else { // GINKOMAN_CHOICE_NO func_8019F230(); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); - if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { + if ((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) == 0) { Message_StartTextbox(play, 0x456, &this->actor); this->curTextId = 0x456; // Is that so? think about it } else { @@ -403,14 +403,14 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, PlayState* play) { break; case 0x471: // Are you really withdrawling [selected rupees]? if (play->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { - if ((s32)((gSaveContext.save.bankRupees & 0xFFFF)) < + if ((s32)((gSaveContext.save.saveInfo.bankRupees & 0xFFFF)) < ((s32)(play->msgCtx.bankRupeesSelected + this->serviceFee))) { play_sound(NA_SE_SY_ERROR); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_LEGSMACKING); Message_StartTextbox(play, 0x476, &this->actor); this->curTextId = 0x476; // you dont have enough deposited to withdrawl } else if (CUR_CAPACITY(UPG_WALLET) < - (play->msgCtx.bankRupeesSelected + gSaveContext.save.playerData.rupees)) { + (play->msgCtx.bankRupeesSelected + gSaveContext.save.saveInfo.playerData.rupees)) { // check if wallet is big enough play_sound(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x475, &this->actor); @@ -428,11 +428,11 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, PlayState* play) { this->curTextId = 0x472; // It's a waste to take out such a tiny bit } - this->previousBankValue = (s16)(gSaveContext.save.bankRupees & 0xFFFF); - gSaveContext.save.bankRupees = - (((gSaveContext.save.bankRupees & 0xFFFF) - play->msgCtx.bankRupeesSelected) - + this->previousBankValue = (s16)(gSaveContext.save.saveInfo.bankRupees & 0xFFFF); + gSaveContext.save.saveInfo.bankRupees = + (((gSaveContext.save.saveInfo.bankRupees & 0xFFFF) - play->msgCtx.bankRupeesSelected) - this->serviceFee) | - (gSaveContext.save.bankRupees & 0xFFFF0000); + (gSaveContext.save.saveInfo.bankRupees & 0xFFFF0000); Rupees_ChangeBy(play->msgCtx.bankRupeesSelected); } } else { @@ -510,7 +510,7 @@ void EnGinkoMan_Dialogue(EnGinkoMan* this, PlayState* play) { if ((this->skelAnime.animation == &object_boj_Anim_0008C0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BANK_MAN_HAND_HIT); + Actor_PlaySfx(&this->actor, NA_SE_EV_BANK_MAN_HAND_HIT); } } @@ -525,16 +525,16 @@ void EnGinkoMan_BankAward(EnGinkoMan* this, PlayState* play) { EnGinkoMan_SetupBankAward2(this); } else if (this->curTextId == 0x45B) { // "Whats this, you already saved up 200?" if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_10_08)) { - Actor_PickUp(&this->actor, play, GI_WALLET_ADULT + CUR_UPG_VALUE(UPG_WALLET), 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_WALLET_ADULT + CUR_UPG_VALUE(UPG_WALLET), 500.0f, 100.0f); } else { - Actor_PickUp(&this->actor, play, GI_RUPEE_BLUE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_BLUE, 500.0f, 100.0f); } } else if (this->curTextId == 0x45C) { // "Whats this, you already saved up 5000?" - Actor_PickUp(&this->actor, play, GI_RUPEE_BLUE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_BLUE, 500.0f, 100.0f); } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_59_08)) { - Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); } else { - Actor_PickUp(&this->actor, play, GI_RUPEE_BLUE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_BLUE, 500.0f, 100.0f); } } @@ -579,7 +579,7 @@ void EnGinkoMan_SetupStamp(EnGinkoMan* this) { void EnGinkoMan_Stamp(EnGinkoMan* this, PlayState* play) { if ((this->curTextId == 0x464) // "Hey, relax! It doesn't leave any marks, and it's not gonna hurt." && (Animation_OnFrame(&this->skelAnime, 10.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); // "stamp" + Actor_PlaySfx(&this->actor, NA_SE_EV_HANKO); // "stamp" } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -591,7 +591,7 @@ void EnGinkoMan_Stamp(EnGinkoMan* this, PlayState* play) { break; case 0x469: // "Excuse me, but let me take a look at you..." Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); - play->msgCtx.bankRupees = (gSaveContext.save.bankRupees & 0xFFFF); + play->msgCtx.bankRupees = (gSaveContext.save.saveInfo.bankRupees & 0xFFFF); if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { Message_StartTextbox(play, 0x46C, &this->actor); this->curTextId = 0x46C; // "Ah, yes...[Link], right? 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 65df46284..90e449be3 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -159,8 +159,8 @@ void EnGirlA_SetupAction(EnGirlA* this, EnGirlAActionFunc action) { void EnGirlA_InitObjIndex(EnGirlA* this, PlayState* play) { s16 params = this->actor.params; - //! @bug: Condition is impossible, && should be an || if ((params >= SI_MAX) && (params < SI_POTION_RED_1)) { + //! @bug: Impossible to reach, && should be an || Actor_Kill(&this->actor); return; } @@ -188,7 +188,7 @@ s32 EnGirlA_CanBuyPotionRed(PlayState* play, EnGirlA* this) { if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; @@ -198,7 +198,7 @@ s32 EnGirlA_CanBuyPotionGreen(PlayState* play, EnGirlA* this) { if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; @@ -214,7 +214,7 @@ s32 EnGirlA_CanBuyPotionBlue(PlayState* play, EnGirlA* this) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_53_10)) { return CANBUY_RESULT_SUCCESS_2; } - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; @@ -227,7 +227,7 @@ s32 EnGirlA_CanBuyArrows(PlayState* play, EnGirlA* this) { if (AMMO(ITEM_BOW) >= CUR_CAPACITY(UPG_QUIVER)) { return CANBUY_RESULT_NO_ROOM_2; } - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; @@ -237,7 +237,7 @@ s32 EnGirlA_CanBuyNuts(PlayState* play, EnGirlA* this) { if (CUR_CAPACITY(UPG_NUTS) != 0 && CUR_CAPACITY(UPG_NUTS) <= AMMO(ITEM_NUT)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_NUT) == ITEM_NONE) { @@ -250,7 +250,7 @@ s32 EnGirlA_CanBuyShieldHero(PlayState* play, EnGirlA* this) { if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != EQUIP_VALUE_SHIELD_NONE) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; @@ -260,7 +260,7 @@ s32 EnGirlA_CanBuyStick(PlayState* play, EnGirlA* this) { if (CUR_CAPACITY(UPG_STICKS) != 0 && AMMO(ITEM_STICK) >= CUR_CAPACITY(UPG_STICKS)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_STICK) == ITEM_NONE) { @@ -270,7 +270,7 @@ s32 EnGirlA_CanBuyStick(PlayState* play, EnGirlA* this) { } s32 EnGirlA_CanBuyMaskAllNight(PlayState* play, EnGirlA* this) { - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; @@ -280,7 +280,7 @@ s32 EnGirlA_CanBuyBombBagCuriosityShop(PlayState* play, EnGirlA* this) { if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) >= 2) { return CANBUY_RESULT_CANNOT_GET_NOW; } - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; @@ -293,7 +293,7 @@ s32 EnGirlA_CanBuyBombBag20BombShop(PlayState* play, EnGirlA* this) { if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) >= 2) { return CANBUY_RESULT_HAVE_BETTER; } - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; @@ -306,7 +306,7 @@ s32 EnGirlA_CanBuyBombBag30BombShop(PlayState* play, EnGirlA* this) { if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 3) { return CANBUY_RESULT_HAVE_BETTER; } - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; @@ -319,7 +319,7 @@ s32 EnGirlA_CanBuyBombchus(PlayState* play, EnGirlA* this) { if (AMMO(ITEM_BOMBCHU) >= CUR_CAPACITY(UPG_BOMB_BAG)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } if (Item_CheckObtainability(ITEM_BOMBCHU) == ITEM_NONE) { @@ -335,21 +335,21 @@ s32 EnGirlA_CanBuyBombs(PlayState* play, EnGirlA* this) { if (AMMO(ITEM_BOMB) >= CUR_CAPACITY(UPG_BOMB_BAG)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyBottleStolen(PlayState* play, EnGirlA* this) { - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } s32 EnGirlA_CanBuySword(PlayState* play, EnGirlA* this) { - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; @@ -359,7 +359,7 @@ s32 EnGirlA_CanBuyShieldMirror(PlayState* play, EnGirlA* this) { if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != EQUIP_VALUE_SHIELD_NONE) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; @@ -369,7 +369,7 @@ s32 EnGirlA_CanBuyFairy(PlayState* play, EnGirlA* this) { if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.c b/src/overlays/actors/ovl_En_Gk/z_en_gk.c index 6f2f3c09c..40cf72a98 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -240,7 +240,8 @@ void func_80B507A0(EnGk* this, PlayState* play) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 30.0f, 30.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 30.0f, 30.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); } s32 func_80B50854(EnGk* this, PlayState* play) { @@ -268,7 +269,7 @@ s32 func_80B50854(EnGk* this, PlayState* play) { void func_80B50954(EnGk* this) { if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 4.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLONKID_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLONKID_WALK); } } @@ -373,7 +374,7 @@ s32 func_80B50C78(EnGk* this, Path* path, s32 arg2_) { phi_f14 = sp5C[arg2 + 1].z - sp5C[arg2 - 1].z; } - func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RAD_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { ret = true; @@ -510,19 +511,19 @@ void func_80B51410(EnGk* this, PlayState* play) { this->unk_1E4 |= 0x20; } - if (ActorCutscene_GetCanPlayNext(this->unk_318)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLONKID_SOB_TALK); - ActorCutscene_Start(this->unk_318, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLONKID_SOB_TALK); + CutsceneManager_Start(this->csId, &this->actor); this->unk_1E4 &= ~0x20; return; } - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } if (this->unk_1E4 & 0x20) { - ActorCutscene_SetIntentToPlay(this->unk_318); + CutsceneManager_Queue(this->csId); } } else { this->unk_1E4 &= ~0x20; @@ -531,16 +532,16 @@ void func_80B51410(EnGk* this, PlayState* play) { void func_80B51510(EnGk* this, PlayState* play) { s32 pad; - s32 actionIndex; + s32 cueChannel; if (this) {} - if (Cutscene_CheckActorAction(play, 479)) { - actionIndex = Cutscene_GetActorActionIndex(play, 479); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_479)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_479); - if (play->csCtx.actorActions[actionIndex]->action != this->unk_31B) { - this->unk_31B = play->csCtx.actorActions[actionIndex]->action; - switch (play->csCtx.actorActions[actionIndex]->action) { + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: this->unk_31A = 0; this->unk_2E4 = 0; @@ -584,10 +585,10 @@ void func_80B51510(EnGk* this, PlayState* play) { func_80B51308(this, play); } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); this->actor.shape.yOffset = 0.0f; } else { - this->unk_31B = 0x63; + this->cueId = 99; } } @@ -661,9 +662,9 @@ void func_80B51970(EnGk* this, PlayState* play) { if (((talkState == TEXT_STATE_DONE) || (talkState == TEXT_STATE_5)) && Message_ShouldAdvance(play)) { if ((this->unk_31C == 0xE84) || (this->unk_31C == 0xE99)) { - ActorCutscene_Stop(this->unk_318); - this->unk_318 = ActorCutscene_GetAdditionalCutscene(this->unk_318); - ActorCutscene_SetIntentToPlay(this->unk_318); + CutsceneManager_Stop(this->csId); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); + CutsceneManager_Queue(this->csId); this->actionFunc = func_80B51D9C; return; } @@ -722,8 +723,8 @@ void func_80B51B40(EnGk* this, PlayState* play) { if (this->unk_31C == 0xE8F) { play->nextEntrance = ENTRANCE(GORON_RACETRACK, 1); play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; Magic_Add(play, MAGIC_FILL_TO_CAPACITY); } else { this->actionFunc = func_80B51760; @@ -772,8 +773,8 @@ void func_80B51B40(EnGk* this, PlayState* play) { void func_80B51D9C(EnGk* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (ActorCutscene_GetCanPlayNext(this->unk_318)) { - ActorCutscene_StartAndSetFlag(this->unk_318, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); if (this->unk_1E4 & 4) { this->unk_1E4 &= ~4; this->unk_2E4 = 6; @@ -790,10 +791,10 @@ void func_80B51D9C(EnGk* this, PlayState* play) { this->actionFunc = func_80B51970; } } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->unk_318); + CutsceneManager_Queue(this->csId); } func_80B50954(this); } @@ -809,19 +810,19 @@ void func_80B51EA4(EnGk* this, PlayState* play) { sp36 = this->actor.shape.rot.y - sp38.y; if (func_80B50C78(this, this->path, this->unk_1EC)) { if (this->unk_1EC >= (this->path->count - 1)) { - ActorCutscene_Stop(this->unk_318); + CutsceneManager_Stop(this->csId); Actor_Kill(&this->actor); } else { this->unk_1EC++; } } - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { sp38.y = this->actor.wallYaw; } if (ABS_ALT(sp36) < 0x2AAA) { - Math_ApproachF(&this->actor.speedXZ, 3.0f, 0.2f, 0.5f); + Math_ApproachF(&this->actor.speed, 3.0f, 0.2f, 0.5f); } Actor_MoveWithGravity(&this->actor); } @@ -841,7 +842,7 @@ void func_80B51FD0(EnGk* this, PlayState* play) { void func_80B5202C(EnGk* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (play->csCtx.state == 0) { + if (play->csCtx.state == CS_STATE_IDLE) { func_80B51410(this, play); } @@ -859,7 +860,8 @@ void func_80B5202C(EnGk* this, PlayState* play) { } if (this->unk_1E4 & 2) { - if ((play->msgCtx.ocarinaMode != 1) && (play->msgCtx.ocarinaMode != 3) && (play->csCtx.state == 0)) { + if ((play->msgCtx.ocarinaMode != 1) && (play->msgCtx.ocarinaMode != 3) && + (play->csCtx.state == CS_STATE_IDLE)) { func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); } } else { @@ -897,7 +899,7 @@ void func_80B5227C(EnGk* this, PlayState* play) { if (!(this->unk_1E4 & 0x80)) { SET_WEEKEVENTREG(WEEKEVENTREG_22_04); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SIT_IMT); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_SIT_IMT); this->unk_350 = 0x4000; this->actionFunc = func_80B52654; } @@ -968,7 +970,7 @@ void func_80B5253C(EnGk* this, PlayState* play) { } this->actionFunc = func_80B525E0; } else { - Actor_PickUp(&this->actor, play, sp24, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, sp24, 300.0f, 300.0f); } } @@ -978,13 +980,13 @@ void func_80B525E0(EnGk* this, PlayState* play) { Message_StartTextbox(play, this->unk_31C, &this->actor); this->actionFunc = func_80B52430; } else { - func_800B85E0(&this->actor, play, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); } } void func_80B52654(EnGk* this, PlayState* play) { this->unk_350 += 0x400; - if ((this->unk_1E4 & 0x80) && (play->csCtx.frames == 250)) { + if ((this->unk_1E4 & 0x80) && (play->csCtx.curFrame == 250)) { SET_WEEKEVENTREG(WEEKEVENTREG_22_04); } @@ -993,7 +995,7 @@ void func_80B52654(EnGk* this, PlayState* play) { this->actor.scale.z = 0.006f - this->unk_354; this->actor.scale.x = 0.006f + this->unk_354; if (this->unk_350 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLONKID_SNORE); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLONKID_SNORE); } } @@ -1022,12 +1024,12 @@ void EnGk_Init(Actor* thisx, PlayState* play) { if (Flags_GetSwitch(play, ENGK_GET_3F00(&this->actor))) { Actor_Kill(&this->actor); } else { - this->unk_318 = this->actor.cutscene; + this->csId = this->actor.csId; this->path = SubS_GetPathByIndex(play, ENGK_GET_F0(&this->actor), 0xF); this->actionFunc = func_80B51760; } } else if (play->sceneId == SCENE_GORONRACE) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE)) { if (gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 1)) { this->actionFunc = func_80B51760; } else if (gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 2)) { @@ -1052,7 +1054,7 @@ void EnGk_Init(Actor* thisx, PlayState* play) { } } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04)) { this->unk_2E4 = 0; - this->unk_318 = this->actor.cutscene; + this->csId = this->actor.csId; this->actor.flags |= ACTOR_FLAG_10; this->actor.flags |= ACTOR_FLAG_2000000; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); @@ -1226,8 +1228,8 @@ TexturePtr D_80B533E4[] = { void EnGk_Draw(Actor* thisx, PlayState* play) { s32 pad; EnGk* this = THIS; - Vec3f sp5C; - Vec3f sp50; + Vec3f pos; + Vec3f scale; OPEN_DISPS(play->state.gfxCtx); @@ -1242,12 +1244,12 @@ void EnGk_Draw(Actor* thisx, PlayState* play) { func_8012C2DC(play->state.gfxCtx); - sp5C = this->actor.world.pos; - sp50.x = 0.2f; - sp50.y = 0.2f; - sp50.z = 0.2f; + pos = this->actor.world.pos; + scale.x = 0.2f; + scale.y = 0.2f; + scale.z = 0.2f; - func_800BC620(&sp5C, &sp50, 255, play); + func_800BC620(&pos, &scale, 255, play); } else { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B533E4[this->unk_2E0])); @@ -1259,20 +1261,21 @@ void EnGk_Draw(Actor* thisx, PlayState* play) { func_8012C2DC(play->state.gfxCtx); if ((this->unk_2E4 == 0) || (this->unk_2E4 == 1) || (this->unk_2E4 == 2) || (this->unk_2E4 == 3) || (this->unk_2E4 == 4)) { - sp5C.x = this->actor.world.pos.x - 15.0f; - sp5C.y = this->actor.world.pos.y; - sp5C.z = this->actor.world.pos.z; + pos.x = this->actor.world.pos.x - 15.0f; + pos.y = this->actor.world.pos.y; + pos.z = this->actor.world.pos.z; - sp50.x = 0.2f; - sp50.y = 0.2f; - sp50.z = 0.2f; + scale.x = 0.2f; + scale.y = 0.2f; + scale.z = 0.2f; } else { - sp5C = this->actor.world.pos; - sp50.x = 0.2f; - sp50.y = 0.2f; - sp50.z = 0.2f; + pos = this->actor.world.pos; + scale.x = 0.2f; + scale.y = 0.2f; + scale.z = 0.2f; } - func_800BC620(&sp5C, &sp50, 255, play); + + func_800BC620(&pos, &scale, 255, play); } } diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.h b/src/overlays/actors/ovl_En_Gk/z_en_gk.h index bebe6c6c9..0f74c1d65 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.h +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.h @@ -39,9 +39,9 @@ typedef struct EnGk { /* 0x2F4 */ Vec3f unk_2F4; /* 0x300 */ Vec3f unk_300; /* 0x30C */ Vec3f unk_30C; - /* 0x318 */ s16 unk_318; + /* 0x318 */ s16 csId; /* 0x31A */ u8 unk_31A; - /* 0x31B */ u8 unk_31B; + /* 0x31B */ u8 cueId; /* 0x31C */ u16 unk_31C; /* 0x31E */ s16 unk_31E; /* 0x320 */ s16 unk_320; 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 01146c0cf..f31dd7cd2 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -328,7 +328,7 @@ s32 func_8094E054(EnGm* this, PlayState* play, s32 arg2) { s32 func_8094E0F8(EnGm* this, PlayState* play) { s32 ret = false; - if ((this->unk_260 != play->roomCtx.curRoom.num) && (play->roomCtx.unk31 == 0)) { + if ((this->unk_260 != play->roomCtx.curRoom.num) && (play->roomCtx.status == 0)) { this->unk_260 = play->roomCtx.curRoom.num; this->unk_262 = SubS_GetObjectIndex(OBJECT_IN2, play); this->actor.draw = NULL; @@ -425,48 +425,48 @@ void func_8094E2D0(EnGm* this) { } } -s32 func_8094E454(EnGm* this, s16 arg1) { +s32 func_8094E454(EnGm* this, s16 csId) { s32 ret = false; - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(arg1); - } else if (ActorCutscene_GetCanPlayNext(arg1)) { - ActorCutscene_StartAndSetUnkLinkFields(arg1, &this->actor); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(csId); + } else if (CutsceneManager_IsNext(csId)) { + CutsceneManager_StartWithPlayerCs(csId, &this->actor); ret = true; } else { - ActorCutscene_SetIntentToPlay(arg1); + CutsceneManager_Queue(csId); } return ret; } -s16 func_8094E4D0(EnGm* this, s32 arg1) { +s16 func_8094E4D0(EnGm* this, s32 numCutscenes) { s32 i; - s16 cutscene = this->actor.cutscene; + s16 csId = this->actor.csId; - for (i = 0; i < arg1; i++) { - cutscene = ActorCutscene_GetAdditionalCutscene(cutscene); + for (i = 0; i < numCutscenes; i++) { + csId = CutsceneManager_GetAdditionalCsId(csId); } - return cutscene; + return csId; } s32 func_8094E52C(EnGm* this, PlayState* play) { s32 pad; - s16 sp2A = func_8094E4D0(this, 0); + s16 csId = func_8094E4D0(this, 0); s32 ret = false; switch (this->unk_3E0) { case 0: - if (!func_8094E454(this, sp2A)) { + if (!func_8094E454(this, csId)) { break; } case 2: if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_86_40) && (this->unk_3E0 == 2)) { - ActorCutscene_Stop(sp2A); + CutsceneManager_Stop(csId); } else { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)), &this->actor); } this->unk_3E0++; ret = true; @@ -474,14 +474,15 @@ s32 func_8094E52C(EnGm* this, PlayState* play) { case 1: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)), + this->actor.child); } this->unk_3E0++; ret = true; break; case 3: - ActorCutscene_Stop(sp2A); + CutsceneManager_Stop(csId); this->unk_3E0++; ret = true; break; @@ -492,7 +493,7 @@ s32 func_8094E52C(EnGm* this, PlayState* play) { s32 func_8094E69C(EnGm* this, PlayState* play) { Camera* subCam; - s16 sp4A = func_8094E4D0(this, 0); + s16 csId = func_8094E4D0(this, 0); s16 sp48; Vec3f sp3C; Vec3f sp30; @@ -500,7 +501,7 @@ s32 func_8094E69C(EnGm* this, PlayState* play) { switch (this->unk_3E0) { case 0: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHAIR_ROLL); func_8094E054(this, play, 2); this->unk_3E2 = 0; this->unk_3E0++; @@ -530,10 +531,10 @@ s32 func_8094E69C(EnGm* this, PlayState* play) { break; case 2: - if (func_8094E454(this, sp4A)) { + if (func_8094E454(this, csId)) { case 4: case 6: - subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp4A)); + subCam = Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)); Camera_SetTargetActor(subCam, &this->actor); this->unk_3E0++; ret = true; @@ -544,7 +545,7 @@ s32 func_8094E69C(EnGm* this, PlayState* play) { case 5: case 7: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp4A)); + subCam = Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)); Camera_SetTargetActor(subCam, this->actor.child); } this->unk_3E0++; @@ -552,8 +553,8 @@ s32 func_8094E69C(EnGm* this, PlayState* play) { break; case 8: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); - ActorCutscene_Stop(sp4A); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHAIR_ROLL); + CutsceneManager_Stop(csId); this->unk_3E2 = 0; this->unk_3E0++; break; @@ -637,7 +638,7 @@ s32 func_8094EB1C(EnGm* this, PlayState* play) { ret = true; break; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHAIR_ROLL); func_8094E054(this, play, 2); this->unk_3E2 = 0; this->unk_3E0++; @@ -657,7 +658,7 @@ s32 func_8094EB1C(EnGm* this, PlayState* play) { break; case 2: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHAIR_ROLL); this->unk_3E2 = 0; this->unk_3E0++; @@ -760,13 +761,13 @@ s32 func_8094EE84(EnGm* this, PlayState* play) { s32 func_8094EFC4(EnGm* this, PlayState* play) { s32 ret = false; - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { if (this->unk_3F8 == 0) { if ((play->sceneId == SCENE_MILK_BAR) && (gSaveContext.sceneLayer == 2)) { func_8094E054(this, play, 0); this->unk_258 = 255; } - this->unk_259 = 255; + this->cueId = 255; this->unk_3F8 = 1; } ret = true; @@ -965,7 +966,7 @@ s32 func_8094F53C(EnGm* this, PlayState* play) { if ((this->unk_3E8 == 6) && !(play->actorCtx.flags & ACTORCTX_FLAG_5) && Animation_OnFrame(&this->skelAnime, 20.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); + Actor_PlaySfx(&this->actor, NA_SE_EV_HANKO); } return false; @@ -1427,7 +1428,7 @@ s32 func_80950690(EnGm* this, PlayState* play) { case 7: this->unk_3D0 += 992; if (DECR(this->unk_3B8) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_GO_SLEEP); + Actor_PlaySfx(&this->actor, NA_SE_VO_GO_SLEEP); this->unk_3B8 = 30; } break; @@ -1465,7 +1466,7 @@ s32 func_80950804(EnGm* this, PlayState* play) { Lib_Vec3f_TranslateAndRotateY(&this->unk_278, this->actor.world.rot.y, &sp38, &this->actor.world.pos); this->unk_3BA += this->timePathTimeSpeed; if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_PIRATE_WALK); } } @@ -1521,7 +1522,7 @@ s32 func_8095097C(EnGm* this, PlayState* play) { this->timePathWaypoint = sp50; this->timePathTargetPos = timePathTargetPos; } else if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_PIRATE_WALK); } return false; } @@ -1634,20 +1635,20 @@ void func_80950F2C(EnGm* this, PlayState* play) { s32 pad; Vec3f sp3C; Vec3f sp30; - s32 sp2C; + s32 cueId; s16 yaw; - if (Cutscene_CheckActorAction(play, 526)) { - sp2C = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 526)]->action; - if (this->unk_259 != (sp2C & 0xFF)) { - if (sp2C == 3) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_526)) { + cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_526)]->id; + if (this->cueId != (u8)cueId) { + if (cueId == 3) { + Actor_PlaySfx(&this->actor, NA_SE_EV_CHAIR_ROLL); } - this->unk_259 = sp2C; - func_8094E054(this, play, sp50[sp2C]); + this->cueId = cueId; + func_8094E054(this, play, sp50[cueId]); } - if ((this->unk_259 == 3) && (this->unk_268 != NULL) && (this->unk_268->update != NULL)) { + if ((this->cueId == 3) && (this->unk_268 != NULL) && (this->unk_268->update != NULL)) { Math_Vec3f_Copy(&sp3C, &player->actor.world.pos); Math_Vec3f_Copy(&sp30, &this->actor.world.pos); yaw = Math_Vec3f_Yaw(&sp30, &sp3C); @@ -1714,7 +1715,7 @@ void EnGm_Update(Actor* thisx, PlayState* play) { func_8013C964(&this->actor, play, this->unk_3B4, 30.0f, PLAYER_IA_NONE, this->unk_3A4 & 7); if ((this->unk_258 != 3) && (this->unk_258 != 5) && (this->unk_258 != 8)) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } func_8094E1DC(this, play); } @@ -1763,7 +1764,7 @@ void EnGm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Vec3f sp30; s32 pad2; - if ((ActorCutscene_GetCurrentIndex() == -1) && (limbIndex == 16)) { + if ((CutsceneManager_GetCurrentCsId() == CS_ID_NONE) && (limbIndex == 16)) { Matrix_MultVec3f(&D_80951E24, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.h b/src/overlays/actors/ovl_En_Gm/z_en_gm.h index 3bed5335a..6eede0744 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.h +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.h @@ -26,7 +26,7 @@ typedef struct EnGm { /* 0x250 */ s32 timePathWaypoint; /* 0x254 */ s32 timePathElapsedTime; /* 0x258 */ u8 unk_258; - /* 0x259 */ u8 unk_259; + /* 0x259 */ u8 cueId; /* 0x25C */ s32 unk_25C; /* 0x260 */ s8 unk_260; /* 0x261 */ s8 unk_261; 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 e1250dbc6..3f993ae3a 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -539,7 +539,7 @@ s32 func_80A1222C(EnGo* this, PlayState* play) { (play->msgCtx.lastPlayedSong == OCARINA_SONG_GORON_LULLABY) && (this->unk_3EC == 0) && (this->actor.xzDistToPlayer < 400.0f)) || (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04) && (play->sceneId == SCENE_16GORON_HOUSE) && - (gSaveContext.sceneLayer == 0) && (this->unk_3EC == 0) && (play->csCtx.currentCsIndex == 1))) { + (gSaveContext.sceneLayer == 0) && (this->unk_3EC == 0) && (play->csCtx.scriptIndex == 1))) { ret = true; } return ret; @@ -710,12 +710,12 @@ s32 func_80A12868(EnGo* this, PlayState* play) { } s32 func_80A12954(EnGo* this, PlayState* play) { - if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (play->csCtx.state != 0) && (this->actor.draw != NULL) && + if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (play->csCtx.state != CS_STATE_IDLE) && (this->actor.draw != NULL) && (play->sceneId == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneLayer == 1) && - (play->csCtx.currentCsIndex == 0)) { + (play->csCtx.scriptIndex == 0)) { if (this->unk_3F0 == 0) { this->actor.flags &= ~ACTOR_FLAG_1; - this->unk_394 = 255; + this->cueId = 255; this->unk_3F0 = 1; this->unk_18C = this->actionFunc; } @@ -723,7 +723,7 @@ s32 func_80A12954(EnGo* this, PlayState* play) { this->actionFunc = func_80A14FC8; } else if (this->unk_3F0 != 0) { this->actor.flags |= ACTOR_FLAG_1; - this->unk_394 = 255; + this->cueId = 255; this->unk_3F0 = 0; SubS_UpdateFlags(&this->unk_390, 3, 7); this->actionFunc = this->unk_18C; @@ -756,22 +756,22 @@ s32 func_80A12A64(EnGo* this, PlayState* play) { } s32 func_80A12B78(EnGo* this, PlayState* play) { - if (play->csCtx.state == 0) { + if (play->csCtx.state == CS_STATE_IDLE) { if (this->unk_3DC == 4) { if (Animation_OnFrame(&this->skelAnime, 2.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_CIRCLE); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_CIRCLE); } if (Animation_OnFrame(&this->skelAnime, 22.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SIT_IMT); + Actor_PlaySfx(&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); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_CIRCLE_OFF); } if (Animation_OnFrame(&this->skelAnime, 24.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_STAND_IMT); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_STAND_IMT); } } } @@ -995,14 +995,14 @@ void func_80A134B0(EnGo* this, PlayState* play, s32 arg2) { } } -s32 func_80A134F4(EnGo* this, s16 arg1) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - } else if (ActorCutscene_GetCanPlayNext(arg1)) { - ActorCutscene_StartAndSetUnkLinkFields(arg1, &this->actor); +s32 func_80A134F4(EnGo* this, s16 csId) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + } else if (CutsceneManager_IsNext(csId)) { + CutsceneManager_StartWithPlayerCs(csId, &this->actor); return true; } - ActorCutscene_SetIntentToPlay(arg1); + CutsceneManager_Queue(csId); return false; } @@ -1012,7 +1012,7 @@ s32 func_80A13564(EnGo* this, f32 arg1, f32 arg2, s32 arg3) { f32 temp_f14 = this->actor.velocity.y + this->actor.gravity; s32 ret; - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { ret = true; } else { if (temp_f14 > 0.0f) { @@ -1046,16 +1046,16 @@ s32 func_80A13564(EnGo* this, f32 arg1, f32 arg2, s32 arg3) { return ret; } -void func_80A136B8(PlayState* play, s16 speed, s16 verticalMag, s16 countdown) { - s16 quakeIndex = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); +void EnGo_RequestQuake(PlayState* play, s16 speed, s16 y, s16 duration) { + s16 quakeIndex = Quake_Request(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); - Quake_SetCountdown(quakeIndex, countdown); + Quake_SetDuration(quakeIndex, duration); Quake_SetSpeed(quakeIndex, speed); - Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0); + Quake_SetPerturbations(quakeIndex, y, 0, 0, 0); } void func_80A13728(EnGo* this, PlayState* play) { - func_80A136B8(play, 27767, 7, 20); + EnGo_RequestQuake(play, 27767, 7, 20); play->actorCtx.unk2 = 4; Actor_Spawn(&play->actorCtx, play, ACTOR_EN_TEST, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); @@ -1112,8 +1112,8 @@ s32 func_80A13B1C(EnGo* this, PlayState* play) { switch (this->unk_3C0) { case 0: - this->unk_3B8 = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); - if (func_80A134F4(this, this->unk_3B8)) { + this->csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); + if (func_80A134F4(this, this->csId)) { this->unk_3C4 = 1; this->unk_3C0 = 1; } else { @@ -1121,26 +1121,26 @@ s32 func_80A13B1C(EnGo* this, PlayState* play) { } case 1: - if (ActorCutscene_GetCurrentIndex() != this->unk_3B8) { - this->unk_3B8 = ActorCutscene_GetAdditionalCutscene(this->unk_3B8); + if (CutsceneManager_GetCurrentCsId() != this->csId) { + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); this->unk_3C0 = 2; } else { break; } case 2: - if (func_80A134F4(this, this->unk_3B8)) { + if (func_80A134F4(this, this->csId)) { this->unk_3C0 = 3; } else { break; } case 3: - if (ActorCutscene_GetCanPlayNext(0x7C)) { - ActorCutscene_StartAndSetUnkLinkFields(0x7C, NULL); + if (CutsceneManager_IsNext(CS_ID_GLOBAL_TALK)) { + CutsceneManager_StartWithPlayerCs(CS_ID_GLOBAL_TALK, NULL); this->unk_3C0 = 4; - } else if (ActorCutscene_GetCurrentIndex() == this->unk_3B8) { - ActorCutscene_SetIntentToPlay(0x7C); + } else if (CutsceneManager_GetCurrentCsId() == this->csId) { + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); } } @@ -1165,7 +1165,7 @@ s32 func_80A13B1C(EnGo* this, PlayState* play) { case 3: this->unk_3C2++; if (this->unk_3C2 >= 10) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_JUMP); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_JUMP); this->actor.velocity.y = 10.0f; this->actor.gravity = -1.0f; this->unk_3C4++; @@ -1174,7 +1174,7 @@ s32 func_80A13B1C(EnGo* this, PlayState* play) { case 4: if (func_80A13564(this, 10.0f, 0.004f, 6)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_LAND_BIG); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_LAND_BIG); func_80A13728(this, play); this->unk_3C4++; this->unk_3C2 = 0; @@ -1230,8 +1230,8 @@ s32 func_80A13E80(EnGo* this, PlayState* play) { switch (this->unk_3C0) { case 0: - this->unk_3B8 = this->actor.cutscene; - if (func_80A134F4(this, this->unk_3B8)) { + this->csId = this->actor.csId; + if (func_80A134F4(this, this->csId)) { this->unk_3C0++; } break; @@ -1242,7 +1242,7 @@ s32 func_80A13E80(EnGo* this, PlayState* play) { case 2: if (Animation_OnFrame(&this->skelAnime, 16.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_HAND_HIT); + Actor_PlaySfx(&this->actor, NA_SE_EV_GORON_HAND_HIT); } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -1258,7 +1258,7 @@ s32 func_80A13E80(EnGo* this, PlayState* play) { case 3: if (this->unk_3C2 >= 60) { - ActorCutscene_Stop(this->unk_3B8); + CutsceneManager_Stop(this->csId); this->unk_3C2 = 0; this->unk_3C0 = 0; ret = true; @@ -1376,7 +1376,7 @@ void func_80A143A8(EnGo* this, PlayState* play) { void func_80A14430(EnGo* this, PlayState* play) { if (((gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 0)) || (gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 2))) && - (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80))) { + (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE))) { func_80A14018(this, play); this->actionFunc = func_80A149B0; } else { @@ -1413,7 +1413,7 @@ void func_80A144F4(EnGo* this, PlayState* play) { void func_80A145AC(EnGo* this, PlayState* play) { if ((ENGO_GET_70(&this->actor) == ENGO_70_1) && (((play->sceneId == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneLayer == 1) && - (play->csCtx.currentCsIndex == 0)) || + (play->csCtx.scriptIndex == 0)) || !CHECK_WEEKEVENTREG(WEEKEVENTREG_21_08))) { this->actor.child = func_80A13400(this, play); this->actor.child->child = &this->actor; @@ -1515,7 +1515,7 @@ void func_80A149B0(EnGo* this, PlayState* play) { s16 sp26 = this->actor.world.rot.y; if ((ENGO_GET_F(&this->actor) == ENGO_F_2) && (gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 1))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_CHEER - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EV_GORON_CHEER - SFX_FLAG); } else if (ENGO_GET_F(&this->actor) != ENGO_F_8) { if (func_80A1222C(this, play)) { SubS_UpdateFlags(&this->unk_390, 0, 7); @@ -1582,7 +1582,7 @@ void func_80A14B30(EnGo* this, PlayState* play) { } else { sfxId = NA_SE_EN_GOLON_SNORE2; } - Actor_PlaySfxAtPos(&this->actor, sfxId); + Actor_PlaySfx(&this->actor, sfxId); } this->unk_3AE += 0x400; this->actor.shape.yOffset = (this->actor.scale.y / this->unk_3A4) * 14.0f; @@ -1611,7 +1611,7 @@ void func_80A14E14(EnGo* this, PlayState* play) { } void func_80A14E74(EnGo* this, PlayState* play) { - if (func_80A134F4(this, this->actor.cutscene)) { + if (func_80A134F4(this, this->actor.csId)) { this->actionFunc = func_80A14EB0; } } @@ -1620,12 +1620,12 @@ void func_80A14EB0(EnGo* this, PlayState* play) { 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); + Actor_PlaySfx(&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); + CutsceneManager_Stop(this->actor.csId); func_80A143A8(this, play); if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (ENGO_GET_70(&this->actor) == ENGO_70_1)) { SubS_UpdateFlags(&this->unk_390, 4, 7); @@ -1640,35 +1640,35 @@ void func_80A14FC8(EnGo* this, PlayState* play) { s32 sp38[] = { 0, 2, 6, 20, 18, 5, 5, 15, }; - u16 actorActionCmd = 0; - s32 sp30; - s32 actionIndex; + u16 cueType = 0; + s32 cueId; + s32 cueChannel; switch (ENGO_GET_70(&this->actor)) { case ENGO_70_0: - actorActionCmd = 128; + cueType = CS_CMD_ACTOR_CUE_128; break; case ENGO_70_1: - actorActionCmd = 129; + cueType = CS_CMD_ACTOR_CUE_129; break; } - if ((actorActionCmd == 128) || (actorActionCmd == 129)) { - if (Cutscene_CheckActorAction(play, actorActionCmd)) { - actionIndex = Cutscene_GetActorActionIndex(play, actorActionCmd); - sp30 = play->csCtx.actorActions[actionIndex]->action; + if ((cueType == CS_CMD_ACTOR_CUE_128) || (cueType == CS_CMD_ACTOR_CUE_129)) { + if (Cutscene_IsCueInChannel(play, cueType)) { + cueChannel = Cutscene_GetCueChannel(play, cueType); + cueId = play->csCtx.actorCues[cueChannel]->id; - if (this->unk_394 != (u8)sp30) { - this->unk_394 = sp30; - func_80A12C48(this, play, sp38[sp30]); + if (this->cueId != (u8)cueId) { + this->cueId = cueId; + func_80A12C48(this, play, sp38[cueId]); this->unk_390 = 0; this->unk_390 |= 0x20; this->unk_3BE = 0; this->unk_39C = 0.0f; this->unk_3A0 = 0.0f; - switch (sp30) { + switch (cueId) { case 1: this->unk_390 |= 0x80; this->skelAnime.curFrame = this->skelAnime.endFrame; @@ -1681,7 +1681,7 @@ void func_80A14FC8(EnGo* this, PlayState* play) { } } - switch (this->unk_394) { + switch (this->cueId) { case 3: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (this->unk_3DC == 20)) { func_80A12C48(this, play, 21); @@ -1696,7 +1696,7 @@ void func_80A14FC8(EnGo* this, PlayState* play) { case 6: if ((s32)(this->unk_39C * 3.0f) != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); + Actor_PlaySfx(&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); @@ -1706,53 +1706,53 @@ void func_80A14FC8(EnGo* this, PlayState* play) { break; } - if (actorActionCmd == 128) { - switch (play->csCtx.frames) { + if (cueType == 128) { + switch (play->csCtx.curFrame) { case 55: case 100: case 130: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_COLD); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_COLD); break; case 185: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_WAKE_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_WAKE_UP); break; case 250: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_EYE_BIG); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_EYE_BIG); break; case 465: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IWAIGORON_SOLO); + Actor_PlaySfx(&this->actor, NA_SE_EN_IWAIGORON_SOLO); break; case 490: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_VOICE_EATFULL); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_VOICE_EATFULL); break; } - } else if (actorActionCmd == 129) { - switch (play->csCtx.frames) { + } else if (cueType == 129) { + switch (play->csCtx.curFrame) { case 360: case 390: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_COLD); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_COLD); break; case 430: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_WAKE_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_WAKE_UP); break; case 450: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_EYE_BIG); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_EYE_BIG); break; case 480: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_VOICE_EATFULL); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_VOICE_EATFULL); break; } } SubS_FillLimbRotTables(play, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } } } @@ -1763,16 +1763,16 @@ void func_80A153FC(EnGo* this, PlayState* play) { Vec3f sp44; if ((this->unk_390 & 0x1000) && (this->actor.colChkInfo.damageEffect == 0xF)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SNOWBALL_BROKEN); + Actor_PlaySfx(&this->actor, NA_SE_EV_SNOWBALL_BROKEN); this->actor.flags &= ~ACTOR_FLAG_10; this->actor.flags |= ACTOR_FLAG_2000000; func_80A118F8(this->unk_3F8, this->actor.world.pos); this->actor.shape.rot.x = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_COLD); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_COLD); if (gSaveContext.save.day == 3) { func_80A141D4(this, play); @@ -1783,7 +1783,7 @@ void func_80A153FC(EnGo* this, PlayState* play) { } } else if (this->unk_284 != NULL) { if (this->unk_390 & 0x800) { - func_800B8E58(GET_PLAYER(play), NA_SE_PL_BODY_HIT); + Player_PlaySfx(GET_PLAYER(play), NA_SE_PL_BODY_HIT); func_800B8D50(play, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); } @@ -1801,16 +1801,16 @@ void func_80A153FC(EnGo* this, PlayState* play) { 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); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + Actor_PlaySfx(&this->actor, NA_SE_EV_BIGBALL_ROLL - SFX_FLAG); func_800AE930(&play->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); + this->actor.speed = 4.0f; + this->actor.shape.rot.x += (s16)(this->actor.speed * 546.0f); Actor_MoveWithGravity(&this->actor); } } @@ -1937,7 +1937,7 @@ void EnGo_Update(Actor* thisx, PlayState* play) { 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(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } func_80A122EC(this); 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 fd4876430..9d12dfdce 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.h +++ b/src/overlays/actors/ovl_En_Go/z_en_go.h @@ -67,7 +67,7 @@ typedef struct EnGo { /* 0x38C */ Actor* unk_38C; /* 0x390 */ u16 unk_390; /* 0x392 */ u16 unk_392; - /* 0x394 */ u8 unk_394; + /* 0x394 */ u8 cueId; /* 0x398 */ f32 unk_398; /* 0x39C */ f32 unk_39C; /* 0x3A0 */ f32 unk_3A0; @@ -79,7 +79,7 @@ typedef struct EnGo { /* 0x3B2 */ s16 unk_3B2; /* 0x3B4 */ s16 unk_3B4; /* 0x3B6 */ s16 unk_3B6; - /* 0x3B8 */ s16 unk_3B8; + /* 0x3B8 */ s16 csId; /* 0x3BA */ s16 unk_3BA; /* 0x3BC */ s16 unk_3BC; /* 0x3BE */ s16 unk_3BE; 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 98d27f735..c947d3334 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -358,7 +358,7 @@ s32 func_8093F34C(EnGoroiwa* this) { f32 x; f32 z; - Math_StepToF(&this->actor.speedXZ, D_80942DFC[this->unk_1E4], 0.3f); + Math_StepToF(&this->actor.speed, D_80942DFC[this->unk_1E4], 0.3f); Actor_UpdateVelocityWithGravity(&this->actor); temp_v0 = &this->unk_1D0[this->unk_1D8]; this->actor.velocity.y *= 0.97f; @@ -368,7 +368,7 @@ s32 func_8093F34C(EnGoroiwa* this) { tempX = x - this->actor.world.pos.x; tempZ = z - this->actor.world.pos.z; - if (SQ(this->actor.speedXZ + 1.0f) < (SQ(tempX) + SQ(tempZ))) { + if (SQ(this->actor.speed + 1.0f) < (SQ(tempX) + SQ(tempZ))) { this->actor.world.pos.x += this->actor.velocity.x; this->actor.world.pos.y += this->actor.velocity.y; this->actor.world.pos.z += this->actor.velocity.z; @@ -393,12 +393,12 @@ s32 func_8093F498(EnGoroiwa* this) { sp2C.y = temp_v0->y; sp2C.z = temp_v0->z; - Math_StepToF(&this->actor.speedXZ, D_80942DFC[this->unk_1E4], 0.3f); + Math_StepToF(&this->actor.speed, D_80942DFC[this->unk_1E4], 0.3f); Math_Vec3f_Diff(&sp2C, &this->actor.world.pos, &this->actor.velocity); temp_f0 = Math3D_Vec3fMagnitude(&this->actor.velocity); - if ((this->actor.speedXZ + 1.0f) < temp_f0) { - Math_Vec3f_Scale(&this->actor.velocity, this->actor.speedXZ / temp_f0); + if ((this->actor.speed + 1.0f) < temp_f0) { + Math_Vec3f_Scale(&this->actor.velocity, this->actor.speed / temp_f0); this->actor.world.pos.x += this->actor.velocity.x; this->actor.world.pos.y += this->actor.velocity.y; this->actor.world.pos.z += this->actor.velocity.z; @@ -451,11 +451,11 @@ s32 func_8093F6F8(EnGoroiwa* this, PlayState* play) { if ((this->actor.velocity.y < 0.0f) && (this->actor.world.pos.y <= sp7C)) { if (this->unk_1CA == 0) { if (this->actor.xzDistToPlayer < 400.0f) { - s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 17232); - Quake_SetQuakeValues(quakeIndex, 3, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 7); + Quake_SetPerturbations(quakeIndex, 3, 0, 0, 0); + Quake_SetDuration(quakeIndex, 7); } this->unk_1C4 = 0.0f; @@ -483,7 +483,7 @@ s32 func_8093F6F8(EnGoroiwa* this, PlayState* play) { func_8093EF54(play, &sp48, &D_80942E30[ENGOROIWA_GET_C000(&this->actor)], &D_80942E3C[ENGOROIWA_GET_C000(&this->actor)], this->actor.scale.x); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BIGBALL_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EV_BIGBALL_BOUND); } } } @@ -894,7 +894,7 @@ void func_80940E38(EnGoroiwa* this, PlayState* play) { if (this->actor.flags & ACTOR_FLAG_40) { if (this->actor.xzDistToPlayer < 1000.0f) { - sp5C = (1000.0f - this->actor.xzDistToPlayer) * 0.0012f * (this->actor.speedXZ * 0.1f); + sp5C = (1000.0f - this->actor.xzDistToPlayer) * 0.0012f * (this->actor.speed * 0.1f); if (Rand_ZeroOne() < sp5C) { this->unk_1CE += 20000; sp46 = (s32)Rand_ZeroFloat(20000.0f) + this->unk_1CE; @@ -1049,7 +1049,7 @@ s32 func_8094156C(EnGoroiwa* this, PlayState* play) { temp2 = Math_SinS(ptr->unk_1E); temp3 = Math_SinS(this->actor.world.rot.y); - ptr->unk_0C = ((1.0f / D_80942DFC[this->unk_1E4]) * (temp3 * 14.0f * this->actor.speedXZ)) + + ptr->unk_0C = ((1.0f / D_80942DFC[this->unk_1E4]) * (temp3 * 14.0f * this->actor.speed)) + (temp2 * (temp + 5.0f)); ptr->unk_10 = (Rand_ZeroOne() * 11.0f) + 20.0f; @@ -1057,7 +1057,7 @@ s32 func_8094156C(EnGoroiwa* this, PlayState* play) { temp = Rand_ZeroOne(); temp2 = Math_CosS(ptr->unk_1E); temp3 = Math_CosS(this->actor.world.rot.y); - ptr->unk_14 = ((1.0f / D_80942DFC[this->unk_1E4]) * ((temp3 * 14.0f) * this->actor.speedXZ)) + + ptr->unk_14 = ((1.0f / D_80942DFC[this->unk_1E4]) * ((temp3 * 14.0f) * this->actor.speed)) + (temp2 * (temp + 5.0f)); ptr->unk_1C = 0; @@ -1168,7 +1168,7 @@ void func_80941A10(EnGoroiwa* this, PlayState* play) { func_80941DB4(this); } - func_800B8E58(player, NA_SE_PL_BODY_HIT); + Player_PlaySfx(player, NA_SE_PL_BODY_HIT); if ((sp34 == 1) || (sp34 == 2)) { this->unk_1CC = 50; @@ -1207,8 +1207,8 @@ void func_80941A10(EnGoroiwa* this, PlayState* play) { } } - if (this->actor.bgCheckFlags & 1) { - Actor_PlaySfxAtPos(&this->actor, D_80942E9C[this->unk_1E4][this->actor.home.rot.x & 1]); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + Actor_PlaySfx(&this->actor, D_80942E9C[this->unk_1E4][this->actor.home.rot.x & 1]); } } } @@ -1218,14 +1218,14 @@ void func_80941DB4(EnGoroiwa* this) { func_8093EAB0(this, 6); this->actor.gravity = -0.86f; this->actor.terminalVelocity = -15.0f; - this->actor.speedXZ *= 0.15f; + this->actor.speed *= 0.15f; this->actor.velocity.y = 5.0f; this->unk_1C4 = 1.0f; } void func_80941E28(EnGoroiwa* this, PlayState* play) { func_8093F34C(this); - if ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.velocity.y < 0.0f)) { if ((this->unk_1E5 & 8) && ((this->actor.home.rot.z & 3) == 1)) { func_8093EDB0(this); } @@ -1237,7 +1237,7 @@ void func_80941EB4(EnGoroiwa* this) { static s16 D_80942EAC[] = { 20, 6, 20 }; this->actionFunc = func_80941F10; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; func_8093EAB0(this, 6); this->unk_1C8 = D_80942EAC[this->actor.home.rot.z & 3]; this->unk_1C4 = 0.0f; @@ -1257,7 +1257,7 @@ void func_80941F54(EnGoroiwa* this) { this->actionFunc = func_80941FA4; func_8093EAB0(this, 7); this->unk_1C4 = 0.0f; - this->actor.velocity.y = fabsf(this->actor.speedXZ) * 0.1f; + this->actor.velocity.y = fabsf(this->actor.speed) * 0.1f; } void func_80941FA4(EnGoroiwa* this, PlayState* play) { @@ -1266,14 +1266,14 @@ void func_80941FA4(EnGoroiwa* this, PlayState* play) { if (func_8094156C(this, play) == 0) { if ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & PLAYER_STATE3_80000)) { func_800B8D50(play, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); - func_800B8E58(player, NA_SE_PL_BODY_HIT); + Player_PlaySfx(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; } } else if (func_8093F5EC(this)) { func_8093FC00(this); func_809419D0(this); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } } } @@ -1283,7 +1283,7 @@ void func_80942084(EnGoroiwa* this) { func_8093EAB0(this, 7); this->unk_1C4 = 0.3f; this->unk_1CA = 0; - this->actor.velocity.y = fabsf(this->actor.speedXZ) * -0.3f; + this->actor.velocity.y = fabsf(this->actor.speed) * -0.3f; this->unk_1E5 |= 0x10; this->unk_1E5 &= ~0x20; } @@ -1294,7 +1294,7 @@ void func_809420F0(EnGoroiwa* this, PlayState* play) { if (func_8094156C(this, play) == 0) { if ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & PLAYER_STATE3_80000)) { func_800B8D50(play, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); - func_800B8E58(player, NA_SE_PL_BODY_HIT); + Player_PlaySfx(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; } @@ -1302,7 +1302,7 @@ void func_809420F0(EnGoroiwa* this, PlayState* play) { func_8093FC00(this); func_809419D0(this); this->unk_1E5 &= ~0x10; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } } } @@ -1431,7 +1431,7 @@ void EnGoroiwa_Update(Actor* thisx, PlayState* play) { Vec3f sp50; f32 sp4C; s32 sp48 = true; - u32 temp_v0_2; + FloorType floorType; CollisionPoly* tmp; if (!(player->stateFlags1 & @@ -1440,8 +1440,8 @@ void EnGoroiwa_Update(Actor* thisx, PlayState* play) { this->unk_1CC--; } - if ((ENGOROIWA_GET_3000(&this->actor) == ENGOROIWA_3000_2) && (this->actor.bgCheckFlags & 1) && - (this->actionFunc == func_80941A10) && (this->actor.speedXZ > 2.0f)) { + if ((ENGOROIWA_GET_3000(&this->actor) == ENGOROIWA_3000_2) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + (this->actionFunc == func_80941A10) && (this->actor.speed > 2.0f)) { Math_StepToF(&this->actor.scale.x, 0.16f, (this->actor.xzDistToPlayer < 400.0f) ? this->unk_1E0 * 1.4f : this->unk_1E0); @@ -1453,9 +1453,9 @@ void EnGoroiwa_Update(Actor* thisx, PlayState* play) { if (this->actor.flags & ACTOR_FLAG_40) { tmp = this->actor.floorPoly; if (tmp != NULL) { - temp_v0_2 = func_800C99D4(&play->colCtx, tmp, this->actor.floorBgId); + floorType = SurfaceType_GetFloorType(&play->colCtx, tmp, this->actor.floorBgId); - if ((temp_v0_2 == 14) || (temp_v0_2 == 15)) { + if ((floorType == FLOOR_TYPE_14) || (floorType == FLOOR_TYPE_15)) { if (!(this->unk_1E5 & 0x40)) { sp50.x = this->actor.world.pos.x; sp50.y = this->actor.floorHeight; @@ -1485,7 +1485,8 @@ void EnGoroiwa_Update(Actor* thisx, PlayState* play) { switch (ENGOROIWA_GET_400(&this->actor)) { case ENGOROIWA_400_1: - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 0x1C); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, + UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); break; case ENGOROIWA_400_0: @@ -1497,12 +1498,12 @@ void EnGoroiwa_Update(Actor* thisx, PlayState* play) { if (this->actor.floorHeight > BGCHECK_Y_MIN) { this->actor.floorBgId = bgId; if (this->actor.world.pos.y <= (this->actor.floorHeight + 2.0f)) { - this->actor.bgCheckFlags |= 1; + this->actor.bgCheckFlags |= BGCHECKFLAG_GROUND; } else { - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; } } else { - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->actor.floorBgId = 50; } break; diff --git a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c index eb7948ffb..2bd6fec69 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c @@ -354,7 +354,7 @@ void EnGrasshopper_Fly(EnGrasshopper* this, PlayState* play) { f32 targetSpeed; Vec3f collisionCheckPos; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); diffX = this->flyingHomePos.x - this->actor.world.pos.x; diffZ = this->flyingHomePos.z - this->actor.world.pos.z; if ((this->type != EN_GRASSHOPPER_TYPE_WOODFALL_TEMPLE_FINAL_ROOM) && @@ -397,11 +397,11 @@ void EnGrasshopper_Fly(EnGrasshopper* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.z, this->targetRot.z, 5, 0x3E8, 5); this->targetRot.z *= 0.8f; if (this->waitTimer != 0) { - Math_ApproachZeroF(&this->actor.speedXZ, 0.2f, 0.5f); + Math_ApproachZeroF(&this->actor.speed, 0.2f, 0.5f); } else { this->targetRot.z = (this->actor.world.rot.y - this->targetRot.y) * 0.2f; targetSpeed = (this->index * 0.1f) + 4.0f; - Math_ApproachF(&this->actor.speedXZ, targetSpeed, 0.4f, 0.7f); + Math_ApproachF(&this->actor.speed, targetSpeed, 0.4f, 0.7f); Math_ApproachF(&this->rotationalVelocity, 2000.0f, 1.0f, 50.0f); Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRot.y, 5, this->rotationalVelocity, 5); if (this->timer == 0) { @@ -430,7 +430,7 @@ void EnGrasshopper_RoamInCircles(EnGrasshopper* this, PlayState* play) { Vec3f collisionCheckPos; Player* player = GET_PLAYER(play); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); if (Player_GetMask(play) == PLAYER_MASK_STONE) { EnGrasshopper_SetupFly(this); } else { @@ -450,7 +450,8 @@ void EnGrasshopper_RoamInCircles(EnGrasshopper* this, PlayState* play) { collisionCheckPos.y = this->actor.world.pos.y; collisionCheckPos.z = (Math_CosS(this->actor.shape.rot.y) * 100.0f) + this->actor.world.pos.z; - if ((this->actor.bgCheckFlags & 8) || BgCheck_SphVsFirstPoly(&play->colCtx, &collisionCheckPos, 10.0f)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || + BgCheck_SphVsFirstPoly(&play->colCtx, &collisionCheckPos, 10.0f)) { EnGrasshopper_SetupBank(this); } else if (player->stateFlags1 & PLAYER_STATE1_8000000) { this->collider.elements[0].info.toucherFlags |= (TOUCH_ON | TOUCH_SFX_WOOD); @@ -464,7 +465,7 @@ void EnGrasshopper_RoamInCircles(EnGrasshopper* this, PlayState* play) { rotationSpeed = this->index + 70; targetSpeed = (this->index * 0.05f) + 4.0f; this->targetRot.y = Math_Atan2S(diffX, diffZ); - Math_ApproachF(&this->actor.speedXZ, targetSpeed, 0.4f, 0.8f); + Math_ApproachF(&this->actor.speed, targetSpeed, 0.4f, 0.8f); Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRot.y, rotationSpeed, 0xFA0, 0xA); } } @@ -474,11 +475,11 @@ void EnGrasshopper_RoamInCircles(EnGrasshopper* this, PlayState* play) { * Unused in the final game. */ void EnGrasshopper_SetupBank(EnGrasshopper* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); this->targetBankRot.y = this->actor.world.rot.y + 0x8000; this->action = EN_GRASSHOPPER_ACTION_BANK; this->bankState = EN_GRASSHOPPER_BANK_STATE_BANKING; - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; this->actionFunc = EnGrasshopper_Bank; } @@ -487,7 +488,7 @@ void EnGrasshopper_SetupBank(EnGrasshopper* this) { * it flies forward for 100 frames. */ void EnGrasshopper_Bank(EnGrasshopper* this, PlayState* play) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); switch (this->bankState) { case EN_GRASSHOPPER_BANK_STATE_BANKING: Math_SmoothStepToS(&this->actor.world.rot.y, this->targetBankRot.y, 0x64, 0x3E8, 0x3E8); @@ -529,9 +530,9 @@ void EnGrasshopper_SetupBounced(EnGrasshopper* this) { void EnGrasshopper_Bounced(EnGrasshopper* this, PlayState* play) { f32 targetSpeed; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); targetSpeed = (this->index * 0.05f) + 7.0f; - Math_ApproachF(&this->actor.speedXZ, targetSpeed, 0.4f, 0.8f); + Math_ApproachF(&this->actor.speed, targetSpeed, 0.4f, 0.8f); Math_SmoothStepToS(&this->actor.world.rot.z, this->targetRot.z, 5, 0x3E8, 5); this->targetRot.z *= 0.8f; Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRot.y, 5, this->rotationalVelocity, 5); @@ -564,7 +565,7 @@ void EnGrasshopper_ApproachPlayer(EnGrasshopper* this, PlayState* play) { WaterBox* waterBox; Vec3f splashPos; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); this->bobPhase += 0xAF0; this->targetApproachPos.y = (Math_SinS(this->bobPhase) * 10.0f) + (player->actor.world.pos.y + 120.0f); @@ -603,11 +604,11 @@ void EnGrasshopper_SetupAttack(EnGrasshopper* this) { EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_ATTACK); this->approachSpeed = 0.0f; Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, 0xFA0, 0xA); - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; this->baseFlyHeight = this->actor.world.pos.y; this->collider.elements[0].info.toucherFlags &= ~(TOUCH_ON | TOUCH_SFX_WOOD); this->collider.elements[1].info.toucherFlags |= (TOUCH_ON | TOUCH_SFX_WOOD); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_BATTA_ATTACK); this->action = EN_GRASSHOPPER_ACTION_ATTACK; this->actionFunc = EnGrasshopper_Attack; } @@ -675,7 +676,7 @@ void EnGrasshopper_SetupWaitAfterAttack(EnGrasshopper* this) { Math_ApproachF(&this->actor.world.pos.y, this->targetPosY, 0.1f, 10.0f); this->action = EN_GRASSHOPPER_ACTION_WAIT_AFTER_ATTACK; this->waitTimer = 20; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->collider.elements[1].info.toucherFlags &= ~(TOUCH_ON | TOUCH_SFX_WOOD); this->actionFunc = EnGrasshopper_WaitAfterAttack; } @@ -697,7 +698,7 @@ void EnGrasshopper_SetupDamaged(EnGrasshopper* this, PlayState* play) { Vec3f damagedVelocity; EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_DAMAGE); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.flags |= ACTOR_FLAG_1; this->approachSpeed = 0.0f; this->collider.elements[1].info.toucherFlags &= ~(TOUCH_ON | TOUCH_SFX_WOOD); @@ -712,7 +713,7 @@ void EnGrasshopper_SetupDamaged(EnGrasshopper* this, PlayState* play) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); this->action = EN_GRASSHOPPER_ACTION_DAMAGED; this->actionFunc = EnGrasshopper_Damaged; } @@ -726,8 +727,8 @@ void EnGrasshopper_Damaged(EnGrasshopper* this, PlayState* play) { void EnGrasshopper_SetupDead(EnGrasshopper* this, PlayState* play) { EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_DEAD); - this->actor.flags |= ACTOR_FLAG_8000000; - this->actor.speedXZ = 0.0f; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; + this->actor.speed = 0.0f; this->approachSpeed = 0.0f; this->actor.velocity.y = 5.0f; this->actor.gravity = -0.5f; @@ -737,9 +738,9 @@ void EnGrasshopper_SetupDead(EnGrasshopper* this, PlayState* play) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 25); Enemy_StartFinishingBlow(play, &this->actor); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_BATTA_DEAD); this->action = EN_GRASSHOPPER_ACTION_DEAD; this->actionFunc = EnGrasshopper_Dead; } @@ -768,7 +769,7 @@ void EnGrasshopper_Dead(EnGrasshopper* this, PlayState* play) { void EnGrasshopper_SetupFall(EnGrasshopper* this) { EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_FALL); this->action = EN_GRASSHOPPER_ACTION_FALL; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->approachSpeed = 0.0f; this->actionFunc = EnGrasshopper_Fall; } @@ -874,7 +875,7 @@ void EnGrasshopper_UpdateDamage(EnGrasshopper* this, PlayState* play) { return; } } else if (this->actor.colChkInfo.damageEffect == EN_GRASSHOPPER_DMGEFF_LIGHT_ORB) { - Actor_SetColorFilter(&this->actor, 0x8000, 255, 0, 25); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_GRAY, 255, COLORFILTER_BUFFLAG_OPA, 25); this->drawDmgEffTimer = 20; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.focus.pos.x, this->actor.focus.pos.y, @@ -887,7 +888,7 @@ void EnGrasshopper_UpdateDamage(EnGrasshopper* this, PlayState* play) { if (attackDealsDamage) { Actor_ApplyDamage(&this->actor); if (this->actor.colChkInfo.health > 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_BATTA_DAMAGE); EnGrasshopper_SetupDamaged(this, play); } else { EnGrasshopper_SetupDead(this, play); @@ -919,7 +920,9 @@ void EnGrasshopper_Update(Actor* thisx, PlayState* play) { Math_ApproachZeroF(&this->damagedVelocity.y, 1.0f, 2.0f); Math_ApproachZeroF(&this->damagedVelocity.z, 1.0f, 2.0f); if ((this->action != EN_GRASSHOPPER_ACTION_FALL) && (this->type != EN_GRASSHOPPER_TYPE_WOODFALL)) { - Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 60.0f, 60.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 60.0f, 60.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } this->actor.shape.rot.z = this->actor.world.rot.z; diff --git a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h index 8056253f6..11ed8a130 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h @@ -6,6 +6,8 @@ #define EN_GRASSHOPPER_GET_TYPE(thisx) ((thisx)->params) +#define EN_GRASSHOPPER_PARAMS(type) (type) + struct EnGrasshopper; typedef void (*EnGrasshopperActionFunc)(struct EnGrasshopper*, PlayState*); 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 93d7e3f88..6d8e64931 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -112,7 +112,7 @@ s8 func_80997A90(s16 arg0, s16 arg1) { if ((arg0 == 0) || ((arg0 != 1) && (arg0 != 2) && (arg0 == 3))) { phi_v1 = 0; } else { - phi_v1 = (gSaveContext.save.unk_EC4 >> (arg1 * 3)) & 7; + phi_v1 = (gSaveContext.save.saveInfo.unk_EA0 >> (arg1 * 3)) & 7; } return phi_v1; } @@ -156,7 +156,7 @@ void EnGs_Init(Actor* thisx, PlayState* play) { this->unk_1F4 = this->unk_1FA; Math_Vec3f_Copy(&this->unk_1B0[0], &gOneVec3f); Math_Vec3f_Copy(&this->unk_1B0[1], &gOneVec3f); - SubS_FillCutscenesList(&this->actor, this->unk_212, ARRAY_COUNT(this->unk_212)); + SubS_FillCutscenesList(&this->actor, this->csIdList, ARRAY_COUNT(this->csIdList)); func_801A5080(0); if (this->actor.params == ENGS_1) { Actor_SetScale(&this->actor, 0.15f); @@ -170,7 +170,7 @@ void EnGs_Destroy(Actor* thisx, PlayState* play) { EnGs* this = THIS; Collider_DestroyCylinder(play, &this->collider); - func_80165690(); + Play_DisableMotionBlur(); } void func_80997D14(EnGs* this, PlayState* play) { @@ -249,7 +249,7 @@ void func_80997E4C(EnGs* this, PlayState* play) { this->unk_210 = this->unk_195 + 0x20F7; break; } - func_80151938(play, this->unk_210); + Message_ContinueTextbox(play, this->unk_210); break; default: @@ -262,7 +262,8 @@ void func_80997E4C(EnGs* this, PlayState* play) { } void func_80997FF0(EnGs* this, PlayState* play) { - if (SubS_StartActorCutscene(&this->actor, play->playerActorCsIds[0], -1, SUBS_CUTSCENE_NORMAL)) { + if (SubS_StartCutscene(&this->actor, play->playerCsIds[PLAYER_CS_ID_ITEM_OCARINA], CS_ID_NONE, + SUBS_CUTSCENE_NORMAL)) { func_80998040(this, play); } } @@ -281,7 +282,7 @@ void func_8099807C(EnGs* this, PlayState* play) { if (!Flags_GetSwitch(play, this->unk_196)) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, 2); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); + Actor_PlaySfx(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); Flags_SetSwitch(play, this->unk_196); } break; @@ -290,7 +291,7 @@ void func_8099807C(EnGs* this, PlayState* play) { if (!Flags_GetSwitch(play, this->unk_196)) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, 7); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); + Actor_PlaySfx(&this->actor, NA_SE_EV_BUTTERFRY_TO_FAIRY); Flags_SetSwitch(play, this->unk_196); } break; @@ -338,8 +339,8 @@ void func_8099807C(EnGs* this, PlayState* play) { } void func_80998300(EnGs* this, PlayState* play) { - if (this->actor.cutscene != -1) { - ActorCutscene_Stop(play->playerActorCsIds[0]); + if (this->actor.csId != CS_ID_NONE) { + CutsceneManager_Stop(play->playerCsIds[PLAYER_CS_ID_ITEM_OCARINA]); } } @@ -349,8 +350,8 @@ f32 func_80998334(EnGs* this, PlayState* play, f32* arg2, f32* arg3, s16* arg4, if (arg9 == 0) { sp2C = Math_SmoothStepToF(arg2, *arg3, arg5, arg6, arg7); - this->unk_1B0[0].x = (sinf(DEGF_TO_RADF((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2) + 1.0f; - this->unk_1B0[0].y = 1.0f - (sinf(DEGF_TO_RADF((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2); + this->unk_1B0[0].x = (sinf(DEG_TO_RAD((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2) + 1.0f; + this->unk_1B0[0].y = 1.0f - (sinf(DEG_TO_RAD((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2); (*arg4)++; } return sp2C; @@ -372,7 +373,7 @@ void func_809984F4(EnGs* this, PlayState* play) { } } while (gossipStone != NULL); - func_800B7298(play, &this->actor, PLAYER_CSMODE_7); + func_800B7298(play, &this->actor, PLAYER_CSMODE_WAIT); this->actionFunc = func_809985B8; } @@ -380,7 +381,7 @@ void func_809985B8(EnGs* this, PlayState* play) { EnGs* gossipStone; Vec3f sp38; - if (SubS_StartActorCutscene(&this->actor, this->unk_212[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + if (SubS_StartCutscene(&this->actor, this->csIdList[0], CS_ID_NONE, SUBS_CUTSCENE_WITH_PLAYER)) { Player* player = GET_PLAYER(play); Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); @@ -388,8 +389,8 @@ void func_809985B8(EnGs* this, PlayState* play) { Math_Vec3f_Sum(&player->actor.world.pos, &sp38, &player->actor.world.pos); Math_Vec3f_Copy(&player->actor.prevPos, &player->actor.world.pos); this->unk_200 = 0.0f; - gSaveContext.save.unk_EC4 = ((u32)gSaveContext.save.unk_EC4 & ~(7 << (this->unk_198 * 3))) | - ((this->unk_194 & 7) << (this->unk_198 * 3)); + gSaveContext.save.saveInfo.unk_EA0 = ((u32)gSaveContext.save.saveInfo.unk_EA0 & ~(7 << (this->unk_198 * 3))) | + ((this->unk_194 & 7) << (this->unk_198 * 3)); gossipStone = NULL; do { @@ -411,7 +412,7 @@ void func_809985B8(EnGs* this, PlayState* play) { void func_80998704(EnGs* this, PlayState* play) { this->unk_19D = 0; this->unk_19A &= ~(0x100 | 0x4); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_G_STONE_CHANGE_COLOR); + Actor_PlaySfx(&this->actor, NA_SE_EV_G_STONE_CHANGE_COLOR); this->actionFunc = func_8099874C; } @@ -446,11 +447,11 @@ void func_8099874C(EnGs* this, PlayState* play) { if ((this->unk_19C == 5) && (this->unk_194 != 0)) { s32 i; - ActorCutscene_Stop(this->unk_212[0]); + CutsceneManager_Stop(this->csIdList[0]); phi_v0 = 1; for (i = 0; i < 4; i++) { - if (((gSaveContext.save.unk_EC4 >> (i * 3)) & 7) != (u32)this->unk_194) { + if (((gSaveContext.save.saveInfo.unk_EA0 >> (i * 3)) & 7) != (u32)this->unk_194) { phi_v0 = 0; } } @@ -500,7 +501,7 @@ void func_8099874C(EnGs* this, PlayState* play) { } void func_809989B4(EnGs* this, PlayState* play) { - Actor_PickUp(&this->actor, play, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_OfferGetItem(&this->actor, play, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809989F4; } @@ -509,7 +510,7 @@ void func_809989F4(EnGs* this, PlayState* play) { this->actor.parent = NULL; func_80997D14(this, play); } else { - Actor_PickUp(&this->actor, play, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_OfferGetItem(&this->actor, play, this->unk_20C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } @@ -518,12 +519,12 @@ s32 func_80998A48(EnGs* this, PlayState* play) { if (this->unk_19D == 0) { this->unk_216 = 200; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_1D4 = 0; this->unk_19A |= 1; - this->unk_21C = 5; - this->unk_21E = 40; + this->quakeY = 5; + this->quakeDuration = 40; this->unk_197++; this->unk_197 &= 0xF; this->unk_19D = 1; @@ -536,7 +537,7 @@ s32 func_80998A48(EnGs* this, PlayState* play) { if ((this->actor.params != ENGS_0) && !Play_InCsMode(play) && (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { this->unk_216 = 0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIVE_LUPY_COUNT); + Actor_PlaySfx(&this->actor, NA_SE_EV_FAIVE_LUPY_COUNT); Message_StartTextbox(play, 0x20D2, NULL); } this->unk_19A &= ~1; @@ -551,19 +552,19 @@ s32 func_80998BBC(EnGs* this, PlayState* play) { if (this->unk_19D == 0) { this->unk_216 = 200; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_1DC = 0.3f; this->unk_1E0 = 0.0f; this->unk_1D4 = 0; this->unk_19A |= 1; - this->unk_21C = 5; - this->unk_21E = 40; + this->quakeY = 5; + this->quakeDuration = 40; this->unk_197--; this->unk_197 &= 0xF; this->unk_19D = 1; } else if (this->unk_19D == 1) { - this->unk_19E[0].z = (this->unk_1D4 % 8) * 0.125f * 360.0f * (0x10000 / 360.0f); + this->unk_19E[0].z = DEG_TO_BINANG((this->unk_1D4 % 8) * 0.125f * 360.0f); this->unk_19E[1].z = -this->unk_19E[0].z; if (func_80998334(this, play, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, 0.8f, 0.005f, 0.001f, 7, 0) == 0.0f) { @@ -582,10 +583,10 @@ s32 func_80998D44(EnGs* this, PlayState* play) { this->unk_216 = 200; this->unk_1DC = this->unk_1B0[0].y - 1.0f; this->unk_1E0 = -0.8f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_G_STONE_CRUSH); + Actor_PlaySfx(&this->actor, NA_SE_EV_G_STONE_CRUSH); this->unk_19A |= 1; - this->unk_21C = 40; - this->unk_21E = 11; + this->quakeY = 40; + this->quakeDuration = 11; this->unk_19D++; } else if (this->unk_19D == 1) { step = Math_SmoothStepToF(&this->unk_1DC, this->unk_1E0, 1.0f, 0.4f, 0.001f); @@ -610,10 +611,10 @@ s32 func_80998D44(EnGs* this, PlayState* play) { this->unk_216 = 0; this->unk_1E0 = 0.0f; this->unk_1D4 = 0; - this->unk_21C = 10; - this->unk_21E = 10; + this->quakeY = 10; + this->quakeDuration = 10; this->unk_1DC = 0.5f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_19D += 1; } } else if ((this->unk_19D == 4) && (func_80998334(this, play, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, 1.0f, @@ -640,15 +641,15 @@ s32 func_80998F9C(EnGs* this, PlayState* play) { this->unk_1EC = 0.0f; this->unk_19D = 1; - this->unk_21C = 2; - this->unk_21E = 40; + this->quakeY = 2; + this->quakeDuration = 40; this->unk_216 = 200; } if (this->unk_19D == 1) { Math_SmoothStepToF(&this->unk_1E4, this->unk_1E8, 1.0f, 0.1f, 0.001f); sp48 = Math_SmoothStepToF(&this->unk_1DC, this->unk_1E0, 1.0f, this->unk_1E4, 0.001f); - this->unk_19E[0].y += (s32)(this->unk_1DC * (0x10000 / 360.0f)); + this->unk_19E[0].y += (s32)DEG_TO_BINANG_ALT3(this->unk_1DC); if (sp48 == 0.0f) { this->unk_1D4 = 0; this->unk_19D = 2; @@ -656,13 +657,13 @@ s32 func_80998F9C(EnGs* this, PlayState* play) { } if (this->unk_19D == 2) { - this->unk_19E[0].y += (s32)(this->unk_1DC * (0x10000 / 360.0f)); + this->unk_19E[0].y += (s32)DEG_TO_BINANG_ALT3(this->unk_1DC); if (this->unk_1D4++ > 40) { this->unk_1DC = this->unk_1B0[0].y - 1.0f; this->unk_1E0 = 1.5f; this->unk_1E4 = this->unk_1B0[1].y - 1.0f; this->unk_1E8 = -0.3f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_STONE_GROW_UP); + Actor_PlaySfx(&this->actor, NA_SE_EV_STONE_GROW_UP); this->unk_19D = 3; } } @@ -712,9 +713,9 @@ s32 func_80998F9C(EnGs* this, PlayState* play) { this->unk_1E8 = 0.0f; this->unk_1F0 = 0.0f; this->unk_1EC = 0.5f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); - this->unk_21C = 20; - this->unk_21E = 2; + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_ATTACK); + this->quakeY = 20; + this->quakeDuration = 2; this->unk_19D = 6; } } @@ -725,8 +726,8 @@ s32 func_80998F9C(EnGs* this, PlayState* play) { sp40 = Math_SmoothStepToF(&this->unk_1EC, this->unk_1F0, 0.8f, 0.02f, 0.001f); this->unk_1B0[0].x = this->unk_1E4 + 1.0f; this->unk_1B0[0].y = this->unk_1DC + 1.0f; - this->unk_1B0[0].x += sinf(DEGF_TO_RADF((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; - this->unk_1B0[0].y += sinf(DEGF_TO_RADF((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; + this->unk_1B0[0].x += sinf(DEG_TO_RAD((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; + this->unk_1B0[0].y += sinf(DEG_TO_RAD((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; this->unk_1D4++; if ((sp48 == 0.0f) && (sp44 == 0.0f) && (sp40 == 0.0f)) { this->unk_216 = 0; @@ -735,7 +736,7 @@ s32 func_80998F9C(EnGs* this, PlayState* play) { } if ((u16)this->unk_19E[0].y < sp3A) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_STONE_ROLLING); + Actor_PlaySfx(&this->actor, NA_SE_EV_STONE_ROLLING); } return sp4C; @@ -799,8 +800,8 @@ s32 func_809995A4(EnGs* this, PlayState* play) { if (this->unk_1D4 <= 0) { this->unk_19A &= ~4; - this->unk_21C = 3; - this->unk_21E = 40; + this->quakeY = 3; + this->quakeDuration = 40; this->unk_1D4 = 0; this->unk_19D++; } @@ -833,8 +834,8 @@ s32 func_809995A4(EnGs* this, PlayState* play) { this->unk_1DC = 0.0f; this->unk_19D++; - this->unk_21C = 5; - this->unk_21E = 20; + this->quakeY = 5; + this->quakeDuration = 20; this->unk_19A |= 1; this->unk_216 = 200; this->unk_1E0 = (this->unk_197 >> 2) * 0x444; @@ -842,14 +843,14 @@ s32 func_809995A4(EnGs* this, PlayState* play) { } if (this->unk_19D == 4) { - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 60.0f, 3); - if (this->actor.bgCheckFlags & (0x10 | 0x8)) { + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 60.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2); + if (this->actor.bgCheckFlags & (BGCHECKFLAG_WALL | BGCHECKFLAG_CEILING)) { Vec3f sp54; sp54.x = this->actor.world.pos.x; sp54.y = this->actor.world.pos.y; sp54.z = this->actor.world.pos.z; - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfx(&this->actor, NA_SE_IT_BOMB_EXPLOSION); EffectSsBomb2_SpawnLayered(play, &sp54, &bomb2Velocity, &bomb2Accel, 100, 20); this->unk_1D4 = 10; this->unk_19A |= 8; @@ -902,16 +903,16 @@ void func_80999AC0(EnGs* this) { void func_80999B34(EnGs* this) { if (this->unk_216 > 0) { if (this->unk_218 == 0) { - func_8016566C(this->unk_216); + Play_EnableMotionBlur(this->unk_216); this->unk_218 = this->unk_216; } else { - func_80165658(this->unk_218); + Play_SetMotionBlurAlpha(this->unk_218); } } else if (this->unk_218 > 0) { Math_StepToS(&this->unk_218, this->unk_216, 20); - func_80165658(this->unk_218); + Play_SetMotionBlurAlpha(this->unk_218); if (this->unk_218 <= 0) { - func_80165690(); + Play_DisableMotionBlur(); } } } @@ -1012,7 +1013,7 @@ void EnGs_Update(Actor* thisx, PlayState* play) { } else if (func_800B8718(&this->actor, &play->state)) { this->unk_19A |= 0x200; this->collider.base.acFlags &= ~AC_HIT; - if (this->actor.cutscene != -1) { + if (this->actor.csId != CS_ID_NONE) { this->actionFunc = func_80997FF0; } else { func_80998040(this, play); @@ -1027,8 +1028,8 @@ void EnGs_Update(Actor* thisx, PlayState* play) { if ((this->actor.xyzDistToPlayerSq > SQ(400.0f)) || (sp2E < 0) || (sp2E > SCREEN_WIDTH) || (sp2C < 0) || (sp2C > SCREEN_HEIGHT)) { this->unk_216 = 0; - } else if (this->unk_21C > 0) { - func_800BC848(&this->actor, play, this->unk_21C, this->unk_21E); + } else if (this->quakeY > 0) { + Actor_RequestQuakeAndRumble(&this->actor, play, this->quakeY, this->quakeDuration); } } else { this->unk_216 = 0; @@ -1047,8 +1048,8 @@ void EnGs_Update(Actor* thisx, PlayState* play) { } } - if (this->unk_21C > 0) { - this->unk_21C = 0; + if (this->quakeY > 0) { + this->quakeY = 0; } func_80999B34(this); diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.h b/src/overlays/actors/ovl_En_Gs/z_en_gs.h index 51e899fcc..abb4a5b86 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.h +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.h @@ -49,12 +49,12 @@ typedef struct EnGs { /* 0x208 */ s32 unk_208; /* 0x20C */ s32 unk_20C; /* 0x210 */ u16 unk_210; - /* 0x212 */ s16 unk_212[2]; + /* 0x212 */ s16 csIdList[2]; /* 0x216 */ s16 unk_216; /* 0x218 */ s16 unk_218; /* 0x21A */ s16 unk_21A; - /* 0x21C */ s16 unk_21C; - /* 0x21E */ s16 unk_21E; + /* 0x21C */ s16 quakeY; + /* 0x21E */ s16 quakeDuration; } EnGs; // size = 0x220 #endif // Z_EN_GS_H diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c index b13bca1dd..f5925f524 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c @@ -232,7 +232,7 @@ void func_80ABB590(EnGuardNuts* this, PlayState* play) { if (Message_ShouldAdvance(play)) { if (D_80ABBE38[this->guardTextIndex] != 1) { if (D_80ABBE38[this->guardTextIndex] == 2) { - func_801477B4(play); + Message_CloseTextbox(play); D_80ABBE20 = 2; SET_WEEKEVENTREG(WEEKEVENTREG_12_40); EnGuardNuts_Burrow(this, play); @@ -247,11 +247,11 @@ void func_80ABB590(EnGuardNuts* this, PlayState* play) { } else if (this->guardTextIndex != 3) { this->targetHeadPos.x = 0; this->targetHeadPos.y = this->targetHeadPos.x; - func_801477B4(play); + Message_CloseTextbox(play); this->state = GUARD_NUTS_UNK_STATE; this->actionFunc = EnGuardNuts_Unburrow; } else { - func_801477B4(play); + Message_CloseTextbox(play); EnGuardNuts_SetupWait(this); } } @@ -276,10 +276,10 @@ void EnGuardNuts_Burrow(EnGuardNuts* this, PlayState* play) { digPos.y = this->actor.floorHeight; EffectSsHahen_SpawnBurst(play, &digPos, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); this->targetHeadPos.y = 0; - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->targetHeadPos.x = this->targetHeadPos.y; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_UP); this->actionFunc = EnGuardNuts_SetupUnburrow; } @@ -306,12 +306,12 @@ void EnGuardNuts_Unburrow(EnGuardNuts* this, PlayState* play) { Math_Vec3f_Copy(&digPos, &this->actor.world.pos); digPos.y = this->actor.floorHeight; EffectSsHahen_SpawnBurst(play, &digPos, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_UP); D_80ABBE20 = 0; if (this->guardTextIndex == 9) { this->hasCompletedConversation = true; } - this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_CANT_LOCK_ON; EnGuardNuts_SetupWait(this); } } @@ -329,7 +329,7 @@ void EnGuardNuts_Update(Actor* thisx, PlayState* play) { } if ((this->animIndex == WALK_ANIM) && ((Animation_OnFrame(&this->skelAnime, 1.0f)) || (Animation_OnFrame(&this->skelAnime, 5.0f)))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_WALK); } this->actionFunc(this, play); @@ -345,7 +345,9 @@ void EnGuardNuts_Update(Actor* thisx, PlayState* play) { } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 60.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); if ((this->state != GUARD_NUTS_BURROWED_STATE) && (this->state != GUARD_NUTS_UNK_STATE)) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); 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 f7eddbe6f..a6f5f98b3 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -83,7 +83,7 @@ void EnGuruguru_Init(Actor* thisx, PlayState* play) { if (this->actor.params == 0) { func_80BC6E10(this); } else if (this->actor.params == 2) { - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.draw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = EnGuruguru_DoNothing; @@ -208,7 +208,7 @@ void func_80BC7068(EnGuruguru* this, PlayState* play) { } } if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); this->headZRotTarget = 0; if ((this->textIdIndex == 13) || (this->textIdIndex == 14)) { func_80151BB4(play, 0x13); @@ -257,11 +257,11 @@ void func_80BC7068(EnGuruguru* this, PlayState* play) { } if ((this->unk268 != 0) && (this->textIdIndex >= 7)) { this->skelAnime.playSpeed = 2.0f; - func_801A29D4(3, 1.18921f, 2); + Audio_SetSeqTempoAndFreq(3, 1.18921f, 2); func_801A3B48(0); } else { if (this->skelAnime.playSpeed == 2.0f) { - func_801A29D4(3, 1.0f, 2); + Audio_SetSeqTempoAndFreq(3, 1.0f, 2); } if (this->unk268 == 0) { func_801A3B48(1); @@ -271,7 +271,7 @@ void func_80BC7068(EnGuruguru* this, PlayState* play) { this->skelAnime.playSpeed = 1.0f; } this->unk266 = 1; - func_80151938(play, textIDs[this->textIdIndex]); + Message_ContinueTextbox(play, textIDs[this->textIdIndex]); return; } func_801A3B48(0); @@ -300,7 +300,7 @@ void func_80BC7440(EnGuruguru* this, PlayState* play) { SET_WEEKEVENTREG(WEEKEVENTREG_38_40); this->actionFunc = func_80BC7520; } else { - Actor_PickUp(&this->actor, play, GI_MASK_BREMEN, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_MASK_BREMEN, 300.0f, 300.0f); } } @@ -363,7 +363,9 @@ void EnGuruguru_Update(Actor* thisx, PlayState* play) { Actor_MoveWithGravity(&this->actor); Math_SmoothStepToS(&this->headXRot, this->headXRotTarget, 1, 3000, 0); Math_SmoothStepToS(&this->headZRot, this->headZRotTarget, 1, 1000, 0); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } 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 0e1d2f050..44e42d01a 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -165,7 +165,7 @@ void func_80B21EA4(EnHakurock* this, s32 arg1) { } void func_80B21FFC(EnHakurock* this) { - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->collider.base.atFlags &= ~AT_HIT; this->collider.base.ocFlags1 &= ~OC1_HIT; this->actor.draw = NULL; @@ -186,7 +186,7 @@ void func_80B22040(EnHakurock* this, PlayState* play) { void func_80B220A8(EnHakurock* this) { this->actor.params = EN_HAKUROCK_TYPE_BOULDER; this->actor.draw = func_80B228F4; - this->actor.speedXZ = Rand_ZeroFloat(3.5f) + 2.5f; + this->actor.speed = Rand_ZeroFloat(3.5f) + 2.5f; this->actor.velocity.y = Rand_ZeroFloat(4.5f) + 18.0f; Actor_SetScale(&this->actor, (Rand_ZeroFloat(5.0f) + 15.0f) * 0.001f); this->actor.world.rot.y = ((s32)Rand_Next() >> 0x12) + this->actor.parent->shape.rot.y + 0x8000; @@ -210,8 +210,8 @@ void func_80B221E8(EnHakurock* this, PlayState* play) { this->actor.shape.rot.z += 0xB00; 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))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROCK_BROKEN); + ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.velocity.y < 0.0f))) { + Actor_PlaySfx(&this->actor, NA_SE_EV_ROCK_BROKEN); func_80B21EA4(this, 0); func_80B21FFC(this); } @@ -244,9 +244,9 @@ void func_80B2242C(EnHakurock* this, PlayState* play) { if ((this->collider.base.ocFlags1 & OC1_HIT) && (this->collider.base.oc == this->actor.parent)) { func_80B21EA4(this, 1); func_80B21FFC(this); - } else if ((this->actor.bgCheckFlags & 1)) { + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { func_80B21EA4(this, 2); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OBJECT_STICK); + Actor_PlaySfx(&this->actor, NA_SE_EV_OBJECT_STICK); func_80B224C0(this); } } @@ -323,7 +323,8 @@ void EnHakurock_Update(Actor* thisx, PlayState* play) { rockParams = this->actor.params; if ((rockParams == EN_HAKUROCK_TYPE_BOULDER) || (rockParams == EN_HAKUROCK_TYPE_UNK_2)) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, this->collider.dim.radius, 0.0f, 0x85); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, this->collider.dim.radius, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_80); if (this->actor.floorHeight == BGCHECK_Y_MIN) { func_80B21FFC(this); } else { diff --git a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c index 507bf9deb..c54703ef9 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -297,7 +297,7 @@ void func_80B236C8(EnHanabi* this, PlayState* play) { this->actor.home.rot.y += (s16)((Rand_ZeroFloat(40.0f) + 80.0f) * 256.0f); this->unk_144 = (s32)Rand_ZeroFloat(5.0f) + 20; - Actor_PlaySfxAtPos(&this->actor, NA_SE_OC_FIREWORKS); + Actor_PlaySfx(&this->actor, NA_SE_OC_FIREWORKS); func_80B235CC(this, &sp34, sp28); } } @@ -324,15 +324,15 @@ void func_80B23910(EnHanabi* this, PlayState* play) { void func_80B23934(EnHanabi* this, PlayState* play) { if ((gSaveContext.save.entrance == ENTRANCE(TERMINA_FIELD, 1)) && (gSaveContext.sceneLayer == 7)) { - if (play->csCtx.frames > 1650) { + if (play->csCtx.curFrame > 1650) { func_80B236C8(this, play); func_800B8FE8(&this->actor, NA_SE_EV_FIREWORKS_LAUNCH - SFX_FLAG); } } - if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 7) && (play->csCtx.currentCsIndex == 0) && - (play->csCtx.frames == 610)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_GROAN); + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 7) && (play->csCtx.scriptIndex == 0) && + (play->csCtx.curFrame == 610)) { + Actor_PlaySfx(&this->actor, NA_SE_EV_KYOJIN_GROAN); } } diff --git a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c index 756f37eb8..5fa9f5ea2 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c @@ -87,7 +87,7 @@ void EnHeishi_Init(Actor* thisx, PlayState* play) { this->actor.targetMode = 6; this->actor.gravity = -3.0f; Collider_InitAndSetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; EnHeishi_SetupIdle(this); } @@ -156,7 +156,9 @@ void EnHeishi_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 29); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); Actor_SetScale(&this->actor, 0.01f); if (this->shouldSetHeadRotation) { EnHeishi_SetHeadRotation(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 e100a2de3..34e1d1e15 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -133,7 +133,7 @@ static u32 sHasSoundPlayed = false; void EnHg_Init(Actor* thisx, PlayState* play) { EnHg* this = THIS; - s16 currentCutscene = this->actor.cutscene; + s16 csId = this->actor.csId; s32 i; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 36.0f); @@ -142,18 +142,18 @@ void EnHg_Init(Actor* thisx, PlayState* play) { Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) || CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) || CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE)) { Actor_Kill(&this->actor); } this->actor.targetMode = 1; this->actor.colChkInfo.health = 0; this->actor.gravity = -1.0f; - for (i = 0; i < ARRAY_COUNT(this->cutscenes); i++) { - if (currentCutscene == -1) { + for (i = 0; i < ARRAY_COUNT(this->csIdList); i++) { + if (csId == CS_ID_NONE) { break; } - this->cutscenes[i] = currentCutscene; - currentCutscene = ActorCutscene_GetAdditionalCutscene(currentCutscene); + this->csIdList[i] = csId; + csId = CutsceneManager_GetAdditionalCsId(csId); } EnHg_SetupWait(this); } @@ -171,13 +171,13 @@ void EnHg_SetupWait(EnHg* this) { void EnHg_Wait(EnHg* this, PlayState* play) { if (this->actor.colChkInfo.health == 1) { - if ((this->actor.xzDistToPlayer < 200.0f && this->actor.playerHeightRel < 40.0f) && - !Cutscene_CheckActorAction(play, 0x1E3)) { + if (((this->actor.xzDistToPlayer < 200.0f) && (this->actor.playerHeightRel < 40.0f)) && + !Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_483)) { EnHg_SetupChasePlayer(this); } - if ((gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 0) && - ((play->csCtx.frames == 20) || (play->csCtx.frames == 60))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HALF_REDEAD_SURPRISE); + if ((gSaveContext.sceneLayer == 0) && (play->csCtx.scriptIndex == 0) && + ((play->csCtx.curFrame == 20) || (play->csCtx.curFrame == 60))) { + Actor_PlaySfx(&this->actor, NA_SE_EN_HALF_REDEAD_SURPRISE); } } } @@ -191,7 +191,7 @@ void EnHg_ChasePlayer(EnHg* this, PlayState* play) { Player* player = GET_PLAYER(play); s32 pad; - this->actor.speedXZ = 1.6f; + this->actor.speed = 1.6f; if (!(player->stateFlags2 & PLAYER_STATE2_8000000) && Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if (((this->skelAnime.curFrame > 9.0f) && (this->skelAnime.curFrame < 16.0f)) || ((this->skelAnime.curFrame > 44.0f) && (this->skelAnime.curFrame < 51.0f))) { @@ -270,51 +270,51 @@ void EnHg_SetupCutscene(EnHg* this) { } void EnHg_PlayCutscene(EnHg* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->cutscenes[this->cutsceneIndex])) { - ActorCutscene_Start(this->cutscenes[this->cutsceneIndex], &this->actor); + if (CutsceneManager_IsNext(this->csIdList[this->csIdIndex])) { + CutsceneManager_Start(this->csIdList[this->csIdIndex], &this->actor); EnHg_SetupCsAction(this); } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIndex]); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); } } void EnHg_SetupCsAction(EnHg* this) { - this->cutscenes[3] = 0x63; - this->cutscenes[2] = 0; + this->csIdList[3] = 99; + this->csIdList[2] = 0; this->actionFunc = EnHg_HandleCsAction; } void EnHg_HandleCsAction(EnHg* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 484)) { - s32 actionIndex = Cutscene_GetActorActionIndex(play, 484); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_484)) { + s32 cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_484); - if (this->cutscenes[3] != play->csCtx.actorActions[actionIndex]->action) { - this->cutscenes[3] = play->csCtx.actorActions[actionIndex]->action; - switch (play->csCtx.actorActions[actionIndex]->action) { + if (this->csIdList[3] != play->csCtx.actorCues[cueChannel]->id) { + this->csIdList[3] = play->csCtx.actorCues[cueChannel]->id; + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: this->animIndex = 0; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_IDLE); break; case 2: - this->cutscenes[2] = 0; + this->csIdList[2] = 0; this->animIndex = HG_ANIM_LEAN_FORWARD; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_LEAN_FORWARD); break; case 3: - this->cutscenes[2] = 0; + this->csIdList[2] = 0; this->animIndex = HG_ANIM_CURL_UP; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_CURL_UP); break; case 4: - this->cutscenes[2] = 0; + this->csIdList[2] = 0; this->animIndex = HG_ANIM_PANIC; - if ((this->cutsceneIndex == HG_CS_GET_MASK) || (this->cutsceneIndex == HG_CS_SONG_OF_HEALING)) { + if ((this->csIdIndex == HG_CS_GET_MASK) || (this->csIdIndex == HG_CS_SONG_OF_HEALING)) { func_8019F128(NA_SE_EN_HALF_REDEAD_TRANS); } Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_PANIC); @@ -356,21 +356,20 @@ void EnHg_HandleCsAction(EnHg* this, PlayState* play) { break; case HG_ANIM_PANIC: - if ((this->cutsceneIndex == HG_CS_FIRST_ENCOUNTER) || - (this->cutsceneIndex == HG_CS_SUBSEQUENT_ENCOUNTER)) { + if ((this->csIdIndex == HG_CS_FIRST_ENCOUNTER) || (this->csIdIndex == HG_CS_SUBSEQUENT_ENCOUNTER)) { func_800B9010(&this->actor, NA_SE_EN_HALF_REDEAD_SCREAME - SFX_FLAG); } break; } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); return; - } else if (play->csCtx.state == 0) { + } else if (play->csCtx.state == CS_STATE_IDLE) { EnHg_SetupWait(this); } - this->cutscenes[3] = 0x63; + this->csIdList[3] = 99; } void EnHg_WaitForPlayerAction(EnHg* this, PlayState* play) { @@ -394,9 +393,9 @@ void EnHg_WaitForPlayerAction(EnHg* this, PlayState* play) { if ((play->msgCtx.lastPlayedSong == OCARINA_SONG_HEALING) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { if (INV_CONTENT(ITEM_MASK_GIBDO) == ITEM_MASK_GIBDO) { - this->cutsceneIndex = HG_CS_SONG_OF_HEALING; + this->csIdIndex = HG_CS_SONG_OF_HEALING; } else { - this->cutsceneIndex = HG_CS_GET_MASK; + this->csIdIndex = HG_CS_GET_MASK; } EnHg_SetupCutscene(this); @@ -407,9 +406,9 @@ void EnHg_WaitForPlayerAction(EnHg* this, PlayState* play) { if ((this->actionFunc != EnHg_PlayCutscene) && (this->actionFunc != EnHg_HandleCsAction)) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_61_02)) { SET_WEEKEVENTREG(WEEKEVENTREG_61_02); - this->cutsceneIndex = HG_CS_FIRST_ENCOUNTER; + this->csIdIndex = HG_CS_FIRST_ENCOUNTER; } else { - this->cutsceneIndex = HG_CS_SUBSEQUENT_ENCOUNTER; + this->csIdIndex = HG_CS_SUBSEQUENT_ENCOUNTER; } EnHg_SetupCutscene(this); @@ -428,7 +427,7 @@ void EnHg_Update(Actor* thisx, PlayState* play) { SkelAnime_Update(&this->skelAnime); EnHg_UpdateCollision(this, play); EnHg_WaitForPlayerAction(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 25.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 25.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); EnHg_PlayRedeadSfx(this, play); } diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.h b/src/overlays/actors/ovl_En_Hg/z_en_hg.h index 1211a4cf3..b79269e9b 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.h +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.h @@ -15,12 +15,12 @@ typedef struct EnHg { /* 0x190 */ SkelAnime skelAnime; /* 0x1D4 */ EnHgActionFunc actionFunc; /* 0x1D8 */ MtxF mf; - /* 0x218 */ s32 cutsceneIndex; + /* 0x218 */ s32 csIdIndex; /* 0x21C */ s32 animIndex; /* 0x220 */ Vec3s jointTable[PAMELAS_FATHER_GIBDO_LIMB_MAX]; /* 0x292 */ Vec3s morphTable[PAMELAS_FATHER_GIBDO_LIMB_MAX]; /* 0x304 */ UNK_TYPE1 pad304[0xC]; - /* 0x310 */ u16 cutscenes[4]; + /* 0x310 */ u16 csIdList[4]; } EnHg; // size = 0x318 #endif // Z_EN_HG_H diff --git a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c index f7a9df82a..bbef58b1a 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -109,7 +109,7 @@ void EnHgo_Init(Actor* thisx, PlayState* play) { this->textId = 0; this->talkFlags = TALK_FLAG_NONE; this->isInCutscene = false; - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) || CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) || CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE)) { EnHgo_SetupTalk(this); } else { thisx->draw = NULL; @@ -268,7 +268,7 @@ void EnHgo_HandlePlayerChoice(EnHgo* this, PlayState* play) { break; case 0x15A7: - func_801477B4(play); + Message_CloseTextbox(play); EnHgo_SetupTalk(this); break; } @@ -276,13 +276,13 @@ void EnHgo_HandlePlayerChoice(EnHgo* this, PlayState* play) { } s32 EnHgo_HandleCsAction(EnHgo* this, PlayState* play) { - s32 actionIndex; + s32 cueChannel; - if (Cutscene_CheckActorAction(play, 486)) { - actionIndex = Cutscene_GetActorActionIndex(play, 486); - if (this->csAction != play->csCtx.actorActions[actionIndex]->action) { - this->csAction = play->csCtx.actorActions[actionIndex]->action; - switch (play->csCtx.actorActions[actionIndex]->action) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_486)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_486); + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: this->animIndex = HGO_ANIM_ARMS_FOLDED; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); @@ -321,8 +321,8 @@ s32 EnHgo_HandleCsAction(EnHgo* this, PlayState* play) { (this->isInCutscene == false)) { this->isInCutscene = true; if ((gSaveContext.sceneLayer == 0) && - ((play->csCtx.currentCsIndex == 2) || (play->csCtx.currentCsIndex == 4))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_GBVO02); + ((play->csCtx.scriptIndex == 2) || (play->csCtx.scriptIndex == 4))) { + Actor_PlaySfx(&this->actor, NA_SE_VO_GBVO02); } } break; @@ -338,11 +338,11 @@ s32 EnHgo_HandleCsAction(EnHgo* this, PlayState* play) { } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); return true; } - if ((play->csCtx.state == CS_STATE_0) && CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) && + if ((play->csCtx.state == CS_STATE_IDLE) && CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) && (this->actionFunc == EnHgo_DoNothing)) { this->actor.shape.rot.y = this->actor.world.rot.y; Actor_Spawn(&play->actorCtx, play, ACTOR_ELF_MSG2, this->actor.focus.pos.x, this->actor.focus.pos.y, @@ -350,7 +350,7 @@ s32 EnHgo_HandleCsAction(EnHgo* this, PlayState* play) { EnHgo_SetupInitCollision(this); } - this->csAction = 0x63; + this->cueId = 99; return false; } diff --git a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.h b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.h index 6882c1127..da7b7c40e 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.h +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.h @@ -24,7 +24,7 @@ typedef struct EnHgo { /* 0x310 */ s16 talkFlags; /* 0x312 */ s16 isInCutscene; /* 0x314 */ u16 textId; - /* 0x316 */ u16 csAction; + /* 0x316 */ u16 cueId; } EnHgo; // size = 0x318 #endif // Z_EN_HGO_H diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c index d8df99887..29a7c6a8e 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c @@ -105,7 +105,7 @@ void EnHiddenNuts_Init(Actor* thisx, PlayState* play) { } this->path = SubS_GetPathByIndex(play, this->unk_21E, 0x3F); - this->unk_226 = this->actor.cutscene; + this->csId = this->actor.csId; func_801A5080(2); func_80BDB268(this); } @@ -145,7 +145,7 @@ void func_80BDB2B8(EnHiddenNuts* this, PlayState* play) { Player* player = GET_PLAYER(play); s32 i; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NEMURI_SLEEP - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_NEMURI_SLEEP - SFX_FLAG); if (player->stateFlags2 & PLAYER_STATE2_8000000) { if (this->unk_20A == 0) { @@ -202,7 +202,7 @@ void func_80BDB580(EnHiddenNuts* this) { void func_80BDB59C(EnHiddenNuts* this, PlayState* play) { s32 i; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NEMURI_SLEEP - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_NEMURI_SLEEP - SFX_FLAG); if (this->unk_218 == 0) { Vec3f sp98 = { 0.0f, 0.0f, 0.0f }; @@ -226,16 +226,16 @@ void func_80BDB59C(EnHiddenNuts* this, PlayState* play) { } if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); func_80BDB268(this); } } void func_80BDB788(EnHiddenNuts* this) { this->actor.flags |= ACTOR_FLAG_10; - this->actor.flags |= ACTOR_FLAG_8000000; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DEAD); this->unk_21A = 2; this->actionFunc = func_80BDB7E8; } @@ -243,18 +243,18 @@ void func_80BDB788(EnHiddenNuts* this) { void func_80BDB7E8(EnHiddenNuts* this, PlayState* play) { Vec3f sp3C; - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_226); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csId); return; } - if (!ActorCutscene_GetCanPlayNext(this->unk_226)) { - ActorCutscene_SetIntentToPlay(this->unk_226); + if (!CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Queue(this->csId); return; } - ActorCutscene_StartAndSetUnkLinkFields(this->unk_226, &this->actor); + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); this->unk_228 = -1200.0f; Math_Vec3f_Copy(&sp3C, &this->actor.world.pos); @@ -262,7 +262,7 @@ void func_80BDB7E8(EnHiddenNuts* this, PlayState* play) { EffectSsHahen_SpawnBurst(play, &sp3C, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_UP); func_80BDB1B4(this, 7); this->actionFunc = func_80BDB8F4; } @@ -287,7 +287,7 @@ void func_80BDB978(EnHiddenNuts* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUT_FAINT); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUT_FAINT); } if (this->unk_22C <= curFrame) { @@ -309,14 +309,14 @@ void func_80BDBA28(EnHiddenNuts* this, PlayState* play) { EffectSsHahen_SpawnBurst(play, &sp44, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_UP); this->unk_208 = 1; if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_208, &this->unk_20C)) { Actor_Kill(&this->actor); } - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; this->actor.gravity = -2.0f; this->actor.velocity.y = 4.0f; this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_20C); @@ -345,14 +345,14 @@ void func_80BDBB48(EnHiddenNuts* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || Animation_OnFrame(&this->skelAnime, 10.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALK_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EV_WALK_WATER); sp4E = 1; } } if ((sp4E != 0) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || Animation_OnFrame(&this->skelAnime, 10.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_WALK); } Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_20C), 1, 0x1388, 0); @@ -360,7 +360,7 @@ void func_80BDBB48(EnHiddenNuts* this, PlayState* play) { if (this->unk_220 == 2) { if (this->unk_22C <= sp58) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; func_80BDB1B4(this, 6); } @@ -400,7 +400,7 @@ void func_80BDBED4(EnHiddenNuts* this, PlayState* play) { Math_Vec3f_Copy(&sp38, &this->actor.world.pos); sp38.y = this->actor.floorHeight; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DOWN); EffectSsHahen_SpawnBurst(play, &sp38, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); Actor_Kill(&this->actor); } @@ -423,7 +423,9 @@ void EnHiddenNuts_Update(Actor* thisx, PlayState* play) { if (this->unk_21A >= 4) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 40.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 40.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } Collider_UpdateCylinder(&this->actor, &this->collider); diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h index e40a89193..435e4662c 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h @@ -26,7 +26,7 @@ typedef struct EnHiddenNuts { /* 0x21E */ s16 unk_21E; /* 0x220 */ s32 unk_220; /* 0x224 */ s16 unk_224; - /* 0x226 */ s16 unk_226; + /* 0x226 */ s16 csId; /* 0x228 */ f32 unk_228; /* 0x22C */ f32 unk_22C; /* 0x230 */ UNK_TYPE1 unk230[4]; diff --git a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c index c07bbc5da..09a110dbf 100644 --- a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c +++ b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c @@ -182,13 +182,13 @@ void func_80C1FE20(EnHintSkb* this, PlayState* play) { void func_80C1FE30(EnHintSkb* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); - this->actor.speedXZ = 1.6f; + this->actor.speed = 1.6f; this->actionFunc = func_80C1FE80; } void func_80C1FE80(EnHintSkb* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_WALK); } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 750, 0); this->actor.world.rot.y = this->actor.shape.rot.y; @@ -199,7 +199,7 @@ void func_80C1FE80(EnHintSkb* this, PlayState* play) { void func_80C1FF30(EnHintSkb* this) { this->collider.base.atFlags &= ~AT_BOUNCED; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); this->actionFunc = func_80C1FF88; } @@ -211,7 +211,7 @@ void func_80C1FF88(EnHintSkb* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 3.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_ATTACK); } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -241,23 +241,23 @@ void func_80C200B8(EnHintSkb* this, PlayState* play) { } void func_80C2011C(EnHintSkb* this) { - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.speed = 0.0f; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = func_80C2016C; } void func_80C2016C(EnHintSkb* this, PlayState* play) { - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; - } else if (this->actor.bgCheckFlags & 1) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.05f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + this->actor.speed = 0.0f; + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + if (this->actor.speed < 0.0f) { + this->actor.speed += 0.05f; } } - if ((this->actor.colorFilterTimer == 0) && (this->actor.bgCheckFlags & 1)) { + if ((this->actor.colorFilterTimer == 0) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { if (this->actor.colChkInfo.health == 0) { SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80C20484(this); @@ -276,40 +276,41 @@ void func_80C20274(EnHintSkb* this) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 8); this->actor.gravity = -1.0f; - this->actor.speedXZ = 1.0f; + this->actor.speed = 1.0f; } else { this->actor.world.rot.y = this->actor.yawTowardsPlayer; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = -4.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.speed = -4.0f; } } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->actionFunc = func_80C20334; } void func_80C20334(EnHintSkb* this, PlayState* play) { - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { s32 i; for (i = 0; i < 10; i++) { func_80C215E4(play, this, &this->actor.world.pos); } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } - if (this->actor.bgCheckFlags & 1) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.05f; - } else if (this->actor.speedXZ != 0.0f) { - this->actor.speedXZ -= 0.05f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + if (this->actor.speed < 0.0f) { + this->actor.speed += 0.05f; + } else if (this->actor.speed != 0.0f) { + this->actor.speed -= 0.05f; } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 2500, 0); } Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 16, 2000, 100); - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (this->actor.bgCheckFlags & 1)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->actor.world.rot = this->actor.shape.rot; func_80C1FE30(this); } @@ -318,8 +319,8 @@ void func_80C20334(EnHintSkb* this, PlayState* play) { void func_80C20484(EnHintSkb* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); this->unk_3E8 |= 4; - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = -6.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.speed = -6.0f; } this->actionFunc = func_80C204F0; } @@ -334,10 +335,10 @@ void func_80C204F0(EnHintSkb* this, PlayState* play) { } void func_80C20540(EnHintSkb* this) { - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.speed = 0.0f; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = func_80C20590; } @@ -347,9 +348,9 @@ void func_80C20590(EnHintSkb* this, PlayState* play) { this->drawDmgEffScale = 0.0f; this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; func_80C20274(this); } else { @@ -362,8 +363,8 @@ void func_80C20590(EnHintSkb* this, PlayState* play) { } void func_80C2066C(EnHintSkb* this) { - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.speed = 0.0f; } this->actionFunc = func_80C2069C; } @@ -374,9 +375,9 @@ void func_80C2069C(EnHintSkb* this, PlayState* play) { this->drawDmgEffScale = 0.0f; this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; func_80C20274(this); } else { @@ -388,7 +389,7 @@ void func_80C2069C(EnHintSkb* this, PlayState* play) { void func_80C2075C(EnHintSkb* this) { this->unk_3E0 = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_80C2077C; } @@ -401,7 +402,7 @@ void func_80C2077C(EnHintSkb* this, PlayState* play) { this->unk_3E6 = 0x1147; if (this->skelAnime.animation == &object_skb_Anim_00697C) { play->msgCtx.msgMode = 0x44; - this->actor.speedXZ = 2.4f; + this->actor.speed = 2.4f; this->actor.gravity = -1.0f; this->actor.velocity.y = 3.0f; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 8); @@ -452,10 +453,10 @@ void func_80C208D0(EnHintSkb* this, PlayState* play) { } if (this->unk_3E6 == 0x1147) { - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { s32 i; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; for (i = 0; i < 10; i++) { func_80C215E4(play, this, &this->actor.world.pos); @@ -470,7 +471,7 @@ void func_80C208D0(EnHintSkb* this, PlayState* play) { } } - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 5, 0x71C, 0xB6); this->actor.shape.rot.y = this->actor.world.rot.y; } @@ -569,7 +570,7 @@ void func_80C20C24(EnHintSkb* this, PlayState* play) { break; case 0x1151: - func_801477B4(play); + Message_CloseTextbox(play); if (this->unk_3E8 & 0x10) { SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80C20484(this); @@ -611,7 +612,8 @@ void func_80C20D64(EnHintSkb* this, PlayState* play) { void func_80C20E90(EnHintSkb* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((this->actor.bgCheckFlags & 0x60) && (this->actor.depthInWater >= 40.0f)) { + if ((this->actor.bgCheckFlags & (BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH)) && + (this->actor.depthInWater >= 40.0f)) { this->actor.colChkInfo.health = 0; SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80C20484(this); @@ -661,12 +663,12 @@ void func_80C20E90(EnHintSkb* this, PlayState* play) { this->drawDmgEffTimer = 40; this->drawDmgEffAlpha = 1.0f; this->drawDmgEffScale = 0.0f; - Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 120, COLORFILTER_BUFFLAG_OPA, 40); func_80C2011C(this); break; case 1: - Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 120, COLORFILTER_BUFFLAG_OPA, 40); func_80C2011C(this); break; @@ -675,14 +677,14 @@ void func_80C20E90(EnHintSkb* this, PlayState* play) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->drawDmgEffAlpha = 1.0f; this->drawDmgEffScale = 0.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; func_80C20274(this); break; case 3: if (this->actor.colChkInfo.health != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->drawDmgEffTimer = 80; } else { this->drawDmgEffTimer = 3; @@ -690,7 +692,7 @@ void func_80C20E90(EnHintSkb* this, PlayState* play) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; this->drawDmgEffAlpha = 1.0f; this->drawDmgEffScale = 0.5f; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); func_80C20540(this); break; case 4: @@ -698,8 +700,8 @@ void func_80C20E90(EnHintSkb* this, PlayState* play) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->drawDmgEffAlpha = 1.0f; this->drawDmgEffScale = 0.5f; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); func_80C2066C(this); break; @@ -717,8 +719,8 @@ void func_80C20E90(EnHintSkb* this, PlayState* play) { } case 13: - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); func_80C20274(this); break; @@ -836,7 +838,9 @@ void EnHintSkb_Update(Actor* thisx, PlayState* play) { } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 60.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 60.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); func_80C21250(this, play); func_80C20D64(this, play); func_80C21320(this, play); 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 df8b29e97..3f7c8d03e 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -151,13 +151,15 @@ void EnHoll_VisibleIdle(EnHoll* this, PlayState* play) { f32 playerDistFromCentralPlane; if (this->type == EN_HOLL_TYPE_DEFAULT) { - u32 actorCtxBitmask = (play->actorCtx.unkC & 0x2AA) >> 1 | (play->actorCtx.unkC & 0x155); + u32 halfDaysBit = + ((play->actorCtx.halfDaysBit & HALFDAYBIT_DAWNS) >> 1) | (play->actorCtx.halfDaysBit & HALFDAYBIT_NIGHTS); u32 zActorBitmask = D_801AED48[EN_HOLL_GET_Z_ACTOR_BITMASK_INDEX(&this->actor)]; - if (!(actorCtxBitmask & zActorBitmask)) { + if (!(halfDaysBit & zActorBitmask)) { Actor_Kill(&this->actor); return; } + if (this == sInstancePlayingSound) { func_800B9010(&this->actor, NA_SE_EV_INVISIBLE_MONKEY - SFX_FLAG); } @@ -180,7 +182,7 @@ void EnHoll_VisibleIdle(EnHoll* this, PlayState* play) { u32 enHollId = EN_HOLL_GET_ID(&this->actor); if (sLoadingPlaneDistance < playerDistFromCentralPlane) { - if ((play->roomCtx.prevRoom.num >= 0) && (play->roomCtx.unk31 == 0)) { + if ((play->roomCtx.prevRoom.num >= 0) && (play->roomCtx.status == 0)) { this->actor.room = play->transitionActors.list[enHollId].sides[this->playerSide].room; if (play->roomCtx.prevRoom.num == this->actor.room) { EnHoll_ChangeRooms(play); @@ -218,7 +220,7 @@ void EnHoll_VisibleIdle(EnHoll* this, PlayState* play) { void EnHoll_TransparentIdle(EnHoll* this, PlayState* play) { Player* player = GET_PLAYER(play); - s32 useViewEye = gDbgCamEnabled || play->csCtx.state != 0; + s32 useViewEye = gDbgCamEnabled || (play->csCtx.state != CS_STATE_IDLE); Vec3f transformedPlayerPos; f32 enHollTop; f32 playerDistFromCentralPlane; @@ -296,7 +298,7 @@ void EnHoll_VerticalIdle(EnHoll* this, PlayState* play) { } void EnHoll_RoomTransitionIdle(EnHoll* this, PlayState* play) { - if (play->roomCtx.unk31 == 0) { + if (play->roomCtx.status == 0) { func_8012EBF8(play, &play->roomCtx); if (play->bgCoverAlpha == 0) { this->bgCoverAlphaActive = false; diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 5ffc364c3..f12599df7 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -50,40 +50,40 @@ void func_80881290(EnHorse* this, PlayState* play); void func_8088159C(EnHorse* this, PlayState* play); void func_80881634(EnHorse* this); void func_8088168C(EnHorse* this); -void EnHorse_CsMoveInit(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void EnHorse_CsMoveToPoint(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void EnHorse_CsMoveInit(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void EnHorse_CsMoveToPoint(EnHorse* this, PlayState* play, CsCmdActorCue* cue); void EnHorse_CsPlayHighJumpAnim(EnHorse* this, PlayState* play); -void EnHorse_CsJumpInit(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void EnHorse_CsJump(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void EnHorse_CsRearingInit(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void EnHorse_CsRearing(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void EnHorse_WarpMoveInit(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void EnHorse_CsWarpMoveToPoint(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void EnHorse_CsWarpRearingInit(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void EnHorse_CsWarpRearing(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void EnHorse_CsJumpInit(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void EnHorse_CsJump(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void EnHorse_CsRearingInit(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void EnHorse_CsRearing(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void EnHorse_WarpMoveInit(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void EnHorse_CsWarpMoveToPoint(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void EnHorse_CsWarpRearingInit(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void EnHorse_CsWarpRearing(EnHorse* this, PlayState* play, CsCmdActorCue* cue); void EnHorse_InitCutscene(EnHorse* this, PlayState* play); void EnHorse_InitHorsebackArchery(EnHorse* this); void EnHorse_UpdateHbaAnim(EnHorse* this); -void func_80883BEC(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_80883CB0(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_80883D64(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_80883DE0(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_80883E10(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_80883EA0(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_80883F18(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_80883F98(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_80884010(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_808840C4(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_80884194(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_8088424C(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_80884314(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_808843B4(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_80884444(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_808844E0(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_80884564(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_80884604(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_808846B4(EnHorse* this, PlayState* play, CsCmdActorAction* action); -void func_808846DC(EnHorse* this, PlayState* play, CsCmdActorAction* action); +void func_80883BEC(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_80883CB0(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_80883D64(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_80883DE0(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_80883E10(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_80883EA0(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_80883F18(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_80883F98(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_80884010(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_808840C4(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_80884194(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_8088424C(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_80884314(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_808843B4(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_80884444(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_808844E0(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_80884564(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_80884604(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_808846B4(EnHorse* this, PlayState* play, CsCmdActorCue* cue); +void func_808846DC(EnHorse* this, PlayState* play, CsCmdActorCue* cue); void func_808846F0(EnHorse* this, PlayState* play); void func_80884994(EnHorse* this); void func_80884D04(EnHorse* this, PlayState* play); @@ -91,7 +91,7 @@ void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle); s32 EnHorse_GetMountSide(EnHorse* this, PlayState* play); typedef struct { - s32 csAction; + s32 cueId; s32 csFuncIdx; } CsActionEntry; @@ -345,7 +345,7 @@ void func_8087B7C0(EnHorse* this, PlayState* play, Path* path) { func_8017D7C0(this->actor.world.pos.x, this->actor.world.pos.z, sp80.x, sp80.z, sp8C.x, sp8C.z, &sp70); - if ((this->actor.bgCheckFlags & 8) || (this->unk_1EC & 4)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || (this->unk_1EC & 4)) { EnHorse_RotateToPoint(this, play, &sp8C, 0xC80); if (this->unk_1EC & 4) { this->unk_1EC &= ~4; @@ -402,81 +402,81 @@ void func_8087B7C0(EnHorse* this, PlayState* play, Path* path) { this->unk_58C = 0x2B; } this->unk_58C--; - if (this->actor.speedXZ > 5.0f) { - this->actor.speedXZ -= 0.5f; + if (this->actor.speed > 5.0f) { + this->actor.speed -= 0.5f; } } else if (this->unk_590 > 0) { if (this->unk_590 == 0x1F4) { if (this->rider != NULL) { - Actor_PlaySfxAtPos(&this->rider->actor, NA_SE_VO_IN_CRY_0); + Actor_PlaySfx(&this->rider->actor, NA_SE_VO_IN_CRY_0); } } this->unk_590--; - if (this->actor.speedXZ < this->unk_398) { - this->actor.speedXZ += 1.0f; + if (this->actor.speed < this->unk_398) { + this->actor.speed += 1.0f; } else { - this->actor.speedXZ -= 0.5f; + this->actor.speed -= 0.5f; } } else if (this->actor.params == ENHORSE_5) { s16 sp4A; if (sp68 >= this->curRaceWaypoint) { - if (this->actor.speedXZ < this->unk_398) { - this->actor.speedXZ += 0.5f; + if (this->actor.speed < this->unk_398) { + this->actor.speed += 0.5f; } else { - this->actor.speedXZ -= 0.5f; + this->actor.speed -= 0.5f; } this->unk_394 |= 1; return; } - sp4A = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(play)->actor) - this->actor.world.rot.y; + sp4A = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(play)->actor) - this->actor.world.rot.y; if ((fabsf(Math_SinS(sp4A)) < 0.9f) && (Math_CosS(sp4A) > 0.0f)) { - if (this->actor.speedXZ < this->unk_398) { - this->actor.speedXZ += 0.5f; + if (this->actor.speed < this->unk_398) { + this->actor.speed += 0.5f; } else { - this->actor.speedXZ -= 0.25f; + this->actor.speed -= 0.25f; } this->unk_394 |= 1; } else { - if (this->actor.speedXZ < 13.0f) { - this->actor.speedXZ += 0.4f; + if (this->actor.speed < 13.0f) { + this->actor.speed += 0.4f; } else { - this->actor.speedXZ -= 0.2f; + this->actor.speed -= 0.2f; } this->unk_394 &= ~1; } } else if (sp68 >= this->curRaceWaypoint) { - if (this->actor.speedXZ < this->unk_398) { - this->actor.speedXZ += 0.5f; + if (this->actor.speed < this->unk_398) { + this->actor.speed += 0.5f; } else { - this->actor.speedXZ -= 0.5f; + this->actor.speed -= 0.5f; } this->unk_394 |= 1; } else if ((sp68 + 1) == this->curRaceWaypoint) { - s16 sp48 = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(play)->actor) - this->actor.world.rot.y; + s16 sp48 = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(play)->actor) - this->actor.world.rot.y; if ((fabsf(Math_SinS(sp48)) < 0.9f) && (Math_CosS(sp48) > 0.0f)) { - if (this->actor.speedXZ < this->unk_398) { - this->actor.speedXZ += 0.5f; + if (this->actor.speed < this->unk_398) { + this->actor.speed += 0.5f; } else { - this->actor.speedXZ -= 0.25f; + this->actor.speed -= 0.25f; } this->unk_394 |= 1; } else { - if (this->actor.speedXZ < 12.0f) { - this->actor.speedXZ += 0.4f; + if (this->actor.speed < 12.0f) { + this->actor.speed += 0.4f; } else { - this->actor.speedXZ -= 0.2f; + this->actor.speed -= 0.2f; } this->unk_394 &= ~1; } } else { - if (this->actor.speedXZ < 13.0f) { - this->actor.speedXZ += 0.4f; + if (this->actor.speed < 13.0f) { + this->actor.speed += 0.4f; } else { - this->actor.speedXZ -= 0.2f; + this->actor.speed -= 0.2f; } this->unk_394 &= ~1; } @@ -622,7 +622,7 @@ s32 EnHorse_Spawn(EnHorse* this, PlayState* play) { this->actor.world.pos.z = spawnPos.z; this->actor.prevPos = this->actor.world.pos; this->actor.world.rot.y = 0; - this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(play)->actor); + this->actor.shape.rot.y = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(play)->actor); spawn = true; SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &this->actor.world.pos, &this->actor.projectedPos, &this->actor.projectedW); @@ -648,7 +648,7 @@ s32 EnHorse_Spawn(EnHorse* this, PlayState* play) { this->actor.world.pos.z = spawnPos.z; this->actor.prevPos = this->actor.world.pos; this->actor.world.rot.y = 0; - this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(play)->actor); + this->actor.shape.rot.y = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(play)->actor); spawn = true; SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &this->actor.world.pos, &this->actor.projectedPos, &this->actor.projectedW); @@ -672,8 +672,8 @@ s32 EnHorse_PlayerCanMove(EnHorse* this, PlayState* play) { if ((player->stateFlags1 & PLAYER_STATE1_1) || (func_800B7128(GET_PLAYER(play)) == true) || (player->stateFlags1 & PLAYER_STATE1_100000) || (((this->stateFlags & ENHORSE_FLAG_19) || (this->stateFlags & ENHORSE_FLAG_29)) && !this->inRace) || - (this->action == ENHORSE_ACTION_HBA) || (player->actor.flags & ACTOR_FLAG_100) || - (play->csCtx.state != CS_STATE_0) || (ActorCutscene_GetCurrentIndex() != -1) || + (this->action == ENHORSE_ACTION_HBA) || (player->actor.flags & ACTOR_FLAG_TALK_REQUESTED) || + (play->csCtx.state != CS_STATE_IDLE) || (CutsceneManager_GetCurrentCsId() != CS_ID_NONE) || (player->stateFlags1 & PLAYER_STATE1_20) || (player->csMode != PLAYER_CSMODE_0)) { return false; } @@ -792,7 +792,8 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { this->stateFlags = 0; } - if (((play->sceneId == SCENE_KOEPONARACE) && (GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_START)) || + if (((play->sceneId == SCENE_KOEPONARACE) && + (GET_WEEKEVENTREG_HORSE_RACE_STATE == WEEKEVENTREG_HORSE_RACE_STATE_START)) || ((gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0)) && (Cutscene_GetSceneLayer(play) != 0))) { this->stateFlags |= ENHORSE_FLAG_25; } @@ -800,7 +801,7 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { thisx->gravity = -3.5f; ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawHorse, 20.0f); this->action = ENHORSE_ACTION_IDLE; - thisx->speedXZ = 0.0f; + thisx->speed = 0.0f; if (this->type == HORSE_TYPE_2) { sJntSphInit.elements[0].dim.limb = 13; @@ -989,7 +990,7 @@ void EnHorse_Freeze(EnHorse* this, PlayState* play) { } void EnHorse_Frozen(EnHorse* this, PlayState* play) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->noInputTimer--; if (this->noInputTimer < 0) { this->colliderCylinder1.base.ocFlags1 |= OC1_ON; @@ -1001,10 +1002,10 @@ void EnHorse_Frozen(EnHorse* this, PlayState* play) { EnHorse_StartMountedIdleResetAnim(this); } else if (this->actor.params == ENHORSE_11) { this->actor.params = ENHORSE_7; - if (play->csCtx.state != CS_STATE_0) { + if (play->csCtx.state != CS_STATE_IDLE) { EnHorse_StartMountedIdle(this); } else { - this->actor.speedXZ = 8.0f; + this->actor.speed = 8.0f; EnHorse_StartGalloping(this); } } else if (this->prevAction == ENHORSE_ACTION_IDLE) { @@ -1035,10 +1036,10 @@ void EnHorse_UpdateSpeed(EnHorse* this, PlayState* play, f32 brakeDecel, f32 bra f32 temp_f12; if (!EnHorse_PlayerCanMove(this, play)) { - if (this->actor.speedXZ > 8.0f) { - this->actor.speedXZ -= decel; - } else if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ = 0.0f; + if (this->actor.speed > 8.0f) { + this->actor.speed -= decel; + } else if (this->actor.speed < 0.0f) { + this->actor.speed = 0.0f; } return; } @@ -1047,63 +1048,62 @@ void EnHorse_UpdateSpeed(EnHorse* this, PlayState* play, f32 brakeDecel, f32 bra EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); if (Math_CosS(stickAngle) <= brakeAngle) { - this->actor.speedXZ -= brakeDecel; - this->actor.speedXZ = CLAMP_MIN(this->actor.speedXZ, 0.0f); + this->actor.speed -= brakeDecel; + this->actor.speed = CLAMP_MIN(this->actor.speed, 0.0f); return; } if (stickMag < minStickMag) { this->stateFlags &= ~ENHORSE_BOOST; this->stateFlags &= ~ENHORSE_BOOST_DECEL; - this->actor.speedXZ -= decel; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ = 0.0f; + this->actor.speed -= decel; + if (this->actor.speed < 0.0f) { + this->actor.speed = 0.0f; } return; } if (this->stateFlags & ENHORSE_BOOST) { if ((16 - this->boostTimer) > 0) { - this->actor.speedXZ = - (((EnHorse_SlopeSpeedMultiplier(this, play) * this->boostSpeed) - this->actor.speedXZ) / - (16.0f - this->boostTimer)) + - this->actor.speedXZ; + this->actor.speed = (((EnHorse_SlopeSpeedMultiplier(this, play) * this->boostSpeed) - this->actor.speed) / + (16.0f - this->boostTimer)) + + this->actor.speed; } else { - this->actor.speedXZ = EnHorse_SlopeSpeedMultiplier(this, play) * this->boostSpeed; + this->actor.speed = EnHorse_SlopeSpeedMultiplier(this, play) * this->boostSpeed; } - if ((EnHorse_SlopeSpeedMultiplier(this, play) * this->boostSpeed) <= this->actor.speedXZ) { + if ((EnHorse_SlopeSpeedMultiplier(this, play) * this->boostSpeed) <= this->actor.speed) { this->stateFlags &= ~ENHORSE_BOOST; this->stateFlags |= ENHORSE_BOOST_DECEL; } } else if (this->stateFlags & ENHORSE_BOOST_DECEL) { - if (this->actor.speedXZ > baseSpeed) { - this->actor.speedXZ -= 0.06f; - } else if (this->actor.speedXZ < baseSpeed) { - this->actor.speedXZ = baseSpeed; + if (this->actor.speed > baseSpeed) { + this->actor.speed -= 0.06f; + } else if (this->actor.speed < baseSpeed) { + this->actor.speed = baseSpeed; this->stateFlags &= ~ENHORSE_BOOST_DECEL; } } else { - if (this->actor.speedXZ <= (baseSpeed * (1.0f / 54.0f) * stickMag)) { + if (this->actor.speed <= (baseSpeed * (1.0f / 54.0f) * stickMag)) { phi_f0 = 1.0f; } else { phi_f0 = -1.0f; } - this->actor.speedXZ += phi_f0 * 50.0f * 0.01f; + this->actor.speed += phi_f0 * 50.0f * 0.01f; - if (this->actor.speedXZ > baseSpeed) { - this->actor.speedXZ -= decel; - if (this->actor.speedXZ < baseSpeed) { - this->actor.speedXZ = baseSpeed; + if (this->actor.speed > baseSpeed) { + this->actor.speed -= decel; + if (this->actor.speed < baseSpeed) { + this->actor.speed = baseSpeed; } } } temp_f12 = stickAngle * (1 / 32236.f); - turn = stickAngle * temp_f12 * temp_f12 * (2.2f - (this->actor.speedXZ * (1.0f / this->boostSpeed))); - turn = CLAMP(turn, -turnSpeed * (2.2f - (1.7f * this->actor.speedXZ * (1.0f / this->boostSpeed))), - turnSpeed * (2.2f - (1.7f * this->actor.speedXZ * (1.0f / this->boostSpeed)))); + turn = stickAngle * temp_f12 * temp_f12 * (2.2f - (this->actor.speed * (1.0f / this->boostSpeed))); + turn = CLAMP(turn, -turnSpeed * (2.2f - (1.7f * this->actor.speed * (1.0f / this->boostSpeed))), + turnSpeed * (2.2f - (1.7f * this->actor.speed * (1.0f / this->boostSpeed)))); this->actor.world.rot.y += turn; this->actor.shape.rot.y = this->actor.world.rot.y; } @@ -1141,7 +1141,7 @@ void EnHorse_MountedIdle(EnHorse* this, PlayState* play) { f32 mag; s16 angle = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; EnHorse_StickDirection(&this->curStick, &mag, &angle); if (mag > 10.0f) { if (EnHorse_PlayerCanMove(this, play) == true) { @@ -1188,7 +1188,7 @@ void EnHorse_MountedIdleWhinnying(EnHorse* this, PlayState* play) { f32 stickMag; s16 stickAngle = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); if (stickMag > 10.0f) { if (EnHorse_PlayerCanMove(this, play) == true) { @@ -1222,7 +1222,7 @@ void EnHorse_MountedTurn(EnHorse* this, PlayState* play) { s16 clampedYaw; s16 stickAngle; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; EnHorse_PlayWalkingSound(this); if (EnHorse_PlayerCanMove(this, play) == true) { EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); @@ -1300,15 +1300,15 @@ void EnHorse_MountedWalk(EnHorse* this, PlayState* play) { ((this->noInputTimer > 0) && (this->noInputTimer < (this->noInputTimerMax - 20)))) { EnHorse_UpdateSpeed(this, play, 0.3f, -0.5f, 10.0f, 0.06f, 3.0f, 0x320); } else { - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; } - if (this->actor.speedXZ == 0.0f) { + if (this->actor.speed == 0.0f) { this->stateFlags &= ~ENHORSE_FLAG_9; EnHorse_StartMountedIdleResetAnim(this); this->noInputTimer = 0; this->noInputTimerMax = 0; - } else if (this->actor.speedXZ > 3.0f) { + } else if (this->actor.speed > 3.0f) { this->stateFlags &= ~ENHORSE_FLAG_9; EnHorse_StartTrotting(this); this->noInputTimer = 0; @@ -1324,9 +1324,9 @@ void EnHorse_MountedWalk(EnHorse* this, PlayState* play) { if (this->waitTimer <= 0) { this->stateFlags &= ~ENHORSE_FLAG_9; - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; - if ((SkelAnime_Update(&this->skin.skelAnime) || (this->actor.speedXZ == 0.0f)) && (this->noInputTimer <= 0)) { - if (this->actor.speedXZ > 3.0f) { + this->skin.skelAnime.playSpeed = this->actor.speed * 0.75f; + if ((SkelAnime_Update(&this->skin.skelAnime) || (this->actor.speed == 0.0f)) && (this->noInputTimer <= 0)) { + if (this->actor.speed > 3.0f) { EnHorse_StartTrotting(this); this->noInputTimer = 0; this->noInputTimerMax = 0; @@ -1340,7 +1340,7 @@ void EnHorse_MountedWalk(EnHorse* this, PlayState* play) { } } else { this->waitTimer--; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } } @@ -1363,18 +1363,18 @@ void EnHorse_MountedTrot(EnHorse* this, PlayState* play) { EnHorse_UpdateSpeed(this, play, 0.3f, -0.5f, 10.0f, 0.06f, 6.0f, 800); EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); - if (this->actor.speedXZ < 3.0f) { + if (this->actor.speed < 3.0f) { EnHorse_StartWalkingInterruptable(this); } - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; + this->skin.skelAnime.playSpeed = this->actor.speed * 0.375f; if (SkelAnime_Update(&this->skin.skelAnime)) { func_8087C178(this); Rumble_Request(0.0f, 60, 8, 255); - if (this->actor.speedXZ >= 6.0f) { + if (this->actor.speed >= 6.0f) { EnHorse_StartGallopingInterruptable(this); - } else if (this->actor.speedXZ < 3.0f) { + } else if (this->actor.speed < 3.0f) { EnHorse_StartWalkingInterruptable(this); } else { EnHorse_MountedTrotReset(this); @@ -1428,14 +1428,14 @@ void EnHorse_MountedGallop(EnHorse* this, PlayState* play) { EnHorse_UpdateSpeed(this, play, 0.3f, -0.5f, 10.0f, 0.06f, 8.0f, 800); } else if (this->noInputTimer > 0) { this->noInputTimer--; - this->actor.speedXZ = 8.0f; + this->actor.speed = 8.0f; } - if (this->actor.speedXZ < 6.0f) { + if (this->actor.speed < 6.0f) { EnHorse_StartTrotting(this); } - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + this->skin.skelAnime.playSpeed = this->actor.speed * 0.3f; if (SkelAnime_Update(&this->skin.skelAnime)) { func_8087C1C0(this); @@ -1443,7 +1443,7 @@ void EnHorse_MountedGallop(EnHorse* this, PlayState* play) { if (EnHorse_PlayerCanMove(this, play) == true) { if ((stickMag >= 10.0f) && (Math_CosS(stickAngle) <= -0.5f)) { EnHorse_StartBraking(this, play); - } else if (this->actor.speedXZ < 6.0f) { + } else if (this->actor.speed < 6.0f) { EnHorse_StartTrotting(this); } else { EnHorse_MountedGallopReset(this); @@ -1491,7 +1491,7 @@ void EnHorse_MountedRearing(EnHorse* this, PlayState* play) { f32 stickMag; s16 stickAngle; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->curFrame > 25.0f) { if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { this->stateFlags |= ENHORSE_LAND2_SOUND; @@ -1560,15 +1560,15 @@ void EnHorse_StartBraking(EnHorse* this, PlayState* play) { } void EnHorse_Stopping(EnHorse* this, PlayState* play) { - if (this->actor.speedXZ > 0.0f) { - this->actor.speedXZ -= 0.6f; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ = 0.0f; + if (this->actor.speed > 0.0f) { + this->actor.speed -= 0.6f; + if (this->actor.speed < 0.0f) { + this->actor.speed = 0.0f; } } if ((this->stateFlags & ENHORSE_STOPPING_NEIGH_SOUND) && (this->skin.skelAnime.curFrame > 29.0f)) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if ((Rand_ZeroOne() > 0.5f) && ((gSaveContext.save.entrance != ENTRANCE(ROMANI_RANCH, 0)) || (Cutscene_GetSceneLayer(play) == 0))) { if (this->stateFlags & ENHORSE_DRAW) { @@ -1586,9 +1586,9 @@ void EnHorse_Stopping(EnHorse* this, PlayState* play) { } if (this->skin.skelAnime.curFrame > 29.0f) { - this->actor.speedXZ = 0.0f; - } else if ((this->actor.speedXZ > 3.0f) && (this->stateFlags & ENHORSE_FORCE_REVERSING)) { - this->actor.speedXZ = 3.0f; + this->actor.speed = 0.0f; + } else if ((this->actor.speed > 3.0f) && (this->stateFlags & ENHORSE_FORCE_REVERSING)) { + this->actor.speed = 3.0f; } if (SkelAnime_Update(&this->skin.skelAnime)) { @@ -1630,29 +1630,29 @@ void EnHorse_Reverse(EnHorse* this, PlayState* play) { ((this->noInputTimer > 0) && (this->noInputTimer < (this->noInputTimerMax - 20)))) { if ((stickMag < 10.0f) && (this->noInputTimer <= 0)) { EnHorse_StartMountedIdleResetAnim(this); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; return; } else if (stickMag < 10.0f) { stickAngle = -0x7FFF; } else if (Math_CosS(stickAngle) > -0.5f) { this->noInputTimerMax = 0; EnHorse_StartMountedIdleResetAnim(this); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; return; } } else if (stickMag < 10.0f) { stickAngle = -0x7FFF; } - } else if ((player->actor.flags & ACTOR_FLAG_100) || (play->csCtx.state != CS_STATE_0) || - (ActorCutscene_GetCurrentIndex() != -1) || (player->stateFlags1 & PLAYER_STATE1_20)) { + } else if ((player->actor.flags & ACTOR_FLAG_TALK_REQUESTED) || (play->csCtx.state != CS_STATE_IDLE) || + (CutsceneManager_GetCurrentCsId() != CS_ID_NONE) || (player->stateFlags1 & PLAYER_STATE1_20)) { EnHorse_StartMountedIdleResetAnim(this); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; return; } else { stickAngle = -0x7FFF; } - this->actor.speedXZ = -2.0f; + this->actor.speed = -2.0f; turnAmount = -0x8000 - stickAngle; turnAmount = CLAMP(turnAmount, -2400.0f, 2400.0f); this->actor.world.rot.y += turnAmount; @@ -1665,7 +1665,7 @@ void EnHorse_Reverse(EnHorse* this, PlayState* play) { } } - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.5f * 1.5f; + this->skin.skelAnime.playSpeed = this->actor.speed * 0.5f * 1.5f; if (SkelAnime_Update(&this->skin.skelAnime) && (this->noInputTimer <= 0) && (EnHorse_PlayerCanMove(this, play) == true)) { @@ -1724,8 +1724,8 @@ void EnHorse_LowJump(EnHorse* this, PlayState* play) { this->stateFlags |= ENHORSE_JUMPING; - if (this->actor.speedXZ < 12.0f) { - this->actor.speedXZ = 12.0f; + if (this->actor.speed < 12.0f) { + this->actor.speed = 12.0f; } if (this->actor.floorHeight != BGCHECK_Y_MIN) { @@ -1822,8 +1822,8 @@ void EnHorse_HighJump(EnHorse* this, PlayState* play) { this->stateFlags |= ENHORSE_JUMPING; - if (this->actor.speedXZ < 13.0f) { - this->actor.speedXZ = 13.0f; + if (this->actor.speed < 13.0f) { + this->actor.speed = 13.0f; } if (this->actor.floorHeight != BGCHECK_Y_MIN) { @@ -1908,7 +1908,7 @@ void EnHorse_Inactive(EnHorse* this, PlayState* play) { void EnHorse_PlayIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames) { this->action = ENHORSE_ACTION_IDLE; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if ((anim != ENHORSE_ANIM_IDLE) && (anim != ENHORSE_ANIM_WHINNY) && (anim != ENHORSE_ANIM_REARING)) { anim = ENHORSE_ANIM_IDLE; @@ -1963,7 +1963,7 @@ void EnHorse_StartIdleRidable(EnHorse* this) { } void EnHorse_Idle(EnHorse* this, PlayState* play) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; EnHorse_IdleAnimSounds(this, play); if ((D_801BDAA4 != 0) && (this->type == HORSE_TYPE_2)) { @@ -2026,7 +2026,7 @@ void EnHorse_StartMovingAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 void EnHorse_SetFollowAnimation(EnHorse* this, PlayState* play) { s32 anim = ENHORSE_ANIM_WALK; - f32 distToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(play)->actor); + f32 distToPlayer = Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(play)->actor); if (distToPlayer > 400.0f) { anim = ENHORSE_ANIM_GALLOP; @@ -2063,7 +2063,7 @@ void EnHorse_FollowPlayer(EnHorse* this, PlayState* play) { f32 distToPlayer; D_801BDAA4 = 0; - distToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(play)->actor); + distToPlayer = Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(play)->actor); if (((this->playerDir == PLAYER_DIR_BACK_R) || (this->playerDir == PLAYER_DIR_BACK_L)) && (distToPlayer > 300.0f) && !(this->stateFlags & ENHORSE_TURNING_TO_PLAYER)) { @@ -2071,7 +2071,7 @@ void EnHorse_FollowPlayer(EnHorse* this, PlayState* play) { this->animIndex = ENHORSE_ANIM_REARING; this->stateFlags |= ENHORSE_TURNING_TO_PLAYER; - this->angleToPlayer = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(play)->actor); + this->angleToPlayer = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(play)->actor); angleDiff = (f32)this->angleToPlayer - this->actor.world.rot.y; if (angleDiff > 0x7FFF) { @@ -2102,18 +2102,18 @@ void EnHorse_FollowPlayer(EnHorse* this, PlayState* play) { } if (this->animIndex == ENHORSE_ANIM_GALLOP) { - this->actor.speedXZ = 8.0f; - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + this->actor.speed = 8.0f; + this->skin.skelAnime.playSpeed = this->actor.speed * 0.3f; } else { if (this->animIndex == ENHORSE_ANIM_TROT) { - this->actor.speedXZ = 6.0f; - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; + this->actor.speed = 6.0f; + this->skin.skelAnime.playSpeed = this->actor.speed * 0.375f; } else if (this->animIndex == ENHORSE_ANIM_WALK) { - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; EnHorse_PlayWalkingSound(this); - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + this->skin.skelAnime.playSpeed = this->actor.speed * 0.75f; } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->skin.skelAnime.playSpeed = 1.0f; } } @@ -2152,7 +2152,7 @@ void EnHorse_FollowPlayer(EnHorse* this, PlayState* play) { void EnHorse_InitIngoHorse(EnHorse* this) { this->curRaceWaypoint = 0; this->soundTimer = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; EnHorse_UpdateIngoHorseAnim(this); if (this->stateFlags & ENHORSE_DRAW) { Audio_PlaySfxAtPos(&this->unk_218, NA_SE_IT_INGO_HORSE_NEIGH); @@ -2177,17 +2177,17 @@ void EnHorse_UpdateIngoHorseAnim(EnHorse* this) { this->action = ENHORSE_ACTION_INGO_RACE; this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; - if (this->actor.speedXZ == 0.0f) { + if (this->actor.speed == 0.0f) { if (this->animIndex != ENHORSE_ANIM_IDLE) { animChanged = true; } this->animIndex = ENHORSE_ANIM_IDLE; - } else if (this->actor.speedXZ <= 3.0f) { + } else if (this->actor.speed <= 3.0f) { if (this->animIndex != ENHORSE_ANIM_WALK) { animChanged = true; } this->animIndex = ENHORSE_ANIM_WALK; - } else if (this->actor.speedXZ <= 6.0f) { + } else if (this->actor.speed <= 6.0f) { if (this->animIndex != ENHORSE_ANIM_TROT) { animChanged = true; } @@ -2200,16 +2200,16 @@ void EnHorse_UpdateIngoHorseAnim(EnHorse* this) { } if (this->animIndex == ENHORSE_ANIM_WALK) { - animSpeed = this->actor.speedXZ * 0.5f; + animSpeed = this->actor.speed * 0.5f; } else if (this->animIndex == ENHORSE_ANIM_TROT) { - animSpeed = this->actor.speedXZ * 0.25f; + animSpeed = this->actor.speed * 0.25f; if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); } } else if (this->animIndex == ENHORSE_ANIM_GALLOP) { - animSpeed = this->actor.speedXZ * 0.2f; + animSpeed = this->actor.speed * 0.2f; if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); } else { @@ -2240,26 +2240,26 @@ void EnHorse_UpdateIngoRace(EnHorse* this, PlayState* play) { } if (!this->inRace) { - this->actor.speedXZ = 0.0f; - this->rider->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; + this->rider->actor.speed = 0.0f; if (this->animIndex != ENHORSE_ANIM_IDLE) { EnHorse_UpdateIngoHorseAnim(this); } } if (this->animIndex == ENHORSE_ANIM_WALK) { - playSpeed = this->actor.speedXZ * 0.5f; + playSpeed = this->actor.speed * 0.5f; } else if (this->animIndex == ENHORSE_ANIM_TROT) { - playSpeed = this->actor.speedXZ * 0.25f; + playSpeed = this->actor.speed * 0.25f; } else if (this->animIndex == ENHORSE_ANIM_GALLOP) { - playSpeed = this->actor.speedXZ * 0.2f; + playSpeed = this->actor.speed * 0.2f; } else { playSpeed = 1.0f; } this->skin.skelAnime.playSpeed = playSpeed; if (SkelAnime_Update(&this->skin.skelAnime) || - ((this->animIndex == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + ((this->animIndex == ENHORSE_ANIM_IDLE) && (this->actor.speed != 0.0f))) { EnHorse_UpdateIngoHorseAnim(this); } } @@ -2296,8 +2296,8 @@ void func_80881398(EnHorse* this, PlayState* play) { f32 curFrame; this->stateFlags |= ENHORSE_JUMPING; - if (this->actor.speedXZ < 14.0f) { - this->actor.speedXZ = 14.0f; + if (this->actor.speed < 14.0f) { + this->actor.speed = 14.0f; } animeUpdated = SkelAnime_Update(&this->skin.skelAnime); @@ -2352,7 +2352,7 @@ void func_8088159C(EnHorse* this, PlayState* play) { void func_80881634(EnHorse* this) { this->curRaceWaypoint = 0; this->soundTimer = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; func_8088168C(this); if (this->stateFlags & ENHORSE_DRAW) { Audio_PlaySfxAtPos(&this->unk_218, NA_SE_IT_INGO_HORSE_NEIGH); @@ -2367,17 +2367,17 @@ void func_8088168C(EnHorse* this) { this->action = ENHORSE_ACTION_5; this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; - if (this->actor.speedXZ == 0.0f) { + if (this->actor.speed == 0.0f) { if (this->animIndex != ENHORSE_ANIM_IDLE) { animChanged = true; } this->animIndex = ENHORSE_ANIM_IDLE; - } else if (this->actor.speedXZ <= 3.0f) { + } else if (this->actor.speed <= 3.0f) { if (this->animIndex != ENHORSE_ANIM_WALK) { animChanged = true; } this->animIndex = ENHORSE_ANIM_WALK; - } else if (this->actor.speedXZ <= 6.0f) { + } else if (this->actor.speed <= 6.0f) { if (this->animIndex != ENHORSE_ANIM_TROT) { animChanged = true; } @@ -2390,16 +2390,16 @@ void func_8088168C(EnHorse* this) { } if (this->animIndex == ENHORSE_ANIM_WALK) { - animSpeed = this->actor.speedXZ * 0.5f; + animSpeed = this->actor.speed * 0.5f; } else if (this->animIndex == ENHORSE_ANIM_TROT) { - animSpeed = this->actor.speedXZ * 0.25f; + animSpeed = this->actor.speed * 0.25f; if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); } else { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); } } else if (this->animIndex == ENHORSE_ANIM_GALLOP) { - animSpeed = this->actor.speedXZ * 0.2f; + animSpeed = this->actor.speed * 0.2f; if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); } else { @@ -2434,8 +2434,8 @@ void func_808819D8(EnHorse* this, PlayState* play) { } if (!this->inRace) { - this->actor.speedXZ = 0.0f; - this->rider->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; + this->rider->actor.speed = 0.0f; if (this->animIndex != ENHORSE_ANIM_IDLE) { EnHorse_UpdateIngoHorseAnim(this); } @@ -2450,29 +2450,29 @@ void func_808819D8(EnHorse* this, PlayState* play) { } if (!this->inRace) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->animIndex != ENHORSE_ANIM_IDLE) { func_8088168C(this); } } if (this->animIndex == ENHORSE_ANIM_WALK) { - animSpeed = this->actor.speedXZ * 0.5f; + animSpeed = this->actor.speed * 0.5f; } else if (this->animIndex == ENHORSE_ANIM_TROT) { - animSpeed = this->actor.speedXZ * 0.25f; + animSpeed = this->actor.speed * 0.25f; } else if (this->animIndex == ENHORSE_ANIM_GALLOP) { - animSpeed = this->actor.speedXZ * 0.2f; + animSpeed = this->actor.speed * 0.2f; } else { animSpeed = 1.0f; } this->skin.skelAnime.playSpeed = animSpeed; if (SkelAnime_Update(&this->skin.skelAnime) || - ((this->animIndex == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + ((this->animIndex == ENHORSE_ANIM_IDLE) && (this->actor.speed != 0.0f))) { func_8088168C(this); } - if (GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_3) { + if (GET_WEEKEVENTREG_HORSE_RACE_STATE == WEEKEVENTREG_HORSE_RACE_STATE_3) { this->rider->unk488 = 7; } else { EnHorse_SetIngoAnimation(this->animIndex, this->skin.skelAnime.curFrame, this->unk_394 & 1, @@ -2480,35 +2480,35 @@ void func_808819D8(EnHorse* this, PlayState* play) { } } -void EnHorse_CsMoveInit(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void EnHorse_CsMoveInit(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { this->animIndex = ENHORSE_ANIM_GALLOP; this->cutsceneAction = 1; Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], - this->actor.speedXZ * 0.2f * 1.5f); + this->actor.speed * 0.2f * 1.5f); } -void EnHorse_CsMoveToPoint(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void EnHorse_CsMoveToPoint(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { Vec3f endPos; s32 pad; - endPos.x = action->endPos.x; - endPos.y = action->endPos.y; - endPos.z = action->endPos.z; + endPos.x = cue->endPos.x; + endPos.y = cue->endPos.y; + endPos.z = cue->endPos.z; if (Math3D_Distance(&endPos, &this->actor.world.pos) > 8.0f) { EnHorse_RotateToPoint(this, play, &endPos, 0x320); - this->actor.speedXZ = 8.0f; - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + this->actor.speed = 8.0f; + this->skin.skelAnime.playSpeed = this->actor.speed * 0.3f; } else { this->actor.world.pos = endPos; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } if (SkelAnime_Update(&this->skin.skelAnime)) { func_8087C1C0(this); Rumble_Request(0.0f, 120, 8, 255); Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], - this->actor.speedXZ * 0.3f); + this->actor.speed * 0.3f); } } @@ -2544,25 +2544,25 @@ void EnHorse_CsPlayHighJumpAnim(EnHorse* this, PlayState* play) { Rumble_Request(0.0f, 170, 10, 10); } -void EnHorse_CsJumpInit(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void EnHorse_CsJumpInit(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { EnHorse_CsSetAnimHighJump(this, play); this->cutsceneAction = 2; this->cutsceneFlags &= ~1; } -void EnHorse_CsJump(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void EnHorse_CsJump(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { f32 curFrame; f32 y; Vec3s* jointTable; s32 pad[2]; if (this->cutsceneFlags & 1) { - EnHorse_CsMoveToPoint(this, play, action); + EnHorse_CsMoveToPoint(this, play, cue); return; } curFrame = this->skin.skelAnime.curFrame; - this->actor.speedXZ = 13.0f; + this->actor.speed = 13.0f; this->stateFlags |= ENHORSE_JUMPING; if (curFrame > 19.0f) { @@ -2609,7 +2609,7 @@ void EnHorse_CsJump(EnHorse* this, PlayState* play, CsCmdActorAction* action) { } } -void EnHorse_CsRearingInit(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void EnHorse_CsRearingInit(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { this->animIndex = ENHORSE_ANIM_REARING; this->cutsceneAction = 3; this->cutsceneFlags &= ~4; @@ -2625,8 +2625,8 @@ void EnHorse_CsRearingInit(EnHorse* this, PlayState* play, CsCmdActorAction* act Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); } -void EnHorse_CsRearing(EnHorse* this, PlayState* play, CsCmdActorAction* action) { - this->actor.speedXZ = 0.0f; +void EnHorse_CsRearing(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { + this->actor.speed = 0.0f; if (this->curFrame > 25.0f) { if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { this->stateFlags |= ENHORSE_LAND2_SOUND; @@ -2653,53 +2653,53 @@ void EnHorse_CsRearing(EnHorse* this, PlayState* play, CsCmdActorAction* action) } } -void EnHorse_WarpMoveInit(EnHorse* this, PlayState* play, CsCmdActorAction* action) { - this->actor.world.pos.x = action->startPos.x; - this->actor.world.pos.y = action->startPos.y; - this->actor.world.pos.z = action->startPos.z; +void EnHorse_WarpMoveInit(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { + this->actor.world.pos.x = cue->startPos.x; + this->actor.world.pos.y = cue->startPos.y; + this->actor.world.pos.z = cue->startPos.z; this->actor.prevPos = this->actor.world.pos; - this->actor.world.rot.y = action->urot.y; + this->actor.world.rot.y = cue->rot.y; this->actor.shape.rot = this->actor.world.rot; this->animIndex = ENHORSE_ANIM_GALLOP; this->cutsceneAction = 4; Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], - this->actor.speedXZ * 0.3f); + this->actor.speed * 0.3f); } -void EnHorse_CsWarpMoveToPoint(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void EnHorse_CsWarpMoveToPoint(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { Vec3f endPos; s32 pad; - endPos.x = action->endPos.x; - endPos.y = action->endPos.y; - endPos.z = action->endPos.z; + endPos.x = cue->endPos.x; + endPos.y = cue->endPos.y; + endPos.z = cue->endPos.z; if (Math3D_Distance(&endPos, &this->actor.world.pos) > 8.0f) { EnHorse_RotateToPoint(this, play, &endPos, 0x320); - this->actor.speedXZ = 8.0f; - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + this->actor.speed = 8.0f; + this->skin.skelAnime.playSpeed = this->actor.speed * 0.3f; } else { this->actor.world.pos = endPos; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } if (SkelAnime_Update(&this->skin.skelAnime)) { func_8087C1C0(this); Rumble_Request(0.0f, 120, 8, 255); Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], - this->actor.speedXZ * 0.3f); + this->actor.speed * 0.3f); } } -void EnHorse_CsWarpRearingInit(EnHorse* this, PlayState* play, CsCmdActorAction* action) { - this->actor.world.pos.x = action->startPos.x; - this->actor.world.pos.y = action->startPos.y; - this->actor.world.pos.z = action->startPos.z; +void EnHorse_CsWarpRearingInit(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { + this->actor.world.pos.x = cue->startPos.x; + this->actor.world.pos.y = cue->startPos.y; + this->actor.world.pos.z = cue->startPos.z; this->actor.prevPos = this->actor.world.pos; - this->actor.world.rot.y = action->urot.y; + this->actor.world.rot.y = cue->rot.y; this->actor.shape.rot = this->actor.world.rot; this->animIndex = ENHORSE_ANIM_REARING; @@ -2718,8 +2718,8 @@ void EnHorse_CsWarpRearingInit(EnHorse* this, PlayState* play, CsCmdActorAction* Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); } -void EnHorse_CsWarpRearing(EnHorse* this, PlayState* play, CsCmdActorAction* action) { - this->actor.speedXZ = 0.0f; +void EnHorse_CsWarpRearing(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { + this->actor.speed = 0.0f; if (this->curFrame > 25.0f) { if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { this->stateFlags |= ENHORSE_LAND2_SOUND; @@ -2750,19 +2750,19 @@ void EnHorse_InitCutscene(EnHorse* this, PlayState* play) { this->playerControlled = false; this->action = ENHORSE_ACTION_CS_UPDATE; this->cutsceneAction = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } -s32 EnHorse_GetCutsceneFunctionIndex(s32 csAction) { +s32 EnHorse_GetCutsceneFunctionIndex(s32 cueId) { s32 numActions = ARRAY_COUNT(sCsActionTable); // prevents unrolling s32 i; for (i = 0; i < numActions; i++) { - if (csAction == sCsActionTable[i].csAction) { + if (cueId == sCsActionTable[i].cueId) { return sCsActionTable[i].csFuncIdx; } - if (csAction < sCsActionTable[i].csAction) { + if (cueId < sCsActionTable[i].cueId) { return 0; } } @@ -2771,9 +2771,9 @@ s32 EnHorse_GetCutsceneFunctionIndex(s32 csAction) { void EnHorse_CutsceneUpdate(EnHorse* this, PlayState* play) { s32 csFunctionIdx; - CsCmdActorAction* playerAction = play->csCtx.playerAction; + CsCmdActorCue* playerCue = play->csCtx.playerCue; - if (play->csCtx.state == CS_STATE_3) { + if (play->csCtx.state == CS_STATE_STOP) { this->playerControlled = true; this->actor.params = ENHORSE_12; this->action = ENHORSE_ACTION_IDLE; @@ -2781,23 +2781,23 @@ void EnHorse_CutsceneUpdate(EnHorse* this, PlayState* play) { return; } - if (playerAction != NULL) { - csFunctionIdx = EnHorse_GetCutsceneFunctionIndex(playerAction->action); + if (playerCue != NULL) { + csFunctionIdx = EnHorse_GetCutsceneFunctionIndex(playerCue->id); if (csFunctionIdx != 0) { if (csFunctionIdx != this->cutsceneAction) { if (this->cutsceneAction == 0) { - this->actor.world.pos.x = playerAction->startPos.x; - this->actor.world.pos.y = playerAction->startPos.y; - this->actor.world.pos.z = playerAction->startPos.z; + this->actor.world.pos.x = playerCue->startPos.x; + this->actor.world.pos.y = playerCue->startPos.y; + this->actor.world.pos.z = playerCue->startPos.z; - this->actor.world.rot.y = playerAction->urot.y; + this->actor.world.rot.y = playerCue->rot.y; this->actor.shape.rot = this->actor.world.rot; this->actor.prevPos = this->actor.world.pos; } this->cutsceneAction = csFunctionIdx; - sCutsceneInitFuncs[csFunctionIdx](this, play, playerAction); + sCutsceneInitFuncs[csFunctionIdx](this, play, playerCue); } - sCutsceneActionFuncs[this->cutsceneAction](this, play, playerAction); + sCutsceneActionFuncs[this->cutsceneAction](this, play, playerCue); } } } @@ -2829,12 +2829,12 @@ s32 EnHorse_UpdateHbaRaceInfo(EnHorse* this, PlayState* play, RaceInfo* raceInfo } this->actor.shape.rot.y = this->actor.world.rot.y; - if ((this->actor.speedXZ < raceInfo->waypoints[this->curRaceWaypoint].speed) && !(this->hbaFlags & 1)) { - this->actor.speedXZ += 0.4f; + if ((this->actor.speed < raceInfo->waypoints[this->curRaceWaypoint].speed) && !(this->hbaFlags & 1)) { + this->actor.speed += 0.4f; } else { - this->actor.speedXZ -= 0.4f; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ = 0.0f; + this->actor.speed -= 0.4f; + if (this->actor.speed < 0.0f) { + this->actor.speed = 0.0f; } } return false; @@ -2845,7 +2845,7 @@ void EnHorse_InitHorsebackArchery(EnHorse* this) { this->soundTimer = 0; this->curRaceWaypoint = 0; this->hbaTimer = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; EnHorse_UpdateHbaAnim(this); } @@ -2854,17 +2854,17 @@ void EnHorse_UpdateHbaAnim(EnHorse* this) { f32 animSpeed; this->action = ENHORSE_ACTION_HBA; - if (this->actor.speedXZ == 0.0f) { + if (this->actor.speed == 0.0f) { if (this->animIndex != ENHORSE_ANIM_IDLE) { animChanged = true; } this->animIndex = ENHORSE_ANIM_IDLE; - } else if (this->actor.speedXZ <= 3.0f) { + } else if (this->actor.speed <= 3.0f) { if (this->animIndex != ENHORSE_ANIM_WALK) { animChanged = true; } this->animIndex = ENHORSE_ANIM_WALK; - } else if (this->actor.speedXZ <= 6.0f) { + } else if (this->actor.speed <= 6.0f) { if (this->animIndex != ENHORSE_ANIM_TROT) { animChanged = true; } @@ -2877,9 +2877,9 @@ void EnHorse_UpdateHbaAnim(EnHorse* this) { } if (this->animIndex == ENHORSE_ANIM_WALK) { - animSpeed = this->actor.speedXZ * 0.5f; + animSpeed = this->actor.speed * 0.5f; } else if (this->animIndex == ENHORSE_ANIM_TROT) { - animSpeed = this->actor.speedXZ * 0.25f; + animSpeed = this->actor.speed * 0.25f; if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); } else { @@ -2887,7 +2887,7 @@ void EnHorse_UpdateHbaAnim(EnHorse* this) { } Rumble_Request(0.0f, 60, 8, 255); } else if (this->animIndex == ENHORSE_ANIM_GALLOP) { - animSpeed = this->actor.speedXZ * 0.2f; + animSpeed = this->actor.speed * 0.2f; if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); } else { @@ -2926,7 +2926,7 @@ void EnHorse_UpdateHorsebackArchery(EnHorse* this, PlayState* play) { if (((this->hbaFlags & 1) || (this->hbaTimer > 45)) && (sp28 != 1) && (gSaveContext.minigameStatus != MINIGAME_STATUS_END)) { - gSaveContext.save.cutscene = 0; + gSaveContext.save.cutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_64; } @@ -2935,29 +2935,29 @@ void EnHorse_UpdateHorsebackArchery(EnHorse* this, PlayState* play) { if (((play->interfaceCtx.minigameAmmo == 0) || (this->hbaFlags & 2)) && (this->hbaFlags & 4)) { this->hbaFlags &= ~4; - Audio_QueueSeqCmd(0x8041); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_HORSE_GOAL | SEQ_FLAG_ASYNC); } if (this->hbaStarted == 0) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->animIndex != ENHORSE_ANIM_IDLE) { EnHorse_UpdateHbaAnim(this); } } if (this->animIndex == ENHORSE_ANIM_WALK) { - playSpeed = this->actor.speedXZ * 0.5f; + playSpeed = this->actor.speed * 0.5f; } else if (this->animIndex == ENHORSE_ANIM_TROT) { - playSpeed = this->actor.speedXZ * 0.25f; + playSpeed = this->actor.speed * 0.25f; } else if (this->animIndex == ENHORSE_ANIM_GALLOP) { - playSpeed = this->actor.speedXZ * 0.2f; + playSpeed = this->actor.speed * 0.2f; } else { playSpeed = 1.0f; } this->skin.skelAnime.playSpeed = playSpeed; if (SkelAnime_Update(&this->skin.skelAnime) || - ((this->animIndex == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + ((this->animIndex == ENHORSE_ANIM_IDLE) && (this->actor.speed != 0.0f))) { EnHorse_UpdateHbaAnim(this); } } @@ -2986,36 +2986,36 @@ void EnHorse_FleePlayer(EnHorse* this, PlayState* play) { if (playerDistToHome > 300.0f) { if (distToHome > 150.0f) { - this->actor.speedXZ += 0.4f; - if (this->actor.speedXZ > 8.0f) { - this->actor.speedXZ = 8.0f; + this->actor.speed += 0.4f; + if (this->actor.speed > 8.0f) { + this->actor.speed = 8.0f; } } else { - this->actor.speedXZ -= 0.5f; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ = 0.0f; + this->actor.speed -= 0.5f; + if (this->actor.speed < 0.0f) { + this->actor.speed = 0.0f; } } } else if (distToPlayer < 300.0f) { - this->actor.speedXZ += 0.4f; - if (this->actor.speedXZ > 8.0f) { - this->actor.speedXZ = 8.0f; + this->actor.speed += 0.4f; + if (this->actor.speed > 8.0f) { + this->actor.speed = 8.0f; } } else { - this->actor.speedXZ -= 0.5f; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ = 0.0f; + this->actor.speed -= 0.5f; + if (this->actor.speed < 0.0f) { + this->actor.speed = 0.0f; } } - if (this->actor.speedXZ >= 6.0f) { - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + if (this->actor.speed >= 6.0f) { + this->skin.skelAnime.playSpeed = this->actor.speed * 0.3f; nextAnimIndex = ENHORSE_ANIM_GALLOP; - } else if (this->actor.speedXZ >= 3.0f) { - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; + } else if (this->actor.speed >= 3.0f) { + this->skin.skelAnime.playSpeed = this->actor.speed * 0.375f; nextAnimIndex = ENHORSE_ANIM_TROT; - } else if (this->actor.speedXZ > 0.1f) { - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + } else if (this->actor.speed > 0.1f) { + this->skin.skelAnime.playSpeed = this->actor.speed * 0.75f; nextAnimIndex = ENHORSE_ANIM_WALK; EnHorse_PlayWalkingSound(this); } else { @@ -3032,7 +3032,7 @@ void EnHorse_FleePlayer(EnHorse* this, PlayState* play) { (nextAnimIndex == ENHORSE_ANIM_WALK)) { if (playerDistToHome < 300.0f) { yaw = player->actor.shape.rot.y; - yaw += ((Actor_YawBetweenActors(&this->actor, &player->actor) > 0) ? 1 : -1) * 0x3FFF; + yaw += ((Actor_WorldYawTowardActor(&this->actor, &player->actor) > 0) ? 1 : -1) * 0x3FFF; } else { yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos) - this->actor.world.rot.y; } @@ -3109,28 +3109,28 @@ void EnHorse_FleePlayer(EnHorse* this, PlayState* play) { } } -void func_80883B70(EnHorse* this, CsCmdActorAction* action) { - this->actor.world.pos.x = action->startPos.x; - this->actor.world.pos.y = action->startPos.y; - this->actor.world.pos.z = action->startPos.z; +void func_80883B70(EnHorse* this, CsCmdActorCue* cue) { + this->actor.world.pos.x = cue->startPos.x; + this->actor.world.pos.y = cue->startPos.y; + this->actor.world.pos.z = cue->startPos.z; - this->actor.world.rot.y = action->urot.y; + this->actor.world.rot.y = cue->rot.y; this->actor.shape.rot = this->actor.world.rot; this->actor.prevPos = this->actor.world.pos; } -void func_80883BEC(EnHorse* this, PlayState* play, CsCmdActorAction* action) { - func_80883B70(this, action); +void func_80883BEC(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { + func_80883B70(this, cue); this->animIndex = ENHORSE_ANIM_IDLE; - this->unk_3E0 = 1; + this->cueId = 1; this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); this->stateFlags |= ENHORSE_SANDDUST_SOUND; } -void func_80883CB0(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void func_80883CB0(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { EnHorse_IdleAnimSounds(this, play); if (SkelAnime_Update(&this->skin.skelAnime)) { this->animIndex = ENHORSE_ANIM_IDLE; @@ -3139,74 +3139,74 @@ void func_80883CB0(EnHorse* this, PlayState* play, CsCmdActorAction* action) { } } -void func_80883D64(EnHorse* this, PlayState* play, CsCmdActorAction* action) { - func_80883B70(this, action); - this->unk_3E0 = 2; +void func_80883D64(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { + func_80883B70(this, cue); + this->cueId = 2; Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00A8DC, 0.0f, 0.0f, Animation_GetLastFrame(&object_horse_link_child_Anim_00A8DC), ANIMMODE_ONCE, 0.0f); } -void func_80883DE0(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void func_80883DE0(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { SkelAnime_Update(&this->skin.skelAnime); } -void func_80883E10(EnHorse* this, PlayState* play, CsCmdActorAction* action) { - func_80883B70(this, action); - this->unk_3E0 = 3; +void func_80883E10(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { + func_80883B70(this, cue); + this->cueId = 3; Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00A8DC, 1.0f, 0.0f, Animation_GetLastFrame(&object_horse_link_child_Anim_00A8DC), ANIMMODE_ONCE, -3.0f); Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); } -void func_80883EA0(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void func_80883EA0(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { if (SkelAnime_Update(&this->skin.skelAnime)) { Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00B3E0, 1.0f, 11.0f, Animation_GetLastFrame(&object_horse_link_child_Anim_00B3E0), ANIMMODE_ONCE, 0.0f); } } -void func_80883F18(EnHorse* this, PlayState* play, CsCmdActorAction* action) { - func_80883B70(this, action); - this->unk_3E0 = 4; +void func_80883F18(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { + func_80883B70(this, cue); + this->cueId = 4; Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00AD08, 1.0f, 0.0f, Animation_GetLastFrame(&object_horse_link_child_Anim_00AD08), ANIMMODE_ONCE, -3.0f); } -void func_80883F98(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void func_80883F98(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { if (Animation_OnFrame(&this->skin.skelAnime, Animation_GetLastFrame(&object_horse_link_child_Anim_00AD08) - 1.0f)) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); } SkelAnime_Update(&this->skin.skelAnime); } -void func_80884010(EnHorse* this, PlayState* play, CsCmdActorAction* action) { - func_80883B70(this, action); - this->unk_3E0 = 5; +void func_80884010(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { + func_80883B70(this, cue); + this->cueId = 5; this->animIndex = ENHORSE_ANIM_WALK; Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); } -void func_808840C4(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void func_808840C4(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { EnHorse_PlayWalkingSound(this); - Cutscene_ActorTranslateAndYaw(&this->actor, play, this->unk_530); + Cutscene_ActorTranslateAndYaw(&this->actor, play, this->cueChannel); if (SkelAnime_Update(&this->skin.skelAnime)) { Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); } } -void func_80884194(EnHorse* this, PlayState* play, CsCmdActorAction* action) { - func_80883B70(this, action); - this->unk_3E0 = 6; +void func_80884194(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { + func_80883B70(this, cue); + this->cueId = 6; this->animIndex = ENHORSE_ANIM_GALLOP; Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, -3.0f); func_8087C1C0(this); } -void func_8088424C(EnHorse* this, PlayState* play, CsCmdActorAction* action) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, this->unk_530); +void func_8088424C(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, this->cueChannel); if (SkelAnime_Update(&this->skin.skelAnime)) { Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, 0.0f, Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); @@ -3214,36 +3214,36 @@ void func_8088424C(EnHorse* this, PlayState* play, CsCmdActorAction* action) { } } -void func_80884314(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void func_80884314(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); - func_80883B70(this, action); - this->unk_3E0 = 7; + func_80883B70(this, cue); + this->cueId = 7; Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00D178, 1.0f, 0.0f, Animation_GetLastFrame(&object_horse_link_child_Anim_00D178), ANIMMODE_ONCE, 0.0f); Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); } -void func_808843B4(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void func_808843B4(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { SkelAnime_Update(&this->skin.skelAnime); if (this->curFrame > 42.0f) { if (((s32)this->curFrame % 11) == 0) { func_8087C1C0(this); } - Cutscene_ActorTranslateAndYaw(&this->actor, play, this->unk_530); + Cutscene_ActorTranslateAndYaw(&this->actor, play, this->cueChannel); } } -void func_80884444(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void func_80884444(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); - func_80883B70(this, action); + func_80883B70(this, cue); this->cutsceneAction = 8; Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00D4E8, 1.0f, 0.0f, Animation_GetLastFrame(&object_horse_link_child_Anim_00D4E8), ANIMMODE_ONCE, 0.0f); func_8087C1C0(this); } -void func_808844E0(EnHorse* this, PlayState* play, CsCmdActorAction* action) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, this->unk_530); +void func_808844E0(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, this->cueChannel); if (SkelAnime_Update(&this->skin.skelAnime)) { Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00D4E8, 1.0f, 0.0f, Animation_GetLastFrame(&object_horse_link_child_Anim_00D4E8), ANIMMODE_ONCE, 0.0f); @@ -3251,17 +3251,17 @@ void func_808844E0(EnHorse* this, PlayState* play, CsCmdActorAction* action) { } } -void func_80884564(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void func_80884564(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); - func_80883B70(this, action); + func_80883B70(this, cue); this->cutsceneAction = 8; Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00BDE0, 1.0f, 0.0f, Animation_GetLastFrame(&object_horse_link_child_Anim_00BDE0), ANIMMODE_ONCE, -3.0f); func_8087C1C0(this); } -void func_80884604(EnHorse* this, PlayState* play, CsCmdActorAction* action) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, this->unk_530); +void func_80884604(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, this->cueChannel); if (SkelAnime_Update(&this->skin.skelAnime)) { Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00BDE0, 1.0f, 0.0f, Animation_GetLastFrame(&object_horse_link_child_Anim_00BDE0), ANIMMODE_ONCE, 0.0f); @@ -3272,48 +3272,48 @@ void func_80884604(EnHorse* this, PlayState* play, CsCmdActorAction* action) { } } -void func_808846B4(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void func_808846B4(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { Actor_Kill(&this->actor); } -void func_808846DC(EnHorse* this, PlayState* play, CsCmdActorAction* action) { +void func_808846DC(EnHorse* this, PlayState* play, CsCmdActorCue* cue) { } void func_808846F0(EnHorse* this, PlayState* play) { this->playerControlled = false; this->action = ENHORSE_ACTION_21; - this->unk_3E0 = -1; - this->actor.speedXZ = 0.0f; + this->cueId = -1; + this->actor.speed = 0.0f; } void func_80884718(EnHorse* this, PlayState* play) { - CsCmdActorAction* action; + CsCmdActorCue* cue; - if (Cutscene_CheckActorAction(play, 0x70)) { - this->unk_530 = Cutscene_GetActorActionIndex(play, 0x70); - action = play->csCtx.actorActions[this->unk_530]; + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_112)) { + this->cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_112); + cue = play->csCtx.actorCues[this->cueChannel]; this->unk_1EC |= 0x20; - if (this->unk_3E0 != action->action) { - if (this->unk_3E0 == -1) { - this->actor.world.pos.x = action->startPos.x; - this->actor.world.pos.y = action->startPos.y; - this->actor.world.pos.z = action->startPos.z; + if (this->cueId != cue->id) { + if (this->cueId == -1) { + this->actor.world.pos.x = cue->startPos.x; + this->actor.world.pos.y = cue->startPos.y; + this->actor.world.pos.z = cue->startPos.z; - this->actor.world.rot.y = action->urot.y; + this->actor.world.rot.y = cue->rot.y; this->actor.shape.rot = this->actor.world.rot; this->actor.prevPos = this->actor.world.pos; } - this->unk_3E0 = action->action; - if (D_808890F0[this->unk_3E0] != NULL) { - D_808890F0[this->unk_3E0](this, play, action); + this->cueId = cue->id; + if (D_808890F0[this->cueId] != NULL) { + D_808890F0[this->cueId](this, play, cue); } } - if (D_8088911C[this->unk_3E0] != NULL) { - D_8088911C[this->unk_3E0](this, play, action); + if (D_8088911C[this->cueId] != NULL) { + D_8088911C[this->cueId](this, play, cue); } } } @@ -3329,9 +3329,9 @@ void func_808848C8(EnHorse* this, PlayState* play) { Vec3f sp24 = { -1916.0f, -106.0f, -523.0f }; EnHorse_PlayWalkingSound(this); - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; func_800F415C(&this->actor, &sp24, 2000); - this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + this->skin.skelAnime.playSpeed = this->actor.speed * 0.75f; SkelAnime_Update(&this->skin.skelAnime); if (Math3D_Distance(&sp24, &this->actor.world.pos) < 30.0f) { this->stateFlags &= ~ENHORSE_UNRIDEABLE; @@ -3383,12 +3383,12 @@ void func_80884A40(EnHorse* this, PlayState* play) { } if ((this->unk_538 == OBJ_UM_ANIM_TROT) || (this->unk_538 == OBJ_UM_ANIM_GALLOP)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HORSE_RUN); + Actor_PlaySfx(&this->actor, NA_SE_EV_HORSE_RUN); } else if (this->unk_538 == OBJ_UM_ANIM_IDLE) { if (this->animIndex == ENHORSE_ANIM_IDLE) { EnHorse_IdleAnimSounds(this, play); } else if (this->animIndex == ENHORSE_ANIM_WHINNY) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HORSE_GROAN); + Actor_PlaySfx(&this->actor, NA_SE_EV_HORSE_GROAN); } } } @@ -3397,12 +3397,12 @@ void func_80884A40(EnHorse* this, PlayState* play) { void func_80884D04(EnHorse* this, PlayState* play) { f32 playSpeed; - this->actor.speedXZ = 10.0f; + this->actor.speed = 10.0f; this->action = ENHORSE_ACTION_25; this->unk_540 = this->actor.world.pos; - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_INGO_HORSE_NEIGH); + Actor_PlaySfx(&this->actor, NA_SE_IT_INGO_HORSE_NEIGH); this->animIndex = ENHORSE_ANIM_GALLOP; - playSpeed = this->actor.speedXZ * 0.2f; + playSpeed = this->actor.speed * 0.2f; Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], sPlaybackSpeeds[this->animIndex] * playSpeed * 2.5f, 0.0f, Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, 0.0f); @@ -3473,7 +3473,7 @@ s32 EnHorse_CalcFloorHeight(EnHorse* this, PlayState* play, Vec3f* pos, Collisio if ((COLPOLY_GET_NORMAL((*polyFloor)->normal.y) < 0.81915206f) || SurfaceType_IsHorseBlocked(&play->colCtx, *polyFloor, *bgId) || - (func_800C99D4(&play->colCtx, *polyFloor, *bgId) == 7)) { + (SurfaceType_GetFloorType(&play->colCtx, *polyFloor, *bgId) == FLOOR_TYPE_7)) { return 3; // Horse blocked surface } @@ -3493,13 +3493,13 @@ void EnHorse_ObstructMovement(EnHorse* this, PlayState* play, s32 obstacleType, if ((this->action == ENHORSE_ACTION_5) || (this->action == ENHORSE_ACTION_6)) { this->actor.world.pos = this->actor.prevPos; this->actor.world.rot.y -= 0x640; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.shape.rot.y = this->actor.world.rot.y; this->unk_1EC |= 4; } else if (this->action == ENHORSE_ACTION_25) { this->unk_1EC |= 0x80; this->actor.world.pos = this->actor.prevPos; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else if ((play->sceneId != SCENE_KOEPONARACE) || (this->unk_1EC & 2)) { this->unk_1EC &= ~2; this->actor.world.pos = this->lastPos; @@ -3539,7 +3539,7 @@ void EnHorse_CheckFloors(EnHorse* this, PlayState* play) { f32 nx; f32 ny; f32 nz; - s32 galloping = this->actor.speedXZ > 8.0f; + s32 galloping = this->actor.speed > 8.0f; s32 status; f32 waterHeight; WaterBox* waterbox; @@ -3600,7 +3600,7 @@ void EnHorse_CheckFloors(EnHorse* this, PlayState* play) { pos.y = this->yFront; dist = Math3D_DistPlaneToPos(nx, ny, nz, this->actor.floorPoly->dist, &pos); - if ((frontFloor != this->actor.floorPoly) && (this->actor.speedXZ >= 0.0f) && + if ((frontFloor != this->actor.floorPoly) && (this->actor.speed >= 0.0f) && ((!(this->stateFlags & ENHORSE_JUMPING) && (dist < -40.0f)) || ((this->stateFlags & ENHORSE_JUMPING) && (dist < -200.0f)))) { EnHorse_ObstructMovement(this, play, 4, galloping); @@ -3611,7 +3611,7 @@ void EnHorse_CheckFloors(EnHorse* this, PlayState* play) { pos.y = this->yBack; dist = Math3D_DistPlaneToPos(nx, ny, nz, this->actor.floorPoly->dist, &pos); - if ((backFloor != this->actor.floorPoly) && (this->actor.speedXZ <= 0.0f) && + if ((backFloor != this->actor.floorPoly) && (this->actor.speed <= 0.0f) && ((!(this->stateFlags & ENHORSE_JUMPING) && (dist < -40.0f)) || ((this->stateFlags & ENHORSE_JUMPING) && (dist < -200.0f)))) { EnHorse_ObstructMovement(this, play, 5, galloping); @@ -3620,8 +3620,8 @@ void EnHorse_CheckFloors(EnHorse* this, PlayState* play) { if ((ny < 0.81915206f) || SurfaceType_IsHorseBlocked(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) || - (func_800C99D4(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 7)) { - if (this->actor.speedXZ >= 0.0f) { + (SurfaceType_GetFloorType(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == FLOOR_TYPE_7)) { + if (this->actor.speed >= 0.0f) { EnHorse_ObstructMovement(this, play, 4, galloping); } else { EnHorse_ObstructMovement(this, play, 5, galloping); @@ -3740,14 +3740,18 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) { if ((this->actor.params != ENHORSE_4) && (this->actor.params != ENHORSE_5) && (this->actor.params != ENHORSE_19) && (this->actor.params != ENHORSE_20) && (this->actor.params != ENHORSE_18)) { - Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 35.0f, 100.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 35.0f, 100.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } else { - Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 35.0f, 100.0f, 0x1C); + Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 35.0f, 100.0f, + UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); } - if ((this->actor.bgCheckFlags & 8) && (Math_CosS(this->actor.wallYaw - this->actor.world.rot.y) < -0.3f)) { - if (this->actor.speedXZ > 4.0f) { - this->actor.speedXZ -= 1.0f; + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && + (Math_CosS(this->actor.wallYaw - this->actor.world.rot.y) < -0.3f)) { + if (this->actor.speed > 4.0f) { + this->actor.speed -= 1.0f; if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); } else { @@ -3763,8 +3767,8 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) { ((horseJump->actor.params & 0xFF) == 5)) { this->stateFlags |= ENHORSE_FLAG_28; this->unk_3E8 += ((-10.0f / this->actor.scale.y) - this->unk_3E8) * 0.5f; - if (this->actor.speedXZ > 2.0f) { - this->actor.speedXZ -= 1.0f; + if (this->actor.speed > 2.0f) { + this->actor.speed -= 1.0f; if (this->type == HORSE_TYPE_2) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); } else { @@ -3777,13 +3781,13 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) { } } - if ((this->stateFlags & ENHORSE_JUMPING) || (this->stateFlags & ENHORSE_FLAG_28) || (this->actor.speedXZ < 0.0f) || + if ((this->stateFlags & ENHORSE_JUMPING) || (this->stateFlags & ENHORSE_FLAG_28) || (this->actor.speed < 0.0f) || (this->action == ENHORSE_ACTION_STOPPING) || (this->action == ENHORSE_ACTION_MOUNTED_REARING)) { return; } - if (this->actor.speedXZ > 8.0f) { - if (this->actor.speedXZ < 12.8f) { + if (this->actor.speed > 8.0f) { + if (this->actor.speed < 12.8f) { intersectDist = 160.0f; movingFast = false; } else { @@ -3888,7 +3892,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) { temp_f0 = COLPOLY_GET_NORMAL(obstacleFloor->normal.y); if ((temp_f0 < 0.81915206f) || SurfaceType_IsHorseBlocked(&play->colCtx, obstacleFloor, bgId) || - (func_800C99D4(&play->colCtx, obstacleFloor, bgId) == 7)) { + (SurfaceType_GetFloorType(&play->colCtx, obstacleFloor, bgId) == FLOOR_TYPE_7)) { if ((Math_CosS(sp7E) < 0.9f) && (movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACTION_STOPPING) && (play->sceneId != SCENE_KOEPONARACE)) { this->stateFlags |= ENHORSE_FORCE_REVERSING; @@ -3951,7 +3955,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) { temp_f0 = COLPOLY_GET_NORMAL(obstacleFloor->normal.y); if ((temp_f0 < 0.81915206f) || SurfaceType_IsHorseBlocked(&play->colCtx, obstacleFloor, bgId) || - (func_800C99D4(&play->colCtx, obstacleFloor, bgId) == 7)) { + (SurfaceType_GetFloorType(&play->colCtx, obstacleFloor, bgId) == FLOOR_TYPE_7)) { if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACTION_STOPPING) && (play->sceneId != SCENE_KOEPONARACE)) { this->stateFlags |= ENHORSE_FORCE_REVERSING; @@ -3973,9 +3977,9 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) { EnHorse_Stub1(this); this->postDrawFunc = EnHorse_LowJumpInit; } else if ((movingFast == true) && - (((this->actor.speedXZ < 13.8f) && ((19.0f * temp_f0) < obstacleHeight) && + (((this->actor.speed < 13.8f) && ((19.0f * temp_f0) < obstacleHeight) && (obstacleHeight <= (72.0f * temp_f0))) || - ((this->actor.speedXZ > 13.8f) && (obstacleHeight <= (112.0f * temp_f0))))) { + ((this->actor.speed > 13.8f) && (obstacleHeight <= (112.0f * temp_f0))))) { EnHorse_Stub2(this); this->postDrawFunc = EnHorse_HighJumpInit; } @@ -4069,7 +4073,7 @@ void EnHorse_RegenBoost(EnHorse* this, PlayState* play) { void EnHorse_UpdatePlayerDir(EnHorse* this, PlayState* play) { Player* player = GET_PLAYER(play); - s16 angle = Actor_YawBetweenActors(&this->actor, &player->actor) - this->actor.world.rot.y; + s16 angle = Actor_WorldYawTowardActor(&this->actor, &player->actor) - this->actor.world.rot.y; f32 s = Math_SinS(angle); f32 c = Math_CosS(angle); @@ -4096,7 +4100,7 @@ void EnHorse_TiltBody(EnHorse* this, PlayState* play) { s32 targetRoll; s16 turnVel; - speed = this->actor.speedXZ / this->boostSpeed; + speed = this->actor.speed / this->boostSpeed; turnVel = this->actor.shape.rot.y - this->lastYaw; targetRoll = -((s16)((2730.0f * speed) * (turnVel / 960.00006f))); rollDiff = targetRoll - this->actor.world.rot.z; @@ -4119,7 +4123,8 @@ s32 EnHorse_UpdateConveyors(EnHorse* this, PlayState* play) { s16 conveyorDir; if ((this->actor.floorPoly == NULL) || (&this->actor != player->rideActor) || - !SurfaceType_GetConveyorSpeed(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + (SurfaceType_GetConveyorSpeed(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == + CONVEYOR_SPEED_DISABLED)) { return false; } @@ -4223,8 +4228,8 @@ void EnHorse_Update(Actor* thisx, PlayState* play2) { EnHorse_RegenBoost(this, play); } - if (ActorCutscene_GetCurrentIndex() != -1) { - thisx->speedXZ = 0.0f; + if (CutsceneManager_GetCurrentCsId() != CS_ID_NONE) { + thisx->speed = 0.0f; } if (this->action != ENHORSE_ACTION_25) { @@ -4252,8 +4257,8 @@ void EnHorse_Update(Actor* thisx, PlayState* play2) { } if (this->colliderJntSph.elements->info.ocElemFlags & OCELEM_HIT) { - if (thisx->speedXZ > 10.0f) { - thisx->speedXZ -= 1.0f; + if (thisx->speed > 10.0f) { + thisx->speed -= 1.0f; } } @@ -4351,13 +4356,13 @@ void EnHorse_Update(Actor* thisx, PlayState* play2) { } } - if ((thisx->speedXZ == 0.0f) && !(this->stateFlags & ENHORSE_FLAG_19)) { + if ((thisx->speed == 0.0f) && !(this->stateFlags & ENHORSE_FLAG_19)) { thisx->colChkInfo.mass = MASS_IMMOVABLE; } else { thisx->colChkInfo.mass = MASS_HEAVY; } - if (thisx->speedXZ >= 5.0f) { + if (thisx->speed >= 5.0f) { this->colliderCylinder1.base.atFlags |= AT_ON; } else { this->colliderCylinder1.base.atFlags &= ~AT_ON; @@ -4399,7 +4404,7 @@ s32 EnHorse_PlayerDirToMountSide(EnHorse* this, PlayState* play, Player* player) s32 EnHorse_MountSideCheck(EnHorse* this, PlayState* play, Player* player) { s32 mountSide; - if (Actor_XZDistanceBetweenActors(&this->actor, &player->actor) > 75.0f) { + if (Actor_WorldDistXZToActor(&this->actor, &player->actor) > 75.0f) { return 0; } @@ -4407,7 +4412,7 @@ s32 EnHorse_MountSideCheck(EnHorse* this, PlayState* play, Player* player) { return 0; } - if (Math_CosS(Actor_YawBetweenActors(&player->actor, &this->actor) - player->actor.world.rot.y) < + if (Math_CosS(Actor_WorldYawTowardActor(&player->actor, &this->actor) - player->actor.world.rot.y) < 0.17364818f) { // cos(80 degrees) return 0; } 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 97ab2c898..b2c58bcad 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.h +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.h @@ -11,7 +11,7 @@ struct EnIn; typedef void (*EnHorseActionFunc)(struct EnHorse*, PlayState*); typedef void (*EnHorsePostdrawFunc)(struct EnHorse*, PlayState*); -typedef void (*EnHorseCsFunc)(struct EnHorse*, PlayState*, CsCmdActorAction*); +typedef void (*EnHorseCsFunc)(struct EnHorse*, PlayState*, CsCmdActorCue*); #define ENHORSE_BOOST (1 << 0) /* 0x1 */ #define ENHORSE_BOOST_DECEL (1 << 1) /* 0x2 */ @@ -190,7 +190,7 @@ typedef struct EnHorse { /* 0x3BC */ Vec3f frontLeftHoof; /* 0x3C8 */ Vec3f backRightHoof; /* 0x3D4 */ Vec3f backLeftHoof; - /* 0x3E0 */ s32 unk_3E0; + /* 0x3E0 */ s32 cueId; /* 0x3E4 */ UNK_TYPE1 unk_3E4[0x4]; /* 0x3E8 */ f32 unk_3E8; /* 0x3EC */ s16 unk_3EC; @@ -198,7 +198,7 @@ typedef struct EnHorse { /* 0x48A */ Vec3s morphTable[OBJECT_HA_1_LIMB_MAX]; /* 0x528 */ f32 unk_528; /* 0x52C */ s32 unk_52C; - /* 0x530 */ s32 unk_530; + /* 0x530 */ s32 cueChannel; /* 0x534 */ s32 unk_534; /* 0x538 */ s32 unk_538; /* 0x53C */ s32 unk_53C; diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c index e97deee04..d37fb8f23 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c @@ -59,7 +59,7 @@ s32 func_808F8AA0(EnHorseGameCheck* this, PlayState* play) { DynaPolyActor_Init(&this->dyna, 0); - if (GET_WEEKEVENTREG_RACE_FLAGS != WEEKEVENTREG_RACE_FLAG_START) { + if (GET_WEEKEVENTREG_HORSE_RACE_STATE != WEEKEVENTREG_HORSE_RACE_STATE_START) { Actor_Kill(&this->dyna.actor); return false; } @@ -116,7 +116,7 @@ s32 func_808F8CCC(EnHorseGameCheck* this, PlayState* play2) { this->unk_168 = 0; this->unk_174 = 0; - if (GET_WEEKEVENTREG_RACE_FLAGS != WEEKEVENTREG_RACE_FLAG_START) { + if (GET_WEEKEVENTREG_HORSE_RACE_STATE != WEEKEVENTREG_HORSE_RACE_STATE_START) { Actor_Kill(&this->dyna.actor); return false; } @@ -156,16 +156,16 @@ s32 func_808F8EB0(EnHorseGameCheck* this, PlayState* play) { return false; } - if (GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_3) { + if (GET_WEEKEVENTREG_HORSE_RACE_STATE == WEEKEVENTREG_HORSE_RACE_STATE_3) { play->transitionType = TRANS_TYPE_64; - gSaveContext.nextTransitionType = TRANS_TYPE_02; - } else if (GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_2) { + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; + } else if (GET_WEEKEVENTREG_HORSE_RACE_STATE == WEEKEVENTREG_HORSE_RACE_STATE_2) { play->transitionType = TRANS_TYPE_80; - gSaveContext.nextTransitionType = TRANS_TYPE_03; - } else if (GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_4) { - SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_3); - play->transitionType = TRANS_TYPE_02; - gSaveContext.nextTransitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; + } else if (GET_WEEKEVENTREG_HORSE_RACE_STATE == WEEKEVENTREG_HORSE_RACE_STATE_4) { + SET_WEEKEVENTREG_HORSE_RACE_STATE(WEEKEVENTREG_HORSE_RACE_STATE_3); + play->transitionType = TRANS_TYPE_FADE_BLACK; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; } D_801BDA9C = 0; @@ -248,11 +248,11 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) { } if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(180)) { - Audio_QueueSeqCmd(0x8041); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_HORSE_GOAL | SEQ_FLAG_ASYNC); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x40000; gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; - SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_4); + SET_WEEKEVENTREG_HORSE_RACE_STATE(WEEKEVENTREG_HORSE_RACE_STATE_4); this->unk_174 = 60; } @@ -281,11 +281,11 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) { if ((this->unk_164 & 0x4000) && (horseGameCheck != NULL) && (horseGameCheck->dyna.actor.id == ACTOR_EN_HORSE_GAME_CHECK) && (horseGameCheck->unk_15C == ENHORSEGAMECHECK_FF_7) && !(this->unk_164 & 0x40000)) { - Audio_QueueSeqCmd(0x8041); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_HORSE_GOAL | SEQ_FLAG_ASYNC); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x40000; gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; - SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_3); + SET_WEEKEVENTREG_HORSE_RACE_STATE(WEEKEVENTREG_HORSE_RACE_STATE_3); this->unk_174 = 60; } @@ -314,11 +314,11 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) { if ((this->unk_164 & 0x200000) && (horseGameCheck != NULL) && (horseGameCheck->dyna.actor.id == ACTOR_EN_HORSE_GAME_CHECK) && (horseGameCheck->unk_15C == ENHORSEGAMECHECK_FF_7) && !(this->unk_164 & 0x02000000)) { - Audio_QueueSeqCmd(0x8041); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_HORSE_GOAL | SEQ_FLAG_ASYNC); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x02000000; gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; - SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_3); + SET_WEEKEVENTREG_HORSE_RACE_STATE(WEEKEVENTREG_HORSE_RACE_STATE_3); this->unk_174 = 60; } @@ -343,11 +343,11 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) { if ((this->unk_164 & 0x80) && (horseGameCheck != NULL) && (horseGameCheck->dyna.actor.id == ACTOR_EN_HORSE_GAME_CHECK) && (horseGameCheck->unk_15C == ENHORSEGAMECHECK_FF_7) && !(this->unk_164 & 0x800)) { - Audio_QueueSeqCmd(0x8041); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_HORSE_GOAL | SEQ_FLAG_ASYNC); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x800; gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; - SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_2); + SET_WEEKEVENTREG_HORSE_RACE_STATE(WEEKEVENTREG_HORSE_RACE_STATE_2); this->unk_174 = 60; } return true; diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c index a10504720..8c77bb2a0 100644 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c +++ b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c @@ -120,11 +120,11 @@ f32 func_808DE728(EnHorseLinkChild* this) { f32 phi_fv1; if (this->unk_148 == 2) { - phi_fv1 = D_808DFF18[this->unk_148] * this->actor.speedXZ * (1.0f / 2.0f); + phi_fv1 = D_808DFF18[this->unk_148] * this->actor.speed * (1.0f / 2.0f); } else if (this->unk_148 == 3) { - phi_fv1 = D_808DFF18[this->unk_148] * this->actor.speedXZ * (1.0f / 3.0f); + phi_fv1 = D_808DFF18[this->unk_148] * this->actor.speed * (1.0f / 3.0f); } else if (this->unk_148 == 4) { - phi_fv1 = D_808DFF18[this->unk_148] * this->actor.speedXZ * (1.0f / 5.0f); + phi_fv1 = D_808DFF18[this->unk_148] * this->actor.speed * (1.0f / 5.0f); } else { phi_fv1 = D_808DFF18[this->unk_148]; } @@ -142,7 +142,7 @@ void EnHorseLinkChild_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); this->unk_144 = 1; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 70.0f; @@ -186,7 +186,7 @@ void func_808DE9A8(EnHorseLinkChild* this) { } void func_808DEA0C(EnHorseLinkChild* this, PlayState* play) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (SkelAnime_Update(&this->skin.skelAnime)) { func_808DE9A8(this); } @@ -194,7 +194,7 @@ void func_808DEA0C(EnHorseLinkChild* this, PlayState* play) { void func_808DEA54(EnHorseLinkChild* this, s32 arg1) { this->unk_144 = 2; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if ((arg1 != 0) && (arg1 != 1)) { arg1 = 0; @@ -208,7 +208,7 @@ void func_808DEA54(EnHorseLinkChild* this, s32 arg1) { } void func_808DEB14(EnHorseLinkChild* this, PlayState* play) { - f32 sp44 = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(play)->actor); + f32 sp44 = Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(play)->actor); s32 phi_v0; if (SkelAnime_Update(&this->skin.skelAnime)) { @@ -237,7 +237,7 @@ void func_808DEB14(EnHorseLinkChild* this, PlayState* play) { void func_808DECA0(EnHorseLinkChild* this) { this->unk_144 = 1; this->unk_148 = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); } @@ -248,7 +248,7 @@ void func_808DED40(EnHorseLinkChild* this, PlayState* play) { s32 phi_v0; if ((this->unk_148 == 4) || (this->unk_148 == 3) || (this->unk_148 == 2)) { - temp_a0 = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(play)->actor) - this->actor.world.rot.y; + temp_a0 = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(play)->actor) - this->actor.world.rot.y; if (temp_a0 > 0x12C) { this->actor.world.rot.y += 0x12C; } else if (temp_a0 < -0x12C) { @@ -260,7 +260,7 @@ void func_808DED40(EnHorseLinkChild* this, PlayState* play) { } if (SkelAnime_Update(&this->skin.skelAnime)) { - temp_fv0 = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(play)->actor); + temp_fv0 = Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(play)->actor); if (temp_fv0 > 1000.0f) { func_808DEA54(this, 0); return; @@ -268,14 +268,14 @@ void func_808DED40(EnHorseLinkChild* this, PlayState* play) { if ((temp_fv0 < 1000.0f) && (temp_fv0 >= 300.0f)) { phi_v0 = 4; - this->actor.speedXZ = 6.0f; + this->actor.speed = 6.0f; } else if ((temp_fv0 < 300.0f) && (temp_fv0 >= 150.0f)) { phi_v0 = 3; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; } else if ((temp_fv0 < 150.0f) && (temp_fv0 >= 70.0f)) { phi_v0 = 2; this->unk_1E8 = 0; - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; } else { func_808DEA54(this, 1); return; @@ -295,7 +295,7 @@ void func_808DED40(EnHorseLinkChild* this, PlayState* play) { void func_808DEFE8(EnHorseLinkChild* this) { this->unk_144 = 3; this->unk_148 = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); } @@ -309,7 +309,7 @@ void func_808DF088(EnHorseLinkChild* this, PlayState* play) { if (Math3D_Distance(&player->actor.world.pos, &this->actor.home.pos) < 250.0f) { sp32 = player->actor.shape.rot.y; - if (Actor_YawBetweenActors(&this->actor, &player->actor) > 0) { + if (Actor_WorldYawTowardActor(&this->actor, &player->actor) > 0) { phi_v0 = 1; } else { phi_v0 = -1; @@ -340,28 +340,29 @@ void func_808DF194(EnHorseLinkChild* this, PlayState* play) { func_808DF088(this, play); player = GET_PLAYER(play); - sp50 = Actor_XZDistanceBetweenActors(&this->actor, &player->actor); + sp50 = Actor_WorldDistXZToActor(&this->actor, &player->actor); sp48 = this->unk_148; sp4C = SkelAnime_Update(&this->skin.skelAnime); if ((sp4C != 0) || (this->unk_148 == 1) || (this->unk_148 == 0)) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_01_20)) { + // The carry-over of this flag from OoT was not done correctly + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_ENTERED_ZORA_HALL)) { f32 sp44 = Math3D_Distance(&this->actor.world.pos, &this->actor.home.pos); s32 pad; if (Math3D_Distance(&player->actor.world.pos, &this->actor.home.pos) > 250.0f) { if (sp44 >= 300.0f) { sp48 = 4; - this->actor.speedXZ = 6.0f; + this->actor.speed = 6.0f; } else if ((sp44 < 300.0f) && (sp44 >= 150.0f)) { sp48 = 3; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; } else if ((sp44 < 150.0f) && (sp44 >= 70.0f)) { sp48 = 2; this->unk_1E8 = 0; - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->unk_148 == 0) { sp48 = (sp4C == 1) ? 1 : 0; } else { @@ -370,16 +371,16 @@ void func_808DF194(EnHorseLinkChild* this, PlayState* play) { } } else if (sp50 < 200.0f) { sp48 = 4; - this->actor.speedXZ = 6.0f; + this->actor.speed = 6.0f; } else if (sp50 < 300.0f) { sp48 = 3; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; } else if (sp50 < 400.0f) { sp48 = 2; this->unk_1E8 = 0; - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->unk_148 == 0) { sp48 = (sp4C == 1) ? 1 : 0; } else { @@ -387,7 +388,7 @@ void func_808DF194(EnHorseLinkChild* this, PlayState* play) { } } } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->unk_148 == 0) { sp48 = (sp4C == 1) ? 1 : 0; } else { @@ -431,8 +432,8 @@ void func_808DF620(EnHorseLinkChild* this, PlayState* play) { return; } - this->actor.speedXZ = 0.0f; - sp36 = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(play)->actor) - this->actor.world.rot.y; + this->actor.speed = 0.0f; + sp36 = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(play)->actor) - this->actor.world.rot.y; if ((Math_CosS(sp36) < 0.7071f) && (this->unk_148 == 2)) { func_800F415C(&this->actor, &GET_PLAYER(play)->actor.world.pos, 0x12C); @@ -454,7 +455,7 @@ void func_808DF788(EnHorseLinkChild* this) { this->unk_144 = 4; this->unk_148 = 2; this->unk_1E0 = 0; - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); } @@ -479,7 +480,7 @@ void func_808DF838(EnHorseLinkChild* this, PlayState* play) { if (SkelAnime_Update(&this->skin.skelAnime)) { if (this->unk_1E0 == 0) { - phi_fv0 = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(play)->actor); + phi_fv0 = Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(play)->actor); } else { phi_fv0 = Math3D_Distance(&this->actor.world.pos, &this->actor.home.pos); } @@ -487,25 +488,25 @@ void func_808DF838(EnHorseLinkChild* this, PlayState* play) { if (this->unk_1E0 == 0) { if (phi_fv0 >= 300.0f) { phi_v0 = 4; - this->actor.speedXZ = 6.0f; + this->actor.speed = 6.0f; } else if (phi_fv0 >= 150.0f) { phi_v0 = 3; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; } else { phi_v0 = 2; this->unk_1E8 = 0; - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; } } else if (phi_fv0 >= 300.0f) { phi_v0 = 4; - this->actor.speedXZ = 6.0f; + this->actor.speed = 6.0f; } else if (phi_fv0 >= 150.0f) { phi_v0 = 3; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; } else if (phi_fv0 >= 70.0f) { phi_v0 = 2; this->unk_1E8 = 0; - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; } else { func_808DF560(this); return; @@ -528,7 +529,9 @@ void EnHorseLinkChild_Update(Actor* thisx, PlayState* play) { D_808DFF30[this->unk_144](this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 55.0f, 100.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 55.0f, 100.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 70.0f; diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.c b/src/overlays/actors/ovl_En_Hs/z_en_hs.c index 2eb1c71a6..4d535292f 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -150,7 +150,7 @@ void func_80952FE0(EnHs* this, PlayState* play) { } else { this->actionFunc = func_80953180; this->stateFlags &= ~4; - func_80151938(play, 0x33F6); + Message_ContinueTextbox(play, 0x33F6); func_80952DFC(play); } this->stateTimer++; @@ -166,9 +166,9 @@ void func_80953098(EnHs* this, PlayState* play) { } else { this->stateFlags |= 8; if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { - Actor_PickUp(&this->actor, play, GI_RUPEE_RED, 10000.0f, 50.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_RED, 10000.0f, 50.0f); } else { - Actor_PickUp(&this->actor, play, GI_MASK_BUNNY, 10000.0f, 50.0f); + Actor_OfferGetItem(&this->actor, play, GI_MASK_BUNNY, 10000.0f, 50.0f); } } } @@ -178,20 +178,20 @@ void func_80953180(EnHs* this, PlayState* play) { switch (play->msgCtx.currentTextId) { case 0x33F4: // text: laughing that they are all roosters (!) case 0x33F6: // text: Grog regrets not being able to see his chicks reach adult hood - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_8095345C; break; case 0x33F7: // text: notice his chicks are grown up, happy, wants to give you bunny hood this->actor.flags &= ~ACTOR_FLAG_10000; - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80953098; func_80953098(this, play); break; case 0x33F9: // text: laughing that they are all roosters (.) this->actor.flags &= ~ACTOR_FLAG_10000; - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_8095345C; break; @@ -204,7 +204,7 @@ void func_80953180(EnHs* this, PlayState* play) { break; default: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_8095345C; break; } @@ -225,7 +225,7 @@ void EnHs_SceneTransitToBunnyHoodDialogue(EnHs* this, PlayState* play) { void func_80953354(EnHs* this, PlayState* play) { if (!Play_InCsMode(play)) { - func_800B7298(play, &this->actor, PLAYER_CSMODE_7); + func_800B7298(play, &this->actor, PLAYER_CSMODE_WAIT); this->actionFunc = EnHs_SceneTransitToBunnyHoodDialogue; } } @@ -282,7 +282,7 @@ void EnHs_Update(Actor* thisx, PlayState* play) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); if (SkelAnime_Update(&this->skelAnime)) { this->skelAnime.curFrame = 0.0f; diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.c b/src/overlays/actors/ovl_En_Ig/z_en_ig.c index 2468e5961..e053a8528 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -320,49 +320,49 @@ void func_80BF15EC(EnIg* this) { } } -s32 func_80BF16C8(EnIg* this, s16 arg1) { +s32 func_80BF16C8(EnIg* this, s16 csId) { s32 ret = false; - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(arg1); - } else if (ActorCutscene_GetCanPlayNext(arg1)) { - ActorCutscene_StartAndSetUnkLinkFields(arg1, &this->actor); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(csId); + } else if (CutsceneManager_IsNext(csId)) { + CutsceneManager_StartWithPlayerCs(csId, &this->actor); ret = true; } else { - ActorCutscene_SetIntentToPlay(arg1); + CutsceneManager_Queue(csId); } return ret; } -s16 func_80BF1744(EnIg* this, s32 arg1) { - s16 cs = -1; +s16 func_80BF1744(EnIg* this, s32 numCutscenes) { + s16 csId = CS_ID_NONE; s32 i; if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - cs = this->actor.child->cutscene; - for (i = 0; i < arg1; i++) { - cs = ActorCutscene_GetAdditionalCutscene(cs); + csId = this->actor.child->csId; + for (i = 0; i < numCutscenes; i++) { + csId = CutsceneManager_GetAdditionalCsId(csId); } } - return cs; + return csId; } s32 func_80BF17BC(EnIg* this, PlayState* play) { s32 pad; - s16 sp2A; + s16 csId; s32 ret; - sp2A = func_80BF1744(this, 0); + csId = func_80BF1744(this, 0); ret = false; switch (this->unk_3F6) { case 0: - if (func_80BF16C8(this, sp2A)) { + if (func_80BF16C8(this, csId)) { case 2: case 4: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)), this->actor.child); } this->unk_3F6++; @@ -373,17 +373,17 @@ s32 func_80BF17BC(EnIg* this, PlayState* play) { case 1: case 3: if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_75_10) && (this->unk_3F6 == 3)) { - ActorCutscene_Stop(sp2A); + CutsceneManager_Stop(csId); this->unk_3F6 = 5; } else { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)), &this->actor); } this->unk_3F6++; ret = true; break; case 5: - ActorCutscene_Stop(sp2A); + CutsceneManager_Stop(csId); this->unk_3F6++; ret = true; break; @@ -750,7 +750,7 @@ s32 func_80BF2470(EnIg* this, PlayState* play) { Lib_Vec3f_TranslateAndRotateY(&this->unk_2B0, this->actor.world.rot.y, &sp38, &this->actor.world.pos); this->unk_3E2 += this->timePathTimeSpeed; if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_PIRATE_WALK); } } return false; @@ -804,7 +804,7 @@ s32 func_80BF25E8(EnIg* this, PlayState* play) { this->timePathWaypoint = sp50; this->timePathTargetPos = timePathTargetPos; } else if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_PIRATE_WALK); } return false; } @@ -816,9 +816,9 @@ s32 func_80BF2890(EnIg* this, PlayState* play) { if (!(this->unk_3D0 & 0x100) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (this->unk_408 != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SNORE1); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_SNORE1); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SNORE2); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_SNORE2); } this->unk_408 ^= 1; } @@ -952,7 +952,7 @@ void EnIg_Update(Actor* thisx, PlayState* play) { func_80BF15EC(this); func_8013C964(&this->actor, play, 60.0f, 30.0f, PLAYER_IA_NONE, this->unk_3D0 & 7); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); func_80BF1354(this, play); } } diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.c b/src/overlays/actors/ovl_En_Ik/z_en_ik.c index 4188f44c4..fc7fafdcf 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -300,7 +300,7 @@ void EnIk_Freeze(EnIk* this) { this->drawDmgEffAlpha = 1.0f; this->timer = 80; this->actor.flags &= ~ACTOR_FLAG_400; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 80); } void EnIk_Thaw(EnIk* this, PlayState* play) { @@ -375,7 +375,7 @@ void EnIk_SetupIdle(EnIk* this) { Animation_Change(&this->skelAnime, &gIronKnuckleEndHorizontalAttackAnim, 1.0f, frameCount, frameCount, ANIMMODE_ONCE, this->timer); this->actionFunc = EnIk_Idle; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void EnIk_Idle(EnIk* this, PlayState* play) { @@ -386,7 +386,7 @@ void EnIk_Idle(EnIk* this, PlayState* play) { EnIk_CheckActions(this, play); } } else if (this->colliderCylinder.base.acFlags & AC_HIT) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); this->actor.hintId = TATL_HINT_ID_IRON_KNUCKLE; this->colliderCylinder.base.acFlags &= ~AC_HIT; @@ -397,7 +397,7 @@ void EnIk_Idle(EnIk* this, PlayState* play) { void EnIk_SetupWalk(EnIk* this) { Animation_MorphToLoop(&this->skelAnime, &gIronKnuckleWalkAnim, -4.0f); - this->actor.speedXZ = 0.9f; + this->actor.speed = 0.9f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = EnIk_WalkTowardsPlayer; } @@ -407,10 +407,10 @@ void EnIk_WalkTowardsPlayer(EnIk* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 16.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_WALK); } yawDiff = this->actor.wallYaw - this->actor.shape.rot.y; - if ((this->actor.bgCheckFlags & 8) && (ABS_ALT(yawDiff) >= 0x4000)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && (ABS_ALT(yawDiff) >= 0x4000)) { yawDiff = (this->actor.yawTowardsPlayer > 0) ? this->actor.wallYaw - 0x4000 : this->actor.wallYaw + 0x4000; Math_ScaledStepToS(&this->actor.shape.rot.y, yawDiff, 0x320); } else { @@ -424,8 +424,8 @@ void EnIk_WalkTowardsPlayer(EnIk* this, PlayState* play) { void EnIk_SetupRun(EnIk* this) { Animation_MorphToLoop(&this->skelAnime, &gIronKnuckleRunAnim, -4.0f); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TWINROBA_SHOOT_VOICE); - this->actor.speedXZ = 2.5f; + Actor_PlaySfx(&this->actor, NA_SE_EN_TWINROBA_SHOOT_VOICE); + this->actor.speed = 2.5f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = EnIk_RunTowardsPlayer; } @@ -435,10 +435,10 @@ void EnIk_RunTowardsPlayer(EnIk* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 9.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_WALK); } yawDiff = this->actor.wallYaw - this->actor.shape.rot.y; - if ((this->actor.bgCheckFlags & 8) && (ABS_ALT(yawDiff) >= 0x4000)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && (ABS_ALT(yawDiff) >= 0x4000)) { yawDiff = (this->actor.yawTowardsPlayer > 0) ? this->actor.wallYaw - 0x4000 : this->actor.wallYaw + 0x4000; Math_ScaledStepToS(&this->actor.shape.rot.y, yawDiff, 0x4B0); } else { @@ -454,7 +454,7 @@ void EnIk_SetupVerticalAttack(EnIk* this) { s32 pad; f32 playbackSpeed; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->drawArmorFlags) { playbackSpeed = 1.5f; } else { @@ -473,13 +473,13 @@ void EnIk_VerticalAttack(EnIk* this, PlayState* play) { this->timer++; if (!(this->skelAnime.curFrame < 7.0f) || !EnIk_IsChangingAction(this, play)) { if (Animation_OnFrame(&this->skelAnime, 15.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); } else if (Animation_OnFrame(&this->skelAnime, 21.0f)) { particlePos.x = (Math_SinS((this->actor.shape.rot.y + 0x6A4)) * 70.0f) + this->actor.world.pos.x; particlePos.z = (Math_CosS((this->actor.shape.rot.y + 0x6A4)) * 70.0f) + this->actor.world.pos.z; particlePos.y = this->actor.world.pos.y; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_HIT_GND); + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_HIT_GND); Camera_AddQuake(GET_ACTIVE_CAM(play), 2, 25, 5); Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); CollisionCheck_SpawnShieldParticles(play, &particlePos); @@ -488,11 +488,11 @@ void EnIk_VerticalAttack(EnIk* this, PlayState* play) { if ((this->skelAnime.curFrame > 13.0f) && (this->skelAnime.curFrame < 23.0f)) { this->colliderQuad.base.atFlags |= AT_ON; if (this->drawArmorFlags) { - this->actor.speedXZ = sin_rad((this->skelAnime.curFrame - 13.0f) * (M_PI / 20)) * 10.0f; + this->actor.speed = sin_rad((this->skelAnime.curFrame - 13.0f) * (M_PI / 20)) * 10.0f; } } else { this->colliderQuad.base.atFlags &= ~AT_ON; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } if ((this->drawArmorFlags) && (this->skelAnime.curFrame < 13.0f)) { @@ -508,7 +508,7 @@ void EnIk_VerticalAttack(EnIk* this, PlayState* play) { void EnIk_SetupTakeOutAxe(EnIk* this) { Animation_PlayOnce(&this->skelAnime, &gIronKnuckleEndVerticalAttackAnim); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_PULLOUT); + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_PULLOUT); this->actionFunc = EnIk_TakeOutAxe; } @@ -525,7 +525,7 @@ void EnIk_TakeOutAxe(EnIk* this, PlayState* play) { } void EnIk_SetupHorizontalDoubleAttack(EnIk* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Animation_Change(&this->skelAnime, &gIronKnuckleHorizontalAttackAnim, (this->drawArmorFlags) ? 1.3f : 1.0f, 0.0f, Animation_GetLastFrame(&gIronKnuckleHorizontalAttackAnim.common), ANIMMODE_ONCE_INTERP, (this->drawArmorFlags) ? 4.0f : 10.0f); @@ -539,7 +539,7 @@ void EnIk_HorizontalDoubleAttack(EnIk* this, PlayState* play) { this->timer++; if ((Animation_OnFrame(&this->skelAnime, 1.0f)) || (Animation_OnFrame(&this->skelAnime, 13.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); } if (((this->skelAnime.curFrame > 1.0f) && (this->skelAnime.curFrame < 9.0f)) || ((this->skelAnime.curFrame > 12.0f) && (this->skelAnime.curFrame < 20.0f))) { @@ -551,12 +551,12 @@ void EnIk_HorizontalDoubleAttack(EnIk* this, PlayState* play) { } else { phi_f2 = this->skelAnime.curFrame - 1.0f; } - this->actor.speedXZ = sin_rad((M_PI / 8) * phi_f2) * 4.5f; + this->actor.speed = sin_rad((M_PI / 8) * phi_f2) * 4.5f; } this->colliderQuad.base.atFlags |= AT_ON; } else { this->colliderQuad.base.atFlags &= ~AT_ON; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } if (SkelAnime_Update(&this->skelAnime)) { EnIk_SetupEndHorizontalAttack(this); @@ -566,7 +566,7 @@ void EnIk_HorizontalDoubleAttack(EnIk* this, PlayState* play) { void EnIk_SetupSingleHorizontalAttack(EnIk* this) { f32 playSpeed; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->drawArmorFlags) { this->actor.world.rot.z = 0x1000; playSpeed = 1.3f; @@ -584,7 +584,7 @@ void EnIk_SetupSingleHorizontalAttack(EnIk* this) { void EnIk_SingleHorizontalAttack(EnIk* this, PlayState* play) { this->timer++; if (Animation_OnFrame(&this->skelAnime, 13.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_SWING_AXE); } if ((this->skelAnime.curFrame > 12.0f) && (this->skelAnime.curFrame < 20.0f)) { this->colliderQuad.base.atFlags |= AT_ON; @@ -611,7 +611,7 @@ void EnIk_EndHorizontalAttack(EnIk* this, PlayState* play) { } void EnIk_SetupBlock(EnIk* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Animation_Change(&this->skelAnime, &gIronKnuckleBlockAnim, 2.0f, 0.0f, Animation_GetLastFrame(&gIronKnuckleBlockAnim), ANIMMODE_ONCE, -2.0f); this->timer = 20; @@ -634,7 +634,7 @@ void EnIk_SetupReactToAttack(EnIk* this, s32 arg1) { if (arg1) { func_800BE504(&this->actor, &this->colliderCylinder); } - this->actor.speedXZ = 6.0f; + this->actor.speed = 6.0f; temp_v0 = (this->actor.world.rot.y - this->actor.shape.rot.y) + 0x8000; if (ABS_ALT(temp_v0) <= 0x4000) { Animation_MorphToPlayOnce(&this->skelAnime, &gIronKnuckleFrontHitAnim, -4.0f); @@ -645,13 +645,13 @@ void EnIk_SetupReactToAttack(EnIk* this, s32 arg1) { } void EnIk_ReactToAttack(EnIk* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); + Math_StepToF(&this->actor.speed, 0.0f, 1.0f); if (this->subCamId != SUB_CAM_ID_DONE) { Play_SetCameraAtEye(play, this->subCamId, &this->actor.focus.pos, &Play_GetCamera(play, this->subCamId)->eye); } if (SkelAnime_Update(&this->skelAnime)) { if (this->subCamId != SUB_CAM_ID_DONE) { - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); this->subCamId = SUB_CAM_ID_DONE; EnIk_SetupIdle(this); } else { @@ -664,10 +664,10 @@ void EnIk_ReactToAttack(EnIk* this, PlayState* play) { } void EnIk_SetupDie(EnIk* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Animation_MorphToPlayOnce(&this->skelAnime, &gIronKnuckleDeathAnim, -4.0f); this->timer = 24; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_DEAD); this->actionFunc = EnIk_Die; } @@ -693,19 +693,19 @@ void EnIk_Die(EnIk* this, PlayState* play) { } if (this->timer == 0) { Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0xB0); - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); Actor_Kill(&this->actor); } } } else if (Animation_OnFrame(&this->skelAnime, 23.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_WALK); } } void EnIk_SetupFrozen(EnIk* this) { this->invincibilityFrames = 0; this->actionFunc = EnIk_Frozen; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void EnIk_Frozen(EnIk* this, PlayState* play) { @@ -723,8 +723,8 @@ void EnIk_Frozen(EnIk* this, PlayState* play) { } void EnIk_SetupCutscene(EnIk* this) { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); - this->actor.speedXZ = 0.0f; + CutsceneManager_Queue(this->actor.csId); + this->actor.speed = 0.0f; if (this->actor.colChkInfo.health != 0) { func_800BE504(&this->actor, &this->colliderCylinder); } @@ -735,10 +735,10 @@ void EnIk_PlayCutscene(EnIk* this, PlayState* play) { Vec3f subCamEye; this->invincibilityFrames = 12; - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - if (this->actor.cutscene != -1) { - ActorCutscene_StartAndSetFlag(this->actor.cutscene, &this->actor); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + if (CutsceneManager_IsNext(this->actor.csId)) { + if (this->actor.csId != CS_ID_NONE) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->actor.csId, &this->actor); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->actor.csId); subCamEye.x = (Math_SinS((this->actor.shape.rot.y - 0x2000)) * 120.0f) + this->actor.focus.pos.x; subCamEye.y = this->actor.focus.pos.y + 20.0f; subCamEye.z = (Math_CosS((this->actor.shape.rot.y - 0x2000)) * 120.0f) + this->actor.focus.pos.z; @@ -750,7 +750,7 @@ void EnIk_PlayCutscene(EnIk* this, PlayState* play) { EnIk_SetupDie(this); } } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -776,7 +776,7 @@ void EnIk_UpdateDamage(EnIk* this, PlayState* play) { if ((this->actor.colChkInfo.damageEffect != DMG_EFF_IMMUNE) && ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || (!(this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)))) { - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 12); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 12); this->invincibilityFrames = 12; EnIk_Thaw(this, play); this->colliderQuad.base.atFlags &= ~AT_ON; @@ -793,7 +793,7 @@ void EnIk_UpdateDamage(EnIk* this, PlayState* play) { this->drawArmorFlags = 1; this->colliderCylinder.base.colType = 3; this->actor.colChkInfo.damageTable = &sDamageTableNoArmor; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_ARMOR_OFF_DEMO); + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_ARMOR_OFF_DEMO); EnIk_SetupCutscene(this); } else if (this->drawArmorFlags) { if (this->actor.colChkInfo.damageEffect == DMG_EFF_ICE) { @@ -811,7 +811,7 @@ void EnIk_UpdateDamage(EnIk* this, PlayState* play) { } else if (this->actor.colChkInfo.damageEffect == DMG_EFF_LIGHT_SPARKS) { EnIk_HitArmor(this, play); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_DAMAGE); if (this->actor.colChkInfo.health != 0) { EnIk_SetupReactToAttack(this, true); } else { @@ -819,8 +819,8 @@ void EnIk_UpdateDamage(EnIk* this, PlayState* play) { } } } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IRONNACK_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_ARMOR_HIT); + Actor_PlaySfx(&this->actor, NA_SE_EN_IRONNACK_DAMAGE); if (this->actor.colChkInfo.damageEffect == 4) { EnIk_HitArmor(this, play); } @@ -870,7 +870,9 @@ void EnIk_Update(Actor* thisx, PlayState* play2) { } this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 75.0f, 30.0f, 30.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 75.0f, 30.0f, 30.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); this->actor.focus.rot.y = this->actor.shape.rot.y; CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderCylinder.base); if (this->invincibilityFrames == 0) { @@ -1064,7 +1066,7 @@ void EnIk_UpdateArmorDraw(EnIk* this, PlayState* play) { } void EnIk_Draw(Actor* thisx, PlayState* play) { - static Vec3f D_8092C200 = { 0.53f, 0.53f, 0.53f }; + static Vec3f sScale = { 0.53f, 0.53f, 0.53f }; EnIk* this = THIS; Gfx* gfx; Gfx** gfxArmorType; @@ -1091,7 +1093,7 @@ void EnIk_Draw(Actor* thisx, PlayState* play) { if (this->actor.colorFilterTimer != 0) { func_800AE5A0(play); } - func_800BC620(&this->actor.focus.pos, &D_8092C200, 255, play); + func_800BC620(&this->actor.focus.pos, &sScale, 255, play); Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); 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 a51cae556..71c512418 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -169,12 +169,12 @@ s32 func_808F3178(EnIn* this, PlayState* play) { u8 tmp; this->unk260 = tmp = SubS_IsFloorAbove(play, &this->unk248, -6.0f); - if (this->unk260 != 0 && prevUnk260 == 0 && tmp) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); + if ((this->unk260 != 0) && (prevUnk260 == 0) && tmp) { + Actor_PlaySfx(&this->actor, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_STONE); } this->unk261 = tmp = SubS_IsFloorAbove(play, &this->unk254, -6.0f); - if (this->unk261 != 0 && prevUnk261 == 0 && tmp) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); + if ((this->unk261 != 0) && (prevUnk261 == 0) && tmp) { + Actor_PlaySfx(&this->actor, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_STONE); } return 0; @@ -214,7 +214,7 @@ s32 func_808F3334(EnIn* this, PlayState* play) { if (this->colliderJntSph.base.atFlags & AT_BOUNCED) { return 0; } - Actor_PlaySfxAtPos(&player->actor, NA_SE_PL_BODY_HIT); + Actor_PlaySfx(&player->actor, NA_SE_PL_BODY_HIT); func_800B8D98(play, &this->actor, 3.0f, this->actor.yawTowardsPlayer, 6.0f); } return 1; @@ -287,8 +287,8 @@ void func_808F3690(EnIn* this, PlayState* play) { s16 sp36; Vec3f sp28; - Math_SmoothStepToF(&this->actor.speedXZ, 1.0f, 0.4f, 1000.0f, 0.0f); - sp36 = this->actor.speedXZ * 400.0f; + Math_SmoothStepToF(&this->actor.speed, 1.0f, 0.4f, 1000.0f, 0.0f); + sp36 = this->actor.speed * 400.0f; if (SubS_CopyPointFromPath(this->path, this->unk244, &sp28) && SubS_MoveActorToPoint(&this->actor, &sp28, sp36)) { this->unk244++; if (this->unk244 >= this->path->count) { @@ -313,7 +313,7 @@ void func_808F374C(EnIn* this, PlayState* play) { } } if (this->skelAnime.animation == &object_in_Anim_0198A8 && Animation_OnFrame(&this->skelAnime, 20.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_CRY_0); + Actor_PlaySfx(&this->actor, NA_SE_VO_IN_CRY_0); } if (SkelAnime_Update(&this->skelAnime)) { this->unk488 %= ARRAY_COUNT(sAnimations); @@ -336,7 +336,7 @@ void func_808F38F8(EnIn* this, PlayState* play) { } void func_808F395C(EnIn* this, PlayState* play) { - if (this->unk4B0 == WEEKEVENTREG_RACE_FLAG_END) { + if (this->unk4B0 == WEEKEVENTREG_HORSE_RACE_STATE_END) { this->actionFunc = func_808F5A94; } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { @@ -352,33 +352,33 @@ void func_808F39DC(EnIn* this, PlayState* play) { u16 textId = 0; if (gSaveContext.save.day != 3) { - switch (GET_WEEKEVENTREG_RACE_FLAGS) { - case WEEKEVENTREG_RACE_FLAG_2: + switch (GET_WEEKEVENTREG_HORSE_RACE_STATE) { + case WEEKEVENTREG_HORSE_RACE_STATE_2: textId = 0x347A; break; - case WEEKEVENTREG_RACE_FLAG_3: + case WEEKEVENTREG_HORSE_RACE_STATE_3: textId = 0x3476; break; } - SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_END); + SET_WEEKEVENTREG_HORSE_RACE_STATE(WEEKEVENTREG_HORSE_RACE_STATE_END); } else { - switch (GET_WEEKEVENTREG_RACE_FLAGS) { - case WEEKEVENTREG_RACE_FLAG_2: + switch (GET_WEEKEVENTREG_HORSE_RACE_STATE) { + case WEEKEVENTREG_HORSE_RACE_STATE_2: textId = 0x349D; break; - case WEEKEVENTREG_RACE_FLAG_3: + case WEEKEVENTREG_HORSE_RACE_STATE_3: textId = 0x3499; break; } - SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_END); + SET_WEEKEVENTREG_HORSE_RACE_STATE(WEEKEVENTREG_HORSE_RACE_STATE_END); } this->actor.flags |= ACTOR_FLAG_10000; this->actor.textId = textId; this->actionFunc = func_808F395C; - if (this->unk4B0 == WEEKEVENTREG_RACE_FLAG_2) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); + if (this->unk4B0 == WEEKEVENTREG_HORSE_RACE_STATE_2) { + Actor_PlaySfx(&this->actor, NA_SE_VO_IN_LOST); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); + Actor_PlaySfx(&this->actor, NA_SE_VO_IN_JOY0); } } @@ -402,7 +402,7 @@ void func_808F3B40(EnIn* this, PlayState* play) { textId = gSaveContext.save.day != 3 ? 0x3481 : 0x34A4; this->actor.textId = textId; } else { - Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_MILK, 500.0f, 100.0f); } } @@ -426,7 +426,7 @@ void func_808F3C40(EnIn* this, PlayState* play) { textId = gSaveContext.save.day != 3 ? 0x346A : 0x3492; this->actor.textId = textId; } else { - Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_MILK, 500.0f, 100.0f); } } @@ -450,7 +450,7 @@ void func_808F3D40(EnIn* this, PlayState* play) { this->actor.textId = textId; this->actor.flags |= ACTOR_FLAG_10000; } else { - Actor_PickUp(&this->actor, play, GI_MASK_GARO, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_MASK_GARO, 500.0f, 100.0f); } } @@ -576,7 +576,7 @@ s32 func_808F4150(PlayState* play, EnIn* this, s32 arg2, MessageContext* msgCtx) if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.save.playerData.rupees >= play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees >= play->msgCtx.unk1206C) { Rupees_ChangeBy(-play->msgCtx.unk1206C); if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_57_01)) { func_808F4108(this, play, 0x3474); @@ -602,7 +602,7 @@ s32 func_808F4270(PlayState* play, EnIn* this, s32 arg2, MessageContext* msgCtx, if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.save.playerData.rupees >= fee) { + if (gSaveContext.save.saveInfo.playerData.rupees >= fee) { Rupees_ChangeBy(-fee); if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_57_01)) { if (arg4 != 0) { @@ -635,7 +635,7 @@ s32 func_808F4270(PlayState* play, EnIn* this, s32 arg2, MessageContext* msgCtx, s32 func_808F43E0(EnIn* this) { this->unk48C = 0; this->actor.textId = 0; - SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_END); + SET_WEEKEVENTREG_HORSE_RACE_STATE(WEEKEVENTREG_HORSE_RACE_STATE_END); return 0; } @@ -747,10 +747,10 @@ s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { case 0x3466: if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.save.playerData.rupees >= play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees >= play->msgCtx.unk1206C) { if (Inventory_HasEmptyBottle()) { this->actionFunc = func_808F3C40; - Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_MILK, 500.0f, 100.0f); Rupees_ChangeBy(-play->msgCtx.unk1206C); ret = true; } else { @@ -817,10 +817,10 @@ s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { func_80151BB4(play, 0x11); break; case 0x3475: - SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_START); + SET_WEEKEVENTREG_HORSE_RACE_STATE(WEEKEVENTREG_HORSE_RACE_STATE_START); func_800FD750(NA_BGM_HORSE); play->nextEntrance = ENTRANCE(GORMAN_TRACK, 5); - play->transitionType = TRANS_TYPE_05; + play->transitionType = TRANS_TYPE_FADE_WHITE_FAST; play->transitionTrigger = TRANS_TRIGGER_START; SET_WEEKEVENTREG(WEEKEVENTREG_57_01); break; @@ -896,7 +896,7 @@ s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { func_808F35D8(this, play); if (Inventory_HasEmptyBottle()) { this->actionFunc = func_808F3B40; - Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_MILK, 500.0f, 100.0f); ret = true; } else { Actor_ContinueText(play, &this->actor, 0x347F); @@ -920,7 +920,7 @@ s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { break; case 0x347C: this->actionFunc = func_808F3D40; - Actor_PickUp(&this->actor, play, GI_MASK_GARO, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_MASK_GARO, 500.0f, 100.0f); func_808F35D8(this, play); ret = true; break; @@ -999,10 +999,10 @@ s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { case 0x3490: if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.save.playerData.rupees >= play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees >= play->msgCtx.unk1206C) { if (Inventory_HasEmptyBottle()) { this->actionFunc = func_808F3C40; - Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_MILK, 500.0f, 100.0f); Rupees_ChangeBy(-play->msgCtx.unk1206C); ret = true; } else { @@ -1064,10 +1064,10 @@ s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { ret = false; break; case 0x3475: - SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_START); + SET_WEEKEVENTREG_HORSE_RACE_STATE(WEEKEVENTREG_HORSE_RACE_STATE_START); func_800FD750(NA_BGM_HORSE); play->nextEntrance = ENTRANCE(GORMAN_TRACK, 5); - play->transitionType = TRANS_TYPE_05; + play->transitionType = TRANS_TYPE_FADE_WHITE_FAST; play->transitionTrigger = TRANS_TRIGGER_START; SET_WEEKEVENTREG(WEEKEVENTREG_57_01); break; @@ -1085,7 +1085,7 @@ s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { break; case 0x349F: this->actionFunc = func_808F3D40; - Actor_PickUp(&this->actor, play, GI_MASK_GARO, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_MASK_GARO, 500.0f, 100.0f); func_808F35D8(this, play); ret = true; break; @@ -1100,7 +1100,7 @@ s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { func_808F35D8(this, play); if (Inventory_HasEmptyBottle()) { this->actionFunc = func_808F3B40; - Actor_PickUp(&this->actor, play, GI_MILK, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_MILK, 500.0f, 100.0f); ret = true; } else { Actor_ContinueText(play, &this->actor, 0x34A2); @@ -1188,7 +1188,7 @@ s32 func_808F5674(PlayState* play, EnIn* this, s32 arg2) { case TEXT_STATE_CHOICE: case TEXT_STATE_5: if (Message_ShouldAdvance(play) && func_808F4414(play, this, arg2)) { - func_801477B4(play); + Message_CloseTextbox(play); ret = true; } break; @@ -1210,7 +1210,7 @@ s32 func_808F5728(PlayState* play, EnIn* this, s32 arg2, s32* arg3) { return 0; } if (*arg3 == 3) { - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); *arg3 = 1; return 0; } @@ -1322,7 +1322,7 @@ void func_808F5B58(EnIn* this, PlayState* play) { } void func_808F5C98(EnIn* this, PlayState* play) { - if (this->unk4B0 == WEEKEVENTREG_RACE_FLAG_END) { + if (this->unk4B0 == WEEKEVENTREG_HORSE_RACE_STATE_END) { this->actionFunc = func_808F5B58; } if ((Player_GetMask(play) == PLAYER_MASK_CIRCUS_LEADER && CHECK_WEEKEVENTREG(WEEKEVENTREG_63_40)) || @@ -1334,10 +1334,10 @@ void func_808F5C98(EnIn* this, PlayState* play) { } } if (this->unk4A8 == 2) { - if (this->unk4B0 == WEEKEVENTREG_RACE_FLAG_2) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); + if (this->unk4B0 == WEEKEVENTREG_HORSE_RACE_STATE_2) { + Actor_PlaySfx(&this->actor, NA_SE_VO_IN_LOST); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); + Actor_PlaySfx(&this->actor, NA_SE_VO_IN_JOY0); } this->unk4A8 = 3; } else if (this->unk4A8 < 3) { @@ -1366,7 +1366,7 @@ void EnIn_Init(Actor* thisx, PlayState* play) { this->unk48C = 0; this->unk4AC = 0; type = ENIN_GET_TYPE(thisx); - this->unk4B0 = GET_WEEKEVENTREG_RACE_FLAGS; + this->unk4B0 = GET_WEEKEVENTREG_HORSE_RACE_STATE; if (type == ENIN_HORSE_RIDER_BLUE_SHIRT || type == ENIN_BLUE_SHIRT) { this->unk4AC |= 8; } @@ -1387,8 +1387,8 @@ void EnIn_Init(Actor* thisx, PlayState* play) { this->path = SubS_GetPathByIndex(play, ENIN_GET_PATH(&this->actor), 0x3F); this->unk23D = 0; if (type == ENIN_YELLOW_SHIRT || type == ENIN_BLUE_SHIRT) { - if ((GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_2) || - (GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_3)) { + if ((GET_WEEKEVENTREG_HORSE_RACE_STATE == WEEKEVENTREG_HORSE_RACE_STATE_2) || + (GET_WEEKEVENTREG_HORSE_RACE_STATE == WEEKEVENTREG_HORSE_RACE_STATE_3)) { CLEAR_WEEKEVENTREG(WEEKEVENTREG_56_08); this->unk4A8 = 0; this->unk4AC |= 2; @@ -1396,12 +1396,12 @@ void EnIn_Init(Actor* thisx, PlayState* play) { this->unk23C = 0; D_801BDAA0 = 0; - if (GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_2) { + if (GET_WEEKEVENTREG_HORSE_RACE_STATE == WEEKEVENTREG_HORSE_RACE_STATE_2) { EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_6); } else { EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_4); } - if (GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_2) { + if (GET_WEEKEVENTREG_HORSE_RACE_STATE == WEEKEVENTREG_HORSE_RACE_STATE_2) { this->skelAnime.curFrame = ((Rand_ZeroOne() * 0.6f) + 0.2f) * this->skelAnime.endFrame; } if (this->unk4AC & 8) { @@ -1410,7 +1410,7 @@ void EnIn_Init(Actor* thisx, PlayState* play) { this->actionFunc = func_808F5C98; } } else { - if (GET_WEEKEVENTREG_RACE_FLAGS != WEEKEVENTREG_RACE_FLAG_START) { + if (GET_WEEKEVENTREG_HORSE_RACE_STATE != WEEKEVENTREG_HORSE_RACE_STATE_START) { CLEAR_WEEKEVENTREG(WEEKEVENTREG_56_08); this->unk23C = 0; this->unk4AC |= 2; @@ -1468,7 +1468,7 @@ void EnIn_Update(Actor* thisx, PlayState* play) { this->unk4AC &= ~0x40; } this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); func_808F3414(this, play); func_808F32A0(this, play); } diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.c b/src/overlays/actors/ovl_En_Insect/z_en_insect.c index 9eae19437..866f1d1b8 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.c @@ -112,7 +112,7 @@ void func_8091A9E4(EnInsect* this) { return; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MUSI_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_MUSI_WALK); this->unk_316 = 3.0f / CLAMP_MIN(this->skelAnime.playSpeed, 0.1f); if (this->unk_316 < 2) { @@ -181,9 +181,9 @@ void func_8091AC78(EnInsect* this) { void func_8091ACC4(EnInsect* this, PlayState* play) { f32 temp_f2; - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); + Math_SmoothStepToF(&this->actor.speed, 0.0f, 0.1f, 0.5f, 0.0f); - temp_f2 = (Rand_ZeroOne() * 0.8f) + (this->actor.speedXZ * 1.2f); + temp_f2 = (Rand_ZeroOne() * 0.8f) + (this->actor.speed * 1.2f); if (temp_f2 < 0.0f) { this->skelAnime.playSpeed = 0.0f; } else { @@ -201,7 +201,7 @@ void func_8091ACC4(EnInsect* this, PlayState* play) { if ((this->unk_30C & 4) && (this->unk_314 <= 0)) { func_8091B3D0(this); - } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & 0x40)) { + } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH)) { func_8091B618(this); } else if (this->actor.xzDistToPlayer < 40.0f) { func_8091B030(this); @@ -218,7 +218,7 @@ void func_8091AE5C(EnInsect* this, PlayState* play) { s32 pad; f32 temp_f0; - Math_SmoothStepToF(&this->actor.speedXZ, 1.5f, 0.1f, 0.5f, 0.0f); + Math_SmoothStepToF(&this->actor.speed, 1.5f, 0.1f, 0.5f, 0.0f); if ((EnInsect_XZDistanceSquared(&this->actor.world.pos, &this->actor.home.pos) > SQ(40.0f)) || (this->unk_312 < 4)) { @@ -231,7 +231,7 @@ void func_8091AE5C(EnInsect* this, PlayState* play) { this->actor.shape.rot.y = this->actor.world.rot.y; - temp_f0 = this->actor.speedXZ * 1.4f; + temp_f0 = this->actor.speed * 1.4f; this->skelAnime.playSpeed = CLAMP(temp_f0, 0.7f, 1.9f); SkelAnime_Update(&this->skelAnime); @@ -241,7 +241,7 @@ void func_8091AE5C(EnInsect* this, PlayState* play) { if ((this->unk_30C & 4) && (this->unk_314 <= 0)) { func_8091B3D0(this); - } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & 0x40)) { + } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH)) { func_8091B618(this); } else if (this->actor.xzDistToPlayer < 40.0f) { func_8091B030(this); @@ -261,7 +261,7 @@ void func_8091B07C(EnInsect* this, PlayState* play) { s16 yaw; s32 sp38 = this->actor.xzDistToPlayer < 40.0f; - Math_SmoothStepToF(&this->actor.speedXZ, 1.8f, 0.1f, 0.5f, 0.0f); + Math_SmoothStepToF(&this->actor.speed, 1.8f, 0.1f, 0.5f, 0.0f); if ((EnInsect_XZDistanceSquared(&this->actor.world.pos, &this->actor.home.pos) > SQ(160.0f)) || (this->unk_312 < 4)) { @@ -284,13 +284,13 @@ void func_8091B07C(EnInsect* this, PlayState* play) { this->actor.shape.rot.y = this->actor.world.rot.y; - speed = this->actor.speedXZ * 1.6f; + speed = this->actor.speed * 1.6f; this->skelAnime.playSpeed = CLAMP(speed, 0.8f, 1.9f); SkelAnime_Update(&this->skelAnime); if ((this->unk_312 <= 0) || !sp38) { func_8091AC78(this); - } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & 0x40)) { + } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH)) { func_8091B618(this); } } @@ -299,7 +299,7 @@ void func_8091B274(EnInsect* this) { this->unk_312 = 200; Actor_SetScale(&this->actor, 0.001f); this->actor.draw = NULL; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->skelAnime.playSpeed = 0.3f; this->actionFunc = func_8091B2D8; this->unk_30C &= ~0x100; @@ -325,7 +325,7 @@ void func_8091B2D8(EnInsect* this, PlayState* play) { void func_8091B3D0(EnInsect* this) { this->unk_312 = 60; this->skelAnime.playSpeed = 1.9f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALTURA_BOUND); Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); this->actionFunc = func_8091B440; this->unk_30C &= ~0x100; @@ -336,7 +336,7 @@ void func_8091B440(EnInsect* this, PlayState* play) { s32 pad[2]; Vec3f sp34; - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); + Math_SmoothStepToF(&this->actor.speed, 0.0f, 0.1f, 0.5f, 0.0f); Math_StepToS(&this->actor.shape.rot.x, 0x2AAA, 0x160); Actor_SetScale(&this->actor, CLAMP_MIN(this->actor.scale.x - 0.0002f, 0.001f)); @@ -373,9 +373,9 @@ void func_8091B670(EnInsect* this, PlayState* play) { Vec3f sp40; if (this->unk_312 > 80) { - Math_StepToF(&this->actor.speedXZ, 0.6f, 0.08f); + Math_StepToF(&this->actor.speed, 0.6f, 0.08f); } else { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.02f); + Math_StepToF(&this->actor.speed, 0.0f, 0.02f); } this->actor.velocity.y = 0.0f; @@ -409,7 +409,7 @@ void func_8091B670(EnInsect* this, PlayState* play) { if ((this->unk_312 <= 0) || ((this->unk_30C & 4) && (this->unk_314 <= 0))) { func_8091B928(this); - } else if (!(this->actor.bgCheckFlags & 0x40)) { + } else if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH)) { func_8091AC78(this); } } @@ -417,7 +417,7 @@ void func_8091B670(EnInsect* this, PlayState* play) { void func_8091B928(EnInsect* this) { this->unk_312 = 100; this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.terminalVelocity = -0.8f; this->actor.gravity = -0.04f; this->unk_30C &= ~1; @@ -442,7 +442,7 @@ void func_8091B984(EnInsect* this, PlayState* play) { void EnInsect_Update(Actor* thisx, PlayState* play) { EnInsect* this = THIS; - s32 phi_v0; + s32 updBgCheckInfoFlags; if ((this->actor.child != NULL) && (this->actor.child->update == NULL) && (&this->actor != this->actor.child)) { this->actor.child = NULL; @@ -462,7 +462,7 @@ void EnInsect_Update(Actor* thisx, PlayState* play) { Actor_MoveWithGravity(&this->actor); if (this->unk_30C & 0x100) { if (this->unk_30C & 1) { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { func_8091A9E4(this); } } else { @@ -470,14 +470,14 @@ void EnInsect_Update(Actor* thisx, PlayState* play) { } } - phi_v0 = 0; + updBgCheckInfoFlags = 0; if (this->unk_30C & 1) { - phi_v0 = 4; + updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_4; } - if (phi_v0 != 0) { - phi_v0 |= 0x40; - Actor_UpdateBgCheckInfo(play, &this->actor, 8.0f, 5.0f, 0.0f, phi_v0); + if (updBgCheckInfoFlags != 0) { + updBgCheckInfoFlags |= UPDBGCHECKINFO_FLAG_40; + Actor_UpdateBgCheckInfo(play, &this->actor, 8.0f, 5.0f, 0.0f, updBgCheckInfoFlags); } if (Actor_HasParent(&this->actor, play)) { @@ -494,7 +494,7 @@ void EnInsect_Update(Actor* thisx, PlayState* play) { } if (!(this->unk_30C & 8) && (D_8091BD60 < 4) && EnInsect_InBottleRange(this, play) && - Actor_PickUp(&this->actor, play, GI_MAX, 60.0f, 30.0f)) { + Actor_OfferGetItem(&this->actor, play, GI_MAX, 60.0f, 30.0f)) { D_8091BD60++; } } 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 2c6a15737..e29a91b4b 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1,17 +1,4 @@ -/* - * File: z_en_invadepoh.c - * Overlay: ovl_En_Invadepoh - * Description: Ranch nighttime actors - */ - #include "z_en_invadepoh.h" -#include "overlays/actors/ovl_En_Door/z_en_door.h" -#include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_ma1/object_ma1.h" -#include "objects/object_ma2/object_ma2.h" -#include "objects/object_dog/object_dog.h" -#include "objects/object_cow/object_cow.h" -#include "objects/object_uch/object_uch.h" #define FLAGS (ACTOR_FLAG_10) @@ -21,164 +8,8 @@ void EnInvadepoh_Init(Actor* thisx, PlayState* play); void EnInvadepoh_Destroy(Actor* thisx, PlayState* play); void EnInvadepoh_Update(Actor* thisx, PlayState* play); -void func_80B46DA8(EnInvadepoh* this); -void func_80B46DC8(EnInvadepoh* this, PlayState* play); -void func_80B46E20(EnInvadepoh* this); -void func_80B46E44(EnInvadepoh* this, PlayState* play); -void func_80B46EC0(EnInvadepoh* this); -void func_80B46EE8(EnInvadepoh* this, PlayState* play); -void func_80B46F88(EnInvadepoh* this); -void func_80B46FA8(EnInvadepoh* this, PlayState* play); -void func_80B47064(EnInvadepoh* this); -void func_80B47084(EnInvadepoh* this, PlayState* play); -void func_80B470E0(EnInvadepoh* this); -void func_80B47108(EnInvadepoh* this, PlayState* play); -void func_80B471C0(EnInvadepoh* this); -void func_80B471E0(EnInvadepoh* this, PlayState* play); -void func_80B47248(EnInvadepoh* this); -void func_80B47268(EnInvadepoh* this, PlayState* play); -void func_80B47298(EnInvadepoh* this, PlayState* play); -void func_80B47304(EnInvadepoh* this); -void func_80B47324(EnInvadepoh* this, PlayState* play); -void func_80B473E4(EnInvadepoh* this, PlayState* play); -void func_80B474DC(EnInvadepoh* this, PlayState* play); -void func_80B47600(EnInvadepoh* this, PlayState* play); -void func_80B477B4(EnInvadepoh* this, PlayState* play); -void func_80B48324(EnInvadepoh* this, PlayState* play); -void func_80B4ACF0(EnInvadepoh* this, PlayState* play); -void func_80B4AD3C(EnInvadepoh* this); -void func_80B4AD60(EnInvadepoh* this, PlayState* play); -void func_80B4ADB8(EnInvadepoh* this); -void func_80B4ADCC(EnInvadepoh* this, PlayState* play); -void func_80B4AEC0(EnInvadepoh* this); -void func_80B4AEDC(EnInvadepoh* this, PlayState* play); -void func_80B4AF80(EnInvadepoh* this); -void func_80B4AF94(EnInvadepoh* this, PlayState* play); -void func_80B4B024(EnInvadepoh* this); -void func_80B4B048(EnInvadepoh* this, PlayState* play); -void func_80B4B484(EnInvadepoh* this, PlayState* play); -void func_80B4B510(EnInvadepoh* this); -void func_80B4B564(EnInvadepoh* this, PlayState* play); -void func_80B4B724(EnInvadepoh* this); -void func_80B4B768(EnInvadepoh* this, PlayState* play); -void func_80B4B820(EnInvadepoh* this); -void func_80B4B864(EnInvadepoh* this, PlayState* play); -void func_80B48374(EnInvadepoh* this); -void func_80B483CC(EnInvadepoh* this, PlayState* play); -void func_80B49A00(EnInvadepoh* this, PlayState* play); -void func_80B4994C(EnInvadepoh* this, PlayState* play); -void func_80B497EC(EnInvadepoh* this, PlayState* play); -void func_80B49628(EnInvadepoh* this); -void func_80B49670(EnInvadepoh* this, PlayState* play); -void func_80B49454(EnInvadepoh* this, PlayState* play); -void func_80B4934C(EnInvadepoh* this, PlayState* play); -void func_80B491EC(EnInvadepoh* this); -void func_80B49228(EnInvadepoh* this, PlayState* play); -void func_80B49C38(EnInvadepoh* this, PlayState* play); -void func_80B49DFC(EnInvadepoh* this, PlayState* play); -void func_80B4A350(EnInvadepoh* this, PlayState* play); -void func_80B4A5E4(EnInvadepoh* this, PlayState* play); -void func_80B4A67C(EnInvadepoh* this, PlayState* play); -void func_80B4A81C(EnInvadepoh* this, PlayState* play); -void func_80B4BC4C(EnInvadepoh* this, PlayState* play); -void func_80B4C058(EnInvadepoh* this, PlayState* play); -void func_80B4C218(EnInvadepoh* this, PlayState* play); -void func_80B4C730(EnInvadepoh* this, PlayState* play); -void func_80B4CB0C(EnInvadepoh* this, PlayState* play); -void func_80B4CCCC(EnInvadepoh* this, PlayState* play); -void func_80B4D480(EnInvadepoh* this, PlayState* play); -void func_80B47568(EnInvadepoh* this); -void func_80B478F4(EnInvadepoh* this, PlayState* play); -void func_80B47938(EnInvadepoh* this); -void func_80B479E8(EnInvadepoh* this, PlayState* play); -void func_80B4843C(EnInvadepoh* this); -void func_80B484EC(EnInvadepoh* this, PlayState* play); -void func_80B48588(EnInvadepoh* this); -void func_80B48610(EnInvadepoh* this, PlayState* play); -void func_80B48848(EnInvadepoh* this, PlayState* play); -void func_80B47278(EnInvadepoh* this); -void func_80B48AD4(EnInvadepoh* this, PlayState* play); -void func_80B48E4C(EnInvadepoh* this, PlayState* play); -void func_80B49404(EnInvadepoh* this); -void func_80B4A570(EnInvadepoh* this); -void func_80B4C1BC(EnInvadepoh* this); -void func_80B4D290(EnInvadepoh* this, PlayState* play); -void func_80B4CC70(EnInvadepoh* this); -void func_80B4770C(EnInvadepoh* this); -void func_80B48948(EnInvadepoh* this); -void func_80B49904(EnInvadepoh* this); -void func_80B499BC(EnInvadepoh* this); -void func_80B492FC(EnInvadepoh* this); -void func_80B4627C(EnInvadepoh* this, PlayState* play); -void EnInvadepoh_InitAlien(EnInvadepoh* this, PlayState* play); -void EnInvadepoh_InitParentCow(EnInvadepoh* this, PlayState* play); -void EnInvadepoh_InitChildCow(EnInvadepoh* this, PlayState* play); -void EnInvadepoh_InitRomani(EnInvadepoh* this, PlayState* play); -void func_80B468B4(EnInvadepoh* this, PlayState* play); -void EnInvadepoh_InitDog(EnInvadepoh* this, PlayState* play); -void EnInvadepoh_InitCremia(EnInvadepoh* this, PlayState* play); -void func_80B46BB0(EnInvadepoh* this, PlayState* play); -void func_80B46BC0(EnInvadepoh* this, PlayState* play); -void func_80B46C08(EnInvadepoh* this, PlayState* play); -void func_80B46C34(EnInvadepoh* this, PlayState* play); -void func_80B46C50(EnInvadepoh* this, PlayState* play); -void func_80B46C50(EnInvadepoh* this, PlayState* play); -void func_80B46C7C(EnInvadepoh* this, PlayState* play); -void func_80B46C50(EnInvadepoh* this, PlayState* play); -void func_80B46C50(EnInvadepoh* this, PlayState* play); -void func_80B46C50(EnInvadepoh* this, PlayState* play); -void func_80B46C94(EnInvadepoh* this, PlayState* play); -void func_80B46CC0(EnInvadepoh* this, PlayState* play); -void func_80B46CF4(EnInvadepoh* this, PlayState* play); -void func_80B46D28(EnInvadepoh* this, PlayState* play); -void func_80B4D670(Actor* thisx, PlayState* play); -void func_80B47BAC(Actor* thisx, PlayState* play); -void func_80B47D30(Actor* thisx, PlayState* play); -void func_80B47FA8(Actor* thisx, PlayState* play); -void func_80B48060(Actor* thisx, PlayState* play); -void func_80B481C4(Actor* thisx, PlayState* play); -void func_80B4827C(Actor* thisx, PlayState* play); -void func_80B48620(Actor* thisx, PlayState* play); -void func_80B48FB0(Actor* thisx, PlayState* play); -void func_80B49F88(Actor* thisx, PlayState* play); -void func_80B4A9C8(Actor* thisx, PlayState* play); -void func_80B4B0C4(Actor* thisx, PlayState* play); -void func_80B4CE54(Actor* thisx, PlayState* play); -void func_80B4B8BC(Actor* thisx, PlayState* play); -void func_80B4C3A0(Actor* thisx, PlayState* play); -void func_80B49B1C(Actor* thisx, PlayState* play); -void func_80B4E158(Actor* thisx, PlayState* play); -void func_80B4E3F0(Actor* thisx, PlayState* play); -void func_80B4D9B4(Actor* thisx, PlayState* play); -void func_80B4E1B0(Actor* thisx, PlayState* play); -void func_80B4E324(Actor* thisx, PlayState* play); -void func_80B4BA84(Actor* thisx, PlayState* play); -void func_80B4E660(Actor* thisx, PlayState* play); -void func_80B4C5C0(Actor* thisx, PlayState* play); -void func_80B4E7BC(Actor* thisx, PlayState* play); -void func_80B4A1B8(Actor* thisx, PlayState* play); -void func_80B4ABDC(Actor* thisx, PlayState* play); -void func_80B4D054(Actor* thisx, PlayState* play); -void func_80B4DB14(Actor* thisx, PlayState* play); -void func_80B4D760(Actor* thisx, PlayState* play); -void func_80B4A168(Actor* thisx, PlayState* play); -void func_80B4873C(Actor* thisx, PlayState* play); -void func_80B490F0(Actor* thisx, PlayState* play); -void func_80B4AB8C(Actor* thisx, PlayState* play); -void func_80B4B218(Actor* thisx, PlayState* play); -void func_80B4BA30(Actor* thisx, PlayState* play); -void func_80B4C568(Actor* thisx, PlayState* play); -void func_80B4CFFC(Actor* thisx, PlayState* play); -void func_80B46184(unkStruct80B50350* unkStruct); -s32 func_80B450C0(f32* x1, f32* z1, f32 x2, f32 z2, f32 speed); -s32 func_80B4516C(EnInvadepoh* this); -void func_80B45A4C(EnInvadePohStruct* s, unkstructInvadepoh4** u); -void func_80B45A94(EnInvadePohStruct* s, unkstructInvadepoh4** u); -void func_80B45B1C(EnInvadePohStruct* s, unkstructInvadepoh4** u); - -extern s32 D_801BDA9C; - -ActorInit En_Invadepoh_InitVars = { +/* +const ActorInit En_Invadepoh_InitVars = { ACTOR_EN_INVADEPOH, ACTORCAT_PROP, FLAGS, @@ -189,4414 +20,492 @@ ActorInit En_Invadepoh_InitVars = { (ActorFunc)EnInvadepoh_Update, (ActorFunc)NULL, }; +*/ -static ColliderCylinderInit sCylinderInitAlien = { - { - COLTYPE_HIT3, - AT_ON | AT_TYPE_ENEMY, - AC_ON | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_1, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK4, - { 0xF7CFFFFF, 0x00, 0x04 }, - { 0x00003820, 0x00, 0x00 }, - TOUCH_ON | TOUCH_SFX_NONE, - BUMP_ON, - OCELEM_ON, - }, - { 40, 95, 10, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit sCylinderInitRomaniAndCremia = { - { - COLTYPE_NONE, - AT_NONE, - AC_NONE, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000000, 0x00, 0x00 }, - TOUCH_NONE | TOUCH_SFX_NORMAL, - BUMP_NONE, - OCELEM_ON, - }, - { 18, 46, 0, { 0, 0, 0 } }, -}; - -static ColliderCylinderInit sCylinderInitDog = { - { - COLTYPE_NONE, - 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, - }, - { 13, 19, 0, { 0, 0, 0 } }, -}; - -static Vec3f D_80B4E934 = { 216.0f, -20.0f, 1395.0f }; - -static s32 D_80B4E940 = 0; - -static TexturePtr sRomaniEyeTextures[] = { - gRomaniEyeOpenTex, gRomaniEyeHalfTex, gRomaniEyeClosedTex, gRomaniEyeHappyTex, gRomaniEyeSadTex, -}; - -static TexturePtr sRomaniMouthTextures[] = { - gRomaniMouthHappyTex, - gRomaniMouthFrownTex, - gRomaniMouthHangingOpenTex, - gRomaniMouthSmileTex, -}; - -static s8 D_80B4E968 = 0; - -static TexturePtr sCremiaEyeTextures[] = { - gCremiaEyeOpenTex, gCremiaEyeHalfTex, gCremiaEyeClosedTex, gCremiaEyeHappyTex, gCremiaEyeAngryTex, gCremiaEyeSadTex, -}; - -static TexturePtr sCremiaMouthTextures[] = { - gCremiaMouthNormalTex, - gCremiaMouthSlightSmileTex, - gCremiaMouthFrownTex, - gCremiaMouthHangingOpenTex, -}; - -static s8 D_80B4E994 = 0; - -static s8 D_80B4E998 = 0; - -static s8 D_80B4E99C[] = { 0 }; - -static s8 D_80B4E9A0[] = { 0, 1, 2, 0 }; - -static s8 D_80B4E9A4[] = { 0, 1, 2, 1, 0 }; - -static s8 D_80B4E9AC[] = { 0, 1, 2, 2, 1, 0 }; - -static s8 D_80B4E9B4[] = { - 0, 1, 2, 1, 0, 1, 2, 0, -}; - -static s8 D_80B4E9BC[] = { 1 }; - -static s8 D_80B4E9C0[] = { 3 }; - -static unkstructInvadepoh0 D_80B4E9C4 = { D_80B4E99C, 1 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B439B0.s") -static unkstructInvadepoh0 D_80B4E9CC = { D_80B4E9A0, 4 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B43A24.s") -static unkstructInvadepoh0 D_80B4E9D4 = { D_80B4E9A4, 5 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B43A74.s") -static unkstructInvadepoh0 D_80B4E9DC = { D_80B4E9AC, 6 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B43A9C.s") -static unkstructInvadepoh0 D_80B4E9E4 = { D_80B4E9B4, 8 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B43AB0.s") -static unkstructInvadepoh0 D_80B4E9EC = { D_80B4E9BC, 1 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B43AF0.s") -static unkstructInvadepoh0 D_80B4E9F4 = { D_80B4E9C0, 1 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B43B80.s") -static unkstructInvadepoh2 D_80B4E9FC = { 0, &D_80B4E9C4 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B43BC8.s") -static unkstructInvadepoh1 D_80B4EA04[] = { - { 2, 0.5f }, - { 3, 0.9f }, - { 4, 0.97f }, - { 5, 1.0f }, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B43DD4.s") -static unkstructInvadepoh1 D_80B4EA24[] = { - { 1, 1.0f }, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B43E6C.s") -static unkstructInvadepoh4 D_80B4EA2C = { 2, &D_80B4E9C4, 4, D_80B4EA04, 0x28, 0x3C }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B43F0C.s") -static unkstructInvadepoh3 D_80B4EA40 = { - 1, - &D_80B4E9CC, - 1, - D_80B4EA24, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B43F70.s") -static unkstructInvadepoh3 D_80B4EA50 = { - 1, - &D_80B4E9D4, - 1, - D_80B4EA24, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44024.s") -static unkstructInvadepoh3 D_80B4EA60 = { - 1, - &D_80B4E9DC, - 1, - D_80B4EA24, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4407C.s") -static unkstructInvadepoh3 D_80B4EA70 = { - 1, - &D_80B4E9E4, - 1, - D_80B4EA24, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B440B8.s") -static unkstructInvadepoh2 D_80B4EA80 = { - 0, - &D_80B4E9EC, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44234.s") -static unkstructInvadepoh2 D_80B4EA88 = { - 0, - &D_80B4E9F4, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B442E4.s") -static void* D_80B4EA90[] = { - &D_80B4E9FC, &D_80B4EA2C, &D_80B4EA40, &D_80B4EA50, &D_80B4EA60, &D_80B4EA70, &D_80B4EA80, &D_80B4EA88, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B443A0.s") -static s8 D_80B4EAB0[] = { 0 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B444BC.s") -static s8 D_80B4EAB4[] = { 1 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B444F4.s") -static s8 D_80B4EAB8[] = { 2 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44514.s") -static s8 D_80B4EABC[] = { 3 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44540.s") -static unkstructInvadepoh0 D_80B4EAC0 = { D_80B4EAB0, 1 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44570.s") -static unkstructInvadepoh0 D_80B4EAC8 = { D_80B4EAB4, 1 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44620.s") -static unkstructInvadepoh0 D_80B4EAD0 = { D_80B4EAB8, 1 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44640.s") -static unkstructInvadepoh0 D_80B4EAD8 = { D_80B4EABC, 1 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44664.s") -static unkstructInvadepoh2 D_80B4EAE0 = { 0, &D_80B4EAC0 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44690.s") -static unkstructInvadepoh2 D_80B4EAE8 = { 0, &D_80B4EAC8 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B446D0.s") -static unkstructInvadepoh2 D_80B4EAF0 = { 0, &D_80B4EAD0 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44700.s") -static unkstructInvadepoh2 D_80B4EAF8 = { 0, &D_80B4EAD8 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B447C0.s") -static void* D_80B4EB00[] = { - &D_80B4EAE0, - &D_80B4EAE8, - &D_80B4EAF0, - &D_80B4EAF8, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44A90.s") -static s8 D_80B4EB10[] = { 0 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44B78.s") -static s8 D_80B4EB14[] = { 0, 1, 2, 0 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44B84.s") -static s8 D_80B4EB18[] = { 0, 1, 2, 1, 0 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44C24.s") -static s8 D_80B4EB20[] = { 0, 1, 2, 2, 1, 0 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44C80.s") -static s8 D_80B4EB28[] = { 0, 1, 2, 1, 0, 1, 2, 0 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44E90.s") -static unkstructInvadepoh0 D_80B4EB30 = { D_80B4EB10, 1 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44EFC.s") -static unkstructInvadepoh0 D_80B4EB38 = { D_80B4EB14, 4 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44F58.s") -static unkstructInvadepoh0 D_80B4EB40 = { D_80B4EB18, 5 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B44FEC.s") -static unkstructInvadepoh0 D_80B4EB48 = { D_80B4EB20, 6 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B45080.s") -static unkstructInvadepoh0 D_80B4EB50 = { D_80B4EB28, 8 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B450C0.s") -static unkstructInvadepoh2 D_80B4EB58 = { 0, &D_80B4EB30 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4516C.s") -static unkstructInvadepoh1 D_80B4EB60[] = { - { 2, 0.5f }, - { 3, 0.9f }, - { 4, 0.95f }, - { 5, 1.0f }, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B451A0.s") -static unkstructInvadepoh1 D_80B4EB80[] = { - { 1, 1.0f }, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B452EC.s") -static unkstructInvadepoh4 D_80B4EB88 = { 2, &D_80B4EB30, 4, D_80B4EB60, 0x28, 0x3C }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B453F4.s") -static unkstructInvadepoh3 D_80B4EB9C = { - 1, - &D_80B4EB38, - 1, - D_80B4EB80, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B45460.s") -static unkstructInvadepoh3 D_80B4EBAC = { - 1, - &D_80B4EB40, - 1, - D_80B4EB80, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B454BC.s") -static unkstructInvadepoh3 D_80B4EBBC = { - 1, - &D_80B4EB48, - 1, - D_80B4EB80, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B45518.s") -static unkstructInvadepoh3 D_80B4EBCC = { - 1, - &D_80B4EB50, - 1, - D_80B4EB80, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B45550.s") -static void* D_80B4EBDC[] = { - &D_80B4EB58, &D_80B4EB88, &D_80B4EB9C, &D_80B4EBAC, &D_80B4EBBC, &D_80B4EBCC, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4560C.s") -static s8 D_80B4EBF4[] = { 0 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B45648.s") -static unkstructInvadepoh0 D_80B4EBF8 = { D_80B4EBF4, 1 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B456A8.s") -static unkstructInvadepoh2 D_80B4EC00 = { 0, &D_80B4EBF8 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B457A0.s") -static void* D_80B4EC08[] = { &D_80B4EC00 }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B458D8.s") -static void (*D_80B4EC0C[])(struct EnInvadePohStruct*, unkstructInvadepoh4** arg1) = { - func_80B45A4C, - func_80B45A94, - func_80B45B1C, -}; - -static Color_RGBA8 D_80B4EC18 = { 255, 255, 200, 255 }; - -static Color_RGBA8 D_80B4EC1C = { 255, 200, 0, 0 }; - -static void (*D_80B4EC20[])(struct unkStruct80B50350*) = { func_80B46184 }; - -static InitChainEntry D_80B4EC24[] = { - ICHAIN_F32(uncullZoneForward, 20000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 600, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), -}; - -static InitChainEntry sInitChainParentCow[] = { - ICHAIN_F32(uncullZoneForward, 20000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), -}; - -static InitChainEntry sInitChainChildCow[] = { - ICHAIN_F32(uncullZoneForward, 20000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), -}; - -static InitChainEntry sInitChainRomani[] = { - ICHAIN_F32(uncullZoneForward, 20000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 1500, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), -}; - -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(terminalVelocity, -100, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), -}; - -static InitChainEntry sInitChainDog[] = { - ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 50, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 50, ICHAIN_CONTINUE), - ICHAIN_F32(gravity, -3, ICHAIN_CONTINUE), - ICHAIN_U8(targetMode, 4, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 7, ICHAIN_STOP), -}; - -static InitChainEntry sInitChainCremia[] = { - ICHAIN_F32(uncullZoneForward, 20000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 150, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 1500, ICHAIN_CONTINUE), - ICHAIN_U8(targetMode, 3, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), -}; - -static EnInvadepohInitFunc D_80B4ECB0[] = { - func_80B4627C, - EnInvadepoh_InitAlien, - EnInvadepoh_InitParentCow, - EnInvadepoh_InitChildCow, - EnInvadepoh_InitRomani, - EnInvadepoh_InitRomani, - func_80B468B4, - EnInvadepoh_InitRomani, - EnInvadepoh_InitRomani, - EnInvadepoh_InitRomani, - EnInvadepoh_InitDog, - EnInvadepoh_InitCremia, - EnInvadepoh_InitRomani, - EnInvadepoh_InitAlien, -}; - -static EnInvadepohDestroyFunc D_80B4ECE8[] = { - func_80B46BB0, func_80B46BC0, func_80B46C08, func_80B46C34, func_80B46C50, func_80B46C50, func_80B46C7C, - func_80B46C50, func_80B46C50, func_80B46C50, func_80B46C94, func_80B46CC0, func_80B46CF4, func_80B46D28, -}; - -static s16 D_80B4ED20[] = { - 130, 125, 115, 100, 80, 78, 76, 74, -}; - -static Vec3f D_80B4ED30[] = { - { 0.01f, 0.01f, 0.01f }, { 0.02f, 0.01f, 0.005f }, { -0.01f, 0.0f, 0.0f }, - { 0.01f, 0.01f, 0.01f }, { 0.005f, 0.01f, 0.02f }, -}; - -static Vec3f D_80B4ED6C[] = { - { 0.0005f, 0.0279999990016f, 0.01f }, { -0.01f, 0.0f, 0.0f }, { -0.01f, 0.0f, 0.0f }, - { 0.016f, 0.0004f, 0.01f }, { -0.01f, 0.0f, 0.0f }, { 0.0005f, 0.0005f, 0.0005f }, - { 0.0002f, 0.0002f, 0.0002f }, -}; - -static s16 D_80B4EDC0[] = { 0xE0C0, 0xE890, 0xD508 }; - -static s16 D_80B4EDC8[] = { - -1800, - -1000, - 0, - 2000, -}; - -static Vec3f D_80B4EDD0[] = { - { -1813.0f, 374.0f, 1900.0f }, { 2198.0f, 153.0f, 3365.0f }, { -1434.0f, 262.0f, 3365.0f }, - { -393.0f, 396.0f, 1084.0f }, { 0.0f, 1500.0f, 0.0f }, -}; - -static unkstruct80B4EE0C D_80B4EE0C[] = { - { 0.08f, 0x02BC, 0xFFF6 }, - { 0.09f, 0x012C, 0xFFFB }, - { 0.05f, 0x0190, 0x0000 }, -}; - -static Vec3f D_80B4EE24 = { - 2000.0f, - 1000.0f, - 0.0f, -}; - -static Vec3f D_80B4EE30 = { - 400.0f, - 270.0f, - 0.0f, -}; - -MtxF D_80B502A0; -MtxF D_80B502E0; -EnInvadepoh* D_80B50320[8]; -u8 D_80B50340[8]; -UNK_TYPE1 D_80B50348; -unkStruct80B50350 D_80B50350[10]; -EnInvadepoh* D_80B503F0; -EnInvadepoh* D_80B503F4; -EnInvadepoh* D_80B503F8; -AnimatedMaterial* sAlienEyeBeamTexAnim; -AnimatedMaterial* sAlienEmptyTexAnim; -s16 D_80B50404[3]; -EnInvadepoh* D_80B5040C; - -void func_80B439B0(s32 arg0, s32 arg1) { - arg1 -= 0x1AAA; - if (arg1 < 0) { - arg1 = 0; - } - - if (!(arg0 & 1)) { - gSaveContext.save.unk_E88[arg0 >> 1] = (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF0000) | (arg1 & 0xFFFF); - } else { - gSaveContext.save.unk_E88[arg0 >> 1] = - (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF) | ((arg1 & 0xFFFF) << 0x10); - } -} - -s32 func_80B43A24(s32 arg0) { - u32 phi_v1; - - if ((arg0 & 1) == 0) { - phi_v1 = gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF; - } else { - phi_v1 = (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF0000) >> 0x10; - } - return phi_v1 + 0x1AAA; -} - -void func_80B43A74(s32 arg0) { - gSaveContext.save.unk_E88[4] = (gSaveContext.save.unk_E88[4] & ~0xFF) | (arg0 & 0xFF); -} - -s32 func_80B43A9C(void) { - return (gSaveContext.save.unk_E88[4] >> 0) & 0xFF; -} - -s32 func_80B43AB0(void) { - s32 retVal = func_80B43A9C(); - - if (retVal < 0xC) { - retVal++; - func_80B43A74(retVal); - } - return retVal; -} - -void func_80B43AF0(s32 arg0) { - s32 currentTime = gSaveContext.save.time; - - if (((CURRENT_DAY == 1) && (currentTime >= CLOCK_TIME(2, 30))) && (currentTime < CLOCK_TIME(5, 15))) { - s32 adjustment = (0xC - func_80B43A9C()) * 25.0f; - - func_80B439B0(arg0, currentTime + adjustment); - } -} - -s32 func_80B43B80(EnInvadepoh* this) { - s32 i; - s32 temp = this->endPoint - 1; - - for (i = 0; i < temp; i++) { - if (this->unk37C[i] > this->clockTime) { - break; - } - } - - return i; -} - -void func_80B43BC8(EnInvadepoh* this, s8* arg1, Vec3f* arg2) { - s32 temp_s5 = this->endPoint; - f32 pathTotalDistInv = 1.0f / this->pathTotalDist; - Vec3s* phi_s0 = &this->pathPoints[1]; - Vec3s* phi_s1 = &this->pathPoints[0]; - f32 new_var; - Vec3f sp70; - s32 phi_s2; - f32 temp_f0; - f32 temp_f12; - f32 temp_f14; - f32 temp_f6; - f32 phi_f20 = 0.0f; - f32 phi_f24 = 0.0f; - - for (phi_s2 = 0; phi_s2 < temp_s5; phi_s2++) { - sp70.x = phi_s0->x - phi_s1->x; - sp70.y = phi_s0->y - phi_s1->y; - sp70.z = phi_s0->z - phi_s1->z; - new_var = Math3D_Vec3fMagnitude(&sp70); - temp_f14 = phi_f20 + new_var; - temp_f12 = temp_f14 * pathTotalDistInv; - - if (this->clockTime <= temp_f12) { - temp_f6 = temp_f12 - phi_f24; - *arg1 = phi_s2; - temp_f0 = (this->clockTime - phi_f24) / temp_f6; - arg2->x = (temp_f0 * sp70.x) + phi_s1->x; - arg2->y = (temp_f0 * sp70.y) + phi_s1->y; - arg2->z = (temp_f0 * sp70.z) + phi_s1->z; - return; - } - - phi_s1 = phi_s0; - phi_s0++; - phi_f20 = temp_f14; - phi_f24 = temp_f12; - } - - *arg1 = temp_s5; - arg2->x = this->pathPoints[temp_s5].x; - arg2->y = this->pathPoints[temp_s5].y; - arg2->z = this->pathPoints[temp_s5].z; -} - -void func_80B43DD4(EnInvadepoh* this, s16 arg1, s16 arg2) { - s32 pad; - Vec3s* arr = &this->pathPoints[this->pathIndex]; - s32 pad2; - Vec3f sp30; - Vec3f sp24; - - if (this->pathIndex != this->endPoint) { - Math_Vec3s_ToVec3f(&sp30, &arr[0]); - Math_Vec3s_ToVec3f(&sp24, &arr[1]); - Math_ScaledStepToS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp30, &sp24) + arg2, arg1); - } -} - -void func_80B43E6C(EnInvadepoh* this, s16 arg1, s16 arg2, s16 arg3) { - s32 pad; - Vec3s* arr = &this->pathPoints[this->pathIndex]; - s32 pad2; - Vec3f sp38; - Vec3f sp2C; - - if (this->pathIndex != this->endPoint) { - Math_Vec3s_ToVec3f(&sp38, &arr[0]); - Math_Vec3s_ToVec3f(&sp2C, &arr[1]); - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp38, &sp2C), arg1, arg2, arg3); - } -} - -void func_80B43F0C(EnInvadepoh* this) { - s32 pad; - Vec3s* arr = &this->pathPoints[this->pathIndex]; - s32 pad2; - Vec3f sp28; - Vec3f sp1C; - - Math_Vec3s_ToVec3f(&sp28, &arr[0]); - Math_Vec3s_ToVec3f(&sp1C, &arr[1]); - this->actor.shape.rot.y = Math_Vec3f_Yaw(&sp28, &sp1C); -} - -f32 EnInvadepoh_GetTotalPathLength(EnInvadepoh* this) { - f32 distance; - s32 pad; - Vec3f sp54; - Vec3f pathPointF; - Vec3s* pathPoint; - f32 totalDistance; - s32 i; - s32 temp_s4; - - temp_s4 = this->endPoint + 1; - pathPoint = this->pathPoints; - totalDistance = 0.0f; - Math_Vec3s_ToVec3f(&pathPointF, pathPoint); - pathPoint++; - for (i = 1; i < temp_s4; i++) { - Math_Vec3f_Copy(&sp54, &pathPointF); - Math_Vec3s_ToVec3f(&pathPointF, pathPoint); - distance = Math3D_Distance(&sp54, &pathPointF); - pathPoint++; - totalDistance += distance; - } - - return totalDistance; -} - -void func_80B44024(EnInvadepoh* this, PlayState* play) { - Path* path = &play->setupPathList[(this->actor.params >> 8) & 0x7F]; - - this->endPoint = path->count - 1; - this->pathPoints = Lib_SegmentedToVirtual(path->points); -} - -void EnInvadepoh_SetPathPointToWorldPos(EnInvadepoh* this, s32 pathIndex) { - Math_Vec3s_ToVec3f(&this->actor.world.pos, &this->pathPoints[pathIndex]); -} - -s32 func_80B440B8(EnInvadepoh* this, f32 arg1, f32 arg2) { - Vec3s* temp_a3 = &this->pathPoints[this->pathIndex + 1]; - Vec3s* sp48 = &this->pathPoints[this->pathIndex]; - f32 new_var; - f32 sp40; - f32 sp3C; - f32 sp38; - f32 sp34; - f32 sp30; - f32 sp2C; - f32 temp_f12_2; - s32 pad1; - s32 pad2; - s16 sp1E; - - if (this->pathIndex >= this->endPoint) { - return false; - } - - sp40 = temp_a3->x - sp48->x; - sp3C = temp_a3->z - sp48->z; - sp1E = Math_Atan2S_XY(sp3C, sp40); - sp38 = Math_CosS(sp1E); - sp34 = Math_SinS(sp1E); - sp30 = this->actor.world.pos.x - sp48->x; - sp2C = this->actor.world.pos.z - sp48->z; - - if ((arg1 - arg2) < fabsf((sp30 * sp38) - (sp2C * sp34))) { - return false; - } - - temp_f12_2 = (sp2C * sp38) + (sp30 * sp34); - new_var = Math3D_XZLength(sp40, sp3C); - - if ((temp_f12_2 < 0.0f) || (new_var < temp_f12_2)) { - return false; - } - - return true; -} - -s32 func_80B44234(EnInvadepoh* this, Vec3f* vec) { - f32 distance; - s8 temp_s3 = this->endPoint; - f32 min = FLT_MAX; - Vec3f sp48; - s32 i; - s32 ret = 0; - Vec3s* arr; - - for (i = 0, arr = this->pathPoints; i < temp_s3; i++, arr++) { - Math_Vec3s_ToVec3f(&sp48, arr); - distance = Math3D_Vec3fDistSq(&sp48, vec); - if (distance < min) { - min = distance; - ret = i; - } - } - - return ret; -} - -void func_80B442E4(EnInvadepoh* this) { - s32 temp_v1_2 = ((void)0, (s32)gSaveContext.save.time) - func_80B43A24(this->actor.params & 7); - - if (D_80B4E940 == 1) { - this->clockTime = 0.0f; - } else if (D_80B4E940 == 2) { - if (temp_v1_2 < 0) { - this->clockTime = 0.0f; - } else { - this->clockTime = temp_v1_2 * 0.00027777779f; - if (this->clockTime > 1.0f) { - this->clockTime = 1.0f; - } - } - } - - this->pathIndex = func_80B43B80(this); -} - -void func_80B443A0(EnInvadepoh* this) { - f32 pathTotalDistInv; - s8 temp_s5; - Vec3s* phi_s1; - Vec3f sp70; - Vec3f sp64; - f32* phi_s0; - f32 phi_f20; - s32 i; - - temp_s5 = this->endPoint; - pathTotalDistInv = 1.0f / this->pathTotalDist; - phi_f20 = 0.0f; - phi_s1 = this->pathPoints; - Math_Vec3s_ToVec3f(&sp64, phi_s1); - phi_s1++; - phi_s0 = this->unk37C; - - for (i = 1; i < temp_s5; i++, phi_s1++, phi_s0++) { - Math_Vec3f_Copy(&sp70, &sp64); - Math_Vec3s_ToVec3f(&sp64, phi_s1); - phi_f20 += Math3D_Distance(&sp70, &sp64); - *phi_s0 = phi_f20 * pathTotalDistInv; - if (*phi_s0 < 0.0f) { - *phi_s0 = 0.0f; - } else if (*phi_s0 > 1.0f) { - *phi_s0 = 1.0f; - } - } -} - -void func_80B444BC(EnInvadepoh* this, PlayState* play) { - func_80B44024(this, play); - this->pathTotalDist = EnInvadepoh_GetTotalPathLength(this); - func_80B443A0(this); -} - -void func_80B444F4(EnInvadepoh* this, PlayState* play) { - func_80B44024(this, play); -} - -void func_80B44514(EnInvadepoh* this) { - this->pathIndex++; - if (this->pathIndex >= this->endPoint) { - this->pathIndex = 0; - } -} - -void func_80B44540(EnInvadepoh* this, PlayState* play) { - func_80B44024(this, play); - this->pathTotalDist = EnInvadepoh_GetTotalPathLength(this); -} - -void func_80B44570(EnInvadepoh* this) { - s32 currentTime = gSaveContext.save.time; - - if ((currentTime < CLOCK_TIME(2, 0)) || (currentTime >= CLOCK_TIME(6, 0))) { - this->clockTime = 0.0f; - } else if ((currentTime >= CLOCK_TIME(2, 15)) && (currentTime < CLOCK_TIME(6, 0))) { - this->clockTime = 1.0f; - } else { - f32 new_var = (currentTime - 0x1555) * 0.0014641288f; - - this->clockTime = new_var; - this->clockTime = CLAMP(this->clockTime, 0.0f, 1.0f); - } -} - -void func_80B44620(EnInvadepoh* this, PlayState* play) { - func_80B44024(this, play); -} - -void func_80B44640(EnInvadepoh* this) { - if (this->pathIndex < this->endPoint) { - this->pathIndex++; - } -} - -void func_80B44664(EnInvadepoh* this, PlayState* play) { - func_80B44024(this, play); - this->direction = DIRECTION_FORWARD; -} - -void func_80B44690(EnInvadepoh* this) { - this->pathIndex += this->direction; - if (this->pathIndex >= this->endPoint) { - this->pathIndex = 0; - } else if (this->pathIndex < 0) { - this->pathIndex = this->endPoint - 1; - } -} - -void func_80B446D0(EnInvadepoh* this, PlayState* play) { - func_80B44024(this, play); - this->pathTotalDist = EnInvadepoh_GetTotalPathLength(this); -} - -void func_80B44700(EnInvadepoh* this) { - s32 currentTime = gSaveContext.save.time; - s32 new_var4 = 0xFFFF2AAB; - - if ((currentTime < CLOCK_TIME(20, 0)) && (currentTime >= CLOCK_TIME(6, 0))) { - this->clockTime = 0.0f; - } else if ((currentTime > 0xD7E0) || (currentTime < CLOCK_TIME(6, 0))) { - this->clockTime = 1.0f; - } else { - f32 new_var = 0.00153374229558f; - - this->clockTime = (currentTime + new_var4) * new_var; - this->clockTime = CLAMP(this->clockTime, 0.0f, 1.0f); - } -} - -void func_80B447C0(EnInvadepoh* this, PlayState* play) { - s32 pad1; - Vec3s* sp60; - s32 pad2; - Vec3f sp50; - Vec3f sp44; - f32 sp40 = this->actor.world.pos.y; - f32 sp3C; - s32 pad3; - f32 sp34; - f32 sp30; - f32 sp2C; - f32 phi_f2; - - sp60 = &this->pathPoints[this->pathIndex]; - if (this->pathIndex <= 0) { - sp3C = 0.0f; - } else { - sp3C = this->unk37C[this->pathIndex - 1]; - } - - if (this->pathIndex < (this->endPoint - 1)) { - phi_f2 = this->unk37C[this->pathIndex]; - } else { - phi_f2 = 1.0f; - } - - if ((phi_f2 - sp3C) < 0.001f) { - Math_Vec3s_ToVec3f(&this->curPathPos, sp60); - } else { - sp34 = this->clockTime - sp3C; - sp30 = phi_f2 - this->clockTime; - sp2C = 1.0f / (phi_f2 - sp3C); - Math_Vec3s_ToVec3f(&sp50, &sp60[0]); - Math_Vec3s_ToVec3f(&sp44, &sp60[1]); - this->curPathPos.x = ((sp50.x * sp30) + (sp44.x * sp34)) * sp2C; - this->curPathPos.y = ((sp50.y * sp30) + (sp44.y * sp34)) * sp2C; - this->curPathPos.z = ((sp50.z * sp30) + (sp44.z * sp34)) * sp2C; - } - - Math_Vec3f_Copy(&this->actor.world.pos, &this->curPathPos); - func_800B4AEC(play, &this->actor, 0.0f); - if (this->actor.floorHeight > BGCHECK_Y_MIN + 1) { - if (sp40 < this->actor.floorHeight) { - if (this->actor.velocity.y < 0.0f) { - this->actor.velocity.y = 0.0f; - } else { - this->actor.velocity.y += 2.0f; - this->actor.velocity.y = CLAMP_MAX(this->actor.velocity.y, 30.0f); - } - this->actor.world.pos.y = this->actor.velocity.y + sp40; - if (this->actor.world.pos.y > this->actor.floorHeight) { - this->actor.world.pos.y = this->actor.floorHeight; - } - } else { - if (this->actor.velocity.y > 0.0f) { - this->actor.velocity.y = 0.0f; - } else { - this->actor.velocity.y -= 2.0f; - } - - this->actor.world.pos.y = this->actor.velocity.y + sp40; - if (this->actor.world.pos.y < this->actor.floorHeight) { - this->actor.world.pos.y = this->actor.floorHeight; - this->actor.velocity.y = CLAMP_MIN(this->actor.velocity.y, -30.0f); - } - } - } else { - this->actor.world.pos.y = sp40; - } -} - -void func_80B44A90(EnInvadepoh* this, PlayState* play) { - if (this->actor.bgCheckFlags & 1) { - this->actor.velocity.y *= 0.3f; - this->actor.speedXZ *= 0.8f; - } else if (this->actor.bgCheckFlags & 8) { - this->actor.velocity.y *= 0.8f; - this->actor.speedXZ *= 0.3f; - } else { - this->actor.velocity.y *= 0.8f; - this->actor.speedXZ *= 0.8f; - } - Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 40.0f, 0.0f, 5); -} - -void func_80B44B78(EnInvadepoh* this) { -} - -s32 func_80B44B84(EnInvadepoh* this, PlayState* play, f32 speed, f32 arg3) { - s32 pad; - Vec3s* pathPoint = &this->pathPoints[this->pathIndex + 1]; - s32 retVal = func_80B450C0(&this->actor.world.pos.x, &this->actor.world.pos.z, pathPoint->x, pathPoint->z, speed); - - func_800B4AEC(play, &this->actor, arg3); - func_80B4516C(this); - return retVal; -} - -void func_80B44C24(EnInvadepoh* this, PlayState* play) { - s32 pad; - f32 worldPosY = this->actor.world.pos.y; - - func_80B43BC8(this, &this->pathIndex, &this->actor.world.pos); - this->actor.world.pos.y = worldPosY; - func_800B4AEC(play, &this->actor, 50.0f); - func_80B4516C(this); -} - -s32 func_80B44C80(EnInvadepoh* this, PlayState* play) { - s32 pad[6]; - Vec3s* temp_a2 = &this->pathPoints[this->pathIndex]; - f32 temp_f0; - Vec3f sp6C; - Vec3f sp60; - f32 temp_f0_2; - Vec3s* temp_v0_2; - f32 temp_f0_3; - f32 temp_f12; - f32 temp_f2; - f32 temp_f14; - f32 sp44; - s32 sp40 = 0; - s32 temp_v1 = this->pathIndex + this->direction; - s32 phi_v0; - - if (temp_v1 >= this->endPoint) { - temp_v1 = 0; - } else if (temp_v1 < 0) { - temp_v1 = this->endPoint - 1; - } - - temp_v0_2 = &this->pathPoints[temp_v1]; - - temp_f0 = temp_a2->x; - temp_f2 = temp_a2->z; - temp_f12 = temp_v0_2->x; - temp_f14 = temp_v0_2->z; - sp6C.x = temp_f12 - temp_f0; - sp6C.y = 0.0f; - sp6C.z = temp_f14 - temp_f2; - sp60.x = temp_f12 - this->actor.world.pos.x; - sp60.y = 0.0f; - sp60.z = temp_f14 - this->actor.world.pos.z; - temp_f0_3 = temp_f0 - this->actor.world.pos.x; - temp_f0_2 = temp_f2 - this->actor.world.pos.z; - - if (this->actor.speedXZ > 0.0f) { - if (Math3D_AngleBetweenVectors(&sp6C, &sp60, &sp44) != 0) { - sp40 = 1; - } else if (sp44 <= 0.0f) { - sp40 = 1; - } - } - - Math_SmoothStepToS(&this->actor.world.rot.y, - Math_Atan2S_XY(((sp60.z + temp_f0_2) * 0.9f) + sp6C.z, ((sp60.x + temp_f0_3) * 0.9f) + sp6C.x), - 4, 0xFA0, 0x64); - Actor_MoveWithGravity(&this->actor); - if (func_80B440B8(this, 50.0f, 15.0f)) { - phi_v0 = 4; - } else { - phi_v0 = 5; - } - - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 15.0f, 0.0f, phi_v0); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x1F40, 0x64); - return sp40; -} - -void func_80B44E90(EnInvadepoh* this, PlayState* play) { - Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 15.0f, 0.0f, 5); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x1F40, 0x64); -} - -void func_80B44EFC(EnInvadepoh* this, PlayState* play) { - s32 pad; - f32 worldPosY = this->actor.world.pos.y; - - func_80B43BC8(this, &this->pathIndex, &this->actor.world.pos); - this->actor.world.pos.y = worldPosY; - func_800B4AEC(play, &this->actor, 50.0f); - func_80B4516C(this); -} - -void func_80B44F58(void) { - s32 i; - TexturePtr* iter; - - if (!D_80B4E968) { - D_80B4E968 = true; - for (i = 0, iter = sRomaniEyeTextures; i < ARRAY_COUNT(sRomaniEyeTextures); i++, iter++) { - *iter = Lib_SegmentedToVirtual(*iter); - } - - for (i = 0, iter = sRomaniMouthTextures; i < ARRAY_COUNT(sRomaniMouthTextures); i++, iter++) { - *iter = Lib_SegmentedToVirtual(*iter); - } - } -} - -void func_80B44FEC(void) { - s32 i; - TexturePtr* iter; - - if (!D_80B4E994) { - D_80B4E994 = true; - for (i = 0, iter = sCremiaEyeTextures; i < ARRAY_COUNT(sCremiaEyeTextures); i++, iter++) { - *iter = Lib_SegmentedToVirtual(*iter); - } - - for (i = 0, iter = sCremiaMouthTextures; i < ARRAY_COUNT(sCremiaMouthTextures); i++, iter++) { - *iter = Lib_SegmentedToVirtual(*iter); - } - } -} - -void func_80B45080(void) { - sAlienEmptyTexAnim = Lib_SegmentedToVirtual(gAlienEmptyTexAnim); - sAlienEyeBeamTexAnim = Lib_SegmentedToVirtual(gAlienEyeBeamTexAnim); -} - -s32 func_80B450C0(f32* x1, f32* z1, f32 x2, f32 z2, f32 speed) { - f32 deltaX = x2 - *x1; - f32 deltaZ = z2 - *z1; - f32 temp_f0 = Math3D_XZLength(deltaX, deltaZ); - - if (speed < temp_f0) { - f32 temp_f2 = speed / temp_f0; - *x1 += (temp_f2 * deltaX); - *z1 += (temp_f2 * deltaZ); - return false; - } else { - *x1 = x2; - *z1 = z2; - return true; - } -} - -s32 func_80B4516C(EnInvadepoh* this) { - if (this->actor.floorHeight > BGCHECK_Y_MIN + 1) { - this->actor.world.pos.y = this->actor.floorHeight; - return true; - } - return false; -} - -void func_80B451A0(EnInvadepoh* this, PlayState* play) { - s32 currentTime; - s32 temp_v0_2; - s32 i; - s32 phi_s1_3; - - if (D_80B4E940 == 0) { - if (CURRENT_DAY <= 0) { - D_80B4E940 = 1; - } else if (CURRENT_DAY == 1) { - currentTime = gSaveContext.save.time; - if ((currentTime < CLOCK_TIME(2, 30)) || (currentTime >= CLOCK_TIME(6, 0))) { - D_80B4E940 = 1; - } else if (currentTime < CLOCK_TIME(5, 15)) { - phi_s1_3 = CLOCK_TIME(5, 15); - for (i = 0; i < this->unk379; i++) { - temp_v0_2 = func_80B43A24(i); - if (temp_v0_2 < phi_s1_3) { - phi_s1_3 = temp_v0_2; - } - } - - if (currentTime < (phi_s1_3 + 0xE11)) { - D_80B4E940 = 2; - } - - if (i) {} // required - } - } - - if (D_80B4E940 == 0) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { - D_80B4E940 = 3; - } else { - D_80B4E940 = 4; - } - } - } -} - -void func_80B452EC(EnInvadepoh* this, PlayState* play) { - s32 phi_s2 = (this->actor.params >> 8) & 0x7F; - s32 i; - - for (i = 0; i < this->unk379; i++) { - D_80B50320[i] = (EnInvadepoh*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_INVADEPOH, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, - (i & 7) | ((phi_s2 << 8) & 0x7F00) | 0x10); - if (phi_s2 != 0xFF) { - Path* path = &play->setupPathList[phi_s2]; - phi_s2 = path->unk1; - } - } -} - -void func_80B453F4(EnInvadepoh* this, PlayState* play, s32 arg2) { - Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_INVADEPOH, this->actor.home.pos.x, - this->actor.home.pos.y, this->actor.home.pos.z, 0, 0, 0, (arg2 & 7) | 0x20); -} - -void func_80B45460(EnInvadepoh* this, PlayState* play) { - Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_INVADEPOH, this->actor.home.pos.x, - this->actor.home.pos.y, this->actor.home.pos.z, 0, 0, 0, 0x40); -} - -void func_80B454BC(EnInvadepoh* this, PlayState* play) { - D_80B503F0 = (EnInvadepoh*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_INVADEPOH, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x60); -} - -void EnInvadepoh_SetSysMatrix(Vec3f* vec) { - MtxF* sysMatrix = Matrix_GetCurrent(); - - sysMatrix->xw = vec->x; - sysMatrix->yw = vec->y; - sysMatrix->zw = vec->z; -} - -s32 func_80B45550(EnInvadepoh* this, PlayState* play, f32 range, s32 arg3) { - s32 pad; - Actor* actorIterator = play->actorCtx.actorLists[ACTORCAT_DOOR].first; - s32 retVal = false; - - while (actorIterator != NULL) { - if ((actorIterator->id == ACTOR_EN_DOOR) && (actorIterator->update != NULL) && - (actorIterator->room == this->actor.room) && - Math3D_Vec3fDistSq(&actorIterator->world.pos, &this->actor.world.pos) < range) { - ((EnDoor*)actorIterator)->unk_1A7 = arg3; - retVal = true; - break; - } - actorIterator = actorIterator->next; - } - return retVal; -} - -void EnInvadepoh_SetTextID(EnInvadepoh* this, PlayState* play, u16 arg2) { - this->textId = arg2; - Message_StartTextbox(play, arg2, &this->actor); -} - -void func_80B45648(EnInvadepoh* this) { - s32 i; - s16 cs = this->actor.cutscene; - - for (i = 0; i < 3; i++) { - D_80B50404[i] = cs; - cs = ActorCutscene_GetAdditionalCutscene(cs); - } -} - -s32 func_80B456A8(PlayState* play, Vec3f* worldPos) { - Vec3f projectedPos; - f32 invW; - - Actor_GetProjectedPos(play, worldPos, &projectedPos, &invW); - if (((projectedPos.z > 1.0f) && (fabsf(projectedPos.x * invW) < 1.0f)) && (fabsf(projectedPos.y * invW) < 1.0f)) { - s32 screenPosX = PROJECTED_TO_SCREEN_X(projectedPos, invW); - s32 screenPosY = PROJECTED_TO_SCREEN_Y(projectedPos, invW); - s32 wZ = (s32)(projectedPos.z * invW * 16352.0f) + 16352; - s32 zBuf = func_80178A94(screenPosX, screenPosY); - if (wZ < zBuf) { - return true; - } - } - - return false; -} - -void func_80B457A0(EnInvadepoh* this) { - f32 distanceSquared; - f32 phi_f20 = FLT_MAX; - s32 i; - s32 phi_s5 = -1; - - for (i = 0; i < this->unk379; i++) { - if ((D_80B50320[i] != NULL) && D_80B50320[i]->drawAlien) { - distanceSquared = Math3D_Vec3fDistSq(&D_80B50320[i]->actor.world.pos, &this->actor.world.pos); - if (distanceSquared < phi_f20) { - phi_f20 = distanceSquared; - phi_s5 = i; - } - } - D_80B50340[i] &= ~2; - } - - D_80B50348 = 0; - if (phi_f20 <= SQ(2000.0f)) { - D_80B50340[phi_s5] |= 2; - if (phi_f20 <= SQ(340.0f)) { - D_80B50348 = 1; - } - } -} - -EnInvadepoh* func_80B458D8(void) { - s32 i; - - for (i = 0; i < 8; i++) { - if (D_80B50340[i] & 2) { - return D_80B50320[i]; - } - } - - return NULL; -} - -s8 func_80B45980(unkstructInvadepoh1* arg0, s32 arg1) { - f32 rand = Rand_ZeroOne(); - s32 i; - unkstructInvadepoh1* ptr = arg0; - - arg1--; - for (i = 0; i < arg1; i++, ptr++) { - if (ptr->unk04 >= rand) { - break; - } - } - - return (arg0 + i)->unk00; -} - -void func_80B459E8(EnInvadePohStruct* s, unkstructInvadepoh4* u) { - s->unk4 = u->unk00; - s->unk8 = u; - s->unkE = 0; - s->unkF = *u->unk04->unk00; - if (s->unk4 == 2) { - s->unkC = Rand_S16Offset(u->unk10, u->unk12); - } -} - -void func_80B45A4C(EnInvadePohStruct* s, unkstructInvadepoh4** u) { - unkstructInvadepoh4* new_var = s->unk8; - unkstructInvadepoh0* temp_v1 = new_var->unk04; - - if (s->unkE < (temp_v1->unk04 - 1)) { - s->unkE++; - s->unkF = temp_v1->unk00[s->unkE]; - } -} - -void func_80B45A94(EnInvadePohStruct* s, unkstructInvadepoh4** u) { - unkstructInvadepoh0* temp_v1 = s->unk8->unk04; - unkstructInvadepoh1* temp_a0; - - if (s->unkE < (temp_v1->unk04 - 1)) { - s->unkE++; - s->unkF = temp_v1->unk00[s->unkE]; - } else { - func_80B459E8(s, u[func_80B45980(s->unk8->unk0C, s->unk8->unk08)]); - } -} - -void func_80B45B1C(EnInvadePohStruct* s, unkstructInvadepoh4** u) { - unkstructInvadepoh0* temp_v1 = s->unk8->unk04; - unkstructInvadepoh1* temp_a0; - - if (s->unkE < (temp_v1->unk04 - 1)) { - s->unkE++; - s->unkF = temp_v1->unk00[s->unkE]; - } else if (s->unkC > 0) { - s->unkC--; - } else { - func_80B459E8(s, u[func_80B45980(s->unk8->unk0C, s->unk8->unk08)]); - } -} - -void func_80B45BB8(EnInvadePohStruct* s) { - if ((s->unk0 != 0) && (s->unk8 != 0)) { - D_80B4EC0C[s->unk4](s, (unkstructInvadepoh4**)s->unk0); - } -} - -void func_80B45C04(AlienBehaviorInfo* substruct, void* arg1[], s32 arg2, void* arg3[], s32 arg4, Vec3s* arg5, s16 arg6, - f32 arg7, f32 arg8, f32 arg9) { - unkstructInvadepoh4* temp_v0; - - Math_Vec3s_Copy(&substruct->unk26, arg5); - substruct->unk2C = arg6; - substruct->unk30 = arg7; - substruct->unk38 = arg8; - substruct->unk3C = arg9; - if (arg1 != NULL) { - temp_v0 = arg1[arg2]; - substruct->unk0.unk0 = (unkstructInvadepoh4*)arg1; - substruct->unk0.unk4 = temp_v0->unk00; - substruct->unk0.unkC = 0; - substruct->unk0.unkE = 0; - substruct->unk0.unk8 = temp_v0; - substruct->unk0.unkF = *temp_v0->unk04->unk00; - } - if (arg3 != NULL) { - temp_v0 = arg3[arg4]; - substruct->unk10.unk0 = (unkstructInvadepoh4*)arg3; - substruct->unk10.unk4 = temp_v0->unk00; - substruct->unk10.unkC = 0; - substruct->unk10.unkE = 0; - substruct->unk10.unk8 = temp_v0; - substruct->unk10.unkF = *temp_v0->unk04->unk00; - } -} - -void func_80B45CE0(AlienBehaviorInfo* substruct) { - Vec3f sp3C; - Vec3s sp34; - s16 step; - - sp34.x = substruct->unk26.x - substruct->unk20.x; - sp34.y = substruct->unk26.y - substruct->unk20.y; - sp34.z = substruct->unk26.z - substruct->unk20.z; - Math_Vec3s_ToVec3f(&sp3C, &sp34); - Math_Vec3f_Scale(&sp3C, substruct->unk30); - Math_Vec3f_ToVec3s(&sp34, &sp3C); - sp34.x = ABS(sp34.x); - sp34.y = ABS(sp34.y); - sp34.z = ABS(sp34.z); - sp34.x = CLAMP_MAX(sp34.x, substruct->unk2C); - sp34.y = CLAMP_MAX(sp34.y, substruct->unk2C); - sp34.z = CLAMP_MAX(sp34.z, substruct->unk2C); - Math_ScaledStepToS(&substruct->unk20.x, substruct->unk26.x, sp34.x); - Math_ScaledStepToS(&substruct->unk20.y, substruct->unk26.y, sp34.y); - Math_ScaledStepToS(&substruct->unk20.z, substruct->unk26.z, sp34.z); - Math_StepToF(&substruct->unk34, substruct->unk38, substruct->unk3C); - - if (substruct->unk40 != substruct->unk42) { - step = substruct->unk42 - substruct->unk40; - step *= substruct->unk44; - step = ABS(step); - step = CLAMP(step, 100, substruct->unk48); - Math_ScaledStepToS(&substruct->unk40, substruct->unk42, step); - } - func_80B45BB8(&substruct->unk0); - func_80B45BB8(&substruct->unk10); -} - -void func_80B45EC8(EnInvadepoh* this, PlayState* play, s32 arg2) { - s16 phi_s0 = 0; - Vec3f spA8; - Vec3f sp9C; - Vec3f sp90; - f32 temp_f20; - s32 i; - - for (i = 0; i < arg2; i++) { - phi_s0 += (s16)(65536.0f / arg2); - - temp_f20 = (Rand_ZeroOne() * 0.5f) + 0.5f; - spA8.x = Math_SinS(phi_s0) * temp_f20; - spA8.z = Math_CosS(phi_s0) * temp_f20; - - sp9C.x = ((Rand_ZeroOne() * 16.0f) + (spA8.x * 30.0f)) - 8.0f; - sp9C.y = -8.0f; - sp9C.z = ((Rand_ZeroOne() * 16.0f) + (spA8.z * 30.0f)) - 8.0f; - - sp90.x = sp9C.x * -0.025f; - sp90.y = sp9C.y * -0.025f; - sp90.z = sp9C.z * -0.025f; - - spA8.x = (spA8.x * 100.0f) + this->actor.world.pos.x; - spA8.y = ((Rand_ZeroOne() * 180.0f) + this->actor.world.pos.y) - 90.0f; - spA8.z = (spA8.z * 100.0f) + this->actor.world.pos.z; - - EffectSsKirakira_SpawnDispersed(play, &spA8, &sp9C, &sp90, &D_80B4EC18, &D_80B4EC1C, 6000, -40); - } -} - -s32 func_80B46118(Vec3f* actorPos) { - unkStruct80B50350* phi_v1; - s32 i; - - for (phi_v1 = D_80B50350, i = 0; i < 10; phi_v1++, i++) { - if (phi_v1->unk1 <= 0) { - phi_v1->unk0 = 0; - phi_v1->unk1 = 40; - Math_Vec3f_Copy(&phi_v1->unk4, actorPos); - phi_v1->unk2 = 0; - return true; - } - } - return false; -} - -void func_80B46184(unkStruct80B50350* unkStruct) { - if (unkStruct->unk1 > 20) { - if (unkStruct->unk2 < 125) { - unkStruct->unk2 += 10; - } else { - unkStruct->unk2 = 135; - } - } else if (unkStruct->unk2 > 13) { - unkStruct->unk2 -= 13; - - } else { - unkStruct->unk2 = 0; - } -} - -s32 func_80B461DC(void) { - s32 phi_s4 = false; - unkStruct80B50350* phi_s0; - s32 i; - - for (phi_s0 = D_80B50350, i = 0; i < 10; phi_s0++, i++) { - if (phi_s0->unk1 > 0) { - D_80B4EC20[phi_s0->unk0](phi_s0); - phi_s0->unk1--; - phi_s4 = true; - } - } - return phi_s4; -} - -void func_80B4627C(EnInvadepoh* this, PlayState* play) { - s32 invadepohType; - s32 i; - - this->actor.flags |= ACTOR_FLAG_20; - invadepohType = (this->actor.params >> 8) & 0x7F; - - for (i = 1; i < 8; i++) { - Path* path = &play->setupPathList[invadepohType]; - invadepohType = path->unk1; - if (invadepohType == 0xFF) { - break; - } - } - - this->unk379 = i; - func_80B451A0(this, play); - func_80B45648(this); - func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_SWITCH); - - if (D_80B4E940 == 1) { - func_80B46DA8(this); - } else if (D_80B4E940 == 2) { - if (gSaveContext.save.time < CLOCK_TIME(2, 31)) { - func_80B46DA8(this); - } else { - func_80B454BC(this, play); - func_80B452EC(this, play); - Audio_QueueSeqCmd(NA_BGM_ALIEN_INVASION | 0x8000); - func_80B46F88(this); - } - } else if (D_80B4E940 == 3) { - if (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 6)) { - func_80B471C0(this); - - } else if (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 7)) { - func_80B47248(this); - } else { - func_80B47248(this); - } - } else if (D_80B4E940 == 4) { - func_80B47304(this); - } -} - -void EnInvadepoh_InitAlien(EnInvadepoh* this, PlayState* play) { - s32 pad; - - Actor_ProcessInitChain(&this->actor, D_80B4EC24); - Collider_InitCylinder(play, &this->collider); - ActorShape_Init(&this->actor.shape, 6800.0f, ActorShadow_DrawWhiteCircle, 150.0f); - this->actor.shape.shadowAlpha = 140; - this->actor.flags = (ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_80000000); - if (INVADEPOH_TYPE(&this->actor) == TYPE_ALIEN_CARRYING_COW) { - this->actor.update = func_80B4D670; - this->actor.world.pos.y = this->actor.home.pos.y + 150.0f; - } else { - this->actor.update = func_80B47BAC; - Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInitAlien); - this->actor.colChkInfo.mass = 40; - } - this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_UCH); - if (this->bankIndex < 0) { - Actor_Kill(&this->actor); - } -} - -void EnInvadepoh_InitParentCow(EnInvadepoh* this, PlayState* play) { - Actor_ProcessInitChain(&this->actor, sInitChainParentCow); - this->actor.update = func_80B47FA8; - Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_INVADEPOH, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0x30); - this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_COW); - if (this->bankIndex < 0) { - Actor_Kill(&this->actor); - } -} - -void EnInvadepoh_InitChildCow(EnInvadepoh* this, PlayState* play) { - Actor_ProcessInitChain(&this->actor, sInitChainChildCow); - this->actor.update = func_80B481C4; - this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_COW); - if (this->bankIndex < 0) { - Actor_Kill(&this->actor); - } -} - -void EnInvadepoh_InitRomani(EnInvadepoh* this, PlayState* play) { - s32 pad; - s32 temp = INVADEPOH_TYPE(&this->actor); - - Actor_ProcessInitChain(&this->actor, sInitChainRomani); - - this->actor.targetMode = (temp == 7 || temp == 0xC) ? 3 : 6; - - func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_NPC); - Collider_InitCylinder(play, &this->collider); - if (temp != 4) { - ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 18.0f); - Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInitRomaniAndCremia); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - } - if (temp == 4) { - this->actor.update = func_80B48620; - } else if (temp == 5) { - this->actor.update = func_80B48FB0; - this->actor.flags = (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10); - } else if (temp == 7) { - this->actor.update = func_80B49F88; - } else if (temp == 8) { - this->actor.update = func_80B4A9C8; - } else if (temp == 9) { - this->actor.update = func_80B4B0C4; - } else { - this->actor.update = func_80B4CE54; - } - - this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_MA1); - if (this->bankIndex < 0) { - Actor_Kill(&this->actor); - } - - if (temp == 5) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { - Actor_Kill(&this->actor); - return; - } - } else if (temp == 7) { - if (gSaveContext.save.time < CLOCK_TIME(6, 0) && gSaveContext.save.time >= CLOCK_TIME(2, 15)) { - Actor_Kill(&this->actor); - return; - } - } else if (temp != 8) { - if (temp == 9) { - if (gSaveContext.save.entrance != ENTRANCE(ROMANI_RANCH, 6)) { - Actor_Kill(&this->actor); - return; - } - } else if (temp == 0xC) { - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { - Actor_Kill(&this->actor); - } - D_80B503F4 = this; - } - } -} - -void func_80B468B4(EnInvadepoh* this, PlayState* play) { - Actor_ProcessInitChain(&this->actor, D_80B4EC68); - this->actor.update = func_80B49B1C; - this->actor.draw = func_80B4E3F0; - func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_NPC); - if (D_80B4E940 == 1 || gSaveContext.save.time < CLOCK_TIME(2, 31)) { - this->actor.world.pos.x += D_80B4E934.x; - this->actor.world.pos.y += D_80B4E934.y + 3000.0f; - this->actor.world.pos.z += D_80B4E934.z; - func_80B491EC(this); - } else if (D_80B4E940 == 2) { - this->actor.world.pos.y += 1500.0f; - func_80B49628(this); - } else { - Actor_Kill(&this->actor); - } -} - -void EnInvadepoh_InitDog(EnInvadepoh* this, PlayState* play) { - s32 pad; - - Actor_ProcessInitChain(&this->actor, sInitChainDog); - this->actor.update = func_80B4B8BC; - Collider_InitCylinder(play, &this->collider); - Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInitDog); - this->actor.colChkInfo.mass = 80; - ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 24.0f); - this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_DOG); - if (this->bankIndex < 0) { - Actor_Kill(&this->actor); - } -} - -void EnInvadepoh_InitCremia(EnInvadepoh* this, PlayState* play) { - s32 pad; - - Actor_ProcessInitChain(&this->actor, sInitChainCremia); - this->actor.update = func_80B4C3A0; - func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_NPC); - Collider_InitCylinder(play, &this->collider); - Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInitRomaniAndCremia); - this->actor.colChkInfo.mass = MASS_HEAVY; - ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 18.0f); - this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_MA2); - if (this->bankIndex < 0) { - Actor_Kill(&this->actor); - } - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { - Actor_Kill(&this->actor); - } - D_80B503F8 = this; -} - -void EnInvadepoh_Init(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - D_80B4ECB0[INVADEPOH_TYPE(&this->actor)](this, play); -} - -void func_80B46BB0(EnInvadepoh* this, PlayState* play) { -} - -void func_80B46BC0(EnInvadepoh* this, PlayState* play) { - s32 pad; - s32 invadepohType = this->actor.params & 7; - - Collider_DestroyCylinder(play, &this->collider); - D_80B50320[invadepohType] = 0; -} - -void func_80B46C08(EnInvadepoh* this, PlayState* play) { - if (this->actor.parent != NULL) { - this->actor.parent->child = NULL; - } - - if (this->actor.child != NULL) { - this->actor.child->parent = NULL; - } -} - -void func_80B46C34(EnInvadepoh* this, PlayState* play) { - if (this->actor.parent != NULL) { - this->actor.parent->child = NULL; - } -} - -void func_80B46C50(EnInvadepoh* this, PlayState* play) { - Collider_DestroyCylinder(play, &this->collider); -} - -void func_80B46C7C(EnInvadepoh* this, PlayState* play) { - D_80B503F0 = NULL; -} - -void func_80B46C94(EnInvadepoh* this, PlayState* play) { - Collider_DestroyCylinder(play, &this->collider); -} - -void func_80B46CC0(EnInvadepoh* this, PlayState* play) { - Collider_DestroyCylinder(play, &this->collider); - D_80B503F8 = NULL; -} - -void func_80B46CF4(EnInvadepoh* this, PlayState* play) { - Collider_DestroyCylinder(play, &this->collider); - D_80B503F4 = NULL; -} - -void func_80B46D28(EnInvadepoh* this, PlayState* play) { - Collider_DestroyCylinder(play, &this->collider); - if (!this) {} // required to match - if (this->actor.child != NULL) { - this->actor.child->parent = NULL; - } -} - -void EnInvadepoh_Destroy(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - D_80B4ECE8[INVADEPOH_TYPE(&this->actor)](this, play); -} - -void func_80B46DA8(EnInvadepoh* this) { - D_80B4E940 = 1; - this->actionFunc = func_80B46DC8; -} - -void func_80B46DC8(EnInvadepoh* this, PlayState* play) { - if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(2, 30))) { - func_80B454BC(this, play); - func_80B452EC(this, play); - func_80B46E20(this); - } -} - -void func_80B46E20(EnInvadepoh* this) { - D_80B4E940 = 2; - this->actionTimer = 2; - this->actionFunc = func_80B46E44; -} - -void func_80B46E44(EnInvadepoh* this, PlayState* play) { - if (this->actionTimer > 0) { - this->actionTimer--; - } else if (ActorCutscene_GetCanPlayNext(D_80B50404[0])) { - ActorCutscene_StartAndSetUnkLinkFields(D_80B50404[0], &this->actor); - func_80B46EC0(this); - } else { - ActorCutscene_SetIntentToPlay(D_80B50404[0]); - } -} - -void func_80B46EC0(EnInvadepoh* this) { - D_80B4E940 = 2; - this->actionTimer = 160; - this->actionFunc = func_80B46EE8; -} - -void func_80B46EE8(EnInvadepoh* this, PlayState* play) { - s32 i; - - for (i = 0; i < 8; i++) { - if (this->actionTimer == D_80B4ED20[i]) { - D_80B50340[i] |= 1; - } - } - - this->actionTimer--; - if (this->actionTimer <= 0) { - ActorCutscene_Stop(D_80B50404[0]); - Audio_QueueSeqCmd(NA_BGM_ALIEN_INVASION | 0x8000); - func_80B46F88(this); - } -} - -void func_80B46F88(EnInvadepoh* this) { - D_80B4E940 = 2; - this->actionFunc = func_80B46FA8; -} - -void func_80B46FA8(EnInvadepoh* this, PlayState* play) { - s32 i; - - if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(5, 15))) { - SET_WEEKEVENTREG(WEEKEVENTREG_22_01); - func_80B47064(this); - } else { - func_80B457A0(this); - for (i = 0; i < this->unk379; i++) { - if ((D_80B50320[i] != NULL) && (D_80B50320[i]->unk38A != 0)) { - func_80B47278(this); - break; - } - } - } -} - -void func_80B47064(EnInvadepoh* this) { - D_80B4E940 = 3; - this->actionFunc = func_80B47084; -} - -void func_80B47084(EnInvadepoh* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(D_80B50404[1])) { - ActorCutscene_StartAndSetUnkLinkFields(D_80B50404[1], &this->actor); - func_80B470E0(this); - } else { - ActorCutscene_SetIntentToPlay(D_80B50404[1]); - } -} - -void func_80B470E0(EnInvadepoh* this) { - D_80B4E940 = 3; - this->actionTimer = 110; - this->actionFunc = func_80B47108; -} - -void func_80B47108(EnInvadepoh* this, PlayState* play) { - if (this->actionTimer == 100) { - Audio_PlayFanfare(NA_BGM_CLEAR_EVENT); - } - this->actionTimer--; - if (this->actionTimer <= 0) { - play->nextEntrance = ENTRANCE(ROMANI_RANCH, 6); - gSaveContext.nextCutsceneIndex = 0; - play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_73; - gSaveContext.nextTransitionType = TRANS_TYPE_72; - D_801BDAA0 = 1; - D_801BDA9C = 0; - func_80B47248(this); - } -} - -void func_80B471C0(EnInvadepoh* this) { - D_80B4E940 = 3; - this->actionFunc = func_80B471E0; -} - -void func_80B471E0(EnInvadepoh* this, PlayState* play) { - if (D_80B4E998) { - play->nextEntrance = ENTRANCE(ROMANI_RANCH, 7); - gSaveContext.nextCutsceneIndex = 0; - play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_72; - gSaveContext.nextTransitionType = TRANS_TYPE_72; - func_80B47248(this); - } -} - -void func_80B47248(EnInvadepoh* this) { - D_80B4E940 = 3; - this->actionFunc = func_80B47268; -} - -void func_80B47268(EnInvadepoh* this, PlayState* play) { -} - -void func_80B47278(EnInvadepoh* this) { - D_80B4E940 = 4; - this->actionFunc = func_80B47298; -} - -void func_80B47298(EnInvadepoh* this, PlayState* play) { - play->nextEntrance = ENTRANCE(ROMANI_RANCH, 0); - gSaveContext.nextCutsceneIndex = 0xFFF3; - play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_72; - gSaveContext.nextTransitionType = TRANS_TYPE_72; - SET_WEEKEVENTREG(WEEKEVENTREG_89_10); - func_80B47304(this); -} - -void func_80B47304(EnInvadepoh* this) { - D_80B4E940 = 4; - this->actionFunc = func_80B47324; -} - -void func_80B47324(EnInvadepoh* this, PlayState* play) { -} - -void EnInvadepoh_Update(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - this->actionFunc(this, play); - if (func_80B461DC()) { - this->actor.draw = func_80B4D9B4; - } else { - this->actor.draw = NULL; - } -} - -void func_80B47380(EnInvadepoh* this) { - this->collider.base.atFlags &= ~AT_ON; - this->collider.base.acFlags &= ~AC_ON; - this->collider.base.ocFlags1 &= ~OC1_ON; - this->actor.flags &= ~ACTOR_FLAG_80000000; - this->alienAlpha = 0; - this->actor.draw = NULL; - this->drawAlien = false; - this->drawAlienDeathEffect = false; - this->alienBeamAlpha = 0; - this->actionFunc = func_80B473E4; -} - -void func_80B473E4(EnInvadepoh* this, PlayState* play) { - func_80B442E4(this); - func_80B447C0(this, play); - func_80B43DD4(this, 800, 0); - if (D_80B50340[this->actor.params & 7] & 1) { - Actor_SetScale(&this->actor, 0.01f); - func_80B4516C(this); - func_80B46118(&this->actor.world.pos); - func_80B47568(this); - } -} - -void func_80B47478(EnInvadepoh* this) { - this->collider.base.atFlags &= ~AT_ON; - this->collider.base.acFlags &= ~AC_ON; - this->collider.base.ocFlags1 &= ~OC1_ON; - this->actor.flags &= ~ACTOR_FLAG_80000000; - this->alienAlpha = 0; - this->actor.draw = NULL; - this->drawAlien = false; - this->drawAlienDeathEffect = false; - this->alienBeamAlpha = 0; - this->actionFunc = func_80B474DC; -} - -void func_80B474DC(EnInvadepoh* this, PlayState* play) { - func_80B442E4(this); - func_80B447C0(this, play); - func_80B43DD4(this, 800, 0); - if (this->clockTime > 0.0f) { - Actor_SetScale(&this->actor, 0.01f); - func_80B4516C(this); - func_80B46118(&this->actor.world.pos); - func_80B47568(this); - } -} - -void func_80B47568(EnInvadepoh* this) { - Animation_MorphToLoop(&this->skelAnime, &gAlienFloatAnim, -6.0f); - this->collider.base.atFlags &= ~AT_ON; - this->collider.base.acFlags &= ~AC_ON; - this->collider.base.ocFlags1 &= ~OC1_ON; - this->alienAlpha = 0; - this->actor.draw = func_80B4DB14; - this->drawAlien = true; - this->drawAlienDeathEffect = false; - this->alienBeamAlpha = 0; - this->actor.flags |= ACTOR_FLAG_80000000; - this->actionFunc = func_80B47600; -} - -void func_80B47600(EnInvadepoh* this, PlayState* play) { - func_80B442E4(this); - func_80B447C0(this, play); - func_80B43DD4(this, 800, 0); - func_800B9010(&this->actor, NA_SE_EN_FOLLOWERS_BEAM_PRE - SFX_FLAG); - if (this->clockTime >= 0.9999f) { - this->unk38A = 1; - } - if (this->alienAlpha > 248) { - this->alienAlpha = 255; - } else { - this->alienAlpha += 6; - } - if (this->alienAlpha > 128) { - this->collider.base.atFlags |= AT_ON; - this->collider.base.acFlags |= AC_ON; - this->collider.base.ocFlags1 |= OC1_ON; - } - if (this->alienAlpha == 255) { - if (this->alienBeamAlpha >= 245) { - this->alienBeamAlpha = 255; - func_80B4770C(this); - } else { - this->alienBeamAlpha += 10; - } - } -} - -void func_80B4770C(EnInvadepoh* this) { - if (this->skelAnime.animation != &gAlienFloatAnim) { - Animation_MorphToLoop(&this->skelAnime, &gAlienFloatAnim, -6.0f); - } - this->collider.base.atFlags |= AT_ON; - this->collider.base.acFlags |= AC_ON; - this->collider.base.ocFlags1 |= OC1_ON; - this->alienAlpha = 255; - this->actor.draw = func_80B4DB14; - this->drawAlien = true; - this->drawAlienDeathEffect = false; - this->alienBeamAlpha = 255; - this->actor.flags |= ACTOR_FLAG_80000000; - this->actionFunc = func_80B477B4; -} - -void func_80B477B4(EnInvadepoh* this, PlayState* play) { - func_80B442E4(this); - func_80B447C0(this, play); - func_80B43DD4(this, 800, 0); - func_800B9010(&this->actor, NA_SE_EN_FOLLOWERS_BEAM_PRE - SFX_FLAG); - if (this->clockTime >= 0.9999f) { - this->unk38A = 1; - } -} - -void func_80B47830(EnInvadepoh* this) { - this->collider.base.atFlags &= ~AT_ON; - this->collider.base.acFlags &= ~AC_ON; - this->collider.base.ocFlags1 |= OC1_ON; - Animation_PlayLoop(&this->skelAnime, &gAlienJerkingAnim); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); - this->alienAlpha = 255; - this->actor.draw = func_80B4DB14; - this->drawAlien = true; - this->drawAlienDeathEffect = false; - this->alienBeamAlpha = 0; - this->actionTimer = 8; - this->counter = 0; - this->actor.flags |= ACTOR_FLAG_80000000; - this->actionFunc = func_80B478F4; -} - -void func_80B478F4(EnInvadepoh* this, PlayState* play) { - func_80B44A90(this, play); - this->actionTimer--; - if (this->actionTimer <= 0) { - func_80B47938(this); - } -} - -void func_80B47938(EnInvadepoh* this) { - this->collider.base.atFlags &= ~AT_ON; - this->collider.base.acFlags &= ~AC_ON; - this->collider.base.ocFlags1 &= ~OC1_ON; - Animation_PlayLoop(&this->skelAnime, &gAlienDeathAnim); - this->actor.flags &= ~ACTOR_FLAG_1; - this->actionTimer = 10; - this->alienAlpha = 255; - this->actor.draw = func_80B4DB14; - this->drawAlien = true; - this->drawAlienDeathEffect = false; - this->alienBeamAlpha = 255; - this->actor.flags |= ACTOR_FLAG_80000000; - this->actionFunc = func_80B479E8; -} - -void func_80B479E8(EnInvadepoh* this, PlayState* play) { - s16 unk2F2; - u32 index; - - func_80B44B78(this); - if (this->counter < 5) { - if (D_80B4ED30[this->counter].x > 0.0f) { - this->drawAlien = true; - this->alienBeamAlpha = 255; - Math_Vec3f_Copy(&this->actor.scale, &D_80B4ED30[this->counter]); - } else { - this->drawAlien = false; - this->alienBeamAlpha = 0; - } - } else { - this->drawAlien = false; - this->alienBeamAlpha = 0; - } - - unk2F2 = this->counter; - if ((unk2F2 >= 2) && (unk2F2 < 9)) { - index = unk2F2 - 2; - if (D_80B4ED6C[index].x > 0.0f) { - this->drawAlienDeathEffect = true; - Math_Vec3f_Copy(&this->alienDeathEffectScale, &D_80B4ED6C[index]); - } else { - this->drawAlienDeathEffect = false; - } - } else { - this->drawAlienDeathEffect = false; - } - - this->counter++; - if (this->actionTimer == 8) { - Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y - 10.0f, - this->actor.world.pos.z, 0, 0, 3, CLEAR_TAG_SMOKE); - } - - if (this->actionTimer == 8) { - Enemy_StartFinishingBlow(play, &this->actor); - } - - this->actionTimer--; - if (this->actionTimer <= 0) { - func_80B43AF0(this->actor.params & 7); - func_80B43AB0(); - Item_DropCollectible(play, &this->actor.world.pos, ITEM00_ARROWS_30); - func_80B47478(this); - } -} - -void func_80B47BAC(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { - this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(play, &this->actor); - func_80B45080(); - this->actor.update = func_80B47D30; - SkelAnime_InitFlex(play, &this->skelAnime, &gAlienSkel, &gAlienFloatAnim, this->jointTable, this->morphTable, - ALIEN_LIMB_MAX); - this->skelAnime.curFrame = (this->actor.params & 7) * this->skelAnime.endFrame * 0.125f; - func_80B444BC(this, play); - func_80B442E4(this); - func_80B447C0(this, play); - func_80B43F0C(this); - func_80B4516C(this); - if (D_80B4E940 == 1 || gSaveContext.save.time < CLOCK_TIME(2, 31)) { - func_80B47380(this); - } else if (D_80B4E940 == 2) { - if (this->clockTime >= 0.0001f) { - func_80B4770C(this); - } else { - func_80B47568(this); - } - } else { - Actor_Kill(&this->actor); - } - } -} - -void func_80B47D30(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - s32 pad; - - if (D_80B4E940 == 3) { - if ((this->actionFunc == func_80B477B4) || (this->actionFunc == func_80B47600)) { - thisx->speedXZ = 0.0f; - thisx->velocity.y = 0.0f; - thisx->gravity = 0.0f; - func_80B47830(this); - } else if ((this->actionFunc == func_80B474DC) || (this->actionFunc == func_80B473E4)) { - Actor_Kill(&this->actor); - return; - } - } else if (this->collider.base.acFlags & AC_HIT) { - Actor* acAttached = this->collider.base.ac; - - thisx->speedXZ = acAttached->speedXZ * 0.5f; - thisx->speedXZ = CLAMP(thisx->speedXZ, -60.0f, 60.0f); - thisx->world.rot.y = acAttached->world.rot.y; - thisx->gravity = 0.0f; - thisx->velocity.y = acAttached->velocity.y * 0.5f; - thisx->velocity.y = CLAMP(thisx->velocity.y, -30.0f, 30.0f); - SoundSource_PlaySfxAtFixedWorldPos(play, &thisx->world.pos, 50, NA_SE_EN_INVADER_DEAD); - func_80B47830(this); - } - - this->actionFunc(this, play); - if (thisx->draw != NULL) { - this->animPlayFlag = SkelAnime_Update(&this->skelAnime); - } - - Collider_UpdateCylinder(&this->actor, &this->collider); - if (this->collider.base.atFlags & AT_ON) { - CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); - } else { - this->collider.base.atFlags &= ~AT_HIT; - } - - if (this->collider.base.acFlags & AC_ON) { - CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); - } else { - this->collider.base.acFlags &= ~AC_HIT; - } - - if (this->collider.base.ocFlags1 & OC1_ON) { - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - } else { - this->collider.base.ocFlags1 &= ~OC1_HIT; - } -} - -void func_80B47FA8(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - s32 pad; - - if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { - this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(play, thisx); - this->actor.update = func_80B48060; - this->actor.draw = func_80B4E158; - SkelAnime_InitFlex(play, &this->skelAnime, &gCowSkel, NULL, this->jointTable, this->morphTable, COW_LIMB_MAX); - Animation_PlayLoop(&this->skelAnime, &gCowMooAnim); - } -} - -void func_80B48060(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - s32 pad; - s32 temp; - s32 pad2; - MtxF unkMtx; - - if (D_80B503F0 == NULL || this->actor.parent == NULL) { - Actor_Kill(&this->actor); - return; - } - - temp = this->actor.params & 7; - SkelAnime_Update(&this->skelAnime); - Math_ScaledStepToS(&this->actor.shape.rot.x, D_80B4EDC0[temp], 0x32); - if (this->actor.child != NULL) { - Matrix_Push(); - Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); - Matrix_Translate(0, 57.0f, -36.0f, MTXMODE_APPLY); - Matrix_RotateXS(this->actor.shape.rot.x * -0.7f, MTXMODE_APPLY); - Matrix_RotateZS(this->actor.shape.rot.z * -0.7f, MTXMODE_APPLY); - Matrix_MultZero(&this->actor.child->world.pos); - Matrix_Get(&unkMtx); - Matrix_MtxFToYXZRot(&unkMtx, &this->actor.child->shape.rot, false); - Matrix_Pop(); - } -} - -void func_80B481C4(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - s32 pad; - - if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { - this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(play, &this->actor); - this->actor.update = func_80B4827C; - this->actor.draw = func_80B4E1B0; - SkelAnime_InitFlex(play, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, - COW_TAIL_LIMB_MAX); - Animation_PlayLoop(&this->skelAnime, &gCowTailSwishAnim); - } -} - -void func_80B4827C(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - if (D_80B503F0 == NULL || this->actor.parent == NULL) { - Actor_Kill(&this->actor); - return; - } - - SkelAnime_Update(&this->skelAnime); -} - -void func_80B482D4(EnInvadepoh* this) { - this->actionTimer = 40; - Animation_MorphToLoop(&this->skelAnime, &gRomaniLookAroundAnim, -10.0f); - this->actor.draw = NULL; - this->actionFunc = func_80B48324; -} - -void func_80B48324(EnInvadepoh* this, PlayState* play) { - this->actionTimer--; - if (this->actionTimer <= 0) { - EnInvadepoh_SetTextID(this, play, 0x332F); - this->actor.draw = func_80B4E324; - func_80B48374(this); - } -} - -void func_80B48374(EnInvadepoh* this) { - this->actionTimer = 60; - Animation_MorphToLoop(&this->skelAnime, &gRomaniLookAroundAnim, -10.0f); - this->actor.draw = func_80B4E324; - this->actionFunc = func_80B483CC; -} - -void func_80B483CC(EnInvadepoh* this, PlayState* play) { - if (this->actionTimer == 20) { - f32 unkFloat = 0.1f; - - this->behaviorInfo.unk26.x = 2000; - this->behaviorInfo.unk26.y = 0; - this->behaviorInfo.unk26.z = 0; - this->behaviorInfo.unk30 = unkFloat; - this->behaviorInfo.unk2C = 1000; - } - - this->actionTimer--; - if (this->actionTimer <= 0) { - func_80B4843C(this); - } -} - -void func_80B4843C(EnInvadepoh* this) { - this->behaviorInfo.unk26.x = 3000; - this->behaviorInfo.unk26.y = 0; - this->behaviorInfo.unk26.z = 0; - this->behaviorInfo.unk30 = 0.24f; - this->behaviorInfo.unk2C = 3000; - this->behaviorInfo.unk42 = 15000; - this->behaviorInfo.unk44 = 0.1f; - this->behaviorInfo.unk48 = 2000; - this->actionTimer = 50; - Animation_Change(&this->skelAnime, &gRomaniRunAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -5.0f); - this->actor.draw = func_80B4E324; - this->actionFunc = func_80B484EC; -} - -void func_80B484EC(EnInvadepoh* this, PlayState* play) { - if (this->actionTimer == 40) { - this->behaviorInfo.unk26.y = 7000; - } else if (this->actionTimer == 30) { - this->behaviorInfo.unk26.y = -7000; - } else if (this->actionTimer == 20) { - this->behaviorInfo.unk26.y = 7000; - } else if (this->actionTimer == 10) { - this->behaviorInfo.unk26.y = 0; - } - this->actionTimer--; - if (this->actionTimer <= 0) { - func_80B48588(this); - } -} - -void func_80B48588(EnInvadepoh* this) { - this->behaviorInfo.unk26.x = 0; - this->behaviorInfo.unk26.y = 0; - this->behaviorInfo.unk26.z = 0; - this->behaviorInfo.unk30 = 0.24f; - this->behaviorInfo.unk2C = 5000; - this->behaviorInfo.unk42 = 0; - this->behaviorInfo.unk44 = 0.28f; - this->behaviorInfo.unk48 = 7000; - Animation_MorphToPlayOnce(&this->skelAnime, &gRomaniIdleAnim, -10.0f); - this->actor.draw = func_80B4E324; - this->actionFunc = func_80B48610; -} - -void func_80B48610(EnInvadepoh* this, PlayState* play) { -} - -void func_80B48620(Actor* thisx, PlayState* play) { - s32 pad[2]; - EnInvadepoh* this = THIS; - - if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { - this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(play, &this->actor); - func_80B44F58(); - this->actor.update = func_80B4873C; - SkelAnime_InitFlex(play, &this->skelAnime, &gRomaniSkel, &gRomaniIdleAnim, this->jointTable, this->morphTable, - ROMANI_LIMB_MAX); - func_80B45C04(&this->behaviorInfo, D_80B4EA90, 6, D_80B4EB00, 2, &gZeroVec3s, 5000, 0.05f, 0.3f, 0.12f); - Animation_PlayLoop(&this->skelAnime, &gRomaniIdleAnim); - func_80B482D4(this); - } -} - -void func_80B4873C(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - s32 pad; - AlienBehaviorInfo* substruct = &this->behaviorInfo; - - if (this->actor.parent == NULL) { - Actor_Kill(&this->actor); - return; - } - this->actionFunc(this, play); - SkelAnime_Update(&this->skelAnime); - func_80B45CE0(substruct); - if (substruct->unk40 != 0) { - this->actor.shape.rot.x = -substruct->unk40; - } -} - -void func_80B487B4(EnInvadepoh* this) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - u32 new_var; - - this->actionTimer = Rand_S16Offset(150, 250); - new_var = Rand_Next(); - substruct->unk26.x = D_80B4EDC8[new_var >> 0x1E]; - substruct->unk26.y = 0; - substruct->unk26.z = 0; - substruct->unk30 = 0.1f; - substruct->unk2C = 800; - Animation_MorphToLoop(&this->skelAnime, &gRomaniWalkAnim, -10.0f); - this->actionFunc = func_80B48848; -} - -void func_80B48848(EnInvadepoh* this, PlayState* play) { - s32 pad; - - Math_StepToF(&this->actor.speedXZ, 1.6f, 0.1f); - if (func_80B44B84(this, play, this->actor.speedXZ, 50.0f)) { - func_80B44514(this); - this->behaviorInfo.unk4C = 0xC8; - this->actor.speedXZ *= 0.25f; - } else { - Math_StepToS(&this->behaviorInfo.unk4C, 0x7D0, 0x46); - } - func_80B43E6C(this, 6, this->behaviorInfo.unk4C, 0x46); - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40) && - (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); - } - if (this->actionTimer > 0) { - this->actionTimer--; - } else { - func_80B48948(this); - } -} - -void func_80B48948(EnInvadepoh* this) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - f32 rand = Rand_ZeroOne(); - - this->actionTimer = Rand_S16Offset(150, 150); - if (rand < 0.5f) { - this->rand = 0; - Math_Vec3s_Copy(&substruct->unk26, &gZeroVec3s); - substruct->unk30 = 0.1f; - substruct->unk2C = 1000; - } else if (rand < 0.75f) { - this->rand = 1; - substruct->unk26.x = Rand_S16Offset(0, 2000); - substruct->unk26.y = 0; - substruct->unk26.z = 0; - substruct->unk30 = 0.06f; - substruct->unk2C = 1000; - } else if (rand < 0.8f) { - this->rand = 2; - substruct->unk26.x = Rand_S16Offset(-2000, 2000); - substruct->unk26.y = 0; - substruct->unk26.z = 0; - substruct->unk30 = 0.05f; - substruct->unk2C = 1000; - } else { - this->rand = 3; - substruct->unk26.x = 0; - substruct->unk26.y = 0; - substruct->unk26.z = Rand_S16Offset(-2500, 5000); - substruct->unk30 = 0.04f; - substruct->unk2C = 1000; - } - - Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, -10.0f); - this->actionFunc = func_80B48AD4; -} - -void func_80B48AD4(EnInvadepoh* this, PlayState* play) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player; - s16 new_var3; - s16 temp_v1; - s32 temp_v1_3; - - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); - if (func_80B44B84(this, play, this->actor.speedXZ, 50.0f)) { - func_80B44514(this); - } - - if (this->rand == 0) { - s32 requiredScopeTemp; - - if ((this->actor.xzDistToPlayer < 350.0f) && ((play->gameplayFrames & 0x60) != 0)) { - player = GET_PLAYER(play); - temp_v1 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos) * 0.85f; - temp_v1 -= this->actor.shape.rot.x; - substruct->unk26.x = CLAMP(temp_v1, -2500, 2500); - new_var3 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); - temp_v1 = new_var3 * 0.7f; - substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - } - } else { - substruct->unk26.x = 0; - substruct->unk26.y = 0; - } - - if (this->actionTimer > 0) { - temp_v1_3 = this->actionTimer & 0x1F; - if ((temp_v1_3 == 0) && (Rand_ZeroOne() < 0.3f)) { - temp_v1_3 = (s32)Rand_Next() % 4; - if (temp_v1_3 != this->rand) { - this->rand = temp_v1_3; - if (this->rand == 0) { - Math_Vec3s_Copy(&substruct->unk26, &gZeroVec3s); - substruct->unk30 = 0.07f; - } else if (this->rand == 1) { - substruct->unk26.x = Rand_S16Offset(1000, 1000); - substruct->unk26.y = Rand_S16Offset(-1000, 2000); - substruct->unk26.z = Rand_S16Offset(-800, 1600); - substruct->unk30 = 0.06f; - } else if (this->rand == 2) { - substruct->unk26.x = Rand_S16Offset(-2000, 1000); - substruct->unk26.y = Rand_S16Offset(-1000, 2000); - substruct->unk26.z = Rand_S16Offset(-800, 1600); - substruct->unk30 = 0.05f; - } else { - substruct->unk26.x = Rand_S16Offset(-1000, 2000); - substruct->unk26.y = Rand_S16Offset(-2000, 4000); - substruct->unk26.z = Rand_S16Offset(-2000, 4000); - substruct->unk30 = 0.04f; - } - } - } - - this->actionTimer--; - } else { - func_80B487B4(this); - } -} - -void func_80B48DE4(EnInvadepoh* this) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - - this->actor.speedXZ = 0.0f; - Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, -10.0f); - this->behaviorInfo.unk4C = 0; - substruct->unk30 = 0.05f; - substruct->unk2C = 1200; - this->actionFunc = func_80B48E4C; -} - -void func_80B48E4C(EnInvadepoh* this, PlayState* play) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = GET_PLAYER(play); - s16 temp_v1; - s16 diff; - - Math_StepToS(&this->behaviorInfo.unk4C, 2000, 50); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, this->behaviorInfo.unk4C, 35); - temp_v1 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos); - temp_v1 *= 0.85f; - temp_v1 -= this->actor.shape.rot.x; - substruct->unk26.x = CLAMP(temp_v1, -0xBB8, 0xBB8); - 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 (Actor_TextboxIsClosing(&this->actor, play)) { - func_80B48948(this); - } -} - -void func_80B48FB0(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { - this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(play, &this->actor); - func_80B44F58(); - this->actor.update = func_80B490F0; - this->actor.draw = func_80B4E324; - this->actor.textId = 0x3330; - SkelAnime_InitFlex(play, &this->skelAnime, &gRomaniSkel, &gRomaniIdleAnim, this->jointTable, this->morphTable, - ROMANI_LIMB_MAX); - func_80B45C04(&this->behaviorInfo, D_80B4EA90, 6, D_80B4EB00, 2, &gZeroVec3s, 100, 0.03, 0.3, 0.03); - func_80B444F4(this, play); - EnInvadepoh_SetPathPointToWorldPos(this, 0); - func_800B4AEC(play, &this->actor, 50.0f); - func_80B4516C(this); - func_80B487B4(this); - } -} - -void func_80B490F0(Actor* thisx, PlayState* play) { - s32 pad; - EnInvadepoh* this = THIS; - s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); - s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &play->state); - - if (isTalking) { - func_80151BB4(play, 5); - func_80B48DE4(this); - } - this->actionFunc(this, play); - if (sp2C) { - SkelAnime_Update(&this->skelAnime); - func_80B45CE0(&this->behaviorInfo); - if ((this->actionFunc != func_80B48E4C) && !isTalking && this->actor.isTargeted) { - func_800B8614(&this->actor, play, 100.0f); - } - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - } -} - -void func_80B491EC(EnInvadepoh* this) { - this->scaleFactorAdj = 0.0f; - this->scaleStep = 0.0f; - this->unk3AA = 0; - this->actor.gravity = -15.0f; - this->scaleTarget = 1.0f; - this->actionFunc = func_80B49228; -} - -void func_80B49228(EnInvadepoh* this, PlayState* play) { - s32 pad; - f32 temp_f0; - - 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); - func_800B9010(&this->actor, NA_SE_EV_UFO_APPEAR - SFX_FLAG); - if (fabsf(temp_f0) < 1.0f) { - func_80B45EC8(this, play, 50); - func_80B492FC(this); - } -} - -void func_80B492FC(EnInvadepoh* this) { - this->actor.velocity.y *= 0.1f; - this->actionTimer = 20; - this->scaleTarget = 0.3f; - this->scaleStep = 0.03f; - this->unk3AA = 3000; - this->actionFunc = func_80B4934C; -} - -void func_80B4934C(EnInvadepoh* this, PlayState* play) { - f32 temp = this->actor.home.pos.y + D_80B4E934.y + 300.0f; - - if (this->actor.world.pos.y < temp) { - this->actor.gravity = 3.0f; - } else { - this->actor.gravity = -2.0f; - } - this->actor.velocity.y *= 0.96f; - Actor_MoveWithGravity(&this->actor); - func_800B9010(&this->actor, NA_SE_EV_UFO_APPEAR - SFX_FLAG); - this->actionTimer--; - if (this->actionTimer <= 0) { - func_80B49404(this); - } -} - -void func_80B49404(EnInvadepoh* this) { - this->actionTimer = 120; - this->scaleTarget = 0.2f; - this->scaleStep = 0.01f; - this->unk3AA = 3000; - this->unk3AC = 0; - this->counter = 0; - this->actor.gravity = 33.0f; - this->actionFunc = func_80B49454; -} - -void func_80B49454(EnInvadepoh* this, PlayState* play) { - s32 pad; - Vec3f sp30; - s32 pad2; - - if (this->counter < 25) { - this->counter++; - } else { - this->counter = 0; - this->unk3AC++; - this->unk3AC = CLAMP_MAX(this->unk3AC, 4); - this->actor.gravity = 33.0f; - func_80B45EC8(this, play, 20); - } - - Math_Vec3f_Sum(&D_80B4EDD0[this->unk3AC], &this->actor.home.pos, &sp30); - if (Math3D_Vec3fDistSq(&this->actor.world.pos, &sp30) < SQ(400.0f)) { - this->actor.speedXZ *= 0.8f; - } else { - Math_StepToF(&this->actor.speedXZ, 170.0f, 21.0f); - this->actor.speedXZ *= 0.98f; - } - if (func_80B450C0(&this->actor.world.pos.x, &this->actor.world.pos.z, sp30.x, sp30.z, this->actor.speedXZ)) { - this->actor.speedXZ = 0.0f; - } - if (sp30.y < this->actor.world.pos.y) { - Math_StepToF(&this->actor.gravity, -12.0f, 7.0f); - } else { - Math_StepToF(&this->actor.gravity, 5.0f, 4.0f); - } - this->actor.velocity.y += this->actor.gravity; - this->actor.velocity.y *= 0.97f; - this->actor.world.pos.y += this->actor.velocity.y; - func_800B9010(&this->actor, NA_SE_EV_UFO_APPEAR - SFX_FLAG); - if (this->actionTimer > 0) { - this->actionTimer--; - } else { - func_80B49628(this); - } -} - -void func_80B49628(EnInvadepoh* this) { - this->scaleTarget = 0.2f; - this->scaleStep = 0.01f; - this->unk3AA = 3000; - this->actor.velocity.y *= 0.8f; - this->actionFunc = func_80B49670; -} - -void func_80B49670(EnInvadepoh* this, PlayState* play) { - s32 pad; - Vec3f sp30; - - sp30.x = this->actor.home.pos.x; - sp30.y = this->actor.home.pos.y + 1500.0f; - sp30.z = this->actor.home.pos.z; - Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp30), 0xA, 0xBB8, 0x64); - if ((play->gameplayFrames % 64) < 14) { - Math_StepToF(&this->actor.speedXZ, 5.0f, 1.0f); - } else { - this->actor.speedXZ *= 0.97f; - } - if (sp30.y < this->actor.world.pos.y) { - this->actor.gravity = -0.5f; - } else { - this->actor.gravity = 2.0f; - } - this->actor.velocity.y *= 0.97f; - Actor_MoveWithGravity(&this->actor); - if (D_80B4E940 == 3) { - func_80B499BC(this); - } -} - -void func_80B497A4(EnInvadepoh* this) { - this->scaleTarget = 0.2f; - this->scaleStep = 0.01f; - this->unk3AA = 3000; - this->actionTimer = 35; - this->actor.gravity = -1.5f; - this->actionFunc = func_80B497EC; -} - -void func_80B497EC(EnInvadepoh* this, PlayState* play) { - s32 pad; - Vec3f sp30; - - sp30.x = this->actor.home.pos.x + D_80B4E934.x; - sp30.y = this->actor.home.pos.y + D_80B4E934.y + 400.0f; - sp30.z = this->actor.home.pos.z + D_80B4E934.z; - Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp30), 4, 0x1F40, 0x64); - Math_StepToF(&this->actor.speedXZ, 70.0f, 3.0f); - if (sp30.y < this->actor.world.pos.y) { - this->actor.gravity = -2.0f; - } else { - this->actor.gravity = 2.0f; - } - this->actor.velocity.y *= 0.97f; - Actor_MoveWithGravity(&this->actor); - if (this->actionTimer > 0) { - this->actionTimer--; - } else { - func_80B49904(this); - } -} - -void func_80B49904(EnInvadepoh* this) { - this->scaleTarget = 0.2f; - this->scaleStep = 0.01f; - this->unk3AA = 3000; - this->actionTimer = 60; - this->actor.gravity = 1.0f; - this->actionFunc = func_80B4994C; -} - -void func_80B4994C(EnInvadepoh* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 150.0f, 4.0f); - this->actor.velocity.y *= 0.95f; - Actor_MoveWithGravity(&this->actor); - if (this->actionTimer > 0) { - this->actionTimer--; - } else { - Actor_Kill(&this->actor); - } -} - -void func_80B499BC(EnInvadepoh* this) { - this->actionTimer = 40; - this->scaleTarget = 0.2f; - this->scaleStep = 0.01f; - this->unk3AA = 3000; - this->actor.speedXZ = 0.0f; - this->actionFunc = func_80B49A00; -} - -void func_80B49A00(EnInvadepoh* this, PlayState* play) { - s32 pad; - Vec3f sp30; - - sp30.x = this->actor.home.pos.x; - sp30.y = this->actor.home.pos.y + 800.0f; - sp30.z = this->actor.home.pos.z; - Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp30), 4, 0x1F40, 0x64); - Math_StepToF(&this->actor.speedXZ, 30.0f, 3.0f); - this->actor.velocity.y *= 0.98f; - if (sp30.y < this->actor.world.pos.y) { - this->actor.gravity = -0.5f; - } else { - this->actor.gravity = 2.0f; - } - Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); - if (this->actionTimer > 0) { - this->actionTimer--; - } else { - func_80B497A4(this); - } -} - -void func_80B49B1C(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - f32 scale; - - this->actionFunc(this, play); - this->scaleAdjAngle += this->unk3AA; - Math_StepToF(&this->scaleFactorAdj, this->scaleTarget, this->scaleStep); - scale = Math_SinS(this->scaleAdjAngle) * this->scaleFactorAdj + 1.0f; - Actor_SetScale(&this->actor, 0.27f * scale); - Math_StepToS(&this->unk306, 600, 8); - this->actor.world.rot.y += this->unk306; - this->unk304 += 600; -} - -void func_80B49BD0(EnInvadepoh* this) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - - Animation_MorphToLoop(&this->skelAnime, &gRomaniWalkAnim, -10.0f); - substruct->unk26.x = 0; - substruct->unk26.y = 0; - substruct->unk26.z = 0; - substruct->unk30 = 0.1f; - substruct->unk2C = 800; - this->actionFunc = func_80B49C38; -} - -void func_80B49C38(EnInvadepoh* this, PlayState* play) { - s32 pad; - s32 temp_v0_2; - - func_80B44570(this); - func_80B44C24(this, play); - func_80B43E6C(this, 6, 2000, 100); - if (1) {} - if (this->pathIndex == 0 || (this->pathIndex + 1) == this->endPoint) { - if (this->unk378 == 0) { - temp_v0_2 = func_800FE620(play); - if (temp_v0_2 > 0) { - temp_v0_2 = (R_TIME_SPEED * -16.0f / temp_v0_2) - 0.5f; - this->unk378 = func_80B45550(this, play, SQ(80.0f), temp_v0_2); - } - } - this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); - } else { - this->unk378 = 0; - this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); - } - - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40) && - (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); - } - if (this->clockTime >= 0.9999f) { - Actor_Kill(&this->actor); - } -} - -void func_80B49DA0(EnInvadepoh* this) { - this->behaviorInfo.unk30 = 0.08f; - this->behaviorInfo.unk2C = 2000; - this->behaviorInfo.unk4C = 0; - Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, -10.0f); - this->actionFunc = func_80B49DFC; -} - -void func_80B49DFC(EnInvadepoh* this, PlayState* play) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = GET_PLAYER(play); - s16 temp_v1; - s16 diff; - - Math_StepToS(&this->behaviorInfo.unk4C, 2000, 500); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, this->behaviorInfo.unk4C, 40); - temp_v1 = (Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos) * 0.85f); - temp_v1 -= this->actor.shape.rot.x; - substruct->unk26.x = CLAMP(temp_v1, -0xBB8, 0xBB8); - diff = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); - temp_v1 = diff; - temp_v1 *= 0.7f; - substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (Actor_TextboxIsClosing(&this->actor, play)) { - if (this->actor.textId == 0x332D) { - SET_WEEKEVENTREG(WEEKEVENTREG_54_10); - this->actor.textId = 0x332E; - } - func_80B49BD0(this); - } -} - -void func_80B49F88(Actor* thisx, PlayState* play) { - s32 pad[2]; - EnInvadepoh* this = THIS; - s32 sp38; - - if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { - sp38 = gSaveContext.save.time; - this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(play, &this->actor); - func_80B44F58(); - SkelAnime_InitFlex(play, &this->skelAnime, &gRomaniSkel, &gRomaniWalkAnim, this->jointTable, this->morphTable, - ROMANI_LIMB_MAX); - func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 1, &gZeroVec3s, 100, 0.03, 0.3, 0.03); - func_80B44540(this, play); - func_80B44570(this); - func_80B44C24(this, play); - func_80B43F0C(this); - func_80B4516C(this); - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_21_20)) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_54_10)) { - this->actor.textId = 0x332E; - } else { - this->actor.textId = 0x332D; - } - - } else { - this->actor.textId = 0x332C; - } - - if (sp38 >= CLOCK_TIME(18, 0) || sp38 < CLOCK_TIME(2, 0)) { - this->actor.update = func_80B4A168; - this->actor.draw = NULL; - } else if ((sp38 < CLOCK_TIME(6, 0)) && (sp38 >= CLOCK_TIME(2, 0)) && (sp38 < CLOCK_TIME(2, 15))) { - this->actor.update = func_80B4A1B8; - this->actor.draw = func_80B4E324; - func_80B49BD0(this); - } else { - Actor_Kill(&this->actor); - } - } -} - -void func_80B4A168(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(2, 0))) { - this->actor.update = func_80B4A1B8; - this->actor.draw = func_80B4E324; - func_80B49BD0(this); - } -} - -void func_80B4A1B8(Actor* thisx, PlayState* play) { - s32 pad; - EnInvadepoh* this = THIS; - s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); - s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &play->state); - - if (isTalking) { - func_80151BB4(play, 5); - func_80B49DA0(this); - } - this->actionFunc(this, play); - if (sp2C && this->actor.update != NULL) { - SkelAnime_Update(&this->skelAnime); - func_80B45CE0(&this->behaviorInfo); - if ((this->actionFunc != func_80B49DFC) && !isTalking && this->actor.isTargeted) { - func_800B8614(&this->actor, play, 350.0f); - } - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - } -} - -void func_80B4A2C0(EnInvadepoh* this) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - - Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, -10.0f); - substruct->unk26.x = 0; - substruct->unk26.y = 0; - substruct->unk26.z = 0; - substruct->unk30 = 0.1f; - substruct->unk2C = 1500; - this->actionTimer = Rand_S16Offset(200, 200); - this->unk304 = this->actor.shape.rot.y; - this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); - this->actionFunc = func_80B4A350; -} - -void func_80B4A350(EnInvadepoh* this, PlayState* play) { - s16 temp_v0; - s16 temp_v1_2; - s16 diff; - Vec3f sp44; - s16 sp42; - AlienBehaviorInfo* substruct = &this->behaviorInfo; - - if ((play->gameplayFrames % 256) == 0) { - Math_Vec3s_ToVec3f(&sp44, this->pathPoints); - sp42 = Math_Vec3f_Yaw(&this->actor.world.pos, &sp44); - temp_v0 = Rand_S16Offset(-0x1F40, 0x3E80); - this->unk304 = temp_v0 + sp42; - this->behaviorInfo.unk4C = 0; - } - - Math_StepToS(&this->behaviorInfo.unk4C, 2000, 40); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk304, 6, this->behaviorInfo.unk4C, 40); - if (this->actor.xzDistToPlayer < 300.0f) { - Player* player = GET_PLAYER(play); - - temp_v1_2 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos); - temp_v1_2 *= 0.85f; - temp_v1_2 -= this->actor.shape.rot.x; - substruct->unk26.x = CLAMP(temp_v1_2, -0x9C4, 0x9C4); - diff = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); - temp_v1_2 = diff; - temp_v1_2 *= 0.7f; - substruct->unk26.y = CLAMP(temp_v1_2, -0x1F40, 0x1F40); - if ((play->gameplayFrames % 256) == 0) { - substruct->unk26.z = Rand_S16Offset(-0x5DC, 0xBB8); - } - } else { - substruct->unk26.x = 0; - substruct->unk26.y = 0; - substruct->unk26.z = 0; - } - if (this->actionTimer > 0) { - this->actionTimer--; - } else { - func_80B4A570(this); - } -} - -void func_80B4A570(EnInvadepoh* this) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - - Animation_MorphToPlayOnce(&this->skelAnime, &gRomaniLookAroundAnim, -10.0f); - substruct->unk26.x = 0; - substruct->unk26.y = 0; - substruct->unk26.z = 0; - substruct->unk30 = 0.1f; - substruct->unk2C = 800; - this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); - this->actionFunc = func_80B4A5E4; -} - -void func_80B4A5E4(EnInvadepoh* this, PlayState* play) { - if (this->animPlayFlag) { - func_80B4A2C0(this); - } -} - -void func_80B4A614(EnInvadepoh* this) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - - Animation_MorphToLoop(&this->skelAnime, &gRomaniWalkAnim, 0.0f); - substruct->unk26.x = 0; - substruct->unk26.y = 0; - substruct->unk26.z = 0; - substruct->unk30 = 0.1f; - substruct->unk2C = 800; - this->actionFunc = func_80B4A67C; -} - -void func_80B4A67C(EnInvadepoh* this, PlayState* play) { - s32 pad; - - Math_StepToF(&this->actor.speedXZ, 5.0f, 1.0f); - if (func_80B44B84(this, play, this->actor.speedXZ, 50.0f)) { - func_80B44640(this); - this->behaviorInfo.unk4C = 0x5DC; - this->actor.speedXZ *= 0.5f; - } else { - Math_StepToS(&this->behaviorInfo.unk4C, 0x190, 0x32); - } - func_80B43E6C(this, 6, this->behaviorInfo.unk4C, 0x32); - if (this->pathIndex == 0) { - if (this->unk378 == 0) { - this->unk378 = func_80B45550(this, play, SQ(80.0f), -0xF); - } - this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); - } else { - this->unk378 = 0; - this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); - } - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40) && - (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); - } - if (this->pathIndex == this->endPoint) { - func_80B4A2C0(this); - } -} - -void func_80B4A7C0(EnInvadepoh* this) { - this->behaviorInfo.unk30 = 0.08f; - this->behaviorInfo.unk2C = 2000; - this->behaviorInfo.unk4C = 0; - Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, 0.0f); - this->actionFunc = func_80B4A81C; -} - -void func_80B4A81C(EnInvadepoh* this, PlayState* play) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = GET_PLAYER(play); - s16 temp_v1; - s16 diff; - - Math_StepToS(&this->behaviorInfo.unk4C, 2000, 500); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, this->behaviorInfo.unk4C, 40); - temp_v1 = (Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos) * 0.85f); - temp_v1 -= this->actor.shape.rot.x; - substruct->unk26.x = CLAMP(temp_v1, -0xBB8, 0xBB8); - diff = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); - temp_v1 = diff; - temp_v1 *= 0.7f; - substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - - if (Actor_TextboxIsClosing(&this->actor, play)) { - if (this->actor.textId == 0x332D) { - SET_WEEKEVENTREG(WEEKEVENTREG_54_10); - this->actor.textId = 0x332E; - } - if (this->pathIndex == this->endPoint) { - func_80B4A2C0(this); - } else { - func_80B4A614(this); - } - } -} - -void func_80B4A9C8(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - s32 pad[2]; - s32 sp38; - - if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { - sp38 = gSaveContext.save.time; - this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(play, &this->actor); - func_80B44F58(); - SkelAnime_InitFlex(play, &this->skelAnime, &gRomaniSkel, &gRomaniWalkAnim, this->jointTable, this->morphTable, - ROMANI_LIMB_MAX); - func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 1, &gZeroVec3s, 100, 0.03f, 0.3f, 0.03f); - func_80B44620(this, play); - if ((sp38 < CLOCK_TIME(2, 15)) || (sp38 >= CLOCK_TIME(6, 0))) { - this->pathIndex = 0; - this->actor.update = func_80B4AB8C; - } else { - this->pathIndex = this->endPoint; - this->actor.update = func_80B4ABDC; - this->actor.draw = func_80B4E324; - func_80B4A2C0(this); - } - - EnInvadepoh_SetPathPointToWorldPos(this, this->pathIndex); - func_80B43F0C(this); - func_800B4AEC(play, &this->actor, 50.0f); - func_80B4516C(this); - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_21_20)) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_54_10)) { - this->actor.textId = 0x332E; - } else { - this->actor.textId = 0x332D; - } - } else { - this->actor.textId = 0x332C; - } - } -} - -void func_80B4AB8C(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(2, 15))) { - this->actor.update = func_80B4ABDC; - this->actor.draw = func_80B4E324; - func_80B4A614(this); - } -} - -void func_80B4ABDC(Actor* thisx, PlayState* play) { - s32 pad; - EnInvadepoh* this = THIS; - s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); - s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &play->state); - - if (isTalking) { - func_80151BB4(play, 5); - func_80B4A7C0(this); - } - this->actionFunc(this, play); - if (sp2C) { - this->animPlayFlag = SkelAnime_Update(&this->skelAnime); - func_80B45CE0(&this->behaviorInfo); - if ((this->actionFunc != func_80B4A81C) && !isTalking && this->actor.isTargeted) { - func_800B8614(&this->actor, play, 100.0f); - } - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - } -} - -void func_80B4ACDC(EnInvadepoh* this) { - this->actionFunc = func_80B4ACF0; -} - -void func_80B4ACF0(EnInvadepoh* this, PlayState* play) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { - this->actor.draw = func_80B4E324; - this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); - func_80B4AD3C(this); - } -} - -void func_80B4AD3C(EnInvadepoh* this) { - this->actor.flags |= ACTOR_FLAG_10000; - this->actionFunc = func_80B4AD60; -} - -void func_80B4AD60(EnInvadepoh* this, PlayState* play) { - if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - EnInvadepoh_SetTextID(this, play, 0x3331); - func_80B4ADB8(this); - } else { - func_800B8614(&this->actor, play, 2000.0f); - } -} - -void func_80B4ADB8(EnInvadepoh* this) { - this->actionFunc = func_80B4ADCC; -} - -void func_80B4ADCC(EnInvadepoh* this, PlayState* play) { - if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - if (this->textId == 0x3331) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_02)) { - EnInvadepoh_SetTextID(this, play, 0x3334); - func_80151BB4(play, 0x1D); - func_80151BB4(play, 5); - return; - } - EnInvadepoh_SetTextID(this, play, 0x3333); - return; - } - if (this->textId == 0x3333) { - func_80B4AEC0(this); - } else if (this->textId == 0x3334) { - func_801477B4(play); - func_80B4B024(this); - } - } -} - -void func_80B4AEC0(EnInvadepoh* this) { - this->actionTimer = 2; - this->actionFunc = func_80B4AEDC; -} - -void func_80B4AEDC(EnInvadepoh* this, PlayState* play) { - if (this->actionTimer > 0) { - this->actionTimer--; - if (this->actionTimer == 0) { - func_801477B4(play); - } - } - if (Actor_HasParent(&this->actor, play)) { - this->actor.parent = NULL; - SET_WEEKEVENTREG(WEEKEVENTREG_22_02); - func_80B4AF80(this); - } else { - Actor_PickUp(&this->actor, play, GI_MILK_BOTTLE, 2000.0f, 2000.0f); - } -} - -void func_80B4AF80(EnInvadepoh* this) { - this->actionFunc = func_80B4AF94; -} - -void func_80B4AF94(EnInvadepoh* this, PlayState* play) { - if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - EnInvadepoh_SetTextID(this, play, 0x3334); - func_80151BB4(play, 0x1E); - func_80151BB4(play, 0x1D); - func_80151BB4(play, 5); - func_80B4ADB8(this); - } else { - func_800B85E0(&this->actor, play, 2000.0f, PLAYER_IA_MINUS1); - } -} - -void func_80B4B024(EnInvadepoh* this) { - this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); - this->actionFunc = func_80B4B048; -} - -void func_80B4B048(EnInvadepoh* this, PlayState* play) { - if (play->msgCtx.unk120B1 == 0) { - if (play->msgCtx.msgMode == 0) { - D_80B4E998 = 1; - } else if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) || - (Message_GetState(&play->msgCtx) == TEXT_STATE_5)) { - D_80B4E998 = 1; - } - } -} - -void func_80B4B0C4(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - AlienBehaviorInfo* substruct; - s32 pad; - - if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { - this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(play, &this->actor); - func_80B44F58(); - this->actor.update = func_80B4B218; - SkelAnime_InitFlex(play, &this->skelAnime, &gRomaniSkel, &gRomaniWalkAnim, this->jointTable, this->morphTable, - ROMANI_LIMB_MAX); - Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, 0.0f); - substruct = &this->behaviorInfo; - func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 3, &gZeroVec3s, 2000, 0.08f, 0.3f, 0.03f); - substruct->unk30 = 0.08f; - substruct->unk2C = 0x7D0; - func_800B4AEC(play, &this->actor, 50.0f); - func_80B4516C(this); - func_80B4ACDC(this); - } -} - -void func_80B4B218(Actor* thisx, PlayState* play) { - s16 diff; - EnInvadepoh* this = THIS; - s16 temp_v1; - s32 sp38 = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); - Player* player; - AlienBehaviorInfo* substruct = &this->behaviorInfo; - - this->actionFunc(this, play); - if (sp38 && this->actor.update != NULL) { - SkelAnime_Update(&this->skelAnime); - player = GET_PLAYER(play); - Math_StepToS(&this->behaviorInfo.unk4C, 2000, 40); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, this->behaviorInfo.unk4C, 40); - temp_v1 = (Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos) * 0.9f); - temp_v1 -= this->actor.shape.rot.x; - substruct->unk26.x = CLAMP(temp_v1, -0xBB8, 0xBB8); - diff = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); - temp_v1 = diff; - temp_v1 *= 0.7f; - substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - func_80B45CE0(substruct); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - } -} - -void func_80B4B3DC(EnInvadepoh* this) { - s32 pad; - - if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 7.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); - } -} - -void func_80B4B430(EnInvadepoh* this) { - Animation_MorphToLoop(&this->skelAnime, &gDogWalkAnim, -6.0f); - this->actionTimer = Rand_S16Offset(50, 80); - this->actionFunc = func_80B4B484; -} - -void func_80B4B484(EnInvadepoh* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 1.1f, 0.5f); - if (func_80B44C80(this, play)) { - func_80B44690(this); - } - func_80B4B3DC(this); - if (this->unk3BC >= 0) { - this->actionTimer = 0; - } - - if (this->actionTimer > 0) { - this->actionTimer--; - } else { - func_80B4B510(this); - } -} - -void func_80B4B510(EnInvadepoh* this) { - Animation_MorphToLoop(&this->skelAnime, &gDogRunAnim, -6.0f); - this->actionTimer = Rand_S16Offset(50, 200); - this->actionFunc = func_80B4B564; -} - -void func_80B4B564(EnInvadepoh* this, PlayState* play) { - s32 pad; - Vec3f sp28; - f32 temp_f0; - - Math_StepToF(&this->actor.speedXZ, 3.8f, 0.45f); - - if (this->unk3BC >= 0) { - Math_Vec3s_ToVec3f(&sp28, &this->pathPoints[this->unk3BC]); - temp_f0 = Math3D_Vec3fDistSq(&this->actor.world.pos, &sp28); - if (temp_f0 < SQ(80.0f)) { - this->actor.speedXZ *= 0.85f; - } else if (temp_f0 < SQ(150.0f)) { - this->actor.speedXZ *= 0.93f; - } else if (temp_f0 < SQ(250.0f)) { - this->actor.speedXZ *= 0.96f; - } - if (this->pathIndex == this->unk3BC || temp_f0 < SQ(50.0f)) { - this->actionTimer = 0; - } - } - func_80B4B3DC(this); - if (func_80B44C80(this, play)) { - func_80B44690(this); - } - - if (this->actionTimer > 0) { - this->actionTimer--; - } else if (this->unk3BC >= 0) { - if ((D_80B50348 == 0) && (Rand_ZeroOne() < 0.4f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_GROAN); - } - func_80B4B724(this); - } else { - func_80B4B430(this); - } -} - -void func_80B4B724(EnInvadepoh* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gDogBarkAnim, -6.0f); - this->actionFunc = func_80B4B768; -} - -void func_80B4B768(EnInvadepoh* this, PlayState* play) { - s32 pad; - - Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); - Math_SmoothStepToS(&this->actor.world.rot.y, Actor_YawBetweenActors(&this->actor, &D_80B5040C->actor), 5, 0x1388, - 0x64); - func_80B44E90(this, play); - if (Animation_OnFrame(&this->skelAnime, 13.0f) || Animation_OnFrame(&this->skelAnime, 19.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_ANG_BARK); - } - if (this->animPlayFlag) { - func_80B4B510(this); - } -} - -void func_80B4B820(EnInvadepoh* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &gDogJumpAnim, -6.0f); - this->actionFunc = func_80B4B864; -} - -void func_80B4B864(EnInvadepoh* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 0.5f, 1.0f); - func_80B44E90(this, play); - if (this->animPlayFlag) { - func_80B4B510(this); - } -} - -void func_80B4B8BC(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - s32 pad; - - if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { - this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(play, &this->actor); - SkelAnime_InitFlex(play, &this->skelAnime, &gDogSkel, &gDogWalkAnim, this->jointTable, this->morphTable, - DOG_LIMB_MAX); - func_80B45C04(&this->behaviorInfo, 0, 0, 0, 0, &gZeroVec3s, 3000, 0.1f, 0.0f, 0.0f); - func_80B44664(this, play); - EnInvadepoh_SetPathPointToWorldPos(this, 0); - func_800B4AEC(play, &this->actor, 50.0f); - func_80B4516C(this); - Math_Vec3f_Copy(&this->curPathPos, &this->actor.world.pos); - if (D_80B4E940 == 2) { - this->actor.update = func_80B4BA84; - this->actor.draw = func_80B4E660; - this->actor.flags |= ACTOR_FLAG_1; - func_80B4B430(this); - } else if (D_80B4E940 == 1) { - this->actor.update = func_80B4BA30; - } else { - Actor_Kill(&this->actor); - if (!this) {} - } - } -} - -void func_80B4BA30(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - if (D_80B4E940 == 2) { - this->actor.update = func_80B4BA84; - this->actor.draw = func_80B4E660; - this->actor.flags |= ACTOR_FLAG_1; - func_80B4B430(this); - } -} - -void func_80B4BA84(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - s32 temp_v0_3; - s32 sp34 = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); - s32 temp_v1_2; - s32 sp2C; - s32 temp_v0_2; - s32 phi_v0; - - D_80B5040C = func_80B458D8(); - if (D_80B5040C == NULL) { - temp_v0_2 = this->unk3BC >= 0; - this->unk3BC = -1; - if (temp_v0_2) { - func_80B4B820(this); - } - } else { - sp2C = this->unk3BC; - this->unk3BC = func_80B44234(this, &D_80B5040C->actor.world.pos); - if (sp2C != this->unk3BC) { - phi_v0 = this->unk3BC - this->pathIndex; - if (phi_v0 < 0) { - phi_v0 += this->endPoint; - } - - if ((this->endPoint >> 1) < phi_v0) { - this->direction = DIRECTION_BACKWARD; - } else if (phi_v0 < (this->endPoint >> 1)) { - this->direction = DIRECTION_FORWARD; - } - } - } - - this->actionFunc(this, play); - this->animPlayFlag = SkelAnime_Update(&this->skelAnime); - if (sp34 && (this->actor.update != NULL)) { - func_80B45CE0(&this->behaviorInfo); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - } -} - -void func_80B4BBE0(EnInvadepoh* this) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - - Animation_MorphToLoop(&this->skelAnime, &gCremiaWalkAnim, -6.0f); - substruct->unk26.x = 0; - substruct->unk26.y = 0; - substruct->unk26.z = 0; - substruct->unk30 = 0.1f; - substruct->unk2C = 800; - - this->behaviorInfo.unk4C = 0; - this->actionFunc = func_80B4BC4C; -} - -void func_80B4BC4C(EnInvadepoh* this, PlayState* play) { - s8 temp_v0; - s16 diff; - EnInvadepoh* temp_t6 = D_80B503F4; - s16 temp_v1_2; - s32 temp_v1; - AlienBehaviorInfo* substruct = &this->behaviorInfo; - s16 temp_a0; - s16 sp40; - - if (temp_t6 != NULL) { - temp_v0 = temp_t6->pathIndex; - if (temp_v0 == 0) { - this->xzPosAdjFactor = 40.0f; - this->unk304 = -0x8000; - this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); - - } else if (temp_v0 < (temp_t6->endPoint - 1)) { - this->xzPosAdjFactor = 40.0f; - Math_ScaledStepToS(&this->unk304, -0x4800, 0xC8); - this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); - } else { - Math_StepToF(&this->xzPosAdjFactor, 5.0f, 3.0f); - Math_ScaledStepToS(&this->unk304, -0x8000, 0x12C); - this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); - } - temp_a0 = this->unk304 + temp_t6->actor.world.rot.y; - this->actor.world.pos.x = (Math_SinS(temp_a0) * this->xzPosAdjFactor) + temp_t6->actor.world.pos.x; - this->actor.world.pos.y = temp_t6->actor.world.pos.y; - this->actor.world.pos.z = (Math_CosS(temp_a0) * this->xzPosAdjFactor) + temp_t6->actor.world.pos.z; - func_800B4AEC(play, &this->actor, 50.0f); - func_80B4516C(this); - Math_StepToS(&this->behaviorInfo.unk4C, 0xBB8, 0x1F5); - if (Math3D_Vec3fDistSq(&this->actor.prevPos, &this->actor.world.pos) > SQ(0.01f)) { - Math_SmoothStepToS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&this->actor.prevPos, &this->actor.world.pos), - 3, this->behaviorInfo.unk4C, 0x1F4); - } - temp_v1 = (play->gameplayFrames + 0x14) % 128; - if ((temp_v1 & 0x40) != 0) { - sp40 = Math_Vec3f_Yaw(&this->actor.world.pos, &temp_t6->actor.world.pos); - if (temp_v1 == 64) { - this->behaviorInfo.unk4C = 0; - } - Math_StepToS(&this->behaviorInfo.unk4C, 2000, 40); - Math_SmoothStepToS(&this->actor.shape.rot.y, sp40, 6, this->behaviorInfo.unk4C, 40); - temp_v1_2 = Math_Vec3f_Pitch(&this->actor.focus.pos, &temp_t6->actor.focus.pos); - temp_v1_2 *= 0.85f; - temp_v1_2 -= this->actor.shape.rot.x; - substruct->unk26.x = CLAMP(temp_v1_2, -3000, 3000); - diff = BINANG_SUB(sp40, this->actor.shape.rot.y); - temp_v1_2 = diff; - temp_v1_2 *= 0.7f; - substruct->unk26.y = CLAMP(temp_v1_2, -8000, 8000); - } - } - - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40) && - (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); - } - if (gSaveContext.save.time > CLOCK_TIME(20, 15)) { - Actor_Kill(&this->actor); - } else if ((temp_t6 != NULL) && (temp_t6->actionFunc == func_80B4CB0C)) { - func_80B4C1BC(this); - } -} - -void func_80B4BFFC(EnInvadepoh* this) { - this->behaviorInfo.unk30 = 0.08f; - this->behaviorInfo.unk2C = 2000; - Animation_MorphToLoop(&this->skelAnime, &gCremiaIdleAnim, -6.0f); - this->behaviorInfo.unk4C = 0; - this->actionFunc = func_80B4C058; -} - -void func_80B4C058(EnInvadepoh* this, PlayState* play) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = GET_PLAYER(play); - s16 temp_v1; - s16 diff; - - Math_StepToS(&this->behaviorInfo.unk4C, 2500, 450); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, this->behaviorInfo.unk4C, 40); - temp_v1 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos); - temp_v1 *= 0.85f; - temp_v1 -= this->actor.shape.rot.x; - substruct->unk26.x = CLAMP(temp_v1, -0xBB8, 0xBB8); - - diff = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); - temp_v1 = diff; - temp_v1 *= 0.7f; - - substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - - if (Actor_TextboxIsClosing(&this->actor, play)) { - func_80B4BBE0(this); - } -} - -void func_80B4C1BC(EnInvadepoh* this) { - this->behaviorInfo.unk30 = 0.08f; - this->behaviorInfo.unk2C = 2000; - Animation_MorphToLoop(&this->skelAnime, &gCremiaIdleAnim, -6.0f); - this->behaviorInfo.unk4C = 0; - this->actionFunc = func_80B4C218; -} - -void func_80B4C218(EnInvadepoh* this, PlayState* play) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = GET_PLAYER(play); - Actor* temp_v0; - s16 temp_v1; - s16 diff; - - Math_StepToS(&this->behaviorInfo.unk4C, 2000, 200); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, this->behaviorInfo.unk4C, 40); - temp_v1 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos); - temp_v1 *= 0.85f; - temp_v1 -= this->actor.shape.rot.x; - substruct->unk26.x = CLAMP(temp_v1, -0xBB8, 0xBB8); - diff = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); - temp_v1 = diff; - temp_v1 *= 0.7f; - substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - - if (D_80B503F4 == NULL) { - func_80B4BBE0(this); - } else if ((D_80B503F4 != NULL) && (D_80B503F4->actionFunc != func_80B4CB0C)) { - func_80B4BBE0(this); - } -} - -void func_80B4C3A0(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { - s32 pad[2]; - s32 currentTime = gSaveContext.save.time; - - this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(play, &this->actor); - func_80B44FEC(); - SkelAnime_InitFlex(play, &this->skelAnime, &gCremiaSkel, &gCremiaWalkAnim, this->jointTable, this->morphTable, - CREMIA_LIMB_MAX); - func_80B45C04(&this->behaviorInfo, D_80B4EBDC, 1, D_80B4EC08, 0, &gZeroVec3s, 100, 0.03f, 0.3f, 0.03f); - this->actor.textId = 0x33CD; - if (currentTime < 0xD5A0) { - this->unk304 = -0x8000; - this->xzPosAdjFactor = 40.0f; - } else if (currentTime >= 0xD7D4) { - this->unk304 = -0x4800; - this->xzPosAdjFactor = 20.0f; - } else { - this->unk304 = -0x8000; - this->xzPosAdjFactor = 40.0f; - } - - if ((currentTime >= CLOCK_TIME(6, 0)) && (currentTime < 0xD573)) { - this->actor.update = func_80B4C568; - this->actor.draw = NULL; - } else if ((currentTime >= 0xD573) && (currentTime < CLOCK_TIME(20, 15))) { - this->actor.update = func_80B4C5C0; - this->actor.draw = func_80B4E7BC; - func_80B4BBE0(this); - } else { - Actor_Kill(&this->actor); - } - } -} - -void func_80B4C568(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - if ((gSaveContext.save.time >= 0xD573) && (gSaveContext.save.time < CLOCK_TIME(20, 15))) { - this->actor.update = func_80B4C5C0; - this->actor.draw = func_80B4E7BC; - func_80B4BBE0(this); - } -} - -void func_80B4C5C0(Actor* thisx, PlayState* play) { - s32 pad; - EnInvadepoh* this = THIS; - s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); - s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &play->state); - - if (isTalking) { - func_80151BB4(play, 6); - func_80B4BFFC(this); - } - this->actionFunc(this, play); - if (sp2C && (this->actor.update != NULL)) { - SkelAnime_Update(&this->skelAnime); - func_80B45CE0(&this->behaviorInfo); - if ((this->actionFunc != func_80B4C058) && !isTalking && this->actor.isTargeted) { - func_800B8614(&this->actor, play, 350.0f); - } - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - } -} - -void func_80B4C6C8(EnInvadepoh* this) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - - Animation_MorphToLoop(&this->skelAnime, &gRomaniWalkAnim, -10.0f); - substruct->unk26.x = 0; - substruct->unk26.y = 0; - substruct->unk26.z = 0; - substruct->unk30 = 0.1f; - substruct->unk2C = 0x320; - this->actionFunc = func_80B4C730; -} - -void func_80B4C730(EnInvadepoh* this, PlayState* play) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - EnInvadepoh* sp68 = D_80B503F8; - s32 phi_a2; - s32 temp_v1_3; - s16 temp_v1_4; - s32 temp_v0_2; - Vec3f sp4C; - Vec3f sp40; - s16 diff; - s16 pad; - s16 sp3A; - s16 pad2; - - func_80B44700(this); - func_80B44EFC(this, play); - func_80B43E6C(this, 6, 2000, 100); - phi_a2 = ((this->pathIndex < this->endPoint) ? this->pathIndex : this->endPoint - 1); - - Math_Vec3s_ToVec3f(&sp4C, &this->pathPoints[phi_a2]); - Math_Vec3s_ToVec3f(&sp40, &this->pathPoints[phi_a2 + 1]); - Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&sp4C, &sp40), 5, 0x7D0, 0x64); - if ((this->pathIndex == 0) || ((this->pathIndex + 1) == this->endPoint)) { - if (this->unk378 == 0) { - temp_v0_2 = func_800FE620(play); - if (temp_v0_2 > 0) { - temp_v0_2 = (R_TIME_SPEED * -23.0f / temp_v0_2) - 0.5f; - this->unk378 = func_80B45550(this, play, SQ(80.0f), temp_v0_2); - } - } - - this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); - } else { - this->unk378 = 0; - this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); - } - - temp_v1_3 = play->gameplayFrames % 128; - if ((temp_v1_3 & 0x40) != 0) { - sp3A = Math_Vec3f_Yaw(&this->actor.world.pos, &sp68->actor.world.pos); - if (temp_v1_3 == 64) { - this->behaviorInfo.unk4C = 0; - } - - Math_StepToS(&this->behaviorInfo.unk4C, 2000, 40); - Math_SmoothStepToS(&this->actor.shape.rot.y, sp3A, 6, this->behaviorInfo.unk4C, 40); - temp_v1_4 = Math_Vec3f_Pitch(&this->actor.focus.pos, &sp68->actor.focus.pos); - temp_v1_4 *= 0.85f; - temp_v1_4 -= this->actor.shape.rot.x; - substruct->unk26.x = CLAMP(temp_v1_4, -3000, 3000); - diff = BINANG_SUB(sp3A, this->actor.shape.rot.y); - temp_v1_4 = diff; - temp_v1_4 *= 0.7f; - substruct->unk26.y = CLAMP(temp_v1_4, -8000, 8000); - } - - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40) && - (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); - } - - if (this->clockTime >= 0.9999f) { - Actor_Kill(&this->actor); - return; - } - - if ((sp68 != NULL) && (sp68->actionFunc == func_80B4C058)) { - func_80B4CC70(this); - } -} - -void func_80B4CAB0(EnInvadepoh* this) { - this->behaviorInfo.unk30 = 0.08f; - this->behaviorInfo.unk2C = 4000; - Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, -10.0f); - this->behaviorInfo.unk4C = 0; - this->actionFunc = func_80B4CB0C; -} - -void func_80B4CB0C(EnInvadepoh* this, PlayState* play) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = GET_PLAYER(play); - s16 temp_v1; - s16 diff; - - Math_StepToS(&this->behaviorInfo.unk4C, 3000, 500); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, this->behaviorInfo.unk4C, 40); - temp_v1 = (Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos)); - temp_v1 *= 0.85f; - temp_v1 -= this->actor.shape.rot.x; - substruct->unk26.x = CLAMP(temp_v1, -0xBB8, 0xBB8); - diff = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); - temp_v1 = diff; - temp_v1 *= 0.7f; - substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (Actor_TextboxIsClosing(&this->actor, play)) { - func_80B4C6C8(this); - } -} - -void func_80B4CC70(EnInvadepoh* this) { - this->behaviorInfo.unk30 = 0.08f; - this->behaviorInfo.unk2C = 2000; - Animation_MorphToLoop(&this->skelAnime, &gRomaniIdleAnim, -10.0f); - this->behaviorInfo.unk4C = 0; - this->actionFunc = func_80B4CCCC; -} - -void func_80B4CCCC(EnInvadepoh* this, PlayState* play) { - AlienBehaviorInfo* substruct = &this->behaviorInfo; - Player* player = GET_PLAYER(play); - s16 temp_v1; - s16 diff; - - Math_StepToS(&this->behaviorInfo.unk4C, 2000, 200); - Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 6, this->behaviorInfo.unk4C, 40); - temp_v1 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.focus.pos); - temp_v1 *= 0.85f; - temp_v1 -= this->actor.shape.rot.x; - substruct->unk26.x = CLAMP(temp_v1, -0xBB8, 0xBB8); - diff = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); - temp_v1 = diff; - temp_v1 *= 0.7f; - substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); - if (D_80B503F8 == NULL) { - func_80B4C6C8(this); - } else if ((D_80B503F8 != NULL) && (D_80B503F8->actionFunc != func_80B4C058)) { - func_80B4C6C8(this); - } -} - -void func_80B4CE54(Actor* thisx, PlayState* play) { - s32 pad[2]; - EnInvadepoh* this = THIS; - s32 sp38; - - if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { - sp38 = gSaveContext.save.time; - - this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(play, &this->actor); - func_80B44F58(); - SkelAnime_InitFlex(play, &this->skelAnime, &gRomaniSkel, &gRomaniWalkAnim, this->jointTable, this->morphTable, - ROMANI_LIMB_MAX); - func_80B45C04(&this->behaviorInfo, D_80B4EA90, 1, D_80B4EB00, 3, &gZeroVec3s, 100, 0.03f, 0.3f, 0.03f); - func_80B446D0(this, play); - this->actor.world.rot.y = this->actor.shape.rot.y; - func_80B44700(this); - func_80B44EFC(this, play); - func_80B43F0C(this); - func_80B4516C(this); - this->actor.textId = 0x33CE; - if ((sp38 >= CLOCK_TIME(6, 0)) && (sp38 < CLOCK_TIME(20, 0))) { - this->actor.update = func_80B4CFFC; - this->actor.draw = NULL; - } else if ((sp38 >= 0xD555) && (sp38 < 0xD7E1)) { - this->actor.update = func_80B4D054; - this->actor.draw = func_80B4E324; - func_80B4C6C8(this); - } else { - Actor_Kill(&this->actor); - } - } -} - -void func_80B4CFFC(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - if ((gSaveContext.save.time >= CLOCK_TIME(20, 0)) && (gSaveContext.save.time < 0xD7E1)) { - this->actor.update = func_80B4D054; - this->actor.draw = func_80B4E324; - func_80B4C6C8(this); - } -} - -void func_80B4D054(Actor* thisx, PlayState* play) { - s32 pad; - EnInvadepoh* this = THIS; - s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); - s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &play->state); - - if (isTalking) { - func_80151BB4(play, 5); - func_80B4CAB0(this); - } - this->actionFunc(this, play); - if (sp2C && this->actor.update != NULL) { - SkelAnime_Update(&this->skelAnime); - func_80B45CE0(&this->behaviorInfo); - if ((this->actionFunc != func_80B4CB0C) && !isTalking && this->actor.isTargeted) { - func_800B8614(thisx, play, 350.0f); - } - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - } -} - -void func_80B4D15C(EnInvadepoh* this) { - s32 pad; - s32 temp_v1 = this->actor.params & 7; - unkstruct80B4EE0C* temp_v0; - - Animation_PlayLoop(&this->skelAnime, &gAlienHoldingCowAnim); - this->skelAnime.curFrame = ((this->actor.params & 7) * this->skelAnime.endFrame) * 0.25f; - this->alienAlpha = 255; - this->actor.draw = func_80B4DB14; - this->drawAlien = true; - this->drawAlienDeathEffect = false; - this->alienBeamAlpha = 255; - temp_v0 = &D_80B4EE0C[temp_v1]; - this->velocityStep = temp_v0->unk00; - this->unk304 = temp_v1 * 0x5555; - this->actor.world.pos.x = this->actor.home.pos.x + (Math_SinS(this->unk304) * 80.0f); - this->actor.world.pos.y = this->actor.home.pos.y; - this->actor.world.pos.z = this->actor.home.pos.z + (Math_CosS(this->unk304) * 80.0f); - this->actor.shape.rot.y = this->unk304 + 0x4000; - this->behaviorInfo.unk4C = temp_v0->unk04; - this->behaviorInfo.unk4E = temp_v0->unk06; - this->actionFunc = func_80B4D290; - this->actor.velocity.y = 0.0f; -} - -void func_80B4D290(EnInvadepoh* this, PlayState* play) { - Actor* temp_v1; - f32 sp28; - - if (D_80B503F0 == NULL) { - Actor_Kill(&this->actor); - return; - } - - Math_StepToF(&this->actor.velocity.y, 15.0f, this->velocityStep); - sp28 = Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 850.0f, 0.2f, this->actor.velocity.y, - 0.01f); - this->unk304 += 0x2BC; - this->actor.world.pos.x = this->actor.home.pos.x + Math_SinS(this->unk304) * 80.0f; - this->actor.world.pos.z = this->actor.home.pos.z + Math_CosS(this->unk304) * 80.0f; - this->behaviorInfo.unk4C += this->behaviorInfo.unk4E; - this->actor.shape.rot.y += this->behaviorInfo.unk4C; - temp_v1 = this->actor.child; - - if (this->actor.child != NULL) { - this->actor.child->world.pos.x = this->actor.world.pos.x; - temp_v1->world.pos.y = this->actor.world.pos.y - 38.0f; - temp_v1->world.pos.z = this->actor.world.pos.z; - temp_v1->shape.rot.y = this->actor.shape.rot.y; - } - - if (sp28 < 5.0f) { - Actor_Kill(&this->actor); - } -} - -void func_80B4D3E4(EnInvadepoh* this) { - Animation_PlayLoop(&this->skelAnime, &gAlienHoldingCowAnim); - this->skelAnime.curFrame = (this->actor.params & 7) * this->skelAnime.endFrame * 0.25f; - this->alienAlpha = 255; - this->actor.draw = NULL; - this->drawAlien = true; - this->drawAlienDeathEffect = false; - this->alienBeamAlpha = 255; - this->unk306 = 400; - this->unk304 = 0; - this->actionTimer = 200; - this->actor.velocity.y = 0.0f; - this->actionFunc = func_80B4D480; -} - -void func_80B4D480(EnInvadepoh* this, PlayState* play) { - f32 target; - s32 pad2; - s32 sp2C = false; - f32 new_var3; - - if (this->actionTimer > 0) { - this->actionTimer--; - } - - if (this->actionTimer > 160) { - this->actor.draw = NULL; - } else { - this->actor.draw = func_80B4DB14; - if (1) {} - if ((this->actionTimer < 105) && (this->actionTimer >= 100)) { - this->actor.gravity = -1.0f; - Math_SmoothStepToS(&this->actor.shape.rot.x, 0x2000, 8, 0x320, 0x28); - } else { - this->actor.gravity = 0.7f; - Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 8, 0x320, 0x28); - } - - this->actor.velocity.y += this->actor.gravity; - this->actor.velocity.y *= 0.92f; - if (this->actionTimer > 80) { - this->actor.world.pos.y += this->actor.velocity.y; - } else { - target = (this->actor.home.pos.y + 850.0f); - sp2C = Math_StepToF(&this->actor.world.pos.y, target, fabsf(this->actor.velocity.y)); - } - - new_var3 = (this->unk304 * -0.06f + this->unk306); - new_var3 *= 0.98f; - this->unk306 = new_var3; - this->actor.shape.rot.y += this->unk306; - - if (this->actor.child != NULL) { - Actor* temp_v1 = this->actor.child; - - temp_v1->world.pos.x = this->actor.world.pos.x; - temp_v1->world.pos.y = this->actor.world.pos.y - 30.0f; - temp_v1->world.pos.z = this->actor.world.pos.z; - temp_v1->shape.rot.y = this->actor.shape.rot.y; - } - } - - if ((this->actionTimer <= 0) || sp2C) { - Actor_Kill(&this->actor); - } -} - -void func_80B4D670(Actor* thisx, PlayState* play) { - s32 pad; - EnInvadepoh* this = THIS; - s32 invadepohType; - - if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { - invadepohType = this->actor.params & 7; - this->actor.objBankIndex = this->bankIndex; - Actor_SetObjectDependency(play, &this->actor); - func_80B45080(); - this->actor.update = func_80B4D760; - SkelAnime_InitFlex(play, &this->skelAnime, &gAlienSkel, &gAlienHoldingCowAnim, this->jointTable, - this->morphTable, ALIEN_LIMB_MAX); - if (invadepohType < 3) { - func_80B453F4(this, play, invadepohType); - func_80B4D15C(this); - } else { - func_80B45460(this, play); - func_80B4D3E4(this); - } - } -} - -void func_80B4D760(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - this->actionFunc(this, play); - if (this->actor.update != NULL) { - SkelAnime_Update(&this->skelAnime); - func_800B9010(&this->actor, NA_SE_EN_FOLLOWERS_BEAM_PRE - SFX_FLAG); - } -} - -void func_80B4D7B8(PlayState* play) { - u32 temp_s5; - u32 temp_s6; - unkStruct80B50350* phi_s2; - s32 i; - - OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(play->state.gfxCtx); - for (phi_s2 = D_80B50350, i = 0; i < 10; phi_s2++, i++) { - if (phi_s2->unk1 > 0) { - temp_s5 = (play->gameplayFrames + ((0x10 * i) & 0xFF)) & 0x7F; - temp_s6 = (u8)(play->gameplayFrames * -0xF); - Matrix_Translate(phi_s2->unk4.x, phi_s2->unk4.y, phi_s2->unk4.z, MTXMODE_NEW); - Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, phi_s2->unk2); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 50, 0, 0); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, 0, temp_s5, 0, 0x20, 0x40, 1, 0, temp_s6, 0x20, 0x40)); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, &gameplay_keep_DL_02E510); - } - } - CLOSE_DISPS(play->state.gfxCtx); -} - -void func_80B4D9B4(Actor* thisx, PlayState* play) { - func_80B4D7B8(play); -} - -s32 func_80B4D9D8(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { - return false; -} - -void func_80B4D9F4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { - EnInvadepoh* this = THIS; - - if ((limbIndex == 12) && (this->alienBeamAlpha != 0)) { - Matrix_Push(); - Matrix_RotateZS(-0x53ED, MTXMODE_APPLY); - Matrix_RotateYS(-0x3830, MTXMODE_APPLY); - Matrix_Scale(1.0f, 1.0f, 1.5f, MTXMODE_APPLY); - Matrix_Get(&D_80B502A0); - Matrix_Pop(); - } else if ((limbIndex == 13) && (this->alienBeamAlpha != 0)) { - Matrix_Push(); - Matrix_RotateZS(-0x53ED, MTXMODE_APPLY); - Matrix_RotateYS(-0x47D0, MTXMODE_APPLY); - Matrix_Scale(1.0f, 1.0f, 1.5f, MTXMODE_APPLY); - Matrix_Get(&D_80B502E0); - Matrix_Pop(); - } - if (limbIndex == 11) { - Matrix_MultVec3f(&D_80B4EE24, &this->actor.focus.pos); - } -} - -void func_80B4DB14(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - Gfx* gfx; - GraphicsContext* spCC = play->state.gfxCtx; - - OPEN_DISPS(spCC); - func_8012C2DC(spCC); - Matrix_Push(); - if (this->drawAlien) { - Gfx* new_var6; - Gfx* spBC; - GraphicsContext* spB8; - - if (this->alienAlpha == 255) { - func_8012C28C(play->state.gfxCtx); - AnimatedMat_Draw(play, sAlienEmptyTexAnim); - Scene_SetRenderModeXlu(play, 0, 1); - gDPSetEnvColor(spCC->polyOpa.p++, 0, 0, 0, 255); - spCC->polyOpa.p = SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, func_80B4D9D8, func_80B4D9F4, &this->actor, - spCC->polyOpa.p); - } else { - AnimatedMat_Draw(play, sAlienEmptyTexAnim); - Scene_SetRenderModeXlu(play, 1, 2); - gDPSetEnvColor(spCC->polyXlu.p++, 0, 0, 0, this->alienAlpha); - spCC->polyXlu.p = SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, func_80B4D9D8, func_80B4D9F4, &this->actor, - spCC->polyXlu.p); - } - - if (this->alienBeamAlpha != 0) { - AnimatedMat_Draw(play, sAlienEyeBeamTexAnim); - spB8 = play->state.gfxCtx; - gfx = spBC = spB8->polyXlu.p; - gDPPipeSync(spBC++); - gDPSetPrimColor(spBC++, 0, 255, 240, 180, 100, 60); - gDPSetEnvColor(spBC++, 255, 255, 255, this->alienBeamAlpha * (150.0f / 255.0f)); - Matrix_Mult(&D_80B502A0, MTXMODE_NEW); - gSPMatrix(spBC++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(spBC++, gAlienEyeBeamDL); - Matrix_Mult(&D_80B502E0, MTXMODE_NEW); - gSPMatrix(spBC++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(spBC++, gAlienEyeBeamDL); - spB8->polyXlu.p = spBC; - } - } - - if (this->drawAlienDeathEffect) { - Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y + 68.0f, this->actor.world.pos.z, - &this->actor.shape.rot); - Matrix_Scale(this->alienDeathEffectScale.x, this->alienDeathEffectScale.y, this->alienDeathEffectScale.z, - MTXMODE_APPLY); - gSPMatrix(spCC->polyXlu.p++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(spCC->polyXlu.p++, gAlienDeathFlashDL); - } - - if (this->drawAlien) { - Vec3f sp80; - Vec3f sp74; - s32 alpha2; - GraphicsContext* sp6C = play->state.gfxCtx; - u32 pad; - - gfx = sp6C->polyXlu.p; - gfx = func_8012C868(gfx); - gDPSetDither(gfx++, G_CD_NOISE); - gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, - 0); - Matrix_Mult(&play->billboardMtxF, MTXMODE_NEW); - Matrix_MultVecZ(60.0f, &sp80); - sp74.x = thisx->world.pos.x + sp80.x; - sp74.y = thisx->world.pos.y + sp80.y + 68.0f; - sp74.z = thisx->world.pos.z + sp80.z; - Matrix_Translate(sp74.x, sp74.y, sp74.z, MTXMODE_NEW); - Matrix_Scale(0.25f, 0.25f, 0.25f, MTXMODE_APPLY); - alpha2 = this->alienAlpha * (100.0f / 255.0f); - gSPDisplayList(gfx++, gameplay_keep_DL_029CB0); - gDPSetPrimColor(gfx++, 0, 0, 240, 180, 100, alpha2); - gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, gameplay_keep_DL_029CF0); - sp6C->polyXlu.p = gfx; - if ((this->alienAlpha > 128) && func_80B456A8(play, &sp74)) { - func_800F9824(play, &play->envCtx, &play->view, play->state.gfxCtx, sp74, 10.0f, 9.0f, 0, 0); - } - } - - Matrix_Pop(); - CLOSE_DISPS(spCC); -} - -s32 func_80B4E120(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { - if (limbIndex == 5) { - EnInvadepoh* this = THIS; - rot->x -= this->actor.shape.rot.x; - } - return false; -} - -void func_80B4E158(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - func_8012C5B0(play->state.gfxCtx); - SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - func_80B4E120, NULL, &this->actor); -} - -void func_80B4E1B0(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - func_8012C5B0(play->state.gfxCtx); - SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, - NULL, &this->actor); -} - -s32 func_80B4E200(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { - if (limbIndex == ROMANI_LIMB_HEAD) { - EnInvadepoh* this = THIS; // both of these needed to match - - rot->x += this->behaviorInfo.unk20.y; - rot->y += this->behaviorInfo.unk20.z; - rot->z += this->behaviorInfo.unk20.x; - } else if (limbIndex == ROMANI_LIMB_TORSO) { - EnInvadepoh* this = THIS; // both of these needed to match - - rot->x += (s16)(this->behaviorInfo.unk34 * this->behaviorInfo.unk20.y); - rot->z += this->behaviorInfo.unk40; - } - return false; -} - -void func_80B4E2AC(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - EnInvadepoh* this = THIS; - - if (limbIndex == ROMANI_LIMB_LEFT_HAND) { - OPEN_DISPS(play->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, gRomaniBowDL); - CLOSE_DISPS(play->state.gfxCtx); - } else if (limbIndex == ROMANI_LIMB_HEAD) { - Matrix_MultVec3f(&D_80B4EE30, &this->actor.focus.pos); - } -} - -void func_80B4E324(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x09, sRomaniMouthTextures[this->behaviorInfo.unk10.unkF]); - gSPSegment(POLY_OPA_DISP++, 0x08, sRomaniEyeTextures[this->behaviorInfo.unk0.unkF]); - SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - func_80B4E200, func_80B4E2AC, &this->actor); - CLOSE_DISPS(play->state.gfxCtx); -} - -void func_80B4E3F0(Actor* thisx, PlayState* play) { - s32 pad; - EnInvadepoh* this = THIS; - Vec3f sp5C; - - Matrix_Push(); - Matrix_Mult(&play->billboardMtxF, MTXMODE_NEW); - Matrix_MultVecZ(200.0f, &sp5C); - Matrix_Pop(); - sp5C.x += thisx->world.pos.x; - sp5C.y += thisx->world.pos.y; - sp5C.z += thisx->world.pos.z; - EnInvadepoh_SetSysMatrix(&sp5C); - Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_RotateZS(this->unk304, MTXMODE_APPLY); - OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0xFF, 0x80, 255, 255, 0, 180); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 50, 0, 0); - gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); - if (func_80B456A8(play, &sp5C)) { - func_800F9824(play, &play->envCtx, &play->view, play->state.gfxCtx, sp5C, 20.0f, 9.0f, 0, 0); - } - - CLOSE_DISPS(play->state.gfxCtx); -} - -s32 func_80B4E5B0(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { - if ((limbIndex == DOG_LIMB_HEAD) || (limbIndex == DOG_LIMB_RIGHT_FACE_HAIR) || - (limbIndex == DOG_LIMB_LEFT_FACE_HAIR)) { - EnInvadepoh* this = THIS; - - rot->x += this->behaviorInfo.unk20.x; - rot->y += this->behaviorInfo.unk20.y; - rot->z += this->behaviorInfo.unk20.z; - } - - return false; -} - -void func_80B4E61C(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - EnInvadepoh* this = THIS; - - if (limbIndex == DOG_LIMB_HEAD) { - Matrix_MultVecY(20.0f, &this->actor.focus.pos); - } -} - -void func_80B4E660(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(play->state.gfxCtx); - gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); - SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - func_80B4E5B0, func_80B4E61C, &this->actor); - CLOSE_DISPS(play->state.gfxCtx); -} - -s32 func_80B4E6E4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { - if (limbIndex == 9) { - EnInvadepoh* this = THIS; // both of these needed to match - - rot->x += this->behaviorInfo.unk20.y; - rot->y += this->behaviorInfo.unk20.z; - rot->z += this->behaviorInfo.unk20.x; - } else if (limbIndex == 2) { - EnInvadepoh* this = THIS; // both of these needed to match - - rot->x += (s16)(this->behaviorInfo.unk34 * this->behaviorInfo.unk20.y); - } - return false; -} - -void func_80B4E784(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - EnInvadepoh* this = THIS; - - if (limbIndex == 9) { - Matrix_MultZero(&this->actor.focus.pos); - } -} - -void func_80B4E7BC(Actor* thisx, PlayState* play) { - EnInvadepoh* this = THIS; - - OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x09, sCremiaMouthTextures[this->behaviorInfo.unk10.unkF]); - gSPSegment(POLY_OPA_DISP++, 0x08, sCremiaEyeTextures[this->behaviorInfo.unk0.unkF]); - SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - func_80B4E6E4, func_80B4E784, &this->actor); - CLOSE_DISPS(play->state.gfxCtx); -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B45980.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B459E8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B45A4C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B45A94.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B45B1C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B45BB8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B45C04.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B45CE0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B45EC8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46118.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46184.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B461DC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4627C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46414.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46520.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B465CC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46644.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B468B4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B469C4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46A80.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/EnInvadepoh_Init.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46BB0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46BC0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46C08.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46C34.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46C50.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46C7C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46C94.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46CC0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46CF4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46D28.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/EnInvadepoh_Destroy.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46DA8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46DC8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46E20.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46E44.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46EC0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46EE8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46F88.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B46FA8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47064.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47084.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B470E0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47108.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B471C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B471E0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47248.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47268.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47278.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47298.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47304.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47324.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/EnInvadepoh_Update.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47380.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B473E4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47478.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B474DC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47568.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47600.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4770C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B477B4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47830.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B478F4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47938.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B479E8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47BAC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47D30.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B47FA8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B48060.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B481C4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4827C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B482D4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B48324.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B48374.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B483CC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4843C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B484EC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B48588.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B48610.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B48620.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4873C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B487B4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B48848.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B48948.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B48AD4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B48DE4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B48E4C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B48FB0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B490F0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B491EC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B49228.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B492FC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4934C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B49404.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B49454.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B49628.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B49670.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B497A4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B497EC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B49904.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4994C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B499BC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B49A00.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B49B1C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B49BD0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B49C38.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B49DA0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B49DFC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B49F88.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4A168.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4A1B8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4A2C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4A350.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4A570.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4A5E4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4A614.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4A67C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4A7C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4A81C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4A9C8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4AB8C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4ABDC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4ACDC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4ACF0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4AD3C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4AD60.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4ADB8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4ADCC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4AEC0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4AEDC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4AF80.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4AF94.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4B024.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4B048.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4B0C4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4B218.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4B3DC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4B430.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4B484.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4B510.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4B564.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4B724.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4B768.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4B820.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4B864.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4B8BC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4BA30.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4BA84.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4BBE0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4BC4C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4BFFC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4C058.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4C1BC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4C218.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4C3A0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4C568.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4C5C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4C6C8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4C730.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4CAB0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4CB0C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4CC70.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4CCCC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4CE54.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4CFFC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4D054.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4D15C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4D290.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4D3E4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4D480.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4D670.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4D760.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4D7B8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4D9B4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4D9D8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4D9F4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4DB14.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4E120.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4E158.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4E1B0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4E200.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4E2AC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4E324.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4E3F0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4E5B0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4E61C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4E660.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4E6E4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4E784.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Invadepoh/func_80B4E7BC.s") diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h index 061d9c326..54253ad03 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.h @@ -5,151 +5,9 @@ struct EnInvadepoh; -typedef void (*EnInvadepohInitFunc)(struct EnInvadepoh*, PlayState*); -typedef void (*EnInvadepohDestroyFunc)(struct EnInvadepoh*, PlayState*); -typedef void (*EnInvadepohActionFunc)(struct EnInvadepoh*, PlayState*); - -#define INVADEPOH_TYPE(thisx) (((thisx)->params >> 4) & 0xF) - -typedef enum{ - /* 0 */ TYPE_UNK0, - /* 1 */ TYPE_ALIEN, - /* 2 */ TYPE_PARENT_COW, - /* 3 */ TYPE_CHILD_COW, - /* 4 */ TYPE_ROMANI, - /* 5 */ TYPE_ROMANI1, - /* 6 */ TYPE_UNK6, - /* 7 */ TYPE_ROMANI2, - /* 8 */ TYPE_ROMANI3, - /* 9 */ TYPE_ROMANI4, - /* 10 */ TYPE_DOG, - /* 11 */ TYPE_CREMIA, - /* 12 */ TYPE_ROMANI5, - /* 13 */ TYPE_ALIEN_CARRYING_COW -} EnInvadepohType; - -typedef enum { - /* -1 */ DIRECTION_BACKWARD = -1, - /* 1 */ DIRECTION_FORWARD = 1, -} EnInvadepohDirection; - -typedef struct unkStruct80B50350 { - /* 0x0 */ s8 unk0; - /* 0x1 */ s8 unk1; - /* 0x2 */ u8 unk2; - /* 0x4 */ Vec3f unk4; -} unkStruct80B50350; // size = 0x10; - -typedef struct { - /* 0x0 */ s8* unk00; - /* 0x4 */ s8 unk04; -} unkstructInvadepoh0; // size = 0x8 - -typedef struct { - /* 0x0 */ s8 unk00; - /* 0x4 */ f32 unk04; -} unkstructInvadepoh1; // size = 0x8 - -typedef struct { - /* 0x0 */ s8 unk00; - /* 0x4 */ unkstructInvadepoh0* unk04; -} unkstructInvadepoh2; // size = 0x8 - -typedef struct { - /* 0x0 */ s8 unk0; - /* 0x4 */ unkstructInvadepoh0* unk4; - /* 0x8 */ s8 unk8; - /* 0xC */ unkstructInvadepoh1* unkC; -} unkstructInvadepoh3; // size = 0x10 - -typedef struct { - /* 0x00 */ s8 unk00; - /* 0x04 */ unkstructInvadepoh0* unk04; - /* 0x08 */ s8 unk08; - /* 0x0C */ unkstructInvadepoh1* unk0C; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; -} unkstructInvadepoh4; // size = 0x14 - -typedef struct { - /* 0x0 */ f32 unk00; - /* 0x4 */ s16 unk04; - /* 0x6 */ s16 unk06; -} unkstruct80B4EE0C; // size = 0x8 - -typedef struct EnInvadePohStruct { - /* 0x0 */ unkstructInvadepoh4* unk0; - /* 0x4 */ s8 unk4; - /* 0x8 */ unkstructInvadepoh4* unk8; - /* 0xC */ s16 unkC; - /* 0xE */ s8 unkE; - /* 0xF */ s8 unkF; -} EnInvadePohStruct; // size = 0x10; - -typedef struct AlienBehaviorInfo { - /* 0x00 */ EnInvadePohStruct unk0; - /* 0x10 */ EnInvadePohStruct unk10; - /* 0x20 */ Vec3s unk20; - /* 0x26 */ Vec3s unk26; - /* 0x2C */ s16 unk2C; - /* 0x2E */ u16 unk2E; - /* 0x30 */ f32 unk30; - /* 0x34 */ f32 unk34; - /* 0x38 */ f32 unk38; - /* 0x3C */ f32 unk3C; - /* 0x40 */ s16 unk40; - /* 0x42 */ s16 unk42; - /* 0x44 */ f32 unk44; - /* 0x48 */ s16 unk48; - /* 0x4A */ UNK_TYPE1 unk4A[0x2]; - /* 0x4C */ s16 unk4C; - /* 0x4E */ s16 unk4E; -} AlienBehaviorInfo; // size = 0x50 - typedef struct EnInvadepoh { /* 0x000 */ Actor actor; - /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[23]; - /* 0x212 */ Vec3s morphTable[23]; - /* 0x29C */ s8 animPlayFlag; - /* 0x2A0 */ ColliderCylinder collider; - /* 0x2EC */ EnInvadepohActionFunc actionFunc; - /* 0x2F0 */ s16 actionTimer; - /* 0x2F2 */ s16 counter; // general counter variable - /* 0x2F4 */ s8 bankIndex; - /* 0x2F8 */ f32 xzPosAdjFactor; - /* 0x2FC */ UNK_TYPE unk2FC; // unused - /* 0x300 */ f32 velocityStep; - /* 0x304 */ s16 unk304; // angle of some sort - /* 0x306 */ s16 unk306; - /* 0x308 */ s8 endPoint; - /* 0x309 */ s8 pathIndex; - /* 0x30A */ s8 direction; // only ever 1 or -1 - /* 0x30C */ Vec3s* pathPoints; - /* 0x310 */ f32 pathTotalDist; - /* 0x314 */ Vec3f curPathPos; - /* 0x320 */ f32 clockTime; - /* 0x324 */ AlienBehaviorInfo behaviorInfo; - /* 0x374 */ s8 rand; - /* 0x376 */ u16 textId; - /* 0x378 */ s8 unk378; - /* 0x379 */ s8 unk379; - /* 0x37C */ f32 unk37C[3]; - /* 0x388 */ s8 unk388; // unused - /* 0x389 */ u8 alienAlpha; - /* 0x38A */ s8 unk38A; // bool - /* 0x38B */ s8 drawAlien; - /* 0x38C */ s8 drawAlienDeathEffect; - /* 0x38D */ u8 alienBeamAlpha; - /* 0x390 */ Vec3f alienDeathEffectScale; - /* 0x39C */ f32 scaleFactorAdj; - /* 0x3A0 */ f32 scaleTarget; - /* 0x3A4 */ f32 scaleStep; - /* 0x3A8 */ s16 scaleAdjAngle; - /* 0x3AA */ s16 unk3AA; - /* 0x3AC */ s8 unk3AC; // index for D_80B4EDD0 - /* 0x3AD */ UNK_TYPE1 unk3AD[0xF]; - /* 0x3BC */ s8 unk3BC; + /* 0x144 */ char unk_144[0x27C]; } EnInvadepoh; // size = 0x3C0 #endif // Z_EN_INVADEPOH_H 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 70f77b18a..d2aceba29 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 @@ -55,12 +55,12 @@ static ColliderCylinderInit sCylinderInit = { void func_80C258A0(EnInvisibleRuppe* this, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } void func_80C2590C(EnInvisibleRuppe* this, PlayState* play) { if (this->collider.base.ocFlags1 & OC1_HIT) { - switch (INVISIBLERUPPE_GET_3(this)) { + switch (INVISIBLERUPPE_GET_3(&this->actor)) { case 0: play_sound(NA_SE_SY_GET_RUPY); Item_DropCollectible(play, &this->actor.world.pos, 0x8000 | ITEM00_RUPEE_GREEN); @@ -93,7 +93,7 @@ void EnInvisibleRuppe_Init(Actor* thisx, PlayState* play) { s32 pad; EnInvisibleRuppe* this = THIS; - this->unk_190 = INVISIBLERUPPE_GET_1FC(this); + this->unk_190 = INVISIBLERUPPE_GET_1FC(&this->actor); if (this->unk_190 == 0x7F) { this->unk_190 = -1; diff --git a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h index 5b6f6ca64..d703a3511 100644 --- a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h +++ b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.h @@ -7,8 +7,8 @@ struct EnInvisibleRuppe; typedef void (*EnInvisibleRuppeActionFunc)(struct EnInvisibleRuppe*, PlayState*); -#define INVISIBLERUPPE_GET_3(thisx) ((thisx)->actor.params & 3) -#define INVISIBLERUPPE_GET_1FC(thisx) (((thisx)->actor.params & 0x1FC) >> 2) +#define INVISIBLERUPPE_GET_3(thisx) ((thisx)->params & 3) +#define INVISIBLERUPPE_GET_1FC(thisx) (((thisx)->params & 0x1FC) >> 2) typedef struct EnInvisibleRuppe { /* 0x000 */ Actor actor; 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 f911bc4f4..22ef1282a 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -191,11 +191,11 @@ void func_8095D804(Actor* thisx, PlayState* play) { spB8.z = ((Rand_ZeroOne() - 0.5f) * 8.0f) + this->actor.world.pos.z; Math_Vec3f_Copy(&spC4, &this->actor.velocity); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { spC4.x *= 0.6f; spC4.y *= -0.3f; spC4.z *= 0.6f; - } else if (this->actor.bgCheckFlags & 8) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { spC4.x *= -0.5f; spC4.y *= 0.5f; spC4.z *= -0.5f; @@ -230,11 +230,11 @@ void func_8095DABC(Actor* thisx, PlayState* play) { Math_Vec3f_Copy(&spD8, &this->actor.velocity); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { spD8.x *= 0.9f; spD8.y *= -0.8f; spD8.z *= 0.9f; - } else if (this->actor.bgCheckFlags & 8) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { spD8.x *= -0.9f; spD8.y *= 0.8f; spD8.z *= -0.9f; @@ -265,11 +265,11 @@ void func_8095DDA8(EnIshi* this, PlayState* play) { Vec3f sp2C; Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { 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) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { sp2C.x -= 2.0f * this->actor.velocity.x; sp2C.y += 2.0f * this->actor.velocity.y; sp2C.z -= 2.0f * this->actor.velocity.z; @@ -281,11 +281,11 @@ void func_8095DE9C(EnIshi* this, PlayState* play) { Vec3f sp2C; Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { 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) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { sp2C.x -= 2.0f * this->actor.velocity.x; sp2C.y += 2.0f * this->actor.velocity.y; sp2C.z -= 2.0f * this->actor.velocity.z; @@ -354,7 +354,7 @@ void func_8095E204(EnIshi* this, PlayState* play) { for (i = 0; i < 3; i++) { if (Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, 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) { + this->actor.csId, this->actor.halfDaysBits, NULL) == NULL) { break; } } @@ -386,7 +386,7 @@ void EnIshi_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain[sp34]); - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { this->actor.uncullZoneForward += 1000.0f; } @@ -513,9 +513,9 @@ void func_8095E660(EnIshi* this, PlayState* play) { if ((this->actor.xzDistToPlayer < 90.0f) && (sp30 == 0)) { if (sp38 == 1) { - Actor_PickUp(&this->actor, play, GI_NONE, 80.0f, 20.0f); + Actor_OfferGetItem(&this->actor, play, GI_NONE, 80.0f, 20.0f); } else { - Actor_PickUp(&this->actor, play, GI_NONE, 50.0f, 10.0f); + Actor_OfferGetItem(&this->actor, play, GI_NONE, 50.0f, 10.0f); } } } @@ -541,7 +541,9 @@ void func_8095E95C(EnIshi* this, PlayState* play) { func_8095E14C(this); func_8095E180(&this->actor.velocity, D_8095F6C8[ENISHI_GET_1(&this->actor)]); Actor_UpdatePos(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + Actor_UpdateBgCheckInfo(play, &this->actor, 7.5f, 35.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40 | + UPDBGCHECKINFO_FLAG_80); } else { sp30.x = this->actor.world.pos.x; sp30.y = this->actor.world.pos.y + 20.0f; @@ -554,8 +556,8 @@ void func_8095E95C(EnIshi* this, PlayState* play) { 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; + this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speed; + this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speed; if (!ENISHI_GET_1(&this->actor)) { sp24 = Rand_ZeroOne() - 0.9f; D_8095F690 = sp24 * 11000.0f; @@ -585,21 +587,21 @@ void func_8095EBDC(EnIshi* this, PlayState* play) { this->unk_194--; - if ((this->actor.bgCheckFlags & 9) || temp_v0 || (this->unk_194 <= 0)) { + if ((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_WALL)) || temp_v0 || (this->unk_194 <= 0)) { func_8095DF90(this, play); D_8095F6D8[sp70](&this->actor, play); - if (!(this->actor.bgCheckFlags & 0x20)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, D_8095F6D4[sp70], D_8095F6D0[sp70]); D_8095F6E0[sp70](this, play); } if (sp70 == 1) { - s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 17232); - Quake_SetQuakeValues(quakeIndex, 3, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 7); + Quake_SetPerturbations(quakeIndex, 3, 0, 0, 0); + Quake_SetDuration(quakeIndex, 7); Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150); } @@ -608,7 +610,7 @@ void func_8095EBDC(EnIshi* this, PlayState* play) { return; } - if (this->actor.bgCheckFlags & 0x40) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { if (sp70 == 0) { sp58.x = this->actor.world.pos.x; sp58.y = this->actor.world.pos.y + this->actor.depthInWater; @@ -639,7 +641,7 @@ void func_8095EBDC(EnIshi* this, PlayState* play) { D_8095F694 >>= 2; SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); - this->actor.bgCheckFlags &= ~0x40; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER_TOUCH; } Math_StepToF(&this->actor.shape.yOffset, 0.0f, 2.0f); @@ -648,7 +650,9 @@ void func_8095EBDC(EnIshi* this, PlayState* play) { Actor_UpdatePos(&this->actor); this->actor.shape.rot.x += D_8095F690; this->actor.shape.rot.y += D_8095F694; - Actor_UpdateBgCheckInfo(play, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + Actor_UpdateBgCheckInfo(play, &this->actor, 7.5f, 35.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40 | + UPDBGCHECKINFO_FLAG_80); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); @@ -656,7 +660,7 @@ void func_8095EBDC(EnIshi* this, PlayState* play) { void func_8095F060(EnIshi* this) { this->actor.flags |= ACTOR_FLAG_10; - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); this->actionFunc = func_8095F0A4; } @@ -664,15 +668,15 @@ void func_8095F0A4(EnIshi* this, PlayState* play) { s32 pad; s32 sp28 = ENISHI_GET_1(&this->actor); - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, D_8095F6D4[sp28], D_8095F6D0[sp28]); D_8095F6D8[sp28](&this->actor, play); D_8095F6E0[sp28](this, play); this->actor.draw = NULL; func_8095F180(this); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -681,9 +685,9 @@ void func_8095F180(EnIshi* this) { } void func_8095F194(EnIshi* this, PlayState* play) { - if (this->actor.cutscene < 0) { + if (this->actor.csId < 0) { Actor_Kill(&this->actor); - } else if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + } else if (CutsceneManager_GetCurrentCsId() != this->actor.csId) { Actor_Kill(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Ja/z_en_ja.c b/src/overlays/actors/ovl_En_Ja/z_en_ja.c index 39a28c4bd..1c65efed8 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -389,7 +389,7 @@ void EnJa_Update(Actor* thisx, PlayState* play) { if (this->unk_1D8.unk_00 != 2) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } func_80BC1984(this, play); } 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 03cc41f20..05855bb20 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 @@ -93,7 +93,7 @@ s32 EnJcMato_CheckForHit(EnJcMato* this, PlayState* play) { 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; - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); play->interfaceCtx.minigamePoints = 1; this->hitFlag = true; return 1; diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.c b/src/overlays/actors/ovl_En_Jg/z_en_jg.c index e7c2ad78d..451b9e553 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -194,7 +194,8 @@ void EnJg_UpdateCollision(EnJg* this, PlayState* play) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 30.0f, 30.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 30.0f, 30.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); } s16 EnJg_GetWalkingYRotation(Path* path, s32 pointIndex, Vec3f* pos, f32* distSQ) { @@ -214,7 +215,7 @@ s16 EnJg_GetWalkingYRotation(Path* path, s32 pointIndex, Vec3f* pos, f32* distSQ *distSQ = SQ(diffX) + SQ(diffZ); - return RADF_TO_BINANG(Math_Atan2F_XY(diffZ, diffX)); + return RAD_TO_BINANG(Math_Atan2F_XY(diffZ, diffX)); } s32 EnJg_ReachedPoint(EnJg* this, Path* path, s32 pointIndex) { @@ -241,7 +242,7 @@ s32 EnJg_ReachedPoint(EnJg* this, Path* path, s32 pointIndex) { diffZ = points[currentPoint + 1].z - points[currentPoint - 1].z; } - func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + func_8017B7F8(&point, RAD_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; @@ -250,32 +251,32 @@ s32 EnJg_ReachedPoint(EnJg* this, Path* path, s32 pointIndex) { return reached; } -s16 EnJg_GetCutsceneForTeachingLullabyIntro(EnJg* this) { +s16 EnJg_GetCsIdForTeachingLullabyIntro(EnJg* this) { s16 temp = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; if (temp > 0) { - return this->actor.cutscene; + return this->actor.csId; } - return ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + return CutsceneManager_GetAdditionalCsId(this->actor.csId); } void EnJg_SetupGoronShrineCheer(EnJg* this) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); if (this->focusedShrineGoronParam == 10) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { this->actionFunc = EnJg_GoronShrineTalk; } else { - this->cutscene = 0x7C; + this->csId = CS_ID_GLOBAL_TALK; } } else { - this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } } - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); this->actionFunc = EnJg_GoronShrineCheer; switch (this->textId) { @@ -373,7 +374,7 @@ void EnJg_GoronShrineTalk(EnJg* this, PlayState* play) { } void EnJg_GoronShrineCheer(EnJg* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { + if (CutsceneManager_IsNext(this->csId)) { switch (this->textId) { case 0xDD0: // The greatest Goron hero of all? case 0xDD2: // The immortal Goron? @@ -382,26 +383,26 @@ void EnJg_GoronShrineCheer(EnJg* this, PlayState* play) { case 0xDD6: // Darmani, greatest in the world! // Focus on a specifc Goron for these lines this->shrineGoron = EnJg_GetShrineGoronToFocusOn(play, this->focusedShrineGoronParam); - ActorCutscene_Start(this->cutscene, this->shrineGoron); + CutsceneManager_Start(this->csId, this->shrineGoron); Camera_SetTargetActor(play->cameraPtrs[CAM_ID_MAIN], this->shrineGoron); break; default: // Focus on the whole group for these lines - ActorCutscene_Start(this->cutscene, &this->actor); + CutsceneManager_Start(this->csId, &this->actor); Camera_SetTargetActor(play->cameraPtrs[CAM_ID_MAIN], this->shrineGoron); break; } this->actionFunc = EnJg_GoronShrineTalk; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { if (this->focusedShrineGoronParam == 10) { this->actionFunc = EnJg_GoronShrineTalk; } else { - ActorCutscene_Stop(0x7C); + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } } - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } @@ -434,7 +435,7 @@ void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, PlayState* play) { this->actionFunc = EnJg_Walk; } } else if (this->animIndex == EN_JG_ANIM_WALK) { - Math_ApproachF(&this->actor.speedXZ, 0.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 0.0f, 0.2f, 1.0f); EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, play); } } @@ -445,7 +446,7 @@ void EnJg_Walk(EnJg* this, PlayState* play) { if (this->path != NULL) { yRotation = EnJg_GetWalkingYRotation(this->path, this->currentPoint, &this->actor.world.pos, &distSQ); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { yRotation = this->actor.wallYaw; } @@ -459,10 +460,10 @@ void EnJg_Walk(EnJg* this, PlayState* play) { this->actionFunc = EnJg_AlternateTalkOrWalkInPlace; } else { this->currentPoint++; - Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 0.5f, 0.2f, 1.0f); } } else { - Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 0.5f, 0.2f, 1.0f); } } @@ -513,11 +514,11 @@ void EnJg_Talk(EnJg* this, PlayState* play) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; - this->cutscene = EnJg_GetCutsceneForTeachingLullabyIntro(this); - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + this->csId = EnJg_GetCsIdForTeachingLullabyIntro(this); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); this->actionFunc = EnJg_TeachLullabyIntro; } } else { @@ -608,27 +609,27 @@ void EnJg_EndFrozenInteraction(EnJg* this, PlayState* play) { } void EnJg_TeachLullabyIntro(EnJg* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_Start(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Start(this->csId, &this->actor); this->actionFunc = EnJg_LullabyIntroCutsceneAction; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } void EnJg_LullabyIntroCutsceneAction(EnJg* this, PlayState* play) { s32 pad; - if (Cutscene_CheckActorAction(play, 470)) { - s32 actionIndex = Cutscene_GetActorActionIndex(play, 470); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_470)) { + s32 cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_470); - if (this->csAction != play->csCtx.actorActions[actionIndex]->action) { - this->csAction = play->csCtx.actorActions[actionIndex]->action; + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; - switch (play->csCtx.actorActions[actionIndex]->action) { + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: this->cutsceneAnimIndex = EN_JG_ANIM_CUTSCENE_IDLE; if (this->drum != NULL) { @@ -687,7 +688,7 @@ void EnJg_LullabyIntroCutsceneAction(EnJg* this, PlayState* play) { this->drum = Actor_SpawnAsChildAndCutscene( &play->actorCtx, play, ACTOR_OBJ_JG_GAKKI, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, - this->actor.params, this->actor.cutscene, this->actor.unk20, NULL); + this->actor.params, this->actor.csId, this->actor.halfDaysBits, NULL); } if (this->cutsceneAnimIndex == EN_JG_ANIM_TAKING_OUT_DRUM) { @@ -698,7 +699,7 @@ void EnJg_LullabyIntroCutsceneAction(EnJg* this, PlayState* play) { } } } else { - this->csAction = 99; + this->cueId = 99; this->freezeTimer = 1000; SET_WEEKEVENTREG(WEEKEVENTREG_24_40); this->actionFunc = EnJg_Idle; @@ -757,10 +758,10 @@ s32 EnJg_GetNextTextId(EnJg* this) { case 0xDCF: // Spring has come thanks to you this->focusedShrineGoronParam = 3; - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); this->actionFunc = EnJg_GoronShrineCheer; return 0xDD0; // The greatest Goron hero of all? @@ -903,7 +904,7 @@ void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, PlayState* play if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->flags |= FLAG_LOOKING_AT_PLAYER; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->textId == 0xDAC) { this->action = EN_JG_ACTION_FIRST_THAW; @@ -948,7 +949,7 @@ void EnJg_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); if (!EN_JG_IS_IN_GORON_SHRINE(thisx)) { - if ((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 7) && (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 7) && (play->csCtx.scriptIndex == 0)) { // This is the elder that appears in the cutscene for learning the full Goron Lullaby. this->animIndex = EN_JG_ANIM_IDLE; this->action = EN_JG_ACTION_LULLABY_INTRO_CS; @@ -967,7 +968,7 @@ void EnJg_Init(Actor* thisx, PlayState* play) { } else { // This is the elder that appears in Goron Shrine in spring. this->animIndex = EN_JG_ANIM_IDLE; - this->cutscene = this->actor.cutscene; + this->csId = this->actor.csId; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnJg_GoronShrineIdle; } diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.h b/src/overlays/actors/ovl_En_Jg/z_en_jg.h index 757a8bd86..ad8eee0a8 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.h +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.h @@ -32,9 +32,9 @@ typedef struct EnJg { /* 0x3A4 */ Vec3f breathPos; /* 0x3B0 */ Vec3f breathVelocity; /* 0x3BC */ Vec3f breathAccel; - /* 0x3C8 */ s16 cutscene; + /* 0x3C8 */ s16 csId; /* 0x3CA */ u8 cutsceneAnimIndex; - /* 0x3CB */ u8 csAction; + /* 0x3CB */ u8 cueId; /* 0x3CC */ u16 flags; /* 0x3CE */ u16 textId; /* 0x3D0 */ u8 focusedShrineGoronParam; diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c index 92e918c5d..2985409dc 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c @@ -189,11 +189,12 @@ void func_80C13BB8(EnJgameTsn* this, PlayState* play) { func_800B8614(&this->actor, play, 80.0f); } - if ((player->actor.bgCheckFlags & 1) && !(player->stateFlags1 & PLAYER_STATE1_2000) && (this->unk_2FE == 0) && - (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) && func_80C149B0(play, &this->unk_1F8)) { + if ((player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && !(player->stateFlags1 & PLAYER_STATE1_2000) && + (this->unk_2FE == 0) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) && + func_80C149B0(play, &this->unk_1F8)) { this->unk_2FE = 1; func_80C13E6C(this); - } else if (!(player->actor.bgCheckFlags & 1)) { + } else if (!(player->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->unk_2FE = 0; } @@ -230,15 +231,15 @@ void func_80C13F88(EnJgameTsn* this) { } void func_80C13F9C(EnJgameTsn* this, PlayState* play) { - if (this->actor.cutscene != -1) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (this->actor.csId != CS_ID_NONE) { + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); func_80C14030(this); } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } else { func_80C14030(this); @@ -267,8 +268,8 @@ void func_80C14044(EnJgameTsn* this, PlayState* play) { case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { - if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { - ActorCutscene_Stop(this->actor.cutscene); + if (CutsceneManager_GetCurrentCsId() == this->actor.csId) { + CutsceneManager_Stop(this->actor.csId); } func_80C13B74(this); } @@ -283,7 +284,7 @@ void func_80C1410C(EnJgameTsn* this, PlayState* play) { Player* player = GET_PLAYER(play); player->stateFlags1 |= PLAYER_STATE1_20; - func_801A2BB8(0x25); + Audio_PlaySubBgm(NA_BGM_TIMED_MINI_GAME); play->interfaceCtx.minigameState = MINIGAME_STATE_COUNTDOWN_SETUP_3; Interface_InitMinigame(play); SET_WEEKEVENTREG(WEEKEVENTREG_90_20); @@ -334,21 +335,22 @@ void func_80C14230(EnJgameTsn* this, PlayState* play) { this->unk_2FC++; - if ((player->actor.bgCheckFlags & 2) && func_80C149B0(play, &this->unk_200)) { + if ((player->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) && func_80C149B0(play, &this->unk_200)) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); Message_StartTextbox(play, 0x109F, &this->actor); this->unk_300 = 0x109F; player->stateFlags1 |= PLAYER_STATE1_20; *this->unk_208[this->unk_218] &= ~OBJLUPYGAMELIFT_IGNITE_FIRE; - func_801A2C20(); + Audio_StopSubBgm(); func_80C14030(this); - } else if ((player->actor.bgCheckFlags & 0x40) || (player->actor.bgCheckFlags & 0x20)) { + } else if ((player->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) || + (player->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); Message_StartTextbox(play, 0x10A0, &this->actor); this->unk_300 = 0x10A0; player->stateFlags1 |= PLAYER_STATE1_20; *this->unk_208[this->unk_218] &= ~OBJLUPYGAMELIFT_IGNITE_FIRE; - func_801A2C20(); + Audio_StopSubBgm(); func_80C14030(this); } @@ -357,7 +359,7 @@ void func_80C14230(EnJgameTsn* this, PlayState* play) { this->unk_300 = 0x10A1; player->stateFlags1 |= PLAYER_STATE1_20; *this->unk_208[this->unk_218] &= ~OBJLUPYGAMELIFT_IGNITE_FIRE; - func_801A2C20(); + Audio_StopSubBgm(); func_80C14030(this); } } @@ -370,7 +372,7 @@ void func_80C144F8(EnJgameTsn* this, PlayState* play) { play->nextEntrance = ENTRANCE(GREAT_BAY_COAST, 13); play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_80; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } void func_80C14540(EnJgameTsn* this) { @@ -384,9 +386,9 @@ void func_80C14554(EnJgameTsn* this, PlayState* play) { } func_80C145FC(this); } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_82_10)) { - Actor_PickUp(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); } else { - Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); } } @@ -400,14 +402,14 @@ void func_80C14610(EnJgameTsn* this, PlayState* play) { this->unk_300 = 0x10A4; func_80C14030(this); } else { - func_800B85E0(&this->actor, play, 200.0f, -1); + func_800B85E0(&this->actor, play, 200.0f, PLAYER_IA_MINUS1); } } void func_80C14684(EnJgameTsn* this, PlayState* play) { if (Message_ShouldAdvance(play)) { if (play->msgCtx.choiceIndex == 0) { - if (gSaveContext.save.playerData.rupees >= 20) { + if (gSaveContext.save.saveInfo.playerData.rupees >= 20) { Message_StartTextbox(play, 0x109E, &this->actor); this->unk_300 = 0x109E; Rupees_ChangeBy(-20); @@ -466,10 +468,10 @@ void func_80C147B4(EnJgameTsn* this, PlayState* play) { break; case 0x109E: - if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { - ActorCutscene_Stop(this->actor.cutscene); + if (CutsceneManager_GetCurrentCsId() == this->actor.csId) { + CutsceneManager_Stop(this->actor.csId); } - func_801477B4(play); + Message_CloseTextbox(play); func_80C1476C(this, play); func_80C1410C(this, play); break; @@ -477,7 +479,7 @@ void func_80C147B4(EnJgameTsn* this, PlayState* play) { case 0x109F: case 0x10A0: case 0x10A1: - func_801477B4(play); + Message_CloseTextbox(play); gSaveContext.minigameStatus = MINIGAME_STATUS_END; gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_20); @@ -485,7 +487,7 @@ void func_80C147B4(EnJgameTsn* this, PlayState* play) { break; case 0x10A3: - func_801477B4(play); + Message_CloseTextbox(play); func_80C14540(this); func_80C14554(this, play); break; @@ -549,7 +551,7 @@ s32 func_80C14BCC(EnJgameTsn* this, PlayState* play) { s32 i; s32 phi_s3 = -1; - if (player->actor.bgCheckFlags & 2) { + if (player->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { for (i = 0; i < ARRAY_COUNT(this->unk_1D8); i++) { if (func_80C149B0(play, &this->unk_1D8[i])) { phi_s3 = i; @@ -561,19 +563,19 @@ s32 func_80C14BCC(EnJgameTsn* this, PlayState* play) { } if (phi_s3 == this->unk_218) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); *this->unk_208[phi_s3] |= OBJLUPYGAMELIFT_DISPLAY_CORRECT; play->interfaceCtx.minigamePoints = 1; return true; } if (*this->unk_208[phi_s3] & OBJLUPYGAMELIFT_IGNITE_FIRE) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); *this->unk_208[phi_s3] |= OBJLUPYGAMELIFT_DISPLAY_CORRECT; play->interfaceCtx.minigamePoints = 1; } else { *this->unk_208[phi_s3] |= OBJLUPYGAMELIFT_DISPLAY_INCORRECT; - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + Actor_PlaySfx(&this->actor, NA_SE_SY_ERROR); } } diff --git a/src/overlays/actors/ovl_En_Js/z_en_js.c b/src/overlays/actors/ovl_En_Js/z_en_js.c index d36bbb6c3..8f48622c8 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.c +++ b/src/overlays/actors/ovl_En_Js/z_en_js.c @@ -76,7 +76,7 @@ Vec3f D_8096AC30 = { 500.0f, -500.0f, 0.0f }; void EnJs_Init(Actor* thisx, PlayState* play) { s32 pad; - s16 cs; + s16 csId; s32 i; EnJs* this = THIS; @@ -92,17 +92,17 @@ void EnJs_Init(Actor* thisx, PlayState* play) { this->actor.terminalVelocity = -9.0f; this->actor.gravity = -1.0f; - cs = this->actor.cutscene; + csId = this->actor.csId; - for (i = 0; i < ARRAY_COUNT(this->cutscenes); i++) { - this->cutscenes[i] = cs; - if (cs != -1) { - this->actor.cutscene = cs; - cs = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + for (i = 0; i < ARRAY_COUNT(this->csIdList); i++) { + this->csIdList[i] = csId; + if (csId != CS_ID_NONE) { + this->actor.csId = csId; + csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); } } - this->cutsceneIndex = -1; + this->csIdIndex = -1; switch (ENJS_GET_TYPE(&this->actor)) { case 0: @@ -110,7 +110,7 @@ void EnJs_Init(Actor* thisx, PlayState* play) { this->actionFunc = func_8096A6F4; Animation_PlayLoop(&this->skelAnime, &gMoonChildSittingAnim); - func_8016566C(0x3C); + Play_EnableMotionBlur(60); if (CHECK_WEEKEVENTREG(WEEKEVENTREG_84_20)) { Inventory_DeleteItem(ITEM_MASK_FIERCE_DEITY, SLOT(ITEM_MASK_FIERCE_DEITY)); @@ -151,7 +151,7 @@ void EnJs_Destroy(Actor* thisx, PlayState* play) { paramsF = ENJS_GET_TYPE(&this->actor); switch (paramsF) { case 0: - func_80165690(); + Play_DisableMotionBlur(); break; case 5: case 6: @@ -254,7 +254,7 @@ s32 func_80968CB8(EnJs* this) { return true; } - Math_StepToF(&this->actor.speedXZ, this->unk_2B4, 0.5f); + Math_StepToF(&this->actor.speed, this->unk_2B4, 0.5f); return false; } @@ -475,20 +475,20 @@ void func_80969400(s32 arg0) { void func_80969494(EnJs* this, PlayState* play) { func_80968A5C(this); - func_801477B4(play); - this->actor.flags &= ~ACTOR_FLAG_100; + Message_CloseTextbox(play); + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; this->actionFunc = func_80969B5C; } void func_809694E8(EnJs* this, PlayState* play) { - func_801477B4(play); - this->actor.flags &= ~ACTOR_FLAG_100; + Message_CloseTextbox(play); + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; this->actionFunc = func_8096A104; } void func_80969530(EnJs* this, PlayState* play) { - func_801477B4(play); - this->actor.flags &= ~ACTOR_FLAG_100; + Message_CloseTextbox(play); + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; this->actionFunc = func_8096A6F4; if ((this->actor.home.rot.y == this->actor.shape.rot.y) && (this->unk_2B8 & 0x10)) { Animation_Change(&this->skelAnime, &gMoonChildGettingUpAnim, -1.0f, @@ -511,17 +511,17 @@ s32 func_809695FC(EnJs* this, PlayState* play) { } void func_80969688(EnJs* this) { - if (this->cutsceneIndex != -1) { - if (ActorCutscene_GetCurrentIndex() == this->cutscenes[this->cutsceneIndex]) { - ActorCutscene_Stop(this->cutscenes[this->cutsceneIndex]); + if (this->csIdIndex != -1) { + if (CutsceneManager_GetCurrentCsId() == this->csIdList[this->csIdIndex]) { + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); } - this->cutsceneIndex = -1; + this->csIdIndex = -1; } } -void func_809696EC(EnJs* this, s16 arg1) { +void func_809696EC(EnJs* this, s16 csIdIndex) { func_80969688(this); - this->cutsceneIndex = arg1; + this->csIdIndex = csIdIndex; } void func_8096971C(EnJs* this, PlayState* play) { @@ -542,7 +542,7 @@ void func_80969748(EnJs* this, PlayState* play) { this->actionFunc = func_80969898; } if (itemAction > PLAYER_IA_NONE) { - func_801477B4(play); + Message_CloseTextbox(play); if ((itemAction >= PLAYER_IA_MASK_TRUTH) && (itemAction <= PLAYER_IA_MASK_GIANT)) { EnJs_TakeMask(itemAction, ENJS_GET_TYPE(&this->actor)); Inventory_UnequipItem(itemAction - 4); @@ -559,7 +559,7 @@ void func_80969748(EnJs* this, PlayState* play) { } if (itemAction <= PLAYER_IA_MINUS1) { - func_80151938(play, 0x2216); + Message_ContinueTextbox(play, 0x2216); } } } @@ -577,11 +577,11 @@ void func_80969898(EnJs* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - func_80151938(play, 0x2217); + Message_ContinueTextbox(play, 0x2217); break; case 1: func_8019F230(); - func_80151938(play, 0x2216); + Message_ContinueTextbox(play, 0x2216); break; } } @@ -592,24 +592,24 @@ void func_80969898(EnJs* this, PlayState* play) { case 0x220C: this->unk_2B8 |= 1; if (!func_8096933C(ENJS_GET_TYPE(&this->actor))) { - func_80151938(play, 0x220F); + Message_ContinueTextbox(play, 0x220F); break; } - func_80151938(play, 0x220D); + Message_ContinueTextbox(play, 0x220D); break; case 0x220D: case 0x2213: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x220E: - func_80151938(play, 0xFF); + Message_ContinueTextbox(play, 0xFF); this->actionFunc = func_80969748; break; case 0x2210: case 0x2211: case 0x2212: player->exchangeItemId = PLAYER_IA_NONE; - func_80151938(play, 0xFF); + Message_ContinueTextbox(play, 0xFF); this->actionFunc = func_80969748; break; case 0x2214: @@ -667,7 +667,7 @@ void func_80969B5C(EnJs* this, PlayState* play) { } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80969898; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_2B4 = 0.0f; func_80969AA0(this, play); } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play)) { @@ -691,7 +691,7 @@ void func_80969C54(EnJs* this, PlayState* play) { } if (itemAction > PLAYER_IA_NONE) { - func_801477B4(play); + Message_CloseTextbox(play); if ((itemAction >= PLAYER_IA_MASK_TRUTH) && (itemAction <= PLAYER_IA_MASK_GIANT)) { EnJs_TakeMask(itemAction, ENJS_GET_TYPE(&this->actor)); Inventory_UnequipItem(itemAction - 4); @@ -708,7 +708,7 @@ void func_80969C54(EnJs* this, PlayState* play) { } if (itemAction <= PLAYER_IA_MINUS1) { - func_80151938(play, 0x221E); + Message_ContinueTextbox(play, 0x221E); } } } @@ -734,7 +734,7 @@ void func_80969DA4(EnJs* this, PlayState* play) { break; case 1: func_8019F230(); - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; } } @@ -744,16 +744,16 @@ void func_80969DA4(EnJs* this, PlayState* play) { switch (play->msgCtx.currentTextId) { case 0x221B: if (!func_8096933C(ENJS_GET_TYPE(&this->actor))) { - func_80151938(play, 0x2219); + Message_ContinueTextbox(play, 0x2219); break; } - func_80151938(play, 0x221C); + Message_ContinueTextbox(play, 0x221C); break; case 0x2224: case 0x2226: case 0x2228: case 0x222A: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x2225: case 0x2227: @@ -766,33 +766,33 @@ void func_80969DA4(EnJs* this, PlayState* play) { break; case 0x2222: player->exchangeItemId = PLAYER_IA_NONE; - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x2223: switch (ENJS_GET_TYPE(&this->actor)) { case 5: - func_80151938(play, 0x2224); + Message_ContinueTextbox(play, 0x2224); break; case 6: - func_80151938(play, 0x2226); + Message_ContinueTextbox(play, 0x2226); break; case 7: - func_80151938(play, 0x2228); + Message_ContinueTextbox(play, 0x2228); break; case 8: - func_80151938(play, 0x222A); + Message_ContinueTextbox(play, 0x222A); break; } break; case 0x221C: - func_80151938(play, 0xFF); + Message_ContinueTextbox(play, 0xFF); this->actionFunc = func_80969C54; break; case 0x221D: case 0x2220: case 0x2221: player->exchangeItemId = PLAYER_IA_NONE; - func_80151938(play, 0xFF); + Message_ContinueTextbox(play, 0xFF); this->actionFunc = func_80969C54; break; default: @@ -872,7 +872,7 @@ void func_8096A2C0(EnJs* this, PlayState* play) { this->actionFunc = func_8096A1E8; func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_MINUS1); } else { - Actor_PickUp(&this->actor, play, GI_MASK_FIERCE_DEITY, 10000.0f, 1000.0f); + Actor_OfferGetItem(&this->actor, play, GI_MASK_FIERCE_DEITY, 10000.0f, 1000.0f); } } @@ -898,12 +898,12 @@ void func_8096A38C(EnJs* this, PlayState* play) { case 0x21FC: switch (play->msgCtx.choiceIndex) { case 0: - func_80151938(play, 0x21FE); + Message_ContinueTextbox(play, 0x21FE); Animation_MorphToPlayOnce(&this->skelAnime, &gMoonChildGettingUpAnim, -5.0f); this->unk_2B8 |= 0x10; break; case 1: - func_80151938(play, 0x21FD); + Message_ContinueTextbox(play, 0x21FD); break; } break; @@ -911,11 +911,11 @@ void func_8096A38C(EnJs* this, PlayState* play) { case 0x21FE: switch (play->msgCtx.choiceIndex) { case 0: - func_80151938(play, 0x2200); + Message_ContinueTextbox(play, 0x2200); func_809696EC(this, 0); break; case 1: - func_80151938(play, 0x21FF); + Message_ContinueTextbox(play, 0x21FF); break; } break; @@ -923,12 +923,12 @@ void func_8096A38C(EnJs* this, PlayState* play) { case 0x2203: switch (play->msgCtx.choiceIndex) { case 0: - func_80151938(play, 0x2205); + Message_ContinueTextbox(play, 0x2205); Animation_MorphToPlayOnce(&this->skelAnime, &gMoonChildGettingUpAnim, -5.0f); this->unk_2B8 |= 0x10; break; case 1: - func_80151938(play, 0x2204); + Message_ContinueTextbox(play, 0x2204); break; } } @@ -941,21 +941,21 @@ void func_8096A38C(EnJs* this, PlayState* play) { case 0x2205: case 0x2206: case 0x2209: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x2200: case 0x2208: func_809696EC(this, 1); - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x2207: if (INV_CONTENT(ITEM_MASK_FIERCE_DEITY) == ITEM_MASK_FIERCE_DEITY) { - func_80151938(play, 0x2208); + Message_ContinueTextbox(play, 0x2208); func_809696EC(this, 0); } else { - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_8096A2C0; func_8096A2C0(this, play); } @@ -1015,18 +1015,18 @@ void EnJs_Update(Actor* thisx, PlayState* play) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 25.0f, 40.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 25.0f, 40.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); - if ((this->cutsceneIndex != -1) && (ActorCutscene_GetCurrentIndex() != this->cutscenes[this->cutsceneIndex])) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIndex]); - } else if (ActorCutscene_GetCanPlayNext(this->cutscenes[this->cutsceneIndex])) { - ActorCutscene_Start(this->cutscenes[this->cutsceneIndex], &this->actor); + if ((this->csIdIndex != -1) && (CutsceneManager_GetCurrentCsId() != this->csIdList[this->csIdIndex])) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); + } else if (CutsceneManager_IsNext(this->csIdList[this->csIdIndex])) { + CutsceneManager_Start(this->csIdList[this->csIdIndex], &this->actor); } else { - ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIndex]); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); } } } diff --git a/src/overlays/actors/ovl_En_Js/z_en_js.h b/src/overlays/actors/ovl_En_Js/z_en_js.h index 4508e4944..c4dd3e3a2 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.h +++ b/src/overlays/actors/ovl_En_Js/z_en_js.h @@ -24,8 +24,8 @@ typedef struct EnJs { /* 0x2B8 */ u16 unk_2B8; /* 0x2BA */ s16 maskType; /* 0x2BC */ s16 unk_2BC; - /* 0x2BE */ s16 cutscenes[2]; - /* 0x2C2 */ s16 cutsceneIndex; + /* 0x2BE */ s16 csIdList[2]; + /* 0x2C2 */ s16 csIdIndex; /* 0x2C4 */ EnJsActionFunc actionFunc; } EnJs; // size = 0x2C8 diff --git a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c index da327642b..7d8f46f91 100644 --- a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c +++ b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c @@ -284,7 +284,7 @@ void EnKaizoku_Init(Actor* thisx, PlayState* play) { blureInit.calcMode = 2; Effect_Add(play, &this->blureIndex, EFFECT_BLURE1, 0, 0, &blureInit); Actor_SetScale(&this->picto.actor, 0.0125f); - this->picto.actor.flags |= ACTOR_FLAG_8000000; + this->picto.actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->picto.actor.flags &= ~ACTOR_FLAG_1; if (this->switchFlag == 127) { this->switchFlag = -1; @@ -298,7 +298,7 @@ void EnKaizoku_Init(Actor* thisx, PlayState* play) { this->bodyCollider.dim.radius = 20; this->bodyCollider.dim.height = 65; this->bodyCollider.dim.yShift = 0; - this->unk_2D6 = this->picto.actor.cutscene; + this->csId = this->picto.actor.csId; this->picto.actor.world.pos.y = player->actor.world.pos.y + 160.0f; this->picto.validationFunc = EnKaizoku_ValidatePictograph; this->picto.actor.flags |= ACTOR_FLAG_400; @@ -371,7 +371,7 @@ s32 func_80B85A00(EnKaizoku* this, PlayState* play, s16 arg2) { } } else if (func_800BE184(play, &this->picto.actor, 100.0f, 0x5DC0, 0x2AA8, this->picto.actor.shape.rot.y)) { this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; - if ((this->picto.actor.bgCheckFlags & 8) && (ABS_ALT(sp32) < 0x2EE0) && + if ((this->picto.actor.bgCheckFlags & BGCHECKFLAG_WALL) && (ABS_ALT(sp32) < 0x2EE0) && (this->picto.actor.xzDistToPlayer < 90.0f)) { if (this->action != KAIZOKU_ACTION_6) { func_80B87C7C(this); @@ -393,9 +393,10 @@ s32 func_80B85A00(EnKaizoku* this, PlayState* play, s16 arg2) { if (explosiveActor != NULL) { this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; - if (((this->picto.actor.bgCheckFlags & 8) && (sp32 < 0x2EE0)) || (explosiveActor->id == ACTOR_EN_BOM_CHU)) { + if (((this->picto.actor.bgCheckFlags & BGCHECKFLAG_WALL) && (sp32 < 0x2EE0)) || + (explosiveActor->id == ACTOR_EN_BOM_CHU)) { if ((explosiveActor->id == ACTOR_EN_BOM_CHU) && - (Actor_DistanceBetweenActors(&this->picto.actor, explosiveActor) < 80.0f) && + (Actor_WorldDistXYZToActor(&this->picto.actor, explosiveActor) < 80.0f) && (BINANG_ADD(this->picto.actor.shape.rot.y - explosiveActor->world.rot.y, 0x8000) < 0x4000)) { if (this->action != KAIZOKU_ACTION_6) { func_80B87C7C(this); @@ -446,10 +447,10 @@ void EnKaizoku_ChangeAnim(EnKaizoku* this, EnKaizokuAnimation animIndex) { } s32 EnKaizoku_ValidatePictograph(PlayState* play, Actor* actor) { - s32 ret = Snap_ValidatePictograph(play, actor, PICTOGRAPH_PIRATE_GOOD, &actor->focus.pos, &actor->shape.rot, 10.0f, + s32 ret = Snap_ValidatePictograph(play, actor, PICTO_VALID_PIRATE_GOOD, &actor->focus.pos, &actor->shape.rot, 10.0f, 400.0f, -1); - ret |= Snap_ValidatePictograph(play, actor, PICTOGRAPH_PIRATE_TOO_FAR, &actor->focus.pos, &actor->shape.rot, 10.0f, + ret |= Snap_ValidatePictograph(play, actor, PICTO_VALID_PIRATE_TOO_FAR, &actor->focus.pos, &actor->shape.rot, 10.0f, 1200.0f, -1); return ret; } @@ -473,14 +474,14 @@ void func_80B85FA8(EnKaizoku* this, PlayState* play) { break; } - if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { - ActorCutscene_SetIntentToPlay(this->unk_2D6); + if (!CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Queue(this->csId); return; } - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->picto.actor); + CutsceneManager_StartWithPlayerCs(this->csId, &this->picto.actor); func_800B7298(play, &this->picto.actor, 0x15); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->picto.actor.csId); this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; sp54 = (this->unk_2CA * 4) + this->unk_2C8; @@ -492,7 +493,7 @@ void func_80B85FA8(EnKaizoku* this, PlayState* play) { player->actor.world.pos.z = this->picto.actor.home.pos.z - 30.0f; } - player->actor.speedXZ = 0.0f; + player->actor.speed = 0.0f; this->picto.actor.world.pos.x = this->picto.actor.home.pos.x; this->picto.actor.world.pos.z = this->picto.actor.home.pos.z; Message_StartTextbox(play, D_80B8A8D0[sp54], &this->picto.actor); @@ -505,7 +506,7 @@ void func_80B85FA8(EnKaizoku* this, PlayState* play) { this->subCamUp.x = -0.11f; this->picto.actor.draw = EnKaizoku_Draw; this->unk_598 = 0; - func_801A0238(0, 0xA); + Audio_SetMainBgmVolume(0, 0xA); this->unk_59C++; case 1: @@ -522,7 +523,7 @@ void func_80B85FA8(EnKaizoku* this, PlayState* play) { } if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_11); this->unk_598 = 0; this->unk_59C++; @@ -531,7 +532,7 @@ void func_80B85FA8(EnKaizoku* this, PlayState* play) { break; case 2: - if (this->picto.actor.bgCheckFlags & 1) { + if (this->picto.actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (this->unk_2D8 != 0) { this->unk_2D8 = 0; this->picto.actor.world.pos.y = this->picto.actor.floorHeight; @@ -539,7 +540,7 @@ void func_80B85FA8(EnKaizoku* this, PlayState* play) { func_800B7298(play, &this->picto.actor, 4); Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_ONGND); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_ONGND); } if (curFrame >= 11.0f) { @@ -571,10 +572,10 @@ void func_80B85FA8(EnKaizoku* this, PlayState* play) { case 4: if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); this->unk_598 = 0; this->unk_59C++; - func_801A0238(0x7F, 0); + Audio_SetMainBgmVolume(0x7F, 0); Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_13); } @@ -583,7 +584,7 @@ void func_80B85FA8(EnKaizoku* this, PlayState* play) { case 5: Math_ApproachF(&this->unk_5E0, 2.0f, 0.2f, 1.0f); if (Animation_OnFrame(&this->skelAnime, 20.0f)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_BOSU_SWORD); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_BOSU_SWORD); } if (curFrame >= 30.0f) { this->unk_598 = 0; @@ -608,11 +609,11 @@ void func_80B85FA8(EnKaizoku* this, PlayState* play) { case 7: if (this->unk_598 == 0) { func_800B7298(play, &this->picto.actor, 6); - ActorCutscene_Stop(this->unk_2D6); + CutsceneManager_Stop(this->csId); this->unk_59C = 0; this->subCamId = 0; this->picto.actor.flags &= ~ACTOR_FLAG_100000; - this->picto.actor.flags &= ~ACTOR_FLAG_8000000; + this->picto.actor.flags &= ~ACTOR_FLAG_CANT_LOCK_ON; this->picto.actor.flags |= ACTOR_FLAG_1; func_80B872A4(this); } @@ -665,15 +666,15 @@ void func_80B85FA8(EnKaizoku* this, PlayState* play) { void func_80B86804(EnKaizoku* this, PlayState* play) { if (this->subCamId == 0) { - if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { - ActorCutscene_SetIntentToPlay(this->unk_2D6); + if (!CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Queue(this->csId); return; } - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->picto.actor); + CutsceneManager_StartWithPlayerCs(this->csId, &this->picto.actor); } func_800B7298(play, &this->picto.actor, 0x60); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->picto.actor.csId); this->unk_2B2 = 30; this->picto.actor.flags &= ~ACTOR_FLAG_1; this->unk_598 = 0; @@ -681,7 +682,7 @@ void func_80B86804(EnKaizoku* this, PlayState* play) { this->unk_2D8 = 0; this->action = KAIZOKU_ACTION_0; this->actionFunc = func_80B868B8; - this->picto.actor.speedXZ = 0.0f; + this->picto.actor.speed = 0.0f; } void func_80B868B8(EnKaizoku* this, PlayState* play) { @@ -713,7 +714,7 @@ void func_80B868B8(EnKaizoku* this, PlayState* play) { EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_15); textId = this->unk_2CA * 4 + this->unk_2C8; Message_StartTextbox(play, D_80B8A8D0[textId], &this->picto.actor); - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_LAST2_SHOUT); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_LAST2_SHOUT); this->unk_598 = 0; this->unk_59C++; } @@ -721,9 +722,9 @@ void func_80B868B8(EnKaizoku* this, PlayState* play) { case 2: if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); func_800B7298(play, &this->picto.actor, 6); - ActorCutscene_Stop(this->unk_2D6); + CutsceneManager_Stop(this->csId); this->subCamId = 0; play->nextEntrance = play->setupExitList[this->exitIndex]; gSaveContext.nextCutsceneIndex = 0; @@ -785,15 +786,15 @@ void func_80B86B74(EnKaizoku* this, PlayState* play) { case 1: if (this->frameCount <= curFrame) { if (this->unk_2D9 == 0) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_DAMM_BREATH); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_DAMM_BREATH); this->unk_2D9 = 1; } else { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); } } if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_18); func_800B7298(play, &this->picto.actor, 0x85); this->unk_5A0 = 0; @@ -820,7 +821,7 @@ void func_80B86B74(EnKaizoku* this, PlayState* play) { if (this->unk_5A0 == 0x12) { Actor* temp_v0_2; - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_SHOUT); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_SHOUT); temp_v0_2 = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ARROW, this->picto.actor.world.pos.x, this->picto.actor.world.pos.y + 10.0f, this->picto.actor.world.pos.z, this->picto.actor.shape.rot.x, this->picto.actor.shape.rot.y, @@ -862,7 +863,7 @@ void func_80B86B74(EnKaizoku* this, PlayState* play) { this->unk_59C = 0; this->subCamId = 0; func_800B7298(play, &this->picto.actor, 6); - ActorCutscene_Stop(this->unk_2D6); + CutsceneManager_Stop(this->csId); if (this->switchFlag >= 0) { Flags_SetSwitch(play, this->switchFlag); } @@ -888,7 +889,7 @@ void func_80B86B74(EnKaizoku* this, PlayState* play) { } void func_80B872A4(EnKaizoku* this) { - this->picto.actor.speedXZ = 0.0f; + this->picto.actor.speed = 0.0f; EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_0); this->action = KAIZOKU_ACTION_1; this->actionFunc = func_80B872F4; @@ -928,13 +929,13 @@ void func_80B874D8(EnKaizoku* this, PlayState* play) { EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_3); if (Math_SinS(player->actor.shape.rot.y - this->picto.actor.shape.rot.y) > 0.0f) { - this->picto.actor.speedXZ = -10.0f; + this->picto.actor.speed = -10.0f; } else if (Math_SinS(player->actor.shape.rot.y - this->picto.actor.shape.rot.y) < 0.0f) { - this->picto.actor.speedXZ = 10.0f; + this->picto.actor.speed = 10.0f; } else if (Rand_ZeroOne() > 0.5f) { - this->picto.actor.speedXZ = 10.0f; + this->picto.actor.speed = 10.0f; } else { - this->picto.actor.speedXZ = -10.0f; + this->picto.actor.speed = -10.0f; } this->skelAnime.playSpeed = 1.0f; @@ -951,18 +952,18 @@ void func_80B8760C(EnKaizoku* this, PlayState* play) { s32 temp_ft1; this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer + 0x3A98; - if ((this->picto.actor.bgCheckFlags & 8) || - !Actor_TestFloorInDirection(&this->picto.actor, play, this->picto.actor.speedXZ, + if ((this->picto.actor.bgCheckFlags & BGCHECKFLAG_WALL) || + !Actor_TestFloorInDirection(&this->picto.actor, play, this->picto.actor.speed, this->picto.actor.shape.rot.y + 0x4000)) { - if (this->picto.actor.bgCheckFlags & 8) { - if (this->picto.actor.speedXZ >= 0.0f) { + if (this->picto.actor.bgCheckFlags & BGCHECKFLAG_WALL) { + if (this->picto.actor.speed >= 0.0f) { var_v0 = this->picto.actor.shape.rot.y + 0x4000; } else { var_v0 = this->picto.actor.shape.rot.y - 0x4000; } var_v0 = this->picto.actor.wallYaw - var_v0; } else { - this->picto.actor.speedXZ *= -0.8f; + this->picto.actor.speed *= -0.8f; var_v0 = 0; } @@ -989,11 +990,11 @@ void func_80B8760C(EnKaizoku* this, PlayState* play) { temp_ft0 = this->skelAnime.curFrame - this->skelAnime.playSpeed; temp_ft1 = this->skelAnime.curFrame + this->skelAnime.playSpeed; if (this->skelAnime.curFrame != 0.0f && ((temp_ft0 < 0 && temp_ft1 > 0) || (temp_ft0 < 5 && temp_ft1 >= 6))) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_GERUDOFT_WALK); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_GERUDOFT_WALK); } if (!(play->gameplayFrames & 0x5F)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); } if (this->unk_2B2 == 0) { @@ -1006,7 +1007,7 @@ void func_80B8760C(EnKaizoku* this, PlayState* play) { } } } else { - if (this->picto.actor.speedXZ >= 0.0f) { + if (this->picto.actor.speed >= 0.0f) { this->picto.actor.shape.rot.y += 0x4000; } else { this->picto.actor.shape.rot.y -= 0x4000; @@ -1021,7 +1022,7 @@ void func_80B87900(EnKaizoku* this) { this->swordState = -1; } this->unk_2D8 = 0; - this->picto.actor.speedXZ = 0.0f; + this->picto.actor.speed = 0.0f; this->unk_2B2 = Rand_S16Offset(10, 10); this->bodyCollider.base.acFlags |= AC_HARD; this->lookTimer = 12; @@ -1089,9 +1090,9 @@ void func_80B8798C(EnKaizoku* this, PlayState* play) { void func_80B87C7C(EnKaizoku* this) { EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_8); - this->picto.actor.speedXZ = 6.5f; + this->picto.actor.speed = 6.5f; this->picto.actor.velocity.y = 15.0f; - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_TEKU_JUMP); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_TEKU_JUMP); this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y; this->bodyCollider.info.elemType = ELEMTYPE_UNK4; this->bodyCollider.base.colType = COLTYPE_NONE; @@ -1120,13 +1121,14 @@ void func_80B87D3C(EnKaizoku* this, PlayState* play) { } this->unk_2D8 = 0; - if ((this->frameCount <= curFrame) && (this->picto.actor.bgCheckFlags & 3)) { + if ((this->frameCount <= curFrame) && + (this->picto.actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH))) { this->bodyCollider.info.elemType = ELEMTYPE_UNK1; this->bodyCollider.base.colType = COLTYPE_HIT3; this->swordCollider.info.elemType = ELEMTYPE_UNK2; this->picto.actor.shape.rot.x = 0; this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y = this->picto.actor.yawTowardsPlayer; - this->picto.actor.speedXZ = 0.0f; + this->picto.actor.speed = 0.0f; this->picto.actor.velocity.y = 0.0f; this->picto.actor.world.pos.y = this->picto.actor.floorHeight; func_80B87F70(this); @@ -1135,8 +1137,8 @@ void func_80B87D3C(EnKaizoku* this, PlayState* play) { void func_80B87E28(EnKaizoku* this) { EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_8); - this->picto.actor.speedXZ = -8.0f; - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_TEKU_JUMP); + this->picto.actor.speed = -8.0f; + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_TEKU_JUMP); this->bodyCollider.info.elemType = ELEMTYPE_UNK4; this->bodyCollider.base.colType = COLTYPE_NONE; this->swordCollider.info.elemType = ELEMTYPE_UNK4; @@ -1158,7 +1160,7 @@ void func_80B87E9C(EnKaizoku* this, PlayState* play) { } } if (!(play->state.frames & 0x5F)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); } } @@ -1166,7 +1168,7 @@ void func_80B87F70(EnKaizoku* this) { EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_9); this->unk_2D0 = 0; this->swordCollider.base.atFlags &= ~AT_BOUNCED; - this->picto.actor.speedXZ = 0.0f; + this->picto.actor.speed = 0.0f; AudioSfx_StopByPosAndId(&this->picto.actor.projectedPos, NA_SE_EN_PIRATE_BREATH); this->action = KAIZOKU_ACTION_9; this->actionFunc = func_80B87FDC; @@ -1182,10 +1184,10 @@ void func_80B87FDC(EnKaizoku* this, PlayState* play2) { curFrame = this->skelAnime.curFrame; sp2E = ABS_ALT(player->actor.shape.rot.y - this->picto.actor.shape.rot.y); sp2C = ABS_ALT(this->picto.actor.yawTowardsPlayer - this->picto.actor.shape.rot.y); - this->picto.actor.speedXZ = 0.0f; + this->picto.actor.speed = 0.0f; if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_ATTACK); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_ATTACK); this->swordState = 1; } else if (Animation_OnFrame(&this->skelAnime, 6.0f)) { this->swordState = -1; @@ -1233,9 +1235,9 @@ void func_80B87FDC(EnKaizoku* this, PlayState* play2) { void func_80B88214(EnKaizoku* this) { EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_8); this->unk_2B2 = 0; - this->picto.actor.speedXZ = 10.0f; + this->picto.actor.speed = 10.0f; this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y = this->picto.actor.yawTowardsPlayer; - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_TEKU_JUMP); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_TEKU_JUMP); this->action = KAIZOKU_ACTION_5; this->actionFunc = func_80B88278; } @@ -1245,7 +1247,7 @@ void func_80B88278(EnKaizoku* this, PlayState* play) { this->unk_2D8 = 0; if (this->frameCount <= curFrame) { - this->picto.actor.speedXZ = 0.0f; + this->picto.actor.speed = 0.0f; if (!Actor_IsFacingPlayer(&this->picto.actor, 0x1554)) { func_80B872A4(this); this->unk_2B2 = Rand_ZeroOne() * 5.0f + 5.0f; @@ -1254,7 +1256,7 @@ void func_80B88278(EnKaizoku* this, PlayState* play) { } } if (!(play->gameplayFrames & 0x5F)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); } } @@ -1274,11 +1276,11 @@ void func_80B88378(EnKaizoku* this, PlayState* play) { Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 1, 0x2EE, 0); this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y; if (this->picto.actor.xzDistToPlayer <= 40.0f) { - Math_ApproachF(&this->picto.actor.speedXZ, -8.0f, 1.0f, 1.5f); + Math_ApproachF(&this->picto.actor.speed, -8.0f, 1.0f, 1.5f); } else if (this->picto.actor.xzDistToPlayer > 55.0f) { - Math_ApproachF(&this->picto.actor.speedXZ, 8.0f, 1.0f, 1.5f); + Math_ApproachF(&this->picto.actor.speed, 8.0f, 1.0f, 1.5f); } else { - Math_ApproachZeroF(&this->picto.actor.speedXZ, 2.0f, 6.65f); + Math_ApproachZeroF(&this->picto.actor.speed, 2.0f, 6.65f); } this->skelAnime.playSpeed = 1.0f; @@ -1325,11 +1327,11 @@ void func_80B88378(EnKaizoku* this, PlayState* play) { } if (!(play->gameplayFrames & 0x5F)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); } if ((this->skelAnime.curFrame != 0.0f) && ((sp30 < 0 && sp2C > 0) || (sp30 < 4 && sp2C >= 5))) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_GERUDOFT_WALK); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_GERUDOFT_WALK); } } } @@ -1364,7 +1366,7 @@ void func_80B887AC(EnKaizoku* this, PlayState* play) { } } if (!(play->gameplayFrames & 0x5F)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); } } } @@ -1375,7 +1377,7 @@ void func_80B88910(EnKaizoku* this) { this->unk_2D0 = 0; this->action = KAIZOKU_ACTION_11; this->actionFunc = func_80B88964; - this->picto.actor.speedXZ = 0.0f; + this->picto.actor.speed = 0.0f; } void func_80B88964(EnKaizoku* this, PlayState* play) { @@ -1400,10 +1402,10 @@ void func_80B88964(EnKaizoku* this, PlayState* play) { Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); this->swordState = 1; - this->picto.actor.speedXZ = 10.0f; - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_ATTACK); + this->picto.actor.speed = 10.0f; + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_ATTACK); } else if (Animation_OnFrame(&this->skelAnime, 21.0f)) { - this->picto.actor.speedXZ = 0.0f; + this->picto.actor.speed = 0.0f; } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { this->swordState = -1; } @@ -1453,7 +1455,7 @@ void func_80B88964(EnKaizoku* this, PlayState* play) { void func_80B88CD8(EnKaizoku* this) { EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_3); - this->picto.actor.speedXZ = randPlusMinusPoint5Scaled(12.0f); + this->picto.actor.speed = randPlusMinusPoint5Scaled(12.0f); this->skelAnime.playSpeed = 1.0f; this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y; this->unk_2B2 = Rand_ZeroOne() * 30.0f + 30.0f; @@ -1474,39 +1476,39 @@ void func_80B88D6C(EnKaizoku* this, PlayState* play) { this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y + 0x4000; sp2A = player->actor.shape.rot.y + 0x8000; if (Math_SinS(sp2A - this->picto.actor.shape.rot.y) >= 0.0f) { - this->picto.actor.speedXZ -= 0.25f; - if (this->picto.actor.speedXZ < -8.0f) { - this->picto.actor.speedXZ = -8.0f; + this->picto.actor.speed -= 0.25f; + if (this->picto.actor.speed < -8.0f) { + this->picto.actor.speed = -8.0f; } } else if (Math_SinS((sp2A - this->picto.actor.shape.rot.y)) < 0.0f) { - this->picto.actor.speedXZ += 0.25f; - if (this->picto.actor.speedXZ > 8.0f) { - this->picto.actor.speedXZ = 8.0f; + this->picto.actor.speed += 0.25f; + if (this->picto.actor.speed > 8.0f) { + this->picto.actor.speed = 8.0f; } } - if ((this->picto.actor.bgCheckFlags & 8) || - !Actor_TestFloorInDirection(&this->picto.actor, play, this->picto.actor.speedXZ, + if ((this->picto.actor.bgCheckFlags & BGCHECKFLAG_WALL) || + !Actor_TestFloorInDirection(&this->picto.actor, play, this->picto.actor.speed, this->picto.actor.shape.rot.y + 0x4000)) { - if (this->picto.actor.bgCheckFlags & 8) { - if (this->picto.actor.speedXZ >= 0.0f) { + if (this->picto.actor.bgCheckFlags & BGCHECKFLAG_WALL) { + if (this->picto.actor.speed >= 0.0f) { yaw = this->picto.actor.shape.rot.y + 0x4000; } else { yaw = this->picto.actor.shape.rot.y - 0x4000; } yaw = this->picto.actor.wallYaw - yaw; } else { - this->picto.actor.speedXZ *= -0.8f; + this->picto.actor.speed *= -0.8f; yaw = 0; } if (ABS_ALT(yaw) > 0x4000) { - this->picto.actor.speedXZ *= -0.8f; - if (this->picto.actor.speedXZ < 0.0f) { - this->picto.actor.speedXZ -= 0.5f; + this->picto.actor.speed *= -0.8f; + if (this->picto.actor.speed < 0.0f) { + this->picto.actor.speed -= 0.5f; } else { - this->picto.actor.speedXZ += 0.5f; + this->picto.actor.speed += 0.5f; } } } @@ -1528,12 +1530,12 @@ void func_80B88D6C(EnKaizoku* this, PlayState* play) { temp_ft5 = this->skelAnime.curFrame + this->skelAnime.playSpeed; if (this->skelAnime.curFrame != 0.0f) { if (((temp_ft4 < 0 && temp_ft5 > 0) || (temp_ft4 < 5 && temp_ft5 > 5))) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_GERUDOFT_WALK); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_GERUDOFT_WALK); } } if (!(play->gameplayFrames & 0x5F)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); } if (this->picto.actor.xzDistToPlayer <= 65.0f) { @@ -1550,8 +1552,8 @@ void func_80B88D6C(EnKaizoku* this, PlayState* play) { // EnKaizoku_SetupStunned void func_80B891B8(EnKaizoku* this) { - if (this->picto.actor.bgCheckFlags & 1) { - this->picto.actor.speedXZ = 0.0f; + if (this->picto.actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->picto.actor.speed = 0.0f; } if (this->action == KAIZOKU_ACTION_11) { @@ -1565,7 +1567,7 @@ void func_80B891B8(EnKaizoku* this) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_COMMON_FREEZE); this->unk_2D8 = 1; if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_SFX) && @@ -1585,18 +1587,18 @@ void func_80B89280(EnKaizoku* this, PlayState* play) { } } - if (this->picto.actor.bgCheckFlags & 2) { - this->picto.actor.speedXZ = 0.0f; + if (this->picto.actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + this->picto.actor.speed = 0.0f; } - if (this->picto.actor.bgCheckFlags & 1) { - if (this->picto.actor.speedXZ < 0.0f) { - this->picto.actor.speedXZ += 0.05f; + if (this->picto.actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + if (this->picto.actor.speed < 0.0f) { + this->picto.actor.speed += 0.05f; } } if ((this->unk_2B6 == 0) && (this->unk_2B8 == 0) && !CHECK_FLAG_ALL(this->picto.actor.flags, ACTOR_FLAG_2000) && - (this->picto.actor.bgCheckFlags & 1)) { + (this->picto.actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->unk_2D8 = 0; func_80B85A00(this, play, true); @@ -1619,7 +1621,7 @@ void func_80B893CC(EnKaizoku* this, PlayState* play) { Math_Vec3f_Copy(&this->unk_3C4, &sp34); this->lookTimer = 0; this->unk_2D8 = 0; - this->picto.actor.speedXZ = 0.0f; + this->picto.actor.speed = 0.0f; EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_5); if (((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || @@ -1632,7 +1634,7 @@ void func_80B893CC(EnKaizoku* this, PlayState* play) { this->picto.actor.flags |= ACTOR_FLAG_400; } - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_DAMAGE); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_DAMAGE); this->action = KAIZOKU_ACTION_14; this->actionFunc = func_80B894C0; } @@ -1644,7 +1646,7 @@ void func_80B894C0(EnKaizoku* this, PlayState* play) { if (!func_80B85858(this, play) && !func_80B85A00(this, play, false) && (this->unk_3C4.x < 1.0f) && (this->unk_3C4.z < 1.0f)) { temp_v0 = this->picto.actor.wallYaw - this->picto.actor.shape.rot.y; - if (this->picto.actor.bgCheckFlags & 8) { + if (this->picto.actor.bgCheckFlags & BGCHECKFLAG_WALL) { if (ABS_ALT(temp_v0) < 0x3000 && (this->picto.actor.xzDistToPlayer < 90.0f)) { func_80B87C7C(this); return; @@ -1674,12 +1676,12 @@ void func_80B8960C(EnKaizoku* this, PlayState* play) { (this->unk_2B8 == 0)) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } - this->picto.actor.speedXZ = 0.0f; + this->picto.actor.speed = 0.0f; this->unk_2D8 = 1; func_800B7298(play, &this->picto.actor, 0x7B); Enemy_StartFinishingBlow(play, &this->picto.actor); - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_DEAD); - this->picto.actor.flags |= ACTOR_FLAG_8000000; + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_DEAD); + this->picto.actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->picto.actor.flags &= ~ACTOR_FLAG_1; this->picto.actor.flags &= ~ACTOR_FLAG_400; this->unk_598 = 0; @@ -1692,12 +1694,12 @@ void func_80B8971C(EnKaizoku* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; Player* player; - if (this->picto.actor.bgCheckFlags & 2) { - this->picto.actor.speedXZ = 0.0f; + if (this->picto.actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + this->picto.actor.speed = 0.0f; } - if (this->picto.actor.bgCheckFlags & 1) { - Math_SmoothStepToF(&this->picto.actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if (this->picto.actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + Math_SmoothStepToF(&this->picto.actor.speed, 0.0f, 1.0f, 0.5f, 0.0f); } if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || @@ -1714,12 +1716,12 @@ void func_80B8971C(EnKaizoku* this, PlayState* play) { if (curFrame >= 25.0f) { player = GET_PLAYER(play); if (this->subCamId == 0) { - if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { - ActorCutscene_SetIntentToPlay(this->unk_2D6); + if (!CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Queue(this->csId); return; } - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->picto.actor); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + CutsceneManager_StartWithPlayerCs(this->csId, &this->picto.actor); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->picto.actor.csId); } Math_Vec3f_Copy(&this->unk_3C4, &gZeroVec3f); @@ -1753,7 +1755,7 @@ void func_80B8971C(EnKaizoku* this, PlayState* play) { this->unk_2D8 = 0; func_80B86B58(this); } else if (Animation_OnFrame(&this->skelAnime, 10.0f)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_GERUDOFT_DOWN); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_GERUDOFT_DOWN); } } @@ -1762,42 +1764,42 @@ void func_80B89A08(EnKaizoku* this, PlayState* play) { Vec3f sp58; s32 i; - if (gSaveContext.save.playerData.health <= 0x10) { + if (gSaveContext.save.saveInfo.playerData.health <= 0x10) { this->swordCollider.info.toucher.damage = 0; } else { this->swordCollider.info.toucher.damage = 4; } if (!(this->swordCollider.base.atFlags & AT_BOUNCED) && (this->swordCollider.base.atFlags & AT_HIT)) { - if ((gSaveContext.save.playerData.health <= 0x10) && (this->action != KAIZOKU_ACTION_16)) { + if ((gSaveContext.save.saveInfo.playerData.health <= 0x10) && (this->action != KAIZOKU_ACTION_16)) { this->unk_2D0 = 2; this->subCamId = 0; this->picto.actor.flags |= ACTOR_FLAG_100000; - if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { - ActorCutscene_SetIntentToPlay(this->unk_2D6); + if (!CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Queue(this->csId); this->actionFunc = func_80B86804; } else { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->picto.actor); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + CutsceneManager_StartWithPlayerCs(this->csId, &this->picto.actor); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->picto.actor.csId); this->actionFunc = func_80B86804; } return; } else if ((this->action == KAIZOKU_ACTION_11) && (this->swordCollider.base.at == &GET_PLAYER(play)->actor)) { func_800B8D98(play, &this->picto.actor, 3.0f, this->picto.actor.yawTowardsPlayer, 1.0f); Health_ChangeBy(play, -0xC); - if ((gSaveContext.save.playerData.health <= 0x10) && (this->action != KAIZOKU_ACTION_16)) { + if ((gSaveContext.save.saveInfo.playerData.health <= 0x10) && (this->action != KAIZOKU_ACTION_16)) { Health_ChangeBy(play, 0x10); this->unk_2D0 = 2; this->subCamId = 0; this->picto.actor.flags |= ACTOR_FLAG_100000; - if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { - ActorCutscene_SetIntentToPlay(this->unk_2D6); + if (!CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Queue(this->csId); this->actionFunc = func_80B86804; } else { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->picto.actor); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + CutsceneManager_StartWithPlayerCs(this->csId, &this->picto.actor); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->picto.actor.csId); this->actionFunc = func_80B86804; } return; @@ -1809,7 +1811,7 @@ void func_80B89A08(EnKaizoku* this, PlayState* play) { } } - if ((this->picto.actor.bgCheckFlags & 8) && (this->picto.actor.wallBgId != BG_ACTOR_MAX) && + if ((this->picto.actor.bgCheckFlags & BGCHECKFLAG_WALL) && (this->picto.actor.wallBgId != BG_ACTOR_MAX) && ((this->action == KAIZOKU_ACTION_2) || (this->action == KAIZOKU_ACTION_3) || (this->action == KAIZOKU_ACTION_4) || (this->action == KAIZOKU_ACTION_1))) { func_80B87F70(this); @@ -1834,7 +1836,8 @@ void func_80B89A08(EnKaizoku* this, PlayState* play) { if (((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_SFX) && (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) || this->unk_2B8 == 0) { - Actor_SetColorFilter(&this->picto.actor, 0, 120, 0, 40); + Actor_SetColorFilter(&this->picto.actor, COLORFILTER_COLORFLAG_BLUE, 120, COLORFILTER_BUFFLAG_OPA, + 40); this->bodyCollider.info.elemType = ELEMTYPE_UNK1; this->bodyCollider.base.colType = COLTYPE_HIT3; this->swordCollider.info.elemType = ELEMTYPE_UNK2; @@ -1906,7 +1909,7 @@ void func_80B89A08(EnKaizoku* this, PlayState* play) { } if (sp64) { - Actor_SetColorFilter(&this->picto.actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->picto.actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); Actor_ApplyDamage(&this->picto.actor); if (this->picto.actor.colChkInfo.health <= 0) { func_80B8960C(this, play); @@ -1940,7 +1943,7 @@ void func_80B89A08(EnKaizoku* this, PlayState* play) { } this->bodyCollider.base.acFlags &= ~AC_HIT; - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_IT_SHIELD_BOUND); + Actor_PlaySfx(&this->picto.actor, NA_SE_IT_SHIELD_BOUND); EffectSsHitmark_SpawnFixedScale(play, 3, &pos); CollisionCheck_SpawnShieldParticlesMetal(play, &pos); } @@ -2015,7 +2018,7 @@ void EnKaizoku_Update(Actor* thisx, PlayState* play2) { } } - if (this->picto.actor.bgCheckFlags & 1) { + if (this->picto.actor.bgCheckFlags & BGCHECKFLAG_GROUND) { Matrix_RotateYS(this->picto.actor.shape.rot.y + this->unk_2F4, 0); Matrix_MultVecZ(this->unk_2F0, &sp34); this->picto.actor.world.pos.x += this->unk_3C4.x + sp34.x; @@ -2025,7 +2028,9 @@ void EnKaizoku_Update(Actor* thisx, PlayState* play2) { Math_ApproachZeroF(&this->unk_2F0, 1.0f, 5.0f); } - Actor_UpdateBgCheckInfo(play, &this->picto.actor, 35.0f, 40.0f, 35.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->picto.actor, 35.0f, 40.0f, 35.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); Collider_UpdateCylinder(&this->picto.actor, &this->bodyCollider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->bodyCollider.base); if ((this->unk_2D0 < 2) && (this->action != KAIZOKU_ACTION_0)) { diff --git a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h index ad161088e..6366c4f7f 100644 --- a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h +++ b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h @@ -58,7 +58,7 @@ typedef struct EnKaizoku { /* 0x2D0 */ s16 unk_2D0; /* 0x2D2 */ s16 swordState; /* 0x2D4 */ s16 exitIndex; - /* 0x2D6 */ s16 unk_2D6; + /* 0x2D6 */ s16 csId; /* 0x2D8 */ u8 unk_2D8; /* 0x2D9 */ u8 unk_2D9; /* 0x2DC */ f32 frameCount; 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 0346749a9..2cec5d9b8 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -143,7 +143,7 @@ void EnKakasi_Destroy(Actor* thisx, PlayState* play) { void EnKakasi_Init(Actor* thisx, PlayState* play) { EnKakasi* this = THIS; - s32 tempCutscene; + s32 csId; s32 i; Collider_InitAndSetCylinder(play, &this->collider, &this->picto.actor, &D_80971D80); @@ -169,10 +169,10 @@ void EnKakasi_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->picto.actor, 0.01f); i = 0; - tempCutscene = this->picto.actor.cutscene; - while (tempCutscene != -1) { + csId = this->picto.actor.csId; + while (csId != CS_ID_NONE) { //! FAKE: - tempCutscene = ActorCutscene_GetAdditionalCutscene(this->actorCutscenes[i] = tempCutscene); + csId = CutsceneManager_GetAdditionalCsId(this->csIdList[i] = csId); i++; } @@ -210,24 +210,24 @@ s32 EnKakasi_ValidatePictograph(PlayState* play, Actor* thisx) { 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)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EV_KAKASHI_SWING); + Actor_PlaySfx(&this->picto.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)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EV_KAKASHI_SWING); + Actor_PlaySfx(&this->picto.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)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_IT_KAKASHI_JUMP); + Actor_PlaySfx(&this->picto.actor, NA_SE_IT_KAKASHI_JUMP); } if (Animation_OnFrame(&this->skelanime, 18.0f)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EV_KAKASHI_ROLL); + Actor_PlaySfx(&this->picto.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)) { - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EV_KAKASH_LONGI_ROLL); + Actor_PlaySfx(&this->picto.actor, NA_SE_EV_KAKASH_LONGI_ROLL); } } } @@ -414,11 +414,11 @@ void EnKakasi_RegularDialogue(EnKakasi* this, PlayState* play) { } if ((this->talkState == Message_GetState(&play->msgCtx)) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); if (this->talkState == TEXT_STATE_5) { // bad song input if (this->unkState196 == 2 && this->picto.actor.textId == 0x1647) { - func_800B7298(play, &this->picto.actor, PLAYER_CSMODE_6); + func_800B7298(play, &this->picto.actor, PLAYER_CSMODE_END); } // after timeskip @@ -440,23 +440,23 @@ void EnKakasi_RegularDialogue(EnKakasi* this, PlayState* play) { this->picto.actor.textId = 0x1645; } - func_80151938(play, this->picto.actor.textId); + Message_ContinueTextbox(play, this->picto.actor.textId); return; } else if (this->picto.actor.textId == 0x165D || this->picto.actor.textId == 0x165F || this->picto.actor.textId == 0x1660 || this->picto.actor.textId == 0x1652) { func_800B7298(play, &this->picto.actor, PLAYER_CSMODE_4); - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csIdList[0]); this->actionFunc = EnKakasi_DancingRemark; } else { - if (!ActorCutscene_GetCanPlayNext(this->actorCutscenes[0])) { - ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + if (!CutsceneManager_IsNext(this->csIdList[0])) { + CutsceneManager_Queue(this->csIdList[0]); this->actionFunc = EnKakasi_DancingRemark; } else { - ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->picto.actor); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + CutsceneManager_StartWithPlayerCs(this->csIdList[0], &this->picto.actor); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->picto.actor.csId); this->actionFunc = EnKakasi_DancingRemark; } } @@ -538,7 +538,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, PlayState* play) { } } } - func_80151938(play, this->picto.actor.textId); + Message_ContinueTextbox(play, this->picto.actor.textId); } } @@ -561,19 +561,19 @@ void EnKakasi_OcarinaRemark(EnKakasi* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { func_80152434(play, 0x35); this->unkState1A8 = 0; - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csIdList[0]); this->actionFunc = EnKakasi_TeachingSong; - } else if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[0]) == 0) { - ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + } else if (!CutsceneManager_IsNext(this->csIdList[0])) { + CutsceneManager_Queue(this->csIdList[0]); this->actionFunc = EnKakasi_TeachingSong; } else { this->unkState1A8 = 1; - ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->picto.actor); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + CutsceneManager_StartWithPlayerCs(this->csIdList[0], &this->picto.actor); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->picto.actor.csId); Math_Vec3f_Copy(&this->unk22C, &this->picto.actor.home.pos); this->actionFunc = EnKakasi_TeachingSong; } @@ -586,17 +586,17 @@ void EnKakasi_TeachingSong(EnKakasi* this, PlayState* play) { EnKakasi_CheckPlayerPosition(this, play); Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.home.rot.y, 1, 3000, 0); if (this->unkState1A8 == 0) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csIdList[0]); return; } - if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[0]) == 0) { - ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + if (!CutsceneManager_IsNext(this->csIdList[0])) { + CutsceneManager_Queue(this->csIdList[0]); return; } - ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->picto.actor); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + CutsceneManager_StartWithPlayerCs(this->csIdList[0], &this->picto.actor); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->picto.actor.csId); Math_Vec3f_Copy(&this->unk22C, &this->picto.actor.home.pos); this->unkState1A8 = 1; this->unkState1A8 = 1; @@ -609,7 +609,7 @@ void EnKakasi_TeachingSong(EnKakasi* this, PlayState* play) { this->subCamEyeNext.z = D_80971DCC[this->unk190].z; Math_Vec3f_Copy(&tempVec, &this->subCamEyeNext); - OLib_DbCameraVec3fSum(&this->picto.actor.home, &tempVec, &this->subCamEyeNext, 1); + OLib_Vec3fAdd(&this->picto.actor.home, &tempVec, &this->subCamEyeNext, OLIB_ADD_OFFSET); Math_Vec3f_Copy(&this->subCamAtNext, &this->unk22C); Math_Vec3f_Copy(&this->subCamEye, &this->subCamEyeNext); Math_Vec3f_Copy(&this->subCamAt, &this->subCamAtNext); @@ -619,8 +619,8 @@ void EnKakasi_TeachingSong(EnKakasi* this, PlayState* play) { if (play->msgCtx.ocarinaMode == 4) { // song failed this->unk190 = 0; this->unkCounter1A4 = 0; - ActorCutscene_Stop(this->actorCutscenes[0]); - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_YASE_DEAD); + CutsceneManager_Stop(this->csIdList[0]); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_YASE_DEAD); if (this) {} this->unkState196 = 2; this->subCamId = SUB_CAM_ID_DONE; @@ -652,7 +652,7 @@ void EnKakasi_PostSongLearnTwirl(EnKakasi* this, PlayState* play) { } void EnKakasi_SetupPostSongLearnDialogue(EnKakasi* this, PlayState* play) { - ActorCutscene_Stop(this->actorCutscenes[0]); + CutsceneManager_Stop(this->csIdList[0]); play->msgCtx.ocarinaMode = 4; this->unk190 = 0; this->unkCounter1A4 = 0; @@ -674,7 +674,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, PlayState* play) { Math_SmoothStepToS(&player->actor.shape.rot.y, this->picto.actor.yawTowardsPlayer + 0x8000, 5, 1000, 0); if (this->unk190 == 0) { - func_801477B4(play); + Message_CloseTextbox(play); func_800B7298(play, &this->picto.actor, PLAYER_CSMODE_86); this->picto.actor.textId = 0x1648; Message_StartTextbox(play, (this->picto.actor.textId), &this->picto.actor); @@ -699,18 +699,18 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, PlayState* play) { } if (this->unkState1A8 == 0) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csIdList[0]); return; } - if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[0]) == 0) { - ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + if (!CutsceneManager_IsNext(this->csIdList[0])) { + CutsceneManager_Queue(this->csIdList[0]); return; } Math_Vec3f_Copy(&this->unk22C, &this->picto.actor.home.pos); - ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->picto.actor); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + CutsceneManager_StartWithPlayerCs(this->csIdList[0], &this->picto.actor); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->picto.actor.csId); func_800B7298(play, &this->picto.actor, PLAYER_CSMODE_86); this->unkState1A8 = 1; } @@ -722,7 +722,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, PlayState* play) { this->subCamEyeNext.y = D_80971FA0[this->unk190].y; this->subCamEyeNext.z = D_80971FA0[this->unk190].z; Math_Vec3f_Copy(&vec3fCopy, &this->subCamEyeNext); - OLib_DbCameraVec3fSum(&this->picto.actor.home, &vec3fCopy, &this->subCamEyeNext, 1); + OLib_Vec3fAdd(&this->picto.actor.home, &vec3fCopy, &this->subCamEyeNext, OLIB_ADD_OFFSET); this->subCamAtNext.x = D_80971FE8[this->unk190].x + this->unk22C.x; this->subCamAtNext.y = D_80971FE8[this->unk190].y + this->unk22C.y; this->subCamAtNext.z = D_80971FE8[this->unk190].z + this->unk22C.z; @@ -735,7 +735,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, PlayState* play) { if ((this->unkState1A8 != 0) && (Message_GetState(&play->msgCtx) == this->talkState) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); if (this->talkState == TEXT_STATE_5) { this->unk190++; @@ -744,7 +744,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, PlayState* play) { } if (this->picto.actor.textId == 0x1648) { - func_800B7298(play, &this->picto.actor, PLAYER_CSMODE_7); + func_800B7298(play, &this->picto.actor, PLAYER_CSMODE_WAIT); this->picto.actor.textId = 0x1649; if (this->animIndex != ENKAKASI_ANIM_ARMS_CROSSED_ROCKING) { EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); @@ -778,7 +778,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, PlayState* play) { this->picto.actor.textId = 0x1661; } } - func_80151938(play, this->picto.actor.textId); + Message_ContinueTextbox(play, this->picto.actor.textId); } } @@ -789,18 +789,18 @@ void EnKakasi_DancingRemark(EnKakasi* this, PlayState* play) { u32 currentDay = gSaveContext.save.day; this->unkState196 = 3; - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); - } else if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[0]) == 0) { - ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csIdList[0]); + } else if (!CutsceneManager_IsNext(this->csIdList[0])) { + CutsceneManager_Queue(this->csIdList[0]); } else { - ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->picto.actor); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + CutsceneManager_StartWithPlayerCs(this->csIdList[0], &this->picto.actor); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->picto.actor.csId); if (currentDay == 3 && gSaveContext.save.isNight) { EnKakasi_SetupDigAway(this); } else { - func_801A2BB8(NA_BGM_SARIAS_SONG); + Audio_PlaySubBgm(NA_BGM_SARIAS_SONG); EnKakasi_SetupDanceNightAway(this); } } @@ -813,7 +813,7 @@ void EnKakasi_SetupDanceNightAway(EnKakasi* this) { this->subCamFovNext = 60.0f; EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_TWIRL); Math_Vec3f_Copy(&this->unk22C, &this->picto.actor.home.pos); - func_8016566C(0xB4); + Play_EnableMotionBlur(180); this->actionFunc = EnKakasi_DancingNightAway; } @@ -831,7 +831,7 @@ void EnKakasi_DancingNightAway(EnKakasi* this, PlayState* play) { this->subCamEyeNext.y = D_80971E38[this->unk190].y; this->subCamEyeNext.z = D_80971E38[this->unk190].z; Math_Vec3f_Copy(&localVec3f, &this->subCamEyeNext); - OLib_DbCameraVec3fSum(&this->picto.actor.home, &localVec3f, &this->subCamEyeNext, 1); + OLib_Vec3fAdd(&this->picto.actor.home, &localVec3f, &this->subCamEyeNext, OLIB_ADD_OFFSET); if (1) {} this->subCamAtNext.x = D_80971EEC[this->unk190].x + this->unk22C.x; @@ -917,7 +917,7 @@ void EnKakasi_DancingNightAway(EnKakasi* this, PlayState* play) { this->unk204 = 0xA; if (this->unk190 == 0xE) { func_800B7298(play, &this->picto.actor, PLAYER_CSMODE_73); - func_80165690(); + Play_DisableMotionBlur(); this->unk204 = 0x14; } } @@ -934,7 +934,7 @@ void EnKakasi_DancingNightAway(EnKakasi* this, PlayState* play) { func_80169EFC(&play->state); //! FAKE - if (0) {} + if (1) {} if (gSaveContext.save.time > CLOCK_TIME(18, 0) || gSaveContext.save.time < CLOCK_TIME(6, 0)) { gSaveContext.save.time = CLOCK_TIME(6, 0); @@ -978,7 +978,7 @@ void EnKakasi_DiggingAway(EnKakasi* this, PlayState* play) { this->subCamEyeNext.z = D_80972030.z; Math_Vec3f_Copy(&tempunk238, &this->subCamEyeNext); - OLib_DbCameraVec3fSum(&this->picto.actor.home, &tempunk238, &this->subCamEyeNext, 1); + OLib_Vec3fAdd(&this->picto.actor.home, &tempunk238, &this->subCamEyeNext, OLIB_ADD_OFFSET); this->subCamAtNext.x = ((f32)D_8097203C.x) + this->unk22C.x; // cast req this->subCamAtNext.y = ((f32)D_8097203C.y) + this->unk22C.y; this->subCamAtNext.z = ((f32)D_8097203C.z) + this->unk22C.z; @@ -1007,15 +1007,15 @@ void EnKakasi_DiggingAway(EnKakasi* this, PlayState* play) { } else { Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->picto.actor.world.pos, this->picto.actor.shape.shadowScale - 20.0f, 5, 4.0f, 200, 10, 1); - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_AKINDONUTS_HIDE); } } Math_ApproachF(&this->picto.actor.shape.yOffset, -6000.0f, 0.5f, 200.0f); if (fabsf(this->picto.actor.shape.yOffset + 6000.0f) < 10.0f) { SET_WEEKEVENTREG(WEEKEVENTREG_79_08); - func_800B7298(play, &this->picto.actor, PLAYER_CSMODE_6); - ActorCutscene_Stop(this->actorCutscenes[0]); + func_800B7298(play, &this->picto.actor, PLAYER_CSMODE_END); + CutsceneManager_Stop(this->csIdList[0]); this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; this->songSummonDist = 80.0f; EnKakasi_SetupIdleUnderground(this); @@ -1025,7 +1025,7 @@ void EnKakasi_DiggingAway(EnKakasi* this, PlayState* play) { void EnKakasi_SetupIdleUnderground(EnKakasi* this) { this->picto.actor.shape.yOffset = -7000.0; this->picto.actor.draw = NULL; - this->picto.actor.flags |= ACTOR_FLAG_8000000; + this->picto.actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->unkState196 = 5; this->actionFunc = EnKakasi_IdleUnderground; } @@ -1033,30 +1033,28 @@ void EnKakasi_SetupIdleUnderground(EnKakasi* this) { void EnKakasi_IdleUnderground(EnKakasi* this, PlayState* play) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_08) && this->picto.actor.xzDistToPlayer < this->songSummonDist && (BREG(1) != 0 || play->msgCtx.ocarinaMode == 0xD)) { - this->picto.actor.flags &= ~ACTOR_FLAG_8000000; + this->picto.actor.flags &= ~ACTOR_FLAG_CANT_LOCK_ON; play->msgCtx.ocarinaMode = 4; this->actionFunc = EnKakasi_SetupRiseOutOfGround; } } void EnKakasi_SetupRiseOutOfGround(EnKakasi* this, PlayState* play) { - s32 cutsceneIndex; + s32 csIdIndex; - cutsceneIndex = 0; + csIdIndex = 0; if (this->aboveGroundStatus == ENKAKASI_ABOVE_GROUND_TYPE) { - cutsceneIndex = 1; + csIdIndex = 1; } - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actorCutscenes[cutsceneIndex]); - - } else if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[cutsceneIndex]) == 0) { - ActorCutscene_SetIntentToPlay(this->actorCutscenes[cutsceneIndex]); - + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csIdList[csIdIndex]); + } else if (!CutsceneManager_IsNext(this->csIdList[csIdIndex])) { + CutsceneManager_Queue(this->csIdList[csIdIndex]); } else { - ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[cutsceneIndex], &this->picto.actor); - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_AKINDONUTS_HIDE); + CutsceneManager_StartWithPlayerCs(this->csIdList[csIdIndex], &this->picto.actor); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_AKINDONUTS_HIDE); this->picto.actor.draw = EnKakasi_Draw; this->unkState196 = 6; this->actionFunc = EnKakasi_RisingOutOfGround; @@ -1073,7 +1071,7 @@ void EnKakasi_RisingOutOfGround(EnKakasi* this, PlayState* play) { if ((play->gameplayFrames % 8) == 0) { Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->picto.actor.world.pos, this->picto.actor.shape.shadowScale - 20.0f, 10, 8.0f, 500, 10, 1); - Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_AKINDONUTS_HIDE); } Math_ApproachF(&this->picto.actor.shape.yOffset, 0.0f, 0.5f, 200.0f); } else { @@ -1102,7 +1100,7 @@ void EnKakasi_RisenDialogue(EnKakasi* this, PlayState* play) { Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 5, 1000, 0); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); EnKakasi_SetupIdleRisen(this); } } @@ -1124,7 +1122,7 @@ void EnKakasi_Update(Actor* thisx, PlayState* play) { if (this->unk1BC.x != 0.0f || this->unk1BC.z != 0.0f) { Math_Vec3f_Copy(&this->picto.actor.focus.pos, &this->unk1BC); this->picto.actor.focus.pos.y += 10.0f; - if (this->subCamId == CAM_ID_MAIN) { + if (this->subCamId == SUB_CAM_ID_DONE) { Math_Vec3s_Copy(&this->picto.actor.focus.rot, &this->picto.actor.world.rot); } else { Math_Vec3s_Copy(&this->picto.actor.focus.rot, &this->picto.actor.home.rot); @@ -1136,7 +1134,8 @@ void EnKakasi_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->picto.actor); - Actor_UpdateBgCheckInfo(play, &this->picto.actor, 50.0f, 50.0f, 100.0f, 0x1C); + Actor_UpdateBgCheckInfo(play, &this->picto.actor, 50.0f, 50.0f, 100.0f, + UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); if (this->picto.actor.draw != NULL) { Collider_UpdateCylinder(&this->picto.actor, &this->collider); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h index c278ef050..cff35d183 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h @@ -21,7 +21,7 @@ typedef struct EnKakasi { /* 0x1A4 */ s32 unkCounter1A4; // counter, counts up to F while he digs away, reused elsewhere /* 0x1A8 */ s32 unkState1A8; /* 0x1AC */ s16 talkState; - /* 0x1AE */ s16 actorCutscenes[3]; + /* 0x1AE */ s16 csIdList[3]; /* 0x1B4 */ f32 animeFrameCount; /* 0x1B8 */ f32 unkHeight; /* 0x1BC */ Vec3f unk1BC; // set by post limbdraw func for one limb 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 6e021186f..9777c7433 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -170,7 +170,7 @@ void func_80AD6F9C(EnKame* this) { this->collider.base.colType = COLTYPE_HIT3; this->unk_2A2 = 80; this->actor.flags &= ~ACTOR_FLAG_400; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 80); } void func_80AD7018(EnKame* this, PlayState* play) { @@ -185,7 +185,7 @@ void func_80AD7018(EnKame* this, PlayState* play) { void func_80AD70A0(EnKame* this) { Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_004210, -5.0f); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_80AD70EC; } @@ -193,7 +193,7 @@ void func_80AD70EC(EnKame* this, PlayState* play) { Player* player = GET_PLAYER(play); if (Animation_OnFrame(&this->skelAnime1, 10.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_VOICE); + Actor_PlaySfx(&this->actor, NA_SE_EN_PAMET_VOICE); this->unk_2A0 = 40; } @@ -207,7 +207,7 @@ void func_80AD70EC(EnKame* this, PlayState* play) { void func_80AD71B4(EnKame* this) { Animation_MorphToLoop(&this->skelAnime1, &object_tl_Anim_00823C, -5.0f); - this->actor.speedXZ = 0.5f; + this->actor.speed = 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); @@ -229,15 +229,15 @@ void func_80AD7254(EnKame* this, PlayState* play) { 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) + ((s32)Rand_Next() >> 0x14); + } else if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 40.0f) { + this->unk_2A4 = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos) + ((s32)Rand_Next() >> 0x14); } 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); + Actor_PlaySfx(&this->actor, NA_SE_EN_PAMET_WALK); } } @@ -246,9 +246,9 @@ void func_80AD73A8(EnKame* this) { this->unk_29E = 0; this->unk_2AC = 1.0f; this->unk_2A8 = 1.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->unk_2A0 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_VOICE); + Actor_PlaySfx(&this->actor, NA_SE_EN_PAMET_VOICE); } this->actionFunc = func_80AD7424; } @@ -278,7 +278,7 @@ void func_80AD7424(EnKame* this, PlayState* play) { } void func_80AD7568(EnKame* this) { - this->actor.speedXZ = this->unk_2A6 * (5.0f / 7552); + this->actor.speed = this->unk_2A6 * (5.0f / 7552); this->actor.shape.rot.z = this->unk_2A6 * 0.11016949f; } @@ -287,13 +287,14 @@ void func_80AD75A8(EnKame* this, PlayState* play) { static Color_RGBA8 D_80AD8E58 = { 180, 180, 180, 255 }; static Vec3f D_80AD8E5C = { 0.0f, 0.75f, 0.0f }; - if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ >= 3.0f)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.speed >= 3.0f)) { if ((play->gameplayFrames % 2) == 0) { - u32 temp_v0 = func_800C9BB8(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + SurfaceMaterial surfaceMaterial = + SurfaceType_GetMaterial(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); - if ((temp_v0 == 0) || (temp_v0 == 1)) { + if ((surfaceMaterial == SURFACE_MATERIAL_DIRT) || (surfaceMaterial == SURFACE_MATERIAL_SAND)) { func_800B1210(play, &this->actor.world.pos, &D_80AD8E5C, &gZeroVec3f, 550, 100); - } else if (temp_v0 == 14) { + } else if (surfaceMaterial == SURFACE_MATERIAL_SNOW) { func_800B0DE0(play, &this->actor.world.pos, &D_80AD8E5C, &gZeroVec3f, &D_80AD8E54, &D_80AD8E58, 550, 100); } @@ -312,11 +313,11 @@ void func_80AD76CC(EnKame* this) { 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->actor.speed = 0.0f; + Actor_PlaySfx(&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); + this->actor.world.rot.y = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); Math_Vec3f_Copy(&this->unk_2BC, &this->actor.home.pos); this->unk_29E = 0; } @@ -363,12 +364,12 @@ void func_80AD7948(EnKame* this, PlayState* play) { func_80AD75A8(this, play); if (this->unk_29E == -1) { - s16 temp_v0 = Actor_YawToPoint(&this->actor, &this->unk_2BC) - this->actor.world.rot.y; + s16 temp_v0 = Actor_WorldYawTowardPoint(&this->actor, &this->unk_2BC) - this->actor.world.rot.y; temp_v1 = ABS_ALT(temp_v0); - if ((this->actor.bgCheckFlags & 8) || (temp_v1 > 0x3000) || - (Actor_XZDistanceToPoint(&this->actor, &this->unk_2BC) < 50.0f)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || (temp_v1 > 0x3000) || + (Actor_WorldDistXZToPoint(&this->actor, &this->unk_2BC) < 50.0f)) { s8 pad; if (this->unk_2BC.y < this->actor.home.pos.y) { @@ -383,7 +384,7 @@ void func_80AD7948(EnKame* this, PlayState* play) { 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); + Actor_PlaySfx(&this->actor, NA_SE_EN_PAMET_CUTTER_OFF); } this->unk_2AC -= 0.1f; this->collider.base.atFlags &= ~AT_ON; @@ -401,7 +402,7 @@ void func_80AD7948(EnKame* this, PlayState* play) { 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->actor.speed = 0.0f; this->unk_2AC = 0.1f; this->unk_2A8 = 1.0f; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -434,13 +435,13 @@ void func_80AD7C54(EnKame* this) { } this->actor.draw = EnKame_Draw; - this->actor.speedXZ = 0.0f; + this->actor.speed = 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 &= ~ACTOR_FLAG_10; this->actor.shape.rot.z = 0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_REVERSE); + Actor_PlaySfx(&this->actor, NA_SE_EN_PAMET_REVERSE); this->actionFunc = func_80AD7D40; } @@ -460,7 +461,7 @@ void func_80AD7DA4(EnKame* this) { this->collider.base.acFlags |= AC_ON; this->collider.base.acFlags &= ~AC_HARD; this->collider.base.colType = COLTYPE_HIT6; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_80AD7E0C; } @@ -472,7 +473,7 @@ void func_80AD7E0C(EnKame* this, PlayState* play) { 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); + Actor_PlaySfx(&this->actor, NA_SE_EN_PAMET_ROAR); } } } else { @@ -482,7 +483,7 @@ void func_80AD7E0C(EnKame* this, PlayState* play) { void func_80AD7EC0(EnKame* this) { Animation_MorphToPlayOnce(&this->skelAnime1, &object_tl_Anim_002510, -3.0f); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_WAKEUP); + Actor_PlaySfx(&this->actor, NA_SE_EN_PAMET_WAKEUP); this->actionFunc = func_80AD7F10; } @@ -498,7 +499,7 @@ void func_80AD7F10(EnKame* this, PlayState* play) { } void func_80AD7FA4(EnKame* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->actor.velocity.y > 0.0f) { this->actor.velocity.y = 0.0f; } @@ -523,11 +524,11 @@ void func_80AD7FF8(EnKame* this, PlayState* play) { } void func_80AD8060(EnKame* this) { - s16 sp36 = Animation_GetLastFrame(&object_tl_Anim_0008B4); + s16 lastFrame = Animation_GetLastFrame(&object_tl_Anim_0008B4); - Animation_Change(&this->skelAnime1, &object_tl_Anim_0008B4, 1.0f, 0.0f, sp36, ANIMMODE_ONCE, -3.0f); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, sp36); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_DAMAGE); + Animation_Change(&this->skelAnime1, &object_tl_Anim_0008B4, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -3.0f); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, lastFrame); + Actor_PlaySfx(&this->actor, NA_SE_EN_PAMET_DAMAGE); this->collider.base.acFlags &= ~AC_ON; this->actionFunc = func_80AD810C; } @@ -540,12 +541,12 @@ void func_80AD810C(EnKame* this, PlayState* play) { void func_80AD8148(EnKame* this, PlayState* play) { Animation_PlayLoop(&this->skelAnime1, &object_tl_Anim_000AF4); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 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; + this->actor.speed = 1.5f; if (play != NULL) { Enemy_StartFinishingBlow(play, &this->actor); if (this->actor.draw == func_80AD8D64) { @@ -554,24 +555,24 @@ void func_80AD8148(EnKame* this, PlayState* play) { func_800BE504(&this->actor, &this->collider); } } - this->actor.bgCheckFlags &= ~0x1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->actor.flags &= ~ACTOR_FLAG_1; this->actor.flags |= ACTOR_FLAG_10; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_PAMET_DEAD); this->unk_29E = 0; this->actionFunc = func_80AD825C; } void func_80AD825C(EnKame* this, PlayState* play) { SkelAnime_Update(&this->skelAnime1); - if ((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_LAND); + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.velocity.y < 0.0f)) { + Actor_PlaySfx(&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); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_NONE, 255, COLORFILTER_BUFFLAG_OPA, 100); } this->actor.shape.rot.x += Rand_S16Offset(0x700, 0x1400); this->actor.shape.rot.y += (s16)Rand_ZeroFloat(5120.0f); @@ -581,7 +582,7 @@ void func_80AD825C(EnKame* this, PlayState* play) { void func_80AD8364(EnKame* this) { this->unk_29E = 20; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_80AD8388; } @@ -643,16 +644,16 @@ void func_80AD84C0(EnKame* this, PlayState* play) { } 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); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->drawDmgEffScale = 0.6f; this->drawDmgEffAlpha = 2.0f; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; 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); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); func_80AD7FA4(this); } else if (this->actor.colChkInfo.damageEffect == 3) { func_80AD6F9C(this); @@ -706,7 +707,7 @@ void EnKame_Update(Actor* thisx, PlayState* play) { 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) { + if (Actor_WorldDistXZToPoint(&this->actor, &this->unk_2BC) < 50.0f) { this->collider.base.atFlags &= ~AT_ON; } this->unk_2A6 = 0x3B00; @@ -716,7 +717,9 @@ void EnKame_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 60.0f, 40.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 60.0f, 40.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); if (this->actor.shape.shadowDraw != NULL) { Actor_SetFocus(&this->actor, 25.0f); diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c index 54df1bcd7..c4ef32e31 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -163,7 +163,7 @@ void EnKanban_Init(Actor* thisx, PlayState* play) { this->bounceX = 1; this->partFlags = 0xFFFF; - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 50.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 50.0f, UPDBGCHECKINFO_FLAG_4); func_80954960(this); } } @@ -209,7 +209,7 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { Vec3f offset; EnKanban* piece; EnKanban* signpost; - s32 temp_v0_18; + FloorType floorType; f32 phi_f0; s32 pad2; @@ -359,10 +359,10 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { if ((hitItem->toucher.dmgFlags & 0x10) || (hitItem->toucher.dmgFlags & 8) || (hitItem->toucher.dmgFlags & 0x80000000)) { piece->actor.velocity.y = Rand_ZeroFloat(3.0f) + 6.0f; - piece->actor.speedXZ = Rand_ZeroFloat(4.0f) + 6.0f; + piece->actor.speed = Rand_ZeroFloat(4.0f) + 6.0f; } else { piece->actor.velocity.y = Rand_ZeroFloat(2.0f) + 3.0f; - piece->actor.speedXZ = Rand_ZeroFloat(2.0f) + 3.0f; + piece->actor.speed = Rand_ZeroFloat(2.0f) + 3.0f; } if (piece->partCount >= 4) { @@ -384,7 +384,7 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { piece->actor.flags &= ~ACTOR_FLAG_1; piece->actor.flags |= ACTOR_FLAG_2000000; this->cutMarkTimer = 5; - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SWORD_STRIKE); + Actor_PlaySfx(&this->actor, NA_SE_IT_SWORD_STRIKE); } } } @@ -423,7 +423,7 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { f32 tempY; f32 tempZ; f32 tempWaterDepth; - u16 tempBgFlags; + u16 bgCheckFlags; u8 onGround; if (this->unk_198 != 0) { @@ -433,27 +433,28 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { Actor_MoveWithGravity(&this->actor); } - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 10.0f, 50.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 10.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); tempX = this->actor.world.pos.x; tempY = this->actor.world.pos.y; tempZ = this->actor.world.pos.z; - tempBgFlags = this->actor.bgCheckFlags; + bgCheckFlags = this->actor.bgCheckFlags; tempWaterDepth = this->actor.depthInWater; this->actor.world.pos.z += ((this->actor.world.pos.y - this->actor.floorHeight) * -50.0f) / 100.0f; - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 50.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 50.0f, UPDBGCHECKINFO_FLAG_4); func_80954960(this); this->actor.world.pos.x = tempX; this->actor.world.pos.y = tempY; this->actor.world.pos.z = tempZ; - this->actor.bgCheckFlags = tempBgFlags; + this->actor.bgCheckFlags = bgCheckFlags; this->actor.depthInWater = tempWaterDepth; if (1) {} - onGround = (this->actor.bgCheckFlags & 1); + onGround = (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND); if (this->spinXFlag != 0) { this->spinRot.x += this->spinVel.x; @@ -495,16 +496,16 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { this->spinVel.z = -0xC00; } - if (this->actor.bgCheckFlags & 8) { - if (!(this->actor.bgCheckFlags & 1)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + Actor_PlaySfx(&this->actor, NA_SE_EV_WOODPLATE_BOUND); } - this->actor.speedXZ *= -0.5f; + this->actor.speed *= -0.5f; } - if (this->actor.bgCheckFlags & 0x40) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { this->actionState = ENKANBAN_WATER; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMB_DROP_WATER); this->bounceX = this->bounceZ = 0; this->actor.world.pos.y += this->actor.depthInWater; EffectSsGSplash_Spawn(play, &this->actor.world.pos, NULL, NULL, 0, (this->partCount * 20) + 300); @@ -516,11 +517,11 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { } if (onGround) { - temp_v0_18 = func_800C99D4(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + floorType = SurfaceType_GetFloorType(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); - if ((temp_v0_18 == 15) || (temp_v0_18 == 14)) { + if ((floorType == FLOOR_TYPE_15) || (floorType == FLOOR_TYPE_14)) { this->unk_197 = 1; - } else if (temp_v0_18 == 5) { + } else if (floorType == FLOOR_TYPE_5) { this->unk_197 = -1; } @@ -539,12 +540,12 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { if (this->unk_197 != 0) { if (this->unk_197 > 0) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else if ((this->floorRot.x > 0.1f) || (this->floorRot.z > 0.1f)) { this->airTimer = 10; - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->actionState = ENKANBAN_GROUND; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; goto nextCase; } else { Vec3f spC8; @@ -556,14 +557,14 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { Math_ApproachF(&this->actor.velocity.z, spC8.z, 0.5f, (KREG(21) * 0.01f) + 0.3f); this->actor.world.rot.y = Math_Atan2S(spC8.x, spC8.z); this->unk_198 = 1; - this->actor.speedXZ = sqrtf(SQXZ(this->actor.velocity)); + this->actor.speed = sqrtf(SQXZ(this->actor.velocity)); } } else { this->unk_198 = 0; - Math_ApproachZeroF(&this->actor.speedXZ, 1, 0.1f); + Math_ApproachZeroF(&this->actor.speed, 1, 0.1f); } } else { - this->actor.speedXZ *= 0.7f; + this->actor.speed *= 0.7f; } if (this->spinRot.x == 0) { @@ -622,9 +623,9 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { if (bounced) { if (this->unk_197 > 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_SNOW); + Actor_PlaySfx(&this->actor, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_SNOW); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EV_WOODPLATE_BOUND); } } @@ -687,38 +688,39 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { s16 rippleDelay; s32 rippleScale; - if ((player->actor.speedXZ > 0.0f) && (player->actor.world.pos.y < this->actor.world.pos.y) && + if ((player->actor.speed > 0.0f) && (player->actor.world.pos.y < this->actor.world.pos.y) && (this->actor.xyzDistToPlayerSq < SQ(50.0f))) { - Math_ApproachF(&this->actor.speedXZ, player->actor.speedXZ, 1.0f, 0.2f); - if (this->actor.speedXZ > 1.0f) { - this->actor.speedXZ = 1.0f; + Math_ApproachF(&this->actor.speed, player->actor.speed, 1.0f, 0.2f); + if (this->actor.speed > 1.0f) { + this->actor.speed = 1.0f; } if (Math_SmoothStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 1, 0x1000, 0) > 0) { - this->spinVel.y = this->actor.speedXZ * 1000.0f; + this->spinVel.y = this->actor.speed * 1000.0f; } else { - this->spinVel.y = this->actor.speedXZ * -1000.0f; + this->spinVel.y = this->actor.speed * -1000.0f; } } - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.speed = 0.0f; } Actor_MoveWithGravity(&this->actor); - if (this->actor.speedXZ != 0.0f) { - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 50.0f, 5); - if (this->actor.bgCheckFlags & 8) { - this->actor.speedXZ *= -0.5f; + if (this->actor.speed != 0.0f) { + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { + this->actor.speed *= -0.5f; if (this->spinVel.y > 0) { this->spinVel.y = -2000; } else { this->spinVel.y = 2000; } } - Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.15f); + Math_ApproachZeroF(&this->actor.speed, 1.0f, 0.15f); } this->actor.shape.rot.y += this->spinVel.y; Math_ApproachS(&this->spinVel.y, 0, 1, 0x3A); @@ -728,9 +730,9 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { Math_ApproachZeroF(&this->floorRot.x, 0.5f, 0.2f); Math_ApproachZeroF(&this->floorRot.z, 0.5f, 0.2f); - if (fabsf(this->actor.speedXZ) > 1.0f) { + if (fabsf(this->actor.speed) > 1.0f) { rippleDelay = 0; - } else if (fabsf(this->actor.speedXZ) > 0.5f) { + } else if (fabsf(this->actor.speed) > 0.5f) { rippleDelay = 3; } else { rippleDelay = 7; @@ -756,12 +758,12 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { this->bounceX = Rand_ZeroFloat(10.0f) + 6.0f; this->bounceZ = Rand_ZeroFloat(10.0f) + 6.0f; this->actor.velocity.y = 2.0f + hammerStrength; - this->actor.speedXZ = Rand_ZeroFloat(1.0f); + this->actor.speed = Rand_ZeroFloat(1.0f); } else { this->bounceX = Rand_ZeroFloat(7.0f) + 3.0f; this->bounceZ = Rand_ZeroFloat(7.0f) + 3.0f; this->actor.velocity.y = 3.0f + hammerStrength; - this->actor.speedXZ = Rand_ZeroFloat(1.5f); + this->actor.speed = Rand_ZeroFloat(1.5f); } this->spinVel.y = randPlusMinusPoint5Scaled(0x1800); @@ -801,12 +803,12 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { this->bounceX = Rand_ZeroFloat(10.0f) + 6.0f; this->bounceZ = Rand_ZeroFloat(10.0f) + 6.0f; this->actor.velocity.y = 2.5f + bombStrength; - this->actor.speedXZ = 3.0f + bombStrength; + this->actor.speed = 3.0f + bombStrength; } else { this->bounceX = Rand_ZeroFloat(7.0f) + 3.0f; this->bounceZ = Rand_ZeroFloat(7.0f) + 3.0f; this->actor.velocity.y = 5.0f + bombStrength; - this->actor.speedXZ = 4.0f + bombStrength; + this->actor.speed = 4.0f + bombStrength; } this->spinVel.y = randPlusMinusPoint5Scaled(0x1800); diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c index 46ad2c30b..0c0078fd3 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c @@ -1,13 +1,12 @@ /* * File: z_en_karebaba.c * Overlay: ovl_En_Karebaba - * Description: Wilted Deku Baba + * Description: Wilted Deku Baba and Mini Baba */ #include "z_en_karebaba.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_dekubaba/object_dekubaba.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) @@ -18,27 +17,26 @@ void EnKarebaba_Destroy(Actor* thisx, PlayState* play); void EnKarebaba_Update(Actor* thisx, PlayState* play2); void EnKarebaba_Draw(Actor* thisx, PlayState* play); -void func_808F155C(EnKarebaba* this); -void func_808F15B0(EnKarebaba* this, PlayState* play); -void func_808F1648(EnKarebaba* this); -void func_808F169C(EnKarebaba* this, PlayState* play); -void func_808F16FC(EnKarebaba* this); -void func_808F1778(EnKarebaba* this, PlayState* play); -void func_808F1878(EnKarebaba* this); -void func_808F190C(EnKarebaba* this, PlayState* play); -void func_808F1A3C(EnKarebaba* this); -void func_808F1A58(EnKarebaba* this, PlayState* play); -void func_808F1BF8(EnKarebaba* this); -void func_808F1C84(EnKarebaba* this, PlayState* play); -void func_808F1FAC(EnKarebaba* this); -void func_808F200C(EnKarebaba* this, PlayState* play); -void func_808F20FC(EnKarebaba* this, PlayState* play); -void func_808F21A4(EnKarebaba* this, PlayState* play); -void func_808F220C(EnKarebaba* this); -void func_808F228C(EnKarebaba* this, PlayState* play); -void func_808F238C(EnKarebaba* this); -void func_808F241C(EnKarebaba* this, PlayState* play); -void func_808F254C(EnKarebaba* this, PlayState* play); +void EnKarebaba_SetupGrow(EnKarebaba* this); +void EnKarebaba_Grow(EnKarebaba* this, PlayState* play); +void EnKarebaba_SetupIdle(EnKarebaba* this); +void EnKarebaba_Idle(EnKarebaba* this, PlayState* play); +void EnKarebaba_SetupAwaken(EnKarebaba* this); +void EnKarebaba_Awaken(EnKarebaba* this, PlayState* play); +void EnKarebaba_SetupUpright(EnKarebaba* this); +void EnKarebaba_Upright(EnKarebaba* this, PlayState* play); +void EnKarebaba_SetupSpin(EnKarebaba* this); +void EnKarebaba_Spin(EnKarebaba* this, PlayState* play); +void EnKarebaba_SetupDying(EnKarebaba* this); +void EnKarebaba_Dying(EnKarebaba* this, PlayState* play); +void EnKarebaba_SetupShrinkDie(EnKarebaba* this); +void EnKarebaba_ShrinkDie(EnKarebaba* this, PlayState* play); +void EnKarebaba_SetupDeadItemDrop(EnKarebaba* this, PlayState* play); +void EnKarebaba_DeadItemDrop(EnKarebaba* this, PlayState* play); +void EnKarebaba_SetupRetract(EnKarebaba* this); +void EnKarebaba_Retract(EnKarebaba* this, PlayState* play); +void EnKarebaba_SetupDead(EnKarebaba* this); +void EnKarebaba_Dead(EnKarebaba* this, PlayState* play); ActorInit En_Karebaba_InitVars = { ACTOR_EN_KAREBABA, @@ -52,7 +50,7 @@ ActorInit En_Karebaba_InitVars = { (ActorFunc)EnKarebaba_Draw, }; -static ColliderCylinderInit sCylinderInit1 = { +static ColliderCylinderInit sHurtCylinderInit = { { COLTYPE_HARD, AT_NONE, @@ -72,7 +70,7 @@ static ColliderCylinderInit sCylinderInit1 = { { 7, 25, 0, { 0, 0, 0 } }, }; -static ColliderCylinderInit sCylinderInit2 = { +static ColliderCylinderInit sAttackCylinderInit = { { COLTYPE_HARD, AT_ON | AT_TYPE_ENEMY, @@ -94,39 +92,47 @@ static ColliderCylinderInit sCylinderInit2 = { static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 80, MASS_HEAVY }; +typedef enum { + /* 0x0 */ KAREBABA_DMGEFF_NONE, + /* 0x2 */ KAREBABA_DMGEFF_FIRE = 2, + /* 0x3 */ KAREBABA_DMGEFF_ICE, + /* 0x4 */ KAREBABA_DMGEFF_LIGHT, + /* 0x5 */ KAREBABA_DMGEFF_ELECTRIC, +} DekuBabaDamageEffect; + static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(3, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0x0), - /* Goron punch */ DMG_ENTRY(2, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(1, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(1, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), + /* Deku Nut */ DMG_ENTRY(0, KAREBABA_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(3, KAREBABA_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, KAREBABA_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, KAREBABA_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, KAREBABA_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, KAREBABA_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, KAREBABA_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(1, KAREBABA_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(2, KAREBABA_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, KAREBABA_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, KAREBABA_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(1, KAREBABA_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, KAREBABA_DMGEFF_ICE), + /* Light arrow */ DMG_ENTRY(2, KAREBABA_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, KAREBABA_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, KAREBABA_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, KAREBABA_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, KAREBABA_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, KAREBABA_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(1, KAREBABA_DMGEFF_ELECTRIC), + /* Normal shield */ DMG_ENTRY(0, KAREBABA_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, KAREBABA_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, KAREBABA_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, KAREBABA_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, KAREBABA_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, KAREBABA_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, KAREBABA_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, KAREBABA_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, KAREBABA_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, KAREBABA_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, KAREBABA_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, KAREBABA_DMGEFF_NONE), }; static InitChainEntry sInitChain[] = { @@ -134,444 +140,441 @@ static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 1, ICHAIN_STOP), }; -Color_RGBA8 D_808F2E28 = { 0, 0, 0, 0 }; - -Gfx* D_808F2E2C[] = { object_dekubaba_DL_001330, object_dekubaba_DL_001628, object_dekubaba_DL_001828 }; - void EnKarebaba_Init(Actor* thisx, PlayState* play) { EnKarebaba* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 22.0f); - SkelAnime_Init(play, &this->skelAnime, &object_dekubaba_Skel_002A40, &object_dekubaba_Anim_0002B8, this->jointTable, - this->morphTable, 8); + SkelAnime_Init(play, &this->skelAnime, &gDekuBabaSkel, &gDekuBabaFastChompAnim, this->jointTable, this->morphTable, + DEKUBABA_LIMB_MAX); - Collider_InitAndSetCylinder(play, &this->collider2, &this->actor, &sCylinderInit1); - Collider_UpdateCylinder(&this->actor, &this->collider2); - Collider_InitAndSetCylinder(play, &this->collider1, &this->actor, &sCylinderInit2); - Collider_UpdateCylinder(&this->actor, &this->collider1); + Collider_InitAndSetCylinder(play, &this->hurtCollider, &this->actor, &sHurtCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->hurtCollider); + Collider_InitAndSetCylinder(play, &this->attackCollider, &this->actor, &sAttackCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->attackCollider); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->unk_22C = NULL; - if (this->actor.params == ENKAREBABA_2) { + this->boundFloor = NULL; + if (this->actor.params == KAREBABA_MINI) { this->actor.hintId = TATL_HINT_ID_MINI_BABA; } else { this->actor.hintId = TATL_HINT_ID_WILTED_DEKU_BABA; } if (this->actor.params == ENKAREBABA_0) { - func_808F155C(this); + EnKarebaba_SetupGrow(this); } else { - func_808F1648(this); + EnKarebaba_SetupIdle(this); } } void EnKarebaba_Destroy(Actor* thisx, PlayState* play) { EnKarebaba* this = THIS; - Collider_DestroyCylinder(play, &this->collider2); - Collider_DestroyCylinder(play, &this->collider1); + Collider_DestroyCylinder(play, &this->hurtCollider); + Collider_DestroyCylinder(play, &this->attackCollider); } -void func_808F1374(EnKarebaba* this, PlayState* play) { - s32 phi_a3; +void EnKarebaba_SpawnIceEffects(EnKarebaba* this, PlayState* play) { + s32 limbPosCount; if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->drawDmgEffAlpha = 0.0f; - if (this->actor.params == ENKAREBABA_2) { - phi_a3 = 1; + + if (this->actor.params == KAREBABA_MINI) { + limbPosCount = 1; } else { - phi_a3 = 4; + limbPosCount = 4; } - Actor_SpawnIceEffects(play, &this->actor, this->limbPos, phi_a3, 4, 0.3f, 0.2f); + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartsPos, limbPosCount, 4, 0.3f, 0.2f); } } -void func_808F13FC(EnKarebaba* this, PlayState* play) { - if (this->actor.colChkInfo.damageEffect == 2) { +void EnKarebaba_SetDamageEffects(EnKarebaba* this, PlayState* play) { + if (this->actor.colChkInfo.damageEffect == KAREBABA_DMGEFF_FIRE) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->drawDmgEffScale = 0.75f; this->drawDmgEffAlpha = 3.0f; - } else if (this->actor.colChkInfo.damageEffect == 4) { + } else if (this->actor.colChkInfo.damageEffect == KAREBABA_DMGEFF_LIGHT) { this->drawDmgEffScale = 0.75f; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->drawDmgEffAlpha = 3.0f; - Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider2.info.bumper.hitPos.x, - this->collider2.info.bumper.hitPos.y, this->collider2.info.bumper.hitPos.z, 0, 0, 0, + + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->hurtCollider.info.bumper.hitPos.x, + this->hurtCollider.info.bumper.hitPos.y, this->hurtCollider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); - } else if (this->actor.colChkInfo.damageEffect == 3) { + } else if (this->actor.colChkInfo.damageEffect == KAREBABA_DMGEFF_ICE) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->drawDmgEffScale = 0.75f; this->drawDmgEffAlpha = 1.0f; this->drawDmgEffFrozenSteamScale = 1.125f; - } else if (this->actor.colChkInfo.damageEffect == 5) { + } else if (this->actor.colChkInfo.damageEffect == KAREBABA_DMGEFF_ELECTRIC) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; this->drawDmgEffScale = 0.75f; this->drawDmgEffAlpha = 3.0f; } } -void func_808F152C(EnKarebaba* this) { - this->collider2.dim.radius = 7; - this->collider2.dim.height = 25; - this->collider2.base.colType = COLTYPE_HARD; - this->collider2.base.acFlags |= AC_HARD; - this->collider1.dim.height = 25; +void EnKarebaba_ResetColliders(EnKarebaba* this) { + this->hurtCollider.dim.radius = 7; + this->hurtCollider.dim.height = 25; + this->hurtCollider.base.colType = COLTYPE_HARD; + this->hurtCollider.base.acFlags |= AC_HARD; + this->attackCollider.dim.height = 25; } -void func_808F155C(EnKarebaba* this) { +void EnKarebaba_SetupGrow(EnKarebaba* this) { Actor_SetScale(&this->actor, 0.0f); this->actor.shape.rot.x = -0x4000; - this->unk_1EE = 0; + this->timer = 0; this->actor.world.pos.y = this->actor.home.pos.y + 14.0f; - this->actionFunc = func_808F15B0; + this->actionFunc = EnKarebaba_Grow; } -void func_808F15B0(EnKarebaba* this, PlayState* play) { - f32 sp1C; +void EnKarebaba_Grow(EnKarebaba* this, PlayState* play) { + f32 scale; - this->unk_1EE++; - sp1C = this->unk_1EE * 0.05f; - Actor_SetScale(&this->actor, 0.005f * sp1C); - this->actor.world.pos.y = this->actor.home.pos.y + (14.0f * sp1C); - if (this->unk_1EE == 20) { - func_808F1648(this); + this->timer++; + scale = this->timer * 0.05f; + Actor_SetScale(&this->actor, 0.005f * scale); + this->actor.world.pos.y = this->actor.home.pos.y + (14.0f * scale); + if (this->timer == 20) { + EnKarebaba_SetupIdle(this); } } -void func_808F1648(EnKarebaba* this) { +void EnKarebaba_SetupIdle(EnKarebaba* this) { Actor_SetScale(&this->actor, 0.005f); this->actor.shape.rot.x = -0x4000; this->actor.world.pos.y = this->actor.home.pos.y + 14.0f; - this->actionFunc = func_808F169C; + this->actionFunc = EnKarebaba_Idle; } -void func_808F169C(EnKarebaba* this, PlayState* play) { +void EnKarebaba_Idle(EnKarebaba* this, PlayState* play) { if ((this->actor.xzDistToPlayer < 200.0f) && (fabsf(this->actor.playerHeightRel) < 30.0f)) { - func_808F16FC(this); + EnKarebaba_SetupAwaken(this); } } -void func_808F16FC(EnKarebaba* this) { - Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, 4.0f, 0.0f, - Animation_GetLastFrame(&object_dekubaba_Anim_0002B8), ANIMMODE_LOOP, -3.0f); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKU_WAKEUP); - this->actionFunc = func_808F1778; +void EnKarebaba_SetupAwaken(EnKarebaba* this) { + Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, 4.0f, 0.0f, + Animation_GetLastFrame(&gDekuBabaFastChompAnim), ANIMMODE_LOOP, -3.0f); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKU_WAKEUP); + this->actionFunc = EnKarebaba_Awaken; } -void func_808F1778(EnKarebaba* this, PlayState* play) { +void EnKarebaba_Awaken(EnKarebaba* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.0005f) && (this->actor.params == ENKAREBABA_2)) { - func_808F1878(this); + if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.0005f) && (this->actor.params == KAREBABA_MINI)) { + EnKarebaba_SetupUpright(this); } - this->actor.scale.z = this->actor.scale.x; - this->actor.scale.y = this->actor.scale.x; + this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; if ((this->actor.params == ENKAREBABA_1) && Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 60.0f, 5.0f)) { - func_808F1878(this); + EnKarebaba_SetupUpright(this); } - this->actor.shape.rot.y += 0x1999; + this->actor.shape.rot.y += 0x10000 / 10; EffectSsHahen_SpawnBurst(play, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); } -void func_808F1878(EnKarebaba* this) { - if (this->actionFunc != func_808F1A58) { +void EnKarebaba_SetupUpright(EnKarebaba* this) { + if (this->actionFunc != EnKarebaba_Spin) { Actor_SetScale(&this->actor, 0.01f); - this->collider2.base.colType = COLTYPE_HIT6; - this->collider2.base.acFlags &= ~AC_HARD; - this->collider2.dim.radius = 15; + this->hurtCollider.base.colType = COLTYPE_HIT6; + this->hurtCollider.base.acFlags &= ~AC_HARD; + this->hurtCollider.dim.radius = 15; if (this->actor.params == ENKAREBABA_1) { - this->collider2.dim.height = 80; - this->collider1.dim.height = 80; + this->hurtCollider.dim.height = 80; + this->attackCollider.dim.height = 80; } else { - this->collider2.dim.height = 35; - this->collider1.dim.height = 35; + this->hurtCollider.dim.height = 35; + this->attackCollider.dim.height = 35; } } - this->unk_1EE = 40; - this->actionFunc = func_808F190C; + this->timer = 40; + this->actionFunc = EnKarebaba_Upright; } -void func_808F190C(EnKarebaba* this, PlayState* play) { +void EnKarebaba_Upright(EnKarebaba* this, PlayState* play) { Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); - if (this->unk_1EE != 0) { - this->unk_1EE--; + if (this->timer != 0) { + this->timer--; } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MIZUBABA1_MOUTH); + Actor_PlaySfx(&this->actor, NA_SE_EN_MIZUBABA1_MOUTH); } - if (this->collider2.base.acFlags & AC_HIT) { - func_808F13FC(this, play); + if (this->hurtCollider.base.acFlags & AC_HIT) { + EnKarebaba_SetDamageEffects(this, play); if (this->actor.params == ENKAREBABA_1) { - func_808F1BF8(this); + EnKarebaba_SetupDying(this); } else { - func_808F1FAC(this); + EnKarebaba_SetupShrinkDie(this); } Enemy_StartFinishingBlow(play, &this->actor); } else if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) > 240.0f) { - func_808F220C(this); - } else if ((this->unk_1EE == 0) && (this->actor.params == ENKAREBABA_1)) { - func_808F1A3C(this); + EnKarebaba_SetupRetract(this); + } else if ((this->timer == 0) && (this->actor.params == ENKAREBABA_1)) { + EnKarebaba_SetupSpin(this); } } -void func_808F1A3C(EnKarebaba* this) { - this->unk_1EE = 40; - this->actionFunc = func_808F1A58; +void EnKarebaba_SetupSpin(EnKarebaba* this) { + this->timer = 40; + this->actionFunc = EnKarebaba_Spin; } -void func_808F1A58(EnKarebaba* this, PlayState* play) { - s32 phi_v0; - f32 sp28; +void EnKarebaba_Spin(EnKarebaba* this, PlayState* play) { + s32 temp; // Used for cylinder radius and shape rotations + f32 headDistHorizontal; - if (this->unk_1EE != 0) { - this->unk_1EE--; + if (this->timer != 0) { + this->timer--; } SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MIZUBABA1_MOUTH); + Actor_PlaySfx(&this->actor, NA_SE_EN_MIZUBABA1_MOUTH); } - phi_v0 = 20 - this->unk_1EE; - phi_v0 = 20 - ABS_ALT(phi_v0); - if (phi_v0 > 10) { - phi_v0 = 10; + temp = 20 - this->timer; + temp = 20 - ABS_ALT(temp); + if (temp > 10) { + temp = 10; } - this->collider1.dim.radius = sCylinderInit2.dim.radius + (phi_v0 * 2); - this->actor.shape.rot.x = 0xC000 - (phi_v0 << 8); - this->actor.shape.rot.y += phi_v0 * 0x2C0; + this->attackCollider.dim.radius = sAttackCylinderInit.dim.radius + (temp * 2); + this->actor.shape.rot.x = 0xC000 - temp * 0x100; + this->actor.shape.rot.y += temp * 0x2C0; this->actor.world.pos.y = (Math_SinS(this->actor.shape.rot.x) * -60.0f) + this->actor.home.pos.y; - sp28 = Math_CosS(this->actor.shape.rot.x) * 60.0f; - this->actor.world.pos.x = (Math_SinS(this->actor.shape.rot.y) * sp28) + this->actor.home.pos.x; - this->actor.world.pos.z = (Math_CosS(this->actor.shape.rot.y) * sp28) + this->actor.home.pos.z; + headDistHorizontal = Math_CosS(this->actor.shape.rot.x) * 60.0f; + this->actor.world.pos.x = (Math_SinS(this->actor.shape.rot.y) * headDistHorizontal) + this->actor.home.pos.x; + this->actor.world.pos.z = (Math_CosS(this->actor.shape.rot.y) * headDistHorizontal) + this->actor.home.pos.z; - if (this->collider2.base.acFlags & AC_HIT) { - func_808F13FC(this, play); - func_808F1BF8(this); + if (this->hurtCollider.base.acFlags & AC_HIT) { + EnKarebaba_SetDamageEffects(this, play); + EnKarebaba_SetupDying(this); Enemy_StartFinishingBlow(play, &this->actor); - } else if (this->unk_1EE == 0) { - func_808F1878(this); + } else if (this->timer == 0) { + EnKarebaba_SetupUpright(this); } } -void func_808F1BF8(EnKarebaba* this) { +void EnKarebaba_SetupDying(EnKarebaba* this) { if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { - this->unk_1EE = 0; + this->timer = 0; this->actor.gravity = -0.8f; this->actor.velocity.y = 4.0f; this->actor.world.rot.y = BINANG_ROT180(this->actor.shape.rot.y); - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; } else { - this->unk_1EE = 3; + this->timer = 3; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKU_JR_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKU_JR_DEAD); this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); - this->actionFunc = func_808F1C84; + this->actionFunc = EnKarebaba_Dying; } -void func_808F1C84(EnKarebaba* this, PlayState* play) { +void EnKarebaba_Dying(EnKarebaba* this, PlayState* play) { s32 i; - Vec3f sp78; - f32 temp_f20; - f32 temp_f22; - f32 temp_f24; + Vec3f dustPos; + f32 xIncr; + f32 zIncr; + f32 yIncr; if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { - this->unk_1EE--; - if (this->unk_1EE == 0) { + this->timer--; + if (this->timer == 0) { this->actor.gravity = -0.8f; - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; this->actor.velocity.y = 4.0f; this->actor.world.rot.y = BINANG_ROT180(this->actor.shape.rot.y); - func_808F1374(this, play); + EnKarebaba_SpawnIceEffects(this, play); } } else { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.1f); + Math_StepToF(&this->actor.speed, 0.0f, 0.1f); - if (this->unk_1EE == 0) { + if (this->timer == 0) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4800, 0x71C); EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); - if ((this->actor.scale.x > 0.005f) && ((this->actor.bgCheckFlags & 2) || (this->actor.bgCheckFlags & 8))) { + if ((this->actor.scale.x > 0.005f) && ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) || + (this->actor.bgCheckFlags & BGCHECKFLAG_WALL))) { this->actor.scale.z = 0.0f; this->actor.scale.y = 0.0f; this->actor.scale.x = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 3.0f, 0, 12, 5, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); } - if (this->actor.bgCheckFlags & 2) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); - this->unk_1EE = 1; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + this->timer = 1; } - } else if (this->unk_1EE == 1) { - Math_Vec3f_Copy(&sp78, &this->actor.world.pos); + } else if (this->timer == 1) { + Math_Vec3f_Copy(&dustPos, &this->actor.world.pos); - temp_f24 = Math_SinS(this->actor.shape.rot.x) * 20.0f; - temp_f20 = (-20.0f * Math_CosS(this->actor.shape.rot.x)) * Math_SinS(this->actor.shape.rot.y); - temp_f22 = (-20.0f * Math_CosS(this->actor.shape.rot.x)) * Math_CosS(this->actor.shape.rot.y); + yIncr = Math_SinS(this->actor.shape.rot.x) * 20.0f; + xIncr = -20.0f * Math_CosS(this->actor.shape.rot.x) * Math_SinS(this->actor.shape.rot.y); + zIncr = -20.0f * Math_CosS(this->actor.shape.rot.x) * Math_CosS(this->actor.shape.rot.y); for (i = 0; i < 4; i++) { - func_800B1210(play, &sp78, &gZeroVec3f, &gZeroVec3f, 500, 50); - sp78.x += temp_f20; - sp78.y += temp_f24; - sp78.z += temp_f22; + func_800B1210(play, &dustPos, &gZeroVec3f, &gZeroVec3f, 500, 50); + dustPos.x += xIncr; + dustPos.y += yIncr; + dustPos.z += zIncr; } func_800B1210(play, &this->actor.home.pos, &gZeroVec3f, &gZeroVec3f, 500, 100); - func_808F20FC(this, play); + EnKarebaba_SetupDeadItemDrop(this, play); } } } -void func_808F1FAC(EnKarebaba* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKU_JR_DEAD); +void EnKarebaba_SetupShrinkDie(EnKarebaba* this) { + Actor_PlaySfx(&this->actor, NA_SE_EN_DEKU_JR_DEAD); this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); this->actor.flags &= ~ACTOR_FLAG_1; if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { - this->unk_1EE = 3; + this->timer = 3; } - this->actionFunc = func_808F200C; + this->actionFunc = EnKarebaba_ShrinkDie; } -void func_808F200C(EnKarebaba* this, PlayState* play) { +void EnKarebaba_ShrinkDie(EnKarebaba* this, PlayState* play) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { - this->unk_1EE--; - if (this->unk_1EE == 0) { - func_808F1374(this, play); + this->timer--; + if (this->timer == 0) { + EnKarebaba_SpawnIceEffects(this, play); } } else { if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.0005f)) { Item_DropCollectible(play, &this->actor.world.pos, ITEM00_NUTS_1); - func_808F238C(this); + EnKarebaba_SetupDead(this); } else { EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 1.0f); } - this->actor.scale.y = this->actor.scale.x; - this->actor.scale.z = this->actor.scale.x; + + this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; } } -void func_808F20FC(EnKarebaba* this, PlayState* play) { +void EnKarebaba_SetupDeadItemDrop(EnKarebaba* this, PlayState* play) { Actor_SetScale(&this->actor, 0.03f); this->actor.shape.rot.x -= 0x4000; this->actor.shape.yOffset = 1000.0f; this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; this->actor.shape.shadowScale = 3.0f; - func_800BC154(play, &play->actorCtx, &this->actor, 8); - this->unk_1EE = 200; + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_MISC); + this->timer = 200; this->actor.flags &= ~ACTOR_FLAG_20; this->drawDmgEffAlpha = 0.0f; - this->actionFunc = func_808F21A4; + this->actionFunc = EnKarebaba_DeadItemDrop; } -void func_808F21A4(EnKarebaba* this, PlayState* play) { - if (this->unk_1EE != 0) { - this->unk_1EE--; +void EnKarebaba_DeadItemDrop(EnKarebaba* this, PlayState* play) { + if (this->timer != 0) { + this->timer--; } - if (Actor_HasParent(&this->actor, play) || (this->unk_1EE == 0)) { - func_808F238C(this); + if (Actor_HasParent(&this->actor, play) || (this->timer == 0)) { + EnKarebaba_SetupDead(this); } else { - Actor_PickUpNearby(&this->actor, play, GI_STICKS_1); + Actor_OfferGetItemNearby(&this->actor, play, GI_STICKS_1); } } -void func_808F220C(EnKarebaba* this) { - Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, -3.0f, - Animation_GetLastFrame(&object_dekubaba_Anim_0002B8), 0.0f, ANIMMODE_ONCE, -3.0f); - func_808F152C(this); - this->actionFunc = func_808F228C; +void EnKarebaba_SetupRetract(EnKarebaba* this) { + Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, -3.0f, Animation_GetLastFrame(&gDekuBabaFastChompAnim), + 0.0f, ANIMMODE_ONCE, -3.0f); + EnKarebaba_ResetColliders(this); + this->actionFunc = EnKarebaba_Retract; } -void func_808F228C(EnKarebaba* this, PlayState* play) { +void EnKarebaba_Retract(EnKarebaba* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Math_StepToF(&this->actor.scale.x, 0.005f, 0.0005f) && (this->actor.params == ENKAREBABA_2)) { - func_808F1648(this); + if (Math_StepToF(&this->actor.scale.x, 0.005f, 0.0005f) && (this->actor.params == KAREBABA_MINI)) { + EnKarebaba_SetupIdle(this); } - this->actor.scale.z = this->actor.scale.x; - this->actor.scale.y = this->actor.scale.x; + this->actor.scale.y = this->actor.scale.z = this->actor.scale.x; if ((this->actor.params == ENKAREBABA_1) && Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 14.0f, 5.0f)) { - func_808F1648(this); + EnKarebaba_SetupIdle(this); } - this->actor.shape.rot.y += 0x1999; + this->actor.shape.rot.y += 0x10000 / 10; EffectSsHahen_SpawnBurst(play, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, HAHEN_OBJECT_DEFAULT, 10, NULL); } -void func_808F238C(EnKarebaba* this) { - Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); - func_808F152C(this); +void EnKarebaba_SetupDead(EnKarebaba* this) { + Animation_Change(&this->skelAnime, &gDekuBabaFastChompAnim, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); + EnKarebaba_ResetColliders(this); this->actor.shape.rot.x = -0x4000; - this->unk_1EE = 200; + this->timer = 200; this->actor.parent = NULL; this->actor.shape.shadowScale = 0.0f; this->drawDmgEffAlpha = 0.0f; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); - this->actionFunc = func_808F254C; + this->actionFunc = EnKarebaba_Dead; } -void func_808F241C(EnKarebaba* this, PlayState* play) { - f32 sp1C; +void EnKarebaba_Regrow(EnKarebaba* this, PlayState* play) { + f32 scale; - this->unk_1EE++; - sp1C = this->unk_1EE * 0.05f; - Actor_SetScale(&this->actor, 0.005f * sp1C); - this->actor.world.pos.y = this->actor.home.pos.y + (14.0f * sp1C); + this->timer++; + scale = this->timer * 0.05f; + Actor_SetScale(&this->actor, 0.005f * scale); + this->actor.world.pos.y = this->actor.home.pos.y + (14.0f * scale); - if (this->unk_1EE == 20) { + if (this->timer == 20) { this->actor.flags &= ~ACTOR_FLAG_10; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); if (this->actor.params == ENKAREBABA_1) { - func_800BC154(play, &play->actorCtx, &this->actor, 5); + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_ENEMY); } - func_808F1648(this); + EnKarebaba_SetupIdle(this); } } -void func_808F24F8(EnKarebaba* this) { +void EnKarebaba_SetupRegrow(EnKarebaba* this) { this->actor.shape.yOffset = 0.0f; this->actor.shape.shadowScale = 22.0f; - this->collider1.dim.radius = sCylinderInit2.dim.radius; + this->attackCollider.dim.radius = sAttackCylinderInit.dim.radius; Actor_SetScale(&this->actor, 0.0f); - this->actionFunc = func_808F241C; + this->actionFunc = EnKarebaba_Regrow; } -void func_808F254C(EnKarebaba* this, PlayState* play) { +void EnKarebaba_Dead(EnKarebaba* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (this->unk_1EE != 0) { - this->unk_1EE--; + if (this->timer != 0) { + this->timer--; } - if (this->unk_1EE == 0) { - func_808F24F8(this); + if (this->timer == 0) { + EnKarebaba_SetupRegrow(this); } } @@ -591,30 +594,31 @@ void EnKarebaba_Update(Actor* thisx, PlayState* play2) { } else { this->drawDmgEffScale = this->drawDmgEffScale; } - } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, 0.75f / 40)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } - if (this->actionFunc != func_808F254C) { - if (this->actionFunc == func_808F1C84) { + if (this->actionFunc != EnKarebaba_Dead) { + if (this->actionFunc == EnKarebaba_Dying) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 15.0f, 10.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 15.0f, 10.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } else { - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); - if (this->unk_22C == 0) { - this->unk_22C = this->actor.floorPoly; + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); + if (this->boundFloor == 0) { + this->boundFloor = this->actor.floorPoly; } } - if ((this->actionFunc != func_808F1C84) && (this->actionFunc != func_808F200C) && - (this->actionFunc != func_808F21A4)) { - if ((this->actionFunc != func_808F241C) && (this->actionFunc != func_808F15B0)) { - CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider1.base); - CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider2.base); + if ((this->actionFunc != EnKarebaba_Dying) && (this->actionFunc != EnKarebaba_ShrinkDie) && + (this->actionFunc != EnKarebaba_DeadItemDrop)) { + if ((this->actionFunc != EnKarebaba_Regrow) && (this->actionFunc != EnKarebaba_Grow)) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->attackCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->hurtCollider.base); } - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->attackCollider.base); Actor_SetFocus(&this->actor, (this->actor.scale.x * 10.0f) / 0.01f); max = this->actor.home.pos.y + 40.0f; @@ -625,8 +629,8 @@ void EnKarebaba_Update(Actor* thisx, PlayState* play2) { } } -void func_808F280C(EnKarebaba* this, PlayState* play) { - MtxF sp40; +void EnKarebaba_DrawShadow(EnKarebaba* this, PlayState* play) { + MtxF mf; OPEN_DISPS(play->state.gfxCtx); @@ -634,10 +638,9 @@ void func_808F280C(EnKarebaba* this, PlayState* play) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); - func_800C0094(this->unk_22C, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, &sp40); - Matrix_Mult(&sp40, MTXMODE_NEW); + func_800C0094(this->boundFloor, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, &mf); + Matrix_Mult(&mf, MTXMODE_NEW); Matrix_Scale(0.15f, 1.0f, 0.15f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); @@ -645,53 +648,53 @@ void func_808F280C(EnKarebaba* this, PlayState* play) { } void EnKarebaba_Draw(Actor* thisx, PlayState* play) { + static Color_RGBA8 sFogColor = { 0, 0, 0, 0 }; + static Gfx* sStemDLists[] = { gDekuBabaStemTopDL, gDekuBabaStemMiddleDL, gDekuBabaStemBaseDL }; EnKarebaba* this = THIS; s32 i; - s32 sp94; + s32 stemSections; s16 limbCount; - f32 sp8C = 0.01f; + f32 scale = 0.01f; OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); - Math_Vec3f_Copy(this->limbPos, &this->actor.world.pos); + Math_Vec3f_Copy(this->bodyPartsPos, &this->actor.world.pos); - if (this->actionFunc == func_808F21A4) { - if ((this->unk_1EE > 40) || (this->unk_1EE & 1)) { + if (this->actionFunc == EnKarebaba_DeadItemDrop) { + if ((this->timer > 40) || (this->timer & 1)) { Matrix_Translate(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_003070); + gSPDisplayList(POLY_OPA_DISP++, gDekuBabaStickDropDL); } - } else if (this->actionFunc != func_808F254C) { - func_800AE2A0(play, &D_808F2E28, 1, 2); + } else if (this->actionFunc != EnKarebaba_Dead) { + func_800AE2A0(play, &sFogColor, 1, 2); SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - if ((this->actionFunc == func_808F241C) || (this->actionFunc == func_808F200C) || - (this->actionFunc == func_808F15B0)) { - sp8C = this->unk_1EE * 0.0005f; + if ((this->actionFunc == EnKarebaba_Regrow) || (this->actionFunc == EnKarebaba_ShrinkDie) || + (this->actionFunc == EnKarebaba_Grow)) { + scale = this->timer * 0.0005f; } - Matrix_Scale(sp8C, sp8C, sp8C, MTXMODE_APPLY); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); Matrix_RotateZYX(this->actor.shape.rot.x, this->actor.shape.rot.y, 0, MTXMODE_APPLY); - if (this->actor.params == ENKAREBABA_2) { - sp94 = 1; - } else if (this->actionFunc == func_808F1C84) { - sp94 = 2; + if (this->actor.params == KAREBABA_MINI) { + stemSections = 1; + } else if (this->actionFunc == EnKarebaba_Dying) { + stemSections = 2; } else { - sp94 = 3; + stemSections = 3; } - for (i = 0; i < sp94; i++) { + for (i = 0; i < stemSections; i++) { Matrix_Translate(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, D_808F2E2C[i]); + gSPDisplayList(POLY_OPA_DISP++, sStemDLists[i]); - Matrix_MultZero(&this->limbPos[1 + i]); - if ((i == 0) && (this->actionFunc == func_808F1C84)) { + Matrix_MultZero(&this->bodyPartsPos[1 + i]); + if ((i == 0) && (this->actionFunc == EnKarebaba_Dying)) { Matrix_MultZero(&this->actor.focus.pos); } } @@ -699,41 +702,39 @@ void EnKarebaba_Draw(Actor* thisx, PlayState* play) { func_800AE5A0(play); } - func_800AE2A0(play, &D_808F2E28, 1, 2); + func_800AE2A0(play, &sFogColor, 1, 2); Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, MTXMODE_NEW); - if (this->actionFunc != func_808F15B0) { - sp8C = 0.01f; + if (this->actionFunc != EnKarebaba_Grow) { + scale = 0.01f; } - Matrix_Scale(sp8C, sp8C, sp8C, MTXMODE_APPLY); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); Matrix_RotateYS(this->actor.home.rot.y, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_0010F0); + gSPDisplayList(POLY_OPA_DISP++, gDekuBabaBaseLeavesDL); - if (this->actionFunc == func_808F1C84) { + if (this->actionFunc == EnKarebaba_Dying) { Matrix_RotateZYX(-0x4000, this->actor.shape.rot.y - this->actor.home.rot.y, 0, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_001828); + gSPDisplayList(POLY_OPA_DISP++, gDekuBabaStemBaseDL); - Matrix_MultZero(&this->limbPos[3]); + Matrix_MultZero(&this->bodyPartsPos[3]); } func_800AE5A0(play); - if (this->actor.params == ENKAREBABA_2) { + if (this->actor.params == KAREBABA_MINI) { limbCount = 1; } else { - limbCount = ARRAY_COUNT(this->limbPos); + limbCount = ARRAY_COUNT(this->bodyPartsPos); } - Actor_DrawDamageEffects(play, &this->actor, this->limbPos, limbCount, this->drawDmgEffScale, + Actor_DrawDamageEffects(play, &this->actor, this->bodyPartsPos, limbCount, this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); - if (this->unk_22C != 0) { - func_808F280C(this, play); + if (this->boundFloor != 0) { + EnKarebaba_DrawShadow(this, play); } CLOSE_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h index 5063a8dbe..aa05aec0a 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h @@ -2,32 +2,33 @@ #define Z_EN_KAREBABA_H #include "global.h" +#include "objects/object_dekubaba/object_dekubaba.h" struct EnKarebaba; typedef void (*EnKarebabaActionFunc)(struct EnKarebaba*, PlayState*); -enum { - /* 0 */ ENKAREBABA_0, - /* 1 */ ENKAREBABA_1, - /* 2 */ ENKAREBABA_2, -}; +typedef enum { + /* 0 */ ENKAREBABA_0, // Unused, always shrinks and drops a Deku Nut + /* 1 */ ENKAREBABA_1, // Drops sticks (Only type OoT has) + /* 2 */ KAREBABA_MINI, +} KarebabaType; typedef struct EnKarebaba { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnKarebabaActionFunc actionFunc; - /* 0x18C */ Vec3s jointTable[8]; - /* 0x1BC */ Vec3s morphTable[8]; + /* 0x18C */ Vec3s jointTable[DEKUBABA_LIMB_MAX]; + /* 0x1BC */ Vec3s morphTable[DEKUBABA_LIMB_MAX]; /* 0x1EC */ u8 drawDmgEffType; - /* 0x1EE */ s16 unk_1EE; + /* 0x1EE */ s16 timer; /* 0x1F0 */ f32 drawDmgEffAlpha; /* 0x1F4 */ f32 drawDmgEffScale; /* 0x1F8 */ f32 drawDmgEffFrozenSteamScale; - /* 0x1FC */ Vec3f limbPos[4]; - /* 0x22C */ CollisionPoly* unk_22C; - /* 0x230 */ ColliderCylinder collider1; - /* 0x27C */ ColliderCylinder collider2; + /* 0x1FC */ Vec3f bodyPartsPos[4]; + /* 0x22C */ CollisionPoly* boundFloor; + /* 0x230 */ ColliderCylinder attackCollider; + /* 0x27C */ ColliderCylinder hurtCollider; } EnKarebaba; // size = 0x2C8 #endif // Z_EN_KAREBABA_H diff --git a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c index d2847a39d..b3b8ca295 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c @@ -71,12 +71,12 @@ void EnKbt_Destroy(Actor* thisx, PlayState* play) { } s32 func_80B33E64(PlayState* play) { - return gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 1; + return gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 & 1; } s32 func_80B33E8C(PlayState* play) { if ((CURRENT_DAY == 3) || - ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 2))) { + ((CURRENT_DAY == 2) && (gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 & 2))) { return true; } return false; diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c index c02b00b5a..c3cdeae33 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Maruta/z_en_maruta.h" #include "objects/object_js/object_js.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnKendoJs*)thisx) @@ -125,7 +125,7 @@ void EnKendoJs_Init(Actor* thisx, PlayState* play) { Actor_Kill(&this->actor); } - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); if (ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) { Path* path = &play->setupPathList[ENKENDOJS_GET_FF00(&this->actor)]; @@ -193,7 +193,8 @@ void func_80B2654C(EnKendoJs* this, PlayState* play) { } else if ((Player_GetMask(play) != PLAYER_MASK_NONE) && (Player_GetMask(play) < PLAYER_MASK_GIANT)) { u16 sp2E = Player_GetMask(play) + 0x273C; - if (0) {} + //! FAKE: + if (1) {} Message_StartTextbox(play, sp2E, &this->actor); this->unk_288 = sp2E; @@ -223,7 +224,7 @@ void func_80B26758(EnKendoJs* this, PlayState* play) { Message_StartTextbox(play, 0x272C, &this->actor); this->unk_288 = 0x272C; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); - } else if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + } else if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x2718, &this->actor); this->unk_288 = 0x2718; @@ -241,7 +242,7 @@ void func_80B26758(EnKendoJs* this, PlayState* play) { Message_StartTextbox(play, 0x272C, &this->actor); this->unk_288 = 0x272C; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); - } else if (gSaveContext.save.playerData.rupees < play->msgCtx.unk12070) { + } else if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk12070) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x2718, &this->actor); this->unk_288 = 0x2718; @@ -280,13 +281,13 @@ void func_80B269A4(EnKendoJs* this, PlayState* play) { break; case 0x2719: - func_801477B4(play); + Message_CloseTextbox(play); player->stateFlags1 |= PLAYER_STATE1_20; func_80B2701C(this); break; case 0x271A: - func_801477B4(play); + Message_CloseTextbox(play); func_80B2714C(this); break; @@ -296,14 +297,14 @@ void func_80B269A4(EnKendoJs* this, PlayState* play) { break; case 0x273B: - func_801477B4(play); + Message_CloseTextbox(play); Interface_InitMinigame(play); player->stateFlags1 |= PLAYER_STATE1_20; func_80B273D0(this); break; case 0x272D: - func_801477B4(play); + Message_CloseTextbox(play); gSaveContext.minigameStatus = MINIGAME_STATUS_END; func_80B276C4(this); func_80B276D8(this, play); @@ -460,7 +461,7 @@ s32 func_80B26F6C(EnKendoJs* this, PlayState* play) { switch (this->unk_288) { case 0x271D: - if (Player_GetMeleeWeaponHeld(player) != 0) { + if (Player_GetMeleeWeaponHeld(player) != PLAYER_MELEEWEAPON_NONE) { Message_StartTextbox(play, 0x272A, &this->actor); this->unk_288 = 0x272A; return true; @@ -523,7 +524,7 @@ void func_80B27188(EnKendoJs* this, PlayState* play) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); } this->unk_286 = 2; - func_801477B4(play); + Message_CloseTextbox(play); player->stateFlags1 &= ~PLAYER_STATE1_20; } } else if (this->unk_286 == 2) { @@ -534,13 +535,13 @@ void func_80B27188(EnKendoJs* this, PlayState* play) { switch (func_80B26BF8(this, play)) { case 0: this->unk_286 = 0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); player->stateFlags1 |= PLAYER_STATE1_20; func_80B26EB4(this, play); break; case 1: - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + Actor_PlaySfx(&this->actor, NA_SE_SY_ERROR); this->unk_286 = 0; player->stateFlags1 |= PLAYER_STATE1_20; Message_StartTextbox(play, 0x2729, &this->actor); @@ -634,7 +635,7 @@ void func_80B274BC(EnKendoJs* this, PlayState* play) { } else { play->interfaceCtx.minigamePoints = 1; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); this->unk_28E = 0; } func_80B2783C(this, play); @@ -649,9 +650,9 @@ void func_80B276D8(EnKendoJs* this, PlayState* play) { this->actor.parent = NULL; func_80B27760(this); } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_63_20)) { - Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 800.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 800.0f, 100.0f); } else { - Actor_PickUp(&this->actor, play, GI_RUPEE_RED, 800.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_RED, 800.0f, 100.0f); } } @@ -674,14 +675,14 @@ void func_80B27774(EnKendoJs* this, PlayState* play) { func_80B26AE8(this); player->stateFlags1 &= ~PLAYER_STATE1_20; } else { - func_800B85E0(&this->actor, play, 1000.0f, -1); + func_800B85E0(&this->actor, play, 1000.0f, PLAYER_IA_MINUS1); } } void func_80B2783C(EnKendoJs* this, PlayState* play) { - if (this->actor.cutscene != -1) { - Camera_ChangeDataIdx(play->cameraPtrs[CAM_ID_MAIN], - ActorCutscene_GetCutscene(this->actor.cutscene)->csCamSceneDataId); + if (this->actor.csId != CS_ID_NONE) { + Camera_ChangeActorCsCamIndex(play->cameraPtrs[CAM_ID_MAIN], + CutsceneManager_GetCutsceneEntry(this->actor.csId)->csCamId); } } 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 f188e1df0..f30f55a33 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -45,7 +45,7 @@ ActorInit En_Kgy_InitVars = { void EnKgy_Init(Actor* thisx, PlayState* play) { EnKgy* this = THIS; - s16 cs; + s16 csId; s32 i; Actor_SetScale(&this->actor, 0.01f); @@ -58,7 +58,8 @@ void EnKgy_Init(Actor* thisx, PlayState* play) { this->zubora = EnKgy_FindZubora(play); this->iceBlock = EnKgy_FindIceBlock(play); Flags_UnsetSwitch(play, ENKGY_GET_FE00(&this->actor) + 1); - if (Flags_GetSwitch(play, ENKGY_GET_FE00(&this->actor)) || CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { + if (Flags_GetSwitch(play, ENKGY_GET_FE00(&this->actor)) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE)) { Flags_SetSwitch(play, ENKGY_GET_FE00(&this->actor) + 1); play->envCtx.lightSettingOverride = 1; SET_WEEKEVENTREG(WEEKEVENTREG_21_01); @@ -86,12 +87,12 @@ void EnKgy_Init(Actor* thisx, PlayState* play) { this->actionFunc = func_80B42D28; } - cs = this->actor.cutscene; - for (i = 0; i < ARRAY_COUNT(this->unk_2D4); i++) { - this->unk_2D4[i] = cs; - if (cs != -1) { - this->actor.cutscene = cs; - cs = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + csId = this->actor.csId; + for (i = 0; i < ARRAY_COUNT(this->csIdList); i++) { + this->csIdList[i] = csId; + if (csId != CS_ID_NONE) { + this->actor.csId = csId; + csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); } } @@ -151,33 +152,33 @@ ObjIcePoly* EnKgy_FindIceBlock(PlayState* play) { } void func_80B40C74(PlayState* play) { - gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 |= 1; + gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 |= 1; if (CURRENT_DAY == 1) { - gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 |= 2; + gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 |= 2; } else { - gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 &= ~2; + gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 &= ~2; } } void func_80B40D00(PlayState* play) { - gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 |= 4; + gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 |= 4; } void func_80B40D30(PlayState* play) { - gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 &= ~7; + gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 &= ~7; } s32 func_80B40D64(PlayState* play) { - return gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 1; + return gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 & 1; } s32 func_80B40D8C(PlayState* play) { - return gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 4; + return gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 & 4; } s32 func_80B40DB4(PlayState* play) { if ((CURRENT_DAY == 3) || - ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 2))) { + ((CURRENT_DAY == 2) && (gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 & 2))) { return true; } return false; @@ -203,7 +204,7 @@ s32 func_80B40E54(EnKgy* this) { } void func_80B40E74(EnKgy* this, PlayState* play, u16 textId) { - func_80151938(play, textId); + Message_ContinueTextbox(play, textId); this->actor.textId = textId; func_80B40E18(this, this->actor.textId); } @@ -227,14 +228,14 @@ void func_80B40EE8(EnKgy* this, PlayState* play) { } } - if ((this->unk_2E0 != -1) && (ActorCutscene_GetCurrentIndex() != this->unk_2D4[this->unk_2E0])) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_2D4[this->unk_2E0]); - } else if (ActorCutscene_GetCanPlayNext(this->unk_2D4[this->unk_2E0])) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[this->unk_2E0], &this->actor); + if ((this->csIdIndex != -1) && (CutsceneManager_GetCurrentCsId() != this->csIdList[this->csIdIndex])) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); + } else if (CutsceneManager_IsNext(this->csIdList[this->csIdIndex])) { + CutsceneManager_StartWithPlayerCs(this->csIdList[this->csIdIndex], &this->actor); } else { - ActorCutscene_SetIntentToPlay(this->unk_2D4[this->unk_2E0]); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); } } @@ -250,7 +251,7 @@ void func_80B40EE8(EnKgy* this, PlayState* play) { } if (((temp_f0 < 0.15f) && (temp_f0 > -0.15f)) || (this->unk_2E6 == 0)) { - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); this->unk_29C &= ~0x2; func_80B40E18(this, this->actor.textId); @@ -304,7 +305,7 @@ void func_80B411DC(EnKgy* this, PlayState* play, s32 arg2) { case 0: this->unk_2B4 = this->unk_2A8; this->actor.focus.pos = this->unk_2A8; - this->unk_2E0 = 0; + this->csIdIndex = 0; break; case 1: @@ -312,7 +313,7 @@ void func_80B411DC(EnKgy* this, PlayState* play, s32 arg2) { this->unk_2B4 = this->zubora->actor.focus.pos; this->actor.focus.pos = this->zubora->actor.focus.pos; } - this->unk_2E0 = 1; + this->csIdIndex = 1; break; case 2: @@ -320,7 +321,7 @@ void func_80B411DC(EnKgy* this, PlayState* play, s32 arg2) { this->unk_2B4 = this->iceBlock->actor.world.pos; this->actor.focus.pos = this->iceBlock->actor.focus.pos; } - this->unk_2E0 = 2; + this->csIdIndex = 2; break; case 3: @@ -328,7 +329,7 @@ void func_80B411DC(EnKgy* this, PlayState* play, s32 arg2) { if (this->zubora != NULL) { this->actor.focus.pos = this->zubora->actor.focus.pos; } - this->unk_2E0 = 3; + this->csIdIndex = 3; break; case 4: @@ -336,13 +337,13 @@ void func_80B411DC(EnKgy* this, PlayState* play, s32 arg2) { this->unk_2B4 = this->zubora->actor.focus.pos; this->actor.focus.pos = this->zubora->actor.focus.pos; } - this->unk_2E0 = 4; + this->csIdIndex = 4; break; } } void func_80B41368(EnKgy* this, PlayState* play, s32 arg2) { - ActorCutscene_Stop(this->unk_2D4[this->unk_2E0]); + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); func_80B411DC(this, play, arg2); this->unk_2E6 = 20; this->unk_29C |= 2; @@ -353,8 +354,8 @@ void func_80B413C8(EnKgy* this) { this->unk_2B4 = sp1C; this->actor.focus.pos = sp1C; - ActorCutscene_Stop(this->unk_2D4[this->unk_2E0]); - this->unk_2E0 = -1; + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); + this->csIdIndex = -1; this->unk_2E6 = 0; this->unk_29C &= ~2; } @@ -443,7 +444,7 @@ void func_80B4163C(EnKgy* this, PlayState* play) { this->lightInfo.params.point.y = this->unk_2C0.y; this->lightInfo.params.point.z = this->unk_2C0.z; this->unk_300 = 200; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SWORD_FORGE); + Actor_PlaySfx(&this->actor, NA_SE_EV_SWORD_FORGE); break; } @@ -456,9 +457,9 @@ void func_80B4163C(EnKgy* this, PlayState* play) { void func_80B417B8(EnKgy* this, PlayState* play) { func_80B4163C(this, play); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); func_80B413C8(this); - this->actor.flags &= ~ACTOR_FLAG_100; + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; this->actionFunc = func_80B419B0; func_80B40E18(this, 7); } @@ -467,12 +468,12 @@ void func_80B417B8(EnKgy* this, PlayState* play) { void func_80B41858(EnKgy* this, PlayState* play) { func_80B4163C(this, play); - if (ActorCutscene_GetCanPlayNext(this->unk_2D4[5])) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[5], &this->actor); + if (CutsceneManager_IsNext(this->csIdList[5])) { + CutsceneManager_StartWithPlayerCs(this->csIdList[5], &this->actor); this->actionFunc = func_80B419B0; func_80B40E18(this, 7); } else { - ActorCutscene_SetIntentToPlay(this->unk_2D4[5]); + CutsceneManager_Queue(this->csIdList[5]); } } @@ -481,12 +482,12 @@ void func_80B418C4(EnKgy* this, PlayState* play) { if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && (Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play) && ((play->msgCtx.currentTextId == 0xC4E) || (play->msgCtx.currentTextId == 0xC4F))) { - func_801477B4(play); + Message_CloseTextbox(play); this->actor.textId = 0xC4F; func_80B413C8(this); - ActorCutscene_SetIntentToPlay(this->unk_2D4[5]); + CutsceneManager_Queue(this->csIdList[5]); this->actionFunc = func_80B41858; - this->actor.flags &= ~ACTOR_FLAG_100; + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; } func_80B40EE8(this, play); } @@ -529,7 +530,7 @@ void func_80B41ACC(EnKgy* this, PlayState* play) { } if (itemAction > PLAYER_IA_NONE) { - func_801477B4(play); + Message_CloseTextbox(play); if (itemAction == PLAYER_IA_BOTTLE_GOLD_DUST) { if (this->unk_29C & 0x10) { this->actor.textId = 0xC55; @@ -573,7 +574,7 @@ void func_80B41C54(EnKgy* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Actor_TextboxIsClosing(&this->actor, play)) { this->actionFunc = func_80B41C30; - this->actor.flags &= ~ACTOR_FLAG_100; + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; } func_80B40EE8(this, play); } @@ -597,7 +598,7 @@ void func_80B41D64(EnKgy* this, PlayState* play) { this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_MINUS1); } else { - Actor_PickUp(&this->actor, play, this->unk_2EA, 2000.0f, 1000.0f); + Actor_OfferGetItem(&this->actor, play, this->unk_2EA, 2000.0f, 1000.0f); } func_80B40EE8(this, play); } @@ -621,7 +622,7 @@ void func_80B41E18(EnKgy* this, PlayState* play) { case 0xC3B: switch (play->msgCtx.choiceIndex) { case 0: - if (gSaveContext.save.playerData.rupees < play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { play_sound(NA_SE_SY_ERROR); func_80B40E74(this, play, 0xC3F); } else { @@ -678,7 +679,7 @@ void func_80B41E18(EnKgy* this, PlayState* play) { case 0xC39: case 0xC52: case 0xC54: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B425A0; func_80B413C8(this); func_80B40E18(this, 5); @@ -698,7 +699,7 @@ void func_80B41E18(EnKgy* this, PlayState* play) { break; case 0xC3D: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B41C54; this->actor.textId = 0xC3E; func_80B413C8(this); @@ -734,7 +735,7 @@ void func_80B41E18(EnKgy* this, PlayState* play) { case 0xC57: this->unk_29C &= ~0x8; - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B41C54; this->actor.textId = 0xC58; func_80B413C8(this); @@ -743,7 +744,7 @@ void func_80B41E18(EnKgy* this, PlayState* play) { case 0xC46: case 0xC55: - Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_BOTTLE); + Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_BOTTLE_EMPTY); player->exchangeItemId = PLAYER_IA_NONE; this->unk_29C &= ~0x8; play->msgCtx.msgLength = 0; @@ -780,7 +781,7 @@ void func_80B41E18(EnKgy* this, PlayState* play) { case 0xC4A: case 0xC4B: func_80B40BC0(this, 4); - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B41C54; this->actor.textId = 0xC4B; func_80B413C8(this); @@ -795,10 +796,10 @@ void func_80B41E18(EnKgy* this, PlayState* play) { this->unk_2EA = 56; this->actor.textId = 0xC51; } - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B41D64; func_80B413C8(this); - Actor_PickUp(&this->actor, play, this->unk_2EA, 2000.0f, 1000.0f); + Actor_OfferGetItem(&this->actor, play, this->unk_2EA, 2000.0f, 1000.0f); break; case 0xC51: @@ -810,7 +811,7 @@ void func_80B41E18(EnKgy* this, PlayState* play) { break; case 0xC56: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B41C54; this->actor.textId = 0xC56; func_80B413C8(this); @@ -855,9 +856,9 @@ void func_80B42660(EnKgy* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); func_80B413C8(this); - this->actor.flags &= ~ACTOR_FLAG_100; + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; this->actionFunc = func_80B42714; func_80B40E18(this, 7); } @@ -918,7 +919,7 @@ void func_80B427C8(EnKgy* this, PlayState* play) { break; case 0xC34: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B41C54; func_80B413C8(this); func_80B40E18(this, 6); @@ -1032,7 +1033,7 @@ void func_80B42A8C(EnKgy* this, PlayState* play) { case 0xC2C: case 0xC2F: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B42D28; func_80B413C8(this); func_80B40E18(this, 1); @@ -1134,7 +1135,7 @@ void func_80B43074(EnKgy* this, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); - func_800B8050(&this->actor, play, MTXMODE_NEW); + func_800B8050(&this->actor, play, 0); Matrix_Push(); Matrix_Translate(-800.0f, 3100.0f, 8400.0f, MTXMODE_APPLY); Matrix_RotateXS(0x4000, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h index d9423783d..8207678fd 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h @@ -25,8 +25,8 @@ typedef struct EnKgy { /* 0x2C0 */ Vec3f unk_2C0; /* 0x2CC */ Vec3s unk_2CC; /* 0x2D2 */ s16 unk_2D2; - /* 0x2D4 */ s16 unk_2D4[6]; - /* 0x2E0 */ s16 unk_2E0; + /* 0x2D4 */ s16 csIdList[6]; + /* 0x2E0 */ s16 csIdIndex; /* 0x2E2 */ s16 unk_2E2; /* 0x2E4 */ s16 unk_2E4; /* 0x2E6 */ s16 unk_2E6; diff --git a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c index 511a5dc46..f3005ca05 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c @@ -9,7 +9,7 @@ #include "z_en_kujiya.h" #include "objects/object_kujiya/object_kujiya.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnKujiya*)thisx) @@ -46,13 +46,13 @@ ActorInit En_Kujiya_InitVars = { (ActorFunc)EnKujiya_Draw, }; -#define CHECK_LOTTERY_NUMBERS \ - (((u32)((void)0, gSaveContext.save.lotteryCodes[CURRENT_DAY - 1][0]) == \ - ((((void)0, gSaveContext.save.lotteryCodeGuess & 0xFFFF) & 0xF00) >> 8)) && \ - ((u32)((void)0, gSaveContext.save.lotteryCodes[CURRENT_DAY - 1][1]) == \ - ((((void)0, gSaveContext.save.lotteryCodeGuess & 0xFFFF) & 0xF0) >> 4)) && \ - ((u32)((void)0, gSaveContext.save.lotteryCodes[CURRENT_DAY - 1][2]) == \ - (((void)0, gSaveContext.save.lotteryCodeGuess & 0xFFFF) & 0xF))) +#define CHECK_LOTTERY_NUMBERS \ + (((u32)((void)0, gSaveContext.save.saveInfo.lotteryCodes[CURRENT_DAY - 1][0]) == \ + ((((void)0, gSaveContext.save.saveInfo.lotteryCodeGuess & 0xFFFF) & 0xF00) >> 8)) && \ + ((u32)((void)0, gSaveContext.save.saveInfo.lotteryCodes[CURRENT_DAY - 1][1]) == \ + ((((void)0, gSaveContext.save.saveInfo.lotteryCodeGuess & 0xFFFF) & 0xF0) >> 4)) && \ + ((u32)((void)0, gSaveContext.save.saveInfo.lotteryCodes[CURRENT_DAY - 1][2]) == \ + (((void)0, gSaveContext.save.saveInfo.lotteryCodeGuess & 0xFFFF) & 0xF))) void EnKujiya_Init(Actor* thisx, PlayState* play) { EnKujiya* this = THIS; @@ -111,7 +111,7 @@ void EnKujiya_Wait(EnKujiya* this, PlayState* play) { void EnKujiya_HandlePlayerChoice(EnKujiya* this, PlayState* play) { if (Message_ShouldAdvance(play)) { if (play->msgCtx.choiceIndex == 0) { // Buy - if (gSaveContext.save.playerData.rupees < 10) { + if (gSaveContext.save.saveInfo.playerData.rupees < 10) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x2B62, &this->actor); this->textId = 0x2B62; // Not enough Rupees @@ -147,7 +147,7 @@ void EnKujiya_ChooseNextDialogue(EnKujiya* this, PlayState* play) { case 0x2B60: EnKujiya_SetBoughtTicket(); - func_801477B4(play); + Message_CloseTextbox(play); EnKujiya_SetupTurnToClosed(this); break; @@ -169,7 +169,7 @@ void EnKujiya_ChooseNextDialogue(EnKujiya* this, PlayState* play) { break; case 0x2B66: - func_801477B4(play); + Message_CloseTextbox(play); EnKujiya_SetupGivePrize(this); EnKujiya_GivePrize(this, play); break; @@ -218,7 +218,7 @@ void EnKujiya_GivePrize(EnKujiya* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { EnKujiya_SetupFinishGivePrize(this); } else { - Actor_PickUp(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); } } @@ -296,18 +296,18 @@ void EnKujiya_SetupTurnToOpen(EnKujiya* this) { } void EnKujiya_TurnToOpen(EnKujiya* this, PlayState* play) { - if (this->actor.cutscene != -1) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (this->actor.csId != CS_ID_NONE) { + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } if (!Math_SmoothStepToS(&this->actor.shape.rot.y, 0x7555, 0xA, 0x16C, 0x16C)) { if (this->timer > 20) { - if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { - ActorCutscene_Stop(this->actor.cutscene); + if (CutsceneManager_GetCurrentCsId() == this->actor.csId) { + CutsceneManager_Stop(this->actor.csId); } EnKujiya_SetupWait(this); } else { @@ -324,18 +324,18 @@ void EnKujiya_SetupTurnToClosed(EnKujiya* this) { } void EnKujiya_TurnToClosed(EnKujiya* this, PlayState* play) { - if (this->actor.cutscene != -1) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (this->actor.csId != CS_ID_NONE) { + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } if (!Math_SmoothStepToS(&this->actor.shape.rot.y, 0, 0xA, 0x16C, 0x16C)) { if (this->timer > 20) { - if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { - ActorCutscene_Stop(this->actor.cutscene); + if (CutsceneManager_GetCurrentCsId() == this->actor.csId) { + CutsceneManager_Stop(this->actor.csId); } EnKujiya_SetupWait(this); } else { 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 eaf5ea96a..2af87ea90 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -4,6 +4,7 @@ * Description: Grass / Bush */ +#include "prevent_bss_reordering.h" #include "z_en_kusa.h" #include "objects/object_kusa/object_kusa.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -328,7 +329,7 @@ void EnKusa_SpawnBugs(EnKusa* this, PlayState* play) { for (numBugs = 0; numBugs < 3; numBugs++) { Actor* bug = Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, 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, 0); + this->actor.csId, this->actor.halfDaysBits, 0); if (bug == NULL) { break; @@ -365,7 +366,7 @@ void EnKusa_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { this->actor.uncullZoneForward += 1000.0f; } EnKusa_InitCollider(&this->actor, play); @@ -489,7 +490,7 @@ void EnKusa_WaitForInteract(EnKusa* this, PlayState* play) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer < 100.0f) { if (KUSA_GET_TYPE(&this->actor) != ENKUSA_TYPE_GRASS_2) { - Actor_LiftActor(&this->actor, play); + Actor_OfferCarry(&this->actor, play); } } } @@ -511,14 +512,16 @@ void EnKusa_LiftedUp(EnKusa* this, PlayState* play) { if (Actor_HasNoParent(&this->actor, play)) { this->actor.room = play->roomCtx.curRoom.num; EnKusa_SetupFall(this); - this->actor.velocity.x = this->actor.speedXZ * Math_SinS(this->actor.world.rot.y); - this->actor.velocity.z = this->actor.speedXZ * Math_CosS(this->actor.world.rot.y); + this->actor.velocity.x = this->actor.speed * Math_SinS(this->actor.world.rot.y); + this->actor.velocity.z = this->actor.speed * Math_CosS(this->actor.world.rot.y); this->actor.colChkInfo.mass = 80; this->actor.gravity = -0.1f; EnKusa_UpdateVelY(this); EnKusa_RandScaleVecToZero(&this->actor.velocity, 0.005f); Actor_UpdatePos(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + Actor_UpdateBgCheckInfo(play, &this->actor, 7.5f, 35.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40 | + UPDBGCHECKINFO_FLAG_80); this->actor.gravity = -3.2f; } else { pos.x = this->actor.world.pos.x; @@ -551,8 +554,9 @@ void EnKusa_Fall(EnKusa* this, PlayState* play) { this->collider.base.atFlags &= ~AT_HIT; } this->timer++; - if ((this->actor.bgCheckFlags & 0xB) || wasHit || (this->timer >= 100)) { - if (!(this->actor.bgCheckFlags & 0x20)) { + if ((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_WALL)) || wasHit || + (this->timer >= 100)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); } EnKusa_SpawnFragments(this, play); @@ -570,7 +574,7 @@ void EnKusa_Fall(EnKusa* this, PlayState* play) { } } else { - if (this->actor.bgCheckFlags & 0x40) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { contactPos.y = this->actor.world.pos.y + this->actor.depthInWater; for (angleOffset = 0, i = 0; i < 4; i++, angleOffset += 0x4000) { contactPos.x = @@ -592,7 +596,7 @@ void EnKusa_Fall(EnKusa* this, PlayState* play) { rotSpeedXtarget >>= 1; rotSpeedY >>= 1; rotSpeedYtarget >>= 1; - this->actor.bgCheckFlags &= ~0x40; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER_TOUCH; SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); } EnKusa_UpdateVelY(this); @@ -602,7 +606,9 @@ void EnKusa_Fall(EnKusa* this, PlayState* play) { this->actor.shape.rot.y += rotSpeedY; EnKusa_RandScaleVecToZero(&this->actor.velocity, 0.05f); Actor_UpdatePos(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + Actor_UpdateBgCheckInfo(play, &this->actor, 7.5f, 35.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40 | + UPDBGCHECKINFO_FLAG_80); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); @@ -682,7 +688,8 @@ void EnKusa_Update(Actor* thisx, PlayState* play2) { } else { this->actor.shape.yOffset = 0.0f; } - if ((kusaGameplayFrames != play->gameplayFrames) && (play->roomCtx.curRoom.unk3 == 0)) { + if ((kusaGameplayFrames != play->gameplayFrames) && + (play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_0)) { EnKusa_Sway(); kusaGameplayFrames = play->gameplayFrames; } @@ -694,8 +701,9 @@ void EnKusa_DrawBush(Actor* thisx, PlayState* play2) { if ((this->actor.projectedPos.z <= 1200.0f) || ((this->isInWater & 1) && (this->actor.projectedPos.z < 1300.0f))) { - if ((play->roomCtx.curRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract) && - (this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { + if ((play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_0) && + (this->actionFunc == EnKusa_WaitForInteract) && (this->actor.projectedPos.z > -150.0f) && + (this->actor.projectedPos.z < 400.0f)) { EnKusa_ApplySway(&D_80936AD8[this->kusaMtxIdx]); } @@ -723,7 +731,8 @@ void EnKusa_DrawGrass(Actor* thisx, PlayState* play) { if (this->isCut) { Gfx_DrawDListOpa(play, gKusaStump); } else { - if ((play->roomCtx.curRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract)) { + if ((play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_0) && + (this->actionFunc == EnKusa_WaitForInteract)) { if ((this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { EnKusa_ApplySway(&D_80936AD8[this->kusaMtxIdx]); } 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 626ab3f3b..8e2d194a6 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -4,6 +4,7 @@ * Description: Keaton grass */ +#include "prevent_bss_reordering.h" #include "z_en_kusa2.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -101,7 +102,7 @@ void func_80A5B160(EnKusa2* this, PlayState* play) { ptr = this->unk_194; actor = (EnKusa2*)Actor_SpawnAsChildAndCutscene( &play->actorCtx, play, ACTOR_EN_KUSA2, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); + this->actor.world.pos.z, 0, Rand_Next() >> 0x10, 0, 1, this->actor.csId, this->actor.halfDaysBits, NULL); *ptr = actor; if (*ptr != NULL) { @@ -117,7 +118,7 @@ void func_80A5B160(EnKusa2* this, PlayState* play) { actor = (EnKusa2*)Actor_SpawnAsChildAndCutscene( &play->actorCtx, play, ACTOR_EN_KUSA2, (Math_SinS(temp_s1) * 80.0f) + this->actor.world.pos.x, this->actor.world.pos.y, (Math_CosS(temp_s1) * 80.0f) + this->actor.world.pos.z, 0, Rand_Next() >> 0x10, - 0, 1, this->actor.cutscene, this->actor.unk20, NULL); + 0, 1, this->actor.csId, this->actor.halfDaysBits, NULL); *ptr = actor; if (*ptr != NULL) { (*ptr)->actor.room = this->actor.room; @@ -158,7 +159,8 @@ void func_80A5B3BC(EnKusa2* this) { void func_80A5B490(EnKusa2* this, PlayState* play) { Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_KITAN, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, - ENKUSA2_GET_7F00(&this->actor) << 9, this->actor.cutscene, this->actor.unk20, NULL); + ENKUSA2_GET_7F00(&this->actor) << 9, this->actor.csId, this->actor.halfDaysBits, + NULL); } void func_80A5B508(void) { @@ -268,7 +270,8 @@ s32 func_80A5BA58(EnKusa2* this, PlayState* play) { } void func_80A5BAFC(EnKusa2* this, PlayState* play) { - Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 35.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 35.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40); } void func_80A5BB40(EnKusa2* this, PlayState* play, s32 arg2) { @@ -700,7 +703,7 @@ void func_80A5CB74(EnKusa2* this) { sp3E = Rand_S16Offset(-10000, 20000) + this->actor.world.rot.y; if (this->unk_1C0 != NULL) { - sp36 = Actor_YawBetweenActors(&this->actor, &this->unk_1C0->actor); + sp36 = Actor_WorldYawTowardActor(&this->actor, &this->unk_1C0->actor); sp3C = Rand_S16Offset(-4000, 8000) + sp36; } else { sp3C = 0; @@ -975,12 +978,12 @@ void func_80A5D7C4(EnKusa2* this, PlayState* play) { if ((this->unk_1C0 != NULL) && (this->unk_1C0->unk_1BE != 0)) { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; if (this2->unk_1C0 != NULL) { - sp2A = Actor_YawBetweenActors(&this->unk_1C0->actor, &this->actor); + sp2A = Actor_WorldYawTowardActor(&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; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_WALK); func_80A5DC70(this); } @@ -989,7 +992,7 @@ void func_80A5D7C4(EnKusa2* this, PlayState* play) { if (this->actor.xzDistToPlayer < 400.0f) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer < 100.0f) { - Actor_LiftActor(&this->actor, play); + Actor_OfferCarry(&this->actor, play); } } } @@ -1037,7 +1040,7 @@ void func_80A5D9C8(EnKusa2* this, PlayState* play) { this->actor.colChkInfo.mass = 80; this->actor.home.rot.y = this->actor.world.rot.y; this->actor.velocity.y = 12.5f; - this->actor.speedXZ += 3.0f; + this->actor.speed += 3.0f; Actor_MoveWithGravity(&this->actor); func_80A5BAFC(this, play); func_80A5CD0C(this); @@ -1054,7 +1057,7 @@ void func_80A5D9C8(EnKusa2* this, PlayState* play) { this->unk_1D0--; if (this->unk_1D0 <= 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); + Actor_PlaySfx(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); this->unk_1D0 = (Rand_Next() >> 0x1D) + 14; } @@ -1086,12 +1089,12 @@ void func_80A5DC98(EnKusa2* this, PlayState* play) { func_80A5BF38(this, 4); func_80A5BF84(this, play); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { func_80A5CD0C(this); func_80A5BB40(this, play, 1); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_WALK); func_80A5DE18(this); - } else if (this->actor.bgCheckFlags & 0x20) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { func_80A5BDB0(this, play); func_80A5E418(this); } else if (this->unk_1CA > 0) { @@ -1121,14 +1124,14 @@ void func_80A5DEB4(EnKusa2* this, PlayState* play) { if (this->unk_1D0 > 0) { this->unk_1D0--; if (this->unk_1D0 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); + Actor_PlaySfx(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); } } if (this->unk_1D1 > 0) { this->unk_1D1--; if (this->unk_1D1 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); + Actor_PlaySfx(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); } } @@ -1136,10 +1139,10 @@ void func_80A5DEB4(EnKusa2* this, PlayState* play) { Math_StepToF(&this->actor.scale.x, 0.4f, 0.032f); this->unk_1C4 += 0x4650; this->actor.scale.z = this->actor.scale.x; - this->actor.speedXZ = fabsf(Math_CosS(this->unk_1C4) + 0.5f) * 1.5f; + this->actor.speed = fabsf(Math_CosS(this->unk_1C4) + 0.5f) * 1.5f; - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ = 0.0f; + if (this->actor.speed < 0.0f) { + this->actor.speed = 0.0f; } Actor_MoveWithGravity(&this->actor); @@ -1156,7 +1159,7 @@ void func_80A5DEB4(EnKusa2* this, PlayState* play) { func_80A5CD0C(this); } - if (this->actor.bgCheckFlags & 0x20) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { func_80A5BDB0(this, play); func_80A5E418(this); } else { @@ -1164,16 +1167,16 @@ void func_80A5DEB4(EnKusa2* this, PlayState* play) { if (this->unk_1C8 <= 0) { func_80A5CD0C(this); func_80A5BB40(this, play, 4); - this->actor.speedXZ += 4.0f; + this->actor.speed += 4.0f; this->actor.velocity.y = (Rand_ZeroOne() * 4.0f) + 15.0f; func_80A5E1D8(this); - } else if (this->actor.bgCheckFlags & 1) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->unk_1CA--; if (this->unk_1CA <= 0) { func_80A5CD0C(this); func_80A5BB40(this, play, 2); this->actor.velocity.y = (Rand_ZeroOne() * 6.0f) + 7.0f; - this->actor.speedXZ += 2.0f; + this->actor.speed += 2.0f; if (this->actor.yawTowardsPlayer < this->actor.world.rot.y) { sp20 = 10000; } else { @@ -1199,9 +1202,9 @@ void func_80A5E1D8(EnKusa2* this) { void func_80A5E210(EnKusa2* this, PlayState* play) { Math_StepToF(&this->actor.gravity, -4.0f, 0.5f); - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ *= 0.4f; - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.speed *= 0.4f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { func_80A5D178(this); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_KUSAMUSHI_HIDE); } @@ -1228,7 +1231,7 @@ void func_80A5E210(EnKusa2* this, PlayState* play) { if (this->actor.velocity.y > 1.0f) { Math_StepToF(&this->actor.scale.y, 0.24000001f, 0.080000006f); Math_StepToF(&this->actor.scale.x, 0.32000002f, 0.040000003f); - } else if (this->actor.bgCheckFlags & 1) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { Math_StepToF(&this->actor.scale.y, 0.0f, 0.120000005f); Math_StepToF(&this->actor.scale.x, 0.48000002f, 0.120000005f); } else { @@ -1252,7 +1255,7 @@ void func_80A5E418(EnKusa2* this) { this->actor.velocity.y *= 0.25f; this->actor.velocity.z *= 0.1f; this->actor.draw = func_80A5EA48; - this->actor.speedXZ *= 0.1f; + this->actor.speed *= 0.1f; this->actor.gravity *= 0.25f; this->unk_1CC = Rand_S16Offset(-800, 1600); this->actionFunc = func_80A5E4BC; @@ -1268,7 +1271,8 @@ void func_80A5E4BC(EnKusa2* this, PlayState* play) { this->actor.shape.rot.x -= 0x5DC; this->actor.shape.rot.y += this->unk_1CC; - if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 5.0f) && (Rand_ZeroOne() < 0.8f)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER) && (this->actor.depthInWater > 5.0f) && + (Rand_ZeroOne() < 0.8f)) { EffectSsBubble_Spawn(play, &this->actor.world.pos, 20.0f, 10.0f, 20.0f, (Rand_ZeroOne() * 0.08f) + 0.04f); } @@ -1289,7 +1293,7 @@ void func_80A5E604(Actor* thisx, PlayState* play) { } else { this->actor.draw = func_80A5E6F0; - if (play->roomCtx.curRoom.unk3 == 0) { + if (play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_0) { func_80A5B508(); } func_80A5CAF4(&D_80A5F1C0); @@ -1352,7 +1356,7 @@ void EnKusa2_Draw(Actor* thisx, PlayState* play) { EnKusa2* this = THIS; if (this->actor.projectedPos.z <= 1200.0f) { - if ((play->roomCtx.curRoom.unk3 == 0) && (this->actor.projectedPos.z > -150.0f) && + if ((play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_0) && (this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { func_80A5B954(&D_80A60908[this->unk_1CE], 0.0015f); } diff --git a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c index f6647cc0b..0bd619a9c 100644 --- a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c +++ b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c @@ -218,7 +218,7 @@ void EnLiftNuts_Init(Actor* thisx, PlayState* play) { Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); if (this->actor.floorBgId != BGCHECK_SCENE) { DynaPolyActor* bgActor = DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId); @@ -284,7 +284,7 @@ void func_80AE9FC8(EnLiftNuts* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80AEA044; } @@ -301,7 +301,7 @@ void func_80AEA0B4(EnLiftNuts* this) { this->actionFunc = func_80AEA1A0; } else { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80AEA128; } } @@ -393,7 +393,7 @@ void func_80AEA1A0(EnLiftNuts* this, PlayState* play) { } } else { if (((void)0, gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]) >= - gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { + gSaveContext.save.saveInfo.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] < 0x2EE0) { Message_StartTextbox(play, 0x27F9, &this->actor); this->textId = 0x27F9; @@ -452,7 +452,7 @@ void func_80AEA7A4(EnLiftNuts* this, PlayState* play) { switch (this->textId) { case 0x27E2: if (play->msgCtx.choiceIndex == 0) { // Yes - if (gSaveContext.save.playerData.rupees >= 10) { + if (gSaveContext.save.saveInfo.playerData.rupees >= 10) { func_8019F208(); Message_StartTextbox(play, 0x27E5, &this->actor); this->textId = 0x27E5; @@ -511,7 +511,7 @@ void func_80AEA910(EnLiftNuts* this, PlayState* play) { break; case 0x27E5: - func_801477B4(play); + Message_CloseTextbox(play); player->stateFlags1 |= PLAYER_STATE1_20; func_80AEAEAC(this); break; @@ -544,7 +544,7 @@ void func_80AEA910(EnLiftNuts* this, PlayState* play) { break; case 0x27FA: - func_801477B4(play); + Message_CloseTextbox(play); player->stateFlags1 &= ~PLAYER_STATE1_20; func_80AEB114(this); break; @@ -556,7 +556,7 @@ void func_80AEA910(EnLiftNuts* this, PlayState* play) { break; case 0x27EF: - func_801477B4(play); + Message_CloseTextbox(play); func_80AEB584(this); func_80AEB598(this, play); break; @@ -573,13 +573,13 @@ void func_80AEA910(EnLiftNuts* this, PlayState* play) { break; case 0x27F4: - func_801477B4(play); + Message_CloseTextbox(play); func_80AEB584(this); func_80AEB598(this, play); break; case 0x27F5: - func_801477B4(play); + Message_CloseTextbox(play); func_80AE9B4C(1, 0); player->stateFlags1 &= ~PLAYER_STATE1_20; func_80AE9FC8(this); @@ -598,7 +598,7 @@ void func_80AEABF0(EnLiftNuts* this) { if (this->actionFunc != func_80AEB698) { if (func_80AE9B4C(0, 0)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); } Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 16); } @@ -674,7 +674,7 @@ void func_80AEACF8(EnLiftNuts* this, PlayState* play) { } void func_80AEAEAC(EnLiftNuts* this) { - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); func_80AE9AC4(this, 1); func_80AE9B4C(1, 1); @@ -685,7 +685,7 @@ void func_80AEAF14(EnLiftNuts* this, PlayState* play) { f32 dist; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 10, 0x1000, 0x500); - dist = Math_Vec3f_StepTo(&this->actor.world.pos, &this->vec_1D8, this->actor.speedXZ); + dist = Math_Vec3f_StepTo(&this->actor.world.pos, &this->vec_1D8, this->actor.speed); this->actor.world.pos.y += this->actor.gravity; if (dist == 0.0f) { @@ -731,7 +731,7 @@ void func_80AEAFA0(EnLiftNuts* this, PlayState* play) { } void func_80AEB114(EnLiftNuts* this) { - func_801A2BB8(NA_BGM_TIMED_MINI_GAME); + Audio_PlaySubBgm(NA_BGM_TIMED_MINI_GAME); this->actionFunc = func_80AEB148; } @@ -739,18 +739,18 @@ void func_80AEB148(EnLiftNuts* this, PlayState* play) { Player* player = GET_PLAYER(play); if (player->stateFlags3 & PLAYER_STATE3_200) { - this->actor.speedXZ = 2.0f; - gSaveContext.eventInf[3] |= 0x10; + this->actor.speed = 2.0f; + SET_EVENTINF(EVENTINF_34); Interface_StartTimer(4, 0); func_80AE9B4C(1, 2); - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_FOUND); + Actor_PlaySfx(&this->actor, NA_SE_SY_FOUND); func_80AEB280(this); } } void func_80AEB1C8(EnLiftNuts* this) { - this->actor.speedXZ = 2.0f; - gSaveContext.eventInf[3] |= 0x10; + this->actor.speed = 2.0f; + SET_EVENTINF(EVENTINF_34); Interface_StartTimer(4, 0); func_80AE9B4C(1, 2); this->actionFunc = func_80AEB230; @@ -772,7 +772,7 @@ void func_80AEB280(EnLiftNuts* this) { void func_80AEB294(EnLiftNuts* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (((player->actor.bgCheckFlags & 1) && (player->actor.floorBgId == BG_ACTOR_MAX) && + if (((player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (player->actor.floorBgId == BG_ACTOR_MAX) && player->actor.world.pos.y < 20.0f) || gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= 0x2EE0) { player->stateFlags1 |= PLAYER_STATE1_20; @@ -784,7 +784,7 @@ void func_80AEB294(EnLiftNuts* this, PlayState* play) { player->stateFlags1 |= PLAYER_STATE1_20; if (((void)0, gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]) < - gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { + gSaveContext.save.saveInfo.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { Flags_SetSwitch(play, 0x40); } Flags_SetSwitch(play, 0x41); @@ -804,7 +804,7 @@ void func_80AEB428(EnLiftNuts* this, PlayState* play) { if (this->unk_354 == 10) { if (((void)0, gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]) > - gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { + gSaveContext.save.saveInfo.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { Message_StartTextbox(play, 0x27EA, &this->actor); this->textId = 0x27EA; } else if (*this->ptr_1EC == 300) { @@ -815,13 +815,13 @@ void func_80AEB428(EnLiftNuts* this, PlayState* play) { this->textId = 0x27EC; } } else if (this->unk_354 == 30) { - gSaveContext.eventInf[3] &= (u8)~0x10; + CLEAR_EVENTINF(EVENTINF_34); gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance = ENTRANCE(DEKU_SCRUB_PLAYGROUND, 1); gSaveContext.nextCutsceneIndex = 0; func_80169EFC(&play->state); gSaveContext.respawnFlag = -2; play->transitionType = TRANS_TYPE_64; - gSaveContext.nextTransitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; } this->unk_354++; } @@ -839,9 +839,9 @@ void func_80AEB598(EnLiftNuts* this, PlayState* play) { } func_80AEB684(this); } else if ((this->textId == 0x27F4) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_14_80)) { - Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); } else { - Actor_PickUp(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); } } @@ -882,7 +882,7 @@ void func_80AEB698(EnLiftNuts* this, PlayState* play) { break; } } else { - func_800B85E0(&this->actor, play, 200.0f, -1); + func_800B85E0(&this->actor, play, 200.0f, PLAYER_IA_MINUS1); } } @@ -975,7 +975,7 @@ void EnLiftNuts_Update(Actor* thisx, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->actionFunc(this, play); func_80AEBB30(this, play); - Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); func_80AE9BCC(this, play); if (func_80AE9B4C(0, 2)) { diff --git a/src/overlays/actors/ovl_En_Light/z_en_light.c b/src/overlays/actors/ovl_En_Light/z_en_light.c index b988fcce3..830484996 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.c +++ b/src/overlays/actors/ovl_En_Light/z_en_light.c @@ -52,7 +52,7 @@ void EnLight_Init(Actor* thisx, PlayState* play) { EnLight* this = THIS; if (!ENLIGHT_GET_4000(&this->actor)) { - if ((gSaveContext.gameMode == 3) || ENLIGHT_GET_2000(&this->actor)) { + if ((gSaveContext.gameMode == GAMEMODE_END_CREDITS) || ENLIGHT_GET_2000(&this->actor)) { Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, ((this->actor.params < 0) ? 1 : 40) + (s32)this->actor.world.pos.y, this->actor.world.pos.z, 255, 255, 180, -1); @@ -112,7 +112,7 @@ void EnLight_Update(Actor* thisx, PlayState* play) { func_80865BF8(this, play); if ((this->actor.params >= 0) && !ENLIGHT_GET_4000(&this->actor)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); } } @@ -156,7 +156,7 @@ void func_80865F38(Actor* thisx, PlayState* play) { func_80865BF8(this, play); if ((this->actor.params >= 0) && (sp2C == true)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); } } diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index ac376bb16..7cd1c3369 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -111,7 +111,7 @@ void EnLookNuts_Init(Actor* thisx, PlayState* play) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.targetMode = 1; Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->pathLocation = LOOKNUTS_GET_PATROL_LOCATION(&this->actor); this->switchFlag = LOOKNUTS_GET_SCENE_FLAG(&this->actor); this->spawnIndex = LOOKNUTS_GET_SPAWN_INDEX(&this->actor); @@ -151,17 +151,17 @@ void EnLookNuts_Patrol(EnLookNuts* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Play_InCsMode(play)) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; return; } - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_WALK); } if (D_80A6862C != 0) { - Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 1.0f); + Math_ApproachZeroF(&this->actor.speed, 0.3f, 1.0f); return; } @@ -207,7 +207,7 @@ void EnLookNuts_StandAndWait(EnLookNuts* this, PlayState* play) { s16 randOffset; SkelAnime_Update(&this->skelAnime); - Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 1.0f); + Math_ApproachZeroF(&this->actor.speed, 0.3f, 1.0f); if (!Play_InCsMode(play) && (D_80A6862C == 0) && (this->eventTimer == 0)) { this->eventTimer = 10; switch (this->waitTimer) { @@ -273,13 +273,13 @@ void EnLookNuts_DetectedPlayer(EnLookNuts* this, PlayState* play) { void EnLookNuts_RunToPlayer(EnLookNuts* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_WALK); } - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); if ((this->actor.xzDistToPlayer < 70.0f) || (this->eventTimer == 0)) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; EnLookNuts_SetupSendPlayerToSpawn(this); } } @@ -295,7 +295,7 @@ void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); play->nextEntrance = Entrance_CreateFromSpawn(this->spawnIndex); gSaveContext.nextCutsceneIndex = 0; Scene_SetExitFade(play); diff --git a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c index 3d97839a0..0586b2111 100644 --- a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c +++ b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c @@ -129,7 +129,7 @@ void EnMThunder_Init(Actor* thisx, PlayState* play) { this->isCharging = false; if (player->stateFlags2 & PLAYER_STATE2_20000) { - if (!gSaveContext.save.playerData.isMagicAcquired || (gSaveContext.magicState != MAGIC_STATE_IDLE) || + if (!gSaveContext.save.saveInfo.playerData.isMagicAcquired || (gSaveContext.magicState != MAGIC_STATE_IDLE) || ((ENMTHUNDER_GET_MAGIC_COST(&this->actor) != 0) && !Magic_Consume(play, ENMTHUNDER_GET_MAGIC_COST(&this->actor), MAGIC_CONSUME_NOW))) { AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, 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 93f33cfed..1242de4ba 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -142,19 +142,21 @@ void EnMa4_ChangeAnim(EnMa4* this, s32 animIndex) { void func_80ABDD9C(EnMa4* this, PlayState* play) { Player* player = GET_PLAYER(play); - s16 flag; + s16 trackingMode; - if (this->unk_1D8.unk_00 == 0 && + if ((this->interactInfo.talkState == NPC_TALK_STATE_IDLE) && ((this->skelAnime.animation == &gRomaniRunAnim) || (this->skelAnime.animation == &gRomaniLookAroundAnim) || (this->skelAnime.animation == &gRomaniShootBowAnim))) { - flag = 1; + trackingMode = NPC_TRACKING_NONE; } else { - flag = (this->type == MA4_TYPE_ALIENS_WON && this->actionFunc != EnMa4_DialogueHandler) ? 1 : 0; + trackingMode = ((this->type == MA4_TYPE_ALIENS_WON) && (this->actionFunc != EnMa4_DialogueHandler)) + ? NPC_TRACKING_NONE + : NPC_TRACKING_PLAYER_AUTO_TURN; } - this->unk_1D8.unk_18 = player->actor.world.pos; - this->unk_1D8.unk_18.y -= -10.0f; - func_800BD888(&this->actor, &this->unk_1D8, 0, flag); + this->interactInfo.trackPos = player->actor.world.pos; + this->interactInfo.trackPos.y -= -10.0f; + Npc_TrackPoint(&this->actor, &this->interactInfo, 0, trackingMode); } void EnMa4_InitPath(EnMa4* this, PlayState* play) { @@ -188,11 +190,11 @@ void EnMa4_Init(Actor* thisx, PlayState* play) { Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &D_80AC00DC); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 0; - this->unk_1D8.unk_00 = 0; + this->interactInfo.talkState = NPC_TALK_STATE_IDLE; this->unk_334 = 0; this->hasBow = true; this->mouthTexIndex = 0; @@ -260,14 +262,14 @@ void EnMa4_RunInCircles(EnMa4* this, PlayState* play) { sAnimIndex = 13; } } else { - this->actor.speedXZ = 2.7f; + this->actor.speed = 2.7f; EnMa4_ChangeAnim(this, 9); sAnimIndex = 9; } } if (sAnimIndex == 13 && Animation_OnFrame(&this->skelAnime, 37.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROMANI_BOW_FLICK); + Actor_PlaySfx(&this->actor, NA_SE_EV_ROMANI_BOW_FLICK); } sp34.x = this->pathPoints[this->pathIndex].x; @@ -279,7 +281,7 @@ void EnMa4_RunInCircles(EnMa4* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, sp2E, 5, 0x3000, 0x100); } else { if ((D_80AC0254 == 0) && ((Rand_Next() % 4) == 0)) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; D_80AC0254 = 2; EnMa4_ChangeAnim(this, 3); sAnimIndex = 3; @@ -296,11 +298,11 @@ void EnMa4_RunInCircles(EnMa4* this, PlayState* play) { } } - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); Actor_MoveWithGravity(&this->actor); if (this->skelAnime.animation == &gRomaniRunAnim) { if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 4.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_ROMANI_WALK); } } } @@ -309,14 +311,14 @@ void EnMa4_SetupWait(EnMa4* this) { if ((this->state != MA4_STATE_AFTERHORSEBACKGAME) && (this->state != MA4_STATE_AFTERDESCRIBETHEMCS)) { if (this->type != MA4_TYPE_ALIENS_WON) { EnMa4_ChangeAnim(this, 9); - this->actor.speedXZ = 2.7f; + this->actor.speed = 2.7f; } else { EnMa4_ChangeAnim(this, 15); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } } else { EnMa4_ChangeAnim(this, 1); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } this->actor.gravity = -0.2f; @@ -449,7 +451,7 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, PlayState* play) { // "Try again?" if (play->msgCtx.choiceIndex == 0) { // Yes func_8019F208(); - func_801477B4(play); + Message_CloseTextbox(play); EnMa4_SetupBeginHorsebackGame(this); } else { // No if (this->type == MA4_TYPE_ALIENS_DEFEATED) { @@ -492,7 +494,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, PlayState* play) { if (Message_ShouldAdvance(play)) { switch (this->textId) { case 0x2390: - func_801477B4(play); + Message_CloseTextbox(play); EnMa4_SetupBeginHorsebackGame(this); break; @@ -527,7 +529,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, PlayState* play) { break; case 0x333E: - func_801477B4(play); + Message_CloseTextbox(play); EnMa4_SetupBeginDescribeThemCs(this); break; @@ -564,7 +566,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, PlayState* play) { break; case 0x334A: - func_801477B4(play); + Message_CloseTextbox(play); EnMa4_SetupBeginHorsebackGame(this); break; @@ -595,7 +597,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, PlayState* play) { Message_StartTextbox(play, 0x334C, &this->actor); this->textId = 0x334C; } else { - func_801477B4(play); + Message_CloseTextbox(play); player->stateFlags1 |= PLAYER_STATE1_20; EnMa4_SetupBeginEponasSongCs(this); EnMa4_BeginEponasSongCs(this, play); @@ -666,7 +668,7 @@ void EnMa4_BeginHorsebackGame(EnMa4* this, PlayState* play) { gSaveContext.nextCutsceneIndex = 0xFFF0; play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_80; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } void EnMa4_HorsebackGameCheckPlayerInteractions(EnMa4* this, PlayState* play) { @@ -728,8 +730,8 @@ void EnMa4_HorsebackGameWait(EnMa4* this, PlayState* play) { void EnMa4_SetupHorsebackGameEnd(EnMa4* this, PlayState* play) { CLEAR_WEEKEVENTREG(WEEKEVENTREG_08_01); this->actionFunc = EnMa4_HorsebackGameEnd; - Audio_QueueSeqCmd(NA_BGM_STOP); - Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_HORSE_GOAL | SEQ_FLAG_ASYNC); } void EnMa4_HorsebackGameEnd(EnMa4* this, PlayState* play) { @@ -760,10 +762,10 @@ void EnMa4_HorsebackGameEnd(EnMa4* this, PlayState* play) { if (this->poppedBalloonCounter == 10) { play->transitionType = TRANS_TYPE_80; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } else { play->transitionType = TRANS_TYPE_64; - gSaveContext.nextTransitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; } this->poppedBalloonCounter = 0; @@ -778,16 +780,16 @@ void EnMa4_SetupBeginEponasSongCs(EnMa4* this) { // Epona's Song cutscene is an ActorCutscene void EnMa4_BeginEponasSongCs(EnMa4* this, PlayState* play) { - s16 cutsceneIndex = this->actor.cutscene; + s16 csId = this->actor.csId; - if (ActorCutscene_GetCanPlayNext(cutsceneIndex) != 0) { - ActorCutscene_Start(cutsceneIndex, &this->actor); + if (CutsceneManager_IsNext(csId)) { + CutsceneManager_Start(csId, &this->actor); EnMa4_SetupEponasSongCs(this); } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(cutsceneIndex); + CutsceneManager_Queue(csId); } } @@ -796,17 +798,17 @@ void EnMa4_SetupEponasSongCs(EnMa4* this) { this->actionFunc = EnMa4_EponasSongCs; } -static u16 D_80AC0260 = 99; +static u16 sCueId = 99; void EnMa4_EponasSongCs(EnMa4* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 120)) { - s32 actionIndex = Cutscene_GetActorActionIndex(play, 120); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_120)) { + s32 cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_120); - if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { - if (play->csCtx.actorActions[actionIndex]->action != D_80AC0260) { - D_80AC0260 = play->csCtx.actorActions[actionIndex]->action; + if (play->csCtx.curFrame == play->csCtx.actorCues[cueChannel]->startFrame) { + if (sCueId != play->csCtx.actorCues[cueChannel]->id) { + sCueId = play->csCtx.actorCues[cueChannel]->id; this->animTimer = 0; - switch (play->csCtx.actorActions[actionIndex]->action) { + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: this->hasBow = true; EnMa4_ChangeAnim(this, 1); @@ -820,8 +822,8 @@ void EnMa4_EponasSongCs(EnMa4* this, PlayState* play) { } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); - if (D_80AC0260 == 2 && this->animTimer == 0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); + if (sCueId == 2 && this->animTimer == 0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { EnMa4_ChangeAnim(this, 7); } } else { @@ -829,7 +831,7 @@ void EnMa4_EponasSongCs(EnMa4* this, PlayState* play) { player->stateFlags1 |= PLAYER_STATE1_20; func_800B85E0(&this->actor, play, 200.0f, PLAYER_IA_MINUS1); - D_80AC0260 = 99; + sCueId = 99; this->hasBow = true; EnMa4_SetupEndEponasSongCs(this); } @@ -863,7 +865,7 @@ void EnMa4_BeginDescribeThemCs(EnMa4* this, PlayState* play) { gSaveContext.nextCutsceneIndex = 0xFFF5; play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_64; - gSaveContext.nextTransitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; } void EnMa4_StartDialogue(EnMa4* this, PlayState* play) { @@ -905,9 +907,9 @@ void EnMa4_StartDialogue(EnMa4* this, PlayState* play) { this->textId = 0x336D; } else { time = gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]; - if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { + if ((s32)time < (s32)gSaveContext.save.saveInfo.horseBackBalloonHighScore) { // [Score] New record! - gSaveContext.save.horseBackBalloonHighScore = time; + gSaveContext.save.saveInfo.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); Message_StartTextbox(play, 0x3350, &this->actor); this->textId = 0x3350; @@ -949,8 +951,8 @@ void EnMa4_StartDialogue(EnMa4* this, PlayState* play) { this->textId = 0x3356; } else { time = gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]; - if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { - gSaveContext.save.horseBackBalloonHighScore = time; + if ((s32)time < (s32)gSaveContext.save.saveInfo.horseBackBalloonHighScore) { + gSaveContext.save.saveInfo.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); Message_StartTextbox(play, 0x3350, &this->actor); this->textId = 0x3350; @@ -976,9 +978,9 @@ void EnMa4_StartDialogue(EnMa4* this, PlayState* play) { this->textId = 0x3356; } else { time = gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]; - if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { + if ((s32)time < (s32)gSaveContext.save.saveInfo.horseBackBalloonHighScore) { // New record - gSaveContext.save.horseBackBalloonHighScore = time; + gSaveContext.save.saveInfo.horseBackBalloonHighScore = time; Message_StartTextbox(play, 0x335D, &this->actor); this->textId = 0x335D; } else { @@ -1027,17 +1029,17 @@ void EnMa4_Update(Actor* thisx, PlayState* play) { s32 EnMa4_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnMa4* this = THIS; - Vec3s sp4; + Vec3s limbRot; if (limbIndex == ROMANI_LIMB_HEAD) { - sp4 = this->unk_1D8.unk_08; - rot->x = rot->x + sp4.y; - rot->z = rot->z + sp4.x; + limbRot = this->interactInfo.headRot; + rot->x += limbRot.y; + rot->z += limbRot.x; } if (limbIndex == ROMANI_LIMB_TORSO) { - sp4 = this->unk_1D8.unk_0E; - rot->x = rot->x - sp4.y; - rot->z = rot->z - sp4.x; + limbRot = this->interactInfo.torsoRot; + rot->x -= limbRot.y; + rot->z -= limbRot.x; } return false; diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.h b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.h index 3ac405b00..91876c938 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.h +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.h @@ -13,7 +13,7 @@ typedef struct EnMa4 { /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnMa4ActionFunc actionFunc; /* 0x18C */ ColliderCylinder collider; - /* 0x1D8 */ struct_800BD888_arg1 unk_1D8; + /* 0x1D8 */ NpcInteractInfo interactInfo; /* 0x200 */ Vec3s* pathPoints; /* 0x204 */ Vec3s jointTable[ROMANI_LIMB_MAX]; /* 0x28E */ UNK_TYPE1 unk28E[0x6]; 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 c9ba0f34d..6d0b027eb 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 @@ -174,7 +174,7 @@ void EnMaYto_Init(Actor* thisx, PlayState* play) { Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit2); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); if (EnMaYto_TryFindRomani(this, play) == 1) { EnMaYto_SetupKeepLookingForRomani(this); @@ -944,7 +944,7 @@ void EnMaYto_AfterMilkRunChooseNextDialogue(EnMaYto* this, PlayState* play) { break; case 0x33C2: - func_801477B4(play); + Message_CloseTextbox(play); EnMaYto_SetupPostMilkRunGiveReward(this); EnMaYto_PostMilkRunGiveReward(this, play); break; @@ -960,10 +960,10 @@ void EnMaYto_PostMilkRunGiveReward(EnMaYto* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { EnMaYto_SetupPostMilkRunExplainReward(this); } else if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) { - Actor_PickUp(&this->actor, play, GI_RUPEE_HUGE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_HUGE, 500.0f, 100.0f); this->unk310 = 2; } else { - Actor_PickUp(&this->actor, play, GI_MASK_ROMANI, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_MASK_ROMANI, 500.0f, 100.0f); this->unk310 = 1; } } @@ -1005,14 +1005,14 @@ void EnMaYto_SetupBeginWarmFuzzyFeelingCs(EnMaYto* this) { } void EnMaYto_BeginWarmFuzzyFeelingCs(EnMaYto* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); EnMaYto_SetupWarmFuzzyFeelingCs(this); } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -1021,20 +1021,20 @@ void EnMaYto_SetupWarmFuzzyFeelingCs(EnMaYto* this) { this->actionFunc = EnMaYto_WarmFuzzyFeelingCs; } -static u16 D_80B915F0 = 99; +static u16 sCueId = 99; void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 556)) { - s32 csActionIndex = Cutscene_GetActorActionIndex(play, 556); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_556)) { + s32 cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_556); - if (play->csCtx.frames == play->csCtx.actorActions[csActionIndex]->startFrame) { - u16 action = play->csCtx.actorActions[csActionIndex]->action; + if (play->csCtx.curFrame == play->csCtx.actorCues[cueChannel]->startFrame) { + u16 cueId = play->csCtx.actorCues[cueChannel]->id; if (1) {} - if (action != D_80B915F0) { - D_80B915F0 = action; - switch (action) { + if (cueId != sCueId) { + sCueId = cueId; + switch (cueId) { case 1: EnMaYto_ChangeAnim(this, 0); break; @@ -1051,13 +1051,13 @@ void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, PlayState* play) { } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, csActionIndex); - if (D_80B915F0 == 2 && this->skelAnime.animation == &gCremiaHugStartAnim && + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); + if (sCueId == 2 && this->skelAnime.animation == &gCremiaHugStartAnim && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { EnMaYto_ChangeAnim(this, 20); } } else { - D_80B915F0 = 99; + sCueId = 99; } } @@ -1068,8 +1068,8 @@ void EnMaYto_SetupPostMilkRunWaitDialogueEnd(EnMaYto* this) { void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, PlayState* play) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE || Message_GetState(&play->msgCtx) == TEXT_STATE_5) { if (Message_ShouldAdvance(play) && Message_GetState(&play->msgCtx) == TEXT_STATE_5) { - func_800B7298(play, &this->actor, PLAYER_CSMODE_7); - func_801477B4(play); + func_800B7298(play, &this->actor, PLAYER_CSMODE_WAIT); + Message_CloseTextbox(play); } } @@ -1091,7 +1091,7 @@ void EnMaYto_PostMilkRunEnd(EnMaYto* this, PlayState* play) { gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_80; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } void EnMaYto_DefaultStartDialogue(EnMaYto* this, PlayState* play) { @@ -1268,29 +1268,29 @@ void EnMaYto_ChangeAnim(EnMaYto* this, s32 animIndex) { void func_80B90C78(EnMaYto* this, PlayState* play) { Player* player = GET_PLAYER(play); - s16 flag; + s16 trackingMode; SkelAnime_Update(&this->skelAnime); - flag = this->unk31E == 2 ? true : false; + trackingMode = (this->unk31E == 2) ? NPC_TRACKING_NONE : NPC_TRACKING_PLAYER_AUTO_TURN; if (this->unk31E == 0) { - this->unk_1D8.unk_18 = player->actor.world.pos; - this->unk_1D8.unk_14 = 0.0f; + this->interactInfo.trackPos = player->actor.world.pos; + this->interactInfo.yOffset = 0.0f; } else if (this->unk31E == 1) { - Math_Vec3f_StepTo(&this->unk_1D8.unk_18, &this->actor.child->world.pos, 8.0f); - this->unk_1D8.unk_14 = 0.0f; + Math_Vec3f_StepTo(&this->interactInfo.trackPos, &this->actor.child->world.pos, 8.0f); + this->interactInfo.yOffset = 0.0f; } if (this->unk320 == 0) { if (this->actionFunc == EnMaYto_WarmFuzzyFeelingCs) { - this->unk_1D8.unk_08.y = 0; - this->unk_1D8.unk_08.x = 0; + this->interactInfo.headRot.y = 0; + this->interactInfo.headRot.x = 0; } else { - func_800BD888(&this->actor, &this->unk_1D8, 0xD, flag); + Npc_TrackPoint(&this->actor, &this->interactInfo, 13, trackingMode); } } else { - Math_SmoothStepToS(&this->unk_1D8.unk_08.y, 0, 3, 0x71C, 0xB6); - Math_SmoothStepToS(&this->unk_1D8.unk_08.x, 0x18E3, 5, 0x71C, 0xB6); + Math_SmoothStepToS(&this->interactInfo.headRot.y, 0, 3, 0x71C, 0xB6); + Math_SmoothStepToS(&this->interactInfo.headRot.x, 0x18E3, 5, 0x71C, 0xB6); } EnMaYto_UpdateEyes(this); @@ -1423,26 +1423,26 @@ void EnMaYto_Update(Actor* thisx, PlayState* play) { s32 EnMaYto_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnMaYto* this = THIS; - Vec3s sp4; + Vec3s limbRot; if (limbIndex == CREMIA_LIMB_HEAD) { - sp4 = this->unk_1D8.unk_08; + limbRot = this->interactInfo.headRot; - rot->x += sp4.y; - rot->z += sp4.x; + rot->x += limbRot.y; + rot->z += limbRot.x; } else if (limbIndex == CREMIA_LIMB_TORSO) { - if (this->skelAnime.animation != &gCremiaSittingPetCowAnim && - this->skelAnime.animation != &gCremiaSittingLookDownAnim) { - sp4 = this->unk_1D8.unk_0E; + if ((this->skelAnime.animation != &gCremiaSittingPetCowAnim) && + (this->skelAnime.animation != &gCremiaSittingLookDownAnim)) { + limbRot = this->interactInfo.torsoRot; - rot->x += sp4.y; - if (this->skelAnime.animation == &gCremiaIdleAnim || this->skelAnime.animation == &gCremiaSittingAnim || - this->skelAnime.animation == &gCremiaSittingLookDownAnim) { - rot->z += sp4.x; + rot->x += limbRot.y; + if ((this->skelAnime.animation == &gCremiaIdleAnim) || (this->skelAnime.animation == &gCremiaSittingAnim) || + (this->skelAnime.animation == &gCremiaSittingLookDownAnim)) { + rot->z += limbRot.x; } } } - return 0; + return false; } void EnMaYto_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.h b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.h index 0955cd8e8..208e41270 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.h +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.h @@ -13,7 +13,7 @@ typedef struct EnMaYto { /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnMaYtoActionFunc actionFunc; /* 0x18C */ ColliderCylinder collider; - /* 0x1D8 */ struct_800BD888_arg1 unk_1D8; + /* 0x1D8 */ NpcInteractInfo interactInfo; /* 0x200 */ s32 unk200; // unused /* 0x204 */ s32 type; /* 0x208 */ Vec3s jointTable[CREMIA_LIMB_MAX]; 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 64a6d138c..edf0e41f2 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 @@ -121,17 +121,17 @@ void EnMaYts_ChangeAnim(EnMaYts* this, s32 animIndex) { void func_80B8D12C(EnMaYts* this, PlayState* play) { Player* player = GET_PLAYER(play); - s16 flag = this->unk_32C == 2 ? true : false; + s16 trackingMode = (this->unk_32C == 2) ? NPC_TRACKING_NONE : NPC_TRACKING_PLAYER_AUTO_TURN; if (this->unk_32C == 0 || this->actor.parent == NULL) { - this->unk_1D8.unk_18 = player->actor.world.pos; - this->unk_1D8.unk_18.y -= -10.0f; + this->interactInfo.trackPos = player->actor.world.pos; + this->interactInfo.trackPos.y -= -10.0f; } else { - Math_Vec3f_StepTo(&this->unk_1D8.unk_18, &this->actor.parent->world.pos, 8.0f); - this->unk_1D8.unk_18.y -= -10.0f; + Math_Vec3f_StepTo(&this->interactInfo.trackPos, &this->actor.parent->world.pos, 8.0f); + this->interactInfo.trackPos.y -= -10.0f; } - func_800BD888(&this->actor, &this->unk_1D8, 0, flag); + Npc_TrackPoint(&this->actor, &this->interactInfo, 0, trackingMode); } void EnMaYts_InitAnimation(EnMaYts* this, PlayState* play) { @@ -235,10 +235,10 @@ void EnMaYts_Init(Actor* thisx, PlayState* play) { this->collider.dim.radius = 40; } - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); Actor_SetScale(&this->actor, 0.01f); - this->unk_1D8.unk_00 = 0; + this->interactInfo.talkState = NPC_TALK_STATE_IDLE; this->unk_200 = 0; this->blinkTimer = 0; @@ -248,7 +248,7 @@ void EnMaYts_Init(Actor* thisx, PlayState* play) { this->hasBow = false; } - if (CURRENT_DAY == 1 || CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { + if ((CURRENT_DAY == 1) || CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { this->overrideEyeTexIndex = 0; this->eyeTexIndex = 0; this->mouthTexIndex = 0; @@ -377,16 +377,16 @@ void EnMaYts_SetupEndCreditsHandler(EnMaYts* this) { this->actionFunc = EnMaYts_EndCreditsHandler; } -static u16 D_80B8E32C = 99; +static u16 sCueId = 99; void EnMaYts_EndCreditsHandler(EnMaYts* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 120)) { - s32 actionIndex = Cutscene_GetActorActionIndex(play, 120); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_120)) { + s32 cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_120); - if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { - if (play->csCtx.actorActions[actionIndex]->action != D_80B8E32C) { - D_80B8E32C = play->csCtx.actorActions[actionIndex]->action; + if (play->csCtx.curFrame == play->csCtx.actorCues[cueChannel]->startFrame) { + if (sCueId != play->csCtx.actorCues[cueChannel]->id) { + sCueId = play->csCtx.actorCues[cueChannel]->id; this->endCreditsFlag = 0; - switch (play->csCtx.actorActions[actionIndex]->action) { + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: this->hasBow = true; EnMaYts_ChangeAnim(this, 0); @@ -410,14 +410,14 @@ void EnMaYts_EndCreditsHandler(EnMaYts* this, PlayState* play) { } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); - if ((D_80B8E32C == 2) && (this->endCreditsFlag == 0) && + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); + if ((sCueId == 2) && (this->endCreditsFlag == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->endCreditsFlag++; EnMaYts_ChangeAnim(this, 5); } } else { - D_80B8E32C = 99; + sCueId = 99; this->hasBow = true; } } @@ -501,18 +501,18 @@ void EnMaYts_Update(Actor* thisx, PlayState* play) { s32 EnMaYts_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnMaYts* this = THIS; - Vec3s sp4; + Vec3s limbRot; if (limbIndex == ROMANI_LIMB_HEAD) { - sp4 = this->unk_1D8.unk_08; - rot->x += sp4.y; + limbRot = this->interactInfo.headRot; + rot->x += limbRot.y; if ((this->skelAnime.animation == &gRomaniIdleAnim) || (this->skelAnime.animation == &gRomaniSittingAnim)) { - rot->z += sp4.x; + rot->z += limbRot.x; } } else if (limbIndex == ROMANI_LIMB_TORSO) { - sp4 = this->unk_1D8.unk_0E; - rot->x += sp4.y; - rot->z += sp4.x; + limbRot = this->interactInfo.torsoRot; + rot->x += limbRot.y; + rot->z += limbRot.x; } return false; diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h index eb700d8c2..65e7a0eb6 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.h @@ -13,7 +13,7 @@ typedef struct EnMaYts { /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnMaYtsActionFunc actionFunc; /* 0x18C */ ColliderCylinder collider; - /* 0x1D8 */ struct_800BD888_arg1 unk_1D8; + /* 0x1D8 */ NpcInteractInfo interactInfo; /* 0x200 */ s32 unk_200; // Set, but not used /* 0x204 */ Vec3s jointTable[ROMANI_LIMB_MAX]; /* 0x28E */ UNK_TYPE1 unk_28E[0x6]; diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 3a72258cc..15aa42bda 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -239,7 +239,7 @@ void EnMag_Update(Actor* thisx, PlayState* play) { CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) || CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_B)) { - if (!EnvFlags_Get(play, 4)) { + if (!CutsceneFlags_Get(play, 4)) { play_sound(NA_SE_SY_PIECE_OF_HEART); this->state = MAG_STATE_CALLED; this->unk11F00 = 0; @@ -383,16 +383,16 @@ void EnMag_Update(Actor* thisx, PlayState* play) { CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_B)) { if (play->transitionTrigger != TRANS_TRIGGER_START) { Audio_SetCutsceneFlag(false); - D_801BB12C++; - if (D_801BB12C >= 2) { - D_801BB12C = 0; + gOpeningEntranceIndex++; + if (gOpeningEntranceIndex >= 2) { + gOpeningEntranceIndex = 0; } play_sound(NA_SE_SY_PIECE_OF_HEART); - gSaveContext.gameMode = 2; // Go to FileChoose + gSaveContext.gameMode = GAMEMODE_FILE_SELECT; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_02; + play->transitionType = TRANS_TYPE_FADE_BLACK; play->nextEntrance = ENTRANCE(CUTSCENE, 0); - gSaveContext.save.cutscene = 0; + gSaveContext.save.cutsceneIndex = 0; gSaveContext.sceneLayer = 0; } this->unk11F54 = 15; @@ -438,12 +438,12 @@ void EnMag_Update(Actor* thisx, PlayState* play) { } if (this->state == MAG_STATE_INITIAL) { - if (EnvFlags_Get(play, 3)) { + if (CutsceneFlags_Get(play, 3)) { this->unk11F02 = 40; this->state = MAG_STATE_FADE_IN_MASK_EFFECTS; } } else if (this->state < MAG_STATE_FADE_OUT) { - if (EnvFlags_Get(play, 4)) { + if (CutsceneFlags_Get(play, 4)) { this->state = MAG_STATE_FADE_OUT; } } diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c index 65e3d8b38..95890455c 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c @@ -525,7 +525,7 @@ void func_80B37CA0(EnMaruta* this, PlayState* play) { ((this->actionFunc == func_80B37428) && !(this->actor.world.pos.y < (this->actor.floorHeight - 20.0f)))) { if ((this->collider.base.acFlags & AC_HIT) && (this->actionFunc == func_80B372CC)) { this->collider.base.acFlags &= ~AC_HIT; - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SWORD_STRIKE); + Actor_PlaySfx(&this->actor, NA_SE_IT_SWORD_STRIKE); if (D_80B386CC[player->meleeWeaponAnimation] != 0) { s32 temp = D_80B386CC[player->meleeWeaponAnimation] + 1; @@ -587,7 +587,7 @@ void func_80B37EC0(EnMaruta* this, PlayState* play) { if (this->actor.velocity.y < -this->actor.gravity) { func_80B382E4(play, sp34); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_LOG_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EV_LOG_BOUND); this->actor.velocity.y *= -0.6f; func_80B38060(this, &sp34); } 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 f459a6a41..7ac16e1b0 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -99,7 +99,7 @@ void EnMinifrog_Init(Actor* thisx, PlayState* play) { this->frogIndex = MINIFROG_YELLOW; } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnMinifrog_Idle; this->jumpState = MINIFROG_STATE_GROUND; this->flags = 0; @@ -115,7 +115,7 @@ void EnMinifrog_Init(Actor* thisx, PlayState* play) { this->timer = 30; this->actionFunc = EnMinifrog_SpawnGrowAndShrink; - this->actor.textId = 0xD81; // "Ah! Don Gero! It has been so long." + this->actor.textId = 0xD81; this->actor.colChkInfo.mass = 30; } else { // Frogs in mountain village if (this->frogIndex == MINIFROG_YELLOW) { @@ -187,14 +187,14 @@ void EnMinifrog_Jump(EnMinifrog* this) { switch (this->jumpState) { case MINIFROG_STATE_JUMP: if (Animation_OnFrame(&this->skelAnime, 4.0f)) { - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->actor.velocity.y = 6.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_JUMP); + Actor_PlaySfx(&this->actor, NA_SE_EV_FROG_JUMP); this->jumpState = MINIFROG_STATE_AIR; } break; case MINIFROG_STATE_AIR: - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->jumpState = MINIFROG_STATE_GROUND; Animation_MorphToLoop(&this->skelAnime, &object_fr_Anim_001534, -2.5f); SkelAnime_Update(&this->skelAnime); @@ -254,32 +254,32 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, PlayState* play) { EnMinifrog_SetJumpState(this); switch (play->msgCtx.currentTextId) { - case 0xD81: // "Ah! Don Gero! It has been so long." - case 0xD83: // "Could it be... Has spring finally come to the mountains?" - case 0xD84: // "That look...It is true! Winter was so long that I began to lose all hope." - case 0xD86: // "Could it be... You came all this way looking for me?" - case 0xD87: // "Ah! You need not say a thing. Upon seeing that face, I understand!" ... - func_80151938(play, play->msgCtx.currentTextId + 1); + case 0xD81: + case 0xD83: + case 0xD84: + case 0xD86: + case 0xD87: + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; - case 0xD82: // "What has brought you all this way?" - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { - func_80151938(play, 0xD83); // "Could it be... Has spring finally come to the mountains?" + case 0xD82: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE)) { + Message_ContinueTextbox(play, 0xD83); } else { - func_80151938(play, 0xD86); // "Could it be... You came all this way looking for me?" + Message_ContinueTextbox(play, 0xD86); } SET_WEEKEVENTREG(isFrogReturnedFlags[this->frogIndex]); break; - case 0xD85: // "I understand. I shall head for the mountains immediately." + case 0xD85: default: - func_801477B4(play); + Message_CloseTextbox(play); EnMinifrog_SpawnDust(this, play); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_EN_NPC_FADEAWAY); - if (this->actor.cutscene != -1) { - if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { - ActorCutscene_Stop(this->actor.cutscene); + if (this->actor.csId != CS_ID_NONE) { + if (CutsceneManager_GetCurrentCsId() == this->actor.csId) { + CutsceneManager_Stop(this->actor.csId); } } @@ -289,14 +289,14 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, PlayState* play) { } if (this->flags & 1) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actor.cutscene); - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->actor.csId); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); this->flags &= ~1; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } } @@ -319,7 +319,7 @@ void EnMinifrog_Idle(EnMinifrog* this, PlayState* play) { EnMinifrog_JumpTimer(this); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = EnMinifrog_ReturnFrogCutscene; - if (this->actor.cutscene != -1) { + if (this->actor.csId != CS_ID_NONE) { this->flags |= 1; } } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play) && @@ -338,7 +338,7 @@ void EnMinifrog_SetupNextFrogInit(EnMinifrog* this, PlayState* play) { missingFrog = nextFrog->frog; if (nextFrog->frog != NULL) { this->actor.home.rot.y = - (s16)Actor_YawBetweenActors(&this->actor, &missingFrog->actor); // Set home to missing frog + (s16)Actor_WorldYawTowardActor(&this->actor, &missingFrog->actor); // Set home to missing frog EnMinifrog_TurnToMissingFrog(this); } else { EnMinifrog_TurnToPlayer(this); @@ -354,10 +354,9 @@ void EnMinifrog_SetupNextFrogInit(EnMinifrog* this, PlayState* play) { void EnMinifrog_CheckChoirSuccess(EnMinifrog* this, PlayState* play) { this->actionFunc = EnMinifrog_YellowFrogDialog; if (this->frog != NULL) { - func_80151938(play, 0xD78); // "Unfortunately, it seems not all of our members have gathered." + Message_ContinueTextbox(play, 0xD78); } else { - func_80151938(play, - 0xD7C); // "The conducting was spectacular. And all of our members rose to the occasion!" + Message_ContinueTextbox(play, 0xD7C); } EnMinifrog_SetJumpState(this); @@ -367,19 +366,19 @@ void EnMinifrog_CheckChoirSuccess(EnMinifrog* this, PlayState* play) { void EnMinifrog_ContinueChoirCutscene(EnMinifrog* this, PlayState* play) { EnMinifrog_Jump(this); - if (ActorCutscene_GetCurrentIndex() == 0x7C) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { EnMinifrog_CheckChoirSuccess(this, play); return; // necessary to match - } else if (ActorCutscene_GetCanPlayNext(0x7C)) { - ActorCutscene_Start(0x7C, NULL); + } else if (CutsceneManager_IsNext(CS_ID_GLOBAL_TALK)) { + CutsceneManager_Start(CS_ID_GLOBAL_TALK, NULL); EnMinifrog_CheckChoirSuccess(this, play); return; // necessary to match - } else if (this->actor.cutscene != -1 && ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { - ActorCutscene_Stop(this->actor.cutscene); - ActorCutscene_SetIntentToPlay(0x7C); + } else if ((this->actor.csId != CS_ID_NONE) && (CutsceneManager_GetCurrentCsId() == this->actor.csId)) { + CutsceneManager_Stop(this->actor.csId); + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); return; // necessary to match } else { - ActorCutscene_SetIntentToPlay(0x7C); + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); } } @@ -401,7 +400,7 @@ void EnMinifrog_NextFrogReturned(EnMinifrog* this, PlayState* play) { this->actionFunc = EnMinifrog_ContinueChoirCutscene; this->flags &= ~(0x2 << MINIFROG_YELLOW | 0x2 << MINIFROG_CYAN | 0x2 << MINIFROG_PINK | 0x2 << MINIFROG_BLUE | 0x2 << MINIFROG_WHITE); - play->setPlayerTalkAnim(play, &gPlayerAnim_link_normal_talk_free_wait, 0); + play->setPlayerTalkAnim(play, &gPlayerAnim_link_normal_talk_free_wait, ANIMMODE_LOOP); } } @@ -427,12 +426,12 @@ void EnMinifrog_SetupNextFrogChoir(EnMinifrog* this, PlayState* play) { this->actor.home.rot.z = 0; this->actionFunc = EnMinifrog_NextFrogMissing; this->timer = 60; - this->actor.home.rot.y = Actor_YawBetweenActors(&this->actor, &this->frog->actor); + this->actor.home.rot.y = Actor_WorldYawTowardActor(&this->actor, &this->frog->actor); func_801A1F88(); this->flags &= ~0x100; this->flags &= ~(0x2 << MINIFROG_YELLOW | 0x2 << MINIFROG_CYAN | 0x2 << MINIFROG_PINK | 0x2 << MINIFROG_BLUE | 0x2 << MINIFROG_WHITE); - play->setPlayerTalkAnim(play, &gPlayerAnim_link_normal_talk_free_wait, 0); + play->setPlayerTalkAnim(play, &gPlayerAnim_link_normal_talk_free_wait, ANIMMODE_LOOP); } else if (this->timer <= 0) { this->actionFunc = EnMinifrog_NextFrogReturned; this->timer = 30; @@ -441,20 +440,20 @@ void EnMinifrog_SetupNextFrogChoir(EnMinifrog* this, PlayState* play) { void EnMinifrog_BeginChoirCutscene(EnMinifrog* this, PlayState* play) { EnMinifrog_Jump(this); - if (this->actor.cutscene == -1) { + if (this->actor.csId == CS_ID_NONE) { this->actionFunc = EnMinifrog_SetupNextFrogChoir; - } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actor.cutscene); - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); + } else if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->actor.csId); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); this->actionFunc = EnMinifrog_SetupNextFrogChoir; this->timer = 5; func_801A1F00(3, NA_BGM_FROG_SONG); this->flags |= 0x100; - play->setPlayerTalkAnim(play, &gPlayerAnim_pn_gakkiplay, 0); + play->setPlayerTalkAnim(play, &gPlayerAnim_pn_gakkiplay, ANIMMODE_LOOP); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -462,7 +461,7 @@ void EnMinifrog_EndChoir(EnMinifrog* this, PlayState* play) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - Message_StartTextbox(play, 0xD7E, &this->actor); // "Let us do it again sometime." + Message_StartTextbox(play, 0xD7E, &this->actor); this->actionFunc = EnMinifrog_YellowFrogDialog; } else { func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_MINUS1); @@ -478,7 +477,7 @@ void EnMinifrog_GetFrogHP(EnMinifrog* this, PlayState* play) { this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_NONE); } else { - Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 10000.0f, 50.0f); + Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 10000.0f, 50.0f); } } @@ -496,7 +495,7 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, PlayState* play) { break; case 1: // No func_8019F230(); - func_80151938(play, 0xD7E); // "Let us do it again sometime." + Message_ContinueTextbox(play, 0xD7E); break; } } @@ -506,40 +505,38 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, PlayState* play) { if (Message_ShouldAdvance(play)) { EnMinifrog_SetJumpState(this); switch (play->msgCtx.currentTextId) { - case 0xD76: // "I have been waiting for you, Don Gero. Forgive me if I'm mistaken, but it looks like - // you've lost a little weight..." - func_80151938(play, play->msgCtx.currentTextId + 1); + case 0xD76: + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); this->actor.flags &= ~ACTOR_FLAG_10000; SET_WEEKEVENTREG(WEEKEVENTREG_34_01); break; - case 0xD78: // "Unfortunately, it seems not all of our members have gathered." - case 0xD79: // "Perhaps it is because winter was too long? They must not have realized that spring - // has come to the mountains..." - case 0xD7A: // "And when the great Don Gero has come for us, too...What a pity." - case 0xD7F: // "Well, if it isn't the great Don Gero." - func_80151938(play, play->msgCtx.currentTextId + 1); + case 0xD78: + case 0xD79: + case 0xD7A: + case 0xD7F: + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; - case 0xD77: // "Let us begin our chorus" + case 0xD77: this->actionFunc = EnMinifrog_BeginChoirCutscene; play->msgCtx.msgLength = 0; break; - case 0xD7C: // "The conducting was spectacular. And all of our members rose to the occasion!" + case 0xD7C: if (CHECK_WEEKEVENTREG(WEEKEVENTREG_35_80)) { // Obtained Heart Piece - func_80151938(play, 0xD7E); + Message_ContinueTextbox(play, 0xD7E); } else { - func_80151938(play, 0xD7D); // Get Heart Piece + Message_ContinueTextbox(play, 0xD7D); // Get Heart Piece SET_WEEKEVENTREG(WEEKEVENTREG_35_80); } break; - case 0xD7D: // "This is how deeply we were moved by your spectacular conducting..." - func_801477B4(play); + case 0xD7D: + Message_CloseTextbox(play); this->actionFunc = EnMinifrog_GetFrogHP; EnMinifrog_GetFrogHP(this, play); break; - case 0xD7B: // "Where in the world could the other members be, and what could they be doing?" - case 0xD7E: // "Let us do it again sometime." + case 0xD7B: + case 0xD7E: default: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = EnMinifrog_SetupYellowFrogDialog; this->actor.flags &= ~ACTOR_FLAG_10000; break; @@ -558,11 +555,9 @@ void EnMinifrog_SetupYellowFrogDialog(EnMinifrog* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = EnMinifrog_YellowFrogDialog; if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_34_01)) { - Message_StartTextbox(play, 0xD76, - &this->actor); // "I have been waiting for you, Don Gero. Forgive me if I'm mistaken, - // but it looks like you've lost a little weight..." + Message_StartTextbox(play, 0xD76, &this->actor); } else { - Message_StartTextbox(play, 0xD7F, &this->actor); // "Well, if it isn't the great Don Gero." + Message_StartTextbox(play, 0xD7F, &this->actor); } } else if ((this->actor.xzDistToPlayer < 150.0f) && (Player_IsFacingActor(&this->actor, 0x3000, play) || @@ -578,7 +573,9 @@ void EnMinifrog_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 25.0f, 12.0f, 0.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 25.0f, 12.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); this->actor.focus.rot.y = this->actor.shape.rot.y; 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 1ab5f2cc6..3b6cbaf86 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -140,54 +140,54 @@ void EnMinislime_CheckBackgroundCollision(EnMinislime* this) { f32 scaleY = this->actor.scale.y * 400.0f; f32 scaleZ = this->actor.scale.z * 400.0f; - this->actor.bgCheckFlags &= ~(0x10 | 0x8 | 0x2); + this->actor.bgCheckFlags &= ~(BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_WALL | BGCHECKFLAG_CEILING); if ((this->actor.world.pos.y + scaleY) > GBT_ROOM_5_MAX_Y) { - this->actor.bgCheckFlags |= 0x10; - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags |= BGCHECKFLAG_CEILING; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->actor.world.pos.y = GBT_ROOM_5_MAX_Y - scaleY; } else if ((this->actor.world.pos.y - scaleY) < GBT_ROOM_5_MIN_Y) { this->actor.world.pos.y = GBT_ROOM_5_MIN_Y + scaleY; - if (!(this->actor.bgCheckFlags & 1)) { - this->actor.bgCheckFlags |= 2; + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + this->actor.bgCheckFlags |= BGCHECKFLAG_GROUND_TOUCH; } - this->actor.bgCheckFlags |= 1; + this->actor.bgCheckFlags |= BGCHECKFLAG_GROUND; } else { - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; } if ((this->actor.world.pos.x + scaleX) > GBT_ROOM_5_MAX_X) { - this->actor.bgCheckFlags |= 8; + this->actor.bgCheckFlags |= BGCHECKFLAG_WALL; this->actor.world.pos.x = GBT_ROOM_5_MAX_X - scaleX; } else if ((this->actor.world.pos.x - scaleX) < GBT_ROOM_5_MIN_X) { this->actor.world.pos.x = GBT_ROOM_5_MIN_X + scaleX; - this->actor.bgCheckFlags |= 8; + this->actor.bgCheckFlags |= BGCHECKFLAG_WALL; } if ((this->actor.world.pos.z + scaleZ) > GBT_ROOM_5_MAX_Z) { - this->actor.bgCheckFlags |= 8; + this->actor.bgCheckFlags |= BGCHECKFLAG_WALL; this->actor.world.pos.z = GBT_ROOM_5_MAX_Z - scaleZ; } else if ((this->actor.world.pos.z - scaleZ) < GBT_ROOM_5_MIN_Z) { this->actor.world.pos.z = GBT_ROOM_5_MIN_Z + scaleZ; - this->actor.bgCheckFlags |= 8; + this->actor.bgCheckFlags |= BGCHECKFLAG_WALL; } } void EnMinislime_AddIceShardEffect(EnMinislime* this) { + s32 pad; EnBigslime* bigslime = (EnBigslime*)this->actor.parent; EnBigslimeIceShardEffect* iceShardEffect; s32 i = 10 * this->id + BIGSLIME_NUM_VTX; s32 i_end = i + 10; - VecSph vecSph; - - vecSph.yaw = 0; + s16 pitch; + s16 yaw = 0; for (; i < i_end; i++) { iceShardEffect = &bigslime->iceShardEffect[i]; - vecSph.pitch = Rand_S16Offset(0x1000, 0x3000); - iceShardEffect->velocity.x = Math_CosS(vecSph.pitch) * Math_SinS(vecSph.yaw); - iceShardEffect->velocity.y = Math_SinS(vecSph.pitch); - iceShardEffect->velocity.z = Math_CosS(vecSph.pitch) * Math_CosS(vecSph.yaw); + pitch = Rand_S16Offset(0x1000, 0x3000); + iceShardEffect->velocity.x = Math_CosS(pitch) * Math_SinS(yaw); + iceShardEffect->velocity.y = Math_SinS(pitch); + iceShardEffect->velocity.z = Math_CosS(pitch) * Math_CosS(yaw); iceShardEffect->pos.x = this->actor.world.pos.x + (400.0f * this->actor.scale.x) * iceShardEffect->velocity.x; iceShardEffect->pos.y = this->actor.world.pos.y + (((iceShardEffect->velocity.y * 2.0f) - 1.0f) * 400.0f * this->actor.scale.y); @@ -198,11 +198,11 @@ void EnMinislime_AddIceShardEffect(EnMinislime* this) { iceShardEffect->isEnabled = true; Math_Vec3f_ScaleAndStore(&iceShardEffect->velocity, Rand_ZeroFloat(3.0f) + 7.0f, &iceShardEffect->velocity); iceShardEffect->scale = (Rand_ZeroFloat(6.0f) + 2.0f) * 0.001f; - vecSph.yaw += 0x1999; + yaw += 0x1999; } this->frozenAlpha = 0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_BROKEN); + Actor_PlaySfx(&this->actor, NA_SE_EV_ICE_BROKEN); } void EnMinislime_AddIceSmokeEffect(EnMinislime* this, PlayState* play) { @@ -240,14 +240,14 @@ void EnMinislime_SetupFall(EnMinislime* this, PlayState* play) { this->collider.base.atFlags |= AT_ON; this->collider.base.acFlags |= AC_ON; this->collider.base.ocFlags1 |= OC1_ON; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.gravity = -2.0f; if (this->actionFunc != EnMinislime_GekkoThrow) { this->actor.scale.x = 0.095f; this->actor.scale.z = 0.095f; this->actor.scale.y = 0.10700001f; - if (Actor_XZDistanceBetweenActors(&this->actor, &player->actor) < 225.0f) { - yaw = Actor_YawBetweenActors(&player->actor, &this->actor); + if (Actor_WorldDistXZToActor(&this->actor, &player->actor) < 225.0f) { + yaw = Actor_WorldYawTowardActor(&player->actor, &this->actor); this->actor.world.pos.x = Math_SinS(yaw) * 225.0f + player->actor.world.pos.x; this->actor.world.pos.z = Math_CosS(yaw) * 225.0f + player->actor.world.pos.z; } @@ -259,7 +259,7 @@ void EnMinislime_Fall(EnMinislime* this, PlayState* play) { Math_StepToF(&this->actor.scale.x, 0.17999999f, 0.003f); Math_StepToF(&this->actor.scale.y, 0.05f, 0.003f); this->actor.scale.z = this->actor.scale.x; - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { EnMinislime_SetupGrowAndShrink(this); } } @@ -267,11 +267,11 @@ void EnMinislime_Fall(EnMinislime* this, PlayState* play) { void EnMinislime_SetupBreakFromBigslime(EnMinislime* this) { f32 velY; - this->actor.world.rot.y = Actor_YawBetweenActors(this->actor.parent, &this->actor); + this->actor.world.rot.y = Actor_WorldYawTowardActor(this->actor.parent, &this->actor); this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.speedXZ = Math_CosS(this->actor.world.rot.x) * 15.0f; + this->actor.speed = Math_CosS(this->actor.world.rot.x) * 15.0f; velY = Math_SinS(this->actor.world.rot.x) * 15.0f; - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->actor.velocity.y = velY + 2.0f; this->actor.gravity = -1.0f; this->frozenScale = 0.1f; @@ -289,7 +289,7 @@ void EnMinislime_BreakFromBigslime(EnMinislime* this, PlayState* play) { this->actor.shape.rot.x += this->actor.world.rot.x; if (this->actor.velocity.y < 0.0f) { this->collider.base.ocFlags1 |= OC1_ON; - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { EnMinislime_AddIceShardEffect(this); this->attackTimer = 40; EnMinislime_SetupGrowAndShrink(this); @@ -300,7 +300,7 @@ void EnMinislime_BreakFromBigslime(EnMinislime* this, PlayState* play) { void EnMinislime_SetupIceArrowDamage(EnMinislime* this) { this->collider.base.atFlags &= ~AT_ON; this->frozenTimer = 80; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->frozenScale = 0.1f; this->actionFunc = EnMinislime_IceArrowDamage; } @@ -341,7 +341,7 @@ void EnMinislime_IceArrowDamage(EnMinislime* this, PlayState* play) { return; } - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { EnMinislime_AddIceShardEffect(this); EnMinislime_SetupGrowAndShrink(this); } @@ -354,7 +354,7 @@ void EnMinislime_SetupFireArrowDamage(EnMinislime* this) { this->actor.shape.rot.z = 0; this->actor.world.rot.x = 0; this->collider.base.acFlags &= ~AC_ON; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnMinislime_FireArrowDamage; } @@ -385,13 +385,13 @@ void EnMinislime_SetupGrowAndShrink(EnMinislime* this) { this->actor.shape.rot.y = 0; this->actor.shape.rot.z = 0; this->actor.world.rot.x = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); this->growShrinkTimer = 42; this->actor.scale.x = 0.19f; this->actor.scale.y = 0.044999998f; this->actor.scale.z = 0.19f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_SLIME_JUMP2); + Actor_PlaySfx(&this->actor, NA_SE_EN_SLIME_JUMP2); this->actionFunc = EnMinislime_GrowAndShrink; } @@ -425,8 +425,8 @@ void EnMinislime_Idle(EnMinislime* this, PlayState* play) { this->idleTimer--; speedXZ = sin_rad(this->idleTimer * (M_PI / 10)); - this->actor.speedXZ = speedXZ * 1.5f; - this->actor.speedXZ = CLAMP_MIN(this->actor.speedXZ, 0.0f); + this->actor.speed = speedXZ * 1.5f; + this->actor.speed = CLAMP_MIN(this->actor.speed, 0.0f); Math_StepToF(&this->actor.scale.x, ((0.14f * speedXZ) + 1.5f) * 0.1f, 0.010000001f); Math_StepToF(&this->actor.scale.y, ((cos_rad(this->idleTimer * (M_PI / 10)) * 0.07f) + 0.75f) * 0.1f, 0.010000001f); Math_StepToF(&this->actor.scale.z, 0.3f - this->actor.scale.x, 0.010000001f); @@ -434,8 +434,8 @@ void EnMinislime_Idle(EnMinislime* this, PlayState* play) { if (this->actor.xzDistToPlayer < 300.0f) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; } else { - if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 200.0f) { - this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) < 200.0f) { + this->actor.world.rot.y = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); } else { this->actor.world.rot.y += (s16)((s32)Rand_Next() >> 0x13); } @@ -451,9 +451,9 @@ void EnMinislime_Idle(EnMinislime* this, PlayState* play) { } void EnMinislime_SetupBounce(EnMinislime* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->bounceTimer = (this->actionFunc == EnMinislime_GrowAndShrink) ? 1 : 4; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_SLIME_JUMP1); + Actor_PlaySfx(&this->actor, NA_SE_EN_SLIME_JUMP1); this->actionFunc = EnMinislime_Bounce; } @@ -466,7 +466,7 @@ void EnMinislime_Bounce(EnMinislime* this, PlayState* play) { if (this->bounceTimer == 0) { this->actor.gravity = -2.0f; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actor.speedXZ = 1.0f; + this->actor.speed = 1.0f; this->actor.velocity.y = 12.0f; this->actor.shape.rot.y = this->actor.world.rot.y; } @@ -478,7 +478,7 @@ void EnMinislime_Bounce(EnMinislime* this, PlayState* play) { } else { Math_StepToF(&this->actor.scale.x, 0.17999999f, 0.003f); Math_StepToF(&this->actor.scale.y, 0.05f, 0.003f); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { EnMinislime_SetupGrowAndShrink(this); return; } @@ -490,9 +490,9 @@ void EnMinislime_Bounce(EnMinislime* this, PlayState* play) { void EnMinislime_SetupMoveToBigslime(EnMinislime* this) { this->actor.gravity = 0.0f; - this->actor.speedXZ = 15.0f; - this->actor.shape.rot.x = Actor_PitchToPoint(&this->actor, &this->actor.parent->home.pos); - this->actor.shape.rot.y = Actor_YawToPoint(&this->actor, &this->actor.parent->home.pos); + this->actor.speed = 15.0f; + this->actor.shape.rot.x = Actor_WorldPitchTowardPoint(&this->actor, &this->actor.parent->home.pos); + this->actor.shape.rot.y = Actor_WorldYawTowardPoint(&this->actor, &this->actor.parent->home.pos); this->actor.world.rot.x = -this->actor.shape.rot.x; this->actor.world.rot.y = this->actor.shape.rot.y; this->collider.base.atFlags &= ~AT_ON; @@ -517,7 +517,7 @@ void EnMinislime_MoveToBigslime(EnMinislime* this, PlayState* play) { EnMinislime_SetupDisappear(this); } else if ((this->actor.scale.x > 0.0f) && (this->actor.world.pos.y > (GBT_ROOM_5_MAX_Y - 100.0f))) { this->actor.params = MINISLIME_SETUP_DISAPPEAR; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Actor_SetScale(&this->actor, 0.0f); } } @@ -526,7 +526,7 @@ void EnMinislime_SetupKnockback(EnMinislime* this) { this->collider.base.acFlags &= ~AC_ON; this->collider.base.ocFlags1 |= OC1_ON; this->knockbackTimer = 30; - this->actor.speedXZ = 20.0f; + this->actor.speed = 20.0f; func_800BE504(&this->actor, &this->collider); this->actionFunc = EnMinislime_Knockback; } @@ -535,7 +535,7 @@ void EnMinislime_Knockback(EnMinislime* this, PlayState* play) { f32 sqrtFrozenTimer; this->knockbackTimer--; - Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); + Math_StepToF(&this->actor.speed, 0.0f, 1.0f); sqrtFrozenTimer = sqrtf(this->knockbackTimer); this->actor.scale.x = ((cos_rad(this->knockbackTimer * (M_PI / 3)) * (0.05f * sqrtFrozenTimer)) + 1.0f) * 0.15f; this->actor.scale.z = this->actor.scale.x; @@ -556,7 +556,7 @@ void EnMinislime_SetupDefeatIdle(EnMinislime* this) { this->idleTimer = 20; this->collider.base.atFlags &= ~(AT_ON | AT_HIT); this->collider.base.acFlags &= ~(AC_ON | AC_HIT); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->frozenAlpha > 20) { EnMinislime_AddIceShardEffect(this); } @@ -625,7 +625,7 @@ void EnMinislime_Despawn(EnMinislime* this, PlayState* play) { } void EnMinislime_SetupMoveToGekko(EnMinislime* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; this->collider.base.acFlags &= ~AC_ON; @@ -657,11 +657,11 @@ void EnMinislime_SetupGekkoThrow(EnMinislime* this) { this->collider.base.acFlags |= AC_ON; this->collider.base.ocFlags1 |= OC1_ON; xzDistToPlayer = CLAMP_MIN(this->actor.xzDistToPlayer, 200.0f); - this->actor.speedXZ = 17.5f; + this->actor.speed = 17.5f; this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.gravity = -1.0f; this->actor.velocity.y = ((xzDistToPlayer - 200.0f) * 0.01f) + 3.0f; - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->throwTimer = 10; this->actionFunc = EnMinislime_GekkoThrow; } @@ -678,7 +678,7 @@ void EnMinislime_GekkoThrow(EnMinislime* this, PlayState* play) { this->throwTimer = 10; } - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { EnMinislime_SetupGrowAndShrink(this); } } @@ -713,7 +713,7 @@ void EnMinislime_Update(Actor* thisx, PlayState* play) { s32 pad; Vec3f vec1; - if ((this->actor.params == MINISLIME_DEFEAT_IDLE) && (this->actor.bgCheckFlags & 1)) { + if ((this->actor.params == MINISLIME_DEFEAT_IDLE) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { EnMinislime_SetupDefeatIdle(this); } else if (this->actor.params == MINISLIME_DEFEAT_MELT) { EnMinislime_SetupDefeatMelt(this, play); @@ -761,7 +761,7 @@ void EnMinislime_Update(Actor* thisx, PlayState* play) { this->attackTimer--; } - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { player = GET_PLAYER(play); vec1.x = this->actor.world.pos.x; vec1.z = this->actor.world.pos.z; diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.c b/src/overlays/actors/ovl_En_Mk/z_en_mk.c index 894d73a6f..20f32028e 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -76,7 +76,7 @@ s32 func_809592E0(EnMk* this, s16 index) { void EnMk_Init(Actor* thisx, PlayState* play) { EnMk* this = THIS; - s16 cs; + s16 csId; s32 i; this->actor.terminalVelocity = -4.0f; @@ -101,16 +101,16 @@ void EnMk_Init(Actor* thisx, PlayState* play) { this->unk_27A |= 2; } - cs = this->actor.cutscene; - for (i = 0; i < ARRAY_COUNT(this->unk_276); i++) { - this->unk_276[i] = cs; - if (cs != -1) { - this->actor.cutscene = cs; - cs = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + csId = this->actor.csId; + for (i = 0; i < ARRAY_COUNT(this->csIdList); i++) { + this->csIdList[i] = csId; + if (csId != CS_ID_NONE) { + this->actor.csId = csId; + csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); } } - this->actor.cutscene = this->unk_276[0]; + this->actor.csId = this->csIdList[0]; } void EnMk_Destroy(Actor* thisx, PlayState* play) { @@ -120,20 +120,20 @@ void EnMk_Destroy(Actor* thisx, PlayState* play) { } s32 func_80959524(PlayState* play) { - return gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 7; + return gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 & 7; } void func_8095954C(EnMk* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 0x7F)) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 0x7F)); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_127)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_127)); - switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x7F)]->action) { + switch (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_127)]->id) { case 1: case 2: case 3: case 4: case 5: - func_809592E0(this, play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x7F)]->action - 1); + func_809592E0(this, play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_127)]->id - 1); break; } } else { @@ -147,7 +147,7 @@ void func_80959624(EnMk* this, PlayState* play) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (this->unk_27A & 4) { textId = 0xFB9; - } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { textId = 0xFBC; } else { textId = 0xFBB; @@ -170,7 +170,7 @@ void func_809596A0(EnMk* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80959774; } break; @@ -212,7 +212,7 @@ void func_80959844(EnMk* this, PlayState* play) { switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: if (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_10)) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { textId = 0xFAF; } else { textId = 0xFAE; @@ -224,7 +224,7 @@ void func_80959844(EnMk* this, PlayState* play) { case PLAYER_FORM_GORON: if (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_08)) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { textId = 0xFAB; } else { textId = 0xFAA; @@ -239,7 +239,7 @@ void func_80959844(EnMk* this, PlayState* play) { if (func_80959524(play) > 0) { textId = 0xFA7; } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_04)) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { textId = 0xFBF; } else { textId = 0xFA6; @@ -279,15 +279,15 @@ void func_80959A24(EnMk* this, PlayState* play) { case 0xFA4: case 0xFAA: case 0xFAE: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0xFA2: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { - func_801477B4(play); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { + Message_CloseTextbox(play); this->actionFunc = func_80959E18; } else { - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); } break; @@ -303,53 +303,53 @@ void func_80959A24(EnMk* this, PlayState* play) { case 0xFBD: case 0xFBE: case 0xFBF: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80959E18; break; case 0xFA0: SET_WEEKEVENTREG(WEEKEVENTREG_19_04); - func_80151938(play, 0xFA1); + Message_ContinueTextbox(play, 0xFA1); break; case 0xFA8: SET_WEEKEVENTREG(WEEKEVENTREG_19_08); - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { - func_80151938(play, 0xFBD); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { + Message_ContinueTextbox(play, 0xFBD); } else { - func_80151938(play, 0xFA9); + Message_ContinueTextbox(play, 0xFA9); } break; case 0xFAC: SET_WEEKEVENTREG(WEEKEVENTREG_19_10); - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { - func_80151938(play, 0xFBE); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { + Message_ContinueTextbox(play, 0xFBE); } else { - func_80151938(play, 0xFAD); + Message_ContinueTextbox(play, 0xFAD); } break; case 0xFB1: SET_WEEKEVENTREG(WEEKEVENTREG_19_20); - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80959E18; break; case 0xFB3: case 0xFB4: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80959E18; this->actor.flags &= ~ACTOR_FLAG_10000; break; case 0xFB5: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80959E18; break; default: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80959E18; break; } @@ -372,7 +372,7 @@ void func_80959C94(EnMk* this, PlayState* play) { void func_80959D28(EnMk* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if ((play->csCtx.state == 0) && (this->actor.cutscene == -1)) { + if ((play->csCtx.state == CS_STATE_IDLE) && (this->actor.csId == CS_ID_NONE)) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_40)) { this->unk_27A &= ~1; this->actionFunc = func_80959774; @@ -381,14 +381,14 @@ void func_80959D28(EnMk* this, PlayState* play) { } else { this->actionFunc = func_80959E18; } - this->actor.cutscene = this->unk_276[0]; + this->actor.csId = this->csIdList[0]; } else { - if (this->actor.cutscene != -1) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); - this->actor.cutscene = -1; + if (this->actor.csId != CS_ID_NONE) { + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); + this->actor.csId = CS_ID_NONE; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } func_8095954C(this, play); @@ -412,13 +412,13 @@ void func_80959E18(EnMk* this, PlayState* play) { play->msgCtx.ocarinaMode = 4; this->actionFunc = func_80959D28; if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { - this->actor.cutscene = this->unk_276[0]; + this->actor.csId = this->csIdList[0]; SET_WEEKEVENTREG(WEEKEVENTREG_20_40); Item_Give(play, ITEM_SONG_NOVA); } else { - this->actor.cutscene = this->unk_276[1]; + this->actor.csId = this->csIdList[1]; } - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } else if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { func_80959844(this, play); this->actionFunc = func_80959A24; @@ -445,11 +445,11 @@ void EnMk_Update(Actor* thisx, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); - if ((this->unk_27A & 1) && !Cutscene_CheckActorAction(play, 0x7F)) { + if ((this->unk_27A & 1) && !Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_127)) { Actor_TrackPlayer(play, &this->actor, &this->unk_270, &sp38, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->unk_270.x, 0, 6, 0x1838, 0x64); diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.h b/src/overlays/actors/ovl_En_Mk/z_en_mk.h index bbf126f4e..518b0406d 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.h +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.h @@ -15,7 +15,7 @@ typedef struct EnMk { /* 0x1D4 */ Vec3s jointTable[OBJECT_MK_LIMB_MAX]; /* 0x222 */ Vec3s morphTable[OBJECT_MK_LIMB_MAX]; /* 0x270 */ Vec3s unk_270; - /* 0x276 */ s16 unk_276[2]; + /* 0x276 */ s16 csIdList[2]; /* 0x27A */ u16 unk_27A; /* 0x27C */ s16 unk_27C; /* 0x280 */ EnMkActionFunc actionFunc; 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 cbbaffca9..4f1ddc660 100644 --- a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c +++ b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c @@ -256,31 +256,31 @@ void func_80A4E2E8(EnMkk* this, PlayState* play) { s32 sp20; this->unk_14E--; - if ((this->actor.params == 1) && (this->actor.bgCheckFlags & 1) && (this->actor.speedXZ > 2.5f) && + if ((this->actor.params == 1) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.speed > 2.5f) && ((play->gameplayFrames % 3) == 0)) { func_80A4E22C(this, play); } if (this->unk_14E > 0) { - Math_StepToF(&this->actor.speedXZ, 5.0f, 0.7f); + Math_StepToF(&this->actor.speed, 5.0f, 0.7f); sp20 = false; } else { - sp20 = Math_StepToF(&this->actor.speedXZ, 0.0f, 0.7f); + sp20 = Math_StepToF(&this->actor.speed, 0.0f, 0.7f); } if ((player->stateFlags3 & 0x100) || (Player_GetMask(play) == PLAYER_MASK_STONE)) { - Math_ScaledStepToS(&this->unk_150, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x400); + Math_ScaledStepToS(&this->unk_150, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), 0x400); } else if ((player->stateFlags2 & 0x80) || (player->actor.freezeTimer > 0)) { Math_ScaledStepToS(&this->unk_150, this->actor.yawTowardsPlayer + 0x8000, 0x400); } else { Math_ScaledStepToS(&this->unk_150, this->actor.yawTowardsPlayer, 0x400); } this->actor.shape.rot.y = - (s32)(sin_rad(this->unk_14E * ((2 * M_PI) / 15)) * (614.4f * this->actor.speedXZ)) + this->unk_150; + (s32)(sin_rad(this->unk_14E * ((2 * M_PI) / 15)) * (614.4f * this->actor.speed)) + this->unk_150; func_800B9010(&this->actor, NA_SE_EN_KUROSUKE_MOVE - SFX_FLAG); if (sp20) { this->unk_14B &= ~2; func_80A4E190(this); } else if ((this->unk_149 == 0) && (!(player->stateFlags3 & 0x100)) && - (Player_GetMask(play) != PLAYER_MASK_STONE) && (this->actor.bgCheckFlags & 1) && + (Player_GetMask(play) != PLAYER_MASK_STONE) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (Actor_IsFacingPlayer(&this->actor, 0x1800)) && (this->actor.xzDistToPlayer < 120.0f) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { func_80A4E58C(this); @@ -289,9 +289,9 @@ void func_80A4E2E8(EnMkk* this, PlayState* play) { void func_80A4E58C(EnMkk* this) { this->unk_14B |= 1; - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; this->actor.velocity.y = 5.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUROSUKE_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_KUROSUKE_ATTACK); this->collider.base.atFlags |= AT_ON; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x800); this->actionFunc = func_80A4E60C; @@ -301,7 +301,7 @@ void func_80A4E60C(EnMkk* this, PlayState* play) { if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~(AT_ON | AT_HIT); } - if ((this->actor.velocity.y < 0.0f) && (this->actor.bgCheckFlags & 1)) { + if ((this->actor.velocity.y < 0.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->unk_149 = 2; this->collider.base.atFlags &= ~AT_ON; func_80A4E2B8(this); @@ -313,35 +313,35 @@ void func_80A4E67C(EnMkk* this) { this->actor.flags &= ~ACTOR_FLAG_1; this->collider.base.acFlags &= ~AC_ON; this->actor.flags |= ACTOR_FLAG_10; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_DEAD); this->alpha = 254; func_800BE568(&this->actor, &this->collider); - this->actor.speedXZ = 7.0f; + this->actor.speed = 7.0f; this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.velocity.y = 5.0f; this->actor.gravity = -1.3f; - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->actionFunc = func_80A4E72C; } void func_80A4E72C(EnMkk* this, PlayState* play) { Vec3f temp; - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (this->actor.velocity.y > -1.0f) { temp.x = this->actor.world.pos.x; temp.y = this->actor.world.pos.y + 15.0f; temp.z = this->actor.world.pos.z; EffectSsDeadDb_Spawn(play, &temp, &gZeroVec3f, &gZeroVec3f, &sEffPrimColors[this->actor.params], &sEffEnvColors[this->actor.params], 0x46, 4, 0xC); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EXTINCT); + Actor_PlaySfx(&this->actor, NA_SE_EN_EXTINCT); if (this->unk_14C != 0) { Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, this->unk_14C * 0x10); } func_80A4EEF4(this); } else { this->actor.velocity.y *= -0.8f; - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; } } } @@ -379,16 +379,16 @@ void func_80A4E84C(EnMkk* this) { this->unk_154.y = this->actor.world.pos.y; this->unk_154.x = this->actor.world.pos.x - 10.0f * Math_SinS(this->actor.shape.rot.y + - (s32)(1228.8f * this->actor.speedXZ * sin_rad(this->unk_14E * (M_PI / 5)))); + (s32)(1228.8f * this->actor.speed * sin_rad(this->unk_14E * (M_PI / 5)))); this->unk_154.z = this->actor.world.pos.z - 10.0f * Math_CosS(this->actor.shape.rot.y + - (s32)(1228.8f * this->actor.speedXZ * sin_rad(this->unk_14E * (M_PI / 5)))); + (s32)(1228.8f * this->actor.speed * sin_rad(this->unk_14E * (M_PI / 5)))); this->unk_160.x = this->unk_154.x - 12.0f * Math_SinS(this->actor.shape.rot.y - - (s32)(1228.8f * this->actor.speedXZ * sin_rad(this->unk_14E * (M_PI / 5)))); + (s32)(1228.8f * this->actor.speed * sin_rad(this->unk_14E * (M_PI / 5)))); this->unk_160.z = this->unk_154.z - 12.0f * Math_CosS(this->actor.shape.rot.y - - (s32)(1228.8f * this->actor.speedXZ * sin_rad(this->unk_14E * (M_PI / 5)))); + (s32)(1228.8f * this->actor.speed * sin_rad(this->unk_14E * (M_PI / 5)))); } } @@ -415,13 +415,15 @@ void EnMkk_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); this->actor.world.rot.y = this->actor.shape.rot.y; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); if (this->actor.params == 0) { func_80A4E84C(this); } if (Actor_IsFacingPlayer(&this->actor, 0x3000)) { player = GET_PLAYER(play); - this->actor.shape.rot.x = Actor_PitchToPoint(&this->actor, &player->actor.focus.pos); + this->actor.shape.rot.x = Actor_WorldPitchTowardPoint(&this->actor, &player->actor.focus.pos); this->actor.shape.rot.x = CLAMP(this->actor.shape.rot.x, -0x1800, 0x1800); } Actor_SetFocus(&this->actor, 10.0f); @@ -483,7 +485,7 @@ void func_80A4EF74(EnMkk* this, PlayState* play) { Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); Math_Vec3f_Copy(&this->unk_154, &this->actor.world.pos); Math_Vec3f_Copy(&this->unk_160, &this->actor.world.pos); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; func_80A4EDF0(this); } else { 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 d9b0bf507..67a0a1e77 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -87,7 +87,7 @@ void EnMm_Init(Actor* thisx, PlayState* play) { func_80965BBC(this); return; } - if (this->actor.cutscene >= 0) { + if (this->actor.csId >= 0) { action = func_80965D3C; } else { action = func_80965DB4; @@ -102,13 +102,13 @@ void EnMm_Destroy(Actor* thisx, PlayState* play) { } void func_80965D3C(EnMm* this, PlayState* play) { - s16 cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + s16 csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); - if (ActorCutscene_GetCanPlayNext(cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(cutscene, &this->actor); + if (CutsceneManager_IsNext(csId)) { + CutsceneManager_StartWithPlayerCs(csId, &this->actor); EnMm_SetupAction(this, func_80965DB4); } else { - ActorCutscene_SetIntentToPlay(cutscene); + CutsceneManager_Queue(csId); } } @@ -124,54 +124,55 @@ void func_80965DB4(EnMm* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { func_80965BBC(this); - Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PULL_UP_ROCK); + Actor_PlaySfx(&this->actor, NA_SE_PL_PULL_UP_ROCK); } else { - if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & 0x10)) { + if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_CEILING)) { this->actor.velocity.y = 0.0f; } - if ((this->actor.speedXZ != 0.0f) && (this->actor.bgCheckFlags & 8)) { + if ((this->actor.speed != 0.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_WALL)) { angle = BINANG_SUB(this->actor.world.rot.y, BINANG_ROT180(this->actor.wallYaw)); this->actor.world.rot.y += BINANG_SUB(0x8000, (s16)(angle * 2)); - this->actor.speedXZ *= 0.5f; + this->actor.speed *= 0.5f; CollisionCheck_SpawnShieldParticles(play, &this->actor.world.pos); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EV_HUMAN_BOUND); } - if (!(this->actor.bgCheckFlags & 1)) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.08f); + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + Math_StepToF(&this->actor.speed, 0.0f, 0.08f); } else { - temp_f14 = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; - temp_f12 = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; + temp_f14 = Math_SinS(this->actor.world.rot.y) * this->actor.speed; + temp_f12 = Math_CosS(this->actor.world.rot.y) * this->actor.speed; Actor_GetSlopeDirection(this->actor.floorPoly, &slopeNormal, &downwardSlopeYaw); temp_f14 += 3.0f * slopeNormal.x; temp_f12 += 3.0f * slopeNormal.z; temp_f2 = sqrtf(SQ(temp_f14) + SQ(temp_f12)); - if ((temp_f2 < this->actor.speedXZ) || - (SurfaceType_GetSlope(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 1)) { - this->actor.speedXZ = CLAMP_MAX(temp_f2, 16.0f); + if ((temp_f2 < this->actor.speed) || + (SurfaceType_GetFloorEffect(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == + FLOOR_EFFECT_1)) { + this->actor.speed = CLAMP_MAX(temp_f2, 16.0f); this->actor.world.rot.y = Math_Atan2S_XY(temp_f12, temp_f14); } - if (!Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f)) { + if (!Math_StepToF(&this->actor.speed, 0.0f, 1.0f)) { direction = this->actor.world.rot.y; if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->actor.shape.rot.y)) > 0x4000) { direction = BINANG_ROT180(direction); } - Math_ScaledStepToS(&this->actor.shape.rot.y, direction, this->actor.speedXZ * 100.0f); - this->unk_190 += (s16)(this->actor.speedXZ * 800.0f); + Math_ScaledStepToS(&this->actor.shape.rot.y, direction, this->actor.speed * 100.0f); + this->unk_190 += (s16)(this->actor.speed * 800.0f); } - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { if (this->actor.velocity.y < -6.0f) { this->actor.velocity.y *= -0.3f; - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EV_HUMAN_BOUND); } else { - Actor_PickUp(&this->actor, play, GI_NONE, 50.0f, 30.0f); + Actor_OfferGetItem(&this->actor, play, GI_NONE, 50.0f, 30.0f); } } @@ -186,7 +187,7 @@ void func_8096611C(EnMm* this, PlayState* play) { if (Actor_HasNoParent(&this->actor, play)) { EnMm_SetupAction(this, func_80965DB4); this->actor.room = play->roomCtx.curRoom.num; - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; Math_Vec3s_ToVec3f(&this->actor.prevPos, &this->actor.home.rot); gSaveContext.unk_1014 = 0; } else { @@ -200,7 +201,9 @@ void EnMm_Update(Actor* thisx, PlayState* play) { Collider_ResetCylinderAC(play, &this->collider.base); this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 10.0f, 20.0f, 31); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 10.0f, 20.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); Actor_SetFocus(&this->actor, 20.0f); } 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 14c8d1170..48a379304 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c @@ -49,7 +49,7 @@ void EnMm2_Reading(EnMm2* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = EnMm2_WaitForRead; } break; diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index 3e58691cc..366bddef3 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -92,7 +92,7 @@ void EnMm3_Init(Actor* thisx, PlayState* play) { Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); this->actor.parent = NULL; this->actor.targetMode = 0; this->unk_1DC = 1; @@ -106,7 +106,7 @@ void EnMm3_Init(Actor* thisx, PlayState* play) { void EnMm3_Destroy(Actor* thisx, PlayState* play) { EnMm3* this = THIS; - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); Collider_DestroyCylinder(play, &this->collider); } @@ -148,7 +148,7 @@ void func_80A6F3B4(EnMm3* this, PlayState* play) { case 0x278E: if (play->msgCtx.choiceIndex == 0) { if (this->unk_2B2 & 0x20) { - if (gSaveContext.save.playerData.rupees >= play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees >= play->msgCtx.unk1206C) { func_8019F208(); Message_StartTextbox(play, 0x2790, &this->actor); this->unk_2B4 = 0x2790; @@ -174,7 +174,7 @@ void func_80A6F3B4(EnMm3* this, PlayState* play) { case 0x279A: if (play->msgCtx.choiceIndex == 0) { - if (gSaveContext.save.playerData.rupees >= play->msgCtx.unk1206C) { + if (gSaveContext.save.saveInfo.playerData.rupees >= play->msgCtx.unk1206C) { func_8019F208(); Message_StartTextbox(play, 0x2790, &this->actor); this->unk_2B4 = 0x2790; @@ -271,7 +271,7 @@ void func_80A6F5E4(EnMm3* this, PlayState* play) { break; case 0x2793: - func_801477B4(play); + Message_CloseTextbox(play); func_80A6FE1C(this); func_80A6FE30(this, play); break; @@ -279,7 +279,7 @@ void func_80A6F5E4(EnMm3* this, PlayState* play) { case 0x2795: case 0x2796: case 0x2797: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED)) { Message_StartTextbox(play, 0x279B, &this->actor); this->unk_2B4 = 0x279B; func_80151BB4(play, 0xB); @@ -347,12 +347,12 @@ void func_80A6F9DC(EnMm3* this, PlayState* play) { } else { Interface_StartPostmanTimer(0, POSTMAN_MINIGAME_BUNNY_HOOD_OFF); } - func_801477B4(play); + Message_CloseTextbox(play); play_sound(NA_SE_SY_START_SHOT); func_80A6FBA0(this); } else { - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); func_80A6F270(this); } } @@ -365,7 +365,7 @@ void func_80A6F9DC(EnMm3* this, PlayState* play) { if (((this->unk_2B4 == 0x279D) || (this->unk_2B4 == 0x27A0) || (this->unk_2B4 == 0x278B)) && Animation_OnFrame(&this->skelAnime, 8.0f) && (this->unk_2AE == 0)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_LIE_DOWN_ON_BED); + Actor_PlaySfx(&this->actor, NA_SE_EV_LIE_DOWN_ON_BED); this->unk_2AE = 1; } } @@ -373,9 +373,9 @@ void func_80A6F9DC(EnMm3* this, PlayState* play) { void func_80A6FBA0(EnMm3* this) { AudioSfx_MuteBanks((1 << BANK_PLAYER) | (1 << BANK_ITEM) | (1 << BANK_ENV) | (1 << BANK_ENEMY) | (1 << BANK_OCARINA) | (1 << BANK_VOICE)); - func_801A0238(0, 5); - SET_WEEKEVENTREG(WEEKEVENTREG_63_01); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + Audio_SetMainBgmVolume(0, 5); + SET_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); this->actionFunc = func_80A6FBFC; } @@ -400,7 +400,7 @@ void func_80A6FBFC(EnMm3* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { AudioSfx_MuteBanks(0); - func_801A0238(0x7F, 5); + Audio_SetMainBgmVolume(0x7F, 5); Message_StartTextbox(play, 0x2791, &this->actor); this->unk_2B4 = 0x2791; this->unk_2AC = 7; @@ -431,9 +431,9 @@ void func_80A6FE30(EnMm3* this, PlayState* play) { this->actor.parent = NULL; func_80A6FED8(this); } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_01)) { - Actor_PickUp(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); } else { - Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); } } @@ -453,7 +453,7 @@ void func_80A6FEEC(EnMm3* this, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_10000; func_80A6F9C8(this); } else { - func_800B85E0(&this->actor, play, 200.0f, -1); + func_800B85E0(&this->actor, play, 200.0f, PLAYER_IA_MINUS1); } } 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 6aac1355d..3cbf7e2ad 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -69,7 +69,7 @@ void EnMs_Init(Actor* thisx, PlayState* play) { 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; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; this->actor.gravity = -1.0f; } @@ -83,7 +83,7 @@ void EnMs_Destroy(Actor* thisx, PlayState* play) { void EnMs_Wait(EnMs* this, PlayState* play) { s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (gSaveContext.save.inventory.items[SLOT_MAGIC_BEANS] == ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[SLOT_MAGIC_BEANS] == ITEM_NONE) { this->actor.textId = 0x92E; // "[...] You're the first customer [...]" } else { this->actor.textId = 0x932; // "[...] So you liked my Magic Beans [...]" @@ -106,9 +106,9 @@ void EnMs_Talk(EnMs* this, PlayState* play) { case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { - func_801477B4(play); - Actor_PickUp(&this->actor, play, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, - this->actor.playerHeightRel); + Message_CloseTextbox(play); + Actor_OfferGetItem(&this->actor, play, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, + this->actor.playerHeightRel); this->actionFunc = EnMs_Sell; } break; @@ -117,16 +117,16 @@ void EnMs_Talk(EnMs* this, PlayState* play) { if (Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: // yes - func_801477B4(play); - if (gSaveContext.save.playerData.rupees < 10) { + Message_CloseTextbox(play); + if (gSaveContext.save.saveInfo.playerData.rupees < 10) { play_sound(NA_SE_SY_ERROR); - func_80151938(play, 0x935); // "[...] You don't have enough Rupees." + Message_ContinueTextbox(play, 0x935); // "[...] You don't have enough Rupees." } else if (AMMO(ITEM_MAGIC_BEANS) >= 20) { play_sound(NA_SE_SY_ERROR); - func_80151938(play, 0x937); // "[...] You can't carry anymore." + Message_ContinueTextbox(play, 0x937); // "[...] You can't carry anymore." } else { func_8019F208(); - Actor_PickUp(&this->actor, play, GI_MAGIC_BEANS, 90.0f, 10.0f); + Actor_OfferGetItem(&this->actor, play, GI_MAGIC_BEANS, 90.0f, 10.0f); Rupees_ChangeBy(-10); this->actionFunc = EnMs_Sell; } @@ -135,7 +135,7 @@ void EnMs_Talk(EnMs* this, PlayState* play) { case 1: // no default: func_8019F230(); - func_80151938(play, 0x934); // "[...] Well, if your mood changes [...]" + Message_ContinueTextbox(play, 0x934); // "[...] Well, if your mood changes [...]" break; } } @@ -152,13 +152,13 @@ void EnMs_Sell(EnMs* this, PlayState* play) { func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, PLAYER_IA_NONE); this->actionFunc = EnMs_TalkAfterPurchase; } else { - Actor_PickUp(&this->actor, play, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_OfferGetItem(&this->actor, play, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); } } void EnMs_TalkAfterPurchase(EnMs* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - func_80151938(play, 0x936); // "You can plant 'em whenever you want [...]" + Message_ContinueTextbox(play, 0x936); // "You can plant 'em whenever you want [...]" this->actionFunc = EnMs_Talk; } else { func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, PLAYER_IA_MINUS1); diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c index a077ee1bf..c94a94b12 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c @@ -220,7 +220,8 @@ s32 EnMttag_UpdateCheckpoints(EnMttag* this, PlayState* play) { } if ((currentCheckpoints[0] > 0) && (currentCheckpoints[0] < highestCurrentCheckpoint) && - (player->actor.bgCheckFlags & 1) && ((highestCurrentCheckpoint - currentCheckpoints[0]) >= 24)) { + (player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + ((highestCurrentCheckpoint - currentCheckpoints[0]) >= 24)) { playerIsLikelyToLose = true; } @@ -234,7 +235,7 @@ s32 EnMttag_UpdateCheckpoints(EnMttag* this, PlayState* play) { s32 EnMttag_ExitRace(PlayState* play, s32 transitionType, s32 nextTransitionType) { CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; play->nextEntrance = ENTRANCE(GORON_RACETRACK, 2); - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE)) { // Spring gSaveContext.nextCutsceneIndex = 0xFFF0; } else { @@ -245,7 +246,7 @@ s32 EnMttag_ExitRace(PlayState* play, s32 transitionType, s32 nextTransitionType play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = transitionType; gSaveContext.nextTransitionType = nextTransitionType; - func_801477B4(play); + Message_CloseTextbox(play); return 1; } @@ -255,8 +256,8 @@ s32 EnMttag_ExitRace(PlayState* play, s32 transitionType, s32 nextTransitionType void EnMttag_ShowFalseStartMessage(EnMttag* this, PlayState* play) { gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_OFF; Message_StartTextbox(play, 0xE95, NULL); // An entrant made a false start - func_800B7298(play, &this->actor, PLAYER_CSMODE_7); - Audio_QueueSeqCmd(0x101400FF); + func_800B7298(play, &this->actor, PLAYER_CSMODE_WAIT); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20); this->actionFunc = EnMttag_PotentiallyRestartRace; } @@ -266,7 +267,7 @@ void EnMttag_ShowFalseStartMessage(EnMttag* this, PlayState* play) { */ void EnMttag_ShowCantWinMessage(EnMttag* this, PlayState* play) { Message_StartTextbox(play, 0xE97, NULL); // You can't win now... - func_800B7298(play, &this->actor, PLAYER_CSMODE_7); + func_800B7298(play, &this->actor, PLAYER_CSMODE_WAIT); this->actionFunc = EnMttag_HandleCantWinChoice; } @@ -274,11 +275,11 @@ void EnMttag_ShowCantWinMessage(EnMttag* this, PlayState* play) { * Shows the cutscene that pans over the race track and shows all five race entrants. */ void EnMttag_ShowIntroCutscene(EnMttag* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); this->actionFunc = EnMttag_WaitForIntroCutsceneToEnd; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -287,7 +288,7 @@ void EnMttag_ShowIntroCutscene(EnMttag* this, PlayState* play) { * from showing again and starts the race. */ void EnMttag_WaitForIntroCutsceneToEnd(EnMttag* this, PlayState* play) { - if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + if (CutsceneManager_GetCurrentCsId() != this->actor.csId) { SET_WEEKEVENTREG(WEEKEVENTREG_12_02); this->actionFunc = EnMttag_RaceStart; } @@ -316,7 +317,7 @@ void EnMttag_RaceStart(EnMttag* this, PlayState* play) { if (DECR(this->timer) == 60) { Interface_StartTimer(TIMER_ID_MINIGAME_2, 0); play->interfaceCtx.minigameState = MINIGAME_STATE_COUNTDOWN_SETUP_3; - Audio_QueueSeqCmd(NA_BGM_GORON_RACE | 0x8000); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_GORON_RACE | SEQ_FLAG_ASYNC); play->envCtx.unk_E4 = 0xFE; player->stateFlags1 &= ~PLAYER_STATE1_20; } else if ((this->timer < 60) && (play->interfaceCtx.minigameState == MINIGAME_STATE_COUNTDOWN_GO)) { @@ -361,14 +362,14 @@ void EnMttag_Race(EnMttag* this, PlayState* play) { if (EnMttag_IsInFinishLine(playerPos)) { gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; play_sound(NA_SE_SY_START_SHOT); - Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_GORON_GOAL | SEQ_FLAG_ASYNC); this->timer = 55; SET_EVENTINF(EVENTINF_11); this->actionFunc = EnMttag_RaceFinish; } else if (EnMttag_IsAnyRaceGoronOverFinishLine(this)) { gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; play_sound(NA_SE_SY_START_SHOT); - Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_GORON_GOAL | SEQ_FLAG_ASYNC); this->timer = 55; SET_EVENTINF(EVENTINF_12); this->actionFunc = EnMttag_RaceFinish; @@ -398,10 +399,10 @@ void EnMttag_RaceFinish(EnMttag* this, PlayState* play) { if (DECR(this->timer) == 0) { if (CHECK_EVENTINF(EVENTINF_11)) { // Player won - EnMttag_ExitRace(play, TRANS_TYPE_03, TRANS_TYPE_03); + EnMttag_ExitRace(play, TRANS_TYPE_FADE_WHITE, TRANS_TYPE_FADE_WHITE); } else { // A non-player Goron won - EnMttag_ExitRace(play, TRANS_TYPE_02, TRANS_TYPE_02); + EnMttag_ExitRace(play, TRANS_TYPE_FADE_BLACK, TRANS_TYPE_FADE_BLACK); } Actor_Kill(&this->actor); @@ -420,7 +421,7 @@ void EnMttag_PotentiallyRestartRace(EnMttag* this, PlayState* play) { if (this->shouldRestartRace) { play->nextEntrance = ENTRANCE(GORON_RACETRACK, 1); - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE)) { // Spring gSaveContext.nextCutsceneIndex = 0xFFF0; } else { @@ -429,10 +430,10 @@ void EnMttag_PotentiallyRestartRace(EnMttag* this, PlayState* play) { } play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_02; - gSaveContext.nextTransitionType = TRANS_TYPE_02; - func_801477B4(play); - func_800B7298(play, &this->actor, PLAYER_CSMODE_7); + play->transitionType = TRANS_TYPE_FADE_BLACK; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; + Message_CloseTextbox(play); + func_800B7298(play, &this->actor, PLAYER_CSMODE_WAIT); Magic_Add(play, MAGIC_FILL_TO_CAPACITY); CLEAR_EVENTINF(EVENTINF_10); @@ -441,7 +442,7 @@ void EnMttag_PotentiallyRestartRace(EnMttag* this, PlayState* play) { CLEAR_EVENTINF(EVENTINF_13); gSaveContext.eventInf[2] = ((gSaveContext.eventInf[2] & 0xF) + 1) | (gSaveContext.eventInf[2] & 0xF0); } else { - EnMttag_ExitRace(play, TRANS_TYPE_02, TRANS_TYPE_02); + EnMttag_ExitRace(play, TRANS_TYPE_FADE_BLACK, TRANS_TYPE_FADE_BLACK); } Actor_Kill(&this->actor); } @@ -457,7 +458,7 @@ void EnMttag_HandleCantWinChoice(EnMttag* this, PlayState* play) { // Exit the race func_8019F230(); gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_OFF; - EnMttag_ExitRace(play, TRANS_TYPE_02, TRANS_TYPE_02); + EnMttag_ExitRace(play, TRANS_TYPE_FADE_BLACK, TRANS_TYPE_FADE_BLACK); CLEAR_EVENTINF(EVENTINF_13); SET_EVENTINF(EVENTINF_12); Actor_Kill(&this->actor); @@ -466,8 +467,8 @@ void EnMttag_HandleCantWinChoice(EnMttag* this, PlayState* play) { // Keep racing func_8019F208(); - func_801477B4(play); - func_800B7298(play, &this->actor, PLAYER_CSMODE_6); + Message_CloseTextbox(play); + func_800B7298(play, &this->actor, PLAYER_CSMODE_END); CLEAR_EVENTINF(EVENTINF_13); this->timer = 100; this->actionFunc = EnMttag_Race; 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 c10244e55..4bf4db0e0 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -178,7 +178,7 @@ void func_80A68A78(EnMushi2* this, PlayState* play) { Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_MUSHI2, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, this->actor.shape.rot.y + (D_80A6B998 + i)->unk_02, this->actor.shape.rot.z, - (D_80A6B998 + i)->unk_00, this->actor.cutscene, this->actor.unk20, NULL); + (D_80A6B998 + i)->unk_00, this->actor.csId, this->actor.halfDaysBits, NULL); } } @@ -204,7 +204,7 @@ void func_80A68BC8(EnMushi2* this) { if (this->unk_36C > 0) { this->unk_36C--; } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MUSI_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_MUSI_WALK); this->unk_36C = 3.0f / CLAMP_MIN(this->skelAnime.playSpeed, 0.12f); if (this->unk_36C < 2) { @@ -275,9 +275,9 @@ s32 func_80A68DD4(EnMushi2* this, PlayState* play) { } 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; + this->actor.velocity.x = this->actor.speed * this->unk_328.x; + this->actor.velocity.y = this->actor.speed * this->unk_328.y; + this->actor.velocity.z = this->actor.speed * this->unk_328.z; Actor_UpdatePos(&this->actor); } @@ -439,7 +439,8 @@ void func_80A69388(EnMushi2* this) { } void func_80A69424(EnMushi2* this, PlayState* play) { - Actor_UpdateBgCheckInfo(play, &this->actor, 8.0f, 9.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(play, &this->actor, 8.0f, 9.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40); } s32 func_80A69468(EnMushi2* this, PlayState* play) { @@ -797,7 +798,7 @@ void func_80A6A36C(EnMushi2* this, PlayState* play) { s32 pad; s32 sp20 = false; - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); + Math_StepToF(&this->actor.speed, 0.0f, 0.2f); this->actor.velocity.y -= this->actor.velocity.y * D_80A6BA14[ENMUSHI2_GET_3(&this->actor)]; Actor_MoveWithGravity(&this->actor); func_80A69424(this, play); @@ -820,10 +821,10 @@ void func_80A6A36C(EnMushi2* this, PlayState* play) { return; } - if (this->actor.bgCheckFlags & 0x20) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { func_80A6AAA4(this); - } else if (this->actor.bgCheckFlags & 1) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_WALK); + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + Actor_PlaySfx(&this->actor, NA_SE_EN_GERUDOFT_WALK); func_80A68F24(this); func_80A691EC(this, this->actor.floorPoly, -1.0f); func_80A69388(this); @@ -853,11 +854,11 @@ void func_80A6A5C0(EnMushi2* this, PlayState* play) { EnMushi2* this2 = this; func_80A69D3C(this); - Math_SmoothStepToF(&this->actor.speedXZ, this->unk_35C, 0.1f, 0.5f, 0.0f); + Math_SmoothStepToF(&this->actor.speed, this->unk_35C, 0.1f, 0.5f, 0.0f); if (this->unk_354 < SQ(40.0f)) { f32 temp = 1.0f - ((SQ(40.0f) - this->unk_354) * (1.0f / (10.0f * SQ(40.0f)))); - this->actor.speedXZ *= temp; + this->actor.speed *= temp; } func_80A68ED8(this); @@ -866,7 +867,7 @@ void func_80A6A5C0(EnMushi2* this, PlayState* play) { func_80A69388(this); } - this->skelAnime.playSpeed = this->actor.speedXZ * 1.6f; + this->skelAnime.playSpeed = this->actor.speed * 1.6f; this2->skelAnime.playSpeed = CLAMP(this2->skelAnime.playSpeed, 0.1f, 1.9f); if ((this->unk_36A <= 0) || func_80A68BA0(this)) { @@ -896,7 +897,7 @@ void func_80A6A794(EnMushi2* this) { void func_80A6A824(EnMushi2* this, PlayState* play) { EnMushi2* this2 = this; - Math_SmoothStepToF(&this->actor.speedXZ, this->unk_35C, 0.1f, 0.5f, 0.0f); + Math_SmoothStepToF(&this->actor.speed, this->unk_35C, 0.1f, 0.5f, 0.0f); func_80A68ED8(this); func_80A697C4(this, play); @@ -904,7 +905,7 @@ void func_80A6A824(EnMushi2* this, PlayState* play) { func_80A69388(this); } - this->skelAnime.playSpeed = (Rand_ZeroOne() * 0.8f) + (this->actor.speedXZ * 1.2f); + this->skelAnime.playSpeed = (Rand_ZeroOne() * 0.8f) + (this->actor.speed * 1.2f); this2->skelAnime.playSpeed = CLAMP(this2->skelAnime.playSpeed, 0.0f, 1.9f); if ((this->unk_36A <= 0) || func_80A68BA0(this)) { @@ -963,9 +964,9 @@ void func_80A6AB08(EnMushi2* this, PlayState* play) { s16 temp; if (this->unk_368 > 80) { - Math_StepToF(&this->actor.speedXZ, 0.6f, 0.08f); + Math_StepToF(&this->actor.speed, 0.6f, 0.08f); } else { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.02f); + Math_StepToF(&this->actor.speed, 0.0f, 0.02f); } Actor_MoveWithGravity(&this->actor); @@ -1005,7 +1006,7 @@ void func_80A6AB08(EnMushi2* this, PlayState* play) { func_80A6A094(this); func_80A6A0D8(this); func_80A6AE14(this); - } else if (!(this->actor.bgCheckFlags & 0x20)) { + } else if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { func_80A6A794(this); } } @@ -1025,8 +1026,8 @@ void func_80A6AE7C(EnMushi2* this, PlayState* play) { this->actor.shape.rot.x -= 0x1F4; this->actor.shape.rot.y += 0xC8; - this->actor.speedXZ += (Rand_ZeroOne() - 0.5f) * 0.16f; - this->actor.speedXZ *= 0.9f; + this->actor.speed += (Rand_ZeroOne() - 0.5f) * 0.16f; + this->actor.speed *= 0.9f; 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; @@ -1049,7 +1050,7 @@ void func_80A6B078(EnMushi2* this) { this->unk_30C &= ~1; this->unk_368 = 50; this->skelAnime.playSpeed = 1.9f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALTURA_BOUND); func_80A68B6C(this); this->actionFunc = func_80A6B0D8; } @@ -1058,7 +1059,7 @@ void func_80A6B0D8(EnMushi2* this, PlayState* play) { s32 pad[2]; f32 temp_f2; - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.4f, 1.2f, 0.0f); + Math_SmoothStepToF(&this->actor.speed, 0.0f, 0.4f, 1.2f, 0.0f); temp_f2 = this->actor.scale.x - 0.0002f; Actor_SetScale(&this->actor, CLAMP_MIN(temp_f2, 0.001f)); @@ -1077,19 +1078,20 @@ void func_80A6B0D8(EnMushi2* this, PlayState* play) { } this->actor.velocity.x = - (this->actor.speedXZ * this->unk_328.x) + (-0.01f * this->unk_31C.x) + (this->unk_310.x * temp_f2); + (this->actor.speed * this->unk_328.x) + (-0.01f * this->unk_31C.x) + (this->unk_310.x * temp_f2); this->actor.velocity.y = - (this->actor.speedXZ * this->unk_328.y) + (-0.01f * this->unk_31C.y) + (this->unk_310.y * temp_f2); + (this->actor.speed * this->unk_328.y) + (-0.01f * this->unk_31C.y) + (this->unk_310.y * temp_f2); this->actor.velocity.z = - (this->actor.speedXZ * this->unk_328.z) + (-0.01f * this->unk_31C.z) + (this->unk_310.z * temp_f2); + (this->actor.speed * this->unk_328.z) + (-0.01f * this->unk_31C.z) + (this->unk_310.z * temp_f2); if ((this->actor.flags & ACTOR_FLAG_40) && (this->unk_368 > 20) && (Rand_ZeroOne() < 0.15f)) { Vec3f sp48; s32 sp44 = 0; if (this->poly != NULL) { - u32 temp_v0 = func_800C99D4(&play->colCtx, this->poly, this->polyBgId); - if ((temp_v0 == 5) || (temp_v0 == 14) || (temp_v0 == 15)) { + FloorType floorType = SurfaceType_GetFloorType(&play->colCtx, this->poly, this->polyBgId); + + if ((floorType == FLOOR_TYPE_5) || (floorType == FLOOR_TYPE_14) || (floorType == FLOOR_TYPE_15)) { sp44 = 1; } } @@ -1159,7 +1161,7 @@ void EnMushi2_Update(Actor* thisx, PlayState* play) { if ((temp != BGCHECK_SCENE) && ((this->actionFunc == func_80A6A5C0) || (this->actionFunc == func_80A6A824) || (this->actionFunc == func_80A6A9E4) || (this->actionFunc == func_80A6B0D8)) && - BgCheck2_UpdateActorAttachedToMesh(&play->colCtx, temp, &this->actor)) { + DynaPolyActor_TransformCarriedActor(&play->colCtx, temp, &this->actor)) { func_80A68F24(this); } @@ -1225,7 +1227,7 @@ void EnMushi2_Update(Actor* thisx, PlayState* play) { } if ((this->unk_30C & 1) && func_80A68DD4(this, play)) { - Actor_PickUp(&this->actor, play, GI_MAX, 60.0f, 30.0f); + Actor_OfferGetItem(&this->actor, play, 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 f9d17ca96..7c9d1e9b2 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -199,7 +199,7 @@ void EnMuto_InDialogue(EnMuto* this, PlayState* play) { if (!this->isInMayorsRoom) { this->yawTowardsTarget = this->actor.yawTowardsPlayer; if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); if (this->actor.textId == 0x62C) { SET_WEEKEVENTREG(WEEKEVENTREG_88_08); @@ -272,7 +272,9 @@ void EnMuto_Update(Actor* thisx, PlayState* play2) { Math_SmoothStepToS(&this->headRot.x, this->headRotTarget.x, 1, 0x3E8, 0); Math_SmoothStepToS(&this->waistRot.y, this->waistRotTarget.y, 1, 0xBB8, 0); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); this->actor.uncullZoneForward = 500.0f; diff --git a/src/overlays/actors/ovl_En_Nb/z_en_nb.c b/src/overlays/actors/ovl_En_Nb/z_en_nb.c index 385325080..c5a8b2498 100644 --- a/src/overlays/actors/ovl_En_Nb/z_en_nb.c +++ b/src/overlays/actors/ovl_En_Nb/z_en_nb.c @@ -227,31 +227,31 @@ Actor* func_80BBFF90(EnNb* this, PlayState* play) { return actor; } -s32 func_80BBFFD4(EnNb* this, s16 index) { +s32 func_80BBFFD4(EnNb* this, s16 csId) { s32 ret = false; - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(index); - } else if (ActorCutscene_GetCanPlayNext(index)) { - ActorCutscene_StartAndSetUnkLinkFields(index, &this->actor); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(csId); + } else if (CutsceneManager_IsNext(csId)) { + CutsceneManager_StartWithPlayerCs(csId, &this->actor); ret = true; } else { - ActorCutscene_SetIntentToPlay(index); + CutsceneManager_Queue(csId); } return ret; } -s16 func_80BC0050(EnNb* this, s32 arg1) { - s16 cutscene = this->actor.cutscene; +s16 func_80BC0050(EnNb* this, s32 numCutscenes) { + s16 csId = this->actor.csId; s32 i; - for (i = 0; i < arg1; i++) { - cutscene = ActorCutscene_GetAdditionalCutscene(cutscene); + for (i = 0; i < numCutscenes; i++) { + csId = CutsceneManager_GetAdditionalCsId(csId); } - return cutscene; + return csId; } typedef enum EnNbBehaviour { @@ -269,12 +269,12 @@ typedef enum EnNbBehaviour { s32 func_80BC00AC(Actor* thisx, PlayState* play) { EnNb* this = THIS; - s16 cutscene = func_80BC0050(this, 0); + s16 csId = func_80BC0050(this, 0); s32 ret = false; switch (this->behaviour) { case ENNB_BEHAVIOUR_0: - if (!func_80BBFFD4(this, cutscene)) { + if (!func_80BBFFD4(this, csId)) { break; } // fallthrough @@ -282,7 +282,7 @@ s32 func_80BC00AC(Actor* thisx, PlayState* play) { case ENNB_BEHAVIOUR_4: case ENNB_BEHAVIOUR_6: case ENNB_BEHAVIOUR_8: - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(cutscene)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)), &this->actor); this->behaviour++; ret = true; break; @@ -292,7 +292,7 @@ s32 func_80BC00AC(Actor* thisx, PlayState* play) { case ENNB_BEHAVIOUR_5: case ENNB_BEHAVIOUR_7: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(cutscene)), + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)), this->actor.child); } this->behaviour++; @@ -300,7 +300,7 @@ s32 func_80BC00AC(Actor* thisx, PlayState* play) { break; case ENNB_BEHAVIOUR_9: - ActorCutscene_Stop(cutscene); + CutsceneManager_Stop(csId); this->behaviour++; ret = true; break; @@ -335,7 +335,7 @@ s32 func_80BC01DC(Actor* thisx, PlayState* play) { R_PLAY_FILL_SCREEN_ALPHA = (s16)(s32)(255.0f - (((f32)ABS_ALT(20 - this->storyTimer) / 20.0f) * 255.0f)); if (this->storyTimer == 20) { - if (gSaveContext.eventInf[4] & 4) { + if (CHECK_EVENTINF(EVENTINF_42)) { // play->interfaceCtx.storyType = STORY_TYPE_MASK_FESTIVAL; play->interfaceCtx.storyType = 0; } else { @@ -365,7 +365,7 @@ s32 func_80BC01DC(Actor* thisx, PlayState* play) { this->behaviour++; // fallthrough case ENNB_BEHAVIOUR_5: - if (!(gSaveContext.eventInf[4] & 4)) { + if (!CHECK_EVENTINF(EVENTINF_42)) { gSaveContext.save.time = CLOCK_TIME(8, 0); Sram_IncrementDay(); } else { @@ -376,9 +376,9 @@ s32 func_80BC01DC(Actor* thisx, PlayState* play) { play->nextEntrance = ENTRANCE(STOCK_POT_INN, 2); gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_02; - gSaveContext.nextTransitionType = TRANS_TYPE_06; - gSaveContext.eventInf[4] |= 8; + play->transitionType = TRANS_TYPE_FADE_BLACK; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK_SLOW; + SET_EVENTINF(EVENTINF_43); break; } @@ -386,7 +386,7 @@ s32 func_80BC01DC(Actor* thisx, PlayState* play) { } u8* func_80BC045C(EnNb* this, PlayState* play) { - if (gSaveContext.eventInf[4] & 8) { + if (CHECK_EVENTINF(EVENTINF_43)) { this->msgEventCallback = func_80BC01DC; return D_80BC1464; } else if (this->scheduleResult == EN_NB_SCH_2) { @@ -586,7 +586,7 @@ s32 func_80BC0B98(EnNb* this, PlayState* play, ScheduleOutput* scheduleOutput) { } s32 func_80BC0C0C(EnNb* this, PlayState* play, ScheduleOutput* scheduleOutput) { - if (!(gSaveContext.eventInf[4] & 8)) { + if (!CHECK_EVENTINF(EVENTINF_43)) { SubS_UpdateFlags(&this->stateFlags, EN_NB_FLAG_1 | EN_NB_FLAG_2, EN_NB_FLAG_1 | EN_NB_FLAG_2 | EN_NB_FLAG_4); } else { SubS_UpdateFlags(&this->stateFlags, EN_NB_FLAG_4, EN_NB_FLAG_1 | EN_NB_FLAG_2 | EN_NB_FLAG_4); @@ -640,7 +640,7 @@ void EnNb_FollowSchedule(EnNb* this, PlayState* play) { this->timePathTimeSpeed = R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset); - if (gSaveContext.eventInf[4] & 8) { + if (CHECK_EVENTINF(EVENTINF_43)) { scheduleOutput.result = EN_NB_SCH_1; EnNb_ProcessScheduleOutput(this, play, &scheduleOutput); this->actor.shape.shadowDraw = ActorShadow_DrawCircle; @@ -663,9 +663,9 @@ void EnNb_FollowSchedule(EnNb* this, PlayState* play) { void func_80BC0EAC(EnNb* this, PlayState* play) { if (func_8010BF58(&this->actor, play, this->msgEventScript, this->msgEventCallback, &this->msgEventArg4)) { - if (gSaveContext.eventInf[4] & 8) { - gSaveContext.eventInf[4] &= (u8)~4; - gSaveContext.eventInf[4] &= (u8)~8; + if (CHECK_EVENTINF(EVENTINF_43)) { + CLEAR_EVENTINF(EVENTINF_42); + CLEAR_EVENTINF(EVENTINF_43); } SubS_UpdateFlags(&this->stateFlags, EN_NB_FLAG_1 | EN_NB_FLAG_2, EN_NB_FLAG_1 | EN_NB_FLAG_2 | EN_NB_FLAG_4); @@ -695,11 +695,11 @@ void EnNb_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); this->stateFlags = EN_NB_FLAG_NONE; - if (gSaveContext.eventInf[4] & 8) { + if (CHECK_EVENTINF(EVENTINF_43)) { SubS_UpdateFlags(&this->stateFlags, EN_NB_FLAG_4, EN_NB_FLAG_1 | EN_NB_FLAG_2 | EN_NB_FLAG_4); } else { - gSaveContext.eventInf[4] &= (u8)~4; - gSaveContext.eventInf[4] &= (u8)~8; + CLEAR_EVENTINF(EVENTINF_42); + CLEAR_EVENTINF(EVENTINF_43); } this->actionFunc = EnNb_FollowSchedule; @@ -745,7 +745,7 @@ void EnNb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, EnNb* this = THIS; Vec3f focusTarget; - if ((ActorCutscene_GetCurrentIndex() == -1) && (limbIndex == NB_LIMB_HEAD)) { + if ((CutsceneManager_GetCurrentCsId() == CS_ID_NONE) && (limbIndex == NB_LIMB_HEAD)) { Matrix_MultVec3f(&gZeroVec3f, &focusTarget); Math_ApproachF(&thisx->focus.pos.x, focusTarget.x, 0.6f, 10000.0f); Math_ApproachF(&thisx->focus.pos.y, focusTarget.y, 0.6f, 10000.0f); diff --git a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c index 86099a214..960767b11 100644 --- a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c +++ b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c @@ -171,7 +171,7 @@ void EnNeoReeba_WaitUnderground(EnNeoReeba* this, PlayState* play) { s32 pad; Player* player = GET_PLAYER(play); - if ((Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos) < 200.0f) && + if ((Actor_WorldDistXZToPoint(&player->actor, &this->actor.home.pos) < 200.0f) && (Player_GetMask(play) != PLAYER_MASK_STONE) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { EnNeoReeba_SetupRise(this); } @@ -199,7 +199,7 @@ void EnNeoReeba_SetupChooseAction(EnNeoReeba* this) { void EnNeoReeba_ChooseAction(EnNeoReeba* this, PlayState* play) { Player* player = GET_PLAYER(play); - f32 distToPlayer = Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos); + f32 distToPlayer = Actor_WorldDistXZToPoint(&player->actor, &this->actor.home.pos); if ((distToPlayer > 200.0f) || (fabsf(this->actor.playerHeightRel) > 100.0f)) { EnNeoReeba_SetupSink(this); @@ -207,8 +207,8 @@ void EnNeoReeba_ChooseAction(EnNeoReeba* this, PlayState* play) { if (this->actionTimer == 0) { if ((distToPlayer < 140.0f) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { this->targetPos = player->actor.world.pos; - this->targetPos.x += 10.0f * player->actor.speedXZ * Math_SinS(player->actor.world.rot.y); - this->targetPos.z += 10.0f * player->actor.speedXZ * Math_CosS(player->actor.world.rot.y); + this->targetPos.x += 10.0f * player->actor.speed * Math_SinS(player->actor.world.rot.y); + this->targetPos.z += 10.0f * player->actor.speed * Math_CosS(player->actor.world.rot.y); EnNeoReeba_SetupMove(this); } else { EnNeoReeba_SetupReturnHome(this); @@ -224,7 +224,7 @@ void EnNeoReeba_ChooseAction(EnNeoReeba* this, PlayState* play) { void EnNeoReeba_SetupSink(EnNeoReeba* this) { this->sinkRiseRate = 0.0f; this->skelAnime.playSpeed = 2.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = EnNeoReeba_Sink; } @@ -247,7 +247,7 @@ void EnNeoReeba_SetupRise(EnNeoReeba* this) { this->actor.draw = EnNeoReeba_Draw; this->sinkRiseRate = 300.0f; this->skelAnime.playSpeed = 2.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_APPEAR); this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = EnNeoReeba_RiseOutOfGround; } @@ -268,28 +268,28 @@ void EnNeoReeba_RiseOutOfGround(EnNeoReeba* this, PlayState* play) { } void EnNeoReeba_SetupMove(EnNeoReeba* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_MOVE); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIVA_MOVE); this->sfxTimer = 10; this->actionTimer = 60; this->actionFunc = EnNeoReeba_Move; this->skelAnime.playSpeed = 2.0f; - this->actor.speedXZ = 14.0f; + this->actor.speed = 14.0f; } void EnNeoReeba_Move(EnNeoReeba* this, PlayState* play) { - f32 remainingDist = Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->targetPos, this->actor.speedXZ); + f32 remainingDist = Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->targetPos, this->actor.speed); Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, 4.0f, 0xFA, 0xA, 1); if (remainingDist < 2.0f) { EnNeoReeba_SetupChooseAction(this); - } else if (remainingDist < 40.0f && this->actor.speedXZ > 3.0f) { - this->actor.speedXZ -= 2.0f; + } else if (remainingDist < 40.0f && this->actor.speed > 3.0f) { + this->actor.speed -= 2.0f; } if (this->sfxTimer == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_MOVE); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIVA_MOVE); this->sfxTimer = 10; } else { this->sfxTimer--; @@ -304,21 +304,21 @@ void EnNeoReeba_Move(EnNeoReeba* this, PlayState* play) { void EnNeoReeba_SetupReturnHome(EnNeoReeba* this) { this->actionFunc = EnNeoReeba_ReturnHome; - this->actor.speedXZ = 6.0f; + this->actor.speed = 6.0f; } void EnNeoReeba_ReturnHome(EnNeoReeba* this, PlayState* play) { Player* player = GET_PLAYER(play); s32 pad; - f32 remainingDist = Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->actor.home.pos, this->actor.speedXZ); + f32 remainingDist = Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->actor.home.pos, this->actor.speed); if (remainingDist < 2.0f) { EnNeoReeba_SetupChooseAction(this); - } else if (remainingDist < 40.0f && this->actor.speedXZ > 3.0f) { - this->actor.speedXZ -= 1.0f; + } else if (remainingDist < 40.0f && this->actor.speed > 3.0f) { + this->actor.speed -= 1.0f; } - if (Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos) > 200.0f || + if (Actor_WorldDistXZToPoint(&player->actor, &this->actor.home.pos) > 200.0f || fabsf(this->actor.playerHeightRel) > 100.0f) { EnNeoReeba_SetupSink(this); } @@ -333,7 +333,7 @@ void EnNeoReeba_SetupBounce(EnNeoReeba* this) { } void EnNeoReeba_Bounce(EnNeoReeba* this, PlayState* play) { - if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->targetPos, this->actor.speedXZ) < 2.0f) { + if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->targetPos, this->actor.speed) < 2.0f) { EnNeoReeba_SetupChooseAction(this); } @@ -345,7 +345,7 @@ void EnNeoReeba_Bounce(EnNeoReeba* this, PlayState* play) { } void EnNeoReeba_SetupStun(EnNeoReeba* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = EnNeoReeba_Stunned; } @@ -378,7 +378,7 @@ void EnNeoReeba_SetupFrozen(EnNeoReeba* this) { this->stunTimer = 12; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = EnNeoReeba_Frozen; } @@ -407,8 +407,8 @@ void EnNeoReeba_SetupDamageAnim(EnNeoReeba* this) { this->velToTarget.x = Math_SinS(this->actor.yawTowardsPlayer) * -12.0f; this->velToTarget.z = Math_CosS(this->actor.yawTowardsPlayer) * -12.0f; this->rotationSpeed = 4551.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_DAMAGE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 25); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIVA_DAMAGE); this->actionFunc = EnNeoReeba_DamageAnim; } @@ -444,11 +444,11 @@ void EnNeoReeba_SetupDeathEffects(EnNeoReeba* this) { this->velToTarget.z = Math_CosS(this->actor.yawTowardsPlayer) * -12.0f; this->rotationSpeed = 3640.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 25); - this->actor.flags |= ACTOR_FLAG_8000000; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 25); + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~ACTOR_FLAG_1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIVA_DEAD); this->actionFunc = EnNeoReeba_PlayDeathEffects; } @@ -562,12 +562,12 @@ void EnNeoReeba_HandleHit(EnNeoReeba* this, PlayState* play) { this->stunTimer = 40; this->drawEffectAlpha = 1.0f; this->drawEffectScale = 2.0f; - Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 120, COLORFILTER_BUFFLAG_OPA, 40); EnNeoReeba_SetupStun(this); break; case EN_NEO_REEBA_DMGEFF_STUN: - Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 120, COLORFILTER_BUFFLAG_OPA, 40); EnNeoReeba_SetupStun(this); break; } @@ -604,7 +604,7 @@ void EnNeoReeba_UpdatePosition(EnNeoReeba* this, PlayState* play) { Math_ApproachZeroF(&this->velToTarget.x, 1.0f, 2.0f); Math_ApproachZeroF(&this->velToTarget.z, 1.0f, 2.0f); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 40.0f, 40.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 40.0f, 40.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } } diff --git a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c index abaf6c3e0..807bbd849 100644 --- a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c +++ b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c @@ -53,7 +53,7 @@ static ColliderCylinderInit sCylinderInit = { void EnNimotsu_UpdateCollision(EnNimotsu* this, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } void EnNimotsu_Init(Actor* thisx, PlayState* play) { @@ -81,7 +81,7 @@ void EnNimotsu_Update(Actor* thisx, PlayState* play) { Actor_MoveWithGravity(&this->actor); - if (!(this->dustDone & 1) && (this->actor.bgCheckFlags & 1)) { + if (!(this->dustDone & 1) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { if (DECR(this->timer) == 0) { this->dustDone |= 1; } 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 1c9212a63..bded43eda 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -86,41 +86,20 @@ static ColliderCylinderInit sCylinderInit = { { 15, 25, 4, { 0, 0, 0 } }, }; -static Vec3f D_808934C4 = { - 90000.0f, - 90000.0f, - 90000.0f, -}; - -static InitChainEntry sInitChain[] = { - ICHAIN_U8(targetMode, 6, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), -}; - -static Vec3f D_808934DC = { - 90000.0f, - 90000.0f, - 90000.0f, -}; - -static Vec3f D_808934E8 = { - 90000.0f, - 90000.0f, - 90000.0f, -}; - -static s32 pad = 0; - void EnNiw_Init(Actor* thisx, PlayState* play) { + static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 6, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), + }; EnNiw* this = THIS; - Vec3f dTemp = D_808934C4; + Vec3f D_808934C4 = { 90000.0f, 90000.0f, 90000.0f }; if (this->actor.params < 0) { // all scene spawned cucco are (-1) this->actor.params = NIW_TYPE_REGULAR; } - Math_Vec3f_Copy(&this->unk2BC, &dTemp); + Math_Vec3f_Copy(&this->unk2BC, &D_808934C4); this->niwType = this->actor.params; Actor_ProcessInitChain(&this->actor, sInitChain); @@ -138,9 +117,6 @@ void EnNiw_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); if (this->niwType == NIW_TYPE_UNK1) { - // @Bug this unused variant is broken and crashes on spawn (EnNiw_Update expects a parent, NULL) - // if modified to change niwType to TYPE_REGULAR here, new size is smaller than normal - // theory: was meant to be a small hand held cucco for grog to show the player Actor_SetScale(&this->actor, (BREG(86) / 10000.0f) + 0.004f); } @@ -154,13 +130,13 @@ void EnNiw_Init(Actor* thisx, PlayState* play) { } if (this->niwType == NIW_TYPE_HELD) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_M); this->sfxTimer1 = 30; this->heldTimer = 30; this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->niwState = NIW_STATE_HELD; this->actionFunc = EnNiw_Held; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk2BC.z = 0.0f; this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; @@ -319,8 +295,8 @@ void EnNiw_UpdateRunning(EnNiw* this, PlayState* play, s32 isStormCucco) { if (this->hopTimer == 0) { this->hopTimer = 3; - if (this->actor.bgCheckFlags & 1) { // hit floor - this->actor.velocity.y = 3.5f; // hopping up while running away + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.velocity.y = 3.5f; // hopping up while running away } } @@ -336,8 +312,7 @@ void EnNiw_UpdateRunning(EnNiw* this, PlayState* play, s32 isStormCucco) { runningDirection = -runningAngles[isStormCucco]; } - if (isStormCucco == true && - (this->runAwayTimer == 0 || (this->actor.bgCheckFlags & 8))) { // bgCheckFlags 8: hit a wall + if (isStormCucco == true && (this->runAwayTimer == 0 || (this->actor.bgCheckFlags & BGCHECKFLAG_WALL))) { this->runAwayTimer = 150; if (this->yawTimer == 0) { this->yawTimer = 70; @@ -366,17 +341,17 @@ void EnNiw_Idle(EnNiw* this, PlayState* play) { s16 nextAnimIndex; if (this->niwType == NIW_TYPE_REGULAR) { - if (Actor_HasParent(&this->actor, play)) { // picked up - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + if (Actor_HasParent(&this->actor, play)) { // picked up + Actor_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->heldTimer = 30; this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->niwState = NIW_STATE_HELD; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnNiw_Held; return; } else { - Actor_LiftActor(&this->actor, play); + Actor_OfferCarry(&this->actor, play); } } else { // NIW_TYPE_UNK1 || NIW_TYPE_HELD this->unkIdleTimer2 = 10; @@ -414,8 +389,8 @@ void EnNiw_Idle(EnNiw* this, PlayState* play) { } else { this->unkIdleTimer = 4; - if (this->actor.bgCheckFlags & 1) { // hit floor - this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.speed = 0.0f; this->actor.velocity.y = 3.5f; // hopping up and down } } @@ -451,7 +426,7 @@ void EnNiw_Idle(EnNiw* this, PlayState* play) { } void EnNiw_Held(EnNiw* this, PlayState* play) { - Vec3f vec3fcopy = D_808934DC; + Vec3f D_808934DC = { 90000.0f, 90000.0f, 90000.0f }; s16 rotZ; if (this->heldTimer == 0) { @@ -476,7 +451,7 @@ void EnNiw_Held(EnNiw* this, PlayState* play) { this->actor.shape.rot.z = 0; rotZ = this->actor.shape.rot.z; this->actor.velocity.y = 8.0f; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; this->actor.gravity = -2.0f; this->niwState = NIW_STATE_FALLING; this->unk2EC = 0; @@ -484,7 +459,7 @@ void EnNiw_Held(EnNiw* this, PlayState* play) { this->actor.shape.rot.y = rotZ; this->actor.shape.rot.x = rotZ; Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - Math_Vec3f_Copy(&this->unk2BC, &vec3fcopy); + Math_Vec3f_Copy(&this->unk2BC, &D_808934DC); this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnNiw_Thrown; } @@ -494,16 +469,16 @@ void EnNiw_Held(EnNiw* this, PlayState* play) { void EnNiw_Thrown(EnNiw* this, PlayState* play) { if (this->unk2EC == 0) { - if (this->actor.bgCheckFlags & 1) { // hit floor + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->unk2EC = 1; this->hoppingTimer = 80; // hop timer - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 4.0f; } else { return; // wait until back on floor } } else { - if (this->actor.bgCheckFlags & 1) { // hit floor + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->sfxTimer1 = 0; this->actor.velocity.y = 4.0f; // vertical hop this->unk29E = 1; @@ -519,17 +494,17 @@ void EnNiw_Thrown(EnNiw* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { // picked up again before could run off - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->unk2EC = 0; this->heldTimer = 30; this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->niwState = NIW_STATE_HELD; this->actionFunc = EnNiw_Held; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { if (this->hoppingTimer > 5) { - Actor_LiftActor(&this->actor, play); + Actor_OfferCarry(&this->actor, play); } EnNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_AND_WAVING); } @@ -544,8 +519,8 @@ void EnNiw_Swimming(EnNiw* this, PlayState* play) { EnNiw_SpawnAttackNiw(this, play); // spawn attack niw } - this->actor.speedXZ = 2.0f; - if (this->actor.bgCheckFlags & 0x20) { // touching water + this->actor.speed = 2.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { this->actor.gravity = 0.0f; if (this->actor.depthInWater > 15.0f) { this->actor.world.pos.y += 2.0f; @@ -557,21 +532,21 @@ void EnNiw_Swimming(EnNiw* this, PlayState* play) { EffectSsGRipple_Spawn(play, &ripplePos, 100, 500, 30); } - if (this->actor.bgCheckFlags & 8) { // hit a wall + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->actor.velocity.y = 10.0f; // fly up in straight line - this->actor.speedXZ = 1.0f; + this->actor.speed = 1.0f; } } else { this->actor.gravity = -2.0f; - if (this->actor.bgCheckFlags & 8) { // hit a wall + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->actor.velocity.y = 10.0f; // fly up in straight line - this->actor.speedXZ = 1.0f; + this->actor.speed = 1.0f; this->actor.gravity = 0.0f; } else { - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; } - if (this->actor.bgCheckFlags & 1) { // hit floor + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->actor.gravity = -2.0f; this->runAwayTimer = 100; this->swimRippleTimer = 0; @@ -629,7 +604,7 @@ void EnNiw_SetupCuccoStorm(EnNiw* this, PlayState* play) { this->targetLimbRots[1] = 0.0f; this->targetLimbRots[2] = 0.0f; this->unkTimer24C = 10; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_M); } if (this->cuccoStormTimer == 0) { @@ -646,7 +621,7 @@ void EnNiw_SetupCuccoStorm(EnNiw* this, PlayState* play) { void EnNiw_CuccoStorm(EnNiw* this, PlayState* play) { EnNiw_SpawnAttackNiw(this, play); if (this->cuccoStormTimer == 1) { // not countdown to 0? mistype? - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; this->isRunningRight = Rand_ZeroFloat(1.99f); this->generalTimer1 = 0; this->unkTimer24E = this->generalTimer1; @@ -662,12 +637,12 @@ void EnNiw_SetupRunAway(EnNiw* this) { this->isRunningRight = Rand_ZeroFloat(1.99f); this->niwState = NIW_STATE_RUNNING; this->actionFunc = EnNiw_RunAway; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; } void EnNiw_RunAway(EnNiw* this, PlayState* play) { Player* player = GET_PLAYER(play); - Vec3f tempVec3f = D_808934E8; + Vec3f D_808934E8 = { 90000.0f, 90000.0f, 90000.0f }; s16 temp298; f32 dX; f32 dZ; @@ -678,12 +653,12 @@ void EnNiw_RunAway(EnNiw* this, PlayState* play) { this->unk2A4.z = this->unk2B0.z = this->actor.world.pos.z; this->generalTimer2 = this->generalTimer1 = this->unk298 = 0; this->unk300 = this->unk304 = 0; - this->actor.speedXZ = 0; + this->actor.speed = 0; this->targetLimbRots[8] = 0; this->targetLimbRots[6] = 0; this->targetLimbRots[5] = 0; this->targetLimbRots[7] = 0; - Math_Vec3f_Copy(&this->unk2BC, &tempVec3f); + Math_Vec3f_Copy(&this->unk2BC, &D_808934E8); EnNiw_SetupIdle(this); @@ -702,7 +677,7 @@ void EnNiw_RunAway(EnNiw* this, PlayState* play) { } void EnNiw_LandBeforeIdle(EnNiw* this, PlayState* play) { - if (this->actor.bgCheckFlags & 1) { // hit floor + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { EnNiw_SetupIdle(this); } } @@ -715,7 +690,7 @@ void EnNiw_CheckRage(EnNiw* this, PlayState* play) { this->iframeTimer = 10; this->sfxTimer1 = 30; this->unk29E = 1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->runAwayTimer = 100; this->unk2EC = 0; EnNiw_SetupRunAway(this); @@ -746,13 +721,13 @@ void EnNiw_CheckRage(EnNiw* this, PlayState* play) { this->actionFunc = EnNiw_Trigger; this->unk304 = 0.0f; this->unk300 = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { this->iframeTimer = 10; this->sfxTimer1 = 30; this->unk29E = 1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->runAwayTimer = 100; this->unk2EC = 0; EnNiw_SetupRunAway(this); @@ -837,7 +812,9 @@ void EnNiw_Update(Actor* thisx, PlayState* play) { Actor_SetFocus(&this->actor, this->unk308); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 60.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 60.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); // if cucco is off the map if (this->actor.floorHeight <= BGCHECK_Y_MIN || this->actor.floorHeight >= BGCHECK_Y_MAX) { @@ -857,7 +834,7 @@ void EnNiw_Update(Actor* thisx, PlayState* play) { this->actor.world.pos.y = this->actor.home.pos.y + 300.0f; } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.gravity = -2.0f; Math_Vec3f_Copy(&this->unk2A4, &this->actor.home.pos); Math_Vec3f_Copy(&this->unk2B0, &this->actor.home.pos); @@ -890,8 +867,8 @@ void EnNiw_Update(Actor* thisx, PlayState* play) { return; } - if ((this->actor.bgCheckFlags & 0x20) && // touching water - this->actor.depthInWater > 15.0f && this->niwState != NIW_STATE_SWIMMING) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER) && (this->actor.depthInWater > 15.0f) && + (this->niwState != NIW_STATE_SWIMMING)) { this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; Math_Vec3f_Copy(&pos, &this->actor.world.pos); @@ -911,16 +888,16 @@ void EnNiw_Update(Actor* thisx, PlayState* play) { EnNiw_CheckRage(this, play); if (this->flutterSfxTimer == 0 && this->niwState == NIW_STATE_HELD) { this->flutterSfxTimer = 7; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); + Actor_PlaySfx(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); } if (this->sfxTimer1 == 0) { if (this->niwState != NIW_STATE_IDLE) { this->sfxTimer1 = 30; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_A); } else { this->sfxTimer1 = 300; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_N); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_N); } } diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.h b/src/overlays/actors/ovl_En_Niw/z_en_niw.h index c1cec3b88..c60397535 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.h +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.h @@ -79,7 +79,7 @@ typedef struct EnNiw { /* 0x2E8 */ s16 yawTowardsPlayer; /* 0x2EA */ s16 headRotationToggle; /* 0x2EC */ s16 unk2EC; - /* 0x2EE */ UNK_TYPE1 pad2EE[0x6]; + /* 0x2EE */ UNK_TYPE1 pad2EE[0x6]; /* 0x2F4 */ f32 unusedFloat2F4; // set in EnNiw_Update if Cucco falls off map, never read /* 0x2F8 */ f32 unusedFloat2F8; /* 0x2FC */ f32 unusedFloat2FC; @@ -91,12 +91,13 @@ typedef struct EnNiw { /* 0x35C */ EnNiwFeather feathers[NIW_FEATHER_COUNT]; } EnNiw; // size = 0x7BC -// in init, any value below zero becomes zero -// however, in vanilla, only 0xFFFF (-1) exists in scene spawns, actors can spawn 0x0 -#define NIW_TYPE_VANILLA 0xFFFF -#define NIW_TYPE_REGULAR 0 -#define NIW_TYPE_UNK1 1 -#define NIW_TYPE_HELD 2 // spawns held by the bomber kid in east clock town during hide and seek +typedef enum { + /* -1 */ NIW_TYPE_VANILLA = -1, // Will be converted to 0, in vanilla exists only in scene spawns + /* 0 */ NIW_TYPE_REGULAR, + /* 1 */ NIW_TYPE_UNK1, // This unused variant must be spawned as a child, as it expects a NON-NULL parent. + // Theory: This was meant to be a small hand held cucco for Grog to show the player + /* 2 */ NIW_TYPE_HELD // spawns held by the bomber kid in east clock town during hide and seek +} NiwType; // the attacking cuccos are not here, they are a different actor: [ ovl_En_Attack_Niw ] typedef enum { 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 ad872cd21..9c6fe4a9d 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -57,7 +57,7 @@ void EnNutsball_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 400.0f, ActorShadow_DrawCircle, 13.0f); Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.shape.rot.y = 0; - this->actor.speedXZ = 10.0f; + this->actor.speed = 10.0f; if (this->actor.params == 2) { this->timer = 1; this->timerThreshold = 0; @@ -107,9 +107,9 @@ void EnNutsball_Update(Actor* thisx, PlayState* play2) { this->actor.world.rot.x = Math_Atan2S_XY(spdXZ, this->actor.velocity.y); } this->actor.home.rot.z += 0x2AA8; - if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1) || (this->actor.bgCheckFlags & 16) || - (this->collider.base.atFlags & AT_HIT) || (this->collider.base.acFlags & AC_HIT) || - (this->collider.base.ocFlags1 & OC1_HIT)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || + (this->actor.bgCheckFlags & BGCHECKFLAG_CEILING) || (this->collider.base.atFlags & AT_HIT) || + (this->collider.base.acFlags & AC_HIT) || (this->collider.base.ocFlags1 & OC1_HIT)) { if ((player->currentShield == PLAYER_SHIELD_HEROS_SHIELD) && (this->collider.base.atFlags & AT_HIT) && (this->collider.base.atFlags & AT_TYPE_ENEMY) && (this->collider.base.atFlags & AT_BOUNCED)) { EnNutsball_InitColliderParams(this); @@ -136,18 +136,20 @@ void EnNutsball_Update(Actor* thisx, PlayState* play2) { Actor_MoveWithoutGravity(&this->actor); Math_Vec3f_Copy(&worldPos, &this->actor.world.pos); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 5.0f, 10.0f, 0x7); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 5.0f, 10.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); - if (this->actor.bgCheckFlags & 8) { - if (func_800C9A4C(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId) & 0x30) { - this->actor.bgCheckFlags &= ~8; + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { + if (SurfaceType_GetWallFlags(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId) & + (WALL_FLAG_4 | WALL_FLAG_5)) { + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WALL; if (BgCheck_EntityLineTest1(&play->colCtx, &this->actor.prevPos, &worldPos, &this->actor.world.pos, &poly, true, false, false, true, &bgId)) { - if (func_800C9A4C(&play->colCtx, poly, bgId) & 0x30) { + if (SurfaceType_GetWallFlags(&play->colCtx, poly, bgId) & (WALL_FLAG_4 | WALL_FLAG_5)) { this->actor.world.pos.x += this->actor.velocity.x * 0.01f; this->actor.world.pos.z += this->actor.velocity.z * 0.01f; } else { - this->actor.bgCheckFlags |= 8; + this->actor.bgCheckFlags |= BGCHECKFLAG_WALL; } } else { Math_Vec3f_Copy(&this->actor.world.pos, &worldPos); diff --git a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c index 74ac78b5f..b11e8c408 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c @@ -172,7 +172,7 @@ s32 EnNwc_IsFound(EnNwc* this, PlayState* play) { } void EnNwc_ChangeState(EnNwc* this, s16 newState) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; switch (newState) { case NWC_STATE_CHECK_BREMAN: this->stateTimer = 10; @@ -209,7 +209,7 @@ void EnNwc_ChangeState(EnNwc* this, s16 newState) { * If previously checking for breman -> select random (NWC_STATE_TURNING, NWC_STATE_HOPPING_FORWARD) */ void EnNwc_ToggleState(EnNwc* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->state != NWC_STATE_CHECK_BREMAN) { EnNwc_ChangeState(this, NWC_STATE_CHECK_BREMAN); } else { @@ -276,7 +276,7 @@ void EnNwc_Follow(EnNwc* this, PlayState* play) { s16 targetUpperBodyRot = 0; s16 targetFootRot = 0; - if (this->actor.speedXZ > 0.0f) { + if (this->actor.speed > 0.0f) { if (this->stateTimer & 4) { targetFootRot = 0x1B58; targetUpperBodyRot = -0x2710; @@ -293,7 +293,7 @@ void EnNwc_Follow(EnNwc* this, PlayState* play) { this->actor.velocity.y = 2.0f; // hop up and down } if ((this->stateTimer & 0x1B) == 24) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHICK_SONG); } } @@ -306,13 +306,13 @@ void EnNwc_Follow(EnNwc* this, PlayState* play) { this->grog->actor.home.rot.x += 2; // increment grog's adult tranformation counter EnNwc_SpawnDust(this, play); Actor_SetScale(&this->actor, 0.002f); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_TO_CHICKEN); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHICK_TO_CHICKEN); } } Math_Vec3f_Diff(&chickCoords[this->actor.home.rot.z], &this->actor.world.pos, &targetVector); if (SQXZ(targetVector) < SQ(5.0f)) { // too close to keep moving, stop - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; // first nwc in the line follows player, the rest follow the previous one if (this->actor.home.rot.z == 1) { @@ -329,7 +329,7 @@ void EnNwc_Follow(EnNwc* this, PlayState* play) { } else if (this->randomRot < -0x1388) { this->randomRot = -0x1388; } - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; newRotY = Math_Vec3f_Yaw(&this->actor.world.pos, &chickCoords[this->actor.home.rot.z]) + this->randomRot; } @@ -356,9 +356,9 @@ void EnNwc_Follow(EnNwc* this, PlayState* play) { } if (this->grog->actor.home.rot.x >= 20) { // all chicks have turned into adult cucco, stop and crow - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_M); this->actionFunc = EnNwc_CrowAtTheEnd; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Actor_SetScale(&this->actor, 0.01f); } } @@ -378,14 +378,14 @@ void EnNwc_HopForward(EnNwc* this, PlayState* play) { this->actor.velocity.y = 2.0f; // hop up and down } if ((this->stateTimer & 0xB) == 8) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHICK_SONG); } // they only move forward while off the ground, which gives the visual of them hopping to move - if (this->actor.bgCheckFlags & 0x1) { // touching floor - this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.speed = 0.0f; } else { - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; } } @@ -404,11 +404,11 @@ void EnNwc_RunAway(EnNwc* this, PlayState* play) { this->actor.velocity.y = 2.0f; // hop up and down } if ((this->stateTimer & 0xB) == 8) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHICK_SONG); } - this->actor.speedXZ = 2.0f; - if (this->actor.bgCheckFlags & 0x8) { // touching wall + this->actor.speed = 2.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { EnNwc_ToggleState(this); } } @@ -429,11 +429,11 @@ void EnNwc_Turn(EnNwc* this, PlayState* play) { } if ((this->stateTimer & 0xB) == 8) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + Actor_PlaySfx(&this->actor, NA_SE_EV_CHICK_SONG); } // they only rotate when off the ground, giving the visual that they turn by hopping - if (!(this->actor.bgCheckFlags & 0x1)) { // NOT touching floor + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->fallingRotY, 0xA, 0x1000, 0x800); this->actor.world.rot.y = this->actor.shape.rot.y; } @@ -457,7 +457,7 @@ void EnNwc_Update(Actor* thisx, PlayState* play) { EnNwc* this = THIS; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); if (this->hasGrownUp & 1) { this->actor.objBankIndex = this->niwObjectIndex; diff --git a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c index d4d3db017..01cbb5dda 100644 --- a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c +++ b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c @@ -6,7 +6,7 @@ #include "z_en_okarina_tag.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnOkarinaTag*)thisx) @@ -81,7 +81,7 @@ void func_8093E518(EnOkarinaTag* this, PlayState* play) { var_v1 = this->unk14A; if (var_v1 == 6) { var_v1 = 0xA; - if (gSaveContext.save.unk_F65 == 0) { + if (gSaveContext.save.saveInfo.unk_F41 == 0) { return; } } diff --git a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c index df18de3e7..cd20f489c 100644 --- a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c +++ b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c @@ -86,14 +86,14 @@ Actor* func_80B11F44(PlayState* play) { void func_80B11F78(EnOnpuman* this, PlayState* play) { if (play->msgCtx.ocarinaMode == 4) { this->actionFunc = func_80B121D8; - if (this->actor.cutscene != -1) { - ActorCutscene_Stop(this->actor.cutscene); + if (this->actor.csId != CS_ID_NONE) { + CutsceneManager_Stop(this->actor.csId); } } else if (play->msgCtx.ocarinaMode == 3) { play_sound(NA_SE_SY_CORRECT_CHIME); play->msgCtx.ocarinaMode = 4; - if (this->actor.cutscene != -1) { - ActorCutscene_Stop(this->actor.cutscene); + if (this->actor.csId != CS_ID_NONE) { + CutsceneManager_Stop(this->actor.csId); } this->actionFunc = func_80B121D8; } @@ -106,11 +106,11 @@ void func_80B1202C(EnOnpuman* this, PlayState* play2) { switch (play->msgCtx.currentTextId) { case 0x8D4: this->unk_2A4 |= 1; - func_80151938(play, 0x8DA); + Message_ContinueTextbox(play, 0x8DA); break; case 0x8DA: - func_80151938(play, 0x8D6); + Message_ContinueTextbox(play, 0x8D6); if (this->unk_2A0 != NULL) { this->unk_2A0->home.rot.x = 0x50; } @@ -126,13 +126,13 @@ void func_80B1202C(EnOnpuman* this, PlayState* play2) { } } if (this->unk_2A4 & 1) { - if (this->actor.cutscene == -1) { + if (this->actor.csId == CS_ID_NONE) { this->unk_2A4 &= ~1; - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + } else if (CutsceneManager_IsNext(this->actor.csId)) { this->unk_2A4 &= ~1; - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } } @@ -140,7 +140,7 @@ void func_80B1202C(EnOnpuman* this, PlayState* play2) { void func_80B1217C(EnOnpuman* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && (Message_ShouldAdvance(play))) { this->actionFunc = func_80B121D8; - func_801477B4(play); + Message_CloseTextbox(play); } } @@ -172,6 +172,6 @@ void EnOnpuman_Update(Actor* thisx, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); } diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.c b/src/overlays/actors/ovl_En_Osk/z_en_osk.c index ac3c5ef6b..3f10f6771 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.c +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.c @@ -66,7 +66,7 @@ void EnOsk_Init(Actor* thisx, PlayState* play) { this->actionFunc = func_80BF5F60; this->unk_254 = -1; - this->unk_256 = -1; + this->cueId = -1; this->actor.flags &= ~ACTOR_FLAG_1; switch (ENOSK_GET_F(&this->actor)) { @@ -75,7 +75,7 @@ void EnOsk_Init(Actor* thisx, PlayState* play) { this->jointTable, this->morphTable, 7); Animation_PlayLoop(&this->skelAnime, &object_ikn_demo_Anim_006808); this->actionFunc = func_80BF656C; - this->unk_258 = 0x210; + this->cueType = CS_CMD_ACTOR_CUE_528; break; case ENOSK_2: @@ -83,7 +83,7 @@ void EnOsk_Init(Actor* thisx, PlayState* play) { this->jointTable, this->morphTable, 7); Animation_PlayLoop(&this->skelAnime, &object_ikn_demo_Anim_006808); this->actionFunc = func_80BF6A20; - this->unk_258 = 0x211; + this->cueType = CS_CMD_ACTOR_CUE_529; break; default: @@ -92,7 +92,7 @@ void EnOsk_Init(Actor* thisx, PlayState* play) { this->jointTable, this->morphTable, 17); Animation_PlayLoop(&this->skelAnime, &object_ikn_demo_Anim_0000B8); this->actionFunc = func_80BF61EC; - this->unk_258 = 0x212; + this->cueType = CS_CMD_ACTOR_CUE_530; this->actor.home.rot.z = 0; this->unk_25C = 0.0f; break; @@ -129,12 +129,12 @@ void func_80BF5F60(EnOsk* this, PlayState* play) { } void func_80BF5F70(EnOsk* this) { - if ((this->unk_256 != 1) && (this->unk_256 != 6)) { + if ((this->cueId != 1) && (this->cueId != 6)) { this->actor.draw = EnOsk_Draw; Actor_SetScale(&this->actor, 0.017f); } - switch (this->unk_256) { + switch (this->cueId) { case 1: this->actor.draw = NULL; break; @@ -181,20 +181,20 @@ void func_80BF609C(EnOsk* this, PlayState* play) { case 0: if (Animation_OnFrame(&this->skelAnime, this->unk_25C) || Animation_OnFrame(&this->skelAnime, this->unk_25C + 8.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOSU_TALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_BOSU_TALK); } break; case 1: if (Animation_OnFrame(&this->skelAnime, this->unk_25C)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOSU_TALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_BOSU_TALK); } break; case 2: if (Animation_OnFrame(&this->skelAnime, this->unk_25C) || Animation_OnFrame(&this->skelAnime, this->unk_25C + 6.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOSU_TALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_BOSU_TALK); } break; } @@ -205,10 +205,10 @@ void func_80BF609C(EnOsk* this, PlayState* play) { void func_80BF61EC(EnOsk* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Cutscene_CheckActorAction(play, this->unk_258)) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->unk_258)); - if (this->unk_256 != play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_258)]->action) { - this->unk_256 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_258)]->action; + if (Cutscene_IsCueInChannel(play, this->cueType)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); + if (this->cueId != play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id) { + this->cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; func_80BF5F70(this); } func_80BF609C(this, play); @@ -216,7 +216,7 @@ void func_80BF61EC(EnOsk* this, PlayState* play) { this->actor.draw = NULL; } - if (this->unk_256 == 6) { + if (this->cueId == 6) { if (this->actor.scale.x > 0.85f * 0.001f) { this->actor.scale.x -= 0.85f * 0.001f; Actor_SetScale(&this->actor, this->actor.scale.x); @@ -229,12 +229,12 @@ void func_80BF61EC(EnOsk* this, PlayState* play) { } void func_80BF6314(EnOsk* this) { - if ((this->unk_256 != 1) && (this->unk_256 != 9)) { + if ((this->cueId != 1) && (this->cueId != 9)) { this->actor.draw = EnOsk_Draw; Actor_SetScale(&this->actor, 0.013f); } - switch (this->unk_256) { + switch (this->cueId) { case 1: this->actor.draw = NULL; break; @@ -280,19 +280,19 @@ void func_80BF6478(EnOsk* this) { case 1: if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || Animation_OnFrame(&this->skelAnime, 11.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEBU_HEAD_UP); } break; case 3: if (Animation_OnFrame(&this->skelAnime, 11.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEBU_HEAD_UP); } break; case 4: if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEBU_HEAD_UP); } break; @@ -329,10 +329,10 @@ void func_80BF656C(EnOsk* this, PlayState* play) { } } - if (Cutscene_CheckActorAction(play, this->unk_258)) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->unk_258)); - if (this->unk_256 != play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_258)]->action) { - this->unk_256 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_258)]->action; + if (Cutscene_IsCueInChannel(play, this->cueType)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); + if (this->cueId != play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id) { + this->cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; func_80BF6314(this); } func_80BF6478(this); @@ -340,12 +340,12 @@ void func_80BF656C(EnOsk* this, PlayState* play) { this->actor.draw = NULL; } - if ((this->unk_256 == 2) && (this->actor.scale.x < 13.0f * 0.001f)) { + if ((this->cueId == 2) && (this->actor.scale.x < 13.0f * 0.001f)) { this->actor.scale.x += 0.65f * 0.001f; Actor_SetScale(&this->actor, this->actor.scale.x); } - if (this->unk_256 == 9) { + if (this->cueId == 9) { if (this->actor.scale.x > 0.65f * 0.001f) { this->actor.scale.x -= 0.65f * 0.001f; Actor_SetScale(&this->actor, this->actor.scale.x); @@ -358,12 +358,12 @@ void func_80BF656C(EnOsk* this, PlayState* play) { } void func_80BF67A8(EnOsk* this) { - if ((this->unk_256 != 1) && (this->unk_256 != 8)) { + if ((this->cueId != 1) && (this->cueId != 8)) { this->actor.draw = EnOsk_Draw; Actor_SetScale(&this->actor, 0.013f); } - switch (this->unk_256) { + switch (this->cueId) { case 1: this->actor.draw = NULL; break; @@ -406,31 +406,31 @@ void func_80BF68E0(EnOsk* this) { case 7: if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || Animation_OnFrame(&this->skelAnime, 11.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEBU_HEAD_UP); } break; case 2: if (Animation_OnFrame(&this->skelAnime, 4.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEBU_HEAD_UP); } break; case 4: if (Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEBU_HEAD_UP); } break; case 5: if ((Animation_OnFrame(&this->skelAnime, 6.0f)) || Animation_OnFrame(&this->skelAnime, 11.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEBU_HEAD_UP); } break; case 8: if (Animation_OnFrame(&this->skelAnime, 13.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_DEBU_HEAD_UP); } break; } @@ -466,10 +466,10 @@ void func_80BF6A20(EnOsk* this, PlayState* play) { } } - if (Cutscene_CheckActorAction(play, this->unk_258)) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->unk_258)); - if (this->unk_256 != play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_258)]->action) { - this->unk_256 = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->unk_258)]->action; + if (Cutscene_IsCueInChannel(play, this->cueType)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); + if (this->cueId != play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id) { + this->cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; func_80BF67A8(this); } func_80BF68E0(this); @@ -477,7 +477,7 @@ void func_80BF6A20(EnOsk* this, PlayState* play) { this->actor.draw = NULL; } - if (this->unk_256 == 8) { + if (this->cueId == 8) { if (this->actor.scale.x > 0.65f * 0.001f) { this->actor.scale.x -= 0.65f * 0.001f; Actor_SetScale(&this->actor, this->actor.scale.x); diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.h b/src/overlays/actors/ovl_En_Osk/z_en_osk.h index 0358911d3..c83cc5d91 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.h +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.h @@ -18,8 +18,8 @@ typedef struct EnOsk { /* 0x188 */ Vec3s jointTable[17]; /* 0x1EE */ Vec3s morphTable[17]; /* 0x254 */ s16 unk_254; - /* 0x256 */ s16 unk_256; - /* 0x258 */ u16 unk_258; + /* 0x256 */ s16 cueId; + /* 0x258 */ u16 cueType; /* 0x25C */ f32 unk_25C; /* 0x260 */ EnOskActionFunc actionFunc; } EnOsk; // size = 0x264 diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index 7df9d843d..6cc29578a 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -443,10 +443,11 @@ s32 EnOsn_GetInitialMaskText(EnOsn* this, PlayState* play) { s32 EnOsn_GetInitialText(EnOsn* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { + if ((gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] != ITEM_NONE) && + CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { if (this->stateFlags & OSN_STATE_SPECIAL_CONVERSTATION) { this->stateFlags |= OSN_STATE_END_CONVERSATION; - if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && + if ((gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] != ITEM_NONE) && (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) { @@ -691,14 +692,14 @@ void EnOsn_HandleConversation(EnOsn* this, PlayState* play) { } void EnOsn_InitCutscene(EnOsn* this) { - this->cutscene = this->actor.cutscene; - if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) || + this->csId = this->actor.csId; + if ((gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] == ITEM_NONE) || (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { - this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); - if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) || + if ((gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] != ITEM_NONE) || (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { - this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); } } } @@ -706,7 +707,7 @@ void EnOsn_InitCutscene(EnOsn* this) { void EnOsn_ChooseAction(EnOsn* this, PlayState* play) { u32 isFlagSet = Flags_GetSwitch(play, 0); - this->cutscene = this->actor.cutscene; + this->csId = this->actor.csId; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, OSN_ANIM_IDLE); if (!isFlagSet) { @@ -719,7 +720,8 @@ void EnOsn_ChooseAction(EnOsn* this, PlayState* play) { void EnOsn_Idle(EnOsn* this, PlayState* play) { s16 yaw = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && !CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { + if ((gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] != ITEM_NONE) && + !CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = EnOsn_StartCutscene; } else if (((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (yaw < 0x4000) && @@ -737,27 +739,27 @@ void EnOsn_Idle(EnOsn* this, PlayState* play) { } void EnOsn_StartCutscene(EnOsn* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_Start(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Start(this->csId, &this->actor); this->actionFunc = EnOsn_HandleCsAction; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } void EnOsn_HandleCsAction(EnOsn* this, PlayState* play) { u8 pad; - s32 actionIndex; + s32 cueChannel; - if (Cutscene_CheckActorAction(play, 130)) { - actionIndex = Cutscene_GetActorActionIndex(play, 130); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_130)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_130); this->shouldRotateHead = false; - if (this->csAction != play->csCtx.actorActions[actionIndex]->action) { - this->csAction = play->csCtx.actorActions[actionIndex]->action; - switch (play->csCtx.actorActions[actionIndex]->action) { + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: this->animIndex = OSN_ANIM_BOWING; break; @@ -850,8 +852,8 @@ void EnOsn_HandleCsAction(EnOsn* this, PlayState* play) { } if ((this->animIndex == OSN_ANIM_BELIEVE) && (play->sceneId == SCENE_SPOT00) && - (gSaveContext.sceneLayer == 0xB) && (play->csCtx.frames == 400)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_OMVO00); + (gSaveContext.sceneLayer == 0xB) && (play->csCtx.curFrame == 400)) { + Actor_PlaySfx(&this->actor, NA_SE_VO_OMVO00); } if (this->animIndex == OSN_ANIM_TURN_AROUND_START) { @@ -870,12 +872,12 @@ void EnOsn_HandleCsAction(EnOsn* this, PlayState* play) { (((Animation_OnFrame(&this->skelAnime, 17.0f))) || (Animation_OnFrame(&this->skelAnime, 27.0f)) || (Animation_OnFrame(&this->skelAnime, 37.0f)) || (Animation_OnFrame(&this->skelAnime, 47.0f)) || (Animation_OnFrame(&this->skelAnime, 57.0f)) || (Animation_OnFrame(&this->skelAnime, 67.0f)))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OMENYA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_OMENYA_WALK); } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } else { this->shouldRotateHead = true; - this->csAction = 0x63; + this->cueId = 99; EnOsn_ChooseAction(this, play); } } diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.h b/src/overlays/actors/ovl_En_Osn/z_en_osn.h index 638f31e4e..906c0b6c9 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.h +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.h @@ -26,8 +26,8 @@ typedef struct EnOsn { /* 0x1E4 */ UNK_TYPE1 unk_1E4[0x6]; /* 0x1EA */ u16 stateFlags; /* 0x1EC */ u8 animIndex; - /* 0x1ED */ u8 csAction; - /* 0x1EE */ s16 cutscene; + /* 0x1ED */ u8 cueId; + /* 0x1EE */ s16 csId; /* 0x1F0 */ u8 shouldRotateHead; /* 0x1F1 */ UNK_TYPE1 unk_1F1[0x3]; /* 0x1F4 */ u16 textId; 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 d1f7dbec9..2444acca5 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -265,8 +265,8 @@ void EnOssan_Init(Actor* thisx, PlayState* play) { EnOssan* this = THIS; s16 id; - //! @bug Condition is impossible, params cannot be both greater then 1 AND less then 0. if ((this->actor.params > ENOSSAN_PART_TIME_WORKER) && (this->actor.params < ENOSSAN_CURIOSITY_SHOP_MAN)) { + //! @bug: Impossible to reach, && should be an || Actor_Kill(&this->actor); return; } @@ -310,7 +310,7 @@ void EnOssan_EndInteraction(PlayState* play, EnOssan* this) { play->interfaceCtx.unk_222 = 0; play->interfaceCtx.unk_224 = 0; if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENOSSAN_CUTSCENESTATE_STOPPED; } if (this->actor.params == ENOSSAN_CURIOSITY_SHOP_MAN) { @@ -332,7 +332,7 @@ s32 EnOssan_TestEndInteraction(EnOssan* this, PlayState* play, Input* input) { s32 EnOssan_TestCancelOption(EnOssan* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); return true; } return false; @@ -349,7 +349,7 @@ void EnOssan_SetupStartShopping(PlayState* play, EnOssan* this, u8 skipHello) { void EnOssan_StartShopping(PlayState* play, EnOssan* this) { EnOssan_SetupAction(this, EnOssan_FaceShopkeeper); - func_80151938(play, 0x640); + Message_ContinueTextbox(play, 0x640); func_8011552C(play, DO_ACTION_DECIDE); this->stickRightPrompt.isEnabled = true; this->stickLeftPrompt.isEnabled = true; @@ -369,11 +369,11 @@ void EnOssan_Idle(EnOssan* this, PlayState* play) { player->stateFlags2 |= PLAYER_STATE2_20000000; EnOssan_SetupAction(this, EnOssan_BeginInteraction); if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENOSSAN_CUTSCENESTATE_WAITING; } } else { @@ -397,11 +397,11 @@ void EnOssan_BeginInteraction(EnOssan* this, PlayState* play) { frameCount = 0; } if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENOSSAN_CUTSCENESTATE_PLAYING; } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } if (this->actor.params == ENOSSAN_CURIOSITY_SHOP_MAN) { @@ -586,7 +586,7 @@ void EnOssan_Hello(EnOssan* this, PlayState* play) { SubS_ChangeAnimationByInfoS(&this->skelAnime, animationInfo, ANI_ANIM_APOLOGY_LOOP); } if ((this->animIndex == FSN_ANIM_SLAM_COUNTER_LOOP) && Animation_OnFrame(&this->skelAnime, 18.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); + Actor_PlaySfx(&this->actor, NA_SE_EV_HANKO); } } @@ -602,7 +602,7 @@ s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, PlayState* play) { SubS_ChangeAnimationByInfoS(&this->skelAnime, animationInfo, 9); } EnOssan_SetupAction(this, EnOssan_TalkToShopkeeper); - func_80151938(play, sTalkOptionTextIds[this->actor.params]); + Message_ContinueTextbox(play, sTalkOptionTextIds[this->actor.params]); func_8011552C(play, DO_ACTION_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -622,11 +622,11 @@ void EnOssan_FaceShopkeeper(EnOssan* this, PlayState* play) { u8 cursorIndex; if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENOSSAN_CUTSCENESTATE_WAITING; } else { if (talkState == TEXT_STATE_CHOICE) { @@ -676,26 +676,26 @@ void EnOssan_TalkToShopkeeper(EnOssan* this, PlayState* play) { void EnOssan_LookToLeftShelf(EnOssan* this, PlayState* play) { if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENOSSAN_CUTSCENESTATE_STOPPED; } if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToLeftShelfCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToLeftShelfCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENOSSAN_CUTSCENESTATE_WAITING; } else { if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENOSSAN_CUTSCENESTATE_PLAYING; EnOssan_UpdateCursorPos(play, this); EnOssan_SetupAction(this, EnOssan_BrowseLeftShelf); - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } this->stickAccumX = 0; @@ -704,26 +704,26 @@ void EnOssan_LookToLeftShelf(EnOssan* this, PlayState* play) { void EnOssan_LookToRightShelf(EnOssan* this, PlayState* play) { if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENOSSAN_CUTSCENESTATE_STOPPED; } if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToRightShelfCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToRightShelfCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENOSSAN_CUTSCENESTATE_WAITING; } else { if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENOSSAN_CUTSCENESTATE_PLAYING; EnOssan_UpdateCursorPos(play, this); EnOssan_SetupAction(this, EnOssan_BrowseRightShelf); - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } this->stickAccumX = 0; @@ -824,7 +824,7 @@ s32 EnOssan_HasPlayerSelectedItem(PlayState* play, EnOssan* this, Input* input) if (EnOssan_TestItemSelected(play)) { if (!item->isOutOfStock) { this->prevActionFunc = this->actionFunc; - func_80151938(play, this->items[this->cursorIndex]->choiceTextId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->choiceTextId); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; play_sound(NA_SE_SY_DECIDE); @@ -888,7 +888,7 @@ void EnOssan_BrowseLeftShelf(EnOssan* this, PlayState* play) { } EnOssan_CursorUpDown(this); if (this->cursorIndex != prevCursorIndex) { - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); play_sound(NA_SE_SY_CURSOR); } } @@ -946,7 +946,7 @@ void EnOssan_BrowseRightShelf(EnOssan* this, PlayState* play) { } EnOssan_CursorUpDown(this); if (this->cursorIndex != prevCursorIndex) { - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); play_sound(NA_SE_SY_CURSOR); } } @@ -956,24 +956,24 @@ void EnOssan_BrowseRightShelf(EnOssan* this, PlayState* play) { void EnOssan_LookToShopkeeperFromShelf(EnOssan* this, PlayState* play) { if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENOSSAN_CUTSCENESTATE_STOPPED; } if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopKeeperFromShelfCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopKeeperFromShelfCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENOSSAN_CUTSCENESTATE_WAITING; } else if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENOSSAN_CUTSCENESTATE_PLAYING; EnOssan_UpdateCursorPos(play, this); EnOssan_StartShopping(play, this); } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } } @@ -981,7 +981,7 @@ void EnOssan_LookToShopkeeperFromShelf(EnOssan* this, PlayState* play) { void EnOssan_SetupBuyItemWithFanfare(PlayState* play, EnOssan* this) { Player* player = GET_PLAYER(play); - Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~PLAYER_STATE2_20000000; @@ -991,12 +991,12 @@ void EnOssan_SetupBuyItemWithFanfare(PlayState* play, EnOssan* this) { } void EnOssan_SetupCannotBuy(PlayState* play, EnOssan* this, u16 textId) { - func_80151938(play, textId); + Message_ContinueTextbox(play, textId); EnOssan_SetupAction(this, EnOssan_CannotBuy); } void EnOssan_SetupBuy(PlayState* play, EnOssan* this, u16 textId) { - func_80151938(play, textId); + Message_ContinueTextbox(play, textId); EnOssan_SetupAction(this, EnOssan_CanBuy); } @@ -1006,7 +1006,7 @@ void EnOssan_HandleCanBuyItem(PlayState* play, EnOssan* this) { switch (item->canBuyFunc(play, item)) { case CANBUY_RESULT_SUCCESS_1: if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENOSSAN_CUTSCENESTATE_STOPPED; } func_8019F208(); @@ -1061,7 +1061,7 @@ void EnOssan_SelectItem(EnOssan* this, PlayState* play) { case 1: func_8019F230(); this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); break; } } @@ -1071,7 +1071,7 @@ void EnOssan_SelectItem(EnOssan* this, PlayState* play) { void EnOssan_CannotBuy(EnOssan* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); } } @@ -1084,7 +1084,7 @@ void EnOssan_CanBuy(EnOssan* this, PlayState* play) { item = this->items[this->cursorIndex]; item->restockFunc(play, item); this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); } } @@ -1093,7 +1093,7 @@ void EnOssan_BuyItemWithFanfare(EnOssan* this, PlayState* play) { this->actor.parent = NULL; EnOssan_SetupAction(this, EnOssan_SetupItemPurchased); } else { - Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); } } @@ -1103,11 +1103,11 @@ void EnOssan_SetupItemPurchased(EnOssan* this, PlayState* play) { play->msgCtx.stateTimer = 4; EnOssan_SetupAction(this, EnOssan_ItemPurchased); if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperCsId; + CutsceneManager_Queue(this->csId); } func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); } @@ -1158,21 +1158,21 @@ void EnOssan_ItemPurchased(EnOssan* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); player->stateFlags2 |= PLAYER_STATE2_20000000; EnOssan_SetupAction(this, EnOssan_ContinueShopping); this->cutsceneState = ENOSSAN_CUTSCENESTATE_PLAYING; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperCsId; + CutsceneManager_Queue(this->csId); } } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - func_80151938(play, 0x642); + Message_ContinueTextbox(play, 0x642); } else { func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); } @@ -1474,7 +1474,7 @@ void EnOssan_InitShop(EnOssan* this, PlayState* play) { this->cursorPos.y = this->cursorPos.x = 100.0f; this->cutsceneState = ENOSSAN_CUTSCENESTATE_STOPPED; - this->cutscene = this->lookToShopkeeperCutscene; + this->csId = this->lookToShopkeeperCsId; this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.colChkInfo.cylRadius = 50; this->stickAccumX = this->stickAccumY = 0; @@ -1538,10 +1538,10 @@ void EnOssan_InitShop(EnOssan* this, PlayState* play) { } void EnOssan_GetCutscenes(EnOssan* this, PlayState* play) { - this->lookToShopkeeperCutscene = this->actor.cutscene; - this->lookToLeftShelfCutscene = ActorCutscene_GetAdditionalCutscene(this->lookToShopkeeperCutscene); - this->lookToRightShelfCutscene = ActorCutscene_GetAdditionalCutscene(this->lookToLeftShelfCutscene); - this->lookToShopKeeperFromShelfCutscene = ActorCutscene_GetAdditionalCutscene(this->lookToRightShelfCutscene); + this->lookToShopkeeperCsId = this->actor.csId; + this->lookToLeftShelfCsId = CutsceneManager_GetAdditionalCsId(this->lookToShopkeeperCsId); + this->lookToRightShelfCsId = CutsceneManager_GetAdditionalCsId(this->lookToLeftShelfCsId); + this->lookToShopKeeperFromShelfCsId = CutsceneManager_GetAdditionalCsId(this->lookToRightShelfCsId); } void EnOssan_Update(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h index a4787cc14..c5de183d5 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h @@ -43,11 +43,11 @@ typedef struct EnOssan { /* 0x2B0 */ u8 arrowAnimState; /* 0x2B1 */ u8 stickAnimState; /* 0x2B4 */ f32 shopItemSelectedTween; - /* 0x2B8 */ s16 lookToShopkeeperCutscene; - /* 0x2BA */ s16 lookToLeftShelfCutscene; - /* 0x2BC */ s16 lookToRightShelfCutscene; - /* 0x2BE */ s16 lookToShopKeeperFromShelfCutscene; - /* 0x2C0 */ s16 cutscene; + /* 0x2B8 */ s16 lookToShopkeeperCsId; + /* 0x2BA */ s16 lookToLeftShelfCsId; + /* 0x2BC */ s16 lookToRightShelfCsId; + /* 0x2BE */ s16 lookToShopKeeperFromShelfCsId; + /* 0x2C0 */ s16 csId; /* 0x2C2 */ s16 cutsceneState; /* 0x2C4 */ u16 textId; /* 0x2C6 */ Vec3s headRot; 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 e2490bb8d..a4d820364 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -5,7 +5,6 @@ */ #include "z_en_ot.h" -#include "prevent_bss_reordering.h" #include "objects/object_ot/object_ot.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -141,7 +140,7 @@ void EnOt_Init(Actor* thisx, PlayState* play) { this->unk_33C = ENOT_GET_C000(&this->actor); if (this->unk_33C == 0) { D_80B5E880 = this; - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.update = func_80B5DB6C; this->actor.draw = NULL; @@ -162,7 +161,7 @@ void EnOt_Init(Actor* thisx, PlayState* play) { this->actor.shape.rot.z = 0; this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.gravity = 0.0f; - SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_FillCutscenesList(&this->actor, this->csIdList, ARRAY_COUNT(this->csIdList)); SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIndex); this->skelAnime.curFrame = Rand_ZeroOne() * this->skelAnime.endFrame; this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); @@ -265,7 +264,7 @@ void EnOt_Init(Actor* thisx, PlayState* play) { case 3: if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_26_08)) { - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Actor_SetScale(&this->actor, 0.0064999997f); this->collider.dim.radius *= 0.5f; @@ -301,20 +300,20 @@ void func_80B5BB38(Color_RGB8* arg0, Color_RGB8* arg1, f32 arg2) { void func_80B5BDA8(EnOt* this, PlayState* play) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIndex); - SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_FillCutscenesList(&this->actor, this->csIdList, ARRAY_COUNT(this->csIdList)); this->actionFunc = func_80B5BE04; } void func_80B5BE04(EnOt* this, PlayState* play) { switch (this->unk_388) { case 0: - if (SubS_StartActorCutscene(&this->actor, this->cutscenes[2], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + if (SubS_StartCutscene(&this->actor, this->csIdList[2], CS_ID_NONE, SUBS_CUTSCENE_WITH_PLAYER)) { func_80B5BF60(this, play); } break; case 1: - if (SubS_StartActorCutscene(&this->actor, this->cutscenes[3], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + if (SubS_StartCutscene(&this->actor, this->csIdList[3], CS_ID_NONE, SUBS_CUTSCENE_WITH_PLAYER)) { func_80B5BF60(this, play); } break; @@ -327,10 +326,10 @@ void func_80B5BE88(EnOt* this, PlayState* play) { } void func_80B5BED4(EnOt* this, PlayState* play) { - func_800BE33C(&this->actor.world.pos, &this->unk_360->actor.world.pos, &this->actor.world.rot, 0); - Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, &this->unk_360->actor), 3, 0xE38, - 0x38E); - this->actor.speedXZ = 3.5f; + func_800BE33C(&this->actor.world.pos, &this->unk_360->actor.world.pos, &this->actor.world.rot, false); + Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardActor(&this->actor, &this->unk_360->actor), 3, + 0xE38, 0x38E); + this->actor.speed = 3.5f; this->actor.world.pos.y = this->unk_360->actor.world.pos.y; Actor_MoveWithoutGravityReverse(&this->actor); } @@ -349,10 +348,10 @@ void func_80B5BFB8(EnOt* this, PlayState* play) { Math_StepToF(&this->actor.world.pos.y, temp_f0, 2.0f); } - Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, &this->unk_360->actor), 3, 0xE38, - 0x38E); + Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardActor(&this->actor, &this->unk_360->actor), 3, + 0xE38, 0x38E); - if (Actor_DistanceBetweenActors(&this->actor, &this->unk_360->actor) <= 52.519997f) { + if (Actor_WorldDistXYZToActor(&this->actor, &this->unk_360->actor) <= 52.519997f) { this->unk_73C = 50; Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_NEW); Matrix_MultVecZ(52.519997f, &sp34); @@ -382,7 +381,7 @@ void func_80B5C154(EnOt* this, PlayState* play) { this->getItemId = GI_HEART_PIECE; SET_WEEKEVENTREG(WEEKEVENTREG_32_01); } - Actor_PickUp(&this->actor, play, this->getItemId, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_OfferGetItem(&this->actor, play, this->getItemId, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_80B5C1CC; } @@ -392,7 +391,8 @@ void func_80B5C1CC(EnOt* this, PlayState* play) { func_80B5C244(this, play); func_80B5C244(this->unk_360, play); } else { - Actor_PickUp(&this->actor, play, this->getItemId, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + Actor_OfferGetItem(&this->actor, play, this->getItemId, this->actor.xzDistToPlayer, + this->actor.playerHeightRel); } } @@ -401,7 +401,7 @@ void func_80B5C244(EnOt* this, PlayState* play) { } void func_80B5C25C(EnOt* this, PlayState* play) { - this->unk_390 = Actor_YawBetweenActors(&this->actor, &this->unk_360->actor); + this->unk_390 = Actor_WorldYawTowardActor(&this->actor, &this->unk_360->actor); Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_390, 3, 0xE38, 0x38E); if (BINANG_SUB(BINANG_ROT180(this->unk_360->actor.shape.rot.y), this->actor.shape.rot.y) < 0x38E) { this->unk_32C |= 0x80; @@ -412,9 +412,9 @@ void func_80B5C25C(EnOt* this, PlayState* play) { this->unk_360->unk_32C |= 0x100; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 2, &this->animIndex); SubS_ChangeAnimationBySpeedInfo(&this->unk_360->skelAnime, sAnimations, 2, &this->unk_360->animIndex); - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); - this->unk_360->actor.flags |= ACTOR_FLAG_8000000; + this->unk_360->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->unk_360->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80B5C9A8(this->unk_360, play); func_80B5C3B8(this, play); @@ -450,7 +450,7 @@ void func_80B5C3D8(EnOt* this, PlayState* play) { Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_348); Math_Vec3f_Copy(&this->unk_360->actor.world.pos, &this->unk_360->unk_348); - temp = Actor_YawBetweenActors(&this->actor, &this->unk_360->actor); + temp = Actor_WorldYawTowardActor(&this->actor, &this->unk_360->actor); this->actor.shape.rot.y = temp; this->unk_360->actor.shape.rot.y = BINANG_ROT180(temp); @@ -488,7 +488,7 @@ void func_80B5C64C(EnOt* this, PlayState* play) { } void func_80B5C684(EnOt* this, PlayState* play) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIndex); this->actionFunc = func_80B5C6DC; } @@ -499,7 +499,7 @@ void func_80B5C6DC(EnOt* this, PlayState* play) { s16 sp3E; Vec3f sp30; - sp3E = Actor_YawToPoint(&player->actor, &this->unk_394); + sp3E = Actor_WorldYawTowardPoint(&player->actor, &this->unk_394); Matrix_RotateYS(BINANG_ADD(sp3E, 0x4000), MTXMODE_NEW); if (this->unk_33C == 2) { Matrix_MultVecZ(26.259998f, &sp30); @@ -508,11 +508,11 @@ void func_80B5C6DC(EnOt* this, PlayState* play) { SET_WEEKEVENTREG(WEEKEVENTREG_84_10); switch (this->unk_388) { case 0: - ActorCutscene_Stop(this->cutscenes[2]); + CutsceneManager_Stop(this->csIdList[2]); break; case 1: - ActorCutscene_Stop(this->cutscenes[3]); + CutsceneManager_Stop(this->csIdList[3]); break; } this->unk_73C = -1; @@ -535,7 +535,7 @@ void func_80B5C6DC(EnOt* this, PlayState* play) { this->unk_360->unk_3A0 = this->unk_3A0; func_80B5C9A8(this, play); func_80B5D114(this, play); - } else if ((player->actor.bgCheckFlags & 1) && !func_801242B4(player) && + } else if ((player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && !func_801242B4(player) && (this->actor.xzDistToPlayer < 130.0f)) { func_800B8614(&this->actor, play, 130.0f); } @@ -555,7 +555,7 @@ void func_80B5C910(EnOt* this, PlayState* play) { void func_80B5C950(EnOt* this, PlayState* play) { if (this->unk_32C & 8) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); + Actor_PlaySfx(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); SET_WEEKEVENTREG(WEEKEVENTREG_25_04); func_80B5CAD0(this, play); } @@ -576,7 +576,7 @@ void func_80B5C9D0(EnOt* this, PlayState* play) { 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; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); + Actor_PlaySfx(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); this->actionFunc = func_80B5CA30; } @@ -591,7 +591,7 @@ void func_80B5CA30(EnOt* this, PlayState* play) { } void func_80B5CAD0(EnOt* this, PlayState* play) { - SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes) / 2); + SubS_FillCutscenesList(&this->actor, this->csIdList, ARRAY_COUNT(this->csIdList) / 2); this->actionFunc = func_80B5CB0C; } @@ -626,7 +626,7 @@ void func_80B5CC88(EnOt* this, PlayState* play) { } void func_80B5CCA0(EnOt* this, PlayState* play) { - if (SubS_StartActorCutscene(&this->actor, this->cutscenes[0], 0x7C, SUBS_CUTSCENE_NORMAL)) { + if (SubS_StartCutscene(&this->actor, this->csIdList[0], CS_ID_GLOBAL_TALK, SUBS_CUTSCENE_NORMAL)) { Player* player = GET_PLAYER(play); player->stateFlags2 |= PLAYER_STATE2_20000000; @@ -665,7 +665,7 @@ void func_80B5CD40(EnOt* this, PlayState* play) { case TEXT_STATE_DONE: if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x1069)) { this->unk_32C |= 4; - ActorCutscene_Stop(this->cutscenes[0]); + CutsceneManager_Stop(this->csIdList[0]); player->stateFlags2 &= ~PLAYER_STATE2_20000000; func_80B5CE6C(this, play); } @@ -696,7 +696,8 @@ void func_80B5CEC8(EnOt* this, PlayState* play) { func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, PLAYER_IA_NONE); } else { this->actor.flags &= ~ACTOR_FLAG_10000; - if ((player->actor.bgCheckFlags & 1) && !func_801242B4(player) && (this->actor.xzDistToPlayer < 130.0f)) { + if ((player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && !func_801242B4(player) && + (this->actor.xzDistToPlayer < 130.0f)) { func_800B8614(&this->actor, play, 130.0f); } } @@ -803,12 +804,12 @@ void func_80B5D160(EnOt* this, PlayState* play) { break; case 0x10A5: - func_801477B4(play); + Message_CloseTextbox(play); func_80B5CE6C(this, play); break; case 0x106D: - func_801477B4(play); + Message_CloseTextbox(play); func_80B5C154(this, play); break; } @@ -820,11 +821,11 @@ void func_80B5D160(EnOt* this, PlayState* play) { s32 EnOt_ActorPathing_Move(PlayState* play, ActorPathing* actorPath) { Actor* thisx = actorPath->actor; EnOt* this = (EnOt*)thisx; - f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speedXZ; + f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speed; f32 sp20 = gFramerateDivisorHalf; thisx->velocity.x = Math_SinS(thisx->world.rot.y) * sp24; - thisx->velocity.y = Math_SinS(-thisx->world.rot.x) * thisx->speedXZ; + thisx->velocity.y = Math_SinS(-thisx->world.rot.x) * thisx->speed; thisx->velocity.z = Math_CosS(thisx->world.rot.y) * sp24; this->unk_330.x += (thisx->velocity.x * sp20) + thisx->colChkInfo.displacement.x; @@ -846,7 +847,7 @@ s32 EnOt_ActorPathing_UpdateActorInfo(PlayState* play, ActorPathing* actorPath) s32 sp34; thisx->gravity = 0.0f; - Math_SmoothStepToF(&thisx->speedXZ, 10.0f, 0.8f, 2.0f, 0.0f); + Math_SmoothStepToF(&thisx->speed, 10.0f, 0.8f, 2.0f, 0.0f); sp50.x = actorPath->curPoint.x - thisx->world.pos.x; sp50.y = actorPath->curPoint.y - thisx->world.pos.y; @@ -857,10 +858,10 @@ s32 EnOt_ActorPathing_UpdateActorInfo(PlayState* play, ActorPathing* actorPath) sp44.z = actorPath->curPoint.z - actorPath->prevPoint.z; temp = Math3D_Parallel(&sp50, &sp44); - if ((actorPath->distSqToCurPointXZ < SQ(thisx->speedXZ)) || (temp <= 0.0f)) { + if ((actorPath->distSqToCurPointXZ < SQ(thisx->speed)) || (temp <= 0.0f)) { ret = true; } else { - temp = SQ(thisx->speedXZ) / actorPath->distSqToCurPoint; + temp = SQ(thisx->speed) / actorPath->distSqToCurPoint; sp34 = ABS(actorPath->rotToCurPoint.x - thisx->world.rot.x); sp2C = (s32)(sp34 * temp) + 0xAAA; @@ -885,9 +886,9 @@ void func_80B5D648(EnOt* this, PlayState* play) { this->actorPath.pointOffset.y = 0.0f; this->actorPath.pointOffset.z = 0.0f; this->actor.gravity = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIndex); - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Flags_SetSwitch(play, ENOT_GET_3F80(&this->actor)); this->actionFunc = func_80B5D750; @@ -915,7 +916,7 @@ void func_80B5D750(EnOt* this, PlayState* play) { } if ((this->unk_32C & 1) && (this->actor.xzDistToPlayer <= 180.0f)) { - this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); if (D_80B5E884 != 0) { func_80B5C9A8(this, play); @@ -930,11 +931,11 @@ void EnOt_Update(Actor* thisx, PlayState* play) { EnOt* this = THIS; if ((this->animIndex == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SEAHORSE_SWIM); + Actor_PlaySfx(&this->actor, NA_SE_EV_SEAHORSE_SWIM); } this->actionFunc(this, play); - if (this->actor.bgCheckFlags & 0x20) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { if (DECR(this->unk_354) == 0) { if (this->actor.flags & ACTOR_FLAG_40) { s32 i; @@ -947,7 +948,7 @@ void EnOt_Update(Actor* thisx, PlayState* play) { } } - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 10.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 10.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); if (this->actor.world.pos.y <= this->actor.floorHeight + 50.0f) { this->actor.world.pos.y = this->actor.floorHeight + 50.0f; @@ -992,7 +993,7 @@ void func_80B5DB6C(Actor* thisx, PlayState* play) { func_80B5B2E0(play, &this->actor.world.pos, ENOT_GET_7F(&this->actor), &sp50, &this->unk_340); if (Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_OT, sp50.x, sp50.y, sp50.z, 0, this->actor.shape.rot.y, 1, ENOT_GET_3FFF(&this->actor) | 0x8000, - this->actor.cutscene, this->actor.unk20, NULL) != NULL) { + this->actor.csId, this->actor.halfDaysBits, NULL) != NULL) { this->unk_32C |= 8; } } else if (D_80B5E888 != NULL) { @@ -1010,7 +1011,7 @@ void func_80B5DB6C(Actor* thisx, PlayState* play) { temp->unk_32C |= 8; temp->unk_346 = ENOT_GET_7F(&this->actor); temp->actor.params = this->actor.params; - temp->actor.cutscene = this->actor.cutscene; + temp->actor.csId = this->actor.csId; this->unk_32C |= 8; } } else if (SurfaceType_IsHorseBlocked(&play->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { @@ -1137,7 +1138,7 @@ void func_80B5E1D8(PlayState* play, EnOtUnkStruct* arg1, s32 arg2) { OPEN_DISPS(play->state.gfxCtx); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); for (i = 0; i < arg2; i++, arg1++) { diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.h b/src/overlays/actors/ovl_En_Ot/z_en_ot.h index 7e8d7f651..8b01c6654 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.h +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.h @@ -45,7 +45,7 @@ typedef struct EnOt { /* 0x346 */ s16 unk_346; /* 0x348 */ Vec3f unk_348; /* 0x354 */ s16 unk_354; - /* 0x356 */ s16 cutscenes[4]; + /* 0x356 */ s16 csIdList[4]; /* 0x360 */ struct EnOt* unk_360; /* 0x364 */ LightNode* lightNode; /* 0x368 */ LightInfo lightInfo; 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 8d7b92b69..f71d227f6 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -102,19 +102,19 @@ void EnOwl_Init(Actor* thisx, PlayState* play) { s32 pad; EnOwl* this = THIS; s32 i; - s16 cutscene = this->actor.cutscene; + s16 csId = this->actor.csId; s32 owlType; s32 switchFlag; - for (i = 0; i < ARRAY_COUNT(this->unk_400); i++) { - this->unk_400[i] = cutscene; - if (cutscene != -1) { - this->actor.cutscene = cutscene; - cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + for (i = 0; i < ARRAY_COUNT(this->csIdList); i++) { + this->csIdList[i] = csId; + if (csId != CS_ID_NONE) { + this->actor.csId = csId; + csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); } } - this->actor.cutscene = this->unk_400[0]; + this->actor.csId = this->csIdList[0]; Actor_ProcessInitChain(&this->actor, sInitChain); if (ENOWL_GET_TYPE(&this->actor) == ENOWL_GET_TYPE_30) { Actor_SetScale(&this->actor, 0.1f); @@ -144,7 +144,7 @@ void EnOwl_Init(Actor* thisx, PlayState* play) { this->unk_409 = 4; this->unk_40B = this->unk_408 = 0; this->unk_40C = 4; - this->unk_406 = -1; + this->csIdIndex = -1; owlType = ENOWL_GET_TYPE(&this->actor); switchFlag = ENOWL_GET_SWITCHFLAG(&this->actor); @@ -157,7 +157,7 @@ void EnOwl_Init(Actor* thisx, PlayState* play) { break; case ENOWL_GET_TYPE_2: - if (gSaveContext.save.inventory.items[ITEM_LENS] == ITEM_LENS) { + if (gSaveContext.save.saveInfo.inventory.items[ITEM_LENS] == ITEM_LENS) { Actor_Kill(&this->actor); return; } @@ -292,7 +292,7 @@ void func_8095ABA8(EnOwl* this) { void func_8095ABF0(EnOwl* this, PlayState* play) { if (Actor_TextboxIsClosing(&this->actor, play)) { - Audio_QueueSeqCmd(0x110000FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); func_8095AAD0(this, play); this->actor.flags &= ~ACTOR_FLAG_10000; } @@ -301,7 +301,7 @@ void func_8095ABF0(EnOwl* this, PlayState* play) { // Unused? void func_8095AC50(EnOwl* this, PlayState* play) { if (Actor_TextboxIsClosing(&this->actor, play)) { - Audio_QueueSeqCmd(0x110000FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); if ((this->unk_3DA % 64) == 0) { func_8095AAD0(this, play); } else { @@ -315,11 +315,11 @@ void func_8095AC50(EnOwl* this, PlayState* play) { void func_8095ACEC(EnOwl* this) { this->actionFlags &= ~0x40; - if (this->unk_406 >= 0) { - if (ActorCutscene_GetCurrentIndex() == this->unk_400[this->unk_406]) { - ActorCutscene_Stop(this->unk_400[this->unk_406]); + if (this->csIdIndex >= 0) { + if (CutsceneManager_GetCurrentCsId() == this->csIdList[this->csIdIndex]) { + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); } - this->unk_406 = -1; + this->csIdIndex = -1; } } @@ -327,12 +327,12 @@ void func_8095AD54(EnOwl* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case OWL_REPEAT: - func_80151938(play, 0x7D1); + Message_ContinueTextbox(play, 0x7D1); this->actionFunc = func_8095AE00; break; case OWL_OK: - func_80151938(play, 0x7D3); + Message_ContinueTextbox(play, 0x7D3); this->actionFunc = func_8095ABF0; break; } @@ -341,14 +341,14 @@ void func_8095AD54(EnOwl* this, PlayState* play) { void func_8095AE00(EnOwl* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_80151938(play, 0x7D2); + Message_ContinueTextbox(play, 0x7D2); this->actionFunc = func_8095AD54; } } void func_8095AE60(EnOwl* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_80151938(play, 0x7D1); + Message_ContinueTextbox(play, 0x7D1); this->actionFunc = func_8095AE00; } } @@ -367,10 +367,10 @@ void func_8095AF2C(EnOwl* this, PlayState* play) { if (Message_ShouldAdvance(play)) { if (play->msgCtx.currentTextId == 0xBFE) { func_8095ACEC(this); - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_8095ABF0; } else { - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); } } break; @@ -387,7 +387,7 @@ void func_8095AFEC(EnOwl* this, PlayState* play) { if (func_8095A978(this, play, 0xBF6, 200.0f, 100.0f)) { Audio_PlayFanfare(NA_BGM_OWL); this->actionFunc = func_8095AF2C; - this->unk_406 = 0; + this->csIdIndex = 0; this->actionFlags |= 0x40; } } @@ -419,13 +419,13 @@ 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)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OWL_FLUTTER); + Actor_PlaySfx(&this->actor, NA_SE_EN_OWL_FLUTTER); } } void func_8095B1E4(EnOwl* this, PlayState* play) { - if (this->actor.speedXZ < 6.0f) { - this->actor.speedXZ += 1.0f; + if (this->actor.speed < 6.0f) { + this->actor.speed += 1.0f; } if (this->actor.xzDistToPlayer > 6000.0f) { @@ -434,8 +434,8 @@ void func_8095B1E4(EnOwl* this, PlayState* play) { } void func_8095B254(EnOwl* this, PlayState* play) { - if (this->actor.speedXZ < 6.0f) { - this->actor.speedXZ += 1.0f; + if (this->actor.speed < 6.0f) { + this->actor.speed += 1.0f; } if (this->actionFlags & 1) { @@ -491,7 +491,7 @@ void func_8095B480(EnOwl* this, PlayState* play) { this->unk_3EC = this->actor.home.rot.y; this->actor.world.pos = this->actor.home.pos; func_8095A510(this, play); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_8095BE0C; } } @@ -502,7 +502,7 @@ void func_8095B574(EnOwl* this, PlayState* play) { this->actionFunc = func_8095BA84; Audio_PlayFanfare(NA_BGM_OWL); this->actionFlags |= 0x40; - this->unk_406 = 2; + this->csIdIndex = 2; } else if (this->actor.xzDistToPlayer < 200.0f) { this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, play, 200.0f, 400.0f, PLAYER_IA_NONE); @@ -540,8 +540,8 @@ void func_8095B76C(EnOwl* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, sp4A, 6, 0x800, 0x200); this->actor.shape.rot.y = this->actor.world.rot.y; - if (sp44 < SQ(this->actor.speedXZ)) { - this->actor.speedXZ = 0.0f; + if (sp44 < SQ(this->actor.speed)) { + this->actor.speed = 0.0f; points = Lib_SegmentedToVirtual(this->path->points); points += this->unk_3F8; @@ -564,13 +564,13 @@ void func_8095B76C(EnOwl* this, PlayState* play) { } func_8095B0C8(this); } else if (sp44 < SQ(21.0f)) { - if (this->actor.speedXZ > 1.0f) { - this->actor.speedXZ -= 1.0f; + if (this->actor.speed > 1.0f) { + this->actor.speed -= 1.0f; } else { - this->actor.speedXZ = 1.0f; + this->actor.speed = 1.0f; } - } else if (this->actor.speedXZ < 6.0f) { - this->actor.speedXZ += 1.0f; + } else if (this->actor.speed < 6.0f) { + this->actor.speed += 1.0f; } func_8095B06C(this); @@ -614,16 +614,16 @@ void func_8095BA84(EnOwl* this, PlayState* play) { case 0: func_8019F208(); if (CHECK_WEEKEVENTREG(WEEKEVENTREG_09_40)) { - func_80151938(play, 0xBF4); + Message_ContinueTextbox(play, 0xBF4); } else { SET_WEEKEVENTREG(WEEKEVENTREG_09_40); - func_80151938(play, 0xBED); + Message_ContinueTextbox(play, 0xBED); } break; case 1: func_8019F230(); - func_80151938(play, 0xBEF); + Message_ContinueTextbox(play, 0xBEF); break; } break; @@ -632,12 +632,12 @@ void func_8095BA84(EnOwl* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - func_80151938(play, 0xBF4); + Message_ContinueTextbox(play, 0xBF4); return; case 1: func_8019F230(); - func_80151938(play, 0xBF3); + Message_ContinueTextbox(play, 0xBF3); return; } break; @@ -650,22 +650,22 @@ void func_8095BA84(EnOwl* this, PlayState* play) { switch (play->msgCtx.currentTextId) { case 0xBEA: SET_WEEKEVENTREG(WEEKEVENTREG_09_20); - func_80151938(play, 0xBEB); + Message_ContinueTextbox(play, 0xBEB); break; case 0xBEB: case 0xBF0: - func_80151938(play, 0xBEC); + Message_ContinueTextbox(play, 0xBEC); break; case 0xBED: case 0xBF4: - func_80151938(play, 0xBEE); + Message_ContinueTextbox(play, 0xBEE); break; case 0xBEE: - func_801477B4(play); - Audio_QueueSeqCmd(0x110000FF); + Message_CloseTextbox(play); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); EnOwl_ChangeMode(this, func_8095B9FC, func_8095C484, &this->skelAnime1, &object_owl_Anim_00CB94, 0.0f); this->eyeTexIndex = 0; @@ -674,14 +674,14 @@ void func_8095BA84(EnOwl* this, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.home.rot.x = 0; func_8095ACEC(this); - this->unk_406 = 0; + this->csIdIndex = 0; this->actionFlags |= 0x40; break; case 0xBEF: case 0xBF3: - func_801477B4(play); - Audio_QueueSeqCmd(0x110000FF); + Message_CloseTextbox(play); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); func_8095ACEC(this); this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.textId = 0xBF0; @@ -689,12 +689,12 @@ void func_8095BA84(EnOwl* this, PlayState* play) { break; case 0xBF1: - func_80151938(play, 0xBF2); + Message_ContinueTextbox(play, 0xBF2); break; case 0xBF5: - func_801477B4(play); - Audio_QueueSeqCmd(0x110000FF); + Message_CloseTextbox(play); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); this->actor.flags &= ~ACTOR_FLAG_10000; EnOwl_ChangeMode(this, func_8095B3DC, func_8095C484, &this->skelAnime1, &object_owl_Anim_00CB94, 0.0f); @@ -714,7 +714,7 @@ void func_8095BE0C(EnOwl* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_8095BA84; Audio_PlayFanfare(NA_BGM_OWL); - this->unk_406 = 1; + this->csIdIndex = 1; this->actionFlags |= 0x40; } else if (this->actor.textId == 0xBF0) { if (this->actor.isTargeted) { @@ -745,8 +745,8 @@ void func_8095BF78(EnOwl* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_3EC, 2, 0x80, 0x40); this->actor.shape.rot.y = this->actor.world.rot.y; - if (this->actor.speedXZ < 16.0f) { - this->actor.speedXZ += 0.5f; + if (this->actor.speed < 16.0f) { + this->actor.speed += 0.5f; } if ((this->unk_3E4 + 1000.0f) < this->actor.world.pos.y) { @@ -767,11 +767,11 @@ void func_8095C09C(EnOwl* this, PlayState* play) { if (this->skelAnime1.curFrame > 45.0f) { this->actor.velocity.y = 2.0f; this->actor.gravity = 0.0f; - this->actor.speedXZ = 8.0f; + this->actor.speed = 8.0f; } else if (this->skelAnime1.curFrame > 17.0f) { this->actor.velocity.y = 6.0f; this->actor.gravity = 0.0f; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; } if (this->actionFlags & 1) { @@ -865,16 +865,16 @@ s32 func_8095C510(EnOwl* this) { void func_8095C568(EnOwl* this) { if (this->actionFlags & 0x40) { - if ((this->unk_406 < 0) || (this->unk_400[this->unk_406] < 0)) { + if ((this->csIdIndex < 0) || (this->csIdList[this->csIdIndex] < 0)) { this->actionFlags &= ~0x40; - } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_400[this->unk_406]); - } else if (ActorCutscene_GetCanPlayNext(this->unk_400[this->unk_406])) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_400[this->unk_406], &this->actor); + } else if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); + } else if (CutsceneManager_IsNext(this->csIdList[this->csIdIndex])) { + CutsceneManager_StartWithPlayerCs(this->csIdList[this->csIdIndex], &this->actor); this->actionFlags &= ~0x40; } else { - ActorCutscene_SetIntentToPlay(this->unk_400[this->unk_406]); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); } } } @@ -894,12 +894,12 @@ void EnOwl_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); func_8095C568(this); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, UPDBGCHECKINFO_FLAG_4); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if (this->actor.update != NULL) { if ((this->skelAnime1.animation == &object_owl_Anim_001ADC) && Animation_OnFrame(&this->skelAnime1, 4.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OWL_FLUTTER); + Actor_PlaySfx(&this->actor, NA_SE_EN_OWL_FLUTTER); } if (this->actionFlags & 2) { @@ -1077,8 +1077,8 @@ void func_8095CCF4(Actor* thisx, PlayState* play) { } this->actor.world.pos.y -= 1.0f; - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 4); - if (this->actor.bgCheckFlags & 1) { + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, UPDBGCHECKINFO_FLAG_4); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->unk_3DA = (this->unk_3DA >> 3) * 7; if (this->unk_3DC > 0) { this->unk_3DC--; diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.h b/src/overlays/actors/ovl_En_Owl/z_en_owl.h index 033857886..5e02aba94 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.h +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.h @@ -44,8 +44,8 @@ typedef struct EnOwl { /* 0x3F4 */ Path* path; /* 0x3F8 */ s32 unk_3F8; /* 0x3FC */ s32 unk_3FC; - /* 0x400 */ s16 unk_400[3]; - /* 0x406 */ s16 unk_406; + /* 0x400 */ s16 csIdList[3]; + /* 0x406 */ s16 csIdIndex; /* 0x408 */ u8 unk_408; /* 0x409 */ u8 unk_409; /* 0x40A */ u8 unk_40A; 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 2b0aae48a..b4e7c29e3 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -156,7 +156,7 @@ void EnPamera_Init(Actor* thisx, PlayState* play) { if (1) {} - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_14_04) || CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20) || + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_14_04) || CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE) || CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) || (gSaveContext.save.entrance == ENTRANCE(IKANA_CANYON, 9))) { Actor_Kill(&this->actor); } @@ -216,14 +216,14 @@ void func_80BD8588(EnPamera* this, PlayState* play) { void func_80BD8658(EnPamera* this) { s32 i; - s16 nextCutscene = this->actor.cutscene; + s16 csId = this->actor.csId; - for (i = 0; i < ARRAY_COUNT(this->cutscenes); i++) { - if (nextCutscene == -1) { + for (i = 0; i < ARRAY_COUNT(this->csIdList); i++) { + if (csId == CS_ID_NONE) { break; } - this->cutscenes[i] = nextCutscene; - nextCutscene = ActorCutscene_GetAdditionalCutscene(nextCutscene); + this->csIdList[i] = csId; + csId = CutsceneManager_GetAdditionalCsId(csId); } } @@ -242,20 +242,20 @@ void func_80BD8700(EnPamera* this) { void func_80BD8758(EnPamera* this, PlayState* play) { if (this->hideInisdeTimer++ > 1800) { - if (ActorCutscene_GetCanPlayNext(this->cutscenes[0]) && (this->cutscenes[0] != -1)) { - ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[0], &this->actor); - Camera_SetToTrackActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(this->cutscenes[0])), - &this->actor); - this->actor.speedXZ = 1.5f; + if (CutsceneManager_IsNext(this->csIdList[0]) && (this->csIdList[0] != -1)) { + CutsceneManager_StartWithPlayerCs(this->csIdList[0], &this->actor); + Camera_SetFocalActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(this->csIdList[0])), + &this->actor); + this->actor.speed = 1.5f; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); this->actor.shape.rot.y = this->actor.home.rot.y; this->actor.world.rot.y = this->actor.home.rot.y; func_80BD9338(this, play); func_80BD8908(this); - } else if ((this->cutscenes[0] != -1) && (this->actor.xzDistToPlayer < 1000.0f)) { - ActorCutscene_SetIntentToPlay(this->cutscenes[0]); + } else if ((this->csIdList[0] != -1) && (this->actor.xzDistToPlayer < 1000.0f)) { + CutsceneManager_Queue(this->csIdList[0]); } else { - this->actor.speedXZ = 1.5f; + this->actor.speed = 1.5f; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); this->actor.shape.rot.y = this->actor.home.rot.y; this->actor.world.rot.y = this->actor.home.rot.y; @@ -290,7 +290,7 @@ void func_80BD8964(EnPamera* this, PlayState* play) { vec.z = this->pathPoints->z; if (Math_Vec3f_StepTo(&this->actor.world.pos, &vec, 1.0f) < 5.0f) { - this->actor.speedXZ = 1.5f; + this->actor.speed = 1.5f; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); SET_WEEKEVENTREG(WEEKEVENTREG_59_01); func_80BD8B50(this); @@ -329,7 +329,7 @@ void func_80BD8B70(EnPamera* this, PlayState* play) { vec.y = this->pathPoints[this->pathIndex].y; vec.z = this->pathPoints[this->pathIndex].z; sp32 = Math_Vec3f_Yaw(&this->actor.world.pos, &vec); - if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &vec, this->actor.speedXZ) > 10.0f) { + if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &vec, this->actor.speed) > 10.0f) { Math_SmoothStepToS(&this->actor.shape.rot.y, sp32, 0xA, 0x3000, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; } else if (this->pathIndex < (this->pathPointsCount - 1)) { @@ -338,20 +338,20 @@ void func_80BD8B70(EnPamera* this, PlayState* play) { func_80BD8CCC(this); } - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); this->actor.world.pos.y += this->actor.gravity; } void func_80BD8CCC(EnPamera* this) { this->hideInisdeTimer = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); this->actionFunc = func_80BD8D1C; } void func_80BD8D1C(EnPamera* this, PlayState* play) { if (this->hideInisdeTimer++ > 200) { - this->actor.speedXZ = 1.5f; + this->actor.speed = 1.5f; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); func_80BD8D80(this); } @@ -373,7 +373,7 @@ void func_80BD8DB0(EnPamera* this, PlayState* play) { vec.y = this->pathPoints[this->pathIndex].y; vec.z = this->pathPoints[this->pathIndex].z; sp32 = Math_Vec3f_Yaw(&this->actor.world.pos, &vec); - if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &vec, this->actor.speedXZ) > 10.0f) { + if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &vec, this->actor.speed) > 10.0f) { Math_SmoothStepToS(&this->actor.shape.rot.y, sp32, 0xA, 0x3000, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; } else if (this->pathIndex > 0) { @@ -382,7 +382,7 @@ void func_80BD8DB0(EnPamera* this, PlayState* play) { func_80BD9338(this, play); func_80BD8A38(this); } - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); this->actor.world.pos.y += this->actor.gravity; } @@ -396,7 +396,7 @@ void func_80BD8F60(EnPamera* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x3000, 0x1000); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; func_80BD93CC(this, 0, 0); func_80BD8D80(this); } @@ -425,17 +425,17 @@ void func_80BD90AC(EnPamera* this, PlayState* play) { if (Player_GetMask(play) != PLAYER_MASK_STONE && (this->actionFunc != func_80BD8758) && (this->actionFunc != func_80BD8964) && (this->actionFunc != func_80BD8A7C) && (this->actionFunc != func_80BD8F60) && ((this->actionFunc != func_80BD8B70) || (this->pathIndex != 0)) && - ((this->actionFunc != func_80BD8DB0) || (this->actor.speedXZ != 3.0f)) && + ((this->actionFunc != func_80BD8DB0) || (this->actor.speed != 3.0f)) && ((this->actor.xzDistToPlayer < 150.0f) || ((this->actionFunc == func_80BD909C) && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 200.0f)))) { - if ((ActorCutscene_GetCanPlayNext(this->cutscenes[1])) && ((this->cutscenes[1] != -1))) { - ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[1], &this->actor); - Camera_SetToTrackActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(this->cutscenes[1])), - &this->actor); + if ((CutsceneManager_IsNext(this->csIdList[1])) && ((this->csIdList[1] != -1))) { + CutsceneManager_StartWithPlayerCs(this->csIdList[1], &this->actor); + Camera_SetFocalActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(this->csIdList[1])), + &this->actor); EnPamera_LookDownWell(this); - } else if (this->cutscenes[1] != -1) { - ActorCutscene_SetIntentToPlay(this->cutscenes[1]); + } else if (this->csIdList[1] != -1) { + CutsceneManager_Queue(this->csIdList[1]); } else { EnPamera_LookDownWell(this); } @@ -501,11 +501,11 @@ void func_80BD93F4(EnPamera* this, PlayState* play) { (this->actionFunc == func_80BD8964) || (this->actionFunc == func_80BD8A7C)) { if (this->skelAnime.animation == &object_pamera_Anim_008AE0) { if (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_PAMERA_WALK); } } else if ((this->skelAnime.animation == &object_pamera_Anim_008E38) && (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_PAMERA_WALK); } } } @@ -513,7 +513,7 @@ void func_80BD93F4(EnPamera* this, PlayState* play) { void func_80BD94E0(EnPamera* this, PlayState* play) { if ((this->actionFunc != func_80BD8B70) && (this->actionFunc != func_80BD8964) && (this->actionFunc != func_80BD909C) && (this->actionFunc != func_80BD8D1C) && - ((this->actionFunc != func_80BD8DB0) || (this->actor.speedXZ == 3.0f))) { + ((this->actionFunc != func_80BD8DB0) || (this->actor.speed == 3.0f))) { Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->torsoRot, this->actor.focus.pos); } else { Actor_TrackNone(&this->headRot, &this->torsoRot); @@ -569,7 +569,7 @@ void func_80BD9840(EnPamera* this, PlayState* play) { this->actor.update = func_80BDA344; this->actor.flags |= ACTOR_FLAG_2000000; this->actor.flags |= ACTOR_FLAG_100000; - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) || CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) || CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE)) { func_80BD9E60(this); func_80BD9938(this); } else { @@ -605,7 +605,8 @@ void func_80BD994C(EnPamera* this, PlayState* play) { this->unk_324 = 0x15A8; } else if ((gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) || - (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20))) { + (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20))) { func_80BD93CC(this, 1, 0); Message_StartTextbox(play, 0x158E, &this->actor); this->unk_324 = 0x158E; @@ -680,7 +681,7 @@ void func_80BD9B4C(EnPamera* this, PlayState* play) { break; case 0x158E: case 0x15A8: - func_801477B4(play); + Message_CloseTextbox(play); func_80BD9C70(this, play); break; } @@ -691,18 +692,18 @@ void func_80BD9C70(EnPamera* this, PlayState* play) { play->nextEntrance = ENTRANCE(IKANA_CANYON, 2); play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_70; - gSaveContext.nextTransitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; } s32 func_80BD9CB8(EnPamera* this, PlayState* play) { - s32 actionIndex; + s32 cueChannel; - if (Cutscene_CheckActorAction(play, 0x1E5)) { - actionIndex = Cutscene_GetActorActionIndex(play, 0x1E5); - if (this->unk_326 != play->csCtx.actorActions[actionIndex]->action) { - this->unk_326 = play->csCtx.actorActions[actionIndex]->action; + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_485)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_485); + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; - switch (play->csCtx.actorActions[actionIndex]->action) { + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: func_80BD9E88(this); break; @@ -727,18 +728,18 @@ s32 func_80BD9CB8(EnPamera* this, PlayState* play) { break; } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); this->setupFunc(this, play); return 1; } - if ((play->csCtx.state == 0) && CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20)) { + if ((play->csCtx.state == CS_STATE_IDLE) && CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20)) { if ((this->actionFunc != func_80BD994C) && (this->actionFunc != EnPamera_HandleDialogue)) { this->actor.shape.rot.y = this->actor.world.rot.y; func_80BD9904(this); func_80BD9E60(this); } } - this->unk_326 = 0x63; + this->cueId = 99; return 0; } @@ -772,7 +773,7 @@ void func_80BD9F3C(EnPamera* this, PlayState* play) { 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)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_PAMERA_WALK); } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; @@ -820,7 +821,7 @@ void func_80BDA1C8(EnPamera* this, PlayState* play) { 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)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_PAMERA_WALK); } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.h b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.h index 34f18e815..59bf40e09 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.h +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.h @@ -28,13 +28,13 @@ typedef struct EnPamera { /* 0x312 */ s16 unk_312; /* 0x314 */ s16 unk_314; /* 0x316 */ s16 unk_316; - /* 0x318 */ s16 cutscenes[2]; + /* 0x318 */ s16 csIdList[2]; /* 0x31C */ s16 hideInisdeTimer; /* 0x31E */ s16 unk_31E; /* 0x320 */ UNK_TYPE1 unk_320[0x2]; /* 0x322 */ s16 unk_322; /* 0x324 */ u16 unk_324; - /* 0x326 */ u16 unk_326; + /* 0x326 */ u16 cueId; } EnPamera; // size = 0x328 #endif // Z_EN_PAMERA_H 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 82b424657..850442bad 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -341,8 +341,8 @@ void EnPametfrog_StopCutscene(EnPametfrog* this, PlayState* play) { subCam = Play_GetCamera(play, this->subCamId); Play_SetCameraAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye); this->subCamId = SUB_CAM_ID_DONE; - ActorCutscene_Stop(this->cutscene); - func_800B724C(play, &this->actor, PLAYER_CSMODE_6); + CutsceneManager_Stop(this->csId); + func_800B724C(play, &this->actor, PLAYER_CSMODE_END); } } @@ -376,10 +376,10 @@ void EnPametfrog_PlaceSnapper(EnPametfrog* this, PlayState* play) { void EnPametfrog_JumpOnGround(EnPametfrog* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_JUMP); + Actor_PlaySfx(&this->actor, NA_SE_EN_FROG_JUMP); } else if (Animation_OnFrame(&this->skelAnime, 11.0f)) { EnPametfrog_JumpWaterEffects(this, play); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALK_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EV_WALK_WATER); } } @@ -402,8 +402,8 @@ void EnPametfrog_ApplyMagicArrowEffects(EnPametfrog* this, PlayState* play) { void EnPametfrog_ApplyElectricStun(EnPametfrog* this) { this->freezeTimer = 40; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; this->drawDmgEffScale = 0.75f; this->drawDmgEffAlpha = 2.0f; @@ -411,8 +411,8 @@ void EnPametfrog_ApplyElectricStun(EnPametfrog* this) { void EnPametfrog_ApplyStun(EnPametfrog* this) { this->freezeTimer = 40; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); } void EnPametfrog_SetupRearOnSnapper(EnPametfrog* this) { @@ -447,7 +447,7 @@ void EnPametfrog_RearOnSnapper(EnPametfrog* this, PlayState* play) { rearingPoint.x = this->actor.world.pos.x; rearingPoint.y = this->actor.world.pos.y + 10.0f; rearingPoint.z = this->actor.world.pos.z; - if (actor->world.rot.x < Actor_PitchToPoint(actor, &rearingPoint)) { + if (actor->world.rot.x < Actor_WorldPitchTowardPoint(actor, &rearingPoint)) { EnPametfrog_SetupRearOnSnapperWave(this); } else { EnPametfrog_SetupRearOnSnapperRise(this); @@ -497,19 +497,19 @@ void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, PlayState* play) { Animation_PlayOnce(&this->skelAnime, &gGekkoFallInAirAnim); this->actor.params = GEKKO_FALL_OFF_SNAPPER; - this->actor.speedXZ = 7.0f; + this->actor.speed = 7.0f; this->actor.velocity.y = 15.0f; this->actor.world.rot.y = BINANG_ROT180(this->actor.child->world.rot.y); this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.flags |= ACTOR_FLAG_1; this->timer = 30; this->collider.base.ocFlags1 |= OC1_ON; - yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + yaw = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); subCamEye.x = (Math_SinS(yaw) * 300.0f) + this->actor.focus.pos.x; subCamEye.y = this->actor.focus.pos.y + 100.0f; subCamEye.z = (Math_CosS(yaw) * 300.0f) + this->actor.focus.pos.z; Play_SetCameraAtEye(play, this->subCamId, &this->actor.focus.pos, &subCamEye); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_FROG_DAMAGE); this->actionFunc = EnPametfrog_FallOffSnapper; } @@ -525,7 +525,7 @@ void EnPametfrog_FallOffSnapper(EnPametfrog* this, PlayState* play) { sin = sin_rad(this->timer * (M_PI / 3)) * ((0.02f * (this->timer * (1.0f / 6.0f))) + 0.005f) + 1.0f; EnPametfrog_ShakeCamera(this, play, 300.0f * sin, 100.0f * sin); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { EnPametfrog_StopCutscene(this, play); EnPametfrog_SetupJumpToWall(this); } @@ -535,22 +535,22 @@ void EnPametfrog_SetupJumpToWall(EnPametfrog* this) { Animation_Change(&this->skelAnime, &gGekkoJumpForwardAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f); this->actor.shape.rot.x = 0; this->actor.shape.rot.z = 0; - this->actor.bgCheckFlags &= ~8; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_VOICE2); + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WALL; + Actor_PlaySfx(&this->actor, NA_SE_EN_FROG_VOICE2); this->actionFunc = EnPametfrog_JumpToWall; } void EnPametfrog_JumpToWall(EnPametfrog* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); EnPametfrog_JumpOnGround(this, play); - if ((this->actor.bgCheckFlags & 1) && (this->actor.bgCheckFlags & 8) && (this->actor.wallBgId == BGCHECK_SCENE) && - (COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y) < 0.5f)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && + (this->actor.wallBgId == BGCHECK_SCENE) && (COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y) < 0.5f)) { EnPametfrog_SetupWallCrawl(this); - } else if (!(this->actor.bgCheckFlags & 1) || + } else if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || ((this->skelAnime.curFrame > 1.0f) && (this->skelAnime.curFrame < 12.0f))) { - this->actor.speedXZ = 12.0f; + this->actor.speed = 12.0f; } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } } @@ -579,8 +579,8 @@ void EnPametfrog_SetupWallCrawl(EnPametfrog* this) { this->skelAnime.playSpeed = 1.0f; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_RUNAWAY); - this->actor.speedXZ = 8.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_FROG_RUNAWAY); + this->actor.speed = 8.0f; this->timer = Rand_S16Offset(35, 15); this->actionFunc = EnPametfrog_WallCrawl; } @@ -602,8 +602,8 @@ void EnPametfrog_WallCrawl(EnPametfrog* this, PlayState* play) { } else { SkelAnime_Update(&this->skelAnime); this->timer--; - this->actor.speedXZ = 8.0f; - doubleSpeedXZ = this->actor.speedXZ * 2.0f; + this->actor.speed = 8.0f; + doubleSpeedXZ = this->actor.speed * 2.0f; vec1.x = this->actor.world.pos.x + this->unk_2DC.x * 2.0f; vec1.y = this->actor.world.pos.y + this->unk_2DC.y * 2.0f; vec1.z = this->actor.world.pos.z + this->unk_2DC.z * 2.0f; @@ -619,7 +619,7 @@ void EnPametfrog_WallCrawl(EnPametfrog* this, PlayState* play) { isSuccess = func_8086A2CC(this, poly1); Math_Vec3f_Copy(&this->actor.world.pos, &worldPos1); this->actor.floorBgId = bgId1; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { if (this->actor.floorPoly != poly2) { isSuccess = func_8086A2CC(this, poly2); @@ -636,11 +636,11 @@ void EnPametfrog_WallCrawl(EnPametfrog* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 15.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_BOMCHU_WALK); } if (((play->gameplayFrames % 60) == 0) && (Rand_ZeroOne() < 0.8f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_REAL); + Actor_PlaySfx(&this->actor, NA_SE_EN_FROG_REAL); } if ((this->timer == 0) || @@ -659,7 +659,7 @@ void EnPametfrog_SetupWallPause(EnPametfrog* this) { s32 pad; f32 randFloat; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->skelAnime.playSpeed = 1.5f; if (this->timer != 0) { this->wallRotation = this->unk_2E8.y > 0.0f ? (M_PI / 30) : (-M_PI / 30); @@ -668,7 +668,7 @@ void EnPametfrog_SetupWallPause(EnPametfrog* this) { this->wallRotation = (Rand_ZeroOne() < 0.5f ? -1 : 1) * (0x1000 + randFloat) * (M_PI / (15 * 0x8000)); } this->timer = 15; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_RUNAWAY2); + Actor_PlaySfx(&this->actor, NA_SE_EN_FROG_RUNAWAY2); this->actionFunc = EnPametfrog_WallPause; } @@ -686,7 +686,7 @@ void EnPametfrog_WallPause(EnPametfrog* this, PlayState* play) { Math3D_CrossProduct(&this->unk_2DC, &this->unk_2D0, &this->unk_2E8); func_8086A238(this); if (((play->gameplayFrames % 60) == 0) && (Rand_ZeroOne() < 0.8f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_REAL); + Actor_PlaySfx(&this->actor, NA_SE_EN_FROG_REAL); } if (this->timer == 0) { @@ -700,19 +700,19 @@ void EnPametfrog_SetupClimbDownWall(EnPametfrog* this) { Animation_Change(&this->skelAnime, &gGekkoJumpForwardAnim, 0.0f, 0.0f, Animation_GetLastFrame(&gGekkoJumpForwardAnim), ANIMMODE_ONCE, 0.0f); - this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->actor.child); + this->actor.shape.rot.y = Actor_WorldYawTowardActor(&this->actor, this->actor.child); this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.shape.rot.x = 0; this->actor.shape.rot.z = 0; this->actor.colChkInfo.mass = 50; - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; this->collider.base.acFlags &= ~AC_ON; this->actor.velocity.y = 0.0f; this->actor.gravity = -1.0f; - yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + yaw = Actor_WorldYawTowardPoint(&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); - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->actor.params = GEKKO_RETURN_TO_SNAPPER; this->actionFunc = EnPametfrog_ClimbDownWall; } @@ -720,10 +720,10 @@ void EnPametfrog_SetupClimbDownWall(EnPametfrog* this) { void EnPametfrog_ClimbDownWall(EnPametfrog* this, PlayState* play) { s16 yaw; - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { EnPametfrog_SetupRunToSnapper(this); } else if (this->actor.floorHeight == BGCHECK_Y_MIN) { - yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + yaw = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); this->actor.world.pos.x += 5.0f * Math_SinS(yaw); this->actor.world.pos.z += 5.0f * Math_CosS(yaw); if (this->actor.world.pos.y < (this->actor.home.pos.y - 5.0f)) { @@ -741,15 +741,16 @@ void EnPametfrog_SetupRunToSnapper(EnPametfrog* this) { void EnPametfrog_RunToSnapper(EnPametfrog* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); EnPametfrog_JumpOnGround(this, play); - this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->actor.child); + this->actor.shape.rot.y = Actor_WorldYawTowardActor(&this->actor, this->actor.child); this->actor.world.rot.y = this->actor.shape.rot.y; - if (!(this->actor.bgCheckFlags & 1) || ((this->skelAnime.curFrame > 1.0f) && (this->skelAnime.curFrame < 12.0f))) { - this->actor.speedXZ = 12.0f; + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || + ((this->skelAnime.curFrame > 1.0f) && (this->skelAnime.curFrame < 12.0f))) { + this->actor.speed = 12.0f; } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } - if ((this->actor.child->params == 1) && (Actor_XZDistanceBetweenActors(&this->actor, this->actor.child) < 120.0f) && + if ((this->actor.child->params == 1) && (Actor_WorldDistXZToActor(&this->actor, this->actor.child) < 120.0f) && Animation_OnFrame(&this->skelAnime, 0.0f)) { EnPametfrog_SetupJumpOnSnapper(this); } @@ -760,12 +761,12 @@ void EnPametfrog_SetupJumpOnSnapper(EnPametfrog* this) { this->timer = 6; this->collider.base.ocFlags1 &= ~OC1_ON; this->collider.base.acFlags &= ~AC_ON; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; - this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->actor.child); + this->actor.shape.rot.y = Actor_WorldYawTowardActor(&this->actor, this->actor.child); this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.params = GEKKO_JUMP_ON_SNAPPER; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_GREET); + Actor_PlaySfx(&this->actor, NA_SE_EN_FROG_GREET); this->actionFunc = EnPametfrog_JumpOnSnapper; } @@ -811,18 +812,18 @@ void EnPametfrog_SetupFallInAir(EnPametfrog* this, PlayState* play) { this->actor.params = GEKKO_RETURN_TO_SNAPPER; } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; this->collider.base.acFlags &= ~AC_ON; this->timer = 10; if (this->actor.colChkInfo.health == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_FROG_DEAD); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_FROG_DAMAGE); } - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); - yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 16); + yaw = Actor_WorldYawTowardPoint(&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); if (this->subCamId != SUB_CAM_ID_DONE) { @@ -860,7 +861,7 @@ void EnPametfrog_FallInAir(EnPametfrog* this, PlayState* play) { &Play_GetCamera(play, this->subCamId)->eye); } - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { EnPametfrog_SetupFallOnGround(this, play); } } @@ -875,7 +876,7 @@ void EnPametfrog_SetupFallOnGround(EnPametfrog* this, PlayState* play) { this->timer = 5; EnPametfrog_Thaw(this, play); EnPametfrog_JumpWaterEffects(this, play); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALK_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EV_WALK_WATER); this->actionFunc = EnPametfrog_FallOnGround; } @@ -898,7 +899,7 @@ void EnPametfrog_FallOnGround(EnPametfrog* this, PlayState* play) { void EnPametfrog_SetupDefeatGekko(EnPametfrog* this, PlayState* play) { Vec3f subCamEye; - s16 yaw = Actor_YawToPoint(this->actor.child, &this->actor.home.pos); + s16 yaw = Actor_WorldYawTowardPoint(this->actor.child, &this->actor.home.pos); s16 yawDiff = this->actor.yawTowardsPlayer - yaw; yaw = yawDiff > 0 ? yaw - 0x2000 : yaw + 0x2000; @@ -923,7 +924,7 @@ void EnPametfrog_DefeatGekko(EnPametfrog* this, PlayState* play) { void EnPametfrog_SetupDefeatSnapper(EnPametfrog* this, PlayState* play) { Vec3f subCamEye; - s16 yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + s16 yaw = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); s16 yawDiff = this->actor.yawTowardsPlayer - yaw; yaw = yawDiff > 0 ? yaw - 0x2000 : yaw + 0x2000; @@ -990,22 +991,22 @@ void EnPametfrog_SpawnFrog(EnPametfrog* this, PlayState* play) { void EnPametfrog_SetupCutscene(EnPametfrog* this) { if (this->actor.colChkInfo.health == 0) { - this->cutscene = this->actor.cutscene; + this->csId = this->actor.csId; } else { - this->cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + this->csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); } - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); this->actionFunc = EnPametfrog_PlayCutscene; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; } void EnPametfrog_PlayCutscene(EnPametfrog* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_Start(this->cutscene, &this->actor); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->cutscene); - func_800B724C(play, &this->actor, PLAYER_CSMODE_7); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Start(this->csId, &this->actor); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->csId); + func_800B724C(play, &this->actor, PLAYER_CSMODE_WAIT); if (this->actor.colChkInfo.health == 0) { if (this->actor.params == GEKKO_PRE_SNAPPER) { EnPametfrog_SetupCallSnapper(this, play); @@ -1016,14 +1017,14 @@ void EnPametfrog_PlayCutscene(EnPametfrog* this, PlayState* play) { EnPametfrog_SetupFallOffSnapper(this, play); } } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } void EnPametfrog_SetupLookAround(EnPametfrog* this) { Animation_PlayOnce(&this->skelAnime, &gGekkoLookAroundAnim); this->collider.base.atFlags &= ~AT_ON; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = EnPametfrog_LookAround; } @@ -1053,10 +1054,11 @@ void EnPametfrog_JumpToLink(EnPametfrog* this, PlayState* play) { this->actor.shape.rot.y = this->actor.world.rot.y; SkelAnime_Update(&this->skelAnime); EnPametfrog_JumpOnGround(this, play); - if (!(this->actor.bgCheckFlags & 1) || (this->skelAnime.curFrame > 1.0f && this->skelAnime.curFrame < 12.0f)) { - this->actor.speedXZ = 8.0f; + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || + (this->skelAnime.curFrame > 1.0f && this->skelAnime.curFrame < 12.0f)) { + this->actor.speed = 8.0f; } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } if ((this->collider.base.ocFlags1 & OC1_HIT) && (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) && @@ -1069,7 +1071,7 @@ void EnPametfrog_JumpToLink(EnPametfrog* this, PlayState* play) { void EnPametfrog_SetupMeleeAttack(EnPametfrog* this) { Animation_PlayOnce(&this->skelAnime, &gGekkoBoxingStanceAnim); this->timer = 7; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnPametfrog_MeleeAttack; } @@ -1099,9 +1101,9 @@ void EnPametfrog_MeleeAttack(EnPametfrog* this, PlayState* play) { ((this->skelAnime.animation == &gGekkoWindupPunchAnim) && Animation_OnFrame(&this->skelAnime, 27.0f))) { this->collider.base.atFlags |= AT_ON; if (this->skelAnime.animation == &gGekkoKickAnim) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_KICK); + Actor_PlaySfx(&this->actor, NA_SE_EN_FROG_KICK); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_PUNCH1); + Actor_PlaySfx(&this->actor, NA_SE_EN_FROG_PUNCH1); } } else { this->collider.base.atFlags &= ~AT_ON; @@ -1113,9 +1115,9 @@ void EnPametfrog_SetupDamage(EnPametfrog* this) { this->timer = 20; this->collider.base.atFlags &= ~AT_ON; this->collider.base.acFlags &= ~AC_ON; - this->actor.speedXZ = 10.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DAMAGE); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->actor.speed = 10.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_FROG_DAMAGE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 20); func_800BE5CC(&this->actor, &this->collider, 0); this->actor.shape.rot.y = BINANG_ROT180(this->actor.world.rot.y); this->actionFunc = EnPametfrog_Damage; @@ -1124,7 +1126,7 @@ void EnPametfrog_SetupDamage(EnPametfrog* this) { void EnPametfrog_Damage(EnPametfrog* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); this->timer--; - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); if (this->timer == 0) { if (this->actor.colChkInfo.health > 0) { EnPametfrog_SetupJumpToLink(this); @@ -1141,7 +1143,7 @@ void EnPametfrog_SetupStun(EnPametfrog* this) { } this->collider.base.atFlags &= ~AT_ON; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->actor.colChkInfo.health == 0) { this->collider.base.acFlags &= ~AC_ON; @@ -1168,10 +1170,10 @@ void EnPametfrog_SetupCallSnapper(EnPametfrog* this, PlayState* play) { s16 yawDiff; Animation_MorphToPlayOnce(&this->skelAnime, &gGekkoCallAnim, 3.0f); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_GREET); + Actor_PlaySfx(&this->actor, NA_SE_EN_FROG_GREET); this->actor.flags &= ~ACTOR_FLAG_1; this->actor.colChkInfo.health = 6; - this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->actor.world.rot.y = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; if (yawDiff > 0) { this->actor.world.rot.y -= 0x2000; @@ -1209,7 +1211,7 @@ void EnPametfrog_SetupSnapperSpawn(EnPametfrog* this, PlayState* play) { subCamAt.x = this->actor.child->world.pos.x; subCamAt.z = this->actor.child->world.pos.z; subCamAt.y = this->actor.child->floorHeight + 50.0f; - if ((s16)(Actor_YawToPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y) > 0) { + if ((s16)(Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y) > 0) { yaw = this->actor.child->shape.rot.y - 0x1000; } else { yaw = this->actor.child->shape.rot.y + 0x1000; @@ -1222,10 +1224,10 @@ void EnPametfrog_SetupSnapperSpawn(EnPametfrog* this, PlayState* play) { // Zooms in on Snapper spawn point Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye); - this->quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); + this->quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); Quake_SetSpeed(this->quakeIndex, 18000); - Quake_SetQuakeValues(this->quakeIndex, 2, 0, 0, 0); - Quake_SetCountdown(this->quakeIndex, 15); + Quake_SetPerturbations(this->quakeIndex, 2, 0, 0, 0); + Quake_SetDuration(this->quakeIndex, 15); Rumble_Request(this->actor.xyzDistToPlayerSq, 120, 20, 10); @@ -1247,12 +1249,12 @@ void EnPametfrog_SnapperSpawn(EnPametfrog* this, PlayState* play) { void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, PlayState* play) { this->actor.params = GEKKO_GET_SNAPPER; - Quake_Remove(this->quakeIndex); + Quake_RemoveRequest(this->quakeIndex); - this->quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + this->quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(this->quakeIndex, 20000); - Quake_SetQuakeValues(this->quakeIndex, 17, 0, 0, 0); - Quake_SetCountdown(this->quakeIndex, 12); + Quake_SetPerturbations(this->quakeIndex, 17, 0, 0, 0); + Quake_SetDuration(this->quakeIndex, 12); Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150); @@ -1285,7 +1287,7 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, PlayState* play) { } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_ICE) { EnPametfrog_Freeze(this); this->freezeTimer = 80; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0x50); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 80); EnPametfrog_SetupStun(this); } else { EnPametfrog_Thaw(this, play); @@ -1341,7 +1343,9 @@ void EnPametfrog_Update(Actor* thisx, PlayState* play) { if (this->actor.gravity < -0.1f) { Actor_MoveWithGravity(&this->actor); arg3 = this->actionFunc == EnPametfrog_FallInAir ? 3.0f : 15.0f; - Actor_UpdateBgCheckInfo(play, &this->actor, 25.0f, arg3, 3.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 25.0f, arg3, 3.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); } else if (this->freezeTimer == 0) { Actor_MoveWithoutGravity(&this->actor); this->actor.floorHeight = this->actor.world.pos.y; diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h index 9ae2f76df..90bc0cb1b 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h @@ -30,7 +30,7 @@ typedef struct EnPametfrog { /* 0x2AC */ u8 drawDmgEffType; /* 0x2AD */ u8 wallPauseTimer; // Gekko stops 10 times along wall/ceiling after being blown off of Snapper /* 0x2AE */ u8 unk_2AE; // True/False - /* 0x2B0 */ s16 cutscene; + /* 0x2B0 */ s16 csId; /* 0x2B2 */ s16 params; /* 0x2B4 */ s16 quakeIndex; /* 0x2B6 */ s16 timer; diff --git a/src/overlays/actors/ovl_En_Paper/z_en_paper.c b/src/overlays/actors/ovl_En_Paper/z_en_paper.c index a3f158cbd..7659b524b 100644 --- a/src/overlays/actors/ovl_En_Paper/z_en_paper.c +++ b/src/overlays/actors/ovl_En_Paper/z_en_paper.c @@ -47,7 +47,7 @@ void EnPaper_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); this->timer = 70; this->windForce = sUnitVecZ; - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); EnPaper_SetupSpreadConfettiGroup(this); } diff --git a/src/overlays/actors/ovl_En_Part/z_en_part.c b/src/overlays/actors/ovl_En_Part/z_en_part.c index 527a91b3d..2a12b9af8 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.c +++ b/src/overlays/actors/ovl_En_Part/z_en_part.c @@ -52,7 +52,7 @@ void func_80865390(EnPart* this, PlayState* play) { this->actor.world.rot.y = this->actor.parent->shape.rot.y + 0x8000; this->unk146 = 100; this->actor.velocity.y = 7.0f; - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; this->actor.gravity = -1.0f; break; } 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 3e2fdcfac..2f4678b8d 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -234,7 +234,7 @@ void func_80897170(EnPeehat* this) { this->drawDmgEffAlpha = 1.0f; this->colliderSphere.base.colType = COLTYPE_HIT3; this->unk_2B0 = 80; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 80); } void func_808971DC(EnPeehat* this, PlayState* play) { @@ -283,7 +283,7 @@ void func_80897390(EnPeehat* this, PlayState* play) { } this->unk_2B0 = 8; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIHAT_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_PIHAT_DAMAGE); } void func_80897498(EnPeehat* this) { @@ -327,7 +327,7 @@ void func_80897648(EnPeehat* this) { Animation_GetLastFrame(&object_ph_Anim_0009C4), ANIMMODE_ONCE, 0.0f); } this->unk_2B0 = 16; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIHAT_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_PIHAT_UP); this->actionFunc = func_808976DC; } @@ -378,7 +378,7 @@ void func_80897864(EnPeehat* this) { void func_80897910(EnPeehat* this, PlayState* play) { Player* player = GET_PLAYER(play); - Math_StepToF(&this->actor.speedXZ, 3.0f, 0.25f); + Math_StepToF(&this->actor.speed, 3.0f, 0.25f); Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 80.0f, 3.0f); SkelAnime_Update(&this->skelAnime); if (!gSaveContext.save.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { @@ -396,7 +396,7 @@ void func_80897910(EnPeehat* this, PlayState* play) { void func_80897A34(EnPeehat* this) { Animation_PlayLoop(&this->skelAnime, &object_ph_Anim_0005C4); this->unk_2B0 = 30; - this->actor.speedXZ = 5.3f; + this->actor.speed = 5.3f; this->colliderTris.base.atFlags |= AT_ON; this->actionFunc = func_80897A94; } @@ -432,10 +432,10 @@ void func_80897A94(EnPeehat* this, PlayState* play) { 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)) { + } else if ((this->colliderCylinder.base.acFlags & AC_HIT) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 40, 7, 0); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); - if (!(this->actor.bgCheckFlags & 1)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_PIHAT_SM_DEAD); } Actor_Kill(&this->actor); @@ -449,7 +449,7 @@ void func_80897A94(EnPeehat* this, PlayState* play) { 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), + if ((BINANG_SUB(Actor_WorldYawTowardActor(&this->actor, this->colliderCylinder.base.oc), this->actor.world.rot.y)) > 0) { this->actor.world.rot.y -= 0x2000; } else { @@ -469,12 +469,12 @@ void func_80897D48(EnPeehat* this, PlayState* play) { Vec3f sp34; Math_StepToF(&this->actor.shape.yOffset, -1000.0f, 50.0f); - Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f); + Math_StepToF(&this->actor.speed, 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); + Actor_PlaySfx(&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) { @@ -490,7 +490,7 @@ void func_80897D48(EnPeehat* this, PlayState* play) { void func_80897EAC(EnPeehat* this) { Animation_PlayLoop(&this->skelAnime, &object_ph_Anim_0005C4); - this->actor.speedXZ = Rand_ZeroFloat(0.5f) + 2.5f; + this->actor.speed = 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; @@ -512,7 +512,7 @@ void func_80897F44(EnPeehat* this, PlayState* play) { this->unk_2B0--; if (this->unk_2B0 <= 0) { - this->actor.speedXZ = Rand_ZeroFloat(0.5f) + 2.5f; + this->actor.speed = Rand_ZeroFloat(0.5f) + 2.5f; this->unk_2B0 = Rand_ZeroFloat(10.0f) + 10.0f; this->unk_2B6 = randPlusMinusPoint5Scaled(1000.0f); } @@ -536,7 +536,7 @@ void func_80897F44(EnPeehat* this, PlayState* play) { void func_80898124(EnPeehat* this) { this->actionFunc = func_80898144; - this->actor.speedXZ = 2.5f; + this->actor.speed = 2.5f; } void func_80898144(EnPeehat* this, PlayState* play) { @@ -574,7 +574,7 @@ void func_80898144(EnPeehat* this, PlayState* play) { void func_808982E0(EnPeehat* this) { Animation_MorphToPlayOnce(&this->skelAnime, &object_ph_Anim_000844, -4.0f); - this->actor.speedXZ = -9.0f; + this->actor.speed = -9.0f; this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actionFunc = func_80898338; } @@ -583,7 +583,7 @@ void func_80898338(EnPeehat* this, PlayState* play) { this->unk_2B4 += this->unk_2B2; SkelAnime_Update(&this->skelAnime); - if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f)) { + if (Math_StepToF(&this->actor.speed, 0.0f, 0.5f)) { if (this->actor.params != 0) { func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 40, 7, 0); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_EN_EXTINCT); @@ -599,7 +599,7 @@ void func_80898338(EnPeehat* this, PlayState* play) { void func_80898414(EnPeehat* this) { func_800BE568(&this->actor, &this->colliderSphere); this->unk_2B2 = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_80898454; } @@ -622,11 +622,11 @@ void func_80898454(EnPeehat* this, PlayState* play) { void func_808984E0(EnPeehat* this) { Animation_MorphToPlayOnce(&this->skelAnime, &object_ph_Anim_000844, -4.0f); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIHAT_DAMAGE); + Actor_PlaySfx(&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->actor.speed = 10.0f; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 14); this->colliderSphere.base.acFlags &= ~AC_ON; this->unk_2C4 = 0.0f; if (this->actor.colChkInfo.health == 0) { @@ -640,7 +640,7 @@ void func_80898594(EnPeehat* this, PlayState* play) { 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); + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); this->unk_2B0--; if (this->unk_2B0 <= 0) { if (this->actor.colChkInfo.health == 0) { @@ -697,16 +697,16 @@ void func_8089874C(EnPeehat* this, PlayState* play) { 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); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->drawDmgEffScale = 1.1f; this->drawDmgEffAlpha = 2.0f; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; 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); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 200, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); func_80898414(this); } else if (this->actor.colChkInfo.damageEffect == 3) { func_80897170(this); @@ -750,7 +750,7 @@ void EnPeehat_Update(Actor* thisx, PlayState* play2) { func_8089874C(this, play); } Actor_MoveWithGravity(thisx); - Actor_UpdateBgCheckInfo(play, thisx, 25.0f, 30.0f, 30.0f, 5); + Actor_UpdateBgCheckInfo(play, thisx, 25.0f, 30.0f, 30.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); @@ -930,7 +930,7 @@ void EnPeehat_Draw(Actor* thisx, PlayState* play) { SkelAnime_DrawOpa(play, 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)) { + if ((this->actor.speed != 0.0f) || (this->actor.velocity.y != 0.0f)) { Matrix_MultVecZ(4500.0f, &sp40); Matrix_MultVecZ(-4500.0f, &sp4C); Matrix_MultVecX(4500.0f, &sp58); 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 c2846a26b..088d5c8a4 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -789,43 +789,43 @@ Actor* func_80AF8040(EnPm* this, PlayState* play) { return actor; } -s32 func_80AF80F4(EnPm* this, s16 arg1) { +s32 func_80AF80F4(EnPm* this, s16 csId) { s32 ret = false; - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(arg1); - } else if (ActorCutscene_GetCanPlayNext(arg1)) { - ActorCutscene_StartAndSetUnkLinkFields(arg1, &this->actor); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(csId); + } else if (CutsceneManager_IsNext(csId)) { + CutsceneManager_StartWithPlayerCs(csId, &this->actor); ret = true; } else { - ActorCutscene_SetIntentToPlay(arg1); + CutsceneManager_Queue(csId); } return ret; } -s16 func_80AF8170(EnPm* this, s32 arg1) { +s16 func_80AF8170(EnPm* this, s32 numCutscenes) { s32 i; - s16 cs = -1; + s16 csId = CS_ID_NONE; if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - cs = this->actor.child->cutscene; + csId = this->actor.child->csId; - for (i = 0; i < arg1; i++) { - cs = ActorCutscene_GetAdditionalCutscene(cs); + for (i = 0; i < numCutscenes; i++) { + csId = CutsceneManager_GetAdditionalCsId(csId); } } - return cs; + return csId; } s32 func_80AF81E8(EnPm* this, PlayState* play) { s32 pad; - s16 sp2A = func_80AF8170(this, 0); + s16 csId = func_80AF8170(this, 0); s32 ret = false; switch (this->unk_378) { case 0: - if (!func_80AF80F4(this, sp2A)) { + if (!func_80AF80F4(this, csId)) { break; } @@ -833,7 +833,8 @@ s32 func_80AF81E8(EnPm* this, PlayState* play) { case 4: case 6: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)), + this->actor.child); } this->unk_378++; ret = true; @@ -843,16 +844,16 @@ s32 func_80AF81E8(EnPm* this, PlayState* play) { case 3: case 5: if (CHECK_WEEKEVENTREG(WEEKEVENTREG_86_08) && (this->unk_378 == 3)) { - ActorCutscene_Stop(sp2A); + CutsceneManager_Stop(csId); } else { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)), &this->actor); } this->unk_378++; ret = true; break; case 7: - ActorCutscene_Stop(sp2A); + CutsceneManager_Stop(csId); this->unk_378++; ret = true; break; @@ -862,12 +863,12 @@ s32 func_80AF81E8(EnPm* this, PlayState* play) { s32 func_80AF8348(EnPm* this, PlayState* play) { s32 pad; - s16 sp2A = func_80AF8170(this, 0); + s16 csId = func_80AF8170(this, 0); s32 ret = false; switch (this->unk_378) { case 0: - if (!func_80AF80F4(this, sp2A)) { + if (!func_80AF80F4(this, csId)) { break; } @@ -875,7 +876,7 @@ s32 func_80AF8348(EnPm* this, PlayState* play) { case 4: case 6: case 8: - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)), &this->actor); this->unk_378++; ret = true; break; @@ -885,14 +886,15 @@ s32 func_80AF8348(EnPm* this, PlayState* play) { case 5: case 7: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)), + this->actor.child); } this->unk_378++; ret = true; break; case 9: - ActorCutscene_Stop(sp2A); + CutsceneManager_Stop(csId); this->unk_378++; ret = true; break; @@ -1017,20 +1019,20 @@ s32 func_80AF86F0(EnPm* this, PlayState* play) { s32 func_80AF87C4(EnPm* this, PlayState* play) { s32 ret = false; - if ((play->csCtx.state != 0) && (play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 9) && + if ((play->csCtx.state != CS_STATE_IDLE) && (play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 9) && (play->curSpawn == 1)) { if (!this->unk_380) { func_80AF7E98(this, 0); this->unk_258 = 255; this->unk_380 = true; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; this->actor.gravity = -1.0f; } ret = true; } else if (this->unk_380) { this->unk_258 = 0; this->unk_380 = false; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } return ret; } @@ -1311,7 +1313,7 @@ s32 func_80AF91E8(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { this->unk_356 &= ~8; this->unk_356 &= ~0x10; if (this->unk_258 == 27) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROOM_CARTAIN); + Actor_PlaySfx(&this->actor, NA_SE_EV_ROOM_CARTAIN); Flags_UnsetSwitch(play, 0); } @@ -1431,7 +1433,7 @@ s32 func_80AF95E8(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { switch (scheduleOutput->result) { case 27: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROOM_CARTAIN); + Actor_PlaySfx(&this->actor, NA_SE_EV_ROOM_CARTAIN); Flags_SetSwitch(play, 0); this->unk_36C = 20; SubS_UpdateFlags(&this->unk_356, 3, 7); @@ -1717,7 +1719,7 @@ s32 func_80AF9D04(EnPm* this, PlayState* play) { Lib_Vec3f_TranslateAndRotateY(&this->unk_26C, this->actor.world.rot.y, &sp38, &this->actor.world.pos); this->unk_36E += this->timePathTimeSpeed; if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_POSTMAN_WALK); } } return false; @@ -1774,7 +1776,7 @@ s32 func_80AF9E7C(EnPm* this, PlayState* play) { this->timePathTargetPos = timePathTargetPos; } else if ((this->unk_258 != 91) && (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_POSTMAN_WALK); } if ((this->unk_356 & 0x10) && (this->unk_258 == 90)) { @@ -1820,7 +1822,7 @@ s32 func_80AFA170(EnPm* this, PlayState* play) { } if ((this->unk_384 == 11) && Animation_OnFrame(&this->skelAnime, 8.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMACHINE_HIT_OPEN); + Actor_PlaySfx(&this->actor, NA_SE_EV_POSTMACHINE_HIT_OPEN); } if (this->unk_258 == 19) { @@ -1865,7 +1867,7 @@ s32 func_80AFA334(EnPm* this, PlayState* play) { case 21: case 22: if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_NP_SLEEP_OUT); + Actor_PlaySfx(&this->actor, NA_SE_VO_NP_SLEEP_OUT); } break; @@ -2042,9 +2044,9 @@ void func_80AFA5FC(EnPm* this, PlayState* play) { void func_80AFA724(EnPm* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_POSTMAN_WALK); } } @@ -2089,7 +2091,7 @@ void EnPm_Update(Actor* thisx, PlayState* play) { func_80AF8AC8(this); func_8013C964(&this->actor, play, this->unk_368, 30.0f, this->unk_394, this->unk_356 & 7); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); func_80AF7F68(this, play); } } @@ -2112,7 +2114,7 @@ void EnPm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, switch (limbIndex) { case 15: - if (ActorCutscene_GetCurrentIndex() == -1) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_NONE) { Matrix_MultVec3f(&gZeroVec3f, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } 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 a9fcf95e3..beffe3bb8 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 @@ -6,7 +6,6 @@ #include "z_en_po_fusen.h" #include "overlays/actors/ovl_En_Ma4/z_en_ma4.h" -#include "objects/object_po_fusen/object_po_fusen.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000 | ACTOR_FLAG_80000000) @@ -17,7 +16,7 @@ void EnPoFusen_Destroy(Actor* thisx, PlayState* play); void EnPoFusen_Update(Actor* thisx, PlayState* play); void EnPoFusen_Draw(Actor* thisx, PlayState* play); -u16 EnPoFusen_CheckParent(EnPoFusen* this, PlayState* play); +s32 EnPoFusen_CheckParent(EnPoFusen* this, PlayState* play); void EnPoFusen_InitNoFuse(EnPoFusen* this); void EnPoFusen_InitFuse(EnPoFusen* this); void EnPoFusen_Pop(EnPoFusen* this, PlayState* play); @@ -57,44 +56,49 @@ static ColliderSphereInit sSphereInit = { { 0, { { 0, 0, 0 }, 200 }, 100 }, }; +typedef enum { + /* 0x0 */ POE_BALLOON_DMGEFF_NONE, + /* 0xF */ POE_BALLOON_DMGEFF_POP = 0xF, +} PoeBalloonDamageEffect; + static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(0, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(0, 0x0), - /* Zora boomerang */ DMG_ENTRY(0, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x0), - /* Goron punch */ DMG_ENTRY(0, 0x0), - /* Sword */ DMG_ENTRY(0, 0x0), - /* Goron pound */ DMG_ENTRY(0, 0x0), - /* Fire arrow */ DMG_ENTRY(1, 0xF), - /* Ice arrow */ DMG_ENTRY(1, 0xF), - /* Light arrow */ DMG_ENTRY(1, 0xF), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0x0), - /* Deku bubble */ DMG_ENTRY(0, 0x0), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(0, 0x0), - /* Zora punch */ DMG_ENTRY(0, 0x0), - /* Spin attack */ DMG_ENTRY(0, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(0, 0x0), + /* Deku Nut */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, POE_BALLOON_DMGEFF_POP), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(1, POE_BALLOON_DMGEFF_POP), + /* Ice arrow */ DMG_ENTRY(1, POE_BALLOON_DMGEFF_POP), + /* Light arrow */ DMG_ENTRY(1, POE_BALLOON_DMGEFF_POP), + /* Goron spikes */ DMG_ENTRY(1, POE_BALLOON_DMGEFF_POP), + /* Deku spin */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Normal shield */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(0, POE_BALLOON_DMGEFF_NONE), }; void EnPoFusen_Init(Actor* thisx, PlayState* play) { EnPoFusen* this = THIS; - f32 heightTemp; + f32 flyingHeightMin; this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = 0.007f; this->actor.targetMode = 6; @@ -103,38 +107,36 @@ void EnPoFusen_Init(Actor* thisx, PlayState* play) { Collider_InitSphere(play, &this->collider); Collider_SetSphere(play, &this->collider, &this->actor, &sSphereInit); - if (0) {} this->collider.dim.worldSphere.radius = 40; - SkelAnime_InitFlex(play, &this->anime, &object_po_fusen_Skel_0024F0, &object_po_fusen_Anim_000040, this->jointTable, - this->morphTable, 10); + SkelAnime_InitFlex(play, &this->anime, &gPoeBalloonSkel, &gPoeBalloonEmptyAnim, this->jointTable, this->morphTable, + POE_BALLOON_LIMB_MAX); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); if (!EnPoFusen_CheckParent(this, play)) { Actor_Kill(&this->actor); } - heightTemp = this->actor.floorHeight + 90.0f; - if (this->actor.home.pos.y < heightTemp) { - this->actor.home.pos.y = heightTemp; + flyingHeightMin = this->actor.floorHeight + 90.0f; + if (this->actor.home.pos.y < flyingHeightMin) { + this->actor.home.pos.y = flyingHeightMin; } this->randScaleChange = (Rand_Next() % 0xFFFE) - 0x7FFF; this->randYRotChange = (Rand_Next() % 0x4B0) - 0x258; this->avgBaseRotation = 0x10000 / 12; - this->limb3Rot = 0; + this->limbRotYRightUpperArm = 0; this->limb46Rot = 0; this->limb57Rot = 0; - this->limb8Rot = 0; - this->limb9Rot = 0x71C; + this->limbRotLeftHand = 0; + this->limbRotChainAndLantern = 0x71C; this->randBaseRotChange = 0; - if (ENPOFUSEN_IS_FUSE_TYPE(&this->actor)) { + if (POE_BALLOON_IS_FUSE_TYPE(&this->actor)) { EnPoFusen_InitFuse(this); - return; + } else { + EnPoFusen_InitNoFuse(this); } - - EnPoFusen_InitNoFuse(this); } void EnPoFusen_Destroy(Actor* thisx, PlayState* play) { @@ -143,26 +145,28 @@ void EnPoFusen_Destroy(Actor* thisx, PlayState* play) { Collider_DestroySphere(play, &this->collider); } -u16 EnPoFusen_CheckParent(EnPoFusen* this, PlayState* play) { - Actor* actorPtr; +/** + * Search for Romani's actor, beacuse it's PoFusen's job to update her actor when the balloon is popped. + */ +s32 EnPoFusen_CheckParent(EnPoFusen* this, PlayState* play) { + Actor* actorIter = play->actorCtx.actorLists[ACTORCAT_NPC].first; - actorPtr = play->actorCtx.actorLists[ACTORCAT_NPC].first; - if (ENPOFUSEN_IS_FUSE_TYPE(&this->actor)) { + if (POE_BALLOON_IS_FUSE_TYPE(&this->actor)) { return true; } - while (actorPtr != NULL) { - if (actorPtr->id == ACTOR_EN_MA4) { - this->actor.parent = actorPtr; + while (actorIter != NULL) { + if (actorIter->id == ACTOR_EN_MA4) { + this->actor.parent = actorIter; return true; } - actorPtr = actorPtr->next; + actorIter = actorIter->next; } return false; } -u16 EnPoFusen_CheckCollision(EnPoFusen* this, PlayState* play) { +s32 EnPoFusen_CheckCollision(EnPoFusen* this, PlayState* play) { if (this->actionFunc == EnPoFusen_IdleFuse) { return false; } @@ -171,7 +175,7 @@ u16 EnPoFusen_CheckCollision(EnPoFusen* this, PlayState* play) { this->collider.dim.worldSphere.center.y = this->actor.world.pos.y + 20.0f; this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; - if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { + if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == POE_BALLOON_DMGEFF_POP)) { this->collider.base.acFlags &= ~AC_HIT; return true; } @@ -191,7 +195,6 @@ void EnPoFusen_Idle(EnPoFusen* this, PlayState* play) { f32 shadowScaleTmp; f32 shadowAlphaTmp; f32 heightOffset; - f32 f255 = 255.0f; this->actor.world.pos = this->actor.home.pos; this->randScaleChange += 0x190; @@ -203,30 +206,30 @@ void EnPoFusen_Idle(EnPoFusen* this, PlayState* play) { this->actor.world.pos.y += heightOffset; this->actor.shape.rot.z = (Math_SinS(this->randBaseRotChange) * 910.0f); - if ((this->randScaleChange < 0x4000) && (this->randScaleChange >= -0x3FFF)) { - Math_SmoothStepToS(&this->limb9Rot, 0x38E, 0x14, 0xBB8, 0x64); + if ((this->randScaleChange < 0x4000) && (this->randScaleChange > -0x4000)) { + Math_SmoothStepToS(&this->limbRotChainAndLantern, 0x38E, 0x14, 0xBB8, 0x64); } else { - Math_SmoothStepToS(&this->limb9Rot, 0x71C, 0x8, 0xBB8, 0x64); + Math_SmoothStepToS(&this->limbRotChainAndLantern, 0x71C, 0x8, 0xBB8, 0x64); } - this->avgBaseRotation = this->limb9Rot * 3; - this->limb3Rot = (Math_SinS(this->randBaseRotChange + 0x38E3) * this->avgBaseRotation); + this->avgBaseRotation = this->limbRotChainAndLantern * 3; + this->limbRotYRightUpperArm = (Math_SinS(this->randBaseRotChange + 0x38E3) * this->avgBaseRotation); this->limb46Rot = (Math_SinS(this->randBaseRotChange) * this->avgBaseRotation); this->limb57Rot = (Math_SinS(this->randBaseRotChange - 0x38E3) * this->avgBaseRotation); - this->limb8Rot = (Math_SinS(this->randBaseRotChange - 0x71C6) * this->avgBaseRotation); + this->limbRotLeftHand = (Math_SinS(this->randBaseRotChange - 0x71C6) * this->avgBaseRotation); shadowScaleTmp = ((1.0f - Math_SinS(this->randScaleChange)) * 10.0f) + 50.0f; shadowAlphaTmp = ((1.0f - Math_SinS(this->randScaleChange)) * 75.0f) + 100.0f; this->actor.shape.shadowScale = shadowScaleTmp; - this->actor.shape.shadowAlpha = (shadowAlphaTmp > f255) ? (u8)f255 : (u8)shadowAlphaTmp; + this->actor.shape.shadowAlpha = CLAMP_MAX(shadowAlphaTmp, 255.0f); } void EnPoFusen_IncrementRomaniPop(EnPoFusen* this) { Actor* parent = this->actor.parent; - EnMa4* romani; if ((parent != NULL) && (parent->id == ACTOR_EN_MA4)) { - romani = (EnMa4*)parent; + EnMa4* romani = (EnMa4*)parent; + romani->poppedBalloonCounter++; } @@ -237,13 +240,14 @@ void EnPoFusen_IncrementRomaniPop(EnPoFusen* this) { void EnPoFusen_Pop(EnPoFusen* this, PlayState* play) { Actor_Spawn(&play->actorCtx, play, 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); - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfx(&this->actor, NA_SE_IT_BOMB_EXPLOSION); Actor_Kill(&this->actor); } void EnPoFusen_InitFuse(EnPoFusen* this) { s16 rotZ = this->actor.shape.rot.z; - this->fuse = ENPOFUSEN_GET_FUSE_LEN(&this->actor); + + this->fuse = POE_BALLOON_GET_FUSE_LEN(&this->actor); this->actor.shape.rot.z = 0; this->randScaleChange = rotZ & 0xFFFF; this->actionFunc = EnPoFusen_IdleFuse; @@ -258,6 +262,7 @@ void EnPoFusen_IdleFuse(EnPoFusen* this, PlayState* play) { void EnPoFusen_Update(Actor* thisx, PlayState* play) { EnPoFusen* this = THIS; + this->actionFunc(this, play); if (EnPoFusen_CheckCollision(this, play)) { EnPoFusen_IncrementRomaniPop(this); @@ -266,39 +271,38 @@ void EnPoFusen_Update(Actor* thisx, PlayState* play) { s32 EnPoFusen_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnPoFusen* this = THIS; - f32 zScale; - f32 yScale; - f32 xScale; - s16 pad; - s16 zRot; - s16 pad2; - s16 xRot; - if (limbIndex == 2) { - zScale = (Math_CosS(this->randScaleChange) * 0.08f) + 1.0f; - xScale = zScale; - if (!zScale) {} + if (limbIndex == POE_BALLOON_LIMB_BODY) { + f32 zScale = (Math_CosS(this->randScaleChange) * 0.08f) + 1.0f; + f32 yScale; + f32 xScale = zScale; + s16 pad; + s16 zRot; + s16 pad2; + s16 xRot; + yScale = (Math_SinS(this->randScaleChange) * 0.08f) + 1.0f; - yScale = yScale * yScale; + yScale = SQ(yScale); xRot = ((Math_SinS(this->randXZRotChange) * 2730.0f)); zRot = ((Math_CosS(this->randXZRotChange) * 2730.0f)); Matrix_RotateZYX(xRot, 0, zRot, MTXMODE_APPLY); Matrix_Scale(xScale, yScale, zScale, MTXMODE_APPLY); Matrix_RotateZS(-zRot, MTXMODE_APPLY); Matrix_RotateXS(-xRot, MTXMODE_APPLY); - } else if (limbIndex == 3) { - rot->y += this->limb3Rot; - } else if (limbIndex == 6) { + + } else if (limbIndex == POE_BALLOON_RIGHT_UPPER_ARM) { + rot->y += this->limbRotYRightUpperArm; + } else if (limbIndex == POE_BALLOON_LEFT_UPPER_ARM) { rot->y += this->limb46Rot; - } else if (limbIndex == 4) { + } else if (limbIndex == POE_BALLOON_RIGHT_FOREARM) { rot->z += this->limb46Rot; - } else if ((limbIndex == 5) || (limbIndex == 7)) { + } else if ((limbIndex == POE_BALLOON_RIGHT_HAND) || (limbIndex == POE_BALLOON_LEFT_FOREARM)) { rot->z += this->limb57Rot; - } else if (limbIndex == 8) { - rot->z += this->limb8Rot; - } else if (limbIndex == 9) { - rot->y += (s16)(this->limb9Rot * Math_SinS(this->randBaseRotChange)); - rot->z += (s16)(this->limb9Rot * Math_CosS(this->randBaseRotChange)); + } else if (limbIndex == POE_BALLOON_LEFT_HAND) { + rot->z += this->limbRotLeftHand; + } else if (limbIndex == POE_BALLOON_LIMB_CHAIN_AND_LANTERN) { + rot->y += (s16)(this->limbRotChainAndLantern * Math_SinS(this->randBaseRotChange)); + rot->z += (s16)(this->limbRotChainAndLantern * Math_CosS(this->randBaseRotChange)); } return false; } @@ -311,6 +315,7 @@ void EnPoFusen_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { void EnPoFusen_Draw(Actor* thisx, PlayState* play) { EnPoFusen* this = THIS; + func_8012C28C(play->state.gfxCtx); SkelAnime_DrawTransformFlexOpa(play, this->anime.skeleton, this->anime.jointTable, this->anime.dListCount, EnPoFusen_OverrideLimbDraw, EnPoFusen_PostLimbDraw, EnPoFusen_TransformLimbDraw, diff --git a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h index 740d65968..506f046d0 100644 --- a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h +++ b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.h @@ -2,11 +2,13 @@ #define Z_EN_PO_FUSEN_H #include "global.h" +#include "objects/object_po_fusen/object_po_fusen.h" struct EnPoFusen; -#define ENPOFUSEN_GET_FUSE_LEN(thisx) ((thisx)->params & 0x3FF) -#define ENPOFUSEN_IS_FUSE_TYPE(thisx) ((thisx)->params & 0x8000) +// The version used in the credits, where we see romani shoot three in a row, are on timer, this is the fuse length. +#define POE_BALLOON_GET_FUSE_LEN(thisx) ((thisx)->params & 0x3FF) +#define POE_BALLOON_IS_FUSE_TYPE(thisx) ((thisx)->params & 0x8000) typedef void (*EnPoFusenActionFunc)(struct EnPoFusen*, PlayState*); @@ -15,17 +17,17 @@ typedef struct EnPoFusen { /* 0x144 */ SkelAnime anime; /* 0x188 */ EnPoFusenActionFunc actionFunc; /* 0x18C */ ColliderSphere collider; - /* 0x1E4 */ Vec3s jointTable[0xA]; - /* 0x220 */ Vec3s morphTable[0xA]; + /* 0x1E4 */ Vec3s jointTable[POE_BALLOON_LIMB_MAX]; + /* 0x220 */ Vec3s morphTable[POE_BALLOON_LIMB_MAX]; /* 0x25C */ s16 randScaleChange; /* 0x25E */ s16 randXZRotChange; /* 0x260 */ s16 randYRotChange; /* 0x262 */ s16 avgBaseRotation; - /* 0x264 */ s16 limb3Rot; + /* 0x264 */ s16 limbRotYRightUpperArm; /* 0x266 */ s16 limb46Rot; /* 0x268 */ s16 limb57Rot; - /* 0x26A */ s16 limb8Rot; - /* 0x26C */ s16 limb9Rot; + /* 0x26A */ s16 limbRotLeftHand; + /* 0x26C */ s16 limbRotChainAndLantern; /* 0x26E */ s16 randBaseRotChange; /* 0x270 */ s16 fuse; } EnPoFusen; // size = 0x274 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 a89a55d9e..53ae73479 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 @@ -7,7 +7,7 @@ #include "z_en_po_sisters.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_4000) #define THIS ((EnPoSisters*)thisx) @@ -97,46 +97,46 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit sColChkInfoInit = { 6, 25, 60, 50 }; typedef enum { - /* 0x0 */ POSISTERS_DAMAGEEFFECT_NOEFFECT, - /* 0x1 */ POSISTERS_DAMAGEEFFECT_UNKDMG12, // set in DamageTable, but unused - /* 0x4 */ POSISTERS_DAMAGEEFFECT_LIGHTARROWS = 0x4, - /* 0xE */ POSISTERS_DAMAGEEFFECT_SPINATTACK = 0xE, - /* 0xF */ POSISTERS_DAMAGEEFFECT_DEKUNUT = 0xF, -} PoSisterDamageEffect; + /* 0x0 */ POE_SISTERS_DMGEFF_NONE, + /* 0x1 */ POE_SISTERS_DMGEFF_UNKDMG12, // set in DamageTable, but unused + /* 0x4 */ POE_SISTERS_DMGEFF_LIGHTARROWS = 0x4, + /* 0xE */ POE_SISTERS_DMGEFF_SPINATTACK = 0xE, + /* 0xF */ POE_SISTERS_DMGEFF_DEKUNUT = 0xF, +} PoeSisterDamageEffect; static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_DEKUNUT), - /* Deku Stick */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Horse trample */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Explosives */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Zora boomerang */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Normal arrow */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Hookshot */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Goron punch */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Sword */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Goron pound */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Fire arrow */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Ice arrow */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Light arrow */ DMG_ENTRY(2, POSISTERS_DAMAGEEFFECT_LIGHTARROWS), - /* Goron spikes */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Deku spin */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Deku bubble */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Deku launch */ DMG_ENTRY(2, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_UNKDMG12), - /* Zora barrier */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Normal shield */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Light ray */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Thrown object */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Zora punch */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Spin attack */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_SPINATTACK), - /* Sword beam */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Normal Roll */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Unblockable */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, POSISTERS_DAMAGEEFFECT_NOEFFECT), - /* Powder Keg */ DMG_ENTRY(1, POSISTERS_DAMAGEEFFECT_NOEFFECT), + /* Deku Nut */ DMG_ENTRY(0, POE_SISTERS_DMGEFF_DEKUNUT), + /* Deku Stick */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, POE_SISTERS_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(0, POE_SISTERS_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), + /* Light arrow */ DMG_ENTRY(2, POE_SISTERS_DMGEFF_LIGHTARROWS), + /* Goron spikes */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, POE_SISTERS_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, POE_SISTERS_DMGEFF_UNKDMG12), + /* Zora barrier */ DMG_ENTRY(0, POE_SISTERS_DMGEFF_NONE), + /* Normal shield */ DMG_ENTRY(0, POE_SISTERS_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, POE_SISTERS_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_SPINATTACK), + /* Sword beam */ DMG_ENTRY(0, POE_SISTERS_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, POE_SISTERS_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, POE_SISTERS_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, POE_SISTERS_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, POE_SISTERS_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, POE_SISTERS_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, POE_SISTERS_DMGEFF_NONE), }; static InitChainEntry sInitChain[] = { @@ -146,15 +146,15 @@ static InitChainEntry sInitChain[] = { // clang-format off // PoSisters have their own flags variable for cross function behavior detection -#define POSISTERS_FLAG_CLEAR (0) -#define POSISTERS_FLAG_CHECK_AC (1 << 0) -#define POSISTERS_FLAG_UPDATE_SHAPE_ROT (1 << 1) -#define POSISTERS_FLAG_CHECK_Z_TARGET (1 << 2) // meg doesnt go invis if you ztarget her for too long -#define POSISTERS_FLAG_MATCH_PLAYER_HEIGHT (1 << 3) // the po is attempting to level with player's height -#define POSISTERS_FLAG_UPDATE_BGCHECK_INFO (1 << 4) -#define POSISTERS_FLAG_UPDATE_FIRES (1 << 5) // firePos updated to match limb in PostLimbDraw -#define POSISTERS_FLAG_REAL_MEG_ROTATION (1 << 6) // real meg rotates different than her clones for one cycle -#define POSISTERS_FLAG_DRAW_TORCH (1 << 7) +#define POE_SISTERS_FLAG_CLEAR (0) +#define POE_SISTERS_FLAG_CHECK_AC (1 << 0) +#define POE_SISTERS_FLAG_UPDATE_SHAPE_ROT (1 << 1) +#define POE_SISTERS_FLAG_CHECK_Z_TARGET (1 << 2) // Meg doesnt go invisible if you ztarget her for too long +#define POE_SISTERS_FLAG_MATCH_PLAYER_HEIGHT (1 << 3) // The Poe is attempting to level with player's height +#define POE_SISTERS_FLAG_UPDATE_BGCHECK_INFO (1 << 4) +#define POE_SISTERS_FLAG_UPDATE_FIRES (1 << 5) // firePos updated to match limb in PostLimbDraw +#define POE_SISTERS_FLAG_REAL_MEG_ROTATION (1 << 6) // Real Meg rotates different than her clones for one cycle +#define POE_SISTERS_FLAG_DRAW_TORCH (1 << 7) // clang-format on void EnPoSisters_Init(Actor* thisx, PlayState* play) { @@ -163,8 +163,8 @@ void EnPoSisters_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); - SkelAnime_Init(play, &this->skelAnime, &gPoSistersSkel, &gPoeSistersSwayAnim, this->jointTable, this->morphTable, - POSISTERS_LIMB_MAX); + SkelAnime_Init(play, &this->skelAnime, &gPoeSistersSkel, &gPoeSistersSwayAnim, this->jointTable, this->morphTable, + POE_SISTERS_LIMB_MAX); this->color.r = 255; this->color.g = 255; @@ -176,21 +176,21 @@ void EnPoSisters_Init(Actor* thisx, PlayState* play) { Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->type = ENPOSISTERS_GET_TYPE(thisx); + this->type = POE_SISTERS_GET_TYPE(thisx); this->actor.hintId = this->type + TATL_HINT_ID_POE_SISTER_MEG; - this->megCloneId = ENPOSISTERS_GET_MEG_CLONE_ID(thisx); + this->megCloneId = POE_SISTERS_GET_MEG_CLONE_ID(thisx); this->floatingBobbingTimer = 32; this->zTargetTimer = 20; this->fireCount = 1; - this->poSisterFlags = POSISTERS_FLAG_UPDATE_FIRES; + this->poSisterFlags = POE_SISTERS_FLAG_UPDATE_FIRES; this->megDistToPlayer = 110.0f; thisx->flags &= ~ACTOR_FLAG_1; - if (ENPOSISTERS_GET_OBSERVER_FLAG(&this->actor)) { - // if flagged observer, they are a floating prop spawned by EnGb2 (po hut proprieter) + if (POE_SISTERS_GET_OBSERVER_FLAG(&this->actor)) { + // "Flagged observer": non-enemy floating prop spawned by EnGb2 (Poe Hut Proprieter) for display EnPoSisters_SetupObserverIdle(this); - } else if (this->type == POSISTER_TYPE_MEG) { - if (this->megCloneId == POSISTER_MEG_REAL) { + } else if (this->type == POE_SISTERS_TYPE_MEG) { + if (this->megCloneId == POE_SISTERS_MEG_REAL) { this->actor.colChkInfo.health = 8; this->collider.info.toucher.damage = 16; this->collider.base.ocFlags1 = (OC1_TYPE_PLAYER | OC1_ON); @@ -242,7 +242,7 @@ void EnPoSisters_MatchPlayerXZ(EnPoSisters* this, PlayState* play) { Player* player = GET_PLAYER(play); f32 dist; - if (this->megCloneId == POSISTER_MEG_REAL || this->actionFunc != EnPoSisters_DamageFlinch) { + if (this->megCloneId == POE_SISTERS_MEG_REAL || this->actionFunc != EnPoSisters_DamageFlinch) { if ((player->meleeWeaponState == 0 || player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H) && ((player->actor.world.pos.y - player->actor.floorHeight) < 1.0f)) { Math_StepToF(&this->megDistToPlayer, 110.0f, 3.0f); @@ -250,7 +250,7 @@ void EnPoSisters_MatchPlayerXZ(EnPoSisters* this, PlayState* play) { Math_StepToF(&this->megDistToPlayer, 170.0f, 10.0f); } dist = this->megDistToPlayer; - } else if (this->megCloneId != POSISTER_MEG_REAL) { + } else if (this->megCloneId != POE_SISTERS_MEG_REAL) { dist = this->actor.parent->xzDistToPlayer; } @@ -309,7 +309,7 @@ void EnPoSisters_CheckZTarget(EnPoSisters* this, PlayState* play) { void EnPoSisters_SetupObserverIdle(EnPoSisters* this) { Animation_MorphToLoop(&this->skelAnime, &gPoeSistersSwayAnim, -3.0f); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->laughTimer = Rand_S16Offset(100, 50); this->actionFunc = EnPoSisters_ObserverIdle; } @@ -318,7 +318,7 @@ void EnPoSisters_ObserverIdle(EnPoSisters* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (DECR(this->laughTimer) == 0) { this->laughTimer = Rand_S16Offset(100, 50); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_LAUGH2); } } @@ -330,7 +330,7 @@ void EnPoSisters_ObserverIdle(EnPoSisters* this, PlayState* play) { void EnPoSisters_SetupAimlessIdleFlying2(EnPoSisters* this) { Animation_MorphToLoop(&this->skelAnime, &gPoeSistersSwayAnim, -3.0f); this->idleFlyingAnimationCounter = Rand_S16Offset(2, 3); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnPoSisters_AimlessIdleFlying2; } @@ -353,29 +353,32 @@ void EnPoSisters_SetupAimlessIdleFlying(EnPoSisters* this) { Animation_MorphToLoop(&this->skelAnime, &gPoeSistersFloatAnim, -3.0f); } this->idleFlyingAnimationCounter = Rand_S16Offset(15, 3); - this->poSisterFlags |= (POSISTERS_FLAG_CHECK_Z_TARGET | POSISTERS_FLAG_UPDATE_SHAPE_ROT | POSISTERS_FLAG_CHECK_AC); + this->poSisterFlags |= + (POE_SISTERS_FLAG_CHECK_Z_TARGET | POE_SISTERS_FLAG_UPDATE_SHAPE_ROT | POE_SISTERS_FLAG_CHECK_AC); this->actionFunc = EnPoSisters_AimlessIdleFlying; } void EnPoSisters_AimlessIdleFlying(EnPoSisters* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - Math_StepToF(&this->actor.speedXZ, 1.0f, 0.2f); + Math_StepToF(&this->actor.speed, 1.0f, 0.2f); if (Animation_OnFrame(&this->skelAnime, 0.0f)) { DECR(this->idleFlyingAnimationCounter); } if ((this->actor.xzDistToPlayer < 600.0f) && (fabsf(this->actor.playerHeightRel + 5.0f) < 30.0f)) { EnPoSisters_SetupInvestigating(this); - } else if ((this->idleFlyingAnimationCounter == 0) && Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f)) { + } else if ((this->idleFlyingAnimationCounter == 0) && Math_StepToF(&this->actor.speed, 0.0f, 0.2f)) { // ! @bug: this is never reached because speedXZ is reduced // at the same rate it is increased at the top of this function EnPoSisters_SetupAimlessIdleFlying2(this); } - if (this->actor.bgCheckFlags & 8) { // touching a wall - Math_ScaledStepToS(&this->actor.world.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x71C); - } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 600.0f) { - Math_ScaledStepToS(&this->actor.world.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x71C); + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { + Math_ScaledStepToS(&this->actor.world.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), + 0x71C); + } else if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 600.0f) { + Math_ScaledStepToS(&this->actor.world.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), + 0x71C); } } @@ -392,7 +395,7 @@ void EnPoSisters_Investigating(EnPoSisters* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); yawDiff = this->actor.yawTowardsPlayer - player->actor.shape.rot.y; - Math_StepToF(&this->actor.speedXZ, 2.0f, 0.2f); + Math_StepToF(&this->actor.speed, 2.0f, 0.2f); if (yawDiff > 0x3000) { Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer + 0x3000, 0x71C); @@ -418,10 +421,10 @@ void EnPoSisters_SetupSpinUp(EnPoSisters* this) { this->collider.base.acFlags |= AC_HARD; } - Animation_MorphToLoop(&this->skelAnime, &gPoSistersAttackAnim, -5.0f); - this->actor.speedXZ = 0.0f; - this->spinupTimer = Animation_GetLastFrame(&gPoSistersAttackAnim.common) * 3 + 3; - this->poSisterFlags &= ~POSISTERS_FLAG_UPDATE_SHAPE_ROT; + Animation_MorphToLoop(&this->skelAnime, &gPoeSistersAttackAnim, -5.0f); + this->actor.speed = 0.0f; + this->spinupTimer = Animation_GetLastFrame(&gPoeSistersAttackAnim.common) * 3 + 3; + this->poSisterFlags &= ~POE_SISTERS_FLAG_UPDATE_SHAPE_ROT; this->actionFunc = EnPoSisters_SpinUp; } @@ -430,23 +433,23 @@ void EnPoSisters_SpinUp(EnPoSisters* this, PlayState* play) { DECR(this->spinupTimer); this->actor.shape.rot.y += ((s32)((this->skelAnime.endFrame + 1.0f) * 3.0f) - this->spinupTimer) * 0x180; if ((this->spinupTimer == 18) || (this->spinupTimer == 7)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_ROLL); } else if (this->spinupTimer == 0) { EnPoSisters_SetupSpinAttack(this); } } void EnPoSisters_SetupSpinAttack(EnPoSisters* this) { - this->actor.speedXZ = 5.0f; - if (this->type == POSISTER_TYPE_MEG) { + this->actor.speed = 5.0f; + if (this->type == POE_SISTERS_TYPE_MEG) { this->collider.base.colType = COLTYPE_METAL; this->collider.base.acFlags |= AC_HARD; - Animation_MorphToLoop(&this->skelAnime, &gPoSistersAttackAnim, -5.0f); + Animation_MorphToLoop(&this->skelAnime, &gPoeSistersAttackAnim, -5.0f); } this->spinTimer = 5; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->poSisterFlags |= POSISTERS_FLAG_MATCH_PLAYER_HEIGHT; + this->poSisterFlags |= POE_SISTERS_FLAG_MATCH_PLAYER_HEIGHT; this->actionFunc = EnPoSisters_SpinAttack; } @@ -462,19 +465,19 @@ void EnPoSisters_SpinAttack(EnPoSisters* this, PlayState* play) { s16 rotY = this->actor.shape.rot.y - this->actor.world.rot.y; if (ABS_ALT(rotY) < 0x1000) { - if (this->type != POSISTER_TYPE_MEG) { + if (this->type != POE_SISTERS_TYPE_MEG) { this->collider.base.colType = COLTYPE_HIT3; this->collider.base.acFlags &= ~AC_HARD; EnPoSisters_SetupAimlessIdleFlying(this); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_LAUGH2); EnPoSisters_MegCloneVanish(this, play); } } } if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_ROLL); } } @@ -484,7 +487,7 @@ void EnPoSisters_SpinAttack(EnPoSisters* this, PlayState* play) { void EnPoSisters_SetupAttackConnect(EnPoSisters* this) { Animation_MorphToLoop(&this->skelAnime, &gPoeSistersFloatAnim, -3.0f); this->actor.world.rot.y = BINANG_ROT180(this->actor.yawTowardsPlayer); - if (this->type != POSISTER_TYPE_MEG) { + if (this->type != POE_SISTERS_TYPE_MEG) { this->collider.base.colType = COLTYPE_HIT3; this->collider.base.acFlags &= ~AC_HARD; } @@ -494,14 +497,14 @@ void EnPoSisters_SetupAttackConnect(EnPoSisters* this) { void EnPoSisters_AttackConnectDrift(EnPoSisters* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - this->actor.shape.rot.y -= (s16)(this->actor.speedXZ * 10.0f * 128.0f); + this->actor.shape.rot.y -= (s16)(this->actor.speed * 10.0f * 128.0f); - if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.1f)) { // wait to stop moving + if (Math_StepToF(&this->actor.speed, 0.0f, 0.1f)) { // wait to stop moving this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->type != POSISTER_TYPE_MEG) { + if (this->type != POE_SISTERS_TYPE_MEG) { EnPoSisters_SetupAimlessIdleFlying(this); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_LAUGH2); EnPoSisters_MegCloneVanish(this, play); } } @@ -513,22 +516,23 @@ void EnPoSisters_SetupDamageFlinch(EnPoSisters* this) { func_800BE504(&this->actor, &this->collider); } - if (this->type != POSISTER_TYPE_MEG) { - this->actor.speedXZ = 10.0f; + if (this->type != POE_SISTERS_TYPE_MEG) { + this->actor.speed = 10.0f; } this->poSisterFlags &= - ~(POSISTERS_FLAG_MATCH_PLAYER_HEIGHT | POSISTERS_FLAG_UPDATE_SHAPE_ROT | POSISTERS_FLAG_CHECK_AC); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); + ~(POE_SISTERS_FLAG_MATCH_PLAYER_HEIGHT | POE_SISTERS_FLAG_UPDATE_SHAPE_ROT | POE_SISTERS_FLAG_CHECK_AC); + + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 16); this->actionFunc = EnPoSisters_DamageFlinch; } void EnPoSisters_DamageFlinch(EnPoSisters* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime) && !(this->actor.flags & ACTOR_FLAG_8000)) { if (this->actor.colChkInfo.health != 0) { - if (this->type != POSISTER_TYPE_MEG) { + if (this->type != POE_SISTERS_TYPE_MEG) { EnPoSisters_SetupFlee(this); - } else if (this->megCloneId != POSISTER_MEG_REAL) { + } else if (this->megCloneId != POE_SISTERS_MEG_REAL) { EnPoSisters_MegCloneVanish(this, NULL); } else { EnPoSisters_MegCloneVanish(this, play); @@ -538,28 +542,28 @@ void EnPoSisters_DamageFlinch(EnPoSisters* this, PlayState* play) { } } - if (this->megCloneId != POSISTER_MEG_REAL) { + if (this->megCloneId != POE_SISTERS_MEG_REAL) { s32 alpha; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.parent->shape.rot.y, - (this->megCloneId == POSISTER_MEG_CLONE2) ? 0x800 : 0x400); + (this->megCloneId == POE_SISTERS_MEG_CLONE2) ? 0x800 : 0x400); alpha = ((this->skelAnime.endFrame - this->skelAnime.curFrame) * 255.0f) / this->skelAnime.endFrame; this->color.a = CLAMP(alpha, 0, 255); this->actor.world.pos.y = this->actor.parent->world.pos.y; EnPoSisters_MatchPlayerXZ(this, play); - } else if (this->type != POSISTER_TYPE_MEG) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + } else if (this->type != POE_SISTERS_TYPE_MEG) { + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); } } void EnPoSisters_SetupFlee(EnPoSisters* this) { - Animation_MorphToLoop(&this->skelAnime, &gPoSistersFleeAnim, -3.0f); + Animation_MorphToLoop(&this->skelAnime, &gPoeSistersFleeAnim, -3.0f); this->actor.world.rot.y = BINANG_ROT180(this->actor.shape.rot.y); this->fleeTimer = 5; this->poSisterFlags |= - (POSISTERS_FLAG_MATCH_PLAYER_HEIGHT | POSISTERS_FLAG_UPDATE_SHAPE_ROT | POSISTERS_FLAG_CHECK_AC); - this->actor.speedXZ = 5.0f; + (POE_SISTERS_FLAG_MATCH_PLAYER_HEIGHT | POE_SISTERS_FLAG_UPDATE_SHAPE_ROT | POE_SISTERS_FLAG_CHECK_AC); + this->actor.speed = 5.0f; this->actionFunc = EnPoSisters_Flee; } @@ -570,9 +574,9 @@ void EnPoSisters_Flee(EnPoSisters* this, PlayState* play) { DECR(this->fleeTimer); } - if (this->actor.bgCheckFlags & 8) { // touching a wall + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->actor.world.rot.y = this->actor.shape.rot.y; - this->poSisterFlags |= POSISTERS_FLAG_UPDATE_SHAPE_ROT; + this->poSisterFlags |= POE_SISTERS_FLAG_UPDATE_SHAPE_ROT; EnPoSisters_SetupSpinToInvis(this); } else if (this->fleeTimer == 0 && this->actor.xzDistToPlayer > 480.0f) { this->actor.world.rot.y = this->actor.shape.rot.y; @@ -584,11 +588,11 @@ void EnPoSisters_SetupSpinToInvis(EnPoSisters* this) { Animation_Change(&this->skelAnime, &gPoeSistersAppearDisappearAnim, 1.5f, 0.0f, Animation_GetLastFrame(&gPoeSistersAppearDisappearAnim.common), ANIMMODE_ONCE, -3.0f); this->invisibleTimer = 100; // 5 seconds - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - this->poSisterFlags &= ~(POSISTERS_FLAG_CHECK_Z_TARGET | POSISTERS_FLAG_CHECK_AC); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DISAPPEAR); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); + this->poSisterFlags &= ~(POE_SISTERS_FLAG_CHECK_Z_TARGET | POE_SISTERS_FLAG_CHECK_AC); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_DISAPPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_LAUGH2); this->actionFunc = EnPoSisters_SpinToInvis; } @@ -607,7 +611,7 @@ void EnPoSisters_SpinToInvis(EnPoSisters* this, PlayState* play) { void EnPoSisters_SetupSpinBackToVisible(EnPoSisters* this, PlayState* play) { Animation_Change(&this->skelAnime, &gPoeSistersAppearDisappearAnim, 1.5f, 0.0f, Animation_GetLastFrame(&gPoeSistersAppearDisappearAnim.common), ANIMMODE_ONCE, -3.0f); - if (this->type == POSISTER_TYPE_MEG) { + if (this->type == POE_SISTERS_TYPE_MEG) { this->megDistToPlayer = 110.0f; EnPoSisters_MatchPlayerXZ(this, play); this->color.a = 0; @@ -617,17 +621,17 @@ void EnPoSisters_SetupSpinBackToVisible(EnPoSisters* this, PlayState* play) { } this->spinInvisibleTimer = 15; - this->actor.speedXZ = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); - this->poSisterFlags &= ~POSISTERS_FLAG_CHECK_AC; + this->actor.speed = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + this->poSisterFlags &= ~POE_SISTERS_FLAG_CHECK_AC; this->actionFunc = EnPoSisters_SpinBackToVisible; } void EnPoSisters_SpinBackToVisible(EnPoSisters* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { this->color.a = 255; // fully visible - if (this->type != POSISTER_TYPE_MEG) { - this->poSisterFlags |= POSISTERS_FLAG_CHECK_AC; + if (this->type != POE_SISTERS_TYPE_MEG) { + this->poSisterFlags |= POE_SISTERS_FLAG_CHECK_AC; this->collider.info.bumper.dmgFlags = ~(0x8000000 | 0x200000 | 0x100000 | 0x40000 | 0x1); DECR(this->spinInvisibleTimer); @@ -643,7 +647,7 @@ void EnPoSisters_SpinBackToVisible(EnPoSisters* this, PlayState* play) { s32 alpha = (this->skelAnime.curFrame * 255.0f) / this->skelAnime.endFrame; this->color.a = CLAMP(alpha, 0, 255); - if (this->type == POSISTER_TYPE_MEG) { + if (this->type == POE_SISTERS_TYPE_MEG) { EnPoSisters_MatchPlayerXZ(this, play); } } @@ -651,11 +655,11 @@ void EnPoSisters_SpinBackToVisible(EnPoSisters* this, PlayState* play) { void EnPoSisters_SetupDeathStage1(EnPoSisters* this) { this->deathTimer = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.pos.y += 42.0f; this->actor.shape.yOffset = -6000.0f; this->actor.flags &= ~ACTOR_FLAG_1; - this->poSisterFlags = POSISTERS_FLAG_CLEAR; + this->poSisterFlags = POE_SISTERS_FLAG_CLEAR; this->actionFunc = EnPoSisters_DeathStage1; } @@ -696,7 +700,7 @@ void EnPoSisters_DeathStage1(EnPoSisters* this, PlayState* play) { } if (this->deathTimer == 16) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); } } @@ -724,15 +728,15 @@ void EnPoSisters_DeathStage2(EnPoSisters* this, PlayState* play) { void EnPoSisters_SpawnMegClones(EnPoSisters* this, PlayState* play) { Actor* clone1 = Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_PO_SISTERS, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, - 0, ENPOSISTERS_PARAMS(false, POSISTER_MEG_CLONE1, POSISTER_TYPE_MEG)); + 0, POE_SISTERS_PARAMS(false, POE_SISTERS_MEG_CLONE1, POE_SISTERS_TYPE_MEG)); Actor* clone2 = Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_PO_SISTERS, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, - 0, ENPOSISTERS_PARAMS(false, POSISTER_MEG_CLONE2, POSISTER_TYPE_MEG)); + 0, POE_SISTERS_PARAMS(false, POE_SISTERS_MEG_CLONE2, POE_SISTERS_TYPE_MEG)); Actor* clone3 = Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_PO_SISTERS, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, - 0, ENPOSISTERS_PARAMS(false, POSISTER_MEG_CLONE3, POSISTER_TYPE_MEG)); + 0, POE_SISTERS_PARAMS(false, POE_SISTERS_MEG_CLONE3, POE_SISTERS_TYPE_MEG)); - // if we cannot spawn all clones: abort + // If we cannot spawn all clones: Abort if ((clone1 == NULL) || (clone2 == NULL) || (clone3 == NULL)) { if (clone1 != NULL) { Actor_Kill(clone1); @@ -759,7 +763,7 @@ void EnPoSisters_MegCloneVanish(EnPoSisters* this, PlayState* play) { this->actor.draw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; this->invisibleTimer = 100; // 5 seconds - this->poSisterFlags = POSISTERS_FLAG_UPDATE_FIRES; + this->poSisterFlags = POE_SISTERS_FLAG_UPDATE_FIRES; this->collider.base.colType = COLTYPE_HIT3; this->collider.base.acFlags &= ~AC_HARD; @@ -767,10 +771,10 @@ void EnPoSisters_MegCloneVanish(EnPoSisters* this, PlayState* play) { pos.x = this->actor.world.pos.x; pos.y = this->actor.world.pos.y + 45.0f; pos.z = this->actor.world.pos.z; - func_800B3030(play, &pos, &gZeroVec3f, &gZeroVec3f, 150, 0, 3); // spawns EffectSsDeadDb + func_800B3030(play, &pos, &gZeroVec3f, &gZeroVec3f, 150, 0, 3); // Spawns EffectSsDeadDb (flame effects) } - Lights_PointSetColorAndRadius(&this->lightInfo, 0, 0, 0, 0); // light OFF + Lights_PointSetColorAndRadius(&this->lightInfo, 0, 0, 0, 0); // Light OFF this->actionFunc = EnPoSisters_MegCloneWaitForSpinBack; } @@ -778,7 +782,7 @@ void EnPoSisters_MegCloneWaitForSpinBack(EnPoSisters* this, PlayState* play) { Player* player = GET_PLAYER(play); EnPoSisters* parent = (EnPoSisters*)this->actor.parent; - if (this->megCloneId == POSISTER_MEG_REAL) { + if (this->megCloneId == POE_SISTERS_MEG_REAL) { DECR(this->invisibleTimer); if (this->invisibleTimer == 0) { s32 rand = Rand_ZeroFloat(4.0f); @@ -803,7 +807,7 @@ void EnPoSisters_SetupMegSurroundPlayer(EnPoSisters* this) { this->color.a = 255; this->megSurroundTimer = 300; // 15 seconds this->megClonesRemaining = 3; - this->poSisterFlags |= (POSISTERS_FLAG_MATCH_PLAYER_HEIGHT | POSISTERS_FLAG_CHECK_AC); + this->poSisterFlags |= (POE_SISTERS_FLAG_MATCH_PLAYER_HEIGHT | POE_SISTERS_FLAG_CHECK_AC); this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = EnPoSisters_MegSurroundPlayer; } @@ -815,47 +819,48 @@ void EnPoSisters_MegSurroundPlayer(EnPoSisters* this, PlayState* play) { if (this->megClonesRemaining > 0 && this->megSurroundTimer >= 16) { SkelAnime_Update(&this->skelAnime); - if (this->megCloneId == POSISTER_MEG_REAL) { + if (this->megCloneId == POE_SISTERS_MEG_REAL) { if (ABS_ALT(16 - this->floatingBobbingTimer) < 14) { - // every x frames rotate around player, the fewer meg clones remaining the faster they spin + // Every N frames rotate around player. The fewer Meg clones remaining the faster they spin. this->actor.shape.rot.y += (s16)((0x580 - (this->megClonesRemaining * 0x180)) * fabsf(Math_SinS(this->floatingBobbingTimer * 0x800))); } - // twirl the real meg backwards for a bit for visual tell to player + // Twirl the real Meg backwards for a bit for a visual tell to player. if ((this->megSurroundTimer >= 284) || (this->megSurroundTimer <= 30)) { - this->poSisterFlags |= POSISTERS_FLAG_REAL_MEG_ROTATION; + this->poSisterFlags |= POE_SISTERS_FLAG_REAL_MEG_ROTATION; } else { - this->poSisterFlags &= ~POSISTERS_FLAG_REAL_MEG_ROTATION; + this->poSisterFlags &= ~POE_SISTERS_FLAG_REAL_MEG_ROTATION; } } else { this->actor.shape.rot.y = this->actor.parent->shape.rot.y + (this->megCloneId * 0x4000); } } - if (this->megCloneId == POSISTER_MEG_REAL) { + if (this->megCloneId == POE_SISTERS_MEG_REAL) { if ((this->megSurroundTimer >= 284) || ((this->megSurroundTimer <= 30) && (this->megSurroundTimer >= 16))) { - this->poSisterFlags |= POSISTERS_FLAG_REAL_MEG_ROTATION; + this->poSisterFlags |= POE_SISTERS_FLAG_REAL_MEG_ROTATION; } else { - this->poSisterFlags &= ~POSISTERS_FLAG_REAL_MEG_ROTATION; + this->poSisterFlags &= ~POE_SISTERS_FLAG_REAL_MEG_ROTATION; } } if (this->megSurroundTimer == 0) { - if (this->megCloneId == POSISTER_MEG_REAL) { + if (this->megCloneId == POE_SISTERS_MEG_REAL) { EnPoSisters_SetupSpinAttack(this); } else { EnPoSisters_MegCloneVanish(this, play); } - } else if (this->megCloneId != POSISTER_MEG_REAL) { + } else if (this->megCloneId != POE_SISTERS_MEG_REAL) { parent = (EnPoSisters*)this->actor.parent; if (parent->actionFunc == EnPoSisters_DamageFlinch) { - // flinch clones if you hit the real meg + // Clones flinch if you hit the real Meg EnPoSisters_SetupDamageFlinch(this); } } else if (this->megClonesRemaining == 0) { - // all meg clones have been killed, meg waits 15 frames then spin attacks - // timer is negative because megClonesRemaining and megAttackTimer are the same union'd variable + // All Meg clones have been killed: Real Meg waits 15 frames then spin attacks in retaliation + // Timer is negative (inrecrements to zero) + // because megClonesRemaining and megAttackTimer are the same union'd variable this->megAttackTimer = -15; } else if (this->megAttackTimer < 0) { this->megAttackTimer++; @@ -872,9 +877,9 @@ void EnPoSisters_MegSurroundPlayer(EnPoSisters* this, PlayState* play) { */ void EnPoSisters_SetupSpawnPo(EnPoSisters* this) { Animation_PlayOnce(&this->skelAnime, &gPoeSistersAppearDisappearAnim); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_APPEAR); this->color.a = 0; - this->poSisterFlags = POSISTERS_FLAG_UPDATE_FIRES; + this->poSisterFlags = POE_SISTERS_FLAG_UPDATE_FIRES; this->actionFunc = EnPoSisters_PoeSpawn; } @@ -882,8 +887,8 @@ void EnPoSisters_PoeSpawn(EnPoSisters* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { this->color.a = 255; this->actor.flags |= ACTOR_FLAG_1; - this->poSisterFlags |= (POSISTERS_FLAG_UPDATE_BGCHECK_INFO | POSISTERS_FLAG_MATCH_PLAYER_HEIGHT); - if (this->type == POSISTER_TYPE_MEG) { + this->poSisterFlags |= (POE_SISTERS_FLAG_UPDATE_BGCHECK_INFO | POE_SISTERS_FLAG_MATCH_PLAYER_HEIGHT); + if (this->type == POE_SISTERS_TYPE_MEG) { EnPoSisters_MegCloneVanish(this, play); } else { EnPoSisters_SetupAimlessIdleFlying(this); @@ -903,9 +908,9 @@ void EnPoSisters_CheckCollision(EnPoSisters* this, PlayState* play) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); - if (this->megCloneId != POSISTER_MEG_REAL) { + if (this->megCloneId != POE_SISTERS_MEG_REAL) { ((EnPoSisters*)this->actor.parent)->megClonesRemaining--; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH2); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_LAUGH2); EnPoSisters_MegCloneVanish(this, play); if (Rand_ZeroOne() < 0.2f) { pos.x = this->actor.world.pos.x; @@ -914,27 +919,27 @@ void EnPoSisters_CheckCollision(EnPoSisters* this, PlayState* play) { Item_DropCollectible(play, &pos, ITEM00_ARROWS_10); } } else if (this->collider.base.colType != 9) { - if (this->actor.colChkInfo.damageEffect == POSISTERS_DAMAGEEFFECT_DEKUNUT) { + if (this->actor.colChkInfo.damageEffect == POE_SISTERS_DMGEFF_DEKUNUT) { this->actor.world.rot.y = this->actor.shape.rot.y; - this->poSisterFlags |= POSISTERS_FLAG_UPDATE_SHAPE_ROT; + this->poSisterFlags |= POE_SISTERS_FLAG_UPDATE_SHAPE_ROT; EnPoSisters_SetupSpinBackToVisible(this, play); - } else if ((this->type == POSISTER_TYPE_MEG) && - (this->actor.colChkInfo.damageEffect == POSISTERS_DAMAGEEFFECT_SPINATTACK) && + } else if ((this->type == POE_SISTERS_TYPE_MEG) && + (this->actor.colChkInfo.damageEffect == POE_SISTERS_DMGEFF_SPINATTACK) && (this->actionFunc == EnPoSisters_MegSurroundPlayer)) { if (this->megClonesRemaining == 0) { - // all meg clones have been killed, meg waits 45 frames then spin attacks - // timer is negative because megClonesRemaining and megAttackTimer are the same union'd variable + // All Meg clones have been killed: Real Meg waits 45 frames then spin attacks + // Timer is negative because megClonesRemaining and megAttackTimer are the same union'd variable this->megAttackTimer = -45; } } else { if (Actor_ApplyDamage(&this->actor)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_DAMAGE); } else { Enemy_StartFinishingBlow(play, &this->actor); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_SISTER_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_SISTER_DEAD); } - if (this->actor.colChkInfo.damageEffect == POSISTERS_DAMAGEEFFECT_LIGHTARROWS) { + if (this->actor.colChkInfo.damageEffect == POE_SISTERS_DMGEFF_LIGHTARROWS) { this->drawDmgEffAlpha = 4.0f; this->drawDmgEffScale = 0.5f; Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, @@ -960,20 +965,20 @@ void EnPoSisters_Update(Actor* thisx, PlayState* play) { } EnPoSisters_CheckCollision(this, play); - if (this->poSisterFlags & POSISTERS_FLAG_CHECK_Z_TARGET) { + if (this->poSisterFlags & POE_SISTERS_FLAG_CHECK_Z_TARGET) { EnPoSisters_CheckZTarget(this, play); } this->actionFunc(this, play); - if (this->poSisterFlags & POSISTERS_FLAG_MATCH_PLAYER_HEIGHT) { + if (this->poSisterFlags & POE_SISTERS_FLAG_MATCH_PLAYER_HEIGHT) { EnPoSisters_MatchPlayerY(this, play); } Actor_MoveWithGravity(&this->actor); - if (this->poSisterFlags & POSISTERS_FLAG_UPDATE_BGCHECK_INFO) { - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 0.0f, 5); + if (this->poSisterFlags & POE_SISTERS_FLAG_UPDATE_BGCHECK_INFO) { + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } else { checkPos.x = this->actor.world.pos.x; checkPos.y = this->actor.world.pos.y + 10.0f; @@ -999,8 +1004,8 @@ void EnPoSisters_Update(Actor* thisx, PlayState* play) { } if (this->poSisterFlags & - (POSISTERS_FLAG_UPDATE_BGCHECK_INFO | POSISTERS_FLAG_MATCH_PLAYER_HEIGHT | POSISTERS_FLAG_CHECK_Z_TARGET | - POSISTERS_FLAG_UPDATE_SHAPE_ROT | POSISTERS_FLAG_CHECK_AC)) { + (POE_SISTERS_FLAG_UPDATE_BGCHECK_INFO | POE_SISTERS_FLAG_MATCH_PLAYER_HEIGHT | POE_SISTERS_FLAG_CHECK_Z_TARGET | + POE_SISTERS_FLAG_UPDATE_SHAPE_ROT | POE_SISTERS_FLAG_CHECK_AC)) { Collider_UpdateCylinder(&this->actor, &this->collider); if ((this->actionFunc == EnPoSisters_SpinAttack) || (this->actionFunc == EnPoSisters_SpinUp)) { this->fireCount++; @@ -1014,7 +1019,7 @@ void EnPoSisters_Update(Actor* thisx, PlayState* play) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } - if (this->poSisterFlags & POSISTERS_FLAG_CHECK_AC) { + if (this->poSisterFlags & POE_SISTERS_FLAG_CHECK_AC) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } @@ -1024,23 +1029,23 @@ void EnPoSisters_Update(Actor* thisx, PlayState* play) { if (this->actionFunc == EnPoSisters_Flee) { this->actor.shape.rot.y = BINANG_ROT180(this->actor.world.rot.y); - } else if (this->poSisterFlags & POSISTERS_FLAG_UPDATE_SHAPE_ROT) { + } else if (this->poSisterFlags & POE_SISTERS_FLAG_UPDATE_SHAPE_ROT) { this->actor.shape.rot.y = this->actor.world.rot.y; } } } void EnPoSisters_UpdateColors(EnPoSisters* this) { - if (this->skelAnime.animation == &gPoSistersAttackAnim) { + if (this->skelAnime.animation == &gPoeSistersAttackAnim) { this->color.r = CLAMP_MAX(this->color.r + 5, 255); this->color.g = CLAMP_MIN(this->color.g - 5, 50); this->color.b = CLAMP_MIN(this->color.b - 5, 0); - } else if (this->skelAnime.animation == &gPoSistersFleeAnim) { + } else if (this->skelAnime.animation == &gPoeSistersFleeAnim) { this->color.r = CLAMP_MAX(this->color.r + 5, 80); this->color.g = CLAMP_MAX(this->color.g + 5, 255); this->color.b = CLAMP_MAX(this->color.b + 5, 225); } else if (this->skelAnime.animation == &gPoeSistersDamagedAnim) { - // flash every other frame after taking damage + // Flash every other frame after taking damage if (this->actor.colorFilterTimer & 0x2) { this->color.r = 0; this->color.g = 0; @@ -1067,16 +1072,16 @@ void EnPoSisters_UpdateColors(EnPoSisters* this) { s32 EnPoSisters_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { static Gfx* gPoSisterBodyDisplayLists[] = { - gPoSistersMegBodyDL, - gPoSistersJoelleBodyDL, - gPoSistersBethBodyDL, - gPoSistersAmyBodyDL, + gPoeSistersMegBodyDL, + gPoeSistersJoelleBodyDL, + gPoeSistersBethBodyDL, + gPoeSistersAmyBodyDL, }; static Gfx* gPoSisterFaceDisplayLists[] = { - gPoSistersMegFaceDL, - gPoSistersJoelleFaceDL, - gPoSistersBethFaceDL, - gPoSistersAmyFaceDL, + gPoeSistersMegFaceDL, + gPoeSistersJoelleFaceDL, + gPoeSistersBethFaceDL, + gPoeSistersAmyFaceDL, }; static Color_RGBA8 gPoSisterColors[] = { { 80, 0, 100, 0 }, @@ -1086,7 +1091,7 @@ s32 EnPoSisters_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Ve }; EnPoSisters* this = THIS; - if (limbIndex == POSISTERS_LIMB_ROOT && (this->poSisterFlags & POSISTERS_FLAG_REAL_MEG_ROTATION)) { + if (limbIndex == POE_SISTERS_LIMB_ROOT && (this->poSisterFlags & POE_SISTERS_FLAG_REAL_MEG_ROTATION)) { if (this->megSurroundTimer >= 284) { rot->x += (this->megSurroundTimer - 284) * 0x1000; } else { @@ -1094,17 +1099,17 @@ s32 EnPoSisters_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Ve } } - if ((this->color.a == 0) || (limbIndex == POSISTERS_LIMB_TORCH) || + if ((this->color.a == 0) || (limbIndex == POE_SISTERS_LIMB_TORCH) || ((this->actionFunc == EnPoSisters_DeathStage1) && (this->deathTimer >= 8))) { *dList = NULL; - } else if (limbIndex == POSISTERS_LIMB_MAIN_BODY) { + } else if (limbIndex == POE_SISTERS_LIMB_MAIN_BODY) { *dList = gPoSisterBodyDisplayLists[this->type]; - } else if (limbIndex == POSISTERS_LIMB_FACE) { + } else if (limbIndex == POE_SISTERS_LIMB_FACE) { *dList = gPoSisterFaceDisplayLists[this->type]; gDPPipeSync((*gfx)++); gDPSetEnvColor((*gfx)++, this->color.r, this->color.g, this->color.b, this->color.a); - } else if (limbIndex == POSISTERS_LIMB_LOWER_BODY) { + } else if (limbIndex == POE_SISTERS_LIMB_LOWER_BODY) { Color_RGBA8* color = &gPoSisterColors[this->type]; gDPPipeSync((*gfx)++); @@ -1114,46 +1119,47 @@ s32 EnPoSisters_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Ve return false; } -#define POSISTER_LIMBPOS_INVALID -1 +#define POE_SISTERS_LIMBPOS_INVALID -1 void EnPoSisters_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { static Vec3f D_80B1DAFC = { 1000.0f, -1700.0f, 0.0f }; static s8 D_80B1DB08[] = { - POSISTER_LIMBPOS_INVALID, - POSISTER_LIMBPOS_INVALID, + POE_SISTERS_LIMBPOS_INVALID, + POE_SISTERS_LIMBPOS_INVALID, 0, 1, 2, - POSISTER_LIMBPOS_INVALID, + POE_SISTERS_LIMBPOS_INVALID, 3, - POSISTER_LIMBPOS_INVALID, - POSISTER_LIMBPOS_INVALID, - POSISTER_LIMBPOS_INVALID, - POSISTER_LIMBPOS_INVALID, - POSISTER_LIMBPOS_INVALID, + POE_SISTERS_LIMBPOS_INVALID, + POE_SISTERS_LIMBPOS_INVALID, + POE_SISTERS_LIMBPOS_INVALID, + POE_SISTERS_LIMBPOS_INVALID, + POE_SISTERS_LIMBPOS_INVALID, }; EnPoSisters* this = THIS; s32 end; f32 brightness; - if (D_80B1DB08[limbIndex] != POSISTER_LIMBPOS_INVALID) { + if (D_80B1DB08[limbIndex] != POE_SISTERS_LIMBPOS_INVALID) { Matrix_MultZero(&this->limbPos[D_80B1DB08[limbIndex]]); - } else if (limbIndex == POSISTERS_LIMB_MAIN_BODY) { + } else if (limbIndex == POE_SISTERS_LIMB_MAIN_BODY) { Matrix_MultVecY(-2500.0f, &this->limbPos[4]); Matrix_MultVecY(3000.0f, &this->limbPos[5]); - } else if (limbIndex == POSISTERS_LIMB_FACE) { + } else if (limbIndex == POE_SISTERS_LIMB_FACE) { Matrix_MultVecY(-4000.0f, &this->limbPos[6]); - } else if (limbIndex == POSISTERS_LIMB_LOWER_BODY) { + } else if (limbIndex == POE_SISTERS_LIMB_LOWER_BODY) { Matrix_MultVecX(3000.0f, &this->limbPos[7]); } - if (this->actionFunc == EnPoSisters_DeathStage1 && this->deathTimer >= 8 && limbIndex == POSISTERS_LIMB_MAIN_BODY) { + if (this->actionFunc == EnPoSisters_DeathStage1 && this->deathTimer >= 8 && + limbIndex == POE_SISTERS_LIMB_MAIN_BODY) { gSPMatrix((*gfx)++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfx)++, gPoSistersBurnBodyDL); + gSPDisplayList((*gfx)++, gPoeSistersBurnBodyDL); } - if (limbIndex == POSISTERS_LIMB_TORCH) { - if (this->poSisterFlags & POSISTERS_FLAG_UPDATE_FIRES) { + if (limbIndex == POE_SISTERS_LIMB_TORCH) { + if (this->poSisterFlags & POE_SISTERS_FLAG_UPDATE_FIRES) { for (end = this->fireCount - 1; end > 0; end--) { this->firePos[end] = this->firePos[end - 1]; } @@ -1164,7 +1170,7 @@ void EnPoSisters_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s if (this->fireCount > 0) { Color_RGBA8* flameColor = &sPoSisterFlameColors[this->type]; - brightness = Rand_ZeroFloat(0.3f) + 0.7f; // flickering torch light level + brightness = Rand_ZeroFloat(0.3f) + 0.7f; // Flickering torch light level if (this->actionFunc == EnPoSisters_DeathStage2) { Lights_PointNoGlowSetInfo(&this->lightInfo, this->firePos[0].x, this->firePos[0].y + 15.0f, @@ -1179,7 +1185,7 @@ void EnPoSisters_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s Lights_PointSetColorAndRadius(&this->lightInfo, 0, 0, 0, 0); } - if (!(this->poSisterFlags & POSISTERS_FLAG_DRAW_TORCH)) { + if (!(this->poSisterFlags & POE_SISTERS_FLAG_DRAW_TORCH)) { Matrix_Get(&this->mtxf); } } @@ -1203,23 +1209,23 @@ void EnPoSisters_Draw(Actor* thisx, PlayState* play) { if ((this->color.a == 255) || (this->color.a == 0)) { gDPSetEnvColor(POLY_OPA_DISP++, this->color.r, this->color.g, this->color.b, this->color.a); - gSPSegment(POLY_OPA_DISP++, 0x09, D_801AEFA0); // empty + gSPSegment(POLY_OPA_DISP++, 0x09, D_801AEFA0); // Empty DL POLY_OPA_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnPoSisters_OverrideLimbDraw, EnPoSisters_PostLimbDraw, &this->actor, POLY_OPA_DISP); } else { gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->color.a); - gSPSegment(POLY_XLU_DISP++, 0x09, D_801AEF88); // xlu only DL + gSPSegment(POLY_XLU_DISP++, 0x09, D_801AEF88); // XLU only DL POLY_XLU_DISP = SkelAnime_Draw(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnPoSisters_OverrideLimbDraw, EnPoSisters_PostLimbDraw, &this->actor, POLY_XLU_DISP); } - if (!(this->poSisterFlags & POSISTERS_FLAG_DRAW_TORCH)) { + if (!(this->poSisterFlags & POE_SISTERS_FLAG_DRAW_TORCH)) { Matrix_Put(&this->mtxf); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gPoSistersDrawTorchDL); + gSPDisplayList(POLY_OPA_DISP++, gPoeSistersDrawTorchDL); } gSPSegment( diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h index 5e549c4d7..cfb8a1697 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h @@ -8,24 +8,24 @@ struct EnPoSisters; typedef void (*EnPoSistersActionFunc)(struct EnPoSisters*, PlayState*); -#define ENPOSISTERS_GET_OBSERVER_FLAG(thisx) ((thisx)->params & 0x1000) -#define ENPOSISTERS_GET_MEG_CLONE_ID(thisx) (((thisx)->params >> 0xA) & 3) -#define ENPOSISTERS_GET_TYPE(thisx) (((thisx)->params >> 8) & 3) +#define POE_SISTERS_GET_OBSERVER_FLAG(thisx) ((thisx)->params & 0x1000) +#define POE_SISTERS_GET_MEG_CLONE_ID(thisx) (((thisx)->params >> 0xA) & 3) +#define POE_SISTERS_GET_TYPE(thisx) (((thisx)->params >> 8) & 3) -#define ENPOSISTERS_PARAMS(observerFlag, megClone, type) (((observerFlag) << 0xC) | ((megClone & 3) << 0xA) | ((type & 3) << 8)) +#define POE_SISTERS_PARAMS(observerFlag, megClone, type) (((observerFlag) << 0xC) | ((megClone & 3) << 0xA) | ((type & 3) << 8)) typedef enum { - /* 0 */ POSISTER_TYPE_MEG, // purple - /* 1 */ POSISTER_TYPE_JO, // red - /* 2 */ POSISTER_TYPE_BETH, // blue - /* 3 */ POSISTER_TYPE_AMY, // green + /* 0 */ POE_SISTERS_TYPE_MEG, // purple + /* 1 */ POE_SISTERS_TYPE_JO, // red + /* 2 */ POE_SISTERS_TYPE_BETH, // blue + /* 3 */ POE_SISTERS_TYPE_AMY, // green } EnPoSisterType; typedef enum { - /* 0 */ POSISTER_MEG_REAL, - /* 1 */ POSISTER_MEG_CLONE1, - /* 2 */ POSISTER_MEG_CLONE2, - /* 3 */ POSISTER_MEG_CLONE3, + /* 0 */ POE_SISTERS_MEG_REAL, + /* 1 */ POE_SISTERS_MEG_CLONE1, + /* 2 */ POE_SISTERS_MEG_CLONE2, + /* 3 */ POE_SISTERS_MEG_CLONE3, } EnPoSisterMegCloneID; typedef struct EnPoSisters { @@ -54,8 +54,8 @@ typedef struct EnPoSisters { s16 megAttackTimer; // delay until meg spin attacks player (negative frames counting up to 0) s16 megClonesRemaining; // positive count of meg clones remaining }; - /* 0x196 */ Vec3s jointTable[POSISTERS_LIMB_MAX]; - /* 0x1DE */ Vec3s morphTable[POSISTERS_LIMB_MAX]; + /* 0x196 */ Vec3s jointTable[POE_SISTERS_LIMB_MAX]; + /* 0x1DE */ Vec3s morphTable[POE_SISTERS_LIMB_MAX]; /* 0x226 */ Color_RGBA8 color; /* 0x22C */ Vec3f firePos[8]; /* 0x28C */ Vec3f limbPos[8]; // passed to Actor_DrawDamageEffects 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 f1b0f74d4..c8da2f1ee 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -4,10 +4,11 @@ * Description: Poe */ +#include "prevent_bss_reordering.h" #include "z_en_poh.h" #include "objects/object_po/object_po.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200 | ACTOR_FLAG_1000) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200 | ACTOR_FLAG_IGNORE_QUAKE) #define THIS ((EnPoh*)thisx) @@ -167,7 +168,7 @@ void EnPoh_Init(Actor* thisx, PlayState* play) { 255, 255, 255, 0); SkelAnime_Init(play, &this->skelAnime, &object_po_Skel_0050D0, &object_po_Anim_000A60, this->jointTable, this->morphTable, 21); - this->actor.bgCheckFlags |= 0x400; + this->actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_400; func_80B2D0E8(this); } @@ -216,7 +217,7 @@ void func_80B2CA4C(EnPoh* this) { Animation_PlayLoop(&this->skelAnime, &object_po_Anim_0015B0); this->unk_18E = Rand_S16Offset(2, 3); this->actionFunc = func_80B2CAA4; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void func_80B2CAA4(EnPoh* this, PlayState* play) { @@ -247,13 +248,13 @@ void func_80B2CB60(EnPoh* this) { void func_80B2CBBC(EnPoh* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - Math_StepToF(&this->actor.speedXZ, 1.0f, 0.2f); + Math_StepToF(&this->actor.speed, 1.0f, 0.2f); if (Animation_OnFrame(&this->skelAnime, 0.0f) && (this->unk_18E != 0)) { this->unk_18E--; } - if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 400.0f) { - this->unk_192 = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 400.0f) { + this->unk_192 = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); } Math_ScaledStepToS(&this->actor.world.rot.y, this->unk_192, 0x71C); @@ -277,7 +278,7 @@ void func_80B2CD14(EnPoh* this) { Animation_PlayLoop(&this->skelAnime, &object_po_Anim_000A60); this->actionFunc = func_80B2CD64; this->unk_18E = 0; - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; } void func_80B2CD64(EnPoh* this, PlayState* play) { @@ -315,15 +316,15 @@ void func_80B2CD64(EnPoh* this, PlayState* play) { void func_80B2CEC8(EnPoh* this) { Animation_MorphToLoop(&this->skelAnime, &object_po_Anim_0001A8, -6.0f); this->unk_18E = 12; - this->actor.speedXZ = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); + this->actor.speed = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_LAUGH); this->actionFunc = func_80B2CF28; } void func_80B2CF28(EnPoh* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_KANTERA); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_KANTERA); if (this->unk_18E != 0) { this->unk_18E--; } @@ -333,7 +334,7 @@ void func_80B2CF28(EnPoh* this, PlayState* play) { if (this->unk_18E >= 10) { Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xAAA); } else if (this->unk_18E == 9) { - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; this->skelAnime.playSpeed = 2.0f; } else if (this->unk_18E == 0) { func_80B2CB60(this); @@ -345,13 +346,13 @@ void func_80B2CFF8(EnPoh* this) { Animation_MorphToPlayOnce(&this->skelAnime, &object_po_Anim_0004EC, -6.0f); func_800BE504(&this->actor, &this->colliderCylinder); this->colliderCylinder.base.acFlags &= ~AC_ON; - this->actor.speedXZ = 5.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); + this->actor.speed = 5.0f; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 16); this->actionFunc = func_80B2D07C; } void func_80B2D07C(EnPoh* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.colChkInfo.health != 0) { func_80B2DAD0(this); @@ -379,13 +380,13 @@ void func_80B2D140(EnPoh* this, PlayState* play) { } if ((this->skelAnime.playSpeed < 0.5f) && (this->actor.xzDistToPlayer < 280.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_APPEAR); this->skelAnime.playSpeed = 1.0f; } } void func_80B2D2C0(EnPoh* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->unk_18E = 0; this->actor.hintId = TATL_HINT_ID_NONE; @@ -438,14 +439,14 @@ void func_80B2D300(EnPoh* this, PlayState* play) { } if (this->unk_18E == 18) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); } } void func_80B2D5DC(EnPoh* this) { Animation_PlayOnce(&this->skelAnime, &object_po_Anim_000A60); this->actionFunc = func_80B2D628; - this->actor.speedXZ = -5.0f; + this->actor.speed = -5.0f; } void func_80B2D628(EnPoh* this, PlayState* play) { @@ -454,7 +455,7 @@ void func_80B2D628(EnPoh* this, PlayState* play) { func_80B2CB60(this); this->unk_18E = 23; } else { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); this->actor.shape.rot.y += 0x1000; } } @@ -463,7 +464,7 @@ void func_80B2D694(EnPoh* this) { Animation_PlayLoop(&this->skelAnime, &object_po_Anim_0015B0); this->unk_192 = BINANG_ROT180(this->actor.world.rot.y); this->actionFunc = func_80B2D6EC; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void func_80B2D6EC(EnPoh* this, PlayState* play) { @@ -482,10 +483,10 @@ void func_80B2D6EC(EnPoh* this, PlayState* play) { void func_80B2D76C(EnPoh* this) { this->unk_18C = 32; this->unk_192 = 0x2000; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DISAPPEAR); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_DISAPPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_LAUGH); this->colliderCylinder.base.acFlags &= ~AC_ON; this->actionFunc = func_80B2D7D4; } @@ -513,9 +514,9 @@ void func_80B2D7D4(EnPoh* this, PlayState* play) { void func_80B2D924(EnPoh* this) { this->unk_18C = 0; this->unk_192 = 0x2000; - this->actor.speedXZ = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); + this->actor.speed = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_LAUGH); this->colliderCylinder.base.acFlags &= ~AC_ON; this->actionFunc = func_80B2D980; } @@ -539,7 +540,7 @@ void func_80B2D980(EnPoh* this, PlayState* play) { void func_80B2DAD0(EnPoh* this) { Animation_MorphToLoop(&this->skelAnime, &object_po_Anim_0006E0, -5.0f); - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; this->actor.world.rot.y = BINANG_ROT180(this->actor.shape.rot.y); this->colliderCylinder.base.acFlags |= AC_ON; this->unk_18E = 200; @@ -582,13 +583,13 @@ void func_80B2DC50(EnPoh* this, PlayState* play) { } void func_80B2DD2C(EnPoh* this, PlayState* play) { - if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight <= BGCHECK_Y_MIN)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->actor.floorHeight <= BGCHECK_Y_MIN)) { EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 6.0f, 0, 1, 1, 15, OBJECT_PO, 10, object_po_DL_002D28); func_80B2E0B0(this); } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, UPDBGCHECKINFO_FLAG_4); } void func_80B2DDF8(EnPoh* this, s32 arg1) { @@ -629,7 +630,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; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_METAL_BOX_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EV_METAL_BOX_BOUND); this->actionFunc = func_80B2E180; } @@ -663,7 +664,7 @@ void func_80B2E230(EnPoh* this, PlayState* play) { return; } - Actor_PickUp(&this->actor, play, GI_MAX, 35.0f, 60.0f); + Actor_OfferGetItem(&this->actor, play, 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--; @@ -680,7 +681,7 @@ void func_80B2E230(EnPoh* this, PlayState* play) { void func_80B2E3B0(EnPoh* this) { AudioSfx_StopByPosAndId(&this->actor.projectedPos, NA_SE_EN_PO_BIG_CRY - SFX_FLAG); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_LAUGH); this->actionFunc = func_80B2E3F8; } @@ -696,9 +697,9 @@ void func_80B2E438(EnPoh* this, PlayState* play) { this->colliderCylinder.base.acFlags &= ~AC_HIT; if (!Actor_ApplyDamage(&this->actor)) { Enemy_StartFinishingBlow(play, &this->actor); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_DEAD); } else if (this->actor.colChkInfo.damage != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_DAMAGE); } if (this->actor.colChkInfo.damageEffect != 14) { @@ -1005,7 +1006,7 @@ void func_80B2F37C(Actor* thisx, PlayState* play) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 170, 255, this->unk_197); gDPSetEnvColor(POLY_XLU_DISP++, this->unk_194, this->unk_195, this->unk_196, 255); - Matrix_RotateYF((Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000) * (M_PI / 32768), MTXMODE_APPLY); + Matrix_RotateYF(BINANG_TO_RAD(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_po_DL_003850); diff --git a/src/overlays/actors/ovl_En_Pp/z_en_pp.c b/src/overlays/actors/ovl_En_Pp/z_en_pp.c index fad487e62..5d1d6935e 100644 --- a/src/overlays/actors/ovl_En_Pp/z_en_pp.c +++ b/src/overlays/actors/ovl_En_Pp/z_en_pp.c @@ -446,27 +446,27 @@ void EnPp_PlaySfxForAnimation(EnPp* this) { case EN_PP_ANIM_WALK: case EN_PP_ANIM_TURN_TO_FACE_PLAYER: if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_FOOTSTEP); + Actor_PlaySfx(&this->actor, NA_SE_EN_HIPLOOP_FOOTSTEP); } break; case EN_PP_ANIM_WIND_UP: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_FOOT - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_HIPLOOP_FOOT - SFX_FLAG); break; case EN_PP_ANIM_CHARGE: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_RUN - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_HIPLOOP_RUN - SFX_FLAG); break; case EN_PP_ANIM_ATTACK: if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_PAUSE); + Actor_PlaySfx(&this->actor, NA_SE_EN_HIPLOOP_PAUSE); } break; case EN_PP_ANIM_ROAR: if (Animation_OnFrame(&this->skelAnime, 6.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_PAUSE); + Actor_PlaySfx(&this->actor, NA_SE_EN_HIPLOOP_PAUSE); } break; @@ -537,7 +537,7 @@ void EnPp_Idle(EnPp* this, PlayState* play) { posToLookAt.x += randPlusMinusPoint5Scaled(50.0f); posToLookAt.z += randPlusMinusPoint5Scaled(50.0f); this->targetRotY = Math_Vec3f_Yaw(&this->actor.world.pos, &posToLookAt); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->animIndex != EN_PP_ANIM_IDLE) { EnPp_ChangeAnim(this, EN_PP_ANIM_IDLE); } @@ -561,7 +561,7 @@ void EnPp_Idle(EnPp* this, PlayState* play) { if ((this->maskBounceRotationalVelocity < 0x64) && (fabsf(this->actor.world.rot.y - this->targetRotY) < 100.0f)) { - Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.3f, 1.0f); + Math_ApproachF(&this->actor.speed, 1.0f, 0.3f, 1.0f); } Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRotY, 1, @@ -611,7 +611,7 @@ void EnPp_Charge(EnPp* this, PlayState* play) { Math_SmoothStepToS(&this->maskBounceRotationalVelocity, 0, 1, 0x1F4, 0); if (!this->actionVar.isCharging) { - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 1.0f); + Math_ApproachZeroF(&this->actor.speed, 0.5f, 1.0f); if (fabsf(this->actor.world.rot.y - this->targetRotY) < 100.0f) { if (this->chargesInStraightLines) { this->actor.world.rot.y = this->targetRotY; @@ -629,13 +629,13 @@ void EnPp_Charge(EnPp* this, PlayState* play) { } } else if (this->animIndex == EN_PP_ANIM_CHARGE) { if (EnPp_CheckCollision(this, play) != EN_PP_COLLISION_RESULT_OK) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; EnPp_SetupRoar(this); return; } if (!this->chargesInStraightLines) { - Math_ApproachF(&this->actor.speedXZ, 10.0f, 0.3f, 1.0f); + Math_ApproachF(&this->actor.speed, 10.0f, 0.3f, 1.0f); } else { Math_ApproachF(&this->actor.world.pos.x, this->targetPos.x, 0.5f, fabsf(Math_SinS(this->targetRotY) * this->chargeAndBounceSpeed)); @@ -661,9 +661,9 @@ void EnPp_Charge(EnPp* this, PlayState* play) { return; } else { if (EN_PP_GET_TYPE(&this->actor) != EN_PP_TYPE_MASKED) { - this->actor.speedXZ *= -1.0f; + this->actor.speed *= -1.0f; } else { - this->actor.speedXZ *= -0.5f; + this->actor.speed *= -0.5f; } EnPp_SetupRoar(this); @@ -682,7 +682,7 @@ void EnPp_SetupAttack(EnPp* this) { EnPp_ChangeAnim(this, EN_PP_ANIM_ATTACK); this->hornColliderOn = true; this->action = EN_PP_ACTION_ATTACK; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnPp_Attack; } @@ -711,7 +711,7 @@ void EnPp_SetupBounced(EnPp* this) { this->targetPos.x += distanceFromWorldPos.x; this->targetPos.z += distanceFromWorldPos.z; EnPp_ChangeAnim(this, EN_PP_ANIM_DAMAGE); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->action = EN_PP_ACTION_BOUNCED; this->chargeAndBounceSpeed = 14.0f; this->actionFunc = EnPp_Bounced; @@ -751,7 +751,7 @@ void EnPp_Roar(EnPp* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (EnPp_CheckCollision(this, play) == EN_PP_COLLISION_RESULT_ABOUT_TO_RUN_OFF_LEDGE) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->chargeAndBounceSpeed = 0.0f; } @@ -771,8 +771,8 @@ void EnPp_Roar(EnPp* this, PlayState* play) { } } - Math_ApproachZeroF(&this->actor.speedXZ, 0.5f, 1.0f); - if ((this->actor.speedXZ > 0.3f) && (this->secondaryTimer == 0)) { + Math_ApproachZeroF(&this->actor.speed, 0.5f, 1.0f); + if ((this->actor.speed > 0.3f) && (this->secondaryTimer == 0)) { EnPp_SpawnDust(this, play); this->secondaryTimer = 3; } @@ -793,7 +793,7 @@ void EnPp_SetupJump(EnPp* this) { this->secondaryTimer = 0; this->actionVar.hasLandedFromJump = false; this->timer = this->secondaryTimer; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 20.0f; this->actor.gravity = -3.0f; EnPp_ChangeAnim(this, EN_PP_ANIM_JUMP); @@ -836,7 +836,7 @@ void EnPp_Jump(EnPp* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRotY, 1, 0x1388, 0); if (!this->actionVar.hasLandedFromJump) { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->actionVar.hasLandedFromJump = true; EnPp_ChangeAnim(this, EN_PP_ANIM_LAND); } @@ -853,7 +853,7 @@ void EnPp_SetupStunnedOrFrozen(EnPp* this) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->action = EN_PP_ACTION_STUNNED_OR_FROZEN; this->actionFunc = EnPp_StunnedOrFrozen; } @@ -914,7 +914,7 @@ void EnPp_SetupDamaged(EnPp* this, PlayState* play) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); this->secondaryTimer = 0; EnPp_ChangeAnim(this, EN_PP_ANIM_DAMAGE); this->targetRotY = this->actor.yawTowardsPlayer + 0x8000; @@ -922,10 +922,10 @@ void EnPp_SetupDamaged(EnPp* this, PlayState* play) { if (EnPp_CheckCollision(this, play) == EN_PP_COLLISION_RESULT_ABOUT_TO_RUN_OFF_LEDGE) { this->damagedVelocity.z = 0.0f; this->damagedVelocity.x = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_HIPLOOP_DAMAGE); this->actionFunc = EnPp_Damaged; } @@ -957,7 +957,7 @@ void EnPp_Damaged(EnPp* this, PlayState* play) { if (EnPp_CheckCollision(this, play) == EN_PP_COLLISION_RESULT_ABOUT_TO_RUN_OFF_LEDGE) { this->damagedVelocity.z = 0.0f; this->damagedVelocity.x = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } if ((fabsf(this->actor.home.pos.y - this->actor.world.pos.y) > 100.0f) && @@ -998,10 +998,10 @@ void EnPp_SetupDead(EnPp* this, PlayState* play) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 25); Enemy_StartFinishingBlow(play, &this->actor); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_EN_HIPLOOP_DEAD); - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~ACTOR_FLAG_1; this->action = EN_PP_ACTION_DEAD; this->actionFunc = EnPp_Dead; @@ -1096,7 +1096,7 @@ void EnPp_Mask_SetupDetach(EnPp* this, PlayState* play) { } this->actor.gravity = 0.0f; - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~ACTOR_FLAG_1; this->actionVar.maskDetachState = EN_PP_MASK_DETACH_STATE_START; EnPp_ChangeAnim(this, EN_PP_ANIM_IDLE); @@ -1117,7 +1117,7 @@ void EnPp_Mask_Detach(EnPp* this, PlayState* play) { this->maskAccelY = 50.0f; this->maskVelocity.y = -230.0f; this->maskVelocity.x = -150.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HIPLOOP_MASC_OFF); + Actor_PlaySfx(&this->actor, NA_SE_EN_HIPLOOP_MASC_OFF); this->actionVar.maskDetachState = EN_PP_MASK_DETACH_STATE_FALL; break; @@ -1172,7 +1172,7 @@ void EnPp_BodyPart_SetupMove(EnPp* this) { this->deadBodyPartRotationalVelocity.x = (this->deadBodyPartIndex * 0x2E) + 0xFF00; this->deadBodyPartRotationalVelocity.z = (this->deadBodyPartIndex * 0x2E) + 0xFF00; if (EN_PP_GET_TYPE(&this->actor) != EN_PP_TYPE_BODY_PART_BODY) { - this->actor.speedXZ = Rand_ZeroFloat(4.0f) + 4.0f; + this->actor.speed = Rand_ZeroFloat(4.0f) + 4.0f; this->actor.world.rot.y = ((s32)randPlusMinusPoint5Scaled(223.0f) + 0x1999) * this->deadBodyPartIndex; } @@ -1224,7 +1224,7 @@ void EnPp_BodyPart_Move(EnPp* this, PlayState* play) { SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_BOMB_DROP_WATER); } - if ((this->timer == 0) || (this->actor.bgCheckFlags & 1)) { + if ((this->timer == 0) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { Actor_Kill(&this->actor); } } @@ -1276,8 +1276,9 @@ void EnPp_UpdateDamage(EnPp* this, PlayState* play) { (this->drawDmgEffTimer == 0)) { this->drawDmgEffTimer = 40; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, + 40); EnPp_SetupStunnedOrFrozen(this); } return; @@ -1285,8 +1286,9 @@ void EnPp_UpdateDamage(EnPp* this, PlayState* play) { if (((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_SFX) && (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) || (this->drawDmgEffTimer == 0)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, + 40); this->secondaryTimer = 40; EnPp_SetupStunnedOrFrozen(this); } @@ -1295,7 +1297,7 @@ void EnPp_UpdateDamage(EnPp* this, PlayState* play) { (this->actor.colChkInfo.damageEffect != EN_PP_DMGEFF_JUMP)) { attackDealsDamage = true; this->hasBeenDamaged = true; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->actor.colChkInfo.damageEffect == EN_PP_DMGEFF_FIRE) { this->drawDmgEffTimer = 40; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; @@ -1323,7 +1325,8 @@ void EnPp_UpdateDamage(EnPp* this, PlayState* play) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); - Actor_SetColorFilter(&this->actor, 0x8000, 255, 0, 25); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_GRAY, 255, COLORFILTER_BUFFLAG_OPA, + 25); this->drawDmgEffTimer = 20; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; } @@ -1350,7 +1353,7 @@ void EnPp_UpdateDamage(EnPp* this, PlayState* play) { this->secondaryTimer = 0; this->timer = 10; this->maskBounceRotationalVelocity = 0x20D0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->action == EN_PP_ACTION_CHARGE) { this->actionVar.isCharging = false; EnPp_ChangeAnim(this, EN_PP_ANIM_TURN_TO_FACE_PLAYER); @@ -1359,7 +1362,7 @@ void EnPp_UpdateDamage(EnPp* this, PlayState* play) { this->targetRotY = this->actor.yawTowardsPlayer; if (EN_PP_GET_TYPE(&this->actor) == EN_PP_TYPE_MASKED) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SHIELD_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_IT_SHIELD_BOUND); } } } @@ -1413,7 +1416,7 @@ void EnPp_Update(Actor* thisx, PlayState* play) { if (this->action != EN_PP_ACTION_BODY_PART_MOVE) { EnPp_UpdateDamage(this, play); Actor_SetFocus(&this->actor, 40.0f); - if ((this->action == EN_PP_ACTION_DEAD) || (this->actor.bgCheckFlags & 1)) { + if ((this->action == EN_PP_ACTION_DEAD) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->actor.world.pos.x += this->damagedVelocity.x; this->actor.world.pos.z += this->damagedVelocity.z; Math_ApproachZeroF(&this->damagedVelocity.x, 1.0f, 2.0f); @@ -1421,7 +1424,9 @@ void EnPp_Update(Actor* thisx, PlayState* play) { } } - Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 40.0f, 40.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 40.0f, 40.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); if (this->action != EN_PP_ACTION_BODY_PART_MOVE) { this->actor.shape.rot.y = this->actor.world.rot.y; } diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.c b/src/overlays/actors/ovl_En_Pr/z_en_pr.c index 5068c96ee..ab47e693f 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.c +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.c @@ -241,7 +241,7 @@ void func_80A326F0(EnPr* this) { func_80A3242C(this, 0); } this->unk_206 = 0; - this->actor.speedXZ = 1.0f; + this->actor.speed = 1.0f; this->actionFunc = func_80A32740; } @@ -343,19 +343,19 @@ void func_80A32AF8(EnPr* this) { void func_80A32B20(EnPr* this, PlayState* play) { Player* player = GET_PLAYER(play); - this->actor.speedXZ = BREG(57) + 3.0f; + this->actor.speed = BREG(57) + 3.0f; Math_SmoothStepToS(&this->unk_22C, this->actor.yawTowardsPlayer, BREG(49) + 1, BREG(50) + 1000, BREG(51)); this->unk_2B8 = D_80A338C0[GET_PLAYER_FORM] + player->actor.world.pos.y; func_80A324E0(this, play); if (!(player->stateFlags1 & PLAYER_STATE1_8000000)) { this->skelAnime.playSpeed = 1.0f; - this->actor.speedXZ = 1.0f; + this->actor.speed = 1.0f; func_80A32854(this); } else if (this->unk_2C8 < sqrtf(SQ(player->actor.world.pos.x - this->actor.home.pos.x) + SQ(player->actor.world.pos.z - this->actor.home.pos.z))) { this->skelAnime.playSpeed = 1.0f; - this->actor.speedXZ = 1.0f; + this->actor.speed = 1.0f; func_80A32854(this); } else if (!func_80A325E4(this) && (this->actor.xzDistToPlayer < 200.0f) && (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 80.0f)) { @@ -377,7 +377,7 @@ void func_80A32D28(EnPr* this, PlayState* play) { if (!(player->stateFlags1 & PLAYER_STATE1_8000000)) { this->skelAnime.playSpeed = 1.0f; - this->actor.speedXZ = 1.0f; + this->actor.speed = 1.0f; func_80A32854(this); } else { Math_SmoothStepToS(&this->unk_22C, this->actor.yawTowardsPlayer, BREG(49) + 1, BREG(50) + 1000, BREG(51)); @@ -387,7 +387,7 @@ void func_80A32D28(EnPr* this, PlayState* play) { if (this->unk_2C8 < sqrtf(SQ(player->actor.world.pos.x - this->actor.home.pos.x) + SQ(player->actor.world.pos.z - this->actor.home.pos.z))) { this->skelAnime.playSpeed = 1.0f; - this->actor.speedXZ = 1.0f; + this->actor.speed = 1.0f; func_80A32854(this); } } @@ -396,7 +396,7 @@ void func_80A32D28(EnPr* this, PlayState* play) { void func_80A32E60(EnPr* this) { func_80A3242C(this, 4); this->unk_206 = 6; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_80A32EA4; } @@ -407,10 +407,10 @@ void func_80A32EA4(EnPr* this, PlayState* play) { if (this->actor.colChkInfo.health <= 0) { this->unk_206 = 7; this->unk_20A = 50; - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->unk_2C4 = 0.0f; Enemy_StartFinishingBlow(play, &this->actor); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEWALK_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLEWALK_DEAD); this->unk_216 = 0; this->actionFunc = func_80A32F48; } else { @@ -470,8 +470,8 @@ void func_80A33098(EnPr* this, PlayState* play) { if ((this->unk_206 != 6) && (this->unk_206 != 7)) { Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEWALK_DAMAGE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLEWALK_DAMAGE); func_80A32E60(this); } } @@ -536,7 +536,9 @@ void EnPr_Update(Actor* thisx, PlayState* play) { } } - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 30.0f, 20.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 30.0f, 20.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); if (this->unk_206 != 7) { diff --git a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c index 0cc6dc134..1c76d5985 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -151,7 +151,7 @@ void EnPr2_Init(Actor* thisx, PlayState* play) { Actor* parent = this->actor.parent; if (parent->update != NULL) { - this->unk_1C8 = ((EnEncount1*)parent)->unk_15A; + this->unk_1C8 = ((EnEncount1*)parent)->pathIndex; this->path = SubS_GetPathByIndex(play, this->unk_1C8, 0x3F); this->unk_208 = parent->world.rot.z * 20.0f; if (this->unk_208 < 20.0f) { @@ -171,9 +171,11 @@ void EnPr2_Init(Actor* thisx, PlayState* play) { func_80A751B4(this); } - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 20.0f, 20.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 20.0f, 20.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); - if (!(this->actor.bgCheckFlags & 0x60)) { + if (!(this->actor.bgCheckFlags & (BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH))) { Actor_Kill(&this->actor); } } @@ -188,8 +190,8 @@ void EnPr2_Destroy(Actor* thisx, PlayState* play) { if (this->actor.parent != NULL) { EnEncount1* encount1 = (EnEncount1*)this->actor.parent; - if ((encount1->actor.update != NULL) && (encount1->unk_14E > 0)) { - encount1->unk_14E--; + if ((encount1->actor.update != NULL) && (encount1->spawnActiveCount > 0)) { + encount1->spawnActiveCount--; } } } @@ -267,13 +269,13 @@ void func_80A745FC(EnPr2* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_EXIST - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_PIRANHA_EXIST - SFX_FLAG); Math_ApproachF(&this->unk_204, 0.02f, 0.1f, 0.005f); if (this->path->unk2 < this->unk_1D0) { - Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.3f, 1.0f); + Math_ApproachF(&this->actor.speed, 5.0f, 0.3f, 1.0f); } else { - Math_ApproachF(&this->actor.speedXZ, 10.0f, 0.3f, 1.0f); + Math_ApproachF(&this->actor.speed, 10.0f, 0.3f, 1.0f); } if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_1D0, &this->unk_21C)) { @@ -326,7 +328,7 @@ void func_80A748E8(EnPr2* this, PlayState* play) { Vec3f sp3C; Math_ApproachF(&this->unk_204, 0.02f, 0.1f, 0.005f); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_EXIST - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_PIRANHA_EXIST - SFX_FLAG); if (fabsf(this->actor.world.rot.y - this->unk_1EE) < 200.0f) { sp48 = true; @@ -334,7 +336,7 @@ void func_80A748E8(EnPr2* this, PlayState* play) { } if (this->unk_1F4 != 255) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Math_SmoothStepToS(&this->unk_1F4, 0, 1, 30, 100); if (this->unk_1F4 < 2) { Actor_Kill(&this->actor); @@ -370,7 +372,7 @@ void func_80A748E8(EnPr2* this, PlayState* play) { sp4C = true; this->unk_1DC = 0; Math_Vec3f_Copy(&this->unk_21C, &this->unk_228); - Math_ApproachF(&this->actor.speedXZ, 3.0f, 0.3f, 0.2f); + Math_ApproachF(&this->actor.speed, 3.0f, 0.3f, 0.2f); } } break; @@ -383,7 +385,7 @@ void func_80A748E8(EnPr2* this, PlayState* play) { this->unk_1D6 = true; } - Math_ApproachZeroF(&this->actor.speedXZ, 0.1f, 0.2f); + Math_ApproachZeroF(&this->actor.speed, 0.1f, 0.2f); if (this->unk_1DA == 1) { this->unk_1D8 = Rand_S16Offset(100, 100); @@ -393,12 +395,13 @@ void func_80A748E8(EnPr2* this, PlayState* play) { Math_Vec3f_Copy(&this->unk_21C, &sp3C); } } else { - Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.3f, 0.2f); + Math_ApproachF(&this->actor.speed, 2.0f, 0.3f, 0.2f); Math_Vec3f_Copy(&sp3C, &this->actor.world.pos); sp3C.x += Math_SinS(this->actor.world.rot.y) * 20.0f; sp3C.z += Math_CosS(this->actor.world.rot.y) * 20.0f; if (fabsf(this->actor.world.rot.y - this->unk_1EE) < 100.0f) { - if (BgCheck_SphVsFirstPoly(&play->colCtx, &sp3C, 20.0f) || (this->actor.bgCheckFlags & 8)) { + if (BgCheck_SphVsFirstPoly(&play->colCtx, &sp3C, 20.0f) || + (this->actor.bgCheckFlags & BGCHECKFLAG_WALL)) { this->unk_1DC = 0; this->unk_1F2++; Math_Vec3f_Copy(&this->unk_21C, &this->unk_228); @@ -430,7 +433,7 @@ void func_80A74DEC(EnPr2* this, PlayState* play) { this->unk_1F0 = 0; func_80A74510(this, 1); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_PIRANHA_ATTACK); Math_Vec3f_Copy(&this->unk_21C, &player->actor.world.pos); this->unk_1EE = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_21C); @@ -452,7 +455,7 @@ void func_80A74E90(EnPr2* this, PlayState* play) { } if (this->unk_1F4 != 255) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Math_SmoothStepToS(&this->unk_1F4, 0, 1, 30, 100); if (this->unk_1F4 < 2) { Actor_Kill(&this->actor); @@ -470,7 +473,7 @@ void func_80A74E90(EnPr2* this, PlayState* play) { } this->unk_21C.y = player->actor.world.pos.y + 30.0f + this->unk_20C; - Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.3f, 1.0f); + Math_ApproachF(&this->actor.speed, 5.0f, 0.3f, 1.0f); this->unk_1F0 = 0; if (this->unk_1E0 == 2) { @@ -514,7 +517,7 @@ void func_80A74E90(EnPr2* this, PlayState* play) { void func_80A751B4(EnPr2* this) { this->unk_1EC = 0; - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~ACTOR_FLAG_1; if (this->unk_1E0 < 10) { func_80A74510(this, 2); @@ -532,10 +535,10 @@ void func_80A751B4(EnPr2* this) { this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.shape.rot.z = this->actor.world.rot.z; this->unk_1D8 = 30; - this->actor.speedXZ = Rand_ZeroFloat(0.5f); + this->actor.speed = Rand_ZeroFloat(0.5f); this->actor.world.rot.y = randPlusMinusPoint5Scaled(0x8000); } - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 10); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 10); this->unk_1D4 = 3; this->actionFunc = func_80A75310; } @@ -614,8 +617,8 @@ void func_80A755D8(EnPr2* this, PlayState* play) { Actor_ApplyDamage(&this->actor); if ((this->actor.colChkInfo.health <= 0) && (this->unk_1D4 != 3)) { Enemy_StartFinishingBlow(play, &this->actor); - this->actor.speedXZ = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_DEAD); + this->actor.speed = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_PIRANHA_DEAD); if (this->unk_218 >= 0) { Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, D_80A75C3C[this->unk_218]); @@ -627,7 +630,7 @@ void func_80A755D8(EnPr2* this, PlayState* play) { } if (this->collider.base.atFlags & AT_BOUNCED) { - this->actor.speedXZ = -10.0f; + this->actor.speed = -10.0f; } } @@ -660,7 +663,9 @@ void EnPr2_Update(Actor* thisx, PlayState* play) { Actor_SetFocus(&this->actor, 10.0f); func_80A755D8(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 0, 10.0f, 20.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 0, 10.0f, 20.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); if (this->unk_1D6) { s32 i; diff --git a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h index 617a5cc73..bbcd28afd 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h @@ -10,6 +10,8 @@ typedef void (*EnPr2ActionFunc)(struct EnPr2*, PlayState*); #define ENPR2_GET_F(thisx) ((thisx)->params & 0xF) #define ENPR2_GET_FF0(thisx) (((thisx)->params >> 4) & 0xFF) +#define ENPR2_PARAMS(paramF, paramFF0) (((paramF) & 0xF) | (((paramFF0) << 4) & 0xFF0)) + typedef struct EnPr2 { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.c b/src/overlays/actors/ovl_En_Prz/z_en_prz.c index dad8fc126..e34ffe1f6 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -119,7 +119,7 @@ void EnPrz_Init(Actor* thisx, PlayState* play) { this->unk_1E6 = ENPRZ_GET(&this->actor); this->actor.shape.yOffset = 500.0f; - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~ACTOR_FLAG_1; Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); @@ -218,7 +218,7 @@ s32 func_80A762C0(EnPrz* this, PlayState* play) { } void func_80A76388(EnPrz* this) { - this->actor.speedXZ = randPlusMinusPoint5Scaled(1.0f) + 4.0f; + this->actor.speed = randPlusMinusPoint5Scaled(1.0f) + 4.0f; func_80A75F18(this, 0); this->unk_1EA = 1; this->actionFunc = func_80A763E8; @@ -302,7 +302,7 @@ void func_80A76634(EnPrz* this, PlayState* play) { } void func_80A76748(EnPrz* this) { - this->actor.speedXZ = randPlusMinusPoint5Scaled(1.0f) + 3.0f; + this->actor.speed = randPlusMinusPoint5Scaled(1.0f) + 3.0f; this->unk_1EE = 0; this->unk_1EA = 3; this->skelAnime.playSpeed = 2.0f; @@ -317,7 +317,7 @@ void func_80A767A8(EnPrz* this, PlayState* play) { if (func_80A762C0(this, play)) { func_80A75F18(this, 0); - this->actor.speedXZ = randPlusMinusPoint5Scaled(1.0f) + 4.0f; + this->actor.speed = randPlusMinusPoint5Scaled(1.0f) + 4.0f; func_80A76604(this, play); return; } @@ -360,10 +360,10 @@ void func_80A767A8(EnPrz* this, PlayState* play) { void func_80A76A1C(EnPrz* this) { this->unk_1E8 = 0; - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->actor.flags &= ~ACTOR_FLAG_1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEWALK_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_BUBLEWALK_DEAD); this->unk_1EE = Rand_S16Offset(100, 30); this->unk_1FC = 0x4000; @@ -373,10 +373,10 @@ void func_80A76A1C(EnPrz* this) { } this->unk_1FE = this->actor.world.rot.y; - this->actor.speedXZ = Rand_ZeroFloat(0.5f); + this->actor.speed = Rand_ZeroFloat(0.5f); this->actor.world.rot.y = randPlusMinusPoint5Scaled(0x8000); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 30); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 30); this->unk_1EE = 50; func_80A75F18(this, 0); this->unk_1EA = 7; @@ -441,7 +441,9 @@ void EnPrz_Update(Actor* thisx, PlayState* play) { } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 10.0f, 10.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 10.0f, 10.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); if (this->unk_1EA != 7) { Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); diff --git a/src/overlays/actors/ovl_En_Pst/z_en_pst.c b/src/overlays/actors/ovl_En_Pst/z_en_pst.c index c49852746..cef354c70 100644 --- a/src/overlays/actors/ovl_En_Pst/z_en_pst.c +++ b/src/overlays/actors/ovl_En_Pst/z_en_pst.c @@ -393,7 +393,7 @@ void EnPst_Init(Actor* thisx, PlayState* play) { this->actor.targetMode = 0; Actor_SetScale(&this->actor, 0.02f); this->actionFunc = EnPst_FollowSchedule; - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } void EnPst_Destroy(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index 0caa2f8ca..a8e222bec 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -9,14 +9,13 @@ */ #include "z_en_racedog.h" +#include "overlays/actors/ovl_En_Aob_01/z_en_aob_01.h" #include "overlays/actors/ovl_En_Dg/z_en_dg.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnRacedog*)thisx) -//! TODO: this file require macros for its uses of weekEventReg - void EnRacedog_Init(Actor* thisx, PlayState* play); void EnRacedog_Destroy(Actor* thisx, PlayState* play); void EnRacedog_Update(Actor* thisx, PlayState* play); @@ -259,7 +258,7 @@ void EnRacedog_UpdateCollision(EnRacedog* this, PlayState* play) { this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 10.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 10.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } /** @@ -288,7 +287,7 @@ s16 EnRacedog_GetYRotation(Path* path, s32 pointIndex, Vec3f* pos, f32* distSQ) } *distSQ = SQ(diffX) + SQ(diffZ); - return RADF_TO_BINANG(Math_Atan2F_XY(diffZRand, diffXRand)); + return RAD_TO_BINANG(Math_Atan2F_XY(diffZRand, diffXRand)); } void EnRacedog_GetFloorRot(EnRacedog* this, Vec3f* floorRot) { @@ -317,7 +316,7 @@ void EnRacedog_Init(Actor* thisx, PlayState* play) { this->path = SubS_GetPathByIndex(play, ENRACEDOG_GET_PATH(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.gravity = -3.0f; - if (ENRACEDOG_GET_INDEX(&this->actor) < 14) { + if (ENRACEDOG_GET_INDEX(&this->actor) < RACEDOG_COUNT) { this->index = ENRACEDOG_GET_INDEX(&this->actor); } else { Actor_Kill(&this->actor); @@ -353,7 +352,7 @@ void EnRacedog_Init(Actor* thisx, PlayState* play) { this->actor.flags |= ACTOR_FLAG_10; this->actor.flags |= ACTOR_FLAG_20; - sSelectedDogInfo = sDogInfo[(s16)((gSaveContext.eventInf[0] & 0xF8) >> 3)]; + sSelectedDogInfo = sDogInfo[(s16)GET_EVENTINF_DOG_RACE_SELECTED_DOG_INDEX]; this->selectedDogIndex = sSelectedDogInfo.index; EnRacedog_ChangeAnim(&this->skelAnime, sAnimationInfo, RACEDOG_ANIM_IDLE); @@ -393,7 +392,7 @@ void EnRacedog_Race(EnRacedog* this, PlayState* play) { this->collider.dim.radius = 15; if (this->path != NULL) { yRotation = EnRacedog_GetYRotation(this->path, this->currentPoint, &this->actor.world.pos, &distSq); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { yRotation = this->actor.wallYaw; } @@ -439,14 +438,8 @@ void EnRacedog_Race(EnRacedog* this, PlayState* play) { * or an intentional choice to introduce a bit of extra variance to the race. */ void EnRacedog_UpdateTextId(EnRacedog* this) { - // Assuming that the weekEventRegs haven't been tampered with, then this will produce a text ID in the - // range of 0x3539 to 0x3546. - if (this->index % 2) { - sDogInfo[this->index].textId = - (((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & 0xF0) >> 4) + 0x3539; - } else { - sDogInfo[this->index].textId = ((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & 0x0F) + 0x3539; - } + // This will produce a text ID in the range of 0x3539 to 0x3546. + sDogInfo[this->index].textId = GET_WEEKEVENTREG_DOG_RACE_TEXT(this->index, 0x3539); // As a sanity check, this makes sure the text ID is something in the expected range of 0x3539 to 0x3546. if ((sDogInfo[this->index].textId > 0x3546) || (sDogInfo[this->index].textId < 0x3539)) { @@ -515,16 +508,16 @@ void EnRacedog_UpdateSpeed(EnRacedog* this) { this->actor.shape.rot.y = this->actor.world.rot.y; } - Math_ApproachF(&this->actor.speedXZ, this->targetSpeed, 0.5f, 3.0f); + Math_ApproachF(&this->actor.speed, this->targetSpeed, 0.5f, 3.0f); // The dog that the player has selected has a slightly higher max speed than the other dogs. if (this->index == this->selectedDogIndex) { - if (this->actor.speedXZ > 7.5f) { - this->actor.speedXZ = 7.5f; + if (this->actor.speed > 7.5f) { + this->actor.speed = 7.5f; } } else { - if (this->actor.speedXZ > 7.0f) { - this->actor.speedXZ = 7.0f; + if (this->actor.speed > 7.0f) { + this->actor.speed = 7.0f; } } } @@ -586,13 +579,13 @@ void EnRacedog_CheckForFinish(EnRacedog* this) { this->raceStatus == RACEDOG_RACE_STATUS_AFTER_POINT_11) { sNumberOfDogsFinished++; if (sNumberOfDogsFinished == 1) { - Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_HORSE_GOAL | SEQ_FLAG_ASYNC); play_sound(NA_SE_SY_START_SHOT); } this->raceStatus = RACEDOG_RACE_STATUS_FINISHED; if (this->index == this->selectedDogIndex) { - gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (sNumberOfDogsFinished * 8); + SET_EVENTINF_DOG_RACE_RACE_STANDING(sNumberOfDogsFinished); } } } @@ -602,7 +595,7 @@ void EnRacedog_CheckForFinish(EnRacedog* this) { * to normal speed otherwise. */ void EnRacedog_UpdateRunAnimationPlaySpeed(EnRacedog* this) { - if (this->actor.speedXZ < 3.0f) { + if (this->actor.speed < 3.0f) { sAnimationInfo[RACEDOG_ANIM_RUN].playSpeed = 0.9f; } else { sAnimationInfo[RACEDOG_ANIM_RUN].playSpeed = 1.0f; @@ -660,7 +653,7 @@ s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* finishLineCoordinates) { void EnRacedog_SpawnFloorDustRing(EnRacedog* this, PlayState* play) { s16 curFrame = this->skelAnime.curFrame; - s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; + s16 mod = (this->actor.speed > 6.0f) ? 2 : 3; Vec3f pos; if (((this->index + curFrame) % mod) == 0) { @@ -675,7 +668,7 @@ void EnRacedog_PlaySfxWalk(EnRacedog* this) { s16 curFrame = this->skelAnime.curFrame; if ((curFrame == 1) || (curFrame == 7)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_MONKEY_WALK); } } @@ -701,7 +694,7 @@ void EnRacedog_Update(Actor* thisx, PlayState* play) { } } - if (!(this->actor.bgCheckFlags & 1)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->skelAnime.curFrame = 0.0f; } diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h index 9d49ea4c2..a8cf2a9f9 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h @@ -6,6 +6,7 @@ #define ENRACEDOG_GET_INDEX(thisx) (((thisx)->params & 0x3E0) >> 5) #define ENRACEDOG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 10) +#define ENRACEDOG_PARAMS(index, path) ((index << 5) | (path)) /** * The main point of this seems to be some very light anti-cheat detection. The dog diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.c b/src/overlays/actors/ovl_En_Raf/z_en_raf.c index 8421b20ac..6a3f1af5a 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.c +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.c @@ -6,7 +6,7 @@ #include "z_en_raf.h" -#define FLAGS (ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnRaf*)thisx) @@ -310,7 +310,7 @@ void EnRaf_Idle(EnRaf* this, PlayState* play) { if (this->timer == 0) { if ((player->transformation != PLAYER_FORM_DEKU) && (this->dyna.actor.xzDistToPlayer < (BREG(48) + 80.0f) && (player->invincibilityTimer == 0) && - DynaPolyActor_IsInRidingMovingState(&this->dyna) && !(player->stateFlags1 & PLAYER_STATE1_8000000) && + DynaPolyActor_IsPlayerOnTop(&this->dyna) && !(player->stateFlags1 & PLAYER_STATE1_8000000) && play->grabPlayer(play, player))) { player->actor.parent = &this->dyna.actor; this->grabTarget = EN_RAF_GRAB_TARGET_PLAYER; @@ -360,7 +360,7 @@ void EnRaf_Idle(EnRaf* this, PlayState* play) { void EnRaf_SetupGrab(EnRaf* this) { EnRaf_ChangeAnim(this, EN_RAF_ANIM_CLOSE); this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_GRAB; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_DRINK); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EN_SUISEN_DRINK); this->action = EN_RAF_ACTION_GRAB; this->actionFunc = EnRaf_Grab; } @@ -426,11 +426,15 @@ void EnRaf_Chew(EnRaf* this, PlayState* play) { this->chewCount++; } - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_EAT); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EN_SUISEN_EAT); switch (this->grabTarget) { case EN_RAF_GRAB_TARGET_PLAYER: play->damagePlayer(play, -2); - func_800B8E58((Player*)this, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S); + + //! @bug: This function should only pass Player*: it uses *(this + 0x153), which is meant to be + //! player->currentMask, but in this case is padding in `DynaPolyActor` + Player_PlaySfx((Player*)&this->dyna.actor, + player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S); CollisionCheck_GreenBlood(play, NULL, &player->actor.world.pos); if ((this->chewCount > (BREG(53) + 5)) || !(player->stateFlags2 & PLAYER_STATE2_80)) { player->actor.freezeTimer = 10; @@ -478,7 +482,7 @@ void EnRaf_Throw(EnRaf* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 10.0f)) { player->actor.freezeTimer = 0; player->actor.parent = NULL; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_THROW); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EN_SUISEN_THROW); func_800B8D50(play, &this->dyna.actor, BREG(55) + 3.0f, this->playerRotYWhenGrabbed + 0x8000, BREG(56) + 10.0f, 0); } else if (curFrame < 10.0f) { @@ -508,8 +512,8 @@ void EnRaf_Explode(EnRaf* this, PlayState* play) { explosionPos.y += 10.0f; Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, explosionPos.x, explosionPos.y, explosionPos.z, 0, 0, 0, CLEAR_TAG_SMALL_EXPLOSION); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_BOMB_EXPLOSION); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_DEAD); + Actor_PlaySfx(&this->dyna.actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EN_SUISEN_DEAD); if (this->switchFlag >= 0) { Flags_SetSwitch(play, this->switchFlag); } @@ -706,11 +710,11 @@ void EnRaf_Update(Actor* thisx, PlayState* play) { return; } - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { if ((this->heightDiffFromPlayer > -0.1f) && !this->isCurrentlyInRidingMovingState) { this->heightDiffFromPlayer = -20.0f; this->isCurrentlyInRidingMovingState = true; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_COMMON_WATER_MID); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EN_COMMON_WATER_MID); } } else { this->isCurrentlyInRidingMovingState = false; 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 073f2045a..10d654cc7 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 @@ -281,7 +281,7 @@ void EnRailSkb_Init(Actor* thisx, PlayState* play) { } Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.speedXZ = 1.6f; + this->actor.speed = 1.6f; this->actor.hintId = TATL_HINT_ID_STALCHILD; this->unk_3F2 = 0; this->unk_2E4 = -1; @@ -296,7 +296,7 @@ void EnRailSkb_Init(Actor* thisx, PlayState* play) { this->unk_3F8 = 0; } - if ((play->sceneId == SCENE_BOTI) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_BOTI) && (gSaveContext.sceneLayer == 1) && (play->csCtx.scriptIndex == 0)) { this->actor.flags |= ACTOR_FLAG_100000; } @@ -334,7 +334,7 @@ void func_80B70FF8(EnRailSkb* this, PlayState* play) { } void func_80B710AC(EnRailSkb* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = func_80B710E4; } @@ -345,7 +345,7 @@ void func_80B710E4(EnRailSkb* this, PlayState* play) { } void func_80B71114(EnRailSkb* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = func_80B7114C; } @@ -355,9 +355,9 @@ void func_80B7114C(EnRailSkb* this, PlayState* play) { this->drawDmgEffScale = 0.0f; this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_402 |= 1; func_80B712FC(this); } else { @@ -379,9 +379,9 @@ void func_80B7123C(EnRailSkb* this, PlayState* play) { this->drawDmgEffScale = 0.0f; this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_402 |= 1; func_80B712FC(this); } else { @@ -405,7 +405,7 @@ void func_80B71314(EnRailSkb* this, PlayState* play) { } void func_80B71354(EnRailSkb* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_ATTACK); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); this->actionFunc = func_80B713A4; } @@ -452,7 +452,7 @@ void func_80B7151C(EnRailSkb* this) { this->actor.colChkInfo.health = 2; this->unk_402 = 0; this->actor.flags |= ACTOR_FLAG_1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); + Actor_PlaySfx(&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; @@ -575,7 +575,7 @@ void func_80B71954(EnRailSkb* this, PlayState* play) { } void func_80B71A08(EnRailSkb* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_ATTACK); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); this->actionFunc = func_80B71A58; } @@ -584,7 +584,7 @@ void func_80B71A58(EnRailSkb* this, PlayState* play) { s16 sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_ATTACK); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); if (this->unk_2E8 < this->unk_22C->dyna.actor.colChkInfo.health) { this->unk_22C->dyna.actor.colChkInfo.health--; @@ -625,7 +625,7 @@ void func_80B71BB8(EnRailSkb* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos), 1, 0x71C, 0xB6); - if ((this->actor.bgCheckFlags & 1) && (this->unk_22C->dyna.actor.colChkInfo.health == 0)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->unk_22C->dyna.actor.colChkInfo.health == 0)) { Actor_MoveWithGravity(&this->actor); } else { this->actor.velocity.y += this->actor.gravity; @@ -634,13 +634,13 @@ void func_80B71BB8(EnRailSkb* this, PlayState* play) { Math_SmoothStepToF(&this->actor.world.pos.z, this->unk_22C->dyna.actor.world.pos.z, 0.6f, 1.6f, 0.1f); } - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { Actor_Kill(&this->actor); return; } - if ((sp34 < 50.0f) && (this->actor.bgCheckFlags & 1)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + if ((sp34 < 50.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_ATTACK); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 9); this->actor.velocity.y = 10.0f; @@ -732,7 +732,7 @@ void func_80B71F3C(EnRailSkb* this, PlayState* play) { Message_StartTextbox(play, 0x13F4, &this->actor); this->unk_400 = 0x13F4; } else { - func_801477B4(play); + Message_CloseTextbox(play); func_80B71D8C(this, play, func_80B71650); } break; @@ -744,7 +744,7 @@ void func_80B71F3C(EnRailSkb* this, PlayState* play) { break; case 0x13F4: - func_801477B4(play); + Message_CloseTextbox(play); func_80B71D8C(this, play, func_80B718B0); break; } @@ -773,7 +773,7 @@ void func_80B72190(EnRailSkb* this, PlayState* play) { if ((this->actionFunc != func_80B714D8) && (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 15.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_WALK); } if (this->actor.parent == NULL) { @@ -984,12 +984,12 @@ void func_80B72970(EnRailSkb* this, PlayState* play) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; this->drawDmgEffAlpha = 1.0f; this->drawDmgEffScale = 0.0f; - Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 120, COLORFILTER_BUFFLAG_OPA, 40); func_80B710AC(this); break; case 1: - Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 120, COLORFILTER_BUFFLAG_OPA, 40); func_80B710AC(this); break; @@ -998,8 +998,8 @@ void func_80B72970(EnRailSkb* this, PlayState* play) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->drawDmgEffAlpha = 1.0f; this->drawDmgEffScale = 0.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); this->unk_402 |= 1; func_80B712FC(this); @@ -1007,7 +1007,7 @@ void func_80B72970(EnRailSkb* this, PlayState* play) { case 3: if (this->actor.colChkInfo.health != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->drawDmgEffTimer = 80; } else { this->drawDmgEffTimer = 3; @@ -1015,7 +1015,7 @@ void func_80B72970(EnRailSkb* this, PlayState* play) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; this->drawDmgEffAlpha = 1.0f; this->drawDmgEffScale = 0.5f; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); func_80B71114(this); break; @@ -1024,8 +1024,8 @@ void func_80B72970(EnRailSkb* this, PlayState* play) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->drawDmgEffAlpha = 1.0f; this->drawDmgEffScale = 0.5f; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); func_80B71228(this); break; @@ -1043,8 +1043,8 @@ void func_80B72970(EnRailSkb* this, PlayState* play) { } case 13: - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); func_80B712FC(this); break; @@ -1071,7 +1071,7 @@ void EnRailSkb_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); func_80B72190(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 60.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 60.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); func_80B72970(this, play); if ((this->actionFunc != func_80B710E4) && (this->actionFunc != func_80B7114C) && 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 50a203c81..853dbfd61 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -44,7 +44,7 @@ s32 EnRailgibud_MoveToIdealGrabPositionAndRotation(EnRailgibud* this, PlayState* void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, PlayState* play); void EnRailgibud_MainGibdo_DeadUpdate(Actor* thisx, PlayState* play); void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, PlayState* play); -void EnRailgibud_InitActorActionCommand(EnRailgibud* this); +void EnRailgibud_InitCueType(EnRailgibud* this); void EnRailgibud_SetupDoNothing(EnRailgibud* this); void EnRailgibud_DoNothing(EnRailgibud* this, PlayState* play); void EnRailgibud_SinkIntoGround(EnRailgibud* this, PlayState* play); @@ -286,7 +286,7 @@ void EnRailgibud_Destroy(Actor* thisx, PlayState* play) { } void EnRailgibud_SetupWalkInCircles(EnRailgibud* this) { - this->actor.speedXZ = 0.6f; + this->actor.speed = 0.6f; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_WALK); this->actionFunc = EnRailgibud_WalkInCircles; } @@ -350,7 +350,7 @@ void EnRailgibud_AttemptPlayerFreeze(EnRailgibud* this, PlayState* play) { player->actor.freezeTimer = 60; Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(play, &this->actor); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_AIM); EnRailgibud_SetupWalkToPlayer(this); } @@ -359,7 +359,7 @@ void EnRailgibud_AttemptPlayerFreeze(EnRailgibud* this, PlayState* play) { void EnRailgibud_SetupWalkToPlayer(EnRailgibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_WALK); - this->actor.speedXZ = 0.4f; + this->actor.speed = 0.4f; if (this->actionFunc == EnRailgibud_AttemptPlayerFreeze) { this->playerStunWaitTimer = 80; @@ -396,7 +396,7 @@ void EnRailgibud_WalkToPlayer(EnRailgibud* this, PlayState* play) { this->playerStunWaitTimer = 60; Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(play, &this->actor); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_AIM); } else { this->playerStunWaitTimer--; } @@ -412,9 +412,9 @@ void EnRailgibud_WalkToPlayer(EnRailgibud* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_WALK); } else if (!(play->gameplayFrames & 95)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -452,7 +452,7 @@ void EnRailgibud_Grab(EnRailgibud* this, PlayState* play) { damageSfxId = player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S; play->damagePlayer(play, -8); - func_800B8E58(player, damageSfxId); + Player_PlaySfx(player, damageSfxId); Rumble_Request(this->actor.xzDistToPlayer, 240, 1, 12); this->grabDamageTimer = 0; } else { @@ -460,7 +460,7 @@ void EnRailgibud_Grab(EnRailgibud* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_ATTACK); } if (!(player->stateFlags2 & PLAYER_STATE2_80) || (player->unk_B62 != 0)) { @@ -490,14 +490,14 @@ void EnRailgibud_Grab(EnRailgibud* this, PlayState* play) { void EnRailgibud_SetupGrabFail(EnRailgibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_DAMAGE); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); - this->actor.speedXZ = -2.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + this->actor.speed = -2.0f; this->actionFunc = EnRailgibud_GrabFail; } void EnRailgibud_GrabFail(EnRailgibud* this, PlayState* play) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.15f; + if (this->actor.speed < 0.0f) { + this->actor.speed += 0.15f; } this->actor.world.rot.y = this->actor.yawTowardsPlayer; @@ -530,18 +530,18 @@ void EnRailgibud_TurnAwayAndShakeHead(EnRailgibud* this, PlayState* play) { void EnRailgibud_SetupWalkToHome(EnRailgibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_WALK); - this->actor.speedXZ = 0.4f; + this->actor.speed = 0.4f; this->actionFunc = EnRailgibud_WalkToHome; } void EnRailgibud_WalkToHome(EnRailgibud* this, PlayState* play) { Math_SmoothStepToS(&this->headRotation.y, 0, 1, 100, 0); Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 100, 0); - if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 5.0f) { - if (this->actor.speedXZ > 0.2f) { - this->actor.speedXZ -= 0.2f; + if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) < 5.0f) { + if (this->actor.speed > 0.2f) { + this->actor.speed -= 0.2f; } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 200, 10); @@ -550,7 +550,8 @@ void EnRailgibud_WalkToHome(EnRailgibud* this, PlayState* play) { EnRailgibud_SetupWalkInCircles(this); } } else { - Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 450); + Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), + 450); this->actor.world.rot = this->actor.shape.rot; } if (EnRailgibud_PlayerInRangeWithCorrectState(this, play)) { @@ -563,17 +564,17 @@ void EnRailgibud_WalkToHome(EnRailgibud* this, PlayState* play) { void EnRailgibud_SetupDamage(EnRailgibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_DAMAGE); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->stunTimer = 0; this->grabWaitTimer = 0; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actor.speedXZ = -2.0f; + this->actor.speed = -2.0f; this->actionFunc = EnRailgibud_Damage; } void EnRailgibud_Damage(EnRailgibud* this, PlayState* play) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.15f; + if (this->actor.speed < 0.0f) { + this->actor.speed += 0.15f; } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -596,9 +597,9 @@ void EnRailgibud_SetupStunned(EnRailgibud* this) { this->stunTimer = 10; if (this->drawDmgEffTimer != 0) { - Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 200, COLORFILTER_BUFFLAG_OPA, 40); } else { - Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 200, COLORFILTER_BUFFLAG_OPA, 40); } this->actionFunc = EnRailgibud_Stunned; @@ -621,7 +622,7 @@ void EnRailgibud_Stunned(EnRailgibud* this, PlayState* play) { void EnRailgibud_SetupDead(EnRailgibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_DEATH); this->actor.flags &= ~ACTOR_FLAG_1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_DEAD); this->deathTimer = 0; this->actionFunc = EnRailgibud_Dead; } @@ -750,7 +751,7 @@ s32 EnRailgibud_PlayerInRangeWithCorrectState(EnRailgibud* this, PlayState* play return false; } - if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 100.0f && + if (Actor_WorldDistXYZToPoint(&player->actor, &this->actor.home.pos) < 100.0f && !(player->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_40000 | PLAYER_STATE1_80000 | PLAYER_STATE1_200000)) && !(player->stateFlags2 & (PLAYER_STATE2_80 | PLAYER_STATE2_4000))) { @@ -768,7 +769,7 @@ s32 EnRailgibud_PlayerInRangeWithCorrectState(EnRailgibud* this, PlayState* play s32 EnRailgibud_PlayerOutOfRange(EnRailgibud* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 100.0f) { + if (Actor_WorldDistXYZToPoint(&player->actor, &this->actor.home.pos) >= 100.0f) { return true; } @@ -787,7 +788,7 @@ void EnRailgibud_UpdateDamage(EnRailgibud* this, PlayState* play) { switch (this->actor.colChkInfo.damageEffect) { case EN_RAILGIBUD_DMGEFF_DAMAGE: - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); if (player->unk_ADC != 0) { this->unk_405 = player->unk_ADD; } @@ -808,7 +809,7 @@ void EnRailgibud_UpdateDamage(EnRailgibud* this, PlayState* play) { break; case EN_RAILGIBUD_DMGEFF_FIRE_ARROW: - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); if (this->actor.colChkInfo.health == 0) { EnRailgibud_SetupDead(this); } else { @@ -820,7 +821,7 @@ void EnRailgibud_UpdateDamage(EnRailgibud* this, PlayState* play) { break; case EN_RAILGIBUD_DMGEFF_LIGHT_ARROW: - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); if (this->actor.colChkInfo.health == 0) { EnRailgibud_SetupDead(this); } else { @@ -900,13 +901,15 @@ void EnRailgibud_MoveGrabbedPlayerAwayFromWall(EnRailgibud* this, PlayState* pla Vec3f targetPos; if ((this->actionFunc == EnRailgibud_Grab) && (this->grabState != EN_RAILGIBUD_GRAB_RELEASE)) { - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 35.0f, 1); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 35.0f, UPDBGCHECKINFO_FLAG_1); } else { - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 35.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 35.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } if ((this->actionFunc == EnRailgibud_Grab) && (this->grabState == EN_RAILGIBUD_GRAB_START) && - (this->actor.bgCheckFlags & 8)) { + (this->actor.bgCheckFlags & BGCHECKFLAG_WALL)) { targetPos = player->actor.world.pos; targetPos.x += 10.0f * Math_SinS(this->actor.wallYaw); targetPos.z += 10.0f * Math_CosS(this->actor.wallYaw); @@ -962,8 +965,8 @@ void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, PlayState* play) { this->isInvincible = true; Message_StartTextbox(play, 0x13B2, &this->actor); this->textId = 0x13B2; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); - this->actor.speedXZ = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_AIM); + this->actor.speed = 0.0f; } else if (CHECK_FLAG_ALL(this->actor.flags, (ACTOR_FLAG_1 | ACTOR_FLAG_8)) && !(this->collider.base.acFlags & AC_HIT)) { func_800B8614(&this->actor, play, 100.0f); @@ -981,7 +984,7 @@ void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, PlayState* play) { if (Message_ShouldAdvance(play)) { this->textId = 0; this->isInvincible = false; - this->actor.speedXZ = 0.6f; + this->actor.speed = 0.6f; } break; @@ -1103,8 +1106,8 @@ void EnRailgibud_Draw(Actor* thisx, PlayState* play) { void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, PlayState* play) { s32 pad[2]; - EnRailgibud_InitActorActionCommand(this); - this->csAction = 99; + EnRailgibud_InitCueType(this); + this->cueId = 99; this->actor.flags |= ACTOR_FLAG_100000; this->actor.flags |= ACTOR_FLAG_10; @@ -1123,30 +1126,30 @@ void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, PlayState* play) { this->actor.update = EnRailgibud_Cutscene_Update; } -void EnRailgibud_InitActorActionCommand(EnRailgibud* this) { +void EnRailgibud_InitCueType(EnRailgibud* this) { switch (ENRAILGIBUD_GET_CUTSCENE_TYPE(&this->actor)) { case 1: - this->actorActionCommand = 519; + this->cueType = CS_CMD_ACTOR_CUE_519; break; case 2: - this->actorActionCommand = 520; + this->cueType = CS_CMD_ACTOR_CUE_520; break; case 3: - this->actorActionCommand = 521; + this->cueType = CS_CMD_ACTOR_CUE_521; break; case 4: - this->actorActionCommand = 522; + this->cueType = CS_CMD_ACTOR_CUE_522; break; case 5: - this->actorActionCommand = 523; + this->cueType = CS_CMD_ACTOR_CUE_523; break; default: - this->actorActionCommand = 519; + this->cueType = CS_CMD_ACTOR_CUE_519; break; } } @@ -1174,13 +1177,13 @@ void EnRailgibud_SinkIntoGround(EnRailgibud* this, PlayState* play) { } s32 EnRailgibud_PerformCutsceneActions(EnRailgibud* this, PlayState* play) { - s32 actionIndex; + s32 cueChannel; - if (Cutscene_CheckActorAction(play, this->actorActionCommand)) { - actionIndex = Cutscene_GetActorActionIndex(play, this->actorActionCommand); - if (this->csAction != play->csCtx.actorActions[actionIndex]->action) { - this->csAction = play->csCtx.actorActions[actionIndex]->action; - switch (play->csCtx.actorActions[actionIndex]->action) { + if (Cutscene_IsCueInChannel(play, this->cueType)) { + cueChannel = Cutscene_GetCueChannel(play, this->cueType); + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_IDLE; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_IDLE); @@ -1188,7 +1191,7 @@ s32 EnRailgibud_PerformCutsceneActions(EnRailgibud* this, PlayState* play) { case 2: this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_SLUMP_START; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_WEAKENED2); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_WEAKENED2); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_SLUMP_START); break; @@ -1218,7 +1221,7 @@ s32 EnRailgibud_PerformCutsceneActions(EnRailgibud* this, PlayState* play) { } } - switch (this->csAction) { + switch (this->cueId) { case 3: case 4: if (this->actionFunc == EnRailgibud_SinkIntoGround) { @@ -1230,20 +1233,20 @@ s32 EnRailgibud_PerformCutsceneActions(EnRailgibud* this, PlayState* play) { case 5: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - if (play->csCtx.frames < 280) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); + if (play->csCtx.curFrame < 280) { + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_CRY); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_WEAKENED1); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_WEAKENED1); } } break; } - Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); return true; } - this->csAction = 99; + this->cueId = 99; return false; } 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 cf06d1996..95a2bbd7b 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h @@ -47,8 +47,8 @@ typedef struct EnRailgibud { /* 0x3F6 */ s16 drawDmgEffTimer; /* 0x3F8 */ s16 type; /* 0x3FA */ s16 isInvincible; - /* 0x3FC */ u16 actorActionCommand; - /* 0x3FE */ u16 csAction; + /* 0x3FC */ u16 cueType; + /* 0x3FE */ u16 cueId; /* 0x400 */ u16 textId; /* 0x402 */ s16 timeInitialized; // unused other than setting it /* 0x404 */ u8 drawDmgEffType; diff --git a/src/overlays/actors/ovl_En_Rat/z_en_rat.c b/src/overlays/actors/ovl_En_Rat/z_en_rat.c index da0b27e6d..81898dfa6 100644 --- a/src/overlays/actors/ovl_En_Rat/z_en_rat.c +++ b/src/overlays/actors/ovl_En_Rat/z_en_rat.c @@ -293,7 +293,7 @@ void EnRat_ChooseDirection(EnRat* this) { angle -= 0x8000; } } else { - if (Actor_DistanceToPoint(&this->actor, &this->actor.home.pos) > 50.0f) { + if (Actor_WorldDistXYZToPoint(&this->actor, &this->actor.home.pos) > 50.0f) { Vec3f homeInHome; Vec3f worldInHome; Vec3f worldPlusForwardInHome; @@ -331,7 +331,7 @@ void EnRat_ChooseDirection(EnRat* this) { } angle = CLAMP(angle, -0x800, 0x800); - Matrix_RotateAxisF(angle * (M_PI / 0x8000), &this->axisUp, MTXMODE_NEW); + Matrix_RotateAxisF(BINANG_TO_RAD(angle), &this->axisUp, MTXMODE_NEW); Matrix_MultVec3f(&this->axisForwards, &newAxisForwards); Math_Vec3f_Copy(&this->axisForwards, &newAxisForwards); Math3D_CrossProduct(&this->axisUp, &this->axisForwards, &this->axisLeft); @@ -355,7 +355,8 @@ s32 EnRat_IsOnCollisionPoly(PlayState* play, Vec3f* posA, Vec3f* posB, Vec3f* po } if (BgCheck_EntityLineTest1(&play->colCtx, posA, posB, posResult, poly, 1, 1, 1, 1, bgId)) { - if (!(func_800C9A4C(&play->colCtx, *poly, *bgId) & 0x30) && (!isOnWater || (waterSurface <= posResult->y))) { + if (!(SurfaceType_GetWallFlags(&play->colCtx, *poly, *bgId) & (WALL_FLAG_4 | WALL_FLAG_5)) && + (!isOnWater || (waterSurface <= posResult->y))) { return true; } } @@ -386,7 +387,7 @@ s32 EnRat_IsTouchingSurface(EnRat* this, PlayState* play) { bgIdUpDown = bgIdSide = BGCHECK_SCENE; - lineLength = 2.0f * this->actor.speedXZ; + lineLength = 2.0f * this->actor.speed; posA.x = this->actor.world.pos.x + (this->axisUp.x * 5.0f); posA.y = this->actor.world.pos.y + (this->axisUp.y * 5.0f); @@ -409,7 +410,7 @@ s32 EnRat_IsTouchingSurface(EnRat* this, PlayState* play) { this->shouldRotateOntoSurfaces |= EnRat_UpdateFloorPoly(this, polySide, play); Math_Vec3f_Copy(&this->actor.world.pos, &posSide); this->actor.floorBgId = bgIdSide; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { if (polyUpDown != this->actor.floorPoly) { this->shouldRotateOntoSurfaces |= EnRat_UpdateFloorPoly(this, polyUpDown, play); @@ -419,7 +420,7 @@ s32 EnRat_IsTouchingSurface(EnRat* this, PlayState* play) { this->actor.floorBgId = bgIdUpDown; } } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; lineLength *= 3.0f; Math_Vec3f_Copy(&posA, &posB); @@ -494,7 +495,7 @@ void EnRat_HandleNonSceneCollision(EnRat* this, PlayState* play) { f32 cos; f32 tempX; - BgCheck2_UpdateActorAttachedToMesh(&play->colCtx, this->actor.floorBgId, &this->actor); + DynaPolyActor_TransformCarriedActor(&play->colCtx, this->actor.floorBgId, &this->actor); if (yaw != this->actor.shape.rot.y) { yaw = this->actor.shape.rot.y - yaw; @@ -535,7 +536,7 @@ void EnRat_SetupRevive(EnRat* this) { EnRat_InitializeAxes(this); EnRat_UpdateRotation(this); this->actor.flags &= ~ACTOR_FLAG_1; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Animation_PlayLoopSetSpeed(&this->skelAnime, &gRealBombchuSpotAnim, 0.0f); this->revivePosY = 2666.6667f; this->actor.draw = NULL; @@ -573,7 +574,7 @@ void EnRat_Revive(EnRat* this, PlayState* play) { void EnRat_SetupIdle(EnRat* this) { Animation_PlayLoop(&this->skelAnime, &gRealBombchuRunAnim); this->animLoopCounter = 5; - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; this->actionFunc = EnRat_Idle; } @@ -583,16 +584,16 @@ void EnRat_SetupIdle(EnRat* this) { void EnRat_Idle(EnRat* this, PlayState* play) { Player* player = GET_PLAYER(play); - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_BOMCHU_WALK); if (this->animLoopCounter != 0) { this->animLoopCounter--; } } if ((this->animLoopCounter == 0) && (Rand_ZeroOne() < 0.05f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_VOICE); + Actor_PlaySfx(&this->actor, NA_SE_EN_BOMCHU_VOICE); this->animLoopCounter = 5; } @@ -606,7 +607,7 @@ void EnRat_SetupSpottedPlayer(EnRat* this) { this->actor.flags |= ACTOR_FLAG_10; Animation_MorphToLoop(&this->skelAnime, &gRealBombchuSpotAnim, -5.0f); this->animLoopCounter = 3; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnRat_SpottedPlayer; } @@ -615,7 +616,7 @@ void EnRat_SetupSpottedPlayer(EnRat* this) { */ void EnRat_SpottedPlayer(EnRat* this, PlayState* play) { if ((this->animLoopCounter == 3) && Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_AIM); + Actor_PlaySfx(&this->actor, NA_SE_EN_BOMCHU_AIM); } if (Animation_OnFrame(&this->skelAnime, 0.0f)) { @@ -640,7 +641,7 @@ void EnRat_UpdateSparkOffsets(EnRat* this) { void EnRat_SetupChasePlayer(EnRat* this) { Animation_MorphToLoop(&this->skelAnime, &gRealBombchuRunAnim, -5.0f); - this->actor.speedXZ = 6.1f; + this->actor.speed = 6.1f; EnRat_UpdateSparkOffsets(this); this->actionFunc = EnRat_ChasePlayer; } @@ -659,7 +660,7 @@ void EnRat_ChasePlayer(EnRat* this, PlayState* play) { Vec3f blureP1; Vec3f blureP2; - this->actor.speedXZ = 6.1f; + this->actor.speed = 6.1f; if (this->hasLostTrackOfPlayer) { if (!(player->stateFlags3 & PLAYER_STATE3_100) && (Player_GetMask(play) != PLAYER_MASK_STONE) && Actor_IsFacingPlayer(&this->actor, 0x3000)) { @@ -674,7 +675,7 @@ void EnRat_ChasePlayer(EnRat* this, PlayState* play) { this->animLoopCounter--; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_BOMCHU_WALK); } DECR(this->timer); @@ -704,7 +705,7 @@ void EnRat_ChasePlayer(EnRat* this, PlayState* play) { } if ((this->animLoopCounter == 0) && (Rand_ZeroOne() < 0.05f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOMCHU_AIM); + Actor_PlaySfx(&this->actor, NA_SE_EN_BOMCHU_AIM); this->animLoopCounter = 5; } @@ -713,12 +714,12 @@ void EnRat_ChasePlayer(EnRat* this, PlayState* play) { } void EnRat_SetupBounced(EnRat* this) { - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; this->actor.velocity.y = 8.0f; this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; this->actor.gravity = -1.0f; EnRat_UpdateSparkOffsets(this); - this->actor.bgCheckFlags &= ~(0x10 | 0x8 | 0x1); + this->actor.bgCheckFlags &= ~(BGCHECKFLAG_GROUND | BGCHECKFLAG_WALL | BGCHECKFLAG_CEILING); this->actionFunc = EnRat_Bounced; } @@ -733,14 +734,14 @@ void EnRat_Bounced(EnRat* this, PlayState* play) { this->timer = 30; } - if (this->actor.bgCheckFlags & (0x10 | 0x8 | 0x1)) { + if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_WALL | BGCHECKFLAG_CEILING)) { EnRat_Explode(this, play); } } void EnRat_Explode(EnRat* this, PlayState* play) { EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOM_0); + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, BOMB_TYPE_BODY); if (bomb != NULL) { bomb->timer = 0; @@ -750,7 +751,7 @@ void EnRat_Explode(EnRat* this, PlayState* play) { Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x100); } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnRat_PostDetonation; } @@ -790,10 +791,10 @@ void EnRat_Update(Actor* thisx, PlayState* play) { if (this->actor.colChkInfo.damageEffect == EN_RAT_DMGEFF_HOOKSHOT) { this->damageReaction.hookedState = EN_RAT_HOOK_STARTED; } else if (this->actor.colChkInfo.damageEffect == EN_RAT_DMGEFF_STUN) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 120, COLORFILTER_BUFFLAG_OPA, 40); if (this->actionFunc == EnRat_Bounced) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->actor.velocity.y > 0.0f) { this->actor.velocity.y = 0.0f; } @@ -853,7 +854,8 @@ void EnRat_Update(Actor* thisx, PlayState* play) { this->actor.floorHeight = this->actor.world.pos.y; } else { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 30.0f, 60.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 30.0f, 60.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); } if (SurfaceType_IsWallDamage(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { 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 3e46c9f04..b8e8e4139 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -266,7 +266,7 @@ void EnRd_Init(Actor* thisx, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_INVISIBLE) { - this->actor.flags |= ACTOR_FLAG_80; + this->actor.flags |= ACTOR_FLAG_REACT_TO_LENS; } if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_FROZEN) { @@ -356,7 +356,7 @@ void EnRd_SetupIdle(EnRd* this) { this->action = EN_RD_ACTION_IDLE; this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = EnRd_Idle; } @@ -410,7 +410,7 @@ void EnRd_Idle(EnRd* this, PlayState* play) { } if ((play->gameplayFrames & 0x5F) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -419,7 +419,7 @@ void EnRd_SetupSquattingDance(EnRd* this) { this->action = EN_RD_ACTION_SQUATTING_DANCE; this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; this->danceEndTimer = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = EnRd_SquattingDance; } @@ -454,7 +454,7 @@ void EnRd_SquattingDance(EnRd* this, PlayState* play) { } if ((play->gameplayFrames & 0x5F) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -463,7 +463,7 @@ void EnRd_SetupClappingDance(EnRd* this) { this->action = EN_RD_ACTION_CLAPPING_DANCE; this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; this->danceEndTimer = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = EnRd_ClappingDance; } @@ -498,14 +498,14 @@ void EnRd_ClappingDance(EnRd* this, PlayState* play) { } if ((play->gameplayFrames & 0x5F) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_CRY); } } void EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose(EnRd* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if ((play->gameplayFrames & 0x5F) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_CRY); } this->danceEndTimer++; @@ -524,7 +524,7 @@ void EnRd_SetupPirouette(EnRd* this) { this->action = EN_RD_ACTION_PIROUETTE; this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; this->pirouetteRotationalVelocity = 0x1112; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = EnRd_Pirouette; } @@ -558,7 +558,7 @@ void EnRd_Pirouette(EnRd* this, PlayState* play) { } if ((play->gameplayFrames & 0x5F) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_CRY); } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -574,7 +574,7 @@ void EnRd_Pirouette(EnRd* this, PlayState* play) { void EnRd_EndPirouetteWhenPlayerIsClose(EnRd* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if ((play->gameplayFrames & 0x5F) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_CRY); } this->actor.world.rot.y -= this->pirouetteRotationalVelocity; @@ -600,7 +600,7 @@ void EnRd_SetupRiseFromCoffin(EnRd* this) { this->actor.shape.rot.x = -0x4000; this->actor.gravity = 0.0f; this->actor.shape.yOffset = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnRd_RiseFromCoffin; } @@ -613,14 +613,14 @@ void EnRd_RiseFromCoffin(EnRd* this, PlayState* play) { } } else { if (this->actor.world.pos.y == this->actor.home.pos.y) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfx(&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) { if (this->coffinRiseForwardAccelTimer != 0) { this->coffinRiseForwardAccelTimer--; - Math_SmoothStepToF(&this->actor.speedXZ, 6.0f, 0.3f, 1.0f, 0.3f); - } else if (Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.3f, 1.0f, 0.3f) == 0.0f) { + Math_SmoothStepToF(&this->actor.speed, 6.0f, 0.3f, 1.0f, 0.3f); + } else if (Math_SmoothStepToF(&this->actor.speed, 0.0f, 0.3f, 1.0f, 0.3f) == 0.0f) { Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x7D0, 0); } } @@ -631,7 +631,7 @@ void EnRd_SetupWalkToPlayer(EnRd* this, PlayState* play) { f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 1.0f, 4.0f, frameCount, ANIMMODE_LOOP_INTERP, -4.0f); - this->actor.speedXZ = 0.4f; + this->actor.speed = 0.4f; this->action = EN_RD_ACTION_WALKING_TO_PLAYER_OR_RELEASING_GRAB; this->actionFunc = EnRd_WalkToPlayer; } @@ -642,18 +642,18 @@ void EnRd_WalkToPlayer(EnRd* this, PlayState* play) { s16 yaw = ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->headYRotation) - this->upperBodyYRotation; - this->skelAnime.playSpeed = this->actor.speedXZ; + this->skelAnime.playSpeed = this->actor.speed; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 250, 0); Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); this->actor.world.rot.y = this->actor.shape.rot.y; SkelAnime_Update(&this->skelAnime); - if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { + if (Actor_WorldDistXYZToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { EnRd_SetupWalkToHome(this, play); } - if ((ABS_ALT(yaw) < 0x1554) && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 150.0f)) { + if ((ABS_ALT(yaw) < 0x1554) && (Actor_WorldDistXYZToActor(&this->actor, &player->actor) <= 150.0f)) { if (!(player->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_40000 | PLAYER_STATE1_80000 | PLAYER_STATE1_200000)) && !(player->stateFlags2 & (PLAYER_STATE2_80 | PLAYER_STATE2_4000))) { @@ -665,7 +665,7 @@ void EnRd_WalkToPlayer(EnRd* this, PlayState* play) { Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); } this->playerStunWaitTimer = 60; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_AIM); } } else { EnRd_SetupWalkToHome(this, play); @@ -676,11 +676,11 @@ void EnRd_WalkToPlayer(EnRd* this, PlayState* play) { this->grabWaitTimer--; } - if (!this->grabWaitTimer && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 45.0f) && + if (!this->grabWaitTimer && (Actor_WorldDistXYZToActor(&this->actor, &player->actor) <= 45.0f) && 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) { + if (Actor_WorldDistXYZToPoint(&this->actor, &this->actor.home.pos) < 150.0f) { // If the Gibdo/Redead tries to grab Goron or Deku Link, it will fail to // do so. It will appear to take damage and shake its head side-to-side. EnRd_SetupGrabFail(this); @@ -700,9 +700,9 @@ void EnRd_WalkToPlayer(EnRd* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_WALK); } else if ((play->gameplayFrames & 0x5F) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -716,12 +716,12 @@ void EnRd_SetupWalkToHome(EnRd* this, PlayState* play) { void EnRd_WalkToHome(EnRd* this, PlayState* play) { Player* player = GET_PLAYER(play); s32 pad; - s16 sp36 = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + s16 sp36 = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); - if (Actor_DistanceToPoint(&this->actor, &this->actor.home.pos) >= 5.0f) { + if (Actor_WorldDistXYZToPoint(&this->actor, &this->actor.home.pos) >= 5.0f) { Math_SmoothStepToS(&this->actor.shape.rot.y, sp36, 1, 450, 0); } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (!Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 450, 0)) { if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { EnRd_SetupIdle(this); @@ -739,7 +739,7 @@ void EnRd_WalkToHome(EnRd* this, PlayState* play) { if (!(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && !(player->stateFlags2 & (0x4000 | 0x80)) && (player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_DEKU) && - (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 150.0f)) { + (Actor_WorldDistXYZToPoint(&player->actor, &this->actor.home.pos) < 150.0f)) { this->actor.targetMode = 0; EnRd_SetupWalkToPlayer(this, play); } else if (EN_RD_GET_TYPE(&this->actor) > EN_RD_TYPE_DOES_NOT_MOURN_IF_WALKING) { @@ -751,9 +751,9 @@ void EnRd_WalkToHome(EnRd* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_WALK); } else if ((play->gameplayFrames & 0x5F) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -779,13 +779,13 @@ void EnRd_WalkToParent(EnRd* this, PlayState* play) { if (this->actor.parent != NULL) { parentPos = this->actor.parent->world.pos; - yaw = Actor_YawToPoint(&this->actor, &parentPos); + yaw = Actor_WorldYawTowardPoint(&this->actor, &parentPos); Math_SmoothStepToS(&this->actor.shape.rot.y, yaw, 1, 250, 0); - if (Actor_DistanceToPoint(&this->actor, &parentPos) >= 45.0f) { - this->actor.speedXZ = 0.4f; + if (Actor_WorldDistXYZToPoint(&this->actor, &parentPos) >= 45.0f) { + this->actor.speed = 0.4f; } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { EnRd_SetupIdle(this); } else { @@ -802,9 +802,9 @@ void EnRd_WalkToParent(EnRd* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_WALK); } else if ((play->gameplayFrames & 0x5F) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -814,7 +814,7 @@ void EnRd_SetupGrab(EnRd* this) { this->grabState = 0; this->grabDamageTimer = 200; this->action = EN_RD_ACTION_GRABBING; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnRd_Grab; } @@ -873,7 +873,7 @@ void EnRd_Grab(EnRd* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 6000, 0); if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_ATTACK); } this->grabDamageTimer--; @@ -881,7 +881,7 @@ void EnRd_Grab(EnRd* this, PlayState* play) { play->damagePlayer(play, -8); Rumble_Request(this->actor.xzDistToPlayer, 240, 1, 12); this->grabDamageTimer = 20; - func_800B8E58(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S); + Player_PlaySfx(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S); } break; @@ -922,7 +922,7 @@ void EnRd_AttemptPlayerFreeze(EnRd* this, PlayState* play) { Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(play, &this->actor); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_AIM); EnRd_SetupWalkToPlayer(this, play); } } @@ -930,15 +930,15 @@ void EnRd_AttemptPlayerFreeze(EnRd* this, PlayState* play) { void EnRd_SetupGrabFail(EnRd* this) { this->action = EN_RD_ACTION_FAILING_GRAB; Animation_MorphToPlayOnce(&this->skelAnime, &gGibdoRedeadDamageAnim, -6.0f); - this->actor.speedXZ = -2.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + this->actor.speed = -2.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->action = EN_RD_ACTION_FAILING_GRAB; this->actionFunc = EnRd_GrabFail; } void EnRd_GrabFail(EnRd* this, PlayState* play) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.15f; + if (this->actor.speed < 0.0f) { + this->actor.speed += 0.15f; } this->actor.world.rot.y = this->actor.yawTowardsPlayer; @@ -1004,12 +1004,12 @@ void EnRd_Crouch(EnRd* this, PlayState* play) { void EnRd_SetupDamage(EnRd* this) { this->actor.shape.yOffset = 0.0f; Animation_MorphToPlayOnce(&this->skelAnime, &gGibdoRedeadDamageAnim, -6.0f); - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = -2.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.speed = -2.0f; } this->actor.flags |= ACTOR_FLAG_1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->action = EN_RD_ACTION_DAMAGE; this->actionFunc = EnRd_Damage; } @@ -1017,8 +1017,8 @@ void EnRd_SetupDamage(EnRd* this) { void EnRd_Damage(EnRd* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.15f; + if (this->actor.speed < 0.0f) { + this->actor.speed += 0.15f; } this->actor.world.rot.y = this->actor.yawTowardsPlayer; @@ -1029,7 +1029,7 @@ void EnRd_Damage(EnRd* this, PlayState* play) { this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.parent != NULL) { EnRd_SetupWalkToParent(this); - } else if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { + } else if (Actor_WorldDistXYZToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { EnRd_SetupWalkToHome(this, play); } else { EnRd_SetupWalkToPlayer(this, play); @@ -1043,8 +1043,8 @@ void EnRd_SetupDead(EnRd* this) { this->action = EN_RD_ACTION_DEAD; this->deathTimer = 300; this->actor.flags &= ~ACTOR_FLAG_1; - this->actor.speedXZ = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); + this->actor.speed = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_DEAD); this->actionFunc = EnRd_Dead; } @@ -1075,24 +1075,25 @@ void EnRd_Dead(EnRd* this, PlayState* play) { this->deathTimer--; } } else if (Animation_OnFrame(&this->skelAnime, 33.0f) || Animation_OnFrame(&this->skelAnime, 40.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } } void EnRd_SetupStunned(EnRd* this) { this->action = EN_RD_ACTION_STUNNED; this->stunTimer = 10; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE) { this->stunnedBySunsSong = true; this->sunsSongStunTimer = 600; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIGHT_ARROW_HIT); - Actor_SetColorFilter(&this->actor, 0x8000, 0x80C8, 0, 255); + Actor_PlaySfx(&this->actor, NA_SE_EN_LIGHT_ARROW_HIT); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_GRAY, COLORFILTER_INTENSITY_FLAG | 200, + COLORFILTER_BUFFLAG_OPA, 255); } else if (this->damageEffect == EN_RD_DMGEFF_STUN) { - Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 200, COLORFILTER_BUFFLAG_OPA, 40); } else if (this->damageEffect == EN_RD_DMGEFF_ZORA_MAGIC) { - Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 200, COLORFILTER_BUFFLAG_OPA, 40); } this->actionFunc = EnRd_Stunned; } @@ -1106,7 +1107,8 @@ void EnRd_Stunned(EnRd* this, PlayState* play) { if (this->sunsSongStunTimer != 0) { this->sunsSongStunTimer--; if (this->sunsSongStunTimer >= 255) { - Actor_SetColorFilter(&this->actor, 0x8000, 0x80C8, 0, 255); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_GRAY, COLORFILTER_INTENSITY_FLAG | 200, + COLORFILTER_BUFFLAG_OPA, 255); } if (this->sunsSongStunTimer == 0) { @@ -1186,7 +1188,7 @@ void EnRd_UpdateDamage(EnRd* this, PlayState* play) { return; case EN_RD_DMGEFF_FIRE_ARROW: - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 40); this->drawDmgEffTimer = 180; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->stunnedBySunsSong = false; @@ -1195,7 +1197,7 @@ void EnRd_UpdateDamage(EnRd* this, PlayState* play) { break; case EN_RD_DMGEFF_LIGHT_ARROW: - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 40); this->drawDmgEffTimer = 60; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->stunnedBySunsSong = false; @@ -1204,13 +1206,13 @@ void EnRd_UpdateDamage(EnRd* this, PlayState* play) { break; case EN_RD_DMGEFF_DAMAGE: - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); this->stunnedBySunsSong = false; this->sunsSongStunTimer = 0; break; case EN_RD_DMGEFF_LIGHT_RAY: - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); this->stunnedBySunsSong = false; this->sunsSongStunTimer = 0; this->actor.colChkInfo.health = 0; @@ -1273,13 +1275,14 @@ void EnRd_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); - if ((this->action != EN_RD_ACTION_GRABBING) && (this->actor.speedXZ != 0.0f)) { + if ((this->action != EN_RD_ACTION_GRABBING) && (this->actor.speed != 0.0f)) { Actor_MoveWithGravity(&this->actor); } - if ((this->actor.shape.rot.x == 0) && (this->action != EN_RD_ACTION_GRABBING) && - (this->actor.speedXZ != 0.0f)) { - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 35.0f, 0x1D); + if ((this->actor.shape.rot.x == 0) && (this->action != EN_RD_ACTION_GRABBING) && (this->actor.speed != 0.0f)) { + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 35.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } if (this->action == EN_RD_ACTION_ATTEMPTING_PLAYER_STUN) { @@ -1325,10 +1328,10 @@ void EnRd_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, } void EnRd_Draw(Actor* thisx, PlayState* play) { - static Vec3f D_808D7138 = { 0.25f, 0.25f, 0.25f }; + static Vec3f sScale = { 0.25f, 0.25f, 0.25f }; s32 pad; EnRd* this = THIS; - Vec3f sp54 = this->actor.world.pos; + Vec3f pos = this->actor.world.pos; OPEN_DISPS(play->state.gfxCtx); @@ -1344,7 +1347,7 @@ void EnRd_Draw(Actor* thisx, PlayState* play) { SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnRd_OverrideLimbDraw, EnRd_PostLimbDraw, &this->actor, POLY_OPA_DISP); - func_800BC620(&sp54, &D_808D7138, 255, play); + func_800BC620(&pos, &sScale, 255, play); } else { func_8012C2DC(play->state.gfxCtx); @@ -1354,7 +1357,7 @@ void EnRd_Draw(Actor* thisx, PlayState* play) { POLY_XLU_DISP = SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnRd_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); - func_800BC620(&sp54, &D_808D7138, this->alpha, play); + func_800BC620(&pos, &sScale, this->alpha, play); } CLOSE_DISPS(play->state.gfxCtx); 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 051cc8b33..64313c4be 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -168,7 +168,7 @@ void EnRecepgirl_Talk(EnRecepgirl* this, PlayState* play) { this->actor.textId = 0x2AE0; // drawing room on the right, don't go in without an appointment } } - func_80151938(play, this->actor.textId); + Message_ContinueTextbox(play, this->actor.textId); } } diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index 7f6d39886..d552c5605 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -231,7 +231,7 @@ void func_80BF3DC4(EnRg* this, PlayState* play) { this->collider2.dim.worldSphere.center.y = this->actor.world.pos.y + this->actor.shape.yOffset; this->collider2.dim.worldSphere.center.z = this->actor.world.pos.z; - if (this->actor.speedXZ >= 10.0f) { + if (this->actor.speed >= 10.0f) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider2.base); } CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider2.base); @@ -283,13 +283,13 @@ void func_80BF3FF8(EnRg* this) { } s32 func_80BF4024(EnRg* this, PlayState* play) { - if ((play->csCtx.state == 0) && (this->unk_334 == 1)) { + if ((play->csCtx.state == CS_STATE_IDLE) && (this->unk_334 == 1)) { if (Animation_OnFrame(&this->skelAnime, 2.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_CIRCLE); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_CIRCLE); } if (Animation_OnFrame(&this->skelAnime, 22.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SIT_IMT); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_SIT_IMT); } } @@ -318,8 +318,8 @@ void func_80BF40F4(EnRg* this) { } s32 func_80BF416C(EnRg* this, PlayState* play) { - if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ >= 0.01f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_ROLLING - SFX_FLAG); + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.speed >= 0.01f)) { + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_ROLLING - SFX_FLAG); func_800AE930(&play->colCtx, Effect_GetByIndex(this->unk_340), &this->actor.world.pos, 18.0f, this->actor.shape.rot.y, this->actor.floorPoly, this->actor.floorBgId); } else { @@ -345,9 +345,9 @@ s32 func_80BF42BC(EnRg* this, f32 arg1) { f32 sp2C; s32 sp24; - Math_ApproachF(&this->actor.speedXZ, arg1, 0.3f, 0.5f); + Math_ApproachF(&this->actor.speed, arg1, 0.3f, 0.5f); - sp2C = this->actor.speedXZ * (1.0f / 26); + sp2C = this->actor.speed * (1.0f / 26); if (sp2C > 1.0f) { sp2C = 1.0f; } @@ -410,7 +410,7 @@ s32 func_80BF45B4(EnRg* this) { s16 temp_v0; s16 temp_v1; - if ((this->actor.bgCheckFlags & 8) && (this->actor.speedXZ >= 5.0f)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && (this->actor.speed >= 5.0f)) { temp_v1 = this->actor.world.rot.y; temp_v0 = temp_v1 - BINANG_ROT180(this->actor.wallYaw); @@ -419,27 +419,27 @@ s32 func_80BF45B4(EnRg* this) { this->unk_322 = 0xA; } else if (ABS_ALT(temp_v0) >= 0x1000) { this->actor.world.rot.y = BINANG_ROT180(BINANG_ROT180(this->actor.wallYaw) - temp_v0); - this->actor.speedXZ *= 0.75f; + this->actor.speed *= 0.75f; this->unk_322 = 0xA; } else { this->actor.world.rot.y = BINANG_ROT180(temp_v1); ret = 1; - this->actor.speedXZ *= 0.25f; + this->actor.speed *= 0.25f; } sp24 = 1; } else if (this->unk_310 & 0x40) { - s16 yaw = Actor_YawBetweenActors(&this->actor, ((void)0, this->collider2.base.ac)); + s16 yaw = Actor_WorldYawTowardActor(&this->actor, ((void)0, this->collider2.base.ac)); sp24 = 2; if (this->actor.colorFilterTimer == 0) { - this->actor.speedXZ *= 0.5f; + this->actor.speed *= 0.5f; if ((s16)(yaw - this->actor.world.rot.y) > 0) { this->actor.world.rot.y -= 0x2000; } else { this->actor.world.rot.y += 0x2000; } } - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 40); this->unk_322 = 0xA; } @@ -501,7 +501,7 @@ s32 func_80BF47AC(EnRg* this, PlayState* play) { void func_80BF4934(EnRg* this) { if (this->unk_318 == 1) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_DASH); } } @@ -533,7 +533,7 @@ void func_80BF4964(EnRg* this) { } if (!(this->unk_310 & 0x400) && !(this->unk_310 & 0x1000) && (this->unk_322 == 0) && (this->unk_324 == 0) && - (this->actor.bgCheckFlags & 1)) { + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { if (this->unk_18C == NULL) { Math_Vec3s_ToVec3f(&sp30, &sp3C[this->unk_33C]); } else { @@ -625,8 +625,8 @@ s32 func_80BF4DA8(EnRg* this) { s32 i; for (i = 0; i < ARRAY_COUNT(D_80BF596C); i++) { - temp_f20 = Actor_XZDistanceToPoint(&this->actor, &D_80BF596C[i]); - temp_v1 = Actor_YawToPoint(&this->actor, &D_80BF596C[i]) - this->actor.world.rot.y; + temp_f20 = Actor_WorldDistXZToPoint(&this->actor, &D_80BF596C[i]); + temp_v1 = Actor_WorldYawTowardPoint(&this->actor, &D_80BF596C[i]) - this->actor.world.rot.y; if ((temp_f20 < 100.0f) && (ABS_ALT(temp_v1) < 0xC00)) { if (temp_v1 > 0) { @@ -676,10 +676,10 @@ void func_80BF4FC4(EnRg* this, PlayState* play) { this->unk_344 = func_80BF4560(this, play); if (!Play_InCsMode(play)) { - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { if (this->unk_310 & 0x400) { this->unk_310 &= ~0x400; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } if (this->unk_344 != -1) { @@ -688,7 +688,7 @@ void func_80BF4FC4(EnRg* this, PlayState* play) { this->unk_33C++; } } - } else if ((this->actor.bgCheckFlags & 1) && !(this->unk_310 & 0x1000) && + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && !(this->unk_310 & 0x1000) && func_80BF4D64(&this->actor.world.pos)) { this->unk_310 |= 0x1000; } @@ -786,7 +786,9 @@ void EnRg_Update(Actor* thisx, PlayState* play) { func_80BF4024(this, play); } - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 0.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); if (this->actor.floorHeight <= BGCHECK_Y_MIN) { Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); diff --git a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c index 0fd1007d0..ae7da7d1b 100644 --- a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c +++ b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c @@ -86,7 +86,7 @@ void EnRiverSound_Draw(Actor* thisx, PlayState* play) { s16 params = this->actor.params; if (params < RS_RIVER_DEFAULT_LOW_FREQ) { - Actor_PlaySfxAtPos(&this->actor, gAudioEnvironmentalSfx[params]); + Actor_PlaySfx(&this->actor, gAudioEnvironmentalSfx[params]); } else { Audio_PlaySfxForRiver(&this->actor.projectedPos, freqScale[this->soundFreqIndex]); } 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 6c7ac273c..85086d228 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -197,7 +197,7 @@ void func_808FA11C(EnRr* this) { this->drawDmgEffFrozenSteamScale = 1.2750001f; this->drawDmgEffAlpha = 1.0f; this->actor.flags &= ~ACTOR_FLAG_400; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 80); } void func_808FA19C(EnRr* this, PlayState* play) { @@ -214,8 +214,8 @@ void func_808FA19C(EnRr* this, PlayState* play) { } void func_808FA238(EnRr* this, f32 arg1) { - this->actor.speedXZ = arg1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIKE_WALK); + this->actor.speed = arg1; + Actor_PlaySfx(&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; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIKE_UNARI); + Actor_PlaySfx(&this->actor, NA_SE_EN_LIKE_UNARI); } void func_808FA344(EnRr* this) { @@ -271,7 +271,7 @@ void func_808FA3F8(EnRr* this, Player* player) { this->actor.flags &= ~ACTOR_FLAG_1; this->unk_1F0 = 8; this->unk_1E1 = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_218 = 0.0f; this->unk_210 = 0.0f; this->unk_204 = 0.15f; @@ -286,7 +286,7 @@ void func_808FA3F8(EnRr* this, Player* player) { } this->actionFunc = func_808FB1C0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_SUISEN_DRINK); + Actor_PlaySfx(&this->actor, NA_SE_EN_SUISEN_DRINK); } void func_808FA4F4(EnRr* this, PlayState* play) { @@ -331,7 +331,7 @@ void func_808FA4F4(EnRr* this, PlayState* play) { player->actor.world.pos.z += sp30 * Math_CosS(this->actor.shape.rot.y); func_800B8D50(play, &this->actor, sp30, this->actor.shape.rot.y, sp2C, sp38); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_SUISEN_THROW); + Actor_PlaySfx(&this->actor, NA_SE_EN_SUISEN_THROW); } } @@ -344,7 +344,7 @@ void func_808FA6B8(EnRr* this) { } else { this->unk_1EC = 40; } - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, this->unk_1EC); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, this->unk_1EC); this->unk_1E6 = 20; this->unk_1F6 = 2500; @@ -360,7 +360,7 @@ void func_808FA6B8(EnRr* this) { } this->actionFunc = func_808FB398; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIKE_DAMAGE); + Actor_PlaySfx(&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; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 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; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIKE_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_LIKE_DEAD); this->actor.flags &= ~ACTOR_FLAG_1; } @@ -482,8 +482,8 @@ s32 func_808FAA94(EnRr* this, PlayState* play) { func_808FA910(this); } } else if (this->actor.colChkInfo.damageEffect == 1) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - Actor_SetColorFilter(&this->actor, 0, 255, 0, 80); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 80); this->unk_1EE = 80; func_808FA9CC(this); } else if (this->actor.colChkInfo.damageEffect == 3) { @@ -575,7 +575,7 @@ void func_808FAF94(EnRr* this, PlayState* play) { (Player_GetMask(play) != PLAYER_MASK_STONE) && (this->actor.xzDistToPlayer < (8421.053f * this->actor.scale.x))) { func_808FA260(this); - } else if ((this->actor.xzDistToPlayer < 400.0f) && (this->actor.speedXZ == 0.0f)) { + } else if ((this->actor.xzDistToPlayer < 400.0f) && (this->actor.speed == 0.0f)) { func_808FA238(this, 2.0f); } } @@ -632,7 +632,7 @@ void func_808FB1C0(EnRr* this, PlayState* play) { Rumble_Request(this->actor.xyzDistToPlayerSq, 120, 2, 120); if (!(this->unk_1E4 & 7)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEMO_EYE); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_DEMO_EYE); } player->unk_AE8 = 0; @@ -742,7 +742,7 @@ void func_808FB680(EnRr* this, PlayState* play) { } else { Math_SmoothStepToS(&this->actor.shape.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 10, 1000, 0); this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->actor.speedXZ == 0.0f) { + if (this->actor.speed == 0.0f) { func_808FA238(this, 2.0f); } } @@ -801,13 +801,15 @@ void EnRr_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); if (this->actor.params == ENRR_2) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.1f); + Math_StepToF(&this->actor.speed, 0.0f, 0.1f); } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, this->collider1.dim.radius, 0.0f, 0x5D); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, this->collider1.dim.radius, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10 | UPDBGCHECKINFO_FLAG_40); func_808FB794(this, play); if (this->unk_1FC > 0) { diff --git a/src/overlays/actors/ovl_En_Ru/z_en_ru.c b/src/overlays/actors/ovl_En_Ru/z_en_ru.c index 042f2e46f..527d41b99 100644 --- a/src/overlays/actors/ovl_En_Ru/z_en_ru.c +++ b/src/overlays/actors/ovl_En_Ru/z_en_ru.c @@ -138,35 +138,36 @@ s32 EnRu_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { s32 EnRu_PlayWalkingSound(EnRu* this, PlayState* play) { u8 leftWasGrounded; u8 rightWasGrounded; - s32 waterSfxId; + SurfaceSfxOffset surfaceSfxOffset; s16 sfxId; u8 isFootGrounded; leftWasGrounded = this->isLeftFootGrounded; rightWasGrounded = this->isRightFootGrounded; - if (this->actor.bgCheckFlags & 0x20) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { if (this->actor.depthInWater < 20.0f) { - waterSfxId = NA_SE_PL_WALK_WATER0 - SFX_FLAG; + surfaceSfxOffset = SURFACE_SFX_OFFSET_WATER_SHALLOW; } else { - waterSfxId = NA_SE_PL_WALK_WATER1 - SFX_FLAG; + surfaceSfxOffset = SURFACE_SFX_OFFSET_WATER_DEEP; } - sfxId = waterSfxId + SFX_FLAG; + sfxId = NA_SE_PL_WALK_GROUND + surfaceSfxOffset; } else { - sfxId = SurfaceType_GetSfx(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) + SFX_FLAG; + sfxId = NA_SE_PL_WALK_GROUND + + SurfaceType_GetSfxOffset(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); } this->isLeftFootGrounded = isFootGrounded = SubS_IsFloorAbove(play, &this->leftFootPos, -6.0f); if (this->isLeftFootGrounded && !leftWasGrounded && isFootGrounded) { - Actor_PlaySfxAtPos(&this->actor, sfxId); + Actor_PlaySfx(&this->actor, sfxId); } this->isRightFootGrounded = isFootGrounded = SubS_IsFloorAbove(play, &this->rightFootPos, -6.0f); if (this->isRightFootGrounded && !rightWasGrounded && isFootGrounded) { - Actor_PlaySfxAtPos(&this->actor, sfxId); + Actor_PlaySfx(&this->actor, sfxId); } return false; @@ -250,7 +251,7 @@ void EnRu_Update(Actor* thisx, PlayState* play) { EnRu* this = THIS; this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); EnRu_UpdateModel(this, play); EnRu_UpdateCollider(this, play); } 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 f77993e5d..e270f1515 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c @@ -130,7 +130,8 @@ s32 EnRuppecrow_UpdateCollision(EnRuppecrow* this, PlayState* play) { this->collider.elements->dim.worldSphere.center.z = this->actor.world.pos.z; CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 25.0f, 50.0f, 0x07); + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 25.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); return true; } @@ -162,7 +163,7 @@ s32 EnRuppecrow_ReachedPointClockwise(EnRuppecrow* this, Path* path, s32 pointIn } } - func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + func_8017B7F8(&point, RAD_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; } @@ -197,7 +198,7 @@ s32 EnRuppecrow_ReachedPointCounterClockwise(EnRuppecrow* this, Path* path, s32 } } - func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + func_8017B7F8(&point, RAD_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; } @@ -282,7 +283,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, PlayState* play) { 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); + Actor_PlaySfx(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; @@ -293,7 +294,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, PlayState* play) { 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); + Actor_PlaySfx(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; @@ -305,7 +306,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, PlayState* play) { 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); + Actor_PlaySfx(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; @@ -316,7 +317,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, PlayState* play) { 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); + Actor_PlaySfx(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; @@ -329,7 +330,7 @@ void EnRuppecrow_UpdatePosition(EnRuppecrow* this, PlayState* play) { Vec3s nextPointDirection; EnRuppecrow_GetPointDirection(this->path, this->currentPoint, &this->actor.world, &nextPointDirection); - if (this->actor.bgCheckFlags & 0x8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { nextPointDirection.y = this->actor.wallYaw; } @@ -438,18 +439,18 @@ void EnRuppecrow_UpdateSpeed(EnRuppecrow* this, PlayState* play) { void EnRuppecrow_HandleDeath(EnRuppecrow* this) { f32 scale; - this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); + this->actor.speed *= Math_CosS(this->actor.world.rot.x); this->actor.velocity.y = 0.0f; Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); this->actor.shape.yOffset = 0.0f; this->actor.targetArrowOffset = 0.0f; - this->actor.bgCheckFlags &= ~0x1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; scale = this->actor.scale.x * 100.0f; this->actor.world.pos.y += 20.0f * scale; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_KAICHO_DEAD); this->unk_2CC = 0.5f; if (this->actor.colChkInfo.damageEffect == 0x3) { @@ -464,9 +465,9 @@ void EnRuppecrow_HandleDeath(EnRuppecrow* this) { this->unk_2C8 = 5.0f; } - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x0, 0x28); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 40); if (this->actor.flags & ACTOR_FLAG_8000) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } this->collider.base.acFlags &= ~AC_ON; @@ -492,7 +493,7 @@ void EnRuppecrow_HandleSong(EnRuppecrow* this, PlayState* play) { Player* player = GET_PLAYER(play); EnRuppecrow_UpdatePosition(this, play); - if (this->actor.xzDistToPlayer < 1000.0f && EnRuppecrow_CheckPlayedMatchingSong(play)) { + if ((this->actor.xzDistToPlayer < 1000.0f) && EnRuppecrow_CheckPlayedMatchingSong(play)) { // If Link is in front, the guay will turn around and go the other way if (Actor_IsFacingPlayer(&this->actor, 0x4000)) { this->isGoingCounterClockwise |= 1; @@ -503,14 +504,14 @@ void EnRuppecrow_HandleSong(EnRuppecrow* this, PlayState* play) { } } - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); this->actionFunc = EnRuppecrow_HandleSongCutscene; } if (player->stateFlags2 & PLAYER_STATE2_8000000) { - Math_ApproachF(&this->actor.speedXZ, 0.0f, 0.1f, 1.0f); + Math_ApproachF(&this->actor.speed, 0.0f, 0.1f, 1.0f); } else { - Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.1f, 0.1f); + Math_ApproachF(&this->actor.speed, 6.0f, 0.1f, 0.1f); } Actor_MoveWithoutGravity(&this->actor); @@ -518,19 +519,19 @@ void EnRuppecrow_HandleSong(EnRuppecrow* this, PlayState* play) { this->actor.shape.yOffset = Math_SinS(this->yOffset) * 500.0f; if ((play->state.frames % 43) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_KAICHO_CRY); } } void EnRuppecrow_HandleSongCutscene(EnRuppecrow* this, PlayState* play) { EnRuppecrow_UpdatePosition(this, play); - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); EnRuppecrow_UpdateSpeed(this, play); this->actionFunc = EnRuppecrow_FlyWhileDroppingRupees; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } Actor_MoveWithoutGravity(&this->actor); @@ -546,16 +547,16 @@ void EnRuppecrow_FlyWhileDroppingRupees(EnRuppecrow* this, PlayState* play) { //! @bug: 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.speed, 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) { + if (CutsceneManager_GetCurrentCsId() != this->actor.csId) { EnRuppecrow_UpdateSpeed(this, play); - Math_ApproachF(&this->actor.speedXZ, this->speedModifier, 0.2f, 0.5f); + Math_ApproachF(&this->actor.speed, this->speedModifier, 0.2f, 0.5f); } Actor_MoveWithoutGravity(&this->actor); @@ -563,17 +564,17 @@ void EnRuppecrow_FlyWhileDroppingRupees(EnRuppecrow* this, PlayState* play) { this->actor.shape.yOffset = Math_SinS(this->yOffset) * 500.0f; if ((play->state.frames % 43) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_KAICHO_CRY); } } } void EnRuppecrow_FlyToDespawn(EnRuppecrow* this, PlayState* play) { - if (this->actor.bgCheckFlags & 0x8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->actor.world.rot.y *= -0x1; } - Math_ApproachF(&this->actor.speedXZ, this->speedModifier, 0.1f, 0.1f); + Math_ApproachF(&this->actor.speed, 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) { @@ -585,13 +586,13 @@ void EnRuppecrow_FlyToDespawn(EnRuppecrow* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); if ((play->state.frames % 43) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_KAICHO_CRY); } } } void EnRuppecrow_FallToDespawn(EnRuppecrow* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); if (this->currentEffect != ENRUPPECROW_EFFECT_ICE) { Math_StepToF(&this->unk_2C8, 0.0f, 0.05f); @@ -608,7 +609,7 @@ void EnRuppecrow_FallToDespawn(EnRuppecrow* this, PlayState* play) { this->actor.shape.rot.z += 0x1780; } - if (this->actor.bgCheckFlags & 0x1 || this->actor.floorHeight == BGCHECK_Y_MIN) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { EnRuppecrow_ShatterIce(this, play); func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, (this->actor.scale.x * 10000.0f), 0x0, 0x0); diff --git a/src/overlays/actors/ovl_En_Rz/z_en_rz.c b/src/overlays/actors/ovl_En_Rz/z_en_rz.c index 108d88023..a223fe900 100644 --- a/src/overlays/actors/ovl_En_Rz/z_en_rz.c +++ b/src/overlays/actors/ovl_En_Rz/z_en_rz.c @@ -87,14 +87,14 @@ static ColliderCylinderInit sCylinderInit = { void EnRz_Init(Actor* thisx, PlayState* play) { EnRz* this = THIS; - s16 tempCutscene = this->actor.cutscene; + s16 csId = this->actor.csId; s32 i; - for (i = 0; i < ARRAY_COUNT(this->cutscenes); i++) { - this->cutscenes[i] = tempCutscene; - if (tempCutscene != -1) { - this->actor.cutscene = tempCutscene; - tempCutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + for (i = 0; i < ARRAY_COUNT(this->csIdList); i++) { + this->csIdList[i] = csId; + if (csId != CS_ID_NONE) { + this->actor.csId = csId; + csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); } } @@ -156,12 +156,12 @@ void EnRz_Init(Actor* thisx, PlayState* play) { } if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { - this->csAction = 0x226; + this->cueType = CS_CMD_ACTOR_CUE_550; } else { // EN_RZ_MARILLA - this->csAction = 0x227; + this->cueType = CS_CMD_ACTOR_CUE_551; } - this->actionIndex = 0; + this->cueId = 0; } /** @@ -203,7 +203,7 @@ void EnRz_ChangeAnim(PlayState* play, EnRz* this, s16 animIndex, u8 animMode, f3 &gRosaSistersStandingAnim, &gRosaSistersStandingAnim, &gRosaSistersWalkingAnim, &gRosaSistersSittingAnim, &gRosaSistersApplaudingAnim, &gRosaSistersOnKneesAnim, &gRosaSistersDancingAnim, }; - static LinkAnimationHeader* sLinkAnimations[] = { + static PlayerAnimationHeader* sPlayerAnimations[] = { &gPlayerAnim_link_normal_wait_free, &gPlayerAnim_alink_dance_loop, }; @@ -219,13 +219,15 @@ void EnRz_ChangeAnim(PlayState* play, EnRz* this, s16 animIndex, u8 animMode, f3 if ((animIndex >= EN_RZ_ANIM_THINKING) && (animIndex < EN_RZ_ANIM_MAX) && ((animIndex != this->animIndex) || (animMode != ANIMMODE_LOOP))) { if (animIndex >= ARRAY_COUNT(sJudoAnimations)) { - endFrame = Animation_GetLastFrame(sLinkAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)]); + endFrame = Animation_GetLastFrame(sPlayerAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)]); if (animMode == ANIMMODE_LOOP) { - LinkAnimation_Change(play, &this->skelAnime, sLinkAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)], - 2.0f / 3.0f, 0.0f, endFrame, ANIMMODE_LOOP, morphFrames); + PlayerAnimation_Change(play, &this->skelAnime, + sPlayerAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)], 2.0f / 3.0f, 0.0f, + endFrame, ANIMMODE_LOOP, morphFrames); } else { - LinkAnimation_Change(play, &this->skelAnime, sLinkAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)], - 2.0f / 3.0f, 0.0f, endFrame, ANIMMODE_LOOP, morphFrames); + PlayerAnimation_Change(play, &this->skelAnime, + sPlayerAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)], 2.0f / 3.0f, 0.0f, + endFrame, ANIMMODE_LOOP, morphFrames); } } else { Animation_Change(&this->skelAnime, animationPtr[animIndex], 1.0f, 0.0f, @@ -325,7 +327,7 @@ s32 EnRz_UpdateSkelAnime(EnRz* this, PlayState* play) { if (this->animIndex < EN_RZ_ANIM_LINK_NORMAL_WAIT_FREE) { return SkelAnime_Update(&this->skelAnime); } else { - return LinkAnimation_Update(play, &this->skelAnime); + return PlayerAnimation_Update(play, &this->skelAnime); } } @@ -357,18 +359,18 @@ void EnRz_Destroy(Actor* thisx, PlayState* play) { } s32 func_80BFBE70(EnRz* this, PlayState* play) { - u16 action; + u16 cueId; if ((EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) && (this->animIndex == EN_RZ_ANIM_APPLAUDING)) { func_800B9010(&this->actor, NA_SE_EV_CLAPPING_2P - SFX_FLAG); } - if (Cutscene_CheckActorAction(play, this->csAction)) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csAction)); - action = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action; - if (this->actionIndex != action) { - this->actionIndex = action; - switch (this->actionIndex) { + if (Cutscene_IsCueInChannel(play, this->cueType)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); + cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; + if (this->cueId != cueId) { + this->cueId = cueId; + switch (this->cueId) { case 1: func_80BFBA1C(play, this, EN_RZ_ANIM_STANDING); break; @@ -393,18 +395,18 @@ s32 func_80BFBE70(EnRz* this, PlayState* play) { } s32 func_80BFBFAC(EnRz* this, PlayState* play) { - if (this->actor.cutscene == -1) { + if (this->actor.csId == CS_ID_NONE) { Message_StartTextbox(play, 0x2925, &this->actor); this->actionFunc = func_80BFC078; - } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->actor.csId); return false; - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); return true; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } return false; } @@ -423,12 +425,12 @@ void func_80BFC078(EnRz* this, PlayState* play) { switch (play->msgCtx.currentTextId) { case 0x2927: case 0x2928: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); SET_WEEKEVENTREG(WEEKEVENTREG_77_04); break; default: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BFC3F8; if (this->animIndex != EN_RZ_ANIM_LINK_DANCE) { func_80BFB9E4(play, this, EN_RZ_ANIM_DANCE); @@ -444,7 +446,7 @@ void func_80BFC078(EnRz* this, PlayState* play) { sp28.x = this->actor.projectedPos.x; sp28.y = this->actor.projectedPos.y; sp28.z = this->actor.projectedPos.z; - func_801A1FB4(3, &sp28, NA_BGM_ROSA_SISTERS, 900.0f); + func_801A1FB4(SEQ_PLAYER_BGM_SUB, &sp28, NA_BGM_ROSA_SISTERS, 900.0f); } } @@ -473,15 +475,15 @@ void func_80BFC270(EnRz* this, PlayState* play) { this->actionFunc = func_80BFC214; func_80BFBDFC(play); } else { - Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 2000.0f, 1000.0f); + Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 2000.0f, 1000.0f); } } void func_80BFC2F4(EnRz* this, PlayState* play) { EnRz_UpdateSkelAnime(this, play); if (!func_80BFBE70(this, play)) { - func_801477B4(play); - Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 2000.0f, 1000.0f); + Message_CloseTextbox(play); + Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 2000.0f, 1000.0f); this->actionFunc = func_80BFC270; } } @@ -496,7 +498,7 @@ void func_80BFC36C(EnRz* this, PlayState* play) { this->actionFunc = func_80BFC2F4; SET_WEEKEVENTREG(WEEKEVENTREG_75_80); } - this->actor.cutscene = this->cutscenes[1]; + this->actor.csId = this->csIdList[1]; } } @@ -516,7 +518,7 @@ void func_80BFC3F8(EnRz* this, PlayState* play) { if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_10000)) { this->actionFunc = func_80BFC36C; - this->actor.cutscene = this->cutscenes[0]; + this->actor.csId = this->csIdList[0]; this->actor.flags &= ~ACTOR_FLAG_10000; } else if (Player_GetMask(play) == PLAYER_MASK_KAMARO) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_04)) { @@ -545,7 +547,7 @@ void func_80BFC3F8(EnRz* this, PlayState* play) { bgmPos.x = this->actor.projectedPos.x; bgmPos.y = this->actor.projectedPos.y; bgmPos.z = this->actor.projectedPos.z; - func_801A1FB4(3, &bgmPos, NA_BGM_ROSA_SISTERS, 900.0f); + func_801A1FB4(SEQ_PLAYER_BGM_SUB, &bgmPos, NA_BGM_ROSA_SISTERS, 900.0f); } } } @@ -554,7 +556,7 @@ void func_80BFC608(EnRz* this, PlayState* play) { EnRz_UpdateSkelAnime(this, play); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BFC674; } } @@ -578,7 +580,7 @@ void func_80BFC728(EnRz* this, PlayState* play) { EnRz_UpdateSkelAnime(this, play); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BFC7E0; this->actor.textId++; if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { @@ -604,7 +606,7 @@ void func_80BFC7E0(EnRz* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80BFC728; func_80BFB9E4(play, this, EN_RZ_ANIM_THINKING); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; func_80BFBDFC(play); } else if (EnRz_CanTalk(this, play)) { func_800B8614(&this->actor, play, 120.0f); @@ -614,13 +616,13 @@ void func_80BFC7E0(EnRz* this, PlayState* play) { void EnRz_StopToThink(EnRz* this, PlayState* play) { this->timer = 100; this->actionFunc = func_80BFC7E0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; func_80BFB9E4(play, this, EN_RZ_ANIM_THINKING); } void EnRz_Walk(EnRz* this, PlayState* play) { EnRz_UpdateSkelAnime(this, play); - this->actor.speedXZ = 1.5f; + this->actor.speed = 1.5f; switch (EnRz_GetPathStatus(this)) { case EN_RZ_PATHSTATUS_END: @@ -639,7 +641,7 @@ void EnRz_Walk(EnRz* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80BFC728; func_80BFB9E4(play, this, EN_RZ_ANIM_THINKING); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; func_80BFBDFC(play); } else if (EnRz_CanTalk(this, play)) { func_800B8614(&this->actor, play, 120.0f); @@ -653,7 +655,7 @@ void EnRz_Update(Actor* thisx, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 25.0f, 40.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 25.0f, 40.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); diff --git a/src/overlays/actors/ovl_En_Rz/z_en_rz.h b/src/overlays/actors/ovl_En_Rz/z_en_rz.h index 38a7088e8..c6d8fe3c8 100644 --- a/src/overlays/actors/ovl_En_Rz/z_en_rz.h +++ b/src/overlays/actors/ovl_En_Rz/z_en_rz.h @@ -40,9 +40,9 @@ typedef struct EnRz { /* 0x420 */ u16 stateFlags; /* 0x422 */ s16 animIndex; /* 0x424 */ s16 timer; - /* 0x426 */ u16 csAction; - /* 0x428 */ u16 actionIndex; - /* 0x42A */ s16 cutscenes[2]; + /* 0x426 */ u16 cueType; + /* 0x428 */ u16 cueId; + /* 0x42A */ s16 csIdList[2]; /* 0x430 */ EnRzActionFunc actionFunc; } EnRz; // size = 0x434 diff --git a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c index cc3cd2455..14904e5b7 100644 --- a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c +++ b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c @@ -701,7 +701,7 @@ u16 EnSGoro_BombshopGoron_NextTextId(EnSGoro* this, PlayState* play) { return 0x673; } this->powderKegPrice = play->msgCtx.unk1206C; - if (gSaveContext.save.playerData.rupees < this->powderKegPrice) { + if (gSaveContext.save.saveInfo.playerData.rupees < this->powderKegPrice) { this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; this->actionFlags |= EN_S_GORO_ACTIONFLAG_TIRED; play_sound(NA_SE_SY_ERROR); @@ -765,10 +765,10 @@ void EnSGoro_UpdateSleeping(EnSGoro* this, PlayState* play) { if (this->snorePhase == 0) { if (this->actionFlags & EN_S_GORO_ACTIONFLAG_SNOREPHASE) { this->actionFlags &= ~EN_S_GORO_ACTIONFLAG_SNOREPHASE; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SNORE2); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_SNORE2); } else { this->actionFlags |= EN_S_GORO_ACTIONFLAG_SNOREPHASE; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SNORE1); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_SNORE1); } } } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04)) { @@ -1245,7 +1245,7 @@ void EnSGoro_ShopGoron_Talk(EnSGoro* this, PlayState* play) { if ((this->textId == 0x675) || (this->textId == 0x676)) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; - Actor_PickUp(&this->actor, play, GI_POWDER_KEG, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_POWDER_KEG, 300.0f, 300.0f); this->actionFunc = EnSGoro_ShopGoron_TakePayment; } else { Message_StartTextbox(play, this->textId, &this->actor); @@ -1262,7 +1262,7 @@ void EnSGoro_ShopGoron_TakePayment(EnSGoro* this, PlayState* play) { Rupees_ChangeBy(-this->powderKegPrice); this->actionFunc = EnSGoro_ShopGoron_FinishTransaction; } else { - Actor_PickUp(&this->actor, play, GI_POWDER_KEG, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_POWDER_KEG, 300.0f, 300.0f); } } @@ -1271,7 +1271,7 @@ void EnSGoro_ShopGoron_FinishTransaction(EnSGoro* this, PlayState* play) { Message_StartTextbox(play, this->textId, &this->actor); this->actionFunc = EnSGoro_ShopGoron_Talk; } else { - func_800B85E0(&this->actor, play, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); } } @@ -1328,7 +1328,7 @@ void EnSGoro_Update(Actor* thisx, PlayState* play) { EnSGoro* this = (EnSGoro*)thisx; this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->loadedObjIndex].segment); SkelAnime_Update(&this->skelAnime); if (this->animInfoIndex != EN_S_GORO_ANIM_SLEEPY) { 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 868b48923..b34ee8c64 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -118,7 +118,7 @@ void EnSb_Init(Actor* thisx, PlayState* play) { this->isDead = false; this->actor.colChkInfo.mass = 90; this->actor.shape.rot.y = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.gravity = -0.35f; this->fireCount = 0; this->unk_252 = 0; @@ -155,7 +155,7 @@ void EnSb_SetupOpen(EnSb* this) { ANIMMODE_ONCE, 0.0f); this->state = SHELLBLADE_OPEN; this->actionFunc = EnSb_Open; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); + Actor_PlaySfx(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); } void EnSb_SetupWaitOpen(EnSb* this) { @@ -172,7 +172,7 @@ void EnSb_SetupLunge(EnSb* this) { Animation_Change(&this->skelAnime, &object_sb_Anim_000124, playbackSpeed, 0.0f, frameCount, ANIMMODE_ONCE, 0); this->state = SHELLBLADE_LUNGE; this->actionFunc = EnSb_Lunge; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); + Actor_PlaySfx(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); } void EnSb_SetupBounce(EnSb* this) { @@ -191,12 +191,12 @@ void EnSb_SetupIdle(EnSb* this, s32 changeSpeed) { this->state = SHELLBLADE_WAIT_CLOSED; if (changeSpeed) { if (this->actor.depthInWater > 0.0f) { - this->actor.speedXZ = -5.0f; + this->actor.speed = -5.0f; if (this->actor.velocity.y < 0.0f) { this->actor.velocity.y = 2.1f; } } else { - this->actor.speedXZ = -6.0f; + this->actor.speed = -6.0f; if (this->actor.velocity.y < 0.0f) { this->actor.velocity.y = 1.4f; } @@ -253,11 +253,11 @@ void EnSb_TurnAround(EnSb* this, PlayState* play) { this->actor.world.rot.y = this->yawAngle; if (this->actor.depthInWater > 0.0f) { this->actor.velocity.y = 3.0f; - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; this->actor.gravity = -0.35f; } else { this->actor.velocity.y = 2.0f; - this->actor.speedXZ = 6.0f; + this->actor.speed = 6.0f; this->actor.gravity = -2.0f; } EnSb_SpawnBubbles(play, this); @@ -267,12 +267,12 @@ void EnSb_TurnAround(EnSb* this, PlayState* play) { } void EnSb_Lunge(EnSb* this, PlayState* play) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); - if (this->actor.velocity.y <= -0.1f || this->actor.bgCheckFlags & 2) { + Math_StepToF(&this->actor.speed, 0.0f, 0.2f); + if ((this->actor.velocity.y <= -0.1f) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH)) { if (!(this->actor.depthInWater > 0.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } - this->actor.bgCheckFlags &= ~2; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND_TOUCH; EnSb_SetupBounce(this); } } @@ -282,25 +282,25 @@ void EnSb_Bounce(EnSb* this, PlayState* play) { f32 currentFrame = currentFrame = this->skelAnime.curFrame; f32 frameCount = frameCount = Animation_GetLastFrame(&object_sb_Anim_0000B4); - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); + Math_StepToF(&this->actor.speed, 0.0f, 0.2f); if (currentFrame == frameCount) { if (this->bounceCounter != 0) { this->bounceCounter--; this->attackTimer = 1; if (this->actor.depthInWater > 0.0f) { this->actor.velocity.y = 3.0f; - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; this->actor.gravity = -0.35f; } else { this->actor.velocity.y = 2.0f; - this->actor.speedXZ = 6.0f; + this->actor.speed = 6.0f; this->actor.gravity = -2.0f; } EnSb_SpawnBubbles(play, this); EnSb_SetupLunge(this); - } else if (this->actor.bgCheckFlags & 1) { - this->actor.bgCheckFlags &= ~2; - this->actor.speedXZ = 0.0f; + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND_TOUCH; + this->actor.speed = 0.0f; this->attackTimer = 1; EnSb_SetupWaitClosed(this); } @@ -310,14 +310,14 @@ void EnSb_Bounce(EnSb* this, PlayState* play) { void EnSb_ReturnToIdle(EnSb* this, PlayState* play) { if (this->attackTimer != 0) { this->attackTimer--; - if (this->actor.bgCheckFlags & 1) { - this->actor.bgCheckFlags &= ~1; - this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; + this->actor.speed = 0.0f; } - } else if (this->actor.bgCheckFlags & 1) { - this->actor.bgCheckFlags &= ~1; + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->actionFunc = EnSb_Idle; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } } @@ -331,7 +331,7 @@ void EnSb_UpdateDamage(EnSb* this, PlayState* play) { hitPlayer = 0; if (this->vulnerableTimer != 0) { Actor_ApplyDamage(&this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x2000, 80); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_XLU, 80); hitPlayer = 1; } } @@ -375,7 +375,7 @@ void EnSb_Update(Actor* thisx, PlayState* play) { Actor_SetFocus(&this->actor, 20.0f); Actor_MoveWithGravity(&this->actor); this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 25.0f, 20.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 25.0f, 20.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); EnSb_UpdateDamage(this, play); if (player->stateFlags1 & PLAYER_STATE1_8000000) { Collider_UpdateCylinder(&this->actor, &this->collider); diff --git a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c index fa017af87..be449e0a3 100644 --- a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c +++ b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c @@ -67,7 +67,7 @@ static ColliderCylinderInit sCylinderInit = { void EnScRuppe_UpdateCollision(EnScRuppe* this, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } s32 func_80BD697C(s16 ruppeIndex) { @@ -116,7 +116,7 @@ void func_80BD6A8C(EnScRuppe* this, PlayState* play) { if (this->collider.base.ocFlags1 & OC1_HIT) { this->ruppeDisplayTime = 0; this->actor.gravity = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_GET_RUPY); + Actor_PlaySfx(&this->actor, NA_SE_SY_GET_RUPY); Rupees_ChangeBy(sRupeeInfo[this->ruppeIndex].amount); this->actionFunc = func_80BD6B18; } @@ -156,7 +156,7 @@ void EnScRuppe_Init(Actor* thisx, PlayState* play) { if ((this->ruppeIndex < RUPEE_GREEN) || (this->ruppeIndex >= RUPEE_UNUSED)) { this->ruppeIndex = RUPEE_GREEN; } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_80BD6A8C; this->actor.gravity = -0.5f; this->actor.shape.yOffset = 700.0f; diff --git a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c index b37190ee1..321c790d1 100644 --- a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c +++ b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c @@ -166,7 +166,7 @@ void func_80BCD2BC(EnScopecrow* this, PlayState* play) { Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_SC_RUPPE, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, this->actor.params, - this->actor.cutscene, this->actor.unk20, NULL); + this->actor.csId, this->actor.halfDaysBits, NULL); } s32 func_80BCD334(EnScopecrow* this, Path* path, s32 pointIndex) { @@ -192,7 +192,7 @@ s32 func_80BCD334(EnScopecrow* this, Path* path, s32 pointIndex) { phi_fa1 = points[index + 1].z - points[index - 1].z; } - func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_fa0, phi_fa1)), &sp3C.z, &sp3C.y, &sp3C.x); + func_8017B7F8(&sp30, RAD_TO_BINANG(func_80086B30(phi_fa0, phi_fa1)), &sp3C.z, &sp3C.y, &sp3C.x); if (((this->actor.world.pos.x * sp3C.z) + (sp3C.y * this->actor.world.pos.z) + sp3C.x) > 0.0f) { ret = true; @@ -236,7 +236,7 @@ void func_80BCD640(EnScopecrow* this, PlayState* play) { if (this->path != NULL) { func_80BCD4D0(this->path, this->unk_1FC, &this->actor.world.pos, &sp30); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { sp30.y = this->actor.wallYaw; } @@ -257,7 +257,7 @@ void func_80BCD640(EnScopecrow* this, PlayState* play) { } } - Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 6.0f, 0.2f, 1.0f); Actor_MoveWithoutGravity(&this->actor); this->unk_264 += 0x1000; this->actor.shape.yOffset = Math_SinS(this->unk_264) * 500.0f; diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index 4f8207046..07e2646a0 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -126,19 +126,19 @@ void func_80BCAC40(EnScopenuts* this, PlayState* play) { } void func_80BCAD64(EnScopenuts* this, s16 arg1) { - f32 sp24 = Math_CosS(this->actor.world.rot.x) * this->actor.speedXZ; + f32 sp24 = Math_CosS(this->actor.world.rot.x) * this->actor.speed; switch (arg1) { case 1: - this->actor.velocity.y = this->actor.speedXZ; + this->actor.velocity.y = this->actor.speed; this->actor.velocity.x = 0.0f; this->actor.velocity.z = 0.0f; break; case 2: - this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; + this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speed; this->actor.velocity.y = 0.0f; - this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; + this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speed; break; case 3: @@ -149,7 +149,7 @@ void func_80BCAD64(EnScopenuts* this, s16 arg1) { default: this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * sp24; - this->actor.velocity.y = Math_SinS(this->actor.world.rot.x) * this->actor.speedXZ; + this->actor.velocity.y = Math_SinS(this->actor.world.rot.x) * this->actor.speed; this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * sp24; break; } @@ -163,7 +163,7 @@ void func_80BCAE78(EnScopenuts* this, PlayState* play) { } if (this->unk_328 & 2) { - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } } @@ -208,7 +208,7 @@ void func_80BCB078(EnScopenuts* this, PlayState* play) { if (this->path != NULL) { func_80BCC448(this->path, this->unk_334, &this->actor.world.pos, &sp30); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { sp30.y = this->actor.wallYaw; } Math_SmoothStepToS(&this->actor.world.rot.y, sp30.y, 10, 300, 0); @@ -219,7 +219,7 @@ void func_80BCB078(EnScopenuts* this, PlayState* play) { if (func_80BCC2AC(this, this->path, this->unk_334)) { if (this->unk_334 >= (this->path->count - 1)) { this->actionFunc = func_80BCB1C8; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.gravity = -1.0f; return; } @@ -228,9 +228,9 @@ void func_80BCB078(EnScopenuts* this, PlayState* play) { } if (this->unk_334 >= (this->path->count - 2)) { - Math_ApproachF(&this->actor.speedXZ, 1.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 1.5f, 0.2f, 1.0f); } else { - Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 5.0f, 0.2f, 1.0f); } Actor_MoveWithoutGravity(&this->actor); } @@ -238,7 +238,7 @@ void func_80BCB078(EnScopenuts* this, PlayState* play) { void func_80BCB1C8(EnScopenuts* this, PlayState* play) { this->unk_350 *= 0.92f; Actor_SetScale(&this->actor, this->unk_350); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { SET_WEEKEVENTREG(WEEKEVENTREG_52_40); Actor_Kill(&this->actor); } @@ -252,7 +252,7 @@ void func_80BCB230(EnScopenuts* this, PlayState* play) { if ((((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false) && ((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80BCB4DC; this->unk_348 = 3; this->collider.dim.height = 64; @@ -262,12 +262,12 @@ void func_80BCB230(EnScopenuts* this, PlayState* play) { if ((this->unk_348 == 4) || (this->unk_348 == 18)) { this->unk_348 = 17; this->collider.dim.height = 0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DOWN); SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 17); } else if (this->unk_348 == 2) { this->unk_348 = 16; this->collider.dim.height = 32; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_UP); SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 16); } else if (this->unk_348 == 17) { if (DECR(this->unk_34E) == 0) { @@ -334,7 +334,7 @@ void func_80BCB6D0(EnScopenuts* this, PlayState* play) { if (Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: - if (gSaveContext.save.playerData.rupees < this->unk_358) { + if (gSaveContext.save.saveInfo.playerData.rupees < this->unk_358) { play_sound(NA_SE_SY_ERROR); this->unk_33C = 0x1636; this->unk_328 |= 1; @@ -360,7 +360,7 @@ void func_80BCB6D0(EnScopenuts* this, PlayState* play) { } } } else if (talkState == TEXT_STATE_DONE) { - func_800B85E0(&this->actor, play, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); this->actionFunc = func_80BCB980; } } @@ -371,7 +371,7 @@ void func_80BCB90C(EnScopenuts* this, PlayState* play) { SET_WEEKEVENTREG(WEEKEVENTREG_53_02); this->actionFunc = func_80BCB6D0; } else { - Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 300.0f, 300.0f); } } @@ -382,7 +382,7 @@ void func_80BCB980(EnScopenuts* this, PlayState* play) { Message_StartTextbox(play, this->unk_33C, &this->actor); this->actionFunc = func_80BCB6D0; } else { - func_800B85E0(&this->actor, play, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); } } @@ -448,14 +448,14 @@ void func_80BCBA00(EnScopenuts* this, PlayState* play) { } if (this->unk_36C == 0) { - if (ActorCutscene_GetCanPlayNext(this->unk_338)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_338, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); this->unk_36C = 1; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->unk_338); + CutsceneManager_Queue(this->csId); return; } } @@ -464,7 +464,7 @@ void func_80BCBA00(EnScopenuts* this, PlayState* play) { this->unk_35A = 3; this->unk_348 = 19; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 19); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_328 &= ~2; this->unk_34E = 50; this->unk_328 |= 8; @@ -528,7 +528,7 @@ void func_80BCBD28(EnScopenuts* this, PlayState* play) { this->unk_368 = 0.3f; this->unk_348 = 9; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 9); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); func_80BCAC40(this, play); this->actionFunc = func_80BCBF0C; } @@ -564,7 +564,7 @@ void func_80BCBFFC(EnScopenuts* this, PlayState* play) { if (this->path != NULL) { sp34 = func_80BCC448(this->path, this->unk_334, &this->actor.world.pos, &sp38); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { sp38.y = this->actor.wallYaw; } @@ -593,7 +593,7 @@ void func_80BCBFFC(EnScopenuts* this, PlayState* play) { if (sp32 == 3) { if (this->unk_334 >= (this->path->count - 1)) { - ActorCutscene_Stop(this->unk_338); + CutsceneManager_Stop(this->csId); CLEAR_WEEKEVENTREG(WEEKEVENTREG_52_40); this->actionFunc = func_80BCC288; } else { @@ -601,25 +601,25 @@ void func_80BCBFFC(EnScopenuts* this, PlayState* play) { } } } else if (this->actor.playerHeightRel > 500.0f) { - ActorCutscene_Stop(this->unk_338); + CutsceneManager_Stop(this->csId); this->actionFunc = func_80BCC288; } - Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 1.0f, 0.2f, 1.0f); func_80BCAD64(this, sp32); if (this->unk_36C == 2) { - if (ActorCutscene_GetCanPlayNext(this->unk_338)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_338, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); this->unk_36C = 3; } else { - ActorCutscene_SetIntentToPlay(this->unk_338); + CutsceneManager_Queue(this->csId); return; } } else if ((this->unk_36C == 1) && (this->unk_36E == 20)) { - ActorCutscene_Stop(this->unk_338); - this->unk_338 = ActorCutscene_GetAdditionalCutscene(this->unk_338); - ActorCutscene_SetIntentToPlay(this->unk_338); + CutsceneManager_Stop(this->csId); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); + CutsceneManager_Queue(this->csId); this->unk_36C = 2; } this->unk_36E++; @@ -654,7 +654,7 @@ s32 func_80BCC2AC(EnScopenuts* this, Path* path, s32 arg2_) { phi_f14 = sp5C[arg2 + 1].z - sp5C[arg2 - 1].z; } - func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RAD_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { sp50 = true; @@ -684,7 +684,8 @@ void EnScopenuts_Init(Actor* thisx, PlayState* play) { s32 pad; EnScopenuts* this = THIS; - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_74_40) && (gSaveContext.save.inventory.items[ITEM_OCARINA] == ITEM_NONE)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_74_40) && + (gSaveContext.save.saveInfo.inventory.items[ITEM_OCARINA] == ITEM_NONE)) { Actor_Kill(&this->actor); return; } @@ -701,7 +702,7 @@ void EnScopenuts_Init(Actor* thisx, PlayState* play) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_328 |= 2; this->unk_328 |= 4; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (ENSCOPENUTS_GET_3E0(&this->actor) == ENSCOPENUTS_3E0_0) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_40)) { @@ -722,7 +723,7 @@ void EnScopenuts_Init(Actor* thisx, PlayState* play) { } else { this->actor.gravity = -1.0f; this->actor.draw = EnScopenuts_Draw; - this->unk_338 = this->actor.cutscene; + this->csId = this->actor.csId; this->unk_33C = 0; this->unk_358 = 150; this->unk_348 = 4; diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.h b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.h index 5ea0d15eb..ef2ea74d8 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.h +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.h @@ -24,7 +24,7 @@ typedef struct EnScopenuts { /* 0x32C */ f32 unk_32C; /* 0x330 */ Path* path; /* 0x334 */ s32 unk_334; - /* 0x338 */ s16 unk_338; + /* 0x338 */ s16 csId; /* 0x33A */ UNK_TYPE1 unk33A[2]; /* 0x33C */ u16 unk_33C; /* 0x33E */ s16 unk_33E; diff --git a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c index 88fab3298..538f7d304 100644 --- a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c +++ b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c @@ -59,8 +59,10 @@ void EnSekihi_Init(Actor* thisx, PlayState* play) { return; } - if ((params == SEKIHI_TYPE_4) && (((gSaveContext.save.skullTokenCount & 0xFFFF)) >= 30)) { - SET_WEEKEVENTREG(WEEKEVENTREG_13_20); + if ((params == SEKIHI_TYPE_4) && + ((gSaveContext.save.saveInfo.skullTokenCount & 0xFFFF) >= SPIDER_HOUSE_TOKENS_REQUIRED)) { + // For some reason the mikau grave sets the flag instead of something in the spider house on exit. + SET_WEEKEVENTREG(WEEKEVENTREG_OCEANSIDE_SPIDER_HOUSE_BUYER_MOVED_IN); } objectIndex = Object_GetIndex(&play->objectCtx, sObjectIds[params]); @@ -118,15 +120,15 @@ void func_80A44F40(EnSekihi* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - func_80151938(play, 0x101A); + Message_ContinueTextbox(play, 0x101A); break; case 1: func_8019F208(); - func_80151938(play, 0x101B); + Message_ContinueTextbox(play, 0x101B); break; case 2: func_8019F230(); - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80A450B0; break; } @@ -138,11 +140,11 @@ void func_80A44F40(EnSekihi* this, PlayState* play) { if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x1018: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x101A: case 0x101B: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80A450B0; break; } diff --git a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.h b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.h index fb4ad7e60..0c26dab71 100644 --- a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.h +++ b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.h @@ -2,6 +2,8 @@ #define Z_EN_SEKIHI_H #include "global.h" +#include "overlays/actors/ovl_En_Si/z_en_si.h" + #define ENSIKIHI_GET_TYPE(thisx) ((thisx)->params & 0xF) 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 b16153a53..871bb85a8 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -118,7 +118,7 @@ void func_80ADADD0(EnSellnuts* this, PlayState* play) { } if (this->unk_338 & 1) { - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } } @@ -294,7 +294,7 @@ void func_80ADB254(EnSellnuts* this, PlayState* play) { 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)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80ADB4F4; this->unk_34C = 3; this->collider.dim.height = 64; @@ -303,12 +303,12 @@ void func_80ADB254(EnSellnuts* this, PlayState* play) { if ((this->unk_34C == 4) || (this->unk_34C == 18)) { this->unk_34C = 17; this->collider.dim.height = 0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DOWN); SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 17); } else if (this->unk_34C == 2) { this->unk_34C = 16; this->collider.dim.height = 32; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_UP); SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 16); } else if (this->unk_34C == 17) { if (DECR(this->unk_34E) == 0) { @@ -433,20 +433,20 @@ void func_80ADB924(EnSellnuts* this, PlayState* play) { this->unk_340 = player->actor.textId; this->actionFunc = func_80ADB0D8; } - func_801477B4(play); + Message_CloseTextbox(play); } else if (itemAction <= PLAYER_IA_MINUS1) { this->unk_340 = D_80ADD920[this->unk_33A]; - func_80151938(play, this->unk_340); + Message_ContinueTextbox(play, this->unk_340); this->actionFunc = func_80ADB0D8; } } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_340 == D_80ADD910[this->unk_33A]) { this->unk_340 = D_80ADD938[this->unk_33A]; - func_80151938(play, this->unk_340); + Message_ContinueTextbox(play, this->unk_340); this->actionFunc = func_80ADB0D8; } else { this->unk_340 = 0xFF; - func_80151938(play, this->unk_340); + Message_ContinueTextbox(play, this->unk_340); this->actionFunc = func_80ADB0D8; } } @@ -483,7 +483,7 @@ void func_80ADBBEC(EnSellnuts* this, PlayState* play) { SET_WEEKEVENTREG(WEEKEVENTREG_17_80); this->actionFunc = func_80ADBCE4; } else { - Actor_PickUp(&this->actor, play, GI_DEED_LAND, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_DEED_LAND, 300.0f, 300.0f); } } @@ -532,14 +532,14 @@ void func_80ADBE80(EnSellnuts* this, PlayState* play) { func_80ADAE64(this); if (this->unk_366 == 0) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); this->unk_366 = 1; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); return; } } @@ -548,7 +548,7 @@ void func_80ADBE80(EnSellnuts* this, PlayState* play) { this->unk_350 = 4; this->unk_34C = 19; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 19); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_338 &= ~1; this->unk_338 |= 8; this->unk_32C = this->actor.world.pos.y; @@ -617,7 +617,7 @@ void func_80ADC118(EnSellnuts* this, PlayState* play) { this->unk_34C = 9; this->unk_360 = 0.3f; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 9); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80ADC034; } } @@ -649,7 +649,7 @@ void func_80ADC37C(EnSellnuts* this, PlayState* play) { this->actor.gravity = 0.0f; if (this->path != NULL) { sp2C = func_80ADCFE8(this->path, this->unk_334, &this->actor.world.pos, &sp30); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { sp30.y = this->actor.wallYaw; } Math_SmoothStepToS(&this->actor.world.rot.y, sp30.y, 0xA, 0x12C, 0); @@ -659,31 +659,31 @@ void func_80ADC37C(EnSellnuts* this, PlayState* play) { this->actor.world.rot.x = -sp30.x; if (func_80ADCE4C(this, this->path, this->unk_334) && (sp2C < 500.0f)) { if (this->unk_334 >= (this->path->count - 1)) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->actionFunc = func_80ADC580; } else { this->unk_334++; } } } else if (this->actor.playerHeightRel > 500.0f) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->actionFunc = func_80ADC580; } - Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 2.0f, 0.2f, 1.0f); Actor_MoveWithoutGravity(&this->actor); if (this->unk_366 == 2) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); this->unk_366 = 3; } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); return; } } else if ((this->unk_366 == 1) && (this->unk_368 == 20)) { - ActorCutscene_Stop(this->cutscene); - this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Stop(this->csId); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); + CutsceneManager_Queue(this->csId); this->unk_366 = 2; } @@ -741,22 +741,22 @@ void func_80ADC7B4(EnSellnuts* this, PlayState* play) { s32 talkState = Message_GetState(&play->msgCtx); if (this->unk_366 == 0) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); this->unk_366 = 1; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } else if ((this->unk_366 == 1) && (talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; this->unk_366 = 0; - ActorCutscene_Stop(this->cutscene); - this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Stop(this->csId); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); + CutsceneManager_Queue(this->csId); this->unk_338 |= 8; this->actionFunc = func_80ADC8C4; } @@ -766,21 +766,21 @@ void func_80ADC8C4(EnSellnuts* this, PlayState* play) { Vec3s sp30; if (this->unk_366 == 0) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); this->unk_366 = 1; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); return; } } if (this->path != NULL) { func_80ADCFE8(this->path, this->unk_334, &this->actor.world.pos, &sp30); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { sp30.y = this->actor.wallYaw; } Math_SmoothStepToS(&this->actor.world.rot.y, sp30.y, 0xA, 0x12C, 0); @@ -793,7 +793,7 @@ void func_80ADC8C4(EnSellnuts* this, PlayState* play) { this->unk_34C = 22; this->actor.gravity = -1.0f; this->actor.velocity.y = -1.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_34C); this->unk_338 &= ~1; this->unk_338 &= ~2; @@ -802,7 +802,7 @@ void func_80ADC8C4(EnSellnuts* this, PlayState* play) { } this->unk_334++; } - Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 2.0f, 0.2f, 1.0f); Actor_MoveWithoutGravity(&this->actor); } } @@ -816,14 +816,14 @@ void func_80ADCA64(EnSellnuts* this, PlayState* play) { this->actor.shape.rot.y += 0x4000; this->unk_360 *= 0.93f; if (this->actor.world.pos.y < -50.0f) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->unk_338 &= ~8; this->unk_34E = 20; this->unk_350 = 4; this->unk_34C = 19; this->actor.velocity.y = 0.0f; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_34C); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DOWN); } return; } @@ -835,7 +835,7 @@ void func_80ADCA64(EnSellnuts* this, PlayState* play) { this->collider.dim.height = 0; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 17); } else if (this->unk_34C == 17) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); SET_WEEKEVENTREG(WEEKEVENTREG_73_04); Actor_Kill(&this->actor); } @@ -884,7 +884,7 @@ void func_80ADCD3C(EnSellnuts* this, PlayState* play) { this->collider.dim.height = 64; this->unk_34C = 3; this->unk_350 = 4; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_34C); this->actionFunc = func_80ADCC04; } else if (D_80ADD940 != 0) { @@ -916,7 +916,7 @@ s32 func_80ADCE4C(EnSellnuts* this, Path* path, s32 arg2) { pointY = points[var + 1].z - points[var - 1].z; } - func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(pointX, pointY)), &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RAD_TO_BINANG(func_80086B30(pointX, pointY)), &sp44, &sp40, &sp3C); if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { ret = true; } @@ -959,7 +959,7 @@ void EnSellnuts_Init(Actor* thisx, PlayState* play) { Collider_SetCylinderType1(play, &this->collider, &this->actor, &sCylinderInit); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); this->path = SubS_GetPathByIndex(play, ENSELLNUTS_GET_FC00(&this->actor), 0x3F); - this->cutscene = this->actor.cutscene; + this->csId = this->actor.csId; Actor_SetScale(&this->actor, 0.01f); this->actor.colChkInfo.cylRadius = 0; this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -968,7 +968,7 @@ void EnSellnuts_Init(Actor* thisx, PlayState* play) { this->unk_374 = 0.01f; this->unk_370 = 0.01f; this->unk_36C = 0.01f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; if (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_04)) { if (ENSELLNUTS_GET_1(&this->actor)) { diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.h b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.h index b9793a6d3..3acf7a3e0 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.h +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.h @@ -23,7 +23,7 @@ typedef struct EnSellnuts { /* 0x334 */ s32 unk_334; /* 0x338 */ u16 unk_338; /* 0x33A */ u16 unk_33A; - /* 0x33C */ s16 cutscene; + /* 0x33C */ s16 csId; /* 0x33E */ UNK_TYPE1 unk33E[0x2]; /* 0x340 */ u16 unk_340; /* 0x342 */ u16 unk_342; diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index d606e17f4..bdd5b787f 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -227,8 +227,8 @@ s32 func_80AE65F4(EnShn* this, PlayState* play) { s32 func_80AE6704(Actor* thisx, PlayState* play) { static s32 sPictographFlags[] = { - PICTOGRAPH_0, PICTOGRAPH_MONKEY, PICTOGRAPH_BIG_OCTO, - PICTOGRAPH_TINGLE, PICTOGRAPH_DEKU_KING, PICTOGRAPH_IN_SWAMP, + PICTO_VALID_0, PICTO_VALID_MONKEY, PICTO_VALID_BIG_OCTO, + PICTO_VALID_TINGLE, PICTO_VALID_DEKU_KING, PICTO_VALID_IN_SWAMP, }; EnShn* this = THIS; s32 ret = 0; @@ -259,12 +259,12 @@ s32 func_80AE6704(Actor* thisx, PlayState* play) { case 6: CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_40); - func_800B7298(play, &this->actor, PLAYER_CSMODE_7); + func_800B7298(play, &this->actor, PLAYER_CSMODE_WAIT); play->nextEntrance = ENTRANCE(SOUTHERN_SWAMP_POISONED, 6); gSaveContext.nextCutsceneIndex = 0; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_03; - gSaveContext.nextTransitionType = TRANS_TYPE_07; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE_SLOW; this->unk_2C6++; break; } diff --git a/src/overlays/actors/ovl_En_Si/z_en_si.c b/src/overlays/actors/ovl_En_Si/z_en_si.c index 5f7e111a4..cf44d641b 100644 --- a/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -15,10 +15,8 @@ void EnSi_Destroy(Actor* thisx, PlayState* play); void EnSi_Update(Actor* thisx, PlayState* play); void EnSi_Draw(Actor* thisx, PlayState* play); -void func_8098CB70(EnSi* this, PlayState* play); -void func_8098CBDC(EnSi* this, PlayState* play); +void EnSi_DraggedByHookshot(EnSi* this, PlayState* play); -#if 0 ActorInit En_Si_InitVars = { ACTOR_EN_SI, ACTORCAT_ITEMACTION, @@ -31,18 +29,29 @@ ActorInit En_Si_InitVars = { (ActorFunc)EnSi_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_8098CD80 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 10 }, 100 }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_8098CDAC = { 1, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_8098CDB8 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -77,24 +86,79 @@ static DamageTable D_8098CDB8 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -#endif +void EnSi_UpdateCollision(EnSi* this, PlayState* play) { + this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.world.pos.y; + this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; + this->collider.dim.worldSphere.radius = this->collider.dim.modelSphere.radius * this->collider.dim.scale; + if (this->actor.colChkInfo.health > 0) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); +} -extern ColliderSphereInit D_8098CD80; -extern CollisionCheckInfoInit2 D_8098CDAC; -extern DamageTable D_8098CDB8; +void EnSi_GiveToken(EnSi* this, PlayState* play) { + s32 chestFlag = ENSI_GET_CHEST_FLAG(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Si/func_8098CA20.s") + if ((chestFlag < 0x20) && (chestFlag >= 0)) { + Flags_SetTreasure(play, chestFlag); + } + Item_Give(play, ITEM_SKULL_TOKEN); + if (Inventory_GetSkullTokenCount(play->sceneId) >= SPIDER_HOUSE_TOKENS_REQUIRED) { + Message_StartTextbox(play, 0xFC, NULL); // You collected all tokens, curse lifted + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); + } else { + Message_StartTextbox(play, 0x52, NULL); // You got one more gold token, your [count] one! + Audio_PlayFanfare(NA_BGM_GET_SMALL_ITEM); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Si/func_8098CAD0.s") +void EnSi_Wait(EnSi* this, PlayState* play) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { + this->actionFunc = EnSi_DraggedByHookshot; + } else if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { + EnSi_GiveToken(this, play); + Actor_Kill(&this->actor); + return; + } + this->actor.shape.rot.y += 0x38E; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Si/func_8098CB70.s") +void EnSi_DraggedByHookshot(EnSi* this, PlayState* play) { + if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { + EnSi_GiveToken(this, play); + Actor_Kill(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Si/func_8098CBDC.s") +void EnSi_Init(Actor* thisx, PlayState* play) { + EnSi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Si/EnSi_Init.s") + Collider_InitSphere(play, &this->collider); + Collider_SetSphere(play, &this->collider, &this->actor, &sSphereInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.25f); + this->actionFunc = EnSi_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Si/EnSi_Destroy.s") +void EnSi_Destroy(Actor* thisx, PlayState* play) { + EnSi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Si/EnSi_Update.s") + Collider_DestroySphere(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Si/EnSi_Draw.s") +void EnSi_Update(Actor* thisx, PlayState* play) { + EnSi* this = THIS; + + this->actionFunc(this, play); + EnSi_UpdateCollision(this, play); + Actor_SetFocus(&this->actor, 0.0f); +} + +void EnSi_Draw(Actor* thisx, PlayState* play) { + EnSi* this = THIS; + + func_800B8118(&this->actor, play, 0); + func_800B8050(&this->actor, play, 0); + GetItem_Draw(play, GID_SKULL_TOKEN_2); +} diff --git a/src/overlays/actors/ovl_En_Si/z_en_si.h b/src/overlays/actors/ovl_En_Si/z_en_si.h index b401e5e6a..f1b089ddd 100644 --- a/src/overlays/actors/ovl_En_Si/z_en_si.h +++ b/src/overlays/actors/ovl_En_Si/z_en_si.h @@ -3,6 +3,10 @@ #include "global.h" +#define ENSI_GET_CHEST_FLAG(thisx) (((thisx)->params & 0xFC) >> 2) + +#define SPIDER_HOUSE_TOKENS_REQUIRED 30 + struct EnSi; typedef void (*EnSiActionFunc)(struct EnSi*, PlayState*); @@ -10,7 +14,7 @@ typedef void (*EnSiActionFunc)(struct EnSi*, PlayState*); typedef struct EnSi { /* 0x000 */ Actor actor; /* 0x144 */ EnSiActionFunc actionFunc; - /* 0x148 */ char unk_148[0x58]; + /* 0x148 */ ColliderSphere collider; } EnSi; // size = 0x1A0 #endif // Z_EN_SI_H 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 bb1fb7e0b..735111a2b 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -230,7 +230,7 @@ void EnSkb_Init(Actor* thisx, PlayState* play) { this->unk_3D6 = ENSKB_GET_F0(&this->actor); this->actor.floorHeight = this->actor.world.pos.y; - if ((play->sceneId == SCENE_BOTI) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_BOTI) && (gSaveContext.sceneLayer == 1) && (play->csCtx.scriptIndex == 0)) { this->actor.flags |= ACTOR_FLAG_100000; } @@ -289,7 +289,7 @@ void func_80994DA8(EnSkb* this, PlayState* play) { void func_80994E2C(EnSkb* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); this->actor.flags &= ~ACTOR_FLAG_1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_APPEAR); this->unk_3D0 = 0; this->unk_3DE = 0; this->actionFunc = func_80994E94; @@ -325,7 +325,7 @@ void func_80994F7C(EnSkb* this, PlayState* play) { this->unk_3E0 = 1; } this->actionFunc = func_80995190; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && !(this->collider.base.acFlags & AC_HIT)) { func_800B8614(&this->actor, play, 100.0f); } @@ -333,7 +333,7 @@ void func_80994F7C(EnSkb* this, PlayState* play) { void func_8099504C(EnSkb* this) { this->actionFunc = func_80995068; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void func_80995068(EnSkb* this, PlayState* play) { @@ -349,7 +349,7 @@ void func_80995068(EnSkb* this, PlayState* play) { this->unk_3E0 = 1; } this->actionFunc = func_80995190; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else if (Player_GetMask(play) != PLAYER_MASK_CAPTAIN) { this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); @@ -417,7 +417,7 @@ void func_809952D8(EnSkb* this) { this->unk_3DE = 9; this->actionFunc = func_8099533C; this->actor.shape.shadowScale = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.shape.yOffset = 0.0f; } @@ -439,7 +439,7 @@ void func_809953E8(EnSkb* this) { this->unk_3DE = 10; this->actionFunc = func_8099544C; this->actor.shape.shadowScale = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.shape.yOffset = 0.0f; } @@ -462,7 +462,7 @@ void func_809954F8(EnSkb* this) { this->actionFunc = func_8099556C; this->actor.gravity = 0.0f; this->actor.shape.shadowScale = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.shape.yOffset = 0.0f; this->actor.targetArrowOffset = 4000.0f; } @@ -495,19 +495,19 @@ void func_8099556C(EnSkb* this, PlayState* play) { } void func_8099571C(EnSkb* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_3DC = 0; this->actor.shape.shadowScale = 0.0f; if (this->unk_3DE == 9) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 8); - this->actor.speedXZ = 2.4f; + this->actor.speed = 2.4f; this->actor.gravity = -1.0f; this->actor.velocity.y = 3.0f; } else if (this->unk_3DE == 0xA) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 8); } else if (this->unk_3DE == 0xB) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 9); - this->actor.speedXZ = 3.2f; + this->actor.speed = 3.2f; this->actor.gravity = -1.0f; this->actor.velocity.y = 2.0f; } @@ -526,8 +526,8 @@ void func_80995818(EnSkb* this, PlayState* play) { func_80995A30(this); } - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + this->actor.speed = 0.0f; for (i = 0; i < 10; i++) { func_809947B0(play, this, &this->actor.world.pos); } @@ -539,8 +539,8 @@ void func_809958F4(EnSkb* this) { 0.0f, ANIMMODE_ONCE, -4.0f); this->unk_3E4 = 0; this->actor.flags &= ~ACTOR_FLAG_1; - this->actor.speedXZ = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + this->actor.speed = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->unk_3DE = 1; this->actionFunc = func_8099599C; } @@ -561,7 +561,7 @@ void func_8099599C(EnSkb* this, PlayState* play) { void func_80995A30(EnSkb* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); - this->actor.speedXZ = 1.6f; + this->actor.speed = 1.6f; this->unk_3DA = 0; this->unk_3DE = 2; this->actionFunc = func_80995A8C; @@ -585,7 +585,7 @@ void func_80995A8C(EnSkb* this, PlayState* play) { 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)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_WALK); } if ((this->actor.xzDistToPlayer > 800.0f) || func_80996594(this, play)) { @@ -598,14 +598,14 @@ void func_80995A8C(EnSkb* this, PlayState* play) { void func_80995C24(EnSkb* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); this->collider.base.atFlags &= ~AT_BOUNCED; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_3DE = 3; this->actionFunc = func_80995C84; } void func_80995C84(EnSkb* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 3.0f) && (this->unk_3E4 == 0)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_ATTACK); this->unk_3E4 = 1; } else if (Animation_OnFrame(&this->skelAnime, 6.0f)) { this->unk_3E4 = 0; @@ -635,27 +635,27 @@ void func_80995DC4(EnSkb* this, PlayState* play) { } void func_80995E08(EnSkb* this) { - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.speed = 0.0f; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->unk_3E4 = 0; this->unk_3DE = 5; this->actionFunc = func_80995E64; } void func_80995E64(EnSkb* this, PlayState* play) { - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + this->actor.speed = 0.0f; } - if (this->actor.bgCheckFlags & 1) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.05f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + if (this->actor.speed < 0.0f) { + this->actor.speed += 0.05f; } } - if ((this->actor.colorFilterTimer == 0) && (this->actor.bgCheckFlags & 1)) { + if ((this->actor.colorFilterTimer == 0) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { if (this->unk_3DC == 0) { if (this->actor.colChkInfo.health == 0) { func_809961E4(this, play); @@ -684,43 +684,44 @@ void func_80995F98(EnSkb* this) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 8); this->actor.gravity = -1.0f; - this->actor.speedXZ = 1.0f; + this->actor.speed = 1.0f; } else if (this->unk_3DE == 0xB) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 9); - this->actor.speedXZ = 3.2f; + this->actor.speed = 3.2f; this->actor.velocity.y = 2.0f; this->actor.gravity = -1.0f; } else { this->actor.world.rot.y = this->actor.yawTowardsPlayer; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = -4.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.speed = -4.0f; } } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3DE = 6; this->actionFunc = func_809960AC; } void func_809960AC(EnSkb* this, PlayState* play) { - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { s32 i; for (i = 0; i < 10; i++) { func_809947B0(play, this, &this->actor.world.pos); } - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } - if (this->actor.bgCheckFlags & 1) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.05f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + if (this->actor.speed < 0.0f) { + this->actor.speed += 0.05f; } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0x9C4, 0); } Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 0x10, 0x7D0, 0x64); - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (this->actor.bgCheckFlags & 1)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->actor.shape.rot.x = 0; this->actor.world.rot = this->actor.shape.rot; func_80994DA8(this, play); @@ -730,8 +731,8 @@ void func_809960AC(EnSkb* this, PlayState* play) { void func_809961E4(EnSkb* this, PlayState* play) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); this->unk_3D8 |= 0x40; - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = -6.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.speed = -6.0f; } this->unk_3E4 = 0; this->actor.flags &= ~ACTOR_FLAG_1; @@ -749,7 +750,7 @@ void func_80996284(EnSkb* this, PlayState* play) { } void func_809962D4(EnSkb* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = func_8099630C; } @@ -759,7 +760,7 @@ void func_8099630C(EnSkb* this, PlayState* play) { this->drawDmgEffScale = 0.0f; this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); this->unk_3D8 |= 1; func_80995F98(this); @@ -781,7 +782,7 @@ void func_809963D8(EnSkb* this, PlayState* play) { this->drawDmgEffScale = 0.0f; this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); this->unk_3D8 |= 1; func_80995F98(this); @@ -873,7 +874,8 @@ void func_8099672C(EnSkb* this, PlayState* play) { Player* player = GET_PLAYER(play); if ((this->unk_3DE != 6) && (this->unk_3DE != 7)) { - if ((this->actor.bgCheckFlags & 0x60) && (this->actor.depthInWater >= 40.0f)) { + if ((this->actor.bgCheckFlags & (BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH)) && + (this->actor.depthInWater >= 40.0f)) { this->actor.colChkInfo.health = 0; this->unk_3E4 = 0; func_809961E4(this, play); @@ -913,12 +915,12 @@ void func_8099672C(EnSkb* this, PlayState* play) { this->drawDmgEffTimer = 40; this->drawDmgEffAlpha = 1.0f; this->drawDmgEffScale = 0.0f; - Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 120, COLORFILTER_BUFFLAG_OPA, 40); func_80995E08(this); break; case 1: - Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 120, COLORFILTER_BUFFLAG_OPA, 40); func_80995E08(this); break; @@ -927,14 +929,14 @@ void func_8099672C(EnSkb* this, PlayState* play) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->drawDmgEffAlpha = 1.0f; this->drawDmgEffScale = 0.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); this->unk_3D8 |= 1; func_80995F98(this); break; case 3: if (this->actor.colChkInfo.health != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->drawDmgEffTimer = 80; } else { this->drawDmgEffTimer = 3; @@ -942,7 +944,7 @@ void func_8099672C(EnSkb* this, PlayState* play) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; this->drawDmgEffAlpha = 1.0f; this->drawDmgEffScale = 0.5f; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); func_809962D4(this); break; @@ -951,8 +953,8 @@ void func_8099672C(EnSkb* this, PlayState* play) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->drawDmgEffAlpha = 1.0f; this->drawDmgEffScale = 0.5f; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); func_809963C4(this); break; @@ -970,7 +972,7 @@ void func_8099672C(EnSkb* this, PlayState* play) { } case 13: - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); func_80995F98(this); break; @@ -1060,7 +1062,9 @@ void EnSkb_Update(Actor* thisx, PlayState* play) { Actor_MoveWithGravity(&this->actor); } - Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 60.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 60.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); func_809964DC(this, play); func_80996AD0(this, play); func_80996D68(this, play); diff --git a/src/overlays/actors/ovl_En_Slime/z_en_slime.c b/src/overlays/actors/ovl_En_Slime/z_en_slime.c index 2b8e5f4c6..3aab4b3ce 100644 --- a/src/overlays/actors/ovl_En_Slime/z_en_slime.c +++ b/src/overlays/actors/ovl_En_Slime/z_en_slime.c @@ -10,30 +10,62 @@ #define THIS ((EnSlime*)thisx) +#define ICE_BLOCK_TIMER_MAX 254 +#define ICE_BLOCK_UNUSED (ICE_BLOCK_TIMER_MAX + 1) + +typedef enum EnSlimeEyeTexture { + /* 0 */ EN_SLIME_EYETEX_OPEN, + /* 1 */ EN_SLIME_EYETEX_HALF, + /* 2 */ EN_SLIME_EYETEX_CLOSED, + /* 3 */ EN_SLIME_EYETEX_HALF2, + /* 4 */ EN_SLIME_EYETEX_MAX +} EnSlimeEyeTexture; + +typedef enum EnSlimeDamageEffect { + /* 0x0 */ EN_SLIME_DMGEFF_NORMAL, + /* 0x1 */ EN_SLIME_DMGEFF_STUN, + /* 0x3 */ EN_SLIME_DMGEFF_FREEZE = 0x3, + /* 0x4 */ EN_SLIME_DMGEFF_LIGHT, + /* 0x5 */ EN_SLIME_DMGEFF_ELECTRIC, + /* 0xE */ EN_SLIME_DMGEFF_HOOKSHOT = 0xE, + /* 0xF */ EN_SLIME_DMGEFF_BLUNT, +} EnSlimeDamageEffect; + void EnSlime_Init(Actor* thisx, PlayState* play); void EnSlime_Destroy(Actor* thisx, PlayState* play); void EnSlime_Update(Actor* thisx, PlayState* play); void EnSlime_Draw(Actor* thisx, PlayState* play); -void func_80A2F140(EnSlime* this, PlayState* play); -void func_80A2F1A4(EnSlime* this, PlayState* play); -void func_80A2F418(EnSlime* this, PlayState* play); -void func_80A2F6CC(EnSlime* this, PlayState* play); -void func_80A2F8E0(EnSlime* this, PlayState* play); -void func_80A2FA88(EnSlime* this, PlayState* play); -void func_80A2FBA0(EnSlime* this, PlayState* play); -void func_80A2FE38(EnSlime* this, PlayState* play); -void func_80A30344(EnSlime* this, PlayState* play); -void func_80A304B8(EnSlime* this, PlayState* play); -void func_80A30820(EnSlime* this, PlayState* play); -void func_80A30944(EnSlime* this, PlayState* play); -void func_80A30A20(EnSlime* this, PlayState* play); -void func_80A30AE4(EnSlime* this, PlayState* play); -void func_80A30C2C(EnSlime* this, PlayState* play); -void func_80A30CEC(EnSlime* this, PlayState* play); +void EnSlime_SetupInitializeIdle(EnSlime* this); +void EnSlime_InitializeIdle(EnSlime* this, PlayState* play); +void EnSlime_SetupIdle(EnSlime* this); +void EnSlime_Idle(EnSlime* this, PlayState* play); +void EnSlime_SetupMoveInDirection(EnSlime* this); +void EnSlime_MoveInDirection(EnSlime* this, PlayState* play); +void EnSlime_SetupMoveToHome(EnSlime* this); +void EnSlime_MoveToHome(EnSlime* this, PlayState* play); +void EnSlime_SetupTurnToPlayer(EnSlime* this); +void EnSlime_TurnToPlayer(EnSlime* this, PlayState* play); +void EnSlime_SetupJump(EnSlime* this); +void EnSlime_Jump(EnSlime* this, PlayState* play); +void EnSlime_SetupLand(EnSlime* this); +void EnSlime_Land(EnSlime* this, PlayState* play); +void EnSlime_ReactToBluntHit(EnSlime* this, PlayState* play); +void EnSlime_Damaged(EnSlime* this, PlayState* play); +void EnSlime_SetupDead(EnSlime* this); +void EnSlime_Dead(EnSlime* this, PlayState* play); +void EnSlime_SpawnIceBlock(EnSlime* this, PlayState* play); +void EnSlime_SetupIceBlock(EnSlime* this); +void EnSlime_IceBlock(EnSlime* this, PlayState* play); +void EnSlime_Stun(EnSlime* this, PlayState* play); +void EnSlime_SetupIceBlockThaw(EnSlime* this); +void EnSlime_IceBlockThaw(EnSlime* this, PlayState* play); +void EnSlime_SetupWaitForRevive(EnSlime* this); +void EnSlime_WaitForRevive(EnSlime* this, PlayState* play); +void EnSlime_SetupRevive(EnSlime* this); +void EnSlime_Revive(EnSlime* this, PlayState* play); -#if 0 -ActorInit En_Slime_InitVars = { +const ActorInit En_Slime_InitVars = { ACTOR_EN_SLIME, ACTORCAT_ENEMY, FLAGS, @@ -45,146 +77,1171 @@ ActorInit En_Slime_InitVars = { (ActorFunc)EnSlime_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A31AF0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 22, 35, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A31B1C = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(3, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xE), - /* Goron punch */ DMG_ENTRY(0, 0xF), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(0, 0xF), - /* Fire arrow */ DMG_ENTRY(2, 0x0), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(0, 0xF), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(1, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(0, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_SLIME_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(3, EN_SLIME_DMGEFF_NORMAL), + /* Horse trample */ DMG_ENTRY(1, EN_SLIME_DMGEFF_NORMAL), + /* Explosives */ DMG_ENTRY(1, EN_SLIME_DMGEFF_NORMAL), + /* Zora boomerang */ DMG_ENTRY(1, EN_SLIME_DMGEFF_NORMAL), + /* Normal arrow */ DMG_ENTRY(1, EN_SLIME_DMGEFF_NORMAL), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_SLIME_DMGEFF_NORMAL), + /* Hookshot */ DMG_ENTRY(0, EN_SLIME_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(0, EN_SLIME_DMGEFF_BLUNT), + /* Sword */ DMG_ENTRY(1, EN_SLIME_DMGEFF_NORMAL), + /* Goron pound */ DMG_ENTRY(0, EN_SLIME_DMGEFF_BLUNT), + /* Fire arrow */ DMG_ENTRY(2, EN_SLIME_DMGEFF_NORMAL), + /* Ice arrow */ DMG_ENTRY(2, EN_SLIME_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, EN_SLIME_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, EN_SLIME_DMGEFF_NORMAL), + /* Deku spin */ DMG_ENTRY(1, EN_SLIME_DMGEFF_NORMAL), + /* Deku bubble */ DMG_ENTRY(0, EN_SLIME_DMGEFF_BLUNT), + /* Deku launch */ DMG_ENTRY(2, EN_SLIME_DMGEFF_NORMAL), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_SLIME_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(1, EN_SLIME_DMGEFF_ELECTRIC), + /* Normal shield */ DMG_ENTRY(0, EN_SLIME_DMGEFF_NORMAL), + /* Light ray */ DMG_ENTRY(0, EN_SLIME_DMGEFF_NORMAL), + /* Thrown object */ DMG_ENTRY(0, EN_SLIME_DMGEFF_BLUNT), + /* Zora punch */ DMG_ENTRY(1, EN_SLIME_DMGEFF_NORMAL), + /* Spin attack */ DMG_ENTRY(1, EN_SLIME_DMGEFF_NORMAL), + /* Sword beam */ DMG_ENTRY(0, EN_SLIME_DMGEFF_NORMAL), + /* Normal Roll */ DMG_ENTRY(0, EN_SLIME_DMGEFF_NORMAL), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_SLIME_DMGEFF_NORMAL), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_SLIME_DMGEFF_NORMAL), + /* Unblockable */ DMG_ENTRY(0, EN_SLIME_DMGEFF_NORMAL), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_SLIME_DMGEFF_NORMAL), + /* Powder Keg */ DMG_ENTRY(1, EN_SLIME_DMGEFF_NORMAL), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80A31B3C = { 1, 22, 35, 60 }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 22, 35, 60 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A31B54[] = { +static TexturePtr sEyeTextures[] = { + gChuchuEyeOpenTex, + gChuchuEyeHalfTex, + gChuchuEyeClosedTex, + gChuchuEyeHalfTex, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(gravity, -2, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 6000, ICHAIN_STOP), }; -#endif +static s32 sTexturesDesegmented = false; -extern ColliderCylinderInit D_80A31AF0; -extern DamageTable D_80A31B1C; -extern CollisionCheckInfoInit D_80A31B3C; -extern InitChainEntry D_80A31B54[]; +static Color_RGBA8 sBubblePrimColor = { 255, 255, 255, 255 }; +static Color_RGBA8 sBubbleEnvColor = { 150, 150, 150, 0 }; +static Vec3f sBubbleAccel = { 0.0f, -0.8f, 0.0f }; -extern UNK_TYPE D_060004C0; -extern UNK_TYPE D_06000828; +static Color_RGBA8 sPrimColors[] = { + { 255, 255, 255, 255 }, + { 255, 255, 0, 255 }, + { 255, 255, 200, 255 }, + { 225, 200, 255, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/EnSlime_Init.s") +static Color_RGBA8 sEnvColors[] = { + { 140, 255, 195, 255 }, + { 50, 255, 0, 255 }, + { 255, 180, 0, 255 }, + { 255, 50, 155, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/EnSlime_Destroy.s") +static Vec3f sLimbPosOffsets[EN_SLIME_LIMBPOS_COUNT] = { + { 2000.0f, 2000.0f, 0.0f }, { -1500.0f, 2500.0f, -500.0f }, { -500.0f, 1000.0f, 2500.0f }, + { 0.0f, 4000.0f, 0.0f }, { 0.0f, 2000.0f, -2000.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2EFAC.s") +AnimatedMaterial* sSlimeTexAnim; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2F028.s") +void EnSlime_Init(Actor* thisx, PlayState* play) { + EnSlime* this = THIS; + s32 reviveTimeSeconds; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2F0A8.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 38.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2F110.s") + this->iceBlockTimer = ICE_BLOCK_UNUSED; + this->eyeTexIndex = EN_SLIME_EYETEX_OPEN; + this->wobbleRot.y = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2F140.s") + // Sets maximum distance chuchu will move from its home before turning around. + if (this->actor.shape.rot.x <= 0) { + this->distLimit = 30000.0f; + } else { + this->distLimit = this->actor.shape.rot.x * 40.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2F180.s") + this->actor.shape.rot.x = 0; + reviveTimeSeconds = EN_SLIME_GET_REVIVE_TIME(&this->actor); + this->actor.shape.rot.z = 0; + this->actor.params &= 0xFF; + if (reviveTimeSeconds == 0xFF) { + reviveTimeSeconds = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2F1A4.s") + // Upper byte of actorParams at init is # of seconds past 10s to revive. + this->reviveTime = (reviveTimeSeconds * 20) + 200; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2F354.s") + // Update addresses of texture assets (if another instance hasn't already) + if (!sTexturesDesegmented) { + for (i = 0; i < EN_SLIME_EYETEX_MAX; i++) { + sEyeTextures[i] = Lib_SegmentedToVirtual(sEyeTextures[i]); + } + sSlimeTexAnim = Lib_SegmentedToVirtual(gChuchuSlimeFlowTexAnim); + sTexturesDesegmented = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2F418.s") + // Set hint IDs and drop item icon depending on chuchu color + if (EN_SLIME_GET_TYPE(&this->actor) == EN_SLIME_TYPE_YELLOW) { + this->itemDropTex = Lib_SegmentedToVirtual(gDropArrows1Tex); + this->actor.hintId = TATL_HINT_ID_YELLOW_CHUCHU; + } else if (EN_SLIME_GET_TYPE(&this->actor) == EN_SLIME_TYPE_GREEN) { + this->itemDropTex = Lib_SegmentedToVirtual(gDropMagicSmallTex); + this->actor.hintId = TATL_HINT_ID_GREEN_CHUCHU; + } else if (EN_SLIME_GET_TYPE(&this->actor) == EN_SLIME_TYPE_RED) { + this->itemDropTex = Lib_SegmentedToVirtual(gDropRecoveryHeartTex); + this->actor.hintId = TATL_HINT_ID_RED_CHUCHU; + } else { + this->actor.hintId = TATL_HINT_ID_BLUE_CHUCHU; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2F684.s") + // Sets actor scale and initial action func + EnSlime_SetupInitializeIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2F6CC.s") +void EnSlime_Destroy(Actor* thisx, PlayState* play) { + EnSlime* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2F8B4.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2F8E0.s") +/** + * Upon immobilization via ice arrow (for chuchu types outside of blue), + * initialize ice visual effects before chuchu enters immobile state. + */ +void EnSlime_Freeze(EnSlime* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.4f; + this->collider.base.colType = COLTYPE_HIT3; + this->drawDmgEffFrozenSteamScale = 0.6f; + this->drawDmgEffAlpha = 1.0f; + this->timer = 80; + this->actor.flags &= ~ACTOR_FLAG_400; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_XLU, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2F9A0.s") +/** + * If stunned ice effect is active (ie. non-blue chuchu was frozen by ice arrow), + * initialize thaw and spawn thawing effect. + */ +void EnSlime_Thaw(EnSlime* this, PlayState* play) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = 0; // So it's not triggered again until Freeze has been called again. + this->collider.base.colType = COLTYPE_NONE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.2f, 0.2f); + this->actor.flags |= ACTOR_FLAG_200; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2FA88.s") +/** + * If blink animation is in progress, advance to next frame. + * If eyes are open, randomly (5% chance) initialize new blink cycle. + */ +void EnSlime_Blink(EnSlime* this) { + if (this->eyeTexIndex != EN_SLIME_EYETEX_OPEN) { + this->eyeTexIndex++; + if (this->eyeTexIndex == EN_SLIME_EYETEX_MAX) { + this->eyeTexIndex = EN_SLIME_EYETEX_OPEN; + } + } else if (Rand_ZeroOne() < 0.05f) { + this->eyeTexIndex = EN_SLIME_EYETEX_HALF; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2FB60.s") +/** + * Set the actor's initial scale and action function. + */ +void EnSlime_SetupInitializeIdle(EnSlime* this) { + this->actor.scale.x = 0.008f; + this->actor.scale.z = 0.008f; + this->actor.scale.y = 0.011f; + this->actionFunc = EnSlime_InitializeIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2FBA0.s") +/** + * Once actor touches the ground, it starts its idle behavior. + * This function is only called right after the actor is first initialized. + * It is not set as the action function again. + */ +void EnSlime_InitializeIdle(EnSlime* this, PlayState* play) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.flags &= ~ACTOR_FLAG_10; + EnSlime_SetupIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2FD94.s") +/** + * Set or restore idle action state. + * Sets timer to 25 and cycles to SitIdle action. + */ +void EnSlime_SetupIdle(EnSlime* this) { + this->timer = 25; + this->actor.speed = 0.0f; + this->actionFunc = EnSlime_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A2FE38.s") +/** + * Sit idle for one frame, updating rotation and scale to give + * the actor an amorphous, oozing effect. + * Chuchu will engage player if player is visible and + * close enough to it. + */ +void EnSlime_Idle(EnSlime* this, PlayState* play) { + f32 timerFactor; + f32 scale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A30018.s") + this->timer--; + timerFactor = sqrtf(this->timer) * 0.2f; + EnSlime_Blink(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A30344.s") + scale = ((sin_rad(this->timer * (2.0f * M_PI / 5.0f)) * (0.13f * timerFactor)) + 1.0f) * 0.01f; + this->actor.scale.x = scale; + this->actor.scale.z = scale; + if (this->timer < 24) { + this->actor.scale.y = ((cos_rad(this->timer * (2.0f * M_PI / 5.0f)) * (0.05f * timerFactor)) + 1.0f) * 0.01f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A30454.s") + this->actor.shape.rot.x = randPlusMinusPoint5Scaled(0x200) * timerFactor; + this->actor.shape.rot.z = randPlusMinusPoint5Scaled(0x200) * timerFactor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A304B8.s") + // If player is not wearing the stone mask, is within 280 units of the chuchu, + // and the chuchu is facing the player, initialize chase/attack cycle. + if ((Player_GetMask(play) != PLAYER_MASK_STONE) && (this->actor.xzDistToPlayer < 280.0f) && + Actor_IsFacingPlayer(&this->actor, 0x5000)) { + EnSlime_SetupTurnToPlayer(this); + } else if (this->timer == 0) { + // Start moving (remaining idle) + EnSlime_SetupMoveInDirection(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A3072C.s") +/** + * Reset the action timer (to 120), then select a new direction for + * chuchu to move. + */ +void EnSlime_SetupMoveInDirection(EnSlime* this) { + this->timer = 120; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A30778.s") + // If actor is more than 120 units from its home, set the new direction to be towards its home. + // Otherwise, the new direction to move is pretty much random. + if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 120.0f) { + this->idleRotY = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); + } else if (Rand_ZeroOne() < 0.7f) { + this->idleRotY = (s32)randPlusMinusPoint5Scaled(0x4000) + this->actor.shape.rot.y; + } + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnSlime_MoveInDirection; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A30820.s") +/** + * While moving idle, update rotation, speed, scale in a sinusoidal fashion to + * give oozing effect. + * If actor has hit a wall or is too far from home, turn around. + * Chuchu will engage player during idle movement if player is visible and + * close enough to it. + */ +void EnSlime_MoveInDirection(EnSlime* this, PlayState* play) { + f32 sinFactor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A30924.s") + EnSlime_Blink(this); + this->timer--; + Math_ApproachS(&this->actor.shape.rot.y, this->idleRotY, 4, 0x100); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A30944.s") + // If actor is touching a wall, set target rotation to match wall where it is touching. + // If actor is more than 120 units from its home, turn around to face home. + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { + this->idleRotY = this->actor.wallYaw; + } else if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 120.0f) { + this->idleRotY = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A309C8.s") + // Update actor scale, xz speed, and rotation to provide amorphous effect + sinFactor = fabsf(sin_rad(this->timer * (M_PI / 24))); + Math_StepToF(&this->actor.scale.z, ((0.15f * sinFactor) + 1.0f) * 0.01f, 0.0002f); + Math_StepToF(&this->actor.scale.x, (1.0f - (0.2f * sinFactor)) * 0.01f, 0.0002f); + Math_StepToF(&this->actor.scale.y, (1.0f - (0.1f * sinFactor)) * 0.01f, 0.0002f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A30A20.s") + this->actor.speed = (0.8f * sinFactor) + 0.2f; + this->actor.shape.rot.x = 0x800 * sinFactor; + this->actor.world.rot.y = this->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A30A90.s") + if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > this->distLimit) { + // If actor is too far from home, start return home cycle + EnSlime_SetupMoveToHome(this); + } else if ((Player_GetMask(play) != PLAYER_MASK_STONE) && (this->actor.xzDistToPlayer < 280.0f) && + (Actor_IsFacingPlayer(&this->actor, 0x5000))) { + // If player is close enough to chuchu while not wearing the stone mask, and the chuchu is facing player, + // initialize attack cycle + EnSlime_SetupTurnToPlayer(this); + } else if (this->timer == 0) { + // If move timer runs out, restart idle cycle (sit in place for 25 frames) + EnSlime_SetupIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A30AE4.s") +/** + * Reset the action timer (to 24), then set the target y angle to face home. + */ +void EnSlime_SetupMoveToHome(EnSlime* this) { + this->timer = 24; + this->idleRotY = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnSlime_MoveToHome; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A30BE0.s") +/** + * While moving towards home point, update rotation, speed, scale + * in a sinusoidal fashion to give oozing effect. + * If actor has hit a wall, turn around. + * Once it is close enough to home point, return to idle cycle. + * Chuchu will not engage player while the return home cycle is active. + */ +void EnSlime_MoveToHome(EnSlime* this, PlayState* play) { + f32 timerFactor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A30C2C.s") + EnSlime_Blink(this); + this->timer--; + Math_ApproachS(&this->actor.shape.rot.y, this->idleRotY, 4, 0x400); + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { + // If hit wall, turn around. + this->idleRotY = this->actor.wallYaw; + } else { + this->idleRotY = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A30C68.s") + timerFactor = fabsf(sin_rad(this->timer * (M_PI / 24))); + Math_StepToF(&this->actor.scale.z, ((0.15f * timerFactor) + 1.0f) * 0.01f, 0.0002f); + Math_StepToF(&this->actor.scale.x, (1.0f - (0.2f * timerFactor)) * 0.01f, 0.0002f); + Math_StepToF(&this->actor.scale.y, (1.0f - (0.1f * timerFactor)) * 0.01f, 0.0002f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A30CEC.s") + this->actor.speed = (0.8f * timerFactor) + 0.2f; + this->actor.shape.rot.x = 0x800 * timerFactor; + this->actor.world.rot.y = this->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/func_80A30F98.s") + // Reset timer for use calculating wobble/ooze amount for frame + if (this->timer == 0) { + this->timer = 24; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/EnSlime_Update.s") + // Only return to idle once actor is close enough to home point. + if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) < (this->distLimit * 0.8f)) { + EnSlime_SetupIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Slime/EnSlime_Draw.s") +void EnSlime_SetupTurnToPlayer(EnSlime* this) { + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + this->timer = 8; + this->actionFunc = EnSlime_TurnToPlayer; + this->actor.speed = 0.0f; +} + +/** + * Update actor angle and ooze effect as chuchu initially + * turns to face player. + */ +void EnSlime_TurnToPlayer(EnSlime* this, PlayState* play) { + f32 factorY; + f32 scaleXZ; + + this->timer--; + EnSlime_Blink(this); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0x1000); + if (this->timer >= 0) { + factorY = 8 - this->timer; + scaleXZ = ((factorY * 0.04f) + 1.0f) * 0.01f; + this->actor.scale.x = scaleXZ; + this->actor.scale.y = (1.0f - (factorY * 0.05f)) * 0.01f; + this->actor.scale.z = scaleXZ; + } + if (this->timer < -2) { + EnSlime_SetupJump(this); + } +} + +/** + * If fewer than 120 units from the player, start a larger attack lunge. + * Otherwise, hop forward. + */ +void EnSlime_SetupJump(EnSlime* this) { + if (this->actor.xzDistToPlayer > 120.0f) { + this->actor.velocity.y = 11.0f; + this->actor.speed = 5.0f; + this->actor.gravity = -2.0f; + } else { + this->actor.velocity.y = 18.0f; + this->actor.speed = 7.0f; + this->actor.gravity = -3.5f; + } + this->actor.world.rot.y = this->actor.shape.rot.y; + this->timer = 12; + this->eyeTexIndex = EN_SLIME_EYETEX_OPEN; + Math_StepToF(&this->actor.scale.x, 0.008f, 0.0025f); + Math_StepToF(&this->actor.scale.y, 0.011f, 0.0025f); + this->actor.scale.z = this->actor.scale.x; + Actor_PlaySfx(&this->actor, NA_SE_EN_SLIME_JUMP); + this->actionFunc = EnSlime_Jump; +} + +/** + * Check for collision and whether actor has stopped falling. + * Update actor scale for slime effect. + * If collision, knockback actor. If actor has stopped moving + * in Y direction, initialize landing action. + */ +void EnSlime_Jump(EnSlime* this, PlayState* play) { + this->timer--; + if (this->collider.base.atFlags & AT_HIT) { + if (this->actor.speed > 0.0f) { + this->actor.speed *= -1.2f; + this->collider.base.atFlags &= ~AT_HIT; + } + } + Math_StepToF(&this->actor.scale.x, 0.008f, 0.0025f); + Math_StepToF(&this->actor.scale.y, 0.011f, 0.0025f); + this->actor.scale.z = this->actor.scale.x; + if ((this->actor.velocity.y < 0.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + EnSlime_SetupLand(this); + } +} + +void EnSlime_SetupLand(EnSlime* this) { + this->timer = 15; + this->actor.scale.x = 0.0132f; + this->actor.scale.y = 0.0074399994f; + this->actor.scale.z = 0.0132f; + this->actor.speed = 0.0f; + this->actionFunc = EnSlime_Land; +} + +/** + * Update scale/rot for ooze jiggle effect (XZ), update Y scale + * to make it appear as though chuchu is compressing. + * If > 12 frames have passed since jump start, check again if player + * is in range and restart engage/jump cycle if so. + * If too far from home, initialize return home cycle + * (takes priority over player engage check). + * Otherwise if timer is up, return to idle. + */ +void EnSlime_Land(EnSlime* this, PlayState* play) { + f32 scaleY; + f32 rotXZ; + f32 scaleXZ; + + EnSlime_Blink(this); + this->timer--; + scaleY = ((this->timer / 5) + 1) * 1.6f; + rotXZ = sqrtf(this->timer) * 0.2f; + scaleXZ = ((cos_rad(this->timer * (2.0f * M_PI / 5.0f)) * (0.05f * scaleY)) + 1.0f) * 0.01f; + this->actor.scale.x = scaleXZ; + this->actor.scale.z = scaleXZ; + if (this->timer < 15) { + this->actor.scale.y = (1.0f - (sin_rad(this->timer * (2.0f * M_PI / 5.0f)) * (0.04f * scaleY))) * 0.01f; + } + this->actor.shape.rot.x = randPlusMinusPoint5Scaled(0x200) * rotXZ; + this->actor.shape.rot.z = randPlusMinusPoint5Scaled(0x200) * rotXZ; + + if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > this->distLimit) { + EnSlime_SetupMoveToHome(this); + } else if ((Player_GetMask(play) != PLAYER_MASK_STONE) && (this->actor.xzDistToPlayer < 280.0f) && + (this->timer < 12)) { + EnSlime_SetupTurnToPlayer(this); + } else if (this->timer == 0) { + EnSlime_SetupIdle(this); + } +} + +/** + * Initialize reaction to receiving a blunt hit (such as with Goron Punch etc.) + * Chuchu does not take damage, but appears slide backwards. + */ +void EnSlime_SetupReactToBluntHit(EnSlime* this) { + this->actor.speed = 10.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + this->collider.base.acFlags &= ~AC_ON; + this->timer = 30; + Actor_PlaySfx(&this->actor, NA_SE_EN_SLIME_DEFENCE); + if (this->collider.base.ac != NULL) { + this->actor.world.rot.y = Actor_WorldYawTowardActor(&this->actor, this->collider.base.ac) + 0x8000; + } else { + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + } + this->actionFunc = EnSlime_ReactToBluntHit; +} + +/** + * Update reaction to receiving a blunt hit (such as with Goron Punch etc.) + * Update XZ speed and jiggle effect + * AC_ON flag is off until 15 frames of reaction remain. + * When timer is up, chuchu will choose whether to engage player, return home, + * or return to idle. + * If chuchu is too far from home, returning home will take precedence. + */ +void EnSlime_ReactToBluntHit(EnSlime* this, PlayState* play) { + f32 timerFactor; + f32 scale; + + EnSlime_Blink(this); + this->timer--; + Math_StepToF(&this->actor.speed, 0.0f, 1.0f); + timerFactor = sqrtf(this->timer); + if (this->timer < 30) { + scale = ((cos_rad(this->timer * (2.0f * M_PI / 5.0f)) * (0.08f * timerFactor)) + 1.0f) * 0.01f; + this->actor.scale.x = scale; + this->actor.scale.z = scale; + } + if (this->timer == 15) { + this->collider.base.acFlags |= AC_ON; + } + this->actor.scale.y = ((sin_rad((f32)this->timer * (2.0f * M_PI / 5.0f)) * (0.07f * timerFactor)) + 1.0f) * 0.01f; + this->actor.shape.rot.x = randPlusMinusPoint5Scaled(0x200) * timerFactor; + this->actor.shape.rot.z = randPlusMinusPoint5Scaled(0x200) * timerFactor; + + if (this->timer == 0) { + if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > this->distLimit) { + EnSlime_SetupMoveToHome(this); + } else if ((this->actor.xzDistToPlayer < 280.0f) && (Player_GetMask(play) != PLAYER_MASK_STONE)) { + EnSlime_SetupTurnToPlayer(this); + } else { + EnSlime_SetupIdle(this); + } + } +} + +/** + * Spawn bubbles & splash, start actor rebuff wobble, + * push actor, and play sfx. + */ +void EnSlime_SetupDamaged(EnSlime* this, PlayState* play, s32 arg2) { + s32 i; + Vec3f effectVelocity; + Vec3f effectPos; + f32 ySin; + f32 yCos; + + this->collider.base.acFlags &= ~AC_ON; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_XLU, 20); + this->timer = 20; + this->actor.speed = 10.0f; + if (arg2 == true) { + // This function changes actor's world Y rotation? + func_800BE504(&this->actor, &this->collider); + } + + this->eyeTexIndex = EN_SLIME_EYETEX_OPEN; + Actor_SetScale(&this->actor, 0.01f); + this->wobbleRot.x = Rand_ZeroOne() * (M_PI * 2.0f); + this->wobbleRot.z = Rand_ZeroOne() * (M_PI * 2.0f); + ySin = Math_SinS(this->actor.world.rot.y) * 10.0f; + yCos = Math_CosS(this->actor.world.rot.y) * 10.0f; + effectPos.x = this->actor.world.pos.x + ySin; + effectPos.y = this->actor.world.pos.y + 20.0f; + effectPos.z = this->actor.world.pos.z + yCos; + EffectSsGSplash_Spawn(play, &effectPos, NULL, NULL, 1, 550); + + for (i = 0; i < 10; i++) { + effectPos.x = randPlusMinusPoint5Scaled(40.0f) + this->actor.world.pos.x + ySin; + effectPos.y = randPlusMinusPoint5Scaled(10.0f) + this->actor.world.pos.y + 40.0f; + effectPos.z = randPlusMinusPoint5Scaled(40.0f) + this->actor.world.pos.z + yCos; + + effectVelocity.x = ((Rand_ZeroOne() * 3.5f) + 1.0f) * -Math_SinS(this->actor.world.rot.y); + effectVelocity.z = ((Rand_ZeroOne() * 3.5f) + 1.0f) * -Math_CosS(this->actor.world.rot.y); + + effectVelocity.y = (Rand_ZeroOne() * 6.0f) + 2.0f; + EffectSsDtBubble_SpawnCustomColor(play, &effectPos, &effectVelocity, &sBubbleAccel, &sBubblePrimColor, + &sBubbleEnvColor, Rand_S16Offset(40, 20), 20, 0); + } + + if (this->actor.colChkInfo.health == 0) { + Actor_PlaySfx(&this->actor, NA_SE_EN_SLIME_DEAD); + } else { + Actor_PlaySfx(&this->actor, NA_SE_EN_SLIME_DAMAGE); + } + this->actionFunc = EnSlime_Damaged; +} + +/** + * Update reaction to taking damage. + * Updates the rebuff wobble. + * Once timer drops to 0, actor initializes death cycle, re-engages player, or returns to idle. + */ +void EnSlime_Damaged(EnSlime* this, PlayState* play) { + this->timer--; + Math_StepToF(&this->actor.speed, 0.0f, 1.0f); + if ((this->timer % 5) == 0) { + this->wobbleRot.x = Rand_ZeroOne() * (M_PI * 2.0f); + this->wobbleRot.z = Rand_ZeroOne() * (M_PI * 2.0f); + } + if (this->timer == 0) { + if (this->actor.colChkInfo.health != 0) { + this->collider.base.acFlags |= AC_ON; + if ((this->actor.xzDistToPlayer < 280.0f) && (Player_GetMask(play) != PLAYER_MASK_STONE)) { + EnSlime_SetupTurnToPlayer(this); + } else { + EnSlime_SetupIdle(this); + } + } else { + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_SLIME_BREAK); + EnSlime_SetupDead(this); + } + } +} + +/** + * Disable AC_ON flag, make actor stop moving, and shrink the actor. + */ +void EnSlime_SetupDead(EnSlime* this) { + this->collider.base.acFlags &= ~AC_ON; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + Actor_SetScale(&this->actor, 0.01f); + this->actor.speed = 0.0f; + this->actionFunc = EnSlime_Dead; +} + +/** + * Spawn random effects (bubbles, splash) for death sequence. + * If chuchu is red, green, or yellow, spawn item drop. + * Shrink actor scale to 0. + * Call SetupWaitForRevive function for cleanup. + */ +void EnSlime_Dead(EnSlime* this, PlayState* play) { + s32 i; + Vec3f velocity; + Vec3f effectPos; + f32 randFloat; + s32 randSign; + + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.002f)) { + effectPos.x = this->actor.world.pos.x; + effectPos.y = this->actor.world.pos.y + 20.0f; + effectPos.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(play, &effectPos, NULL, NULL, 1, 800); + + for (i = 0; i < 15; i++) { + randFloat = Rand_ZeroOne(); + randSign = Rand_ZeroOne() < 0.5f ? -1 : 1; + velocity.x = randSign * ((randFloat * 2.5f) + 2.0f); + + randFloat = Rand_ZeroOne(); + randSign = Rand_ZeroOne() < 0.5f ? -1 : 1; + velocity.z = randSign * ((randFloat * 2.5f) + 2.0f); + + velocity.y = (Rand_ZeroOne() * 6.0f) + 2.0f; + EffectSsDtBubble_SpawnCustomColor(play, &effectPos, &velocity, &sBubbleAccel, &sBubblePrimColor, + &sBubbleEnvColor, Rand_S16Offset(40, 20), 20, 0); + } + + if (this->actor.params == EN_SLIME_TYPE_YELLOW) { + Item_DropCollectible(play, &this->actor.world.pos, ITEM00_ARROWS_10); + } else if (this->actor.params == EN_SLIME_TYPE_GREEN) { + Item_DropCollectible(play, &this->actor.world.pos, ITEM00_MAGIC_SMALL); + } else if (this->actor.params == EN_SLIME_TYPE_RED) { + Item_DropCollectible(play, &this->actor.world.pos, ITEM00_RECOVERY_HEART); + } + EnSlime_SetupWaitForRevive(this); + } + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; +} + +/** + * Calculate a new "current" position value that is a multiple of 60 + * away from the "home" position. + * This is for use by blue chuchus frozen into an ice block so that + * their position is a multiple of the ice block size. + */ +f32 EnSlime_SnapIceBlockPosition(f32 currentPosition, f32 homePosition) { + s32 dist = currentPosition - homePosition; + + if (dist > 0) { + dist += 30; + } else { + dist -= 30; + } + + return ((dist / 60) * 60.0f) + homePosition; +} + +/** + * Prepare actor for ice block to spawn around it. + * The actor will stop moving, have AC_ON cleared, + * and target position will be snapped to + * a multiple of the size of an ice block. + */ +void EnSlime_SetupSpawnIceBlock(EnSlime* this) { + this->collider.base.acFlags &= ~AC_ON; + this->actor.flags &= ~ACTOR_FLAG_1; + this->drawDmgEffAlpha = 0.0f; + this->actor.speed = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + this->iceBlockSnapPos.x = EnSlime_SnapIceBlockPosition(this->actor.world.pos.x, this->actor.home.pos.x); + this->iceBlockSnapPos.z = EnSlime_SnapIceBlockPosition(this->actor.world.pos.z, this->actor.home.pos.z); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_GRAY, COLORFILTER_INTENSITY_FLAG | 255, + COLORFILTER_BUFFLAG_XLU, 10); + this->eyeTexIndex = EN_SLIME_EYETEX_OPEN; + this->iceBlockTimer = ICE_BLOCK_TIMER_MAX; + this->actionFunc = EnSlime_SpawnIceBlock; +} + +/** + * Attempt to move the chuchu to snapped position and + * spawn an ice block actor as a child of the chuchu actor. + * If ice block spawn fails, chuchu returns to idle. + */ +void EnSlime_SpawnIceBlock(EnSlime* this, PlayState* play) { + s32 stepCheck; + + stepCheck = Math_StepToF(&this->actor.world.pos.x, this->iceBlockSnapPos.x, 10.0f); + stepCheck &= Math_StepToF(&this->actor.world.pos.z, this->iceBlockSnapPos.z, 10.0f); + + this->actor.colorFilterTimer = 10; + if (stepCheck) { + this->actor.child = + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_OBJ_ICEBLOCK, this->actor.world.pos.x, + this->actor.world.pos.y + 30.0f, this->actor.world.pos.z, 0, 0, 0, 0); + if (this->actor.child != NULL) { + this->actor.child->csId = this->actor.csId; + EnSlime_SetupIceBlock(this); + } else { + this->actor.colorFilterTimer = 0; + this->collider.base.acFlags |= AC_ON; + this->iceBlockTimer = ICE_BLOCK_UNUSED; + this->actor.flags |= ACTOR_FLAG_1; + this->actor.gravity = -2.0f; + EnSlime_SetupIdle(this); + } + } +} + +void EnSlime_SetupIceBlock(EnSlime* this) { + this->actor.flags |= ACTOR_FLAG_10; + this->actionFunc = EnSlime_IceBlock; +} + +/** + * Decrement the ice block timer, or if it has hit zero, + * check to see if the ice block child actor link has been broken + * or if the block has shrunk sufficiently. + * If timer is up and ice block is sufficiently "gone", init thaw. + */ +void EnSlime_IceBlock(EnSlime* this, PlayState* play) { + if (this->iceBlockTimer == 0) { + if ((this->actor.child == NULL) || (this->actor.child->update == NULL) || + !(this->actor.child->scale.y >= 0.1f)) { + EnSlime_SetupIceBlockThaw(this); + } + } else { + this->actor.colorFilterTimer = 10; + if ((this->iceBlockTimer - 5) < 0) { + this->iceBlockTimer = 0; + } else { + this->iceBlockTimer -= 5; + } + } +} + +void EnSlime_SetupStun(EnSlime* this) { + this->actor.speed = 0.0f; + func_800BE504(&this->actor, &this->collider); + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + this->actionFunc = EnSlime_Stun; +} + +/** + * Check the actor's timer to see whether stun has worn off. + * If so, either react to damage and initialize death, or start + * idly wobbling in a new direction. + */ +void EnSlime_Stun(EnSlime* this, PlayState* play) { + this->timer--; + if (this->timer == 0) { + EnSlime_Thaw(this, play); + if (this->actor.colChkInfo.health == 0) { + EnSlime_SetupDamaged(this, play, false); + } else { + this->actor.world.rot.y = this->actor.shape.rot.y; + EnSlime_SetupMoveInDirection(this); + } + } +} + +void EnSlime_SetupIceBlockThaw(EnSlime* this) { + this->actor.colorFilterTimer = 0; + this->actor.gravity = -2.0f; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_GRAY, COLORFILTER_INTENSITY_FLAG | 255, + COLORFILTER_BUFFLAG_XLU, 10); + this->actionFunc = EnSlime_IceBlockThaw; +} + +/** + * Update the actor's ice block timer to match state of ice block. + * When it reaches the "unset" value (255), return actor to idle. + */ +void EnSlime_IceBlockThaw(EnSlime* this, PlayState* play) { + s32 iceBlockTimerAdj; + + this->actor.colorFilterTimer = 10; + if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { + iceBlockTimerAdj = (0.1f - this->actor.child->scale.y) * 10.0f * 255.0f; + this->iceBlockTimer = CLAMP(iceBlockTimerAdj, 0, ICE_BLOCK_UNUSED); + } else { + this->actor.child = NULL; + iceBlockTimerAdj = this->iceBlockTimer + 10; + this->iceBlockTimer = CLAMP_MAX(iceBlockTimerAdj, ICE_BLOCK_UNUSED); + } + + if (this->iceBlockTimer == ICE_BLOCK_UNUSED) { + this->collider.base.acFlags |= AC_ON; + this->actor.flags |= ACTOR_FLAG_1; + this->actor.flags &= ~ACTOR_FLAG_10; + EnSlime_SetupIdle(this); + } +} + +/** + * Set speed to zero, and make undrawable. + * Initialize revive timer. + */ +void EnSlime_SetupWaitForRevive(EnSlime* this) { + this->actor.draw = NULL; + this->actor.flags |= ACTOR_FLAG_10; + this->drawDmgEffAlpha = 0.0f; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.speed = 0.0f; + this->collider.base.ocFlags1 &= ~OC1_ON; + this->timer = this->reviveTime; + this->actionFunc = EnSlime_WaitForRevive; +} + +/** + * Decrement the revival timer, or if it is zero, + * initialize revive. + */ +void EnSlime_WaitForRevive(EnSlime* this, PlayState* play) { + if (this->timer == 0) { + EnSlime_SetupRevive(this); + } else { + this->timer--; + } +} + +/** + * Re-enable drawing, reset the actor's health and home, + * and setup and initialize revive action. + */ +void EnSlime_SetupRevive(EnSlime* this) { + this->actor.draw = EnSlime_Draw; + this->actor.colChkInfo.health = sColChkInfoInit.health; + this->iceBlockTimer = ICE_BLOCK_UNUSED; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->timer = 0; + this->actor.colorFilterTimer = 0; + this->actor.home.rot.y = this->actor.yawTowardsPlayer; + Actor_PlaySfx(&this->actor, NA_SE_EN_SLIME_SURFACE); + this->actor.gravity = -2.0f; + this->actionFunc = EnSlime_Revive; +} + +/** + * Update bubbling back up effect. After 21 frames, OC1_ON is set. + * After 28 frames, AC_ON is set and actor returns to idle movement. + */ +void EnSlime_Revive(EnSlime* this, PlayState* play) { + f32 rescaleFactor1; + f32 rescaleFactor2; + + this->timer++; + if (this->timer == 28) { + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_1; + this->collider.base.acFlags |= AC_ON; + this->actor.shape.rot.y = this->actor.home.rot.y; + EnSlime_SetupMoveInDirection(this); + } else { + if (this->timer < 12) { + rescaleFactor1 = this->timer * 0.0008333333f; // This is about 1/1200, but (1.0f/1200.0f) does not match + this->reviveScale.x = rescaleFactor1; + this->reviveScale.z = rescaleFactor1; + this->reviveScale.y = 2.0f * rescaleFactor1; + this->reviveRotY = this->timer * (0x4000 / 10.0f); + } else if (this->timer < 20) { + rescaleFactor1 = (this->timer - 12) * (1.0f / 1600.0f); + rescaleFactor2 = 0.01f + rescaleFactor1; + this->reviveScale.x = rescaleFactor2; + this->reviveScale.z = rescaleFactor2; + this->reviveScale.y = 2.0f * (0.01f - rescaleFactor1); + this->reviveRotY = this->timer * (0x4000 / 10.0f); + } else if (this->timer < 24) { + rescaleFactor1 = (this->timer - 20) * 0.0033333332f; // This is about 1/300 + rescaleFactor2 = 0.015f - rescaleFactor1; + this->reviveScale.x = rescaleFactor2; + this->reviveScale.z = rescaleFactor2; + this->reviveScale.y = (2.0f * rescaleFactor1) + 0.01f; + Actor_SetScale(&this->actor, 1.5f * rescaleFactor1); + this->reviveRotY = ((23 - this->timer) * 7281.778f) + 10922.667f; + this->actor.shape.rot.y = (28 - this->timer) * (f32)0x1000; + } else { + Actor_SetScale(&this->actor, (((28 - this->timer) * 0.1f) + 1.0f) * 0.01f); + Math_Vec3f_Copy(&this->reviveScale, &gZeroVec3f); + this->actor.shape.rot.y = (28 - this->timer) * (f32)0x1000; + } + + if (this->timer == 21) { + this->collider.base.ocFlags1 |= OC1_ON; + } + + this->reviveRotY += this->actor.home.rot.y; + this->actor.shape.rot.y += this->actor.home.rot.y; + } +} + +/** + * Check actor AC hit since last update. If hit, initialize appropriate action cycle. + */ +void EnSlime_UpdateDamage(EnSlime* this, PlayState* play) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + + EnSlime_Thaw(this, play); + if ((this->actor.params == EN_SLIME_TYPE_BLUE) && + (this->actor.colChkInfo.damageEffect == EN_SLIME_DMGEFF_FREEZE)) { + // Blue chuchus take no damage from ice arrows. + this->actor.colChkInfo.damage = 0; + } + + if (Actor_ApplyDamage(&this->actor) == 0) { + Actor_SetDropFlag(&this->actor, &this->collider.info); + Enemy_StartFinishingBlow(play, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_1; + } + + if (this->actor.colChkInfo.damageEffect == EN_SLIME_DMGEFF_BLUNT) { + EnSlime_SetupReactToBluntHit(this); + } else if (this->actor.colChkInfo.damageEffect == EN_SLIME_DMGEFF_STUN) { + this->timer = 40; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_XLU, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); + EnSlime_SetupStun(this); + } else if (this->actor.colChkInfo.damageEffect != EN_SLIME_DMGEFF_HOOKSHOT) { + if (this->actor.colChkInfo.damageEffect == EN_SLIME_DMGEFF_FREEZE) { + if (this->actor.params == EN_SLIME_TYPE_BLUE) { + EnSlime_SetupSpawnIceBlock(this); + } else { + EnSlime_Freeze(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->collider.base.acFlags &= ~AC_ON; + } + EnSlime_SetupStun(this); + } + } else { + if (this->actor.colChkInfo.damageEffect == EN_SLIME_DMGEFF_LIGHT) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&play->actorCtx, play, 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); + } else if (this->actor.colChkInfo.damageEffect == EN_SLIME_DMGEFF_ELECTRIC) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.4f; + } + EnSlime_SetupDamaged(this, play, true); + } + } + } + } +} + +void EnSlime_Update(Actor* thisx, PlayState* play) { + EnSlime* this = THIS; + s32 pad; + Player* player = GET_PLAYER(play); + + EnSlime_UpdateDamage(this, play); + this->actionFunc(this, play); + + // Note: Does not match if you use this->actor instead of thisx + thisx->shape.shadowAlpha = this->iceBlockTimer; + if (this->iceBlockTimer == ICE_BLOCK_UNUSED) { + if (thisx->scale.y > 0.0001f) { + thisx->targetArrowOffset = 60.0f / thisx->scale.y; + } + + if (this->collider.base.ocFlags1 & OC1_ON) { + Actor_MoveWithGravity(thisx); + Actor_UpdateBgCheckInfo(play, thisx, 20.0f, 35.0f, 40.0f, 0x1D); + } + + Collider_UpdateCylinder(thisx, &this->collider); + this->collider.dim.radius = sCylinderInit.dim.radius * (100.0f * thisx->scale.z); + this->collider.dim.height = sCylinderInit.dim.height * (100.0f * thisx->scale.y); + + if (this->actionFunc == EnSlime_Jump) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + } + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } + + if (player->stateFlags3 & PLAYER_STATE3_100) { + this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; + } else { + this->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; + } + + if (this->collider.base.ocFlags1 & OC1_ON) { + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } + + Actor_SetFocus(thisx, 15.0f); + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.2f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.4f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.4f, 0.01f)) { + func_800B9010(thisx, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +void EnSlime_Draw(Actor* thisx, PlayState* play) { + s32 i; + EnSlime* this = THIS; + Vec3f wobbleScale; + Color_RGBA8* primColor; + Color_RGBA8* envColor; + s32 pad; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + func_800B8118(&this->actor, play, 0); + if (this->iceBlockTimer != ICE_BLOCK_UNUSED) { + gSPSegment(POLY_XLU_DISP++, 10, D_801AEFA0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 170, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 150, 255, 255, this->iceBlockTimer); + } else { + primColor = &sPrimColors[this->actor.params]; + envColor = &sEnvColors[this->actor.params]; + AnimatedMat_Draw(play, sSlimeTexAnim); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 100, primColor->r, primColor->g, primColor->b, primColor->a); + gDPSetEnvColor(POLY_XLU_DISP++, envColor->r, envColor->g, envColor->b, 255); + } + + if (this->actionFunc == EnSlime_Damaged) { + wobbleScale.x = 1.0f - (sin_rad((f32)this->timer * (M_PI / 2.0f)) * 0.3f); + wobbleScale.y = (sin_rad((f32)this->timer * (M_PI / 2.0f)) * 0.3f) + 1.0f; + wobbleScale.z = 1.0f - (cos_rad((f32)this->timer * (M_PI / 2.0f)) * 0.3f); + + Matrix_RotateXFApply(this->wobbleRot.x); + Matrix_RotateZF(this->wobbleRot.z, MTXMODE_APPLY); + Matrix_Scale(wobbleScale.x, wobbleScale.y, wobbleScale.z, MTXMODE_APPLY); + Matrix_RotateZF(-this->wobbleRot.z, MTXMODE_APPLY); + Matrix_RotateXFApply(-this->wobbleRot.x); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gChuchuBodyDL); + + if (this->iceBlockTimer == ICE_BLOCK_UNUSED) { + // Ice block is not active + Scene_SetRenderModeXlu(play, 0, 1); + + gSPSegment(POLY_OPA_DISP++, 9, (u32)sEyeTextures[this->eyeTexIndex]); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 30, 70, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gChuchuEyesDL); + + } else { + Scene_SetRenderModeXlu(play, 1, 2); + gSPSegment(POLY_XLU_DISP++, 9, (u32)sEyeTextures[this->eyeTexIndex]); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gChuchuEyesDL); + } + + for (i = 0; i < EN_SLIME_LIMBPOS_COUNT; i++) { + Matrix_MultVec3f(&sLimbPosOffsets[i], &this->limbPos[i]); + } + + if (this->actionFunc == EnSlime_Revive) { + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->reviveRotY, MTXMODE_APPLY); + Matrix_Scale(this->reviveScale.x, this->reviveScale.y, this->reviveScale.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gChuchuPuddleDL); + } + + if ((this->actor.params != EN_SLIME_TYPE_BLUE) && (this->actor.scale.x > 0.0f)) { + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + (2000.0f * this->actor.scale.y), + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale(0.03f, 0.03f, 0.03f, MTXMODE_APPLY); + + gSPSegment(POLY_OPA_DISP++, 8, (u32)this->itemDropTex); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); + } + + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Slime/z_en_slime.h b/src/overlays/actors/ovl_En_Slime/z_en_slime.h index 0381a592a..0a40a117e 100644 --- a/src/overlays/actors/ovl_En_Slime/z_en_slime.h +++ b/src/overlays/actors/ovl_En_Slime/z_en_slime.h @@ -2,6 +2,13 @@ #define Z_EN_SLIME_H #include "global.h" +#include "objects/object_slime/object_slime.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define EN_SLIME_LIMBPOS_COUNT 5 + +#define EN_SLIME_GET_TYPE(thisx) ((thisx)->params) +#define EN_SLIME_GET_REVIVE_TIME(thisx) ((((thisx)->params) >> 8) & 0xFF) struct EnSlime; @@ -10,7 +17,32 @@ typedef void (*EnSlimeActionFunc)(struct EnSlime*, PlayState*); typedef struct EnSlime { /* 0x000 */ Actor actor; /* 0x144 */ EnSlimeActionFunc actionFunc; - /* 0x148 */ char unk_148[0xC0]; + /* 0x148 */ u8 iceBlockTimer; + /* 0x149 */ u8 eyeTexIndex; + /* 0x14A */ u8 drawDmgEffType; + /* 0x14C */ s16 timer; + /* 0x14E */ s16 idleRotY; + /* 0x150 */ s16 reviveRotY; + /* 0x152 */ s16 reviveTime; + /* 0x154 */ union { + Vec3f iceBlockSnapPos; + Vec3f wobbleRot; + }; + /* 0x160 */ TexturePtr itemDropTex; + /* 0x164 */ f32 drawDmgEffAlpha; + /* 0x168 */ f32 drawDmgEffScale; + /* 0x16C */ f32 drawDmgEffFrozenSteamScale; + /* 0x170 */ f32 distLimit; + /* 0x174 */ Vec3f reviveScale; + /* 0x180 */ Vec3f limbPos[EN_SLIME_LIMBPOS_COUNT]; + /* 0x1BC */ ColliderCylinder collider; } EnSlime; // size = 0x208 +typedef enum EnSlimeType { + /* 0 */ EN_SLIME_TYPE_BLUE, + /* 1 */ EN_SLIME_TYPE_GREEN, + /* 2 */ EN_SLIME_TYPE_YELLOW, + /* 3 */ EN_SLIME_TYPE_RED, +} EnSlimeType; + #endif // Z_EN_SLIME_H diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c index 994115f89..baf3ccdfa 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -208,7 +208,7 @@ void EnSnowman_Init(Actor* thisx, PlayState* play) { thisx->world.pos.z, 0, 0, 0, EN_SNOWMAN_TYPE_SPLIT); thisx->parent = Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_SNOWMAN, thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 0, 0, 0, - EN_SNOWMAN_TYPE_SPLIT, -1, thisx->unk20, NULL); + EN_SNOWMAN_TYPE_SPLIT, CS_ID_NONE, thisx->halfDaysBits, NULL); if ((thisx->child == NULL) || (thisx->parent == NULL)) { if (thisx->child != NULL) { Actor_Kill(thisx->child); @@ -242,19 +242,19 @@ void EnSnowman_Init(Actor* thisx, PlayState* play) { thisx->flags &= ~ACTOR_FLAG_1; Collider_InitAndSetCylinder(play, &this->collider, thisx, &sSnowballCylinderInit); - thisx->world.rot.y = Actor_YawBetweenActors(thisx, &player->actor); - thisx->velocity.y = (Actor_XZDistanceBetweenActors(thisx, &player->actor) * 0.035f) + -5.0f; + thisx->world.rot.y = Actor_WorldYawTowardActor(thisx, &player->actor); + thisx->velocity.y = (Actor_WorldDistXZToActor(thisx, &player->actor) * 0.035f) + -5.0f; thisx->velocity.y = CLAMP_MAX(thisx->velocity.y, 3.5f); if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { - thisx->speedXZ = 15.0f; + thisx->speed = 15.0f; } else { - thisx->speedXZ = 22.5f; + thisx->speed = 22.5f; thisx->velocity.y *= 1.5f; } - thisx->world.pos.x += thisx->speedXZ * Math_SinS(thisx->world.rot.y); + thisx->world.pos.x += thisx->speed * Math_SinS(thisx->world.rot.y); thisx->world.pos.y += thisx->velocity.y; - thisx->world.pos.z += thisx->speedXZ * Math_CosS(thisx->world.rot.y); + thisx->world.pos.z += thisx->speed * Math_CosS(thisx->world.rot.y); if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { this->collider.dim.radius = 8; @@ -338,7 +338,7 @@ void EnSnowman_SpawnBigSnowballFragmentEffects(EnSnowman* this, PlayState* play) void EnSnowman_SetupMoveSnowPile(EnSnowman* this) { Animation_PlayLoop(&this->snowPileSkelAnime, &gEenoSnowPileMoveAnim); this->actor.scale.y = this->actor.scale.x; - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; this->actor.draw = EnSnowman_DrawSnowPile; this->work.timer = 40; this->turningOnSteepSlope = false; @@ -403,10 +403,11 @@ void EnSnowman_MoveSnowPile(EnSnowman* this, PlayState* play) { } this->actor.world.rot.y = this->actor.shape.rot.y; - } else if (this->actor.bgCheckFlags & 8) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->snowPileTargetRotY = this->actor.wallYaw; - } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 200.0f) { - this->snowPileTargetRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + ((s32)Rand_Next() >> 0x14); + } else if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 200.0f) { + this->snowPileTargetRotY = + Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos) + ((s32)Rand_Next() >> 0x14); } else if (Rand_ZeroOne() < 0.02f) { this->snowPileTargetRotY += (s16)(((Rand_Next() >> 0x13) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); } @@ -414,12 +415,12 @@ void EnSnowman_MoveSnowPile(EnSnowman* this, PlayState* play) { void EnSnowman_SetupEmerge(EnSnowman* this, PlayState* play) { Animation_PlayOnce(&this->skelAnime, &gEenoEmergeAnim); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_SURFACE); + Actor_PlaySfx(&this->actor, NA_SE_EN_YMAJIN_SURFACE); this->collider.dim.radius = this->eenoScale * 40.0f; this->collider.dim.height = this->eenoScale * 25.0f; this->actor.draw = EnSnowman_Draw; this->actor.scale.y = this->actor.scale.x * 0.4f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; EnSnowman_SpawnCircularDustEffect(this, play); this->collider.base.acFlags &= ~AC_ON; @@ -494,9 +495,9 @@ void EnSnowman_ReadySnowball(EnSnowman* this, PlayState* play) { EnSnowman_SetupThrowSnowball(this); } else if (Animation_OnFrame(&this->skelAnime, this->fwork.frameToStartHoldingSnowball)) { if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_HOLD_SNOW); + Actor_PlaySfx(&this->actor, NA_SE_EN_YMAJIN_HOLD_SNOW); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_HOLD); + Actor_PlaySfx(&this->actor, NA_SE_EN_YMAJIN_MINI_HOLD); } this->isHoldingSnowball = true; @@ -539,10 +540,10 @@ void EnSnowman_ThrowSnowball(EnSnowman* this, PlayState* play) { this->isHoldingSnowball = false; if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { params = EN_SNOWMAN_TYPE_LARGE_SNOWBALL; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_THROW); + Actor_PlaySfx(&this->actor, NA_SE_EN_YMAJIN_THROW); } else { params = EN_SNOWMAN_TYPE_SMALL_SNOWBALL; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_THROW); + Actor_PlaySfx(&this->actor, NA_SE_EN_YMAJIN_MINI_THROW); } Actor_Spawn(&play->actorCtx, play, ACTOR_EN_SNOWMAN, this->snowballPos.x, this->snowballPos.y, @@ -572,7 +573,7 @@ void EnSnowman_SetupSubmerge(EnSnowman* this, PlayState* play) { Animation_Change(&this->skelAnime, &gEenoEmergeAnim, -1.0f, Animation_GetLastFrame(&gEenoEmergeAnim), 0.0f, ANIMMODE_ONCE, -3.0f); EnSnowman_SpawnCircularDustEffect(this, play); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_HIDE); + Actor_PlaySfx(&this->actor, NA_SE_EN_YMAJIN_HIDE); this->actionFunc = EnSnowman_Submerge; } @@ -598,13 +599,13 @@ void EnSnowman_Submerge(EnSnowman* this, PlayState* play) { } void EnSnowman_SetupMelt(EnSnowman* this) { - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 50); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 50); this->collider.base.acFlags &= ~AC_ON; this->work.timer = 50; this->actor.flags &= ~ACTOR_FLAG_1; this->actor.flags |= ACTOR_FLAG_10; this->actor.scale.y = this->actor.scale.x; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnSnowman_Melt; } @@ -667,18 +668,18 @@ void EnSnowman_Stun(EnSnowman* this, PlayState* play) { void EnSnowman_SetupDamaged(EnSnowman* this) { Animation_PlayLoop(&this->skelAnime, &gEenoDamageAnim); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 20); this->collider.base.acFlags &= ~AC_ON; this->work.timer = 20; this->actor.draw = EnSnowman_Draw; this->actor.scale.y = this->actor.scale.x; - this->actor.speedXZ = 10.0f; + this->actor.speed = 10.0f; func_800BE504(&this->actor, &this->collider); if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_YMAJIN_DAMAGE); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_YMAJIN_MINI_DAMAGE); } this->actionFunc = EnSnowman_Damaged; @@ -695,7 +696,7 @@ void EnSnowman_Damaged(EnSnowman* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); rotationalVelocityScale = CLAMP_MAX(this->work.timer, 10); this->actor.shape.rot.y += rotationalVelocityScale * 0x300; - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { Math_StepToF(&this->actor.scale.y, 1.3f * 0.01f, 0.7f * 0.001f); @@ -706,7 +707,7 @@ void EnSnowman_Damaged(EnSnowman* this, PlayState* play) { if (this->work.timer > 0) { this->work.timer--; } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_SPLIT); + Actor_PlaySfx(&this->actor, NA_SE_EN_YMAJIN_SPLIT); EnSnowman_SpawnCircularDustEffect(this, play); this->drawDmgEffAlpha = 0.0f; EnSnowman_CreateSplitEeno((EnSnowman*)this->actor.parent, &this->actor.world.pos, @@ -844,7 +845,7 @@ void EnSnowman_CreateSplitEeno(EnSnowman* this, Vec3f* basePos, s32 yRot) { * target scale increases. */ void EnSnowman_AbsorbEeno(EnSnowman* smallerEeno, EnSnowman* largerEeno) { - Actor_PlaySfxAtPos(&largerEeno->actor, NA_SE_EN_YMAJIN_UNITE); + Actor_PlaySfx(&largerEeno->actor, NA_SE_EN_YMAJIN_UNITE); largerEeno->fwork.targetScaleDuringCombine += 0.005f; smallerEeno->combineState = EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE; smallerEeno->collider.base.ocFlags1 &= ~OC1_HIT; @@ -877,11 +878,11 @@ void EnSnowman_SetupCombine(EnSnowman* this, PlayState* play, Vec3f* combinePos) //! @bug: If an Eeno is in the middle of submerging, its draw function will still be EnSnowman_Draw. //! It will call EnSnowman_SetupSubmerge again, resulting in the submerge animation playing twice. if (this->actor.draw == EnSnowman_DrawSnowPile) { - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; this->actionFunc = EnSnowman_Combine; } else { this->isHoldingSnowball = false; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; // At this point, the combineState is EN_SNOWMAN_COMBINE_STATE_ACTIVE, and the actionFunc // will be set to EnSnowman_Submerge. When the submerging animation is complete with this @@ -902,7 +903,7 @@ void EnSnowman_Combine(EnSnowman* this, PlayState* play) { SkelAnime_Update(&this->snowPileSkelAnime); parent = (EnSnowman*)this->actor.parent; child = (EnSnowman*)this->actor.child; - Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->combinePos), 0x1000); + Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->combinePos), 0x1000); this->actor.world.rot.y = this->actor.shape.rot.y; if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { @@ -940,8 +941,8 @@ void EnSnowman_Combine(EnSnowman* this, PlayState* play) { this->fwork.targetScaleDuringCombine = 0.0f; } - if (Actor_XZDistanceToPoint(&this->actor, &this->combinePos) < 20.0f) { - this->actor.speedXZ = 0.0f; + if (Actor_WorldDistXZToPoint(&this->actor, &this->combinePos) < 20.0f) { + this->actor.speed = 0.0f; } if (Math_StepToF(&this->actor.scale.x, this->fwork.targetScaleDuringCombine, 0.0005f)) { @@ -976,15 +977,15 @@ void EnSnowman_UpdateDamage(EnSnowman* this, PlayState* play) { if ((this->actionFunc == EnSnowman_MoveSnowPile) || (this->actionFunc == EnSnowman_Combine)) { EnSnowman_SetupEmerge(this, play); } else if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_STUN) { - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); EnSnowman_SetupStun(this); } else if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_ELECTRIC_STUN) { - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); this->drawDmgEffScale = 0.55f; this->drawDmgEffAlpha = 2.0f; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); EnSnowman_SetupStun(this); } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { if (this->isHoldingSnowball == true) { @@ -1036,7 +1037,9 @@ void EnSnowman_Update(Actor* thisx, PlayState* play) { wallCheckRadius = this->collider.dim.radius; } - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, wallCheckRadius, 0.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, wallCheckRadius, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); if ((this->actor.floorPoly != NULL) && ((this->actor.floorPoly->normal.y * SHT_MINV) < 0.7f)) { Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); if (!this->turningOnSteepSlope) { @@ -1080,9 +1083,9 @@ void EnSnowman_UpdateSnowball(Actor* thisx, PlayState* play) { this->collider.base.ocFlags1 |= OC1_ON; } - if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1) || (this->actor.bgCheckFlags & 0x10) || - (this->collider.base.atFlags & AT_HIT) || (this->collider.base.acFlags & AC_HIT) || - (this->collider.base.ocFlags1 & OC1_HIT)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || + (this->actor.bgCheckFlags & BGCHECKFLAG_CEILING) || (this->collider.base.atFlags & AT_HIT) || + (this->collider.base.acFlags & AC_HIT) || (this->collider.base.ocFlags1 & OC1_HIT)) { if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { scale = 10; for (i = 0; i < 3; i++) { @@ -1110,7 +1113,9 @@ void EnSnowman_UpdateSnowball(Actor* thisx, PlayState* play) { this->actor.shape.rot.x += 0xF00; Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, this->collider.dim.radius * 0.6f, - this->collider.dim.height - this->collider.dim.yShift, 0x1F); + this->collider.dim.height - this->collider.dim.yShift, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); 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 035bc2bfa..a23600fb9 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -406,7 +406,7 @@ void EnSob1_Init(Actor* thisx, PlayState* play) { this->shopType = ZORA_SHOP; break; case GORON_SHOP: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE)) { this->shopType = GORON_SHOP_SPRING; } else { this->shopType = GORON_SHOP; @@ -456,7 +456,7 @@ void EnSob1_EndInteraction(PlayState* play, EnSob1* this) { Player* player = GET_PLAYER(play); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; } Actor_ProcessTalkRequest(&this->actor, &play->state); @@ -487,7 +487,7 @@ s32 EnSob1_TestEndInteraction(EnSob1* this, PlayState* play, Input* input) { s32 EnSob1_TestCancelOption(EnSob1* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); return true; } return false; @@ -504,7 +504,7 @@ void EnSob1_SetupStartShopping(PlayState* play, EnSob1* this, u8 skipHello) { void EnSob1_StartShopping(PlayState* play, EnSob1* this) { EnSob1_SetupAction(this, EnSob1_FaceShopkeeper); - func_80151938(play, sFacingShopkeeperTextIds[this->shopType]); + Message_ContinueTextbox(play, sFacingShopkeeperTextIds[this->shopType]); func_8011552C(play, DO_ACTION_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; @@ -513,7 +513,7 @@ void EnSob1_StartShopping(PlayState* play, EnSob1* this) { void EnSob1_TalkToShopkeeper(PlayState* play, EnSob1* this) { EnSob1_SetupAction(this, EnSob1_TalkingToShopkeeper); this->talkOptionTextId = EnSob1_GetTalkOption(this, play); - func_80151938(play, this->talkOptionTextId); + Message_ContinueTextbox(play, this->talkOptionTextId); func_8011552C(play, DO_ACTION_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -546,11 +546,11 @@ void EnSob1_Idle(EnSob1* this, PlayState* play) { this->headRotTarget = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookFowardCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookFowardCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENSOB1_CUTSCENESTATE_WAITING; } player->stateFlags2 |= PLAYER_STATE2_20000000; @@ -623,11 +623,11 @@ void EnSob1_Hello(EnSob1* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENSOB1_CUTSCENESTATE_PLAYING; } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play) && @@ -664,19 +664,19 @@ void EnSob1_FaceShopkeeper(EnSob1* this, PlayState* play) { u8 cursorIndex; if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENSOB1_CUTSCENESTATE_PLAYING; } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookFowardCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookFowardCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENSOB1_CUTSCENESTATE_WAITING; } else { if (talkState == TEXT_STATE_CHOICE) { @@ -707,23 +707,23 @@ void EnSob1_TalkingToShopkeeper(EnSob1* this, PlayState* play) { void EnSob1_LookToShopkeeperFromShelf(EnSob1* this, PlayState* play) { if (this->cutsceneState == ENSOB1_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; } if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENSOB1_CUTSCENESTATE_WAITING; } else if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENSOB1_CUTSCENESTATE_PLAYING; EnSob1_StartShopping(play, this); } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } } @@ -738,9 +738,9 @@ void EnSob1_EndWalk(EnSob1* this, PlayState* play) { EnSob1_GetDistSqAndOrient(this->path, this->waypoint - 1, &this->actor.world.pos, &distSq), 4, 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; - Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 0.5f, 0.2f, 1.0f); if (distSq < 12.0f) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (animLastFrame == curFrame) { EnSob1_ChangeAnim(&this->skelAnime, sAnimationInfoBombShopkeeper, BOMB_SHOPKEEPER_ANIM_SIT_AT_COUNTER_START); @@ -765,11 +765,11 @@ void EnSob1_Walk(EnSob1* this, PlayState* play) { f32 distSq; if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENSOB1_CUTSCENESTATE_PLAYING; } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } if (this->path != NULL) { @@ -777,11 +777,11 @@ void EnSob1_Walk(EnSob1* this, PlayState* play) { EnSob1_GetDistSqAndOrient(this->path, this->waypoint, &this->actor.world.pos, &distSq), 4, 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.speedXZ = 2.0f; + this->actor.speed = 2.0f; if (distSq < SQ(5.0f)) { this->waypoint++; if ((this->path->count - 1) < this->waypoint) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; EnSob1_SetupAction(this, EnSob1_EndWalk); } } @@ -794,20 +794,20 @@ void EnSob1_Walking(EnSob1* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENSOB1_CUTSCENESTATE_PLAYING; } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookFowardCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookFowardCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENSOB1_CUTSCENESTATE_WAITING; } player->stateFlags2 |= PLAYER_STATE2_20000000; @@ -828,21 +828,21 @@ void EnSob1_ItemPurchased(EnSob1* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); player->stateFlags2 |= PLAYER_STATE2_20000000; EnSob1_SetupAction(this, EnSob1_ContinueShopping); this->cutsceneState = ENSOB1_CUTSCENESTATE_PLAYING; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperCsId; + CutsceneManager_Queue(this->csId); } } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - func_80151938(play, 0x647); + Message_ContinueTextbox(play, 0x647); } else { func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); } @@ -850,25 +850,25 @@ void EnSob1_ItemPurchased(EnSob1* this, PlayState* play) { void EnSob1_LookToShelf(EnSob1* this, PlayState* play) { if (this->cutsceneState == ENSOB1_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; } if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShelfCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShelfCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENSOB1_CUTSCENESTATE_WAITING; } else if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene) != 0) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENSOB1_CUTSCENESTATE_PLAYING; EnSob1_UpdateCursorPos(play, this); EnSob1_SetupAction(this, EnSob1_BrowseShelf); - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } } @@ -904,7 +904,7 @@ s32 EnSob1_HasPlayerSelectedItem(PlayState* play, EnSob1* this, Input* input) { if (EnSob1_TestItemSelected(play)) { if (!item->isOutOfStock) { this->prevActionFunc = this->actionFunc; - func_80151938(play, this->items[this->cursorIndex]->choiceTextId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->choiceTextId); play_sound(NA_SE_SY_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -938,7 +938,7 @@ void EnSob1_BrowseShelf(EnSob1* this, PlayState* play) { EnSob1_CursorLeftRight(play, this); cursorIndex = this->cursorIndex; if (cursorIndex != prevCursorIndex) { - func_80151938(play, this->items[cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[cursorIndex]->actor.textId); play_sound(NA_SE_SY_CURSOR); } } @@ -949,7 +949,7 @@ void EnSob1_BrowseShelf(EnSob1* this, PlayState* play) { void EnSob1_SetupBuyItemWithFanfare(PlayState* play, EnSob1* this) { Player* player = GET_PLAYER(play); - Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~PLAYER_STATE2_20000000; @@ -959,12 +959,12 @@ void EnSob1_SetupBuyItemWithFanfare(PlayState* play, EnSob1* this) { } void EnSob1_SetupCannotBuy(PlayState* play, EnSob1* this, u16 textId) { - func_80151938(play, textId); + Message_ContinueTextbox(play, textId); EnSob1_SetupAction(this, EnSob1_CannotBuy); } void EnSob1_SetupCanBuy(PlayState* play, EnSob1* this, u16 textId) { - func_80151938(play, textId); + Message_ContinueTextbox(play, textId); EnSob1_SetupAction(this, EnSob1_CanBuy); } @@ -975,7 +975,7 @@ void EnSob1_HandleCanBuyItem(PlayState* play, EnSob1* this) { switch (item->canBuyFunc(play, item)) { case CANBUY_RESULT_SUCCESS_1: if (this->cutsceneState == ENSOB1_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; } func_8019F208(); @@ -1050,7 +1050,7 @@ void EnSob1_SelectItem(EnSob1* this, PlayState* play) { case 1: func_8019F230(); this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); break; } } @@ -1061,7 +1061,7 @@ void EnSob1_CannotBuy(EnSob1* this, PlayState* play) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); } } } @@ -1075,7 +1075,7 @@ void EnSob1_CanBuy(EnSob1* this, PlayState* play) { item = this->items[this->cursorIndex]; item->restockFunc(play, item); this->actionFunc = this->prevActionFunc; - func_80151938(play, this->items[this->cursorIndex]->actor.textId); + Message_ContinueTextbox(play, this->items[this->cursorIndex]->actor.textId); } } @@ -1084,7 +1084,7 @@ void EnSob1_BuyItemWithFanfare(EnSob1* this, PlayState* play) { this->actor.parent = NULL; EnSob1_SetupAction(this, EnSob1_SetupItemPurchased); } else { - Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); } } @@ -1094,11 +1094,11 @@ void EnSob1_SetupItemPurchased(EnSob1* this, PlayState* play) { play->msgCtx.stateTimer = 4; EnSob1_SetupAction(this, EnSob1_ItemPurchased); if (this->cutsceneState == ENSOB1_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperCsId; + CutsceneManager_Queue(this->csId); } func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); } @@ -1286,13 +1286,13 @@ s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIndex, Vec3f* pos, f32* distS diffZ = 0.0f; } *distSq = SQ(diffX) + SQ(diffZ); - return RADF_TO_BINANG(Math_Atan2F_XY(diffZ, diffX)); + return RAD_TO_BINANG(Math_Atan2F_XY(diffZ, diffX)); } void EnSob1_GetCutscenes(EnSob1* this) { - this->lookFowardCutscene = this->actor.cutscene; - this->lookToShelfCutscene = ActorCutscene_GetAdditionalCutscene(this->lookFowardCutscene); - this->lookToShopkeeperCutscene = ActorCutscene_GetAdditionalCutscene(this->lookToShelfCutscene); + this->lookFowardCsId = this->actor.csId; + this->lookToShelfCsId = CutsceneManager_GetAdditionalCsId(this->lookFowardCsId); + this->lookToShopkeeperCsId = CutsceneManager_GetAdditionalCsId(this->lookToShelfCsId); } void EnSob1_WaitForBlink(EnSob1* this) { @@ -1387,7 +1387,7 @@ void EnSob1_InitShop(EnSob1* this, PlayState* play) { this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; EnSob1_GetCutscenes(this); - this->cutscene = this->lookFowardCutscene; + this->csId = this->lookFowardCsId; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); sInitFuncs[this->shopType](this, play); this->actor.colChkInfo.mass = MASS_IMMOVABLE; diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h index eee86c112..1509868ee 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h @@ -60,10 +60,10 @@ typedef struct EnSob1 { /* 0x39C */ u8 arrowAnimState; /* 0x39D */ u8 stickAnimState; /* 0x39E */ s16 cutsceneState; - /* 0x3A0 */ s16 cutscene; - /* 0x3A2 */ s16 lookFowardCutscene; - /* 0x3A4 */ s16 lookToShelfCutscene; - /* 0x3A6 */ s16 lookToShopkeeperCutscene; + /* 0x3A0 */ s16 csId; + /* 0x3A2 */ s16 lookFowardCsId; + /* 0x3A4 */ s16 lookToShelfCsId; + /* 0x3A6 */ s16 lookToShopkeeperCsId; /* 0x3A8 */ UNK_TYPE1 pad3A8[0x4]; /* 0x3AC */ f32 shopItemSelectedTween; /* 0x3B0 */ UNK_TYPE1 pad3B0[0x4]; 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 7494695fa..60846fda8 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -228,7 +228,7 @@ void EnSsh_SetWaitAnimation(EnSsh* this) { } void EnSsh_SetReturnAnimation(EnSsh* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALTU_UP); EnSsh_ChangeAnim(this, SSH_ANIM_UP); } @@ -282,7 +282,7 @@ void EnSsh_SetColliderScale(EnSsh* this, f32 arg1, f32 arg2) { s32 EnSsh_Damaged(EnSsh* this) { if ((this->stunTimer == 120) && (this->stateFlags & SSH_STATE_STUNNED)) { - Actor_SetColorFilter(&this->actor, 0, 200, 0, this->stunTimer); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 200, COLORFILTER_BUFFLAG_OPA, this->stunTimer); } if (DECR(this->stunTimer) != 0) { @@ -297,8 +297,8 @@ s32 EnSsh_Damaged(EnSsh* this) { this->spinTimer = 30; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_ROLL); - Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_ST_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALTU_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_VO_ST_ATTACK); return true; } @@ -419,7 +419,7 @@ void EnSsh_Sway(EnSsh* this) { } temp_f20 = (this->swayTimer * (1.0f / 6)); - swayAngle = Math_SinS(this->swayAngle) * (temp_f20 * (0x10000 / 360.0f)); + swayAngle = (f32)DEG_TO_BINANG_ALT3(temp_f20) * Math_SinS(this->swayAngle); temp_f20 = this->actor.world.pos.y - this->ceilingPos.y; swayVecBase.x = Math_SinS(swayAngle) * temp_f20; @@ -428,7 +428,7 @@ void EnSsh_Sway(EnSsh* this) { Matrix_Push(); Matrix_Translate(this->ceilingPos.x, this->ceilingPos.y, this->ceilingPos.z, MTXMODE_NEW); - Matrix_RotateYF(this->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateYF(BINANG_TO_RAD(this->actor.world.rot.y), MTXMODE_APPLY); Matrix_MultVec3f(&swayVecBase, &swayVec); Matrix_Pop(); @@ -477,8 +477,8 @@ s32 EnSsh_CheckHitPlayer(EnSsh* this, PlayState* play) { this->spinTimer = this->hitTimer; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_ROLL); - Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_ST_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALTU_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_VO_ST_ATTACK); play->damagePlayer(play, -8); @@ -532,8 +532,8 @@ s32 EnSsh_CheckHitBack(EnSsh* this, PlayState* play) { } if (this->stunTimer == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_ST_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_VO_ST_DAMAGE); } EnSsh_SetStunned(this); @@ -553,8 +553,8 @@ s32 EnSsh_CollisionCheck(EnSsh* this, PlayState* play) { if (play->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); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_VO_ST_DAMAGE); } EnSsh_SetStunned(this); this->stateFlags |= SSH_STATE_STUNNED; @@ -595,7 +595,7 @@ s32 EnSsh_SetCylinderOC(EnSsh* this, PlayState* play) { Matrix_Push(); Matrix_Translate(colliderPos.x, colliderPos.y, colliderPos.z, MTXMODE_NEW); - Matrix_RotateYF(BINANG_TO_RAD(this->initialYaw), MTXMODE_APPLY); + Matrix_RotateYF(BINANG_TO_RAD_ALT(this->initialYaw), MTXMODE_APPLY); Matrix_MultVec3f(&colliderOffsets[i], &colliderPos); Matrix_Pop(); @@ -654,7 +654,7 @@ void EnSsh_Init(Actor* thisx, PlayState* play) { this->actor.gravity = 0.0f; this->initialYaw = this->actor.world.rot.y; EnSsh_SetupAction(this, EnSsh_Start); - if (Inventory_GetSkullTokenCount(play->sceneId) >= 30) { + if (Inventory_GetSkullTokenCount(play->sceneId) >= SPIDER_HOUSE_TOKENS_REQUIRED) { Actor_Kill(&this->actor); } } @@ -686,19 +686,19 @@ void EnSsh_Talk(EnSsh* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { - case 0x904: - case 0x905: - case 0x906: - case 0x908: - case 0x910: - case 0x911: - case 0x912: - case 0x914: - func_80151938(play, play->msgCtx.currentTextId + 1); + case 0x904: // (does not exist) + case 0x905: // (does not exist) + case 0x906: // (does not exist) + case 0x908: // (does not exist) + case 0x910: // Help me! I am not a monster, I was cursed this way + case 0x911: // Find all in here and defeat them + case 0x912: // Don't forget to collect their token + case 0x914: // In here, cursed spiders, defeat them to make me normal + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; - default: - func_801477B4(play); + default: // intended case 0x915 from above (914+1) + Message_CloseTextbox(play); this->actionFunc = EnSsh_Idle; break; } @@ -706,15 +706,15 @@ void EnSsh_Talk(EnSsh* this, PlayState* play) { } void func_809756D0(EnSsh* this, PlayState* play) { - u16 phi_a1; + u16 nextTextId; - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_34_08)) { - phi_a1 = 0x914; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_TALKED_SWAMP_SPIDER_HOUSE_MAN)) { + nextTextId = 0x914; // In here, cursed spiders, defeat them to make me normal } else { - phi_a1 = 0x910; - SET_WEEKEVENTREG(WEEKEVENTREG_34_08); + nextTextId = 0x910; // Help me! I am not a monster, I was cursed this way + SET_WEEKEVENTREG(WEEKEVENTREG_TALKED_SWAMP_SPIDER_HOUSE_MAN); } - Message_StartTextbox(play, phi_a1, &this->actor); + Message_StartTextbox(play, nextTextId, &this->actor); } void EnSsh_Idle(EnSsh* this, PlayState* play) { @@ -739,7 +739,7 @@ void EnSsh_Idle(EnSsh* this, PlayState* play) { } if (DECR(this->sfxTimer) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_LAUGH); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALTU_LAUGH); this->sfxTimer = 64; } @@ -780,7 +780,7 @@ void EnSsh_Drop(EnSsh* this, PlayState* play) { EnSsh_SetLandAnimation(this); EnSsh_SetupAction(this, EnSsh_Land); } else if (DECR(this->sfxTimer) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_DOWN); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALTU_DOWN); this->sfxTimer = 3; } } @@ -849,7 +849,7 @@ void EnSsh_Update(Actor* thisx, PlayState* play) { } else { SkelAnime_Update(&this->skelAnime); Actor_UpdatePos(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); } 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 094c63f7e..6f19a5e51 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h @@ -2,6 +2,8 @@ #define Z_EN_SSH_H #include "global.h" +#include "overlays/actors/ovl_En_Si/z_en_si.h" +#include "overlays/actors/ovl_En_Sth/z_en_sth.h" struct EnSsh; 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 14e0c1cb5..994a455a6 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -348,7 +348,7 @@ s16 func_808A5BEC(EnSt* this) { } else { ret = this->actor.yawTowardsPlayer; if (DECR(this->unk_30E) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALTU_ROLL); this->unk_18C ^= 2; this->unk_310 = 8; if (this->unk_18C & 1) { @@ -456,7 +456,7 @@ void func_808A60E0(EnSt* this) { if (sp1C == 1.0f) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); - Actor_PlaySfxAtPos(&this->actor, sfxId); + Actor_PlaySfx(&this->actor, sfxId); } this->unk_2D4 = (1.0f - sp1C) * sp20 * this->unk_2C8; @@ -587,23 +587,26 @@ s32 func_808A6580(EnSt* this, PlayState* play) { } else if (func_808A61F4(this)) { switch (this->actor.colChkInfo.damageEffect) { case 1: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->unk_312 = 40; - Actor_SetColorFilter(&this->actor, 0, 200, 0, this->unk_312); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 200, COLORFILTER_BUFFLAG_OPA, + this->unk_312); break; case 5: this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; this->unk_312 = 40; func_808A576C(this); - Actor_SetColorFilter(&this->actor, 0, 200, 0, this->unk_312); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 200, COLORFILTER_BUFFLAG_OPA, + this->unk_312); break; default: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_DAMAGE); + Actor_PlaySfx(&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); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 200, COLORFILTER_BUFFLAG_OPA, + this->unk_314); SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, 1); this->unk_18C |= 8; this->actionFunc = func_808A6D84; @@ -652,7 +655,7 @@ s32 func_808A6580(EnSt* this, PlayState* play) { } this->unk_314 = 20; this->unk_312 = 0; - Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->unk_314); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 200, COLORFILTER_BUFFLAG_OPA, this->unk_314); ret = true; } this->unk_310 = 0; @@ -663,7 +666,7 @@ s32 func_808A6580(EnSt* this, PlayState* play) { if ((this->unk_316 == 0) && (this->unk_314 == 0) && (this->unk_312 == 0) && !(this->collider1.base.atFlags & AT_BOUNCED) && (this->actor.colChkInfo.health != 0)) { play->damagePlayer(play, -8); - Actor_PlaySfxAtPos(&sp3C->actor, NA_SE_PL_BODY_HIT); + Actor_PlaySfx(&sp3C->actor, NA_SE_PL_BODY_HIT); func_800B8D98(play, &this->actor, 4.0f, this->actor.yawTowardsPlayer, 6.0f); this->unk_316 = 10; this->unk_18C |= 1; @@ -699,7 +702,7 @@ void func_808A6A78(EnSt* this, PlayState* play) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (ENST_GET_1C0(&this->actor) == ENST_1C0_1) { - this->actor.flags |= ACTOR_FLAG_80; + this->actor.flags |= ACTOR_FLAG_REACT_TO_LENS; } Actor_SetScale(&this->actor, 0.04f); @@ -776,15 +779,15 @@ void func_808A6E24(EnSt* this, PlayState* play) { this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; } else { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { 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; + this->actor.speed = 0.0f; if ((s32)this->unk_2D0 != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } else { this->actor.velocity.y = 0.0f; this->actionFunc = func_808A701C; @@ -864,8 +867,8 @@ void EnSt_Update(Actor* thisx, PlayState* play) { return; } - if (!(this->actor.flags & ACTOR_FLAG_80) && func_808A6A3C(this)) { - this->actor.flags |= ACTOR_FLAG_80; + if (!(this->actor.flags & ACTOR_FLAG_REACT_TO_LENS) && func_808A6A3C(this)) { + this->actor.flags |= ACTOR_FLAG_REACT_TO_LENS; } if (func_808A6580(this, play)) { @@ -875,7 +878,7 @@ void EnSt_Update(Actor* thisx, PlayState* play) { if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { SkelAnime_Update(&this->skelAnime); } - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } else if (this->unk_312 < 20) { s16 idx = (this->unk_312 % 2) ? -1 : 1; diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 5d1bd1471..215845341 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -1,13 +1,13 @@ /* * File: z_en_sth.c * Overlay: ovl_En_Sth - * Description: Guy looking at moon in South Clock Town + * Description: Guy looking at moon in South Clock Town, + * And the Cured Swamp Spider House man who gives you Mask of Truth + * (the cursed version is EnSsh) + * And the man who wants to buy Oceanside Spider House from you with rupees or Wallet */ #include "z_en_sth.h" -#include "objects/object_sth/object_sth.h" -#include "objects/object_ahg/object_ahg.h" -#include "objects/object_mask_truth/object_mask_truth.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -15,17 +15,17 @@ void EnSth_Init(Actor* thisx, PlayState* play); void EnSth_Destroy(Actor* thisx, PlayState* play); -void EnSth_Update(Actor* thisx, PlayState* play); +void EnSth_UpdateWaitForObject(Actor* thisx, PlayState* play); -void func_80B67208(EnSth* this, PlayState* play); -void func_80B67540(EnSth* this, PlayState* play); -void func_80B677BC(EnSth* this, PlayState* play); -void func_80B678A8(EnSth* this, PlayState* play); -void func_80B67958(EnSth* this, PlayState* play); -void func_80B67C1C(EnSth* this, PlayState* play); -void func_80B67DA0(EnSth* this, PlayState* play); -void func_80B680A8(Actor* thisx, PlayState* play); -void func_80B6849C(Actor* thisx, PlayState* play); +void EnSth_PanicIdle(EnSth* this, PlayState* play); +void EnSth_HandleOceansideSpiderHouseConversation(EnSth* this, PlayState* play); +void EnSth_OceansideSpiderHouseIdle(EnSth* this, PlayState* play); +void EnSth_MoonLookingIdle(EnSth* this, PlayState* play); +void EnSth_DefaultIdle(EnSth* this, PlayState* play); +void EnSth_HandleSwampSpiderHouseConversation(EnSth* this, PlayState* play); +void EnSth_SwampSpiderHouseIdle(EnSth* this, PlayState* play); +void EnSth_Update(Actor* thisx, PlayState* play); +void EnSth_Draw(Actor* thisx, PlayState* play); ActorInit En_Sth_InitVars = { ACTOR_EN_STH, @@ -35,7 +35,7 @@ ActorInit En_Sth_InitVars = { sizeof(EnSth), (ActorFunc)EnSth_Init, (ActorFunc)EnSth_Destroy, - (ActorFunc)EnSth_Update, + (ActorFunc)EnSth_UpdateWaitForObject, (ActorFunc)NULL, }; @@ -61,21 +61,48 @@ static ColliderCylinderInit sCylinderInit = { { 30, 40, 0, { 0, 0, 0 } }, }; -AnimationHeader* D_80B6D1C8[] = { - &ovl_En_Sth_Anim_003F50, &ovl_En_Sth_Anim_0045B4, &ovl_En_Sth_Anim_004CC0, &ovl_En_Sth_Anim_00533C, - &ovl_En_Sth_Anim_0059B8, &ovl_En_Sth_Anim_005E40, &ovl_En_Sth_Anim_006354, &ovl_En_Sth_Anim_00645C, +typedef enum { + /* 0 */ STH_ANIM_SIGNALLING, // default, waving arms at you from telescope, OOT: cured happy animation + /* 1 */ STH_ANIM_BENDING_DOWN, // default anim of cured spider house, but never seen before wait overrides it + /* 2 */ STH_ANIM_TALK, + /* 3 */ STH_ANIM_WAIT, + /* 4 */ STH_ANIM_LOOK_UP, // South Clock Town, looking at moon + /* 5 */ STH_ANIM_LOOK_AROUND, // checking out Oceanside Spider House + /* 6 */ STH_ANIM_PLEAD, // wants to buy Oceanside Spider House + /* 7 */ STH_ANIM_PANIC, // after buying Oceanside Spider House, can be found at bottom of slide, + /* 8 */ STH_ANIM_START, // set in init, not an actual index to the array +} EnSthAnimation; + +static AnimationHeader* sAnimationInfo[] = { + &gEnSthSignalAnim, &gEnSthBendDownAnim, &gEnSthTalkWithHandUpAnim, &gEnSthWaitAnim, + &gEnSthLookUpAnim, &gEnSthLookAroundAnim, &gEnSthPleadAnim, &gEnSthPanicAnim, }; -u16 D_80B6D1E8[] = { 0x1144, 0x1145, 0x1146 }; +// three slightly different variants of "Only a little time left, oh goddess please save me" +static u16 sSthOceanspiderhousePanicText[] = { 0x1144, 0x1145, 0x1146 }; -u16 D_80B6D1F0[] = { 0x1139, 0x113E, 0x1143 }; +static u16 sSthFirstOceansideSpiderHouseGreet2TextIds[] = { + 0x1139, // I thought I heard noises... I'm glad I found it early + 0x113E, // I had no idea this place was here, perhaps it can keep me safe + 0x1143 // There's no time we have to hide! +}; -u16 D_80B6D1F8[] = { 0x1132, 0x113A, 0x113F }; +static u16 sSthFirstOceansideSpiderHouseGreet1TextIds[] = { + 0x1132, // I thought I heard some noise.. is this some sort of underground shelter? + 0x113A, // I had no idea there was a basement here.. + 0x113F // I heard loud noises.. I never thought I'd find a place like this.. +}; -Vec3f D_80B6D200 = { 700.0f, 400.0f, 0.0f }; +static Vec3f sFocusOffset = { 700.0f, 400.0f, 0.0f }; -Color_RGB8 D_80B6D20C[] = { - { 190, 110, 0 }, { 0, 180, 110 }, { 0, 255, 0x50 }, { 255, 160, 60 }, { 190, 230, 250 }, { 240, 230, 120 }, +// Sth is hardcoded to only use element [1]. +static Color_RGB8 sShirtColors[] = { + { 190, 110, 0 }, // darker orange + { 0, 180, 110 }, // green + { 0, 255, 80 }, // lime green + { 255, 160, 60 }, // brighter orange + { 190, 230, 250 }, // white + { 240, 230, 120 }, // pale yellow }; void EnSth_Init(Actor* thisx, PlayState* play) { @@ -83,82 +110,88 @@ void EnSth_Init(Actor* thisx, PlayState* play) { EnSth* this = THIS; s32 objectId; - if (ENSTH_GET_100(&this->actor)) { + // this actor can draw two separate bodies that use different objects + if (STH_GET_SWAMP_BODY(&this->actor)) { objectId = Object_GetIndex(&play->objectCtx, OBJECT_AHG); } else { objectId = Object_GetIndex(&play->objectCtx, OBJECT_STH); } - this->unk_29E = objectId; - this->unk_29F = Object_GetIndex(&play->objectCtx, OBJECT_MASK_TRUTH); + this->mainObjectId = objectId; + this->maskOfTruthObjectId = Object_GetIndex(&play->objectCtx, OBJECT_MASK_TRUTH); Actor_SetScale(&this->actor, 0.01f); Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - this->unk_29C = 0; - this->unk_29A = 8; + this->sthFlags = 0; // clear + this->animIndex = STH_ANIM_START; this->actor.terminalVelocity = -9.0f; this->actor.gravity = -1.0f; - switch (ENSTH_GET_F(&this->actor)) { - case ENSTH_F_1: + switch (STH_GET_TYPE(&this->actor)) { + case STH_TYPE_UNUSED_1: if (play->actorCtx.flags & ACTORCTX_FLAG_1) { this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); - this->actionFunc = func_80B67958; + this->actionFunc = EnSth_DefaultIdle; } else { Actor_Kill(&this->actor); return; } break; - case ENSTH_F_2: - if (Inventory_GetSkullTokenCount(play->sceneId) >= 30) { - this->actionFunc = func_80B67DA0; + case STH_TYPE_SWAMP_SPIDER_HOUSE_CURED: + if (Inventory_GetSkullTokenCount(play->sceneId) >= SPIDER_HOUSE_TOKENS_REQUIRED) { + this->actionFunc = EnSth_SwampSpiderHouseIdle; } else { Actor_Kill(&this->actor); } this->actor.textId = 0; - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_34_40) || !CHECK_WEEKEVENTREG(WEEKEVENTREG_34_08)) { - this->unk_29C |= 1; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_RECEIVED_MASK_OF_TRUTH) || + !CHECK_WEEKEVENTREG(WEEKEVENTREG_TALKED_SWAMP_SPIDER_HOUSE_MAN)) { + this->sthFlags |= STH_FLAG_DRAW_MASK_OF_TRUTH; } break; - case ENSTH_F_3: - if ((gSaveContext.save.skullTokenCount & 0xFFFF) >= 30) { + case STH_TYPE_MOON_LOOKING: // South Clock Town + if ((gSaveContext.save.saveInfo.skullTokenCount & 0xFFFF) >= SPIDER_HOUSE_TOKENS_REQUIRED) { Actor_Kill(&this->actor); return; } - this->actionFunc = func_80B678A8; - this->unk_29C |= 8; + + this->actionFunc = EnSth_MoonLookingIdle; + this->sthFlags |= STH_FLAG_DISABLE_HEAD_TRACK; this->actor.targetMode = 3; this->actor.uncullZoneForward = 800.0f; break; - case ENSTH_F_4: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_20)) { + case STH_TYPE_OCEANSIDE_SPIDER_HOUSE_GREET: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_OCEANSIDE_SPIDER_HOUSE_BUYER_MOVED_IN)) { + // The player has already exited the house after complete; EnSth has moved deeper into the house. Actor_Kill(&this->actor); return; } this->actor.textId = 0; - this->actionFunc = func_80B677BC; - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_80)) { - this->unk_29C |= 2; + this->actionFunc = EnSth_OceansideSpiderHouseIdle; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_OCEANSIDE_SPIDER_HOUSE_COLLECTED_REWARD)) { + this->sthFlags |= STH_FLAG_OCEANSIDE_SPIDER_HOUSE_GREET; } break; - case ENSTH_F_5: - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_13_20) || (Inventory_GetSkullTokenCount(play->sceneId) < 30)) { + case STH_TYPE_OCEANSIDE_SPIDER_HOUSE_PANIC: + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_OCEANSIDE_SPIDER_HOUSE_BUYER_MOVED_IN) || + (Inventory_GetSkullTokenCount(play->sceneId) < SPIDER_HOUSE_TOKENS_REQUIRED)) { + // Has not moved in, and has not completed the house; do NOT spawn yet. Actor_Kill(&this->actor); return; } - this->actionFunc = func_80B67208; + this->actionFunc = EnSth_PanicIdle; this->actor.textId = 0; - this->unk_29C |= 8; + this->sthFlags |= STH_FLAG_DISABLE_HEAD_TRACK; break; default: - this->actionFunc = func_80B67958; + this->actionFunc = EnSth_DefaultIdle; break; } } @@ -169,142 +202,144 @@ void EnSth_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -s32 func_80B6703C(EnSth* this, PlayState* play) { +s32 EnSth_CanSpeakToPlayer(EnSth* this, PlayState* play) { if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play) && Actor_IsFacingPlayer(&this->actor, 0x2000)) { return true; - } - return false; -} - -void func_80B670A4(EnSth* this, s16 arg1) { - if ((arg1 >= 0) && (arg1 < ARRAY_COUNT(D_80B6D1C8)) && (arg1 != this->unk_29A)) { - Animation_Change(&this->skelAnime, D_80B6D1C8[arg1], 1.0f, 0.0f, Animation_GetLastFrame(D_80B6D1C8[arg1]), - ANIMMODE_LOOP, -5.0f); - this->unk_29A = arg1; + } else { + return false; } } -void func_80B67148(EnSth* this, PlayState* play) { +void EnSth_ChangeAnim(EnSth* this, s16 animIndex) { + if ((animIndex >= 0) && (animIndex < ARRAY_COUNT(sAnimationInfo)) && (animIndex != this->animIndex)) { + Animation_Change(&this->skelAnime, sAnimationInfo[animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[animIndex]), ANIMMODE_LOOP, -5.0f); + this->animIndex = animIndex; + } +} + +void EnSth_GetInitialPanicText(EnSth* this, PlayState* play) { s32 day = CURRENT_DAY - 1; - u16 val; + u16 nextTextId; if (day < 0) { day = 0; } - val = D_80B6D1E8[day]; + nextTextId = sSthOceanspiderhousePanicText[day]; - Message_StartTextbox(play, val, &this->actor); + Message_StartTextbox(play, nextTextId, &this->actor); } -void func_80B671A0(EnSth* this, PlayState* play) { +void EnSth_HandlePanicConversation(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - this->actionFunc = func_80B67208; - func_801477B4(play); + this->actionFunc = EnSth_PanicIdle; + Message_CloseTextbox(play); } } -void func_80B67208(EnSth* this, PlayState* play) { +void EnSth_PanicIdle(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - func_80B67148(this, play); - this->actionFunc = func_80B671A0; + EnSth_GetInitialPanicText(this, play); + this->actionFunc = EnSth_HandlePanicConversation; } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play)) { func_800B8614(&this->actor, play, 110.0f); } } -void func_80B672A4(EnSth* this, PlayState* play) { - u16 sp1E; +void EnSth_GetInitialOceansideSpiderHouseText(EnSth* this, PlayState* play) { + u16 nextTextId; s32 day = CURRENT_DAY - 1; if (day < 0) { day = 0; } - if (this->unk_29C & 2) { + if (this->sthFlags & STH_FLAG_OCEANSIDE_SPIDER_HOUSE_GREET) { s32 pad; - sp1E = D_80B6D1F0[day]; + nextTextId = sSthFirstOceansideSpiderHouseGreet2TextIds[day]; if (day == 2) { - func_80B670A4(this, 5); + EnSth_ChangeAnim(this, STH_ANIM_LOOK_AROUND); } } else { - sp1E = D_80B6D1F8[day]; + nextTextId = sSthFirstOceansideSpiderHouseGreet1TextIds[day]; } - Message_StartTextbox(play, sp1E, &this->actor); + Message_StartTextbox(play, nextTextId, &this->actor); } -void func_80B67348(EnSth* this, PlayState* play) { - u16 phi_a1; +void EnSth_PostOceanspiderhouseReward(EnSth* this, PlayState* play) { + u16 nextTextId; SkelAnime_Update(&this->skelAnime); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - this->actionFunc = func_80B67540; + this->actionFunc = EnSth_HandleOceansideSpiderHouseConversation; - switch (this->actor.home.rot.z) { - case 8: - case 9: - phi_a1 = 0x1137; + switch (STH_GI_ID(&this->actor)) { + case GI_WALLET_ADULT: + case GI_WALLET_GIANT: + nextTextId = 0x1137; // I'm just glad it was something you needed break; - case 6: - phi_a1 = 0x1138; + case GI_RUPEE_SILVER: + // unused code, as he only gives wallet, purple and red, silver is never assigned to STH_GI_ID + nextTextId = 0x1138; // That's my life's fortune break; - case 5: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_40)) { - phi_a1 = 0x113D; + case GI_RUPEE_PURPLE: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_RECEIVED_OCEANSIDE_WALLET_UPGRADE)) { + nextTextId = 0x113D; // That's my life's savings } else { - phi_a1 = 0x113C; + nextTextId = 0x113C; // That's my life's savings (2) } break; default: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_40)) { - phi_a1 = 0x1142; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_RECEIVED_OCEANSIDE_WALLET_UPGRADE)) { + nextTextId = 0x1142; // Well, thats all I have on me } else { - phi_a1 = 0x1141; + nextTextId = 0x1141; // Well, thats all I have on me } break; } - Message_StartTextbox(play, phi_a1, &this->actor); + Message_StartTextbox(play, nextTextId, &this->actor); } else { func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_MINUS1); } } -void func_80B67458(EnSth* this, PlayState* play) { +void EnSth_GiveOceansideSpiderHouseReward(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; - this->actionFunc = func_80B67348; + this->actionFunc = EnSth_PostOceanspiderhouseReward; this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_MINUS1); if (CURRENT_DAY == 3) { - func_80B670A4(this, 6); + EnSth_ChangeAnim(this, STH_ANIM_PLEAD); } else { - func_80B670A4(this, 3); + EnSth_ChangeAnim(this, STH_ANIM_WAIT); } } else { - Actor_PickUp(&this->actor, play, this->actor.home.rot.z, 10000.0f, 500.0f); + Actor_OfferGetItem(&this->actor, play, STH_GI_ID(&this->actor), 10000.0f, 500.0f); } } -void func_80B67540(EnSth* this, PlayState* play) { - s32 sp2C = CURRENT_DAY - 1; +void EnSth_HandleOceansideSpiderHouseConversation(EnSth* this, PlayState* play) { + s32 day = CURRENT_DAY - 1; - if (sp2C < 0) { - sp2C = 0; + if (day < 0) { + day = 0; } - if (this->unk_29A == 6) { + if (this->animIndex == STH_ANIM_PLEAD) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); this->actor.world.rot.y = this->actor.shape.rot.y; } @@ -315,374 +350,397 @@ void func_80B67540(EnSth* this, PlayState* play) { case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { - case 0x1134: - func_80151938(play, play->msgCtx.currentTextId + 1); + case 0x1134: // (does not exist) + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; - case 0x1132: - case 0x113A: - case 0x113F: - func_80151938(play, 0x1133); + case 0x1132: // Heard noise, came in to see + case 0x113A: // Had no idea there was a basement here + case 0x113F: // Heard noise... I never thought I'd find a place like this + Message_ContinueTextbox(play, 0x1133); // did you find this place? break; - case 0x1133: - func_80151938(play, 0x1136); - func_80B670A4(this, 6); + case 0x1133: // did you find this place? + Message_ContinueTextbox(play, 0x1136); // I want to buy this place from you + EnSth_ChangeAnim(this, STH_ANIM_PLEAD); break; - case 0x1136: - SET_WEEKEVENTREG(WEEKEVENTREG_13_80); + case 0x1136: // I want to buy this house from you + // This flag prevents multiple rewards, switching to secondary dialogue after + SET_WEEKEVENTREG(WEEKEVENTREG_OCEANSIDE_SPIDER_HOUSE_COLLECTED_REWARD); - switch (sp2C) { - case 0: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_40)) { - this->actor.home.rot.z = 6; + switch (day) { + case 0: // first day + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_RECEIVED_OCEANSIDE_WALLET_UPGRADE)) { + STH_GI_ID(&this->actor) = GI_RUPEE_SILVER; } else { - SET_WEEKEVENTREG(WEEKEVENTREG_13_40); + // This flag prevents getting two wallets from the same place. + // Instead, getting silver rupee above. + SET_WEEKEVENTREG(WEEKEVENTREG_RECEIVED_OCEANSIDE_WALLET_UPGRADE); switch (CUR_UPG_VALUE(UPG_WALLET)) { case 0: - this->actor.home.rot.z = 8; + STH_GI_ID(&this->actor) = GI_WALLET_ADULT; break; case 1: - this->actor.home.rot.z = 9; + STH_GI_ID(&this->actor) = GI_WALLET_GIANT; break; } } break; - case 1: - this->actor.home.rot.z = 5; + case 1: // second day + STH_GI_ID(&this->actor) = GI_RUPEE_PURPLE; break; - default: - this->actor.home.rot.z = 4; + default: // final day + STH_GI_ID(&this->actor) = GI_RUPEE_RED; break; } - func_801477B4(play); - this->actionFunc = func_80B67458; - func_80B67458(this, play); + Message_CloseTextbox(play); + this->actionFunc = EnSth_GiveOceansideSpiderHouseReward; + EnSth_GiveOceansideSpiderHouseReward(this, play); break; - case 0x113C: - func_80151938(play, 0x113B); + case 0x113C: // (Second day) I am giving you my life savings + Message_ContinueTextbox(play, 0x113B); // If only I had gotten here yesterday... break; - case 0x1141: - func_80151938(play, 0x1140); - func_80B670A4(this, 3); + case 0x1141: // (Final day) This is all I have + Message_ContinueTextbox(play, 0x1140); // If only I had gotten here two days ago... + EnSth_ChangeAnim(this, STH_ANIM_WAIT); break; default: - this->actionFunc = func_80B677BC; - func_801477B4(play); - this->unk_29C |= 2; + this->actionFunc = EnSth_OceansideSpiderHouseIdle; + Message_CloseTextbox(play); + this->sthFlags |= STH_FLAG_OCEANSIDE_SPIDER_HOUSE_GREET; break; } } break; case TEXT_STATE_CLOSING: - this->actionFunc = func_80B677BC; - this->unk_29C |= 2; + this->actionFunc = EnSth_OceansideSpiderHouseIdle; + this->sthFlags |= STH_FLAG_OCEANSIDE_SPIDER_HOUSE_GREET; break; } } -void func_80B677BC(EnSth* this, PlayState* play) { +void EnSth_OceansideSpiderHouseIdle(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - func_80B672A4(this, play); - this->actionFunc = func_80B67540; - } else if (func_80B6703C(this, play)) { + EnSth_GetInitialOceansideSpiderHouseText(this, play); + this->actionFunc = EnSth_HandleOceansideSpiderHouseConversation; + } else if (EnSth_CanSpeakToPlayer(this, play)) { func_800B8614(&this->actor, play, 110.0f); } } -void func_80B67838(EnSth* this, PlayState* play) { +void EnSth_HandleMoonLookingConversation(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - this->actionFunc = func_80B678A8; - func_801477B4(play); + this->actionFunc = EnSth_MoonLookingIdle; + Message_CloseTextbox(play); } - this->unk_294.x = -0x1388; + this->headRot.x = -0x1388; } -void func_80B678A8(EnSth* this, PlayState* play) { +void EnSth_MoonLookingIdle(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - this->actionFunc = func_80B67838; - } else if (func_80B6703C(this, play) || this->actor.isTargeted) { + this->actionFunc = EnSth_HandleMoonLookingConversation; + } else if (EnSth_CanSpeakToPlayer(this, play) || this->actor.isTargeted) { if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time <= CLOCK_TIME(18, 0))) { - this->actor.textId = 0x1130; + this->actor.textId = 0x1130; // Huh? The Moon... } else { - this->actor.textId = 0x1131; + this->actor.textId = 0x1131; // (The Moon) gotten bigger again } func_800B8614(&this->actor, play, 110.0f); } - this->unk_294.x = -0x1388; + this->headRot.x = -0x1388; } -void func_80B67958(EnSth* this, PlayState* play) { +// used by type: STH_TYPE_UNUSED_1 and undefined types +void EnSth_DefaultIdle(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); } -void func_80B67984(EnSth* this, PlayState* play) { - u16 sp1E; +void EnSth_GetInitialSwampSpiderHouseText(EnSth* this, PlayState* play) { + u16 nextTextId; if (CHECK_WEEKEVENTREG(WEEKEVENTREG_34_10)) { - sp1E = 0x903; - func_80B670A4(this, 2); + nextTextId = 0x903; // (does not exist) + EnSth_ChangeAnim(this, STH_ANIM_TALK); } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_34_20)) { - sp1E = 0x90F; - func_80B670A4(this, 2); - } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_34_40)) { - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_34_08)) { - sp1E = 0x91B; + nextTextId = 0x90F; // (does not exist) + EnSth_ChangeAnim(this, STH_ANIM_TALK); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_RECEIVED_MASK_OF_TRUTH)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_TALKED_SWAMP_SPIDER_HOUSE_MAN)) { + nextTextId = 0x91B; // As soon as I calm down, getting rid of it } else { - sp1E = 0x918; + nextTextId = 0x918; // I've had enough of this, going home } - func_80B670A4(this, 2); - } else if (Inventory_GetSkullTokenCount(play->sceneId) >= 30) { + EnSth_ChangeAnim(this, STH_ANIM_TALK); + } else if (Inventory_GetSkullTokenCount(play->sceneId) >= SPIDER_HOUSE_TOKENS_REQUIRED) { if (INV_CONTENT(ITEM_MASK_TRUTH) == ITEM_MASK_TRUTH) { - this->unk_29C |= 4; - sp1E = 0x919; + this->sthFlags |= STH_FLAG_SWAMP_SPIDER_HOUSE_SAVED; + nextTextId = 0x919; // I've been saved! } else { - sp1E = 0x916; + nextTextId = 0x916; // I've been saved! (Duplicate) } } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_34_02)) { - sp1E = 0x8FF; + nextTextId = 0x8FF; // (does not exist) } else { - sp1E = 0x8FC; + nextTextId = 0x8FC; // (does not exist) SET_WEEKEVENTREG(WEEKEVENTREG_34_02); } - Message_StartTextbox(play, sp1E, &this->actor); + + Message_StartTextbox(play, nextTextId, &this->actor); } -void func_80B67AB4(EnSth* this, PlayState* play) { +void EnSth_TalkAfterSwampSpiderHouseGiveMask(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - this->actionFunc = func_80B67C1C; - SET_WEEKEVENTREG(WEEKEVENTREG_34_40); - Message_StartTextbox(play, 0x918, &this->actor); + this->actionFunc = EnSth_HandleSwampSpiderHouseConversation; + SET_WEEKEVENTREG(WEEKEVENTREG_RECEIVED_MASK_OF_TRUTH); + Message_StartTextbox(play, 0x918, &this->actor); // I've had enough of this, going home } else { func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_MINUS1); } } -void func_80B67B50(EnSth* this, PlayState* play) { +void EnSth_SwampSpiderHouseGiveMask(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; - this->actionFunc = func_80B67AB4; + this->actionFunc = EnSth_TalkAfterSwampSpiderHouseGiveMask; this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_MINUS1); } else { - this->unk_29C &= ~1; - SET_WEEKEVENTREG(WEEKEVENTREG_34_08); - Actor_PickUp(&this->actor, play, GI_MASK_TRUTH, 10000.0f, 50.0f); + this->sthFlags &= ~STH_FLAG_DRAW_MASK_OF_TRUTH; + // This flag is used to keep track if the player has already spoken to the actor, triggering secondary dialogue. + SET_WEEKEVENTREG(WEEKEVENTREG_TALKED_SWAMP_SPIDER_HOUSE_MAN); + Actor_OfferGetItem(&this->actor, play, GI_MASK_TRUTH, 10000.0f, 50.0f); } } -void func_80B67C1C(EnSth* this, PlayState* play) { +void EnSth_HandleSwampSpiderHouseConversation(EnSth* this, PlayState* play) { s32 pad; SkelAnime_Update(&this->skelAnime); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { - case 0x90C: - func_80B670A4(this, 2); - func_80151938(play, play->msgCtx.currentTextId + 1); + case 0x90C: // (does not exist) + EnSth_ChangeAnim(this, STH_ANIM_TALK); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; - case 0x916: - case 0x919: - func_80B670A4(this, 3); - func_80151938(play, play->msgCtx.currentTextId + 1); + case 0x916: // I have been saved! I thought I was doomed + case 0x919: // I have been saved! I thought I was doomed (duplicate) + EnSth_ChangeAnim(this, STH_ANIM_WAIT); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; - case 0x8FC: - case 0x8FD: - case 0x900: - case 0x90A: - case 0x90D: - func_80151938(play, play->msgCtx.currentTextId + 1); + case 0x8FC: // (does not exist) + case 0x8FD: // (does not exist) + case 0x900: // (does not exist) + case 0x90A: // (does not exist) + case 0x90D: // (does not exist) + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; - case 0x901: - case 0x90B: - case 0x917: - func_801477B4(play); - this->actionFunc = func_80B67B50; - func_80B67B50(this, play); + case 0x901: // (does not exist) + case 0x90B: // (does not exist) + case 0x917: // Someone gave me this mask and said it would make me rich, Take it + Message_CloseTextbox(play); + this->actionFunc = EnSth_SwampSpiderHouseGiveMask; + EnSth_SwampSpiderHouseGiveMask(this, play); break; - case 0x91A: - SET_WEEKEVENTREG(WEEKEVENTREG_34_40); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_34_08); + case 0x91A: // Someone gave me this mask and said it would make me rich, getting rid of it + SET_WEEKEVENTREG(WEEKEVENTREG_RECEIVED_MASK_OF_TRUTH); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_TALKED_SWAMP_SPIDER_HOUSE_MAN); - case 0x902: - case 0x903: - case 0x90E: - case 0x90F: - case 0x918: - case 0x91B: - func_80B670A4(this, 3); + case 0x902: // (does not exist) + case 0x903: // (does not exist) + case 0x90E: // (does not exist) + case 0x90F: // (does not exist) + case 0x918: // I have had enough, going home + case 0x91B: // As soon as I calm down, getting rid of it + EnSth_ChangeAnim(this, STH_ANIM_WAIT); default: this->actor.flags &= ~ACTOR_FLAG_10000; - func_801477B4(play); - this->actionFunc = func_80B67DA0; + Message_CloseTextbox(play); + this->actionFunc = EnSth_SwampSpiderHouseIdle; break; } } } -void func_80B67DA0(EnSth* this, PlayState* play) { +void EnSth_SwampSpiderHouseIdle(EnSth* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - func_80B67984(this, play); - this->actionFunc = func_80B67C1C; - } else if (func_80B6703C(this, play)) { + EnSth_GetInitialSwampSpiderHouseText(this, play); + this->actionFunc = EnSth_HandleSwampSpiderHouseConversation; + } else if (EnSth_CanSpeakToPlayer(this, play)) { this->actor.textId = 0; func_800B8614(&this->actor, play, 110.0f); } } -void func_80B67E20(Actor* thisx, PlayState* play) { +/** + * Oceanside Spider House EnSth shows up after you collect all 30 tokens. + * Here we wait invisible until the player has finished. + */ +void EnSth_UpdateOceansideSpiderHouseWaitForTokens(Actor* thisx, PlayState* play) { EnSth* this = THIS; - if (Inventory_GetSkullTokenCount(play->sceneId) >= 30) { - this->actor.update = func_80B680A8; - this->actor.draw = func_80B6849C; + if (Inventory_GetSkullTokenCount(play->sceneId) >= SPIDER_HOUSE_TOKENS_REQUIRED) { + this->actor.update = EnSth_Update; + this->actor.draw = EnSth_Draw; this->actor.flags |= ACTOR_FLAG_1; } } +/** + * Dual object actors have to wait for the object to finish loading. + * This dev chose to use a temporary update instead of temporary actionFunc. + */ +void EnSth_UpdateWaitForObject(Actor* thisx, PlayState* play) { + s32 pad; + EnSth* this = THIS; + + if (Object_IsLoaded(&play->objectCtx, this->mainObjectId)) { + this->actor.objBankIndex = this->mainObjectId; + Actor_SetObjectDependency(play, &this->actor); + + if (STH_GET_SWAMP_BODY(&this->actor)) { + SkelAnime_InitFlex(play, &this->skelAnime, &gAhgSkel, &gEnSthBendDownAnim, this->jointTable, + this->morphTable, AHG_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gEnSthBendDownAnim); + this->animIndex = STH_ANIM_BENDING_DOWN; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_34_10) || CHECK_WEEKEVENTREG(WEEKEVENTREG_34_20) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_RECEIVED_MASK_OF_TRUTH) || + (Inventory_GetSkullTokenCount(play->sceneId) >= SPIDER_HOUSE_TOKENS_REQUIRED)) { + EnSth_ChangeAnim(this, STH_ANIM_WAIT); + } + } else { + SkelAnime_InitFlex(play, &this->skelAnime, &gSthSkel, &gEnSthSignalAnim, this->jointTable, this->morphTable, + STH_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gEnSthSignalAnim); + } + + this->actor.update = EnSth_Update; + this->actor.draw = EnSth_Draw; + + switch (STH_GET_TYPE(&this->actor)) { + case STH_TYPE_MOON_LOOKING: + EnSth_ChangeAnim(this, STH_ANIM_LOOK_UP); + break; + + case STH_TYPE_OCEANSIDE_SPIDER_HOUSE_GREET: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_OCEANSIDE_SPIDER_HOUSE_COLLECTED_REWARD)) { + EnSth_ChangeAnim(this, STH_ANIM_LOOK_AROUND); + } else { + EnSth_ChangeAnim(this, STH_ANIM_LOOK_AROUND); + } + break; + + case STH_TYPE_OCEANSIDE_SPIDER_HOUSE_PANIC: + EnSth_ChangeAnim(this, STH_ANIM_PANIC); + break; + } + + // not ready to appear yet + if ((STH_GET_TYPE(&this->actor) == STH_TYPE_OCEANSIDE_SPIDER_HOUSE_GREET) && + (Inventory_GetSkullTokenCount(play->sceneId) < SPIDER_HOUSE_TOKENS_REQUIRED)) { + this->actor.update = EnSth_UpdateOceansideSpiderHouseWaitForTokens; + this->actor.draw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + } + } +} + void EnSth_Update(Actor* thisx, PlayState* play) { s32 pad; EnSth* this = THIS; - if (Object_IsLoaded(&play->objectCtx, this->unk_29E)) { - this->actor.objBankIndex = this->unk_29E; - Actor_SetObjectDependency(play, &this->actor); - - if (ENSTH_GET_100(&this->actor)) { - SkelAnime_InitFlex(play, &this->skelAnime, &object_ahg_Skel_005998, &ovl_En_Sth_Anim_0045B4, - this->jointTable, this->morphTable, 16); - Animation_PlayLoop(&this->skelAnime, &ovl_En_Sth_Anim_0045B4); - this->unk_29A = 1; - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_34_10) || CHECK_WEEKEVENTREG(WEEKEVENTREG_34_20) || - CHECK_WEEKEVENTREG(WEEKEVENTREG_34_40) || (Inventory_GetSkullTokenCount(play->sceneId) >= 30)) { - func_80B670A4(this, 3); - } - } else { - SkelAnime_InitFlex(play, &this->skelAnime, &object_sth_Skel_0031F8, &ovl_En_Sth_Anim_003F50, - this->jointTable, this->morphTable, 16); - Animation_PlayLoop(&this->skelAnime, &ovl_En_Sth_Anim_003F50); - } - - this->actor.update = func_80B680A8; - this->actor.draw = func_80B6849C; - - switch (ENSTH_GET_F(&this->actor)) { - case ENSTH_F_3: - func_80B670A4(this, 4); - break; - - case ENSTH_F_4: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_80)) { - func_80B670A4(this, 5); - } else { - func_80B670A4(this, 5); - } - break; - - case ENSTH_F_5: - func_80B670A4(this, 7); - break; - } - - if ((ENSTH_GET_F(&this->actor) == ENSTH_F_4) && (Inventory_GetSkullTokenCount(play->sceneId) < 30)) { - this->actor.update = func_80B67E20; - this->actor.draw = NULL; - this->actor.flags &= ~ACTOR_FLAG_1; - } - } -} - -void func_80B680A8(Actor* thisx, PlayState* play) { - s32 pad; - EnSth* this = THIS; - Vec3s sp38; - Actor_MoveWithGravity(&this->actor); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); - if (func_80B6703C(this, play) && !(this->unk_29C & 8) && (this->unk_29A != 5)) { - sp38.x = sp38.y = sp38.z = 0; + if (EnSth_CanSpeakToPlayer(this, play) && !(this->sthFlags & STH_FLAG_DISABLE_HEAD_TRACK) && + (this->animIndex != STH_ANIM_LOOK_AROUND)) { + Vec3s torsoRot; - Actor_TrackPlayer(play, &this->actor, &this->unk_294, &sp38, this->actor.focus.pos); + torsoRot.x = torsoRot.y = torsoRot.z = 0; // this should block torso rot from working + + Actor_TrackPlayer(play, &this->actor, &this->headRot, &torsoRot, this->actor.focus.pos); } else { - Math_SmoothStepToS(&this->unk_294.x, 0, 6, 6200, 100); - Math_SmoothStepToS(&this->unk_294.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->headRot.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->headRot.y, 0, 6, 6200, 100); } } -s32 func_80B681E8(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnSth_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { s32 pad; EnSth* this = THIS; - if (limbIndex == 15) { - rot->x += this->unk_294.y; - rot->z += this->unk_294.x; - *dList = ovl_En_Sth_DL_0034A0; + if (limbIndex == STH_LIMB_HEAD) { + rot->x += this->headRot.y; + rot->z += this->headRot.x; + + // object_sth body has no head by default, forced here from overlay data + *dList = gEnSthHeadDL; } - if ((limbIndex == 8) || (limbIndex == 10) || (limbIndex == 13)) { + if ((limbIndex == STH_LIMB_CHEST) || (limbIndex == STH_LIMB_LEFT_FOREARM) || + (limbIndex == STH_LIMB_RIGHT_FOREARM)) { rot->y += (s16)(Math_SinS(play->state.frames * ((limbIndex * 50) + 0x814)) * 200.0f); rot->z += (s16)(Math_CosS(play->state.frames * ((limbIndex * 50) + 0x940)) * 200.0f); } + return false; } -void func_80B68310(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnSth_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnSth* this = THIS; - if (limbIndex == 15) { + if (limbIndex == STH_LIMB_HEAD) { s32 pad; - Matrix_MultVec3f(&D_80B6D200, &this->actor.focus.pos); + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); - if (!ENSTH_GET_100(&this->actor)) { + if (!STH_GET_SWAMP_BODY(&this->actor)) { OPEN_DISPS(play->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, ovl_En_Sth_DL_0037C0); + gSPDisplayList(POLY_OPA_DISP++, gEnSthExtraHairDL); CLOSE_DISPS(play->state.gfxCtx); } else { OPEN_DISPS(play->state.gfxCtx); - if (this->unk_29C & 1) { - if (Object_IsLoaded(&play->objectCtx, this->unk_29F)) { + if (this->sthFlags & STH_FLAG_DRAW_MASK_OF_TRUTH) { + if (Object_IsLoaded(&play->objectCtx, this->maskOfTruthObjectId)) { Matrix_Push(); Matrix_RotateZS(0x3A98, MTXMODE_APPLY); Matrix_Translate(0.0f, 190.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_OPA_DISP++, 0x0A, play->objectCtx.status[this->unk_29F].segment); + gSPSegment(POLY_OPA_DISP++, 0x0A, play->objectCtx.status[this->maskOfTruthObjectId].segment); gSPDisplayList(POLY_OPA_DISP++, object_mask_truth_DL_0001A0); Matrix_Pop(); @@ -694,7 +752,7 @@ void func_80B68310(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Acto } } -void func_80B6849C(Actor* thisx, PlayState* play) { +void EnSth_Draw(Actor* thisx, PlayState* play) { s32 pad; EnSth* this = THIS; @@ -703,11 +761,11 @@ void func_80B6849C(Actor* thisx, PlayState* play) { func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_EnvColor(play->state.gfxCtx, D_80B6D20C[1].r, D_80B6D20C[1].g, D_80B6D20C[1].b, 255)); + Gfx_EnvColor(play->state.gfxCtx, sShirtColors[1].r, sShirtColors[1].g, sShirtColors[1].b, 255)); gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(play->state.gfxCtx, 90, 110, 130, 255)); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - func_80B681E8, func_80B68310, &this->actor); + EnSth_OverrideLimbDraw, EnSth_PostLimbDraw, &this->actor); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.h b/src/overlays/actors/ovl_En_Sth/z_en_sth.h index 857b92505..1c8c92852 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.h +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.h @@ -2,33 +2,48 @@ #define Z_EN_STH_H #include "global.h" +#include "overlays/actors/ovl_En_Si/z_en_si.h" +#include "objects/object_sth/object_sth.h" +#include "objects/object_ahg/object_ahg.h" +#include "objects/object_mask_truth/object_mask_truth.h" struct EnSth; typedef void (*EnSthActionFunc)(struct EnSth*, PlayState*); -#define ENSTH_GET_F(thisx) ((thisx)->params & 0xF) -#define ENSTH_GET_100(thisx) ((thisx)->params & 0x100) +typedef enum { + /* 1 */ STH_TYPE_UNUSED_1 = 1, + /* 2 */ STH_TYPE_SWAMP_SPIDER_HOUSE_CURED, // cursed is EnSsh + /* 3 */ STH_TYPE_MOON_LOOKING, // South Clock Town, looking up at the moon + /* 4 */ STH_TYPE_OCEANSIDE_SPIDER_HOUSE_GREET, // looking for shelter + /* 5 */ STH_TYPE_OCEANSIDE_SPIDER_HOUSE_PANIC, // shelter was not enough + // Other values: Actor will spawn and animate with arm waving, no further interaction. +} EnSthTypes; -enum { - /* 1 */ ENSTH_F_1 = 1, - /* 2 */ ENSTH_F_2, - /* 3 */ ENSTH_F_3, - /* 4 */ ENSTH_F_4, - /* 5 */ ENSTH_F_5, -}; +// Note: Vanilla types usually have 0xFEXX typing, but this upper section is unused by the code, reason unknown +#define STH_GET_TYPE(thisx) ((thisx)->params & 0xF) +#define STH_GET_SWAMP_BODY(thisx) ((thisx)->params & 0x100) + +// The get item ID for the reward for Oceanside Spider House (wallet, or rupees) is set here +#define STH_GI_ID(thisx) ((thisx)->home.rot.z) + +// This actor has its own flags system +#define STH_FLAG_DRAW_MASK_OF_TRUTH (1 << 0) +#define STH_FLAG_OCEANSIDE_SPIDER_HOUSE_GREET (1 << 1) +#define STH_FLAG_SWAMP_SPIDER_HOUSE_SAVED (1 << 2) // set, but not read +#define STH_FLAG_DISABLE_HEAD_TRACK (1 << 3) typedef struct EnSth { /* 0x000 */ Actor actor; /* 0x144 */ ColliderCylinder collider; /* 0x190 */ SkelAnime skelAnime; - /* 0x1D4 */ Vec3s jointTable[16]; - /* 0x234 */ Vec3s morphTable[16]; - /* 0x294 */ Vec3s unk_294; - /* 0x29A */ s16 unk_29A; - /* 0x29C */ u16 unk_29C; - /* 0x29E */ u8 unk_29E; - /* 0x29F */ u8 unk_29F; + /* 0x1D4 */ Vec3s jointTable[STH_LIMB_MAX]; + /* 0x234 */ Vec3s morphTable[STH_LIMB_MAX]; + /* 0x294 */ Vec3s headRot; + /* 0x29A */ s16 animIndex; + /* 0x29C */ u16 sthFlags; + /* 0x29E */ u8 mainObjectId; + /* 0x29F */ u8 maskOfTruthObjectId; /* 0x2A0 */ EnSthActionFunc actionFunc; } EnSth; // size = 0x2A4 diff --git a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c index ac615a8dd..ba6d72cb6 100644 --- a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c +++ b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c @@ -63,8 +63,8 @@ void EnSth2_Update(Actor* thisx, PlayState* play) { if (Object_IsLoaded(&play->objectCtx, this->objIndex)) { this->actor.objBankIndex = this->objIndex; Actor_SetObjectDependency(play, &this->actor); - SkelAnime_InitFlex(play, &this->skelAnime, &object_sth_Skel_0031F8, &gEnSth2WavingHandAnim, this->jointTable, - this->morphTable, OBJECT_STH_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gSthSkel, &gEnSth2WavingHandAnim, this->jointTable, + this->morphTable, STH_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gEnSth2WavingHandAnim); this->actor.update = EnSth2_UpdateActionFunc; this->actor.draw = EnSth2_Draw; @@ -80,10 +80,11 @@ void EnSth2_UpdateActionFunc(Actor* thisx, PlayState* play) { s32 EnSth2_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { s32 pad; - if (limbIndex == OBJECT_STH_LIMB_0F) { + if (limbIndex == STH_LIMB_HEAD) { *dList = gEnSth2HeadDL; } - if ((limbIndex == OBJECT_STH_LIMB_08) || (limbIndex == OBJECT_STH_LIMB_0A) || (limbIndex == OBJECT_STH_LIMB_0D)) { + if ((limbIndex == STH_LIMB_CHEST) || (limbIndex == STH_LIMB_LEFT_FOREARM) || + (limbIndex == STH_LIMB_RIGHT_FOREARM)) { rot->y += (s16)(Math_SinS((play->state.frames * ((limbIndex * 50) + 0x814))) * 200.0f); rot->z += (s16)(Math_CosS((play->state.frames * ((limbIndex * 50) + 0x940))) * 200.0f); } @@ -93,7 +94,7 @@ s32 EnSth2_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* void EnSth2_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { static Vec3f focusOffset = { 700.0f, 400.0f, 0.0f }; - if (limbIndex == OBJECT_STH_LIMB_0F) { + if (limbIndex == STH_LIMB_HEAD) { Matrix_MultVec3f(&focusOffset, &thisx->focus.pos); OPEN_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.h b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.h index 265332ffd..d8ecc9cdb 100644 --- a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.h +++ b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.h @@ -11,8 +11,8 @@ typedef void (*EnSth2ActionFunc)(struct EnSth2*, PlayState*); typedef struct EnSth2 { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[OBJECT_STH_LIMB_MAX]; - /* 0x1E8 */ Vec3s morphTable[OBJECT_STH_LIMB_MAX]; + /* 0x188 */ Vec3s jointTable[STH_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[STH_LIMB_MAX]; /* 0x248 */ s16 unused; /* 0x24A */ u8 objIndex; /* 0x24C */ EnSth2ActionFunc actionFunc; diff --git a/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c b/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c index 36dd9398e..1692e1461 100644 --- a/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c +++ b/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c @@ -6,7 +6,7 @@ #include "z_en_stone_heishi.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_REACT_TO_LENS) #define THIS ((EnStoneheishi*)thisx) @@ -164,7 +164,7 @@ void func_80BC94B0(EnStoneheishi* this) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_41_40)) { // After drinking bottle EnStoneheishi_ChangeAnim(this, EN_STONE_HEISHI_ANIM_CHEER_WITH_SPEAR); this->textIdIndex = 8; - this->actor.flags &= ~ACTOR_FLAG_80; + this->actor.flags &= ~ACTOR_FLAG_REACT_TO_LENS; } else { // Initial configuration EnStoneheishi_ChangeAnim(this, EN_STONE_HEISHI_ANIM_WAVE); if (CHECK_WEEKEVENTREG(WEEKEVENTREG_41_80)) { @@ -186,13 +186,13 @@ void func_80BC9560(EnStoneheishi* this, PlayState* play) { } if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_41_40) && (play->actorCtx.lensMaskSize != 100)) { - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; return; } SkelAnime_Update(&this->skelAnime); - this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_CANT_LOCK_ON; yawDiff = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.world.rot.y)); @@ -229,7 +229,7 @@ void func_80BC9680(EnStoneheishi* this, PlayState* play) { this->textIdSet = true; player->actor.textId = sEnStoneHeishiTextIds[this->textIdIndex]; - func_80151938(play, sEnStoneHeishiTextIds[this->textIdIndex]); + Message_ContinueTextbox(play, sEnStoneHeishiTextIds[this->textIdIndex]); func_80151BB4(play, 0x12); } } @@ -237,10 +237,10 @@ void func_80BC9680(EnStoneheishi* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); if (this->textIdIndex == 2) { - func_80151938(play, 0xFF); + Message_ContinueTextbox(play, 0xFF); EnStoneheishi_SetupCheckGivenItem(this); } else if (this->textIdIndex == 3) { func_80BC94B0(this); @@ -254,7 +254,7 @@ void func_80BC9680(EnStoneheishi* this, PlayState* play) { func_80BC94B0(this); return; } - func_80151938(play, sEnStoneHeishiTextIds[this->textIdIndex]); + Message_ContinueTextbox(play, sEnStoneHeishiTextIds[this->textIdIndex]); } } } @@ -274,7 +274,7 @@ void EnStoneheishi_CheckGivenItem(EnStoneheishi* this, PlayState* play) { if (itemAction > PLAYER_IA_NONE) { this->timer = 40; - func_801477B4(play); + Message_CloseTextbox(play); if ((itemAction == PLAYER_IA_BOTTLE_POTION_RED) || (itemAction == PLAYER_IA_BOTTLE_POTION_BLUE)) { this->playerGivesBluePotion = false; @@ -292,7 +292,7 @@ void EnStoneheishi_CheckGivenItem(EnStoneheishi* this, PlayState* play) { this->actionFunc = func_80BC9680; } } else if (itemAction <= PLAYER_IA_MINUS1) { - func_801477B4(play); + Message_CloseTextbox(play); func_80151BB4(play, 0x12); func_80BC94B0(this); } @@ -314,7 +314,7 @@ void EnStoneheishi_DrinkBottleProcess(EnStoneheishi* this, PlayState* play) { case EN_STONE_DRINK_BOTTLE_INITIAL: if (this->timer == 0) { this->textIdIndex = 4; - func_80151938(play, sEnStoneHeishiTextIds[this->textIdIndex]); + Message_ContinueTextbox(play, sEnStoneHeishiTextIds[this->textIdIndex]); player->actor.textId = sEnStoneHeishiTextIds[this->textIdIndex]; this->drinkBottleState++; } @@ -346,8 +346,8 @@ void EnStoneheishi_DrinkBottleProcess(EnStoneheishi* this, PlayState* play) { if (this->timer != 0) { if ((this->timer < 10) && (this->bottleDisplay != EN_STONE_BOTTLE_EMPTY)) { this->bottleDisplay = EN_STONE_BOTTLE_EMPTY; - Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_NP_DRINK); - Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_BOTTLE); + Actor_PlaySfx(&this->actor, NA_SE_VO_NP_DRINK); + Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_BOTTLE_EMPTY); } } else { this->drinkBottleState++; @@ -366,7 +366,7 @@ void EnStoneheishi_DrinkBottleProcess(EnStoneheishi* this, PlayState* play) { case EN_STONE_DRINK_BOTTLE_STANDING: if (this->endFrame <= currentFrame) { this->textIdIndex = 5; - func_80151938(play, sEnStoneHeishiTextIds[this->textIdIndex]); + Message_ContinueTextbox(play, sEnStoneHeishiTextIds[this->textIdIndex]); player->actor.textId = sEnStoneHeishiTextIds[this->textIdIndex]; EnStoneheishi_ChangeAnim(this, EN_STONE_HEISHI_ANIM_STAND_HAND_ON_HIP); this->action = EN_STONE_ACTION_1; @@ -377,12 +377,12 @@ void EnStoneheishi_DrinkBottleProcess(EnStoneheishi* this, PlayState* play) { } void EnStoneheishi_GiveItemReward(EnStoneheishi* this, PlayState* play) { - func_801477B4(play); + Message_CloseTextbox(play); if (INV_CONTENT(ITEM_MASK_STONE) == ITEM_MASK_STONE) { - Actor_PickUp(&this->actor, play, GI_RUPEE_BLUE, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_BLUE, 300.0f, 300.0f); } else { - Actor_PickUp(&this->actor, play, GI_MASK_STONE, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_MASK_STONE, 300.0f, 300.0f); } this->action = EN_STONE_ACTION_4; @@ -401,9 +401,9 @@ void func_80BC9D28(EnStoneheishi* this, PlayState* play) { func_800B8500(&this->actor, play, 400.0f, 400.0f, PLAYER_IA_MINUS1); this->actionFunc = func_80BC9E50; } else if (INV_CONTENT(ITEM_MASK_STONE) == ITEM_MASK_STONE) { - Actor_PickUp(&this->actor, play, GI_RUPEE_BLUE, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_BLUE, 300.0f, 300.0f); } else { - Actor_PickUp(&this->actor, play, GI_MASK_STONE, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_MASK_STONE, 300.0f, 300.0f); } } @@ -433,7 +433,9 @@ void EnStoneheishi_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); Actor_SetScale(&this->actor, 0.01f); if ((CHECK_WEEKEVENTREG(WEEKEVENTREG_41_40) || (play->actorCtx.lensMaskSize == 100)) && diff --git a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c index c4d56b70a..dd82ef682 100644 --- a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c +++ b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c @@ -18,8 +18,22 @@ void EnStopheishi_Draw(Actor* thisx, PlayState* play); void func_80AE7F34(EnStopheishi* this, PlayState* play); void func_80AE85C4(EnStopheishi* this, PlayState* play); +void func_80AE7E9C(EnStopheishi* this); +void func_80AE854C(EnStopheishi* this, PlayState* play); +void func_80AE795C(EnStopheishi* this, PlayState* play); + +typedef enum { + /* 0 */ SOLDIER_ANIM_LOOK_DOWN, + /* 1 */ SOLDIER_ANIM_COME_UP_HERE, + /* 2 */ SOLDIER_ANIM_STAND_HAND_ON_HIP, + /* 3 */ SOLDIER_ANIM_STAND_LOOK_DOWN, + /* 4 */ SOLDIER_ANIM_4, + /* 5 */ SOLDIER_ANIM_5, + /* 6 */ SOLDIER_ANIM_6, + /* 7 */ SOLDIER_ANIM_STAND_HAND_ON_CHEST, + /* 8 */ SOLDIER_ANIM_MAX, +} SoldierAnimation; -#if 0 ActorInit En_Stop_heishi_InitVars = { ACTOR_EN_STOP_HEISHI, ACTORCAT_NPC, @@ -32,45 +46,540 @@ ActorInit En_Stop_heishi_InitVars = { (ActorFunc)EnStopheishi_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AE88B0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, 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_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 50, 260, 0, { 0, 0, 0 } }, }; -#endif +static u16 sLeaveMessages[] = { + 0x0516, 0x0517, 0x051A, 0x0000, 0x051C, 0x0000, 0x051E, 0x0000, 0x0520, 0x0521, 0x0524, 0x0000, 0x0526, 0x0000, + 0x0528, 0x0000, 0x052A, 0x052B, 0x052E, 0x0000, 0x0530, 0x0000, 0x0532, 0x0000, 0x0534, 0x0535, 0x0538, 0x0000, + 0x053A, 0x0000, 0x053C, 0x0000, 0x0518, 0x0519, 0x051B, 0x0000, 0x051D, 0x0000, 0x051F, 0x0000, 0x0522, 0x0523, + 0x0525, 0x0000, 0x0527, 0x0000, 0x0529, 0x0000, 0x052C, 0x052D, 0x052F, 0x0000, 0x0531, 0x0000, 0x0533, 0x0000, + 0x0536, 0x0537, 0x0539, 0x0000, 0x053B, 0x0000, 0x053D, 0x0000, 0x0514, 0x0000, 0x0560, 0x0000, 0x0562, 0x0000, + 0x0564, 0x0000, 0x0515, 0x0000, 0x0561, 0x0000, 0x0563, 0x0000, 0x0565, 0x0000, +}; -extern ColliderCylinderInit D_80AE88B0; +static u16 sThirdDayLeaveMessages[] = { + 0x0540, 0x0541, 0x0542, 0x0000, 0x0543, 0x0000, 0x0543, 0x0000, 0x0547, 0x0548, 0x0549, 0x0000, 0x054A, 0x0000, + 0x054B, 0x0000, 0x054F, 0x0550, 0x0551, 0x0000, 0x0552, 0x0000, 0x0553, 0x0000, 0x0557, 0x0558, 0x0559, 0x0000, + 0x055A, 0x0000, 0x055A, 0x0000, 0x0544, 0x0545, 0x0546, 0x0000, 0x0546, 0x0000, 0x0546, 0x0000, 0x054C, 0x054D, + 0x054E, 0x0000, 0x054E, 0x0000, 0x054E, 0x0000, 0x0554, 0x0555, 0x0556, 0x0000, 0x0556, 0x0000, 0x0556, 0x0000, + 0x055B, 0x055C, 0x055D, 0x0000, 0x055D, 0x0000, 0x055D, 0x0000, 0x053E, 0x0000, 0x053E, 0x0000, 0x053E, 0x0000, + 0x053E, 0x0000, 0x053F, 0x0000, 0x053F, 0x0000, 0x053F, 0x0000, 0x053F, 0x0000, +}; -extern UNK_TYPE D_06006C18; +static AnimationHeader* sAnimations[SOLDIER_ANIM_MAX] = { + &gSoldierLookDown, // SOLDIER_ANIM_LOOK_DOWN + &gSoldierComeUpHere, // SOLDIER_ANIM_COME_UP_HERE + &gSoldierStandHandOnHip, // SOLDIER_ANIM_STAND_HAND_ON_HIP + &gSoldierStandAndLookDown, // SOLDIER_ANIM_STAND_LOOK_DOWN + &object_sdn_Anim_0057BC, // SOLDIER_ANIM_4 + &object_sdn_Anim_005D28, // SOLDIER_ANIM_5 + &object_sdn_Anim_0064C0, // SOLDIER_ANIM_6 + &gSoldierStandWithHandOnChest, // SOLDIER_ANIM_STAND_HAND_ON_CHEST +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stop_heishi/EnStopheishi_Init.s") +void EnStopheishi_Init(Actor* thisx, PlayState* play) { + EnStopheishi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stop_heishi/EnStopheishi_Destroy.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gSoldierSkel, &gSoldierStandHandOnHip, this->jointTable, + this->morphTable, SOLDIER_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stop_heishi/func_80AE750C.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->unk_276 = ENSTOPHEISHI_GET_F000(&this->actor); + this->switchFlag = ENSTOPHEISHI_GET_SWITCH_FLAG(&this->actor); + this->unk_288 = (this->actor.world.rot.z * 40.0f) + 50.0f; + this->actor.world.rot.z = 0; + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } + if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) { + Actor_Kill(&this->actor); + return; + } + this->actor.targetMode = 0; + this->actor.gravity = -3.0f; + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->rotYTarget = this->actor.world.rot.y; + this->headTurnTimer2 = 6; + func_80AE7E9C(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stop_heishi/func_80AE75C8.s") +void EnStopheishi_Destroy(Actor* thisx, PlayState* play) { + EnStopheishi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stop_heishi/func_80AE7718.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stop_heishi/func_80AE77D4.s") +void EnStopHeishi_ChangeAnim(EnStopheishi* this, s32 animIndex) { + s32 mode; + f32 morphFrames; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stop_heishi/func_80AE795C.s") + this->currentAnim = animIndex; + this->currentAnimFrameCount = Animation_GetLastFrame(sAnimations[animIndex]); + mode = ANIMMODE_ONCE; + morphFrames = -10.0f; + if ((animIndex >= SOLDIER_ANIM_STAND_HAND_ON_HIP) && (animIndex != SOLDIER_ANIM_4)) { + mode = ANIMMODE_LOOP; + } + if (animIndex == SOLDIER_ANIM_5) { + morphFrames = 0.0f; + } + Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, this->currentAnimFrameCount, mode, + morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stop_heishi/func_80AE7E9C.s") +void EnStopheishi_UpdateHeadNormal(EnStopheishi* this, PlayState* play) { + s32 yawDiff; + Player* player; + Vec3f playerPos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stop_heishi/func_80AE7F34.s") + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.world.rot.y)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stop_heishi/func_80AE854C.s") + this->headRotXTarget = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stop_heishi/func_80AE85C4.s") + if (this->actor.xzDistToPlayer < 200.0f) { + player = GET_PLAYER(play); + if (yawDiff < 0x4E20) { + this->headRotXTarget = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + if (this->headRotXTarget > 0x2710) { + this->headRotXTarget = 0x2710; + } else if (this->headRotXTarget < -0x2710) { + this->headRotXTarget = -0x2710; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stop_heishi/EnStopheishi_Update.s") + Math_Vec3f_Copy(&playerPos, &player->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stop_heishi/func_80AE87A4.s") + if ((player->transformation == PLAYER_FORM_DEKU) || (player->transformation == PLAYER_FORM_HUMAN)) { + playerPos.y += 57.0f + BREG(34); + } else { + playerPos.y += 70.0f + BREG(35); + } + this->pitchToPlayer = Math_Vec3f_Pitch(&this->actor.focus.pos, &playerPos); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stop_heishi/func_80AE87EC.s") +void EnStopHeishi_UpdateHeadThirdDay(EnStopheishi* this) { + if (this->headTurnTimer1 != 0) { + this->headTurnTimer1--; + } + this->pitchToPlayer = -0xBB8; + this->headRotXTarget = 0; + if (this->headTurnTimer2 < 6) { + this->headRotXTarget = 0x1770; + if (((u32)this->headTurnTimer2 % 8) == 0) { + this->headRotXTarget = -0x1770; + } + if (this->headTurnTimer1 == 0) { + this->headTurnTimer2++; + this->headTurnTimer1 = 10; + if (this->headTurnTimer2 >= 6) { + this->headTurnTimer1 = 50; + } + } + } else if ((this->headTurnTimer1 == 0) && (Quake_GetNumActiveQuakes() != 0) && (this->headTurnTimer2 >= 6)) { + this->headTurnTimer2 = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stop_heishi/EnStopheishi_Draw.s") +void func_80AE77D4(EnStopheishi* this) { + this->unk_274 = 0; + this->maxMoveStep = 0.0f; + this->rotYTarget = this->actor.home.rot.y; + if (this->timer == 1) { + this->pitchToPlayer = 0; + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_5); + } + if ((this->timer == 0) && (this->unk_264 == 0)) { + if ((fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 3.0f) || + (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 3.0f)) { + this->skelAnime.playSpeed = 3.0f; + Math_ApproachF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.3f, 5.0f); + Math_ApproachF(&this->actor.world.pos.z, this->actor.home.pos.z, 0.3f, 5.0f); + } else { + this->unk_264 = 1; + } + } + if ((this->currentAnim != SOLDIER_ANIM_STAND_HAND_ON_HIP) && (this->currentAnim != SOLDIER_ANIM_STAND_LOOK_DOWN) && + (this->currentAnim != SOLDIER_ANIM_STAND_HAND_ON_CHEST) && (this->unk_264 != 0)) { + this->skelAnime.playSpeed = 1.0f; + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_STAND_HAND_ON_HIP); + if ((gSaveContext.save.day != 3) && gSaveContext.save.isNight) { + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_STAND_LOOK_DOWN); + } + if (gSaveContext.save.day == 3) { + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_STAND_HAND_ON_CHEST); + } + } +} + +void func_80AE795C(EnStopheishi* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 curFrame = this->skelAnime.curFrame; + Vec3f newPos; + f32 xDiff; + f32 zDiff; + f32 playSpeed; + s16 yaw; + s16 rotY; + + if (ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)) < 0x2000) { + this->rotYTarget = this->actor.yawTowardsPlayer; + } + playSpeed = + fabsf((f32)this->actor.yawTowardsPlayer - Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos)) * + 0.01f * 5.0f; + if (this->unk_274 != 4) { + this->skelAnime.playSpeed = CLAMP(playSpeed, 1.0f, 5.0f); + } + yaw = Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos); + xDiff = fabsf(this->actor.home.pos.x - player->actor.world.pos.x); + zDiff = fabsf(this->actor.home.pos.z - player->actor.world.pos.z); + Math_Vec3f_Copy(&newPos, &this->actor.home.pos); + rotY = this->actor.home.rot.y; + + if (rotY == -0x8000) { + if (yaw > 0) { + xDiff = Math_SinS(this->actor.home.rot.y + 0xC000) * xDiff; + zDiff = Math_CosS(this->actor.home.rot.y + 0xC000) * zDiff; + } else { + xDiff = Math_SinS(this->actor.home.rot.y + 0x4000) * xDiff; + zDiff = Math_CosS(this->actor.home.rot.y + 0x4000) * zDiff; + } + } else if (yaw < rotY) { + xDiff = Math_SinS(this->actor.home.rot.y + 0xC000) * xDiff; + zDiff = Math_CosS(this->actor.home.rot.y + 0xC000) * zDiff; + } else { + xDiff = Math_SinS(this->actor.home.rot.y + 0x4000) * xDiff; + zDiff = Math_CosS(this->actor.home.rot.y + 0x4000) * zDiff; + } + + if (this->unk_288 < xDiff) { + xDiff = this->unk_288; + } else if (xDiff < -this->unk_288) { + xDiff = -this->unk_288; + } + if (this->unk_288 < zDiff) { + zDiff = this->unk_288; + } else if (zDiff < -this->unk_288) { + zDiff = -this->unk_288; + } + newPos.x += xDiff; + newPos.z += zDiff; + Math_ApproachF(&this->actor.world.pos.x, newPos.x, 0.5f, this->maxMoveStep); + Math_ApproachF(&this->actor.world.pos.z, newPos.z, 0.5f, this->maxMoveStep); + Math_ApproachF(&this->maxMoveStep, 50.0f, 0.3f, 1.0f); + + switch (this->unk_274) { + case 0: + if (gSaveContext.save.day != 3) { + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_4); + this->unk_274 = 2; + } else { + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_STAND_HAND_ON_HIP); + this->unk_274 = 1; + } + break; + + case 1: + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_4); + this->unk_274 = 2; + break; + + case 2: + if (this->currentAnimFrameCount <= curFrame) { + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_5); + this->unk_274 = 3; + } + break; + + case 3: + if ((fabsf(this->actor.world.pos.x - newPos.x) < 2.0f) && + (fabsf(this->actor.world.pos.z - newPos.z) < 2.0f)) { + this->skelAnime.playSpeed = 1.0f; + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_6); + this->unk_274 = 4; + } + break; + + case 4: + if ((fabsf(this->actor.world.pos.x - newPos.x) > 4.0f) || + (fabsf(this->actor.world.pos.z - newPos.z) > 4.0f)) { + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_5); + this->unk_274 = 3; + } + break; + } + this->unk_264 = 0; + this->timer = 20; + this->pitchToPlayer = 0; + if (this->unk_276 == 3) { + Math_Vec3f_Copy(&newPos, &player->actor.world.pos); + if ((player->transformation == PLAYER_FORM_DEKU) || (player->transformation == PLAYER_FORM_HUMAN)) { + newPos.y += 77.0f + BREG(37); + this->pitchToPlayer = Math_Vec3f_Pitch(&this->actor.focus.pos, &newPos); + } + } +} + +void func_80AE7E9C(EnStopheishi* this) { + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_STAND_HAND_ON_HIP); + if ((gSaveContext.save.day != 3) && gSaveContext.save.isNight) { + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_STAND_LOOK_DOWN); + } + if (gSaveContext.save.day == 3) { + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_STAND_HAND_ON_CHEST); + } + this->unk_274 = 0; + this->disableCollider = false; + this->actionFunc = func_80AE7F34; + this->actor.speed = 0.0f; +} + +void func_80AE7F34(EnStopheishi* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s16 sp32; + s16 phi_a2; + s32 yawDiffAbs; + s16 yawDiff; + f32 xDiff; + f32 zDiff; + + SkelAnime_Update(&this->skelAnime); + if ((this->currentAnim == SOLDIER_ANIM_5) && (((s16)this->skelAnime.curFrame % 2) != 0)) { + Actor_PlaySfx(&this->actor, NA_SE_EV_SOLDIER_WALK); + } + if (gSaveContext.save.day != 3) { + EnStopheishi_UpdateHeadNormal(this, play); + } else { + EnStopHeishi_UpdateHeadThirdDay(this); + } + Math_SmoothStepToS(&this->actor.world.rot.y, this->rotYTarget, 1, 0x1388, 0); + + sp32 = 0; + if (gSaveContext.save.isNight) { + sp32 = 0x20; + } + + phi_a2 = 0; + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + if ((STOLEN_ITEM_1 == SLOT_SWORD_GREAT_FAIRY) || (STOLEN_ITEM_1 == ITEM_SWORD_KOKIRI) || + (STOLEN_ITEM_1 == ITEM_SWORD_RAZOR) || (STOLEN_ITEM_1 == ITEM_SWORD_GILDED) || + (STOLEN_ITEM_2 == SLOT_SWORD_GREAT_FAIRY) || (STOLEN_ITEM_2 == ITEM_SWORD_KOKIRI) || + (STOLEN_ITEM_2 == ITEM_SWORD_RAZOR) || (STOLEN_ITEM_2 == ITEM_SWORD_GILDED)) { + if (this->unk_265 != 0) { + phi_a2 = 1; + } + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_12_20)) { + phi_a2 = 1; + } + break; + + case PLAYER_FORM_DEKU: + phi_a2 = 4; + break; + + case PLAYER_FORM_ZORA: + phi_a2 = 3; + break; + + case PLAYER_FORM_GORON: + phi_a2 = 2; + break; + } + + if (((phi_a2 == 1) || (phi_a2 == 2) || (phi_a2 == 3)) && + (((this->currentAnim == SOLDIER_ANIM_4)) || (this->currentAnim == SOLDIER_ANIM_5) || + (this->currentAnim == SOLDIER_ANIM_6))) { + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_STAND_HAND_ON_HIP); + if ((gSaveContext.save.day != 3) && gSaveContext.save.isNight) { + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_STAND_LOOK_DOWN); + } + if (gSaveContext.save.day == 3) { + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_STAND_HAND_ON_CHEST); + } + } + + if ((phi_a2 == 0) || (phi_a2 == 4)) { + xDiff = this->actor.home.pos.x - player->actor.world.pos.x; + zDiff = this->actor.home.pos.z - player->actor.world.pos.z; + this->collider.dim.radius = 50; + this->collider.dim.height = 260; + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < 240.0f) { + func_80AE795C(this, play); + } else { + func_80AE77D4(this); + } + } else { + this->collider.dim.radius = 15; + this->collider.dim.height = 60; + } + if (phi_a2 != 4) { + this->messageIndex = this->unk_276 * 8; + this->messageIndex += sp32; + this->messageIndex += phi_a2 * 2; + } else { + this->messageIndex = 64; + if (sp32 != 0) { + this->messageIndex = 72; + } + this->messageIndex += this->unk_276 * 2; + } + if (gSaveContext.save.day != 3) { + this->actor.textId = sLeaveMessages[this->messageIndex]; + this->unk_27E = sLeaveMessages[this->messageIndex + 1]; + } else { + this->actor.textId = sThirdDayLeaveMessages[this->messageIndex]; + this->unk_27E = sThirdDayLeaveMessages[this->messageIndex + 1]; + } + if (this->unk_27E != 0) { + if ((STOLEN_ITEM_1 == ITEM_SWORD_GREAT_FAIRY) || (STOLEN_ITEM_1 == ITEM_SWORD_KOKIRI) || + (STOLEN_ITEM_1 == ITEM_SWORD_RAZOR) || (STOLEN_ITEM_1 == ITEM_SWORD_GILDED) || + (STOLEN_ITEM_2 == ITEM_SWORD_GREAT_FAIRY) || (STOLEN_ITEM_2 == ITEM_SWORD_KOKIRI) || + (STOLEN_ITEM_2 == ITEM_SWORD_RAZOR) || (STOLEN_ITEM_2 == ITEM_SWORD_GILDED)) { + if (this->actor.textId == 0x516) { + this->actor.textId = 0x56C; + } else if (this->actor.textId == 0x520) { + this->actor.textId = 0x56E; + } else if (this->actor.textId == 0x52A) { + this->actor.textId = 0x570; + } else if (this->actor.textId == 0x534) { + this->actor.textId = 0x572; + } else if (this->actor.textId == 0x518) { + this->actor.textId = 0x56D; + } else if (this->actor.textId == 0x522) { + this->actor.textId = 0x56F; + } else if (this->actor.textId == 0x52C) { + this->actor.textId = 0x571; + } else if (this->actor.textId == 0x536) { + this->actor.textId = 0x573; + } + } else if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_NONE) { + if (this->actor.textId == 0x516) { + this->actor.textId = 0x55E; + } else if (this->actor.textId == 0x520) { + this->actor.textId = 0x566; + } else if (this->actor.textId == 0x52A) { + this->actor.textId = 0x568; + } else if (this->actor.textId == 0x534) { + this->actor.textId = 0x56A; + } else if (this->actor.textId == 0x518) { + this->actor.textId = 0x55F; + } else if (this->actor.textId == 0x522) { + this->actor.textId = 0x567; + } else if (this->actor.textId == 0x52C) { + this->actor.textId = 0x569; + } else if (this->actor.textId == 0x536) { + this->actor.textId = 0x56B; + } + } + } + yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + yawDiffAbs = ABS_ALT(yawDiff); + + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->skelAnime.playSpeed = 1.0f; + func_80AE854C(this, play); + } else if (yawDiffAbs < 0x4BB9) { + func_800B8614(&this->actor, play, 70.0f); + } +} + +void func_80AE854C(EnStopheishi* this, PlayState* play) { + if (((this->unk_265 != 0) || (CHECK_WEEKEVENTREG(WEEKEVENTREG_12_20))) && + (this->currentAnim != SOLDIER_ANIM_STAND_HAND_ON_HIP)) { + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_STAND_HAND_ON_HIP); + } + this->pitchToPlayer = 0; + this->unk_274 = 0; + this->disableCollider = true; + this->actionFunc = func_80AE85C4; +} + +void func_80AE85C4(EnStopheishi* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + EnStopheishi_UpdateHeadNormal(this, play); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + if (this->unk_27E != 0) { + this->actor.textId = this->unk_27E; + Message_ContinueTextbox(play, this->actor.textId); + EnStopHeishi_ChangeAnim(this, SOLDIER_ANIM_STAND_HAND_ON_HIP); + SET_WEEKEVENTREG(WEEKEVENTREG_12_20); + this->unk_265 = 1; + this->unk_27E = 0; + } else { + Message_CloseTextbox(play); + func_80AE7E9C(this); + } + } +} + +void EnStopheishi_Update(Actor* thisx, PlayState* play) { + EnStopheishi* this = (EnStopheishi*)thisx; + s32 pad; + + if (this->timer != 0) { + this->timer--; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->headRotX, this->headRotXTarget, 1, 0x7D0, 0); + Math_SmoothStepToS(&this->headRotZ, this->pitchToPlayer, 1, 0x7D0, 0); + this->actionFunc(this, play); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); + Actor_SetScale(&this->actor, 0.01f); + this->actor.uncullZoneForward = 500.0f; + Math_Vec3f_Copy(&this->actor.focus.pos, &this->headWorldPos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + if (!this->disableCollider) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } +} + +s32 EnStopheishi_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnStopheishi* this = THIS; + + if (limbIndex == SOLDIER_LIMB_HEAD) { + rot->x += this->headRotX; + rot->z += this->headRotZ; + } + return false; +} + +void EnStopheishi_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnStopheishi* this = THIS; + + if (limbIndex == SOLDIER_LIMB_HEAD) { + Matrix_MultVec3f(&gZeroVec3f, &this->headWorldPos); + } +} + +void EnStopheishi_Draw(Actor* thisx, PlayState* play) { + EnStopheishi* this = THIS; + + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnStopheishi_OverrideLimbDraw, EnStopheishi_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.h b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.h index 8e27f1c36..651a66496 100644 --- a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.h +++ b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.h @@ -2,16 +2,46 @@ #define Z_EN_STOP_HEISHI_H #include "global.h" +#include "objects/object_sdn/object_sdn.h" struct EnStopheishi; typedef void (*EnStopheishiActionFunc)(struct EnStopheishi*, PlayState*); +#define ENSTOPHEISHI_GET_SWITCH_FLAG(thisx) (((thisx)->params) & 0x3F) +#define ENSTOPHEISHI_GET_F000(thisx) ((((thisx)->params) >> 0xC) & 0xF) + typedef struct EnStopheishi { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x110]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[SOLDIER_LIMB_MAX]; + /* 0x1EE */ Vec3s morphTable[SOLDIER_LIMB_MAX]; /* 0x254 */ EnStopheishiActionFunc actionFunc; - /* 0x258 */ char unk_258[0x90]; + /* 0x258 */ s16 headRotZ; + /* 0x25A */ s16 headRotX; + /* ox25C */ UNK_TYPE1 unk_25C[2]; + /* 0x25E */ s16 pitchToPlayer; + /* 0x260 */ s16 headRotXTarget; + /* 0x262 */ s16 unk_262; // Unused + /* 0x264 */ u8 unk_264; // Locking value at `0` prevents leaving the guard pose, however locking to 1 doesn't prevent guarding. + /* 0x265 */ u8 unk_265; + /* 0x266 */ s16 unk_266; + /* 0x268 */ s32 currentAnim; + /* 0x26C */ f32 currentAnimFrameCount; + /* 0x270 */ s16 timer; + /* 0x272 */ s16 headTurnTimer1; + /* 0x274 */ s16 unk_274; + /* 0x276 */ s16 unk_276; + /* 0x278 */ s16 disableCollider; + /* 0x27A */ s16 switchFlag; + /* 0x27C */ s16 messageIndex; + /* 0x27E */ s16 unk_27E; + /* 0x280 */ s16 rotYTarget; + /* 0x284 */ s32 headTurnTimer2; + /* 0x288 */ f32 unk_288; + /* 0x28C */ f32 maxMoveStep; + /* 0x28C */ Vec3f headWorldPos; + /* 0x29C */ ColliderCylinder collider; } EnStopheishi; // size = 0x2E8 #endif // Z_EN_STOP_HEISHI_H 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 93c93eef9..196b29263 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -205,9 +205,9 @@ void EnSuttari_UpdateCollider(EnSuttari* this, PlayState* play) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); if ((this->flags1 & 1) && (this->actionFunc != func_80BADE14)) { - Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 30.0f, 30.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 30.0f, 30.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } else { - Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 30.0f, 30.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 30.0f, 30.0f, UPDBGCHECKINFO_FLAG_4); } } @@ -230,7 +230,7 @@ void EnSuttari_TriggerTransition(PlayState* play, u16 entrance) { play->transitionTrigger = TRANS_TRIGGER_START; } -void EnSuttari_UpdateTime(void) { +void EnSuttari_AdvanceTime(void) { gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)R_TIME_SPEED; gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.timeSpeedOffset); } @@ -306,60 +306,60 @@ void func_80BAAB78(EnSuttari* this, PlayState* play) { switch (this->textId) { case 0: this->flags1 |= 0x20; - this->cutsceneIdx = 0; + this->csIdIndex = 0; this->textId = 0x29E5; break; case 0x29E5: - ActorCutscene_Stop(this->cutscenes[this->cutsceneIdx]); - this->cutsceneIdx = 1; + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); + this->csIdIndex = 1; this->textId = 0x29E6; break; case 0x29E6: - ActorCutscene_Stop(this->cutscenes[this->cutsceneIdx]); - this->cutsceneIdx = 0; + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); + this->csIdIndex = 0; this->textId = 0x29E7; break; case 0x29E7: - ActorCutscene_Stop(this->cutscenes[this->cutsceneIdx]); - this->cutsceneIdx = 1; + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); + this->csIdIndex = 1; this->textId = 0x29E8; break; case 0x29E8: - ActorCutscene_Stop(this->cutscenes[this->cutsceneIdx]); - this->cutsceneIdx = 0; + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); + this->csIdIndex = 0; this->textId = 0x29E9; break; case 0x29E9: - ActorCutscene_Stop(this->cutscenes[this->cutsceneIdx]); - this->cutsceneIdx = 1; + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); + this->csIdIndex = 1; this->textId = 0x29EA; break; case 0x29EA: - ActorCutscene_Stop(this->cutscenes[this->cutsceneIdx]); - this->cutsceneIdx = 0; + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); + this->csIdIndex = 0; this->textId = 0x29EB; break; case 0x29EB: - ActorCutscene_Stop(this->cutscenes[this->cutsceneIdx]); - this->cutsceneIdx = 1; + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); + this->csIdIndex = 1; this->textId = 0x29EC; break; case 0x29EC: - ActorCutscene_Stop(this->cutscenes[this->cutsceneIdx]); - this->cutsceneIdx = 0; + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); + this->csIdIndex = 0; this->textId = 0x29ED; break; case 0x29ED: - ActorCutscene_Stop(this->cutscenes[this->cutsceneIdx]); + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); this->flags1 |= 0x400; - this->cutsceneIdx = 1; + this->csIdIndex = 1; this->textId = 0x29EE; break; } - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIdx]); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); this->actionFunc = func_80BADD0C; } else if (this->flags1 & 1) { switch (this->textId) { @@ -452,7 +452,7 @@ void func_80BAAFDC(EnSuttari* this, PlayState* play) { if (this->playerDetected == true) { play_sound(NA_SE_SY_FOUND); this->playerDetected = false; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->unk1F4[0] != 0) { this->unk1F4[0]--; } @@ -485,7 +485,7 @@ void func_80BAB1A0(EnSuttari* this, PlayState* play) { if (this->playerDetected == true) { play_sound(NA_SE_SY_FOUND); this->playerDetected = false; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->unk1F4[0] != 0) { this->unk1F4[0]--; } @@ -563,7 +563,7 @@ s16 EnSuttari_GetDistSqAndOrient(Path* path, s32 index, Vec3f* pos, f32* distSq) } *distSq = SQ(diffX) + SQ(diffZ); - return RADF_TO_BINANG(Math_Atan2F_XY(diffZ, diffX)); + return RAD_TO_BINANG(Math_Atan2F_XY(diffZ, diffX)); } s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { @@ -589,7 +589,7 @@ s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { sp54 = sp5C[index + 1].x - sp5C[index - 1].x; sp48 = sp5C[index + 1].z - sp5C[index - 1].z; } - func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(sp54, sp48)), &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RAD_TO_BINANG(func_80086B30(sp54, sp48)), &sp44, &sp40, &sp3C); if (((sp44 * this->actor.world.pos.x) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { ret = true; } @@ -619,7 +619,7 @@ s32 func_80BAB8F4(EnSuttari* this, Path* path, s32 arg2) { sp54 = sp5C[index - 1].x - sp5C[index + 1].x; sp48 = sp5C[index - 1].z - sp5C[index + 1].z; } - func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(sp54, sp48)), &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RAD_TO_BINANG(func_80086B30(sp54, sp48)), &sp44, &sp40, &sp3C); if (((sp44 * this->actor.world.pos.x) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { ret = true; } @@ -632,7 +632,7 @@ void func_80BABA90(EnSuttari* this, s32 arg1, u8 arg2) { if (this->paths[arg1] != NULL) { target = EnSuttari_GetDistSqAndOrient(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &dist); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { if (arg2 == 2) { this->unk1F4[arg1] = -0x63; } else { @@ -661,7 +661,7 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { if (this->paths[arg1] != NULL) { target = EnSuttari_GetDistSqAndOrient(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &sp30); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { target = this->actor.wallYaw; } Math_SmoothStepToS(&this->actor.world.rot.y, target, 1, 0xBB8, 0); @@ -859,8 +859,8 @@ void func_80BAC2FC(EnSuttari* this, PlayState* play) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_83_04) && !(this->flags1 & 0x1000)) { - if (ActorCutscene_GetCanPlayNext(this->cutscenes[0])) { - ActorCutscene_Start(this->cutscenes[0], &this->actor); + if (CutsceneManager_IsNext(this->csIdList[0])) { + CutsceneManager_Start(this->csIdList[0], &this->actor); if (!(player->stateFlags1 & PLAYER_STATE1_10000000)) { this->flags2 |= 0x10; player->stateFlags1 |= PLAYER_STATE1_10000000; @@ -868,7 +868,7 @@ void func_80BAC2FC(EnSuttari* this, PlayState* play) { this->flags1 |= 0x1000; this->flags2 |= 2; } else { - ActorCutscene_SetIntentToPlay(this->cutscenes[0]); + CutsceneManager_Queue(this->csIdList[0]); } } func_80BABFD4(this, play); @@ -969,8 +969,8 @@ void func_80BAC6E8(EnSuttari* this, PlayState* play) { if ((gSaveContext.save.entrance == ENTRANCE(NORTH_CLOCK_TOWN, 7)) || CHECK_WEEKEVENTREG(WEEKEVENTREG_58_40)) { Actor_Kill(&this->actor); } - this->cutscenes[0] = this->actor.cutscene; - this->cutscenes[1] = ActorCutscene_GetAdditionalCutscene(this->cutscenes[0]); + this->csIdList[0] = this->actor.csId; + this->csIdList[1] = CutsceneManager_GetAdditionalCsId(this->csIdList[0]); this->flags1 |= 0x80; this->flags1 |= 8; this->animIndex = 1; @@ -994,8 +994,8 @@ void func_80BAC6E8(EnSuttari* this, PlayState* play) { } this->animIndex = 0; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); - this->cutscenes[0] = this->actor.cutscene; - this->cutscenes[1] = ActorCutscene_GetAdditionalCutscene(this->cutscenes[0]); + this->csIdList[0] = this->actor.csId; + this->csIdList[1] = CutsceneManager_GetAdditionalCsId(this->csIdList[0]); this->flags1 |= 4; this->actionFunc = func_80BAD7F8; return; @@ -1032,7 +1032,7 @@ void func_80BACA14(EnSuttari* this, PlayState* play) { func_800B8614(&this->actor, play, 200.0f); } } - Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 0.1f); + Math_ApproachF(&this->actor.speed, 5.0f, 0.2f, 0.1f); Actor_MoveWithGravity(&this->actor); } @@ -1045,7 +1045,7 @@ void func_80BACBB0(EnSuttari* this, PlayState* play) { this->actionFunc = func_80BACA14; } if ((this->actor.playerHeightRel < 60.0f) && (this->actor.xzDistToPlayer < 500.0f)) { - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { target = this->actor.wallYaw; } else if (func_80BAA904(this, play)) { target = -this->actor.world.rot.y; @@ -1054,13 +1054,13 @@ void func_80BACBB0(EnSuttari* this, PlayState* play) { } Math_SmoothStepToS(&this->actor.world.rot.y, target, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; - Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 0.1f); + Math_ApproachF(&this->actor.speed, 5.0f, 0.2f, 0.1f); } else { this->actionFunc = func_80BACD2C; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } Actor_MoveWithGravity(&this->actor); - if (!(this->actor.bgCheckFlags & 1)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->actor.world.pos = this->actor.prevPos; this->actor.world.rot.y = -this->actor.world.rot.y; this->actionFunc = func_80BACE4C; @@ -1076,13 +1076,13 @@ void func_80BACD2C(EnSuttari* this, PlayState* play) { } if ((this->actor.playerHeightRel < 60.0f) && (this->actor.xzDistToPlayer < 500.0f)) { this->actionFunc = func_80BACBB0; - Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 0.1f); + Math_ApproachF(&this->actor.speed, 5.0f, 0.2f, 0.1f); } else { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; } Actor_MoveWithGravity(&this->actor); - if (!(this->actor.bgCheckFlags & 1)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->actor.world.pos = this->actor.prevPos; this->actor.world.rot.y = -this->actor.world.rot.y; this->actionFunc = func_80BACE4C; @@ -1118,7 +1118,7 @@ void func_80BACEE0(EnSuttari* this, PlayState* play) { if (this->unk428 == 5) { SET_WEEKEVENTREG(WEEKEVENTREG_58_80); this->actionFunc = func_80BADDB4; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else if (Player_GetMask(play) != PLAYER_MASK_STONE) { func_80BAB1A0(this, play); } @@ -1168,26 +1168,26 @@ void func_80BAD130(EnSuttari* this, PlayState* play) { } void func_80BAD230(EnSuttari* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->cutscenes[1])) { - ActorCutscene_Start(this->cutscenes[1], &this->actor); + if (CutsceneManager_IsNext(this->csIdList[1])) { + CutsceneManager_Start(this->csIdList[1], &this->actor); this->textId = 0x2A31; Message_StartTextbox(play, this->textId, &this->actor); this->flags1 |= 0x4000; - Audio_QueueSeqCmd(NA_BGM_CHASE | 0x8000); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_CHASE | SEQ_FLAG_ASYNC); this->actionFunc = func_80BAD380; } else { - ActorCutscene_SetIntentToPlay(this->cutscenes[1]); + CutsceneManager_Queue(this->csIdList[1]); } } void func_80BAD2B4(EnSuttari* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->textId == 0x2A30) { - ActorCutscene_Stop(this->cutscenes[0]); - ActorCutscene_SetIntentToPlay(this->cutscenes[1]); + CutsceneManager_Stop(this->csIdList[0]); + CutsceneManager_Queue(this->csIdList[1]); this->actionFunc = func_80BAD230; } else { - ActorCutscene_Stop(this->cutscenes[1]); + CutsceneManager_Stop(this->csIdList[1]); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; this->flags1 |= 0x40; @@ -1203,7 +1203,7 @@ void func_80BAD380(EnSuttari* this, PlayState* play) { if ((player->stateFlags1 & PLAYER_STATE1_40) && (play->msgCtx.currentTextId != 0x2A31)) { this->flags1 |= 0x8000; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { this->flags1 &= ~0x8000; func_80BABA90(this, 1, 1); @@ -1211,7 +1211,7 @@ void func_80BAD380(EnSuttari* this, PlayState* play) { this->flags2 &= ~0x10; player->stateFlags1 &= ~PLAYER_STATE1_10000000; this->flags1 &= ~0x4000; - ActorCutscene_Stop(this->cutscenes[1]); + CutsceneManager_Stop(this->csIdList[1]); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; this->flags1 |= 0x40; @@ -1222,7 +1222,7 @@ void func_80BAD380(EnSuttari* this, PlayState* play) { } else if (this->flags1 & 0x200) { SET_WEEKEVENTREG(WEEKEVENTREG_79_40); this->flags2 |= 4; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_SMALL_EXPLOSION); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_IT_BOMB_EXPLOSION); @@ -1233,13 +1233,13 @@ void func_80BAD380(EnSuttari* this, PlayState* play) { if (this->flags2 & 8) { SET_WEEKEVENTREG(WEEKEVENTREG_33_08); } - this->actor.speedXZ = 0.0f; - Audio_QueueSeqCmd(0x101400FF); + this->actor.speed = 0.0f; + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20); this->flags2 |= 4; EnSuttari_TriggerTransition(play, ENTRANCE(NORTH_CLOCK_TOWN, 7)); } else { this->unk3F2 = this->headRot.y; - Math_ApproachF(&this->actor.speedXZ, 4.0f, 0.2f, 0.5f); + Math_ApproachF(&this->actor.speed, 4.0f, 0.2f, 0.5f); Actor_MoveWithGravity(&this->actor); func_80BAB374(this, play); } @@ -1346,7 +1346,7 @@ void func_80BADA9C(EnSuttari* this, PlayState* play) { if (Message_ShouldAdvance(play)) { if (this->flags1 & 0x400) { if (this->textId == 0x29EE) { - ActorCutscene_Stop(this->cutscenes[this->cutsceneIdx]); + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); } this->flags1 &= ~0x400; if (this->flags2 & 1) { @@ -1385,16 +1385,16 @@ void func_80BADA9C(EnSuttari* this, PlayState* play) { } void func_80BADD0C(EnSuttari* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->cutscenes[this->cutsceneIdx])) { - if (this->cutsceneIdx == 0) { - ActorCutscene_Start(this->cutscenes[this->cutsceneIdx], &this->enFsn->actor); + if (CutsceneManager_IsNext(this->csIdList[this->csIdIndex])) { + if (this->csIdIndex == 0) { + CutsceneManager_Start(this->csIdList[this->csIdIndex], &this->enFsn->actor); } else { - ActorCutscene_Start(this->cutscenes[this->cutsceneIdx], &this->actor); + CutsceneManager_Start(this->csIdList[this->csIdIndex], &this->actor); } func_80BAAA94(this); this->actionFunc = func_80BADA9C; } else { - ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIdx]); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); } } @@ -1410,10 +1410,10 @@ void func_80BADDB4(EnSuttari* this, PlayState* play) { void func_80BADE14(EnSuttari* this, PlayState* play) { func_80BABA90(this, 1, 2); if (this->unk1F4[1] == -0x63) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { this->unk3F2 = this->headRot.y; - Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); + Math_ApproachF(&this->actor.speed, 6.0f, 0.2f, 0.5f); } Actor_MoveWithGravity(&this->actor); } @@ -1438,7 +1438,7 @@ void func_80BADF3C(EnSuttari* this, PlayState* play) { } this->unk3F2 = this->headRot.y; if (DECR(this->unk3F6) == 0) { - Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); + Math_ApproachF(&this->actor.speed, 6.0f, 0.2f, 0.5f); } Actor_MoveWithGravity(&this->actor); } @@ -1465,7 +1465,7 @@ void EnSuttari_Destroy(Actor* thisx, PlayState* play) { EnSuttari* this = THIS; if ((play->sceneId == SCENE_BACKTOWN) && !(this->flags2 & 4)) { - Audio_QueueSeqCmd(0x101400FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20); } Collider_DestroyCylinder(play, &this->collider); } @@ -1483,16 +1483,16 @@ void EnSuttari_Update(Actor* thisx, PlayState* play) { func_80BAB4F0(this, play); } if (this->flags2 & 2) { - EnSuttari_UpdateTime(); + EnSuttari_AdvanceTime(); } if (this->unk428 != 0) { if (this->animIndex == 2 || this->animIndex == 6) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 16.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_PAMERA_WALK); } } else if (this->animIndex == 0 || this->animIndex == 5) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_PAMERA_WALK); } } } @@ -1562,11 +1562,12 @@ void EnSuttari_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { void EnSuttari_Draw(Actor* thisx, PlayState* play) { EnSuttari* this = THIS; s32 pad; - Vec3f sp5C; - Vec3f sp50; + Vec3f pos; + Vec3f scale; if (this->flags1 & 0x80) { OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(play->state.gfxCtx, 255, 255, 255, 0)); gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(play->state.gfxCtx, 55, 55, 255, 0)); @@ -1576,12 +1577,13 @@ void EnSuttari_Draw(Actor* thisx, PlayState* play) { EnSuttari_TransformLimbDraw, &this->actor); if (this->flags1 & 0x80) { func_8012C2DC(play->state.gfxCtx); - sp5C = this->actor.world.pos; - sp50.x = 0.2f; - sp50.y = 0.2f; - sp50.z = 0.2f; - func_800BC620(&sp5C, &sp50, 0xFF, play); + pos = this->actor.world.pos; + scale.x = 0.2f; + scale.y = 0.2f; + scale.z = 0.2f; + func_800BC620(&pos, &scale, 255, play); } + CLOSE_DISPS(play->state.gfxCtx); } } diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h index 669cf549e..071000763 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -56,8 +56,8 @@ typedef struct EnSuttari { /* 0x444 */ Vec3f unk444; /* 0x450 */ s32 animIndex; /* 0x454 */ UNK_TYPE1 unk_454[0x2]; - /* 0x456 */ s16 cutscenes[2]; - /* 0x45A */ s16 cutsceneIdx; + /* 0x456 */ s16 csIdList[2]; + /* 0x45A */ s16 csIdIndex; } EnSuttari; // size = 0x45C #endif // Z_EN_SUTTARI_H 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 d8dd72923..11e84301b 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -277,7 +277,7 @@ void func_808D90F0(EnSw* this, s32 arg1, s16 arg2) { temp = arg2; } - Matrix_RotateAxisF(BINANG_TO_RAD(temp), &this->unk_368, MTXMODE_NEW); + Matrix_RotateAxisF(BINANG_TO_RAD_ALT(temp), &this->unk_368, MTXMODE_NEW); Matrix_MultVec3f(&this->unk_350, &sp2C); Math_Vec3f_Copy(&this->unk_350, &sp2C); Math3D_CrossProduct(&this->unk_368, &this->unk_350, &this->unk_35C); @@ -352,7 +352,7 @@ s32 func_808D9440(PlayState* play, Vec3f* posA, Vec3f* posB, Vec3f* posResult, C s32 ret = false; if (BgCheck_EntityLineTest1(&play->colCtx, posA, posB, posResult, outPoly, true, true, true, true, bgId) && - !(func_800C9A4C(&play->colCtx, *outPoly, *bgId) & 0x30)) { + !(SurfaceType_GetWallFlags(&play->colCtx, *outPoly, *bgId) & (WALL_FLAG_4 | WALL_FLAG_5))) { ret = true; } return ret; @@ -378,8 +378,8 @@ void func_808D94D0(EnSw* this, PlayState* play, s32 arg2, s32 arg3, s16 arg4) { sp68 = BGCHECK_SCENE; sp64 = BGCHECK_SCENE; func_808D90F0(this, arg3, arg4); - this->actor.speedXZ = this->unk_44C; - temp_f20 = thisx->speedXZ * 2.0f; + this->actor.speed = this->unk_44C; + temp_f20 = thisx->speed * 2.0f; sp90.x = this->actor.world.pos.x + (this->unk_368.x * 2.0f); sp90.y = this->actor.world.pos.y + (this->unk_368.y * 2.0f); @@ -397,7 +397,7 @@ void func_808D94D0(EnSw* this, PlayState* play, s32 arg2, s32 arg3, s16 arg4) { func_808D91C4(this, spA4); Math_Vec3f_Copy(&this->actor.world.pos, &sp78); this->actor.floorBgId = sp64; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { if (spA0 != this->actor.floorPoly) { func_808D91C4(this, spA0); @@ -406,7 +406,7 @@ void func_808D94D0(EnSw* this, PlayState* play, s32 arg2, s32 arg3, s16 arg4) { this->actor.floorBgId = sp68; } } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; temp_f20 *= 3.0f; Math_Vec3f_Copy(&sp90, &sp84); @@ -440,8 +440,8 @@ void func_808D94D0(EnSw* this, PlayState* play, s32 arg2, s32 arg3, s16 arg4) { this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.shape.rot.z = this->actor.world.rot.z; - if (this->actor.speedXZ != 0.0f) { - this->unk_44C = this->actor.speedXZ; + if (this->actor.speed != 0.0f) { + this->unk_44C = this->actor.speed; } if (arg2 == 1) { @@ -504,8 +504,8 @@ s32 func_808D99C8(EnSw* this, PlayState* play) { return false; } - if ((this->actor.xyzDistToPlayerSq < ((sREG(16) * 10) + 60000)) && (play->actorCtx.unk1F5 != 0) && - (play->actorCtx.unk1F4 == 0)) { + if ((this->actor.xyzDistToPlayerSq < ((sREG(16) * 10) + 60000)) && (play->actorCtx.playerImpact.timer != 0) && + (play->actorCtx.playerImpact.type == PLAYER_IMPACT_GORON_GROUND_POUND)) { this->actor.colChkInfo.damage = 4; phi_v1 = true; } @@ -524,9 +524,9 @@ s32 func_808D9A70(EnSw* this, PlayState* play) { } else { if (this->unk_456 != 0) { if (!ENSW_GET_3(&this->actor)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALWALL_ROLL); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALGOLD_ROLL); } this->unk_456--; this->skelAnime.curFrame = 0.0f; @@ -555,15 +555,15 @@ s32 func_808D9C18(EnSw* this) { f32 new_var; if ((this->unk_498 == 0xF9) || (this->unk_498 == 0x82) || (this->unk_498 == 0xE4) || (this->unk_498 == 0xE5)) { - this->actor.velocity.x = this->actor.speedXZ; - this->actor.velocity.z = this->actor.speedXZ; + this->actor.velocity.x = this->actor.speed; + this->actor.velocity.z = this->actor.speed; this->actor.velocity.x *= Math_SinS(this->actor.world.rot.y); this->actor.velocity.z *= Math_CosS(this->actor.world.rot.y); } else { - new_var = this->actor.speedXZ * this->unk_350.x; - this->actor.velocity.x = new_var + (this->actor.speedXZ * this->unk_368.x); - new_var = this->actor.speedXZ * this->unk_350.z; - this->actor.velocity.z = new_var + this->actor.speedXZ * this->unk_368.z; + new_var = this->actor.speed * this->unk_350.x; + this->actor.velocity.x = new_var + (this->actor.speed * this->unk_368.x); + new_var = this->actor.speed * this->unk_350.z; + this->actor.velocity.z = new_var + this->actor.speed * this->unk_368.z; this->actor.velocity.y = 14.0f; Math_Vec3f_Copy(&sp3C, &this->actor.world.pos); Math_Vec3f_Copy(&sp30, &this->actor.world.pos); @@ -575,7 +575,7 @@ s32 func_808D9C18(EnSw* this) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALTURA_APPEAR); if (ENSW_GET_3(&this->actor) == 1) { Actor_SetScale(&this->actor, 0.0f); @@ -635,10 +635,10 @@ void func_808D9F78(EnSw* this, PlayState* play, s32 arg2) { } Actor_SetScale(&this->actor, 0.02f); func_808D9DA0(this); - this->actor.speedXZ = 10.0f; + this->actor.speed = 10.0f; this->unk_44C = 10.0f; func_808D94D0(this, play, 0, 0, 0); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_44C = 0.0f; this->unk_450 = 1.0f; Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); @@ -647,10 +647,10 @@ void func_808D9F78(EnSw* this, PlayState* play, s32 arg2) { void func_808DA024(EnSw* this, PlayState* play) { func_808D9DA0(this); - this->actor.speedXZ = 10.0f; + this->actor.speed = 10.0f; this->unk_44C = 10.0f; func_808D94D0(this, play, 0, 0, 0); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_44C = 0.0f; this->unk_450 = 1.0f; } @@ -717,19 +717,20 @@ s32 func_808DA08C(EnSw* this, PlayState* play) { } this->unk_458 = 20; this->unk_45A = 0; - Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->unk_458); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 200, COLORFILTER_BUFFLAG_OPA, this->unk_458); ret = true; } else if (this->actor.colChkInfo.damageEffect == 1) { if (this->unk_45A == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->unk_45A = 40; - Actor_SetColorFilter(&this->actor, 0, 200, 0, this->unk_45A); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 200, COLORFILTER_BUFFLAG_OPA, + this->unk_45A); } } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTU_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALTU_DAMAGE); this->unk_458 = 20; this->unk_45A = 0; - Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->unk_458); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 200, COLORFILTER_BUFFLAG_OPA, this->unk_458); } } return ret; @@ -739,7 +740,7 @@ void func_808DA350(EnSw* this, PlayState* play) { Player* player = GET_PLAYER(play); if ((player->stateFlags1 & PLAYER_STATE1_200000) && (this->actor.xyzDistToPlayerSq < 8000.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_LAUGH); + Actor_PlaySfx(&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; @@ -764,7 +765,7 @@ void func_808DA3F4(EnSw* this, PlayState* play) { temp_v0 = Math_Atan2S_XY(sp38.z, sp38.x); if (ABS_ALT(temp_v0) < temp_s1) { this->skelAnime.curFrame = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALWALL_DASH); this->unk_414 = 0.0f; if (this->unk_410 & 0x20) { this->actionFunc = func_808DA6FC; @@ -775,7 +776,7 @@ void func_808DA3F4(EnSw* this, PlayState* play) { } temp_s1 *= (temp_v0 < 0) ? -1 : 1; } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALWALL_ROLL); this->skelAnime.curFrame = 0.0f; } func_808D94D0(this, play, 0, 0, temp_s1); @@ -791,7 +792,7 @@ void func_808DA578(EnSw* this, PlayState* play) { temp_f0 = this->skelAnime.endFrame - this->skelAnime.curFrame; this->unk_44C = 0.3f * temp_f0; func_808D94D0(this, play, 1, 0, 0); - if ((this->actor.speedXZ == 0.0f) && (this->unk_44C != 0.0f)) { + if ((this->actor.speed == 0.0f) && (this->unk_44C != 0.0f)) { Math_Vec3f_Copy(&sp30, &this->unk_374); func_808D9894(this, &sp30); temp2 = Math_Atan2S_XY(sp30.z, sp30.x); @@ -801,7 +802,7 @@ void func_808DA578(EnSw* this, PlayState* play) { Math_Vec3f_Copy(&this->unk_374, &this->actor.home.pos); this->actionFunc = func_808DA3F4; } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALWALL_DASH); this->skelAnime.curFrame = 0.0f; } @@ -822,14 +823,14 @@ void func_808DA6FC(EnSw* this, PlayState* play) { temp_f0 = this->skelAnime.endFrame - this->skelAnime.curFrame; this->unk_44C = 0.14f * temp_f0; func_808D94D0(this, play, 1, 0, 0); - if ((this->actor.speedXZ == 0.0f) && (this->unk_44C != 0.0f)) { + if ((this->actor.speed == 0.0f) && (this->unk_44C != 0.0f)) { Math_Vec3f_Copy(&sp38, &this->unk_374); func_808D9894(this, &sp38); temp2 = Math_Atan2S_XY(sp38.z, sp38.x); func_808D94D0(this, play, 0, 0, temp2); } } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALWALL_DASH); this->skelAnime.curFrame = 0.0f; } @@ -873,16 +874,16 @@ void func_808DA89C(EnSw* this, PlayState* play) { } else if (ENSW_GET_3(&this->actor)) { this->actionFunc = func_808DAEB4; } else { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { f32 temp_f2; this->actor.shape.yOffset = 400.0f; temp_f2 = fabsf(this->actor.velocity.y) * 0.6f; this->actor.velocity.y = temp_f2; this->unk_448 = temp_f2; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if ((s32)temp_f2 != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALTURA_BOUND); } else { this->actionFunc = func_808DAEB4; this->actor.velocity.y = 0.0f; @@ -895,7 +896,7 @@ void func_808DA89C(EnSw* this, PlayState* play) { } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } } @@ -919,7 +920,7 @@ void func_808DAA60(EnSw* this, PlayState* play) { temp_v0 = Math_Atan2S_XY(sp34.z, sp34.x); if (ABS_ALT(temp_v0) < sp40) { this->skelAnime.curFrame = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); + Actor_PlaySfx(&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; @@ -929,7 +930,7 @@ void func_808DAA60(EnSw* this, PlayState* play) { } } else { if (this->unk_456 != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALGOLD_ROLL); this->unk_456--; this->skelAnime.curFrame = 0.0f; } else { @@ -963,7 +964,7 @@ void func_808DACF4(EnSw* this, PlayState* play) { temp = this->skelAnime.endFrame - this->skelAnime.curFrame; this->unk_44C = 0.1f * temp; func_808D94D0(this, play, 1, 0, 0); - if ((this->actor.speedXZ == 0.0f) && (this->unk_44C != 0.0f)) { + if ((this->actor.speed == 0.0f) && (this->unk_44C != 0.0f)) { Math_Vec3f_Copy(&sp38, &this->unk_374); func_808D9894(this, &sp38); @@ -971,7 +972,7 @@ void func_808DACF4(EnSw* this, PlayState* play) { func_808D94D0(this, play, 0, 0, temp_f6); } } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALWALL_DASH); this->skelAnime.curFrame = 0.0f; } @@ -1075,9 +1076,9 @@ void func_808DB100(EnSw* this, PlayState* play) { if ((DECR(this->unk_454) == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (this->unk_456 != 0) { if (!ENSW_GET_3(&this->actor)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALWALL_ROLL); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALGOLD_ROLL); } this->unk_456--; this->skelAnime.curFrame = 0.0f; @@ -1089,21 +1090,21 @@ void func_808DB100(EnSw* this, PlayState* play) { } void func_808DB25C(EnSw* this, PlayState* play) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); func_808D9C18(this); this->actionFunc = func_808DB2E0; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } void func_808DB2E0(EnSw* this, PlayState* play) { f32 temp_f2; - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { func_808D9F78(this, play, 0); temp_f2 = fabsf(this->actor.velocity.y) * 0.6f; this->actor.velocity.x *= 0.5f; @@ -1112,7 +1113,7 @@ void func_808DB2E0(EnSw* this, PlayState* play) { this->actor.velocity.z *= 0.5f; if ((s32)temp_f2 != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALTURA_BOUND); } else { func_800BC154(play, &play->actorCtx, &this->actor, 5); Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); @@ -1129,7 +1130,7 @@ void func_808DB2E0(EnSw* this, PlayState* play) { Actor_SetScale(&this->actor, this->actor.scale.x); this->actor.velocity.y += this->actor.gravity; Actor_UpdatePos(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } void EnSw_Init(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c index 1a2f8b685..abc773637 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c @@ -7,7 +7,7 @@ #include "z_en_syateki_crow.h" #include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnSyatekiCrow*)thisx) @@ -16,8 +16,8 @@ void EnSyatekiCrow_Destroy(Actor* thisx, PlayState* play); void EnSyatekiCrow_Update(Actor* thisx, PlayState* play); void EnSyatekiCrow_Draw(Actor* thisx, PlayState* play); -void EnSyatekiCrow_SetupWaitForSpawn(EnSyatekiCrow* this); -void EnSyatekiCrow_WaitForSpawn(EnSyatekiCrow* this, PlayState* play); +void EnSyatekiCrow_SetupWaitForSignal(EnSyatekiCrow* this); +void EnSyatekiCrow_WaitForSignal(EnSyatekiCrow* this, PlayState* play); void EnSyatekiCrow_SetupWaitToMove(EnSyatekiCrow* this); void EnSyatekiCrow_WaitToMove(EnSyatekiCrow* this, PlayState* play); void EnSyatekiCrow_Fly(EnSyatekiCrow* this, PlayState* play); @@ -105,7 +105,7 @@ void EnSyatekiCrow_Init(Actor* thisx, PlayState* play2) { this->maxPointIndex = path->count; this->deathTimer = 20; this->waitTimer = 0; - EnSyatekiCrow_SetupWaitForSpawn(this); + EnSyatekiCrow_SetupWaitForSignal(this); } void EnSyatekiCrow_Destroy(Actor* thisx, PlayState* play) { @@ -114,22 +114,22 @@ void EnSyatekiCrow_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyJntSph(play, &this->collider); } -void EnSyatekiCrow_SetupWaitForSpawn(EnSyatekiCrow* this) { +void EnSyatekiCrow_SetupWaitForSignal(EnSyatekiCrow* this) { Actor_SetScale(&this->actor, 0.03f); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.gravity = 0.0f; this->actor.world = this->actor.home; this->actor.prevPos = this->actor.home.pos; this->actor.shape.rot = this->actor.world.rot; this->currentPointIndex = 1; this->actor.draw = NULL; - this->actionFunc = EnSyatekiCrow_WaitForSpawn; + this->actionFunc = EnSyatekiCrow_WaitForSignal; } /** - * Waits until the shooting gallery man sets the appropriate Guay flag to spawn. + * Waits until the shooting gallery man sets the appropriate Guay flag. */ -void EnSyatekiCrow_WaitForSpawn(EnSyatekiCrow* this, PlayState* play) { +void EnSyatekiCrow_WaitForSignal(EnSyatekiCrow* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->isActive == true) && @@ -144,6 +144,10 @@ void EnSyatekiCrow_WaitForSpawn(EnSyatekiCrow* this, PlayState* play) { } } +/** + * Positions the Guay at the start of its assigned path and rotates it to face the + * next point on the path, then sets it up to start waiting. + */ void EnSyatekiCrow_SetupWaitToMove(EnSyatekiCrow* this) { Vec3f targetPos; @@ -165,9 +169,9 @@ void EnSyatekiCrow_SetupWaitToMove(EnSyatekiCrow* this) { */ void EnSyatekiCrow_WaitToMove(EnSyatekiCrow* this, PlayState* play) { if (((EN_SYATEKI_CROW_GET_WAIT_MOD(&this->actor) * 20) + 20) < this->waitTimer) { - Actor_PlaySfxAtPos(this->actor.parent, NA_SE_EN_KAICHO_CRY); + Actor_PlaySfx(this->actor.parent, NA_SE_EN_KAICHO_CRY); this->waitTimer = 0; - this->actor.speedXZ = EN_SYATEKI_CROW_GET_SPEED_MOD(&this->actor) + 6.0f; + this->actor.speed = EN_SYATEKI_CROW_GET_SPEED_MOD(&this->actor) + 6.0f; this->actor.gravity = -0.5f; this->actionFunc = EnSyatekiCrow_Fly; } else { @@ -181,7 +185,7 @@ void EnSyatekiCrow_Fly(EnSyatekiCrow* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { - EnSyatekiCrow_SetupWaitForSpawn(this); + EnSyatekiCrow_SetupWaitForSignal(this); return; } @@ -203,13 +207,13 @@ void EnSyatekiCrow_Fly(EnSyatekiCrow* this, PlayState* play) { } else { this->isActive = false; syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_INDEX(&this->actor)); - EnSyatekiCrow_SetupWaitForSpawn(this); + EnSyatekiCrow_SetupWaitForSignal(this); } SkelAnime_Update(&this->skelAnime); this->actor.shape.yOffset = (fabsf(this->skelAnime.curFrame - 3.0f) * 150.0f) + 1700.0f; if ((syatekiMan->perGameVar1.guaySpawnTimer % 90) == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_KAICHO_CRY); } } @@ -218,19 +222,19 @@ void EnSyatekiCrow_SetupDead(EnSyatekiCrow* this) { syatekiMan->score += 60; this->isActive = false; - this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); + this->actor.speed *= Math_CosS(this->actor.world.rot.x); this->actor.velocity.y = 0.0f; Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); - this->actor.bgCheckFlags &= ~1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; + Actor_PlaySfx(&this->actor, NA_SE_EN_KAICHO_DEAD); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 40); this->actionFunc = EnSyatekiCrow_Dead; } void EnSyatekiCrow_Dead(EnSyatekiCrow* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); this->actor.colorFilterTimer = 40; if (this->actor.colorFilterParams & 0x4000) { @@ -242,7 +246,7 @@ void EnSyatekiCrow_Dead(EnSyatekiCrow* this, PlayState* play) { func_800B3030(play, &this->actor.world.pos, &sZeroVec, &sZeroVec, this->actor.scale.x * 10000.0f, 0, 0); syatekiMan->guayHitCounter++; syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_INDEX(&this->actor)); - EnSyatekiCrow_SetupWaitForSpawn(this); + EnSyatekiCrow_SetupWaitForSignal(this); } this->deathTimer++; diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c index 601095cfd..20abd71e4 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnSyatekiDekunuts*)thisx) @@ -17,10 +17,10 @@ void EnSyatekiDekunuts_Destroy(Actor* thisx, PlayState* play); void EnSyatekiDekunuts_Update(Actor* thisx, PlayState* play); void EnSyatekiDekunuts_Draw(Actor* thisx, PlayState* play); -void EnSyatekiDekunuts_SetupWaitForSpawn(EnSyatekiDekunuts* this); -void EnSyatekiDekunuts_WaitForSpawn(EnSyatekiDekunuts* this, PlayState* play); -void EnSyatekiDekunuts_SetupSpawn(EnSyatekiDekunuts* this); -void EnSyatekiDekunuts_Spawn(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupWaitForSignal(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_WaitForSignal(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupWaitToStart(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_WaitToStart(EnSyatekiDekunuts* this, PlayState* play); void EnSyatekiDekunuts_SetupWaitToEmerge(EnSyatekiDekunuts* this); void EnSyatekiDekunuts_WaitToEmerge(EnSyatekiDekunuts* this, PlayState* play); void EnSyatekiDekunuts_SetupEmerge(EnSyatekiDekunuts* this); @@ -152,7 +152,7 @@ void EnSyatekiDekunuts_Init(Actor* thisx, PlayState* play2) { this->timer = 0; this->unk_1DC = 0; this->waitTimer = 0; - EnSyatekiDekunuts_SetupWaitForSpawn(this); + EnSyatekiDekunuts_SetupWaitForSignal(this); } void EnSyatekiDekunuts_Destroy(Actor* thisx, PlayState* play) { @@ -161,10 +161,10 @@ void EnSyatekiDekunuts_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void EnSyatekiDekunuts_SetupWaitForSpawn(EnSyatekiDekunuts* this) { +void EnSyatekiDekunuts_SetupWaitForSignal(EnSyatekiDekunuts* this) { Animation_PlayOnceSetSpeed(&this->skelAnime, &gDekuScrubUpAnim, 0.0f); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world = this->actor.home; this->actor.prevPos = this->actor.home.pos; this->actor.shape.rot = this->actor.world.rot; @@ -176,18 +176,18 @@ void EnSyatekiDekunuts_SetupWaitForSpawn(EnSyatekiDekunuts* this) { this->isAlive = true; } - this->actionFunc = EnSyatekiDekunuts_WaitForSpawn; + this->actionFunc = EnSyatekiDekunuts_WaitForSignal; } /** - * Waits until the shooting gallery man sets the appropriate Deku Scrub flag to spawn. + * Waits until the shooting gallery man sets the appropriate Deku Scrub flag. */ -void EnSyatekiDekunuts_WaitForSpawn(EnSyatekiDekunuts* this, PlayState* play) { +void EnSyatekiDekunuts_WaitForSignal(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->isAlive == true) && (syatekiMan->dekuScrubFlags & (1 << this->index))) { - EnSyatekiDekunuts_SetupSpawn(this); + EnSyatekiDekunuts_SetupWaitToStart(this); } else if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { this->isAlive = true; } @@ -201,7 +201,7 @@ void EnSyatekiDekunuts_WaitForSpawn(EnSyatekiDekunuts* this, PlayState* play) { /** * Positions the Deku Scrub to match up with its flower, then sets it up to start waiting. */ -void EnSyatekiDekunuts_SetupSpawn(EnSyatekiDekunuts* this) { +void EnSyatekiDekunuts_SetupWaitToStart(EnSyatekiDekunuts* this) { Vec3f pos; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; @@ -221,18 +221,18 @@ void EnSyatekiDekunuts_SetupSpawn(EnSyatekiDekunuts* this) { this->headdressType = EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_NORMAL; } - this->actionFunc = EnSyatekiDekunuts_Spawn; + this->actionFunc = EnSyatekiDekunuts_WaitToStart; } /** * Waits 20 frames, then plays a sound and starts the process of making the Deku Scrubs emerge. */ -void EnSyatekiDekunuts_Spawn(EnSyatekiDekunuts* this, PlayState* play) { +void EnSyatekiDekunuts_WaitToStart(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan; if (this->waitTimer > 20) { syatekiMan = (EnSyatekiMan*)this->actor.parent; - Actor_PlaySfxAtPos(&syatekiMan->actor, NA_SE_EN_NUTS_DAMAGE); + Actor_PlaySfx(&syatekiMan->actor, NA_SE_EN_NUTS_DAMAGE); this->waitTimer = 0; EnSyatekiDekunuts_SetupWaitToEmerge(this); } else { @@ -258,7 +258,7 @@ void EnSyatekiDekunuts_WaitToEmerge(EnSyatekiDekunuts* this, PlayState* play) { } void EnSyatekiDekunuts_SetupEmerge(EnSyatekiDekunuts* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_UP); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_UP); this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; @@ -357,7 +357,7 @@ void EnSyatekiDekunuts_SetupGameEnd(EnSyatekiDekunuts* this) { */ void EnSyatekiDekunuts_GameEnd(EnSyatekiDekunuts* this, PlayState* play) { if (this->waitTimer > 20) { - EnSyatekiDekunuts_SetupWaitForSpawn(this); + EnSyatekiDekunuts_SetupWaitForSignal(this); this->waitTimer = 0; } else { this->waitTimer++; @@ -379,7 +379,7 @@ void EnSyatekiDekunuts_SetupDead(EnSyatekiDekunuts* this, PlayState* play) { syatekiMan->dekuScrubHitCounter++; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DAMAGE); this->isAlive = false; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_DAMAGE); this->timer = 160; @@ -394,7 +394,7 @@ void EnSyatekiDekunuts_Dead(EnSyatekiDekunuts* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (this->timer == 160) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_DIE); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_DEAD); this->timer--; } else if (this->timer < 160) { Vec3f pos; @@ -411,7 +411,7 @@ void EnSyatekiDekunuts_Dead(EnSyatekiDekunuts* this, PlayState* play) { syatekiMan->dekuScrubFlags &= ~(1 << this->index); } - EnSyatekiDekunuts_SetupWaitForSpawn(this); + EnSyatekiDekunuts_SetupWaitForSignal(this); } } else if (this->timer < 160) { this->timer--; @@ -424,7 +424,7 @@ void EnSyatekiDekunuts_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); - if ((this->actionFunc != EnSyatekiDekunuts_WaitForSpawn) && (this->timer < this->timeToBurrow) && + if ((this->actionFunc != EnSyatekiDekunuts_WaitForSignal) && (this->timer < this->timeToBurrow) && (this->timer > 10)) { if ((this->collider.base.acFlags & AC_HIT) && (this->isAlive == true)) { if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) == EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { @@ -463,7 +463,7 @@ void EnSyatekiDekunuts_Draw(Actor* thisx, PlayState* play) { Vec3f flowerPos; s32 i; - if (this->actionFunc != EnSyatekiDekunuts_WaitForSpawn) { + if (this->actionFunc != EnSyatekiDekunuts_WaitForSignal) { SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSyatekiDekunuts_OverrideLimbDraw, NULL, &this->actor); } 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 759e97206..01c8e96a5 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 @@ -12,7 +12,7 @@ #include "overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h" #include "overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnSyatekiMan*)thisx) @@ -222,7 +222,7 @@ void EnSyatekiMan_Init(Actor* thisx, PlayState* play) { } void EnSyatekiMan_Destroy(Actor* thisx, PlayState* play) { - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); } /** @@ -327,7 +327,7 @@ void EnSyatekiMan_Swamp_HandleChoice(EnSyatekiMan* this, PlayState* play) { // You don't have a bow! Message_StartTextbox(play, 0xA30, &this->actor); this->prevTextId = 0xA30; - } else if (gSaveContext.save.playerData.rupees < 20) { + } else if (gSaveContext.save.saveInfo.playerData.rupees < 20) { play_sound(NA_SE_SY_ERROR); // You don't have enough rupees! @@ -341,8 +341,8 @@ void EnSyatekiMan_Swamp_HandleChoice(EnSyatekiMan* this, PlayState* play) { } else { func_8019F208(); Rupees_ChangeBy(-20); - SET_WEEKEVENTREG(WEEKEVENTREG_63_01); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + SET_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; this->shootingGameState = SG_GAME_STATE_MOVING_PLAYER; @@ -404,15 +404,15 @@ void EnSyatekiMan_Swamp_HandleNormalMessage(EnSyatekiMan* this, PlayState* play) func_80123F2C(play, 80); this->shootingGameState = SG_GAME_STATE_RUNNING; this->actionFunc = EnSyatekiMan_Swamp_StartGame; - func_801A2BB8(NA_BGM_TIMED_MINI_GAME); + Audio_PlaySubBgm(NA_BGM_TIMED_MINI_GAME); break; case 0xA32: // You have to try harder! - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { - func_801477B4(play); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED)) { + Message_CloseTextbox(play); player->stateFlags1 &= ~PLAYER_STATE1_20; - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); this->actionFunc = EnSyatekiMan_Swamp_Idle; gSaveContext.minigameStatus = MINIGAME_STATUS_END; this->shootingGameState = SG_GAME_STATE_NONE; @@ -469,8 +469,8 @@ void EnSyatekiMan_Swamp_Talk(EnSyatekiMan* this, PlayState* play) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; player->stateFlags1 &= ~PLAYER_STATE1_20; - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); this->actionFunc = EnSyatekiMan_Swamp_Idle; this->shootingGameState = SG_GAME_STATE_NONE; } @@ -627,7 +627,7 @@ void EnSyatekiMan_Town_HandleChoice(EnSyatekiMan* this, PlayState* play) { Message_StartTextbox(play, 0x3FA, &this->actor); this->prevTextId = 0x3FA; } - } else if (gSaveContext.save.playerData.rupees < 20) { + } else if (gSaveContext.save.saveInfo.playerData.rupees < 20) { play_sound(NA_SE_SY_ERROR); if (CURRENT_DAY != 3) { // You don't have a enough rupees! @@ -660,8 +660,8 @@ void EnSyatekiMan_Town_HandleChoice(EnSyatekiMan* this, PlayState* play) { this->prevTextId = 0x3FF; } - SET_WEEKEVENTREG(WEEKEVENTREG_63_01); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + SET_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); } } else { func_8019F230(); @@ -747,8 +747,8 @@ void EnSyatekiMan_Town_HandleNormalMessage(EnSyatekiMan* this, PlayState* play) player->actor.freezeTimer = 0; this->shootingGameState = SG_GAME_STATE_MOVING_PLAYER; player->stateFlags1 |= PLAYER_STATE1_20; - SET_WEEKEVENTREG(WEEKEVENTREG_63_01); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + SET_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); this->actionFunc = EnSyatekiMan_Town_MovePlayerAndSayHighScore; } break; @@ -762,15 +762,15 @@ void EnSyatekiMan_Town_HandleNormalMessage(EnSyatekiMan* this, PlayState* play) Interface_InitMinigame(play); func_80123F2C(play, 0x63); this->shootingGameState = SG_GAME_STATE_RUNNING; - func_801A2BB8(NA_BGM_TIMED_MINI_GAME); + Audio_PlaySubBgm(NA_BGM_TIMED_MINI_GAME); this->actionFunc = EnSyatekiMan_Town_StartGame; break; case 0x401: // You got [score]? Oh, that's too bad... - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { - func_801477B4(play); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED)) { + Message_CloseTextbox(play); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); this->shootingGameState = SG_GAME_STATE_NONE; this->actionFunc = EnSyatekiMan_Town_Idle; } else { @@ -781,10 +781,10 @@ void EnSyatekiMan_Town_HandleNormalMessage(EnSyatekiMan* this, PlayState* play) break; case 0x403: // You got [score]? Too bad... - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { - func_801477B4(play); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED)) { + Message_CloseTextbox(play); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); this->shootingGameState = SG_GAME_STATE_NONE; this->actionFunc = EnSyatekiMan_Town_Idle; } else { @@ -839,8 +839,8 @@ void EnSyatekiMan_Town_Talk(EnSyatekiMan* this, PlayState* play) { case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); player->stateFlags1 &= ~PLAYER_STATE1_20; this->actionFunc = EnSyatekiMan_Town_Idle; this->shootingGameState = SG_GAME_STATE_NONE; @@ -872,13 +872,13 @@ void EnSyatekiMan_Swamp_SetupGiveReward(EnSyatekiMan* this, PlayState* play) { this->actionFunc = EnSyatekiMan_Swamp_GiveReward; } else { if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_10)) { - Actor_PickUp(&this->actor, play, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); } else if (this->score < 2180) { - Actor_PickUp(&this->actor, play, GI_RUPEE_RED, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_RED, 500.0f, 100.0f); } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_32_02)) { - Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); } else { - Actor_PickUp(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); } player->actor.shape.rot.y = -0x8000; @@ -933,14 +933,14 @@ void EnSyatekiMan_Town_SetupGiveReward(EnSyatekiMan* this, PlayState* play) { } else { if (this->prevTextId == 0x407) { if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_20)) { - Actor_PickUp(&this->actor, play, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); } else { - Actor_PickUp(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); } } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_32_04)) { - Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); } else { - Actor_PickUp(&this->actor, play, GI_RUPEE_HUGE, 500.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_HUGE, 500.0f, 100.0f); } player->actor.shape.rot.y = -0x8000; @@ -958,8 +958,8 @@ void EnSyatekiMan_Town_GiveReward(EnSyatekiMan* this, PlayState* play) { player->stateFlags1 &= ~PLAYER_STATE1_20; this->score = 0; this->shootingGameState = SG_GAME_STATE_NONE; - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); this->actionFunc = EnSyatekiMan_SetupIdle; } } else if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { @@ -1012,7 +1012,7 @@ void EnSyatekiMan_Swamp_StartGame(EnSyatekiMan* this, PlayState* play) { this->flagsIndex = 0; this->score = 0; player->stateFlags1 &= ~PLAYER_STATE1_20; - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_FOUND); + Actor_PlaySfx(&this->actor, NA_SE_SY_FOUND); this->dekuScrubFlags = (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1) | (1 << 0); this->guayFlags = 0; this->wolfosFlags = 0; @@ -1036,7 +1036,7 @@ void EnSyatekiMan_Swamp_RunGame(EnSyatekiMan* this, PlayState* play) { // Spawn three guays after the player has killed all Deku Scrubs, or after 140 frames. sHasSpawnedGuaysForThisWave = true; this->perGameVar1.guaySpawnTimer = 0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_FOUND); + Actor_PlaySfx(&this->actor, NA_SE_SY_FOUND); this->guayFlags = sGuayFlagsPerWave[this->flagsIndex]; if (this->flagsIndex == 3) { this->flagsIndex = 0; @@ -1078,7 +1078,7 @@ void EnSyatekiMan_Swamp_RunGame(EnSyatekiMan* this, PlayState* play) { this->currentWave = 0; player->stateFlags1 |= PLAYER_STATE1_20; sHasSpawnedGuaysForThisWave = false; - func_801A2C20(); + Audio_StopSubBgm(); this->actionFunc = EnSyatekiMan_Swamp_EndGame; } else if ((this->currentWave == 4) && (this->wolfosFlags == 0) && (this->perGameVar2.bonusDekuScrubHitCounter == 2)) { @@ -1087,7 +1087,7 @@ void EnSyatekiMan_Swamp_RunGame(EnSyatekiMan* this, PlayState* play) { this->currentWave = 0; player->stateFlags1 |= PLAYER_STATE1_20; sHasSpawnedGuaysForThisWave = false; - func_801A2C20(); + Audio_StopSubBgm(); this->shootingGameState = SG_GAME_STATE_GIVING_BONUS; if (this->score == 2120) { Interface_SetPerfectLetters(play, PERFECT_LETTERS_TYPE_2); @@ -1118,9 +1118,9 @@ void EnSyatekiMan_Swamp_EndGame(EnSyatekiMan* this, PlayState* play) { this->prevTextId = 0xA34; this->shootingGameState = SG_GAME_STATE_ENDED; } else if (this->score >= 2000) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); - CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); this->shootingGameState = SG_GAME_STATE_NONE; gSaveContext.minigameStatus = MINIGAME_STATUS_END; this->actionFunc = EnSyatekiMan_Swamp_Idle; @@ -1168,7 +1168,7 @@ void EnSyatekiMan_Swamp_AddBonusPoints(EnSyatekiMan* this, PlayState* play) { gSaveContext.timerStopTimes[TIMER_ID_MINIGAME_1] += SECONDS_TO_TIMER(1); play->interfaceCtx.minigamePoints += 10; this->score += 10; - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); sBonusTimer = 0; } else { sBonusTimer++; @@ -1342,7 +1342,7 @@ void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { if ((sModFromLosingTime == (timer % 50)) && (this->perGameVar1.octorokState >= SG_OCTO_STATE_INITIAL)) { if (this->flagsIndex < 15) { this->octorokFlags = sOctorokFlagsPerWave[this->flagsIndex++]; - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_FOUND); + Actor_PlaySfx(&this->actor, NA_SE_SY_FOUND); this->perGameVar1.octorokState = SG_OCTO_STATE_SPAWNING; } } @@ -1355,7 +1355,7 @@ void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { player->stateFlags1 |= PLAYER_STATE1_20; sModFromLosingTime = 0; this->actor.draw = EnSyatekiMan_Draw; - func_801A2C20(); + Audio_StopSubBgm(); this->actionFunc = EnSyatekiMan_Town_EndGame; if (this->score == 50) { Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c index 162a6d718..401bc34ff 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c @@ -7,7 +7,7 @@ #include "z_en_syateki_okuta.h" #include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnSyatekiOkuta*)thisx) @@ -195,7 +195,7 @@ void func_80A363B4(EnSyatekiOkuta* this, PlayState* play) { return; } else { func_80A361B0(this, play); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_JUMP); + Actor_PlaySfx(&this->actor, NA_SE_EN_OCTAROCK_JUMP); } } @@ -225,7 +225,7 @@ void func_80A364C0(EnSyatekiOkuta* this) { void func_80A36504(EnSyatekiOkuta* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 4.0f)) { func_80A361B0(this, play); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_LAND); + Actor_PlaySfx(&this->actor, NA_SE_EN_DAIOCTA_LAND); } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_80A362F8(this); } @@ -235,7 +235,7 @@ void func_80A3657C(EnSyatekiOkuta* this) { this->unk_2A4 = 0; this->unk_2AA = 300; if (this->unk_2A6 == 1) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_DEAD1); + Actor_PlaySfx(&this->actor, NA_SE_EN_OCTAROCK_DEAD1); } Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); @@ -261,7 +261,7 @@ void func_80A365EC(EnSyatekiOkuta* this, PlayState* play) { sp84.y = -0.5f; sp84.z = 0.0f; func_80A36148(&sp78, &sp84, -20, play); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_DEAD2); + Actor_PlaySfx(&this->actor, NA_SE_EN_OCTAROCK_DEAD2); } this->unk_2A4++; @@ -369,12 +369,12 @@ void EnSyatekiOkuta_Update(Actor* thisx, PlayState* play) { if (func_80A36A90(this, play)) { syatekiMan = (EnSyatekiMan*)this->actor.parent; if (this->unk_2A6 == 1) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); play->interfaceCtx.minigamePoints++; syatekiMan->score++; syatekiMan->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_RED; } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + Actor_PlaySfx(&this->actor, NA_SE_SY_ERROR); syatekiMan->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_BLUE; } diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c index 20871efb2..8a3a65ed2 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c @@ -7,7 +7,7 @@ #include "z_en_syateki_wf.h" #include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnSyatekiWf*)thisx) @@ -16,19 +16,19 @@ void EnSyatekiWf_Destroy(Actor* thisx, PlayState* play); void EnSyatekiWf_Update(Actor* thisx, PlayState* play2); void EnSyatekiWf_Draw(Actor* thisx, PlayState* play); -void func_80A201CC(EnSyatekiWf* this); -void func_80A20284(EnSyatekiWf* this, PlayState* play); -void func_80A2030C(EnSyatekiWf* this); -void func_80A20320(EnSyatekiWf* this, PlayState* play); -void func_80A20378(EnSyatekiWf* this); -void func_80A203DC(EnSyatekiWf* this, PlayState* play); -void func_80A20670(EnSyatekiWf* this); -void func_80A206DC(EnSyatekiWf* this, PlayState* play); -void func_80A20710(EnSyatekiWf* this); -void func_80A2075C(EnSyatekiWf* this, PlayState* play); -void func_80A2079C(EnSyatekiWf* this); -void func_80A20800(EnSyatekiWf* this, PlayState* play); -void func_80A208F8(EnSyatekiWf* this, PlayState* play); +void EnSyatekiWf_SetupWaitForSignal(EnSyatekiWf* this); +void EnSyatekiWf_WaitForSignal(EnSyatekiWf* this, PlayState* play); +void EnSyatekiWf_SetupWaitToMove(EnSyatekiWf* this); +void EnSyatekiWf_WaitToMove(EnSyatekiWf* this, PlayState* play); +void EnSyatekiWf_SetupRun(EnSyatekiWf* this); +void EnSyatekiWf_Run(EnSyatekiWf* this, PlayState* play); +void EnSyatekiWf_SetupJump(EnSyatekiWf* this); +void EnSyatekiWf_Jump(EnSyatekiWf* this, PlayState* play); +void EnSyatekiWf_SetupLand(EnSyatekiWf* this); +void EnSyatekiWf_Land(EnSyatekiWf* this, PlayState* play); +void EnSyatekiWf_SetupHowl(EnSyatekiWf* this); +void EnSyatekiWf_Howl(EnSyatekiWf* this, PlayState* play); +void EnSyatekiWf_Dead(EnSyatekiWf* this, PlayState* play); static ColliderJntSphElementInit sJntSphElementsInit[1] = { { @@ -40,11 +40,11 @@ static ColliderJntSphElementInit sJntSphElementsInit[1] = { BUMP_ON, OCELEM_ON, }, - { 17, { { 800, 0, 0 }, 25 }, 100 }, + { WOLFOS_NORMAL_LIMB_HEAD, { { 800, 0, 0 }, 25 }, 100 }, }, }; -static ColliderCylinderInit sCylinderInit1 = { +static ColliderCylinderInit sBodyCylinderInit = { { COLTYPE_HIT5, AT_NONE, @@ -77,7 +77,7 @@ static ColliderJntSphInit sJntSphInit = { sJntSphElementsInit, }; -static ColliderCylinderInit sCylinderInit2 = { +static ColliderCylinderInit sTailCylinderInit = { { COLTYPE_HIT5, AT_NONE, @@ -97,9 +97,9 @@ static ColliderCylinderInit sCylinderInit2 = { { 15, 20, -15, { 0, 0, 0 } }, }; -static Vec3f D_80A20EDC = { 0.0f, 20.0f, 0.0f }; +static Vec3f sVelocity = { 0.0f, 20.0f, 0.0f }; -static Vec3f D_80A20EE8 = { 0.0f, 0.0f, 0.0f }; +static Vec3f sAccel = { 0.0f, 0.0f, 0.0f }; ActorInit En_Syateki_Wf_InitVars = { ACTOR_EN_SYATEKI_WF, @@ -113,14 +113,24 @@ ActorInit En_Syateki_Wf_InitVars = { (ActorFunc)EnSyatekiWf_Draw, }; +typedef enum { + /* 0 */ EN_SYATEKI_WF_ANIM_WAIT, // unused + /* 1 */ EN_SYATEKI_WF_ANIM_RUN, + /* 2 */ EN_SYATEKI_WF_ANIM_JUMP, + /* 3 */ EN_SYATEKI_WF_ANIM_LAND, + /* 4 */ EN_SYATEKI_WF_ANIM_BACKFLIP, // unused + /* 5 */ EN_SYATEKI_WF_ANIM_DAMAGED, + /* 6 */ EN_SYATEKI_WF_ANIM_REAR_UP_FALL_OVER, +} EnSyatekiWfAnimation; + static AnimationInfo sAnimationInfo[] = { - { &gWolfosWaitingAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, - { &gWolfosRunningAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &gWolfosRunningAnim, 1.0f, 0.0f, 4.0f, ANIMMODE_ONCE, 1.0f }, - { &gWolfosRunningAnim, 1.0f, 4.0f, 8.0f, ANIMMODE_ONCE, 1.0f }, - { &gWolfosBackflippingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gWolfosWaitAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gWolfosRunAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gWolfosRunAnim, 1.0f, 0.0f, 4.0f, ANIMMODE_ONCE, 1.0f }, + { &gWolfosRunAnim, 1.0f, 4.0f, 8.0f, ANIMMODE_ONCE, 1.0f }, + { &gWolfosBackflipAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, { &gWolfosDamagedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 8.0f }, - { &gWolfosRearingUpFallingOverAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gWolfosRearUpFallOverAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, }; static InitChainEntry sInitChain[] = { @@ -128,17 +138,6 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_STOP), }; -static Vec3f D_80A20FC4 = { 0.0f, 0.5f, 0.0f }; - -static Vec3f D_80A20FD0 = { 1200.0f, 0.0f, 0.0f }; - -static TexturePtr sEyeTextures[] = { - gWolfosNormalEyeOpenTex, - gWolfosNormalEyeHalfTex, - gWolfosNormalEyeNarrowTex, - gWolfosNormalEyeHalfTex, -}; - void EnSyatekiWf_Init(Actor* thisx, PlayState* play) { s32 pad; EnSyatekiWf* this = THIS; @@ -160,12 +159,12 @@ void EnSyatekiWf_Init(Actor* thisx, PlayState* play) { return; } - this->unk_2A0 = Lib_SegmentedToVirtual(path->points); - this->unk_2A4 = 1; - this->unk_2A6 = path->count; + this->pathPoints = Lib_SegmentedToVirtual(path->points); + this->currentPointIndex = 1; + this->maxPointIndex = path->count; Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_29C = 0; + this->waitTimer = 0; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); this->actor.focus.pos = this->actor.world.pos; this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -175,146 +174,159 @@ void EnSyatekiWf_Init(Actor* thisx, PlayState* play) { this->eyeIndex = 0; this->unk_2AC = 10.0f; - Collider_InitCylinder(play, &this->unk_2B4); - Collider_SetCylinder(play, &this->unk_2B4, &this->actor, &sCylinderInit1); - Collider_InitCylinder(play, &this->unk_300); - Collider_SetCylinder(play, &this->unk_300, &this->actor, &sCylinderInit2); - Collider_InitJntSph(play, &this->unk_34C); - Collider_SetJntSph(play, &this->unk_34C, &this->actor, &sJntSphInit, this->unk_36C); - this->unk_34C.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; + Collider_InitCylinder(play, &this->bodyCollider); + Collider_SetCylinder(play, &this->bodyCollider, &this->actor, &sBodyCylinderInit); + Collider_InitCylinder(play, &this->tailCollider); + Collider_SetCylinder(play, &this->tailCollider, &this->actor, &sTailCylinderInit); + Collider_InitJntSph(play, &this->headCollider); + Collider_SetJntSph(play, &this->headCollider, &this->actor, &sJntSphInit, this->headColliderElements); + this->headCollider.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; - SkelAnime_InitFlex(play, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitingAnim, this->jointTable, - this->morphTable, WOLFOS_NORMAL_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitAnim, this->jointTable, this->morphTable, + WOLFOS_NORMAL_LIMB_MAX); Actor_SetScale(&this->actor, 0.01f); this->actor.hintId = TATL_HINT_ID_WOLFOS; - func_80A201CC(this); + EnSyatekiWf_SetupWaitForSignal(this); } void EnSyatekiWf_Destroy(Actor* thisx, PlayState* play) { EnSyatekiWf* this = THIS; - Collider_DestroyCylinder(play, &this->unk_2B4); - Collider_DestroyCylinder(play, &this->unk_300); + Collider_DestroyCylinder(play, &this->bodyCollider); + Collider_DestroyCylinder(play, &this->tailCollider); } -void func_80A200E0(EnSyatekiWf* this) { - Vec3f sp24; - s16 temp; +/** + * Positions the Wolfos at the start of its assigned path and rotates it to face + * the next point on the path. + */ +void EnSyatekiWf_InitPathStart(EnSyatekiWf* this) { + Vec3f targetPos; - this->actor.world.pos.x = this->unk_2A0[0].x; - this->actor.world.pos.y = this->unk_2A0[0].y; - this->actor.world.pos.z = this->unk_2A0[0].z; - sp24.x = this->unk_2A0[this->unk_2A4].x; - sp24.y = this->unk_2A0[this->unk_2A4].y; - sp24.z = this->unk_2A0[this->unk_2A4].z; - temp = Math_Vec3f_Yaw(&this->actor.world.pos, &sp24); - this->actor.shape.rot.y = temp; - this->actor.world.rot.y = temp; + this->actor.world.pos.x = this->pathPoints[0].x; + this->actor.world.pos.y = this->pathPoints[0].y; + this->actor.world.pos.z = this->pathPoints[0].z; + targetPos.x = this->pathPoints[this->currentPointIndex].x; + targetPos.y = this->pathPoints[this->currentPointIndex].y; + targetPos.z = this->pathPoints[this->currentPointIndex].z; + this->actor.world.rot.y = this->actor.shape.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &targetPos); } -void func_80A201CC(EnSyatekiWf* this) { +void EnSyatekiWf_SetupWaitForSignal(EnSyatekiWf* this) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world = this->actor.home; this->actor.prevPos = this->actor.home.pos; this->actor.shape.rot = this->actor.world.rot; this->actor.colChkInfo.health = 2; this->actor.draw = NULL; - this->unk_2A4 = 1; - this->unk_298 = 0; + this->currentPointIndex = 1; + this->isActive = false; syatekiMan->wolfosFlags &= ~(1 << EN_SYATEKI_WF_GET_INDEX(&this->actor)); - this->actionFunc = func_80A20284; + this->actionFunc = EnSyatekiWf_WaitForSignal; } -void func_80A20284(EnSyatekiWf* this, PlayState* play) { +/** + * Waits until the shooting gallery man sets the appropriate Wolfos flag. + */ +void EnSyatekiWf_WaitForSignal(EnSyatekiWf* this, PlayState* play) { EnSyatekiMan* syatekiMan; if (this->actor.parent != NULL) { syatekiMan = (EnSyatekiMan*)this->actor.parent; - if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->unk_298 == 1)) { - func_80A200E0(this); - func_80A2030C(this); + if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->isActive == true)) { + EnSyatekiWf_InitPathStart(this); + EnSyatekiWf_SetupWaitToMove(this); } else if (syatekiMan->wolfosFlags & (1 << EN_SYATEKI_WF_GET_INDEX(&this->actor))) { - this->unk_298 = 1; + this->isActive = true; } } } -void func_80A2030C(EnSyatekiWf* this) { - this->actionFunc = func_80A20320; +void EnSyatekiWf_SetupWaitToMove(EnSyatekiWf* this) { + this->actionFunc = EnSyatekiWf_WaitToMove; } -void func_80A20320(EnSyatekiWf* this, PlayState* play) { - if (this->unk_29C >= 11) { - Actor_PlaySfxAtPos(this->actor.parent, NA_SE_EN_WOLFOS_APPEAR); - this->unk_29C = 0; - func_80A20378(this); +/** + * Waits 11 frames, then makes the Wolfos start running forward. + */ +void EnSyatekiWf_WaitToMove(EnSyatekiWf* this, PlayState* play) { + if (this->waitTimer >= 11) { + Actor_PlaySfx(this->actor.parent, NA_SE_EN_WOLFOS_APPEAR); + this->waitTimer = 0; + EnSyatekiWf_SetupRun(this); } else { - this->unk_29C++; + this->waitTimer++; } } -void func_80A20378(EnSyatekiWf* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); - this->actor.speedXZ = 10.0f; +void EnSyatekiWf_SetupRun(EnSyatekiWf* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_WF_ANIM_RUN); + this->actor.speed = 10.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.draw = EnSyatekiWf_Draw; - this->actionFunc = func_80A203DC; + this->actionFunc = EnSyatekiWf_Run; } -void func_80A203DC(EnSyatekiWf* this, PlayState* play) { - Vec3f sp54; - f32 sp50; - s16 temp_v0; +/** + * Runs forward along its assigned path. If the Wolfos encounters a wall directly + * in front of it, this function will make it jump. If the Wolfos reaches a certain + * point along the path (which is specified via its params), this function will make + * it stop running and howl in place. + */ +void EnSyatekiWf_Run(EnSyatekiWf* this, PlayState* play) { + Vec3f targetPoint; + f32 distToTarget; + s16 wallYawDiff; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { - func_80A201CC(this); + EnSyatekiWf_SetupWaitForSignal(this); } - sp54.x = this->unk_2A0[this->unk_2A4].x; - sp54.y = this->unk_2A0[this->unk_2A4].y; - sp54.z = this->unk_2A0[this->unk_2A4].z; - temp_v0 = (this->actor.wallYaw - this->actor.world.rot.y) + 0x8000; + targetPoint.x = this->pathPoints[this->currentPointIndex].x; + targetPoint.y = this->pathPoints[this->currentPointIndex].y; + targetPoint.z = this->pathPoints[this->currentPointIndex].z; + wallYawDiff = (this->actor.wallYaw - this->actor.world.rot.y) + 0x8000; - if (this->actor.bgCheckFlags & 1) { - if (this->actor.bgCheckFlags & 8) { - if ((ABS(temp_v0) < 0x1555) && (this->actor.wallPoly != this->actor.floorPoly)) { - func_80A20670(this); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { + if ((ABS(wallYawDiff) < 0x1555) && (this->actor.wallPoly != this->actor.floorPoly)) { + EnSyatekiWf_SetupJump(this); return; } } - if (this->actor.bgCheckFlags & 4) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_LEAVE) { this->actor.velocity.y = 2.0f; } - sp50 = Math_Vec3f_DistXZ(&this->actor.world.pos, &sp54); - this->unk_2A8 = Math_Vec3f_Yaw(&this->actor.world.pos, &sp54); + distToTarget = Math_Vec3f_DistXZ(&this->actor.world.pos, &targetPoint); + this->yawTarget = Math_Vec3f_Yaw(&this->actor.world.pos, &targetPoint); - if (sp50 > 15.0f) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2A8, 5, 0x3000, 0x100); + if (distToTarget > 15.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->yawTarget, 5, 0x3000, 0x100); this->actor.shape.rot.y = this->actor.world.rot.y; - if (sp50 < 50.0f) { - if (this->actor.speedXZ > 3.0f) { - this->actor.speedXZ = this->actor.speedXZ - 0.5f; + if (distToTarget < 50.0f) { + if (this->actor.speed > 3.0f) { + this->actor.speed = this->actor.speed - 0.5f; } else { - this->actor.speedXZ = this->actor.speedXZ; + this->actor.speed = this->actor.speed; } } } else { - if (this->unk_2A4 < (this->unk_2A6 - 1)) { - if (this->unk_2A4 == EN_SYATEKI_WF_GET_PARAM_F0(&this->actor)) { - func_80A2079C(this); + if (this->currentPointIndex < (this->maxPointIndex - 1)) { + if (this->currentPointIndex == EN_SYATEKI_WF_GET_POINT_TO_HOWL(&this->actor)) { + EnSyatekiWf_SetupHowl(this); } - this->unk_2A4++; + this->currentPointIndex++; } else { - this->unk_298 = 0; - this->unk_2A4 = 1; - func_80A201CC(this); + this->isActive = false; + this->currentPointIndex = 1; + EnSyatekiWf_SetupWaitForSignal(this); } } @@ -324,76 +336,82 @@ void func_80A203DC(EnSyatekiWf* this, PlayState* play) { } } -void func_80A20670(EnSyatekiWf* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); +void EnSyatekiWf_SetupJump(EnSyatekiWf* this) { + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_JUMP); this->actor.velocity.y = 20.0f; - this->actor.speedXZ = 5.0f; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); - this->actionFunc = func_80A206DC; + this->actor.speed = 5.0f; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_WF_ANIM_JUMP); + this->actionFunc = EnSyatekiWf_Jump; } -void func_80A206DC(EnSyatekiWf* this, PlayState* play) { - if (this->actor.bgCheckFlags & 2) { - func_80A20710(this); +void EnSyatekiWf_Jump(EnSyatekiWf* this, PlayState* play) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + EnSyatekiWf_SetupLand(this); } } -void func_80A20710(EnSyatekiWf* this) { - this->actor.speedXZ = 0.0f; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); - this->actionFunc = func_80A2075C; +void EnSyatekiWf_SetupLand(EnSyatekiWf* this) { + this->actor.speed = 0.0f; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_WF_ANIM_LAND); + this->actionFunc = EnSyatekiWf_Land; } -void func_80A2075C(EnSyatekiWf* this, PlayState* play) { +/** + * Freezes the Wolfos in place until its landing animation is complete, then makes it start running. + */ +void EnSyatekiWf_Land(EnSyatekiWf* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80A20378(this); + EnSyatekiWf_SetupRun(this); } } -void func_80A2079C(EnSyatekiWf* this) { - this->unk_29A = 40; - this->actor.speedXZ = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_APPEAR); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); - this->actionFunc = func_80A20800; +void EnSyatekiWf_SetupHowl(EnSyatekiWf* this) { + this->timer = 40; + this->actor.speed = 0.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_APPEAR); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_WF_ANIM_DAMAGED); + this->actionFunc = EnSyatekiWf_Howl; } -void func_80A20800(EnSyatekiWf* this, PlayState* play) { +/** + * Makes the Wolfos stand completely still until 40 frames after its damaged animation is complete. + */ +void EnSyatekiWf_Howl(EnSyatekiWf* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->unk_29A--; - if (this->unk_29A == 0) { - func_80A20378(this); + this->timer--; + if (this->timer == 0) { + EnSyatekiWf_SetupRun(this); } } } -void func_80A20858(EnSyatekiWf* this, PlayState* play) { +void EnSyatekiWf_SetupDead(EnSyatekiWf* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - this->unk_298 = 0; - this->actor.speedXZ = 0.0f; - EffectSsExtra_Spawn(play, &this->actor.world.pos, &D_80A20EDC, &D_80A20EE8, 5, 2); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_DEAD); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 6); + this->isActive = false; + this->actor.speed = 0.0f; + EffectSsExtra_Spawn(play, &this->actor.world.pos, &sVelocity, &sAccel, 5, 2); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_DEAD); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_WF_ANIM_REAR_UP_FALL_OVER); syatekiMan->score += 100; - this->actionFunc = func_80A208F8; + this->actionFunc = EnSyatekiWf_Dead; } -void func_80A208F8(EnSyatekiWf* this, PlayState* play) { +void EnSyatekiWf_Dead(EnSyatekiWf* this, PlayState* play) { s32 pad; if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80A201CC(this); + EnSyatekiWf_SetupWaitForSignal(this); } else { - Vec3f sp68; - Vec3f sp5C = D_80A20FC4; + Vec3f firePos; + Vec3f sFireVelocityAndAccel = { 0.0f, 0.5f, 0.0f }; s32 i; for (i = (s32)this->skelAnime.animLength - (s32)this->skelAnime.curFrame; i >= 0; i--) { - sp68.x = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.x; - sp68.z = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.z; - sp68.y = randPlusMinusPoint5Scaled(50.0f) + (this->actor.world.pos.y + 20.0f); - func_800B3030(play, &sp68, &sp5C, &sp5C, 0x64, 0, 2); + firePos.x = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.x; + firePos.z = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.z; + firePos.y = randPlusMinusPoint5Scaled(50.0f) + (this->actor.world.pos.y + 20.0f); + func_800B3030(play, &firePos, &sFireVelocityAndAccel, &sFireVelocityAndAccel, 100, 0, 2); } } } @@ -402,41 +420,49 @@ void EnSyatekiWf_Update(Actor* thisx, PlayState* play2) { PlayState* play = play2; EnSyatekiWf* this = THIS; - if (this->actionFunc != func_80A20284) { + if (this->actionFunc != EnSyatekiWf_WaitForSignal) { SkelAnime_Update(&this->skelAnime); } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 60.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 60.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); - if (this->actor.bgCheckFlags & 3) { + if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) { func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); } else { Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x3E8, 0); Math_SmoothStepToS(&this->actor.shape.rot.z, 0, 1, 0x3E8, 0); } - if ((this->unk_2B4.base.acFlags & AC_HIT) || (this->unk_300.base.acFlags & AC_HIT) || - (this->unk_34C.base.acFlags & AC_HIT)) { - this->unk_2B4.base.acFlags &= ~AC_HIT; - this->unk_300.base.acFlags &= ~AC_HIT; - this->unk_34C.base.acFlags &= ~AC_HIT; + if ((this->bodyCollider.base.acFlags & AC_HIT) || (this->tailCollider.base.acFlags & AC_HIT) || + (this->headCollider.base.acFlags & AC_HIT)) { + this->bodyCollider.base.acFlags &= ~AC_HIT; + this->tailCollider.base.acFlags &= ~AC_HIT; + this->headCollider.base.acFlags &= ~AC_HIT; + + // The Wolfos always starts with 2 health, so the subtraction below is guaranteed to kill it; + // the else-block is never reached in practice. If you *could* damage the Wolfos without killing + // it, then the number "30" would appear every time you hit it, and the player's displayed score + // would increase by 30. However, the else-block doesn't increase the shooting gallery man's + // "score" variable, so it would become desynchronized from the displayed score. This could cause + // weird behavior, like not getting a free replay after finishing a game with 2000 or more points. this->actor.colChkInfo.health -= 2; if (this->actor.colChkInfo.health == 0) { Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); - func_80A20858(this, play); + EnSyatekiWf_SetupDead(this, play); } else { play_sound(NA_SE_SY_TRE_BOX_APPEAR); - EffectSsExtra_Spawn(play, &this->actor.world.pos, &D_80A20EDC, &D_80A20EE8, 3, 0); + EffectSsExtra_Spawn(play, &this->actor.world.pos, &sVelocity, &sAccel, 3, 0); } } - Collider_UpdateCylinder(&this->actor, &this->unk_2B4); - if ((this->actionFunc != func_80A20284) && (this->actionFunc != func_80A208F8) && (this->actor.draw != NULL)) { - CollisionCheck_SetAC(play, &play->colChkCtx, &this->unk_300.base); - CollisionCheck_SetAC(play, &play->colChkCtx, &this->unk_2B4.base); - CollisionCheck_SetAC(play, &play->colChkCtx, &this->unk_34C.base); + Collider_UpdateCylinder(&this->actor, &this->bodyCollider); + if ((this->actionFunc != EnSyatekiWf_WaitForSignal) && (this->actionFunc != EnSyatekiWf_Dead) && + (this->actor.draw != NULL)) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->tailCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->bodyCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->headCollider.base); this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 25.0f; } @@ -455,19 +481,26 @@ s32 EnSyatekiWf_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Ve } void EnSyatekiWf_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f sTailColliderOffset = { 1200.0f, 0.0f, 0.0f }; EnSyatekiWf* this = THIS; - Vec3f sp18; + Vec3f tailColliderPos; - Collider_UpdateSpheres(limbIndex, &this->unk_34C); + Collider_UpdateSpheres(limbIndex, &this->headCollider); if (limbIndex == WOLFOS_NORMAL_LIMB_TAIL) { - Matrix_MultVec3f(&D_80A20FD0, &sp18); - this->unk_300.dim.pos.x = sp18.x; - this->unk_300.dim.pos.y = sp18.y; - this->unk_300.dim.pos.z = sp18.z; + Matrix_MultVec3f(&sTailColliderOffset, &tailColliderPos); + this->tailCollider.dim.pos.x = tailColliderPos.x; + this->tailCollider.dim.pos.y = tailColliderPos.y; + this->tailCollider.dim.pos.z = tailColliderPos.z; } } void EnSyatekiWf_Draw(Actor* thisx, PlayState* play) { + static TexturePtr sEyeTextures[] = { + gWolfosNormalEyeOpenTex, + gWolfosNormalEyeHalfTex, + gWolfosNormalEyeNarrowTex, + gWolfosNormalEyeHalfTex, + }; EnSyatekiWf* this = THIS; OPEN_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h index 56770952f..4a1fb2f72 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h @@ -4,9 +4,9 @@ #include "global.h" #include "objects/object_wf/object_wf.h" -#define EN_SYATEKI_WF_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define EN_SYATEKI_WF_GET_POINT_TO_HOWL(thisx) (((thisx)->params & 0xF0) >> 4) #define EN_SYATEKI_WF_GET_INDEX(thisx) (((thisx)->params & 0xFF00) >> 8) -#define EN_SYATEKI_WF_PARAMS(index, unkF0, unused) (((index << 8) & 0xFF00) | ((unkF0 << 4) & 0xF0) | (unused & 0xF)) +#define EN_SYATEKI_WF_PARAMS(index, pointToHowl, unused) (((index << 8) & 0xFF00) | ((pointToHowl << 4) & 0xF0) | (unused & 0xF)) struct EnSyatekiWf; @@ -19,19 +19,19 @@ typedef struct EnSyatekiWf { /* 0x20C */ Vec3s morphTable[WOLFOS_NORMAL_LIMB_MAX]; /* 0x290 */ UNK_TYPE1 unk_290[0x4]; /* 0x294 */ EnSyatekiWfActionFunc actionFunc; - /* 0x298 */ s16 unk_298; - /* 0x29A */ s16 unk_29A; - /* 0x29C */ s16 unk_29C; - /* 0x2A0 */ Vec3s* unk_2A0; - /* 0x2A4 */ s16 unk_2A4; - /* 0x2A6 */ s16 unk_2A6; - /* 0x2A8 */ s16 unk_2A8; - /* 0x2AC */ f32 unk_2AC; + /* 0x298 */ s16 isActive; + /* 0x29A */ s16 timer; + /* 0x29C */ s16 waitTimer; + /* 0x2A0 */ Vec3s* pathPoints; + /* 0x2A4 */ s16 currentPointIndex; + /* 0x2A6 */ s16 maxPointIndex; + /* 0x2A8 */ s16 yawTarget; + /* 0x2AC */ f32 unk_2AC; // set to 10.0f, but never used /* 0x2B0 */ u8 eyeIndex; - /* 0x2B4 */ ColliderCylinder unk_2B4; - /* 0x300 */ ColliderCylinder unk_300; - /* 0x34C */ ColliderJntSph unk_34C; - /* 0x36C */ ColliderJntSphElement unk_36C[1]; + /* 0x2B4 */ ColliderCylinder bodyCollider; + /* 0x300 */ ColliderCylinder tailCollider; + /* 0x34C */ ColliderJntSph headCollider; + /* 0x36C */ ColliderJntSphElement headColliderElements[1]; /* 0x3AC */ UNK_TYPE1 unk_3AC[0x20]; } EnSyatekiWf; // size = 0x3CC diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index abd7c100c..dfa1e0bb7 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -323,9 +323,9 @@ s32 func_80BE0D60(EnTab* this, PlayState* play) { this->unk_320++; if (this->unk_320 == 1) { - play->setPlayerTalkAnim(play, &gPlayerAnim_link_demo_bikkuri, 2); + play->setPlayerTalkAnim(play, &gPlayerAnim_link_demo_bikkuri, ANIMMODE_ONCE); } else if (this->unk_320 > 20) { - play->setPlayerTalkAnim(play, NULL, 0); + play->setPlayerTalkAnim(play, NULL, ANIMMODE_LOOP); this->unk_320 = 0; ret = true; } @@ -553,7 +553,7 @@ void EnTab_Update(Actor* thisx, PlayState* play) { func_8013C964(&this->actor, play, radius, height, PLAYER_IA_NONE, this->unk_2FC & 7); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); func_80BE0620(this, play); } } 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 a84059634..11d984fe7 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 @@ -313,7 +313,7 @@ void EnTalkGibud_AttemptPlayerFreeze(EnTalkGibud* this, PlayState* play) { player->actor.freezeTimer = 60; Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(play, &this->actor); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_AIM); EnTalkGibud_SetupWalkToPlayer(this); } @@ -322,7 +322,7 @@ void EnTalkGibud_AttemptPlayerFreeze(EnTalkGibud* this, PlayState* play) { void EnTalkGibud_SetupWalkToPlayer(EnTalkGibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_WALK); - this->actor.speedXZ = 0.4f; + this->actor.speed = 0.4f; if (this->actionFunc == EnTalkGibud_AttemptPlayerFreeze) { this->playerStunWaitTimer = 80; @@ -358,7 +358,7 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, PlayState* play) { this->playerStunWaitTimer = 60; Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(play, &this->actor); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_AIM); } else { this->playerStunWaitTimer--; } @@ -374,9 +374,9 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_RIZA_WALK); } else if (!(play->gameplayFrames & 95)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -409,7 +409,7 @@ void EnTalkGibud_Grab(EnTalkGibud* this, PlayState* play) { damageSfxId = player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S; play->damagePlayer(play, -8); - func_800B8E58(player, damageSfxId); + Player_PlaySfx(player, damageSfxId); Rumble_Request(this->actor.xzDistToPlayer, 240, 1, 12); this->grabDamageTimer = 0; } else { @@ -417,7 +417,7 @@ void EnTalkGibud_Grab(EnTalkGibud* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_ATTACK); } if (!(player->stateFlags2 & PLAYER_STATE2_80) || (player->unk_B62 != 0)) { @@ -447,14 +447,14 @@ void EnTalkGibud_Grab(EnTalkGibud* this, PlayState* play) { void EnTalkGibud_SetupGrabFail(EnTalkGibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_DAMAGE); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); - this->actor.speedXZ = -2.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + this->actor.speed = -2.0f; this->actionFunc = EnTalkGibud_GrabFail; } void EnTalkGibud_GrabFail(EnTalkGibud* this, PlayState* play) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.15f; + if (this->actor.speed < 0.0f) { + this->actor.speed += 0.15f; } this->actor.world.rot.y = this->actor.yawTowardsPlayer; @@ -487,18 +487,18 @@ void EnTalkGibud_TurnAwayAndShakeHead(EnTalkGibud* this, PlayState* play) { void EnTalkGibud_SetupWalkToHome(EnTalkGibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_WALK); - this->actor.speedXZ = 0.4f; + this->actor.speed = 0.4f; this->actionFunc = EnTalkGibud_WalkToHome; } void EnTalkGibud_WalkToHome(EnTalkGibud* this, PlayState* play) { Math_SmoothStepToS(&this->headRotation.y, 0, 1, 100, 0); Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 100, 0); - if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 5.0f) { - if (this->actor.speedXZ > 0.2f) { - this->actor.speedXZ -= 0.2f; + if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) < 5.0f) { + if (this->actor.speed > 0.2f) { + this->actor.speed -= 0.2f; } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 200, 10); @@ -507,7 +507,8 @@ void EnTalkGibud_WalkToHome(EnTalkGibud* this, PlayState* play) { EnTalkGibud_SetupIdle(this); } } else { - Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 450); + Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), + 450); this->actor.world.rot = this->actor.shape.rot; } if (EnTalkGibud_PlayerInRangeWithCorrectState(this, play)) { @@ -520,13 +521,13 @@ void EnTalkGibud_WalkToHome(EnTalkGibud* this, PlayState* play) { void EnTalkGibud_SetupStunned(EnTalkGibud* this) { this->stunTimer = 10; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; if (this->drawDmgEffTimer != 0) { - Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 200, COLORFILTER_BUFFLAG_OPA, 40); } else { - Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 200, COLORFILTER_BUFFLAG_OPA, 40); } this->actionFunc = EnTalkGibud_Stunned; @@ -548,17 +549,17 @@ void EnTalkGibud_Stunned(EnTalkGibud* this, PlayState* play) { void EnTalkGibud_SetupDamage(EnTalkGibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_DAMAGE); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->stunTimer = 0; this->grabWaitTimer = 0; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actor.speedXZ = -2.0f; + this->actor.speed = -2.0f; this->actionFunc = EnTalkGibud_Damage; } void EnTalkGibud_Damage(EnTalkGibud* this, PlayState* play) { - if (this->actor.speedXZ < 0.0f) { - this->actor.speedXZ += 0.15f; + if (this->actor.speed < 0.0f) { + this->actor.speed += 0.15f; } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -585,7 +586,7 @@ void EnTalkGibud_Damage(EnTalkGibud* this, PlayState* play) { void EnTalkGibud_SetupDead(EnTalkGibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_TALK_GIBUD_ANIM_DEATH); this->actor.flags &= ~ACTOR_FLAG_1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_DEAD); this->deathTimer = 0; this->actionFunc = EnTalkGibud_Dead; } @@ -611,7 +612,7 @@ void EnTalkGibud_SetupRevive(EnTalkGibud* this) { Animation_Change(&this->skelAnime, &gGibdoRedeadDeathAnim, -1.0f, Animation_GetLastFrame(&gGibdoRedeadDeathAnim), 0.0f, ANIMMODE_ONCE, -8.0f); this->actor.flags |= ACTOR_FLAG_1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_REVERSE); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_REVERSE); this->deathTimer = 0; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = EnTalkGibud_Revive; @@ -751,7 +752,7 @@ void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, PlayState* play) { default: break; } - func_801477B4(play); + Message_CloseTextbox(play); } else if (this->itemAction <= PLAYER_IA_MINUS1) { Message_StartTextbox(play, 0x1389, &this->actor); this->textId = 0x1389; @@ -776,7 +777,7 @@ void EnTalkGibud_PassiveIdle(EnTalkGibud* this, PlayState* play) { this->isTalking = true; Message_StartTextbox(play, 0x1388, &this->actor); this->textId = 0x1388; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); + Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_AIM); EnTalkGibud_SetupTalk(this); } else if (this->actor.xzDistToPlayer < 100.0f && !(this->collider.base.acFlags & AC_HIT)) { Actor_TrackPlayer(play, &this->actor, &this->headRotation, &this->upperBodyRotation, this->actor.focus.pos); @@ -823,7 +824,7 @@ void EnTalkGibud_Talk(EnTalkGibud* this, PlayState* play) { if (!requestedItem->isBottledItem) { Inventory_ChangeAmmo(requestedItem->item, -requestedItem->amount); } else { - Player_UpdateBottleHeld(play, player, ITEM_BOTTLE, PLAYER_IA_BOTTLE); + Player_UpdateBottleHeld(play, player, ITEM_BOTTLE, PLAYER_IA_BOTTLE_EMPTY); } player->stateFlags1 |= PLAYER_STATE1_20; player->stateFlags1 |= PLAYER_STATE1_20000000; @@ -895,7 +896,7 @@ void EnTalkGibud_FacePlayerWhenTalking(EnTalkGibud* this, PlayState* play) { s32 EnTalkGibud_PlayerInRangeWithCorrectState(EnTalkGibud* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 150.0f) && + if ((Actor_WorldDistXYZToPoint(&player->actor, &this->actor.home.pos) < 150.0f) && !(player->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_40000 | PLAYER_STATE1_80000 | PLAYER_STATE1_200000)) && !(player->stateFlags2 & (PLAYER_STATE2_80 | PLAYER_STATE2_4000))) { @@ -913,7 +914,7 @@ s32 EnTalkGibud_PlayerInRangeWithCorrectState(EnTalkGibud* this, PlayState* play s32 EnTalkGibud_PlayerOutOfRange(EnTalkGibud* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { + if (Actor_WorldDistXYZToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { return true; } @@ -1017,7 +1018,7 @@ void EnTalkGibud_UpdateDamage(EnTalkGibud* this, PlayState* play) { switch (this->actor.colChkInfo.damageEffect) { case EN_TALK_GIBUD_DMGEFF_DAMAGE: - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); if (player->unk_ADC != 0) { this->unk_3F7 = player->unk_ADD; } @@ -1038,7 +1039,7 @@ void EnTalkGibud_UpdateDamage(EnTalkGibud* this, PlayState* play) { break; case EN_TALK_GIBUD_DMGEFF_FIRE_ARROW: - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); if (this->actor.colChkInfo.health == 0) { EnTalkGibud_SetupDead(this); } else { @@ -1050,7 +1051,7 @@ void EnTalkGibud_UpdateDamage(EnTalkGibud* this, PlayState* play) { break; case EN_TALK_GIBUD_DMGEFF_LIGHT_ARROW: - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); if (this->actor.colChkInfo.health == 0) { EnTalkGibud_SetupDead(this); } else { @@ -1110,9 +1111,11 @@ void EnTalkGibud_MoveGrabbedPlayerAwayFromWall(EnTalkGibud* this, PlayState* pla Player* player = GET_PLAYER(play); Vec3f targetPos; - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 35.0f, 29); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 35.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); if (this->actionFunc == EnTalkGibud_Grab && this->grabState == EN_TALK_GIBUD_GRAB_START && - (this->actor.bgCheckFlags & 8)) { + (this->actor.bgCheckFlags & BGCHECKFLAG_WALL)) { targetPos = player->actor.world.pos; targetPos.x += 10.0f * Math_SinS(this->actor.wallYaw); targetPos.z += 10.0f * Math_CosS(this->actor.wallYaw); diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c index 332560403..2d1c29970 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -155,7 +155,7 @@ void EnTanron2_Init(Actor* thisx, PlayState* play) { this->unk_14C = -this->unk_14C; } - Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 60.0f, 60.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 60.0f, 60.0f, UPDBGCHECKINFO_FLAG_4); this->actor.floorHeight += 20.0f; this->unk_148 = Rand_ZeroFloat(32.0f); } @@ -188,7 +188,7 @@ void func_80BB69FC(EnTanron2* this, PlayState* play) { if ((this->unk_158 == 0) && ((sp34 + sp30 + sp2C) < 2.0f)) { this->unk_158 = 1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_EAT); + Actor_PlaySfx(&this->actor, NA_SE_EN_B_SLIME_EAT); } Math_ApproachF(&this->unk_15C, 1.0f, 1.0f, 0.02f); @@ -201,7 +201,7 @@ void func_80BB69FC(EnTanron2* this, PlayState* play) { void func_80BB6B80(EnTanron2* this) { this->actionFunc = func_80BB6BD8; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.z = 0.0f; this->actor.velocity.y = 0.0f; this->actor.velocity.x = 0.0f; @@ -228,7 +228,7 @@ void func_80BB6BD8(EnTanron2* this, PlayState* play) { if (this->actor.world.pos.y <= this->actor.floorHeight) { this->actor.world.pos.y = this->actor.floorHeight; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_JUMP2); + Actor_PlaySfx(&this->actor, NA_SE_EN_IKURA_JUMP2); sp2C = D_80BB8450->unk_6BC.x - this->actor.world.pos.x; sp28 = D_80BB8450->unk_6BC.z - this->actor.world.pos.z; @@ -240,14 +240,14 @@ void func_80BB6BD8(EnTanron2* this, PlayState* play) { } else { sp32 = Math_Atan2S(sp2C, sp28); } - this->actor.speedXZ = Rand_ZeroFloat(5.0f) + 5.0f; + this->actor.speed = Rand_ZeroFloat(5.0f) + 5.0f; break; case 1: sp32 = Math_Atan2S(sp2C, sp28); - this->actor.speedXZ += 2.0f; - if (this->actor.speedXZ > 10.0f) { - this->actor.speedXZ = 10.0f; + this->actor.speed += 2.0f; + if (this->actor.speed > 10.0f) { + this->actor.speed = 10.0f; } break; @@ -255,14 +255,14 @@ void func_80BB6BD8(EnTanron2* this, PlayState* play) { sp32 = Math_Atan2S(player->actor.world.pos.x - this->actor.world.pos.x, player->actor.world.pos.z - this->actor.world.pos.z) + (s16)Rand_ZeroFloat(20000.0f); - this->actor.speedXZ = Rand_ZeroFloat(7.0f) + 7.0f; + this->actor.speed = Rand_ZeroFloat(7.0f) + 7.0f; if ((this->unk_152 == 0) && (D_80BB8450->unk_1F6 == 0)) { this->unk_158 = 1; } break; } Matrix_RotateYS(sp32, MTXMODE_NEW); - Matrix_MultVecZ(this->actor.speedXZ, &this->actor.velocity); + Matrix_MultVecZ(this->actor.speed, &this->actor.velocity); this->actor.velocity.y = Rand_ZeroFloat(5.0f) + 12.0f; this->unk_14E = 5; } @@ -285,7 +285,7 @@ void func_80BB6BD8(EnTanron2* this, PlayState* play) { func_80BB69C0(this); } else { this->unk_150 = 10; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_JUMP1); + Actor_PlaySfx(&this->actor, NA_SE_EN_IKURA_JUMP1); } } } @@ -318,9 +318,9 @@ void func_80BB6F78(EnTanron2* this, PlayState* play) { if (this->actor.world.pos.y <= this->actor.floorHeight) { this->actor.world.pos.y = this->actor.floorHeight; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_JUMP2); + Actor_PlaySfx(&this->actor, NA_SE_EN_IKURA_JUMP2); if (D_80BB8450->unk_6F8 > 0.1f) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER_L); + Actor_PlaySfx(&this->actor, NA_SE_EV_OUT_OF_WATER_L); } this->actor.velocity.y = Rand_ZeroFloat(5.0f) + 12.0f; this->unk_14E = 5; @@ -344,7 +344,7 @@ void func_80BB6F78(EnTanron2* this, PlayState* play) { this->unk_159 = 0; } else { this->unk_150 = 0xA; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_JUMP1); + Actor_PlaySfx(&this->actor, NA_SE_EN_IKURA_JUMP1); } } } @@ -381,7 +381,7 @@ void func_80BB7398(EnTanron2* this, PlayState* play) { Enemy_StartFinishingBlow(play, &this->actor); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_EN_IKURA_DEAD); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_IKURA_DAMAGE); } } @@ -427,7 +427,7 @@ void func_80BB7578(EnTanron2* this, PlayState* play) { if (acHitInfo->toucher.dmgFlags & 0x80) { func_80BB6B80(this); this->unk_158 = 1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_IKURA_DAMAGE); if ((player->targetedActor != NULL) && (&this->actor != player->targetedActor)) { player->targetedActor = &this->actor; play->actorCtx.targetContext.arrowPointedActor = &this->actor; @@ -448,7 +448,7 @@ void func_80BB7578(EnTanron2* this, PlayState* play) { func_80BB7398(this, play); } } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_IKURA_DAMAGE); goto block_18; } } 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 d991ab323..c3d62e166 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c @@ -153,7 +153,7 @@ void EnTanron3_SetupLive(EnTanron3* this, PlayState* play) { this->rotationStep = 0; this->rotationScale = 5; this->workTimer[WORK_TIMER_PICK_NEW_DEVIATION] = 50; - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; this->speedMaxStep = 0.5f; this->deviation.x = randPlusMinusPoint5Scaled(500.0f); this->deviation.y = randPlusMinusPoint5Scaled(100.0f); @@ -180,7 +180,7 @@ void EnTanron3_Live(EnTanron3* this, PlayState* play) { Player* player = GET_PLAYER(play); this->skelAnime.curFrame = 4.0f; - if ((player->actor.bgCheckFlags & 1) && player->actor.shape.feetPos[0].y >= 438.0f) { + if ((player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && player->actor.shape.feetPos[0].y >= 438.0f) { // Player is standing on the central platform, so stop chasing them this->isNonHostile = true; } else if (this->isNonHostile && this->workTimer[WORK_TIMER_WAIT] == 0 && !(this->timer & 0x1F)) { @@ -205,7 +205,7 @@ void EnTanron3_Live(EnTanron3* this, PlayState* play) { Math_Vec3f_Copy(&this->targetPos, &player->actor.world.pos); if (!(this->timer & 0xF)) { if (Rand_ZeroOne() < 0.5f && this->actor.xzDistToPlayer <= 200.0f) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_PIRANHA_ATTACK); } } @@ -219,7 +219,7 @@ void EnTanron3_Live(EnTanron3* this, PlayState* play) { case true: if (sGyorg->unk_324 != 0 && !(this->timer & 0x7)) { this->nextRotationAngle = 0x4E20; - this->actor.speedXZ = 6.0f; + this->actor.speed = 6.0f; } else { this->nextRotationAngle = 0x1F40; } @@ -242,7 +242,7 @@ void EnTanron3_Live(EnTanron3* this, PlayState* play) { } if (this->workTimer[WORK_TIMER_OUT_OF_WATER] == 0) { - if (this->workTimer[WORK_TIMER_PICK_NEW_DEVIATION] == 0 && this->actor.speedXZ > 1.0f) { + if (this->workTimer[WORK_TIMER_PICK_NEW_DEVIATION] == 0 && this->actor.speed > 1.0f) { this->workTimer[WORK_TIMER_PICK_NEW_DEVIATION] = Rand_ZeroFloat(20.0f); this->deviation.x = randPlusMinusPoint5Scaled(100.0f); this->deviation.y = randPlusMinusPoint5Scaled(50.0f + extraScaleY); @@ -265,7 +265,7 @@ void EnTanron3_Live(EnTanron3* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, atanTemp, this->rotationScale, this->rotationStep, 0); Math_ApproachS(&this->rotationStep, this->targetRotationStep, 1, 0x100); - Math_ApproachF(&this->actor.speedXZ, this->targetSpeedXZ, 1.0f, this->speedMaxStep); + Math_ApproachF(&this->actor.speed, this->targetSpeedXZ, 1.0f, this->speedMaxStep); Actor_MoveWithoutGravityReverse(&this->actor); } else { switch (this->isBeached) { @@ -275,13 +275,13 @@ void EnTanron3_Live(EnTanron3* this, PlayState* play) { this->targetPosWithDeviation.y = this->waterSurfaceYPos - 50.0f; this->workTimer[WORK_TIMER_OUT_OF_WATER] = 25; Math_ApproachS(&this->actor.world.rot.x, 0x3000, 5, 0xBD0); - if (this->actor.bgCheckFlags & 8) { - this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { + this->actor.speed = 0.0f; if (this->actor.velocity.y > 0.0f) { this->actor.velocity.y = -1.0f; } } - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { // Fish has touched land this->isBeached = true; } @@ -289,10 +289,10 @@ void EnTanron3_Live(EnTanron3* this, PlayState* play) { case true: this->nextRotationAngle = 0x3A98; this->actor.gravity = -1.5f; - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { // Fish is still touching land, so it's still beached. Randomly flop around this->actor.velocity.y = Rand_ZeroFloat(5.0f) + 5.0f; - this->actor.speedXZ = Rand_ZeroFloat(2.0f) + 2.0f; + this->actor.speed = Rand_ZeroFloat(2.0f) + 2.0f; if (Rand_ZeroOne() < 0.5f) { this->targetShapeRotation.x = (s16)randPlusMinusPoint5Scaled(500.0f) + this->targetShapeRotation.x + 0x8000; @@ -346,8 +346,8 @@ void EnTanron3_SetupDie(EnTanron3* this, PlayState* play) { this->actor.world.rot.x = Math_Atan2S_XY(sqrtf(SQ(xDistance) + SQ(zDistance)), -yDistance); this->actor.world.rot.y = Math_Atan2S_XY(zDistance, xDistance); this->workTimer[WORK_TIMER_DIE] = 6; - this->actor.speedXZ = 10.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_MINI_DEAD); + this->actor.speed = 10.0f; + Actor_PlaySfx(&this->actor, NA_SE_EN_KONB_MINI_DEAD); } void EnTanron3_Die(EnTanron3* this, PlayState* play) { @@ -404,7 +404,7 @@ void EnTanron3_Update(Actor* thisx, PlayState* play) { } this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 20.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 20.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); // The fish has either just entered or just exited the water, so create a splash effect if (((this->actor.prevPos.y < this->waterSurfaceYPos) && (this->waterSurfaceYPos <= this->actor.world.pos.y)) || @@ -413,7 +413,7 @@ void EnTanron3_Update(Actor* thisx, PlayState* play) { splashPos.y = this->waterSurfaceYPos + 10.0f; splashPos.z = this->actor.world.pos.z; EffectSsGSplash_Spawn(play, &splashPos, NULL, NULL, 1, 500); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EV_OUT_OF_WATER); } } @@ -458,7 +458,7 @@ void EnTanron3_Draw(Actor* thisx, PlayState* play) { } SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTanron3_OverrideLimbDraw, NULL, &this->actor); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c index b53343931..1eaf1d128 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c @@ -51,7 +51,7 @@ void EnTanron4_Init(Actor* thisx, PlayState* play2) { OBJECT_TANRON4_LIMB_MAX); thisx->flags &= ~ACTOR_FLAG_1; - thisx->speedXZ = 3.0f + KREG(48); + thisx->speed = 3.0f + KREG(48); thisx->uncullZoneForward = 10000.0f + KREG(70); this->randRollTimer = Rand_ZeroFloat(10.0f); diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c index c052c3309..24d036bee 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -163,7 +163,7 @@ void EnTanron5_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, (Rand_ZeroFloat(0.015f) + 0.01f) * D_80BE5DD0); } - this->actor.speedXZ = (Rand_ZeroFloat(10.0f) + 10.0f) * D_80BE5DD0; + this->actor.speed = (Rand_ZeroFloat(10.0f) + 10.0f) * D_80BE5DD0; this->actor.velocity.y = (Rand_ZeroFloat(10.0f) + 15.0f) * D_80BE5DD0; this->actor.gravity = -2.5f * D_80BE5DD0; this->actor.terminalVelocity = -1000.0f * D_80BE5DD0; @@ -203,7 +203,7 @@ void EnTanron5_Init(Actor* thisx, PlayState* play) { Actor_Kill(&this->actor); } else { - Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 150.0f, 100.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 150.0f, 100.0f, UPDBGCHECKINFO_FLAG_4); this->actor.world.pos.y = this->actor.floorHeight + -20.0f; } } @@ -349,8 +349,8 @@ void EnTanron5_Update(Actor* thisx, PlayState* play2) { } this->actor.shape.rot.y += phi_v0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BIG_BOMB_EXPLOSION); - func_800BC848(&this->actor, play, 4, 4); + Actor_PlaySfx(&this->actor, NA_SE_IT_BIG_BOMB_EXPLOSION); + Actor_RequestQuakeAndRumble(&this->actor, play, 4, 4); this->unk_1A0++; } else { Vec3f sp90; @@ -360,7 +360,7 @@ void EnTanron5_Update(Actor* thisx, PlayState* play2) { sp90.y = info->bumper.hitPos.y; sp90.z = info->bumper.hitPos.z; - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SHIELD_REFLECT_SW); + Actor_PlaySfx(&this->actor, NA_SE_IT_SHIELD_REFLECT_SW); CollisionCheck_SpawnShieldParticlesMetal(play, &sp90); } } @@ -415,9 +415,9 @@ void func_80BE5818(Actor* thisx, PlayState* play2) { Actor_Kill(&this->actor); } - if (this->actor.speedXZ > 0.02f) { + if (this->actor.speed > 0.02f) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 150.0f, 100.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 150.0f, 100.0f, UPDBGCHECKINFO_FLAG_4); } if (ENTANRON5_GET(&this->actor) < ENTANRON5_110) { @@ -425,7 +425,7 @@ void func_80BE5818(Actor* thisx, PlayState* play2) { this->actor.shape.rot.y += this->unk_19A; sp6C = 1225.0f; - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (ENTANRON5_GET(&this->actor) < ENTANRON5_108) { Math_Vec3f_Copy(&sp5C, &this->actor.world.pos); sp5C.y = this->actor.floorHeight; @@ -441,9 +441,9 @@ void func_80BE5818(Actor* thisx, PlayState* play2) { } else { sp6C = 400.0f; this->unk_198 += 0x2000; - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->unk_198 = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } } 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 4faa072f9..875f36a61 100644 --- a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c +++ b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c @@ -91,7 +91,9 @@ void EnTanron6_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 40.0f, 40.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 40.0f, 40.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } void EnTanron6_Draw(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.c b/src/overlays/actors/ovl_En_Test/z_en_test.c index 7f0a3e971..d98790c6f 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -161,18 +161,18 @@ void EnTest_Init(Actor* thisx, PlayState* play2) { PlayState* play = play2; EnTest* this = THIS; MtxF sp38; - s32 sp34; + s32 bgId; this->unk_209 = 0; this->unk_174 = 0; if (thisx->params > 0) { Actor_SetScale(thisx, thisx->params / 100000.0f); - this->unk_20A = 0; + this->surfaceMaterial = SURFACE_MATERIAL_DIRT; } else { thisx->floorPoly = NULL; thisx->world.pos.y += 10.0f; - thisx->floorHeight = BgCheck_EntityRaycastFloor3(&play->colCtx, &thisx->floorPoly, &sp34, &thisx->world.pos); + thisx->floorHeight = BgCheck_EntityRaycastFloor3(&play->colCtx, &thisx->floorPoly, &bgId, &thisx->world.pos); if ((thisx->floorPoly == NULL) || (thisx->floorHeight == BGCHECK_Y_MIN)) { Actor_Kill(thisx); @@ -183,7 +183,7 @@ void EnTest_Init(Actor* thisx, PlayState* play2) { func_800C0094(thisx->floorPoly, thisx->world.pos.x, thisx->floorHeight, thisx->world.pos.z, &sp38); Matrix_MtxFToYXZRot(&sp38, &thisx->shape.rot, true); thisx->world.rot = thisx->shape.rot; - this->unk_20A = func_800C9BB8(&play->colCtx, thisx->floorPoly, sp34); + this->surfaceMaterial = SurfaceType_GetMaterial(&play->colCtx, thisx->floorPoly, bgId); } func_80183430(&this->skeletonInfo, &gameplay_keep_Blob_06EB70, &gameplay_keep_Blob_06BB0C, this->unk_178, @@ -257,7 +257,8 @@ void EnTest_Draw(Actor* thisx, PlayState* play) { sp2C = 29; } - if ((this->unk_20A == 15) || (this->unk_20A == 14)) { + //! @bug Checks for non-existent SURFACE_MATERIAL_MAX material + if ((this->surfaceMaterial == SURFACE_MATERIAL_MAX) || (this->surfaceMaterial == SURFACE_MATERIAL_SNOW)) { AnimatedMat_DrawStep(play, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_06B730), sp2C); } else { AnimatedMat_DrawStep(play, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_06B6A0), sp2C); diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.h b/src/overlays/actors/ovl_En_Test/z_en_test.h index 2b8d62993..68395a96a 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.h +++ b/src/overlays/actors/ovl_En_Test/z_en_test.h @@ -24,7 +24,7 @@ typedef struct EnTest { /* 0x1C0 */ Vec3s unk_1C0[12]; /* 0x208 */ u8 unk_208; /* 0x209 */ u8 unk_209; - /* 0x20A */ u8 unk_20A; + /* 0x20A */ u8 surfaceMaterial; /* 0x20C */ EnTestStruct unk_20C[20]; } EnTest; // size = 0x6BC diff --git a/src/overlays/actors/ovl_En_Test2/z_en_test2.c b/src/overlays/actors/ovl_En_Test2/z_en_test2.c index 257aea283..fd1710264 100644 --- a/src/overlays/actors/ovl_En_Test2/z_en_test2.c +++ b/src/overlays/actors/ovl_En_Test2/z_en_test2.c @@ -12,7 +12,7 @@ #include "objects/object_meganeana_obj/object_meganeana_obj.h" #include "objects/object_haka_obj/object_haka_obj.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_REACT_TO_LENS) #define THIS ((EnTest2*)thisx) @@ -96,7 +96,7 @@ void EnTest2_Update(Actor* thisx, PlayState* play) { Actor_SetObjectDependency(play, &this->actor); this->animMat = Lib_SegmentedToVirtual(modelInfo->animMat); } - if (play->roomCtx.curRoom.unk5) { + if (play->roomCtx.curRoom.lensMode != LENS_MODE_HIDE_ACTORS) { this->actor.update = EnTest2_UpdateForLens; } else { this->actor.update = Actor_Noop; @@ -108,9 +108,9 @@ void EnTest2_UpdateForLens(Actor* thisx, PlayState* play) { EnTest2* this = THIS; if (play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) { - this->actor.flags |= ACTOR_FLAG_80; + this->actor.flags |= ACTOR_FLAG_REACT_TO_LENS; } else { - this->actor.flags &= ~ACTOR_FLAG_80; + this->actor.flags &= ~ACTOR_FLAG_REACT_TO_LENS; } } @@ -122,7 +122,7 @@ void EnTest2_Draw(Actor* thisx, PlayState* play) { if (this->animMat != NULL) { AnimatedMat_Draw(play, this->animMat); } - if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_REACT_TO_LENS)) { OPEN_DISPS(play->state.gfxCtx); func_8012C2DC(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Test3/z_en_test3.c b/src/overlays/actors/ovl_En_Test3/z_en_test3.c index dade95ee3..cedf00861 100644 --- a/src/overlays/actors/ovl_En_Test3/z_en_test3.c +++ b/src/overlays/actors/ovl_En_Test3/z_en_test3.c @@ -4,14 +4,13 @@ * Description: Kafei */ -#include "prevent_bss_reordering.h" #include "z_en_test3.h" #include "objects/object_test3/object_test3.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_mask_ki_tan/object_mask_ki_tan.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000000) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_CAN_PRESS_SWITCH) #define THIS ((EnTest3*)thisx) @@ -316,12 +315,12 @@ s32 func_80A3E898(EnTest3* this, PlayState* play) { func_80151BB4(play, 2); } if (textId == 0xFFFF) { - func_801477B4(play); + Message_CloseTextbox(play); } else if (textId) { // != 0 - func_80151938(play, textId); + Message_ContinueTextbox(play, textId); } if (textId == 0x296B) { - LinkAnimation_PlayOnceSetSpeed(play, &this->player.skelAnime, &gPlayerAnim_al_yareyare, 2.0f / 3.0f); + PlayerAnimation_PlayOnceSetSpeed(play, &this->player.skelAnime, &gPlayerAnim_al_yareyare, 2.0f / 3.0f); } return false; } @@ -340,11 +339,11 @@ s32 func_80A3E97C(EnTest3* this, PlayState* play) { } s32 func_80A3E9DC(EnTest3* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->unk_D8D)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_D8D, &this->player.actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->player.actor); return true; } else { - ActorCutscene_SetIntentToPlay(this->unk_D8D); + CutsceneManager_Queue(this->csId); return false; } } @@ -358,8 +357,8 @@ s32 func_80A3EA30(EnTest3* this, PlayState* play) { } } if (this->unk_D78->unk_1 != 0) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_D8D); + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csId); play->msgCtx.msgMode = 0x44; } return false; @@ -375,9 +374,9 @@ s32 func_80A3EAC4(EnTest3* this, PlayState* play) { s32 func_80A3EAF8(EnTest3* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_D78->textId == 0x145F) { - ActorCutscene_Stop(this->unk_D8D); - this->unk_D8D = 0x7C; - ActorCutscene_SetIntentToPlay(this->unk_D8D); + CutsceneManager_Stop(this->csId); + this->csId = CS_ID_GLOBAL_TALK; + CutsceneManager_Queue(this->csId); this->player.targetedActor = &GET_PLAYER(play)->actor; } return 1; @@ -453,7 +452,7 @@ void EnTest3_Init(Actor* thisx, PlayState* play2) { D_80A41D24 = true; this->player.actor.room = -1; - this->player.unk_A86 = -1; + this->player.csId = CS_ID_NONE; this->player.transformation = PLAYER_FORM_HUMAN; this->player.ageProperties = &sAgeProperties; this->player.heldItemAction = PLAYER_IA_NONE; @@ -479,8 +478,8 @@ void EnTest3_Init(Actor* thisx, PlayState* play2) { if (play->sceneId == SCENE_SECOM) { this->subCamId = Play_CreateSubCamera(play); subCam = Play_GetCamera(play, this->subCamId); - Camera_InitPlayerSettings(subCam, &this->player); - Camera_SetFlags(subCam, CAM_STATE_0 | CAM_STATE_6); + Camera_InitFocalActorSettings(subCam, &this->player.actor); + Camera_SetStateFlag(subCam, CAM_STATE_0 | CAM_STATE_6); Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_WAIT); } @@ -527,8 +526,8 @@ void func_80A3F0B0(EnTest3* this, PlayState* play) { } void func_80A3F114(EnTest3* this, PlayState* play) { - if (this->player.csMode != 0) { - play->startPlayerCutscene(play, &this->player, 6); + if (this->player.csMode != PLAYER_CSMODE_0) { + play->startPlayerCutscene(play, &this->player, PLAYER_CSMODE_END); } } @@ -576,7 +575,7 @@ Actor* func_80A3F2BC(PlayState* play, EnTest3* this, s32 actorId, s32 category, if (actorId == actor->id) { f32 dy = this->player.actor.world.pos.y - actor->world.pos.y; - if ((fabsf(dy) < arg5) && (Actor_XZDistanceBetweenActors(&this->player.actor, actor) < arg4)) { + if ((fabsf(dy) < arg5) && (Actor_WorldDistXZToActor(&this->player.actor, actor) < arg4)) { return actor; } } @@ -597,7 +596,7 @@ s32 func_80A3F384(EnTest3* this, PlayState* play) { this->player.doorType = 1; this->player.doorDirection = (offset.z >= 0.0f) ? 1.0f : -1.0f; this->player.doorActor = &door->dyna.actor; - this->player.unk_A86 = -1; + this->player.csId = CS_ID_NONE; return true; } return false; @@ -617,7 +616,7 @@ void func_80A3F534(EnTest3* this, PlayState* play) { } else { this->unk_D78 = &D_80A41854[1]; } - this->unk_D8D = this->player.actor.cutscene; + this->csId = this->player.actor.csId; } void func_80A3F5A4(EnTest3* this, PlayState* play) { @@ -629,7 +628,7 @@ void func_80A3F5A4(EnTest3* this, PlayState* play) { } else { this->unk_D78 = &D_80A41854[12]; } - this->unk_D8D = this->player.actor.cutscene; + this->csId = this->player.actor.csId; } s32 func_80A3F62C(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput) { @@ -667,8 +666,8 @@ s32 func_80A3F73C(EnTest3* this, PlayState* play) { this->unk_D90->stateFlags1 |= PLAYER_STATE1_20; func_800BC154(play, &play->actorCtx, &this->unk_D90->actor, 4); func_800BC154(play, &play->actorCtx, &this->player.actor, 2); - ActorCutscene_SetReturnCamera(this->subCamId); - play->startPlayerCutscene(play, &this->player, 7); + CutsceneManager_SetReturnCamera(this->subCamId); + play->startPlayerCutscene(play, &this->player, PLAYER_CSMODE_WAIT); } func_800B863C(&this->player.actor, play); if (this->unk_D88 == 3) { @@ -688,9 +687,9 @@ s32 func_80A3F8D4(EnTest3* this, PlayState* play, struct_80A41828* arg2, Schedul func_80A3F15C(this, play, arg2); if (((postActor = func_80A3F2BC(play, this, ACTOR_EN_PST, ACTORCAT_PROP, 100.0f, 20.0f)) != NULL) || ((postActor = func_80A3F2BC(play, this, ACTOR_EN_PM, ACTORCAT_NPC, 100.0f, 20.0f)) != NULL)) { - this->player.actor.home.rot.y = Actor_YawBetweenActors(&this->player.actor, postActor); + this->player.actor.home.rot.y = Actor_WorldYawTowardActor(&this->player.actor, postActor); } - play->startPlayerCutscene(play, &this->player, 0x61); + play->startPlayerCutscene(play, &this->player, PLAYER_CSMODE_97); return true; } @@ -737,7 +736,7 @@ s32 func_80A3FA58(EnTest3* this, PlayState* play) { return false; } if (this->unk_D8A == 90) { - play->startPlayerCutscene(play, &this->player, 0x15); + play->startPlayerCutscene(play, &this->player, PLAYER_CSMODE_21); } } else { this->unk_D8A++; @@ -758,28 +757,28 @@ s32 func_80A3FBE8(EnTest3* this, PlayState* play) { if (!Play_InCsMode(play)) { D_80A41D20 = 1; this->unk_D78 = &D_80A41854[20]; - this->unk_D8D = this->player.actor.cutscene; + this->csId = this->player.actor.csId; this->player.actor.textId = this->unk_D78->textId; } } else if (D_80A41D20 == 1) { - if (this->unk_D8D >= 0) { + if (this->csId >= 0) { if (func_80A3E9DC(this, play)) { - this->unk_D8D = -1; + this->csId = CS_ID_NONE; Environment_StopTime(); } } else if ((play->actorCtx.flags & ACTORCTX_FLAG_6) || (play->actorCtx.flags & ACTORCTX_FLAG_5)) { - this->unk_D8D = ActorCutscene_GetAdditionalCutscene(this->player.actor.cutscene); + this->csId = CutsceneManager_GetAdditionalCsId(this->player.actor.csId); SET_WEEKEVENTREG(WEEKEVENTREG_90_02); if (play->actorCtx.flags & ACTORCTX_FLAG_5) { - this->unk_D8D = ActorCutscene_GetAdditionalCutscene(this->unk_D8D); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); } - Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); D_80A41D20 = 2; } else { func_80A3F73C(this, play); } } else if ((D_80A41D20 == 2) && func_80A3E9DC(this, play)) { - ActorCutscene_SetReturnCamera(CAM_ID_MAIN); + CutsceneManager_SetReturnCamera(CAM_ID_MAIN); Environment_StartTime(); if (((void)0, gSaveContext.save.time) > CLOCK_TIME(6, 0)) { func_800FE658(TIME_TO_MINUTES_ALT_F(fabsf((s16) - ((void)0, gSaveContext.save.time)))); @@ -794,7 +793,7 @@ s32 func_80A3FBE8(EnTest3* this, PlayState* play) { } s32 func_80A3FDE4(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput) { - this->unk_D8D = ActorCutscene_GetAdditionalCutscene(this->player.actor.cutscene); + this->csId = CutsceneManager_GetAdditionalCsId(this->player.actor.csId); return true; } @@ -814,7 +813,7 @@ s32 func_80A3FE20(EnTest3* this, PlayState* play) { } else if (D_80A41D64 == 1) { func_80A40230(this, play); } else if (D_80A41D64 == 2) { - ActorCutscene_Stop(this->unk_D8D); + CutsceneManager_Stop(this->csId); SET_WEEKEVENTREG(WEEKEVENTREG_90_02); D_80A41D64 = 3; } @@ -836,9 +835,9 @@ s32 func_80A3FF10(EnTest3* this, PlayState* play, struct_80A41828* arg2, Schedul return true; } else { func_80A3F15C(this, play, arg2); - this->unk_D8D = this->player.actor.cutscene; + this->csId = this->player.actor.csId; if (play->roomCtx.curRoom.num == 2) { - this->unk_D8D = ActorCutscene_GetAdditionalCutscene(this->unk_D8D); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); } return true; } @@ -857,7 +856,7 @@ s32 func_80A3FFD0(EnTest3* this, PlayState* play2) { } } else { SET_WEEKEVENTREG(WEEKEVENTREG_51_40); - play->startPlayerCutscene(play, &this->player, 0x6E); + play->startPlayerCutscene(play, &this->player, PLAYER_CSMODE_110); } return false; } @@ -1033,7 +1032,7 @@ void func_80A409D4(EnTest3* this, PlayState* play) { if ((play->actorCtx.flags & ACTORCTX_FLAG_5) || (play->actorCtx.flags & ACTORCTX_FLAG_4)) { play->actorCtx.flags &= ~ACTORCTX_FLAG_4; func_80A3F0B0(this, play); - ActorCutscene_SetReturnCamera(CAM_ID_MAIN); + CutsceneManager_SetReturnCamera(CAM_ID_MAIN); } else { sEnTest3_Input = *CONTROLLER1(&play->state); } @@ -1056,16 +1055,16 @@ void EnTest3_Update(Actor* thisx, PlayState* play2) { this->player.actor.draw = EnTest3_Draw; D_80A41D48 = false; this->player.actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); - if (Cutscene_CheckActorAction(play, 0x1FA) && + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_506) && !((this->player.actor.category == ACTORCAT_PLAYER) && ((play->actorCtx.flags & ACTORCTX_FLAG_5) || (play->actorCtx.flags & ACTORCTX_FLAG_4)))) { - if (this->player.csMode != 5) { - play->startPlayerCutscene(play, &this->player, 5); + if (this->player.csMode != PLAYER_CSMODE_5) { + play->startPlayerCutscene(play, &this->player, PLAYER_CSMODE_5); } play->actorCtx.flags &= ~ACTORCTX_FLAG_4; } else if (this->player.actor.category == ACTORCAT_PLAYER) { func_80A409D4(this, play); - } else if (play->startPlayerCutscene(play, &this->player, 0)) { + } else if (play->startPlayerCutscene(play, &this->player, PLAYER_CSMODE_0)) { if (this->unk_D88 >= 7) { Vec3f worldPos; @@ -1124,9 +1123,9 @@ s32 EnTest3_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* *dList = NULL; } if (limbIndex == OBJECT_TEST3_LIMB_0B) { - rot->x += this->player.unk_AAC.z; - rot->y -= this->player.unk_AAC.y; - rot->z += this->player.unk_AAC.x; + rot->x += this->player.headLimbRot.z; + rot->y -= this->player.headLimbRot.y; + rot->z += this->player.headLimbRot.x; } else if (limbIndex == OBJECT_TEST3_LIMB_0A) { s32 requiredScopeTemp; @@ -1134,12 +1133,12 @@ s32 EnTest3_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* Matrix_RotateZS(0x44C, MTXMODE_APPLY); Matrix_RotateYS(this->player.unk_AA8, MTXMODE_APPLY); } - if (this->player.unk_AB2.y != 0) { - Matrix_RotateYS(this->player.unk_AB2.y, MTXMODE_APPLY); + if (this->player.upperLimbRot.y != 0) { + Matrix_RotateYS(this->player.upperLimbRot.y, MTXMODE_APPLY); } - Matrix_RotateXS(this->player.unk_AB2.x, MTXMODE_APPLY); - if (this->player.unk_AB2.z != 0) { - Matrix_RotateZS(this->player.unk_AB2.z, MTXMODE_APPLY); + Matrix_RotateXS(this->player.upperLimbRot.x, MTXMODE_APPLY); + if (this->player.upperLimbRot.z != 0) { + Matrix_RotateZS(this->player.upperLimbRot.z, MTXMODE_APPLY); } } else { func_80125500(play, &this->player, limbIndex, pos, rot); @@ -1215,7 +1214,7 @@ void EnTest3_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList1, Gfx** dL } else if (limbIndex == OBJECT_TEST3_LIMB_15) { if (D_80A41D60 || CHECK_WEEKEVENTREG(WEEKEVENTREG_50_80) || (INV_CONTENT(ITEM_PENDANT_OF_MEMORIES) == ITEM_PENDANT_OF_MEMORIES) || - (this->player.getItemDrawId - 1 == GID_PENDANT_OF_MEMORIES)) { + (this->player.getItemDrawIdPlusOne - 1 == GID_PENDANT_OF_MEMORIES)) { D_80A41D60 = true; } else { OPEN_DISPS(play->state.gfxCtx); @@ -1223,7 +1222,7 @@ void EnTest3_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList1, Gfx** dL CLOSE_DISPS(play->state.gfxCtx); } } else { - func_80128B74(play, &this->player, limbIndex); + Player_SetFeetPos(play, &this->player, limbIndex); } } @@ -1258,7 +1257,7 @@ void EnTest3_Draw(Actor* thisx, PlayState* play2) { OPEN_DISPS(play->state.gfxCtx); - func_8012C268(play); + func_8012C268(&play->state); if (this->player.invincibilityTimer > 0) { s32 temp2; // Must exist for stack order. Could hold the result of CLAMP instead. @@ -1294,9 +1293,9 @@ void EnTest3_Draw(Actor* thisx, PlayState* play2) { this->player.skelAnime.dListCount, EnTest3_OverrideLimbDraw, EnTest3_PostLimbDraw, &this->player.actor, 0); if (this->player.invincibilityTimer > 0) { - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); } - if ((this->player.getItemDrawId - 1) != GID_NONE) { + if ((this->player.getItemDrawIdPlusOne - 1) != GID_NONE) { Player_DrawGetItem(play, &this->player); } CLOSE_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Test3/z_en_test3.h b/src/overlays/actors/ovl_En_Test3/z_en_test3.h index a4f1ff659..36cd15c27 100644 --- a/src/overlays/actors/ovl_En_Test3/z_en_test3.h +++ b/src/overlays/actors/ovl_En_Test3/z_en_test3.h @@ -26,7 +26,7 @@ typedef struct EnTest3 { /* 0xD89 */ u8 unk_D89; /* 0xD8A */ s16 unk_D8A; /* 0xD8C */ u8 unk_D8C; - /* 0xD8D */ s8 unk_D8D; + /* 0xD8D */ s8 csId; /* 0xD8E */ s16 subCamId; /* 0xD90 */ Player* unk_D90; /* 0xD94 */ EnTest3ActionFunc unk_D94; diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 1dcb6ccb4..24d8b4137 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -43,19 +43,19 @@ static s16 sNightMessages2[] = { 0x1BB4, 0x1BB5, 0x1BB6 }; static s16 sDayMessages2[] = { 0x1BB2, 0x1BB2, 0x1BB3 }; static u16 D_80A43364[] = { CLOCK_TIME(6, 0), CLOCK_TIME(18, 0) }; -static s16 sCutscenes[2]; -static s16 sCurrentCs; +static s16 sCsIdList[2]; +static s16 sCurCsId; void func_80A41D70(EnTest4* this, PlayState* play) { - if (this->unk_144 != 0) { + if (this->csIdIndex != 0) { func_80151A68(play, sNightMessages1[CURRENT_DAY - 1]); - } else if ((sCutscenes[this->unk_144] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) { + } else if ((sCsIdList[this->csIdIndex] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) { if (play->actorCtx.flags & ACTORCTX_FLAG_1) { Sram_IncrementDay(); gSaveContext.save.time = CLOCK_TIME(6, 0); func_80151A68(play, sDayMessages1[CURRENT_DAY - 1]); } else { - this->unk_144 = 0; + this->csIdIndex = 0; this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; } @@ -67,22 +67,22 @@ void func_80A41D70(EnTest4* this, PlayState* play) { } if (gSaveContext.cutsceneTrigger == 0) { - if ((sCutscenes[this->unk_144] >= 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { + if ((sCsIdList[this->csIdIndex] >= 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { this->actionFunc = func_80A42F20; - sCurrentCs = sCutscenes[this->unk_144]; + sCurCsId = sCsIdList[this->csIdIndex]; this->transitionCsTimer = 0; SET_EVENTINF(EVENTINF_17); - } else if (this->unk_144 == 0) { + } else if (this->csIdIndex == 0) { play_sound(NA_SE_EV_CHICKEN_CRY_M); } else { func_8019F128(NA_SE_EV_DOG_CRY_EVENING); } } else { this->actionFunc = func_80A42AB8; - if (this->unk_144 == 0) { - this->unk_144 = 1; + if (this->csIdIndex == 0) { + this->csIdIndex = 1; } else { - this->unk_144 = 0; + this->csIdIndex = 0; } this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; @@ -90,9 +90,9 @@ void func_80A41D70(EnTest4* this, PlayState* play) { } void func_80A41FA4(EnTest4* this, PlayState* play) { - if (this->unk_144 != 0) { + if (this->csIdIndex != 0) { func_80151A68(play, sNightMessages2[CURRENT_DAY - 1]); - } else if ((sCutscenes[this->unk_144] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) { + } else if ((sCsIdList[this->csIdIndex] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) { Sram_IncrementDay(); gSaveContext.save.time = CLOCK_TIME(6, 0); Interface_NewDay(play, CURRENT_DAY); @@ -104,22 +104,22 @@ void func_80A41FA4(EnTest4* this, PlayState* play) { } if (gSaveContext.cutsceneTrigger == 0) { - if ((sCutscenes[this->unk_144] >= 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { + if ((sCsIdList[this->csIdIndex] >= 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { this->actionFunc = func_80A42F20; - sCurrentCs = sCutscenes[this->unk_144]; + sCurCsId = sCsIdList[this->csIdIndex]; this->transitionCsTimer = 0; SET_EVENTINF(EVENTINF_17); - } else if (this->unk_144 == 0) { + } else if (this->csIdIndex == 0) { play_sound(NA_SE_EV_CHICKEN_CRY_M); } else { func_8019F128(NA_SE_EV_DOG_CRY_EVENING); } } else { this->actionFunc = func_80A42AB8; - if (this->unk_144 == 0) { - this->unk_144 = 1; + if (this->csIdIndex == 0) { + this->csIdIndex = 1; } else { - this->unk_144 = 0; + this->csIdIndex = 0; } this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; @@ -278,12 +278,12 @@ void func_80A425E4(EnTest4* this, PlayState* play) { this->nextBellTime = CLOCK_TIME(17, 30); } - if ((sCutscenes[this->unk_144] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1) || (CURRENT_DAY == 3) || + if ((sCsIdList[this->csIdIndex] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1) || (CURRENT_DAY == 3) || (gSaveContext.save.time >= CLOCK_TIME(17, 0))) { gSaveContext.screenScale = 1000.0f; } if (gSaveContext.screenScale != 1000.0f) { - gSaveContext.screenScaleFlag = 1; + gSaveContext.screenScaleFlag = true; } } } @@ -292,17 +292,17 @@ void EnTest4_Init(Actor* thisx, PlayState* play) { s32 dayTemp; EnTest4* this = THIS; Player* player = GET_PLAYER(play); - s8 temp_v0 = this->actor.cutscene; + s8 csId = this->actor.csId; - sCutscenes[0] = temp_v0; - if (temp_v0 >= 0) { - ActorCutscene* temp_v0_2 = ActorCutscene_GetCutscene(sCutscenes[0]); + sCsIdList[0] = csId; + if (csId >= 0) { + ActorCutscene* actorCutscene = CutsceneManager_GetCutsceneEntry(sCsIdList[0]); SET_EVENTINF(EVENTINF_52); - sCutscenes[1] = temp_v0_2->additionalCutscene; + sCsIdList[1] = actorCutscene->additionalCsId; } else { CLEAR_EVENTINF(EVENTINF_52); - sCutscenes[1] = sCutscenes[0]; + sCsIdList[1] = sCsIdList[0]; } if (sIsLoaded || (CHECK_EVENTINF(EVENTINF_27))) { @@ -310,37 +310,37 @@ void EnTest4_Init(Actor* thisx, PlayState* play) { } else { sIsLoaded = true; this->actor.room = -1; - gSaveContext.screenScaleFlag = 0; + gSaveContext.screenScaleFlag = false; gSaveContext.screenScale = 1000.0f; if (CURRENT_DAY == 0) { if (gSaveContext.save.time < CLOCK_TIME(6, 1)) { gSaveContext.save.time = CLOCK_TIME(6, 0); - gSaveContext.gameMode = 0; + gSaveContext.gameMode = GAMEMODE_NORMAL; STOP_GAMESTATE(&play->state); SET_NEXT_GAMESTATE(&play->state, DayTelop_Init, sizeof(DayTelopState)); - this->unk_144 = 1; + this->csIdIndex = 1; gSaveContext.save.time = CLOCK_TIME(6, 0); Actor_Kill(&this->actor); } else { gSaveContext.save.day = 1; dayTemp = gSaveContext.save.day; gSaveContext.save.daysElapsed = dayTemp; - this->unk_144 = 1; + this->csIdIndex = 1; this->unk_146 = gSaveContext.save.time; this->actionFunc = func_80A42AB8; } } else if (gSaveContext.save.time == CLOCK_TIME(6, 0)) { - this->unk_144 = 0; + this->csIdIndex = 0; func_80A41D70(this, play); - if ((gSaveContext.cutsceneTrigger == 0) && (sCutscenes[this->unk_144] >= 0) && + if ((gSaveContext.cutsceneTrigger == 0) && (sCsIdList[this->csIdIndex] >= 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { player->stateFlags1 |= PLAYER_STATE1_200; } } else { if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 0))) { - this->unk_144 = 0; + this->csIdIndex = 0; } else { - this->unk_144 = 1; + this->csIdIndex = 1; } this->unk_146 = gSaveContext.save.time; this->actionFunc = func_80A42AB8; @@ -354,8 +354,8 @@ void EnTest4_Init(Actor* thisx, PlayState* play) { } this->lastBellTime = gSaveContext.save.time; - if ((sCutscenes[this->unk_144] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) { - gSaveContext.screenScaleFlag = 0; + if ((sCsIdList[this->csIdIndex] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) { + gSaveContext.screenScaleFlag = false; gSaveContext.screenScale = 1000.0f; } } @@ -367,9 +367,9 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { Player* player = GET_PLAYER(play); if ((play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play) && (play->numSetupActors <= 0) && - (play->roomCtx.unk31 == 0) && !Play_IsDebugCamEnabled()) { + (play->roomCtx.status == 0) && !Play_IsDebugCamEnabled()) { s16 temp_a2; - u16 temp_a0 = D_80A43364[this->unk_144]; + u16 temp_a0 = D_80A43364[this->csIdIndex]; s16 temp_a3; s16 bellDiff; s16 new_var; @@ -392,7 +392,7 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { Interface_StartMoonCrash(play); Actor_Kill(&this->actor); SET_EVENTINF(EVENTINF_17); - } else if (((sCutscenes[this->unk_144] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) && + } else if (((sCsIdList[this->csIdIndex] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) && (CURRENT_DAY != 3)) { func_80A41FA4(this, play); } else { @@ -418,14 +418,14 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { } } - if ((sCutscenes[this->unk_144] >= 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { + if ((sCsIdList[this->csIdIndex] >= 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { player->stateFlags1 |= PLAYER_STATE1_200; this->unk_146 = gSaveContext.save.time; } else { - if (this->unk_144 == 0) { - this->unk_144 = 1; + if (this->csIdIndex == 0) { + this->csIdIndex = 1; } else { - this->unk_144 = 0; + this->csIdIndex = 0; } this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; @@ -436,7 +436,7 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { if (CURRENT_DAY == 3) { if ((this->nextBellTime == CLOCK_TIME(0, 0)) && - ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) || + ((gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] == ITEM_NONE) || (play->sceneId == SCENE_CLOCKTOWER))) { s32 playerParams; u32 entrance = gSaveContext.save.entrance; @@ -456,7 +456,7 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { } gSaveContext.nextCutsceneIndex = 0xFFF1; play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_02; + play->transitionType = TRANS_TYPE_FADE_BLACK; player->stateFlags1 |= PLAYER_STATE1_200; Actor_Kill(&this->actor); } @@ -470,11 +470,11 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { void func_80A42F20(EnTest4* this, PlayState* play) { if (!this->transitionCsTimer) { - if (sCurrentCs >= 0) { - if (ActorCutscene_GetCanPlayNext(sCurrentCs) == 0) { - ActorCutscene_SetIntentToPlay(sCurrentCs); + if (sCurCsId >= 0) { + if (!CutsceneManager_IsNext(sCurCsId)) { + CutsceneManager_Queue(sCurCsId); } else { - ActorCutscene_Start(sCurrentCs, &this->actor); + CutsceneManager_Start(sCurCsId, &this->actor); this->transitionCsTimer = 1; } } else { @@ -483,7 +483,7 @@ void func_80A42F20(EnTest4* this, PlayState* play) { } else if (this->transitionCsTimer < 60) { this->transitionCsTimer++; if (this->transitionCsTimer == 10) { - if (this->unk_144 == 0) { + if (this->csIdIndex == 0) { play_sound(NA_SE_EV_CHICKEN_CRY_M); } else { func_8019F128(NA_SE_EV_DOG_CRY_EVENING); @@ -499,14 +499,14 @@ void func_80A42F20(EnTest4* this, PlayState* play) { } } else { this->actionFunc = func_80A42AB8; - if (this->unk_144 == 0) { - this->unk_144 = 1; + if (this->csIdIndex == 0) { + this->csIdIndex = 1; } else { - this->unk_144 = 0; + this->csIdIndex = 0; } - if (sCurrentCs >= 0) { - ActorCutscene_Stop(sCurrentCs); + if (sCurCsId >= 0) { + CutsceneManager_Stop(sCurCsId); } gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.h b/src/overlays/actors/ovl_En_Test4/z_en_test4.h index 0a372f245..106a5a9aa 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.h +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.h @@ -9,7 +9,7 @@ typedef void (*EnTest4ActionFunc)(struct EnTest4*, PlayState*); typedef struct EnTest4 { /* 0x000 */ Actor actor; - /* 0x144 */ s8 unk_144; // 0 on night, 1 on day + /* 0x144 */ s8 csIdIndex; // 0 on night, 1 on day /* 0x145 */ u8 transitionCsTimer; /* 0x146 */ u16 unk_146; /* 0x148 */ u16 nextBellTime; // Next time the bell will sound 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 83451fa02..a041a1aaf 100644 --- a/src/overlays/actors/ovl_En_Test5/z_en_test5.c +++ b/src/overlays/actors/ovl_En_Test5/z_en_test5.c @@ -73,7 +73,8 @@ void EnTest5_HandleBottleAction(EnTest5* this, PlayState* play) { 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) { - Actor_PickUp(&this->actor, play, GI_MAX, this->actor.xzDistToPlayer, fabsf(this->actor.playerHeightRel)); + Actor_OfferGetItem(&this->actor, play, GI_MAX, this->actor.xzDistToPlayer, + fabsf(this->actor.playerHeightRel)); } } } diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index c0915fce6..70ab37232 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -7,6 +7,7 @@ #include "z_en_test6.h" #include "z64quake.h" #include "objects/gameplay_keep/gameplay_keep.h" +#include "z64cutscene_commands.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000) @@ -54,30 +55,57 @@ ActorInit En_Test6_InitVars = { (ActorFunc)EnTest6_Draw, }; -u8 D_80A93E80[] = { - 0x00, 0x0D, 0x01, 0xA8, 0x00, 0x00, 0x00, 0x64, 0x04, 0x64, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x15, 0xFF, 0xED, 0x00, - 0x00, 0x04, 0x64, 0x00, 0x12, 0x00, 0x00, 0x00, 0x15, 0xFF, 0xED, 0x00, 0x00, 0x04, 0x64, 0x00, 0x10, 0x00, 0x00, - 0x00, 0x15, 0xFF, 0xED, 0x00, 0x00, 0x04, 0x64, 0x00, 0x11, 0xFF, 0xE6, 0xFF, 0xFB, 0xFF, 0xE0, 0x00, 0x00, 0x04, - 0x64, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x12, 0xFF, 0xE0, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0E, 0x00, 0x01, 0x00, 0x16, - 0xFF, 0xE5, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFB, 0x00, 0x00, 0x04, 0x64, 0x00, - 0x07, 0x00, 0x10, 0x00, 0x1D, 0xFF, 0xB3, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0x00, 0x01, 0x00, 0x13, 0x00, 0x6F, - 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFF, 0xC5, 0x00, 0x15, 0x00, 0x5B, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFF, - 0xED, 0x00, 0x3B, 0x00, 0x54, 0x00, 0x00, 0x04, 0x64, 0x00, 0x88, 0xFF, 0xED, 0x00, 0x3B, 0x00, 0x54, 0x00, 0x00, - 0x04, 0x64, 0x00, 0x6C, 0xFF, 0xEF, 0x00, 0x39, 0x00, 0x52, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0D, 0x00, 0x00, 0x00, - 0x32, 0x02, 0xA9, 0x00, 0x00, 0x04, 0x64, 0x00, 0x12, 0x00, 0x00, 0x00, 0x32, 0x02, 0xA9, 0x00, 0x00, 0x04, 0x64, - 0x00, 0x10, 0x00, 0x00, 0x00, 0x32, 0x02, 0xA9, 0x00, 0x00, 0x04, 0x64, 0x00, 0x11, 0xFF, 0x98, 0x01, 0x77, 0x01, - 0x59, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0F, 0x00, 0x00, 0xFF, 0xC2, 0x01, 0x21, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0E, - 0xFF, 0xD1, 0x00, 0x7D, 0x00, 0xCD, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0C, 0xFF, 0xC6, 0xFF, 0xEF, 0x00, 0xC7, 0x00, - 0x00, 0x04, 0x64, 0x00, 0x07, 0x00, 0x10, 0x00, 0x35, 0x00, 0xD3, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFF, 0xE1, - 0x00, 0x3F, 0x02, 0x6F, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFE, 0xAB, 0x01, 0xD0, 0x02, 0x1E, 0x00, 0x00, 0x04, - 0x64, 0x00, 0x03, 0xFE, 0xAB, 0x01, 0xD0, 0x02, 0x1E, 0x00, 0x00, 0x04, 0x64, 0x00, 0x88, 0xFE, 0xAB, 0x01, 0xD0, - 0x02, 0x1E, 0x00, 0x00, 0x04, 0x64, 0x00, 0x6C, 0xFE, 0xAD, 0x01, 0xCE, 0x02, 0x1C, 0x00, 0x00, 0x00, 0x0F, 0x00, - 0x0A, 0x00, 0x46, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x0A, 0x00, 0x46, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x0A, 0x00, 0x46, - 0x00, 0x00, 0x00, 0x0A, 0x00, 0x02, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xEC, 0x00, 0x37, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x06, 0x00, 0x2F, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFB, - 0x00, 0x32, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xDC, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xD8, 0x00, 0x78, 0x00, - 0x00, 0x00, 0x02, 0xFF, 0xC4, 0x00, 0x78, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xBA, 0x00, 0x82, 0x00, 0x00, 0x00, 0x02, - 0xFF, 0xB0, 0x00, 0x8C, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x04, +CutsceneData D_80A93E80[] = { + // Header + CS_CAM_SPLINE(13, 424, 0, 100), + + // Camera At Data + /* 0x0 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 13, 0, 21, -19, CS_CAM_REL_0), + /* 0x1 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 18, 0, 21, -19, CS_CAM_REL_0), + /* 0x2 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 16, 0, 21, -19, CS_CAM_REL_0), + /* 0x3 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 17, -26, -5, -32, CS_CAM_REL_0), + /* 0x4 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 15, 0, 18, -32, CS_CAM_REL_0), + /* 0x5 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 14, 1, 22, -27, CS_CAM_REL_0), + /* 0x6 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 12, 0, 1, -5, CS_CAM_REL_0), + /* 0x7 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 7, 16, 29, -77, CS_CAM_REL_0), + /* 0x8 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 3, 1, 19, 111, CS_CAM_REL_0), + /* 0x9 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 3, -59, 21, 91, CS_CAM_REL_0), + /* 0xA */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 3, -19, 59, 84, CS_CAM_REL_0), + /* 0xB */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 136, -19, 59, 84, CS_CAM_REL_0), + /* 0xC */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 108, -17, 57, 82, CS_CAM_REL_0), + + // Camera Eye Data + /* 0x0 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 13, 0, 50, 681, CS_CAM_REL_0), + /* 0x1 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 18, 0, 50, 681, CS_CAM_REL_0), + /* 0x2 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 16, 0, 50, 681, CS_CAM_REL_0), + /* 0x3 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 17, -104, 375, 345, CS_CAM_REL_0), + /* 0x4 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 15, 0, -62, 289, CS_CAM_REL_0), + /* 0x5 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 14, -47, 125, 205, CS_CAM_REL_0), + /* 0x6 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 12, -58, -17, 199, CS_CAM_REL_0), + /* 0x7 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 7, 16, 53, 211, CS_CAM_REL_0), + /* 0x8 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 3, -31, 63, 623, CS_CAM_REL_0), + /* 0x9 */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 3, -341, 464, 542, CS_CAM_REL_0), + /* 0xA */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 3, -341, 464, 542, CS_CAM_REL_0), + /* 0xB */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 136, -341, 464, 542, CS_CAM_REL_0), + /* 0xC */ CS_CAM_POINT(CS_CAM_INTERP_4, 100, 108, -339, 462, 540, CS_CAM_REL_0), + + // Camera Roll and Fov Data + /* 0x0 */ CS_CAM_MISC(15, 0xA, 70, 0), + /* 0x1 */ CS_CAM_MISC(15, 0xA, 70, 0), + /* 0x2 */ CS_CAM_MISC(15, 0xA, 70, 0), + /* 0x3 */ CS_CAM_MISC(10, 0x2, 60, 0), + /* 0x4 */ CS_CAM_MISC(10, -0x14, 55, 0), + /* 0x5 */ CS_CAM_MISC(16, 0x0, 43, 0), + /* 0x6 */ CS_CAM_MISC(12, 0x6, 47, 0), + /* 0x7 */ CS_CAM_MISC(5, -0x5, 50, 0), + /* 0x8 */ CS_CAM_MISC(2, -0x24, 108, 0), + /* 0x9 */ CS_CAM_MISC(2, -0x28, 120, 0), + /* 0xA */ CS_CAM_MISC(2, -0x3C, 120, 0), + /* 0xB */ CS_CAM_MISC(2, -0x46, 130, 0), + /* 0xC */ CS_CAM_MISC(2, -0x50, 140, 0), + + // Terminate + CS_CAM_END() }; TexturePtr D_80A9402C[] = { @@ -113,12 +141,12 @@ void func_80A90730(EnTest6* this, PlayState* play) { case ENTEST6_24: case ENTEST6_25: func_80A91690(this, play); - ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); + CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); return; case ENTEST6_26: func_80A920C8(this, play); - ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); + CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); return; } @@ -183,16 +211,16 @@ void func_80A90730(EnTest6* this, PlayState* play) { } } -void func_80A90C08(s16 arg0) { - func_8016566C(arg0); +void EnTest6_EnableMotionBlur(s16 alpha) { + Play_EnableMotionBlur(alpha); } -void func_80A90C34(void) { - func_80165690(); +void EnTest6_DisableMotionBlur(void) { + Play_DisableMotionBlur(); } void func_80A90C54(PlayState* play, f32 arg1) { - play->envCtx.fillScreen = 1; + play->envCtx.fillScreen = true; play->envCtx.screenFillColor[0] = 250; play->envCtx.screenFillColor[1] = 250; play->envCtx.screenFillColor[2] = 250; @@ -200,7 +228,7 @@ void func_80A90C54(PlayState* play, f32 arg1) { } void func_80A90D20(PlayState* play) { - play->envCtx.fillScreen = 0; + play->envCtx.fillScreen = false; } void func_80A90D34(EnTest6* this, PlayState* play, EnTest6Struct* ptr) { @@ -211,7 +239,7 @@ void func_80A90D34(EnTest6* this, PlayState* play, EnTest6Struct* ptr) { if (ptr->unk_00 != 0) { Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); Matrix_Scale(ptr->unk_04 * 0.02f, ptr->unk_04 * 0.02f, ptr->unk_04 * 0.02f, MTXMODE_APPLY); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A9402C[ptr->unk_00])); @@ -301,7 +329,7 @@ void EnTest6_Init(Actor* thisx, PlayState* play2) { if (((ENTEST6_GET(&this->actor) == ENTEST6_24) || (ENTEST6_GET(&this->actor) == ENTEST6_25) || (ENTEST6_GET(&this->actor) == ENTEST6_26)) && - (play->playerActorCsIds[8] == -1)) { + (play->playerCsIds[PLAYER_CS_ID_SONG_WARP] == CS_ID_NONE)) { Actor_Kill(&this->actor); return; } @@ -313,7 +341,7 @@ void EnTest6_Init(Actor* thisx, PlayState* play2) { } this->unk_286 = 0; - this->unk_274 = 0; + this->cueId = 0; this->unk_278 = 0; this->unk_276 = 99; func_80A90730(this, play); @@ -338,8 +366,8 @@ void EnTest6_Destroy(Actor* thisx, PlayState* play2) { play->envCtx.lightSettings.fogColor[1] = 0; play->envCtx.lightSettings.fogColor[2] = 0; play->envCtx.lightSettings.fogNear = 0; - play->envCtx.lightSettings.fogFar = 0; - play->envCtx.fillScreen = 0; + play->envCtx.lightSettings.zFar = 0; + play->envCtx.fillScreen = false; for (i = 0; i < ARRAY_COUNT(this->lights); i++) { LightContext_RemoveLight(play, &play->lightCtx, this->lights[i].node); @@ -350,21 +378,21 @@ void func_80A9156C(EnTest6* this, PlayState* play) { switch (ENTEST6_GET(&this->actor)) { case ENTEST6_24: case ENTEST6_25: - if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[8])) { - ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); + if (!CutsceneManager_IsNext(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])) { + CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); } else { - ActorCutscene_Start(play->playerActorCsIds[8], NULL); - this->subCamId = ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8]); + CutsceneManager_Start(play->playerCsIds[PLAYER_CS_ID_SONG_WARP], NULL); + this->subCamId = CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); EnTest6_SetupAction(this, func_80A91760); } break; case ENTEST6_26: - if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[8])) { - ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); + if (!CutsceneManager_IsNext(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])) { + CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); } else { - ActorCutscene_Start(play->playerActorCsIds[8], NULL); - this->subCamId = ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8]); + CutsceneManager_Start(play->playerCsIds[PLAYER_CS_ID_SONG_WARP], NULL); + this->subCamId = CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); EnTest6_SetupAction(this, func_80A92188); } break; @@ -379,7 +407,7 @@ void func_80A9156C(EnTest6* this, PlayState* play) { } void func_80A91690(EnTest6* this, PlayState* play) { - this->unk_274 = 90; + this->cueId = 90; this->unk_27A = 100; this->unk_286 = 0; if (ENTEST6_GET(&this->actor) == ENTEST6_25) { @@ -393,11 +421,11 @@ void func_80A916F0(EnTest6* this, PlayState* play) { Player* player = GET_PLAYER(play); player->actor.freezeTimer = 0; - play->unk_18844 = 0; - ActorCutscene_Stop(play->playerActorCsIds[8]); - func_800B7298(play, NULL, PLAYER_CSMODE_6); - func_80A90C34(); - Distortion_ClearType(DISTORTION_TYPE_5); + play->unk_18844 = false; + CutsceneManager_Stop(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); + func_800B7298(play, NULL, PLAYER_CSMODE_END); + EnTest6_DisableMotionBlur(); + Distortion_RemoveRequest(DISTORTION_TYPE_SONG_OF_TIME); Actor_Kill(&this->actor); } @@ -415,14 +443,14 @@ void func_80A91760(EnTest6* this, PlayState* play) { mainCam = Play_GetCamera(play, CAM_ID_MAIN); - switch (this->unk_274) { + switch (this->cueId) { case 90: this->unk_276 = 2; this->unk_15C = 0.0f; this->unk_14C = 0.1f; this->unk_282 = 0; this->unk_278 = 0; - this->unk_274 = 91; + this->cueId = 91; break; case 91: @@ -462,11 +490,11 @@ void func_80A91760(EnTest6* this, PlayState* play) { ((subCam->at.z - subCam->eye.z) * 0.2f); } } - func_80A90C08(0x78); - Distortion_SetType(DISTORTION_TYPE_5); - Distortion_SetCountdown(80); - play->unk_18844 = 1; - this->unk_274 = 95; + EnTest6_EnableMotionBlur(120); + Distortion_Request(DISTORTION_TYPE_SONG_OF_TIME); + Distortion_SetDuration(80); + play->unk_18844 = true; + this->cueId = 95; } break; @@ -517,13 +545,13 @@ void func_80A91760(EnTest6* this, PlayState* play) { if (this->unk_27A == 10) { this->unk_14C = 0.1f; - func_80A90C34(); - Distortion_ClearType(DISTORTION_TYPE_5); - play->unk_18844 = 0; + EnTest6_DisableMotionBlur(); + Distortion_RemoveRequest(DISTORTION_TYPE_SONG_OF_TIME); + play->unk_18844 = false; if (this->unk_254 != NULL) { ZeldaArena_Free(this->unk_254); } - this->unk_274 = 99; + this->cueId = 99; } break; @@ -537,7 +565,7 @@ void func_80A91760(EnTest6* this, PlayState* play) { } if (this->unk_286 != 0) { - func_800B7298(play, NULL, PLAYER_CSMODE_7); + func_800B7298(play, NULL, PLAYER_CSMODE_WAIT); } else { if (this->unk_27A == 90) { func_800B7298(play, NULL, PLAYER_CSMODE_66); @@ -614,11 +642,11 @@ void func_80A92118(EnTest6* this, PlayState* play) { Player* player = GET_PLAYER(play); player->actor.freezeTimer = 0; - play->unk_18844 = 0; - ActorCutscene_Stop(play->playerActorCsIds[8]); - func_800B7298(play, NULL, PLAYER_CSMODE_6); - func_80A90C34(); - Distortion_ClearType(DISTORTION_TYPE_5); + play->unk_18844 = false; + CutsceneManager_Stop(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); + func_800B7298(play, NULL, PLAYER_CSMODE_END); + EnTest6_DisableMotionBlur(); + Distortion_RemoveRequest(DISTORTION_TYPE_SONG_OF_TIME); Actor_Kill(&this->actor); } @@ -657,7 +685,7 @@ void func_80A92188(EnTest6* this, PlayState* play) { func_800FD5E0(play, &D_80A94070, 1.0f); func_800FD654(play, &D_80A94068, 1.0f); func_800FD698(play, D_80A94074, D_80A94078, 1.0f); - play->unk_18844 = 1; + play->unk_18844 = true; } if (this->unk_27A == 15) { @@ -665,7 +693,7 @@ void func_80A92188(EnTest6* this, PlayState* play) { func_800FD5E0(play, &D_80A94070, 0.0f); func_800FD654(play, &D_80A94068, 0.0f); func_800FD698(play, D_80A94074, D_80A94078, 0.0f); - play->unk_18844 = 0; + play->unk_18844 = false; } if (this->unk_286 >= 20) { @@ -673,21 +701,21 @@ void func_80A92188(EnTest6* this, PlayState* play) { func_800FD5E0(play, &D_80A94070, this->unk_160); func_800FD654(play, &D_80A94068, this->unk_160); func_800FD698(play, D_80A94074, D_80A94078, this->unk_160); - play->unk_18844 = 0; + play->unk_18844 = false; } func_800B8F98(&player->actor, NA_SE_PL_FLYING_AIR - SFX_FLAG); switch (this->unk_27A) { case 119: - func_80A90C08(0x32); + EnTest6_EnableMotionBlur(50); break; case 115: - func_80A90C08(0x14); - Distortion_SetType(DISTORTION_TYPE_5); - Distortion_SetCountdown(90); - this->unk_274 = 2; + EnTest6_EnableMotionBlur(20); + Distortion_Request(DISTORTION_TYPE_SONG_OF_TIME); + Distortion_SetDuration(90); + this->cueId = 2; break; case 110: @@ -696,34 +724,34 @@ void func_80A92188(EnTest6* this, PlayState* play) { case 38: case 114: - this->unk_274 = 1; + this->cueId = 1; break; case 76: - this->unk_274 = 3; + this->cueId = 3; break; case 61: - func_80A90C08(0x96); - this->unk_274 = 4; + EnTest6_EnableMotionBlur(150); + this->cueId = 4; break; case 51: - func_80A90C08(0xB4); - this->unk_274 = 5; + EnTest6_EnableMotionBlur(180); + this->cueId = 5; break; case 14: case 15: - func_80A90C08(0x32); - Distortion_ClearType(DISTORTION_TYPE_5); - this->unk_274 = 0; + EnTest6_EnableMotionBlur(50); + Distortion_RemoveRequest(DISTORTION_TYPE_SONG_OF_TIME); + this->cueId = 0; break; case 1: - func_80A90C34(); + EnTest6_DisableMotionBlur(); if (CHECK_EVENTINF(EVENTINF_52)) { - this->unk_274 = 9; + this->cueId = 9; } break; } @@ -731,19 +759,19 @@ void func_80A92188(EnTest6* this, PlayState* play) { func_80A92950(this, play); if (this->unk_27A == 115) { - subCamId = ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8]); + subCamId = CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); subCam = Play_GetCamera(play, subCamId); this->subCamAt = subCam->at; this->subCamEye = subCam->eye; this->subCamFov = subCam->fov; - func_8016119C(subCam, &this->unk_18C); + CutsceneCamera_Init(subCam, &this->unk_18C); } if ((this->unk_27A <= 115) && (this->unk_27A >= 16)) { - func_80161998(D_80A93E80, &this->unk_18C); + CutsceneCamera_UpdateSplines((u8*)D_80A93E80, &this->unk_18C); } else if (this->unk_27A < 16) { - subCamId = ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8]); + subCamId = CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); Play_SetCameraAtEyeUp(play, subCamId, &this->subCamAt, &this->subCamEye, &sSubCamUp); Play_SetCameraFov(play, subCamId, this->subCamFov); @@ -780,7 +808,7 @@ void func_80A92188(EnTest6* this, PlayState* play) { break; case 38: - func_800B7298(play, NULL, PLAYER_CSMODE_7); + func_800B7298(play, NULL, PLAYER_CSMODE_WAIT); break; case 14: @@ -806,7 +834,7 @@ void func_80A92188(EnTest6* this, PlayState* play) { (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B))) { this->unk_286 = 1; this->unk_27A = 39; - Audio_QueueSeqCmd(0x111400FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 20); } if (DECR(this->unk_27A) == 0) { @@ -825,13 +853,13 @@ void func_80A92950(EnTest6* this, PlayState* play) { Player* player = GET_PLAYER(play); f32 temp_f0; s32 i; - s32 temp_v0; + s32 cueChannel; - if (Cutscene_CheckActorAction(play, 0x1F9)) { - temp_v0 = Cutscene_GetActorActionIndex(play, 0x1F9); - this->unk_274 = play->csCtx.actorActions[temp_v0]->action; + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_505)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_505); + this->cueId = play->csCtx.actorCues[cueChannel]->id; - switch (this->unk_274) { + switch (this->cueId) { case 1: break; @@ -841,39 +869,39 @@ void func_80A92950(EnTest6* this, PlayState* play) { this->unk_27C = 0; player->actor.shape.shadowDraw = NULL; - if (play->csCtx.actorActions[temp_v0]->startPos.x != 0) { - this->unk_154 = (u32)play->csCtx.actorActions[temp_v0]->startPos.x; + if (play->csCtx.actorCues[cueChannel]->startPos.x != 0) { + this->unk_154 = (u32)play->csCtx.actorCues[cueChannel]->startPos.x; } else { this->unk_154 = 150.0f; } - if (play->csCtx.actorActions[temp_v0]->startPos.y != 0) { - this->unk_280 = play->csCtx.actorActions[temp_v0]->startPos.y; + if (play->csCtx.actorCues[cueChannel]->startPos.y != 0) { + this->unk_280 = play->csCtx.actorCues[cueChannel]->startPos.y; } else { this->unk_280 = 38; } - if (play->csCtx.actorActions[temp_v0]->startPos.z != 0) { - this->unk_150 = (u32)play->csCtx.actorActions[temp_v0]->startPos.z; + if (play->csCtx.actorCues[cueChannel]->startPos.z != 0) { + this->unk_150 = (u32)play->csCtx.actorCues[cueChannel]->startPos.z; } else { this->unk_150 = 480.0f; } break; case 3: - if (play->csCtx.actorActions[temp_v0]->startPos.x != 0) { - this->unk_154 += (u32)play->csCtx.actorActions[temp_v0]->startPos.x; + if (play->csCtx.actorCues[cueChannel]->startPos.x != 0) { + this->unk_154 += (u32)play->csCtx.actorCues[cueChannel]->startPos.x; } - if (play->csCtx.actorActions[temp_v0]->startPos.y != 0) { - this->unk_280 += (s16)play->csCtx.actorActions[temp_v0]->startPos.y; + if (play->csCtx.actorCues[cueChannel]->startPos.y != 0) { + this->unk_280 += (s16)play->csCtx.actorCues[cueChannel]->startPos.y; } else { this->unk_280 += 6; } - if (play->csCtx.actorActions[temp_v0]->startPos.z != 0) { - this->unk_158 = (u32)play->csCtx.actorActions[temp_v0]->startPos.z; + if (play->csCtx.actorCues[cueChannel]->startPos.z != 0) { + this->unk_158 = (u32)play->csCtx.actorCues[cueChannel]->startPos.z; } else { this->unk_158 = -32.0f; } @@ -881,30 +909,30 @@ void func_80A92950(EnTest6* this, PlayState* play) { break; case 4: - if (play->csCtx.actorActions[temp_v0]->startPos.x != 0) { - this->unk_154 += (u32)play->csCtx.actorActions[temp_v0]->startPos.x; + if (play->csCtx.actorCues[cueChannel]->startPos.x != 0) { + this->unk_154 += (u32)play->csCtx.actorCues[cueChannel]->startPos.x; } - if (play->csCtx.actorActions[temp_v0]->startPos.y != 0) { - this->unk_280 += (s16)play->csCtx.actorActions[temp_v0]->startPos.y; + if (play->csCtx.actorCues[cueChannel]->startPos.y != 0) { + this->unk_280 += (s16)play->csCtx.actorCues[cueChannel]->startPos.y; } else { this->unk_280 -= 4; } break; case 5: - if (play->csCtx.actorActions[temp_v0]->startPos.x != 0) { - this->unk_154 += (u32)play->csCtx.actorActions[temp_v0]->startPos.x; + if (play->csCtx.actorCues[cueChannel]->startPos.x != 0) { + this->unk_154 += (u32)play->csCtx.actorCues[cueChannel]->startPos.x; } - if (play->csCtx.actorActions[temp_v0]->startPos.y != 0) { - this->unk_280 += (s16)play->csCtx.actorActions[temp_v0]->startPos.y; + if (play->csCtx.actorCues[cueChannel]->startPos.y != 0) { + this->unk_280 += (s16)play->csCtx.actorCues[cueChannel]->startPos.y; } else { this->unk_280 -= 8; } - if (play->csCtx.actorActions[temp_v0]->startPos.z != 0) { - this->unk_158 += (u32)play->csCtx.actorActions[temp_v0]->startPos.z; + if (play->csCtx.actorCues[cueChannel]->startPos.z != 0) { + this->unk_158 += (u32)play->csCtx.actorCues[cueChannel]->startPos.z; } else { this->unk_158 += 20.0f; } @@ -912,7 +940,7 @@ void func_80A92950(EnTest6* this, PlayState* play) { this->unk_150 += this->unk_158; if (this->unk_150 > 3500.0f) { this->unk_150 = 3500.0f; - this->unk_274 = 0; + this->cueId = 0; } break; @@ -922,20 +950,20 @@ void func_80A92950(EnTest6* this, PlayState* play) { this->unk_27C = 0; player->actor.shape.shadowDraw = NULL; - if (play->csCtx.actorActions[temp_v0]->startPos.x != 0) { - this->unk_154 = (u32)play->csCtx.actorActions[temp_v0]->startPos.x; + if (play->csCtx.actorCues[cueChannel]->startPos.x != 0) { + this->unk_154 = (u32)play->csCtx.actorCues[cueChannel]->startPos.x; } else { this->unk_154 = 100.0f; } - if (play->csCtx.actorActions[temp_v0]->startPos.y != 0) { - this->unk_14C = (u32)play->csCtx.actorActions[temp_v0]->startPos.y; + if (play->csCtx.actorCues[cueChannel]->startPos.y != 0) { + this->unk_14C = (u32)play->csCtx.actorCues[cueChannel]->startPos.y; } else { this->unk_14C = 20.0f; } - if (play->csCtx.actorActions[temp_v0]->startPos.z != 0) { - this->unk_150 = (u32)play->csCtx.actorActions[temp_v0]->startPos.z; + if (play->csCtx.actorCues[cueChannel]->startPos.z != 0) { + this->unk_150 = (u32)play->csCtx.actorCues[cueChannel]->startPos.z; } else { this->unk_150 = 300.0f; } @@ -943,8 +971,8 @@ void func_80A92950(EnTest6* this, PlayState* play) { break; case 7: - if (play->csCtx.actorActions[temp_v0]->startPos.x != 0) { - this->unk_158 = (u32)play->csCtx.actorActions[temp_v0]->startPos.x; + if (play->csCtx.actorCues[cueChannel]->startPos.x != 0) { + this->unk_158 = (u32)play->csCtx.actorCues[cueChannel]->startPos.x; } else { this->unk_158 = -5.0f; } @@ -952,8 +980,8 @@ void func_80A92950(EnTest6* this, PlayState* play) { break; case 8: - if (play->csCtx.actorActions[temp_v0]->startPos.x != 0) { - this->unk_158 += (u32)play->csCtx.actorActions[temp_v0]->startPos.x; + if (play->csCtx.actorCues[cueChannel]->startPos.x != 0) { + this->unk_158 += (u32)play->csCtx.actorCues[cueChannel]->startPos.x; } else { this->unk_158 += 2.0f; } @@ -961,7 +989,7 @@ void func_80A92950(EnTest6* this, PlayState* play) { this->unk_154 += this->unk_158; if (this->unk_154 > 10000.0f) { this->unk_154 = 10000.0f; - this->unk_274 = 0; + this->cueId = 0; } break; @@ -976,7 +1004,7 @@ void func_80A92950(EnTest6* this, PlayState* play) { this->unk_276 = 99; play->transitionTrigger = TRANS_TRIGGER_START; play->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_RETURN].entrance; - play->transitionType = TRANS_TYPE_02; + play->transitionType = TRANS_TYPE_FADE_BLACK; if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 0))) { gSaveContext.respawnFlag = -0x63; SET_EVENTINF(EVENTINF_27); @@ -987,7 +1015,7 @@ void func_80A92950(EnTest6* this, PlayState* play) { return; } } else { - switch (this->unk_274) { + switch (this->cueId) { case 2: this->unk_276 = 0; this->unk_278 = 0; @@ -1016,7 +1044,7 @@ void func_80A92950(EnTest6* this, PlayState* play) { this->unk_150 += this->unk_158; if (this->unk_150 > 3500.0f) { this->unk_150 = 3500.0f; - this->unk_274 = 0; + this->cueId = 0; } break; @@ -1041,7 +1069,7 @@ void func_80A92950(EnTest6* this, PlayState* play) { this->unk_154 += this->unk_158; if (this->unk_154 > 10000.0f) { this->unk_154 = 10000.0f; - this->unk_274 = 0; + this->cueId = 0; } break; @@ -1058,7 +1086,7 @@ void func_80A92950(EnTest6* this, PlayState* play) { this->unk_276 = 99; play->transitionTrigger = TRANS_TRIGGER_START; play->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_RETURN].entrance; - play->transitionType = TRANS_TYPE_02; + play->transitionType = TRANS_TYPE_FADE_BLACK; gSaveContext.respawnFlag = 2; play->msgCtx.ocarinaMode = 4; } @@ -1231,7 +1259,7 @@ void func_80A939E8(EnTest6* this, PlayState* play2) { OPEN_DISPS(play->state.gfxCtx); - switch (this->unk_274) { + switch (this->cueId) { case 91: case 93: Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, @@ -1297,7 +1325,7 @@ void func_80A939E8(EnTest6* this, PlayState* play2) { void EnTest6_Draw(Actor* thisx, PlayState* play) { EnTest6* this = THIS; - if (this->unk_274 != 0) { + if (this->cueId != 0) { switch (this->unk_276) { case 1: func_80A93298(this, play); diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.h b/src/overlays/actors/ovl_En_Test6/z_en_test6.h index ec06afb91..d7e40a983 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.h +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.h @@ -31,13 +31,13 @@ typedef struct EnTest6 { /* 0x15C */ f32 unk_15C; /* 0x160 */ f32 unk_160; /* 0x164 */ EnTest6Light lights[2]; - /* 0x18C */ DbCameraUnkStruct unk_18C; + /* 0x18C */ CutsceneCamera unk_18C; /* 0x20C */ Vec3f unk_20C[6]; /* 0x254 */ Vec3f (*unk_254)[64]; /* 0x258 */ Vec3f subCamAt; /* 0x264 */ Vec3f subCamEye; /* 0x270 */ f32 subCamFov; - /* 0x274 */ s16 unk_274; + /* 0x274 */ s16 cueId; /* 0x276 */ s16 unk_276; /* 0x278 */ s16 unk_278; /* 0x27A */ s16 unk_27A; diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.c b/src/overlays/actors/ovl_En_Test7/z_en_test7.c index 43facd831..9c672ed51 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -412,12 +412,12 @@ void EnTest7_Init(Actor* thisx, PlayState* play2) { Audio_PlayBgm_StorePrevBgm(NA_BGM_SONG_OF_SOARING); } - if (play->playerActorCsIds[8] == -1) { + if (play->playerCsIds[PLAYER_CS_ID_SONG_WARP] == CS_ID_NONE) { Actor_Kill(&this->actor); return; } - ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); + CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); player2->stateFlags1 |= PLAYER_STATE1_20; Lights_PointNoGlowSetInfo(&this->lightInfo, (Math_SinS(this->unk_1E8E) * 90.0f) + player->actor.world.pos.x, player->actor.world.pos.y + 10.0f, @@ -428,17 +428,17 @@ void EnTest7_Init(Actor* thisx, PlayState* play2) { void EnTest7_Destroy(Actor* thisx, PlayState* play) { EnTest7* this = THIS; - ActorCutscene_Stop(play->playerActorCsIds[8]); + CutsceneManager_Stop(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); } void func_80AF19A8(EnTest7* this, PlayState* play) { - if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[8])) { - ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); + if (!CutsceneManager_IsNext(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])) { + CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); } else { - ActorCutscene_Start(play->playerActorCsIds[8], NULL); + CutsceneManager_Start(play->playerCsIds[PLAYER_CS_ID_SONG_WARP], NULL); func_80AF082C(this, func_80AF1A2C); - play->unk_18844 = 1; + play->unk_18844 = true; } } @@ -452,7 +452,8 @@ void func_80AF1A2C(EnTest7* this, PlayState* play) { func_800FD698(play, 2000, 4000, sp2C); if (this->unk_1E54 >= 10) { - Camera* subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + Camera* subCam = + Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])); this->subCamEye = subCam->eye; this->subCamAt = subCam->at; @@ -461,7 +462,7 @@ void func_80AF1A2C(EnTest7* this, PlayState* play) { func_80AF082C(this, func_80AF1CA0); this->unk_144 |= 0x20; Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_OPEN); - func_8016566C(0x78); + Play_EnableMotionBlur(120); } } @@ -514,7 +515,8 @@ void func_80AF1CA0(EnTest7* this, PlayState* play) { } if (Rand_ZeroOne() < 0.3f) { - Camera* subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + Camera* subCam = + Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])); f32 rand = Rand_ZeroOne(); sp34.x = ((subCam->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; @@ -537,7 +539,7 @@ void func_80AF1E44(EnTest7* this, PlayState* play) { func_80AF1B68(this, play); if (Rand_ZeroOne() < 0.3f) { - subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + subCam = Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])); rand = Rand_ZeroOne(); sp34.x = ((subCam->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; sp34.y = ((subCam->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; @@ -585,7 +587,7 @@ void func_80AF2030(EnTest7* this, PlayState* play) { this->unk_148.unk_10 -= 0x2EE0; this->actor.world.pos.y += 100.0f; - subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + subCam = Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])); subCam->focalActor = NULL; subCam->eye.x = ((subCam->eye.x - this->subCamEye.x) * sp1C) + this->subCamEye.x; @@ -599,10 +601,10 @@ void func_80AF2030(EnTest7* this, PlayState* play) { R_PLAY_FILL_SCREEN_G = 255; R_PLAY_FILL_SCREEN_B = 255; R_PLAY_FILL_SCREEN_ALPHA = 255; - play->unk_18844 = 0; + play->unk_18844 = false; this->unk_144 &= ~4; func_80AF082C(this, func_80AF21E8); - func_80165690(); + Play_DisableMotionBlur(); } } @@ -667,16 +669,17 @@ void func_80AF2350(EnTest7* this, PlayState* play) { gSaveContext.respawnFlag = -6; } else { play->nextEntrance = D_80AF343C[ENTEST7_GET(&this->actor) - ENTEST7_1C]; - if ((play->nextEntrance == ENTRANCE(SOUTHERN_SWAMP_POISONED, 10)) && CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { + if ((play->nextEntrance == ENTRANCE(SOUTHERN_SWAMP_POISONED, 10)) && + CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE)) { play->nextEntrance = ENTRANCE(SOUTHERN_SWAMP_CLEARED, 10); } else if ((play->nextEntrance == ENTRANCE(MOUNTAIN_VILLAGE_WINTER, 8)) && - CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { + CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE)) { play->nextEntrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 8); } } play->transitionTrigger = TRANS_TRIGGER_START; - play->transitionType = TRANS_TYPE_02; + play->transitionType = TRANS_TYPE_FADE_BLACK; gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; } @@ -685,7 +688,8 @@ void func_80AF24D8(EnTest7* this, PlayState* play, f32 arg2) { Vec3f sp3C; Vec3f* pos; Player* player = GET_PLAYER(play); - Camera* subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + Camera* subCam = + Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])); pos = &player->actor.world.pos; subCam->focalActor = NULL; @@ -708,7 +712,7 @@ void func_80AF2654(EnTest7* this, PlayState* play, f32 arg2) { Camera* subCam; Vec3f sp30; - subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + subCam = Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])); subCam->focalActor = NULL; pos = &player->actor.world.pos; @@ -762,7 +766,7 @@ void func_80AF2938(EnTest7* this, PlayState* play) { player->stateFlags2 |= PLAYER_STATE2_20000000; this->unk_144 |= 2; this->unk_148.unk_04 = 30.0f; - if (play->roomCtx.curRoom.unk3 != 1) { + if (play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_1) { func_80AF082C(this, func_80AF2AE8); } else { func_80AF082C(this, func_80AF2EC8); @@ -777,7 +781,8 @@ void func_80AF29C0(EnTest7* this, PlayState* play) { s32 pad; Player* player = GET_PLAYER(play); Vec3f* pos = &player->actor.world.pos; - Camera* subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + Camera* subCam = + Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])); subCam->at.x = ((D_80AF3454 * Math_SinS(D_80AF3450[0]) * Math_CosS(D_80AF3450[1]))) + pos->x; subCam->at.y = (Math_SinS(D_80AF3450[1]) * D_80AF3454) + pos->y; @@ -791,15 +796,15 @@ void func_80AF29C0(EnTest7* this, PlayState* play) { void func_80AF2AE8(EnTest7* this, PlayState* play) { Camera* subCam; - if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[8])) { - ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); + if (!CutsceneManager_IsNext(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])) { + CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); return; } - ActorCutscene_Start(play->playerActorCsIds[8], NULL); + CutsceneManager_Start(play->playerCsIds[PLAYER_CS_ID_SONG_WARP], NULL); func_80AF082C(this, func_80AF2C48); - subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + subCam = Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])); this->subCamEye = subCam->eye; this->subCamAt = subCam->at; @@ -810,7 +815,8 @@ void func_80AF2BAC(EnTest7* this, PlayState* play, Vec3f* arg2, f32 arg3) { f32 x; f32 y; f32 z; - Camera* subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + Camera* subCam = + Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])); subCam->focalActor = NULL; x = ((subCam->at.x - arg2->x) * arg3) + arg2->x; @@ -836,7 +842,7 @@ void func_80AF2C48(EnTest7* this, PlayState* play) { this->actor.world.pos.y = ((this->actor.world.pos.y - this->actor.home.pos.y) * sp24) + this->actor.home.pos.y; this->actor.world.pos.z = ((this->actor.world.pos.z - this->actor.home.pos.z) * sp24) + this->actor.home.pos.z; - subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + subCam = Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])); func_80AF2BAC(this, play, &this->actor.home.pos, sp24); subCam->at.x = this->actor.world.pos.x; @@ -855,7 +861,7 @@ void func_80AF2DB4(EnTest7* this, PlayState* play) { Player* player = GET_PLAYER(play); Vec3f* pos = &player->actor.world.pos; - subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + subCam = Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])); subCam->eye.x = (Math_SinS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->x; subCam->eye.y = pos->y + 108.8042f; @@ -869,13 +875,13 @@ void func_80AF2DB4(EnTest7* this, PlayState* play) { void func_80AF2EC8(EnTest7* this, PlayState* play) { Camera* subCam; - if (!ActorCutscene_GetCanPlayNext(play->playerActorCsIds[8])) { - ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); + if (!CutsceneManager_IsNext(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])) { + CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); } else { - ActorCutscene_Start(play->playerActorCsIds[8], NULL); + CutsceneManager_Start(play->playerCsIds[PLAYER_CS_ID_SONG_WARP], NULL); func_80AF082C(this, func_80AF2F98); - subCam = Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(play->playerActorCsIds[8])); + subCam = Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])); this->subCamEye = subCam->eye; this->subCamAt = subCam->at; this->unk_1E54 = 40; diff --git a/src/overlays/actors/ovl_En_Tg/z_en_tg.c b/src/overlays/actors/ovl_En_Tg/z_en_tg.c index 947f97b62..ed048288e 100644 --- a/src/overlays/actors/ovl_En_Tg/z_en_tg.c +++ b/src/overlays/actors/ovl_En_Tg/z_en_tg.c @@ -162,7 +162,7 @@ void EnTg_Update(Actor* thisx, PlayState* play) { EnTg* this = THIS; this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); EnTg_UpdateSkelAnime(this, play); EnTg_UpdateHearts(play, this->effects, ARRAY_COUNT(this->effects)); EnTg_UpdateCollider(this, play); @@ -259,7 +259,7 @@ void EnTg_DrawHearts(PlayState* play, EnTgHeartEffect* effect, s32 numEffects) { OPEN_DISPS(play->state.gfxCtx); - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); for (i = 0; i < numEffects; i++, effect++) { 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 58f44d468..a26095bc7 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -7,7 +7,7 @@ #include "prevent_bss_reordering.h" #include "z_en_thiefbird.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200 | ACTOR_FLAG_1000 | ACTOR_FLAG_80000000) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_80000000) #define THIS ((EnThiefbird*)thisx) @@ -223,10 +223,10 @@ s32 func_80C10B0C(EnThiefbird* this, PlayState* play) { s16 itemId2 = 0; for (; slotId < 24; slotId++) { - if ((gSaveContext.save.inventory.items[slotId] >= ITEM_BOTTLE) && - (gSaveContext.save.inventory.items[slotId] <= ITEM_POTION_BLUE)) { + if ((gSaveContext.save.saveInfo.inventory.items[slotId] >= ITEM_BOTTLE) && + (gSaveContext.save.saveInfo.inventory.items[slotId] <= ITEM_POTION_BLUE)) { isItemFound = true; - itemId2 = gSaveContext.save.inventory.items[slotId]; + itemId2 = gSaveContext.save.saveInfo.inventory.items[slotId]; break; } } @@ -343,7 +343,7 @@ s32 func_80C10E98(PlayState* play) { spAC = 0; } - sp98 = (gSaveContext.save.playerData.rupees / 4) * 3; + sp98 = (gSaveContext.save.saveInfo.playerData.rupees / 4) * 3; phi_s0_2 = sp98 / 50; sp5C = (-spB0 - spAC); sp5C += 8; @@ -403,7 +403,7 @@ s32 func_80C10E98(PlayState* play) { if (temp_s1_5 != NULL) { temp_s1_5->velocity.y = Rand_ZeroFloat(3.0f) + 6.0f; - temp_s1_5->speedXZ = Rand_ZeroFloat(3.0f) + 3.0f; + temp_s1_5->speed = 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)); @@ -430,7 +430,7 @@ void func_80C11338(EnThiefbird* this, PlayState* play) { item = (EnItem00*)SubS_FindActor(play, &item->actor, ACTORCAT_MISC, ACTOR_EN_ITEM00); if (item != NULL) { if (item->unk152 > 0) { - if (Actor_XZDistanceBetweenActors(&player->actor, &item->actor) > 10.0f) { + if (Actor_WorldDistXZToActor(&player->actor, &item->actor) > 10.0f) { for (i = 0; i < ARRAY_COUNT(D_80C13664); i++) { if (item->actor.params == D_80C13664[i]) { break; @@ -438,7 +438,7 @@ void func_80C11338(EnThiefbird* this, PlayState* play) { } if (i != ARRAY_COUNT(D_80C13664)) { - temp_f0 = Actor_DistanceBetweenActors(&this->actor, &item->actor); + temp_f0 = Actor_WorldDistXYZToActor(&this->actor, &item->actor); if (temp_f0 < phi_f20) { this->unk_3EC = item; phi_f20 = temp_f0; @@ -457,7 +457,7 @@ void func_80C11454(EnThiefbird* this) { this->drawDmgEffFrozenSteamScale = 0.75f; this->drawDmgEffAlpha = 1.0f; this->actor.flags &= ~ACTOR_FLAG_200; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 80); } void func_80C114C0(EnThiefbird* this, PlayState* play) { @@ -482,29 +482,29 @@ void func_80C11590(EnThiefbird* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); sp38 = Animation_OnFrame(&this->skelAnime, 0.0f); - this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 3.0f; + this->actor.speed = (Rand_ZeroOne() * 1.5f) + 3.0f; - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->unk_192 = this->actor.wallYaw; } else { - if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 300.0f) { - this->unk_192 = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) > 300.0f) { + this->unk_192 = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); } } if (!Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_192, 5, 0x300, 0x10) && (sp38 != 0) && (Rand_ZeroOne() < 0.1f)) { - s16 yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y; + s16 yaw = Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y; if (yaw > 0) { this->unk_192 += Rand_S16Offset(4096, 4096); } else { this->unk_192 -= Rand_S16Offset(4096, 4096); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); + Actor_PlaySfx(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); } - if ((this->actor.depthInWater > -40.0f) || (this->actor.bgCheckFlags & 1)) { + if ((this->actor.depthInWater > -40.0f) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { this->unk_190 = -4096; } else if (this->actor.world.pos.y < (this->actor.home.pos.y - 75.0f)) { this->unk_190 = -Rand_S16Offset(2048, 2048); @@ -538,7 +538,7 @@ void func_80C118E4(EnThiefbird* this) { Animation_MorphToLoop(&this->skelAnime, &gTakkuriAttackAnim, -10.0f); this->unk_18E = 300; this->actionFunc = func_80C1193C; - this->actor.speedXZ = 5.0f; + this->actor.speed = 5.0f; } void func_80C1193C(EnThiefbird* this, PlayState* play) { @@ -547,17 +547,17 @@ void func_80C1193C(EnThiefbird* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_FLUTTER); + Actor_PlaySfx(&this->actor, NA_SE_EN_KAICHO_FLUTTER); } if (this->unk_18E != 0) { this->unk_18E--; } - pitch = Actor_PitchBetweenActors(&this->actor, &player->actor); + pitch = Actor_WorldPitchTowardActor(&this->actor, &player->actor); pitch = CLAMP(pitch, -0x2800, 0x2800); Math_SmoothStepToS(&this->actor.shape.rot.x, pitch, 4, 0x800, 0x80); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 6, 0x1000, 0x100); } else if (Actor_IsFacingPlayer(&this->actor, 0x3C00) || (this->actor.xzDistToPlayer > 120.0f)) { s16 rot = BINANG_ROT180(this->actor.yawTowardsPlayer - player->actor.shape.rot.y); @@ -574,10 +574,10 @@ void func_80C1193C(EnThiefbird* this, PlayState* play) { if ((this->unk_18E == 0) || (player->stateFlags1 & PLAYER_STATE1_800000) || (Player_GetMask(play) == PLAYER_MASK_STONE) || (this->collider.base.atFlags & AT_HIT) || - (this->actor.bgCheckFlags & 1) || (this->actor.depthInWater > -40.0f)) { + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->actor.depthInWater > -40.0f)) { if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); + Actor_PlaySfx(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); if (!(this->collider.base.atFlags & AT_BOUNCED)) { if ((D_80C1392C != 0) && CUR_UPG_VALUE(UPG_QUIVER) && ((STOLEN_ITEM_1 == STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 == STOLEN_ITEM_NONE)) && @@ -599,15 +599,15 @@ void func_80C1193C(EnThiefbird* this, PlayState* play) { } void func_80C11C60(EnThiefbird* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; Animation_PlayOnce(&this->skelAnime, &gTakkuriDeathAnim); - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->actor.shape.rot.x = 0; this->unk_18E = 40; this->actor.velocity.y = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_DEAD); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_THIEFBIRD_DEAD); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 40); this->collider.base.acFlags &= ~AC_ON; this->actor.flags |= ACTOR_FLAG_10; this->unk_192 = 0x1C00; @@ -623,7 +623,7 @@ void func_80C11D14(EnThiefbird* this, PlayState* play) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if (this->unk_18E < 38) { func_80C114C0(this, play); - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; } else { return; } @@ -654,7 +654,7 @@ void func_80C11DF0(EnThiefbird* this, PlayState* play) { this->actor.shape.rot.y += this->unk_192; } - if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { func_800B3030(play, &this->limbPos[i], &gZeroVec3f, &gZeroVec3f, 0x8C, 0, 0); } @@ -676,20 +676,20 @@ void func_80C11F6C(EnThiefbird* this, PlayState* play) { Animation_MorphToLoop(&this->skelAnime, &gTakkuriFlyWithItemAnim, -4.0f); func_80C10984(this, 15); if (this->actor.colChkInfo.damageEffect != 3) { - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; } else { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } if (this->actor.colChkInfo.damageEffect == 5) { - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); } else if (this->actor.colChkInfo.damageEffect == 1) { - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); } else { - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_DAMAGE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_THIEFBIRD_DAMAGE); } this->collider.base.acFlags &= ~AC_ON; @@ -697,7 +697,7 @@ void func_80C11F6C(EnThiefbird* this, PlayState* play) { this->unk_190 = -0x1000; this->unk_192 = BINANG_ROT180(this->actor.yawTowardsPlayer); } else { - this->unk_190 = Actor_PitchToPoint(&this->actor, &D_80C13920); + this->unk_190 = Actor_WorldPitchTowardPoint(&this->actor, &D_80C13920); } this->unk_18E = 40; @@ -725,20 +725,20 @@ void func_80C1215C(EnThiefbird* this, PlayState* play) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if (this->unk_18E < 38) { func_80C114C0(this, play); - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; } else { return; } } SkelAnime_Update(&this->skelAnime); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->unk_192 = this->actor.wallYaw; } else if (this->unk_3E8 == 0) { this->unk_192 = BINANG_ROT180(this->actor.yawTowardsPlayer); } else { - this->unk_192 = Actor_YawToPoint(&this->actor, &D_80C13920); - this->unk_190 = Actor_PitchToPoint(&this->actor, &D_80C13920); + this->unk_192 = Actor_WorldYawTowardPoint(&this->actor, &D_80C13920); + this->unk_190 = Actor_WorldPitchTowardPoint(&this->actor, &D_80C13920); } Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_192, 6, 0x1000, 0x100); @@ -771,7 +771,7 @@ void func_80C12378(EnThiefbird* this, PlayState* play) { } SkelAnime_Update(&this->skelAnime); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->unk_192 = this->actor.wallYaw; } else { this->unk_192 = BINANG_ROT180(this->actor.yawTowardsPlayer); @@ -790,7 +790,7 @@ void func_80C1242C(EnThiefbird* this) { this->actor.flags |= ACTOR_FLAG_10; this->collider.base.acFlags |= AC_ON; this->actionFunc = func_80C124B0; - this->actor.speedXZ = 12.0f; + this->actor.speed = 12.0f; } void func_80C124B0(EnThiefbird* this, PlayState* play) { @@ -798,17 +798,18 @@ void func_80C124B0(EnThiefbird* this, PlayState* play) { s16 temp_v1; SkelAnime_Update(&this->skelAnime); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->unk_192 = this->actor.wallYaw; } else { - this->unk_192 = Actor_YawToPoint(&this->actor, &D_80C13920); + this->unk_192 = Actor_WorldYawTowardPoint(&this->actor, &D_80C13920); } Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_192, 6, 0x1000, 0x100); - Math_SmoothStepToS(&this->actor.shape.rot.x, Actor_PitchToPoint(&this->actor, &D_80C13920), 6, 0x1000, 0x100); + Math_SmoothStepToS(&this->actor.shape.rot.x, Actor_WorldPitchTowardPoint(&this->actor, &D_80C13920), 6, 0x1000, + 0x100); temp_v0 = func_800BC270(play, &this->actor, 80.0f, 0x138B0); if (temp_v0 != NULL) { - temp_v1 = temp_v0->world.rot.x - Actor_PitchToPoint(temp_v0, &this->actor.focus.pos); + temp_v1 = temp_v0->world.rot.x - Actor_WorldPitchTowardPoint(temp_v0, &this->actor.focus.pos); if (ABS_ALT(temp_v1) < 0x1800) { if (temp_v1 > 0) { this->unk_3E0 = 25.0f; @@ -826,7 +827,7 @@ void func_80C124B0(EnThiefbird* this, PlayState* play) { this->unk_3E0 * Math_SinS(this->actor.shape.rot.x) * Math_CosS(this->actor.shape.rot.y); } - if (Actor_DistanceToPoint(&this->actor, &D_80C13920) < 1000.0f) { + if (Actor_WorldDistXYZToPoint(&this->actor, &D_80C13920) < 1000.0f) { func_80C126A8(this); } } @@ -852,7 +853,7 @@ void func_80C12744(EnThiefbird* this) { this->collider.base.acFlags |= AC_ON; this->actor.flags |= ACTOR_FLAG_10; this->actionFunc = func_80C127F4; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; this->skelAnime.playSpeed = 3.0f; } @@ -863,7 +864,7 @@ void func_80C127F4(EnThiefbird* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if ((this->unk_3EC != NULL) && ((this->unk_3EC->actor.update == NULL) || (this->unk_3EC->unk152 == 0) || - (Actor_XZDistanceBetweenActors(&player->actor, &this->unk_3EC->actor) <= 10.0f))) { + (Actor_WorldDistXZToActor(&player->actor, &this->unk_3EC->actor) <= 10.0f))) { this->unk_3EC = NULL; } @@ -880,19 +881,19 @@ void func_80C127F4(EnThiefbird* this, PlayState* play) { } if (this->unk_3EC != NULL) { - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 3, 0x2000, 0x100); } else { - Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, &this->unk_3EC->actor), 3, - 0x2000, 0x100); + Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardActor(&this->actor, &this->unk_3EC->actor), + 3, 0x2000, 0x100); } temp_v0 = Math_Vec3f_Pitch(&this->limbPos[9], &this->unk_3EC->actor.world.pos); temp_v0 = CLAMP(temp_v0, -0x3000, 0x3000); Math_SmoothStepToS(&this->actor.shape.rot.x, temp_v0, 4, 0x800, 0x80); - temp_f0 = Actor_DistanceToPoint(&this->unk_3EC->actor, &this->limbPos[9]); - this->actor.speedXZ = (0.02f * temp_f0) + 2.0f; - this->actor.speedXZ = CLAMP_MAX(this->actor.speedXZ, 4.0f); - if ((this->unk_3EC->actor.speedXZ <= 0.0f) && (temp_f0 < 40.0f)) { + temp_f0 = Actor_WorldDistXYZToPoint(&this->unk_3EC->actor, &this->limbPos[9]); + this->actor.speed = (0.02f * temp_f0) + 2.0f; + this->actor.speed = CLAMP_MAX(this->actor.speed, 4.0f); + if ((this->unk_3EC->actor.speed <= 0.0f) && (temp_f0 < 40.0f)) { s32 i; this->unk_3EC->unk152 = 0; @@ -907,8 +908,8 @@ void func_80C127F4(EnThiefbird* this, PlayState* play) { this->unk_190 = -0x3800; } } else { - this->actor.speedXZ = 4.0f; - if (this->actor.bgCheckFlags & 8) { + this->actor.speed = 4.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 6, 0x1000, 0x100); } else { Math_SmoothStepToS(&this->actor.shape.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 6, 0x1000, 0x100); @@ -1019,7 +1020,8 @@ void EnThiefbird_Update(Actor* thisx, PlayState* play2) { Actor_MoveWithGravity(&this->actor); } - Actor_UpdateBgCheckInfo(play, &this->actor, 25.0f, 25.0f, 50.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 25.0f, 25.0f, 50.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); if (this->actionFunc == func_80C1193C) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } @@ -1042,7 +1044,7 @@ void EnThiefbird_Update(Actor* thisx, PlayState* play2) { func_80C12D00(this); if (((this->skelAnime.animation == &gTakkuriFlyAnim) && Animation_OnFrame(&this->skelAnime, 13.0f)) || ((this->skelAnime.animation == &gTakkuriFlyWithItemAnim) && Animation_OnFrame(&this->skelAnime, 1.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_FLUTTER); + Actor_PlaySfx(&this->actor, NA_SE_EN_KAICHO_FLUTTER); } } diff --git a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c index 4e09f01a9..10f3ea529 100644 --- a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c +++ b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c @@ -1,7 +1,11 @@ /* * File: z_en_time_tag.c * Overlay: ovl_En_Time_Tag - * Description: + * Description: Various text-, time- and event-based triggers. There are 4 variations of this actor. + * - Song of Soaring engraving + * - Clocktown Rooftop Oath to Order event + * - Mikau's and Lulu's diary + * - Kick out of scene event after a certain time */ #include "z_en_time_tag.h" @@ -15,20 +19,23 @@ void EnTimeTag_Init(Actor* thisx, PlayState* play); void EnTimeTag_Destroy(Actor* thisx, PlayState* play); void EnTimeTag_Update(Actor* thisx, PlayState* play); -void func_80AC9FD4(EnTimeTag* this, PlayState* play); -void func_80AC9FE4(EnTimeTag* this, PlayState* play); -void func_80ACA0A8(EnTimeTag* this, PlayState* play); -void func_80ACA12C(EnTimeTag* this, PlayState* play); -void func_80ACA184(EnTimeTag* this, PlayState* play); -void func_80ACA268(EnTimeTag* this, PlayState* play); -void func_80ACA348(EnTimeTag* this, PlayState* play); -void func_80ACA3C0(EnTimeTag* this, PlayState* play); -void func_80ACA418(EnTimeTag* this, PlayState* play); -void func_80ACA5F8(EnTimeTag* this, PlayState* play); -void func_80ACA714(EnTimeTag* this, PlayState* play); -void func_80ACA724(EnTimeTag* this, PlayState* play); -void func_80ACA7C4(EnTimeTag* this, PlayState* play); -void func_80ACA840(EnTimeTag* this, PlayState* play); +void EnTimeTag_RooftopOath_DoNothing(EnTimeTag* this, PlayState* play); +void EnTimeTag_RooftopOath_Cutscene(EnTimeTag* this, PlayState* play); +void EnTimeTag_RooftopOath_Wait(EnTimeTag* this, PlayState* play); + +void EnTimeTag_SoaringEngraving_GetSong(EnTimeTag* this, PlayState* play); +void EnTimeTag_SoaringEngraving_StartCutscene(EnTimeTag* this, PlayState* play); +void EnTimeTag_SoaringEngraving_Wait(EnTimeTag* this, PlayState* play); + +void EnTimeTag_Diary_AfterOcarina(EnTimeTag* this, PlayState* play); +void EnTimeTag_Diary_TeachEvanSongSnippets(EnTimeTag* this, PlayState* play); +void EnTimeTag_Diary_Cutscene(EnTimeTag* this, PlayState* play); +void EnTimeTag_Diary_Wait(EnTimeTag* this, PlayState* play); + +void EnTimeTag_KickOut_DoNothing(EnTimeTag* this, PlayState* play); +void EnTimeTag_KickOut_Transition(EnTimeTag* this, PlayState* play); +void EnTimeTag_KickOut_WaitForTrigger(EnTimeTag* this, PlayState* play); +void EnTimeTag_KickOut_WaitForTime(EnTimeTag* this, PlayState* play); ActorInit En_Time_Tag_InitVars = { ACTOR_EN_TIME_TAG, @@ -45,37 +52,41 @@ ActorInit En_Time_Tag_InitVars = { void EnTimeTag_Init(Actor* thisx, PlayState* play) { EnTimeTag* this = THIS; - this->actionFunc = func_80ACA840; + this->actionFunc = EnTimeTag_KickOut_WaitForTime; - switch (ENTIMETAG_GET_E000(&this->actor)) { - case 4: + switch (TIMETAG_GET_TYPE(&this->actor)) { + case TIMETAG_KICKOUT_FINAL_HOURS: if (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_40) || (CURRENT_DAY != 3)) { Actor_Kill(&this->actor); return; } - this->actor.home.rot.x = 0; - this->actor.home.rot.y = 0; + // Overwrite kickout time to midnight + TIMETAG_KICKOUT_HOUR(&this->actor) = 0; + TIMETAG_KICKOUT_MINUTE(&this->actor) = 0; break; - case 2: - this->actionFunc = func_80ACA0A8; + case TIMETAG_ROOFTOP_OATH: + this->actionFunc = EnTimeTag_RooftopOath_Wait; this->actor.flags |= ACTOR_FLAG_2000000; break; - case 1: - this->actionFunc = func_80ACA268; + case TIMETAG_SOARING_ENGRAVING: + this->actionFunc = EnTimeTag_SoaringEngraving_Wait; this->actor.flags |= ACTOR_FLAG_2000000; if (CHECK_QUEST_ITEM(QUEST_SONG_SOARING)) { this->actor.textId = 0xC02; - return; + } else { + this->actor.textId = 0; } - this->actor.textId = 0; break; - case 3: - this->actionFunc = func_80ACA5F8; + case TIMETAG_DIARY: + this->actionFunc = EnTimeTag_Diary_Wait; this->actor.textId = 0; - this->actor.home.rot.x = 0; + TIMETAG_DIARY_TIMER(&this->actor) = 0; + break; + + default: break; } } @@ -83,222 +94,249 @@ void EnTimeTag_Init(Actor* thisx, PlayState* play) { void EnTimeTag_Destroy(Actor* thisx, PlayState* play) { } -void func_80AC9FD4(EnTimeTag* this, PlayState* play) { +void EnTimeTag_RooftopOath_DoNothing(EnTimeTag* this, PlayState* play) { } -void func_80AC9FE4(EnTimeTag* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); - this->actionFunc = func_80AC9FD4; +void EnTimeTag_RooftopOath_Cutscene(EnTimeTag* this, PlayState* play) { + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); + + this->actionFunc = EnTimeTag_RooftopOath_DoNothing; gSaveContext.timerStates[TIMER_ID_MOON_CRASH] = TIMER_STATE_OFF; + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { SET_WEEKEVENTREG(WEEKEVENTREG_25_02); } } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } -void func_80ACA0A8(EnTimeTag* this, PlayState* play) { +void EnTimeTag_RooftopOath_Wait(EnTimeTag* this, PlayState* play) { EnTimeTag* this2 = this; if ((play->msgCtx.ocarinaMode == 3) && (play->msgCtx.lastPlayedSong == OCARINA_SONG_OATH)) { - if (this->actor.cutscene != -1) { - this->actionFunc = func_80AC9FE4; - ActorCutscene_SetIntentToPlay(this2->actor.cutscene); + if (this->actor.csId != CS_ID_NONE) { + this->actionFunc = EnTimeTag_RooftopOath_Cutscene; + CutsceneManager_Queue(this2->actor.csId); gSaveContext.timerStates[TIMER_ID_MOON_CRASH] = TIMER_STATE_OFF; } play->msgCtx.ocarinaMode = 4; } } -void func_80ACA12C(EnTimeTag* this, PlayState* play) { - if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { - this->actionFunc = func_80ACA268; +void EnTimeTag_SoaringEngraving_GetSong(EnTimeTag* this, PlayState* play) { + if (CutsceneManager_GetCurrentCsId() != this->actor.csId) { + this->actionFunc = EnTimeTag_SoaringEngraving_Wait; this->actor.textId = 0xC02; Item_Give(play, ITEM_SONG_SOARING); } } -void func_80ACA184(EnTimeTag* this, PlayState* play) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actor.cutscene); - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); - this->actionFunc = func_80ACA12C; +void EnTimeTag_SoaringEngraving_StartCutscene(EnTimeTag* this, PlayState* play) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->actor.csId); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); + this->actionFunc = EnTimeTag_SoaringEngraving_GetSong; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } -void func_80ACA208(EnTimeTag* this, PlayState* play) { +void EnTimeTag_SoaringEngraving_SubsequentInteraction(EnTimeTag* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); - this->actionFunc = func_80ACA268; + Message_CloseTextbox(play); + this->actionFunc = EnTimeTag_SoaringEngraving_Wait; } } -void func_80ACA268(EnTimeTag* this, PlayState* play) { +void EnTimeTag_SoaringEngraving_Wait(EnTimeTag* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->actor.textId == 0) { - this->actionFunc = func_80ACA184; + this->actionFunc = EnTimeTag_SoaringEngraving_StartCutscene; } else { - this->actionFunc = func_80ACA208; + this->actionFunc = EnTimeTag_SoaringEngraving_SubsequentInteraction; } } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play) && - (Flags_GetSwitch(play, ENTIMETAG_GET_SWITCHFLAG(&this->actor)) || + (Flags_GetSwitch(play, TIMETAG_SOARING_GET_SWITCHFLAG(&this->actor)) || CHECK_QUEST_ITEM(QUEST_SONG_SOARING))) { this->actor.flags |= ACTOR_FLAG_1; func_800B8614(&this->actor, play, 110.0f); } } -void func_80ACA348(EnTimeTag* this, PlayState* play) { - if (this->actor.home.rot.x > 0) { - this->actor.home.rot.x--; +void EnTimeTag_Diary_AfterOcarina(EnTimeTag* this, PlayState* play) { + if (TIMETAG_DIARY_TIMER(&this->actor) > 0) { + TIMETAG_DIARY_TIMER(&this->actor)--; return; } - if (this->actor.home.rot.z != 0) { - func_80151938(play, 0x1230); + if (TIMETAG_DIARY_SONG(&this->actor) != TIMETAG_DIARY_SONG_EVAN_PART1) { + // TIMETAG_DIARY_SONG_EVAN_PART2 + Message_ContinueTextbox(play, 0x1230); } else { - func_80151938(play, 0x122D); + // TIMETAG_DIARY_SONG_EVAN_PART1 + Message_ContinueTextbox(play, 0x122D); } - this->actionFunc = func_80ACA418; + this->actionFunc = EnTimeTag_Diary_Cutscene; } -void func_80ACA3C0(EnTimeTag* this, PlayState* play) { - if ((play->msgCtx.unk11F00->state == 0) && (play->msgCtx.msgMode == 0x1B)) { - this->actor.home.rot.x = 5; - this->actionFunc = func_80ACA348; +void EnTimeTag_Diary_TeachEvanSongSnippets(EnTimeTag* this, PlayState* play) { + if ((play->msgCtx.ocarinaStaff->state == 0) && (play->msgCtx.msgMode == 0x1B)) { + TIMETAG_DIARY_TIMER(&this->actor) = 5; + this->actionFunc = EnTimeTag_Diary_AfterOcarina; play->msgCtx.msgLength = 0; play->msgCtx.msgMode = 0; } } -void func_80ACA418(EnTimeTag* this, PlayState* play) { +void EnTimeTag_Diary_Cutscene(EnTimeTag* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { - case 0x101C: - case 0x101D: - case 0x101E: - case 0x122D: - func_80151938(play, play->msgCtx.currentTextId + 1); + case 0x101C: // Lulu diary part 1 + case 0x101D: // Lulu diary part 2 + case 0x101E: // Lulu diary part 3 + case 0x122D: // Mikau diary part 2 + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; - case 0x101F: - case 0x122A: - case 0x1230: - func_801477B4(play); - this->actionFunc = func_80ACA5F8; - if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { - ActorCutscene_Stop(this->actor.cutscene); + case 0x101F: // Lulu diary part 4 + case 0x122A: // Can not read Zora script + case 0x1230: // Mikau diary part 4 + Message_CloseTextbox(play); + this->actionFunc = EnTimeTag_Diary_Wait; + if (CutsceneManager_GetCurrentCsId() == this->actor.csId) { + CutsceneManager_Stop(this->actor.csId); } break; - case 0x122B: + case 0x122B: // Mikau diary part 1 func_80152434(play, 0x3F); - this->actionFunc = func_80ACA3C0; - this->actor.home.rot.z = 0; + this->actionFunc = EnTimeTag_Diary_TeachEvanSongSnippets; + TIMETAG_DIARY_SONG(&this->actor) = TIMETAG_DIARY_SONG_EVAN_PART1; break; - case 0x122E: + case 0x122E: // Mikau diary part 3 func_80152434(play, 0x40); - this->actionFunc = func_80ACA3C0; - this->actor.home.rot.z = 1; + this->actionFunc = EnTimeTag_Diary_TeachEvanSongSnippets; + TIMETAG_DIARY_SONG(&this->actor) = TIMETAG_DIARY_SONG_EVAN_PART2; + break; + + default: break; } } break; case TEXT_STATE_CLOSING: - this->actionFunc = func_80ACA5F8; + this->actionFunc = EnTimeTag_Diary_Wait; break; } - if (this->actor.home.rot.x != 0) { - if (this->actor.cutscene == -1) { - this->actor.home.rot.x = 0; - } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actor.cutscene); - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); - this->actor.home.rot.x = 0; + if (TIMETAG_DIARY_TIMER(&this->actor) != 0) { + if (this->actor.csId == CS_ID_NONE) { + TIMETAG_DIARY_TIMER(&this->actor) = 0; + } else if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->actor.csId); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); + TIMETAG_DIARY_TIMER(&this->actor) = 0; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } } -void func_80ACA5F8(EnTimeTag* this, PlayState* play) { +void EnTimeTag_Diary_Wait(EnTimeTag* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { - if (ENTIMETAG_GET_SWITCHFLAG(&this->actor) == 1) { + if (TIMETAG_DIARY_GET_TYPE(&this->actor) == TIMETAG_DIARY_LULU) { Message_StartTextbox(play, 0x101C, &this->actor); } else { + // TIMETAG_DIARY_MIKAU Message_StartTextbox(play, 0x122B, &this->actor); } - this->actor.home.rot.x = 1; + TIMETAG_DIARY_TIMER(&this->actor) = 1; } else { + // unable to read Zora script Message_StartTextbox(play, 0x122A, &this->actor); + + //! FAKE: https://decomp.me/scratch/AHRNe if (0) {} + ((EnElf*)GET_PLAYER(play)->tatlActor)->unk_264 |= 4; Actor_ChangeFocus(&this->actor, play, GET_PLAYER(play)->tatlActor); - this->actor.home.rot.x = 0; + TIMETAG_DIARY_TIMER(&this->actor) = 0; } - this->actionFunc = func_80ACA418; + this->actionFunc = EnTimeTag_Diary_Cutscene; } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play)) { func_800B8614(&this->actor, play, 110.0f); } } -void func_80ACA714(EnTimeTag* this, PlayState* play) { +void EnTimeTag_KickOut_DoNothing(EnTimeTag* this, PlayState* play) { } -void func_80ACA724(EnTimeTag* this, PlayState* play) { +void EnTimeTag_KickOut_Transition(EnTimeTag* this, PlayState* play) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_5) { - play->nextEntrance = play->setupExitList[ENTIMETAG_GET_1F(&this->actor)]; + play->nextEntrance = play->setupExitList[TIMETAG_KICKOUT_GET_EXIT_INDEX(&this->actor)]; play->transitionTrigger = TRANS_TRIGGER_START; - if (!ENTIMETAG_GET_E000(&this->actor)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_OC_DOOR_OPEN); + if (TIMETAG_GET_TYPE(&this->actor) == TIMETAG_KICKOUT_DOOR) { + Actor_PlaySfx(&this->actor, NA_SE_OC_DOOR_OPEN); } - this->actionFunc = func_80ACA714; + this->actionFunc = EnTimeTag_KickOut_DoNothing; } } -void func_80ACA7C4(EnTimeTag* this, PlayState* play) { - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_63_01) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { - func_800B7298(play, &this->actor, PLAYER_CSMODE_7); - Message_StartTextbox(play, ENTIMETAG_GET_1FE0(&this->actor) + 0x1883, NULL); - this->actionFunc = func_80ACA724; +/** + * Setup a request to kickout, but wait for an external system to unset + * both `WEEKEVENTREG_KICKOUT_WAIT` and `WEEKEVENTREG_KICKOUT_TIME_PASSED` + */ +void EnTimeTag_KickOut_WaitForTrigger(EnTimeTag* this, PlayState* play) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED)) { + func_800B7298(play, &this->actor, PLAYER_CSMODE_WAIT); + Message_StartTextbox(play, 0x1883 + TIMETAG_KICKOUT_GET_TEXT(&this->actor), NULL); + this->actionFunc = EnTimeTag_KickOut_Transition; } } -void func_80ACA840(EnTimeTag* this, PlayState* play) { - s16 temp_ft4; - s16 temp_hi; +/** + * Wait for a certain time to pass, then trigger the kickout event. + * If an external system sets `WEEKEVENTREG_KICKOUT_WAIT`, then instead of triggering the kickout event now, + * store the kickout by going to `EnTimeTag_KickOut_WaitForTrigger`. + * If the time has passed but the kickout is being stored, then `WEEKEVENTREG_KICKOUT_TIME_PASSED` is set here + * to indicate to external systems that the time has passed and is waiting for a trigger. + */ +void EnTimeTag_KickOut_WaitForTime(EnTimeTag* this, PlayState* play) { + s16 hour; + s16 minute; - if ((play->sceneId != SCENE_YADOYA) || (INV_CONTENT(ITEM_ROOM_KEY) != ITEM_ROOM_KEY)) { - temp_ft4 = gSaveContext.save.time * (24.0f / 0x10000); // TIME_TO_HOURS_F - temp_hi = (s32)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60; - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_01)) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { - this->actionFunc = func_80ACA7C4; - } else if ((temp_ft4 == this->actor.home.rot.x) && (temp_hi == this->actor.home.rot.y)) { - SET_WEEKEVENTREG(WEEKEVENTREG_63_02); - } - } else if ((temp_ft4 == this->actor.home.rot.x) && (temp_hi == this->actor.home.rot.y) && - !Play_InCsMode(play)) { - func_800B7298(play, &this->actor, PLAYER_CSMODE_7); - Message_StartTextbox(play, ENTIMETAG_GET_1FE0(&this->actor) + 0x1883, NULL); - this->actionFunc = func_80ACA724; + if ((play->sceneId == SCENE_YADOYA) && (INV_CONTENT(ITEM_ROOM_KEY) == ITEM_ROOM_KEY)) { + // Having the room key allows you to stay in Stock Pot Inn + return; + } + + hour = TIME_TO_HOURS_F(gSaveContext.save.time); + minute = (s32)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60; + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED)) { + this->actionFunc = EnTimeTag_KickOut_WaitForTrigger; + } else if ((hour == TIMETAG_KICKOUT_HOUR(&this->actor)) && (minute == TIMETAG_KICKOUT_MINUTE(&this->actor))) { + SET_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED); } + } else if ((hour == TIMETAG_KICKOUT_HOUR(&this->actor)) && (minute == TIMETAG_KICKOUT_MINUTE(&this->actor)) && + !Play_InCsMode(play)) { + func_800B7298(play, &this->actor, PLAYER_CSMODE_WAIT); + Message_StartTextbox(play, 0x1883 + TIMETAG_KICKOUT_GET_TEXT(&this->actor), NULL); + this->actionFunc = EnTimeTag_KickOut_Transition; } } diff --git a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h index ed6b611e4..128e01973 100644 --- a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h +++ b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h @@ -7,10 +7,57 @@ struct EnTimeTag; typedef void (*EnTimeTagActionFunc)(struct EnTimeTag*, PlayState*); -#define ENTIMETAG_GET_1F(thisx) ((thisx)->params & 0x1F) -#define ENTIMETAG_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) -#define ENTIMETAG_GET_1FE0(thisx) (((thisx)->params & 0x1FE0) >> 0x5) -#define ENTIMETAG_GET_E000(thisx) (((thisx)->params & 0xE000) >> 0xD) +#define TIMETAG_GET_TYPE(thisx) (((thisx)->params & 0xE000) >> 0xD) + +#define TIMETAG_KICKOUT_GET_TEXT(thisx) (((thisx)->params & 0x1FE0) >> 0x5) +#define TIMETAG_KICKOUT_GET_EXIT_INDEX(thisx) ((thisx)->params & 0x1F) +#define TIMETAG_KICKOUT_HOUR(thisx) ((thisx)->home.rot.x) +#define TIMETAG_KICKOUT_MINUTE(thisx) ((thisx)->home.rot.y) + +#define TIMETAG_SOARING_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + +#define TIMETAG_DIARY_GET_TYPE(thisx) ((thisx)->params & 0x7F) +#define TIMETAG_DIARY_TIMER(thisx) ((thisx)->home.rot.x) +#define TIMETAG_DIARY_SONG(thisx) ((thisx)->home.rot.z) + +typedef enum { + /* 0 */ TIMETAG_KICKOUT_DOOR, + /* 1 */ TIMETAG_SOARING_ENGRAVING, + /* 2 */ TIMETAG_ROOFTOP_OATH, + /* 3 */ TIMETAG_DIARY, + /* 4 */ TIMETAG_KICKOUT_FINAL_HOURS, + /* 5 */ TIMETAG_KICKOUT_NO_DOOR +} TimeTagType; + +typedef enum { + /* 0 */ TIMETAG_DIARY_MIKAU, + /* 1 */ TIMETAG_DIARY_LULU +} TimeTagDiaryType; + +typedef enum { + /* 0 */ TIMETAG_DIARY_SONG_EVAN_PART1, + /* 1 */ TIMETAG_DIARY_SONG_EVAN_PART2 +} TimeTagDiarySong; + +typedef enum { + /* 0 */ TIMETAG_KICKOUT_TEXT_0, // I am closing the shop + /* 1 */ TIMETAG_KICKOUT_TEXT_SWAMP_SHOOTING_GALLERY, // time to close shop + /* 2 */ TIMETAG_KICKOUT_TEXT_STOCK_POT_INN, // Stock Pot Inn locking the door + /* 3 */ TIMETAG_KICKOUT_TEXT_HONEY_AND_DARLING, // need some alone time + /* 4 */ TIMETAG_KICKOUT_TEXT_LOTTERY, // business is finished + /* 5 */ TIMETAG_KICKOUT_TEXT_BARN_DAY, // the lady needs a break + /* 6 */ TIMETAG_KICKOUT_TEXT_GENERIC, // (Many scenes) place is about to close + /* 7 */ TIMETAG_KICKOUT_TEXT_BARN_NIGHT, // they came + /* 8 */ TIMETAG_KICKOUT_TEXT_TRADING_POST, // we have to close shop + /* 9 */ TIMETAG_KICKOUT_TEXT_MILK_BAR, // I have to get ready for business + /* 10 */ TIMETAG_KICKOUT_TEXT_CURIOSITY_SHOP_BACK_1, // shop is opening, you need to go + /* 11 */ TIMETAG_KICKOUT_TEXT_CURIOSITY_SHOP_BACK_2, // shop is opening, we're in the way + /* 12 */ TIMETAG_KICKOUT_TEXT_TOWN_SHOOTING_GALLERY_1, // it's time to close + /* 13 */ TIMETAG_KICKOUT_TEXT_TOWN_SHOOTING_GALLERY_2, // quick, it's closing time + /* 14 */ TIMETAG_KICKOUT_TEXT_SWORDSMANS_SCHOOL, // need to cut the moon, must leave + /* 15 */ TIMETAG_KICKOUT_TEXT_TREASURE_CHEST_SHOP, // already time to close shop + /* 16 */ TIMETAG_KICKOUT_TEXT_DOGGY_RACETRACK, // no more for today +} TimeTagKickOutText; typedef struct EnTimeTag { /* 0x000 */ Actor actor; 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 eb005b224..3d5c7a741 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -147,7 +147,8 @@ void EnTite_Init(Actor* thisx, PlayState* play) { CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Collider_InitAndSetSphere(play, &this->collider, &this->actor, &sSphereInit); this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; - this->unk_2C0 = 0x1D; + this->updBgCheckInfoFlags = + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10; if (!D_80896B60) { for (i = 0; i < ARRAY_COUNT(D_80896B24); i++) { @@ -178,7 +179,7 @@ void EnTite_Init(Actor* thisx, PlayState* play) { } if (this->actor.params == ENTITE_MINUS_2) { - this->unk_2C0 |= 0x40; + this->updBgCheckInfoFlags |= UPDBGCHECKINFO_FLAG_40; this->actor.colChkInfo.health = 3; } } @@ -195,8 +196,8 @@ void func_80893A18(EnTite* this) { } s32 func_80893A34(EnTite* this, PlayState* play) { - if ((this->actor.params == ENTITE_MINUS_2) && (this->actor.bgCheckFlags & 1) && - (func_800C99D4(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 5)) { + if ((this->actor.params == ENTITE_MINUS_2) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + (SurfaceType_GetFloorType(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == FLOOR_TYPE_5)) { return true; } return false; @@ -211,7 +212,7 @@ void func_80893A9C(EnTite* this, PlayState* play) { } s32 func_80893ADC(EnTite* this) { - if ((this->actor.params == ENTITE_MINUS_2) && (this->actor.bgCheckFlags & 0x20)) { + if ((this->actor.params == ENTITE_MINUS_2) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { return true; } return false; @@ -224,7 +225,7 @@ s32 func_80893B10(EnTite* this) { void func_80893B70(EnTite* this) { if (this->actor.params == ENTITE_MINUS_2) { - if (this->actor.bgCheckFlags & 0x20) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { this->actor.gravity = 0.0f; func_80893B10(this); } else { @@ -238,14 +239,15 @@ void func_80893BCC(EnTite* this, PlayState* play) { s32 i; s32 j; - if (this->actor.bgCheckFlags & 2) { - u32 surface = func_800C9BB8(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + SurfaceMaterial surfaceMaterial = + SurfaceType_GetMaterial(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); - if ((surface == COLPOLY_SURFACE_GROUND) || (surface == COLPOLY_SURFACE_SAND)) { + if ((surfaceMaterial == SURFACE_MATERIAL_DIRT) || (surfaceMaterial == SURFACE_MATERIAL_SAND)) { for (i = 5; i < ARRAY_COUNT(this->limbPos); i++) { func_800BBFB0(play, &this->limbPos[i], 1.0f, 2, 80, 15, 1); } - } else if (surface == COLPOLY_SURFACE_SNOW) { + } else if (surfaceMaterial == SURFACE_MATERIAL_SNOW) { Vec3f* ptr; for (i = 5; i < ARRAY_COUNT(this->limbPos); i++) { @@ -259,7 +261,7 @@ void func_80893BCC(EnTite* this, PlayState* play) { } } } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } } @@ -270,7 +272,7 @@ void func_80893DD4(EnTite* this) { this->drawDmgEffScale = 0.5f; this->drawDmgEffFrozenSteamScale = 0.75f; this->drawDmgEffAlpha = 1.0f; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 80); this->actor.flags &= ~ACTOR_FLAG_200; } @@ -287,7 +289,7 @@ void func_80893E54(EnTite* this, PlayState* play) { void func_80893ED4(EnTite* this) { Animation_MorphToLoop(&this->skelAnime, &object_tite_Anim_0012E4, 4.0f); this->unk_2BC = Rand_S16Offset(15, 30); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_80893F30; } @@ -305,7 +307,7 @@ void func_80893F30(EnTite* this, PlayState* play) { void func_80893FD0(EnTite* this) { Animation_PlayOnce(&this->skelAnime, &object_tite_Anim_00083C); this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_80894024; } @@ -323,10 +325,10 @@ void func_80894024(EnTite* this, PlayState* play) { void func_8089408C(EnTite* this, PlayState* play) { Animation_PlayOnce(&this->skelAnime, &object_tite_Anim_0004F8); if (!func_80893ADC(this)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_JUMP); } else { this->actor.world.pos.y += this->actor.depthInWater; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); } if (this->actor.shape.yOffset < 0.0f) { @@ -356,17 +358,19 @@ void func_8089408C(EnTite* this, PlayState* play) { this->actor.velocity.y = 8.0f; } - this->actor.bgCheckFlags &= ~(0x40 | 0x20 | 0x2 | 0x1); + this->actor.bgCheckFlags &= + ~(BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH); this->actor.gravity = -1.0f; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; this->actionFunc = func_808942B4; } void func_808942B4(EnTite* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.depthInWater > 0.0f))) && + if (((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || + (func_80893ADC(this) && (this->actor.depthInWater > 0.0f))) && (this->actor.velocity.y <= 0.0f)) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->collider.base.atFlags &= ~AT_HIT; if (!func_80893ADC(this)) { func_80893BCC(this, play); @@ -377,7 +381,7 @@ void func_808942B4(EnTite* this, PlayState* play) { func_8089452C(this, play); } else { this->actor.velocity.y = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); func_80894414(this); } } @@ -418,7 +422,7 @@ void func_8089452C(EnTite* this, PlayState* play) { sp2C.y += this->actor.depthInWater; this->actor.velocity.y *= 0.75f; EffectSsGRipple_Spawn(play, &sp2C, 0, 500, 0); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_LAND_WATER); this->actionFunc = func_808945B4; } @@ -430,7 +434,7 @@ void func_808945B4(EnTite* this, PlayState* play) { void func_808945EC(EnTite* this) { Animation_PlayLoop(&this->skelAnime, &object_tite_Anim_000A14); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; this->actionFunc = func_80894638; } @@ -454,16 +458,17 @@ void func_80894638(EnTite* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 7.0f)) { if (func_80893ADC(this)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_WALK_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_WALK_WATER); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_WALK); } } if ((Player_GetMask(play) == PLAYER_MASK_STONE) || (this->actor.xzDistToPlayer > 450.0f) || (this->actor.playerHeightRel > 80.0f)) { func_80893ED4(this); - } else if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.depthInWater < 10.0f))) && + } else if (((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || + (func_80893ADC(this) && (this->actor.depthInWater < 10.0f))) && Actor_IsFacingPlayer(&this->actor, 0xE38)) { if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.playerHeightRel <= 80.0f)) { func_80893A9C(this, play); @@ -480,12 +485,12 @@ void func_8089484C(EnTite* this) { } this->actor.velocity.y = 9.5f; this->actor.gravity = -1.0f; - this->actor.speedXZ = 4.0f; + this->actor.speed = 4.0f; if (func_80893ADC(this)) { this->actor.world.pos.y += this->actor.depthInWater; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_JUMP_WATER); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_JUMP); } this->actionFunc = func_80894910; } @@ -493,10 +498,10 @@ void func_8089484C(EnTite* this) { void func_80894910(EnTite* this, PlayState* play) { Vec3f sp34; - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 1.0f, 0.0f); + Math_SmoothStepToF(&this->actor.speed, 0.0f, 0.1f, 1.0f, 0.0f); SkelAnime_Update(&this->skelAnime); - if (this->actor.bgCheckFlags & 0x40) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER); + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_LAND_WATER); if (func_80893ADC(this)) { Math_Vec3f_Copy(&sp34, &this->actor.world.pos); @@ -508,9 +513,10 @@ void func_80894910(EnTite* this, PlayState* play) { func_80893BCC(this, play); } - if (((this->actor.bgCheckFlags & 1) || (func_80893ADC(this) && (this->actor.depthInWater > 0.0f))) && + if (((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || + (func_80893ADC(this) && (this->actor.depthInWater > 0.0f))) && (this->actor.velocity.y <= 0.0f)) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4000); this->actor.world.rot.y = this->actor.shape.rot.y; @@ -536,7 +542,7 @@ void func_80894910(EnTite* this, PlayState* play) { void func_80894B2C(EnTite* this) { Animation_MorphToLoop(&this->skelAnime, &object_tite_Anim_0012E4, 4.0f); - this->actor.speedXZ = -6.0f; + this->actor.speed = -6.0f; this->actor.gravity = -1.0f; if (this->collider.base.ac != NULL) { func_800BE568(&this->actor, &this->collider); @@ -548,7 +554,7 @@ void func_80894B2C(EnTite* this) { } void func_80894BC8(EnTite* this, PlayState* play) { - Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + Math_SmoothStepToF(&this->actor.speed, 0.0f, 1.0f, 0.5f, 0.0f); SkelAnime_Update(&this->skelAnime); if (func_80893ADC(this) && (this->actor.velocity.y <= 0.0f)) { this->actor.gravity = 0.0f; @@ -556,13 +562,13 @@ void func_80894BC8(EnTite* this, PlayState* play) { this->actor.world.pos.y += this->actor.depthInWater - 1.0f; } - if (this->actor.bgCheckFlags & 0x40) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); } else { func_80893BCC(this, play); } - if ((this->actor.speedXZ == 0.0f) && ((this->actor.bgCheckFlags & 1) || func_80893ADC(this))) { + if ((this->actor.speed == 0.0f) && ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || func_80893ADC(this))) { this->actor.world.rot.y = this->actor.shape.rot.y; this->collider.base.acFlags |= AC_ON; if ((Player_GetMask(play) == PLAYER_MASK_STONE) || @@ -579,7 +585,7 @@ void func_80894BC8(EnTite* this, PlayState* play) { } void func_80894DD0(EnTite* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->actor.velocity.y > 0.0f) { this->actor.velocity.y = 0.0f; } @@ -598,8 +604,8 @@ void func_80894E0C(EnTite* this, PlayState* play) { this->actor.world.pos.y += this->actor.depthInWater; } - if (this->actor.bgCheckFlags & 0x40) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_LAND_WATER2); } else { func_80893BCC(this, play); } @@ -629,7 +635,7 @@ void func_80895020(EnTite* this, PlayState* play) { f32 temp_f0; Vec3f* ptr; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->collider.base.acFlags &= ~AC_ON; this->actor.colorFilterTimer = 0; SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_TEKU_DEAD); @@ -640,7 +646,7 @@ void func_80895020(EnTite* this, PlayState* play) { this->unk_2BC = 25; this->actor.gravity = -0.58f; this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; ptr = &this->unk_33C[0]; for (i = 0; i < ARRAY_COUNT(this->limbPos); i++, ptr++) { @@ -680,15 +686,15 @@ void func_808951B8(EnTite* this, PlayState* play) { void func_808952EC(EnTite* this) { Animation_PlayLoopSetSpeed(&this->skelAnime, &object_tite_Anim_000A14, 1.5f); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); this->collider.base.acFlags &= ~AC_ON; func_80893A18(this); this->unk_2B9 = 1; this->unk_2BC = 400; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.gravity = -1.0f; this->unk_2B8 = Rand_ZeroOne() * 50.0f; - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->actor.velocity.y = 11.0f; this->actionFunc = func_80895424; } @@ -704,11 +710,11 @@ void func_80895424(EnTite* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->collider.base.acFlags |= AC_ON; - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 20.0f, 11, 4.0f, 0, 0, 0); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } if (this->unk_2BC == 0) { @@ -724,8 +730,8 @@ void func_80895424(EnTite* this, PlayState* play) { void func_808955E4(EnTite* this) { this->unk_2B9 = 0; this->actor.velocity.y = 13.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); - this->actor.bgCheckFlags &= ~1; + Actor_PlaySfx(&this->actor, NA_SE_EN_LAST1_GROW_HEAD); + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->collider.base.acFlags &= ~AC_ON; this->actionFunc = func_80895640; } @@ -733,7 +739,7 @@ void func_808955E4(EnTite* this) { void func_80895640(EnTite* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.z, 0, 4000); SkelAnime_Update(&this->skelAnime); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->collider.base.acFlags |= AC_ON; this->actor.shape.yOffset = 0.0f; func_80893BCC(this, play); @@ -752,7 +758,7 @@ void func_808956B8(EnTite* this) { void func_808956FC(EnTite* this) { this->unk_2BC = -1; - this->actor.bgCheckFlags &= ~1; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->actor.velocity.y = 7.5f; func_80893A18(this); } @@ -765,26 +771,26 @@ void func_80895738(EnTite* this, PlayState* play) { if (this->collider.base.atFlags & AT_BOUNCED) { func_808956FC(this); } - } else if (this->actor.bgCheckFlags & 8) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->actor.world.rot.y = BINANG_SUB((this->actor.wallYaw * 2) - this->actor.world.rot.y, 0x8000); } if (this->unk_2BC == -1) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.3f); - if (this->actor.bgCheckFlags & 1) { + Math_StepToF(&this->actor.speed, 0.0f, 0.3f); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->actor.world.rot.y = this->actor.shape.rot.y; func_80893ED4(this); this->unk_2BC = 100; } } else if (this->unk_2BC > 0) { this->unk_2BC--; - Math_StepToF(&this->actor.speedXZ, 10.0f, 0.3f); + Math_StepToF(&this->actor.speed, 10.0f, 0.3f); this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); if (!func_80893A34(this, play)) { this->unk_2BC = 0; } - } else if ((this->unk_2BC == 0) && Math_StepToF(&this->actor.speedXZ, 0.0f, 0.3f)) { + } else if ((this->unk_2BC == 0) && Math_StepToF(&this->actor.speed, 0.0f, 0.3f)) { this->actor.world.rot.y = this->actor.shape.rot.y; func_80893A18(this); if ((Player_GetMask(play) == PLAYER_MASK_STONE) || (this->actor.xzDistToPlayer > 450.0f) || @@ -796,7 +802,7 @@ void func_80895738(EnTite* this, PlayState* play) { func_80893A9C(this, play); } } - this->actor.shape.rot.y += (s16)(this->actor.speedXZ * 768.0f); + this->actor.shape.rot.y += (s16)(this->actor.speed * 768.0f); } void func_8089595C(EnTite* this, PlayState* play) { @@ -813,7 +819,7 @@ void func_80895A10(EnTite* this) { s16 rand; Animation_Change(&this->skelAnime, &object_tite_Anim_000A14, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 4.0f); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; rand = Rand_S16Offset(20, 20); this->unk_2BC = ((Rand_ZeroOne() < 0.5f) ? -1 : 1) * rand; this->actionFunc = func_80895AC0; @@ -828,18 +834,18 @@ void func_80895AC0(EnTite* this, PlayState* play) { if (Rand_ZeroOne() < 0.25f) { func_8089595C(this, play); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_WALK); } if ((this->unk_2BC == 1) || (this->unk_2BC == -1)) { - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { temp_v1 = this->actor.shape.rot.y - this->actor.wallYaw; temp_v0 = ABS_ALT(temp_v1); if (temp_v0 > 0x3000) { this->unk_2BC = (temp_v0 >> 9) * this->unk_2BC; } - } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 200.0f) { - temp_v1 = this->actor.shape.rot.y - Actor_YawToPoint(&this->actor, &this->actor.home.pos); + } else if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) < 200.0f) { + temp_v1 = this->actor.shape.rot.y - Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos); temp_v0 = ABS_ALT(temp_v1); if (temp_v0 > 0x2000) { this->unk_2BC = (temp_v0 >> 9) * this->unk_2BC; @@ -862,7 +868,7 @@ void func_80895AC0(EnTite* this, PlayState* play) { void func_80895CB0(EnTite* this) { this->skelAnime.playSpeed = 1.0f; - this->actor.speedXZ = 1.0f; + this->actor.speed = 1.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->unk_2BC = Rand_S16Offset(20, 20); this->actionFunc = func_80895D08; @@ -874,7 +880,7 @@ void func_80895D08(EnTite* this, PlayState* play) { if (Rand_ZeroOne() < 0.5f) { func_8089595C(this, play); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_WALK); } if ((this->actor.xzDistToPlayer < 240.0f) && (Player_GetMask(play) != PLAYER_MASK_STONE)) { func_8089408C(this, play); @@ -890,7 +896,7 @@ void func_80895DE8(EnTite* this) { this->collider.base.acFlags &= ~AC_ON; this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->skelAnime.playSpeed = 1.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_80895E28; } @@ -956,8 +962,8 @@ void func_80895FF8(EnTite* this, PlayState* play) { if (this->actor.colChkInfo.damageEffect != 0xF) { if (this->actor.colChkInfo.damageEffect == 5) { this->unk_2BC = 40; - Actor_SetColorFilter(&this->actor, 0, 200, 0, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 200, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; this->drawDmgEffScale = 0.5f; this->drawDmgEffAlpha = 2.0f; @@ -967,8 +973,8 @@ void func_80895FF8(EnTite* this, PlayState* play) { if (this->actor.colChkInfo.damageEffect == 1) { this->unk_2BC = 40; - Actor_SetColorFilter(&this->actor, 0, 200, 0, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 200, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); func_80894DD0(this); return; } @@ -996,12 +1002,12 @@ void func_80895FF8(EnTite* this, PlayState* play) { CLEAR_TAG_LARGE_LIGHT_RAYS); } - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); if (this->actor.colChkInfo.health == 0) { func_80895020(this, play); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_DAMAGE); if (this->unk_2B9 == 0) { func_80894B2C(this); @@ -1012,7 +1018,7 @@ void func_80895FF8(EnTite* this, PlayState* play) { } } } - } else if ((this->actor.bgCheckFlags & 1) && (this->collider.base.acFlags & AC_ON) && + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->collider.base.acFlags & AC_ON) && (this->actor.colChkInfo.health != 0) && (play->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < SQ(200.0f))) { this->actor.flags |= ACTOR_FLAG_1; @@ -1032,13 +1038,13 @@ void func_808963B4(EnTite* this, PlayState* play) { s32 i; Vec3f sp48; - if (this->actor.bgCheckFlags & 0x40) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { for (i = 5; i < ARRAY_COUNT(this->limbPos); i++) { Math_Vec3f_Copy(&sp48, &this->limbPos[i]); sp48.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(play, &sp48, 0, 220, 0); } - } else if (this->actor.bgCheckFlags & 0x20) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { s32 temp = play->gameplayFrames & 7; if (!(temp & 1) && (this->actor.depthInWater < 10.0f)) { @@ -1058,9 +1064,9 @@ void EnTite_Update(Actor* thisx, PlayState* play) { if (this->actionFunc != func_808951B8) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 25.0f, 40.0f, 20.0f, this->unk_2C0); + Actor_UpdateBgCheckInfo(play, &this->actor, 25.0f, 40.0f, 20.0f, this->updBgCheckInfoFlags); func_808963B4(this, play); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); if (this->unk_2B9 != 0) { this->actor.shape.rot.z = BINANG_ROT180(this->actor.shape.rot.z); diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.h b/src/overlays/actors/ovl_En_Tite/z_en_tite.h index 4b87634a3..57d8ef3e3 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.h +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.h @@ -27,7 +27,7 @@ typedef struct EnTite { /* 0x2BB */ u8 drawDmgEffType; /* 0x2BC */ s16 unk_2BC; /* 0x2BE */ s16 unk_2BE; - /* 0x2C0 */ s32 unk_2C0; + /* 0x2C0 */ s32 updBgCheckInfoFlags; /* 0x2C4 */ f32 drawDmgEffAlpha; /* 0x2C8 */ f32 drawDmgEffScale; /* 0x2CC */ f32 drawDmgEffFrozenSteamScale; 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 1bdc92b4a..d434bacaa 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -247,7 +247,7 @@ void EnTk_Init(Actor* thisx, PlayState* play) { this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.flags |= ACTOR_FLAG_10; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); - SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_FillCutscenesList(&this->actor, this->csIdList, ARRAY_COUNT(this->csIdList)); switch (this->unk_2B0) { case 4: @@ -299,7 +299,7 @@ void func_80AECA90(EnTk* this, PlayState* play) { } void func_80AECB0C(EnTk* this, PlayState* play) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_3CC = 0xFF; this->unk_2DC = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); @@ -442,8 +442,8 @@ s32 func_80AECE60(EnTk* this, PlayState* play) { do { doorIter = SubS_FindActor(play, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); if (doorIter != NULL) { - if (Actor_XZDistanceBetweenActors(&this->actor, doorIter) <= 120.0f) { - if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &doorIter->world.pos), + if (Actor_WorldDistXZToActor(&this->actor, doorIter) <= 120.0f) { + if (ABS(BINANG_SUB(Actor_WorldYawTowardPoint(&this->actor, &doorIter->world.pos), this->actor.shape.rot.y)) <= 0x2000) { this->unk_2CA |= 0x400; door = (EnDoor*)doorIter; @@ -459,7 +459,7 @@ s32 func_80AECE60(EnTk* this, PlayState* play) { do { doorIter = SubS_FindActor(play, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); if (doorIter != NULL) { - if (Actor_XZDistanceBetweenActors(&this->actor, doorIter) <= 160.0f) { + if (Actor_WorldDistXZToActor(&this->actor, doorIter) <= 160.0f) { door = (EnDoor*)doorIter; break; } @@ -590,13 +590,13 @@ void func_80AED610(EnTk* this, PlayState* play) { break; case 0x13FE: - func_80151938(play, 0x13FF); + Message_ContinueTextbox(play, 0x13FF); break; case 0x1413: Rupees_ChangeBy(30); SET_WEEKEVENTREG(WEEKEVENTREG_60_02); - func_80151938(play, 0x13FF); + Message_ContinueTextbox(play, 0x13FF); break; case 0x13FF: @@ -631,7 +631,7 @@ void func_80AED610(EnTk* this, PlayState* play) { void func_80AED898(EnTk* this, PlayState* play) { this->unk_316 = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->unk_2CA & 0x1000) { if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); @@ -705,23 +705,23 @@ void func_80AED940(EnTk* this, PlayState* play) { void func_80AEDBEC(EnTk* this, PlayState* play) { this->actor.params = -1; - this->unk_2E8 = 0; - this->actor.speedXZ = 0.0f; + this->csLength = 0; + this->actor.speed = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->actionFunc = func_80AEDC4C; } void func_80AEDC4C(EnTk* this, PlayState* play) { - if ((this->actor.params >= 0) && SubS_StartActorCutscene(&this->actor, this->cutscenes[1], this->actor.params, - SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { - this->unk_2E8 = ActorCutscene_GetLength(this->cutscenes[1]); - func_80151938(play, 0x1411); + if ((this->actor.params >= 0) && + SubS_StartCutscene(&this->actor, this->csIdList[1], this->actor.params, SUBS_CUTSCENE_WITH_PLAYER)) { + this->csLength = CutsceneManager_GetLength(this->csIdList[1]); + Message_ContinueTextbox(play, 0x1411); func_80AEDCBC(this, play); } } void func_80AEDCBC(EnTk* this, PlayState* play) { - this->actor.speedXZ = 10.0f; + this->actor.speed = 10.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_2EC); Math_Vec3f_Copy(&this->actor.prevPos, &this->unk_2EC); @@ -731,16 +731,16 @@ void func_80AEDCBC(EnTk* this, PlayState* play) { } void func_80AEDD4C(EnTk* this, PlayState* play) { - this->unk_2E8--; - if (this->unk_2E8 <= 0) { - ActorCutscene_Stop(this->cutscenes[1]); - func_801477B4(play); + this->csLength--; + if (this->csLength <= 0) { + CutsceneManager_Stop(this->csIdList[1]); + Message_CloseTextbox(play); Actor_Kill(&this->actor); } } void func_80AEDDA0(EnTk* this, PlayState* play) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->actor.flags |= ACTOR_FLAG_10000; this->unk_2CA |= 0x80; @@ -837,29 +837,29 @@ void func_80AEDF5C(EnTk* this, PlayState* play) { break; case 0x1405: - func_80151938(play, 0x1406); + Message_ContinueTextbox(play, 0x1406); break; case 0x1406: - func_80151938(play, 0x1407); + Message_ContinueTextbox(play, 0x1407); break; case 0x1407: if (play->msgCtx.choiceIndex == 0) { func_8019F208(); - func_80151938(play, 0x1409); + Message_ContinueTextbox(play, 0x1409); } else { func_8019F230(); - func_80151938(play, 0x1408); + Message_ContinueTextbox(play, 0x1408); } break; case 0x1408: - func_80151938(play, 0x1407); + Message_ContinueTextbox(play, 0x1407); break; case 0x1409: - func_80151938(play, 0x140A); + Message_ContinueTextbox(play, 0x140A); break; case 0x140A: @@ -877,7 +877,7 @@ void func_80AEDF5C(EnTk* this, PlayState* play) { func_80AEE2A8(this, play); } else { func_8019F230(); - func_80151938(play, 0x140E); + Message_ContinueTextbox(play, 0x140E); } break; @@ -901,7 +901,7 @@ void func_80AEE2A8(EnTk* this, PlayState* play) { } void func_80AEE2C0(EnTk* this, PlayState* play) { - if (SubS_StartActorCutscene(&this->actor, this->cutscenes[0], 0x7C, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + if (SubS_StartCutscene(&this->actor, this->csIdList[0], CS_ID_GLOBAL_TALK, SUBS_CUTSCENE_WITH_PLAYER)) { func_80AEE374(this, play); } } @@ -911,7 +911,7 @@ s32 func_80AEE300(PlayState* play, Actor* arg1, Actor* arg2, void* _arg3) { f32 temp_f0; if ((arg2 != arg1) && (ENTK_GET_F(arg2) == 3)) { - temp_f0 = Actor_DistanceBetweenActors(arg1, arg2); + temp_f0 = Actor_WorldDistXYZToActor(arg1, arg2); if (temp_f0 < arg3->unk_04) { arg3->unk_00 = arg2; arg3->unk_04 = temp_f0; @@ -932,7 +932,7 @@ void func_80AEE374(EnTk* this, PlayState* play) { return; } - this->unk_2CC = Actor_YawToPoint(&this->actor, &sp30.unk_00->world.pos); + this->unk_2CC = Actor_WorldYawTowardPoint(&this->actor, &sp30.unk_00->world.pos); this->actionFunc = func_80AEE414; } @@ -958,7 +958,7 @@ void func_80AEE4D0(EnTk* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 33.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIG_UP); + Actor_PlaySfx(&this->actor, NA_SE_EV_DIG_UP); } if (!(this->unk_2CA & 0x20)) { @@ -968,7 +968,7 @@ void func_80AEE4D0(EnTk* this, PlayState* play) { bigPoe = SubS_FindActor(play, bigPoe, ACTORCAT_PROP, ACTOR_EN_BIGPO); if (bigPoe != NULL) { - if ((bigPoe->params == 3) && (Actor_DistanceBetweenActors(&this->actor, bigPoe) < 80.0f)) { + if ((bigPoe->params == 3) && (Actor_WorldDistXYZToActor(&this->actor, bigPoe) < 80.0f)) { bigPoe->params = 4; this->unk_2CA |= 0x20; this->unk_2E4++; @@ -995,15 +995,15 @@ void func_80AEE650(EnTk* this, PlayState* play) { void func_80AEE6B8(EnTk* this, PlayState* play) { if (this->unk_2CA & 0x20) { if (this->unk_2E4 >= 3) { - ActorCutscene_Stop(this->cutscenes[0]); - func_801477B4(play); + CutsceneManager_Stop(this->csIdList[0]); + Message_CloseTextbox(play); func_80AEDBEC(this, play); - } else if (SubS_StartActorCutscene(&this->actor, 0x7C, this->cutscenes[0], SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + } else if (SubS_StartCutscene(&this->actor, CS_ID_GLOBAL_TALK, this->csIdList[0], SUBS_CUTSCENE_WITH_PLAYER)) { this->unk_310 = 3; func_80AEDE10(this, play); this->unk_2CA &= ~0x20; } - } else if (SubS_StartActorCutscene(&this->actor, 0x7C, this->cutscenes[0], SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + } else if (SubS_StartCutscene(&this->actor, CS_ID_GLOBAL_TALK, this->csIdList[0], SUBS_CUTSCENE_WITH_PLAYER)) { this->unk_310 = 4; func_80AEDE10(this, play); } @@ -1035,13 +1035,13 @@ s32 func_80AEE86C(EnTk* this, PlayState* play) { s32 pad; s32 ret = false; s32 pad2; - CollisionPoly* sp38; - s32 sp34; + CollisionPoly* groundPoly; + s32 bgId; Vec3f sp28; Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80AEFA78, &sp28); - if ((BgCheck_EntityRaycastFloor3(&play->colCtx, &sp38, &sp34, &sp28) != BGCHECK_Y_MIN) && - (func_800C9BB8(&play->colCtx, sp38, sp34) == 1) && (this->unk_2D0 == (u32)1) && + if ((BgCheck_EntityRaycastFloor3(&play->colCtx, &groundPoly, &bgId, &sp28) != BGCHECK_Y_MIN) && + (SurfaceType_GetMaterial(&play->colCtx, groundPoly, bgId) == SURFACE_MATERIAL_SAND) && (this->unk_2D0 == 1) && (this->actor.xyzDistToPlayerSq <= SQ(115.0f)) && func_80AEE7E0(&this->actor.world.pos, 100.0f, this->unk_324, this->unk_36C) && (((this->unk_2CA & 2) && (Math_Vec3f_DistXZ(&this->unk_300, &sp28) >= 100.0f)) || !(this->unk_2CA & 2)) && @@ -1183,10 +1183,10 @@ void func_80AEED38(EnTk* this, PlayState* play) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } else { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); - func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &this->actor.speedXZ, &sp64); + func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &this->actor.speed, &sp64); } - if (this->actor.speedXZ > 0.5f) { + if (this->actor.speed > 0.5f) { Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2CC, 2, 0xAAA, 1); this->actor.shape.rot.y = this->actor.world.rot.y; } @@ -1210,17 +1210,17 @@ void func_80AEF094(EnTk* this, PlayState* play) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } else { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); - func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &this->actor.speedXZ, &sp2C); + func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &this->actor.speed, &sp2C); } - if (this->actor.speedXZ >= 0.5f) { + if (this->actor.speed >= 0.5f) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 2, 0x38E, 1); this->actor.shape.rot.y = this->actor.world.rot.y; } } void func_80AEF15C(EnTk* this, PlayState* play) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->unk_30C = func_80AEF1B4; } @@ -1237,7 +1237,7 @@ void func_80AEF210(EnTk* this, PlayState* play) { } void func_80AEF220(EnTk* this, PlayState* play) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->unk_30C = func_80AEF278; } @@ -1264,13 +1264,13 @@ void func_80AEF2D8(Actor* thisx, PlayState* play) { 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))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_WALK); } this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); func_80AEC460(this); } @@ -1286,7 +1286,7 @@ void EnTk_Update(Actor* thisx, PlayState* play) { if (((this->unk_2D4 == 0) || (this->unk_2D4 == 1)) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 24.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_WALK); } this->unk_2CA &= ~1; @@ -1310,9 +1310,10 @@ void EnTk_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); - if ((this->unk_2B0 == 0) && (func_800C9B40(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 12)) { + if ((this->unk_2B0 == 0) && (SurfaceType_GetFloorProperty(&play->colCtx, this->actor.floorPoly, + this->actor.floorBgId) == FLOOR_PROPERTY_12)) { Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); this->unk_2CA |= 0x200; this->actor.velocity.y = 0.0f; @@ -1321,10 +1322,10 @@ void EnTk_Update(Actor* thisx, PlayState* play) { } if (!(this->unk_2CA & 0x200)) { - if (!(this->actor.bgCheckFlags & 1)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { func_800B9010(&this->actor, NA_SE_EV_HONEYCOMB_FALL - SFX_FLAG); - } else if (this->actor.bgCheckFlags & 2) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + Actor_PlaySfx(&this->actor, NA_SE_EV_HUMAN_BOUND); } } } diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.h b/src/overlays/actors/ovl_En_Tk/z_en_tk.h index 42a8aa96a..9604133e7 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.h +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.h @@ -36,13 +36,13 @@ typedef struct EnTk { /* 0x2E0 */ s32 unk_2E0; /* 0x2E4 */ s16 unk_2E4; /* 0x2E6 */ u16 unk_2E6; - /* 0x2E8 */ s16 unk_2E8; + /* 0x2E8 */ s16 csLength; /* 0x2EC */ Vec3f unk_2EC; /* 0x2F8 */ Vec3s unk_2F8; /* 0x300 */ Vec3f unk_300; /* 0x30C */ EnTkUnkFunc unk_30C; /* 0x310 */ s16 unk_310; - /* 0x312 */ s16 cutscenes[2]; + /* 0x312 */ s16 csIdList[2]; /* 0x316 */ s16 unk_316; /* 0x318 */ s16 unk_318; /* 0x31A */ s16 unk_31A; 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 75f966a3c..c6681b4be 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -63,17 +63,14 @@ static Gfx* sShellDLists[] = { void EnTorch2_Init(Actor* thisx, PlayState* play) { EnTorch2* this = THIS; - s16 params; Actor_ProcessInitChain(&this->actor, sInitChain); Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - // params: which form Link is in (e.g. human, deku, etc.) - params = this->actor.params; - if (params != TORCH2_PARAM_DEKU) { - this->actor.flags |= ACTOR_FLAG_4000000; // Can press switch - if (params == TORCH2_PARAM_GORON) { - this->actor.flags |= ACTOR_FLAG_20000; // Can press heavy switches + if (this->actor.params != TORCH2_PARAM_DEKU) { + this->actor.flags |= ACTOR_FLAG_CAN_PRESS_SWITCH; + if (this->actor.params == TORCH2_PARAM_GORON) { + this->actor.flags |= ACTOR_FLAG_CAN_PRESS_HEAVY_SWITCH; } } this->framesUntilNextState = 20; @@ -101,7 +98,7 @@ void EnTorch2_Update(Actor* thisx, PlayState* play) { this->actor.gravity = -1.0f; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 70.0f, 0x05); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 70.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); if (this->framesUntilNextState == 0) { remainingFrames = 0; 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 aefa6383f..3a563ab60 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -190,7 +190,7 @@ void EnToto_Init(Actor* thisx, PlayState* play) { return; } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->actor.bgCheckFlags |= 0x400; + this->actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_400; SkelAnime_InitFlex(play, &this->skelAnime, &object_zm_Skel_00A978, ((play->sceneId == SCENE_SONCHONOIE) ? &object_zm_Anim_003AA8 : &object_zm_Anim_00C880), this->jointTable, this->morphTable, 18); @@ -251,7 +251,7 @@ void func_80BA39C8(EnToto* this, PlayState* play) { return; } - //! @TODO: 0xED02 nor 0xED01 match CLOCK_TIME macro + //! TODO: Neither 0xED02 nor 0xED01 match CLOCK_TIME macro if (((play->sceneId == SCENE_MILK_BAR) && !((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < 0xED02))) || ((play->sceneId != SCENE_MILK_BAR) && func_80BA397C(this, 0x2000))) { @@ -312,7 +312,7 @@ void func_80BA3CC4(EnToto* this, PlayState* play) { } void func_80BA3D38(EnToto* this, PlayState* play) { - this->cutscene = this->actor.cutscene; + this->csId = this->actor.csId; this->text = ENTOTO_WEEK_EVENT_FLAGS ? D_80BA50BC : D_80BA5088; func_80BA4C0C(this, play); play->actorCtx.flags |= ACTORCTX_FLAG_5; @@ -343,7 +343,7 @@ void func_80BA3DBC(EnToto* this, PlayState* play) { } func_80BA36C0(this, play, 0); - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); play->actorCtx.flags &= ~ACTORCTX_FLAG_5; } @@ -357,16 +357,16 @@ s32 func_80BA3ED4(EnToto* this, PlayState* play) { s32 func_80BA3EE8(EnToto* this, PlayState* play) { if (this->text->unk1 == 2) { - func_800B7298(play, NULL, PLAYER_CSMODE_7); + func_800B7298(play, NULL, PLAYER_CSMODE_WAIT); } return 0; } s32 func_80BA3F2C(EnToto* this, PlayState* play) { if (this->text->textId != 0) { - func_80151938(play, this->text->textId); + Message_ContinueTextbox(play, this->text->textId); } else { - func_801477B4(play); + Message_CloseTextbox(play); func_80BA3EE8(this, play); } if (this->text->unk0 == 4) { @@ -389,21 +389,21 @@ s32 func_80BA3FCC(EnToto* this, PlayState* play) { } s32 func_80BA402C(EnToto* this, PlayState* play) { - s16 prevCutscene = this->cutscene; + s16 prevCsId = this->csId; - this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); - ActorCutscene_SetIntentToPlay(this->cutscene); - ActorCutscene_Stop(prevCutscene); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); + CutsceneManager_Queue(this->csId); + CutsceneManager_Stop(prevCsId); return 0; } s32 func_80BA407C(EnToto* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &GET_PLAYER(play)->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &GET_PLAYER(play)->actor); return 1; } - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); return 0; } @@ -452,7 +452,7 @@ s32 func_80BA42BC(EnToto* this, PlayState* play) { Vec3s* end = &D_80BA510C[3]; func_80BA3FB0(this, play); - func_800B7298(play, NULL, PLAYER_CSMODE_6); + func_800B7298(play, NULL, PLAYER_CSMODE_END); if (player->actor.world.pos.z > -310.0f) { if ((player->actor.world.pos.x > -150.0f) || (player->actor.world.pos.z > -172.0f)) { phi_s0 = 3; @@ -480,14 +480,14 @@ s32 func_80BA43F4(EnToto* this, PlayState* play) { s32 func_80BA445C(EnToto* this, PlayState* play) { if (func_80BA4128(this, play)) { - func_800B7298(play, NULL, PLAYER_CSMODE_6); + func_800B7298(play, NULL, PLAYER_CSMODE_END); return 1; } return 0; } s32 func_80BA44A0(EnToto* this, PlayState* play) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->unk2B1 = 0; return 0; } @@ -515,7 +515,7 @@ s32 func_80BA4530(EnToto* this, PlayState* play) { this->unk2B6 = 1; return this->text->unk1; } - if (player->actor.bgCheckFlags & 1) { + if (player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { temp_s0 = &D_80BA50DC[gSaveContext.save.playerForm - 1]; if (func_80BA44D4(temp_s0, player)) { Math_Vec3s_ToVec3f(&player->actor.world.pos, &temp_s0->unk6); @@ -675,17 +675,17 @@ s32 func_80BA4C44(EnToto* this, PlayState* play) { } void func_80BA4CB4(EnToto* this, PlayState* play) { - CsCmdActorAction* action = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 525)]; + CsCmdActorCue* cue = play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_525)]; - if (this->unk2B5 != action->action) { - this->unk2B5 = action->action; - if (this->unk2B5 != 4) { - if (this->unk2B5 == 3) { + if (this->cueId != cue->id) { + this->cueId = cue->id; + if (this->cueId != 4) { + if (this->cueId == 3) { Animation_MorphToPlayOnce(&this->skelAnime, &object_zm_Anim_001DF0, -4.0f); } else { Animation_PlayOnce(&this->skelAnime, - this->unk2B5 == 1 ? &object_zm_Anim_0016A4 : &object_zm_Anim_0022C8); - if (this->unk2B5 == 2 && this->unk2B3 != 0xF) { + (this->cueId == 1) ? &object_zm_Anim_0016A4 : &object_zm_Anim_0022C8); + if ((this->cueId == 2) && (this->unk2B3 != 0xF)) { func_80151BB4(play, 9); func_80151BB4(play, 10); } @@ -694,12 +694,12 @@ void func_80BA4CB4(EnToto* this, PlayState* play) { } Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x320); if (SkelAnime_Update(&this->skelAnime)) { - if (this->unk2B5 != 3) { - Animation_PlayLoop(&this->skelAnime, this->unk2B5 == 1 ? &object_zm_Anim_00C880 : &object_zm_Anim_001324); + if (this->cueId != 3) { + Animation_PlayLoop(&this->skelAnime, (this->cueId == 1) ? &object_zm_Anim_00C880 : &object_zm_Anim_001324); } } - if (this->unk2B5 == 4 && !Actor_HasParent(&this->actor, play)) { - Actor_PickUp(&this->actor, play, GI_MASK_CIRCUS_LEADER, 9999.9f, 9999.9f); + if ((this->cueId == 4) && !Actor_HasParent(&this->actor, play)) { + Actor_OfferGetItem(&this->actor, play, GI_MASK_CIRCUS_LEADER, 9999.9f, 9999.9f); } } @@ -707,7 +707,7 @@ void EnToto_Update(Actor* thisx, PlayState* play) { EnToto* this = THIS; s32 pad; - if (Cutscene_CheckActorAction(play, 0x20D)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_525)) { func_80BA4CB4(this, play); } else { D_80BA51B8[this->actionFuncIndex](this, play); 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 3c95a7dbb..cf9f3c718 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.h +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.h @@ -30,10 +30,10 @@ typedef struct EnToto { /* 0x264 */ ColliderCylinder collider; /* 0x2B0 */ u8 actionFuncIndex; /* 0x2B1 */ u8 unk2B1; - /* 0x2B2 */ s8 cutscene; + /* 0x2B2 */ s8 csId; /* 0x2B3 */ u8 unk2B3; /* 0x2B4 */ u8 unk2B4; - /* 0x2B5 */ u8 unk2B5; + /* 0x2B5 */ u8 cueId; /* 0x2B6 */ u8 unk2B6; /* 0x2B7 */ u8 unk2B7; /* 0x2B8 */ EnTotoText* text; 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 caceb62bd..e4a4a4ab8 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -170,22 +170,22 @@ void EnTrt_UpdateCursorPos(PlayState* play, EnTrt* this) { void EnTrt_SetupGetMushroomCutscene(EnTrt* this) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { - if (this->cutscene != this->tmpGetMushroomCutscene) { - ActorCutscene_Stop(this->cutscene); - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (this->csId != this->tmpGetMushroomCsId) { + CutsceneManager_Stop(this->csId); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->tmpGetMushroomCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->tmpGetMushroomCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENTRT_CUTSCENESTATE_WAITING; } } if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING_SPECIAL; } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } } @@ -213,7 +213,7 @@ void EnTrt_EndInteraction(PlayState* play, EnTrt* this) { Player* player = GET_PLAYER(play); if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } Actor_ProcessTalkRequest(&this->actor, &play->state); @@ -246,7 +246,7 @@ s32 EnTrt_TestEndInteraction(EnTrt* this, PlayState* play, Input* input) { s32 EnTrt_TestCancelOption(EnTrt* this, PlayState* play, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { this->actionFunc = this->prevActionFunc; - func_80151938(play, EnTrt_GetItemTextId(this)); + Message_ContinueTextbox(play, EnTrt_GetItemTextId(this)); return true; } return false; @@ -262,7 +262,7 @@ void EnTrt_SetupStartShopping(PlayState* play, EnTrt* this, u8 skipHello) { } void EnTrt_StartShopping(PlayState* play, EnTrt* this) { - func_80151938(play, 0x83E); + Message_ContinueTextbox(play, 0x83E); func_8011552C(play, DO_ACTION_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; @@ -318,11 +318,11 @@ void EnTrt_Hello(EnTrt* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { @@ -337,7 +337,7 @@ void EnTrt_GetMushroom(EnTrt* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); Player* player = GET_PLAYER(play); - this->tmpGetMushroomCutscene = this->getMushroomCutscene; + this->tmpGetMushroomCsId = this->getMushroomCsId; if (this->cutsceneState != ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { EnTrt_SetupGetMushroomCutscene(this); if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { @@ -349,7 +349,7 @@ void EnTrt_GetMushroom(EnTrt* this, PlayState* play) { this->textId = 0x884; Message_StartTextbox(play, this->textId, &this->actor); SET_WEEKEVENTREG(WEEKEVENTREG_53_08); - Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_BOTTLE); + Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_BOTTLE_EMPTY); break; case 0x888: this->textId = 0x889; @@ -357,7 +357,7 @@ void EnTrt_GetMushroom(EnTrt* this, PlayState* play) { break; case 0x889: if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } play->msgCtx.msgMode = 0x43; @@ -375,10 +375,10 @@ void EnTrt_GetMushroom(EnTrt* this, PlayState* play) { void EnTrt_PayForMushroom(EnTrt* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; - Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_BOTTLE); + Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_BOTTLE_EMPTY); this->actionFunc = EnTrt_SetupItemGiven; } else { - Actor_PickUp(&this->actor, play, GI_RUPEE_RED, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_RED, 300.0f, 300.0f); } } @@ -387,7 +387,7 @@ void EnTrt_Goodbye(EnTrt* this, PlayState* play) { switch (this->textId) { case 0x886: this->textId = 0x887; - func_80151938(play, this->textId); + Message_ContinueTextbox(play, this->textId); break; case 0x887: case 0x88B: @@ -402,7 +402,7 @@ void EnTrt_StartRedPotionConversation(EnTrt* this, PlayState* play) { if (this->textId == 0x88F) { if (Inventory_HasEmptyBottle() || !CHECK_WEEKEVENTREG(WEEKEVENTREG_12_10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } play->msgCtx.msgMode = 0x43; @@ -453,9 +453,9 @@ void EnTrt_GiveRedPotionForKoume(EnTrt* this, PlayState* play) { player->stateFlags2 &= ~PLAYER_STATE2_20000000; this->actionFunc = EnTrt_GivenRedPotionForKoume; } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_12_10)) { - Actor_PickUp(&this->actor, play, GI_POTION_RED, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_POTION_RED, 300.0f, 300.0f); } else { - Actor_PickUp(&this->actor, play, GI_POTION_RED_BOTTLE, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_POTION_RED_BOTTLE, 300.0f, 300.0f); } } @@ -465,18 +465,18 @@ void EnTrt_GivenRedPotionForKoume(EnTrt* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); player->stateFlags2 |= PLAYER_STATE2_20000000; //! @bug: EnTrt_ContinueShopping gets overwritten by EnTrt_ItemGiven this->actionFunc = EnTrt_ContinueShopping; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperCsId; + CutsceneManager_Queue(this->csId); } } func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); @@ -517,19 +517,19 @@ void EnTrt_FaceShopkeeper(EnTrt* this, PlayState* play) { u8 cursorIndex; if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookForwardCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookForwardCutscene; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENTRT_CUTSCENESTATE_WAITING; } else if (talkState == TEXT_STATE_CHOICE) { func_8011552C(play, DO_ACTION_DECIDE); @@ -551,25 +551,25 @@ void EnTrt_FaceShopkeeper(EnTrt* this, PlayState* play) { void EnTrt_LookToShelf(EnTrt* this, PlayState* play) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShelfCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShelfCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENTRT_CUTSCENESTATE_WAITING; } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; EnTrt_UpdateCursorPos(play, this); this->actionFunc = EnTrt_BrowseShelf; - func_80151938(play, EnTrt_GetItemTextId(this)); + Message_ContinueTextbox(play, EnTrt_GetItemTextId(this)); } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } } @@ -605,7 +605,7 @@ s32 EnTrt_HasPlayerSelectedItem(PlayState* play, EnTrt* this, Input* input) { if (EnTrt_TestItemSelected(play)) { if (item->actor.params != SI_POTION_BLUE || (this->flags & ENTRT_GIVEN_MUSHROOM)) { this->prevActionFunc = this->actionFunc; - func_80151938(play, EnTrt_GetItemChoiceTextId(this)); + Message_ContinueTextbox(play, EnTrt_GetItemChoiceTextId(this)); play_sound(NA_SE_SY_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -638,7 +638,7 @@ void EnTrt_BrowseShelf(EnTrt* this, PlayState* play) { if (!EnTrt_HasPlayerSelectedItem(play, this, CONTROLLER1(&play->state))) { EnTrt_CursorLeftRight(play, this); if (this->cursorIndex != prevCursorIdx) { - func_80151938(play, EnTrt_GetItemTextId(this)); + Message_ContinueTextbox(play, EnTrt_GetItemTextId(this)); play_sound(NA_SE_SY_CURSOR); } } @@ -649,7 +649,7 @@ void EnTrt_BrowseShelf(EnTrt* this, PlayState* play) { void EnTrt_SetupBuyItemWithFanfare(PlayState* play, EnTrt* this) { Player* player = GET_PLAYER(play); - Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~PLAYER_STATE2_20000000; @@ -659,12 +659,12 @@ void EnTrt_SetupBuyItemWithFanfare(PlayState* play, EnTrt* this) { } void EnTrt_SetupCannotBuy(PlayState* play, EnTrt* this, u16 textId) { - func_80151938(play, textId); + Message_ContinueTextbox(play, textId); this->actionFunc = EnTrt_CannotBuy; } void EnTrt_SetupCanBuy(PlayState* play, EnTrt* this, u16 textId) { - func_80151938(play, textId); + Message_ContinueTextbox(play, textId); this->actionFunc = EnTrt_CanBuy; } @@ -675,7 +675,7 @@ void EnTrt_HandleCanBuyItem(PlayState* play, EnTrt* this) { switch (item->canBuyFunc(play, item)) { case CANBUY_RESULT_SUCCESS_1: if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } func_8019F208(); @@ -736,7 +736,7 @@ void EnTrt_SelectItem(EnTrt* this, PlayState* play) { case 1: func_8019F230(); this->actionFunc = this->prevActionFunc; - func_80151938(play, EnTrt_GetItemTextId(this)); + Message_ContinueTextbox(play, EnTrt_GetItemTextId(this)); break; } } @@ -746,7 +746,7 @@ void EnTrt_SelectItem(EnTrt* this, PlayState* play) { EnTrt_SetupCannotBuy(play, this, 0x846); } else { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } EnTrt_SetupBuyItemWithFanfare(play, this); @@ -790,11 +790,11 @@ void EnTrt_IdleSleeping(EnTrt* this, PlayState* play) { this->flags |= ENTRT_MET; } if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookForwardCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookForwardCutscene; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENTRT_CUTSCENESTATE_WAITING; } player->stateFlags2 |= PLAYER_STATE2_20000000; @@ -831,11 +831,11 @@ void EnTrt_IdleAwake(EnTrt* this, PlayState* play) { } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookForwardCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookForwardCutscene; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENTRT_CUTSCENESTATE_WAITING; } player->stateFlags2 |= PLAYER_STATE2_20000000; @@ -866,11 +866,11 @@ void EnTrt_BeginInteraction(EnTrt* this, PlayState* play) { s16 animLastFrame = Animation_GetLastFrame(&gKotakeWakeUpAnim) / (s16)this->skelAnime.playSpeed; if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING_SPECIAL; } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { if (this->animIndex != TRT_ANIM_HANDS_ON_COUNTER) { @@ -880,7 +880,7 @@ void EnTrt_BeginInteraction(EnTrt* this, PlayState* play) { this->blinkFunc = EnTrt_OpenEyesThenSetToBlink; this->timer = 10; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOTAKE_SURPRISED2); + Actor_PlaySfx(&this->actor, NA_SE_EN_KOTAKE_SURPRISED2); } } else { this->blinkFunc = EnTrt_OpenEyesThenSetToBlink; @@ -923,18 +923,18 @@ void EnTrt_BeginInteraction(EnTrt* this, PlayState* play) { void EnTrt_Surprised(EnTrt* this, PlayState* play) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING_SPECIAL; } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { if (DECR(this->timer) == 0) { EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT_ANIM_SURPRISED); this->animIndex = TRT_ANIM_SURPRISED; this->blinkFunc = EnTrt_OpenEyes2; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOTAKE_SURPRISED); + Actor_PlaySfx(&this->actor, NA_SE_EN_KOTAKE_SURPRISED); this->timer = 30; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; } @@ -954,7 +954,7 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, PlayState* play) { if ((talkState == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { if (Inventory_HasEmptyBottle() || !CHECK_WEEKEVENTREG(WEEKEVENTREG_12_10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } this->actionFunc = EnTrt_GiveRedPotionForKoume; @@ -973,7 +973,7 @@ void EnTrt_TryToGiveRedPotion(EnTrt* this, PlayState* play) { if (this->textId == 0x83C) { if (Inventory_HasEmptyBottle()) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } play->msgCtx.msgMode = 0x43; @@ -997,17 +997,17 @@ void EnTrt_ItemGiven(EnTrt* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); player->stateFlags2 |= PLAYER_STATE2_20000000; this->actionFunc = EnTrt_ContinueShopping; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperCsId; + CutsceneManager_Queue(this->csId); } } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { @@ -1029,7 +1029,7 @@ void EnTrt_ItemGiven(EnTrt* this, PlayState* play) { this->textId = 0x849; break; } - func_80151938(play, this->textId); + Message_ContinueTextbox(play, this->textId); } else { func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); } @@ -1054,7 +1054,7 @@ void EnTrt_ShopkeeperGone(EnTrt* this, PlayState* play) { } } if ((talkState == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE)) { play->nextEntrance = ENTRANCE(SOUTHERN_SWAMP_CLEARED, 5); } else { play->nextEntrance = ENTRANCE(SOUTHERN_SWAMP_POISONED, 5); @@ -1068,7 +1068,7 @@ void EnTrt_ShopkeeperGone(EnTrt* this, PlayState* play) { void EnTrt_CannotBuy(EnTrt* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { this->actionFunc = this->prevActionFunc; - func_80151938(play, EnTrt_GetItemTextId(this)); + Message_ContinueTextbox(play, EnTrt_GetItemTextId(this)); } } @@ -1081,7 +1081,7 @@ void EnTrt_CanBuy(EnTrt* this, PlayState* play) { item = this->items[this->cursorIndex]; item->restockFunc(play, item); this->actionFunc = this->prevActionFunc; - func_80151938(play, EnTrt_GetItemTextId(this)); + Message_ContinueTextbox(play, EnTrt_GetItemTextId(this)); } } @@ -1090,7 +1090,7 @@ void EnTrt_BuyItemWithFanfare(EnTrt* this, PlayState* play) { this->actor.parent = NULL; this->actionFunc = EnTrt_SetupItemGiven; } else { - Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); } } @@ -1098,11 +1098,11 @@ void EnTrt_SetupItemGiven(EnTrt* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { this->actionFunc = EnTrt_ItemGiven; if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperCsId; + CutsceneManager_Queue(this->csId); } func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); } @@ -1385,7 +1385,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, PlayState* play) { if (talkState == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { if ((this->talkOptionTextId == 0x845) || (this->talkOptionTextId == 0x882)) { - func_80151938(play, 0xFF); + Message_ContinueTextbox(play, 0xFF); } else { EnTrt_StartShopping(play, this); } @@ -1411,7 +1411,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, PlayState* play) { this->textId = player->actor.textId; this->actionFunc = EnTrt_Goodbye; } - func_801477B4(play); + Message_CloseTextbox(play); } else if (itemAction <= PLAYER_IA_MINUS1) { if (this->flags & ENTRT_GIVEN_MUSHROOM) { this->textId = 0x88B; @@ -1426,7 +1426,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, PlayState* play) { void EnTrt_SetupTalkToShopkeeper(PlayState* play, EnTrt* this) { this->actionFunc = EnTrt_TalkToShopkeeper; - func_80151938(play, this->talkOptionTextId); + Message_ContinueTextbox(play, this->talkOptionTextId); func_8011552C(play, DO_ACTION_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -1440,23 +1440,23 @@ void EnTrt_SetupLookToShopkeeperFromShelf(PlayState* play, EnTrt* this) { void EnTrt_LookToShopkeeperFromShelf(EnTrt* this, PlayState* play) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { - ActorCutscene_Stop(this->cutscene); + CutsceneManager_Stop(this->csId); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - this->cutscene = this->lookToShopkeeperCutscene; - ActorCutscene_SetIntentToPlay(this->cutscene); + this->csId = this->lookToShopkeeperCsId; + CutsceneManager_Queue(this->csId); this->cutsceneState = ENTRT_CUTSCENESTATE_WAITING; } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; EnTrt_StartShopping(play, this); } else { - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } } @@ -1473,7 +1473,7 @@ void EnTrt_InitShopkeeper(EnTrt* this, PlayState* play) { void EnTrt_InitShop(EnTrt* this, PlayState* play) { EnTrt_GetCutscenes(this, play); - this->cutscene = this->lookForwardCutscene; + this->csId = this->lookForwardCutscene; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); EnTrt_InitShopkeeper(this, play); this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -1553,10 +1553,10 @@ void EnTrt_InitShop(EnTrt* this, PlayState* play) { } void EnTrt_GetCutscenes(EnTrt* this, PlayState* play) { - this->lookForwardCutscene = this->actor.cutscene; - this->lookToShelfCutscene = ActorCutscene_GetAdditionalCutscene(this->lookForwardCutscene); - this->lookToShopkeeperCutscene = ActorCutscene_GetAdditionalCutscene(this->lookToShelfCutscene); - this->getMushroomCutscene = ActorCutscene_GetAdditionalCutscene(this->lookToShopkeeperCutscene); + this->lookForwardCutscene = this->actor.csId; + this->lookToShelfCsId = CutsceneManager_GetAdditionalCsId(this->lookForwardCutscene); + this->lookToShopkeeperCsId = CutsceneManager_GetAdditionalCsId(this->lookToShelfCsId); + this->getMushroomCsId = CutsceneManager_GetAdditionalCsId(this->lookToShopkeeperCsId); } void EnTrt_DrawCursor(PlayState* play, EnTrt* this, f32 x, f32 y, f32 z, u8 drawCursor) { diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.h b/src/overlays/actors/ovl_En_Trt/z_en_trt.h index c81032af5..dfa3ba5c4 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.h +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.h @@ -35,8 +35,8 @@ typedef struct EnTrt { /* 0x3D6 */ s16 blinkTimer; /* 0x3D8 */ s16 eyeTexIndex; /* 0x3DC */ EnTrtBlinkFunc blinkFunc; - /* 0x3E0 */ s16 cutscene; - /* 0x3E2 */ s16 tmpGetMushroomCutscene; + /* 0x3E0 */ s16 csId; + /* 0x3E2 */ s16 tmpGetMushroomCsId; /* 0x3E4 */ Vec3f cursorPos; /* 0x3F0 */ Color_RGBAu32 cursorColor; /* 0x400 */ u8 drawCursor; @@ -46,9 +46,9 @@ typedef struct EnTrt { /* 0x408 */ u16 prevTextId; /* 0x40A */ u16 talkOptionTextId; /* 0x40C */ s16 lookForwardCutscene; - /* 0x40E */ s16 lookToShelfCutscene; - /* 0x410 */ s16 lookToShopkeeperCutscene; - /* 0x412 */ s16 getMushroomCutscene; + /* 0x40E */ s16 lookToShelfCsId; + /* 0x410 */ s16 lookToShopkeeperCsId; + /* 0x412 */ s16 getMushroomCsId; /* 0x414 */ UNK_TYPE1 pad414[0x2]; /* 0x416 */ Vec3s headRot; /* 0x41C */ Vec3f headPos; diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index 4018a5021..67f52e064 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -164,7 +164,7 @@ void func_80AD3530(EnTrt2* this, PlayState* play) { func_80AD46F8(this); if (this->path != NULL) { phi_a1 = func_80AD48F8(this->path, this->unk_1E4, &this->actor.world.pos, &sp30); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { phi_a1 = this->actor.wallYaw; } Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 1000, 1); @@ -176,7 +176,7 @@ void func_80AD3530(EnTrt2* this, PlayState* play) { this->unk_1E4++; } } - Math_ApproachF(&this->actor.speedXZ, 1.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 1.5f, 0.2f, 1.0f); } Actor_MoveWithGravity(&this->actor); @@ -189,15 +189,15 @@ void func_80AD3530(EnTrt2* this, PlayState* play) { } void func_80AD3664(EnTrt2* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->unk_3DA)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_3DA, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); if (this->unk_3D9 == 0) { this->unk_3B2 = 1; } else { this->unk_3B2 = 2; } } else { - ActorCutscene_SetIntentToPlay(this->unk_3DA); + CutsceneManager_Queue(this->csId); return; } func_800B9010(&this->actor, NA_SE_EN_KOTAKE_FLY - SFX_FLAG); @@ -217,9 +217,9 @@ void func_80AD36EC(EnTrt2* this, PlayState* play) { this->unk_3D9 = 1; this->actor.velocity.y = 0.0f; this->path = SubS_GetPathByIndex(play, this->path->unk1, -1); - ActorCutscene_Stop(this->unk_3DA); - this->unk_3DA = ActorCutscene_GetAdditionalCutscene(this->unk_3DA); - ActorCutscene_SetIntentToPlay(this->unk_3DA); + CutsceneManager_Stop(this->csId); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); + CutsceneManager_Queue(this->csId); this->unk_3B2 = 0; } else { this->unk_1E4++; @@ -229,7 +229,7 @@ void func_80AD36EC(EnTrt2* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); func_800B9010(&this->actor, NA_SE_EN_KOTAKE_FLY - SFX_FLAG); if ((this->actor.shape.rot.y >= 0x2800) && (this->actor.shape.rot.y < 0x3800)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOTAKE_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_KOTAKE_ROLL); } } @@ -262,22 +262,22 @@ void func_80AD38B8(EnTrt2* this, PlayState* play) { this->actor.world.rot.x = -this->actor.shape.rot.x; if (func_80AD475C(this, this->path, this->unk_1E4)) { if (this->unk_1E4 >= (this->path->count - 1)) { - ActorCutscene_Stop(this->unk_3DA); + CutsceneManager_Stop(this->csId); this->unk_3D9 = 2; } else { this->unk_1E4++; } } - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { if (this->unk_1E4 >= (this->path->count - 1)) { - ActorCutscene_Stop(this->unk_3DA); + CutsceneManager_Stop(this->csId); this->unk_3D9 = 2; } else { sp30.y = this->actor.wallYaw; } } - Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 5.0f, 0.2f, 1.0f); } Actor_MoveWithoutGravity(&this->actor); @@ -286,8 +286,8 @@ void func_80AD38B8(EnTrt2* this, PlayState* play) { void func_80AD3A24(EnTrt2* this, PlayState* play) { func_80AD46F8(this); - if (this->actor.speedXZ > 0.05f) { - Math_ApproachF(&this->actor.speedXZ, 0.0f, 0.2f, 1.0f); + if (this->actor.speed > 0.05f) { + Math_ApproachF(&this->actor.speed, 0.0f, 0.2f, 1.0f); } else if (DECR(this->unk_3AE) == 0) { this->unk_3AE = Rand_S16Offset(100, 50); EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_HOVER); @@ -332,7 +332,7 @@ void func_80AD3BE4(EnTrt2* this, PlayState* play) { void func_80AD3C94(EnTrt2* this, PlayState* play) { if (this->actor.world.pos.y < 5.0f) { func_80AD4A78(this, play); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->unk_3B2 = 0xF; } } @@ -417,15 +417,15 @@ void func_80AD3FF4(EnTrt2* this, PlayState* play) { this->actor.parent = NULL; this->unk_3B2 = 14; } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_12_10)) { - Actor_PickUp(&this->actor, play, GI_POTION_RED, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_POTION_RED, 300.0f, 300.0f); } else { - Actor_PickUp(&this->actor, play, GI_POTION_RED_BOTTLE, 300.0f, 300.0f); + Actor_OfferGetItem(&this->actor, play, GI_POTION_RED_BOTTLE, 300.0f, 300.0f); } } void func_80AD40AC(EnTrt2* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { - func_800B85E0(&this->actor, play, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); this->unk_3B2 = 13; } } @@ -433,10 +433,10 @@ void func_80AD40AC(EnTrt2* this, PlayState* play) { void func_80AD4110(EnTrt2* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->unk_3A8 = 0x84C; - func_80151938(play, this->unk_3A8); + Message_ContinueTextbox(play, this->unk_3A8); this->unk_3B2 = 10; } else { - func_800B85E0(&this->actor, play, 400.0f, -1); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_MINUS1); } } @@ -466,15 +466,15 @@ void func_80AD417C(EnTrt2* this, PlayState* play) { void func_80AD4298(EnTrt2* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (ActorCutscene_GetCanPlayNext(this->unk_3DA)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_3DA, &this->actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); player->stateFlags1 |= PLAYER_STATE1_20; this->unk_3B2 = 6; } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->unk_3DA); + CutsceneManager_Queue(this->csId); } } @@ -492,7 +492,7 @@ void func_80AD434C(EnTrt2* this, PlayState* play) { if (this->actor.world.pos.y > 200.0f) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_3B2 = 0x13; - ActorCutscene_Stop(this->unk_3DA); + CutsceneManager_Stop(this->csId); } else { s32 i; Vec3f sp68; @@ -514,7 +514,7 @@ void func_80AD434C(EnTrt2* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); if ((this->actor.shape.rot.y >= 0x2800) && (this->actor.shape.rot.y < 0x3800)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOTAKE_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_KOTAKE_ROLL); } } @@ -592,7 +592,7 @@ s32 func_80AD475C(EnTrt2* this, Path* path, s32 arg2) { phi_f14 = points[arg + 1].z - points[arg - 1].z; } - func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RAD_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { ret = true; @@ -615,7 +615,7 @@ s16 func_80AD48F8(Path* path, s32 arg1, Vec3f* arg2, f32* arg3) { phi_f12 = 0.0f; } *arg3 = SQ(phi_f14) + SQ(phi_f12); - return RADF_TO_BINANG(Math_Atan2F_XY(phi_f12, phi_f14)); + return RAD_TO_BINANG(Math_Atan2F_XY(phi_f12, phi_f14)); } f32 func_80AD49B8(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3) { @@ -663,10 +663,10 @@ s32 func_80AD4B4C(EnTrt2* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { sp24 = true; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; func_80AD349C(this); this->unk_3B4 = this->unk_3B2; - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if ((player->transformation != PLAYER_FORM_HUMAN) && (player->transformation != PLAYER_FORM_FIERCE_DEITY)) { this->unk_3A8 = 0x84F; } @@ -686,7 +686,7 @@ s32 func_80AD4B4C(EnTrt2* this, PlayState* play) { } s32 func_80AD4C4C(EnTrt2* this) { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (this->actor.xzDistToPlayer < 100.0f) { return true; } @@ -700,9 +700,10 @@ s32 func_80AD4CCC(EnTrt2* this, PlayState* play) { s16 sp1E = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; Player* player = GET_PLAYER(play); - if (((this->unk_3B2 == 4) || (this->unk_3B2 == 5)) && this->actor.isTargeted && !(this->actor.bgCheckFlags & 1) && + if (((this->unk_3B2 == 4) || (this->unk_3B2 == 5)) && this->actor.isTargeted && + !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && ((player->transformation == PLAYER_FORM_HUMAN) || (player->transformation == PLAYER_FORM_FIERCE_DEITY))) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 1.5f; this->unk_3B2 = 16; return true; @@ -737,7 +738,7 @@ void func_80AD4DB4(EnTrt2* this, PlayState* play) { this->unk_3C0 = 0; this->unk_3D8 = false; - this->unk_3DA = this->actor.cutscene; + this->csId = this->actor.csId; this->unk_3B6 = 20; this->unk_3B8 = 0; this->unk_3BC = func_80AD4608; @@ -791,7 +792,7 @@ void func_80AD4FE4(EnTrt2* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); if (play->sceneId != SCENE_20SICHITAI) { - Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 10.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 10.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } Actor_SetFocus(&this->actor, 90.0f); diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.h b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.h index 44c2565f7..f30f41d80 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.h +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.h @@ -38,7 +38,7 @@ typedef struct EnTrt2 { /* 0x3D6 */ s16 unk_3D6; /* 0x3D8 */ u8 unk_3D8; /* 0x3D9 */ u8 unk_3D9; - /* 0x3DA */ s16 unk_3DA; + /* 0x3DA */ s16 csId; } EnTrt2; // size = 0x3DC #endif // Z_EN_TRT2_H 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 733ea0c57..2ba130869 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -93,8 +93,14 @@ ActorInit En_Tru_InitVars = { static Vec3f D_80A8B250 = { 0.0f, 0.02f, 0.0f }; static Color_RGBA8 D_80A8B25C[] = { - { 255, 20, 60, 0 }, { 255, 235, 160, 0 }, { 20, 60, 255, 0 }, - { 100, 100, 100, 0 }, { 255, 255, 200, 0 }, { 100, 100, 100, 0 }, + { 255, 20, 60, 0 }, + { 255, 235, 160, 0 }, + { 20, 60, 255, 0 }, +}; +static Color_RGBA8 D_80A8B268[] = { + { 100, 100, 100, 0 }, + { 255, 255, 200, 0 }, + { 100, 100, 100, 0 }, }; static f32 D_80A8B274[] = { 60.0f, 255.0f, 60.0f }; @@ -176,33 +182,33 @@ void func_80A85788(EnTruUnkStruct* arg0, PlayState* play) { func_8012C2DC(play->state.gfxCtx); for (i = 0; i < 30; i++, arg0++) { - if (arg0->unk_00 == 1) { - f32 alpha; + f32 alpha; - if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, D_80A89000); - flag = true; - } - - do { - alpha = (f32)arg0->unk_02 / arg0->unk_01; - alpha *= 255.0f; - } while (0); - - gDPPipeSync(POLY_XLU_DISP++); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 128); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)alpha); - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, -arg0->unk_02 * 5, 32, 64, 1, 0, 0, 32, 32)); - - Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); - Matrix_Translate(0.0f, 14.0f, 0.0f, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, D_80A890A8); + if (arg0->unk_00 != 1) { + continue; } + + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, D_80A89000); + flag = true; + } + + alpha = (f32)arg0->unk_02 / arg0->unk_01; + alpha *= 255.0f; + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 128); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)alpha); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, -arg0->unk_02 * 5, 32, 64, 1, 0, 0, 32, 32)); + + Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 14.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_80A890A8); } CLOSE_DISPS(play->state.gfxCtx); @@ -227,38 +233,38 @@ void func_80A85AA4(EnTruUnkStruct* arg0, Vec3f* arg1, f32 arg2, f32 arg3, f32 ar } void func_80A85BCC(EnTruUnkStruct* arg0, PlayState* play) { + GraphicsContext* gfxCtx = play->state.gfxCtx; s32 i; s32 flag = false; OPEN_DISPS(play->state.gfxCtx); - if (play) {} func_8012C2DC(play->state.gfxCtx); for (i = 0; i < 30; i++, arg0++) { - if (arg0->unk_00 == 2) { - f32 alpha; + f32 alpha; - if (!flag) { - gDPPipeSync(POLY_XLU_DISP++); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 200, 0); - flag = true; - } - - do { - alpha = (f32)arg0->unk_02 / arg0->unk_01; - alpha *= 255.0f; - } while (0); - - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)alpha); - - Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&play->billboardMtxF); - Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, D_80A8A108); + if (arg0->unk_00 != 2) { + continue; } + + if (!flag) { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 200, 0); + flag = true; + } + + alpha = (f32)arg0->unk_02 / arg0->unk_01; + alpha *= 255.0f; + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)alpha); + + Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_80A8A108); } CLOSE_DISPS(play->state.gfxCtx); @@ -282,11 +288,10 @@ void func_80A85E2C(EnTruUnkStruct* arg0, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, } } -#ifdef NON_MATCHING -// s8/s6 flipped, same deal as above functions but the same fixes don't work void func_80A85F84(EnTruUnkStruct* arg0, PlayState* play) { - u8 flag = false; + GraphicsContext* gfxCtx = play->state.gfxCtx; s32 i; + s32 flag = false; OPEN_DISPS(play->state.gfxCtx); @@ -295,50 +300,44 @@ void func_80A85F84(EnTruUnkStruct* arg0, PlayState* play) { for (i = 0; i < 30; i++, arg0++) { f32 alpha; s32 index; - - if ((arg0->unk_00 == 3) || (arg0->unk_00 == 4) || (arg0->unk_00 == 5)) { - if (!flag) { - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); - gSPDisplayList(POLY_XLU_DISP++, gKoumeDustMaterialDL); - flag = true; - } - - Matrix_Push(); - - do { - alpha = (f32)arg0->unk_02 / arg0->unk_01; - alpha *= D_80A8B274[arg0->unk_00 - 3]; - } while (0); - - gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, 0, TEXEL0, 0, - COMBINED, 0, SHADE, 0, 0, 0, 0, COMBINED); - gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_CLD_SURF2); - gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - gDPPipeSync(POLY_XLU_DISP++); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80A8B25C[arg0->unk_00 - 3].r, D_80A8B25C[arg0->unk_00 - 3].g, - D_80A8B25C[arg0->unk_00 - 3].b, (u8)alpha); - gDPSetEnvColor(POLY_XLU_DISP++, D_80A8B25C[arg0->unk_00 - 3].r, D_80A8B25C[arg0->unk_00 - 3].g, - D_80A8B25C[arg0->unk_00 - 3].b, 0); - - Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); - Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); - Matrix_ReplaceRotation(&play->billboardMtxF); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - index = ((f32)arg0->unk_02 / arg0->unk_01) * 8.0f; - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[index])); - gSPDisplayList(POLY_XLU_DISP++, gKoumeDustModelDL); - - Matrix_Pop(); + if ((arg0->unk_00 != 3) && (arg0->unk_00 != 4) && (arg0->unk_00 != 5)) { + continue; } + + if (!flag) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + gSPDisplayList(POLY_XLU_DISP++, gKoumeDustMaterialDL); + flag = true; + } + + Matrix_Push(); + + alpha = (f32)arg0->unk_02 / arg0->unk_01; + alpha *= D_80A8B274[arg0->unk_00 - 3]; + + gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, 0, TEXEL0, 0, + COMBINED, 0, SHADE, 0, 0, 0, 0, COMBINED); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_CLD_SURF2); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80A8B25C[arg0->unk_00 - 3].r, D_80A8B25C[arg0->unk_00 - 3].g, + D_80A8B25C[arg0->unk_00 - 3].b, (u8)alpha); + gDPSetEnvColor(POLY_XLU_DISP++, D_80A8B268[arg0->unk_00 - 3].r, D_80A8B268[arg0->unk_00 - 3].g, + D_80A8B268[arg0->unk_00 - 3].b, 0); + + Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); + Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); + Matrix_ReplaceRotation(&play->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + index = ((f32)arg0->unk_02 / arg0->unk_01) * 8.0f; + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[index])); + gSPDisplayList(POLY_XLU_DISP++, gKoumeDustModelDL); + Matrix_Pop(); } CLOSE_DISPS(play->state.gfxCtx); } -#else -void func_80A85F84(EnTruUnkStruct* arg0, PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru/func_80A85F84.s") -#endif s32 func_80A86384(EnTruUnkStruct* arg0, Vec3f* arg1) { s32 i; @@ -736,7 +735,7 @@ s32 func_80A87400(EnTru* this, PlayState* play) { this->unk_360 = CLAMP(this->unk_360 + 2000, 0, 0x4000); Math_ApproachF(&this->unk_35C, 30.0f, 0.08f, 1000.0f); - Math_ApproachF(&this->actor.speedXZ, 30.0f, 0.2f, 1000.0f); + Math_ApproachF(&this->actor.speed, 30.0f, 0.2f, 1000.0f); if (this->path != NULL) { sp4C = Lib_SegmentedToVirtual(this->path->points); @@ -771,7 +770,7 @@ s32 func_80A875AC(Actor* thisx, PlayState* play) { switch (this->unk_364) { case 0: if ((this->unk_34E & 0x40) || CHECK_WEEKEVENTREG(WEEKEVENTREG_16_10)) { - this->unk_374 = this->actor.cutscene; + this->csId = this->actor.csId; this->unk_364++; } else { this->unk_364++; @@ -780,14 +779,14 @@ s32 func_80A875AC(Actor* thisx, PlayState* play) { } case 1: - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_374); - } else if (ActorCutscene_GetCanPlayNext(this->unk_374)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_374, &this->actor); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csId); + } else if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); this->unk_364++; } else { - ActorCutscene_SetIntentToPlay(this->unk_374); + CutsceneManager_Queue(this->csId); } break; @@ -867,19 +866,19 @@ s32 func_80A87880(Actor* thisx, PlayState* play) { switch (this->unk_364) { case 0: - ActorCutscene_Stop(this->unk_374); - this->unk_374 = ActorCutscene_GetAdditionalCutscene(this->unk_374); + CutsceneManager_Stop(this->csId); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); this->unk_364++; case 1: - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_374); - } else if (ActorCutscene_GetCanPlayNext(this->unk_374)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_374, &this->actor); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csId); + } else if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); this->unk_364++; } else { - ActorCutscene_SetIntentToPlay(this->unk_374); + CutsceneManager_Queue(this->csId); } break; @@ -913,11 +912,11 @@ s32 func_80A87880(Actor* thisx, PlayState* play) { Animation_OnFrame(&this->skelAnime, 52.0f)) { if (Animation_OnFrame(&this->skelAnime, 52.0f)) { this->unk_34E &= ~0x400; - Player_UpdateBottleHeld(play, player, ITEM_BOTTLE, PLAYER_IA_BOTTLE); + Player_UpdateBottleHeld(play, player, ITEM_BOTTLE, PLAYER_IA_BOTTLE_EMPTY); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DRINK); + Actor_PlaySfx(&this->actor, NA_SE_EN_KOUME_DRINK); } else if (Animation_OnFrame(&this->skelAnime, 90.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_REGAIN); + Actor_PlaySfx(&this->actor, NA_SE_EN_KOUME_REGAIN); } if ((this->skelAnime.curFrame > 90.0f) && (this->skelAnime.curFrame < 95.0f)) { @@ -961,7 +960,7 @@ s32 func_80A87B48(Actor* thisx, PlayState* play) { this->unk_372 = 10; this->unk_364++; } else if (Animation_OnFrame(&this->skelAnime, 22.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_MAGIC); + Actor_PlaySfx(&this->actor, NA_SE_EN_KOUME_MAGIC); func_80A85AA4(this->unk_394, &this->unk_1F8, 1.0f, 0.1f, 40.0f); } break; @@ -999,26 +998,26 @@ s32 func_80A87DC0(Actor* thisx, PlayState* play) { switch (this->unk_364) { case 0: - ActorCutscene_Stop(this->unk_374); - this->unk_374 = ActorCutscene_GetAdditionalCutscene(this->unk_374); + CutsceneManager_Stop(this->csId); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); this->unk_364++; case 1: - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_374); - } else if (ActorCutscene_GetCanPlayNext(this->unk_374)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_374, &this->actor); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csId); + } else if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); this->unk_364++; } else { - ActorCutscene_SetIntentToPlay(this->unk_374); + CutsceneManager_Queue(this->csId); } break; case 2: AudioSfx_StopById(NA_SE_EN_KOUME_MAGIC); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_AWAY); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_LAUGH); + Actor_PlaySfx(&this->actor, NA_SE_EN_KOUME_AWAY); + Actor_PlaySfx(&this->actor, NA_SE_EN_KOUME_LAUGH); EnTru_ChangeAnim(this, KOUME_ANIM_TAKE_OFF); this->skelAnime.baseTransl.y = 0; this->skelAnime.moveFlags = 2; @@ -1102,8 +1101,8 @@ void func_80A881E0(EnTru* this, PlayState* play) { this->unk_34E |= 0x80; } - if (ActorCutscene_GetCurrentIndex() != -1) { - ActorCutscene_Stop(ActorCutscene_GetCurrentIndex()); + if (CutsceneManager_GetCurrentCsId() != CS_ID_NONE) { + CutsceneManager_Stop(CutsceneManager_GetCurrentCsId()); } if (!(this->unk_34E & 0x40) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_16_10)) { @@ -1119,7 +1118,7 @@ void func_80A881E0(EnTru* this, PlayState* play) { this->unk_34E &= ~(0x1000 | 0x8); this->unk_34E |= 0x10; this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.flags &= ~ACTOR_FLAG_100; + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; this->unk_1E8 = 0; this->actionFunc = func_80A87FD0; } @@ -1155,7 +1154,7 @@ void EnTru_Init(Actor* thisx, PlayState* play) { } this->actionFunc = func_80A87FD0; - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } void EnTru_Destroy(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.h b/src/overlays/actors/ovl_En_Tru/z_en_tru.h index 48964b555..c6d2af00c 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.h +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.h @@ -49,7 +49,7 @@ typedef struct EnTru { /* 0x36E */ s16 eyeTexIndex; /* 0x370 */ s16 unk_370; /* 0x372 */ s16 unk_372; - /* 0x374 */ s16 unk_374; + /* 0x374 */ s16 csId; /* 0x378 */ EnTruUnkFunc unk_378; /* 0x37C */ s32 animIndex; /* 0x380 */ UNK_TYPE1 unk380[0x4]; diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index e51af14ae..09ec80172 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -180,13 +180,13 @@ s32 func_80B761FC(EnTruMt* this, PlayState* play) { this->collider.base.acFlags &= ~AC_HIT; if (this->unk_3A4 == 0) { this->unk_3A4 = 1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_KOUME_DAMAGE); } else { this->unk_3A4 = 0; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DAMAGE2); + Actor_PlaySfx(&this->actor, NA_SE_EN_KOUME_DAMAGE2); } play->interfaceCtx.minigameHiddenPoints = 1; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 25); return true; } } @@ -247,13 +247,13 @@ void func_80B76440(EnTruMt* this, PlayState* play) { s16 temp_v1 = this->unk_394 - Math_Vec3f_Yaw(&this->unk_398, &this->actor.world.pos); if ((temp_v1 <= -0x2000) || (temp_v1 >= 0x2000)) { - Math_ApproachF(&this->actor.speedXZ, 7.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 7.0f, 0.2f, 1.0f); } else if (this->actor.xzDistToPlayer < 300.0f) { - Math_ApproachF(&this->actor.speedXZ, 7.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 7.0f, 0.2f, 1.0f); } else if (this->actor.xzDistToPlayer > 500.0f) { - Math_ApproachF(&this->actor.speedXZ, 2.5f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 2.5f, 0.2f, 1.0f); } else { - Math_ApproachF(&this->actor.speedXZ, 4.0f, 0.2f, 1.0f); + Math_ApproachF(&this->actor.speed, 4.0f, 0.2f, 1.0f); } } } @@ -301,7 +301,7 @@ s32 func_80B76600(EnTruMt* this, Path* path, s32 arg2) { phi_f14 = sp5C[idx + 1].z - sp5C[idx - 1].z; } - func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RAD_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { sp50 = true; } @@ -335,7 +335,7 @@ s32 func_80B768F0(EnTruMt* this, PlayState* play) { } void func_80B76924(EnTruMt* this) { - this->unk_38E.z = Math_SinS(this->unk_388) * 30.0f * (0x10000 / 360.0f); + this->unk_38E.z = DEG_TO_BINANG(Math_SinS(this->unk_388) * 30.0f); this->unk_388 += 0x400; } @@ -347,14 +347,14 @@ void func_80B76980(EnTruMt* this, PlayState* play) { SET_EVENTINF(EVENTINF_36); SET_EVENTINF(EVENTINF_40); player->stateFlags3 &= ~PLAYER_STATE3_400; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_80B76BB8; } else if (CHECK_EVENTINF(EVENTINF_40)) { u32 score = gSaveContext.minigameScore; - if (((gSaveContext.save.unk_EE8 & 0xFFFF0000) >> 0x10) < score) { - gSaveContext.save.unk_EE8 = - ((gSaveContext.minigameScore & 0xFFFF) << 0x10) | (gSaveContext.save.unk_EE8 & 0xFFFF); + if (((gSaveContext.save.saveInfo.unk_EC4 & 0xFFFF0000) >> 0x10) < score) { + gSaveContext.save.saveInfo.unk_EC4 = + ((gSaveContext.minigameScore & 0xFFFF) << 0x10) | (gSaveContext.save.saveInfo.unk_EC4 & 0xFFFF); SET_EVENTINF(EVENTINF_37); } } @@ -381,7 +381,7 @@ void func_80B76A64(EnTruMt* this, PlayState* play) { if (func_80B76600(this, this->path, this->unk_36C)) { if (this->unk_36C >= (this->path->count - 1)) { this->actionFunc = func_80B76C38; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; return; } this->unk_36C++; @@ -394,8 +394,8 @@ void func_80B76BB8(EnTruMt* this, PlayState* play) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_5) { if (Message_ShouldAdvance(play)) { play->nextEntrance = ENTRANCE(TOURIST_INFORMATION, 1); - play->transitionType = TRANS_TYPE_03; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; play->transitionTrigger = TRANS_TRIGGER_START; } } @@ -435,7 +435,7 @@ void EnTruMt_Init(Actor* thisx, PlayState* play) { this->actor.targetMode = 0; Actor_SetScale(&this->actor, 0.008f); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); this->unk_328 = 0; this->actor.room = -1; diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index a9631d96b..22ce0600c 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -103,7 +103,7 @@ void func_80ADFCEC(EnTsn* this, PlayState* play) { break; } - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { if ((ENTSN_GET_F(&this->actor)) == ENTSN_F_0) { this->actionFunc = func_80AE0D78; } else { @@ -144,7 +144,7 @@ void EnTsn_Init(Actor* thisx, PlayState* play) { this->actor.terminalVelocity = -9.0f; this->actor.gravity = -1.0f; - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { Actor_Kill(&this->actor); } } @@ -198,43 +198,43 @@ void func_80AE0010(EnTsn* this, PlayState* play) { switch (play->msgCtx.currentTextId) { case 0x107F: case 0x1081: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1080: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_001198, -10.0f); break; case 0x1082: Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); SET_WEEKEVENTREG(WEEKEVENTREG_25_80); - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80AE0304; this->actor.textId = 0; break; case 0x1083: SET_WEEKEVENTREG(WEEKEVENTREG_25_80); - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80AE0304; this->actor.textId = 0; break; case 0x1084: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_000964, -10.0f); break; case 0x1085: case 0x1086: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1089: case 0x1093: SET_WEEKEVENTREG(WEEKEVENTREG_26_01); - func_801477B4(play); + Message_CloseTextbox(play); Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); this->actionFunc = func_80AE0304; this->actor.textId = 0; @@ -242,24 +242,24 @@ void func_80AE0010(EnTsn* this, PlayState* play) { case 0x1087: Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_001198, -10.0f); - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1088: SET_WEEKEVENTREG(WEEKEVENTREG_26_01); if (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA) { - func_801477B4(play); + Message_CloseTextbox(play); Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); this->actionFunc = func_80AE0304; this->actor.textId = 0; } else { - func_80151938(play, 0x1093); + Message_ContinueTextbox(play, 0x1093); Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); } break; case 0x107E: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80AE0304; this->actor.textId = 0; break; @@ -300,7 +300,7 @@ void func_80AE0460(EnTsn* this, PlayState* play) { ENTSN_SET_Z(&this->unk_1D8->actor, false); this->actionFunc = func_80AE0418; } else { - Actor_PickUp(&this->actor, play, GI_SEAHORSE_CAUGHT, 2000.0f, 1000.0f); + Actor_OfferGetItem(&this->actor, play, GI_SEAHORSE_CAUGHT, 2000.0f, 1000.0f); } } @@ -322,16 +322,16 @@ void func_80AE04FC(EnTsn* this, PlayState* play) { } if (itemAction > PLAYER_IA_NONE) { - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80AE0704; if (itemAction == PLAYER_IA_PICTO_BOX) { if (CHECK_QUEST_ITEM(QUEST_PICTOGRAPH)) { - if (Snap_CheckFlag(PICTOGRAPH_PIRATE_GOOD)) { + if (Snap_CheckFlag(PICTO_VALID_PIRATE_GOOD)) { player->actor.textId = 0x107B; return; } - if (Snap_CheckFlag(PICTOGRAPH_PIRATE_TOO_FAR)) { + if (Snap_CheckFlag(PICTO_VALID_PIRATE_TOO_FAR)) { player->actor.textId = 0x10A9; return; } @@ -357,7 +357,7 @@ void func_80AE04FC(EnTsn* this, PlayState* play) { } if (itemAction <= PLAYER_IA_MINUS1) { - func_80151938(play, 0x1078); + Message_ContinueTextbox(play, 0x1078); Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_001198, -10.0f); this->actionFunc = func_80AE0704; } @@ -365,11 +365,11 @@ void func_80AE04FC(EnTsn* this, PlayState* play) { } void func_80AE0698(EnTsn* this, PlayState* play) { - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80AE0C88; this->unk_220 &= ~2; this->actor.focus.pos = this->actor.world.pos; - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); ENTSN_SET_Z(&this->unk_1D8->actor, false); } @@ -391,9 +391,9 @@ void func_80AE0704(EnTsn* this, PlayState* play) { switch (play->msgCtx.currentTextId) { case 0x106E: if (CHECK_WEEKEVENTREG(WEEKEVENTREG_25_40)) { - func_80151938(play, 0x1074); + Message_ContinueTextbox(play, 0x1074); } else { - func_80151938(play, 0x106F); + Message_ContinueTextbox(play, 0x106F); } this->unk_220 |= 2; SET_WEEKEVENTREG(WEEKEVENTREG_25_40); @@ -405,51 +405,51 @@ void func_80AE0704(EnTsn* this, PlayState* play) { case 0x1070: case 0x1071: case 0x1072: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1076: case 0x1079: Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_000964, -10.0f); - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x107A: - func_80151938(play, 0x10A6); + Message_ContinueTextbox(play, 0x10A6); break; case 0x1075: case 0x1078: player->exchangeItemId = 0; - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); break; case 0x107C: if (Inventory_HasEmptyBottle()) { SET_WEEKEVENTREG(WEEKEVENTREG_26_08); - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80AE0460; func_80AE0460(this, play); this->unk_220 &= ~2; this->actor.focus.pos = this->actor.world.pos; - ActorCutscene_Stop(this->actor.cutscene); - this->actor.flags &= ~ACTOR_FLAG_100; + CutsceneManager_Stop(this->actor.csId); + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; REMOVE_QUEST_ITEM(QUEST_PICTOGRAPH); } else { - func_80151938(play, 0x10A8); + Message_ContinueTextbox(play, 0x10A8); } break; case 0x1073: case 0x1074: - func_80151938(play, 0xFF); + Message_ContinueTextbox(play, 0xFF); this->actionFunc = func_80AE04FC; break; case 0x107B: player->exchangeItemId = 0; - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); break; @@ -458,14 +458,14 @@ void func_80AE0704(EnTsn* this, PlayState* play) { case 0x10A8: Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); func_80AE0698(this, play); - this->actor.flags &= ~ACTOR_FLAG_100; + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; this->actionFunc = func_80AE04C4; break; case 0x108A: case 0x1091: SET_WEEKEVENTREG(WEEKEVENTREG_26_04); - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); this->unk_220 |= 2; this->actor.textId = 0x1091; break; @@ -475,14 +475,14 @@ void func_80AE0704(EnTsn* this, PlayState* play) { case 0x108D: case 0x108E: case 0x108F: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1092: if (CHECK_WEEKEVENTREG(WEEKEVENTREG_26_08)) { func_80AE0698(this, play); } else { - func_80151938(play, 0x10A7); + Message_ContinueTextbox(play, 0x10A7); Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_000964, -10.0f); } break; @@ -498,7 +498,7 @@ void func_80AE0704(EnTsn* this, PlayState* play) { case 0x10A9: func_80AE0698(this, play); - this->actor.flags &= ~ACTOR_FLAG_100; + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; this->actionFunc = func_80AE04C4; break; } @@ -515,16 +515,16 @@ void func_80AE0704(EnTsn* this, PlayState* play) { } if (this->unk_220 & 4) { - if (this->actor.cutscene == -1) { + if (this->actor.csId == CS_ID_NONE) { this->unk_220 &= ~4; - } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actor.cutscene); - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } else if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->actor.csId); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); this->unk_220 &= ~4; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } } @@ -543,9 +543,9 @@ void func_80AE0C88(EnTsn* this, PlayState* play) { void func_80AE0D10(EnTsn* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80AE0D78; - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); } } @@ -567,7 +567,7 @@ void EnTsn_Update(Actor* thisx, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 25.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 25.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); SkelAnime_Update(&this->skelAnime); if (this->unk_220 & 1) { 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 4f7b8b720..340618db7 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 @@ -173,7 +173,7 @@ void EnTuboTrap_HandleImpact(EnTuboTrap* this, PlayState* play) { Player* player = GET_PLAYER(play); Player* player2 = GET_PLAYER(play); - if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 15.0f)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER) && (this->actor.depthInWater > 15.0f)) { EnTuboTrap_SpawnEffectsInWater(this, play); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_BOMB_DROP_WATER); EnTuboTrap_DropCollectible(this, play); @@ -214,7 +214,7 @@ void EnTuboTrap_HandleImpact(EnTuboTrap* this, PlayState* play) { } } - if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { EnTuboTrap_SpawnEffectsOnLand(this, play); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); EnTuboTrap_DropCollectible(this, play); @@ -246,7 +246,7 @@ void EnTuboTrap_Idle(EnTuboTrap* this, PlayState* play) { this->targetHeight += transformationHeight; } this->originPos = this->actor.world.pos; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POT_MOVE_START); + Actor_PlaySfx(&this->actor, NA_SE_EV_POT_MOVE_START); this->actionFunc = EnTuboTrap_Levitate; } } @@ -257,7 +257,7 @@ void EnTuboTrap_Levitate(EnTuboTrap* this, PlayState* play) { Math_ApproachF(&this->actor.world.pos.y, this->targetHeight, 0.8f, 3.0f); if (fabsf(this->actor.world.pos.y - this->targetHeight) < 10.0f) { - this->actor.speedXZ = 10.0f; + this->actor.speed = 10.0f; this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actionFunc = EnTuboTrap_FlyAtPlayer; } @@ -273,7 +273,7 @@ void EnTuboTrap_FlyAtPlayer(EnTuboTrap* this, PlayState* play) { // 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 - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MIZUBABA2_ATTACK - SFX_FLAG); + Actor_PlaySfx(&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); @@ -289,7 +289,9 @@ void EnTuboTrap_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 10.0f, 20.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 10.0f, 20.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); Actor_SetFocus(&this->actor, 0.0f); if (this->actor.projectedPos.z < 811.0f) { diff --git a/src/overlays/actors/ovl_En_Twig/z_en_twig.c b/src/overlays/actors/ovl_En_Twig/z_en_twig.c index 5843357ee..b756d0f92 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.c +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.c @@ -4,6 +4,7 @@ * Description: Beaver Race Ring */ +#include "prevent_bss_reordering.h" #include "z_en_twig.h" #include "objects/object_twig/object_twig.h" @@ -37,9 +38,9 @@ ActorInit En_Twig_InitVars = { (ActorFunc)EnTwig_Draw, }; -static s32 sCurrentRing; -static s16 sRingCount; -static s16 sRingNotCollected[25]; +s32 sCurrentRing; +s16 sRingCount; +s16 sRingNotCollected[25]; static CollisionHeader* sColHeaders[] = { NULL, @@ -63,15 +64,16 @@ void EnTwig_Init(Actor* thisx, PlayState* play2) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); this->unk_160 = RACERING_GET_PARAM_F(&this->dyna.actor); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); if (sColHeaders[this->unk_160] != NULL) { DynaPolyActor_LoadMesh(play, &this->dyna, sColHeaders[this->unk_160]); } - this->dyna.actor.bgCheckFlags |= 0x400; + this->dyna.actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_400; switch (this->unk_160) { case 0: Actor_Kill(&this->dyna.actor); break; + case 1: if (!sRingsHaveSpawned) { sRingCount = CHECK_WEEKEVENTREG(WEEKEVENTREG_24_04) ? 25 : 20; @@ -91,14 +93,18 @@ void EnTwig_Init(Actor* thisx, PlayState* play2) { } Actor_SetScale(&this->dyna.actor, 4.2f); this->dyna.actor.uncullZoneScale = this->dyna.actor.uncullZoneDownward = this->dyna.actor.scale.x * 60.0f; - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); func_80AC0A7C(this, play); break; + case 2: Actor_SetScale(&this->dyna.actor, 1.0f); this->dyna.actor.uncullZoneScale = this->dyna.actor.uncullZoneDownward = this->dyna.actor.scale.x * 880.0f; func_80AC0A54(this, play); break; + + default: + break; } } @@ -149,9 +155,9 @@ void func_80AC0AC8(EnTwig* this, PlayState* play) { } } else { if (this->dyna.actor.xyzDistToPlayerSq <= SQ((this->dyna.actor.scale.x * 40.0f) + 40)) { - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } else { - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } if (this->dyna.actor.xyzDistToPlayerSq >= (this->dyna.actor.scale.x * 10.0f * 40.0f * 40.0f)) { this->dyna.actor.shape.rot.y = this->dyna.actor.yawTowardsPlayer; @@ -165,7 +171,7 @@ void func_80AC0CC4(EnTwig* this, PlayState* play) { this->unk_170 = 3458.0f; this->unk_174 = 0.2f; this->unk_16C |= 1; - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->actionFunc = func_80AC0D2C; } diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.c b/src/overlays/actors/ovl_En_Vm/z_en_vm.c index 50109f887..505df7f11 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -180,7 +180,7 @@ void EnVm_Init(Actor* thisx, PlayState* play) { this->unk_21C = params * 40.0f; thisx->params &= 0xFF; - this->actor.bgCheckFlags |= 0x400; + this->actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_400; if (!D_808CD5B8) { for (i = 0; i < ARRAY_COUNT(D_808CD58C); i++) { @@ -265,7 +265,7 @@ void func_808CC610(EnVm* this, PlayState* play) { } void func_808CC788(EnVm* this) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BIMOS_AIM); + Actor_PlaySfx(&this->actor, NA_SE_EN_BIMOS_AIM); Animation_Change(&this->skelAnime, &object_vm_Anim_000068, 3.0f, 3.0f, 7.0f, ANIMMODE_ONCE, 0.0f); this->unk_214 = 305; this->unk_220 = 0.06f; @@ -328,7 +328,7 @@ void func_808CCA10(EnVm* this) { this->unk_210 = 0; this->unk_224 = 0.0f; this->unk_220 = 0.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->actionFunc = func_808CCAA4; } @@ -368,7 +368,7 @@ void func_808CCBE4(EnVm* this, PlayState* play) { Animation_Change(&this->skelAnime, &object_vm_Anim_000068, -1.0f, Animation_GetLastFrame(&object_vm_Anim_000068), 0.0f, ANIMMODE_ONCE, 0.0f); Enemy_StartFinishingBlow(play, &this->actor); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 33); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 33); this->unk_214 = 33; this->unk_220 = 0.0f; this->unk_224 = 0.0f; @@ -376,7 +376,7 @@ void func_808CCBE4(EnVm* this, PlayState* play) { this->actor.world.pos.y = this->actor.focus.pos.y; this->actor.velocity.y = 8.0f; this->actor.gravity = -0.5f; - this->actor.speedXZ = Rand_ZeroOne() + 1.0f; + this->actor.speed = Rand_ZeroOne() + 1.0f; this->unk_210 = 0; this->actor.flags |= ACTOR_FLAG_10; this->actionFunc = func_808CCCF0; @@ -386,7 +386,8 @@ void func_808CCCF0(EnVm* this, PlayState* play) { this->unk_216 += 0x5DC; this->unk_218 += 0x9C4; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 40.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 20.0f, 40.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); this->unk_214--; if (this->unk_214 == 1) { @@ -440,7 +441,7 @@ void EnVm_Update(Actor* thisx, PlayState* play) { if ((play->gameplayFrames % 2) != 0) { func_800BBFB0(play, &this->unk_234, 6.0f, 1, 120, 20, 1); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BIMOS_LAZER_GND - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_BIMOS_LAZER_GND - SFX_FLAG); } if (this->unk_224 > 0.0f) { diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c index 74bd4fec6..a4b3f7cc6 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -191,8 +191,8 @@ void EnWallmas_Destroy(Actor* thisx, PlayState* play) { if (this->actor.parent != NULL) { EnEncount1* encount1 = (EnEncount1*)this->actor.parent; - if ((encount1->actor.update != NULL) && (encount1->unk_14E > 0)) { - encount1->unk_14E--; + if ((encount1->actor.update != NULL) && (encount1->spawnActiveCount > 0)) { + encount1->spawnActiveCount--; } } } @@ -205,7 +205,7 @@ void EnWallmas_Freeze(EnWallmas* this) { this->collider.base.colType = 3; this->timer = 80; this->actor.flags &= ~ACTOR_FLAG_400; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 80); } void EnWallmas_ThawIfFrozen(EnWallmas* this, PlayState* play) { @@ -245,7 +245,7 @@ void EnWallmas_WaitToDrop(EnWallmas* this, PlayState* play) { if ((player->stateFlags1 & (PLAYER_STATE1_100000 | PLAYER_STATE1_8000000)) || (player->stateFlags2 & PLAYER_STATE2_80) || (player->unk_B5E > 0) || (player->actor.freezeTimer > 0) || - !(player->actor.bgCheckFlags & 1) || + !(player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || ((WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) && (Math_Vec3f_DistXZ(&this->actor.home.pos, playerPos) > (120.f + this->detectionRadius)))) { AudioSfx_StopById(NA_SE_EN_FALL_AIM); @@ -253,7 +253,7 @@ void EnWallmas_WaitToDrop(EnWallmas* this, PlayState* play) { } if (this->timer == 80) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_AIM); + Actor_PlaySfx(&this->actor, NA_SE_EN_FALL_AIM); } if (this->timer == 0) { @@ -298,7 +298,7 @@ void EnWallmas_SetupLand(EnWallmas* this, PlayState* play) { ANIMMODE_ONCE, -3.0f); Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, true); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_LAND); + Actor_PlaySfx(&this->actor, NA_SE_EN_FALL_LAND); this->actionFunc = EnWallmas_Land; } @@ -324,7 +324,7 @@ void EnWallmas_Stand(EnWallmas* this, PlayState* play) { void EnWallmas_SetupWalk(EnWallmas* this) { Animation_PlayOnceSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 3.0f); - this->actor.speedXZ = 3.0f; + this->actor.speed = 3.0f; this->actionFunc = EnWallmas_Walk; } @@ -337,13 +337,13 @@ void EnWallmas_Walk(EnWallmas* this, PlayState* play) { this->actor.world.rot.y = this->actor.shape.rot.y; 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)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_FALL_WALK); } } void EnWallmas_SetupJumpToCeiling(EnWallmas* this) { Animation_PlayOnce(&this->skelAnime, &gWallmasterStopWalkAnim); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = EnWallmas_JumpToCeiling; } @@ -355,7 +355,7 @@ void EnWallmas_JumpToCeiling(EnWallmas* this, PlayState* play) { void EnWallmas_SetupReturnToCeiling(EnWallmas* this) { this->timer = 0; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 3.0f, 0.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), ANIMMODE_ONCE, -3.0f); this->actionFunc = EnWallmas_ReturnToCeiling; @@ -372,7 +372,7 @@ void EnWallmas_ReturnToCeiling(EnWallmas* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 20.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_FALL_UP); } if (this->actor.playerHeightRel < -900.0f) { @@ -397,8 +397,8 @@ void EnWallmas_SetupDamage(EnWallmas* this, s32 arg1) { func_800BE504(&this->actor, &this->collider); } - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); - this->actor.speedXZ = 5.0f; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 20); + this->actor.speed = 5.0f; this->actor.velocity.y = 10.0f; this->actionFunc = EnWallmas_Damage; } @@ -413,15 +413,15 @@ void EnWallmas_Damage(EnWallmas* this, PlayState* play) { } if (Animation_OnFrame(&this->skelAnime, 13.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); } - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); + Math_StepToF(&this->actor.speed, 0.0f, 0.2f); } void EnWallmas_SetupCooldown(EnWallmas* this) { Animation_PlayOnce(&this->skelAnime, &gWallmasterRecoverFromDamageAnim); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = EnWallmas_Cooldown; @@ -434,7 +434,7 @@ void EnWallmas_Cooldown(EnWallmas* this, PlayState* play) { } void EnWallmas_SetupDie(EnWallmas* this, PlayState* play) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 250, -10, 2); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); @@ -456,7 +456,7 @@ void EnWallmas_SetupTakePlayer(EnWallmas* this, PlayState* play) { Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterHoverAnim, -5.0f); this->timer = -30; this->actionFunc = EnWallmas_TakePlayer; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; this->yTarget = this->actor.playerHeightRel; func_800B724C(play, &this->actor, PLAYER_CSMODE_18); @@ -466,8 +466,8 @@ void EnWallmas_TakePlayer(EnWallmas* this, PlayState* play) { Player* player = GET_PLAYER(play); if (Animation_OnFrame(&this->skelAnime, 1.0f)) { - func_800B8E58(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_CATCH); + Player_PlaySfx(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S); + Actor_PlaySfx(&this->actor, NA_SE_EN_FALL_CATCH); } if (SkelAnime_Update(&this->skelAnime)) { @@ -482,11 +482,11 @@ void EnWallmas_TakePlayer(EnWallmas* this, PlayState* play) { player->actor.world.pos.y = this->actor.world.pos.y - sYOffsetPerForm[GET_PLAYER_FORM]; if (this->timer == -30) { - func_800B8E58(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_TAKEN_AWAY); + Player_PlaySfx(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_TAKEN_AWAY); } if (this->timer == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_UP); + Actor_PlaySfx(&this->actor, NA_SE_EN_FALL_UP); } this->timer += 2; @@ -530,7 +530,7 @@ void EnWallmas_WaitForSwitchFlag(EnWallmas* this, PlayState* play) { } void EnWallmas_SetupStun(EnWallmas* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->actor.velocity.y > 0.0f) { this->actor.velocity.y = 0.0f; } @@ -564,10 +564,10 @@ void EnWallmas_UpdateDamage(EnWallmas* this, PlayState* play) { (!(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { if (Actor_ApplyDamage(&this->actor) == 0) { Enemy_StartFinishingBlow(play, &this->actor); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_REVERSE); + Actor_PlaySfx(&this->actor, NA_SE_EN_DAIOCTA_REVERSE); this->actor.flags &= ~ACTOR_FLAG_1; } else if (this->actor.colChkInfo.damage != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_FALL_DAMAGE); } EnWallmas_ThawIfFrozen(this, play); @@ -583,13 +583,13 @@ void EnWallmas_UpdateDamage(EnWallmas* this, PlayState* play) { EnWallmas_SetupStun(this); } else if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_STUN) { this->timer = 40; - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); EnWallmas_SetupStun(this); } else if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_ZORA_MAGIC) { this->timer = 40; - Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); this->drawDmgEffScale = 0.55f; this->drawDmgEffAlpha = 2.0f; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; @@ -629,13 +629,15 @@ void EnWallmas_Update(Actor* thisx, PlayState* play) { } if (this->actionFunc != EnWallmas_Drop) { - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 25.0f, 0.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 25.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } if ((this->actionFunc != EnWallmas_Die) && (this->actionFunc != EnWallmas_Drop)) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - if ((this->actionFunc != EnWallmas_Damage) && (this->actor.bgCheckFlags & 1) && + if ((this->actionFunc != EnWallmas_Damage) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.freezeTimer == 0)) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h index ceb1d1823..93dd63245 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h @@ -8,6 +8,8 @@ #define WALLMASTER_GET_SWITCH_FLAG(thisx) (((thisx)->params >> 8) & 0xFF) #define WALLMASTER_IS_FROZEN(thisx) ((thisx)->params & 0x80) +#define WALLMASTER_PARAMS(type, switchFlag, isFrozen) ((type) | (((switchFlag) << 8) & 0xFF) | (((isFrozen) << 7) & 0x80)) + /** * This type determines under what conditions the Wallmaster will drop from the ceiling. * - WALLMASTER_TYPE_TIMER_ONLY: These Wallmasters don't check for anything to determine 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 32038c411..3cfc1eba7 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 @@ -98,7 +98,7 @@ void func_80A66278(EnWarpUzu* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { func_80A66384(this, play); } else { - phi_a0 = ABS((s16)(Actor_YawBetweenActors(&this->actor, &player->actor) - this->actor.shape.rot.y)); + phi_a0 = ABS((s16)(Actor_WorldYawTowardActor(&this->actor, &player->actor) - this->actor.shape.rot.y)); temp_v0 = player->actor.shape.rot.y - this->actor.shape.rot.y; phi_v1 = ABS(temp_v0); if (phi_a0 >= 0x2AAB) { diff --git a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c index 77b857c14..6d5522e8a 100644 --- a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c +++ b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c @@ -8,7 +8,7 @@ #include "z_en_warp_tag.h" #include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnWarptag*)thisx) @@ -126,9 +126,9 @@ void EnWarpTag_Unused809C09A0(EnWarptag* this, PlayState* play) { */ void EnWarpTag_Unused809C0A20(EnWarptag* this, PlayState* play) { if (play->msgCtx.ocarinaMode == 9) { - func_800B7298(play, NULL, PLAYER_CSMODE_7); + func_800B7298(play, NULL, PLAYER_CSMODE_WAIT); this->actionFunc = EnWarpTag_RespawnPlayer; - ActorCutscene_Stop(ActorCutscene_GetCurrentIndex()); + CutsceneManager_Stop(CutsceneManager_GetCurrentCsId()); } else if (play->msgCtx.ocarinaMode >= 2) { play->msgCtx.ocarinaMode = 4; @@ -141,7 +141,7 @@ void EnWarpTag_Unused809C0A20(EnWarptag* this, PlayState* play) { */ void EnWarpTag_RespawnPlayer(EnWarptag* this, PlayState* play) { ActorEntry* playerActorEntry; - Player* player; + Player* player = GET_PLAYER(play); s32 playerSpawnIndex; s32 new15E; s32 entrance; @@ -149,15 +149,15 @@ void EnWarpTag_RespawnPlayer(EnWarptag* this, PlayState* play) { u8 playerForm; s16 playerParams; - player = GET_PLAYER(play); - if (play->playerActorCsIds[4] >= 0 && ActorCutscene_GetCurrentIndex() != play->playerActorCsIds[4]) { - if (ActorCutscene_GetCanPlayNext(play->playerActorCsIds[4]) == 0) { - ActorCutscene_SetIntentToPlay(play->playerActorCsIds[4]); + if (play->playerCsIds[PLAYER_CS_ID_WARP_PAD_MOON] >= 0 && + CutsceneManager_GetCurrentCsId() != play->playerCsIds[PLAYER_CS_ID_WARP_PAD_MOON]) { + if (!CutsceneManager_IsNext(play->playerCsIds[PLAYER_CS_ID_WARP_PAD_MOON])) { + CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_WARP_PAD_MOON]); } else { - ActorCutscene_StartAndSetUnkLinkFields(play->playerActorCsIds[4], &this->dyna.actor); - func_800B8E58(player, NA_SE_PL_WARP_PLATE); - func_8016566C(0); + CutsceneManager_StartWithPlayerCs(play->playerCsIds[PLAYER_CS_ID_WARP_PAD_MOON], &this->dyna.actor); + Player_PlaySfx(player, NA_SE_PL_WARP_PLATE); + Play_EnableMotionBlur(0); } } else { @@ -208,14 +208,13 @@ void EnWarpTag_RespawnPlayer(EnWarptag* this, PlayState* play) { // why are we getting player home rotation from the room data? doesnt player have home.rot.y? // especially because we are converting from deg to binang, but isnt home.rot.y already in binang?? - Play_SetRespawnData( - &play->state, 0, entrance, // parameter 3 is called "sceneSetup" - play->setupEntranceList[playerSpawnIndex].room, playerParams, &newRespawnPos, - ((((playerActorEntry->rot.y >> 7) & 0x1FF) / 180.0f) * 32768.0f)); // DEG_TO_BINANG ? + Play_SetRespawnData(&play->state, 0, entrance, play->setupEntranceList[playerSpawnIndex].room, + playerParams, &newRespawnPos, + DEG_TO_BINANG_ALT((playerActorEntry->rot.y >> 7) & 0x1FF)); func_80169EFC(&play->state); - gSaveContext.respawnFlag = ~0x4; - func_80165690(); + gSaveContext.respawnFlag = -5; + Play_DisableMotionBlur(); } } @@ -224,7 +223,7 @@ void EnWarpTag_RespawnPlayer(EnWarptag* this, PlayState* play) { if (new15E < 0) { new15E = 0; } - func_80165658(new15E * 0.04f); // unknown Play_ function + Play_SetMotionBlurAlpha(new15E * (1 / 25.0f)); } } @@ -232,11 +231,11 @@ void EnWarpTag_RespawnPlayer(EnWarptag* this, PlayState* play) { * ActionFunc: Deku Playground, return to North Clock Town. */ void EnWarpTag_GrottoReturn(EnWarptag* this, PlayState* play) { - if (ActorCutscene_GetCurrentIndex() != this->dyna.actor.cutscene) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_GetCurrentCsId() != this->dyna.actor.csId) { + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } 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 94890bd39..159b7444e 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 @@ -158,7 +158,7 @@ void EnWaterEffect_Update(Actor* thisx, PlayState* play2) { this->unk_DC4++; if ((this->unk_DC4 % 32) == 0) { if (Rand_ZeroOne() < 0.5f) { - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 10.0f, 40.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 10.0f, 40.0f, UPDBGCHECKINFO_FLAG_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; @@ -420,7 +420,7 @@ void func_80A59C04(Actor* thisx, PlayState* play2) { this->unk_DC4++; if (this->unk_DC6 == 0) { this->unk_DC6 = Rand_ZeroFloat(150.0f) + 100.0f; - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 10.0f, 40.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 10.0f, 40.0f, UPDBGCHECKINFO_FLAG_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; @@ -482,7 +482,7 @@ void func_80A59C04(Actor* thisx, PlayState* play2) { player->flameTimers[j] = Rand_S16Offset(0, 200); } player->isBurning = true; - func_800B8E58(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DEMO_DAMAGE); + Player_PlaySfx(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DEMO_DAMAGE); } } @@ -570,7 +570,7 @@ void func_80A5A184(Actor* thisx, PlayState* play2) { } } - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); CLOSE_DISPS(gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index 7ddd539e7..fb00fdae3 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -77,7 +77,7 @@ void EnWeatherTag_Init(Actor* thisx, PlayState* play) { EnWeatherTag_SetupAction(this, func_80966A08); break; case WEATHERTAG_TYPE_UNK1: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE)) { Actor_Kill(&this->actor); } EnWeatherTag_SetupAction(this, func_80966B08); @@ -86,7 +86,9 @@ void EnWeatherTag_Init(Actor* thisx, PlayState* play) { EnWeatherTag_SetupAction(this, func_80966E0C); break; case WEATHERTAG_TYPE_UNK3: - if (0) {} // this can move to diff locations and still match + //! FAKE: this can move to different locations and still match + if (1) {} + EnWeatherTag_SetupAction(this, func_80966EF0); break; case WEATHERTAG_TYPE_UNK4: @@ -94,7 +96,7 @@ void EnWeatherTag_Init(Actor* thisx, PlayState* play) { break; case WEATHERTAG_TYPE_UNK5: func_800BC154(play, &play->actorCtx, &this->actor, 7); - play->skyboxId = 3; + play->skyboxId = SKYBOX_3; play->envCtx.unk_1F = 5; play->envCtx.unk_20 = 5; D_801F4E74 = 1.0f; @@ -119,7 +121,7 @@ u8 func_80966608(EnWeatherTag* this, PlayState* play, UNK_TYPE a3, UNK_TYPE a4, Player* player = GET_PLAYER(play); u8 returnVal = 0; - if (WEATHER_TAG_RANGE100(&this->actor) > Actor_XZDistanceBetweenActors(&player->actor, &this->actor)) { + if (WEATHER_TAG_RANGE100(&this->actor) > Actor_WorldDistXZToActor(&player->actor, &this->actor)) { if (play->envCtx.unk_1F == play->envCtx.unk_20) { D_801BDBB8 = 1; if (!(play->envCtx.unk_1E == 0) || ((play->envCtx.unk_1F != 1) && (play->envCtx.unk_21 == 0))) { @@ -147,7 +149,7 @@ u8 func_80966758(EnWeatherTag* this, PlayState* play, UNK_TYPE a3, UNK_TYPE a4, Player* player = GET_PLAYER(play); u8 returnVal = 0; - if (WEATHER_TAG_RANGE100(&this->actor) < Actor_XZDistanceBetweenActors(&player->actor, &this->actor)) { + if (WEATHER_TAG_RANGE100(&this->actor) < Actor_WorldDistXZToActor(&player->actor, &this->actor)) { if (play->envCtx.unk_1F == play->envCtx.unk_20) { D_801BDBB8 = 1; if (!(play->envCtx.unk_1E == 0) || ((play->envCtx.unk_1F != 1) && (play->envCtx.unk_21 == 0))) { @@ -173,7 +175,7 @@ void func_8096689C(EnWeatherTag* this, PlayState* play) { f32 distance; f32 partialResult; - distance = Actor_XZDistanceBetweenActors(&player->actor, &this->actor); + distance = Actor_WorldDistXZToActor(&player->actor, &this->actor); if (this->fadeDistance < distance) { distance = this->fadeDistance; } @@ -231,10 +233,10 @@ void EnWeatherTag_Die(EnWeatherTag* this, PlayState* play) { // this tag stops spawning after STT cleared? void func_80966B08(EnWeatherTag* this, PlayState* play) { if (func_80966608(this, play, 0, 0, play->envCtx.unk_1F, 5, 100, 2) || (gWeatherMode == 2)) { - play->skyboxId = 3; + play->skyboxId = SKYBOX_3; EnWeatherTag_SetupAction(this, func_80966D20); } else if (D_801F4E74 <= 0.01f) { - play->skyboxId = 1; + play->skyboxId = SKYBOX_NORMAL_SKY; } else { Math_SmoothStepToF(&D_801F4E74, 0.0f, 0.2f, 0.02f, 0.001f); } @@ -244,11 +246,11 @@ void func_80966B08(EnWeatherTag* this, PlayState* play) { // because it uses cutsecnes.. is this the clear ikana cutcsene? void func_80966BF4(EnWeatherTag* this, PlayState* play) { u8 newUnk20; - CsCmdActorAction* tmpAction; + CsCmdActorCue* cue; - if (Cutscene_CheckActorAction(play, 567)) { - tmpAction = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 567)]; - if ((play->csCtx.frames >= tmpAction->startFrame) && (tmpAction->action >= 2)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_567)) { + cue = play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_567)]; + if ((play->csCtx.curFrame >= cue->startFrame) && (cue->id >= 2)) { switch (gSaveContext.save.day) { case 0: case 1: @@ -377,14 +379,13 @@ void func_80967060(EnWeatherTag* this, PlayState* play) { // type 4_3, start cutscene then die? void func_80967148(EnWeatherTag* this, PlayState* play) { - s16 tempCutscene; + s16 csId = this->actor.csId; - tempCutscene = this->actor.cutscene; - if (ActorCutscene_GetCanPlayNext(tempCutscene)) { - ActorCutscene_Start(tempCutscene, &this->actor); + if (CutsceneManager_IsNext(csId)) { + CutsceneManager_Start(csId, &this->actor); EnWeatherTag_SetupAction(this, EnWeatherTag_DoNothing); } else { - ActorCutscene_SetIntentToPlay(tempCutscene); + CutsceneManager_Queue(csId); } } @@ -422,7 +423,7 @@ void func_809672DC(EnWeatherTag* this, PlayState* play) { Actor_GetClosestPosOnPath(this->pathPoints, this->pathCount, &GET_PLAYER(play)->actor.world.pos, &this->actor.world.pos, false); - distance = Actor_XZDistanceBetweenActors(&player->actor, &this->actor); + distance = Actor_WorldDistXZToActor(&player->actor, &this->actor); range = WEATHER_TAG_RANGE100(&this->actor); if (distance < range) { @@ -447,7 +448,7 @@ void func_809672DC(EnWeatherTag* this, PlayState* play) { void func_809674C8(EnWeatherTag* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (Actor_XZDistanceBetweenActors(&player->actor, &this->actor) < WEATHER_TAG_RANGE100(&this->actor)) { + if (Actor_WorldDistXZToActor(&player->actor, &this->actor) < WEATHER_TAG_RANGE100(&this->actor)) { if (CURRENT_DAY == 2) { if ((gSaveContext.save.time >= CLOCK_TIME(7, 0)) && (gSaveContext.save.time < CLOCK_TIME(17, 30)) && (play->envCtx.unk_F2[2] == 0)) { @@ -471,7 +472,7 @@ void func_809674C8(EnWeatherTag* this, PlayState* play) { // WEATHERTAG_TYPE_LOCALDAY2RAIN 2 void func_80967608(EnWeatherTag* this, PlayState* play) { if ((WEATHER_TAG_RANGE100(&this->actor) + 10.0f) < - Actor_XZDistanceBetweenActors(&GET_PLAYER(play)->actor, &this->actor)) { + Actor_WorldDistXZToActor(&GET_PLAYER(play)->actor, &this->actor)) { gWeatherMode = 0; EnWeatherTag_SetupAction(this, func_809674C8); } @@ -483,8 +484,8 @@ void EnWeatherTag_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); if ((play->actorCtx.flags & ACTORCTX_FLAG_1) && (play->msgCtx.msgMode != 0) && (play->msgCtx.currentTextId == 0x5E6) && !FrameAdvance_IsEnabled(&play->state) && - (play->transitionTrigger == TRANS_TRIGGER_OFF) && (ActorCutscene_GetCurrentIndex() == -1) && - (play->csCtx.state == 0)) { + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE) && + (play->csCtx.state == CS_STATE_IDLE)) { gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)R_TIME_SPEED; if (R_TIME_SPEED != 0) { 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 bc505ee53..44a50e99d 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -299,10 +299,10 @@ void EnWf_Init(Actor* thisx, PlayState* play) { if (this->actor.child != NULL) { Player* player = GET_PLAYER(play); - this->actor.child->xzDistToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &player->actor); + this->actor.child->xzDistToPlayer = Actor_WorldDistXZToActor(&this->actor, &player->actor); this->unk_2A4 = (temp_s0 * 0.5f) + 45.0f; this->unk_29C = 0x32000 / this->unk_2A4; - this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, &player->actor); + this->actor.shape.rot.y = Actor_WorldYawTowardActor(&this->actor, &player->actor); this->actor.world.pos.x -= this->unk_2A4 * Math_SinS(this->actor.shape.rot.y); this->actor.world.pos.z -= this->unk_2A4 * Math_CosS(this->actor.shape.rot.y); } @@ -317,7 +317,7 @@ void EnWf_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.0075f); if (this->actor.params == 0) { - SkelAnime_InitFlex(play, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitingAnim, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitAnim, this->jointTable, this->morphTable, WOLFOS_NORMAL_LIMB_MAX); this->actor.hintId = TATL_HINT_ID_WOLFOS; CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable2, &sColChkInfoInit); @@ -325,7 +325,7 @@ void EnWf_Init(Actor* thisx, PlayState* play) { this->collider1.elements[1].info.toucher.damage = 8; this->actor.colChkInfo.health = 6; } else { - SkelAnime_InitFlex(play, &this->skelAnime, &gWolfosWhiteSkel, &gWolfosWaitingAnim, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gWolfosWhiteSkel, &gWolfosWaitAnim, this->jointTable, this->morphTable, WOLFOS_WHITE_LIMB_MAX); this->actor.hintId = TATL_HINT_ID_WHITE_WOLFOS; CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable1, &sColChkInfoInit); @@ -367,7 +367,7 @@ void func_809907D4(EnWf* this) { this->collider3.base.colType = COLTYPE_HIT3; this->unk_2A0 = 80; this->actor.flags &= ~ACTOR_FLAG_400; - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 80); } void func_80990854(EnWf* this, PlayState* play) { @@ -405,7 +405,7 @@ s32 func_80990948(PlayState* play, EnWf* this, s16 arg2) { if (((this->unk_295 == 0) || ((this->unk_295 == 1) && (this->actor.child != NULL) && (this->actor.child->update != NULL))) && (this->actor.xzDistToPlayer > 160.0f) && - (this->unk_2A8 < Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos))) { + (this->unk_2A8 < Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos))) { func_80993524(this); return true; } @@ -419,7 +419,7 @@ s32 func_80990948(PlayState* play, EnWf* this, s16 arg2) { if (func_800BE184(play, &this->actor, 100.0f, 24000, 0x2AA8, this->actor.shape.rot.y)) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - if ((this->actor.bgCheckFlags & 8) && (sp38 < 12000)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && (sp38 < 12000)) { func_809926D0(this); return true; } @@ -471,14 +471,15 @@ void func_80990C6C(EnWf* this, PlayState* play, s32 arg2) { static Color_RGBA8 D_809942EC = { 255, 255, 255, 255 }; s32 i; Vec3f sp88; - u32 temp_v0; + FloorType floorType; Color_RGBA8* phi_s1; s16 phi_s6; if (this->actor.floorPoly != NULL) { - temp_v0 = func_800C99D4(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); - if (temp_v0 != 5) { - if ((temp_v0 == 15) || (temp_v0 == 14)) { + floorType = SurfaceType_GetFloorType(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + + if (floorType != FLOOR_TYPE_5) { + if ((floorType == FLOOR_TYPE_15) || (floorType == FLOOR_TYPE_14)) { phi_s1 = &D_809942EC; phi_s6 = Rand_ZeroFloat(150.0f) + 350.0f; arg2 += 2; @@ -499,9 +500,9 @@ void func_80990C6C(EnWf* this, PlayState* play, s32 arg2) { } void func_80990E4C(EnWf* this, PlayState* play) { - if (Animation_OnFrame(&this->skelAnime, 1.0f) && (this->actor.bgCheckFlags & 1)) { + if (Animation_OnFrame(&this->skelAnime, 1.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { func_80990C6C(this, play, 2); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_WALK); } } @@ -517,7 +518,7 @@ s32 func_80990EAC(EnWf* this) { void func_80990ED4(EnWf* this) { this->actor.child = NULL; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_APPEAR); func_80991438(this); } @@ -549,7 +550,7 @@ void func_80990F50(EnWf* this, PlayState* play) { } void func_80990FC8(EnWf* this) { - Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, ANIMMODE_ONCE_INTERP, 0.0f); + Animation_Change(&this->skelAnime, &gWolfosRearUpFallOverAnim, 0.5f, 0.0f, 7.0f, ANIMMODE_ONCE_INTERP, 0.0f); this->unk_2A0 = 5; this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80991040; @@ -561,7 +562,7 @@ void func_80991040(EnWf* this, PlayState* play) { Math_StepToF(&this->actor.shape.shadowScale, 70.0f, 14.0f); this->unk_2A0--; if (this->unk_2A0 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_APPEAR); } } else if (SkelAnime_Update(&this->skelAnime)) { this->actor.scale.y = this->actor.scale.x; @@ -571,8 +572,8 @@ void func_80991040(EnWf* this, PlayState* play) { void func_809910F0(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, ANIMMODE_ONCE_INTERP, -5.0f); + this->actor.speed = 0.0f; + Animation_Change(&this->skelAnime, &gWolfosRearUpFallOverAnim, 0.5f, 0.0f, 7.0f, ANIMMODE_ONCE_INTERP, -5.0f); this->unk_2A0 = 5; this->actionFunc = func_80991174; } @@ -591,11 +592,11 @@ void func_80991174(EnWf* this, PlayState* play) { void func_80991200(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &gWolfosWaitingAnim, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosWaitAnim, -4.0f); this->unk_2A0 = (s32)Rand_ZeroFloat(10.0f) + 2; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_80991280; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } void func_80991280(EnWf* this, PlayState* play) { @@ -633,7 +634,7 @@ void func_80991280(EnWf* this, PlayState* play) { } if (this->unk_2A2 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_CRY); } } } @@ -642,9 +643,9 @@ void func_80991280(EnWf* this, PlayState* play) { void func_80991438(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunAnim, -4.0f); this->actor.world.rot.y = this->actor.shape.rot.y; - this->actor.speedXZ = 8.0f; + this->actor.speed = 8.0f; this->actionFunc = func_8099149C; } @@ -694,7 +695,7 @@ void func_8099149C(EnWf* this, PlayState* play) { } if (this->unk_2A2 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_CRY); } func_80990E4C(this, play); @@ -703,7 +704,7 @@ void func_8099149C(EnWf* this, PlayState* play) { } void func_80991738(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &gWolfosSidesteppingAnim, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosSidestepAnim, -4.0f); this->actionFunc = func_8099177C; } @@ -748,20 +749,20 @@ void func_8099177C(EnWf* this, PlayState* play) { } } if (this->unk_2A2 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_CRY); } } } void func_80991948(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunAnim, -4.0f); if (Rand_ZeroOne() > 0.5f) { this->unk_29A = 16000; } else { this->unk_29A = -16000; } - this->actor.speedXZ = 6.0f; + this->actor.speed = 6.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->unk_2A0 = (s32)Rand_ZeroFloat(30.0f) + 30; this->actionFunc = func_809919F4; @@ -776,7 +777,7 @@ void func_809919F4(EnWf* this, PlayState* play) { if (!func_8099408C(play, this) && !func_80990948(play, this, 0)) { this->actor.world.rot.y = this->actor.shape.rot.y; sp26 = BINANG_ROT180(player->actor.shape.rot.y + this->unk_29A); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { temp_v0 = (this->actor.wallYaw - this->actor.yawTowardsPlayer) - this->unk_29A; if (ABS_ALT(temp_v0) > 0x2EE0) { this->unk_29A = -this->unk_29A; @@ -787,7 +788,7 @@ void func_809919F4(EnWf* this, PlayState* play) { func_80990E4C(this, play); if (this->unk_2A2 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_CRY); } if ((Math_CosS(sp26 - this->actor.shape.rot.y) < -0.85f) && !Actor_OtherIsTargeted(play, &this->actor) && @@ -809,12 +810,12 @@ void func_809919F4(EnWf* this, PlayState* play) { void func_80991C04(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_PlayOnce(&this->skelAnime, &gWolfosSlashingAnim); + Animation_PlayOnce(&this->skelAnime, &gWolfosSlashAnim); this->collider1.base.atFlags &= ~AT_BOUNCED; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->unk_2A0 = 7; this->skelAnime.endFrame = 20.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_80991C80; } @@ -827,11 +828,11 @@ void func_80991C80(EnWf* this, PlayState* play) { sp2A = BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y); sp30 = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; 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)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_ATTACK); } this->collider1.base.atFlags |= AT_ON; } else { @@ -879,7 +880,7 @@ void func_80991FD8(EnWf* this) { if (this->skelAnime.curFrame > 15.0f) { phi_f0 = 15.0f; } - Animation_Change(&this->skelAnime, &gWolfosSlashingAnim, -0.5f, this->skelAnime.curFrame - 1.0f, phi_f0, + Animation_Change(&this->skelAnime, &gWolfosSlashAnim, -0.5f, this->skelAnime.curFrame - 1.0f, phi_f0, ANIMMODE_ONCE_INTERP, 0.0f); this->collider1.base.atFlags &= ~AT_ON; this->actionFunc = func_80992068; @@ -923,12 +924,12 @@ void func_80992068(EnWf* this, PlayState* play) { void func_8099223C(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosBackflippingAnim, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosBackflipAnim, -3.0f); this->unk_2A0 = 0; - this->actor.speedXZ = -6.0f; + this->actor.speed = -6.0f; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_JUMP); this->actionFunc = func_809922B4; } @@ -944,12 +945,12 @@ void func_809922B4(EnWf* this, PlayState* play) { } } if (this->unk_2A2 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_CRY); } } void func_809923B0(EnWf* this) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->actor.velocity.y > 0.0f) { this->actor.velocity.y = 0.0f; } @@ -974,24 +975,24 @@ void func_809923E4(EnWf* this, PlayState* play) { void func_8099245C(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosDamagedAnim, -4.0f); - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = -4.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.speed = -4.0f; } this->unk_298 = 0; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_DAMAGE); this->actionFunc = func_809924EC; } void func_809924EC(EnWf* this, PlayState* play) { s16 sp26; - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + this->actor.speed = 0.0f; } - if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ < 0.0f)) { - this->actor.speedXZ += 0.05f; + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.speed < 0.0f)) { + this->actor.speed += 0.05f; } Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3000); @@ -1002,7 +1003,8 @@ void func_809924EC(EnWf* this, PlayState* play) { return; } - if ((this->actor.bgCheckFlags & 8) && (ABS_ALT(sp26) < 0x2EE0) && (this->actor.xzDistToPlayer < 120.0f)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && (ABS_ALT(sp26) < 0x2EE0) && + (this->actor.xzDistToPlayer < 120.0f)) { func_809926D0(this); } else if (!func_8099408C(play, this)) { if ((this->actor.xzDistToPlayer <= 80.0f) && !Actor_OtherIsTargeted(play, &this->actor) && @@ -1021,24 +1023,25 @@ void func_809924EC(EnWf* this, PlayState* play) { void func_809926D0(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_Change(&this->skelAnime, &gWolfosBackflippingAnim, -1.0f, - Animation_GetLastFrame(&gWolfosBackflippingAnim.common), 0.0f, ANIMMODE_ONCE, -3.0f); + Animation_Change(&this->skelAnime, &gWolfosBackflipAnim, -1.0f, Animation_GetLastFrame(&gWolfosBackflipAnim.common), + 0.0f, ANIMMODE_ONCE, -3.0f); this->unk_2A0 = 0; - this->actor.speedXZ = 6.5f; + this->actor.speed = 6.5f; this->actor.velocity.y = 15.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); + Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_JUMP); this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_80992784; } void func_80992784(EnWf* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2500); - if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & (2 | 1))) { + if (SkelAnime_Update(&this->skelAnime) && + (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH))) { this->actor.shape.rot.x = 0; this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.world.pos.y = this->actor.floorHeight; if (!Actor_OtherIsTargeted(play, &this->actor)) { func_80991C04(this); @@ -1052,9 +1055,9 @@ void func_8099282C(EnWf* this) { this->collider2.base.acFlags |= AC_ON; this->collider1.base.atFlags &= ~AT_ON; this->unk_2A0 = 10; - this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &gWolfosBlockingAnim, -1.0f, Animation_GetLastFrame(&gWolfosBlockingAnim.common), - 0.0f, ANIMMODE_ONCE, -2.0f); + this->actor.speed = 0.0f; + Animation_Change(&this->skelAnime, &gWolfosBlockAnim, -1.0f, Animation_GetLastFrame(&gWolfosBlockAnim.common), 0.0f, + ANIMMODE_ONCE, -2.0f); this->actionFunc = func_809928CC; } @@ -1091,7 +1094,7 @@ void func_80992A74(EnWf* this, PlayState* play) { f32 temp_f0; this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunAnim, -4.0f); player = GET_PLAYER(play); temp_f0 = Math_SinS((player->actor.shape.rot.y + this->unk_29A) - this->actor.yawTowardsPlayer); if (temp_f0 > 0.0f) { @@ -1103,7 +1106,7 @@ void func_80992A74(EnWf* this, PlayState* play) { } else { this->unk_29A = -16000; } - this->actor.speedXZ = 6.0f; + this->actor.speed = 6.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->unk_2A0 = (s32)Rand_ZeroFloat(10.0f) + 5; this->actionFunc = func_80992B8C; @@ -1115,7 +1118,7 @@ void func_80992B8C(EnWf* this, PlayState* play) { Player* player = GET_PLAYER(play); Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->unk_29A, 2000); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { sp2C = BINANG_SUB((this->actor.wallYaw - this->actor.yawTowardsPlayer), this->unk_29A); if (ABS_ALT(sp2C) > 0x2EE0) { this->unk_29A = -this->unk_29A; @@ -1146,33 +1149,33 @@ void func_80992B8C(EnWf* this, PlayState* play) { func_80990E4C(this, play); if (this->unk_2A2 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_CRY); } } } void func_80992D6C(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosRearUpFallOverAnim, -4.0f); this->actor.world.rot.y = this->actor.yawTowardsPlayer; - if (this->actor.bgCheckFlags & 1) { - this->actor.speedXZ = -6.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->actor.speed = -6.0f; } this->actor.flags &= ~ACTOR_FLAG_1; this->unk_2A0 = 25; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_DEAD); this->actionFunc = func_80992E0C; } void func_80992E0C(EnWf* this, PlayState* play) { static Vec3f D_809942F0 = { 0.0f, 0.5f, 0.0f }; - if (this->actor.bgCheckFlags & 2) { - this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + this->actor.speed = 0.0f; } - if (this->actor.bgCheckFlags & 1) { - Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + Math_StepToF(&this->actor.speed, 0.0f, 0.5f); } if (SkelAnime_Update(&this->skelAnime)) { @@ -1205,7 +1208,7 @@ void func_80992E0C(EnWf* this, PlayState* play) { } void func_80992FD4(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &gWolfosWaitingAnim, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosWaitAnim, -4.0f); this->actionFunc = func_80993018; } @@ -1217,7 +1220,7 @@ void func_80993018(EnWf* this, PlayState* play) { } else if (this->actor.child->xzDistToPlayer < (80.0f + this->unk_2A4)) { func_80993350(this); } else { - s16 temp_v0 = Actor_YawBetweenActors(this->actor.child, &this->actor); + s16 temp_v0 = Actor_WorldYawTowardActor(this->actor.child, &this->actor); s16 temp_v1 = BINANG_SUB(temp_v0 - this->actor.child->yawTowardsPlayer, 0x8000); if (ABS_ALT(temp_v1) > 0x800) { @@ -1232,8 +1235,8 @@ void func_80993018(EnWf* this, PlayState* play) { } void func_80993148(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); - this->actor.speedXZ = 0.0f; + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunAnim, -4.0f); + this->actor.speed = 0.0f; this->actionFunc = func_80993194; } @@ -1251,7 +1254,7 @@ void func_80993194(EnWf* this, PlayState* play) { if (this->actor.child->xzDistToPlayer < (80.0f + this->unk_2A4)) { func_80993350(this); } else { - sp36 = Actor_YawBetweenActors(this->actor.child, &this->actor); + sp36 = Actor_WorldYawTowardActor(this->actor.child, &this->actor); sp34 = Math_SmoothStepToS(&sp36, BINANG_ROT180(this->actor.child->yawTowardsPlayer), 10, this->unk_29C, 16); this->actor.world.pos.x = (Math_SinS(sp36) * this->unk_2A4) + this->actor.child->world.pos.x; @@ -1272,13 +1275,13 @@ void func_80993194(EnWf* this, PlayState* play) { } if (this->unk_2A2 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_CRY); } } void func_80993350(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_APPEAR); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunAnim, -4.0f); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_APPEAR); this->actionFunc = func_809933A0; } @@ -1293,7 +1296,7 @@ void func_809933A0(EnWf* this, PlayState* play) { if (func_80990EAC(this)) { func_80990ED4(this); } else { - sp2E = Actor_YawBetweenActors(this->actor.child, &this->actor); + sp2E = Actor_WorldYawTowardActor(this->actor.child, &this->actor); Math_ScaledStepToS(&sp2E, this->actor.child->yawTowardsPlayer, this->unk_29C >> 2); sp2C = sp2E - this->actor.child->yawTowardsPlayer; this->actor.world.pos.x = (Math_SinS(sp2E) * this->unk_2A4) + this->actor.child->world.pos.x; @@ -1312,13 +1315,13 @@ void func_809933A0(EnWf* this, PlayState* play) { func_80990ED4(this); } if (this->unk_2A2 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_CRY); } } void func_80993524(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); - this->actor.speedXZ = 6.0f; + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunAnim, -4.0f); + this->actor.speed = 6.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_8099357C; } @@ -1330,14 +1333,14 @@ void func_8099357C(EnWf* this, PlayState* play) { func_80990E4C(this, play); if (this->unk_295 != 0) { if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - sp2E = Actor_YawBetweenActors(&this->actor, this->actor.child); + sp2E = Actor_WorldYawTowardActor(&this->actor, this->actor.child); if (func_80990EAC(this)) { this->actor.child = NULL; func_80991738(this); return; } - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { if (BINANG_SUB(sp2E, this->actor.wallYaw) > 0) { sp2E = this->actor.wallYaw - 0x4000; } else { @@ -1348,7 +1351,7 @@ void func_8099357C(EnWf* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, sp2E, 10, 0x800, 16); this->actor.world.rot.y = this->actor.shape.rot.y; - if (Actor_XZDistanceBetweenActors(&this->actor, this->actor.child) < (this->unk_2A4 + 10.0f)) { + if (Actor_WorldDistXZToActor(&this->actor, this->actor.child) < (this->unk_2A4 + 10.0f)) { func_80993148(this); } } else { @@ -1356,16 +1359,16 @@ void func_8099357C(EnWf* this, PlayState* play) { func_80991738(this); } } else { - Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 10, 0x800, - 16); + Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_WorldYawTowardPoint(&this->actor, &this->actor.home.pos), 10, + 0x800, 16); this->actor.world.rot.y = this->actor.shape.rot.y; - if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 40.0f) { + if (Actor_WorldDistXZToPoint(&this->actor, &this->actor.home.pos) < 40.0f) { func_809910F0(this); } } if (this->unk_2A2 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); + Actor_PlaySfx(&this->actor, NA_SE_EN_WOLFOS_CRY); } } @@ -1422,16 +1425,16 @@ void func_8099386C(EnWf* this, PlayState* play) { if (this->actor.colChkInfo.damageEffect == 1) { this->unk_2A0 = 40; - Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 120, COLORFILTER_BUFFLAG_OPA, 40); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); func_809923B0(this); } else if (this->actor.colChkInfo.damageEffect == 5) { this->unk_2A0 = 40; - Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 255, COLORFILTER_BUFFLAG_OPA, 40); this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; this->drawDmgEffScale = 0.75f; this->drawDmgEffAlpha = 2.0f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + Actor_PlaySfx(&this->actor, NA_SE_EN_COMMON_FREEZE); func_809923B0(this); } else if (this->actor.colChkInfo.damageEffect == 3) { func_809907D4(this); @@ -1454,7 +1457,7 @@ void func_8099386C(EnWf* this, PlayState* play) { CLEAR_TAG_LARGE_LIGHT_RAYS); } - Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); if (this->actor.colChkInfo.health == 0) { func_80992D6C(this); } else { @@ -1483,10 +1486,12 @@ void EnWf_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 60.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 32.0f, 30.0f, 60.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); func_80993738(this, play); - if (this->actor.bgCheckFlags & (2 | 1)) { + if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) { func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); } else { Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 600); @@ -1590,7 +1595,7 @@ s32 func_8099408C(PlayState* play, EnWf* this) { s16 temp_v1; if (temp_v0 != NULL) { - temp_v1 = (Actor_YawBetweenActors(&this->actor, temp_v0) - this->actor.shape.rot.y) - this->unk_29E; + temp_v1 = (Actor_WorldYawTowardActor(&this->actor, temp_v0) - this->actor.shape.rot.y) - this->unk_29E; if (ABS_ALT(temp_v1) < 0x3000) { if (Rand_ZeroOne() < 0.5f) { func_8099223C(this); diff --git a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c index ee2f3d158..209218163 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c @@ -8,9 +8,9 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h" -#define FLAGS \ - (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_1000 | ACTOR_FLAG_100000 | \ - ACTOR_FLAG_8000000 | ACTOR_FLAG_80000000) +#define FLAGS \ + (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_100000 | \ + ACTOR_FLAG_CANT_LOCK_ON | ACTOR_FLAG_80000000) #define THIS ((EnWiz*)thisx) @@ -37,8 +37,8 @@ void EnWiz_SetupDead(EnWiz* this); void EnWiz_Dead(EnWiz* this, PlayState* play); // This number is almost-entirely arbirary, with the only requirement being -// that cannot be a valid curPlatformIndex. Any negative number, or any number -// larger than 10, would work just as well. +// that it cannot be a valid curPlatformIndex. Any negative number, or any +// number larger than 10, would work just as well. #define INITIAL_PLATFORM_INDEX 777 typedef enum { @@ -456,9 +456,9 @@ void EnWiz_HandleIntroCutscene(EnWiz* this, PlayState* play) { this->targetPlatformLightAlpha = 255; Math_Vec3f_Copy(&this->platformLightPos, &this->actor.world.pos); if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_UNARI); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_UNARI); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_VOICE - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_VOICE - SFX_FLAG); } this->introCutsceneTimer = 40; @@ -504,7 +504,7 @@ void EnWiz_HandleIntroCutscene(EnWiz* this, PlayState* play) { break; case EN_WIZ_INTRO_CS_RUN_IN_CIRCLES: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); if (this->introCutsceneTimer == 0) { this->animLoopCounter = this->introCutsceneCameraAngle = 0; this->introCutsceneState = EN_WIZ_INTRO_CS_DISAPPEAR; @@ -601,6 +601,9 @@ void EnWiz_SelectPlatform(EnWiz* this, PlayState* play) { break; case EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE: + //! @bug: Setting the Wizrobe's position to the first platform *without* updating + //! this->curPlatformIndex can cause a bug later in EnWiz_Damaged. One way to fix + //! this is to set this->curPlatformIndex to 0 here. Math_Vec3f_Copy(&this->actor.world.pos, &this->platforms[0]->world.pos); for (i = 0, ghostAlpha = 128; i < this->platformCount; i++, ghostAlpha -= 10) { Math_Vec3f_Copy(&this->ghostPos[i], &this->actor.world.pos); @@ -663,18 +666,18 @@ void EnWiz_MoveGhosts(EnWiz* this) { } if (playSfx) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); } } void EnWiz_StartIntroCutscene(EnWiz* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetFlag(this->actor.cutscene, &this->actor); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCsAndSetFlag(this->actor.csId, &this->actor); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->actor.csId); this->actor.flags |= ACTOR_FLAG_100000; EnWiz_SetupAppear(this, play); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -702,9 +705,9 @@ void EnWiz_SetupAppear(EnWiz* this, PlayState* play) { Math_Vec3f_Copy(&this->platformLightPos, &this->actor.world.pos); if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_UNARI); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_UNARI); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_VOICE - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_VOICE - SFX_FLAG); } } @@ -744,7 +747,7 @@ void EnWiz_Appear(EnWiz* this, PlayState* play) { this->shouldStartTimer = true; } } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_VOICE - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_VOICE - SFX_FLAG); } if (this->timer == 0) { @@ -756,7 +759,7 @@ void EnWiz_Appear(EnWiz* this, PlayState* play) { return; } else { this->action = EN_WIZ_ACTION_RUN_IN_CIRCLES; - this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_CANT_LOCK_ON; this->ghostColliders.elements[0].info.bumper.dmgFlags = 0x1013A22; Math_Vec3f_Copy(&this->staffTargetFlameScale, &staffTargetFlameScale); this->targetPlatformLightAlpha = 0; @@ -803,7 +806,7 @@ void EnWiz_Dance(EnWiz* this, PlayState* play) { Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); Math_ApproachF(&this->scale, 0.015f, 0.05f, 0.001f); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); this->actor.world.rot.y += this->rotationalVelocity; if (this->fightState >= EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND) { EnWiz_MoveGhosts(this); @@ -828,13 +831,13 @@ void EnWiz_Dance(EnWiz* this, PlayState* play) { } void EnWiz_SetupSecondPhaseCutscene(EnWiz* this, PlayState* play) { - s16 secondPhaseCutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + s16 secondPhaseCsId = CutsceneManager_GetAdditionalCsId(this->actor.csId); - if (!ActorCutscene_GetCanPlayNext(secondPhaseCutscene)) { - ActorCutscene_SetIntentToPlay(secondPhaseCutscene); + if (!CutsceneManager_IsNext(secondPhaseCsId)) { + CutsceneManager_Queue(secondPhaseCsId); } else { - ActorCutscene_StartAndSetFlag(secondPhaseCutscene, &this->actor); - this->subCamId = ActorCutscene_GetCurrentSubCamId(secondPhaseCutscene); + CutsceneManager_StartWithPlayerCsAndSetFlag(secondPhaseCsId, &this->actor); + this->subCamId = CutsceneManager_GetCurrentSubCamId(secondPhaseCsId); this->actor.flags |= ACTOR_FLAG_100000; EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DANCE, false); this->action = EN_WIZ_ACTION_RUN_BETWEEN_PLATFORMS; @@ -856,7 +859,7 @@ void EnWiz_SecondPhaseCutscene(EnWiz* this, PlayState* play) { Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); subCam = Play_GetCamera(play, this->subCamId); Math_Vec3f_Copy(&subCam->at, &this->actor.focus.pos); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); if (this->platforms[this->nextPlatformIndex] != NULL) { f32 diffX = this->actor.world.pos.x - this->platforms[this->nextPlatformIndex]->world.pos.x; f32 diffZ = this->actor.world.pos.z - this->platforms[this->nextPlatformIndex]->world.pos.z; @@ -875,7 +878,7 @@ void EnWiz_SecondPhaseCutscene(EnWiz* this, PlayState* play) { s32 pad; s32 i; - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; if (sqrtf(SQ(diffX) + SQ(diffZ)) < 20.0f) { for (i = 0; i < this->platformCount; i++) { Math_Vec3f_Copy(&this->ghostPos[i], &gZeroVec3f); @@ -885,7 +888,7 @@ void EnWiz_SecondPhaseCutscene(EnWiz* this, PlayState* play) { this->platformCount = 0; this->fightState = EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_COPY_WIZROBE; this->timer = 0; - ActorCutscene_Stop(ActorCutscene_GetAdditionalCutscene(this->actor.cutscene)); + CutsceneManager_Stop(CutsceneManager_GetAdditionalCsId(this->actor.csId)); this->actor.flags &= ~ACTOR_FLAG_100000; EnWiz_SetupDisappear(this); return; @@ -976,8 +979,8 @@ void EnWiz_Attack(EnWiz* this, PlayState* play) { Math_Vec3f_Pitch(&pos, &player->actor.world.pos), Math_Vec3f_Yaw(&pos, &player->actor.world.pos), 0, type * 4); this->hasActiveProjectile = true; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_ATTACK); - Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_MAGIC_FIRE); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_ATTACK); + Actor_PlaySfx(&this->actor, NA_SE_PL_MAGIC_FIRE); } if ((curFrame >= 8.0f) && !this->shouldStartTimer) { @@ -1003,8 +1006,8 @@ void EnWiz_SetupDisappear(EnWiz* this) { } this->targetPlatformLightAlpha = 0; - this->actor.flags |= ACTOR_FLAG_8000000; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); Math_SmoothStepToS(&this->rotationalVelocity, 0x1388, 0x64, 0x3E8, 0x3E8); this->actor.world.rot.y += this->rotationalVelocity; this->actor.flags &= ~ACTOR_FLAG_1; @@ -1037,7 +1040,7 @@ void EnWiz_Disappear(EnWiz* this, PlayState* play) { if ((this->introCutsceneState == EN_WIZ_INTRO_CS_DISAPPEAR) && (this->introCutsceneTimer == 0)) { this->introCutsceneState = EN_WIZ_INTRO_CS_END; - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); this->actor.flags &= ~ACTOR_FLAG_100000; } @@ -1055,16 +1058,16 @@ void EnWiz_Disappear(EnWiz* this, PlayState* play) { void EnWiz_SetupDamaged(EnWiz* this, PlayState* play) { EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DAMAGE, false); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); this->timer = 20; if ((this->fightState != EN_WIZ_FIGHT_STATE_FIRST_PHASE) && (this->actor.colChkInfo.health <= 0)) { Enemy_StartFinishingBlow(play, &this->actor); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DEAD); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_DEAD); this->timer = 0; this->actor.flags &= ~ACTOR_FLAG_1; } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DAMAGE); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_DAMAGE); } this->scale = 0.015f; @@ -1120,6 +1123,17 @@ void EnWiz_Damaged(EnWiz* this, PlayState* play) { this->ghostRot[i].y += this->rotationalVelocity; } + //! @bug: When the Wizrobe is defeated, it is launched into the air by the code above, and the + //! last check in this conditional is intended to check that the Wizrobe is standing on its + //! platform before transitioning to a different state. However, when the fight is in the + //! EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE state, the Wizrobe will always appear on top of + //! the first platform, while its curPlatformIndex is allowed to randomly choose any other + //! platform in the room. If the Wizrobe is defeated in this state (which is possible with a + //! well-timed attack before the cutscene starts), and if the first platform is elevated above + //! other platforms in the room (as it is in the Secret Shrine), then it is possible for + //! this->platforms[this->curPlatformIndex]->world.pos.y to be under the floor compared to the + //! Wizrobe's current position, causing it to get stuck here and never actually die. This can + //! be fixed by addressing the bug in EnWiz_SelectPlatform. if ((this->timer == 1) || ((this->actor.velocity.y < 0.0f) && (this->actor.world.pos.y < (this->platforms[this->curPlatformIndex]->world.pos.y + 11.0f)))) { @@ -1146,12 +1160,14 @@ void EnWiz_Damaged(EnWiz* this, PlayState* play) { EnWiz_SetupDisappear(this); } - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; } Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 20, 50, 10); Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 40.0f, 40.0f, 0x1F); + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 40.0f, 40.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); } void EnWiz_SetupDead(EnWiz* this) { @@ -1261,7 +1277,8 @@ void EnWiz_UpdateDamage(EnWiz* this, PlayState* play) { // If the player throws a Deku Nut or hits a ghost's collider (something that is impossible // in the final game, since EnWiz_Init effectively disables them), then the below code will // "destroy" the ghost by turning into a cloud of smoke. - if ((iREG(50) != 0) || (this->ghostColliders.elements[i + 1].info.bumperFlags & BUMP_HIT)) { + if ((R_TRANS_FADE_FLASH_ALPHA_STEP != 0) || + (this->ghostColliders.elements[i + 1].info.bumperFlags & BUMP_HIT)) { //! @bug: If a single ghost is destroyed, then changing the fight state here will cause //! strange behavior; the ghosts will stand still and pretend to attack the player like //! the real Wizrobe. Since Deku Nuts destroy all ghosts at once, and since the ghost diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c index f2d88759e..4a3689005 100644 --- a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c +++ b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c @@ -7,7 +7,7 @@ #include "z_en_wiz_brock.h" #include "objects/object_wiz/object_wiz.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnWizBrock*)thisx) 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 4ed3333fd..bad93b685 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 @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Wiz/z_en_wiz.h" #include "objects/object_wiz/object_wiz.h" -#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_8000000) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnWizFire*)thisx) @@ -206,15 +206,15 @@ void EnWiz_MoveMagicProjectile(EnWizFire* this, PlayState* play) { Math_ApproachF(&this->scale, this->targetScale, 0.2f, 0.01f); if (this->wallCheckTimer == 0) { - if ((this->actor.bgCheckFlags & 8) && (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && (this->timer != 0) && - (this->actor.bgCheckFlags & 8)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && + (this->timer != 0) && (this->actor.bgCheckFlags & BGCHECKFLAG_WALL)) { sPoolHitByIceArrow = false; this->timer = 0; this->targetScale = 0.0f; } } - if ((this->actor.bgCheckFlags & 1) && (this->poolTimer == 0)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->poolTimer == 0)) { s32 i; s16 arcingProjectileRotY; s32 pad; @@ -260,13 +260,13 @@ void EnWiz_MoveMagicProjectile(EnWizFire* this, PlayState* play) { arcingProjectileRotY += BINANG_ADD((s32)randPlusMinusPoint5Scaled(0x1000), 0x3333); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfx(&this->actor, NA_SE_IT_BOMB_EXPLOSION); this->poolTimer = Rand_S16Offset(70, 30); if (this->poolTimer != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_EXP - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_EXP - SFX_FLAG); } } else if (this->poolTimer != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); @@ -291,7 +291,7 @@ void EnWiz_MoveMagicProjectile(EnWizFire* this, PlayState* play) { } if (Player_HasMirrorShieldEquipped(play) && (this->collider.base.atFlags & AT_BOUNCED)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SHIELD_REFLECT_MG); + Actor_PlaySfx(&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; @@ -351,7 +351,7 @@ void EnWiz_SmallFlame(EnWizFire* this, PlayState* play) { } if (this->timer != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); } } @@ -392,7 +392,7 @@ void EnWiz_Pool(EnWizFire* this, PlayState* play) { this->collider.dim.height = 30; this->collider.dim.yShift = 15; EnWizFire_InitializeEffect(this, &pos, &accel); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); return; } @@ -426,7 +426,7 @@ void EnWiz_Pool(EnWizFire* this, PlayState* play) { if (this->isIceType == true) { Math_ApproachZeroF(&this->poolScale, 0.046f, 0.001f); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + Actor_PlaySfx(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); if (!this->shouldPoolFadeOut) { if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->poolScale < 0.05f)) { @@ -573,7 +573,9 @@ void EnWizFire_Update(Actor* thisx, PlayState* play2) { DECR(this->steamSpawnTimer); DECR(this->poolTimer); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 5.0f, 10, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 5.0f, 10, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); if ((this->hitByIceArrow || sPoolHitByIceArrow) && (this->steamSpawnTimer == 0)) { Vec3f accel; @@ -625,7 +627,7 @@ void EnWizFire_Update(Actor* thisx, PlayState* play2) { if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; if (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_LAUGH2); + Actor_PlaySfx(&this->actor, NA_SE_EN_WIZ_LAUGH2); if (player->invincibilityTimer > 0) { player->invincibilityTimer += 40; if (this->isIceType) { diff --git a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c index ba63b3021..3c0357999 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c @@ -4,6 +4,7 @@ * Description: Trees, shrubs */ +#include "prevent_bss_reordering.h" #include "z_en_wood02.h" #include "objects/object_wood02/object_wood02.h" @@ -35,8 +36,8 @@ typedef enum { /* 5 */ WOOD_DRAW_LEAF_YELLOW } WoodDrawType; -static f32 sSpawnCos; -static f32 sSpawnSin; +f32 sWood02SpawnCos; +f32 sWood02SpawnSin; ActorInit En_Wood02_InitVars = { ACTOR_EN_WOOD02, @@ -70,9 +71,9 @@ static ColliderCylinderInit sCylinderInit = { { 18, 60, 0, { 0, 0, 0 } }, }; -static f32 sSpawnDistance[] = { 707.0f, 525.0f, 510.0f, 500.0f, 566.0f, 141.0f }; +f32 sWood02SpawnDistance[] = { 707.0f, 525.0f, 510.0f, 500.0f, 566.0f, 141.0f }; -static s16 sSpawnAngle[] = { 0x1FFF, 0x4C9E, 0x77F5, 0xA5C9, -0x293D, 0xA000 }; +s16 sWood02SpawnAngle[] = { 0x1FFF, 0x4C9E, 0x77F5, 0xA5C9, -0x293D, 0xA000 }; static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 5600, ICHAIN_STOP), @@ -136,12 +137,12 @@ void EnWood02_SpawnOffspring(EnWood02* this, PlayState* play) { extraRot = 0x4000; } - sSpawnCos = Math_CosS(sSpawnAngle[i] + this->actor.world.rot.y + extraRot); - sSpawnSin = Math_SinS(sSpawnAngle[i] + this->actor.world.rot.y + extraRot); + sWood02SpawnCos = Math_CosS(sWood02SpawnAngle[i] + this->actor.world.rot.y + extraRot); + sWood02SpawnSin = Math_SinS(sWood02SpawnAngle[i] + this->actor.world.rot.y + extraRot); - childPos.x = (sSpawnDistance[i] * sSpawnSin) + this->actor.home.pos.x; + childPos.x = (sWood02SpawnDistance[i] * sWood02SpawnSin) + this->actor.home.pos.x; childPos.y = this->actor.home.pos.y; - childPos.z = (sSpawnDistance[i] * sSpawnCos) + this->actor.home.pos.z; + childPos.z = (sWood02SpawnDistance[i] * sWood02SpawnCos) + this->actor.home.pos.z; if (EnWood02_SpawnZoneCheck(this, play, &childPos)) { if (this->unk_14A[i] & 0x80) { @@ -152,8 +153,8 @@ void EnWood02_SpawnOffspring(EnWood02* this, PlayState* play) { childParams = ((this->unk_144 << 8) & 0xFF00) | (this->actor.params + 1); child = (EnWood02*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_WOOD02, childPos.x, - childPos.y, childPos.z, this->actor.world.rot.x, sSpawnAngle[i], - unk, childParams); + childPos.y, childPos.z, this->actor.world.rot.x, + sWood02SpawnAngle[i], unk, childParams); if (child != NULL) { child->unk_14A[0] = i; this->unk_14A[i] |= 1; @@ -201,7 +202,7 @@ void EnWood02_Init(Actor* thisx, PlayState* play) { Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_ANI, this->actor.world.pos.x, this->actor.world.pos.y + 120.0f, this->actor.world.pos.z - 15.0f, 0, 0, 0, 1); if (this->actor.child != NULL) { - this->actor.child->cutscene = this->actor.cutscene; + this->actor.child->csId = this->actor.csId; } this->unk_151 = 1; } else { @@ -296,10 +297,10 @@ void EnWood02_Init(Actor* thisx, PlayState* play) { if (spawnType == WOOD_SPAWN_SPAWNER) { EnWood02_SpawnOffspring(this, play); - sSpawnCos = Math_CosS(sSpawnAngle[5] + this->actor.world.rot.y + extraRot); - sSpawnSin = Math_SinS(sSpawnAngle[5] + this->actor.world.rot.y + extraRot); - this->actor.world.pos.x += sSpawnSin * sSpawnDistance[5]; - this->actor.world.pos.z += sSpawnCos * sSpawnDistance[5]; + sWood02SpawnCos = Math_CosS(sWood02SpawnAngle[5] + this->actor.world.rot.y + extraRot); + sWood02SpawnSin = Math_SinS(sWood02SpawnAngle[5] + this->actor.world.rot.y + extraRot); + this->actor.world.pos.x += sWood02SpawnSin * sWood02SpawnDistance[5]; + this->actor.world.pos.z += sWood02SpawnCos * sWood02SpawnDistance[5]; } else { this->actor.flags |= ACTOR_FLAG_10; this->unk_151 = 2; @@ -385,7 +386,7 @@ void EnWood02_Update(Actor* thisx, PlayState* play2) { if ((thisx->params < WOOD_BUSH_GREEN_SMALL) || (thisx->params == WOOD_TREE_SPECIAL)) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - Actor_PlaySfxAtPos(thisx, NA_SE_IT_REFLECTION_WOOD); + Actor_PlaySfx(thisx, NA_SE_IT_REFLECTION_WOOD); } if (thisx->home.rot.y != 0) { @@ -404,7 +405,7 @@ void EnWood02_Update(Actor* thisx, PlayState* play2) { (thisx->params == WOOD_TREE_OVAL_YELLOW_SPAWNED)) { leavesParams = WOOD_LEAF_YELLOW; } - Actor_PlaySfxAtPos(thisx, NA_SE_EV_TREE_SWING); + Actor_PlaySfx(thisx, NA_SE_EV_TREE_SWING); for (i = 3; i >= 0; i--) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WOOD02, dropsSpawnPt.x, dropsSpawnPt.y, dropsSpawnPt.z, @@ -436,10 +437,10 @@ void EnWood02_Update(Actor* thisx, PlayState* play2) { if ((this->unk_146 >= -1) && (((player->rideActor == NULL) && (sqrtf(thisx->xyzDistToPlayerSq) < 20.0f) && (player->linearVelocity != 0.0f)) || ((player->rideActor != NULL) && (sqrtf(thisx->xyzDistToPlayerSq) < 60.0f) && - (player->rideActor->speedXZ != 0.0f)))) { + (player->rideActor->speed != 0.0f)))) { func_808C4458(this, play, &thisx->world.pos, 1); this->unk_146 = -0x15; - Actor_PlaySfxAtPos(thisx, NA_SE_EV_TREE_SWING); + Actor_PlaySfx(thisx, NA_SE_EV_TREE_SWING); } } else { // Leaves this->unk_146++; diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index 2310a2eef..c5224f8e8 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -68,7 +68,10 @@ static ColliderCylinderInit sCylinderInit = { // assumption: draw uses two different skeleton functions, might be incompatible static AnimationHeader* gYbUnusedAnimations[] = { &object_yb_Anim_000200 }; -static LinkAnimationHeader* gLinkAnimations[] = { &gPlayerAnim_link_normal_wait_free, &gPlayerAnim_alink_dance_loop }; +static PlayerAnimationHeader* gPlayerAnimations[] = { + &gPlayerAnim_link_normal_wait_free, + &gPlayerAnim_alink_dance_loop, +}; static Vec3f D_80BFB2E8 = { 0.0f, 0.5f, 0.0f }; @@ -78,7 +81,7 @@ static Vec3f D_80BFB300 = { 500.0f, -500.0f, 0.0f }; void EnYb_Init(Actor* thisx, PlayState* play) { EnYb* this = THIS; - s16 tempCutscene; + s16 csId; s32 i; Actor_SetScale(&this->actor, 0.01f); @@ -99,17 +102,17 @@ void EnYb_Init(Actor* thisx, PlayState* play) { EnYb_ChangeAnim(play, this, 2, ANIMMODE_LOOP, 0.0f); - tempCutscene = this->actor.cutscene; - for (i = 0; i < ARRAY_COUNT(this->cutscenes); i++) { - this->cutscenes[i] = tempCutscene; - if (tempCutscene != -1) { - this->actor.cutscene = tempCutscene; - tempCutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + csId = this->actor.csId; + for (i = 0; i < ARRAY_COUNT(this->csIdList); i++) { + this->csIdList[i] = csId; + if (csId != CS_ID_NONE) { + this->actor.csId = csId; + csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); } } - this->cutsceneIndex = -1; - this->actor.cutscene = this->cutscenes[0]; + this->csIdIndex = -1; + this->actor.csId = this->csIdList[0]; // between midnight and morning start spawned if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { @@ -168,17 +171,17 @@ void EnYb_ActorShadowFunc(Actor* thisx, Lights* mapper, PlayState* play) { void EnYb_ChangeAnim(PlayState* play, EnYb* this, s16 animIndex, u8 animMode, f32 morphFrames) { if (animIndex >= 0 && animIndex < 3) { - if (animIndex != this->animIndex || animMode != ANIMMODE_LOOP) { + if ((animIndex != this->animIndex) || (animMode != ANIMMODE_LOOP)) { if (animIndex > 0) { if (animMode == ANIMMODE_LOOP) { - LinkAnimation_Change(play, &this->skelAnime, gLinkAnimations[animIndex - 1], 1.0f, 0.0f, - Animation_GetLastFrame(gLinkAnimations[animIndex - 1]), ANIMMODE_LOOP, - morphFrames); + PlayerAnimation_Change(play, &this->skelAnime, gPlayerAnimations[animIndex - 1], 1.0f, 0.0f, + Animation_GetLastFrame(gPlayerAnimations[animIndex - 1]), ANIMMODE_LOOP, + morphFrames); } else { // unused case, (only called once with animMode = ANIMMODE_LOOP) - LinkAnimation_Change(play, &this->skelAnime, gLinkAnimations[animIndex - 1], 1.0f, 0.0f, - Animation_GetLastFrame(gLinkAnimations[animIndex - 1]), ANIMMODE_LOOP, - morphFrames); + PlayerAnimation_Change(play, &this->skelAnime, gPlayerAnimations[animIndex - 1], 1.0f, 0.0f, + Animation_GetLastFrame(gPlayerAnimations[animIndex - 1]), ANIMMODE_LOOP, + morphFrames); } } else { // unused case, (only called once with animIndex = 2) @@ -207,22 +210,22 @@ void EnYb_UpdateAnimation(EnYb* this, PlayState* play) { if (this->animIndex <= 0) { SkelAnime_Update(&this->skelAnime); } else { - LinkAnimation_Update(play, &this->skelAnime); + PlayerAnimation_Update(play, &this->skelAnime); } } void EnYb_FinishTeachingCutscene(EnYb* this) { - if (this->cutsceneIndex != -1) { - if (ActorCutscene_GetCurrentIndex() == this->cutscenes[this->cutsceneIndex]) { - ActorCutscene_Stop(this->cutscenes[this->cutsceneIndex]); + if (this->csIdIndex != -1) { + if (CutsceneManager_GetCurrentCsId() == this->csIdList[this->csIdIndex]) { + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); } - this->cutsceneIndex = -1; + this->csIdIndex = -1; } } -void EnYb_ChangeCutscene(EnYb* this, s16 cutsceneId) { +void EnYb_ChangeCutscene(EnYb* this, s16 csIdIndex) { EnYb_FinishTeachingCutscene(this); - this->cutsceneIndex = cutsceneId; + this->csIdIndex = csIdIndex; } /** @@ -276,7 +279,7 @@ void EnYb_ReceiveMask(EnYb* this, PlayState* play) { this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_MINUS1); } else { - Actor_PickUp(&this->actor, play, GI_MASK_KAMARO, 10000.0f, 100.0f); + Actor_OfferGetItem(&this->actor, play, GI_MASK_KAMARO, 10000.0f, 100.0f); } EnYb_EnableProximityMusic(this); } @@ -289,27 +292,27 @@ void EnYb_Talk(EnYb* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x147D: // I am counting on you - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = EnYb_Disappear; SET_WEEKEVENTREG(WEEKEVENTREG_82_04); break; case 0x147C: // Spread my dance across the world if (Player_GetMask(play) == PLAYER_MASK_KAMARO) { - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = EnYb_Idle; } else if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { - func_80151938(play, 0x147D); // I am counting on you + Message_ContinueTextbox(play, 0x147D); // I am counting on you func_80BFA2FC(play); } else { - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = EnYb_ReceiveMask; EnYb_ReceiveMask(this, play); } break; default: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = EnYb_Idle; break; } @@ -377,7 +380,7 @@ void EnYb_Idle(EnYb* this, PlayState* play) { } else if ((player->stateFlags2 & PLAYER_STATE2_8000000) && this->actor.xzDistToPlayer < 180.0f && fabsf(this->actor.playerHeightRel) < 50.0f) { this->playerOcarinaOut |= 1; - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); } EnYb_EnableProximityMusic(this); @@ -406,21 +409,21 @@ void EnYb_Update(Actor* thisx, PlayState* play) { } if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_1)) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 25.0f, 40.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 25.0f, 40.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } this->actionFunc(this, play); - if (this->cutsceneIndex != -1 && ActorCutscene_GetCurrentIndex() != this->cutscenes[this->cutsceneIndex]) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIndex]); - } else if (ActorCutscene_GetCanPlayNext(this->cutscenes[this->cutsceneIndex])) { - if (this->cutsceneIndex == 0) { - ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[this->cutsceneIndex], &this->actor); + if ((this->csIdIndex != -1) && (CutsceneManager_GetCurrentCsId() != this->csIdList[this->csIdIndex])) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); + } else if (CutsceneManager_IsNext(this->csIdList[this->csIdIndex])) { + if (this->csIdIndex == 0) { + CutsceneManager_StartWithPlayerCs(this->csIdList[this->csIdIndex], &this->actor); } } else { - ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIndex]); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); } } } diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.h b/src/overlays/actors/ovl_En_Yb/z_en_yb.h index c7b977653..4728ef44e 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.h +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.h @@ -20,8 +20,8 @@ typedef struct EnYb { /* 0x410 */ u16 playerOcarinaOut; /* 0x412 */ s16 animIndex; /* 0x414 */ s16 alpha; - /* 0x416 */ s16 cutscenes[2]; - /* 0x41A */ s16 cutsceneIndex; + /* 0x416 */ s16 csIdList[2]; + /* 0x41A */ s16 csIdIndex; /* 0x41C */ s16 teachingCutsceneTimer; /* 0x420 */ EnYbActionFunc actionFunc; } EnYb; // size = 0x424 diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index a16b828f9..7a160e368 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -122,32 +122,33 @@ s32 EnZo_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { s32 EnZo_PlayWalkingSound(EnZo* this, PlayState* play) { u8 leftWasGrounded; u8 rightWasGrounded; - s32 waterSfxId; + SurfaceSfxOffset surfaceSfxOffset; u16 sfxId; u8 isFootGrounded; leftWasGrounded = this->isLeftFootGrounded; rightWasGrounded = this->isRightFootGrounded; - if (this->actor.bgCheckFlags & 0x20) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { if (this->actor.depthInWater < 20.0f) { - waterSfxId = NA_SE_PL_WALK_WATER0 - SFX_FLAG; + surfaceSfxOffset = SURFACE_SFX_OFFSET_WATER_SHALLOW; } else { - waterSfxId = NA_SE_PL_WALK_WATER1 - SFX_FLAG; + surfaceSfxOffset = SURFACE_SFX_OFFSET_WATER_DEEP; } - sfxId = waterSfxId + SFX_FLAG; + sfxId = NA_SE_PL_WALK_GROUND + surfaceSfxOffset; } else { - sfxId = SurfaceType_GetSfx(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) + SFX_FLAG; + sfxId = NA_SE_PL_WALK_GROUND + + SurfaceType_GetSfxOffset(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); } this->isLeftFootGrounded = isFootGrounded = SubS_IsFloorAbove(play, &this->leftFootPos, -6.0f); if ((this->isLeftFootGrounded) && (!leftWasGrounded) && (isFootGrounded)) { - Actor_PlaySfxAtPos(&this->actor, sfxId); + Actor_PlaySfx(&this->actor, sfxId); } this->isRightFootGrounded = isFootGrounded = SubS_IsFloorAbove(play, &this->rightFootPos, -6.0f); if ((this->isRightFootGrounded) && (!rightWasGrounded) && (isFootGrounded)) { - Actor_PlaySfxAtPos(&this->actor, sfxId); + Actor_PlaySfx(&this->actor, sfxId); } return 0; @@ -220,8 +221,8 @@ void EnZo_FollowPath(EnZo* this, PlayState* play) { s16 speed; Vec3f pos; - Math_SmoothStepToF(&this->actor.speedXZ, 1.0f, 0.4f, 1000.0f, 0.0f); - speed = this->actor.speedXZ * 400.0f; + Math_SmoothStepToF(&this->actor.speed, 1.0f, 0.4f, 1000.0f, 0.0f); + speed = this->actor.speed * 400.0f; if (SubS_CopyPointFromPath(this->path, this->waypoint, &pos) && SubS_MoveActorToPoint(&this->actor, &pos, speed)) { this->waypoint++; if (this->waypoint >= this->path->count) { @@ -233,7 +234,7 @@ void EnZo_FollowPath(EnZo* this, PlayState* play) { EnZo_ChangeAnim(&this->skelAnime, 1); this->actionFunc = EnZo_TreadWater; this->actor.gravity = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } } @@ -280,7 +281,7 @@ void EnZo_Update(Actor* thisx, PlayState* play) { EnZo* this = THIS; this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); EnZo_LookAtPlayer(this, play); EnZo_PlayWalkingSound(this, play); EnZo_UpdateCollider(this, play); diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.c b/src/overlays/actors/ovl_En_Zob/z_en_zob.c index 58dd246d8..998c2b186 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -80,7 +80,7 @@ Vec3f D_80BA1120 = { 300.0f, 900.0f, 0.0f }; void EnZob_Init(Actor* thisx, PlayState* play) { EnZob* this = THIS; s32 i; - s16 cs; + s16 csId; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -90,8 +90,8 @@ void EnZob_Init(Actor* thisx, PlayState* play) { Animation_PlayLoop(&this->skelAnime, &object_zob_Anim_006998); Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->unk_2F4 = 0; - this->unk_30E = -1; - this->unk_310 = 0; + this->csIdIndex = -1; + this->cueId = 0; this->unk_302 = 9; this->unk_304 = 0; this->actor.terminalVelocity = -4.0f; @@ -100,16 +100,16 @@ void EnZob_Init(Actor* thisx, PlayState* play) { this->actionFunc = func_80BA0728; this->actor.textId = 0; - cs = this->actor.cutscene; - for (i = 0; i < ARRAY_COUNT(this->unk_306); i++) { - this->unk_306[i] = cs; - if (cs != -1) { - this->actor.cutscene = cs; - cs = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + csId = this->actor.csId; + for (i = 0; i < ARRAY_COUNT(this->csIdList); i++) { + this->csIdList[i] = csId; + if (csId != CS_ID_NONE) { + this->actor.csId = csId; + csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); } } - this->actor.cutscene = this->unk_306[0]; + this->actor.csId = this->csIdList[0]; this->actor.flags |= ACTOR_FLAG_2000000; switch (ENZOB_GET_F(&this->actor)) { @@ -120,7 +120,7 @@ void EnZob_Init(Actor* thisx, PlayState* play) { this->actionFunc = func_80BA0AD8; } - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { Actor_Kill(&this->actor); return; } @@ -135,7 +135,7 @@ void EnZob_Init(Actor* thisx, PlayState* play) { break; default: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { Actor_Kill(&this->actor); } this->actor.flags |= ACTOR_FLAG_10; @@ -253,21 +253,21 @@ void func_80B9FA3C(EnZob* this, PlayState* play) { } void func_80B9FC0C(EnZob* this) { - if (this->unk_30E != -1) { - if (ActorCutscene_GetCurrentIndex() == this->unk_306[this->unk_30E]) { - ActorCutscene_Stop(this->unk_306[this->unk_30E]); + if (this->csIdIndex != -1) { + if (CutsceneManager_GetCurrentCsId() == this->csIdList[this->csIdIndex]) { + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); } - this->unk_30E = -1; + this->csIdIndex = -1; } } -void func_80B9FC70(EnZob* this, s16 arg1) { +void func_80B9FC70(EnZob* this, s16 csIdIndex) { func_80B9FC0C(this); - this->unk_30E = arg1; + this->csIdIndex = csIdIndex; } void func_80B9FCA0(EnZob* this, PlayState* play) { - func_801477B4(play); + Message_CloseTextbox(play); play->msgCtx.ocarinaMode = 4; func_80B9FC0C(this); this->unk_2F4 &= ~1; @@ -278,19 +278,19 @@ void func_80B9FCA0(EnZob* this, PlayState* play) { } void func_80B9FD24(EnZob* this, PlayState* play) { - s32 actionIndex; - s16 action; + s32 cueChannel; + s16 cueId; func_80B9F86C(this); - if (Cutscene_CheckActorAction(play, 500)) { - this->unk_30E = -1; - actionIndex = Cutscene_GetActorActionIndex(play, 500); - action = play->csCtx.actorActions[actionIndex]->action; + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_500)) { + this->csIdIndex = -1; + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_500); + cueId = play->csCtx.actorCues[cueChannel]->id; - if (action != this->unk_310) { - this->unk_310 = action; - switch (action) { + if (this->cueId != cueId) { + this->cueId = cueId; + switch (cueId) { case 1: func_80B9F7E4(this, 8, ANIMMODE_LOOP); break; @@ -372,14 +372,14 @@ void func_80BA00BC(EnZob* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 1: func_8019F208(); - func_80151938(play, 0x1209); + Message_ContinueTextbox(play, 0x1209); this->unk_304 = 1; func_80B9F7E4(this, 2, ANIMMODE_ONCE); break; case 0: func_8019F230(); - func_80151938(play, 0x1213); + Message_ContinueTextbox(play, 0x1213); break; } } @@ -391,7 +391,7 @@ void func_80BA00BC(EnZob* this, PlayState* play) { case 0x1208: case 0x120E: case 0x1216: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x120C: @@ -405,7 +405,7 @@ void func_80BA00BC(EnZob* this, PlayState* play) { case 0x1211: case 0x1213: case 0x1217: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); this->unk_304 = 3; func_80B9F7E4(this, 4, ANIMMODE_ONCE); break; @@ -457,13 +457,13 @@ void func_80BA0374(EnZob* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - func_80151938(play, 0x1207); + Message_ContinueTextbox(play, 0x1207); func_80B9F7E4(this, 2, ANIMMODE_ONCE); break; case 1: func_8019F230(); - func_80151938(play, 0x1206); + Message_ContinueTextbox(play, 0x1206); break; } } @@ -474,11 +474,11 @@ void func_80BA0374(EnZob* this, PlayState* play) { switch (play->msgCtx.currentTextId) { case 0x11F8: SET_WEEKEVENTREG(WEEKEVENTREG_30_02); - func_80151938(play, 0x11F9); + Message_ContinueTextbox(play, 0x11F9); break; case 0x11F9: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BA0728; this->unk_304 = 0; func_80B9F7E4(this, 6, ANIMMODE_ONCE); @@ -490,19 +490,19 @@ void func_80BA0374(EnZob* this, PlayState* play) { case 0x11FF: case 0x1201: case 0x1203: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x11FD: this->unk_304 = 3; func_80B9F7E4(this, 4, ANIMMODE_ONCE); - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x11FE: this->unk_304 = 1; func_80B9F7E4(this, 3, ANIMMODE_LOOP); - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x11FA: @@ -513,7 +513,7 @@ void func_80BA0374(EnZob* this, PlayState* play) { case 0x120F: case 0x1210: case 0x1215: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BA0728; this->unk_304 = 0; func_80B9F7E4(this, 6, ANIMMODE_ONCE); @@ -522,7 +522,7 @@ void func_80BA0374(EnZob* this, PlayState* play) { break; case 0x1207: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BA0318; player->unk_A90 = &this->actor; player->stateFlags3 |= PLAYER_STATE3_20; @@ -549,7 +549,7 @@ void func_80BA0610(EnZob* this, PlayState* play) { void func_80BA06BC(EnZob* this, PlayState* play) { func_80B9FD24(this, play); - if (!Cutscene_CheckActorAction(play, 500)) { + if (!Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_500)) { this->actionFunc = func_80BA0610; this->actor.flags |= ACTOR_FLAG_10000; func_80BA0610(this, play); @@ -572,12 +572,12 @@ void func_80BA0728(EnZob* this, PlayState* play) { this->actionFunc = func_80BA00BC; this->unk_304 = 1; func_80B9F7E4(this, 2, ANIMMODE_ONCE); - this->unk_30E = 0; + this->csIdIndex = 0; this->unk_2F4 |= 1; } else if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80BA0374; func_80B9FA3C(this, play); - } else if (Cutscene_CheckActorAction(play, 500)) { + } else if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_500)) { this->actionFunc = func_80BA06BC; } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.xzDistToPlayer > 60.0f) && Player_IsFacingActor(&this->actor, 0x3000, play) && Actor_IsFacingPlayer(&this->actor, 0x3000)) { @@ -588,7 +588,7 @@ void func_80BA0728(EnZob* this, PlayState* play) { sp28.x = this->actor.projectedPos.x; sp28.y = this->actor.projectedPos.y; sp28.z = this->actor.projectedPos.z; - func_801A1FB4(3, &sp28, 0x6C, 1000.0f); + func_801A1FB4(SEQ_PLAYER_BGM_SUB, &sp28, NA_BGM_BASS_PLAY, 1000.0f); } void func_80BA08E8(EnZob* this, PlayState* play) { @@ -630,7 +630,7 @@ void func_80BA0A04(EnZob* this, PlayState* play) { switch (Message_GetState(&play->msgCtx)) { case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BA0AD8; this->unk_304 = 0; func_80B9F7E4(this, 6, ANIMMODE_ONCE); @@ -684,8 +684,8 @@ void func_80BA0C14(EnZob* this, PlayState* play) { this->unk_312 = 999; } - if (Cutscene_CheckActorAction(play, 515)) { - if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 515)]->action == 1) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_515)) { + if (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_515)]->id == 1) { this->actionFunc = func_80BA0CF4; this->unk_312 = -1; } @@ -697,8 +697,8 @@ void func_80BA0C14(EnZob* this, PlayState* play) { void func_80BA0CF4(EnZob* this, PlayState* play) { func_80B9F86C(this); - if (Cutscene_CheckActorAction(play, 515) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 515)]->action == 2)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_515) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_515)]->id == 2)) { this->actionFunc = func_80BA0C14; } } @@ -711,18 +711,18 @@ void EnZob_Update(Actor* thisx, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); - if ((this->unk_30E != -1) && (ActorCutscene_GetCurrentIndex() != this->unk_306[this->unk_30E])) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_306[this->unk_30E]); - } else if (ActorCutscene_GetCanPlayNext(this->unk_306[this->unk_30E])) { - ActorCutscene_Start(this->unk_306[this->unk_30E], &this->actor); + if ((this->csIdIndex != -1) && (CutsceneManager_GetCurrentCsId() != this->csIdList[this->csIdIndex])) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); + } else if (CutsceneManager_IsNext(this->csIdList[this->csIdIndex])) { + CutsceneManager_Start(this->csIdList[this->csIdIndex], &this->actor); } else { - ActorCutscene_SetIntentToPlay(this->unk_306[this->unk_30E]); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); } } @@ -769,7 +769,7 @@ void EnZob_Draw(Actor* thisx, PlayState* play) { func_80BA0F64, func_80BA0FAC, &this->actor); if (this->unk_2F4 & 0x20) { - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); } CLOSE_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.h b/src/overlays/actors/ovl_En_Zob/z_en_zob.h index 25ce14fdc..e0bd7bf79 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.h +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.h @@ -25,9 +25,9 @@ typedef struct EnZob { /* 0x2FC */ Vec3s unk_2FC; /* 0x302 */ s16 unk_302; /* 0x304 */ u16 unk_304; - /* 0x306 */ s16 unk_306[4]; - /* 0x30E */ s16 unk_30E; - /* 0x310 */ s16 unk_310; + /* 0x306 */ s16 csIdList[4]; + /* 0x30E */ s16 csIdIndex; + /* 0x310 */ s16 cueId; /* 0x312 */ s16 unk_312; /* 0x314 */ EnZobActionFunc actionFunc; } EnZob; // size = 0x318 diff --git a/src/overlays/actors/ovl_En_Zod/z_en_zod.c b/src/overlays/actors/ovl_En_Zod/z_en_zod.c index 9c7e7e6b5..826664a9a 100644 --- a/src/overlays/actors/ovl_En_Zod/z_en_zod.c +++ b/src/overlays/actors/ovl_En_Zod/z_en_zod.c @@ -115,16 +115,16 @@ void EnZod_Init(Actor* thisx, PlayState* play) { switch (ENZOD_GET_TYPE(thisx)) { case ENZOD_TYPE_1: - if (gSaveContext.save.weekEventReg[78] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_78_01)) { this->actionFunc = func_80BAFDB4; EnZod_ChangeAnim(this, ENZOD_ANIM_PLAYING_VIVACE, ANIMMODE_ONCE); this->actor.flags |= ACTOR_FLAG_10; - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); break; } this->actionFunc = func_80BAFB84; - if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { + if (!(CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE))) { Actor_Kill(&this->actor); break; } @@ -137,7 +137,7 @@ void EnZod_Init(Actor* thisx, PlayState* play) { break; default: - if (gSaveContext.save.weekEventReg[55] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { Actor_Kill(&this->actor); } this->actor.flags |= ACTOR_FLAG_10; @@ -156,19 +156,19 @@ void EnZod_HandleRoomConversation(EnZod* this, PlayState* play) { if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { textId = 0x1227; - if (gSaveContext.save.weekEventReg[32] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_32_08)) { textId = 0x1229; } else { - gSaveContext.save.weekEventReg[32] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_32_08); } } else if (this->stateFlags & TIJO_STATE_1) { textId = 0x1225; } else { textId = 0x1219; - if (gSaveContext.save.weekEventReg[32] & 0x10) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_32_10)) { textId = 0x1226; } else { - gSaveContext.save.weekEventReg[32] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_32_10); } this->stateFlags |= TIJO_STATE_1; } @@ -316,12 +316,12 @@ void func_80BAF7CC(EnZod* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - func_80151938(play, 0x1220); + Message_ContinueTextbox(play, 0x1220); break; case 1: func_8019F230(); - func_80151938(play, 0x1223); + Message_ContinueTextbox(play, 0x1223); break; } } @@ -336,32 +336,32 @@ void func_80BAF7CC(EnZod* this, PlayState* play) { case 0x1220: case 0x1221: case 0x1227: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1219: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); this->nextAnimIndex = ENZOD_ANIM_ARMS_FOLDED; break; case 0x121D: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); this->nextAnimIndex = ENZOD_ANIM_READY_TO_PLAY; break; case 0x1223: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); this->nextAnimIndex = ENZOD_ANIM_PLAYING_VIVACE; break; case 0x121E: case 0x1226: - func_80151938(play, 0x121F); + Message_ContinueTextbox(play, 0x121F); this->nextAnimIndex = ENZOD_ANIM_READY_TO_PLAY; break; default: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = EnZod_PlayDrumsSequence; EnZod_ChangeAnim(this, ENZOD_ANIM_PLAYING_LENTO, ANIMMODE_ONCE); break; @@ -387,21 +387,21 @@ void EnZod_PlayDrumsSequence(EnZod* this, PlayState* play) { seqPos.y = this->actor.projectedPos.y; seqPos.z = this->actor.projectedPos.z; - func_801A1FB4(3, &seqPos, NA_BGM_DRUMS_PLAY, 700.0f); + func_801A1FB4(SEQ_PLAYER_BGM_SUB, &seqPos, NA_BGM_DRUMS_PLAY, 700.0f); } void func_80BAFA44(EnZod* this, PlayState* play) { u16 textId; if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.save.weekEventReg[79] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_01)) { textId = 0x1253; } else { textId = 0x1251; - if (gSaveContext.save.weekEventReg[78] & 0x20) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_78_20)) { textId = 0x1252; } else { - gSaveContext.save.weekEventReg[78] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_78_20); } } } else { @@ -419,7 +419,7 @@ void func_80BAFADC(EnZod* this, PlayState* play) { talkState = Message_GetState(&play->msgCtx); if (talkState != TEXT_STATE_CLOSING) { if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BAFB84; EnZod_ChangeAnim(this, ENZOD_ANIM_PLAYING_LENTO, ANIMMODE_ONCE); } @@ -445,46 +445,46 @@ void EnZod_DoNothing(EnZod* this, PlayState* play) { void EnZod_Rehearse(EnZod* this, PlayState* play) { EnZod_UpdateAnimation(this); - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); - this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); - if (this->actor.cutscene == -1) { + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); + this->actor.csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); + if (this->actor.csId == CS_ID_NONE) { this->actionFunc = EnZod_DoNothing; play->nextEntrance = play->setupExitList[ENZOD_GET_ENTRANCE_INDEX(&this->actor)]; - play->transitionType = TRANS_TYPE_05; + play->transitionType = TRANS_TYPE_FADE_WHITE_FAST; play->transitionTrigger = TRANS_TRIGGER_START; - gSaveContext.save.weekEventReg[78] &= (u8)~1; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_78_01); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } void EnZod_SetupRehearse(EnZod* this, PlayState* play) { EnZod_UpdateAnimation(this); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); EnZod_ChangeAnim(this, ENZOD_ANIM_PLAYING_LENTO, ANIMMODE_ONCE); this->actionFunc = EnZod_Rehearse; - ActorCutscene_Stop(this->actor.cutscene); - this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); - ActorCutscene_SetIntentToPlay(this->actor.cutscene); - gSaveContext.save.weekEventReg[79] |= 1; - Audio_QueueSeqCmd(NA_BGM_INDIGO_GO_SESSION | 0x8000); + CutsceneManager_Stop(this->actor.csId); + this->actor.csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); + CutsceneManager_Queue(this->actor.csId); + SET_WEEKEVENTREG(WEEKEVENTREG_79_01); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_INDIGO_GO_SESSION | SEQ_FLAG_ASYNC); } } void func_80BAFDB4(EnZod* this, PlayState* play) { EnZod_UpdateAnimation(this); - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); func_800B7298(play, NULL, 0x44); Message_StartTextbox(play, 0x103A, &this->actor); this->actionFunc = EnZod_SetupRehearse; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -500,8 +500,8 @@ void func_80BAFE34(EnZod* this, PlayState* play) { this->fogNear = 999; } - if (Cutscene_CheckActorAction(play, 0x203)) { - if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x203)]->action == 1) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_515)) { + if (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_515)]->id == 1) { this->actionFunc = func_80BAFF14; this->fogNear = -1; } @@ -513,8 +513,8 @@ void func_80BAFE34(EnZod* this, PlayState* play) { void func_80BAFF14(EnZod* this, PlayState* play) { EnZod_UpdateAnimation(this); - if (Cutscene_CheckActorAction(play, 0x203) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x203)]->action == 4)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_515) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_515)]->id == 4)) { this->actionFunc = func_80BAFE34; } } @@ -527,7 +527,7 @@ void EnZod_Update(Actor* thisx, PlayState* play) { Actor_MoveWithGravity(&this->actor); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); EnZod_UpdateInstruments(this); @@ -645,7 +645,7 @@ void EnZod_Draw(Actor* thisx, PlayState* play) { SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnZod_OverrideLimbDraw, EnZod_PostLimbDraw, &this->actor); if (this->stateFlags & TIJO_STATE_2) { - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); } CLOSE_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index a165d91fe..ccbb1f752 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -173,7 +173,7 @@ void func_80B93468(EnZog* this, PlayState* play) { this->actor.world.pos.x = points[-1].x; this->actor.world.pos.z = points[-1].z; this->actor.world.rot.y = Math_Atan2S(points->x - this->actor.world.pos.x, points->z - this->actor.world.pos.z); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } } @@ -181,7 +181,7 @@ void EnZog_Init(Actor* thisx, PlayState* play) { s32 pad; EnZog* this = THIS; s32 i; - s16 cs; + s16 csId; if (!D_80B95E10) { for (i = 0; i < ARRAY_COUNT(D_80B958AC); i++) { @@ -206,7 +206,7 @@ void EnZog_Init(Actor* thisx, PlayState* play) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA) && - ((play->csCtx.currentCsIndex != 2) || (gSaveContext.sceneLayer != 0) || (play->sceneId != SCENE_30GYOSON))) { + ((play->csCtx.scriptIndex != 2) || (gSaveContext.sceneLayer != 0) || (play->sceneId != SCENE_30GYOSON))) { Actor_Kill(&this->actor); return; } @@ -219,7 +219,7 @@ void EnZog_Init(Actor* thisx, PlayState* play) { this->unk_30A = 0; this->unk_31C = 2; this->unk_31E = 0; - this->unk_31A = -1; + this->csIdIndex = -1; this->unk_322 = 100; Math_Vec3f_Copy(&this->unk_2F0, &this->actor.world.pos); @@ -245,13 +245,13 @@ void EnZog_Init(Actor* thisx, PlayState* play) { this->unk_304 = 0; this->unk_2FE = this->unk_2FC; this->unk_300 = this->unk_302; - cs = this->actor.cutscene; + csId = this->actor.csId; - for (i = 0; i < ARRAY_COUNT(this->unk_30C); i++) { - this->unk_30C[i] = cs; - if (cs != -1) { - this->actor.cutscene = cs; - cs = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + for (i = 0; i < ARRAY_COUNT(this->csIdList); i++) { + this->csIdList[i] = csId; + if (csId != CS_ID_NONE) { + this->actor.csId = csId; + csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); } } @@ -331,17 +331,17 @@ void func_80B93A48(EnZog* this, PlayState* play) { void func_80B93B44(EnZog* this) { if (!(this->unk_30A & 4)) { - if (this->unk_31A != -1) { - ActorCutscene_Stop(this->unk_30C[this->unk_31A]); + if (this->csIdIndex != -1) { + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); } } - this->unk_31A = -1; + this->csIdIndex = -1; this->unk_30A &= ~4; } -void func_80B93BA8(EnZog* this, s16 arg1) { +void func_80B93BA8(EnZog* this, s16 csIdIndex) { func_80B93B44(this); - this->unk_31A = arg1; + this->csIdIndex = csIdIndex; this->unk_30A |= 4; } @@ -401,10 +401,10 @@ void func_80B93DE8(Vec3f* arg0, PlayState* play, s32 arg2) { } s32 func_80B93EA0(EnZog* this, PlayState* play) { - s16 sp3E; + s16 cueId; if (SkelAnime_Update(&this->skelAnime)) { - switch (this->unk_306) { + switch (this->cueId) { case 2: case 3: Animation_PlayLoop(&this->skelAnime, *D_80B958F0); @@ -458,14 +458,14 @@ s32 func_80B93EA0(EnZog* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); } - if (Cutscene_CheckActorAction(play, 471)) { - sp3E = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 471)]->action; - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, 471)); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_471)) { + cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_471)]->id; + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_471)); - switch (this->unk_306) { + switch (this->cueId) { case 2: - if (play->csCtx.frames == 60) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_JUMP_SAND); + if (play->csCtx.curFrame == 60) { + Actor_PlaySfx(&this->actor, NA_SE_EV_JUMP_SAND); } break; @@ -497,10 +497,10 @@ s32 func_80B93EA0(EnZog* this, PlayState* play) { break; } - if (this->unk_306 != sp3E) { - this->unk_306 = sp3E; + if (this->cueId != cueId) { + this->cueId = cueId; - switch (this->unk_306) { + switch (this->cueId) { case 1: func_80B939C0(this, 7, ANIMMODE_LOOP); this->unk_31C = 2; @@ -593,7 +593,7 @@ void func_80B943A0(EnZog* this, PlayState* play) { void func_80B943C0(EnZog* this, PlayState* play) { if (!(this->unk_30A & 4)) { this->actionFunc = func_80B943A0; - this->unk_306 = -1; + this->cueId = -1; } } @@ -606,14 +606,14 @@ void func_80B943EC(EnZog* this, PlayState* play) { } } else if ((player->stateFlags2 & PLAYER_STATE2_8000000) && (this->actor.xzDistToPlayer < 120.0f)) { this->unk_30A |= 0x10; - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); } } void func_80B94470(EnZog* this, PlayState* play) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_5) { if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x103C)) { - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B9451C; this->unk_300 = this->unk_302 = 0; this->unk_31C = 2; @@ -657,7 +657,7 @@ void func_80B946B4(EnZog* this, PlayState* play) { func_80B93A48(this, play); if (!(this->unk_30A & 4)) { this->actionFunc = func_80B9461C; - this->unk_306 = -1; + this->cueId = -1; } } @@ -675,7 +675,7 @@ void func_80B946FC(EnZog* this, PlayState* play) { case 1: func_8019F230(); - func_80151938(play, 0x1014); + Message_ContinueTextbox(play, 0x1014); break; } } @@ -685,20 +685,20 @@ void func_80B946FC(EnZog* this, PlayState* play) { if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x1008: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1009: this->unk_300 = 4; - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1014: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1015: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B948A8; this->unk_300 = this->unk_302 = 0; this->unk_31C = 2; @@ -762,9 +762,9 @@ void func_80B94A00(EnZog* this, PlayState* play) { if ((this->skelAnime.curFrame >= 35.0f) || ((this->skelAnime.curFrame >= 10.0f) && (this->skelAnime.curFrame <= 24.0f))) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { - this->actor.speedXZ = 1.5f; + this->actor.speed = 1.5f; } if ((this->actor.depthInWater > 0.0f) && ((play->gameplayFrames % 8) == 0)) { @@ -781,21 +781,21 @@ void func_80B94A00(EnZog* this, PlayState* play) { if ((this->unk_304 == 4) && (Animation_OnFrame(&this->skelAnime, 136.0f) || Animation_OnFrame(&this->skelAnime, 155.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_WATER0); + Actor_PlaySfx(&this->actor, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_WATER_SHALLOW); } if ((this->unk_304 == 5) && (Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 37.0f))) { if (this->actor.depthInWater > 0.0f) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_WATER0); + Actor_PlaySfx(&this->actor, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_WATER_SHALLOW); } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_SAND); + Actor_PlaySfx(&this->actor, NA_SE_PL_WALK_GROUND + SURFACE_SFX_OFFSET_SAND); } } } void func_80B94C5C(EnZog* this, PlayState* play) { - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->unk_304 != 0) { if (this->actor.shape.yOffset > 0.0f) { this->actor.shape.yOffset -= 20.0f; @@ -818,7 +818,7 @@ void func_80B94C5C(EnZog* this, PlayState* play) { void func_80B94D0C(EnZog* this, PlayState* play) { func_80B93D2C(this, play); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; if (this->unk_320 > 0) { this->unk_320--; this->unk_31C = 1; @@ -834,11 +834,11 @@ void func_80B94D0C(EnZog* this, PlayState* play) { case 0x1004: case 0x1005: case 0x1006: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1007: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B94E34; this->unk_300 = 5; this->unk_320 = 0; @@ -857,10 +857,10 @@ void func_80B94E34(EnZog* this, PlayState* play) { func_80B93D2C(this, play); func_80B93BE0(this, play); - if (this->actor.speedXZ < 0.1f) { - this->actor.speedXZ = 0.0f; + if (this->actor.speed < 0.1f) { + this->actor.speed = 0.0f; } else { - if (this->actor.speedXZ > 0.1f) { + if (this->actor.speed > 0.1f) { WaterBox* sp44; Vec3f sp38; @@ -871,19 +871,19 @@ void func_80B94E34(EnZog* this, PlayState* play) { if (WaterBox_GetSurface1(play, &play->colCtx, sp38.x, sp38.z, &sp38.y, &sp44) && (this->actor.world.pos.y < sp38.y)) { EffectSsGSplash_Spawn(play, &sp38, NULL, NULL, 1, - Rand_ZeroFloat(this->actor.speedXZ * 40.0f) + (this->actor.speedXZ * 60.0f)); + Rand_ZeroFloat(this->actor.speed * 40.0f) + (this->actor.speed * 60.0f)); } - if ((player->actor.speedXZ > 3.0f) && (this->unk_324 == 0)) { + if ((player->actor.speed > 3.0f) && (this->unk_324 == 0)) { this->unk_324 = 25; - func_800B8E58(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_PUSH); + Player_PlaySfx(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_PUSH); } } - this->actor.speedXZ *= 0.3f; + this->actor.speed *= 0.3f; } if (ABS_ALT(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0x5000) { - Actor_PickUp(&this->actor, play, GI_NONE, 60.0f, 40.0f); + Actor_OfferGetItem(&this->actor, play, GI_NONE, 60.0f, 40.0f); } if (this->unk_324 > 0) { @@ -892,12 +892,12 @@ void func_80B94E34(EnZog* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B94D0C; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_300 = 2; - } else if (this->actor.bgCheckFlags & 1) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->actor.home.rot.z = 1; this->actionFunc = func_80B94C5C; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->unk_2FE = 1; this->actor.velocity.y = 0.0f; this->actor.terminalVelocity = 0.0f; @@ -922,7 +922,7 @@ void func_80B95128(EnZog* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B94D0C; this->unk_300 = 2; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; switch (CURRENT_DAY) { case 1: @@ -956,8 +956,8 @@ void EnZog_Update(Actor* thisx, PlayState* play) { EnZog* this = THIS; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 5); - if (Cutscene_CheckActorAction(play, 0x1D7) && (ENZOG_GET_F(&this->actor) != ENZOG_F_2)) { + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_471) && (ENZOG_GET_F(&this->actor) != ENZOG_F_2)) { this->actionFunc = func_80B9461C; this->actor.shape.yOffset = 0.0f; } @@ -966,7 +966,7 @@ void EnZog_Update(Actor* thisx, PlayState* play) { if (((this->unk_304 == 6) && Animation_OnFrame(&this->skelAnime, 43.0f)) || ((this->unk_304 == 17) && Animation_OnFrame(&this->skelAnime, 14.0f))) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_LAND_SAND); + Actor_PlaySfx(&this->actor, NA_SE_EV_LAND_SAND); } if (this->unk_30A & 1) { @@ -982,18 +982,18 @@ void EnZog_Update(Actor* thisx, PlayState* play) { this->actor.focus.pos.y += 30.0f; if (this->unk_30A & 4) { - if (this->unk_31A == -1) { + if (this->csIdIndex == -1) { this->unk_30A &= ~4; - } else if (this->unk_30C[this->unk_31A] == -1) { + } else if (this->csIdList[this->csIdIndex] == CS_ID_NONE) { this->unk_30A &= ~4; - } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_30C[this->unk_31A]); - } else if (ActorCutscene_GetCanPlayNext(this->unk_30C[this->unk_31A])) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_30C[this->unk_31A], &this->actor); + } else if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); + } else if (CutsceneManager_IsNext(this->csIdList[this->csIdIndex])) { + CutsceneManager_StartWithPlayerCs(this->csIdList[this->csIdIndex], &this->actor); this->unk_30A &= ~4; } else { - ActorCutscene_SetIntentToPlay(this->unk_30C[this->unk_31A]); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); } } } diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.h b/src/overlays/actors/ovl_En_Zog/z_en_zog.h index 9971d77fa..737168250 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.h +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.h @@ -27,11 +27,11 @@ typedef struct EnZog { /* 0x300 */ s16 unk_300; /* 0x302 */ s16 unk_302; /* 0x304 */ s16 unk_304; - /* 0x306 */ s16 unk_306; + /* 0x306 */ s16 cueId; /* 0x308 */ s16 unk_308; /* 0x30A */ u16 unk_30A; - /* 0x30C */ s16 unk_30C[7]; - /* 0x31A */ s16 unk_31A; + /* 0x30C */ s16 csIdList[7]; + /* 0x31A */ s16 csIdIndex; /* 0x31C */ s16 unk_31C; /* 0x31E */ s16 unk_31E; /* 0x320 */ s16 unk_320; diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c index 2f6f0e791..21201346a 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c @@ -75,7 +75,10 @@ void func_80B31590(EnZoraegg* this) { void EnZoraegg_Init(Actor* thisx, PlayState* play) { s32 pad; EnZoraegg* this = THIS; - u16 sp40[] = { 457, 458, 459, 460, 461, 462, 464 }; + u16 cueTypes[] = { + CS_CMD_ACTOR_CUE_457, CS_CMD_ACTOR_CUE_458, CS_CMD_ACTOR_CUE_459, CS_CMD_ACTOR_CUE_460, + CS_CMD_ACTOR_CUE_461, CS_CMD_ACTOR_CUE_462, CS_CMD_ACTOR_CUE_464, + }; Actor_SetScale(&this->actor, 0.006f); SkelAnime_InitFlex(play, &this->skelAnime, &object_zoraegg_Skel_004C90, &object_zoraegg_Anim_005098, @@ -162,7 +165,7 @@ void EnZoraegg_Init(Actor* thisx, PlayState* play) { case ENZORAEGG_1F_07: case ENZORAEGG_1F_08: case ENZORAEGG_1F_09: - this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_03]; + this->cueType = cueTypes[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_03]; Animation_PlayOnce(&this->skelAnime, &object_zoraegg_Anim_001E08); this->unk_1EC = 1; this->unk_1EE = 0; @@ -181,7 +184,7 @@ void EnZoraegg_Init(Actor* thisx, PlayState* play) { case ENZORAEGG_1F_0E: case ENZORAEGG_1F_0F: case ENZORAEGG_1F_10: - this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_0A]; + this->cueType = cueTypes[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_0A]; this->unk_1EC = 2; this->actionFunc = func_80B324B0; Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); @@ -206,13 +209,13 @@ void EnZoraegg_Destroy(Actor* thisx, PlayState* play) { } s32 func_80B319A8(PlayState* play) { - return gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 & 7; + return gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 & 7; } void func_80B319D0(PlayState* play, s32 arg1) { if ((arg1 < 8) && (arg1 >= 0)) { - gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 &= ~7; - gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 |= arg1; + gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 &= ~7; + gSaveContext.save.saveInfo.permanentSceneFlags[play->sceneId].unk_14 |= arg1; } } @@ -244,7 +247,7 @@ void func_80B31C40(EnZoraegg* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); this->actor.focus.pos.y += 10.0f; - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } Actor* func_80B31CB4(PlayState* play) { @@ -318,7 +321,7 @@ void func_80B31E00(EnZoraegg* this) { } if ((this->unk_1E8 == 111) || (this->unk_1E8 == 32)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_BORN); + Actor_PlaySfx(&this->actor, NA_SE_EV_ZORA_KIDS_BORN); } } @@ -340,7 +343,7 @@ void func_80B320E0(EnZoraegg* this, PlayState* play) { this->actionFunc = func_80B32094; Message_StartTextbox(play, 0x24B, &this->actor); } else { - Actor_PickUp(&this->actor, play, GI_MAX, 80.0f, 60.0f); + Actor_OfferGetItem(&this->actor, play, GI_MAX, 80.0f, 60.0f); if (this->actor.isTargeted) { func_800B8614(&this->actor, play, 110.0f); } @@ -352,7 +355,7 @@ void func_80B320E0(EnZoraegg* this, PlayState* play) { } void func_80B321D0(EnZoraegg* this, PlayState* play) { - if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + if (CutsceneManager_GetCurrentCsId() != this->actor.csId) { this->actionFunc = func_80B322BC; func_80B319D0(play, func_80B319A8(play) + 1); } @@ -362,26 +365,26 @@ void func_80B32228(EnZoraegg* this, PlayState* play) { s32 pad; Player* player = GET_PLAYER(play); - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, this->unk_1DC); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, this->unk_1DC); this->actionFunc = func_80B321D0; } else { if (this->unk_1E8 > 0) { this->unk_1E8--; } else if (this->unk_1E8 == 0) { - ActorCutscene_Stop(player->unk_A86); - player->unk_A86 = -1; + CutsceneManager_Stop(player->csId); + player->csId = CS_ID_NONE; this->unk_1E8 = -1; } - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } void func_80B322BC(EnZoraegg* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (this->actor.cutscene != -1) { + if (this->actor.csId != CS_ID_NONE) { this->unk_1DC = func_80B31CB4(play); if (this->unk_1DC != NULL) { this->unk_1E8 = 3; @@ -400,11 +403,11 @@ void func_80B32390(EnZoraegg* this, PlayState* play) { s32 pad; Player* player = GET_PLAYER(play); - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + if (CutsceneManager_IsNext(this->actor.csId)) { Actor* temp_v0 = func_80B31D14(play); if (temp_v0 != NULL) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, temp_v0); + CutsceneManager_StartWithPlayerCs(this->actor.csId, temp_v0); SET_EVENTINF(EVENTINF_33); Actor_Kill(&this->actor); } @@ -412,32 +415,32 @@ void func_80B32390(EnZoraegg* this, PlayState* play) { (fabsf(player->actor.world.pos.x - this->actor.world.pos.x) < (100.0f * this->actor.scale.x)) && (fabsf(player->actor.world.pos.z - this->actor.world.pos.z) < (100.0f * this->actor.scale.z)) && (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 30.0f)) { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } void func_80B324B0(EnZoraegg* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Cutscene_CheckActorAction(play, this->actorActionCmd)) { + if (Cutscene_IsCueInChannel(play, this->cueType)) { if (this->unk_1EA & 4) { - if (Cutscene_CheckActorAction(play, this->actorActionCmd) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->actorActionCmd)]->action == 3)) { + if (Cutscene_IsCueInChannel(play, this->cueType) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id == 3)) { Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); this->unk_1EA &= ~4; } } else { - if (Cutscene_CheckActorAction(play, this->actorActionCmd) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->actorActionCmd)]->action == 4)) { + if (Cutscene_IsCueInChannel(play, this->cueType) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id == 4)) { Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004E04); this->unk_1EA |= 4; } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->actorActionCmd)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); if ((this->unk_1EA & 4) && Animation_OnFrame(&this->skelAnime, this->unk_1E4)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); + Actor_PlaySfx(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); this->unk_1E4 = Rand_ZeroFloat(5.0f); } } else if (this->unk_1EA & 4) { @@ -453,10 +456,10 @@ void func_80B32644(EnZoraegg* this, PlayState* play) { this->unk_1EA |= 2; } - if (!Cutscene_CheckActorAction(play, this->actorActionCmd)) { + if (!Cutscene_IsCueInChannel(play, this->cueType)) { this->actionFunc = func_80B324B0; } else { - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->actorActionCmd)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); if (this->unk_1EE > 25) { this->unk_1EE -= 25; @@ -469,8 +472,8 @@ void func_80B32644(EnZoraegg* this, PlayState* play) { void func_80B326F4(EnZoraegg* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Cutscene_CheckActorAction(play, this->actorActionCmd) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->actorActionCmd)]->action == 3)) { + if (Cutscene_IsCueInChannel(play, this->cueType) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id == 3)) { Animation_Change(&this->skelAnime, &object_zoraegg_Anim_004D20, 1.0f, 0.0f, Animation_GetLastFrame(&object_zoraegg_Anim_004D20), ANIMMODE_ONCE, 5.0f); this->unk_1E8 = 0; @@ -478,13 +481,13 @@ void func_80B326F4(EnZoraegg* this, PlayState* play) { SET_WEEKEVENTREG(WEEKEVENTREG_19_40); this->unk_1EC = 2; this->unk_1EE = 100; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_2); + Actor_PlaySfx(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_2); } - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->actorActionCmd)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); if (Animation_OnFrame(&this->skelAnime, 4.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); + Actor_PlaySfx(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); } } @@ -504,10 +507,10 @@ void func_80B32820(EnZoraegg* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); } - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->actorActionCmd)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); if (Animation_OnFrame(&this->skelAnime, 16.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_0); + Actor_PlaySfx(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_0); } } @@ -538,17 +541,17 @@ void func_80B32928(EnZoraegg* this, PlayState* play) { } } - Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->actorActionCmd)); + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); if (Animation_OnFrame(&this->skelAnime, 97.0f) || Animation_OnFrame(&this->skelAnime, 101.0f) || Animation_OnFrame(&this->skelAnime, 105.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); + Actor_PlaySfx(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); } } void func_80B32A88(EnZoraegg* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, this->actorActionCmd) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->actorActionCmd)]->action == 2)) { + if (Cutscene_IsCueInChannel(play, this->cueType) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id == 2)) { this->unk_1E8 = 0; this->actionFunc = func_80B32928; } @@ -570,7 +573,7 @@ void func_80B32B3C(EnZoraegg* this, PlayState* play) { void func_80B32B70(EnZoraegg* this, PlayState* play) { func_80B31C40(this, play); - if (Cutscene_CheckActorAction(play, 0x1C9)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_457)) { Actor_Kill(&this->actor); } } @@ -579,11 +582,11 @@ void func_80B32BB8(EnZoraegg* this, PlayState* play) { func_80B31C40(this, play); func_80B31D64(this, play, 13, 0.0f); - if (this->actor.bgCheckFlags & 0x1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->actionFunc = func_80B32B70; } - if (Cutscene_CheckActorAction(play, 0x1C9)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_457)) { Actor_Kill(&this->actor); } } @@ -627,7 +630,7 @@ void func_80B32D08(EnZoraegg* this, PlayState* play) { EffectSsGRipple_Spawn(play, &sp34, 150, 500, 0); EffectSsGSplash_Spawn(play, &sp34, NULL, NULL, 0, 200); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); + Actor_PlaySfx(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); this->actionFunc = func_80B32C34; this->actor.velocity.y = -1.0f; diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h index f36f77c2b..18a421272 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h @@ -53,7 +53,7 @@ typedef struct EnZoraegg { /* 0x1ED */ u8 unk_1ED; /* 0x1EE */ u8 unk_1EE; /* 0x1EF */ u8 unk_1EF; - /* 0x1F0 */ u16 actorActionCmd; + /* 0x1F0 */ u16 cueType; /* 0x1F2 */ s16 unk_1F2; /* 0x1F4 */ s16 unk_1F4; /* 0x1F8 */ EnZoraeggActionFunc actionFunc; diff --git a/src/overlays/actors/ovl_En_Zos/z_en_zos.c b/src/overlays/actors/ovl_En_Zos/z_en_zos.c index ba37c3ffe..039c2a3e6 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.c +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.c @@ -100,7 +100,7 @@ void EnZos_Init(Actor* thisx, PlayState* play) { switch (ENZOS_GET_F(&this->actor)) { case ENZOS_F_1: - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { Actor_Kill(&this->actor); } @@ -120,7 +120,7 @@ void EnZos_Init(Actor* thisx, PlayState* play) { break; default: - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { Actor_Kill(&this->actor); } this->actor.flags |= ACTOR_FLAG_10; @@ -273,20 +273,20 @@ void func_80BBB354(EnZos* this, PlayState* play) { } else { getItemId = GI_HEART_PIECE; } - Actor_PickUp(&this->actor, play, getItemId, 10000.0f, 50.0f); + Actor_OfferGetItem(&this->actor, play, getItemId, 10000.0f, 50.0f); } } void func_80BBB414(EnZos* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); - if (Cutscene_CheckActorAction(play, 501)) { - s16 action = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 501)]->action; + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_501)) { + s16 cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_501)]->id; - if (action != this->unk_2BA) { - this->unk_2BA = action; + if (this->cueId != cueId) { + this->cueId = cueId; - switch (action) { + switch (cueId) { case 1: EnZos_ChangeAnim(this, EN_ZOS_ANIM_LEAN_ON_KEYBOARD_AND_SIGH, ANIMMODE_LOOP); break; @@ -302,15 +302,15 @@ void func_80BBB414(EnZos* this, PlayState* play) { void func_80BBB4CC(EnZos* this, PlayState* play) { func_80BBB414(this, play); - if ((this->actor.cutscene != -1) && (ActorCutscene_GetCurrentIndex() != this->actor.cutscene)) { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actor.cutscene); - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); - this->actor.cutscene = -1; + if ((this->actor.csId != CS_ID_NONE) && (CutsceneManager_GetCurrentCsId() != this->actor.csId)) { + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->actor.csId); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); + this->actor.csId = CS_ID_NONE; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } } @@ -324,7 +324,7 @@ void func_80BBB574(EnZos* this, PlayState* play) { if (func_80BBAFFC(this, play)) { if (this->unk_2B6 & 0x20) { this->unk_2B6 &= ~0x20; - func_80151938(play, 0x124C); + Message_ContinueTextbox(play, 0x124C); } } @@ -335,7 +335,7 @@ void func_80BBB574(EnZos* this, PlayState* play) { play->msgCtx.msgLength = 0; this->unk_2B6 |= 0x20; } else { - func_80151938(play, 0x124C); + Message_ContinueTextbox(play, 0x124C); } break; @@ -348,11 +348,11 @@ void func_80BBB574(EnZos* this, PlayState* play) { case 0x124D: this->unk_2B6 &= ~0x10; EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); - func_80151938(play, 0x124E); + Message_ContinueTextbox(play, 0x124E); break; case 0x124E: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BBB354; func_80BBB354(this, play); break; @@ -370,7 +370,7 @@ void func_80BBB718(EnZos* this, PlayState* play) { itemAction = func_80123810(play); if (itemAction > PLAYER_IA_NONE) { - func_801477B4(play); + Message_CloseTextbox(play); if (itemAction == PLAYER_IA_BOTTLE_ZORA_EGG) { player->actor.textId = 0x1232; @@ -388,9 +388,9 @@ void func_80BBB718(EnZos* this, PlayState* play) { this->actionFunc = func_80BBB8AC; } else if (itemAction <= PLAYER_IA_MINUS1) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_39_08)) { - func_80151938(play, 0x1241); + Message_ContinueTextbox(play, 0x1241); } else { - func_80151938(play, 0x1237); + Message_ContinueTextbox(play, 0x1237); SET_WEEKEVENTREG(WEEKEVENTREG_39_08); EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_LOOK_DOWN, ANIMMODE_LOOP); this->unk_2B6 |= 4; @@ -425,13 +425,13 @@ void func_80BBB8AC(EnZos* this, PlayState* play) { case 0x123C: case 0x123E: case 0x123F: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1244: this->unk_2B6 &= ~0x10; EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1232: @@ -441,29 +441,29 @@ void func_80BBB8AC(EnZos* this, PlayState* play) { case 0x1239: case 0x1246: EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1233: EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_ARMS_OUT, ANIMMODE_LOOP); - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1245: case 0x1248: EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_FOOT_TAP, ANIMMODE_LOOP); - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1231: - func_80151938(play, 0xFF); + Message_ContinueTextbox(play, 0xFF); this->actionFunc = func_80BBB718; break; case 0x1243: case 0x1249: EnZos_ChangeAnim(this, EN_ZOS_ANIM_HANDS_ON_HIPS, ANIMMODE_LOOP); - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BBBDE0; this->unk_2B6 |= 1; break; @@ -473,21 +473,23 @@ void func_80BBB8AC(EnZos* this, PlayState* play) { case 0x1242: EnZos_ChangeAnim(this, EN_ZOS_ANIM_HANDS_ON_HIPS, ANIMMODE_LOOP); Actor_ProcessTalkRequest(&this->actor, &play->state); - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BBBDE0; this->unk_2B6 |= 1; break; case 0x1236: EnZos_ChangeAnim(this, EN_ZOS_ANIM_HANDS_ON_HIPS, ANIMMODE_LOOP); - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BBBDE0; this->unk_2B6 |= 1; break; default: - if (0) {} - func_801477B4(play); + //! FAKE: + if (1) {} + + Message_CloseTextbox(play); this->actionFunc = func_80BBBDE0; this->unk_2B6 |= 1; break; @@ -532,7 +534,7 @@ void func_80BBBCBC(EnZos* this, PlayState* play) { void func_80BBBD5C(EnZos* this, PlayState* play) { func_80BBB414(this, play); - if (!Cutscene_CheckActorAction(play, 0x1F5)) { + if (!Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_501)) { this->actionFunc = func_80BBBCBC; this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_MINUS1); @@ -565,7 +567,7 @@ void func_80BBBDE0(EnZos* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80BBB8AC; func_80BBB15C(this, play); - } else if (Cutscene_CheckActorAction(play, 0x1F5)) { + } else if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_501)) { this->actionFunc = func_80BBBD5C; } else if (func_80BBAF5C(this, play)) { func_800B8614(&this->actor, play, 120.0f); @@ -580,7 +582,7 @@ void func_80BBBDE0(EnZos* this, PlayState* play) { sp28.x = this->actor.projectedPos.x; sp28.y = this->actor.projectedPos.y; sp28.z = this->actor.projectedPos.z; - func_801A1FB4(3, &sp28, 110, 1000.0f); + func_801A1FB4(SEQ_PLAYER_BGM_SUB, &sp28, NA_BGM_PIANO_PLAY, 1000.0f); } void func_80BBBFBC(EnZos* this, PlayState* play) { @@ -612,7 +614,7 @@ void func_80BBC070(EnZos* this, PlayState* play) { case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { EnZos_ChangeAnim(this, EN_ZOS_ANIM_HANDS_ON_HIPS, ANIMMODE_LOOP); - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BBC14C; this->unk_2B6 |= 1; } @@ -673,8 +675,8 @@ void func_80BBC298(EnZos* this, PlayState* play) { this->unk_2BC = 999; } - if (Cutscene_CheckActorAction(play, 515)) { - if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 515)]->action == 1) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_515)) { + if (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_515)]->id == 1) { this->actionFunc = func_80BBC37C; this->unk_2BC = -1; } @@ -686,8 +688,8 @@ void func_80BBC298(EnZos* this, PlayState* play) { void func_80BBC37C(EnZos* this, PlayState* play) { func_80BBAFFC(this, play); - if (Cutscene_CheckActorAction(play, 515) && - (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 515)]->action == 3)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_515) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_515)]->id == 3)) { this->actionFunc = func_80BBC298; } } @@ -699,7 +701,7 @@ void EnZos_Update(Actor* thisx, PlayState* play) { Actor_MoveWithGravity(&this->actor); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 30.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 30.0f, UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); @@ -762,7 +764,7 @@ void EnZos_Draw(Actor* thisx, PlayState* play) { func_80BBC4E4, func_80BBC500, &this->actor); if (this->unk_2B6 & 0x40) { - POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); } CLOSE_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Zos/z_en_zos.h b/src/overlays/actors/ovl_En_Zos/z_en_zos.h index e3ede7b28..669430a0c 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.h +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.h @@ -26,7 +26,7 @@ typedef struct EnZos { /* 0x2B0 */ UNK_TYPE1 unk2B0[6]; /* 0x2B6 */ u16 unk_2B6; /* 0x2B8 */ s16 animIndex; - /* 0x2BA */ s16 unk_2BA; + /* 0x2BA */ s16 cueId; /* 0x2BC */ s16 unk_2BC; /* 0x2C0 */ EnZosActionFunc actionFunc; } EnZos; // size = 0x2C4 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 417a6388e..f382cdf80 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -185,14 +185,14 @@ void EnZot_Init(Actor* thisx, PlayState* play2) { func_80B96BEC(this, 2, ANIMMODE_LOOP); this->actor.colChkInfo.cylRadius = 0; this->actor.shape.yOffset = -1400.0f; - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { Actor_Kill(&this->actor); } break; case 18: this->actionFunc = func_80B99384; - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { Actor_Kill(&this->actor); } break; @@ -220,7 +220,8 @@ void EnZot_Init(Actor* thisx, PlayState* play2) { break; } - if ((ENZOT_GET_1F(thisx) >= 2) && (ENZOT_GET_1F(thisx) < 11) && CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if ((ENZOT_GET_1F(thisx) >= 2) && (ENZOT_GET_1F(thisx) < 11) && + CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { Actor_Kill(&this->actor); } } @@ -299,7 +300,7 @@ s32 func_80B96E5C(EnZot* this) { temp_f14 = points->z - this->actor.world.pos.z; this->actor.world.rot.y = Math_Atan2S(temp_f12, temp_f14); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 2000, 200); - phi_f2 = SQ(this->actor.speedXZ) * SQ(3.0f); + phi_f2 = SQ(this->actor.speed) * SQ(3.0f); if (this->unk_2D4 == 0) { phi_f2 = SQ(20.0f); @@ -383,14 +384,14 @@ void func_80B97194(EnZot* this, PlayState* play) { switch (play->msgCtx.currentTextId) { case 0x125C: case 0x125F: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x125D: case 0x125E: case 0x1260: case 0x1261: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B97240; break; } @@ -454,42 +455,42 @@ void func_80B973BC(EnZot* this, PlayState* play) { case 0x1270: case 0x1273: case 0x1274: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1272: - func_80151938(play, 0x126F); + Message_ContinueTextbox(play, 0x126F); break; case 0x126F: Rupees_ChangeBy(90); - func_80151938(play, 0x1270); + Message_ContinueTextbox(play, 0x1270); break; case 0x1275: - if (gSaveContext.save.playerData.rupees < 10) { - func_80151938(play, 0x1277); + if (gSaveContext.save.saveInfo.playerData.rupees < 10) { + Message_ContinueTextbox(play, 0x1277); } else { - func_80151938(play, 0x1278); + Message_ContinueTextbox(play, 0x1278); Rupees_ChangeBy(-10); } break; case 0x1276: - func_80151938(play, 0x1275); + Message_ContinueTextbox(play, 0x1275); break; case 0x1271: case 0x1277: case 0x1278: case 0x1279: - func_801477B4(play); + Message_CloseTextbox(play); func_80B965D0(this, play); this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.textId = 0; this->actionFunc = func_80B97708; - if ((this->actor.cutscene != -1) && !(this->unk_2F2 & 1)) { - ActorCutscene_Stop(this->actor.cutscene); + if ((this->actor.csId != CS_ID_NONE) && !(this->unk_2F2 & 1)) { + CutsceneManager_Stop(this->actor.csId); } this->unk_2F2 &= ~1; break; @@ -497,16 +498,16 @@ void func_80B973BC(EnZot* this, PlayState* play) { } if (this->unk_2F2 & 1) { - if (this->actor.cutscene == -1) { + if (this->actor.csId == CS_ID_NONE) { this->unk_2F2 &= ~1; - } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->actor.cutscene); - } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } else if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->actor.csId); + } else if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); this->unk_2F2 &= ~1; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } } @@ -530,10 +531,10 @@ void func_80B9765C(EnZot* this, PlayState* play) { case 0x1267: case 0x126A: case 0x126B: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; default: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B97708; break; } @@ -652,9 +653,9 @@ void func_80B979DC(EnZot* this, PlayState* play) { if (func_80B96E5C(this)) { this->actionFunc = func_80B97B5C; func_80B96BEC(this, 0, ANIMMODE_LOOP); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { - this->actor.speedXZ = 1.5f; + this->actor.speed = 1.5f; } } @@ -667,7 +668,7 @@ void func_80B97A44(EnZot* this, PlayState* play) { case 0x1282: case 0x1285: case 0x1288: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x127D: @@ -676,7 +677,7 @@ void func_80B97A44(EnZot* this, PlayState* play) { case 0x1284: case 0x1289: case 0x128A: - func_801477B4(play); + Message_CloseTextbox(play); if (!(this->unk_2F2 & 2)) { this->unk_2F2 |= 2; this->actionFunc = func_80B979DC; @@ -687,7 +688,7 @@ void func_80B97A44(EnZot* this, PlayState* play) { break; default: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B97B5C; break; } @@ -720,7 +721,7 @@ void func_80B97C40(EnZot* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B97CC8; } } @@ -737,14 +738,14 @@ void func_80B97CC8(EnZot* this, PlayState* play) { void func_80B97D6C(EnZot* this, PlayState* play) { if (func_80B96E5C(this)) { this->actionFunc = func_80B97CC8; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; func_80B96BEC(this, 0, ANIMMODE_LOOP); } else { - this->actor.speedXZ = 8.0f; + this->actor.speed = 8.0f; } if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_WALK); + Actor_PlaySfx(&this->actor, NA_SE_EV_ZORA_WALK); } } @@ -772,17 +773,17 @@ void func_80B97E4C(EnZot* this, PlayState* play) { case 0x128C: this->unk_2F2 &= ~4; func_80B96BEC(this, 6, ANIMMODE_ONCE); - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x128D: case 0x128E: case 0x128F: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1290: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B97D6C; this->unk_2F2 |= 4; func_80B96BEC(this, 3, ANIMMODE_LOOP); @@ -790,7 +791,7 @@ void func_80B97E4C(EnZot* this, PlayState* play) { break; case 0x128B: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B97FD0; break; } @@ -819,9 +820,9 @@ void func_80B980FC(EnZot* this, PlayState* play) { this->actor.home.rot.x--; } else if (func_80B96E5C(this)) { this->actionFunc = func_80B97100; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; } else { - this->actor.speedXZ = 8.0f; + this->actor.speed = 8.0f; if (this->unk_2F0 != 3) { func_80B96BEC(this, 3, ANIMMODE_LOOP); } @@ -943,7 +944,7 @@ void func_80B9854C(EnZot* this, PlayState* play) { this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_MINUS1); } else { - Actor_PickUp(&this->actor, play, this->unk_2D4, 10000.0f, 50.0f); + Actor_OfferGetItem(&this->actor, play, this->unk_2D4, 10000.0f, 50.0f); } } @@ -956,10 +957,10 @@ void func_80B985EC(EnZot* this, PlayState* play) { itemAction = func_80123810(play); if (itemAction > PLAYER_IA_NONE) { - func_801477B4(play); + Message_CloseTextbox(play); if ((itemAction == PLAYER_IA_PICTO_BOX) && CHECK_QUEST_ITEM(QUEST_PICTOGRAPH) && - Snap_CheckFlag(PICTOGRAPH_LULU_HEAD)) { - if (Snap_CheckFlag(PICTOGRAPH_LULU_RIGHT_ARM) && Snap_CheckFlag(PICTOGRAPH_LULU_LEFT_ARM)) { + Snap_CheckFlag(PICTO_VALID_LULU_HEAD)) { + if (Snap_CheckFlag(PICTO_VALID_LULU_RIGHT_ARM) && Snap_CheckFlag(PICTO_VALID_LULU_LEFT_ARM)) { player->actor.textId = 0x12AE; } else { player->actor.textId = 0x12AC; @@ -970,7 +971,7 @@ void func_80B985EC(EnZot* this, PlayState* play) { } this->actionFunc = func_80B98728; } else if (itemAction <= PLAYER_IA_MINUS1) { - func_80151938(play, 0x12AB); + Message_ContinueTextbox(play, 0x12AB); this->actionFunc = func_80B98728; } } @@ -985,12 +986,12 @@ void func_80B98728(EnZot* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 0: func_8019F208(); - func_80151938(play, 0x1294); + Message_ContinueTextbox(play, 0x1294); break; case 1: func_8019F230(); - func_80151938(play, 0x1298); + Message_ContinueTextbox(play, 0x1298); break; } } @@ -1015,44 +1016,44 @@ void func_80B98728(EnZot* this, PlayState* play) { case 0x12A7: case 0x12A8: case 0x12AE: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x12A9: case 0x12AA: - func_80151938(play, 0xFF); + Message_ContinueTextbox(play, 0xFF); this->actionFunc = func_80B985EC; break; case 0x1294: if (CURRENT_DAY == 3) { - func_80151938(play, 0x1296); + Message_ContinueTextbox(play, 0x1296); } else { - func_80151938(play, 0x1295); + Message_ContinueTextbox(play, 0x1295); } break; case 0x12AB: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B98998; break; case 0x12AC: - func_801477B4(play); + Message_CloseTextbox(play); this->unk_2D4 = 2; this->actionFunc = func_80B9854C; func_80B9854C(this, play); break; case 0x12AF: - func_801477B4(play); + Message_CloseTextbox(play); this->unk_2D4 = 4; this->actionFunc = func_80B9854C; func_80B9854C(this, play); break; default: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B98998; this->actor.flags &= ~ACTOR_FLAG_10000; break; @@ -1099,25 +1100,25 @@ void func_80B98AD0(EnZot* this, PlayState* play) { case 0x12B4: case 0x12B7: case 0x12B9: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x12B8: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B98CA8; CLEAR_WEEKEVENTREG(WEEKEVENTREG_41_20); AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); break; case 0x12BA: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B98CA8; SET_WEEKEVENTREG(WEEKEVENTREG_41_20); AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); break; default: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B98CA8; break; } @@ -1205,7 +1206,7 @@ void func_80B98F30(EnZot* this, PlayState* play) { this->actor.parent = NULL; this->actionFunc = func_80B990A4; } else { - Actor_PickUp(&this->actor, play, GI_RUPEE_BLUE, 10000.0f, 50.0f); + Actor_OfferGetItem(&this->actor, play, GI_RUPEE_BLUE, 10000.0f, 50.0f); } } @@ -1223,17 +1224,17 @@ void func_80B98F94(EnZot* this, PlayState* play) { case 0x12BC: case 0x12C0: case 0x12C3: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x12BE: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B98F30; func_80B98F30(this, play); break; default: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B990A4; break; } @@ -1282,9 +1283,9 @@ void func_80B991E4(EnZot* this, PlayState* play) { if ((temp == 0x12C6) || (temp == 0x12C7) || (temp == 0x12CA) || (temp == 0x12CB)) { temp2 = temp; - func_80151938(play, temp2 + 1); + Message_ContinueTextbox(play, temp2 + 1); } else { - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80B992C0; func_80B96BEC(this, 1, ANIMMODE_LOOP); } @@ -1295,13 +1296,13 @@ void func_80B992C0(EnZot* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B991E4; func_80B99160(this, play); - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; func_80B96BEC(this, 0, ANIMMODE_LOOP); } else { if (Player_IsFacingActor(&this->actor, 0x3000, play) && (this->actor.xzDistToPlayer < 100.0f)) { func_800B8614(&this->actor, play, 120.0f); } - this->actor.speedXZ = 1.5f; + this->actor.speed = 1.5f; func_80B96FB0(this); } } @@ -1316,7 +1317,7 @@ void EnZot_Update(Actor* thisx, PlayState* play) { Actor_MoveWithGravity(&this->actor); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 15.0f, 30.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 15.0f, 30.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); this->unk_2F2 &= ~0x40; if (SkelAnime_Update(&this->skelAnime) && (this->unk_2F0 != 0)) { diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.c b/src/overlays/actors/ovl_En_Zov/z_en_zov.c index 851214b5d..c6dca4bd7 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -91,10 +91,10 @@ void EnZov_Init(Actor* thisx, PlayState* play) { Animation_PlayLoop(&this->skelAnime, &object_zov_Anim_00D3EC); this->unk_320 = 0; - this->unk_32C = -1; - this->unk_326 = -1; - this->unk_328[0] = this->picto.actor.cutscene; - this->unk_328[1] = 0x7C; + this->csIdIndex = -1; + this->cueId = -1; + this->csIdList[0] = this->picto.actor.csId; + this->csIdList[1] = CS_ID_GLOBAL_TALK; this->unk_322 = 0; this->actionFunc = func_80BD1C84; this->picto.validationFunc = EnZov_ValidatePictograph; @@ -107,7 +107,7 @@ void EnZov_Init(Actor* thisx, PlayState* play) { case ENZOV_F_1: this->actionFunc = func_80BD1F1C; func_80BD1570(this, 9, ANIMMODE_LOOP); - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { Actor_Kill(&this->picto.actor); return; } @@ -120,7 +120,7 @@ void EnZov_Init(Actor* thisx, PlayState* play) { default: this->unk_320 |= 2; - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80) || CHECK_WEEKEVENTREG(WEEKEVENTREG_53_20)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE) || CHECK_WEEKEVENTREG(WEEKEVENTREG_53_20)) { Actor_Kill(&this->picto.actor); } break; @@ -134,17 +134,17 @@ void EnZov_Destroy(Actor* thisx, PlayState* play) { } void func_80BD13DC(EnZov* this) { - if (this->unk_32C != -1) { - if (ActorCutscene_GetCurrentIndex() == this->unk_328[this->unk_32C]) { - ActorCutscene_Stop(this->unk_328[this->unk_32C]); + if (this->csIdIndex != -1) { + if (CutsceneManager_GetCurrentCsId() == this->csIdList[this->csIdIndex]) { + CutsceneManager_Stop(this->csIdList[this->csIdIndex]); } - this->unk_32C = -1; + this->csIdIndex = -1; } } void func_80BD1440(EnZov* this, s16 arg1) { func_80BD13DC(this); - this->unk_32C = arg1; + this->csIdIndex = arg1; } void func_80BD1470(EnZov* this, s16 index, u8 mode, f32 transitionRate) { @@ -264,14 +264,14 @@ void func_80BD187C(EnZov* this, PlayState* play) { if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { case 0x1022: - func_80151938(play, 0x1023); + Message_ContinueTextbox(play, 0x1023); break; case 0x1023: if ((this->unk_322 != 6) && (this->unk_322 != 1)) { func_80BD1570(this, 1, ANIMMODE_ONCE); } - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BD1C84; break; @@ -279,14 +279,14 @@ void func_80BD187C(EnZov* this, PlayState* play) { if (this->unk_322 != 6) { func_80BD1570(this, 0, ANIMMODE_LOOP); } - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BD1C84; break; default: this->unk_320 &= ~1; func_80BD1570(this, 0, ANIMMODE_LOOP); - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BD1C84; break; } @@ -294,7 +294,7 @@ void func_80BD187C(EnZov* this, PlayState* play) { break; case TEXT_STATE_CLOSING: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BD1C84; this->unk_320 &= ~1; func_80BD1570(this, 0, ANIMMODE_LOOP); @@ -328,12 +328,12 @@ void func_80BD19FC(EnZov* this, PlayState* play) { s32 func_80BD1AE0(EnZov* this, PlayState* play) { func_80BD1764(this); - if (Cutscene_CheckActorAction(play, 504)) { - s16 action = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 504)]->action; + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_504)) { + s16 cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_504)]->id; - if (action != this->unk_326) { - this->unk_326 = action; - switch (this->unk_326) { + if (this->cueId != cueId) { + this->cueId = cueId; + switch (this->cueId) { case 1: func_80BD1570(this, 0, ANIMMODE_LOOP); break; @@ -367,7 +367,7 @@ void func_80BD1BF0(EnZov* this, PlayState* play) { void func_80BD1C38(EnZov* this, PlayState* play) { if (func_80BD1AE0(this, play)) { - Cutscene_ActorTranslateAndYaw(&this->picto.actor, play, Cutscene_GetActorActionIndex(play, 504)); + Cutscene_ActorTranslateAndYaw(&this->picto.actor, play, Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_504)); } } @@ -381,7 +381,7 @@ void func_80BD1C84(EnZov* this, PlayState* play) { func_800B8614(&this->picto.actor, play, 120.0f); } - if (Cutscene_CheckActorAction(play, 0x1F8)) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_504)) { this->actionFunc = func_80BD1BF0; func_80BD1BF0(this, play); } @@ -419,21 +419,21 @@ void func_80BD1DB8(EnZov* this, PlayState* play) { case 0x1036: case 0x1037: case 0x1038: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; case 0x1039: play->nextEntrance = play->setupExitList[ENZOV_GET_FE00(&this->picto.actor)]; - play->transitionType = TRANS_TYPE_05; + play->transitionType = TRANS_TYPE_FADE_WHITE_FAST; play->transitionTrigger = TRANS_TRIGGER_START; SET_WEEKEVENTREG(WEEKEVENTREG_78_01); this->actionFunc = func_80BD1D94; play->msgCtx.msgLength = 0; - Audio_QueueSeqCmd(0x101400FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20); break; default: - func_801477B4(play); + Message_CloseTextbox(play); this->actionFunc = func_80BD1F1C; break; } @@ -460,11 +460,11 @@ s32 EnZov_ValidatePictograph(PlayState* play, Actor* thisx) { s32 ret; EnZov* this = THIS; - ret = Snap_ValidatePictograph(play, &this->picto.actor, PICTOGRAPH_LULU_HEAD, &this->picto.actor.focus.pos, + ret = Snap_ValidatePictograph(play, &this->picto.actor, PICTO_VALID_LULU_HEAD, &this->picto.actor.focus.pos, &this->picto.actor.shape.rot, 10.0f, 300.0f, -1); - ret |= Snap_ValidatePictograph(play, &this->picto.actor, PICTOGRAPH_LULU_RIGHT_ARM, &this->unk_308, + ret |= Snap_ValidatePictograph(play, &this->picto.actor, PICTO_VALID_LULU_RIGHT_ARM, &this->unk_308, &this->picto.actor.shape.rot, 50.0f, 160.0f, 0x3000); - ret |= Snap_ValidatePictograph(play, &this->picto.actor, PICTOGRAPH_LULU_LEFT_ARM, &this->unk_314, + ret |= Snap_ValidatePictograph(play, &this->picto.actor, PICTO_VALID_LULU_LEFT_ARM, &this->unk_314, &this->picto.actor.shape.rot, 50.0f, 160.0f, 0x3000); return ret; } @@ -476,11 +476,11 @@ void EnZov_Update(Actor* thisx, PlayState* play) { Actor_MoveWithGravity(&this->picto.actor); Collider_UpdateCylinder(&this->picto.actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(play, &this->picto.actor, 10.0f, 10.0f, 10.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->picto.actor, 10.0f, 10.0f, 10.0f, UPDBGCHECKINFO_FLAG_4); this->actionFunc(this, play); - if (!Cutscene_CheckActorAction(play, 0x1F8)) { + if (!Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_504)) { this->unk_320 &= ~0x10; } @@ -506,14 +506,14 @@ void EnZov_Update(Actor* thisx, PlayState* play) { this->unk_2EC = 0; } - if ((this->unk_32C != -1) && (ActorCutscene_GetCurrentIndex() != this->unk_328[this->unk_32C])) { - if ((this->unk_32C == 0) && (ActorCutscene_GetCurrentIndex() == 0x7C)) { - ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_328[this->unk_32C]); - } else if (ActorCutscene_GetCanPlayNext(this->unk_328[this->unk_32C])) { - ActorCutscene_Start(this->unk_328[this->unk_32C], &this->picto.actor); + if ((this->csIdIndex != -1) && (CutsceneManager_GetCurrentCsId() != this->csIdList[this->csIdIndex])) { + if ((this->csIdIndex == 0) && (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK)) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); + } else if (CutsceneManager_IsNext(this->csIdList[this->csIdIndex])) { + CutsceneManager_Start(this->csIdList[this->csIdIndex], &this->picto.actor); } else { - ActorCutscene_SetIntentToPlay(this->unk_328[this->unk_32C]); + CutsceneManager_Queue(this->csIdList[this->csIdIndex]); } } } diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.h b/src/overlays/actors/ovl_En_Zov/z_en_zov.h index a5e217ca3..7e1204100 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.h +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.h @@ -30,9 +30,9 @@ typedef struct EnZov { /* 0x320 */ u16 unk_320; /* 0x322 */ s16 unk_322; /* 0x324 */ s16 unk_324; - /* 0x326 */ s16 unk_326; - /* 0x328 */ s16 unk_328[2]; - /* 0x32C */ s16 unk_32C; + /* 0x326 */ s16 cueId; + /* 0x328 */ s16 csIdList[2]; + /* 0x32C */ s16 csIdIndex; /* 0x330 */ EnZovActionFunc actionFunc; } EnZov; // size = 0x334 diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index 7e3709162..446470dbe 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -357,7 +357,7 @@ void func_80BDD1E0(EnZow* this, PlayState* play) { u16 phi_a1; if (ENZOW_GET_F(&this->actor) == ENZOW_F_1) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_78_04)) { phi_a1 = 0x12FD; @@ -384,7 +384,7 @@ void func_80BDD1E0(EnZow* this, PlayState* play) { SET_WEEKEVENTREG(WEEKEVENTREG_78_10); phi_a1 = 0x12FF; } - } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE)) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { phi_a1 = 0x12EC; } else { @@ -405,7 +405,7 @@ void func_80BDD1E0(EnZow* this, PlayState* play) { void func_80BDD350(EnZow* this, PlayState* play) { if (this->unk_2CA & 2) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EV_DIVE_WATER); func_80BDCDA8(this, this->unk_2D0); this->actor.flags &= ~ACTOR_FLAG_1; this->skelAnime.playSpeed = 0.0f; @@ -420,7 +420,7 @@ void func_80BDD350(EnZow* this, PlayState* play) { } } - if ((this->actor.bgCheckFlags & 1) || (this->actor.depthInWater > 180.0f)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->actor.depthInWater > 180.0f)) { this->actor.velocity.y = 0.0f; this->actionFunc = func_80BDD79C; } @@ -477,11 +477,11 @@ void func_80BDD570(EnZow* this, PlayState* play) { case 0x12FB: case 0x12FD: case 0x12FF: - func_80151938(play, play->msgCtx.currentTextId + 1); + Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; default: - func_801477B4(play); + Message_CloseTextbox(play); break; } } @@ -511,7 +511,7 @@ void func_80BDD6BC(EnZow* this, PlayState* play) { } if (this->actor.depthInWater < 54.0f) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); + Actor_PlaySfx(&this->actor, NA_SE_EV_OUT_OF_WATER); func_80BDCDA8(this, this->unk_2D0); func_80BDD04C(this, 1, ANIMMODE_ONCE); this->actor.flags |= ACTOR_FLAG_1; @@ -547,7 +547,7 @@ void EnZow_Update(Actor* thisx, PlayState* play) { Actor_MoveWithGravity(&this->actor); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 15.0f, 30.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 15.0f, 30.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); if (this->unk_2CE != 0) { this->unk_2CA &= ~2; 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 c4d72a8f1..c41f45579 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 @@ -1,9 +1,3 @@ -/* - * File: z_item_b_heart.c - * Overlay: ovl_Item_B_Heart - * Description: Heart Container - */ - #include "z_item_b_heart.h" #include "objects/object_gi_hearts/object_gi_hearts.h" @@ -16,9 +10,8 @@ void ItemBHeart_Destroy(Actor* thisx, PlayState* play); void ItemBHeart_Update(Actor* thisx, PlayState* play); void ItemBHeart_Draw(Actor* thisx, PlayState* play); -void func_808BCF54(ItemBHeart* this, PlayState* play); - -ActorInit Item_B_Heart_InitVars = { +/* +const ActorInit Item_B_Heart_InitVars = { ACTOR_ITEM_B_HEART, ACTORCAT_BOSS, FLAGS, @@ -27,89 +20,16 @@ ActorInit Item_B_Heart_InitVars = { (ActorFunc)ItemBHeart_Init, (ActorFunc)ItemBHeart_Destroy, (ActorFunc)ItemBHeart_Update, - (ActorFunc)ItemBHeart_Draw, + (ActorFunc)ItemBHeart_Draw }; +*/ -static InitChainEntry sInitChain[] = { - ICHAIN_VEC3F_DIV1000(scale, 0, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_B_Heart/ItemBHeart_Init.s") -void ItemBHeart_Init(Actor* thisx, PlayState* play) { - ItemBHeart* this = THIS; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_B_Heart/ItemBHeart_Destroy.s") - if (Flags_GetCollectible(play, 0x1F)) { - Actor_Kill(&this->actor); - return; - } +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_B_Heart/ItemBHeart_Update.s") - Actor_ProcessInitChain(&this->actor, sInitChain); - ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.8f); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_B_Heart/func_808BCF54.s") - if (this->actor.params == 0x23) { - this->unk_168 = 0.1f; - } else { - this->unk_168 = 1.0f; - } - - this->actor.world.pos.y += (20.0f * this->unk_168); -} - -void ItemBHeart_Destroy(Actor* thisx, PlayState* play) { -} - -void ItemBHeart_Update(Actor* thisx, PlayState* play) { - ItemBHeart* this = THIS; - - func_808BCF54(this, play); - - if (!(this->unk_168 < 0.5f)) { - if (Actor_HasParent(&this->actor, play)) { - Flags_SetCollectible(play, 0x1F); - Actor_Kill(&this->actor); - return; - } - - Actor_PickUp(&this->actor, play, GI_HEART_CONTAINER, 30.0f, 80.0f); - } -} - -void func_808BCF54(ItemBHeart* this, PlayState* play) { - this->actor.shape.rot.y += 0x400; - Math_ApproachF(&this->unk_164, 0.4f, 0.1f, 0.01f); - Actor_SetScale(&this->actor, this->unk_164 * this->unk_168); -} - -void ItemBHeart_Draw(Actor* thisx, PlayState* play) { - ItemBHeart* this = THIS; - Actor* blueWarpActor; - u8 flag = false; - - OPEN_DISPS(play->state.gfxCtx); - - blueWarpActor = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; - - while (blueWarpActor != NULL) { - if ((blueWarpActor->id == ACTOR_DOOR_WARP1) && (blueWarpActor->projectedPos.z > this->actor.projectedPos.z)) { - flag = true; - break; - } - blueWarpActor = blueWarpActor->next; - } - - if (flag || thisx->world.rot.y != 0) { - func_8012C2DC(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gGiHeartBorderDL); - gSPDisplayList(POLY_XLU_DISP++, gGiHeartContainerDL); - } else { - func_8012C28C(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gGiHeartBorderDL); - gSPDisplayList(POLY_OPA_DISP++, gGiHeartContainerDL); - } - - CLOSE_DISPS(play->state.gfxCtx); -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_B_Heart/ItemBHeart_Draw.s") diff --git a/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h b/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h index f7ff62fa9..4e3126e25 100644 --- a/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h +++ b/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h @@ -7,8 +7,7 @@ struct ItemBHeart; typedef struct ItemBHeart { /* 0x000 */ Actor actor; - /* 0x144 */ UNK_TYPE1 unk_144[0x20]; - /* 0x164 */ f32 unk_164; + /* 0x144 */ UNK_TYPE1 unk_144[0x24]; /* 0x168 */ f32 unk_168; } ItemBHeart; // size = 0x16C diff --git a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c index e327dc3f4..c5b218815 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -106,7 +106,7 @@ void func_8092009C(ItemEtcetera* this, PlayState* play) { return; } - Actor_PickUp(&this->actor, play, this->getItemId, 30.0f, 50.0f); + Actor_OfferGetItem(&this->actor, play, this->getItemId, 30.0f, 50.0f); } void func_809200F8(ItemEtcetera* this, PlayState* play) { diff --git a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c index a552e35ab..c4e861ff6 100644 --- a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c +++ b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c @@ -115,7 +115,7 @@ void MirRay2_Update(Actor* thisx, PlayState* play) { } else { func_80AF3FE0(this, play); if (MIRRAY2_GET_F(thisx) != 1) { - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, UPDBGCHECKINFO_FLAG_4); this->actor.shape.shadowAlpha = 0x50; } else { func_80AF3F70(this); 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 acea3daf1..c32fb582d 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -151,7 +151,10 @@ void ObjAqua_Init(Actor* thisx, PlayState* play) { Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 60.0f); - if (1) {}; + + //! FAKE: + if (1) {} + this->actor.shape.shadowAlpha = 140; this->alpha = 255; if (func_80ACBA60(this, play)) { @@ -175,11 +178,11 @@ void func_80ACBC70(ObjAqua* this) { } void func_80ACBC8C(ObjAqua* this, PlayState* play) { - if (this->actor.bgCheckFlags & 0x21) { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_WATER)) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { func_80ACB7F4(this, play); func_80ACBA10(this); - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOTTLE_WATERING); + Actor_PlaySfx(&this->actor, NA_SE_EV_BOTTLE_WATERING); func_80ACBD34(this); } else { func_80ACB6A0(this, play); @@ -254,7 +257,7 @@ void ObjAqua_Update(Actor* thisx, PlayState* play) { } this->actor.velocity.y *= 0.9f; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 4.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 12.0f, 4.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); if (this->actionFunc != func_80ACBDFC) { Collider_UpdateCylinder(&this->actor, &this->collider); this->collider.dim.radius = this->actor.scale.x * 3000.0f; diff --git a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c index 565c99504..93adab401 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c @@ -7,7 +7,7 @@ #include "z_obj_armos.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_CAN_PRESS_SWITCH) #define THIS ((ObjArmos*)thisx) @@ -227,7 +227,7 @@ void ObjArmos_Destroy(Actor* thisx, PlayState* play) { void func_809A54B4(ObjArmos* this) { this->actionFunc = func_809A54E0; - this->unk_24C = 4; + this->updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_4; this->unk_266[1] = 0; this->unk_266[2] = 0; this->unk_266[3] = 0; @@ -260,7 +260,7 @@ void func_809A54E0(ObjArmos* this, PlayState* play) { void func_809A5610(ObjArmos* this) { this->actionFunc = func_809A562C; - this->unk_24C = 5; + this->updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4; } void func_809A562C(ObjArmos* this, PlayState* play) { @@ -277,14 +277,14 @@ void func_809A562C(ObjArmos* this, PlayState* play) { if ((temp == OBJARMOS_ROT_7_4) || (temp == OBJARMOS_ROT_7_5) || (temp == OBJARMOS_ROT_7_6)) { if (!func_809A500C(this, this->unk_264) || func_809A4E00(this, play, 0x5A)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } } else if (func_809A500C(this, this->unk_264)) { if (func_809A4E00(this, play, 0x5A)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } } else { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); Flags_SetSwitch(play, OBJARMOS_GET_7F(&this->dyna.actor)); sp20 = true; } @@ -304,7 +304,7 @@ void func_809A562C(ObjArmos* this, PlayState* play) { void func_809A57D8(ObjArmos* this) { this->actionFunc = func_809A57F4; - this->unk_24C = 4; + this->updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_4; } void func_809A57F4(ObjArmos* this, PlayState* play) { @@ -322,12 +322,12 @@ void ObjArmos_Update(Actor* thisx, PlayState* play2) { this->actionFunc(this, play); this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; - if (this->unk_24C != 0) { - Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 20.0f, 30.0f, 0.0f, this->unk_24C); + if (this->updBgCheckInfoFlags != 0) { + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 20.0f, 30.0f, 0.0f, this->updBgCheckInfoFlags); - if ((this->actionFunc == func_809A54E0) && (this->dyna.actor.bgCheckFlags & 1) && + if ((this->actionFunc == func_809A54E0) && (this->dyna.actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (DynaPoly_GetActor(&play->colCtx, this->dyna.actor.floorBgId) == NULL)) { - this->unk_24C = 0; + this->updBgCheckInfoFlags = 0; } this->unk_250.x = (Math_SinS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.x; diff --git a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h index 2e9453005..177cc8e66 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h @@ -28,7 +28,7 @@ typedef struct ObjArmos { /* 0x1A0 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; /* 0x1F4 */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; /* 0x248 */ ObjArmosActionFunc actionFunc; - /* 0x24C */ u32 unk_24C; + /* 0x24C */ u32 updBgCheckInfoFlags; /* 0x250 */ Vec3f unk_250; /* 0x25C */ f32* unk_25C; /* 0x260 */ f32 unk_260; diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c index 35f37d5d8..7cc5dfb17 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c @@ -235,15 +235,15 @@ void func_809372D0(ObjBean* this) { sp34 = Math3D_Vec3fMagnitude(&actor->velocity); temp_f2 = D_80938FF8[this->unk_1DE].x; temp_f12 = D_80938FF8[this->unk_1DE].z; - if (sp34 < (actor->speedXZ * 8.0f)) { + if (sp34 < (actor->speed * 8.0f)) { temp_f2 = ((temp_f2 - 2.0f) * 0.1f) + 2.0f; temp_f12 *= 0.4f; } - Math_StepToF(&actor->speedXZ, temp_f2, temp_f12); + Math_StepToF(&actor->speed, temp_f2, temp_f12); - if ((actor->speedXZ + 0.05f) < sp34) { - Math_Vec3f_Scale(&actor->velocity, actor->speedXZ / sp34); + if ((actor->speed + 0.05f) < sp34) { + Math_Vec3f_Scale(&actor->velocity, actor->speed / sp34); this->unk_1BC.x += actor->velocity.x; this->unk_1BC.y += actor->velocity.y; this->unk_1BC.z += actor->velocity.z; @@ -255,7 +255,7 @@ void func_809372D0(ObjBean* this) { } else { this->unk_1DC++; } - actor->speedXZ *= 0.5f; + actor->speed *= 0.5f; } } @@ -365,7 +365,7 @@ void ObjBean_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); this->unk_1FE = 0; this->unk_1B8 = 0.1f; - DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); Collider_InitCylinder(play, &this->collider); if ((sp2C == ENOBJBEAN_GET_C000_1) || (sp2C == ENOBJBEAN_GET_C000_2)) { @@ -414,7 +414,7 @@ void ObjBean_Init(Actor* thisx, PlayState* play) { if (OBJBEAN_GET_80(&this->dyna.actor) || Flags_GetSwitch(play, OBJBEAN_GET_7F(&this->dyna.actor, 1))) { func_80938804(this); } else { - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); func_80938704(this); } } @@ -576,7 +576,7 @@ void func_80937FC8(ObjBean* this, PlayState* play) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } else { - func_800B85E0(&this->dyna.actor, play, 28.0f, 0x2E); + func_800B85E0(&this->dyna.actor, play, 28.0f, PLAYER_IA_MAGIC_BEANS); } } } @@ -588,20 +588,20 @@ void func_809381B0(ObjBean* this) { void func_809381C4(ObjBean* this, PlayState* play) { this->unk_1E8(this); - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - if (this->dyna.actor.cutscene >= 0) { + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); + if (this->dyna.actor.csId >= 0) { func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_1); } this->unk_1E4 = 2; func_80938284(this); } else if (this->unk_1E4 == 4) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); play_sound(NA_SE_SY_ERROR); this->unk_1E4 = 0; func_80937FB0(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -618,7 +618,7 @@ void func_80938298(ObjBean* this, PlayState* play) { this->unk_1E4 = 5; func_8093833C(this); } else if (this->unk_1E4 == 4) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); play_sound(NA_SE_SY_ERROR); this->unk_1E4 = 0; func_80937FB0(this); @@ -634,7 +634,7 @@ void func_80938358(ObjBean* this, PlayState* play) { this->unk_1E8(this); if (this->unk_1B2 <= 0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); func_80937FB0(this); } } @@ -735,7 +735,7 @@ void func_80938704(ObjBean* this) { void func_80938728(ObjBean* this, PlayState* play) { if (this->unk_200 != 0) { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); func_8093876C(this); } } @@ -745,16 +745,16 @@ void func_8093876C(ObjBean* this) { } void func_80938780(ObjBean* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - if (this->dyna.actor.cutscene >= 0) { + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); + if (this->dyna.actor.csId >= 0) { func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_1); } this->unk_1B4 = 36; func_80937130(this); func_80938AA4(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -765,7 +765,7 @@ void func_80938804(ObjBean* this) { } void func_80938834(ObjBean* this, PlayState* play) { - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { func_80938874(this); } func_80936F24(this); @@ -775,7 +775,7 @@ void func_80938874(ObjBean* this) { this->actionFunc = func_809388A8; this->dyna.actor.draw = func_80938E00; this->dyna.actor.flags |= ACTOR_FLAG_10; - this->dyna.actor.speedXZ = 0.0f; + this->dyna.actor.speed = 0.0f; } void func_809388A8(ObjBean* this, PlayState* play) { @@ -784,7 +784,7 @@ void func_809388A8(ObjBean* this, PlayState* play) { func_80937268(this, play); func_809372A8(this); func_8093892C(this); - } else if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + } else if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { func_800B9010(&this->dyna.actor, NA_SE_PL_PLANT_MOVE - SFX_FLAG); } func_80936F24(this); @@ -797,7 +797,7 @@ void func_8093892C(ObjBean* this) { } void func_80938958(ObjBean* this, PlayState* play) { - if (!DynaPolyActor_IsInRidingRotatingState(&this->dyna)) { + if (!DynaPolyActor_IsPlayerAbove(&this->dyna)) { func_80938804(this); } func_80936F24(this); @@ -810,7 +810,7 @@ void func_80938998(ObjBean* this) { } void func_809389BC(ObjBean* this, PlayState* play) { - if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (!DynaPolyActor_IsPlayerOnTop(&this->dyna)) { func_80937268(this, play); func_809372A8(this); func_80937238(this); @@ -847,13 +847,13 @@ void func_80938AD8(ObjBean* this, PlayState* play) { func_80937160(this); if (this->unk_1B2 == 25) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_PL_PLANT_GROW_BIG); + Actor_PlaySfx(&this->dyna.actor, NA_SE_PL_PLANT_GROW_BIG); } if (sp30 != 0) { - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } else { - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } if (this->dyna.actor.xzDistToPlayer < 74.0f) { @@ -909,7 +909,7 @@ void ObjBean_Update(Actor* thisx, PlayState* play) { if (this->unk_1B4 > 0) { this->unk_1B4--; if (this->unk_1B4 == 0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); } } @@ -925,7 +925,7 @@ void ObjBean_Update(Actor* thisx, PlayState* play) { this->dyna.actor.shape.shadowScale = this->dyna.actor.scale.x * 88.0f; if (func_80937468(this, play)) { func_809375F4(this, play); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); func_80938998(this); } } else { 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 f8534afea..fb7f1466c 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c @@ -188,11 +188,11 @@ s32 func_80A357A8(ObjBell* this, PlayState* play) { this->unk_20E = 10; switch (this->dyna.actor.colChkInfo.damageEffect) { case 15: - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGBELL); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BIGBELL); func_80A35510(this, 1); break; case 14: - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGBELL); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BIGBELL); func_80A35510(this, 2); break; default: diff --git a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c index 4b7e9f471..85468c59c 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c @@ -182,7 +182,7 @@ void func_80AE8FD4(ObjBigicicle* this, PlayState* play) { if ((this->collider1.base.acFlags & AC_HIT) || ((this->collider2.base.acFlags & AC_HIT) && (this->collider2.info.acHitInfo->toucher.dmgFlags & 0x3820))) { if ((this->unk_148 == 0) || (this->unk_149 == 1)) { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); this->actionFunc = func_80AE9090; return; } @@ -195,8 +195,8 @@ void func_80AE8FD4(ObjBigicicle* this, PlayState* play) { } void func_80AE9090(ObjBigicicle* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); this->unk_149++; func_80AE8DE4(this, play); if (this->unk_149 == 2) { @@ -213,7 +213,7 @@ void func_80AE9090(ObjBigicicle* this, PlayState* play) { this->actionFunc = func_80AE9180; } } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -227,7 +227,7 @@ void func_80AE9180(ObjBigicicle* this, PlayState* play) { } else { this->actor.shape.rot.x = 0x4000; this->actor.shape.rot.z = 0; - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); this->actionFunc = func_80AE8FD4; } } @@ -238,7 +238,7 @@ void func_80AE9258(ObjBigicicle* this, PlayState* play) { ObjIcePoly* icePoly; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; @@ -247,7 +247,7 @@ void func_80AE9258(ObjBigicicle* this, PlayState* play) { icePoly = (ObjIcePoly*)itemAction; temp_f0 = this->actor.world.pos.y - icePoly->actor.world.pos.y; if ((temp_f0 < icePoly->colliders1[0].dim.height) && (temp_f0 > 0.0f) && - (Actor_XZDistanceBetweenActors(&this->actor, &icePoly->actor) < icePoly->colliders1[0].dim.radius)) { + (Actor_WorldDistXZToActor(&this->actor, &icePoly->actor) < icePoly->colliders1[0].dim.radius)) { Flags_SetSwitch(play, this->actor.params); this->actionFunc = func_80AE939C; return; @@ -256,7 +256,7 @@ void func_80AE9258(ObjBigicicle* this, PlayState* play) { itemAction = itemAction->next; } - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->actionFunc = func_80AE939C; } else { Collider_UpdateCylinder(&this->actor, &this->collider1); @@ -284,7 +284,7 @@ void func_80AE939C(ObjBigicicle* this, PlayState* play) { } SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_GLASSBROKEN_IMPACT); - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); Actor_Kill(&this->actor); } diff --git a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c index 437f0c234..a4f44973f 100644 --- a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c +++ b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c @@ -48,7 +48,7 @@ void ObjBlockstop_CheckForBlock(ObjBlockstop* this, PlayState* play) { s32 params = OBJOSHIHIKI_GET_F(prop); if (params < 3) { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); this->actionFunc = ObjBlockstop_TryPlayCutscene; } } @@ -57,15 +57,15 @@ void ObjBlockstop_CheckForBlock(ObjBlockstop* this, PlayState* play) { } void ObjBlockstop_TryPlayCutscene(ObjBlockstop* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + if (CutsceneManager_IsNext(this->actor.csId)) { Flags_SetSwitch(play, this->actor.params); - if (ActorCutscene_GetLength(this->actor.cutscene) != -1) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (CutsceneManager_GetLength(this->actor.csId) != -1) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); } Actor_Kill(&this->actor); return; } - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } void ObjBlockstop_Update(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c index c48ff332c..43f137326 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c @@ -16,7 +16,7 @@ void ObjBoat_Destroy(Actor* thisx, PlayState* play); void ObjBoat_Update(Actor* thisx, PlayState* play); void ObjBoat_Draw(Actor* thisx, PlayState* play); -void func_80B9B428(Actor* thisx, PlayState* play2); +void ObjBoat_UpdateCutscene(Actor* thisx, PlayState* play2); ActorInit Obj_Boat_InitVars = { ACTOR_OBJ_BOAT, @@ -37,14 +37,21 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), }; -s16 func_80B9AF50(ObjBoat* this, Vec3f* arg0) { +/** + * Get the next point on the path and the yaw to use to get there. + * + * @param this + * @param nextPoint Position of next point on path + * @return yaw to use (or opposite of yaw if reversing) + */ +s16 ObjBoat_GetNextPoint(ObjBoat* this, Vec3f* nextPoint) { s16 yaw; - Vec3s* temp = &this->unk_164[(s32)this->unk_15C]; + Vec3s* curPoint = &this->points[(s32)this->curPointIndex]; - Math_Vec3s_ToVec3f(arg0, &temp[this->unk_15D]); - yaw = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, arg0); + Math_Vec3s_ToVec3f(nextPoint, &curPoint[this->direction]); + yaw = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, nextPoint); - return ((this->unk_15D > 0) ? yaw : (yaw + 0x8000)); + return ((this->direction > 0) ? yaw : yaw + 0x8000); } void ObjBoat_Init(Actor* thisx, PlayState* play) { @@ -54,20 +61,20 @@ void ObjBoat_Init(Actor* thisx, PlayState* play) { Vec3f sp24; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); DynaPolyActor_LoadMesh(play, &this->dyna, &object_kaizoku_obj_Colheader_009A88); if (thisx->params < 0) { - this->dyna.actor.update = func_80B9B428; + this->dyna.actor.update = ObjBoat_UpdateCutscene; } else { path = &play->setupPathList[OBJBOAT_GET_PATH(thisx)]; - this->unk_163 = path->count - 1; - this->unk_164 = Lib_SegmentedToVirtual(path->points); - this->unk_15D = 1; - this->dyna.actor.world.pos.x = this->unk_164[this->unk_15C].x; - this->dyna.actor.world.pos.z = this->unk_164[this->unk_15C].z; - this->dyna.actor.shape.rot.y = func_80B9AF50(this, &sp24); + this->maxPointIndex = path->count - 1; + this->points = Lib_SegmentedToVirtual(path->points); + this->direction = 1; + this->dyna.actor.world.pos.x = this->points[this->curPointIndex].x; + this->dyna.actor.world.pos.z = this->points[this->curPointIndex].z; + this->dyna.actor.shape.rot.y = ObjBoat_GetNextPoint(this, &sp24); this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; - this->unk_15D = -this->unk_15D; + this->direction = -this->direction; } } @@ -77,105 +84,114 @@ void ObjBoat_Destroy(Actor* thisx, PlayState* play) { DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void func_80B9B124(ObjBoat* this) { - this->unk_160 += 1000; - this->dyna.actor.world.pos.y = Math_SinS(this->unk_160) + this->dyna.actor.home.pos.y; - this->dyna.actor.shape.rot.x = Math_SinS(this->unk_160) * 100.0f; - this->dyna.actor.shape.rot.z = Math_SinS(this->unk_160 * 2) * 50.0f; +void ObjBoat_SetRotations(ObjBoat* this) { + this->angle += 0x3E8; + this->dyna.actor.world.pos.y = Math_SinS(this->angle) + this->dyna.actor.home.pos.y; + this->dyna.actor.shape.rot.x = Math_SinS(this->angle) * 100.0f; + this->dyna.actor.shape.rot.z = Math_SinS(this->angle * 2) * 50.0f; } void ObjBoat_Update(Actor* thisx, PlayState* play) { s32 pad; ObjBoat* this = THIS; Player* player = GET_PLAYER(play); - s32 temp = DynaPolyActor_IsInRidingMovingState(&this->dyna); - f32 sp3C = 0.0f; - s16 sp3A = this->dyna.actor.shape.rot.y; - Vec3f sp2C; + s32 isPlayerOnTop = DynaPolyActor_IsPlayerOnTop(&this->dyna); + f32 speedTarget = 0.0f; + s16 yawTarget = this->dyna.actor.shape.rot.y; + Vec3f nextPoint; - if ((temp != 0) || ((DynaPolyActor_IsInRidingFallingState(&this->dyna)))) { - if ((this->unk_15F == 0) && (OBJBOAT_GET_4000(thisx) || ((temp != 0) && (this->unk_15C == this->unk_15E)))) { - this->unk_15D = -this->unk_15D; - if (this->unk_15D > 0) { - this->unk_15E = this->unk_163; + if (isPlayerOnTop || DynaPolyActor_IsActorOnTop(&this->dyna)) { + if ((this->timer == 0) && + (OBJBOAT_GET_4000(thisx) || (isPlayerOnTop && (this->curPointIndex == this->lastPointIndex)))) { + this->direction = -this->direction; + if (this->direction > 0) { + this->lastPointIndex = this->maxPointIndex; } else { - this->unk_15E = 0; + this->lastPointIndex = 0; } - this->unk_15F = 60; + this->timer = 60; } - } else if (this->dyna.actor.speedXZ == 0.0f) { - if (this->unk_15F != 0) { - this->unk_15F--; + } else if (this->dyna.actor.speed == 0.0f) { + if (this->timer != 0) { + this->timer--; } } - if (this->unk_15C != this->unk_15E) { - sp3A = func_80B9AF50(this, &sp2C); - if (Math_Vec3f_DistXZ(&this->dyna.actor.world.pos, &sp2C) < 200.0f) { - this->unk_15C += this->unk_15D; - if (this->unk_15C == this->unk_15E) { + + if (this->curPointIndex != this->lastPointIndex) { + yawTarget = ObjBoat_GetNextPoint(this, &nextPoint); + if (Math_Vec3f_DistXZ(&this->dyna.actor.world.pos, &nextPoint) < 200.0f) { + this->curPointIndex += this->direction; + if (this->curPointIndex == this->lastPointIndex) { if (OBJBOAT_GET_4000(thisx)) { - this->unk_15C = 0; - } else if (this->dyna.actor.speedXZ == 0.0f) { - this->unk_15C = 0; - this->unk_15D = -1; + this->curPointIndex = 0; + } else if (this->dyna.actor.speed == 0.0f) { + this->curPointIndex = 0; + this->direction = -1; } } } else { - sp3C = this->unk_15D * (OBJBOAT_GET_4000(thisx) ? 5.0f : 3.0f); + speedTarget = this->direction * (OBJBOAT_GET_4000(thisx) ? 5.0f : 3.0f); } } + if (player->csMode != PLAYER_CSMODE_26) { - Math_ScaledStepToS(&this->dyna.actor.shape.rot.y, sp3A, (s16)(s32)(fabsf(this->dyna.actor.speedXZ) * 40.0f)); + Math_ScaledStepToS(&this->dyna.actor.shape.rot.y, yawTarget, (s32)(fabsf(this->dyna.actor.speed) * 40.0f)); this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; - Math_StepToF(&this->dyna.actor.speedXZ, sp3C, 0.05f); + Math_StepToF(&this->dyna.actor.speed, speedTarget, 0.05f); Actor_MoveWithGravity(&this->dyna.actor); - if (this->dyna.actor.speedXZ != 0.0f) { + if (this->dyna.actor.speed != 0.0f) { func_800B9010(&this->dyna.actor, NA_SE_EV_PIRATE_SHIP - SFX_FLAG); } } - func_80B9B124(this); + ObjBoat_SetRotations(this); } -void func_80B9B428(Actor* thisx, PlayState* play2) { +// Update used in cutscenes +void ObjBoat_UpdateCutscene(Actor* thisx, PlayState* play2) { PlayState* play = play2; ObjBoat* this = THIS; - if (Cutscene_CheckActorAction(play, 511)) { - CsCmdActorAction* actionIndex = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 511)]; - if (this->unk_15F != actionIndex->action) { - this->dyna.actor.shape.rot.x = actionIndex->urot.x; - if (actionIndex->action != 1) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_511)) { + CsCmdActorCue* cue = play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_511)]; + + if (this->cueId != cue->id) { + this->dyna.actor.shape.rot.x = cue->rot.x; + if (cue->id != 1) { Path* path = &play->setupPathList[OBJBOAT_GET_PATH(&this->dyna.actor)]; - if (actionIndex->action == 3) { + if (cue->id == 3) { path = &play->setupPathList[path->unk1]; } - this->unk_163 = path->count; - this->unk_164 = Lib_SegmentedToVirtual(path->points); - Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, this->unk_164); - this->dyna.actor.speedXZ = actionIndex->urot.z * (45.0f / 0x2000); - this->unk_164++; - this->unk_15C = 1; - } - this->unk_15F = actionIndex->action; - } else { - if (actionIndex->action != 1) { - Vec3f vec; - f32 step; - Math_Vec3s_ToVec3f(&vec, this->unk_164); - step = Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &vec, this->dyna.actor.speedXZ); - if ((this->unk_15C < this->unk_163) && (step < this->dyna.actor.speedXZ)) { - this->unk_164++; - this->unk_15C++; + this->maxPointIndex = path->count; + this->points = Lib_SegmentedToVirtual(path->points); + Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, this->points); + this->dyna.actor.speed = cue->rot.z * (45.0f / 0x2000); + this->points++; + this->curPointIndex = 1; + } + + this->cueId = cue->id; + } else { + if (cue->id != 1) { + Vec3f posTarget; + f32 distRemaining; + + Math_Vec3s_ToVec3f(&posTarget, this->points); + distRemaining = Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &posTarget, this->dyna.actor.speed); + if ((this->curPointIndex < this->maxPointIndex) && (distRemaining < this->dyna.actor.speed)) { + this->points++; + this->curPointIndex++; } } - if (actionIndex->action != 3) { - func_80B9B124(this); - if (actionIndex->action == 2) { + + if (cue->id != 3) { + ObjBoat_SetRotations(this); + if (cue->id == 2) { func_800B9010(&this->dyna.actor, NA_SE_EV_PIRATE_SHIP - SFX_FLAG); } } else { + // Tumble in the air this->dyna.actor.shape.rot.y += 0x7D0; this->dyna.actor.shape.rot.x += 0x3E8; this->dyna.actor.shape.rot.z += 0x1F4; diff --git a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h index 795c50689..bfc7c7c2b 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h @@ -10,14 +10,17 @@ struct ObjBoat; typedef struct ObjBoat { /* 0x000 */ DynaPolyActor dyna; - /* 0x15C */ u8 unk_15C; - /* 0x15D */ s8 unk_15D; - /* 0x15E */ u8 unk_15E; - /* 0x15F */ u8 unk_15F; - /* 0x160 */ s16 unk_160; + /* 0x15C */ u8 curPointIndex; + /* 0x15D */ s8 direction; // To follow the path + /* 0x15E */ u8 lastPointIndex; // max point if direction is negative, first point if forwards + /* 0x15F */ union { + u8 timer; + u8 cueId; + }; + /* 0x160 */ s16 angle; // Angle used to set rotations /* 0x162 */ UNK_TYPE1 pad_162; - /* 0x163 */ u8 unk_163; - /* 0x164 */ Vec3s* unk_164; + /* 0x163 */ u8 maxPointIndex; // point at the other end from 0 + /* 0x164 */ Vec3s* points; } ObjBoat; // size = 0x168 #endif // Z_OBJ_BOAT_H 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 cfecbdad0..e5e53000a 100644 --- a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c +++ b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c @@ -1,13 +1,4 @@ -/* - * File: z_obj_boyo.c - * Overlay: ovl_Obj_Boyo - * Description: Unused Bumper - */ - #include "z_obj_boyo.h" -#include "overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h" -#include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "objects/object_boyo/object_boyo.h" #define FLAGS (ACTOR_FLAG_10) @@ -18,7 +9,8 @@ void ObjBoyo_Destroy(Actor* thisx, PlayState* play2); void ObjBoyo_Update(Actor* thisx, PlayState* play2); void ObjBoyo_Draw(Actor* thisx, PlayState* play); -ActorInit Obj_Boyo_InitVars = { +/* +const ActorInit Obj_Boyo_InitVars = { ACTOR_OBJ_BOYO, ACTORCAT_PROP, FLAGS, @@ -27,158 +19,22 @@ ActorInit Obj_Boyo_InitVars = { (ActorFunc)ObjBoyo_Init, (ActorFunc)ObjBoyo_Destroy, (ActorFunc)ObjBoyo_Update, - (ActorFunc)ObjBoyo_Draw, + (ActorFunc)ObjBoyo_Draw }; +*/ -static ColliderCylinderInit sCylinderInit = { - { - COLTYPE_NONE, - AT_NONE, - AC_ON | AC_HARD | AC_TYPE_PLAYER, - OC1_ON | OC1_TYPE_ALL, - OC2_TYPE_2, - COLSHAPE_CYLINDER, - }, - { - ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x01CBFFBE, 0x00, 0x00 }, - TOUCH_NONE | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_ON, - }, - { 60, 140, 0, { 0, 0, 0 } }, -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/ObjBoyo_Init.s") -static InitChainEntry sInitChain[] = { - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 300, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), -}; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/ObjBoyo_Destroy.s") -void ObjBoyo_Init(Actor* thisx, PlayState* play) { - ObjBoyo* this = THIS; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/func_809A5DC0.s") - Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitCylinder(play, &this->collider); - Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - Collider_UpdateCylinder(&this->actor, &this->collider); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->unk_190 = Lib_SegmentedToVirtual(object_boyo_Matanimheader_000E88); -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/func_809A5DE0.s") -void ObjBoyo_Destroy(Actor* thisx, PlayState* play2) { - PlayState* play = play2; - ObjBoyo* this = THIS; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/func_809A5E14.s") - Collider_DestroyCylinder(play, &this->collider); -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/func_809A5E24.s") -void ObjBoyo_UpdatePlayerBumpValues(ObjBoyo* this, Player* target) { - target->unk_B80 = 30.0f; - target->unk_B84 = this->actor.yawTowardsPlayer; -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/ObjBoyo_Update.s") -void ObjBoyo_UpdatePirateBumpValues(ObjBoyo* src, EnKaizoku* target) { - target->unk_2F0 = 30.0f; - target->unk_2F4 = Actor_YawBetweenActors(&src->actor, &target->picto.actor); -} - -void ObjBoyo_UpdateBombBumpValues(ObjBoyo* src, EnBom* target) { - target->timer = 0; -} - -BumperCollideInfo sBumperCollideInfo[] = { - { ACTOR_PLAYER, (BumperCollideActorFunc)ObjBoyo_UpdatePlayerBumpValues }, - { ACTOR_EN_KAIZOKU, (BumperCollideActorFunc)ObjBoyo_UpdatePirateBumpValues }, - { ACTOR_EN_BOM, (BumperCollideActorFunc)ObjBoyo_UpdateBombBumpValues }, -}; - -Actor* ObjBoyo_GetCollidedActor(ObjBoyo* this, PlayState* play, s32* num) { - Actor* collideActor; - BumperCollideInfo* collideInfo; - s32 i; - - if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { - *num = 0; - return &GET_PLAYER(play)->actor; - } - - if (this->collider.base.ocFlags1 & OC2_UNK1) { - for (collideActor = this->collider.base.oc, collideInfo = &sBumperCollideInfo[1], i = 1; i < 3; - collideInfo++, i++) { - if (collideInfo->id == collideActor->id) { - *num = i; - return collideActor; - } - } - } - - return NULL; -} - -void ObjBoyo_Update(Actor* thisx, PlayState* play2) { - PlayState* play = play2; - ObjBoyo* this = THIS; - Actor* target; - s32 num; - - target = ObjBoyo_GetCollidedActor(this, play, &num); - - if (target != NULL) { - sBumperCollideInfo[num].actorCollideFunc(this, (void*)target); - this->unk_194 = 100; - this->unk_196 = 3; - this->unk_198 = 0.01f; - this->unk_19C = this->unk_1A0 = 0.03f; - this->unk_1A4 = 0x3F40; - this->unk_1A6 = 2000; - this->unk_1A8 = 0; - this->unk_1AA = 0x2DF7; - this->unk_1AC = 600; - } - - if (this->unk_194 > 0) { - this->unk_194 -= this->unk_196; - this->unk_1AA += this->unk_1AC; - this->unk_1A8 += this->unk_1AA; - - this->actor.scale.x = this->actor.scale.z = - (Math_CosS(this->unk_1A8 + this->unk_1A4) * this->unk_194 * this->unk_19C * this->unk_198) + 0.1f; - this->actor.scale.y = - (Math_CosS(this->unk_1A8 + this->unk_1A6) * this->unk_194 * this->unk_1A0 * this->unk_198) + 0.1f; - } else { - Actor_SetScale(&this->actor, 0.1f); - - if (this->collider.base.acFlags & AC_HIT) { - this->unk_194 = 30; - this->unk_196 = 2; - this->unk_198 = 0.033333335f; - this->unk_19C = 0.012f; - this->unk_1A0 = 0.006f; - this->unk_1A4 = 0x3F40; - this->unk_1A6 = 2000; - this->unk_1A8 = 0; - this->unk_1AA = 15000; - this->unk_1AC = 1600; - } - } - - this->collider.base.acFlags &= ~AC_HIT; - this->collider.base.ocFlags1 &= ~OC1_HIT; - this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; - - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - - if (thisx->xzDistToPlayer < 2000.0f) { - CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); - } -} - -void ObjBoyo_Draw(Actor* thisx, PlayState* play) { - ObjBoyo* this = THIS; - - AnimatedMat_Draw(play, this->unk_190); - Gfx_DrawDListOpa(play, object_boyo_DL_000300); -} +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/ObjBoyo_Draw.s") diff --git a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.h b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.h index dcff2a893..feb95dcd1 100644 --- a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.h +++ b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.h @@ -5,27 +5,9 @@ struct ObjBoyo; -typedef void (*BumperCollideActorFunc)(struct ObjBoyo*, void*); - -typedef struct { - /* 0x0 */ s16 id; - /* 0x4 */ BumperCollideActorFunc actorCollideFunc; -} BumperCollideInfo; // size = 0x8 - typedef struct ObjBoyo { /* 0x000 */ Actor actor; - /* 0x144 */ ColliderCylinder collider; - /* 0x190 */ AnimatedMaterial* unk_190; - /* 0x194 */ s16 unk_194; - /* 0x196 */ s16 unk_196; - /* 0x198 */ f32 unk_198; - /* 0x19C */ f32 unk_19C; - /* 0x1A0 */ f32 unk_1A0; - /* 0x1A4 */ s16 unk_1A4; - /* 0x1A6 */ s16 unk_1A6; - /* 0x1A8 */ s16 unk_1A8; - /* 0x1AA */ s16 unk_1AA; - /* 0x1AC */ s16 unk_1AC; + /* 0x144 */ char unk_144[0x6C]; } ObjBoyo; // size = 0x1B0 #endif // Z_OBJ_BOYO_H diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index 27f5cc273..facd8de41 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -92,7 +92,7 @@ void ObjChan_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sObjChanCylinderInit); - SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_FillCutscenesList(&this->actor, this->csIdList, ARRAY_COUNT(this->csIdList)); switch (OBJCHAN_SUBTYPE(&this->actor)) { case OBJCHAN_SUBTYPE_CHANDELIER: this->rotation = this->actor.shape.rot.y; @@ -117,16 +117,16 @@ u32 func_80BB9A1C(ObjChan* this, f32 arg1) { f32 sp20; sp20 = Math_SinS(this->unk1D4) * this->unk1D0; - temp_f6 = (Math_CosS(this->unk1D4) * 0.03834952f * this->unk1D0) + arg1; + temp_f6 = (Math_CosS(this->unk1D4) * (400 * M_PI / 0x8000) * this->unk1D0) + arg1; if (temp_f6 != 0.0f) { - this->unk1D4 = RADF_TO_BINANG(func_80086B30(sp20 * 0.03834952f, temp_f6)); + this->unk1D4 = RAD_TO_BINANG(func_80086B30(sp20 * (400 * M_PI / 0x8000), temp_f6)); } else if (sp20 >= 0.0f) { this->unk1D4 = 0x4000; } else { this->unk1D4 = -0x4000; } if (Math_CosS(this->unk1D4) != 0.0f) { - this->unk1D0 = (temp_f6 / (Math_CosS(this->unk1D4) * 0.03834952f)); + this->unk1D0 = (temp_f6 / (Math_CosS(this->unk1D4) * (400 * M_PI / 0x8000))); } else { this->unk1D0 = sp20; } @@ -150,7 +150,7 @@ void ObjChan_CalculatePotPosition(Vec3f* childPosOut, Vec3s* childRotOut, Vec3f* childRotOut->y += childAngle; } -//! @TODO: Possibly takes actor and recasts +//! TODO: Possibly takes actor and recasts void ObjChan_InitChandelier(ObjChan* this2, PlayState* play) { ObjChan* this = this2; s32 i; @@ -175,14 +175,15 @@ void ObjChan_InitChandelier(ObjChan* this2, PlayState* play) { for (i = 0; i < 5; i++) { ObjChan_CalculatePotPosition(&childPos, &childRot, &this->actor.world.pos, &this->actor.shape.rot, - (s32)(i * 360.0f / 5.0f * (65536.0f / 360.0f)) + this->rotation); - temp_v0 = (ObjChan*)Actor_SpawnAsChildAndCutscene( - &play->actorCtx, play, ACTOR_OBJ_CHAN, childPos.x, childPos.y, childPos.z, childRot.x, childRot.y, - childRot.z, (this->actor.params & 0xFFF) | 0x1000, this->actor.cutscene, this->actor.unk20, &this->actor); + (s32)DEG_TO_BINANG_ALT3(i * 360.0f / 5.0f) + this->rotation); + temp_v0 = (ObjChan*)Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_OBJ_CHAN, childPos.x, childPos.y, + childPos.z, childRot.x, childRot.y, childRot.z, + (this->actor.params & 0xFFF) | 0x1000, this->actor.csId, + this->actor.halfDaysBits, &this->actor); if (temp_v0 != NULL) { this->pots[i] = temp_v0; temp_v0->myPotIndex = i; - temp_v0->actor.cutscene = this->actor.cutscene; + temp_v0->actor.csId = this->actor.csId; } else { Actor_Kill(&this->actor); } @@ -209,7 +210,7 @@ void ObjChan_InitChandelier(ObjChan* this2, PlayState* play) { this->actionFunc = ObjChan_ChandelierAction; } -//! @TODO: More descriptive name than Action? +//! TODO: More descriptive name than Action? void ObjChan_ChandelierAction(ObjChan* this2, PlayState* play) { ObjChan* this = this2; ObjChan* temp; @@ -231,13 +232,13 @@ void ObjChan_ChandelierAction(ObjChan* this2, PlayState* play) { } this->actor.shape.rot.z = (Math_SinS(this->unk1D4) * this->unk1D0); if ((this->stateFlags & OBJCHAN_STATE_START_CUTSCENE) && - SubS_StartActorCutscene(&this->actor, this->cutscenes[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + SubS_StartCutscene(&this->actor, this->csIdList[0], CS_ID_NONE, SUBS_CUTSCENE_WITH_PLAYER)) { this->stateFlags |= OBJCHAN_STATE_CUTSCENE; this->stateFlags &= ~OBJCHAN_STATE_START_CUTSCENE; } if ((this->stateFlags & OBJCHAN_STATE_CUTSCENE) && this->rotationSpeed == OBJCHAN_ROTATION_SPEED) { this->stateFlags &= ~OBJCHAN_STATE_CUTSCENE; - ActorCutscene_Stop(this->cutscenes[0]); + CutsceneManager_Stop(this->csIdList[0]); } Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); @@ -250,7 +251,7 @@ void ObjChan_ChandelierAction(ObjChan* this2, PlayState* play) { temp = this->pots[i]; if (temp != NULL) { ObjChan_CalculatePotPosition(&sp60, &sp58, &this->actor.world.pos, &this->actor.shape.rot, - (s32)(i * 360.0f / 5.0f * (65536.0f / 360.0f)) + this->rotation); + (s32)DEG_TO_BINANG_ALT3(i * 360.0f / 5.0f) + this->rotation); Math_Vec3f_Copy(&temp->actor.world.pos, &sp60); Math_Vec3s_Copy(&temp->actor.shape.rot, &this->actor.shape.rot); temp->actor.shape.rot.y = this->rotation; @@ -314,7 +315,7 @@ void ObjChan_PotAction(ObjChan* this, PlayState* play) { SET_WEEKEVENTREG(WEEKEVENTREG_37_10); Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_EN_MM, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x8000, - this->actor.cutscene, this->actor.unk20, NULL); + this->actor.csId, this->actor.halfDaysBits, NULL); } } Actor_Kill(&this->actor); diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h index f08f18adf..0e6fbca86 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h @@ -54,7 +54,7 @@ typedef struct ObjChan { /* 0x1D8 */ f32 flameSize; /* 0x1DC */ s16 rotationSpeed; // Main object only. Slowly ramps up under some circumstances. In other circumstances it's immediately set to maximum speed. /* 0x1DE */ s16 rotation; // Increases as the chandelier spins. Don't know why they didn't use the actor's rotation variable. - /* 0x1E0 */ s16 cutscenes[2]; + /* 0x1E0 */ s16 csIdList[2]; } ObjChan; // size = 0x1E4 #endif // Z_OBJ_CHAN_H diff --git a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c index 0c888a4ac..79007175d 100644 --- a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c +++ b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c @@ -49,7 +49,7 @@ void func_809B1550(Actor* thisx, PlayState* play) { thisx->world.pos.x = (Math_SinS(thisx->shape.rot.y) * sp18) + thisx->home.pos.x; thisx->world.pos.z = (Math_CosS(thisx->shape.rot.y) * sp18) + thisx->home.pos.z; } else { - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } } @@ -174,7 +174,7 @@ void ObjChikuwa_Update(Actor* thisx, PlayState* play) { func_809B17D0(play, this, &temp->unk_00); temp_fs0 = Math3D_Vec3fDistSq(&temp->unk_00, &GET_PLAYER(play)->actor.world.pos); if (temp_fs0 < SQ(240.0f)) { - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); if (temp_fs0 < SQ(120.0f)) { quakeVerticalMag = 4; } else { @@ -182,8 +182,8 @@ void ObjChikuwa_Update(Actor* thisx, PlayState* play) { } Quake_SetSpeed(quakeIndex, 17232); - Quake_SetQuakeValues(quakeIndex, quakeVerticalMag, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 7); + Quake_SetPerturbations(quakeIndex, quakeVerticalMag, 0, 0, 0); + Quake_SetDuration(quakeIndex, 7); } } } diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c index b03344708..412bade05 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -303,10 +303,10 @@ void func_8098D99C(ObjComb* this, PlayState* play) { temp_v0->parent = &this->actor; if (this->actionFunc == func_8098DC60) { temp_v0->velocity.y = 8.0f; - temp_v0->speedXZ = 2.0f; + temp_v0->speed = 2.0f; } else { temp_v0->velocity.y = 10.0f; - temp_v0->speedXZ = 2.0f; + temp_v0->speed = 2.0f; } this->unk_1B6 = 1; play_sound(NA_SE_SY_TRE_BOX_APPEAR); @@ -406,7 +406,7 @@ void func_8098DC60(ObjComb* this, PlayState* play) { } else { if (this->unk_1B8 >= 0) { if (this->unk_1B8 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALGOLD_ROLL); if (Rand_ZeroOne() < 0.1f) { this->unk_1B8 = Rand_S16Offset(40, 80); } else { @@ -431,15 +431,15 @@ void func_8098DE58(ObjComb* this) { this->unk_1B4 = 100; this->actor.terminalVelocity = -20.0f; this->actor.gravity = -1.5f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_8098DEA0; } void func_8098DEA0(ObjComb* this, PlayState* play) { this->unk_1B4--; - if ((this->actor.bgCheckFlags & 1) || (this->unk_1B4 <= 0)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->unk_1B4 <= 0)) { func_8098DA74(this, play); - if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 30.0f)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER) && (this->actor.depthInWater > 30.0f)) { func_8098D47C(this, play); } else { func_8098D19C(this, play); @@ -447,11 +447,11 @@ void func_8098DEA0(ObjComb* this, PlayState* play) { SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_HONEYCOMB_BROKEN); func_8098E098(this); } else { - if (this->actor.bgCheckFlags & 0x40) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { func_8098D6E0(this, play); } - if (this->actor.bgCheckFlags & 0x20) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { this->actor.gravity = -0.5f; this->actor.velocity.y *= 0.8f; this->unk_1AE >>= 1; @@ -475,7 +475,7 @@ void func_8098DEA0(ObjComb* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); this->actor.shape.rot.x += this->unk_1AE; this->actor.shape.rot.y += this->unk_1B0; - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 12.0f, 0.0f, 5); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } @@ -493,8 +493,8 @@ void func_8098E0B8(ObjComb* this, PlayState* play) { return; } - if ((this->unk_1B4 == 10) && (this->unk_1B6 != 0) && (this->unk_1B5 == 2) && (this->actor.cutscene >= 0)) { - if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + if ((this->unk_1B4 == 10) && (this->unk_1B6 != 0) && (this->unk_1B5 == 2) && (this->actor.csId >= 0)) { + if (CutsceneManager_GetCurrentCsId() == this->actor.csId) { func_800B7298(play, &this->actor, PLAYER_CSMODE_4); } } @@ -518,17 +518,17 @@ void ObjComb_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); if (this->actor.update == NULL) { - if ((this->unk_1B5 == 2) && (func_800F2138(this->actor.cutscene) == -1)) { - ActorCutscene_Stop(this->actor.cutscene); + if ((this->unk_1B5 == 2) && (CutsceneManager_GetCutsceneScriptIndex(this->actor.csId) == -1)) { + CutsceneManager_Stop(this->actor.csId); this->unk_1B5 = 0; } } else { if (this->unk_1B5 != 0) { Actor_SetFocus(&this->actor, 0.0f); if (this->unk_1B5 == 1) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); - if (this->actor.cutscene >= 0) { + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); + if (this->actor.csId >= 0) { func_800B7298(play, &this->actor, PLAYER_CSMODE_1); } @@ -539,7 +539,7 @@ void ObjComb_Update(Actor* thisx, PlayState* play) { this->unk_1B5 = 2; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } } diff --git a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c index 9daa20bad..a33bf2a43 100644 --- a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c +++ b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c @@ -54,7 +54,7 @@ void ObjDanpeilift_Init(Actor* thisx, PlayState* play) { this->dyna.actor.world.rot.x = 0; this->dyna.actor.shape.rot.z = 0; this->dyna.actor.world.rot.z = 0; - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_obj_danpeilift_Colheader_000BA0); if (this->dyna.bgId == BG_ACTOR_MAX) { Actor_Kill(&this->dyna.actor); @@ -107,15 +107,15 @@ void ObjDanpeilift_Move(ObjDanpeilift* this, PlayState* play) { step = this->speed * 0.16f; } - Math_StepToF(&thisx->speedXZ, target, step); - if ((thisx->speedXZ + 0.05f) < speed) { - Math_Vec3f_Scale(&thisx->velocity, thisx->speedXZ / speed); + Math_StepToF(&thisx->speed, target, step); + if ((thisx->speed + 0.05f) < speed) { + Math_Vec3f_Scale(&thisx->velocity, thisx->speed / speed); thisx->world.pos.x += thisx->velocity.x; thisx->world.pos.y += thisx->velocity.y; thisx->world.pos.z += thisx->velocity.z; } else { this->curPoint += this->direction; - thisx->speedXZ *= 0.4f; + thisx->speed *= 0.4f; isTeleporting = OBJDANPEILIFT_SHOULD_TELEPORT(thisx); isPosUpdated = true; if (((this->curPoint >= this->endPoint) && (this->direction > 0)) || @@ -130,7 +130,7 @@ void ObjDanpeilift_Move(ObjDanpeilift* this, PlayState* play) { if ((this->points[0].x != endPoint->x) || (this->points[0].y != endPoint->y) || (this->points[0].z != endPoint->z)) { this->actionFunc = ObjDanpeilift_Teleport; - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); isPosUpdated = false; } } @@ -143,9 +143,9 @@ void ObjDanpeilift_Move(ObjDanpeilift* this, PlayState* play) { } void ObjDanpeilift_Teleport(ObjDanpeilift* this, PlayState* play) { - if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (!DynaPolyActor_IsPlayerOnTop(&this->dyna)) { ObjDanpeilift_UpdatePosition(this, this->curPoint); - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->actionFunc = ObjDanpeilift_Move; } } @@ -154,7 +154,7 @@ void ObjDanpeilift_Wait(ObjDanpeilift* this, PlayState* play) { this->waitTimer--; if (this->waitTimer <= 0) { this->actionFunc = ObjDanpeilift_Move; - this->dyna.actor.speedXZ = 0.0f; + this->dyna.actor.speed = 0.0f; } } @@ -167,23 +167,23 @@ void ObjDanpeilift_Update(Actor* thisx, PlayState* play) { if (this->cutsceneTimer > 0) { this->cutsceneTimer--; if (this->cutsceneTimer == 0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); } } - if (OBJDANPEILIFT_SHOULD_REACT_TO_WEIGHT(thisx)) { + if (OBJDANPEILIFT_REACT_TO_PLAYER_ON_TOP(thisx)) { f32 target; - this->isWeightOnPrev = this->isWeightOn; - this->isWeightOn = DynaPolyActor_IsInRidingMovingState(&this->dyna) ? 1 : 0; - if ((this->isWeightOn != this->isWeightOnPrev) && (this->maxHeight < 1.0f)) { + this->isPlayerOnTopPrev = this->isPlayerOnTop; + this->isPlayerOnTop = DynaPolyActor_IsPlayerOnTop(&this->dyna) ? true : false; + if ((this->isPlayerOnTop != this->isPlayerOnTopPrev) && (this->maxHeight < 1.0f)) { this->cycle = -0x8000; this->maxHeight = 6.0f; } this->cycle += 0xCE4; Math_StepToF(&this->maxHeight, 0.0f, 0.12f); - step = this->isWeightOn ? Math_CosS(fabsf(this->cycleSpeed) * 2048.0f) + 0.02f - : Math_SinS(fabsf(this->cycleSpeed) * 2048.0f) + 0.02f; - target = this->isWeightOn ? -8.0f : 0.0f; + step = this->isPlayerOnTop ? Math_CosS(fabsf(this->cycleSpeed) * 2048.0f) + 0.02f + : Math_SinS(fabsf(this->cycleSpeed) * 2048.0f) + 0.02f; + target = this->isPlayerOnTop ? -8.0f : 0.0f; Math_StepToF(&this->cycleSpeed, target, step); this->dyna.actor.shape.yOffset = ((Math_SinS(this->cycle) * this->maxHeight) + this->cycleSpeed) * 10.0f; } diff --git a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.h b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.h index 392d5d4ca..9c0d023c7 100644 --- a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.h +++ b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.h @@ -13,7 +13,7 @@ typedef void (*ObjDanpeiliftActionFunc)(struct ObjDanpeilift*, PlayState*); #define OBJDANPEILIFT_GET_PATH(thisx) ((thisx)->params & 0x7F) #define OBJDANPEILIFT_SHOULD_TELEPORT(thisx) (((thisx)->params >> 0xC) & 1) #define OBJDANPEILIFT_GET_SPEED(thisx) ((thisx)->home.rot.z * 0.1f) -#define OBJDANPEILIFT_SHOULD_REACT_TO_WEIGHT(thisx) (((thisx)->params >> 0xE) & 1) +#define OBJDANPEILIFT_REACT_TO_PLAYER_ON_TOP(thisx) (((thisx)->params >> 0xE) & 1) typedef struct ObjDanpeilift { /* 0x000 */ DynaPolyActor dyna; @@ -23,8 +23,8 @@ typedef struct ObjDanpeilift { /* 0x168 */ s32 curPoint; /* 0x16C */ s32 direction; /* 0x170 */ Vec3s* points; - /* 0x174 */ s32 isWeightOn; - /* 0x178 */ s32 isWeightOnPrev; + /* 0x174 */ s32 isPlayerOnTop; + /* 0x178 */ s32 isPlayerOnTopPrev; /* 0x17C */ f32 cycleSpeed; /* 0x180 */ f32 maxHeight; /* 0x184 */ s16 cycle; diff --git a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c index 060e793ca..ee76dd9d4 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c @@ -1,7 +1,7 @@ /* * File: z_obj_demo.c * Overlay: ovl_Obj_Demo - * Description: + * Description: Cutscene triggers when player is in range */ #include "z_obj_demo.h" @@ -60,8 +60,8 @@ void ObjDemo_Init(Actor* thisx, PlayState* play) { } void func_80983634(PlayState* play) { - if ((play->sceneId == SCENE_CASTLE) && (Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) == NA_BGM_IKANA_CASTLE)) { - Audio_QueueSeqCmd(0x100100FF); + if ((play->sceneId == SCENE_CASTLE) && (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_IKANA_CASTLE)) { + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); } } @@ -69,37 +69,37 @@ void func_80983678(ObjDemo* this, PlayState* play) { func_80983634(play); if ((this->actor.xzDistToPlayer < this->xzRange) && (fabsf(this->actor.playerHeightRel) < this->yRange)) { if (this->unk_148 == 1) { - ActorCutscene_Stop(0x7D); + CutsceneManager_Stop(CS_ID_GLOBAL_DOOR); } - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); this->actionFunc = func_80983704; } } void func_80983704(ObjDemo* this, PlayState* play) { - if ((this->unk_148 == 1) && (ActorCutscene_GetCurrentIndex() == 0x7D)) { - ActorCutscene_Stop(0x7D); - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + if ((this->unk_148 == 1) && (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_DOOR)) { + CutsceneManager_Stop(CS_ID_GLOBAL_DOOR); + CutsceneManager_Queue(this->actor.csId); } else { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + if (CutsceneManager_IsNext(this->actor.csId)) { if (this->unk_148 == 1) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); + CutsceneManager_Start(this->actor.csId, &this->actor); func_800E0348(play->cameraPtrs[CAM_ID_MAIN]); } else { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); } if (play->sceneId == SCENE_CASTLE) { - Audio_QueueSeqCmd(NA_BGM_IKANA_CASTLE | 0x8000); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_IKANA_CASTLE | SEQ_FLAG_ASYNC); } - this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); - if (this->actor.cutscene == -1) { + this->actor.csId = CutsceneManager_GetAdditionalCsId(this->actor.csId); + if (this->actor.csId == CS_ID_NONE) { if (this->actor.params != 0xFF) { Flags_SetSwitch(play, this->actor.params); } Actor_Kill(&this->actor); } } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); func_80983634(play); } } diff --git a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c index fce6d99ec..0dba9a21f 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c @@ -436,12 +436,12 @@ void func_80B13940(ObjDhouse* this, PlayState* play2) { if (Flags_GetSwitch(play, OBJDHOUSE_GET_7F(&this->dyna.actor))) { sp20 = true; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_EXPLSION_LONG); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_EXPLSION_LONG); } if (sp20) { func_80B12A88(&this->dyna.actor); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = func_80B13C08; this->dyna.actor.flags |= ACTOR_FLAG_20; func_80B139D8(this); @@ -458,20 +458,20 @@ void func_80B139F4(ObjDhouse* this, PlayState* play) { s16 quakeIndex; if (this->unk_1370 == 117) { - quakeIndex = Quake_Add(camera, QUAKE_TYPE_3); + quakeIndex = Quake_Request(camera, QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 20000); - Quake_SetQuakeValues(quakeIndex, 8, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 17); + Quake_SetPerturbations(quakeIndex, 8, 0, 0, 0); + Quake_SetDuration(quakeIndex, 17); } else if (this->unk_1370 == 105) { - quakeIndex = Quake_Add(camera, QUAKE_TYPE_3); + quakeIndex = Quake_Request(camera, QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 20000); - Quake_SetQuakeValues(quakeIndex, 7, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 20); + Quake_SetPerturbations(quakeIndex, 7, 0, 0, 0); + Quake_SetDuration(quakeIndex, 20); } else if (this->unk_1370 == 90) { - quakeIndex = Quake_Add(camera, QUAKE_TYPE_3); + quakeIndex = Quake_Request(camera, QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 20000); - Quake_SetQuakeValues(quakeIndex, 5, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 62); + Quake_SetPerturbations(quakeIndex, 5, 0, 0, 0); + Quake_SetDuration(quakeIndex, 62); } this->unk_1370--; diff --git a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c index 9b6c81266..f3c271c69 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c @@ -274,21 +274,21 @@ void ObjDora_UpdateCollision(ObjDora* this, PlayState* play) { case DORA_DMGEFF_STRONG: case DORA_DMGEFF_LIGHT: if (this->actor.colChkInfo.damageEffect == DORA_DMGEFF_LIGHT) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DORA_S); + Actor_PlaySfx(&this->actor, NA_SE_EV_DORA_S); this->lastGongHitType = DORA_HIT_LIGHT; } else { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DORA_L); + Actor_PlaySfx(&this->actor, NA_SE_EV_DORA_L); this->lastGongHitType = DORA_HIT_STRONG; } - func_800BC848(&this->actor, play, 5, 10); + Actor_RequestQuakeAndRumble(&this->actor, play, 5, 10); ObjDora_SetupMoveGong(this); if ((ObjDora_IsHalfHour(time) == true) && (this->rupeeDropTimer == 0)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); itemDrop = Item_DropCollectible(play, &this->actor.world.pos, ITEM00_RUPEE_BLUE); itemDrop->world.rot.y = this->actor.world.rot.y; - itemDrop->world.rot.y += (s32)(Rand_Centered() * 90.0f * (0x10000 / 360.0f)); + itemDrop->world.rot.y += (s32)DEG_TO_BINANG_ALT3(Rand_Centered() * 90.0f); itemDrop->velocity.y = 5.0f; itemDrop->gravity = -1.0f; this->rupeeDropTimer = 40; @@ -332,20 +332,20 @@ void ObjDora_Draw(Actor* thisx, PlayState* play) { Matrix_Push(); Matrix_RotateXS(this->gongRotation.x, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); + gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); Matrix_Translate(position.x, position.y + gongForceX, position.z + gongForceX, MTXMODE_APPLY); Matrix_RotateXS(this->gongRotation.z - this->gongRotation.x, MTXMODE_APPLY); Matrix_Translate(-position.x, -position.y, -position.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); + gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); Matrix_Pop(); } else { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); + gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); } CLOSE_DISPS(play->state.gfxCtx); 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 01675c173..f1dc17968 100644 --- a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c +++ b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c @@ -65,6 +65,6 @@ void ObjDowsing_Update(Actor* thisx, PlayState* play) { ObjDowsing* this = THIS; if (!ObjDowsing_CheckValidSpawn(this, play)) { - func_800B8C50(thisx, play); + Actor_SetClosestSecretDistance(thisx, play); } } diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c index f0eaaf25a..7d729495a 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c @@ -358,10 +358,10 @@ void func_80A671E0(ObjDriftice* this, PlayState* play) { phi_f12 = this->unk_23C * 0.13f; } - Math_StepToF(&this->dyna.actor.speedXZ, phi_f0, phi_f12); + Math_StepToF(&this->dyna.actor.speed, phi_f0, phi_f12); - if ((this->dyna.actor.speedXZ + 0.05f) < sp3C) { - Math_Vec3f_Scale(&this->dyna.actor.velocity, this->dyna.actor.speedXZ / sp3C); + if ((this->dyna.actor.speed + 0.05f) < sp3C) { + Math_Vec3f_Scale(&this->dyna.actor.velocity, this->dyna.actor.speed / sp3C); this->dyna.actor.world.pos.x += this->dyna.actor.velocity.x; this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; this->dyna.actor.world.pos.z += this->dyna.actor.velocity.z; @@ -371,7 +371,7 @@ void func_80A671E0(ObjDriftice* this, PlayState* play) { if (1) {} - this->dyna.actor.speedXZ *= 0.5f; + this->dyna.actor.speed *= 0.5f; if (((this->unk_164 >= this->unk_160) && (this->unk_168 > 0)) || ((this->unk_164 <= 0) && (this->unk_168 < 0))) { if (!OBJDRIFTICE_GET_1000(&this->dyna.actor)) { @@ -389,7 +389,7 @@ void func_80A671E0(ObjDriftice* this, PlayState* play) { if ((this->unk_16C[0].x != points->x) || (this->unk_16C[0].y != points->y) || (this->unk_16C[0].z != points->z)) { func_80A6743C(this); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); sp30 = false; } } @@ -408,7 +408,7 @@ void func_80A6743C(ObjDriftice* this) { void func_80A67450(ObjDriftice* this, PlayState* play) { if (this->unk_248 < 0) { func_80A66570(this, this->unk_164); - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); func_80A671CC(this); } } @@ -421,7 +421,7 @@ void func_80A674A8(ObjDriftice* this) { void func_80A674C4(ObjDriftice* this, PlayState* play) { this->unk_24C--; if (this->unk_24C <= 0) { - this->dyna.actor.speedXZ = 0.0f; + this->dyna.actor.speed = 0.0f; func_80A671CC(this); } } @@ -429,7 +429,7 @@ void func_80A674C4(ObjDriftice* this, PlayState* play) { void ObjDriftice_Update(Actor* thisx, PlayState* play) { ObjDriftice* this = THIS; - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { if (this->unk_248 < 0) { this->unk_248 = 1; } else { diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h index 21e0f8f27..19627c3df 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h @@ -56,6 +56,4 @@ typedef struct ObjDriftice { /* 0x24C */ s32 unk_24C; } ObjDriftice; // size = 0x250 -extern ActorInit Obj_Driftice_InitVars; - #endif // Z_OBJ_DRIFTICE_H 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 ceedeb6c4..ac9184923 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c @@ -154,12 +154,12 @@ void ObjEtcetera_Idle(ObjEtcetera* this, PlayState* play) { this->oscillationTimer = minOscillationTimer; } } else { - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { if (!(this->burrowFlag & 1)) { // Player is walking onto the Deku Flower, or falling on it from a height this->oscillationTimer = 10; ObjEtcetera_StartRustleAnimation(this); - } else if ((player->actor.speedXZ > 0.1f) || + } else if ((player->actor.speed > 0.1f) || ((player->unk_ABC < 0.0f) && !(player->stateFlags3 & PLAYER_STATE3_100))) { // Player is walking on top of the Deku Flower, is at the very start of burrowing, or is at the very // start of launching @@ -187,7 +187,7 @@ void ObjEtcetera_Idle(ObjEtcetera* this, PlayState* play) { } void ObjEtcetera_PlayRustleAnimation(ObjEtcetera* this, PlayState* play) { - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { this->burrowFlag |= 1; } else { this->burrowFlag &= ~1; @@ -209,11 +209,11 @@ void ObjEtcetera_PlayRustleAnimation(ObjEtcetera* this, PlayState* play) { void ObjEtcetera_DoBounceOscillation(ObjEtcetera* this, PlayState* play) { // 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. + // it's more likely they used dyna given that DynaPolyActor_IsPlayerOnTop takes a DynaPolyActor. DynaPolyActor* dyna = &this->dyna; f32 scaleTemp; - if (DynaPolyActor_IsInRidingMovingState(dyna)) { + if (DynaPolyActor_IsPlayerOnTop(dyna)) { this->burrowFlag |= 1; } else { this->burrowFlag &= ~1; @@ -260,7 +260,7 @@ void ObjEtcetera_Setup(ObjEtcetera* this, PlayState* play) { if (Object_IsLoaded(&play->objectCtx, this->objIndex)) { this->dyna.actor.objBankIndex = this->objIndex; Actor_SetObjectDependency(play, &this->dyna.actor); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); thisCollisionHeader = collisionHeaders[type]; if (thisCollisionHeader != NULL) { CollisionHeader_GetVirtual(thisCollisionHeader, &colHeader); diff --git a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c index a4c4e21d2..f9f86501d 100644 --- a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c +++ b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c @@ -77,7 +77,7 @@ static InitChainEntry sInitChain[] = { }; void func_80A4CA90(ObjFireshield* this) { - if (this->actor.cutscene >= 0) { + if (this->actor.csId >= 0) { this->actionFunc = func_80A4CABC; } else { this->actionFunc = func_80A4CC54; @@ -87,17 +87,17 @@ void func_80A4CA90(ObjFireshield* this) { void func_80A4CABC(ObjFireshield* this) { s32 pad; - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + if (CutsceneManager_IsNext(this->actor.csId)) { s32 sp18 = OBJFIRESHIELD_GET_7F(&this->actor); s32 temp_a0 = (sp18 & ~0x1F) >> 5; - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); this->actionFunc = func_80A4CB7C; this->unk_194 = 20; D_80A4D884[temp_a0] |= 1 << (sp18 & 0x1F); D_80A4D894[temp_a0] |= 1 << (sp18 & 0x1F); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -113,7 +113,7 @@ void func_80A4CB7C(ObjFireshield* this) { return; } - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); this->actionFunc = func_80A4CD28; D_80A4D894[(sp18 & ~0x1F) >> 5] &= ~(1 << (sp18 & 0x1F)); } 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 49e8ac934..cc818c883 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -4,6 +4,7 @@ * Description: Breakable Pot With Grass */ +#include "prevent_bss_reordering.h" #include "z_obj_flowerpot.h" #include "objects/object_flowerpot/object_flowerpot.h" @@ -383,7 +384,8 @@ void func_80A1C554(ObjFlowerpot* this) { } void func_80A1C5E8(ObjFlowerpot* this, PlayState* play) { - Actor_UpdateBgCheckInfo(play, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(play, &this->actor, 18.0f, 15.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40); } void func_80A1C62C(ObjFlowerpot* this, PlayState* play) { @@ -454,8 +456,8 @@ void func_80A1C838(ObjFlowerpot* this, PlayState* play) { //! @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)) { + Player_PlaySfx((Player*)&this->actor, NA_SE_PL_PULL_UP_POT); + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER) && (this->actor.depthInWater > 19.0f)) { if (!(this->unk_1EA & 2)) { func_80A1B914(this, play); func_80A1C328(this, play); @@ -490,7 +492,7 @@ void func_80A1C838(ObjFlowerpot* this, PlayState* play) { if (this->unk_1EA & 1) { Actor_MoveWithGravity(&this->actor); func_80A1C5E8(this, play); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (this->actor.colChkInfo.mass == MASS_IMMOVABLE) { if (DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId) == NULL) { this->actor.flags &= ~ACTOR_FLAG_10; @@ -518,7 +520,7 @@ void func_80A1C838(ObjFlowerpot* this, PlayState* play) { s16 temp_v0_3 = this->actor.yawTowardsPlayer - GET_PLAYER(play)->actor.world.rot.y; if (ABS_ALT(temp_v0_3) >= 0x5556) { - Actor_PickUp(&this->actor, play, GI_NONE, 36.0f, 30.0f); + Actor_OfferGetItem(&this->actor, play, GI_NONE, 36.0f, 30.0f); } } } @@ -537,9 +539,9 @@ void func_80A1CC0C(ObjFlowerpot* this, PlayState* play) { if (Actor_HasNoParent(&this->actor, play)) { this->actor.room = play->roomCtx.curRoom.num; - if (fabsf(this->actor.speedXZ) < 0.1f) { + if (fabsf(this->actor.speed) < 0.1f) { func_80A1C818(this); - func_800B8E58(GET_PLAYER(play), NA_SE_PL_PUT_DOWN_POT); + Player_PlaySfx(GET_PLAYER(play), NA_SE_PL_PUT_DOWN_POT); this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; } else { Actor_MoveWithGravity(&this->actor); @@ -601,7 +603,8 @@ void func_80A1CEF4(ObjFlowerpot* this2, PlayState* play) { func_80A1C62C(this, play); - if ((this->actor.bgCheckFlags & (0x8 | 0x2 | 0x1)) || sp28 || (this->unk_1E8 <= 0)) { + if ((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_WALL)) || sp28 || + (this->unk_1E8 <= 0)) { if (!(this->unk_1EA & 2)) { func_80A1B914(this, play); func_80A1C0FC(this, play); @@ -614,7 +617,7 @@ void func_80A1CEF4(ObjFlowerpot* this2, PlayState* play) { return; } - if (this->actor.bgCheckFlags & 0x40) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { if (!(this->unk_1EA & 2)) { func_80A1B914(this, play); func_80A1C328(this, play); @@ -653,7 +656,7 @@ void ObjFlowerpot_Update(Actor* thisx, PlayState* play2) { func_80A1C554(this); - if ((D_80A1D830 != play->gameplayFrames) && (play->roomCtx.curRoom.unk3 == 0)) { + if ((D_80A1D830 != play->gameplayFrames) && (play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_0)) { func_80A1B3D0(); D_80A1D830 = play->gameplayFrames; } @@ -678,7 +681,7 @@ void ObjFlowerpot_Draw(Actor* thisx, PlayState* play) { } if (!(this->unk_1EA & 2)) { - if ((play->roomCtx.curRoom.unk3 == 0) && (this->actionFunc == func_80A1C838)) { + if ((play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_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]); 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 0581706d5..73aa848a2 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -61,10 +61,10 @@ void func_80B3C2B0(ObjGhaka* this) { void func_80B3C2C4(ObjGhaka* this, PlayState* play) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_20_20)) { Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_BG_GORON_OYU, 0.0f, 25.0f, 261.0f, 0, 0, 0, 0, - this->dyna.actor.cutscene, this->dyna.actor.unk20, 0); + this->dyna.actor.csId, this->dyna.actor.halfDaysBits, 0); } else { - Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_BG_GORON_OYU, 0.0f, 25.0f, 261.0f, 0, 0, 0, 1, -1, - this->dyna.actor.unk20, 0); + Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, ACTOR_BG_GORON_OYU, 0.0f, 25.0f, 261.0f, 0, 0, 0, 1, + CS_ID_NONE, this->dyna.actor.halfDaysBits, 0); } } @@ -154,10 +154,10 @@ void ObjGhaka_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, D_80B3C96C); Actor_SetScale(&this->dyna.actor, 0.1f); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); CollisionHeader_GetVirtual(&object_ghaka_Colheader_003CD0, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); - Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x4); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); if (this->dyna.actor.floorPoly == 0) { Actor_Kill(&this->dyna.actor); } diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index 3414aaafa..b1924c63b 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -4,11 +4,9 @@ * Description: "Master" instance of grass for unit spawned by Obj_Grass_Unit */ -#include "prevent_bss_reordering.h" #include "z_obj_grass.h" #include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h" #include "objects/gameplay_keep/gameplay_keep.h" -#include "prevent_bss_reordering.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -73,13 +71,13 @@ s32 func_809A9110(PlayState* play, Vec3f* arg1) { SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, arg1, &sp20, &sp2C); - if ((play->unk_187F0.z * -130.13191f) < sp20.z) { + if ((play->projectionMtxFDiagonal.z * -130.13191f) < sp20.z) { if (sp2C < 1.0f) { sp2C = 1.0f; } - if (((fabsf(sp20.x) - (130.13191f * play->unk_187F0.x)) < sp2C) && - ((fabsf(sp20.y) - (130.13191f * play->unk_187F0.y)) < sp2C)) { + if (((fabsf(sp20.x) - (130.13191f * play->projectionMtxFDiagonal.x)) < sp2C) && + ((fabsf(sp20.y) - (130.13191f * play->projectionMtxFDiagonal.y)) < sp2C)) { return true; } } 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 9872fb0b7..e46c5da44 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 @@ -103,7 +103,9 @@ void func_809AAF18(ObjGrassCarry* this) { } void func_809AAF58(ObjGrassCarry* this, PlayState* play) { - Actor_UpdateBgCheckInfo(play, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + Actor_UpdateBgCheckInfo(play, &this->actor, 7.5f, 35.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40 | + UPDBGCHECKINFO_FLAG_80); } void func_809AAF9C(Vec3f* arg0, s16 arg1, PlayState* play) { @@ -227,11 +229,11 @@ void func_809AB4A8(ObjGrassCarry* this, PlayState* play) { Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_194->unk_00); this->actor.shape.rot.y = this->actor.world.rot.y = this->unk_194->unk_0C; this->unk_198 = this2->unk_194->unk_0E; - this->actor.xzDistToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &player->actor); + this->actor.xzDistToPlayer = Actor_WorldDistXZToActor(&this->actor, &player->actor); this->actor.playerHeightRel = Actor_HeightDiff(&this->actor, &player->actor); this->actor.xyzDistToPlayerSq = SQ(this->actor.xzDistToPlayer) + SQ(this->actor.playerHeightRel); - this->actor.yawTowardsPlayer = Actor_YawBetweenActors(&this->actor, &player->actor); - Actor_LiftActor(&this->actor, play); + this->actor.yawTowardsPlayer = Actor_WorldYawTowardActor(&this->actor, &player->actor); + Actor_OfferCarry(&this->actor, play); } } @@ -246,8 +248,8 @@ void func_809AB610(ObjGrassCarry* this, PlayState* play) { if (Actor_HasNoParent(&this->actor, play)) { func_809AB6FC(this); - 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; + this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speed; + this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speed; this->actor.gravity = -0.1f; this->actor.terminalVelocity = -17.0f; func_809AAF18(this); @@ -283,7 +285,8 @@ void func_809AB77C(ObjGrassCarry* this, PlayState* play) { this->unk_19A--; - if ((this->actor.bgCheckFlags & (1 | 2 | 8)) || temp_v0 || (this->unk_19A <= 0)) { + if ((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_WALL)) || temp_v0 || + (this->unk_19A <= 0)) { func_809AAFE8(&this->actor.world.pos, play); func_809AAF9C(&this->actor.world.pos, this->unk_198, play); @@ -294,14 +297,14 @@ void func_809AB77C(ObjGrassCarry* this, PlayState* play) { this->actor.room = this->unk_190->actor.room; } - if (!(this->actor.bgCheckFlags & 0x20)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); } func_809AB428(this); return; } - if (this->actor.bgCheckFlags & 0x40) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { sp5C.y = this->actor.world.pos.y + this->actor.depthInWater; for (phi_s0 = 0, i = 0; i < 4; i++, phi_s0 += 0x4000) { @@ -326,7 +329,7 @@ void func_809AB77C(ObjGrassCarry* this, PlayState* play) { D_809ABBFC = D_809ABBFC >> 1; D_809ABC08 = D_809ABC08 >> 1; D_809ABC04 = D_809ABC04 >> 1; - this->actor.bgCheckFlags &= ~0x40; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER_TOUCH; SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); } diff --git a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c index 9c38849c9..8b851285a 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c @@ -106,14 +106,14 @@ void ObjHakaisi_Init(Actor* thisx, PlayState* play) { return; } - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); CollisionHeader_GetVirtual(&object_hakaisi_Colheader_002FC4, &sp7C); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp7C); this->unk_19A = 0; this->unk_198 = 0; this->switchFlag = OBJHAKAISI_GET_SWITCHFLAG(thisx); - this->unk_196 = this->dyna.actor.cutscene; + this->csId = this->dyna.actor.csId; if (this->switchFlag == 0xFF) { this->switchFlag = -1; @@ -123,7 +123,7 @@ void ObjHakaisi_Init(Actor* thisx, PlayState* play) { Actor_Kill(&this->dyna.actor); } - Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); if (this->dyna.actor.floorPoly == NULL) { Actor_Kill(&this->dyna.actor); @@ -192,24 +192,24 @@ void func_80B14558(ObjHakaisi* this) { } void func_80B1456C(ObjHakaisi* this, PlayState* play) { - if (this->unk_196 != -1) { - if (ActorCutscene_GetCanPlayNext(this->unk_196)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_196, &this->dyna.actor); + if (this->csId != CS_ID_NONE) { + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->dyna.actor); } else { - ActorCutscene_SetIntentToPlay(this->unk_196); + CutsceneManager_Queue(this->csId); } } if (this->dyna.actor.colChkInfo.health < 30) { func_80B145F4(this); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } } void func_80B145F4(ObjHakaisi* this) { this->unk_19A = 0; - this->dyna.actor.flags |= ACTOR_FLAG_8000000; + this->dyna.actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; this->dyna.actor.flags &= ~ACTOR_FLAG_1; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); this->actionFunc = func_80B14648; } @@ -258,8 +258,8 @@ void func_80B149A8(ObjHakaisi* this) { void func_80B149C0(ObjHakaisi* this, PlayState* play) { if (this->unk_19A < 60) { this->unk_19A++; - } else if ((this->unk_196 != -1) && !ActorCutscene_GetCanPlayNext(this->unk_196)) { - ActorCutscene_Stop(this->unk_196); + } else if ((this->csId != CS_ID_NONE) && !CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Stop(this->csId); } } @@ -281,7 +281,7 @@ void func_80B14B6C(ObjHakaisi* this, PlayState* play, Vec3f vec, s16 arg3) { s16 temp_s1; Vec3f sp6C; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); for (i = 0; i < 5; i++) { temp_s1 = Rand_Next(); @@ -403,7 +403,7 @@ void func_80B15330(ObjHakaisi* this, PlayState* play) { this->dyna.actor.velocity.y += this->dyna.actor.gravity; Actor_UpdatePos(&this->dyna.actor); - if (this->dyna.actor.bgCheckFlags & 2) { + if (this->dyna.actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { func_80B14B6C(this, play, this->dyna.actor.world.pos, 40); func_80B14CF8(play, this->dyna.actor.world.pos, 100, 30, 10); Actor_Kill(&this->dyna.actor); @@ -423,7 +423,7 @@ void func_80B1544C(Actor* thisx, PlayState* play) { this->actionFunc(this, play); - Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } void func_80B154A0(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h index ed5341a82..1454181dd 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h @@ -17,7 +17,7 @@ typedef struct ObjHakaisi { /* 0x184 */ Vec3f unk_184; /* 0x190 */ s32 switchFlag; /* 0x194 */ s16 unk_194; - /* 0x196 */ s16 unk_196; + /* 0x196 */ s16 csId; /* 0x198 */ s16 unk_198; /* 0x19A */ s16 unk_19A; /* 0x19C */ s16 unk_19C; diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c index 752b669cf..aef42693b 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c @@ -165,7 +165,7 @@ void ObjHamishi_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { this->actor.uncullZoneForward += 1000.0f; } diff --git a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c index 1c33af7fe..a2007ad9b 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c @@ -74,7 +74,7 @@ void ObjHariko_BobHead(ObjHariko* this, PlayState* play) { } void ObjHariko_CheckForQuakes(ObjHariko* this) { - if (Quake_NumActiveQuakes() != 0) { + if (Quake_GetNumActiveQuakes() != 0) { ObjHariko_SetupBobHead(this); } } 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 e3972be18..7b0351e78 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c @@ -70,7 +70,7 @@ void ObjHgdoor_Init(Actor* thisx, PlayState* play) { CollisionHeader* header = NULL; Actor_SetScale(&this->dyna.actor, 0.1f); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); if (OBJHGDOOR_IS_RIGHT_DOOR(&this->dyna.actor)) { CollisionHeader_GetVirtual(&object_hgdoor_Colheader_001D10, &header); } else { @@ -79,7 +79,7 @@ void ObjHgdoor_Init(Actor* thisx, PlayState* play) { this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, header); this->rotation = 0; this->timer = 0; - this->cutscene = this->dyna.actor.cutscene; + this->csId = this->dyna.actor.csId; ObjHgdoor_SetupIdle(this); } @@ -94,7 +94,7 @@ void ObjHgdoor_SetupIdle(ObjHgdoor* this) { } void ObjHgdoor_Idle(ObjHgdoor* this, PlayState* play) { - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20) && + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE) && (this->dyna.actor.xzDistToPlayer < 100.0f) && (this->dyna.actor.playerHeightRel < 40.0f) && OBJHGDOOR_IS_RIGHT_DOOR(&this->dyna.actor)) { ObjHgdoor_SetChild(this, play); @@ -108,33 +108,33 @@ void ObjHgdoor_SetupCutscene(ObjHgdoor* this) { } void ObjHgdoor_PlayCutscene(ObjHgdoor* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_Start(this->cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Start(this->csId, &this->dyna.actor); ObjHgdoor_SetupCsAction(this); ObjHgdoor_SetupCsAction((ObjHgdoor*)this->dyna.actor.child); } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->cutscene); + CutsceneManager_Queue(this->csId); } } void ObjHgdoor_SetupCsAction(ObjHgdoor* this) { - this->csAction = 0x63; + this->cueId = 99; this->actionFunc = ObjHgdoor_HandleCsAction; } void ObjHgdoor_HandleCsAction(ObjHgdoor* this, PlayState* play) { - s32 actionIndex; + s32 cueChannel; - if (Cutscene_CheckActorAction(play, 483)) { - actionIndex = Cutscene_GetActorActionIndex(play, 483); - if (this->csAction != play->csCtx.actorActions[actionIndex]->action) { - this->csAction = play->csCtx.actorActions[actionIndex]->action; - switch (play->csCtx.actorActions[actionIndex]->action) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_483)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_483); + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; + switch (play->csCtx.actorCues[cueChannel]->id) { case 1: - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOOD_DOOR_OPEN_SPEEDY); + Actor_PlaySfx(&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; } @@ -149,7 +149,7 @@ void ObjHgdoor_HandleCsAction(ObjHgdoor* this, PlayState* play) { ObjHgdoor_SetupStopCs(this); } } else { - this->csAction = 0x63; + this->cueId = 99; } } @@ -160,8 +160,8 @@ void ObjHgdoor_SetupStopCs(ObjHgdoor* this) { void ObjHgdoor_StopCs(ObjHgdoor* this, PlayState* play) { if (this->timer++ > 80) { - if (!ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_Stop(this->cutscene); + if (!CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Stop(this->csId); } } } diff --git a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.h b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.h index 7172952bb..1411a5e66 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.h +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.h @@ -13,10 +13,10 @@ typedef void (*ObjHgdoorActionFunc)(struct ObjHgdoor*, PlayState*); typedef struct ObjHgdoor { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ ObjHgdoorActionFunc actionFunc; - /* 0x160 */ s16 cutscene; + /* 0x160 */ s16 csId; /* 0x162 */ s16 rotation; /* 0x164 */ s16 timer; - /* 0x166 */ u16 csAction; + /* 0x166 */ u16 cueId; } ObjHgdoor; // size = 0x168 #endif // Z_OBJ_HGDOOR_H 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 ae047f029..ffc3558e6 100644 --- a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c +++ b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c @@ -45,7 +45,7 @@ void ObjHsStump_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); this->isHidden = OBJHSSTUMP_GET_ISHIDDEN(thisx); this->switchFlag = OBJHSSTUMP_GET_SWITCHFLAG(thisx); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_hsstump_Colheader_0011B0); switch (this->isHidden) { case true: @@ -54,10 +54,15 @@ void ObjHsStump_Init(Actor* thisx, PlayState* play) { } else { this->dyna.actor.draw = NULL; Actor_SetScale(&this->dyna.actor, 0.0f); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } + // fallthrough case false: ObjHsStump_SetupIdle(this, play); + break; + + default: + break; } } @@ -89,14 +94,14 @@ void ObjHsStump_Appear(ObjHsStump* this, PlayState* play) { } if (this->framesAppeared <= 10) { if (this->framesAppeared == 0) { + s32 pad; s32 i; - f32 angleDeg; s16 numDirections = 4; Vec3f iceSmokePosOffset; Vec3f iceSmokeVelOffset; - s16 offsetAngle; + s16 iceSmokeAngle; Vec3f iceSmokeVel; - f32 angleBrad; + f32 baseAngle; Vec3f iceSmokePos; iceSmokePosOffset.x = 1.0f; @@ -107,14 +112,13 @@ void ObjHsStump_Appear(ObjHsStump* this, PlayState* play) { iceSmokeVelOffset.y = 0.5f; iceSmokeVelOffset.z = 0.0f; - angleDeg = (360.0f / numDirections); - angleBrad = (s32)(angleDeg * (0x10000 / 360.0f)); + baseAngle = (s32)DEG_TO_BINANG_ALT3(360.0f / numDirections); for (i = 0; i < numDirections; i++) { - offsetAngle = i * angleBrad; - Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.world.pos, offsetAngle, &iceSmokePosOffset, + iceSmokeAngle = i * baseAngle; + Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.world.pos, iceSmokeAngle, &iceSmokePosOffset, &iceSmokePos); - Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, offsetAngle, &iceSmokeVelOffset, &iceSmokeVel); + Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, iceSmokeAngle, &iceSmokeVelOffset, &iceSmokeVel); EffectSsIceSmoke_Spawn(play, &iceSmokePos, &iceSmokeVel, &sIceSmokeAccel, 100); } } @@ -123,9 +127,9 @@ void ObjHsStump_Appear(ObjHsStump* this, PlayState* play) { Math_SmoothStepToF(&this->dyna.actor.scale.x, 18.0f * 0.01f, 1.0f, 0.01f, 0.001f); Actor_SetScale(&this->dyna.actor, this->dyna.actor.scale.x); } - if (this->dyna.actor.scale.x == 18.0f * 0.01f) { + if (this->dyna.actor.scale.x == (18.0f * 0.01f)) { this->isHidden = false; - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); ObjHsStump_SetupIdle(this, play); } this->framesAppeared++; 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 cade13522..692fa8448 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -293,13 +293,13 @@ void func_80A54600(PlayState* play, Vec3f* arg1, f32 arg2, f32 arg3) { } } -void ObjHugebombiwa_AddQuake(ObjHugebombiwa* this, PlayState* play, s32 quakeVerticalMag) { +void ObjHugebombiwa_RequestQuakeAndRumble(ObjHugebombiwa* this, PlayState* play, s32 quakeVerticalMag) { s32 pad[2]; - s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 20000); - Quake_SetQuakeValues(quakeIndex, quakeVerticalMag, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 7); + Quake_SetPerturbations(quakeIndex, quakeVerticalMag, 0, 0, 0); + Quake_SetDuration(quakeIndex, 7); Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150); } @@ -380,7 +380,7 @@ void func_80A54C04(ObjHugebombiwa* this, PlayState* play) { } if (func_80A54A0C(this)) { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); func_80A54CD8(this); return; } @@ -407,8 +407,8 @@ void func_80A54CD8(ObjHugebombiwa* this) { void func_80A54CEC(ObjHugebombiwa* this, PlayState* play) { s32 pad; - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); Flags_SetSwitch(play, ENHUGEBOMBIWA_GET_7F(&this->actor)); if (!(ENHUGEBOMBIWA_GET_100(&this->actor)) && ((play->sceneId == SCENE_17SETUGEN) || (play->sceneId == SCENE_17SETUGEN2))) { @@ -429,7 +429,7 @@ void func_80A54CEC(ObjHugebombiwa* this, PlayState* play) { func_80A55310(this); } } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -516,14 +516,14 @@ void func_80A55064(ObjHugebombiwa* this, PlayState* play) { ptr->unk_24 = 1; func_80A53E60(play, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 9.8f); if ((play->gameplayFrames % 4) == 0) { - ObjHugebombiwa_AddQuake(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); + ObjHugebombiwa_RequestQuakeAndRumble(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); } } } this->unk_4B2--; if ((this->unk_4B0 >= 20) || (this->unk_4B2 <= 0)) { - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); Actor_Kill(&this->actor); } } @@ -612,14 +612,14 @@ void func_80A55564(ObjHugebombiwa* this, PlayState* play) { ptr->unk_24 = 1; func_80A54600(play, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 10.1f); if ((play->gameplayFrames % 4) == 0) { - ObjHugebombiwa_AddQuake(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); + ObjHugebombiwa_RequestQuakeAndRumble(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); } } } this->unk_4B2--; if ((this->unk_4B0 >= 20) || (this->unk_4B2 <= 0)) { - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); Actor_Kill(&this->actor); } } diff --git a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c index a861e9e63..41cdd8369 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c @@ -120,7 +120,7 @@ void func_80B9C5E8(ObjHunsui* this, PlayState* play) { if ((this->dyna.actor.xzDistToPlayer < (45.0f * this->dyna.actor.scale.x * 10.0f)) && (this->dyna.actor.playerHeightRel < -21.0f)) { - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { this->unk_172 &= ~8; this->unk_19C = 0.0f; this->unk_1A0 = 0.0f; @@ -205,7 +205,7 @@ void ObjHunsui_Init(Actor* thisx, PlayState* play) { this->unk_160 = OBJHUNSUI_GET_F000(thisx); this->unk_164 = OBJHUNSUI_GET_F80(thisx); this->unk_168 = OBJHUNSUI_GET_7F(thisx); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); if ((this->unk_160 != OBJHUNSUI_F000_5) && (this->unk_160 != OBJHUNSUI_F000_6)) { DynaPolyActor_LoadMesh(play, &this->dyna, &object_hunsui_Colheader_000C74); @@ -213,7 +213,7 @@ void ObjHunsui_Init(Actor* thisx, PlayState* play) { D_80B9DED0 = Lib_SegmentedToVirtual(object_hunsui_Matanimheader_000BF0); D_80B9DED4 = Lib_SegmentedToVirtual(object_hunsui_Matanimheader_001888); - SubS_FillCutscenesList(&this->dyna.actor, this->unk_170, ARRAY_COUNT(this->unk_170)); + SubS_FillCutscenesList(&this->dyna.actor, this->csIdList, ARRAY_COUNT(this->csIdList)); this->unk_18C = 0; switch (this->unk_160) { @@ -327,7 +327,7 @@ void ObjHunsui_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); if ((this->unk_172 & 0x40) && - SubS_StartActorCutscene(&this->dyna.actor, this->unk_17C, -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + SubS_StartCutscene(&this->dyna.actor, this->csId, CS_ID_NONE, SUBS_CUTSCENE_WITH_PLAYER)) { this->unk_172 &= ~0x40; } @@ -355,7 +355,7 @@ void func_80B9CE64(ObjHunsui* this, PlayState* play) { if (!(this->unk_172 & 1)) { if (sp2C != this->unk_180) { - this->unk_17C = this->unk_170[0]; + this->csId = this->csIdList[0]; this->unk_172 |= 0x40; } } @@ -447,7 +447,7 @@ void func_80B9D120(ObjHunsui* this, PlayState* play) { } if (func_80B9C450(play, this->unk_168, this->unk_164)) { - this->unk_17C = this->unk_170[0]; + this->csId = this->csIdList[0]; this->unk_172 |= 0x40; func_80B9D4D0(this, play); } @@ -560,7 +560,7 @@ void func_80B9D508(ObjHunsui* this, PlayState* play) { } if (!(this->unk_172 & 1) && !func_80B9C450(play, this->unk_168, this->unk_164)) { - this->unk_17C = this->unk_170[0]; + this->csId = this->csIdList[0]; this->unk_172 |= 0x40; func_80B9D0FC(this, play); } @@ -569,7 +569,7 @@ void func_80B9D508(ObjHunsui* this, PlayState* play) { void func_80B9D714(ObjHunsui* this, PlayState* play) { s32 pad; Player* player = GET_PLAYER(play); - s16 cs; + s16 csId; f32 sp28; if ((this->unk_16C != play->roomCtx.curRoom.num) && (this->unk_16C != play->roomCtx.prevRoom.num) && @@ -579,19 +579,19 @@ void func_80B9D714(ObjHunsui* this, PlayState* play) { if (Flags_GetSwitch(play, this->unk_168)) { this->unk_172 &= ~2; this->unk_172 |= 0x10; - cs = this->dyna.actor.cutscene; + csId = this->dyna.actor.csId; if (this->unk_16E == 0) { - if ((cs >= 0) && !ActorCutscene_GetCanPlayNext(cs)) { - ActorCutscene_SetIntentToPlay(cs); - } else if (cs >= 0) { - ActorCutscene_StartAndSetUnkLinkFields(cs, &this->dyna.actor); + if ((csId >= 0) && !CutsceneManager_IsNext(csId)) { + CutsceneManager_Queue(csId); + } else if (csId >= 0) { + CutsceneManager_StartWithPlayerCs(csId, &this->dyna.actor); this->unk_16E = -1; } else { this->unk_16E = 40; } } else if (this->unk_16E < 0) { - if (func_800F22C4(cs, &this->dyna.actor)) { + if (func_800F22C4(csId, &this->dyna.actor) != 0) { this->unk_16E = 40; } } else { @@ -616,7 +616,7 @@ void func_80B9D714(ObjHunsui* this, PlayState* play) { } } - if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (!DynaPolyActor_IsPlayerOnTop(&this->dyna)) { if (this->dyna.actor.xzDistToPlayer < 45.0f) { if ((this->dyna.actor.playerHeightRel < -this->dyna.actor.velocity.y) && (this->dyna.actor.playerHeightRel >= -800.0f)) { diff --git a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h index 14a2eea62..c06abbe7d 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h @@ -31,11 +31,11 @@ typedef struct ObjHunsui { /* 0x16C */ s8 unk_16C; /* 0x16D */ s8 unk_16D; /* 0x16E */ s8 unk_16E; - /* 0x170 */ s16 unk_170[1]; + /* 0x170 */ s16 csIdList[1]; /* 0x172 */ u16 unk_172; /* 0x174 */ f32 unk_174; /* 0x178 */ f32 unk_178; - /* 0x17C */ s16 unk_17C; + /* 0x17C */ s16 csId; /* 0x180 */ s32 unk_180; /* 0x184 */ s16 unk_184; /* 0x186 */ s16 unk_186; diff --git a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c index 13f49fd1f..0ef50dc98 100644 --- a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c +++ b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c @@ -116,7 +116,7 @@ void ObjIcePoly_Init(Actor* thisx, PlayState* play) { thisx->shape.rot.z = -0x500; if (((this->unk_149 != OBJICEPOLY_FF_FF) && Flags_GetSwitch(play, this->unk_149)) || - ((play->sceneId == SCENE_KAJIYA) && CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80))) { + ((play->sceneId == SCENE_KAJIYA) && CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE))) { Actor_Kill(thisx); return; } @@ -200,7 +200,7 @@ void func_80931A38(ObjIcePoly* this, PlayState* play) { (this->colliders2[1].info.acHitInfo->toucher.dmgFlags == 0x800)) || ((this->colliders2[1].base.ac->id == ACTOR_OBJ_AQUA) && (this->colliders2[1].base.ac->params == OBJAQUA_1))))) { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); this->unk_14A = 0; this->actionFunc = func_80931E58; this->actor.focus.rot.y = this->actor.yawTowardsPlayer; @@ -220,7 +220,7 @@ void func_80931A38(ObjIcePoly* this, PlayState* play) { } while (actor != NULL); } } else if ((this->unk_149 != OBJICEPOLY_FF_FF) && Flags_GetSwitch(play, this->unk_149)) { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); this->unk_14A = 1; this->actionFunc = func_80931E58; } else { @@ -265,8 +265,8 @@ void func_80931A38(ObjIcePoly* this, PlayState* play) { } void func_80931E58(ObjIcePoly* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); if (this->unk_14A == 1) { func_80931828(this, play); Actor_Kill(&this->actor); @@ -274,10 +274,10 @@ void func_80931E58(ObjIcePoly* this, PlayState* play) { } this->unk_14A = 40; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_MELT); + Actor_PlaySfx(&this->actor, NA_SE_EV_ICE_MELT); this->actionFunc = func_80931EEC; } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -327,7 +327,7 @@ void func_80931EEC(ObjIcePoly* this, PlayState* play) { this->unk_148 -= 6; if (this->unk_14A == 0) { - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); if (this->unk_149 != OBJICEPOLY_FF_FF) { Flags_SetSwitch(play, this->unk_149); } 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 8c88c35ee..a1e0d64bc 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -206,10 +206,10 @@ s32 func_80A236D4(ObjIceblock* this, Vec3f* arg1) { s32 sp20; sp26 = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, arg1); - sp2C = Math_SinS(sp26) * this->dyna.actor.speedXZ; + sp2C = Math_SinS(sp26) * this->dyna.actor.speed; sp2C = fabsf(sp2C) + 0.01f; - sp28 = Math_CosS(sp26) * this->dyna.actor.speedXZ; + sp28 = Math_CosS(sp26) * this->dyna.actor.speed; sp28 = fabsf(sp28) + 0.01f; sp20 = Math_StepToF(&this->dyna.actor.world.pos.x, arg1->x, sp2C); @@ -629,7 +629,8 @@ s32 func_80A24954(ObjIceblock* this, PlayState* play) { func_80A262BC(this); this->unk_2B0 = 3; } else if (this->unk_1B0 & 4) { - if (func_800C99D4(&play->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) == 5) { + if (SurfaceType_GetFloorType(&play->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) == + FLOOR_TYPE_5) { func_80A25FA0(this); this->unk_2B0 = 2; } else { @@ -642,7 +643,7 @@ s32 func_80A24954(ObjIceblock* this, PlayState* play) { void func_80A24A48(ObjIceblock* this, PlayState* play) { if (!(this->unk_1B0 & 0x10) && !(this->collider.base.ocFlags1 & OC1_HIT)) { - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->unk_1B0 |= 0x10; } } @@ -892,7 +893,7 @@ void func_80A25440(ObjIceblock* this) { } static InitChainEntry sInitChain[] = { - ICHAIN_F32_DIV1000(speedXZ, 16000, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(speed, 16000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1800, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -26000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), @@ -920,9 +921,9 @@ void ObjIceblock_Init(Actor* thisx, PlayState* play) { this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; } - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &gIceBlockCol); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); @@ -970,13 +971,13 @@ void ObjIceBlock_SetupAttemptSpawnCutscene(ObjIceblock* this) { } void ObjIceBlock_AttemptSpawnCutscene(ObjIceblock* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); this->extendedDrawFunc = func_80A26BF8; this->spawnCutsceneTimer = 80; func_80A25824(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -1096,13 +1097,13 @@ void func_80A25BBC(ObjIceblock* this, PlayState* play) { func_80A23690(this); if (func_80A23F90(this, play)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } if (func_80A24954(this, play)) { func_80A2491C(this); if (this->unk_2B0 == 3) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DIVE_INTO_WATER_L); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_DIVE_INTO_WATER_L); } } } @@ -1175,7 +1176,7 @@ void func_80A25E50(ObjIceblock* this, PlayState* play) { func_80A25BA0(this); } else if (sp38) { if (func_80A24118(this, play, 59.9f, &sp28)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } func_80A2541C(this, play); func_80A25CF4(this); @@ -1208,7 +1209,7 @@ void func_80A25FD4(ObjIceblock* this, PlayState* play) { func_80A23370(this, sp2C); func_80A260E8(this); sp30 = false; - func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_7); + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_WAIT); this->unk_1B0 |= 1; } @@ -1254,7 +1255,7 @@ void func_80A26144(ObjIceblock* this, PlayState* play) { if ((this->unk_1B0 & 1) && (isBool || sp28 || (this->dyna.actor.xzDistToPlayer > 400.0f))) { this->unk_1B0 &= ~1; - func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_6); + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_END); } if (isBool) { @@ -1262,7 +1263,7 @@ void func_80A26144(ObjIceblock* this, PlayState* play) { func_80A23B88(this); func_80A25BA0(this); } else if (sp28) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); func_80A23B88(this); func_80A25FA0(this); } else { @@ -1426,7 +1427,7 @@ void ObjIceblock_Update(Actor* thisx, PlayState* play) { } } - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { if (this->unk_1B0 & 0x20) { this->unk_1B0 &= ~0x40; } else { @@ -1453,7 +1454,7 @@ void ObjIceblock_Update(Actor* thisx, PlayState* play) { this->unk_1B0 &= ~0x100; if (this->unk_1B0 & 1) { this->unk_1B0 &= ~1; - func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_6); + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_END); } func_80A266C4(this); } @@ -1462,7 +1463,7 @@ void ObjIceblock_Update(Actor* thisx, PlayState* play) { if (this->spawnCutsceneTimer > 0) { this->spawnCutsceneTimer--; if (this->spawnCutsceneTimer == 0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); } } 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 0f4f83503..276c4a28e 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 @@ -36,7 +36,7 @@ void ObjJgGakki_Init(Actor* thisx, PlayState* play2) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_Init(play, &this->skelAnime, &gGoronElderDrumSkel, NULL, NULL, NULL, 0); - if (((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 7)) && (play->csCtx.currentCsIndex == 0)) { + if (((play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 7)) && (play->csCtx.scriptIndex == 0)) { Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, frameCount, frameCount, ANIMMODE_ONCE, 0.0f); } else if ((play->sceneId == SCENE_17SETUGEN) || (play->sceneId == SCENE_10YUKIYAMANOMURA)) { diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c index 3942fff76..26191e397 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c @@ -211,7 +211,7 @@ void ObjKendoKanban_Init(Actor* thisx, PlayState* play) { Collider_SetTrisVertices(&this->colliderTris, i, &vertices[0], &vertices[1], &vertices[2]); } - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); this->boardFragments = OBJKENDOKANBAN_GET_BOARD_FRAGMENTS(&this->actor); this->actor.gravity = -2.0f; @@ -380,9 +380,9 @@ void ObjKendoKanban_HandlePhysics(ObjKendoKanban* this, PlayState* play) { Matrix_Pop(); } - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { // When on the ground, apply some friction. this->actor.velocity.x *= 0.8f; this->actor.velocity.z *= 0.8f; @@ -401,18 +401,18 @@ void ObjKendoKanban_HandlePhysics(ObjKendoKanban* this, PlayState* play) { return; } - if (this->actor.bgCheckFlags & 2) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { // Upon touching the ground... - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EV_WOODPLATE_BOUND); this->hasNewRootCornerPos = false; this->actor.velocity.y *= 0.5f; - } else if (this->actor.bgCheckFlags & 1) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { // When on the ground... this->numBounces++; this->hasNewRootCornerPos = false; this->actor.velocity.x *= 0.3f; this->actor.velocity.z *= 0.3f; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + Actor_PlaySfx(&this->actor, NA_SE_EV_WOODPLATE_BOUND); // Adjust and (potentially) reverse rotation depending on the current // facing of the board and the direction in which it is rotating. 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 36927b262..e33f62f8b 100644 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c @@ -8,7 +8,7 @@ #include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #include "objects/object_kibako/object_kibako.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_CAN_PRESS_SWITCH) #define THIS ((ObjKibako*)thisx) @@ -121,7 +121,7 @@ void func_80926318(ObjKibako* this, PlayState* play) { if (this->actor.xzDistToPlayer < 100.0f) { angle = this->actor.yawTowardsPlayer - GET_PLAYER(play)->actor.world.rot.y; if (ABS_ALT(angle) > 0x5555) { - Actor_PickUp(&this->actor, play, GI_NONE, 36.0f, 30.0f); + Actor_OfferGetItem(&this->actor, play, GI_NONE, 36.0f, 30.0f); } } } @@ -252,7 +252,8 @@ void func_80926B40(ObjKibako* this) { void func_80926B54(ObjKibako* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(play, &this->actor, 18.0f, 15.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40); if (Object_IsLoaded(&play->objectCtx, this->bankIndex)) { this->actor.draw = ObjKibako_Draw; this->actor.objBankIndex = this->bankIndex; @@ -278,8 +279,8 @@ void ObjKibako_Idle(ObjKibako* this, PlayState* play) { //! @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)) { + Player_PlaySfx((Player*)&this->actor, NA_SE_PL_PULL_UP_WOODBOX); + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER) && (this->actor.depthInWater > 19.0f)) { ObjKibako_WaterBreak(this, play); ObjKibako_SpawnCollectible(this, play); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); @@ -293,7 +294,8 @@ void ObjKibako_Idle(ObjKibako* this, PlayState* play) { } else { Actor_MoveWithGravity(&this->actor); func_809262BC(this); - Actor_UpdateBgCheckInfo(play, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(play, &this->actor, 18.0f, 15.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40); if (!(this->collider.base.ocFlags1 & OC1_TYPE_PLAYER) && (this->actor.xzDistToPlayer > 28.0f)) { this->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; @@ -340,16 +342,17 @@ void ObjKibako_Held(ObjKibako* this, PlayState* play) { func_80926394(this, play); if (Actor_HasNoParent(&this->actor, play)) { this->actor.room = play->roomCtx.curRoom.num; - if (fabsf(this->actor.speedXZ) < 0.1f) { + if (fabsf(this->actor.speed) < 0.1f) { ObjKibako_SetupIdle(this); this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PUT_DOWN_WOODBOX); + Actor_PlaySfx(&this->actor, NA_SE_EV_PUT_DOWN_WOODBOX); } else { Actor_MoveWithGravity(&this->actor); ObjKibako_SetupThrown(this); - this->actor.flags &= ~ACTOR_FLAG_4000000; + this->actor.flags &= ~ACTOR_FLAG_CAN_PRESS_SWITCH; } - Actor_UpdateBgCheckInfo(play, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(play, &this->actor, 18.0f, 15.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40); } else { pos.x = this->actor.world.pos.x; pos.y = this->actor.world.pos.y + 20.0f; @@ -384,13 +387,14 @@ void ObjKibako_Thrown(ObjKibako* this, PlayState* play) { if (this->timer > 0) { this->timer--; } - if ((this->actor.bgCheckFlags & 0xB) || (atHit) || (this->timer <= 0)) { + if ((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_WALL)) || atHit || + (this->timer <= 0)) { ObjKibako_AirBreak(this, play); ObjKibako_SpawnCollectible(this, play); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); Actor_Kill(&this->actor); } else { - if (this->actor.bgCheckFlags & 0x40) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { ObjKibako_WaterBreak(this, play); ObjKibako_SpawnCollectible(this, play); SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); @@ -405,7 +409,8 @@ void ObjKibako_Thrown(ObjKibako* this, PlayState* play) { Math_StepToS(&D_8092738C, D_80927388, 0xA0); this->actor.shape.rot.x = (s16)(this->actor.shape.rot.x + D_80927384); this->actor.shape.rot.y = (s16)(this->actor.shape.rot.y + D_8092738C); - Actor_UpdateBgCheckInfo(play, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(play, &this->actor, 18.0f, 15.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); 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 06af2a8e3..eb14dff6a 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c @@ -128,7 +128,7 @@ void ObjKibako2_SpawnSkulltula(ObjKibako2* this, PlayState* play) { if (skulltula != NULL) { skulltula->parent = &this->dyna.actor; skulltula->velocity.y = 13.0f; - skulltula->speedXZ = 0.0f; + skulltula->speed = 0.0f; } } } @@ -211,7 +211,7 @@ void ObjKibako2_Idle(ObjKibako2* this, PlayState* play) { ObjKibako2_Break(this, play); SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); this->dyna.actor.flags |= ACTOR_FLAG_10; - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = NULL; this->actionFunc = ObjKibako2_Kill; } else if (this->dyna.actor.xzDistToPlayer < 600.0f) { @@ -233,7 +233,7 @@ void ObjKibako2_Update(Actor* thisx, PlayState* play) { if (this->skulltulaNoiseTimer >= 0) { if (this->skulltulaNoiseTimer == 0) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EN_STALGOLD_ROLL); if (Rand_ZeroOne() < 0.1f) { this->skulltulaNoiseTimer = Rand_S16Offset(40, 80); } else { diff --git a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c index 9c9215b24..b52a66d84 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c @@ -52,10 +52,10 @@ void ObjKinoko_Update(Actor* thisx, PlayState* play) { Actor_Kill(thisx); return; } - Actor_PickUp(thisx, play, GI_MAX, 20.0f, 10.0f); - if (Math_SmoothStepToF(&thisx->speedXZ, 0.0f, 0.04f, 2.0f, 0.5f) < 0.5f) { + Actor_OfferGetItem(thisx, play, GI_MAX, 20.0f, 10.0f); + if (Math_SmoothStepToF(&thisx->speed, 0.0f, 0.04f, 2.0f, 0.5f) < 0.5f) { thisx->scale.x = 0.0f; - thisx->speedXZ = 110.0f; + thisx->speed = 110.0f; thisx->velocity.x = 0.2f; } if (Math_SmoothStepToF(&thisx->scale.x, thisx->velocity.x, 0.04f, 0.004f, 0.001f) < @@ -76,7 +76,7 @@ void ObjKinoko_Draw(Actor* thisx, PlayState* play) { func_8012C2DC(play->state.gfxCtx); gfx = POLY_XLU_DISP; - gDPSetPrimColor(&gfx[0], 0, 0, 169, 63, 186, (u8)thisx->speedXZ); + gDPSetPrimColor(&gfx[0], 0, 0, 169, 63, 186, (u8)thisx->speed); gDPSetEnvColor(&gfx[1], 110, 44, 200, 100); gDPSetRenderMode(&gfx[2], G_RM_PASS, G_RM_ZB_CLD_SURF2); gSPMatrix(&gfx[3], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c index 9ceff660e..31e6905ec 100644 --- a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c +++ b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c @@ -41,7 +41,7 @@ void ObjKzsaku_Init(Actor* thisx, PlayState* play) { CollisionHeader* col = NULL; Actor_SetScale(&this->dyna.actor, 1.0f); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); CollisionHeader_GetVirtual(&object_kzsaku_Colheader_001118, &col); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, col); @@ -78,11 +78,11 @@ void func_80C08BBC(ObjKzsaku* this) { } void ObjKzsaku_Rise(ObjKzsaku* this, PlayState* play) { - if (this->dyna.actor.cutscene != -1) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (this->dyna.actor.csId != CS_ID_NONE) { + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } if (this->raisedAmount < 450.0f) { @@ -103,8 +103,8 @@ void func_80C08C84(ObjKzsaku* this) { void func_80C08CB0(ObjKzsaku* this, PlayState* play) { if (this->timer <= 20) { if (this->timer == 20) { - if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + if (CutsceneManager_GetCurrentCsId() == this->dyna.actor.csId) { + CutsceneManager_Stop(this->dyna.actor.csId); } this->timer = 21; } else { 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 aff88964b..88d04b780 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c @@ -100,7 +100,7 @@ void ObjLift_Init(Actor* thisx, PlayState* play) { this->dyna.actor.shape.rot.z = 0; this->unk_178 = this->dyna.actor.home.rot.z; this->dyna.actor.home.rot.z = this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.z; - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); if ((this->unk_178 <= 0) && (Flags_GetSwitch(play, OBJLIFT_GET_7F(&this->dyna.actor)))) { Actor_Kill(&this->dyna.actor); return; @@ -129,15 +129,15 @@ void func_8093D7A0(ObjLift* this, PlayState* play) { s32 pad; s16 quakeIndex; - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { if (this->timer <= 0) { if (OBJLIFT_GET_7(&this->dyna.actor) == 7) { func_8093D9C0(this); } else { - quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_1); + quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_1); Quake_SetSpeed(quakeIndex, 10000); - Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 20); + Quake_SetPerturbations(quakeIndex, 2, 0, 0, 0); + Quake_SetDuration(quakeIndex, 20); func_8093D88C(this); } @@ -194,7 +194,7 @@ void func_8093DA48(ObjLift* this, PlayState* play) { SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 20, NA_SE_EV_BOX_BREAK); if (this->unk_178 > 0) { func_8093DB70(this); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } else { Flags_SetSwitch(play, OBJLIFT_GET_7F(&this->dyna.actor)); Actor_Kill(&this->dyna.actor); @@ -212,7 +212,7 @@ void func_8093DB90(ObjLift* this, PlayState* play) { if (this->timer <= 0) { Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos); this->dyna.actor.world.rot = this->dyna.actor.shape.rot = this->dyna.actor.home.rot; - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); func_8093D760(this); } } 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 16a628fa2..c54378a74 100644 --- a/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c +++ b/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c @@ -134,7 +134,7 @@ void func_80AF3ADC(ObjLightblock* this, PlayState* play) { } if (this->collisionCounter >= 8) { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); func_80AF3B8C(this); } else { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); @@ -146,13 +146,13 @@ void func_80AF3B8C(ObjLightblock* this) { } void func_80AF3BA0(ObjLightblock* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); Flags_SetSwitch(play, LIGHTBLOCK_DESTROYED(&this->dyna.actor)); func_80AF3910(this, play); func_80AF3C18(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -162,12 +162,12 @@ void func_80AF3C18(ObjLightblock* this) { } void func_80AF3C34(ObjLightblock* this, PlayState* play) { - s8 temp_a0; + s8 csId; this->timer--; if (this->timer <= 0) { - temp_a0 = this->dyna.actor.cutscene; - ActorCutscene_Stop(temp_a0); + csId = this->dyna.actor.csId; + CutsceneManager_Stop(csId); Actor_Kill(&this->dyna.actor); return; } @@ -178,7 +178,7 @@ void func_80AF3C34(ObjLightblock* this, PlayState* play) { } else { this->alpha = 0; this->dyna.actor.draw = NULL; - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } } } 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 f2946d536..34479a72a 100644 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -189,13 +189,13 @@ void ObjLightswitch_SetAction(ObjLightswitch* this, ObjLightswitchSetupFunc setu } void ObjLightswitch_PlayCinema(ObjLightswitch* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); ObjLightswitch_UpdateSwitchFlags(this, play, this->switchFlagSetType); this->cutsceneTimer = 50; this->setupFunc(this); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -231,7 +231,7 @@ void ObjLightSwitch_SetupAsleep(ObjLightswitch* this) { void ObjLightSwitch_Asleep(ObjLightswitch* this, PlayState* play) { if (this->colorShiftTimer == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SUN_MARK_FLASH); + Actor_PlaySfx(&this->actor, NA_SE_EV_SUN_MARK_FLASH); } this->colorShiftTimer++; @@ -244,7 +244,7 @@ void ObjLightSwitch_Asleep(ObjLightswitch* this, PlayState* play) { ObjLightSwitch_SetupEnabled(this); } else if (this->colorShiftTimer == 15) { this->faceState = LIGHTSWITCH_FACE_WAKING; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FOOT_SWITCH); + Actor_PlaySfx(&this->actor, NA_SE_EV_FOOT_SWITCH); } } @@ -302,7 +302,7 @@ void ObjLightSwitch_Disabled(ObjLightswitch* this, PlayState* play) { ObjLightswitch_SetupIdle(this); } else if (this->colorShiftTimer == 15) { this->faceState = LIGHTSWITCH_FACE_ASLEEP; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FOOT_SWITCH); + Actor_PlaySfx(&this->actor, NA_SE_EV_FOOT_SWITCH); } } @@ -351,7 +351,7 @@ void ObjLightswitch_Update(Actor* thisx, PlayState* play) { if ((this->cutsceneTimer > 0) && ((s32)this->actionFunc != (s32)ObjLightswitch_PlayCinema)) { this->cutsceneTimer--; if (this->cutsceneTimer == 0) { - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); } } diff --git a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c index 6620c5116..cb957b839 100644 --- a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c +++ b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c @@ -53,9 +53,9 @@ void ObjLupygamelift_Init(Actor* thisx, PlayState* play) { this->dyna.actor.shape.rot.z = 0; this->dyna.actor.world.rot.z = 0; this->timer = 0; - Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawSquare, 0.0f); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_raillift_Colheader_0048D0); this->targetSpeedXZ = thisx->home.rot.z * 0.1f; if (this->targetSpeedXZ < 0.0f) { @@ -131,21 +131,21 @@ void func_80AF04D8(ObjLupygamelift* this, PlayState* play) { void func_80AF0514(ObjLupygamelift* this) { this->actionFunc = func_80AF0530; - this->dyna.actor.speedXZ = this->targetSpeedXZ; + this->dyna.actor.speed = this->targetSpeedXZ; } void func_80AF0530(ObjLupygamelift* this, PlayState* play) { - f32 step; + f32 distRemaining; Vec3f target; target.x = this->points[this->pointIndex].x; target.y = this->points[this->pointIndex].y; target.z = this->points[this->pointIndex].z; - step = Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &target, this->dyna.actor.speedXZ); - if (step > 30.0f) { - Math_SmoothStepToF(&this->dyna.actor.speedXZ, this->targetSpeedXZ, 0.5f, 5.0f, 0.1f); - } else if (step > 0.0f) { - Math_SmoothStepToF(&this->dyna.actor.speedXZ, 5.0f, 0.5f, 5.0f, 1.0f); + distRemaining = Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &target, this->dyna.actor.speed); + if (distRemaining > 30.0f) { + Math_SmoothStepToF(&this->dyna.actor.speed, this->targetSpeedXZ, 0.5f, 5.0f, 0.1f); + } else if (distRemaining > 0.0f) { + Math_SmoothStepToF(&this->dyna.actor.speed, 5.0f, 0.5f, 5.0f, 1.0f); } else { if (this->pointIndex < (this->count - 1)) { this->pointIndex++; diff --git a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c index c46821ac1..da16d938f 100644 --- a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c +++ b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c @@ -95,11 +95,11 @@ void func_8099FB64(Actor* thisx, PlayState* play) { actor->parent = thisx; if (rotCheck) { actor->velocity.y = 10.0f; - actor->speedXZ = 3.0f; + actor->speed = 3.0f; } else { speedXZ = sqrtf((destVec.x * destVec.x) + (destVec.z * destVec.z)); actor->velocity.y = (4 * destVec.y) + 4.0f; - actor->speedXZ = (2 * speedXZ) + 2.0f; + actor->speed = (2 * speedXZ) + 2.0f; } } } @@ -109,11 +109,11 @@ void ObjMakekinsuta_Update(Actor* thisx, PlayState* play) { if (Flags_GetSwitch(play, OBJMAKEKINSUTA_GET_SWITCH_FLAGS(thisx))) { this->actor.update = func_8099FD7C; - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } else { if (this->unk144 >= 0) { if (this->unk144 == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALGOLD_ROLL); if (Rand_ZeroOne() < 0.1f) { this->unk144 = Rand_S16Offset(0x28, 0x50); } else { @@ -127,15 +127,15 @@ void ObjMakekinsuta_Update(Actor* thisx, PlayState* play) { } void func_8099FD7C(Actor* thisx, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(thisx->cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(thisx->cutscene, thisx); - if (thisx->cutscene >= 0) { + if (CutsceneManager_IsNext(thisx->csId)) { + CutsceneManager_StartWithPlayerCs(thisx->csId, thisx); + if (thisx->csId >= 0) { func_800B7298(play, thisx, PLAYER_CSMODE_4); } func_8099FB64(thisx, play); thisx->update = Actor_Noop; thisx->flags &= ~ACTOR_FLAG_10; } else { - ActorCutscene_SetIntentToPlay(thisx->cutscene); + CutsceneManager_Queue(thisx->csId); } } 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 18c36f87e..e1ee3cee5 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 @@ -117,7 +117,7 @@ void func_80C06768(ObjMoonStone* this, PlayState* play) { this->actor.draw = NULL; func_80C0685C(this); } else if (this->actor.xzDistToPlayer < 25.0f) { - Actor_PickUp(&this->actor, play, GI_MOON_TEAR, 100.0f, 30.0f); + Actor_OfferGetItem(&this->actor, play, GI_MOON_TEAR, 100.0f, 30.0f); } } } 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 e2750e639..b0ac87b4e 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 @@ -40,7 +40,7 @@ ActorInit Obj_Mu_Pict_InitVars = { void ObjMuPict_Init(Actor* thisx, PlayState* play) { ObjMuPict* this = THIS; - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE)) { Actor_Kill(&this->actor); } @@ -64,14 +64,14 @@ void func_80C06B70(ObjMuPict* this, PlayState* play) { s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - if (this->actor.cutscene < 0) { + if (this->actor.csId < 0) { func_80C06DC8(this, play); func_80C06CC4(this); } else { - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); func_80C06DC8(this, play); func_80C06C54(this); } @@ -85,11 +85,11 @@ void func_80C06C54(ObjMuPict* this) { } void func_80C06C68(ObjMuPict* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_Start(this->actor.csId, &this->actor); func_80C06CC4(this); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -113,8 +113,8 @@ void func_80C06CD8(ObjMuPict* this, PlayState* play) { case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { func_80C06B5C(this); - if (this->actor.cutscene >= 0) { - ActorCutscene_Stop(this->actor.cutscene); + if (this->actor.csId >= 0) { + CutsceneManager_Stop(this->actor.csId); } } break; diff --git a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c index 815c15af8..95c43a4bf 100644 --- a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c +++ b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c @@ -139,8 +139,8 @@ void ObjMure_SpawnActors0(Actor* thisx, PlayState* play) { ObjMure_GetSpawnPos(&pos, &this->actor.world.pos, this->ptn, i); this->children[i] = Actor_SpawnAsChildAndCutscene( &play->actorCtx, play, sSpawnActorIds[this->type], pos.x, pos.y, pos.z, this->actor.world.rot.x, - this->actor.world.rot.y, this->actor.world.rot.z, sSpawnParams[this->type], this->actor.cutscene, - this->actor.unk20, NULL); + this->actor.world.rot.y, this->actor.world.rot.z, sSpawnParams[this->type], this->actor.csId, + this->actor.halfDaysBits, NULL); if (this->children[i] != NULL) { if (this->type == 0x90) { ((ObjMureChild*)this->children[i])->unk_197 = 1; @@ -152,8 +152,8 @@ void ObjMure_SpawnActors0(Actor* thisx, PlayState* play) { ObjMure_GetSpawnPos(&pos, &this->actor.world.pos, this->ptn, i); this->children[i] = Actor_SpawnAsChildAndCutscene( &play->actorCtx, play, sSpawnActorIds[this->type], pos.x, pos.y, pos.z, this->actor.world.rot.x, - this->actor.world.rot.y, this->actor.world.rot.z, sSpawnParams[this->type], this->actor.cutscene, - this->actor.unk20, NULL); + this->actor.world.rot.y, this->actor.world.rot.z, sSpawnParams[this->type], this->actor.csId, + this->actor.halfDaysBits, NULL); if (this->children[i] != NULL) { this->children[i]->room = this->actor.room; } @@ -174,8 +174,8 @@ void ObjMure_SpawnActors1(ObjMure* this, PlayState* play2) { this->children[i] = Actor_SpawnAsChildAndCutscene( &play2->actorCtx, play, sSpawnActorIds[this->type], spawnPos.x, spawnPos.y, spawnPos.z, actor->world.rot.x, actor->world.rot.y, actor->world.rot.z, - (this->type == OBJMURE_TYPE_BUTTERFLY && i == 0) ? 1 : sSpawnParams[this->type], this->actor.cutscene, - this->actor.unk20, NULL); + (this->type == OBJMURE_TYPE_BUTTERFLY && i == 0) ? 1 : sSpawnParams[this->type], this->actor.csId, + this->actor.halfDaysBits, NULL); if (this->children[i] != NULL) { this->childrenStates[i] = OBJMURE_CHILD_STATE_0; this->children[i]->room = actor->room; diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c index 933ea06d2..d5dfed84d 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -4,6 +4,7 @@ * Description: Sakon's Hideout Objects (Sun's Mask, doors, etc) */ +#include "prevent_bss_reordering.h" #include "z_obj_nozoki.h" #include "objects/object_secom_obj/object_secom_obj.h" @@ -69,7 +70,7 @@ void ObjNozoki_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); this->dyna.actor.shape.rot.x = 0; this->dyna.actor.shape.rot.z = 0; - this->unk_15F = this->dyna.actor.cutscene; + this->csId = this->dyna.actor.csId; if (play->sceneId == SCENE_AYASHIISHOP) { this->unk_15C = 4; @@ -107,7 +108,7 @@ void func_80BA2514(ObjNozoki* this, PlayState* play) { if (this->unk_15C == 0) { Actor_SetObjectDependency(play, &this->dyna.actor); DynaPolyActor_LoadMesh(play, &this->dyna, &object_secom_obj_Colheader_0001C0); - if (ActorCutscene_GetAdditionalCutscene(this->unk_15F) >= 0) { + if (CutsceneManager_GetAdditionalCsId(this->csId) >= 0) { this->dyna.actor.params |= OBJNOZOKI_400; } ObjNozoki_SetupAction(this, func_80BA27C4); @@ -129,16 +130,16 @@ void func_80BA2514(ObjNozoki* this, PlayState* play) { } s32 func_80BA26A8(ObjNozoki* this) { - if (this->unk_15F < 0) { + if (this->csId < 0) { return true; } - if (ActorCutscene_GetCanPlayNext(this->unk_15F)) { - ActorCutscene_StartAndSetUnkLinkFields(this->unk_15F, &this->dyna.actor); + if (CutsceneManager_IsNext(this->csId)) { + CutsceneManager_StartWithPlayerCs(this->csId, &this->dyna.actor); return true; } - ActorCutscene_SetIntentToPlay(this->unk_15F); + CutsceneManager_Queue(this->csId); return false; } @@ -185,7 +186,7 @@ void func_80BA27C4(ObjNozoki* this, PlayState* play) { this->unk_15E = 25; play_sound(NA_SE_SY_SECOM_WARNING); } else { - this->unk_15E = ActorCutscene_GetLength(this->unk_15F); + this->unk_15E = CutsceneManager_GetLength(this->csId); if (this->unk_15E < 0) { this->unk_15E = 50; } @@ -199,7 +200,7 @@ void func_80BA27C4(ObjNozoki* this, PlayState* play) { void func_80BA28DC(ObjNozoki* this, PlayState* play) { if (this->unk_15E != 0) { if (DECR(this->unk_15E) == 0) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); } return; } @@ -213,25 +214,25 @@ void func_80BA28DC(ObjNozoki* this, PlayState* play) { return; } } else if (Flags_GetSwitch(play, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { - s32 cs = this->dyna.actor.cutscene; + s32 csId = this->dyna.actor.csId; - if (cs == this->unk_15F) { + if (csId == this->csId) { if (OBJNOZOKI_GET_400(&this->dyna.actor)) { Vec3f sp28; Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &sp28, &GET_PLAYER(play)->actor.world.pos); if (sp28.z < -20.0f) { - this->unk_15F = ActorCutscene_GetAdditionalCutscene(this->unk_15F); + this->csId = CutsceneManager_GetAdditionalCsId(this->csId); } } } else if (D_80BA36B4 == 0) { if (func_80BA26A8(this)) { D_80BA36B4 = 1; } - } else if (ActorCutscene_GetCurrentIndex() != this->unk_15F) { - this->unk_15F = cs; + } else if (CutsceneManager_GetCurrentCsId() != this->csId) { + this->csId = csId; this->dyna.actor.params &= ~OBJNOZOKI_400; - Audio_QueueSeqCmd(0x881A); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_ENEMY | 0x800 | SEQ_FLAG_ASYNC); } return; } @@ -239,7 +240,7 @@ void func_80BA28DC(ObjNozoki* this, PlayState* play) { ObjNozoki_SetupAction(this, func_80BA2AB4); this->dyna.actor.velocity.y = 0.0f; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); } void func_80BA2AB4(ObjNozoki* this, PlayState* play) { @@ -275,13 +276,13 @@ void func_80BA2BA4(ObjNozoki* this, PlayState* play) { s32 func_80BA2C28(ObjNozoki* this) { s32 i; - s16 cs = this->unk_15F; + s16 csId = this->csId; for (i = 0; i < 3; i++) { - if (ActorCutscene_GetCurrentIndex() == cs) { + if (CutsceneManager_GetCurrentCsId() == csId) { return i; } - cs = ActorCutscene_GetAdditionalCutscene(cs); + csId = CutsceneManager_GetAdditionalCsId(csId); } return -1; @@ -314,17 +315,17 @@ void func_80BA2C94(ObjNozoki* this, PlayState* play) { Flags_UnsetSwitch(play, this->dyna.actor.world.rot.x); } - Math_StepToF(&this->dyna.actor.speedXZ, D_80BA34E4[this->unk_15D], 0.1f); + Math_StepToF(&this->dyna.actor.speed, D_80BA34E4[this->unk_15D], 0.1f); if ((play->actorCtx.flags & ACTORCTX_FLAG_6) || (play->actorCtx.flags & ACTORCTX_FLAG_5)) { temp_f0 = 0.5f; } else { - temp_f0 = this->dyna.actor.speedXZ; + temp_f0 = this->dyna.actor.speed; } sp34 = Math_Vec3f_StepToXZ(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos, temp_f0); - D_80BA36B8 += this->dyna.actor.speedXZ; + D_80BA36B8 += this->dyna.actor.speed; if (play->actorCtx.flags & ACTORCTX_FLAG_6) { if (sp34 <= 5.0f) { @@ -355,14 +356,14 @@ void func_80BA2C94(ObjNozoki* this, PlayState* play) { } } - this->dyna.actor.velocity.x += this->dyna.actor.speedXZ * 0.66f; + this->dyna.actor.velocity.x += this->dyna.actor.speed * 0.66f; if (this->dyna.actor.velocity.x >= 0x10000) { this->dyna.actor.velocity.x -= 0x10000; } play->roomCtx.unk7A[0] = this->dyna.actor.velocity.x; - func_8019FAD8(&gSfxDefaultPos, NA_SE_EV_SECOM_CONVEYOR - SFX_FLAG, this->dyna.actor.speedXZ); + func_8019FAD8(&gSfxDefaultPos, NA_SE_EV_SECOM_CONVEYOR - SFX_FLAG, this->dyna.actor.speed); } void func_80BA3044(ObjNozoki* this, PlayState* play) { @@ -393,10 +394,10 @@ void func_80BA311C(ObjNozoki* this, PlayState* play) { } else if (this->unk_15D == 1) { if (D_80BA36B8 > 40.0f) { this->unk_15D = 2; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_PL_SIT_ON_HORSE); + Actor_PlaySfx(&this->dyna.actor, NA_SE_PL_SIT_ON_HORSE); } else if (this->unk_15E != 0) { if (DECR(this->unk_15E) == 0) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CONVEYOR_SHUTTER_OPEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_CONVEYOR_SHUTTER_OPEN); } } else { Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 50.0f, 4.0f); diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h index 4c4b74916..8bfc9818e 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h @@ -20,7 +20,7 @@ typedef struct ObjNozoki { /* 0x15C */ u8 unk_15C; /* 0x15D */ u8 unk_15D; /* 0x15E */ s8 unk_15E; - /* 0x15F */ s8 unk_15F; + /* 0x15F */ s8 csId; /* 0x160 */ ObjNozokiActionFunc actionFunc; } ObjNozoki; // size = 0x164 diff --git a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c index 3a25ef402..eab144cbd 100644 --- a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c +++ b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c @@ -62,7 +62,7 @@ void ObjOcarinalift_Init(Actor* thisx, PlayState* play) { this->dyna.actor.world.rot.x = 0; this->dyna.actor.shape.rot.z = 0; this->dyna.actor.world.rot.z = 0; - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &object_raillift_Colheader_0048D0); this->unk160 = thisx->home.rot.z * 0.1f; if (this->unk160 < 0.01f) { @@ -99,7 +99,7 @@ void func_80AC96A4(ObjOcarinalift* this, PlayState* play) { void func_80AC96B4(ObjOcarinalift* this) { this->actionFunc = func_80AC96D0; - this->dyna.actor.speedXZ = 0.0f; + this->dyna.actor.speed = 0.0f; } void func_80AC96D0(ObjOcarinalift* this, PlayState* play) { @@ -125,9 +125,9 @@ void func_80AC96D0(ObjOcarinalift* this, PlayState* play) { phi_fa0 = this->unk160 * 0.16f; } - Math_StepToF(&thisx->speedXZ, phi_fv0, phi_fa0); - if ((thisx->speedXZ + 0.05f) < magnitude) { - Math_Vec3f_Scale(&thisx->velocity, thisx->speedXZ / magnitude); + Math_StepToF(&thisx->speed, phi_fv0, phi_fa0); + if ((thisx->speed + 0.05f) < magnitude) { + Math_Vec3f_Scale(&thisx->velocity, thisx->speed / magnitude); thisx->world.pos.x += thisx->velocity.x; thisx->world.pos.y += thisx->velocity.y; thisx->world.pos.z += thisx->velocity.z; @@ -135,7 +135,7 @@ void func_80AC96D0(ObjOcarinalift* this, PlayState* play) { paramsC = OBJOCARINALIFT_GET_C(thisx); sp34 = true; this->unk168 += this->unk16C; - thisx->speedXZ *= 0.4f; + thisx->speed *= 0.4f; if (((this->unk168 >= this->unk164) && (this->unk16C > 0)) || ((this->unk168 <= 0) && (this->unk16C < 0))) { if (paramsC == OBJOCARINALIFT_PARAMSC_0) { this->unk16C = -this->unk16C; @@ -153,7 +153,7 @@ void func_80AC96D0(ObjOcarinalift* this, PlayState* play) { if (((this->unk170->x != temp_v1_2->x) || (this->unk170->y != temp_v1_2->y)) || (this->unk170->z != temp_v1_2->z)) { func_80AC99C0(this); - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); sp34 = false; } else if ((paramsC == OBJOCARINALIFT_PARAMSC_1) && (this->unk168 == OBJOCARINALIFT_GET_1F(thisx))) { func_80AC9AB8(this); @@ -173,9 +173,9 @@ void func_80AC99C0(ObjOcarinalift* this) { } void func_80AC99D4(ObjOcarinalift* this, PlayState* play) { - if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (!DynaPolyActor_IsPlayerOnTop(&this->dyna)) { func_80AC94C0(this, this->unk168); - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); if ((OBJOCARINALIFT_GET_C(&this->dyna.actor) == OBJOCARINALIFT_PARAMSC_1) && (this->unk168 == OBJOCARINALIFT_GET_1F(&this->dyna.actor))) { func_80AC9AB8(this); @@ -197,7 +197,7 @@ void func_80AC9A7C(ObjOcarinalift* this, PlayState* play) { } void func_80AC9AB8(ObjOcarinalift* this) { - this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000); + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_2000000 | ACTOR_FLAG_CANT_LOCK_ON); this->actionFunc = func_80AC9AE0; } @@ -205,7 +205,7 @@ void func_80AC9AE0(ObjOcarinalift* this, PlayState* play) { if (func_800B8718(&this->dyna.actor, &play->state)) { func_80152434(play, 1); func_80AC9B48(this); - } else if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + } else if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { func_800B8804(&this->dyna.actor, play, 40.0f); } } @@ -221,7 +221,7 @@ void func_80AC9B5C(ObjOcarinalift* this, PlayState* play) { if (OBJOCARINALIFT_GET_C(&this->dyna.actor) != OBJOCARINALIFT_PARAMSC_1) { Flags_SetSwitch(play, OBJOCARINALIFT_GET_SWITCH_FLAG(&this->dyna.actor)); } - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); func_80AC9C20(this); } } else { @@ -234,17 +234,17 @@ void func_80AC9B5C(ObjOcarinalift* this, PlayState* play) { } void func_80AC9C20(ObjOcarinalift* this) { - this->dyna.actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000); + this->dyna.actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_2000000 | ACTOR_FLAG_CANT_LOCK_ON); this->actionFunc = func_80AC9C48; } void func_80AC9C48(ObjOcarinalift* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); this->cutsceneTimer = 50; func_80AC96B4(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -256,7 +256,7 @@ void ObjOcarinalift_Update(Actor* thisx, PlayState* play) { if (this->cutsceneTimer > 0) { this->cutsceneTimer--; if (this->cutsceneTimer == 0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); } } } diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index 1d7762c44..c3e180f50 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -196,7 +196,7 @@ void ObjOshihiki_SetColor(ObjOshihiki* this, PlayState* play) { void ObjOshihiki_Init(Actor* thisx, PlayState* play) { ObjOshihiki* this = THIS; - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); if ((OBJOSHIHIKI_GET_FF00(&this->dyna.actor) >= OBJOSHIHIKI_FF00_0) && (OBJOSHIHIKI_GET_FF00(&this->dyna.actor) < OBJOSHIHIKI_FF00_80)) { @@ -439,8 +439,8 @@ void ObjOshihiki_OnActor(ObjOshihiki* this, PlayState* play) { } else { dyna = DynaPoly_GetActor(&play->colCtx, this->floorBgIds[this->highestFloor]); if (dyna != NULL) { - DynaPolyActor_SetRidingFallingState(dyna); - DynaPolyActor_SetSwitchPressedState(dyna); + DynaPolyActor_SetActorOnTop(dyna); + DynaPolyActor_SetActorOnSwitch(dyna); if ((this->timer <= 0) && (fabsf(this->dyna.pushForce) > 0.001f) && ObjOshihiki_StrongEnough(this, play) && ObjOshihiki_NoSwitchPress(this, dyna, play) && !ObjOshihiki_CheckWall(play, this->dyna.yRotation, this->dyna.pushForce, this)) { @@ -456,9 +456,9 @@ void ObjOshihiki_OnActor(ObjOshihiki* this, PlayState* play) { ObjOshihiki_SetupFall(this, play); } else { dyna = DynaPoly_GetActor(&play->colCtx, this->floorBgIds[this->highestFloor]); - if ((dyna != NULL) && (dyna->flags & 1)) { - DynaPolyActor_SetRidingFallingState(dyna); - DynaPolyActor_SetSwitchPressedState(dyna); + if ((dyna != NULL) && (dyna->transformFlags & DYNA_TRANSFORM_POS)) { + DynaPolyActor_SetActorOnTop(dyna); + DynaPolyActor_SetActorOnSwitch(dyna); this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; } else { ObjOshihiki_SetupFall(this, play); @@ -503,7 +503,7 @@ void ObjOshihiki_Push(ObjOshihiki* this, PlayState* play) { player = GET_PLAYER(play); if (ObjOshihiki_CheckWall(play, this->dyna.yRotation, this->dyna.pushForce, this)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } this->dyna.actor.home.pos.x = this->dyna.actor.world.pos.x; @@ -521,7 +521,7 @@ void ObjOshihiki_Push(ObjOshihiki* this, PlayState* play) { } } - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); } void ObjOshihiki_SetupFall(ObjOshihiki* this, PlayState* play) { @@ -553,10 +553,10 @@ void ObjOshihiki_Fall(ObjOshihiki* this, PlayState* play) { } else { ObjOshihiki_SetupOnActor(this, play); } - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - Actor_PlaySfxAtPos(&this->dyna.actor, SurfaceType_GetSfx(&play->colCtx, this->floorPolys[this->highestFloor], - this->floorBgIds[this->highestFloor]) + - SFX_FLAG); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_PL_WALK_GROUND + SurfaceType_GetSfxOffset( + &play->colCtx, this->floorPolys[this->highestFloor], + this->floorBgIds[this->highestFloor])); } } diff --git a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c index ee26937da..dbd0dfe31 100644 --- a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c +++ b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c @@ -113,7 +113,7 @@ s32 ObjPurify_IsPurified(ObjPurify* this) { return true; } } else { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE)) { return true; } } diff --git a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c index 3aca23bca..0b5021ccb 100644 --- a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c +++ b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c @@ -8,7 +8,7 @@ #include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #include "objects/object_secom_obj/object_secom_obj.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_CAN_PRESS_SWITCH) #define THIS ((ObjPzlblock*)thisx) @@ -244,7 +244,7 @@ void func_809A3A48(ObjPzlblock* this) { this->unk_16E[2] = 0; this->unk_16E[3] = 0; this->unk_16E[0] = 0; - this->unk_160 = 4; + this->updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_4; } void func_809A3A74(ObjPzlblock* this, PlayState* play) { @@ -275,7 +275,7 @@ void func_809A3A74(ObjPzlblock* this, PlayState* play) { void func_809A3BA4(ObjPzlblock* this) { this->actionFunc = func_809A3BC0; - this->unk_160 = 5; + this->updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4; } void func_809A3BC0(ObjPzlblock* this, PlayState* play) { @@ -287,14 +287,14 @@ void func_809A3BC0(ObjPzlblock* this, PlayState* play) { if ((params == 4) || (params == 5) || (params == 6)) { if (!func_809A35EC(this, this->unk_16C) || func_809A33E0(this, play, 0x5A)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } } else if (func_809A35EC(this, this->unk_16C)) { if (func_809A33E0(this, play, 0x5A)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } } else { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); Flags_SetSwitch(play, OBJPZLBLOCK_GET_7F(&this->dyna.actor)); sp20 = 1; } @@ -313,7 +313,7 @@ void func_809A3BC0(ObjPzlblock* this, PlayState* play) { void func_809A3D1C(ObjPzlblock* this) { this->actionFunc = func_809A3D38; - this->unk_160 = 4; + this->updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_4; } void func_809A3D38(ObjPzlblock* this, PlayState* play) { @@ -328,7 +328,7 @@ void ObjPzlblock_Update(Actor* thisx, PlayState* play) { ObjPzlblock* this = THIS; this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; - Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 15.0f, 30.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 15.0f, 30.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); if (Object_IsLoaded(&play->objectCtx, this->unk_17A)) { ObjPzlblockStruct* sp2C = &D_809A4060[OBJPZLBLOCK_GET_1000(&this->dyna.actor)]; @@ -348,11 +348,12 @@ void func_809A3E58(Actor* thisx, PlayState* play) { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; - if (this->unk_160 != 0) { - Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 15.0f, 30.0f, 0.0f, this->unk_160); + if (this->updBgCheckInfoFlags != 0) { + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 15.0f, 30.0f, 0.0f, this->updBgCheckInfoFlags); if (((this->actionFunc == func_809A3A74) || (this->actionFunc == func_809A3D38)) && - (this->dyna.actor.bgCheckFlags & 1) && !DynaPoly_GetActor(&play->colCtx, this->dyna.actor.floorBgId)) { - this->unk_160 = 0; + (this->dyna.actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + !DynaPoly_GetActor(&play->colCtx, this->dyna.actor.floorBgId)) { + this->updBgCheckInfoFlags = 0; } } } diff --git a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h index 27a038860..5cf67efcc 100644 --- a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h +++ b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h @@ -15,7 +15,7 @@ typedef void (*ObjPzlblockActionFunc)(struct ObjPzlblock*, PlayState*); typedef struct ObjPzlblock { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ ObjPzlblockActionFunc actionFunc; - /* 0x160 */ s32 unk_160; + /* 0x160 */ s32 updBgCheckInfoFlags; /* 0x164 */ f32* unk_164; /* 0x168 */ f32 unk_168; /* 0x16C */ s16 unk_16C; 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 d0a705cf2..3c8a7ecc0 100644 --- a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c +++ b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c @@ -66,7 +66,7 @@ void ObjRaillift_Init(Actor* thisx, PlayState* play) { thisx->world.rot.x = 0; thisx->shape.rot.z = 0; thisx->world.rot.z = 0; - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, sColHeaders[type]); this->speed = OBJRAILLIFT_GET_SPEED(thisx); if (this->speed < 0.0f) { @@ -141,15 +141,15 @@ void ObjRaillift_Move(ObjRaillift* this, PlayState* play) { step = this->speed * 0.16f; } - Math_StepToF(&thisx->speedXZ, target, step); - if ((thisx->speedXZ + 0.05f) < speed) { - Math_Vec3f_Scale(&thisx->velocity, thisx->speedXZ / speed); + Math_StepToF(&thisx->speed, target, step); + if ((thisx->speed + 0.05f) < speed) { + Math_Vec3f_Scale(&thisx->velocity, thisx->speed / speed); thisx->world.pos.x += thisx->velocity.x; thisx->world.pos.y += thisx->velocity.y; thisx->world.pos.z += thisx->velocity.z; } else { this->curPoint += this->direction; - thisx->speedXZ *= 0.4f; + thisx->speed *= 0.4f; isTeleporting = OBJRAILLIFT_SHOULD_TELEPORT(thisx); isPosUpdated = true; if (((this->curPoint >= this->endPoint) && (this->direction > 0)) || @@ -164,7 +164,7 @@ void ObjRaillift_Move(ObjRaillift* this, PlayState* play) { if ((this->points[0].x != endPoint->x) || (this->points[0].y != endPoint->y) || (this->points[0].z != endPoint->z)) { this->actionFunc = ObjRaillift_Teleport; - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); isPosUpdated = false; } } @@ -180,9 +180,9 @@ void ObjRaillift_Move(ObjRaillift* this, PlayState* play) { Will teleport to what ever curpoint is set to */ void ObjRaillift_Teleport(ObjRaillift* this, PlayState* play) { - if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (!DynaPolyActor_IsPlayerOnTop(&this->dyna)) { ObjRaillift_UpdatePosition(this, this->curPoint); - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->actionFunc = ObjRaillift_Move; } } @@ -191,25 +191,25 @@ void ObjRaillift_Wait(ObjRaillift* this, PlayState* play) { this->waitTimer--; if (this->waitTimer <= 0) { this->actionFunc = ObjRaillift_Move; - this->dyna.actor.speedXZ = 0.0f; + this->dyna.actor.speed = 0.0f; } } void ObjRaillift_Idle(ObjRaillift* this, PlayState* play) { if (Flags_GetSwitch(play, OBJRAILLIFT_GET_FLAG(&this->dyna.actor))) { - this->dyna.actor.speedXZ = 0.0f; - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->dyna.actor.speed = 0.0f; + CutsceneManager_Queue(this->dyna.actor.csId); this->actionFunc = ObjRaillift_StartCutscene; } } void ObjRaillift_StartCutscene(ObjRaillift* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); this->cutsceneTimer = 50; this->actionFunc = ObjRaillift_Move; } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -223,27 +223,23 @@ void ObjRaillift_Update(Actor* thisx, PlayState* play) { if (this->cutsceneTimer > 0) { this->cutsceneTimer--; if (this->cutsceneTimer == 0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); } } - if (OBJRAILLIFT_SHOULD_REACT_TO_WEIGHT(thisx)) { + if (OBJRAILLIFT_REACT_TO_PLAYER_ON_TOP(thisx)) { s32 requiredScopeTemp; - this->isWeightOnPrev = this->isWeightOn; - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { - this->isWeightOn = true; - } else { - this->isWeightOn = false; - } - if ((this->isWeightOn != this->isWeightOnPrev) && (this->maxHeight < 1.0f)) { + this->isPlayerOnTopPrev = this->isPlayerOnTop; + this->isPlayerOnTop = DynaPolyActor_IsPlayerOnTop(&this->dyna) ? true : false; + if ((this->isPlayerOnTop != this->isPlayerOnTopPrev) && (this->maxHeight < 1.0f)) { this->cycle = -0x8000; this->maxHeight = 6.0f; } this->cycle += 0xCE4; Math_StepToF(&this->maxHeight, 0.0f, 0.12f); - step = this->isWeightOn ? Math_CosS(fabsf(this->cycleSpeed) * 2048.0f) + 0.02f - : Math_SinS(fabsf(this->cycleSpeed) * 2048.0f) + 0.02f; - target = this->isWeightOn ? -8.0f : 0.0f; + step = this->isPlayerOnTop ? Math_CosS(fabsf(this->cycleSpeed) * 2048.0f) + 0.02f + : Math_SinS(fabsf(this->cycleSpeed) * 2048.0f) + 0.02f; + target = this->isPlayerOnTop ? -8.0f : 0.0f; Math_StepToF(&this->cycleSpeed, target, step); this->dyna.actor.shape.yOffset = ((Math_SinS(this->cycle) * this->maxHeight) + this->cycleSpeed) * 10.0f; } diff --git a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.h b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.h index 41b7a821e..b921b0e5a 100644 --- a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.h +++ b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.h @@ -14,7 +14,7 @@ typedef void (*ObjRailliftActionFunc)(struct ObjRaillift*, PlayState*); #define OBJRAILLIFT_GET_STARTING_POINT(thisx) (((thisx)->params >> 7) & 0x1F) #define OBJRAILLIFT_GET_SPEED(thisx) ((thisx)->home.rot.z * 0.1f) #define OBJRAILLIFT_SHOULD_TELEPORT(thisx) (((thisx)->params >> 0xC) & 1) -#define OBJRAILLIFT_SHOULD_REACT_TO_WEIGHT(thisx) (((thisx)->params >> 0xE) & 1) +#define OBJRAILLIFT_REACT_TO_PLAYER_ON_TOP(thisx) (((thisx)->params >> 0xE) & 1) typedef enum { /* 0 */ OOT_WATER_TEMPLE_WATERFALL_PLATFORM, @@ -29,8 +29,8 @@ typedef struct ObjRaillift { /* 0x168 */ s32 curPoint; /* 0x16C */ s32 direction; // +1 for forward, -1 for backward /* 0x170 */ Vec3s* points; - /* 0x174 */ s32 isWeightOn; - /* 0x178 */ s32 isWeightOnPrev; + /* 0x174 */ s32 isPlayerOnTop; + /* 0x178 */ s32 isPlayerOnTopPrev; /* 0x17C */ f32 cycleSpeed; /* 0x180 */ f32 maxHeight; /* 0x184 */ s16 cycle; 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 154f662f8..3871508ba 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c @@ -64,7 +64,7 @@ void func_80973D3C(ObjRoomtimer* this, PlayState* play) { if (this->actor.params != 0x1FF) { gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; } - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); this->actionFunc = func_80973DE0; } else if ((this->actor.params != 0x1FF) && (gSaveContext.timerStates[TIMER_ID_MINIGAME_2] == TIMER_STATE_OFF)) { play_sound(NA_SE_OC_ABYSS); @@ -74,17 +74,17 @@ void func_80973D3C(ObjRoomtimer* this, PlayState* play) { } void func_80973DE0(ObjRoomtimer* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + if (CutsceneManager_IsNext(this->actor.csId)) { Flags_SetClear(play, this->actor.room); Flags_SetSwitch(play, this->switchFlag); - if (ActorCutscene_GetLength(this->actor.cutscene) != -1) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (CutsceneManager_GetLength(this->actor.csId) != -1) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); } Actor_Kill(&this->actor); return; } - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } void ObjRoomtimer_Update(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c index ce18a68b0..4c63908c6 100644 --- a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c +++ b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c @@ -111,7 +111,7 @@ void ObjRotlift_Init(Actor* thisx, PlayState* play2) { ObjRotlift_MoveDekuFlowers(this); } - DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); modelInfo = &sModelInfo[type]; DynaPolyActor_LoadMesh(play, &this->dyna, modelInfo->colHeader); 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 6a469eea0..fa04972ef 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c @@ -489,7 +489,7 @@ void ObjSkateblock_Init(Actor* thisx, PlayState* play) { ObjSkateblock* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); if (D_80A22A18 == NULL) { D_80A22A18 = Lib_SegmentedToVirtual(gameplay_dangeon_keep_Matanimheader_01B370); @@ -535,7 +535,7 @@ void func_80A22334(ObjSkateblock* this, PlayState* play) { func_80A21C88(this, sp2C); func_80A2244C(this); sp30 = false; - func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_7); + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_WAIT); this->unk_1C1 |= 1; } @@ -563,7 +563,7 @@ void func_80A224A4(ObjSkateblock* this, PlayState* play) { *this->unk_16C += this->unk_164; if (func_80A21934(this, play)) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); func_80A21D1C(this); sp28 = true; } else { @@ -591,7 +591,7 @@ void func_80A224A4(ObjSkateblock* this, PlayState* play) { if ((this->unk_1C1 & 1) && (sp24 || sp28 || (this->dyna.actor.xzDistToPlayer > 400.0f))) { this->unk_1C1 &= ~1; - func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_6); + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_END); } func_80A21F74(this, play); @@ -614,8 +614,9 @@ void func_80A2264C(ObjSkateblock* this, PlayState* play) { sp20 = func_80A21548(this, play); if (sp20 || ((this->unk_160 - this->dyna.actor.world.pos.y) > 300.0f)) { - if (func_800C9B40(&play->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) == 12) { - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + if (SurfaceType_GetFloorProperty(&play->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) == + FLOOR_PROPERTY_12) { + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = NULL; func_80A22728(this); return; @@ -632,7 +633,7 @@ void func_80A22728(ObjSkateblock* this) { } void func_80A2273C(ObjSkateblock* this, PlayState* play) { - if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (!DynaPolyActor_IsPlayerOnTop(&this->dyna)) { this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; this->dyna.actor.world.pos.y = (this->dyna.actor.home.pos.y - (600.0f * this->dyna.actor.scale.y)) - 10.0f; this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z; @@ -656,14 +657,14 @@ void func_80A227C0(ObjSkateblock* this, PlayState* play) { return; } - func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_EnableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = ObjSkateblock_Draw; if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f)) { func_80A22308(this); } - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { D_80A22A10 |= 1 << this->unk_1C0; } } 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 068be3ea0..c94d67860 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -106,7 +106,7 @@ void func_80B02CD0(ObjSnowball* this, PlayState* play) { Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, 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); + ptr->unk_02, CS_ID_NONE, this->actor.halfDaysBits, NULL); } void func_80B02D58(ObjSnowball* this, PlayState* play) { @@ -123,8 +123,8 @@ void func_80B02DB0(ObjSnowball* this, PlayState* play) { Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, 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); + this->actor.params | ptr->unk_02, CutsceneManager_GetAdditionalCsId(this->actor.csId), + this->actor.halfDaysBits, NULL); } void func_80B02E54(ObjSnowball* this, PlayState* play) { @@ -132,7 +132,7 @@ void func_80B02E54(ObjSnowball* this, PlayState* play) { Actor_SpawnAsChildAndCutscene(&play->actorCtx, play, 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); + this->actor.params | ptr->unk_02, CS_ID_NONE, this->actor.halfDaysBits, NULL); } void func_80B02EE4(ObjSnowball* this, PlayState* play) { @@ -440,7 +440,7 @@ void func_80B03FF8(ObjSnowball* this, PlayState* play) { sp18->unk_04(this, play); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SNOWBALL_BROKEN); + Actor_PlaySfx(&this->actor, NA_SE_EV_SNOWBALL_BROKEN); if (rotY == 5) { Flags_SetSwitch(play, OBJSNOWBALL_GET_3F(&this->actor)); @@ -549,7 +549,7 @@ void func_80B04350(ObjSnowball* this, PlayState* play) { this->unk_20A = 0; } - if (this->actor.cutscene < 0) { + if (this->actor.csId < 0) { func_80B03FF8(this, play); if (this->unk_20A == 0) { func_80B04608(this, play); @@ -571,7 +571,7 @@ void func_80B04350(ObjSnowball* this, PlayState* play) { } else { this->unk_209 = 10; } - Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_REFLECTION_SNOW); + Actor_PlaySfx(&this->actor, NA_SE_IT_REFLECTION_SNOW); } } @@ -584,13 +584,13 @@ void func_80B04350(ObjSnowball* this, PlayState* play) { } void func_80B04540(ObjSnowball* this, PlayState* play) { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); this->actionFunc = func_80B0457C; } void func_80B0457C(ObjSnowball* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); func_80B03FF8(this, play); this->unk_20B = 1; if (this->unk_20A == 0) { @@ -599,7 +599,7 @@ void func_80B0457C(ObjSnowball* this, PlayState* play) { func_80B046E4(this, play); } } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -615,7 +615,7 @@ void func_80B04648(ObjSnowball* this, PlayState* play) { this->unk_208--; if (this->unk_208 <= 0) { if (this->unk_20B != 0) { - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); } if (this->actor.home.rot.y == 1) { @@ -719,7 +719,7 @@ void func_80B047C0(ObjSnowball* this, PlayState* play) { 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); + CutsceneManager_Stop(this->actor.csId); } if (this->actor.home.rot.y == 1) { 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 d62002e73..ec05294d1 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -356,9 +356,9 @@ void func_80B39C9C(ObjSnowball2* this, PlayState* play) { func_80B38E88(this, play); } func_80B38EFC(this, play); - func_800B8E58(GET_PLAYER(play), NA_SE_PL_PULL_UP_SNOWBALL); + Player_PlaySfx(GET_PLAYER(play), NA_SE_PL_PULL_UP_SNOWBALL); func_80B39F60(this); - } else if ((this->actor.bgCheckFlags & 0x20) && + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER) && ((this->actor.shape.yOffset * this->actor.scale.y) < this->actor.depthInWater)) { func_80B3A498(this); } else if (sp38 && (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x0583FFBC)) { @@ -374,8 +374,10 @@ void func_80B39C9C(ObjSnowball2* this, PlayState* play) { if (this->unk_1AD == 0) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, 0x44); - if ((this->actor.bgCheckFlags & 1) && (DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId) == NULL)) { + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, + UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40); + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + (DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId) == NULL)) { this->unk_1AD = 1; this->actor.flags &= ~ACTOR_FLAG_10; } @@ -388,7 +390,7 @@ void func_80B39C9C(ObjSnowball2* this, PlayState* play) { if (this->actor.xzDistToPlayer < 100.0f) { if (ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, GET_PLAYER(play)->actor.world.rot.y)) >= 0x5556) { - Actor_PickUp(&this->actor, play, GI_NONE, 36.0f, 30.0f); + Actor_OfferGetItem(&this->actor, play, GI_NONE, 36.0f, 30.0f); } } } @@ -417,11 +419,12 @@ void func_80B39FA8(ObjSnowball2* this, PlayState* play) { if (Actor_HasNoParent(&this->actor, play)) { this->actor.room = play->roomCtx.curRoom.num; - this->actor.speedXZ *= 3.8f; + this->actor.speed *= 3.8f; this->actor.velocity.y *= 0.4f; this->actor.gravity = -2.8f; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40); func_80B3A0D8(this); } else { sp30.x = this->actor.world.pos.x; @@ -460,7 +463,9 @@ void func_80B3A13C(ObjSnowball2* this, PlayState* play) { func_80B39B28(this, play); - if ((((this->actor.bgCheckFlags & 9) || sp38) && !(this->actor.bgCheckFlags & 0x20)) || (this->unk_1AC <= 0)) { + if ((((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_WALL)) || sp38) && + !(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) || + (this->unk_1AC <= 0)) { func_80B38E88(this, play); func_80B39108(this, play); func_80B39B5C(this, play); @@ -469,14 +474,14 @@ void func_80B3A13C(ObjSnowball2* this, PlayState* play) { } sp30 = false; - if (this->actor.bgCheckFlags & 0x60) { - if ((this->actor.bgCheckFlags & 0x40) || (this->actor.speedXZ > 3.0f)) { + if (this->actor.bgCheckFlags & (BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) || (this->actor.speed > 3.0f)) { if (this->actor.depthInWater < (1200.0f * this->actor.scale.y)) { func_80B39470(&this->actor, play); func_80B395EC(&this->actor, play); } - if (this->actor.bgCheckFlags & 0x40) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { + Actor_PlaySfx(&this->actor, NA_SE_EV_BOMB_DROP_WATER); } } else if ((((play->gameplayFrames % 16) == 0) || ((Rand_Next() >> 0x10) == 0)) && (this->actor.depthInWater < (1200.0f * this->actor.scale.y))) { @@ -488,26 +493,27 @@ void func_80B3A13C(ObjSnowball2* this, PlayState* play) { this->unk_1AA >>= 1; if (sp34) { - this->actor.speedXZ *= 0.8f; + this->actor.speed *= 0.8f; } else { - this->actor.speedXZ *= 0.65f; + this->actor.speed *= 0.65f; } this->actor.velocity.y *= 0.27f; this->actor.gravity *= 0.27f; - if (this->actor.speedXZ < 0.4f) { + if (this->actor.speed < 0.4f) { sp30 = true; } } else { if (sp34) { - this->actor.speedXZ *= 0.8f; + this->actor.speed *= 0.8f; } else { - this->actor.speedXZ *= 0.96f; + this->actor.speed *= 0.96f; } this->actor.velocity.y *= 0.96f; } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40); this->actor.shape.rot.x += this->unk_1A8; this->actor.shape.rot.y += this->unk_1AA; func_80B38E20(this); @@ -527,7 +533,7 @@ void func_80B3A498(ObjSnowball2* this) { this->actor.home.pos.z = this->actor.world.pos.z; this->actor.world.pos.y = this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y); this->actor.shape.yOffset = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actionFunc = func_80B3A500; } @@ -539,7 +545,7 @@ void func_80B3A500(ObjSnowball2* this, PlayState* play) { this->unk_1AC--; - this->actor.speedXZ *= 0.7f; + this->actor.speed *= 0.7f; this->unk_1A8 >>= 1; this->unk_1AA >>= 1; diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c index 4708062da..907df33fc 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c @@ -676,15 +676,15 @@ void func_80B30A2C(ObjSpidertent* this) { } void func_80B30A4C(ObjSpidertent* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - if (this->dyna.actor.cutscene >= 0) { + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); + if (this->dyna.actor.csId >= 0) { func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_1); } Flags_SetSwitch(play, OBJSPIDERTENT_GET_7F00(&this->dyna.actor)); func_80B30AD4(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -755,14 +755,14 @@ void func_80B30AF8(ObjSpidertent* this, PlayState* play) { this->unk_3C1--; if (this->unk_3C1 == 40) { - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); } if (this->unk_3C1 >= 32) { if (this->unk_3C7 > 0) { this->unk_3C7--; } else if (this->unk_3C1 > 50) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_EXTINCT); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EN_EXTINCT); this->unk_3C7 = Rand_S16Offset(2, 2); } else { SoundSource_PlaySfxAtFixedWorldPos(play, &this->dyna.actor.world.pos, 11, NA_SE_EN_EXTINCT); @@ -791,7 +791,7 @@ void func_80B30AF8(ObjSpidertent* this, PlayState* play) { } } } else if (this->unk_3C1 <= 0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); Actor_Kill(&this->dyna.actor); } } diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c index 83959e168..4541baa2a 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c @@ -149,7 +149,7 @@ void func_80A1DA50(PlayState* play, ObjSpinyroll* this, Vec3f* arg2, Vec3f* arg3 Math_Vec3f_Sum(arg2, arg3, &sp1C); Math_Vec3f_Scale(&sp1C, 0.5f); EffectSsHitmark_SpawnFixedScale(play, 3, &sp1C); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); + Actor_PlaySfx(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); } void func_80A1DAAC(Vec3f* arg0, Vec3f* arg1, s16 arg2) { @@ -195,10 +195,10 @@ void func_80A1DC5C(ObjSpinyroll* this) { void func_80A1DCCC(ObjSpinyroll* this) { f32 phi_f2; - if (this->dyna.actor.speedXZ > 3.0f) { + if (this->dyna.actor.speed > 3.0f) { phi_f2 = 3.0f; } else { - phi_f2 = this->dyna.actor.speedXZ; + phi_f2 = this->dyna.actor.speed; } if (this->unk_4D4 < phi_f2) { @@ -246,15 +246,15 @@ s32 func_80A1DEB8(ObjSpinyroll* this) { s32 sp30 = this->unk_4A8 ^ 1; Vec3f sp24; - Math_StepToF(&this->dyna.actor.speedXZ, this->unk_4A4, this->unk_4A4 * 0.2f); + Math_StepToF(&this->dyna.actor.speed, this->unk_4A4, this->unk_4A4 * 0.2f); - this->dyna.actor.world.pos.x += this->dyna.actor.speedXZ * this->unk_4C4.x; - this->dyna.actor.world.pos.y += this->dyna.actor.speedXZ * this->unk_4C4.y; - this->dyna.actor.world.pos.z += this->dyna.actor.speedXZ * this->unk_4C4.z; + this->dyna.actor.world.pos.x += this->dyna.actor.speed * this->unk_4C4.x; + this->dyna.actor.world.pos.y += this->dyna.actor.speed * this->unk_4C4.y; + this->dyna.actor.world.pos.z += this->dyna.actor.speed * this->unk_4C4.z; Math_Vec3f_Diff(&this->unk_4AC[sp30], &this->dyna.actor.world.pos, &sp24); - return Math3D_LengthSquared(&sp24) < (SQ(this->dyna.actor.speedXZ) + 0.05f); + return Math3D_LengthSquared(&sp24) < (SQ(this->dyna.actor.speed) + 0.05f); } void func_80A1DFA0(ObjSpinyroll* this) { @@ -517,7 +517,7 @@ void ObjSpinyroll_Destroy(Actor* thisx, PlayState* play) { } void func_80A1E9C4(ObjSpinyroll* this) { - this->dyna.actor.speedXZ = 0.0f; + this->dyna.actor.speed = 0.0f; this->actionFunc = func_80A1E9E0; } @@ -531,7 +531,7 @@ void func_80A1E9E0(ObjSpinyroll* this, PlayState* play) { void func_80A1EA10(ObjSpinyroll* this) { this->actionFunc = func_80A1EA4C; this->unk_4E2 = D_80A1F1E4[OBJSPINYROLL_GET_1C00(&this->dyna.actor)]; - this->dyna.actor.speedXZ = 0.0f; + this->dyna.actor.speed = 0.0f; } void func_80A1EA4C(ObjSpinyroll* this, PlayState* play) { @@ -548,7 +548,7 @@ void func_80A1EA4C(ObjSpinyroll* this, PlayState* play) { void func_80A1EAAC(ObjSpinyroll* this) { this->actionFunc = func_80A1EAE0; this->unk_4DC = D_80A1F20C[this->unk_4A8]; - this->dyna.actor.speedXZ = 0.0f; + this->dyna.actor.speed = 0.0f; } void func_80A1EAE0(ObjSpinyroll* this, PlayState* play) { diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index ada5eadd3..2c03f8689 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -266,25 +266,25 @@ void ObjSwitch_CrystalUpdateTimer(ObjSwitch* this) { void ObjSwitch_StopCutscene(ObjSwitch* this) { if (this->isPlayingCutscene) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); this->isPlayingCutscene = false; } } void ObjSwitch_PlayFootSwitchSfx(ObjSwitch* this) { if (this->sfxTimer <= 0) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); } } void ObjSwitch_PlayDiamondSwitchSfx(ObjSwitch* this) { if (this->sfxTimer <= 0) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DIAMOND_SWITCH); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_DIAMOND_SWITCH); } } void ObjSwitch_SetFloorSwitchSnapPlayerState(ObjSwitch* this, s32 state) { - if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { this->floorSwitchPlayerSnapState = state; } } @@ -344,7 +344,7 @@ void ObjSwitch_Init(Actor* thisx, PlayState* play) { } else { this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.0f; } - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &gFloorSwitchCol); } if (type == OBJSWITCH_TYPE_FLOOR) { @@ -486,8 +486,8 @@ void ObjSwitch_TryPlayCutsceneInit(ObjSwitch* this, PlayState* play, ObjSwitchSe } void ObjSwitch_TryPlayCutscene(ObjSwitch* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); ObjSwitch_SetSwitchFlagState(this, play, this->nextSwitchFlagState); if (this->floorSwitchPlayerSnapState == 1) { this->floorSwitchPlayerSnapState = 2; @@ -495,7 +495,7 @@ void ObjSwitch_TryPlayCutscene(ObjSwitch* this, PlayState* play) { this->isPlayingCutscene = true; this->setupFunc(this); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -517,13 +517,13 @@ void ObjSwitch_FloorSwitchUp(ObjSwitch* this, PlayState* play) { } else { switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { case OBJSWITCH_SUBTYPE_ONCE: - if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + if (DynaPolyActor_IsSwitchPressed(&this->dyna)) { ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_FloorSwitchPushDownInit, true); } break; case OBJSWITCH_SUBTYPE_SYNC: - if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + if (DynaPolyActor_IsSwitchPressed(&this->dyna)) { ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_FloorSwitchPushDownInit, true); } else if (Flags_GetSwitch(play, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { @@ -531,7 +531,7 @@ void ObjSwitch_FloorSwitchUp(ObjSwitch* this, PlayState* play) { } break; case OBJSWITCH_SUBTYPE_TOGGLE: - if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + if (DynaPolyActor_IsSwitchPressed(&this->dyna)) { s32 isSwitchFlagNotSet = Flags_GetSwitch(play, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor)) ? false : true; @@ -540,13 +540,13 @@ void ObjSwitch_FloorSwitchUp(ObjSwitch* this, PlayState* play) { } break; case OBJSWITCH_SUBTYPE_RESET: - if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + if (DynaPolyActor_IsSwitchPressed(&this->dyna)) { ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_FloorSwitchPushDownInit, true); } break; case OBJSWITCH_SUBTYPE_RESET_INVERTED: - if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + if (DynaPolyActor_IsSwitchPressed(&this->dyna)) { ObjSwitch_SetFloorSwitchSnapPlayerState(this, 2); ObjSwitch_SetSwitchFlagState(this, play, false); ObjSwitch_FloorSwitchPushDownInit(this); @@ -584,7 +584,7 @@ void ObjSwitch_FloorSwitchDown(ObjSwitch* this, PlayState* play) { case OBJSWITCH_SUBTYPE_ONCE: case OBJSWITCH_SUBTYPE_SYNC: if (!Flags_GetSwitch(play, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { - if ((play->sceneId == SCENE_SECOM) && DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + if ((play->sceneId == SCENE_SECOM) && DynaPolyActor_IsSwitchPressed(&this->dyna)) { ObjSwitch_SetSwitchFlagState(this, play, true); } else { ObjSwitch_FloorSwitchRiseUpInit(this); @@ -594,7 +594,7 @@ void ObjSwitch_FloorSwitchDown(ObjSwitch* this, PlayState* play) { case OBJSWITCH_SUBTYPE_TOGGLE: case OBJSWITCH_SUBTYPE_RESET: case OBJSWITCH_SUBTYPE_RESET_INVERTED: - if (!DynaPolyActor_IsInSwitchPressedState(&this->dyna) && + if (!DynaPolyActor_IsSwitchPressed(&this->dyna) && (!Player_InCsMode(play) || (play->sceneId == SCENE_SECOM))) { if (this->floorSwitchReleaseTimer <= 0) { if (subType == OBJSWITCH_SUBTYPE_RESET) { @@ -841,16 +841,16 @@ void ObjSwitch_LargeFloorSwitchUp(ObjSwitch* this, PlayState* play) { s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); if (subType == OBJSWITCH_SUBTYPE_ONCE) { - if (DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + if (DynaPolyActor_IsHeavySwitchPressed(&this->dyna)) { ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_LargeFloorSwitchPushDownInit, true); } } else if (subType == OBJSWITCH_SUBTYPE_RESET) { - if (DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + if (DynaPolyActor_IsHeavySwitchPressed(&this->dyna)) { ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_LargeFloorSwitchPushDownInit, true); } - } else if (subType == OBJSWITCH_SUBTYPE_RESET_INVERTED && DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + } else if (subType == OBJSWITCH_SUBTYPE_RESET_INVERTED && DynaPolyActor_IsHeavySwitchPressed(&this->dyna)) { ObjSwitch_SetFloorSwitchSnapPlayerState(this, 2); ObjSwitch_SetSwitchFlagState(this, play, false); ObjSwitch_LargeFloorSwitchPushDownInit(this); @@ -885,7 +885,7 @@ void ObjSwitch_LargeFloorSwitchDown(ObjSwitch* this, PlayState* play) { ObjSwitch_LargeFloorSwitchRiseUpInit(this); } } else if (subType == OBJSWITCH_SUBTYPE_RESET || subType == OBJSWITCH_SUBTYPE_RESET_INVERTED) { - if (!DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna) && !Player_InCsMode(play)) { + if (!DynaPolyActor_IsHeavySwitchPressed(&this->dyna) && !Player_InCsMode(play)) { if (this->floorSwitchReleaseTimer <= 0) { if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_RESET) { ObjSwitch_SetSwitchFlagState(this, play, false); @@ -936,7 +936,7 @@ void ObjSwitch_Update(Actor* thisx, PlayState* play) { case OBJSWITCH_TYPE_FLOOR: case OBJSWITCH_TYPE_FLOOR_RUSTY: case OBJSWITCH_TYPE_FLOOR_LARGE: - this->collisionFlags = this->dyna.stateFlags; + this->collisionFlags = this->dyna.interactFlags; break; case OBJSWITCH_TYPE_EYE: this->collisionFlags = this->colliderTris.base.acFlags; diff --git a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c index 578244237..f1b7bfa6f 100644 --- a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c +++ b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c @@ -64,7 +64,7 @@ void func_80C253D0(ObjSwprize* this, PlayState* play) { if (collectible != NULL) { if (sp78.y < 0.98f) { collectible->velocity.y = (sp78.y + 1.0f) * 4.0f; - collectible->speedXZ = (2.0f * (1.0f - fabsf(sp78.y))) + 2.0f; + collectible->speed = (2.0f * (1.0f - fabsf(sp78.y))) + 2.0f; collectible->world.rot.y = Math_Atan2S_XY(sp78.z, sp78.x) + D_80C257F8[i]; } else { collectible->world.rot.y = i * (0x10000 / 3); @@ -75,7 +75,7 @@ void func_80C253D0(ObjSwprize* this, PlayState* play) { collectible = Item_DropCollectible(play, &thisx->world.pos, temp_s0); if ((collectible != NULL) && (sp78.y < 0.98f)) { collectible->velocity.y = (sp78.y + 1.0f) * 4.0f; - collectible->speedXZ = (2.0f * (1.0f - fabsf(sp78.y))) + 2.0f; + collectible->speed = (2.0f * (1.0f - fabsf(sp78.y))) + 2.0f; collectible->world.rot.y = Math_Atan2S_XY(sp78.z, sp78.x); } } @@ -109,12 +109,12 @@ void func_80C25698(ObjSwprize* this) { } void func_80C256AC(ObjSwprize* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (CutsceneManager_IsNext(this->actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); func_80C253D0(this, play); func_80C25710(this); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -127,7 +127,7 @@ void func_80C2572C(ObjSwprize* this, PlayState* play) { if (this->timer > 0) { this->timer--; if (this->timer == 0) { - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); ObjSwprize_SetupDoNothing(this); } } 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 96716d107..902caa42b 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -143,16 +143,16 @@ void ObjSyokudai_Update(Actor* thisx, PlayState* play2) { s32 pad1; if (this->pendingAction != OBJ_SYOKUDAI_PENDING_ACTION_NONE) { - if (ActorCutscene_GetCurrentIndex() != thisx->cutscene) { - if (ActorCutscene_GetCanPlayNext(thisx->cutscene) != 0) { - ActorCutscene_StartAndSetUnkLinkFields(thisx->cutscene, thisx); + if (CutsceneManager_GetCurrentCsId() != thisx->csId) { + if (CutsceneManager_IsNext(thisx->csId)) { + CutsceneManager_StartWithPlayerCs(thisx->csId, thisx); if (this->pendingAction >= OBJ_SYOKUDAI_PENDING_ACTION_CUTSCENE_AND_SWITCH) { Flags_SetSwitch(play, switchFlag); } } else { - ActorCutscene_SetIntentToPlay(thisx->cutscene); + CutsceneManager_Queue(thisx->csId); } - } else if (func_800F22C4(thisx->cutscene, thisx) != 0) { + } else if (func_800F22C4(thisx->csId, thisx) != 0) { this->snuffTimer = OBJ_SYOKUDAI_SNUFF_NEVER; this->pendingAction = OBJ_SYOKUDAI_PENDING_ACTION_NONE; } @@ -171,6 +171,7 @@ void ObjSyokudai_Update(Actor* thisx, PlayState* play2) { } else { s32 interaction = OBJ_SYOKUDAI_INTERACTION_NONE; u32 flameColliderHurtboxDmgFlags = 0; + player = GET_PLAYER(play); if (OBJ_SYOKUDAI_GET_START_LIT(thisx)) { @@ -240,7 +241,7 @@ void ObjSyokudai_Update(Actor* thisx, PlayState* play2) { if (groupSize == 0) { if ((type == OBJ_SYOKUDAI_TYPE_NO_SWITCH) && (switchFlag == 0x7F)) { this->snuffTimer = OBJ_SYOKUDAI_SNUFF_NEVER; - } else if (thisx->cutscene >= 0) { + } else if (thisx->csId >= 0) { this->pendingAction = OBJ_SYOKUDAI_PENDING_ACTION_CUTSCENE_AND_SWITCH; } else { Flags_SetSwitch(play, switchFlag); diff --git a/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c b/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c index 791564b57..aeaddd2ee 100644 --- a/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c +++ b/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c @@ -181,7 +181,7 @@ void func_80B9BCBC(ObjTaru* this, PlayState* play) { if (spawnedActor != NULL) { spawnedActor->parent = &this->dyna.actor; spawnedActor->velocity.y = 12.0f; - spawnedActor->speedXZ = 2.0f; + spawnedActor->speed = 2.0f; } } } @@ -279,7 +279,7 @@ void func_80B9C07C(ObjTaru* this, PlayState* play) { this->actionFunc = func_80B9C1A0; } else { this->dyna.actor.flags |= ACTOR_FLAG_10; - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = NULL; this->actionFunc = func_80B9C174; } @@ -296,14 +296,14 @@ void func_80B9C174(ObjTaru* this, PlayState* play) { } void func_80B9C1A0(ObjTaru* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); Flags_SetSwitch(play, OBJ_TARU_GET_7F(&this->dyna.actor)); Actor_Kill(&this->dyna.actor); return; } - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } void ObjTaru_Update(Actor* thisx, PlayState* play) { @@ -316,7 +316,7 @@ void ObjTaru_Update(Actor* thisx, PlayState* play) { if (this->unk_1AD >= 0) { switch (this->unk_1AD) { case 0: - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EN_STALGOLD_ROLL); if (Rand_ZeroOne() < 0.1f) { this->unk_1AD = Rand_S16Offset(40, 80); } else { 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 306ca7029..c6ed2cc2c 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c @@ -148,7 +148,7 @@ void ObjToge_Init(Actor* thisx, PlayState* play) { Math_Vec3f_Copy(&thisx->world.pos, &this->unk_198[0]); thisx->world.rot.y = Math_Vec3f_Yaw(&this->unk_198[0], &this->unk_198[1]); this->unk_194 = 0; - thisx->speedXZ = 0.0f; + thisx->speed = 0.0f; if (sp3E > 0) { s16 sp36; @@ -228,7 +228,7 @@ void func_809A481C(ObjToge* this, PlayState* play) { } void func_809A488C(ObjToge* this) { - this->actor.speedXZ = 1.0f; + this->actor.speed = 1.0f; this->actionFunc = func_809A48AC; } @@ -237,16 +237,17 @@ void func_809A48AC(ObjToge* this, PlayState* play) { s32 sp30 = this->unk_194 ^ 1; if (this->unk_1B4 && (this->unk_194 == 1)) { - Math_StepToF(&this->actor.speedXZ, 2.0f, 0.4f); + Math_StepToF(&this->actor.speed, 2.0f, 0.4f); } else { - Math_StepToF(&this->actor.speedXZ, D_809A4CDC[OBJTOGE_GET_700(&this->actor)], 1.5f); + Math_StepToF(&this->actor.speed, D_809A4CDC[OBJTOGE_GET_700(&this->actor)], 1.5f); this->actor.shape.rot.y += 0x1770; } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, D_809A4D0C[OBJTOGE_GET_4000(&this->actor)] * 30.0f, 0.0f, 0x81); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, D_809A4D0C[OBJTOGE_GET_4000(&this->actor)] * 30.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_80); - if (this->actor.bgCheckFlags & 8) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_198[this->unk_194]); this->unk_194 = sp30; if (this->unk_1B4 && (this->unk_194 == 0)) { @@ -254,7 +255,7 @@ void func_809A48AC(ObjToge* this, PlayState* play) { } else { func_809A4744(this); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SPINE_TRAP_MOVE); + Actor_PlaySfx(&this->actor, NA_SE_EV_SPINE_TRAP_MOVE); } else { s16 yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_198[sp30]) - this->actor.world.rot.y; @@ -267,7 +268,7 @@ void func_809A48AC(ObjToge* this, PlayState* play) { } else { func_809A4744(this); } - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SPINE_TRAP_MOVE); + Actor_PlaySfx(&this->actor, NA_SE_EV_SPINE_TRAP_MOVE); } } } @@ -279,7 +280,7 @@ void ObjToge_Update(Actor* thisx, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1000) { func_809A43A8(this, play); - Actor_SetColorFilter(&this->actor, 0, 250, 0, 250); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_BLUE, 250, COLORFILTER_BUFFLAG_OPA, 250); } collider->base.acFlags &= ~AC_HIT; } 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 694a5ac59..d5aeffd8f 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 @@ -61,13 +61,13 @@ void ObjTokeiStep_SetSysMatrix(ObjTokeiStepPanel* panel) { mtx->zw = panel->pos.z; } -void ObjTokeiStep_AddQuake(ObjTokeiStep* this, PlayState* play) { +void ObjTokeiStep_RequestQuakeAndRumble(ObjTokeiStep* this, PlayState* play) { s32 pad[2]; - s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, 20000); - Quake_SetQuakeValues(quakeIndex, 1, 0, 0, 0); - Quake_SetCountdown(quakeIndex, 7); + Quake_SetPerturbations(quakeIndex, 1, 0, 0, 0); + Quake_SetDuration(quakeIndex, 7); Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); } @@ -156,7 +156,7 @@ s32 ObjTokeiStep_OpenProcess(ObjTokeiStep* this, PlayState* play) { if (hasPrevBounced && (panel->numBounces < 3) && (panel->startFallingTimer <= 0)) { finalPosY = sPanelXOffsets[i] + this->dyna.actor.world.pos.y; if (!panel->hasSoundPlayed) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CLOCK_TOWER_STAIR_MOVE); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_CLOCK_TOWER_STAIR_MOVE); panel->hasSoundPlayed = true; } panel->posChangeY += -2.5f; @@ -180,7 +180,7 @@ s32 ObjTokeiStep_OpenProcess(ObjTokeiStep* this, PlayState* play) { } if (panel->numBounces == 1) { ObjTokeiStep_SpawnDust(this2, panel, play); - ObjTokeiStep_AddQuake(this2, play); + ObjTokeiStep_RequestQuakeAndRumble(this2, play); } } } @@ -195,7 +195,7 @@ void ObjTokeiStep_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - if ((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) { + if ((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.scriptIndex == 0)) { DynaPolyActor_LoadMesh(play, &this->dyna, &gClocktowerPanelCol); ObjTokeiStep_InitSteps(this); ObjTokeiStep_SetupBeginOpen(this); @@ -221,12 +221,12 @@ void ObjTokeiStep_SetupBeginOpen(ObjTokeiStep* this) { } void ObjTokeiStep_BeginOpen(ObjTokeiStep* this, PlayState* play) { - CsCmdActorAction* action; + CsCmdActorCue* cue; - if (Cutscene_CheckActorAction(play, 134)) { - action = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 134)]; + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_134)) { + cue = play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_134)]; - if ((action->startFrame == play->csCtx.frames) && (action->action != 0)) { + if ((cue->startFrame == play->csCtx.curFrame) && (cue->id != 0)) { this->dyna.actor.draw = ObjTokeiStep_DrawOpen; ObjTokeiStep_SetupOpen(this); } @@ -247,7 +247,7 @@ void ObjTokeiStep_SetupOpen(ObjTokeiStep* this) { void ObjTokeiStep_Open(ObjTokeiStep* this, PlayState* play) { if (ObjTokeiStep_OpenProcess(this, play)) { - func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); ObjTokeiStep_SetupDoNothingOpen(this); } } 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 704bc58c3..3b933157b 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -36,7 +36,7 @@ #define THIS ((ObjTokeidai*)thisx) -#define GET_CURRENT_CLOCK_HOUR(this) ((s32)((this)->clockTime * (24.0f / 0x10000))) +#define GET_CURRENT_CLOCK_HOUR(this) ((s32)TIME_TO_HOURS_F((this)->clockTime)) #define GET_CURRENT_CLOCK_MINUTE(this) ((s32)((this)->clockTime * (360 * 2.0f / 0x10000)) % 30) #define GET_CLOCK_FACE_ROTATION(currentClockHour) ((s16)(currentClockHour * (0x10000 / 24.0f))) #define GET_MINUTE_RING_OR_EXTERIOR_GEAR_ROTATION(currentClockMinute) \ @@ -121,8 +121,8 @@ void ObjTokeidai_ExteriorGear_Init(ObjTokeidai* this, PlayState* play) { this->opaDList = gClockTowerExteriorGearDL; ObjTokeidai_SetupClockOrExteriorGear(this); - if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) || - ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0))) { + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.scriptIndex == 0)) || + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.scriptIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actionFunc = ObjTokeidai_ExteriorGear_OpenedIdle; @@ -138,8 +138,8 @@ void ObjTokeidai_TowerClock_Init(ObjTokeidai* this, PlayState* play) { this->actor.draw = ObjTokeidai_Clock_Draw; ObjTokeidai_Clock_Init(this); - if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) || - ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0))) { + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.scriptIndex == 0)) || + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.scriptIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actor.world.pos.y += (this->actor.scale.y * 5191.0f) - 50.0f; @@ -171,8 +171,8 @@ void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, PlayState* play) { this->spotlightIntensity = 0; } - if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) || - ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0))) { + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.scriptIndex == 0)) || + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.scriptIndex == 0))) { this->spotlightIntensity = 0; ObjTokeidai_SetupTowerOpening(this); @@ -285,7 +285,7 @@ void ObjTokeidai_RotateOnMinuteChange(ObjTokeidai* this, s32 playSfx) { if (currentClockMinute != this->clockMinute) { if (this->minuteRingOrExteriorGearRotationTimer == 8 && playSfx) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_SECOND_HAND); + Actor_PlaySfx(&this->actor, NA_SE_EV_CLOCK_TOWER_SECOND_HAND); } if (this->minuteRingOrExteriorGearRotationTimer > 8) { @@ -318,21 +318,21 @@ void ObjTokeidai_RotateOnMinuteChange(ObjTokeidai* this, s32 playSfx) { } void ObjTokeidai_ExteriorGear_Collapse(ObjTokeidai* this, PlayState* play) { - if ((this->actor.bgCheckFlags & 1) || this->actor.world.pos.y < 0.0f) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || this->actor.world.pos.y < 0.0f) { this->actionFunc = ObjTokeidai_DoNothing; } else { this->actor.shape.rot.x += 0x50; this->actor.shape.rot.z += 0x50; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); } } void ObjTokeidai_ExteriorGear_OpenedIdle(ObjTokeidai* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 132) && - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 2) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_132) && + play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_132)]->id == 2) { this->actionFunc = ObjTokeidai_ExteriorGear_Collapse; - this->actor.speedXZ = this->actor.scale.y * 5.0f; + this->actor.speed = this->actor.scale.y * 5.0f; this->actor.velocity.y = 0.0f; this->actor.terminalVelocity = this->actor.scale.y * -50.0f; this->actor.gravity = this->actor.scale.y * -5.0f; @@ -397,8 +397,8 @@ void ObjTokeidai_TowerClock_SlideOff(ObjTokeidai* this, PlayState* play) { } void ObjTokeidai_TowerClock_OpenedIdle(ObjTokeidai* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 132) && - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 1) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_132) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_132)]->id == 1)) { this->actionFunc = ObjTokeidai_TowerClock_SlideOff; this->slidingClockFaceAngle = 0; this->aerialClockFaceSpeed = -0xD; @@ -415,8 +415,8 @@ void ObjTokeidai_Counterweight_Collapse(ObjTokeidai* this, PlayState* play) { } void ObjTokeidai_Counterweight_OpenedIdle(ObjTokeidai* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 132) && - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 3) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_132) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_132)]->id == 3)) { this->actionFunc = ObjTokeidai_Counterweight_Collapse; this->xRotation = 0; this->actor.velocity.y = 0.0f; @@ -432,32 +432,30 @@ void ObjTokeidai_TerminaFieldWalls_Collapse(ObjTokeidai* this, PlayState* play) } void ObjTokeidai_TerminaFieldWalls_Idle(ObjTokeidai* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 132) != 0 && - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 1) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_132) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_132)]->id == 1)) { this->actionFunc = ObjTokeidai_TerminaFieldWalls_Collapse; } } void ObjTokeidai_TowerOpening_EndCutscene(ObjTokeidai* this, PlayState* play) { - if (Cutscene_CheckActorAction(play, 132) != 0 && - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 5) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_132) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_132)]->id == 5)) { SET_WEEKEVENTREG(WEEKEVENTREG_08_40); - if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && - (play->csCtx.currentCsIndex == 0)) || - ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && - (play->csCtx.currentCsIndex == 0))) { + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.scriptIndex == 0)) || + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.scriptIndex == 0))) { Audio_SetCutsceneFlag(false); - gSaveContext.save.cutscene = 0; + gSaveContext.save.cutsceneIndex = 0; gSaveContext.nextCutsceneIndex = 0; gSaveContext.respawnFlag = 2; play->transitionTrigger = TRANS_TRIGGER_START; play->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_RETURN].entrance; - play->transitionType = TRANS_TYPE_02; + play->transitionType = TRANS_TYPE_FADE_BLACK; if (gSaveContext.respawn[RESPAWN_MODE_RETURN].playerParams == PLAYER_PARAMS(0xFF, PLAYER_INITMODE_TELESCOPE)) { - gSaveContext.nextTransitionType = TRANS_TYPE_21; + gSaveContext.nextTransitionType = TRANS_TYPE_CIRCLE; } else { - gSaveContext.nextTransitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; } } this->actionFunc = ObjTokeidai_DoNothing; @@ -505,15 +503,15 @@ void ObjTokeidai_TowerOpening_DropCounterweight(ObjTokeidai* this, PlayState* pl this->xRotation = 0x4000; switch (this->boundCount) { case 0: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_BOUND_0); + Actor_PlaySfx(&this->actor, NA_SE_EV_CLOCK_TOWER_BOUND_0); break; case 1: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_BOUND_1); + Actor_PlaySfx(&this->actor, NA_SE_EV_CLOCK_TOWER_BOUND_1); break; case 2: - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_BOUND_2); + Actor_PlaySfx(&this->actor, NA_SE_EV_CLOCK_TOWER_BOUND_2); break; } this->boundCount++; @@ -553,7 +551,7 @@ void ObjTokeidai_TowerOpening_FinishRaise(ObjTokeidai* this, PlayState* play) { type = OBJ_TOKEIDAI_TYPE(&this->actor); if ((type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_CLOCK_TOWN) || (type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_FALL); + Actor_PlaySfx(&this->actor, NA_SE_EV_CLOCK_TOWER_FALL); } this->yTranslation = 3400; this->actionFunc = ObjTokeidai_TowerOpening_DropCounterweight; @@ -577,7 +575,7 @@ void ObjTokeidai_TowerOpening_RaiseTower(ObjTokeidai* this, PlayState* play) { type = OBJ_TOKEIDAI_TYPE(&this->actor); if ((type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_CLOCK_TOWN) || (type == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD)) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CLOCK_TOWER_STOP); + Actor_PlaySfx(&this->actor, NA_SE_EV_CLOCK_TOWER_STOP); } this->yTranslation = 3400; this->actionFunc = ObjTokeidai_TowerOpening_FinishRaise; @@ -587,8 +585,8 @@ void ObjTokeidai_TowerOpening_RaiseTower(ObjTokeidai* this, PlayState* play) { } void ObjTokeidai_TowerOpening_Start(ObjTokeidai* this, PlayState* play) { - if ((Cutscene_CheckActorAction(play, 132) && - play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 4) || + if ((Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_132) && + (play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_132)]->id == 4)) || CHECK_WEEKEVENTREG(WEEKEVENTREG_08_40)) { this->actionFunc = ObjTokeidai_TowerOpening_RaiseTower; } @@ -620,7 +618,7 @@ void ObjTokeidai_StaircaseToRooftop_Idle(ObjTokeidai* this, PlayState* play) { } s32 ObjTokeidai_IsPostFirstCycleFinalHours(ObjTokeidai* this, PlayState* play) { - if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[SLOT_OCARINA] == ITEM_NONE) { return false; } if (CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) { @@ -691,14 +689,14 @@ void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, PlayState* play) { return; } - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { this->actor.home.rot.x = 1; this->clockTime += 3; this->actor.draw = ObjTokeidai_Clock_Draw; } else { if (!(play->actorCtx.flags & ACTORCTX_FLAG_1) && OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD && - ActorCutscene_GetCurrentIndex() == -1) { + CutsceneManager_GetCurrentCsId() == CS_ID_NONE) { this->actor.draw = NULL; } this->clockTime = gSaveContext.save.time; @@ -724,14 +722,14 @@ void ObjTokeidai_ExteriorGear_Idle(ObjTokeidai* this, PlayState* play) { if (ObjTokeidai_IsPostFirstCycleFinalHours(this, play)) { this->actor.draw = ObjTokeidai_ExteriorGear_Draw; } else { - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { this->actor.home.rot.x = 1; this->clockTime += 3; this->actor.draw = ObjTokeidai_ExteriorGear_Draw; } else { if (!(play->actorCtx.flags & ACTORCTX_FLAG_1) && (OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_EXTERIOR_GEAR_TERMINA_FIELD) && - (ActorCutscene_GetCurrentIndex() == -1)) { + (CutsceneManager_GetCurrentCsId() == CS_ID_NONE)) { this->actor.draw = NULL; } this->clockTime = gSaveContext.save.time; 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 4dcfd4f74..996bc3810 100644 --- a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c +++ b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c @@ -99,7 +99,7 @@ void ObjTree_Init(Actor* thisx, PlayState* play) { this->dyna.actor.uncullZoneForward = 4000.0f; } else { Actor_SetScale(&this->dyna.actor, 0.1f); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); CollisionHeader_GetVirtual(&object_tree_Colheader_001B2C, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); } @@ -141,7 +141,7 @@ void ObjTree_SetupSway(ObjTree* this) { this->timer = 0; this->swayAmplitude = 546.0f; this->swayVelocity = 35 * 0x10000 / 360; - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_TREE_SWING); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_TREE_SWING); this->actionFunc = ObjTree_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 33b493237..5f0e6c411 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -10,7 +10,7 @@ #include "objects/object_tsubo/object_tsubo.h" #include "objects/object_racetsubo/object_racetsubo.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000 | ACTOR_FLAG_4000000) +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000 | ACTOR_FLAG_CAN_PRESS_SWITCH) #define THIS ((ObjTsubo*)thisx) @@ -148,7 +148,7 @@ void ObjTsubo_SpawnGoldSkulltula(ObjTsubo* this, PlayState* play, s32 arg2) { if (child != NULL) { child->parent = &this->actor; child->velocity.y = 0.0f; - child->speedXZ = 0.0f; + child->speed = 0.0f; } } } @@ -431,7 +431,7 @@ void func_80928914(ObjTsubo* this) { void func_80928928(ObjTsubo* this, PlayState* play) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, 0x44); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40); if (Object_IsLoaded(&play->objectCtx, this->objBankIndex)) { this->actor.objBankIndex = this->objBankIndex; func_809289B4(this); @@ -467,13 +467,13 @@ void func_809289E4(ObjTsubo* this, PlayState* play) { func_80927818(this, play, 0); //! @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->actor, NA_SE_PL_PULL_UP_POT); + Player_PlaySfx((Player*)&this->actor, NA_SE_PL_PULL_UP_POT); func_80928D6C(this); } else if ((this->unk_19B != 0) || (acHit && (this->cylinderCollider.info.acHitInfo->toucher.dmgFlags & 0x058BFFBC))) { typeData = &sPotTypeData[type]; this->unk_19B = 0; - if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 15.0f)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER) && (this->actor.depthInWater > 15.0f)) { typeData->breakPot3(this, play); } else { typeData->breakPot1(this, play); @@ -493,8 +493,10 @@ void func_809289E4(ObjTsubo* this, PlayState* play) { } else { if (!this->unk_195) { Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, 0x44); - if ((this->actor.bgCheckFlags & 1) && (DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId) == NULL)) { + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, + UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40); + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + (DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId) == NULL)) { this->unk_195 = true; this->actor.flags &= ~ACTOR_FLAG_10; } @@ -509,7 +511,7 @@ void func_809289E4(ObjTsubo* this, PlayState* play) { s32 absYawDiff = ABS_ALT(yawDiff); if (absYawDiff > (0x10000 / 3)) { - Actor_PickUp(&this->actor, play, GI_NONE, 36.0f, 30.0f); + Actor_OfferGetItem(&this->actor, play, GI_NONE, 36.0f, 30.0f); } } } @@ -530,8 +532,10 @@ void func_80928D80(ObjTsubo* this, PlayState* play) { if (Actor_HasNoParent(&this->actor, play)) { this->actor.room = play->roomCtx.curRoom.num; Actor_MoveWithGravity(&this->actor); - this->actor.flags &= ~ACTOR_FLAG_4000000; - Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, 0xC5); + this->actor.flags &= ~ACTOR_FLAG_CAN_PRESS_SWITCH; + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40 | + UPDBGCHECKINFO_FLAG_80); func_80928E74(this); } else { pos.x = this->actor.world.pos.x; @@ -568,7 +572,8 @@ void func_80928F18(ObjTsubo* this, PlayState* play) { this->unk_194--; } typeData = &sPotTypeData[type]; - if ((this->actor.bgCheckFlags & 0xB) || atHit || (this->unk_194 <= 0)) { + if ((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_WALL)) || atHit || + (this->unk_194 <= 0)) { typeData->breakPot1(this, play); if (type == OBJ_TSUBO_TYPE_3) { func_8092762C(this, play); @@ -582,7 +587,7 @@ void func_80928F18(ObjTsubo* this, PlayState* play) { } func_809291DC(this); - } else if (this->actor.bgCheckFlags & 0x40) { + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) { typeData->breakPot2(this, play); if (type == OBJ_TSUBO_TYPE_3) { func_8092762C(this, play); @@ -603,7 +608,9 @@ void func_80928F18(ObjTsubo* this, PlayState* play) { Math_StepToS(&D_8092950C, D_80929508, 150); this->actor.shape.rot.x += D_80929504; this->actor.shape.rot.y += D_8092950C; - Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, 0xC5); + Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 15.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_40 | + UPDBGCHECKINFO_FLAG_80); Collider_UpdateCylinder(&this->actor, &this->cylinderCollider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->cylinderCollider.base); CollisionCheck_SetAT(play, &play->colChkCtx, &this->cylinderCollider.base); @@ -621,7 +628,7 @@ void func_809291DC(ObjTsubo* this) { this->actor.shape.rot.x = this->actor.home.rot.x; this->actor.world.rot.x = this->actor.home.rot.x; this->actor.velocity.y = 0.0f; - this->actor.speedXZ = 0.0f; + this->actor.speed = 0.0f; this->actor.shape.rot.y = this->actor.home.rot.y; this->actor.world.rot.y = this->actor.home.rot.y; Actor_SetScale(&this->actor, 0.0f); @@ -640,7 +647,7 @@ void func_8092926C(ObjTsubo* this, PlayState* play) { } else { scale = sPotTypeData[OBJ_TSUBO_GET_TYPE(&this->actor)].scale; if (Math_StepToF(&this->actor.scale.x, scale, scale * 0.1f)) { - this->actor.flags |= ACTOR_FLAG_4000000; + this->actor.flags |= ACTOR_FLAG_CAN_PRESS_SWITCH; func_809289B4(this); } this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; @@ -673,7 +680,7 @@ void ObjTsubo_Update(Actor* thisx, PlayState* play) { } if (this->unk_19A >= 0) { if (this->unk_19A == 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); + Actor_PlaySfx(&this->actor, NA_SE_EN_STALGOLD_ROLL); if (Rand_ZeroOne() < 0.1f) { this->unk_19A = Rand_S16Offset(40, 80); } else { diff --git a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c index 2a819b791..a924c9e06 100644 --- a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c +++ b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c @@ -222,7 +222,7 @@ s32 ObjUm_InitBandits(ObjUm* this, PlayState* play) { EnHorse* bandit2; spawnPoints = Lib_SegmentedToVirtual(path->points); - Audio_QueueSeqCmd(0x8000 | NA_BGM_CHASE); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_CHASE | SEQ_FLAG_ASYNC); bandit1 = (EnHorse*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, spawnPoints[0].x, spawnPoints[0].y, spawnPoints[0].z, 0, this->dyna.actor.shape.rot.y, 0, @@ -410,11 +410,11 @@ s32 func_80B783E0(ObjUm* this, PlayState* play, s32 banditIndex, EnHorse* bandit } bandit->actor.world.rot.y = Math_Vec3f_Yaw(&bandit->actor.world.pos, &sp50); - bandit->actor.speedXZ = 45.0f; + bandit->actor.speed = 45.0f; - sp3C = Math_CosS(bandit->actor.world.rot.x) * bandit->actor.speedXZ; + sp3C = Math_CosS(bandit->actor.world.rot.x) * bandit->actor.speed; bandit->actor.velocity.x = Math_SinS(bandit->actor.world.rot.y) * sp3C; - bandit->actor.velocity.y = Math_SinS(bandit->actor.world.rot.x) * bandit->actor.speedXZ; + bandit->actor.velocity.y = Math_SinS(bandit->actor.world.rot.x) * bandit->actor.speed; bandit->actor.velocity.z = Math_CosS(bandit->actor.world.rot.y) * sp3C; bandit->banditPosition.x = @@ -535,12 +535,12 @@ s32 func_80B78A54(ObjUm* this, PlayState* play, s32 arg2, EnHorse* arg3, EnHorse arg3->unk_564 = 1; if (arg3->rider != NULL) { arg3->rider->actor.colorFilterTimer = 20; - Actor_SetColorFilter(&arg3->rider->actor, 0x4000, 0xFF, 0, 40); + Actor_SetColorFilter(&arg3->rider->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 40); } } else { if (arg3->rider != NULL) { arg3->rider->actor.colorFilterTimer = 20; - Actor_SetColorFilter(&arg3->rider->actor, 0x4000, 0xFF, 0, 40); + Actor_SetColorFilter(&arg3->rider->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 40); } Audio_PlaySfxAtPos(&arg3->actor.projectedPos, NA_SE_EN_CUTBODY); } @@ -620,13 +620,13 @@ void func_80B78EBC(ObjUm* this, PlayState* play) { player->actor.focus.rot.z = 0; player->actor.focus.rot.y = player->actor.shape.rot.y; - player->unk_AAC.x = 0; - player->unk_AAC.y = 0; - player->unk_AAC.z = 0; + player->headLimbRot.x = 0; + player->headLimbRot.y = 0; + player->headLimbRot.z = 0; - player->unk_AB2.x = 0; - player->unk_AB2.y = 0; - player->unk_AB2.z = 0; + player->upperLimbRot.x = 0; + player->upperLimbRot.y = 0; + player->upperLimbRot.z = 0; player->currentYaw = player->actor.focus.rot.y; } @@ -763,7 +763,7 @@ void ObjUm_Init(Actor* thisx, PlayState* play) { DynaPolyActor_Init(&this->dyna, 0); DynaPolyActor_LoadMesh(play, &this->dyna, &object_um_Colheader_007E20); } else { - DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS | DYNA_TRANSFORM_ROT_Y); DynaPolyActor_LoadMesh(play, &this->dyna, &object_um_Colheader_007F50); } @@ -772,7 +772,7 @@ void ObjUm_Init(Actor* thisx, PlayState* play) { return; } - func_800C636C(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DisableCeilingCollision(play, &play->colCtx.dyna, this->dyna.bgId); this->donkey = (EnHorse*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, this->dyna.actor.world.pos.x, @@ -838,7 +838,7 @@ s32 func_80B795A0(PlayState* play, ObjUm* this, s32 arg2) { D_801BDAA0 = 1; } play->transitionType = TRANS_TYPE_64; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; play->transitionTrigger = TRANS_TRIGGER_START; phi_v1 = true; } else { @@ -937,7 +937,7 @@ s32 func_80B7984C(PlayState* play, ObjUm* this, s32 arg2, s32* arg3) { return 0; } if (*arg3 == 3) { - func_80151938(play, this->dyna.actor.textId); + Message_ContinueTextbox(play, this->dyna.actor.textId); *arg3 = 1; return 0; } @@ -1122,9 +1122,9 @@ ObjUmPathState ObjUm_UpdatePath(ObjUm* this, PlayState* play) { } if (this->animIndex == OBJ_UM_ANIM_TROT) { - this->dyna.actor.speedXZ = 4.0f; + this->dyna.actor.speed = 4.0f; } else if (this->animIndex == OBJ_UM_ANIM_GALLOP) { - this->dyna.actor.speedXZ = 8.0f; + this->dyna.actor.speed = 8.0f; } return sp3C; @@ -1139,10 +1139,10 @@ void ObjUm_RanchWaitPathFinished(ObjUm* this, PlayState* play) { case OBJUM_PATH_STATE_1: case OBJUM_PATH_STATE_FINISH: if (CHECK_WEEKEVENTREG(WEEKEVENTREG_31_80)) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); play->nextEntrance = ENTRANCE(MILK_ROAD, 5); play->transitionType = TRANS_TYPE_64; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; play->transitionTrigger = TRANS_TRIGGER_START; } else { func_80B79524(this); @@ -1158,12 +1158,12 @@ void ObjUm_RanchWaitPathFinished(ObjUm* this, PlayState* play) { void ObjUm_RanchStartCs(ObjUm* this, PlayState* play) { ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_IDLE); - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); this->lastTime = gSaveContext.save.time; ObjUm_SetupAction(this, func_80B7A0E0); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -1245,7 +1245,7 @@ void func_80B7A2AC(ObjUm* this, PlayState* play) { case OBJUM_PATH_STATE_FINISH: play->nextEntrance = ENTRANCE(GORMAN_TRACK, 4); play->transitionType = TRANS_TYPE_64; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; play->transitionTrigger = TRANS_TRIGGER_START; break; @@ -1276,12 +1276,12 @@ void ObjUm_PreMilkRunStartCs(ObjUm* this, PlayState* play) { ObjUm_SetPlayerPosition(this, play); this->flags |= OBJ_UM_FLAG_0004; player->stateFlags1 |= PLAYER_STATE1_20; - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); this->lastTime = gSaveContext.save.time; ObjUm_SetupAction(this, func_80B7A394); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -1303,14 +1303,14 @@ void ObjUm_RunMinigame(ObjUm* this, PlayState* play) { if (!this->areAllPotsBroken) { play->nextEntrance = ENTRANCE(MILK_ROAD, 6); play->transitionType = TRANS_TYPE_64; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; play->transitionTrigger = TRANS_TRIGGER_START; SET_WEEKEVENTREG(WEEKEVENTREG_52_01); CLEAR_WEEKEVENTREG(WEEKEVENTREG_52_02); } else { play->nextEntrance = ENTRANCE(ROMANI_RANCH, 8); play->transitionType = TRANS_TYPE_64; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; play->transitionTrigger = TRANS_TRIGGER_START; SET_WEEKEVENTREG(WEEKEVENTREG_52_02); CLEAR_WEEKEVENTREG(WEEKEVENTREG_52_01); @@ -1357,17 +1357,17 @@ void func_80B7A614(ObjUm* this, PlayState* play) { } if (this->flags & OBJ_UM_FLAG_MINIGAME_FINISHED) { - s32 sp20 = ActorCutscene_GetAdditionalCutscene(this->dyna.actor.cutscene); + s32 csId = CutsceneManager_GetAdditionalCsId(this->dyna.actor.csId); if (this->areAllPotsBroken) { - sp20 = ActorCutscene_GetAdditionalCutscene(sp20); + csId = CutsceneManager_GetAdditionalCsId(csId); } - if (ActorCutscene_GetCanPlayNext(sp20)) { - ActorCutscene_StartAndSetUnkLinkFields(sp20, &this->dyna.actor); + if (CutsceneManager_IsNext(csId)) { + CutsceneManager_StartWithPlayerCs(csId, &this->dyna.actor); ObjUm_SetupAction(this, ObjUm_RunMinigame); this->flags &= ~OBJ_UM_FLAG_PLAYING_MINIGAME; } else { - ActorCutscene_SetIntentToPlay(sp20); + CutsceneManager_Queue(csId); } } @@ -1396,14 +1396,14 @@ void func_80B7A860(ObjUm* this, PlayState* play) { ObjUm_RotatePlayer(this, play, 0); this->flags |= OBJ_UM_FLAG_0004; - if (play->csCtx.frames == 449) { + if (play->csCtx.curFrame == 449) { ObjUm_InitBandits(this, play); - } else if (play->csCtx.frames >= 450) { + } else if (play->csCtx.curFrame >= 450) { func_80B78DF0(this, play); } - if (play->csCtx.state == 0) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + if (play->csCtx.state == CS_STATE_IDLE) { + CutsceneManager_Stop(this->dyna.actor.csId); ObjUm_SetupAction(this, func_80B7A7AC); } @@ -1526,12 +1526,12 @@ void ObjUm_StartCs(ObjUm* this, PlayState* play) { ObjUm_RotatePlayer(this, play, 0); this->flags |= OBJ_UM_FLAG_0004; - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); this->lastTime = gSaveContext.save.time; ObjUm_SetupAction(this, func_80B7ABE4); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -1546,13 +1546,13 @@ void ObjUm_PostMilkRunWaitPathFinished(ObjUm* this, PlayState* play) { ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_TROT); if ((ObjUm_UpdatePath(this, play) == OBJUM_PATH_STATE_4) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_02)) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); Audio_SetCutsceneFlag(false); SET_WEEKEVENTREG(WEEKEVENTREG_59_02); gSaveContext.nextCutsceneIndex = 0xFFF3; play->nextEntrance = ENTRANCE(TERMINA_FIELD, 0); play->transitionType = TRANS_TYPE_64; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.save.time += CLOCK_TIME(1, 0) + 2; } @@ -1568,11 +1568,11 @@ void ObjUm_PostMilkRunStartCs(ObjUm* this, PlayState* play) { this->flags |= OBJ_UM_FLAG_0004; ObjUm_ChangeAnim(this, play, OBJ_UM_ANIM_IDLE); - if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); ObjUm_SetupAction(this, ObjUm_PostMilkRunWaitPathFinished); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } } @@ -1656,9 +1656,9 @@ void ObjUm_ChangeAnim(ObjUm* this, PlayState* play, ObjUmAnimation animIndex) { } if (animIndex == OBJ_UM_ANIM_TROT) { - animPlaybackSpeed = this->dyna.actor.speedXZ * 0.25f; + animPlaybackSpeed = this->dyna.actor.speed * 0.25f; } else if (animIndex == OBJ_UM_ANIM_GALLOP) { - animPlaybackSpeed = this->dyna.actor.speedXZ * 0.2f; + animPlaybackSpeed = this->dyna.actor.speed * 0.2f; } else if (animIndex == OBJ_UM_ANIM_IDLE) { animPlaybackSpeed = 1.0f; } @@ -1703,8 +1703,8 @@ void ObjUm_ChangeAnim(ObjUm* this, PlayState* play, ObjUmAnimation animIndex) { if (this->wheelRot / 0x199A != this->unk_420) { this->unk_420 = this->wheelRot / 0x199A; //! FAKE - if (!&sUmAnims[0]) {} - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CART_WHEEL); + if (sUmAnims[0].doesMove) {} + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_CART_WHEEL); } } @@ -1713,7 +1713,8 @@ void ObjUm_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); this->unk_350++; - Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x1C); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, + UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); if (this->donkey != NULL) { this->donkey->actor.world.pos.x = this->dyna.actor.world.pos.x; diff --git a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c index 24e816644..46a6b994d 100644 --- a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c +++ b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c @@ -45,9 +45,9 @@ s32 func_80C07C80(s32 arg0) { s32 var_v1; if (!(arg0 & 1)) { - var_v1 = gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF; + var_v1 = gSaveContext.save.saveInfo.unk_E64[arg0 >> 1] & 0xFFFF; } else { - var_v1 = (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF0000) >> 0x10; + var_v1 = (gSaveContext.save.saveInfo.unk_E64[arg0 >> 1] & 0xFFFF0000) >> 0x10; } return var_v1 + CLOCK_TIME(2, 30); } @@ -139,7 +139,7 @@ void func_80C07F30(ObjUsiyane* this, PlayState* play) { } } - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_HOUSE_BROKEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_HOUSE_BROKEN); this->unk_740 = 0; this->unk_744 |= 4; } @@ -172,18 +172,18 @@ void func_80C081C8(ObjUsiyane* this, PlayState* play) { } void func_80C082CC(ObjUsiyane* this, PlayState* play) { - this->unk_164 = -1; + this->cueId = -1; } void func_80C082E0(ObjUsiyane* this, PlayState* play) { - CsCmdActorAction* csAction; + CsCmdActorCue* cue; - if (Cutscene_CheckActorAction(play, 0x228)) { - this->unk_160 = Cutscene_GetActorActionIndex(play, 0x228); - csAction = play->csCtx.actorActions[this->unk_160]; - if (this->unk_164 != csAction->action) { - this->unk_164 = csAction->action; - if (this->unk_164 == 2) { + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_552)) { + this->cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_552); + cue = play->csCtx.actorCues[this->cueChannel]; + if (this->cueId != cue->id) { + this->cueId = cue->id; + if (this->cueId == 2) { func_80C07F30(this, play); this->actionFunc = func_80C081C8; } diff --git a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h index 2abc2a38b..92bd96549 100644 --- a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h +++ b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h @@ -24,8 +24,8 @@ typedef struct { typedef struct ObjUsiyane { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ ObjUsiyaneActionFunc actionFunc; - /* 0x160 */ s32 unk_160; - /* 0x164 */ s32 unk_164; + /* 0x160 */ s32 cueChannel; + /* 0x164 */ s32 cueId; /* 0x168 */ ObjUsiyaneStruct unk_168[10][4]; /* 0x708 */ f32 unk_708; /* 0x70C */ f32 unk_70C; 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 4b0a797f6..9859d9c0f 100644 --- a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c +++ b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c @@ -7,7 +7,7 @@ #include "z_obj_visiblock.h" #include "objects/object_visiblock/object_visiblock.h" -#define FLAGS (ACTOR_FLAG_80) +#define FLAGS (ACTOR_FLAG_REACT_TO_LENS) #define THIS ((ObjVisiblock*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c index b7a1e59be..257e9eb79 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -123,14 +123,14 @@ s32 func_80A3C700(ObjVspinyroll* this) { s32 sp30 = this->unk_398 ^ 1; Vec3f sp24; - Math_StepToF(&this->dyna.actor.speedXZ, this->unk_394, this->unk_394 * 0.2f); + Math_StepToF(&this->dyna.actor.speed, this->unk_394, this->unk_394 * 0.2f); - this->dyna.actor.world.pos.x += this->dyna.actor.speedXZ * this->unk_3B4.x; - this->dyna.actor.world.pos.y += this->dyna.actor.speedXZ * this->unk_3B4.y; - this->dyna.actor.world.pos.z += this->dyna.actor.speedXZ * this->unk_3B4.z; + this->dyna.actor.world.pos.x += this->dyna.actor.speed * this->unk_3B4.x; + this->dyna.actor.world.pos.y += this->dyna.actor.speed * this->unk_3B4.y; + this->dyna.actor.world.pos.z += this->dyna.actor.speed * this->unk_3B4.z; Math_Vec3f_Diff(&this->unk_39C[sp30], &this->dyna.actor.world.pos, &sp24); - return Math3D_LengthSquared(&sp24) < (SQ(this->dyna.actor.speedXZ) + 0.05f); + return Math3D_LengthSquared(&sp24) < (SQ(this->dyna.actor.speed) + 0.05f); } void func_80A3C7E8(ObjVspinyroll* this) { @@ -208,7 +208,7 @@ s32 func_80A3C8D8(ObjVspinyroll* this, PlayState* play, Vec3f* arg2, s32 arg3) { spB4.z += this->dyna.actor.world.pos.z; EffectSsHitmark_SpawnFixedScale(play, 3, &spB4); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); + Actor_PlaySfx(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); } temp_f0 = Math3D_Vec3fDistSq(&spD8, &spC0); @@ -322,7 +322,7 @@ void ObjVspinyroll_Destroy(Actor* thisx, PlayState* play) { } void func_80A3CEC4(ObjVspinyroll* this) { - this->dyna.actor.speedXZ = 0.0f; + this->dyna.actor.speed = 0.0f; this->actionFunc = func_80A3CEE0; } @@ -336,7 +336,7 @@ void func_80A3CEE0(ObjVspinyroll* this, PlayState* play) { void func_80A3CF10(ObjVspinyroll* this) { this->actionFunc = func_80A3CF4C; this->unk_3C8 = D_80A3D478[OBJVSPINYROLL_GET_1C00(&this->dyna.actor)]; - this->dyna.actor.speedXZ = 0.0f; + this->dyna.actor.speed = 0.0f; } void func_80A3CF4C(ObjVspinyroll* this, PlayState* play) { @@ -351,7 +351,7 @@ void func_80A3CF4C(ObjVspinyroll* this, PlayState* play) { void func_80A3CFAC(ObjVspinyroll* this) { this->actionFunc = func_80A3CFE0; this->unk_3C2 = D_80A3D4DC[this->unk_398]; - this->dyna.actor.speedXZ = 0.0f; + this->dyna.actor.speed = 0.0f; } void func_80A3CFE0(ObjVspinyroll* this, PlayState* play) { 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 3fa3260fd..075ad18db 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -97,19 +97,19 @@ s32 ObjWarpstone_ClosedIdle(ObjWarpstone* this, PlayState* play) { } s32 ObjWarpstone_BeginOpeningCutscene(ObjWarpstone* this, PlayState* play) { - if (this->dyna.actor.cutscene < 0 || ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if ((this->dyna.actor.csId < 0) || CutsceneManager_IsNext(this->dyna.actor.csId)) { + CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor); ObjWarpstone_SetupAction(this, ObjWarpstone_PlayOpeningCutscene); - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_OWL_WARP_SWITCH_ON); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_OWL_WARP_SWITCH_ON); } else { - ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + CutsceneManager_Queue(this->dyna.actor.csId); } return true; } s32 ObjWarpstone_PlayOpeningCutscene(ObjWarpstone* this, PlayState* play) { if (this->openingCSTimer++ >= OBJ_WARPSTONE_TIMER_ACTIVATE_THRESHOLD) { - ActorCutscene_Stop(this->dyna.actor.cutscene); + CutsceneManager_Stop(this->dyna.actor.csId); Sram_ActivateOwl(OBJ_WARPSTONE_GET_ID(&this->dyna.actor)); ObjWarpstone_SetupAction(this, ObjWarpstone_OpenedIdle); } else if (this->openingCSTimer < OBJ_WARPSTONE_TIMER_OPEN_THRESHOLD) { @@ -146,7 +146,7 @@ void ObjWarpstone_Update(Actor* thisx, PlayState* play) { play->msgCtx.unk120D4 = 0; gSaveContext.save.owlSaveLocation = OBJ_WARPSTONE_GET_ID(&this->dyna.actor); } else { - func_801477B4(play); + Message_CloseTextbox(play); } } } else if (Actor_ProcessTalkRequest(&this->dyna.actor, &play->state)) { @@ -179,11 +179,11 @@ void ObjWarpstone_Draw(Actor* thisx, PlayState* play2) { gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 255, 255, 200, this->dyna.actor.home.rot.x); gDPSetEnvColor(POLY_XLU_DISP++, 100, 200, 0, 255); - Matrix_RotateZF((((play->gameplayFrames * 1500) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); + Matrix_RotateZF(BINANG_TO_RAD_ALT2((play->gameplayFrames * 1500) & 0xFFFF), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); Matrix_Pop(); - Matrix_RotateZF((~((play->gameplayFrames * 1200) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); + Matrix_RotateZF(BINANG_TO_RAD_ALT2(~((play->gameplayFrames * 1200) & 0xFFFF)), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); CLOSE_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h index a2db609d6..241eb825d 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h @@ -27,6 +27,6 @@ typedef struct ObjWarpstone { } ObjWarpstone; // size = 0x1B0 #define OBJ_WARPSTONE_GET_ID(thisx) ((u16)((thisx)->params & 0xF)) -#define OBJ_WARPSTONE_IS_ACTIVATED(owlId) (((void)0, gSaveContext.save.playerData.owlActivationFlags) & (u16)gBitFlags[(owlId)]) +#define OBJ_WARPSTONE_IS_ACTIVATED(owlId) (((void)0, gSaveContext.save.saveInfo.playerData.owlActivationFlags) & (u16)gBitFlags[(owlId)]) #endif // Z_OBJ_WARPSTONE_H diff --git a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c index 184fed3d6..54ebe8cc7 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c @@ -52,15 +52,15 @@ void func_808A7968(ObjWturn* this, PlayState* play) { } void func_808A7A24(ObjWturn* this) { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); this->actionFunc = func_808A7A5C; } void func_808A7A5C(ObjWturn* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + if (CutsceneManager_IsNext(this->actor.csId)) { func_808A7AAC(this, play); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -69,9 +69,9 @@ void func_808A7AAC(ObjWturn* this, PlayState* play) { Vec3f subCamEye; Vec3f subCamAt; - ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); - func_8016566C(140); - this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + CutsceneManager_StartWithPlayerCs(this->actor.csId, &this->actor); + Play_EnableMotionBlur(140); + this->subCamId = CutsceneManager_GetCurrentSubCamId(this->actor.csId); func_800B7298(play, &this->actor, PLAYER_CSMODE_21); subCamAt.x = player->actor.focus.pos.x; subCamAt.z = player->actor.focus.pos.z; @@ -97,9 +97,9 @@ void func_808A7C04(ObjWturn* this, PlayState* play) { this->actor.world.pos.y += this->actor.playerHeightRel; player->actor.shape.shadowAlpha = 0; func_800B7298(play, &this->actor, PLAYER_CSMODE_84); - func_800B8E58(player, NA_SE_VO_NAVY_ENEMY); + Player_PlaySfx(player, NA_SE_VO_NAVY_ENEMY); this->unk_14A = 0; - func_80165690(); + Play_DisableMotionBlur(); this->actionFunc = func_808A7C78; } @@ -113,7 +113,7 @@ void func_808A7C78(ObjWturn* this, PlayState* play) { Play_SetCameraAtEyeUp(play, this->subCamId, &player->actor.focus.pos, &subCam->eye, &sSubCamUp); if (this->unk_14A == 1) { play->transitionType = TRANS_TYPE_64; - gSaveContext.nextTransitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; gSaveContext.nextCutsceneIndex = 0; if (play->sceneId == SCENE_F40) { play->nextEntrance = ENTRANCE(STONE_TOWER_INVERTED, 0); diff --git a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c index 9399940d8..96de17fb0 100644 --- a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c +++ b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c @@ -39,7 +39,7 @@ void ObjY2lift_Init(Actor* thisx, PlayState* play) { ObjY2lift* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &gPirateLiftPlatformCol); } @@ -53,13 +53,13 @@ void ObjY2lift_Update(Actor* thisx, PlayState* play) { ObjY2lift* this = THIS; f32 temp_fv0 = this->dyna.actor.world.pos.y; f32 targetVelocityY = 0.0f; - s32 temp_v0 = DynaPolyActor_IsInRidingMovingState(&this->dyna); + s32 isPlayerOnTop = DynaPolyActor_IsPlayerOnTop(&this->dyna); - if (temp_v0 || DynaPolyActor_IsInRidingFallingState(&this->dyna)) { + if (isPlayerOnTop || DynaPolyActor_IsActorOnTop(&this->dyna)) { if (!this->unk15D) { this->unk15D = true; this->unk15F = 12; - } else if (this->unk15F == 0 && temp_v0) { + } else if ((this->unk15F == 0) && isPlayerOnTop) { this->unk15C = 16; } } else { @@ -68,7 +68,7 @@ void ObjY2lift_Update(Actor* thisx, PlayState* play) { if (DECR(this->unk15C) != 0) { temp_fv0 = this->dyna.actor.home.pos.y + 180.0f; targetVelocityY = 2.0f; - } else if (!temp_v0 && this->dyna.actor.velocity.y <= 0.0f) { + } else if (!isPlayerOnTop && (this->dyna.actor.velocity.y <= 0.0f)) { temp_fv0 = this->dyna.actor.home.pos.y; targetVelocityY = -2.0f; } diff --git a/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c b/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c index 9d35288c5..cea1a4e71 100644 --- a/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c +++ b/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c @@ -73,7 +73,7 @@ void ObjY2shutter_SetupOpen(ObjY2shutter* this, ShutterInfo* info, ShutterType s this->openTimer = info->openTimer; this->settleTimer = info->openStartSettleTimer; if (shutterType == SHUTTER_BARRED) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_METALDOOR_OPEN); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_METALDOOR_OPEN); } } @@ -105,19 +105,19 @@ void ObjY2shutter_Update(Actor* thisx, PlayState* play) { if (this->settleTimer == 0) { if (Flags_GetSwitch(play, OBJY2SHUTTER_GET_SWITCHFLAG(&this->dyna.actor))) { - s16 cutscene = this->dyna.actor.cutscene; + s16 csId = this->dyna.actor.csId; if (this->openTimer == 0) { - if ((cutscene >= 0) && !ActorCutscene_GetCanPlayNext(cutscene)) { - ActorCutscene_SetIntentToPlay(cutscene); - } else if (cutscene >= 0) { - ActorCutscene_StartAndSetUnkLinkFields(cutscene, &this->dyna.actor); + if ((csId >= 0) && !CutsceneManager_IsNext(csId)) { + CutsceneManager_Queue(csId); + } else if (csId >= 0) { + CutsceneManager_StartWithPlayerCs(csId, &this->dyna.actor); this->openTimer = -1; } else { ObjY2shutter_SetupOpen(this, info, shutterType); } } else if (this->openTimer < 0) { - if (func_800F22C4(cutscene, &this->dyna.actor)) { + if (func_800F22C4(csId, &this->dyna.actor) != 0) { ObjY2shutter_SetupOpen(this, info, shutterType); } } else { @@ -134,7 +134,7 @@ void ObjY2shutter_Update(Actor* thisx, PlayState* play) { this->openTimer = 0; this->settleTimer = info->openStartSettleTimer; if (shutterType == SHUTTER_BARRED) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_METALDOOR_CLOSE); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_METALDOOR_CLOSE); } } else { targetPosY = this->dyna.actor.home.pos.y; @@ -153,7 +153,7 @@ void ObjY2shutter_Update(Actor* thisx, PlayState* play) { this->isStationary = true; this->settleTimer = info->openEndAndCloseSettleTimer; if (shutterType != SHUTTER_BARRED) { - Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_METALDOOR_STOP); + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_METALDOOR_STOP); } } } else { diff --git a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c index 0d0db6385..f869b95ac 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c +++ b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c @@ -72,15 +72,15 @@ void OceffWipe5_Draw(Actor* thisx, PlayState* play) { s32 i; s32 pad2; Vec3f activeCamEye = GET_ACTIVE_CAM(play)->eye; - Camera* cam = GET_ACTIVE_CAM(play); + Camera* activeCam = GET_ACTIVE_CAM(play); Vec3f quakeOffset; u8 alpha; s32 colorIndex = OCEFF_WIPE5_GET_SONG_TYPE(thisx) * 3; f32 phi_fv1 = 1220.0f; if ((((OCEFF_WIPE5_GET_SONG_TYPE(thisx) == 2) && (play->sceneId == SCENE_LABO)) && - ((play->csCtx.currentCsIndex == 0) || (play->csCtx.currentCsIndex == 1))) && - (play->csCtx.state != 0)) { + ((play->csCtx.scriptIndex == 0) || (play->csCtx.scriptIndex == 1))) && + (play->csCtx.state != CS_STATE_IDLE)) { phi_fv1 = 1150.0f; } @@ -88,7 +88,7 @@ void OceffWipe5_Draw(Actor* thisx, PlayState* play) { colorIndex = 0; } - Camera_GetQuakeOffset(&quakeOffset, cam); + Camera_GetQuakeOffset(&quakeOffset, activeCam); if (this->counter < 32) { z = Math_SinS(this->counter << 9) * phi_fv1; diff --git a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c index 74e711cfa..f237bed47 100644 --- a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c +++ b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c @@ -61,7 +61,7 @@ void ShotSun_Init(Actor* thisx, PlayState* play) { this->actor.flags |= ACTOR_FLAG_10; this->actor.flags |= ACTOR_FLAG_2000000; this->actionFunc = ShotSun_UpdateForOcarina; - this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_CANT_LOCK_ON; } else { Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); @@ -87,7 +87,7 @@ void ShotSun_SpawnFairy(ShotSun* this, PlayState* play2) { if (this->timer > 0) { this->timer--; } else { - ActorCutscene_Stop(this->actor.cutscene); + CutsceneManager_Stop(this->actor.csId); switch (params) { case SHOTSUN_FAIRY_SPAWNER_SUNS: fairyType = ENELF_TYPE_7; @@ -103,9 +103,9 @@ void ShotSun_SpawnFairy(ShotSun* this, PlayState* play2) { } void ShotSun_TriggerFairy(ShotSun* this, PlayState* play) { - if ((this->actor.cutscene == -1) || ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - if (this->actor.cutscene != -1) { - ActorCutscene_Start(this->actor.cutscene, &this->actor); + if ((this->actor.csId == CS_ID_NONE) || CutsceneManager_IsNext(this->actor.csId)) { + if (this->actor.csId != CS_ID_NONE) { + CutsceneManager_Start(this->actor.csId, &this->actor); } this->actionFunc = ShotSun_SpawnFairy; this->timer = 50; @@ -113,7 +113,7 @@ void ShotSun_TriggerFairy(ShotSun* this, PlayState* play) { this->actor.home.pos.z, 0, 0, 0, 0x11); Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_TRE_BOX_APPEAR); } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + CutsceneManager_Queue(this->actor.csId); } } @@ -160,7 +160,7 @@ void ShotSun_UpdateHyliaSun(ShotSun* this, PlayState* play) { collectible = (EnItem00*)Item_DropCollectible(play, &spawnPos, ITEM00_MAGIC_LARGE); if (collectible != NULL) { collectible->unk152 = 0x1770; - collectible->actor.speedXZ = 0.0f; + collectible->actor.speed = 0.0f; } } 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 8c1e98bed..6279c367e 100644 --- a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c +++ b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c @@ -5,6 +5,7 @@ */ #include "z_tg_sw.h" +#include "z64debug_display.h" #define FLAGS (ACTOR_FLAG_10) @@ -33,18 +34,17 @@ ActorInit TG_Sw_InitVars = { void TGSw_ActionDecider(TGSw* this, PlayState* play) { f32 scaledAbsoluteRotZ; f32 scaledAbsoluteRotY; - u8 unk1F4; + PlayerImpactType playerImpactType; - // Maybe actorCtx Debug Flag? - if (play->actorCtx.unk1F5 != 0) { + if (play->actorCtx.playerImpact.timer != 0) { scaledAbsoluteRotY = ABS_ALT(this->actor.world.rot.y) * 4.0f; scaledAbsoluteRotZ = ABS_ALT(this->actor.world.rot.z) * 4.0f; if ((scaledAbsoluteRotZ < this->actor.xzDistToPlayer) || (scaledAbsoluteRotY < this->actor.playerHeightRel)) { return; } - unk1F4 = play->actorCtx.unk1F4; - if (unk1F4 == 2 || unk1F4 == 0) { + playerImpactType = play->actorCtx.playerImpact.type; + if ((playerImpactType == PLAYER_IMPACT_BONK) || (playerImpactType == PLAYER_IMPACT_GORON_GROUND_POUND)) { this->actionFunc = TGSw_ActionExecuteOneShot; } } @@ -62,7 +62,7 @@ void TGSw_ActionExecuteOneShot(TGSw* this, PlayState* play) { } if ((((this->actor.params & 0xFC) >> 2) & 0xFF) == (((actor->params & 0xFC) >> 2) & 0xFF)) { actor->parent = &this->actor; - actor->speedXZ = ABS_ALT(this->actor.world.rot.x); + actor->speed = ABS_ALT(this->actor.world.rot.x); break; } actor = actor->next; @@ -78,7 +78,7 @@ void TGSw_ActionExecuteOneShot(TGSw* this, PlayState* play) { } if ((((this->actor.params & 0xFC) >> 2) & 0xFF) == (((actor->params & 0xFC) >> 2) & 0xFF)) { actor->parent = &this->actor; - actor->speedXZ = ABS_ALT(this->actor.world.rot.x); + actor->speed = ABS_ALT(this->actor.world.rot.x); break; } actor = actor->next; @@ -90,7 +90,7 @@ void TGSw_ActionExecuteOneShot(TGSw* this, PlayState* play) { void TGSw_Init(Actor* thisx, PlayState* play) { TGSw* this = THIS; - this->actor.cutscene = this->actor.world.rot.z; + this->actor.csId = this->actor.world.rot.z; this->actionFunc = TGSw_ActionDecider; } diff --git a/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c b/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c index 09c2afb11..ef88015b7 100644 --- a/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c +++ b/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c @@ -14,7 +14,7 @@ u32 EffectEnIceBlock_Init(PlayState* play, u32 index, EffectSs* this, void* init void EffectEnIceBlock_Update(PlayState* play, u32 index, EffectSs* this); void EffectEnIceBlock_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_En_Ice_Block_InitVars = { +EffectSsInit Effect_En_Ice_Block_InitVars = { EFFECT_EN_ICE_BLOCK, EffectEnIceBlock_Init, }; diff --git a/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.h b/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.h index e5377b20f..2707d64c8 100644 --- a/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.h +++ b/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.h @@ -11,6 +11,4 @@ typedef struct { /* 0x28 */ s16 scale; } EffectEnIceBlockInitParams; // size = 0x2C -extern const EffectSsInit Effect_En_Ice_Block_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c index 93353f28c..2d80b4161 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c +++ b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.c @@ -26,7 +26,7 @@ u32 EffectSsBlast_Init(PlayState* play, u32 index, EffectSs* this, void* initPar void EffectSsBlast_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsBlast_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Blast_InitVars = { +EffectSsInit Effect_Ss_Blast_InitVars = { EFFECT_SS_BLAST, EffectSsBlast_Init, }; @@ -70,7 +70,7 @@ void EffectSsBlast_Draw(PlayState* play, u32 index, EffectSs* this) { func_8012C2DC(play->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); - func_801691F0(play, &mf, &this->pos); + Play_GetFloorSurface(play, &mf, &this->pos); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); Matrix_Put(&mf); Matrix_Scale(radius, radius, radius, MTXMODE_APPLY); diff --git a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h index 72a264c03..1e9087d85 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h +++ b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h @@ -15,6 +15,4 @@ typedef struct { /* 0x32 */ s16 life; } EffectSsBlastInitParams; // size = 0x34 -extern const EffectSsInit Effect_Ss_Blast_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c b/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c index d15151d49..b17a43fbe 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c @@ -26,7 +26,7 @@ void EffectSsBomb2_DrawFade(PlayState* play, u32 index, EffectSs* this); void EffectSsBomb2_DrawLayered(PlayState* play, u32 index, EffectSs* this); void EffectSsBomb2_Update(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Bomb2_InitVars = { +EffectSsInit Effect_Ss_Bomb2_InitVars = { EFFECT_SS_BOMB2, EffectSsBomb2_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.h b/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.h index 468e2c016..4a63bd4c8 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.h +++ b/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.h @@ -12,6 +12,4 @@ typedef struct { /* 0x28 */ u8 drawMode; } EffectSsBomb2InitParams; // size = 0x30 -extern const EffectSsInit Effect_Ss_Bomb2_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c index 3298b2ab3..681aac01d 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c @@ -17,12 +17,16 @@ u32 EffectSsBubble_Init(PlayState* play, u32 index, EffectSs* this, void* initPa void EffectSsBubble_Update(PlayState* play2, u32 index, EffectSs* this); void EffectSsBubble_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Bubble_InitVars = { +EffectSsInit Effect_Ss_Bubble_InitVars = { EFFECT_SS_BUBBLE, EffectSsBubble_Init, }; -static f32 sVecAdjMaximums[] = { 291.0f, 582.0f, 1600.0f }; +static f32 sVecAdjMaximums[] = { + 291.0f, // CONVEYOR_SPEED_SLOW + 582.0f, // CONVEYOR_SPEED_MEDIUM + 1600.0f, // CONVEYOR_SPEED_FAST +}; u32 EffectSsBubble_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { EffectSsBubbleInitParams* initParams = (EffectSsBubbleInitParams*)initParamsx; @@ -85,17 +89,18 @@ void EffectSsBubble_Update(PlayState* play2, u32 index, EffectSs* this) { } if (((play->gameplayFrames + index) % 8) == 0) { CollisionPoly* colPoly; - u32 speed; - s16 direction; + ConveyorSpeed conveyorSpeed; + s16 conveyorDir; f32 rVecAdjMax; BgCheck_EntityRaycastFloor2_1(play, &play->colCtx, &colPoly, &this->pos); - speed = SurfaceType_GetConveyorSpeed(&play->colCtx, colPoly, BGCHECK_SCENE); - if ((speed != 0) && !SurfaceType_IsFloorConveyor(&play->colCtx, colPoly, BGCHECK_SCENE)) { - direction = SurfaceType_GetConveyorDirection(&play->colCtx, colPoly, BGCHECK_SCENE) << 0xA; - rVecAdjMax = sVecAdjMaximums[speed - 1]; - this->rVecAdjX = Math_SinS(direction) * rVecAdjMax; - this->rVecAdjZ = Math_CosS(direction) * rVecAdjMax; + conveyorSpeed = SurfaceType_GetConveyorSpeed(&play->colCtx, colPoly, BGCHECK_SCENE); + if ((conveyorSpeed != CONVEYOR_SPEED_DISABLED) && + !SurfaceType_IsFloorConveyor(&play->colCtx, colPoly, BGCHECK_SCENE)) { + conveyorDir = SurfaceType_GetConveyorDirection(&play->colCtx, colPoly, BGCHECK_SCENE) << 10; + rVecAdjMax = sVecAdjMaximums[conveyorSpeed - 1]; + this->rVecAdjX = Math_SinS(conveyorDir) * rVecAdjMax; + this->rVecAdjZ = Math_CosS(conveyorDir) * rVecAdjMax; } } this->vec.x += this->rVecAdjX / 100.0f; diff --git a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.h b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.h index 0916a95ca..9e57bc657 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.h +++ b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.h @@ -11,6 +11,4 @@ typedef struct { /* 0x18 */ f32 scale; } EffectSsBubbleInitParams; // size = 0x1C -extern const EffectSsInit Effect_Ss_Bubble_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c index 9d8eecfbc..d8394b159 100644 --- a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.c @@ -21,7 +21,7 @@ u32 EffectSsDFire_Init(PlayState* play, u32 index, EffectSs* this, void* initPar void EffectSsDFire_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsDFire_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_D_Fire_InitVars = { +EffectSsInit Effect_Ss_D_Fire_InitVars = { EFFECT_SS_D_FIRE, EffectSsDFire_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h index 2d657bc43..e72616b84 100644 --- a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h +++ b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h @@ -15,6 +15,4 @@ typedef struct { /* 0x30 */ s32 life; } EffectSsDFireInitParams; // size = 0x34 -extern const EffectSsInit Effect_Ss_D_Fire_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c index 54963eb3b..543363ade 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.c @@ -25,7 +25,7 @@ u32 EffectSsDeadDb_Init(PlayState* play, u32 index, EffectSs* this, void* initPa void EffectSsDeadDb_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsDeadDb_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Dead_Db_InitVars = { +EffectSsInit Effect_Ss_Dead_Db_InitVars = { EFFECT_SS_DEAD_DB, EffectSsDeadDb_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h index a1ac62167..58e46426f 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h @@ -14,6 +14,4 @@ typedef struct { /* 0x30 */ s32 life; } EffectSsDeadDbInitParams; // size = 0x34 -extern const EffectSsInit Effect_Ss_Dead_Db_InitVars; - #endif 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 5e8a1e451..9f124d39e 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 @@ -25,7 +25,7 @@ u32 EffectSsDeadDd_Init(PlayState* play, u32 index, EffectSs* this, void* initPa void EffectSsDeadDd_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsDeadDd_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Dead_Dd_InitVars = { +EffectSsInit Effect_Ss_Dead_Dd_InitVars = { EFFECT_SS_DEAD_DD, EffectSsDeadDd_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.h b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.h index 9c9dcf28e..7d32c3284 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.h +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/z_eff_ss_dead_dd.h @@ -23,6 +23,4 @@ typedef struct { /* 0x40 */ u8 type; } EffectSsDeadDdInitParams; // size = 0x44 -extern const EffectSsInit Effect_Ss_Dead_Dd_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c b/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c index 7bf60c2a1..6243b4302 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.c @@ -23,7 +23,7 @@ u32 EffectSsDeadDs_Init(PlayState* play, u32 index, EffectSs* this, void* initPa void EffectSsDeadDs_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsDeadDs_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Dead_Ds_InitVars = { +EffectSsInit Effect_Ss_Dead_Ds_InitVars = { EFFECT_SS_DEAD_DS, EffectSsDeadDs_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.h b/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.h index e04742296..b057f3f42 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.h +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.h @@ -13,6 +13,4 @@ typedef struct { /* 0x2C */ s32 life; } EffectSsDeadDsInitParams; // size = 0x30 -extern const EffectSsInit Effect_Ss_Dead_Ds_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c index 4d009c00a..b6e3b747f 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.c @@ -39,7 +39,7 @@ static Color_RGBA8 sEnvColors[] = { { 150, 150, 150, 0 }, }; -const EffectSsInit Effect_Ss_Dt_Bubble_InitVars = { +EffectSsInit Effect_Ss_Dt_Bubble_InitVars = { EFFECT_SS_DT_BUBBLE, EffectSsDtBubble_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.h b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.h index e572f4a2c..b5247eb0f 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.h +++ b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.h @@ -23,6 +23,4 @@ typedef struct { /* 0x34 */ u8 customColor; } EffectSsDtBubbleInitParams; // size = 0x3C -extern const EffectSsInit Effect_Ss_Dt_Bubble_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c index 7a2274a5d..10e8fbeed 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c +++ b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.c @@ -28,7 +28,7 @@ void EffectSsDust_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsDust_UpdateFire(PlayState* play, u32 index, EffectSs* this); void EffectSsDust_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Dust_InitVars = { +EffectSsInit Effect_Ss_Dust_InitVars = { EFFECT_SS_DUST, EffectSsDust_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.h b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.h index 410a14352..b2b76e0be 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.h +++ b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.h @@ -26,6 +26,4 @@ typedef struct { /* 0x34 */ u8 updateMode; } EffectSsDustInitParams; // size = 0x38 -extern const EffectSsInit Effect_Ss_Dust_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.c b/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.c index fab6f8788..9d78d4d71 100644 --- a/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.c @@ -24,7 +24,7 @@ u32 EffectSsEnFire_Init(PlayState* play, u32 index, EffectSs* this, void* initPa void EffectSsEnFire_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsEnFire_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_En_Fire_InitVars = { +EffectSsInit Effect_Ss_En_Fire_InitVars = { EFFECT_SS_EN_FIRE, EffectSsEnFire_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.h b/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.h index 9fb959824..0f17477b8 100644 --- a/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.h +++ b/src/overlays/effects/ovl_Effect_Ss_En_Fire/z_eff_ss_en_fire.h @@ -15,6 +15,4 @@ typedef struct { /* 0x16 */ s16 bodyPart; } EffectSsEnFireInitParams; // size = 0x18 -extern const EffectSsInit Effect_Ss_En_Fire_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.c b/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.c index 1108e61ce..21a0f1019 100644 --- a/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.c +++ b/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.c @@ -28,7 +28,7 @@ void EffectSsEnIce_UpdateFlying(PlayState* play, u32 index, EffectSs* this); void EffectSsEnIce_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsEnIce_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_En_Ice_InitVars = { +EffectSsInit Effect_Ss_En_Ice_InitVars = { EFFECT_SS_EN_ICE, EffectSsEnIce_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.h b/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.h index 46b162cc1..051e81983 100644 --- a/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.h +++ b/src/overlays/effects/ovl_Effect_Ss_En_Ice/z_eff_ss_en_ice.h @@ -20,6 +20,4 @@ typedef struct { /* 0x38 */ s16 type; } EffectSsEnIceInitParams; // size = 0x3C -extern const EffectSsInit Effect_Ss_En_Ice_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c index bf21a8741..03522f5af 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c +++ b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c @@ -16,7 +16,7 @@ void EffectSsExtra_Draw(PlayState* play, u32 index, EffectSs* this); static s16 sScores[] = { 30, 60, 100 }; -const EffectSsInit Effect_Ss_Extra_InitVars = { +EffectSsInit Effect_Ss_Extra_InitVars = { EFFECT_SS_EXTRA, EffectSsExtra_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.h b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.h index c278ec927..081570f62 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.h +++ b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.h @@ -17,6 +17,4 @@ typedef struct { /* 0x26 */ s16 scoreIdx; } EffectSsExtraInitParams; // size = 0x28 -extern const EffectSsInit Effect_Ss_Extra_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c index b81ccf594..cd7c6d5bd 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c +++ b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c @@ -19,7 +19,7 @@ u32 EffectSsFhgFlash_Init(PlayState* play, u32 index, EffectSs* this, void* init void EffectSsFhgFlash_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsFhgFlash_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Fhg_Flash_InitVars = { +EffectSsInit Effect_Ss_Fhg_Flash_InitVars = { EFFECT_SS_FHG_FLASH, EffectSsFhgFlash_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h index c464047b5..c2f231269 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h +++ b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h @@ -40,6 +40,4 @@ typedef struct { /* 0x2C */ u8 type; } EffectSsFhgFlashInitParams; // size = 0x30 -extern const EffectSsInit Effect_Ss_Fhg_Flash_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.c b/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.c index da4de14d6..1742b03fd 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.c +++ b/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.c @@ -27,7 +27,7 @@ u32 EffectSsFireTail_Init(PlayState* play, u32 index, EffectSs* this, void* init void EffectSsFireTail_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsFireTail_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Fire_Tail_InitVars = { +EffectSsInit Effect_Ss_Fire_Tail_InitVars = { EFFECT_SS_FIRE_TAIL, EffectSsFireTail_Init, }; @@ -107,7 +107,7 @@ void EffectSsFireTail_Draw(PlayState* play, u32 index, EffectSs* this) { temp2 = Math_SinS(yawDiff); dist = Math_Vec3f_DistXZ(&scale, &this->vec) / (this->rReg10 * 0.1f); Matrix_RotateYS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000, MTXMODE_APPLY); - Matrix_RotateZF(DEGF_TO_RADF(temp2 * this->rReg2 * dist), MTXMODE_APPLY); + Matrix_RotateZF(DEG_TO_RAD(temp2 * this->rReg2 * dist), MTXMODE_APPLY); temp2 = 1.0f - ((f32)(this->life + 1) / this->rLifespan); temp2 = 1.0f - SQ(temp2); scale.x = scale.y = scale.z = temp2 * (this->rScale * (0.001f * 0.01f)); diff --git a/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.h b/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.h index 60fc2a6ef..a809e4ebc 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.h +++ b/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/z_eff_ss_fire_tail.h @@ -16,6 +16,4 @@ typedef struct { /* 0x30 */ s32 life; } EffectSsFireTailInitParams; // size = 0x34 -extern const EffectSsInit Effect_Ss_Fire_Tail_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.c b/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.c index 7bc2d6966..b41f35756 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.c @@ -13,7 +13,7 @@ u32 EffectSsGFire_Init(PlayState* play, u32 index, EffectSs* this, void* initPar void EffectSsGFire_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsGFire_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_G_Fire_InitVars = { +EffectSsInit Effect_Ss_G_Fire_InitVars = { EFFECT_SS_G_FIRE, EffectSsGFire_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.h b/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.h index 574abc976..cc02cae83 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.h +++ b/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.h @@ -7,6 +7,4 @@ typedef struct { /* 0x00 */ Vec3f pos; } EffectSsGFireInitParams; // size = 0xC -extern const EffectSsInit Effect_Ss_G_Fire_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c b/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c index b820d8168..24aadc0ec 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.c @@ -27,7 +27,7 @@ u32 EffectSsGRipple_Init(PlayState* play, u32 index, EffectSs* this, void* initP void EffectSsGRipple_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsGRipple_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_G_Ripple_InitVars = { +EffectSsInit Effect_Ss_G_Ripple_InitVars = { EFFECT_SS_G_RIPPLE, EffectSsGRipple_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.h b/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.h index 018fff6be..c746fbf28 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.h +++ b/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.h @@ -10,6 +10,4 @@ typedef struct { /* 0x10 */ s16 life; } EffectSsGRippleInitParams; // size = 0x14 -extern const EffectSsInit Effect_Ss_G_Ripple_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c index 260541b51..ccc2951c6 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.c @@ -26,7 +26,7 @@ void EffectSsGSpk_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsGSpk_UpdateNoAccel(PlayState* play, u32 index, EffectSs* this); void EffectSsGSpk_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_G_Spk_InitVars = { +EffectSsInit Effect_Ss_G_Spk_InitVars = { EFFECT_SS_G_SPK, EffectSsGSpk_Init, }; @@ -134,8 +134,8 @@ void EffectSsGSpk_Update(PlayState* play, u32 index, EffectSs* this) { void EffectSsGSpk_UpdateNoAccel(PlayState* play, u32 index, EffectSs* this) { if (this->actor != NULL) { if ((this->actor->category == ACTORCAT_EXPLOSIVES) && (this->actor->update != NULL)) { - this->pos.x += (Math_SinS(this->actor->world.rot.y) * this->actor->speedXZ); - this->pos.z += (Math_CosS(this->actor->world.rot.y) * this->actor->speedXZ); + this->pos.x += (Math_SinS(this->actor->world.rot.y) * this->actor->speed); + this->pos.z += (Math_CosS(this->actor->world.rot.y) * this->actor->speed); } } diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.h b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.h index c44bb9168..b952802d2 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.h +++ b/src/overlays/effects/ovl_Effect_Ss_G_Spk/z_eff_ss_g_spk.h @@ -20,6 +20,4 @@ typedef struct { /* 0x34 */ u8 updateMode; } EffectSsGSpkInitParams; // size = 0x38 -extern const EffectSsInit Effect_Ss_G_Spk_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c index 78bee9835..8d7647bfe 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c @@ -17,7 +17,7 @@ u32 EffectSsGSplash_Init(PlayState* play, u32 index, EffectSs* this, void* initP void EffectSsGSplash_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsGSplash_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_G_Splash_InitVars = { +EffectSsInit Effect_Ss_G_Splash_InitVars = { EFFECT_SS_G_SPLASH, EffectSsGSplash_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.h b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.h index 7ea428400..9d3fbcd13 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.h +++ b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.h @@ -12,6 +12,4 @@ typedef struct { /* 0x14 */ Color_RGBA8 envColor; } EffectSsGSplashInitParams; // size = 0x18 -extern const EffectSsInit Effect_Ss_G_Splash_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c index b4d9ae6fb..e1a9371cd 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c +++ b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.c @@ -21,7 +21,7 @@ u32 EffectSsHahen_Init(PlayState* play, u32 index, EffectSs* this, void* initPar void EffectSsHahen_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsHahen_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Hahen_InitVars = { +EffectSsInit Effect_Ss_Hahen_InitVars = { EFFECT_SS_HAHEN, EffectSsHahen_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h index 9a73ac664..d962bf55f 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h +++ b/src/overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h @@ -19,6 +19,4 @@ typedef struct { /* 0x2C */ s16 life; } EffectSsHahenInitParams; // size = 0x30 -extern const EffectSsInit Effect_Ss_Hahen_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.c b/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.c index f65e36c7d..36eb650f7 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.c +++ b/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.c @@ -73,7 +73,7 @@ static TexturePtr sTextures[] = { gEffHitmarkWhiteMetal8Tex, }; -const EffectSsInit Effect_Ss_Hitmark_InitVars = { +EffectSsInit Effect_Ss_Hitmark_InitVars = { EFFECT_SS_HITMARK, EffectSsHitmark_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.h b/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.h index 6e38ab8d2..e513f0665 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.h +++ b/src/overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.h @@ -16,6 +16,4 @@ typedef struct { /* 0x08 */ Vec3f pos; } EffectSsHitmarkInitParams; // size = 0x14 -extern const EffectSsInit Effect_Ss_Hitmark_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c b/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c index 52561fea2..9efadc99e 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c +++ b/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c @@ -19,7 +19,7 @@ u32 EffectSsIcePiece_Init(PlayState* play, u32 index, EffectSs* this, void* init void EffectSsIcePiece_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsIcePiece_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Ice_Piece_InitVars = { +EffectSsInit Effect_Ss_Ice_Piece_InitVars = { EFFECT_SS_ICE_PIECE, EffectSsIcePiece_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.h b/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.h index 2bbe9e481..16ada036f 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.h +++ b/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.h @@ -11,6 +11,4 @@ typedef struct { /* 0x28 */ s32 life; } EffectSsIcePieceInitParams; // size = 0xC -extern const EffectSsInit Effect_Ss_Ice_Piece_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c b/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c index 41c9c818a..e1c2bc72d 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c +++ b/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c @@ -18,7 +18,7 @@ u32 EffectSsIceSmoke_Init(PlayState* play, u32 index, EffectSs* this, void* init void EffectSsIceSmoke_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsIceSmoke_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Ice_Smoke_InitVars = { +EffectSsInit Effect_Ss_Ice_Smoke_InitVars = { EFFECT_SS_ICE_SMOKE, EffectSsIceSmoke_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.h b/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.h index bc6893311..e56678fb0 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.h +++ b/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.h @@ -10,6 +10,4 @@ typedef struct { /* 0x24 */ s16 scale; } EffectSsIceSmokeInitParams; // size = 0x28 -extern const EffectSsInit Effect_Ss_Ice_Smoke_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c b/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c index 4aa209639..17d7edc1e 100644 --- a/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c @@ -20,7 +20,7 @@ u32 EffectSsKFire_Init(PlayState* play, u32 index, EffectSs* this, void* initPar void EffectSsKFire_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsKFire_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_K_Fire_InitVars = { +EffectSsInit Effect_Ss_K_Fire_InitVars = { EFFECT_SS_K_FIRE, EffectSsKFire_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.h b/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.h index 23ed053c3..3cb53de39 100644 --- a/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.h +++ b/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.h @@ -11,6 +11,4 @@ typedef struct { /* 0x26 */ u8 type; } EffectSsKFireInitParams; // size = 0x28 -extern const EffectSsInit Effect_Ss_K_Fire_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c index a84b450c1..e424c0b44 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c +++ b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c @@ -28,7 +28,7 @@ void EffectSsKakera_Draw(PlayState* play, u32 index, EffectSs* this); void EffectSsKakera_CheckForObject(EffectSs* this, PlayState* play); -const EffectSsInit Effect_Ss_Kakera_InitVars = { +EffectSsInit Effect_Ss_Kakera_InitVars = { EFFECT_SS_KAKERA, EffectSsKakera_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c index 97899ae68..540d9e505 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c +++ b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c @@ -29,7 +29,7 @@ void func_80977E6C(PlayState* play, u32 index, EffectSs* this); void func_80977F28(PlayState* play, u32 index, EffectSs* this); void EffectSsKirakira_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Kirakira_InitVars = { +EffectSsInit Effect_Ss_Kirakira_InitVars = { EFFECT_SS_KIRAKIRA, EffectSsKirakira_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h index 66e73e0a5..e9513cc7a 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h +++ b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h @@ -17,6 +17,4 @@ typedef struct { /* 0x38 */ u8 updateMode; } EffectSsKirakiraInitParams; // size = 0x3C -extern const EffectSsInit Effect_Ss_Kirakira_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c b/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c index 1f70b8064..9037b20f4 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c +++ b/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c @@ -31,7 +31,7 @@ TexturePtr sLightningTextures[] = { gEffLightning5Tex, gEffLightning6Tex, gEffLightning7Tex, gEffLightning8Tex, }; -const EffectSsInit Effect_Ss_Lightning_InitVars = { +EffectSsInit Effect_Ss_Lightning_InitVars = { EFFECT_SS_LIGHTNING, EffectSsLightning_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.h b/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.h index 35ef380b9..07052e522 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.h +++ b/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.h @@ -13,6 +13,4 @@ typedef struct { /* 0x1A */ s16 numBolts; } EffectSsLightningInitParams; // size = 0x1C -extern const EffectSsInit Effect_Ss_Lightning_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c index c5c058cc3..3402eb2b7 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c +++ b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c @@ -27,7 +27,7 @@ void EffectSsSbn_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsSbn_DrawSliding(PlayState* play, u32 index, EffectSs* this); void EffectSsSbn_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Sbn_InitVars = { +EffectSsInit Effect_Ss_Sbn_InitVars = { EFFECT_SS_SBN, EffectSsSbn_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h index 439ef88a0..9290d7948 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h +++ b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h @@ -9,6 +9,4 @@ typedef struct { /* 0x10 */ f32 scale; } EffectSsSbnInitParams; // size = 0x14 -extern const EffectSsInit Effect_Ss_Sbn_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c index 4dbdc65a2..a9a190948 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c +++ b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c @@ -25,7 +25,7 @@ u32 EffectSsSibuki_Init(PlayState* play, u32 index, EffectSs* this, void* initPa void EffectSsSibuki_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsSibuki_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Sibuki_InitVars = { +EffectSsInit Effect_Ss_Sibuki_InitVars = { EFFECT_SS_SIBUKI, EffectSsSibuki_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.h b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.h index 9efe7c77a..27e3780d2 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.h +++ b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.h @@ -12,6 +12,4 @@ typedef struct { /* 0x28 */ s16 scale; } EffectSsSibukiInitParams; // size = 0x2C -extern const EffectSsInit Effect_Ss_Sibuki_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c index 01224dd32..cd0ea0fad 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c +++ b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.c @@ -15,7 +15,7 @@ u32 EffectSsSolderSrchBall_Init(PlayState* play, u32 index, EffectSs* this, void void EffectSsSolderSrchBall_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsSolderSrchBall_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Solder_Srch_Ball_InitVars = { +EffectSsInit Effect_Ss_Solder_Srch_Ball_InitVars = { EFFECT_SS_SOLDER_SRCH_BALL, EffectSsSolderSrchBall_Init, }; @@ -60,7 +60,7 @@ void EffectSsSolderSrchBall_Draw(PlayState* play, u32 index, EffectSs* this) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, 255); Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZF(DEGF_TO_RADF(20.0f * play->state.frames), MTXMODE_APPLY); + Matrix_RotateZF(DEG_TO_RAD(20.0f * play->state.frames), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); diff --git a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h index fb4fb4159..5c250a7af 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h +++ b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h @@ -15,6 +15,4 @@ typedef struct { /* 0x2C */ s16 flags; } EffectSsSolderSrchBallInitParams; // size = 0x30 -extern const EffectSsInit Effect_Ss_Solder_Srch_Ball_InitVars; - #endif diff --git a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c index 1c6d53e7f..4f1aa5d91 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c @@ -16,7 +16,7 @@ u32 EffectSsStick_Init(PlayState* play, u32 index, EffectSs* this, void* initPar void EffectSsStick_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsStick_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Stick_InitVars = { +EffectSsInit Effect_Ss_Stick_InitVars = { EFFECT_SS_STICK, EffectSsStick_Init, }; diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c index ad61166d3..6e6b48156 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c @@ -15,7 +15,7 @@ u32 EffectSsStone1_Init(PlayState* play, u32 index, EffectSs* this, void* initPa void EffectSsStone1_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsStone1_Draw(PlayState* play, u32 index, EffectSs* this); -const EffectSsInit Effect_Ss_Stone1_InitVars = { +EffectSsInit Effect_Ss_Stone1_InitVars = { EFFECT_SS_STONE1, EffectSsStone1_Init, }; @@ -77,6 +77,6 @@ void EffectSsStone1_Draw(PlayState* play, u32 index, EffectSs* this) { void EffectSsStone1_Update(PlayState* play, u32 index, EffectSs* this) { if ((this->life == 6) && (this->rReg0 != 0)) { - iREG(50) = 0; + R_TRANS_FADE_FLASH_ALPHA_STEP = 0; } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h index 365585a8e..b50868b81 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h @@ -8,6 +8,4 @@ typedef struct { /* 0x0C */ s32 reg0; } EffectSsStone1InitParams; // size = 0x10 -extern const EffectSsInit Effect_Ss_Stone1_InitVars; - #endif diff --git a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c index 00e7cfabd..cf1000add 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c +++ b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c @@ -4,8 +4,9 @@ * Description: */ +#include "global.h" #include "z_fbdemo_triforce.h" -#include "assets/objects/object_fbdemo_triforce/ovl_fbdemo_triforce.c" +#include "assets/overlays/ovl_fbdemo_triforce/ovl_fbdemo_triforce.c" void* TransitionTriforce_Init(void* thisx); void TransitionTriforce_Destroy(void* thisx); @@ -30,8 +31,11 @@ void TransitionTriforce_Start(void* thisx) { case STATE_SPIRAL_IN_FAST: this->transPos = 1.0f; return; + + default: + this->transPos = 0.03f; + return; } - this->transPos = 0.03f; } void* TransitionTriforce_Init(void* thisx) { @@ -43,7 +47,7 @@ void* TransitionTriforce_Init(void* thisx) { this->transPos = 1.0f; this->state = STATE_SPIRAL_IN_FAST; this->step = 0.015f; - this->fadeType = TYPE_TRANSPARENT_TRIFORCE; + this->type = TRANS_INSTANCE_TYPE_FILL_OUT; return this; } @@ -76,7 +80,7 @@ void TransitionTriforce_SetColor(void* thisx, u32 color) { void TransitionTriforce_SetType(void* thisx, s32 type) { TransitionTriforce* this = (TransitionTriforce*)thisx; - this->fadeType = type; + this->type = type; } void TransitionTriforce_SetState(void* thisx, s32 state) { @@ -98,37 +102,43 @@ void TransitionTriforce_Draw(void* thisx, Gfx** gfxP) { guRotate(&modelView[1], rotation, 0.0f, 0.0f, 1.0f); guTranslate(&modelView[2], 0.0f, 0.0f, 0.0f); gDPPipeSync(gfx++); - gSPDisplayList(gfx++, sTriforceWipeDL); + gSPDisplayList(gfx++, sTransTriforceDL); gDPSetColor(gfx++, G_SETPRIMCOLOR, this->color.rgba); gDPSetCombineMode(gfx++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); gSPMatrix(gfx++, &this->projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gSPMatrix(gfx++, &modelView[0], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPMatrix(gfx++, &modelView[1], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); gSPMatrix(gfx++, &modelView[2], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); - gSPVertex(gfx++, &sTriforceWipeVtx, ARRAY_COUNT(sTriforceWipeVtx), 0); + gSPVertex(gfx++, &sTransTriforceVtx, ARRAY_COUNT(sTransTriforceVtx), 0); if (!TransitionTriforce_IsDone(this)) { - switch (this->fadeType) { - case TYPE_TRANSPARENT_TRIFORCE: + switch (this->type) { + case TRANS_INSTANCE_TYPE_FILL_OUT: gSP2Triangles(gfx++, 0, 4, 5, 0, 4, 1, 3, 0); gSP1Triangle(gfx++, 5, 3, 2, 0); break; - case TYPE_FILLED_TRIFORCE: + case TRANS_INSTANCE_TYPE_FILL_IN: gSP2Triangles(gfx++, 3, 4, 5, 0, 0, 2, 6, 0); gSP2Triangles(gfx++, 0, 6, 7, 0, 1, 0, 7, 0); gSP2Triangles(gfx++, 1, 7, 8, 0, 1, 8, 9, 0); gSP2Triangles(gfx++, 1, 9, 2, 0, 2, 9, 6, 0); break; + + default: + break; } } else { - switch (this->fadeType) { - case TYPE_TRANSPARENT_TRIFORCE: + switch (this->type) { + case TRANS_INSTANCE_TYPE_FILL_OUT: break; - case TYPE_FILLED_TRIFORCE: + case TRANS_INSTANCE_TYPE_FILL_IN: gSP1Quadrangle(gfx++, 6, 7, 8, 9, 0); break; + + default: + break; } } gDPPipeSync(gfx++); @@ -142,6 +152,7 @@ s32 TransitionTriforce_IsDone(void* thisx) { return this->transPos <= 0.03f; } else if ((this->state == STATE_SPIRAL_OUT_SLOW) || (this->state == STATE_SPIRAL_OUT_FAST)) { return (this->transPos >= 1.0f); + } else { + return false; } - return false; } diff --git a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h index 06d807a08..1bcfe5c3d 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h +++ b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h @@ -1,7 +1,8 @@ #ifndef Z_FBDEMO_TRIFORCE_H #define Z_FBDEMO_TRIFORCE_H -#include "global.h" +#include "ultra64.h" +#include "color.h" typedef enum { /* 0 */ STATE_NONE, @@ -9,20 +10,14 @@ typedef enum { /* 2 */ STATE_SPIRAL_IN_FAST, /* 3 */ STATE_SPIRAL_OUT_SLOW, /* 4 */ STATE_SPIRAL_OUT_FAST -} FbTriforceState; - -typedef enum { - /* 0 */ TYPE_NONE, - /* 1 */ TYPE_TRANSPARENT_TRIFORCE, - /* 2 */ TYPE_FILLED_TRIFORCE -} TriforceFadeType; +} TransitionTriforceState; typedef struct { /* 0x000 */ Color_RGBA8_u32 color; /* 0x004 */ f32 transPos; /* 0x008 */ f32 step; /* 0x00C */ s32 state; - /* 0x010 */ s32 fadeType; + /* 0x010 */ s32 type; /* 0x018 */ Mtx projection; /* 0x058 */ s32 frame; /* 0x060 */ Mtx modelView[2][3]; diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c index ed12d400e..94285c45b 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c @@ -4,8 +4,11 @@ * Description: */ +#include "global.h" #include "z_fbdemo_wipe1.h" +#define THIS ((TransitionWipe1*)thisx) + void* TransitionWipe1_Init(void* thisx); void TransitionWipe1_Destroy(void* thisx); void TransitionWipe1_Update(void* thisx, s32 updateRate); @@ -16,35 +19,120 @@ void TransitionWipe1_SetColor(void* thisx, u32 color); void TransitionWipe1_SetEnvColor(void* thisx, u32 color); s32 TransitionWipe1_IsDone(void* thisx); -#if 0 +#include "assets/overlays/ovl_fbdemo_wipe1/ovl_fbdemo_wipe1.c" + TransitionInit TransitionWipe1_InitVars = { - TransitionWipe1_Init, - TransitionWipe1_Destroy, - TransitionWipe1_Update, - TransitionWipe1_Draw, - TransitionWipe1_Start, - TransitionWipe1_SetType, - TransitionWipe1_SetColor, - TransitionWipe1_SetEnvColor, - TransitionWipe1_IsDone, + TransitionWipe1_Init, TransitionWipe1_Destroy, TransitionWipe1_Update, + TransitionWipe1_Draw, TransitionWipe1_Start, TransitionWipe1_SetType, + TransitionWipe1_SetColor, TransitionWipe1_SetEnvColor, TransitionWipe1_IsDone, }; -#endif +typedef enum { + /* 0 */ TRANS_WIPE1_DIR_IN, + /* 1 */ TRANS_WIPE1_DIR_OUT +} TransitionWipe1Direction; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_Start.s") +void TransitionWipe1_Start(void* thisx) { + TransitionWipe1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_Init.s") + this->isDone = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_Destroy.s") + if (this->direction != TRANS_WIPE1_DIR_IN) { + this->texY = (s32)(83.25f * (1 << 2)); + } else { + this->texY = (s32)(153.0f * (1 << 2)); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_Update.s") + guPerspective(&this->projection, &this->normal, 60.0f, (4.0f / 3.0f), 10.0f, 12800.0f, 1.0f); + guLookAt(&this->lookAt, 0.0f, 0.0f, 400.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_Draw.s") +void* TransitionWipe1_Init(void* thisx) { + TransitionWipe1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_IsDone.s") + bzero(this, sizeof(TransitionWipe1)); + return this; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_SetType.s") +void TransitionWipe1_Destroy(void* thisx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_SetColor.s") +void TransitionWipe1_Update(void* thisx, s32 updateRate) { + TransitionWipe1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe1/TransitionWipe1_SetEnvColor.s") + if (this->direction != TRANS_WIPE1_DIR_IN) { + this->texY += (((void)0, gSaveContext.transWipeSpeed) * 3) / updateRate; + if (this->texY >= (s32)(153.0f * (1 << 2))) { + this->texY = (s32)(153.0f * (1 << 2)); + this->isDone = true; + } + } else { + this->texY -= (((void)0, gSaveContext.transWipeSpeed) * 3) / updateRate; + if (this->texY <= (s32)(83.25f * (1 << 2))) { + this->texY = (s32)(83.25f * (1 << 2)); + this->isDone = true; + } + } +} + +void TransitionWipe1_Draw(void* thisx, Gfx** gfxP) { + Gfx* gfx = *gfxP; + Mtx* modelView; + TransitionWipe1* this = THIS; + Gfx* texScroll; + s32 pad[4]; + + modelView = this->modelView[this->frame]; + this->frame ^= 1; + + guScale(&modelView[0], 0.56f, 0.56f, 1.0f); + guRotate(&modelView[1], 0.0f, 0.0f, 0.0f, 1.0f); + guTranslate(&modelView[2], 0.0f, 0.0f, 0.0f); + gDPPipeSync(gfx++); + texScroll = Gfx_BranchTexScroll(&gfx, this->texX, this->texY, 0, 0); + gSPSegment(gfx++, 8, texScroll); + gDPSetPrimColor(gfx++, 0, 0x80, this->primColor.r, this->primColor.g, this->primColor.b, 255); + gSPMatrix(gfx++, &this->projection, G_MTX_LOAD | G_MTX_PROJECTION); + gSPPerspNormalize(gfx++, this->normal); + gSPMatrix(gfx++, &this->lookAt, G_MTX_MUL | G_MTX_PROJECTION); + gSPMatrix(gfx++, &modelView[0], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gfx++, &modelView[1], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPMatrix(gfx++, &modelView[2], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, sTransWipe1DL); + gDPPipeSync(gfx++); + *gfxP = gfx; +} + +s32 TransitionWipe1_IsDone(void* thisx) { + TransitionWipe1* this = THIS; + + return this->isDone; +} + +void TransitionWipe1_SetType(void* thisx, s32 type) { + TransitionWipe1* this = THIS; + + if (type == TRANS_INSTANCE_TYPE_FILL_OUT) { + this->direction = TRANS_WIPE1_DIR_OUT; + } else { + this->direction = TRANS_WIPE1_DIR_IN; + } + + if (this->direction != TRANS_WIPE1_DIR_IN) { + this->texY = (s32)(83.25f * (1 << 2)); + } else { + this->texY = (s32)(153.0f * (1 << 2)); + } +} + +void TransitionWipe1_SetColor(void* thisx, u32 color) { + TransitionWipe1* this = THIS; + + this->primColor.rgba = color; +} + +void TransitionWipe1_SetEnvColor(void* thisx, u32 color) { + TransitionWipe1* this = THIS; + + this->envColor.rgba = color; +} diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h index 971940bb2..4906e531c 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h @@ -1,10 +1,21 @@ #ifndef Z_FBDEMO_WIPE1_H #define Z_FBDEMO_WIPE1_H -#include "global.h" +#include "ultra64.h" +#include "color.h" typedef struct { - /* 0x0000 */ char unk_0[0x218]; + /* 0x000 */ Color_RGBA8_u32 primColor; + /* 0x004 */ Color_RGBA8_u32 envColor; + /* 0x008 */ u8 direction; + /* 0x009 */ u8 frame; + /* 0x00A */ u8 isDone; + /* 0x00C */ u16 texX; + /* 0x00E */ u16 texY; + /* 0x010 */ u16 normal; + /* 0x018 */ Mtx projection; + /* 0x058 */ Mtx lookAt; + /* 0x098 */ Mtx modelView[2][3]; } TransitionWipe1; // size = 0x218 #endif diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.c b/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.c index c33f3c8c7..759e1511c 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.c @@ -4,6 +4,7 @@ * Description: */ +#include "global.h" #include "z_fbdemo_wipe3.h" void* TransitionWipe3_Init(void* thisx); diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h b/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h index 8fed0dcfe..b023ecb8b 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h @@ -1,10 +1,11 @@ #ifndef Z_FBDEMO_WIPE3_H #define Z_FBDEMO_WIPE3_H -#include "global.h" +#include "ultra64.h" +#include "color.h" typedef struct { - /* 0x0000 */ char unk_0[0x120]; + /* 0x000 */ char unk_0[0x120]; } TransitionWipe3; // size = 0x120 #endif diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.c b/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.c index e91d8ab5e..1acb8c07a 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.c @@ -4,6 +4,7 @@ * Description: */ +#include "global.h" #include "z_fbdemo_wipe4.h" void* TransitionWipe4_Init(void* thisx); diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h b/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h index 8a677c2a4..b0aec44be 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h @@ -1,10 +1,11 @@ #ifndef Z_FBDEMO_WIPE4_H #define Z_FBDEMO_WIPE4_H -#include "global.h" +#include "ultra64.h" +#include "color.h" typedef struct { - /* 0x0000 */ char unk_0[0x28]; + /* 0x00 */ char unk_0[0x28]; } TransitionWipe4; // size = 0x28 #endif diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c index a4b0cfa74..48c8bdf58 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c @@ -4,6 +4,7 @@ * Description: */ +#include "global.h" #include "z_fbdemo_wipe5.h" #define THIS ((TransitionWipe5*)thisx) @@ -126,7 +127,7 @@ void TransitionWipe5_SetType(void* thisx, s32 type) { if (type & 0x80) { this->unk_11 = 0; this->unk_12 = type & 1; - } else if (type == 1) { + } else if (type == TRANS_INSTANCE_TYPE_FILL_OUT) { this->unk_10 = 1; } else { this->unk_10 = 0; diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h index d5cd9137d..c40c4450a 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h @@ -1,7 +1,8 @@ #ifndef Z_FBDEMO_WIPE5_H #define Z_FBDEMO_WIPE5_H -#include "global.h" +#include "ultra64.h" +#include "color.h" typedef struct { /* 0x00 */ Color_RGBA8_u32 primColor; diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c index 201030862..845baa3cb 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c @@ -73,7 +73,7 @@ void DayTelop_Update(DayTelopState* this, GameState* thisx) { this->transitionCountdown--; if (this->transitionCountdown == 0) { if (gSaveContext.save.day < 9) { - gSaveContext.gameMode = 0; + gSaveContext.gameMode = GAMEMODE_NORMAL; } else { gSaveContext.nextCutsceneIndex = 0xFFF6; gSaveContext.save.day = 1; @@ -213,11 +213,11 @@ void DayTelop_Noop(DayTelopState* this) { void DayTelop_LoadGraphics(DayTelopState* this) { size_t segmentSize = SEGMENT_ROM_SIZE(daytelop_static); - this->daytelopStaticFile = THA_AllocEndAlign16(&this->state.heap, segmentSize); + this->daytelopStaticFile = THA_AllocTailAlign16(&this->state.heap, segmentSize); DmaMgr_SendRequest0(this->daytelopStaticFile, SEGMENT_ROM_START(daytelop_static), segmentSize); segmentSize = SEGMENT_ROM_SIZE(icon_item_gameover_static); - this->gameoverStaticFile = THA_AllocEndAlign16(&this->state.heap, segmentSize); + this->gameoverStaticFile = THA_AllocTailAlign16(&this->state.heap, segmentSize); DmaMgr_SendRequest0(this->gameoverStaticFile, SEGMENT_ROM_START(icon_item_gameover_static), segmentSize); } diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index c56cc4bbb..9697b111f 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -13,12 +13,12 @@ void TitleSetup_SetupTitleScreen(TitleSetupState* this) { static s32 sOpeningCutscenes[] = { 0xFFFA, 0xFFFA }; CLEAR_EVENTINF(EVENTINF_17); - gSaveContext.gameMode = 1; + gSaveContext.gameMode = GAMEMODE_TITLE_SCREEN; Sram_InitNewSave(); - gSaveContext.save.entrance = sOpeningEntrances[D_801BB12C]; - gSaveContext.nextCutsceneIndex = gSaveContext.save.cutscene = sOpeningCutscenes[D_801BB12C]; + gSaveContext.save.entrance = sOpeningEntrances[gOpeningEntranceIndex]; + gSaveContext.nextCutsceneIndex = gSaveContext.save.cutsceneIndex = sOpeningCutscenes[gOpeningEntranceIndex]; gSaveContext.sceneLayer = 0; gSaveContext.save.time = CLOCK_TIME(8, 0); diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 461192d48..08bf65262 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -30,12 +30,12 @@ void MapSelect_LoadGame(MapSelectState* this, u32 entrance, s32 spawn) { gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; gSaveContext.hudVisibilityTimer = 0; - Audio_QueueSeqCmd(NA_BGM_STOP); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); gSaveContext.save.entrance = entrance; if (spawn != 0) { gSaveContext.save.entrance = - Entrance_Create((s32)gSaveContext.save.entrance >> 9, spawn, gSaveContext.save.entrance & 0xF); + Entrance_Create(gSaveContext.save.entrance >> 9, spawn, gSaveContext.save.entrance & 0xF); } if (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 0)) { gSaveContext.save.day = 0; @@ -533,69 +533,69 @@ void MapSelect_UpdateMenu(MapSelectState* this) { } if (CHECK_BTN_ALL(controller1->press.button, BTN_Z)) { - if (gSaveContext.save.cutscene == 0x8000) { - gSaveContext.save.cutscene = 0; - } else if (gSaveContext.save.cutscene == 0) { - gSaveContext.save.cutscene = 0x8800; - } else if (gSaveContext.save.cutscene == 0x8800) { - gSaveContext.save.cutscene = 0xFFF0; - } else if (gSaveContext.save.cutscene == 0xFFF0) { - gSaveContext.save.cutscene = 0xFFF1; - } else if (gSaveContext.save.cutscene == 0xFFF1) { - gSaveContext.save.cutscene = 0xFFF2; - } else if (gSaveContext.save.cutscene == 0xFFF2) { - gSaveContext.save.cutscene = 0xFFF3; - } else if (gSaveContext.save.cutscene == 0xFFF3) { - gSaveContext.save.cutscene = 0xFFF4; - } else if (gSaveContext.save.cutscene == 0xFFF4) { - gSaveContext.save.cutscene = 0xFFF5; - } else if (gSaveContext.save.cutscene == 0xFFF5) { - gSaveContext.save.cutscene = 0xFFF6; - } else if (gSaveContext.save.cutscene == 0xFFF6) { - gSaveContext.save.cutscene = 0xFFF7; - } else if (gSaveContext.save.cutscene == 0xFFF7) { - gSaveContext.save.cutscene = 0xFFF8; - } else if (gSaveContext.save.cutscene == 0xFFF8) { - gSaveContext.save.cutscene = 0xFFF9; - } else if (gSaveContext.save.cutscene == 0xFFF9) { - gSaveContext.save.cutscene = 0xFFFA; - } else if (gSaveContext.save.cutscene == 0xFFFA) { - gSaveContext.save.cutscene = 0x8000; + if (gSaveContext.save.cutsceneIndex == 0x8000) { + gSaveContext.save.cutsceneIndex = 0; + } else if (gSaveContext.save.cutsceneIndex == 0) { + gSaveContext.save.cutsceneIndex = 0x8800; + } else if (gSaveContext.save.cutsceneIndex == 0x8800) { + gSaveContext.save.cutsceneIndex = 0xFFF0; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF0) { + gSaveContext.save.cutsceneIndex = 0xFFF1; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF1) { + gSaveContext.save.cutsceneIndex = 0xFFF2; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF2) { + gSaveContext.save.cutsceneIndex = 0xFFF3; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF3) { + gSaveContext.save.cutsceneIndex = 0xFFF4; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF4) { + gSaveContext.save.cutsceneIndex = 0xFFF5; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF5) { + gSaveContext.save.cutsceneIndex = 0xFFF6; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF6) { + gSaveContext.save.cutsceneIndex = 0xFFF7; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF7) { + gSaveContext.save.cutsceneIndex = 0xFFF8; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF8) { + gSaveContext.save.cutsceneIndex = 0xFFF9; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF9) { + gSaveContext.save.cutsceneIndex = 0xFFFA; + } else if (gSaveContext.save.cutsceneIndex == 0xFFFA) { + gSaveContext.save.cutsceneIndex = 0x8000; } } else if (CHECK_BTN_ALL(controller1->press.button, BTN_R)) { - if (gSaveContext.save.cutscene == 0x8000) { - gSaveContext.save.cutscene = 0xFFFA; - } else if (gSaveContext.save.cutscene == 0) { - gSaveContext.save.cutscene = 0x8000; - } else if (gSaveContext.save.cutscene == 0x8800) { - gSaveContext.save.cutscene = 0; - } else if (gSaveContext.save.cutscene == 0xFFF0) { - gSaveContext.save.cutscene = 0x8800; - } else if (gSaveContext.save.cutscene == 0xFFF1) { - gSaveContext.save.cutscene = 0xFFF0; - } else if (gSaveContext.save.cutscene == 0xFFF2) { - gSaveContext.save.cutscene = 0xFFF1; - } else if (gSaveContext.save.cutscene == 0xFFF3) { - gSaveContext.save.cutscene = 0xFFF2; - } else if (gSaveContext.save.cutscene == 0xFFF4) { - gSaveContext.save.cutscene = 0xFFF3; - } else if (gSaveContext.save.cutscene == 0xFFF5) { - gSaveContext.save.cutscene = 0xFFF4; - } else if (gSaveContext.save.cutscene == 0xFFF6) { - gSaveContext.save.cutscene = 0xFFF5; - } else if (gSaveContext.save.cutscene == 0xFFF7) { - gSaveContext.save.cutscene = 0xFFF6; - } else if (gSaveContext.save.cutscene == 0xFFF8) { - gSaveContext.save.cutscene = 0xFFF7; - } else if (gSaveContext.save.cutscene == 0xFFF9) { - gSaveContext.save.cutscene = 0xFFF8; - } else if (gSaveContext.save.cutscene == 0xFFFA) { - gSaveContext.save.cutscene = 0xFFF9; + if (gSaveContext.save.cutsceneIndex == 0x8000) { + gSaveContext.save.cutsceneIndex = 0xFFFA; + } else if (gSaveContext.save.cutsceneIndex == 0) { + gSaveContext.save.cutsceneIndex = 0x8000; + } else if (gSaveContext.save.cutsceneIndex == 0x8800) { + gSaveContext.save.cutsceneIndex = 0; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF0) { + gSaveContext.save.cutsceneIndex = 0x8800; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF1) { + gSaveContext.save.cutsceneIndex = 0xFFF0; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF2) { + gSaveContext.save.cutsceneIndex = 0xFFF1; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF3) { + gSaveContext.save.cutsceneIndex = 0xFFF2; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF4) { + gSaveContext.save.cutsceneIndex = 0xFFF3; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF5) { + gSaveContext.save.cutsceneIndex = 0xFFF4; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF6) { + gSaveContext.save.cutsceneIndex = 0xFFF5; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF7) { + gSaveContext.save.cutsceneIndex = 0xFFF6; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF8) { + gSaveContext.save.cutsceneIndex = 0xFFF7; + } else if (gSaveContext.save.cutsceneIndex == 0xFFF9) { + gSaveContext.save.cutsceneIndex = 0xFFF8; + } else if (gSaveContext.save.cutsceneIndex == 0xFFFA) { + gSaveContext.save.cutsceneIndex = 0xFFF9; } } gSaveContext.save.isNight = false; - if (gSaveContext.save.cutscene == 0x8800) { + if (gSaveContext.save.cutsceneIndex == 0x8800) { gSaveContext.save.isNight = true; } @@ -995,7 +995,7 @@ void MapSelect_DrawMenu(MapSelectState* this) { MapSelect_PrintMenu(this, printer); MapSelect_PrintAgeSetting(this, printer, GET_PLAYER_FORM); - MapSelect_PrintCutsceneSetting(this, printer, ((void)0, gSaveContext.save.cutscene)); + MapSelect_PrintCutsceneSetting(this, printer, ((void)0, gSaveContext.save.cutsceneIndex)); POLY_OPA_DISP = GfxPrint_Close(printer); GfxPrint_Destroy(printer); @@ -1085,7 +1085,7 @@ void MapSelect_Init(GameState* thisx) { } Game_SetFramerateDivisor(&this->state, 1); - gSaveContext.save.cutscene = 0; + gSaveContext.save.cutsceneIndex = 0; gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; gSaveContext.save.linkAge = 0; } diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 2b23bf565..59b1bed02 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -111,7 +111,7 @@ void ConsoleLogo_Draw(GameState* thisx) { 1 << 10, 1 << 10); } - func_800FC444(this->state.gfxCtx, 0, 0, 0, this->coverAlpha, 2); + Environment_FillScreen(this->state.gfxCtx, 0, 0, 0, this->coverAlpha, 2); sTitleRotation += 300; @@ -132,7 +132,7 @@ void ConsoleLogo_Main(GameState* thisx) { if (this->exit) { gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; - gSaveContext.gameMode = 1; + gSaveContext.gameMode = GAMEMODE_TITLE_SCREEN; STOP_GAMESTATE(&this->state); SET_NEXT_GAMESTATE(&this->state, TitleSetup_Init, sizeof(TitleSetupState)); @@ -153,7 +153,7 @@ void ConsoleLogo_Init(GameState* thisx) { ConsoleLogoState* this = (ConsoleLogoState*)thisx; uintptr_t segmentSize = SEGMENT_ROM_SIZE(nintendo_rogo_static); - this->staticSegment = THA_AllocEndAlign16(&this->state.heap, segmentSize); + this->staticSegment = THA_AllocTailAlign16(&this->state.heap, segmentSize); DmaMgr_SendRequest0(this->staticSegment, SEGMENT_ROM_START(nintendo_rogo_static), segmentSize); Game_SetFramerateDivisor(&this->state, 1); @@ -165,7 +165,7 @@ void ConsoleLogo_Init(GameState* thisx) { this->state.destroy = ConsoleLogo_Destroy; this->exit = false; - if (!(Padmgr_GetControllerBitmask() & 1)) { + if (!(PadMgr_GetValidControllersMask() & 1)) { gSaveContext.fileNum = 0xFEDC; } else { gSaveContext.fileNum = 0xFF; diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c index fe72ee840..75c031c0a 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c @@ -62,9 +62,6 @@ s16 sQuestRemainsEnvBlue[] = { 150, // Unused }; -#ifdef NON_EQUIVALENT -// TODO: is actually NON_MATCHING, update once `z_kaleido_scope_NES.c` is decompiled -// A single small regalloc at the first `Gfx_DrawTexQuadIA8` for the heart piece count (see `gItemIcons`) void KaleidoScope_DrawQuestStatus(PlayState* play) { static s16 sQuestRemainsColorTimer = 20; static s16 sQuestRemainsColorTimerIndex = 0; @@ -135,10 +132,11 @@ void KaleidoScope_DrawQuestStatus(PlayState* play) { s16 k; s16 skullTokenDigits[3]; u16 isDigitDrawn; + u32* questItemsPtr; OPEN_DISPS(play->state.gfxCtx); - KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_QUEST] * 4, pauseCtx->questVtx); + KaleidoScope_SetCursorVtxPos(pauseCtx, pauseCtx->cursorSlot[PAUSE_QUEST] * 4, pauseCtx->questVtx); gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); @@ -321,7 +319,12 @@ void KaleidoScope_DrawQuestStatus(PlayState* play) { } } - if ((GET_SAVE_INVENTORY_QUEST_ITEMS >> QUEST_HEART_PIECE_COUNT) != 0) { + //! FAKE: Used to load `0xF0000000` early + if ((GET_SAVE_INVENTORY_QUEST_ITEMS & 0xF0000000) != 0) {} + questItemsPtr = &gSaveContext.save.saveInfo.inventory.questItems; + if (1) {} + + if ((*questItemsPtr >> QUEST_HEART_PIECE_COUNT) != 0) { gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); @@ -391,7 +394,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play) { POLY_OPA_DISP, sOcarinaButtonTextures[sQuestSongPlayedOcarinaButtons[i]], 16, 16, 0); } } - } else if (IS_PAUSE_MAIN_STATE_SAVE_PROMPT || (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE_CURSOR_ON_SONG)) { + } else if (IS_PAUSE_MAIN_STATE_SONG_PROMPT || (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE_CURSOR_ON_SONG)) { // Draw the buttons for playing a song sp1C8 = pauseCtx->ocarinaSongIndex; sp1CA = gOcarinaSongButtons[sp1C8].numButtons; @@ -548,34 +551,6 @@ void KaleidoScope_DrawQuestStatus(PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -#else -s16 sQuestRemainsColorTimer = 20; -s16 sQuestRemainsColorTimerIndex = 0; -s16 sQuestHpPrimRed = 0; -s16 sQuestHpPrimGreen = 0; -s16 sQuestHpPrimBlue = 0; -s16 sQuestHpPrimAlpha = 0; -s16 sQuestHpColorTimer = 20; -s16 sQuestHpPrimColorTargetIndex = 0; -TexturePtr sOcarinaButtonTextures[] = { - gOcarinaATex, gOcarinaCDownTex, gOcarinaCRightTex, gOcarinaCLeftTex, gOcarinaCUpTex, -}; -s16 sQuestSongsPrimRed[] = { - 150, 255, 100, 255, 255, 255, 255, 255, 255, 255, 255, 255, -}; -s16 sQuestSongsPrimGreen[] = { - 255, 80, 150, 160, 100, 240, 255, 255, 255, 255, 255, 255, -}; -s16 sQuestSongsPrimBlue[] = { - 100, 40, 255, 0, 255, 100, 255, 255, 255, 255, 255, 255, -}; -TexturePtr sQuestUpgradeTextures[][3] = { - { 0x08053000, 0x08054000, 0x08055000 }, - { 0x08056000, 0x08057000, 0x08058000 }, -}; -u8 sQuestUpgrades[] = { UPG_QUIVER, UPG_BOMB_BAG }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_DrawQuestStatus.s") -#endif typedef enum { /* -3 */ CURSOR_TO_LEFT = -3, // Cursor on the "scroll to left page" position diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c index b8858b7ca..d5d0368dd 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c @@ -370,14 +370,14 @@ void KaleidoScope_DrawInventoryEditor(PlayState* play) { gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); // Current Health Quarter (X / 4) - KaleidoScope_DrawDigit(play, (((void)0, gSaveContext.save.playerData.health) % 0x10) / 4, 217, 15); + KaleidoScope_DrawDigit(play, (((void)0, gSaveContext.save.saveInfo.playerData.health) % 0x10) / 4, 217, 15); gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); // Rupees counterDigits[0] = counterDigits[1] = counterDigits[2] = 0; - counterDigits[3] = gSaveContext.save.playerData.rupees; + counterDigits[3] = gSaveContext.save.saveInfo.playerData.rupees; while (counterDigits[3] >= 1000) { counterDigits[0]++; counterDigits[3] -= 1000; @@ -400,7 +400,7 @@ void KaleidoScope_DrawInventoryEditor(PlayState* play) { // Health capacity counterDigits[2] = 0; - counterDigits[3] = gSaveContext.save.playerData.healthCapacity / 0x10; + counterDigits[3] = gSaveContext.save.saveInfo.playerData.healthCapacity / 0x10; while (counterDigits[3] >= 10) { counterDigits[2]++; counterDigits[3] -= 10; @@ -411,7 +411,7 @@ void KaleidoScope_DrawInventoryEditor(PlayState* play) { // Health counterDigits[2] = 0; - counterDigits[3] = gSaveContext.save.playerData.health / 0x10; + counterDigits[3] = gSaveContext.save.saveInfo.playerData.health / 0x10; while (counterDigits[3] >= 10) { counterDigits[2]++; counterDigits[3] -= 10; @@ -431,10 +431,10 @@ void KaleidoScope_DrawInventoryEditor(PlayState* play) { (slot == SLOT_MAGIC_BEANS)) { counterDigits[3] = AMMO(gAmmoItems[slot]); } else if ((slot == SLOT_TRADE_DEED) || (slot == SLOT_TRADE_KEY_MAMA) || (slot == SLOT_TRADE_COUPLE)) { - counterDigits[3] = gSaveContext.save.inventory.items[slot]; + counterDigits[3] = gSaveContext.save.saveInfo.inventory.items[slot]; } else if (slot >= SLOT_BOTTLE_1) { - counterDigits[3] = gSaveContext.save.inventory.items[slot]; - } else if (gSaveContext.save.inventory.items[slot] != ITEM_NONE) { + counterDigits[3] = gSaveContext.save.saveInfo.inventory.items[slot]; + } else if (gSaveContext.save.saveInfo.inventory.items[slot] != ITEM_NONE) { counterDigits[3] = 1; } @@ -461,7 +461,7 @@ void KaleidoScope_DrawInventoryEditor(PlayState* play) { for (j = 0, rectLeft = 204; j < 6; j++, slot++, rectLeft += 14) { counterDigits[2] = 0; - if (gSaveContext.save.inventory.items[SLOT_MASK_POSTMAN + slot] != ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[SLOT_MASK_POSTMAN + slot] != ITEM_NONE) { counterDigits[2] = 1; } KaleidoScope_DrawDigit(play, counterDigits[2], rectLeft, rectTop); @@ -583,7 +583,7 @@ void KaleidoScope_DrawInventoryEditor(PlayState* play) { // Dungeon Items // Loop over columns (i), (counterDigits[1] stores rectLeft) for (counterDigits[1] = 129, i = 0; i < 4; i++) { - counterDigits[2] = gSaveContext.save.inventory.dungeonItems[i] & gEquipMasks[0]; + counterDigits[2] = gSaveContext.save.saveInfo.inventory.dungeonItems[i] & gEquipMasks[0]; KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], 168); counterDigits[1] += 12; } @@ -591,7 +591,7 @@ void KaleidoScope_DrawInventoryEditor(PlayState* play) { // Stray Fairies // Loop over columns (i), (counterDigits[1] stores rectLeft) for (counterDigits[1] = 202, i = 0; i < 4; i++) { - counterDigits[3] = gSaveContext.save.inventory.strayFairies[i]; + counterDigits[3] = gSaveContext.save.saveInfo.inventory.strayFairies[i]; counterDigits[2] = counterDigits[3] / 10; counterDigits[3] -= counterDigits[2] * 10; if (counterDigits[2] != 0) { @@ -602,22 +602,22 @@ void KaleidoScope_DrawInventoryEditor(PlayState* play) { } // Double Defence - KaleidoScope_DrawDigit(play, gSaveContext.save.playerData.doubleDefense, 44, 202); + KaleidoScope_DrawDigit(play, gSaveContext.save.saveInfo.playerData.doubleDefense, 44, 202); // Magic - //! @bug should be gSaveContext.save.playerData.doubleMagic - KaleidoScope_DrawDigit(play, gSaveContext.save.playerData.doubleDefense, 75, 202); + //! @bug should be gSaveContext.save.saveInfo.playerData.isDoubleMagicAcquired + KaleidoScope_DrawDigit(play, gSaveContext.save.saveInfo.playerData.doubleDefense, 75, 202); // Lottery // Loop over columns (i), (counterDigits[1] stores rectLeft) for (counterDigits[1] = 139, i = 0; i < 3; i++) { - counterDigits[2] = gSaveContext.save.lotteryCodes[0][i]; + counterDigits[2] = gSaveContext.save.saveInfo.lotteryCodes[0][i]; KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], 184); - counterDigits[2] = gSaveContext.save.lotteryCodes[1][i]; + counterDigits[2] = gSaveContext.save.saveInfo.lotteryCodes[1][i]; KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], 198); - counterDigits[2] = gSaveContext.save.lotteryCodes[2][i]; + counterDigits[2] = gSaveContext.save.saveInfo.lotteryCodes[2][i]; KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], 212); counterDigits[1] += 12; @@ -626,7 +626,7 @@ void KaleidoScope_DrawInventoryEditor(PlayState* play) { // Oceanside Spider House Mask Order // Loop over columns (i), (counterDigits[1] stores rectLeft) for (counterDigits[1] = 217, i = 0; i < 6; i++) { - counterDigits[2] = gSaveContext.save.spiderHouseMaskOrder[i]; + counterDigits[2] = gSaveContext.save.saveInfo.spiderHouseMaskOrder[i]; KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], 186); counterDigits[1] += 12; @@ -635,7 +635,7 @@ void KaleidoScope_DrawInventoryEditor(PlayState* play) { // Bombers code // Loop over columns (i), (counterDigits[1] stores rectLeft) for (counterDigits[1] = 220, i = 0; i < 5; i++) { - counterDigits[2] = gSaveContext.save.bomberCode[i]; + counterDigits[2] = gSaveContext.save.saveInfo.bomberCode[i]; KaleidoScope_DrawDigit(play, counterDigits[2], counterDigits[1], 210); counterDigits[1] += 12; @@ -709,24 +709,24 @@ void KaleidoScope_UpdateInventoryEditor(PlayState* play) { case INV_EDITOR_SECTION_RUPEE: // Rupees if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { - gSaveContext.save.playerData.rupees -= 100; - if (gSaveContext.save.playerData.rupees < 0) { - gSaveContext.save.playerData.rupees = 0; + gSaveContext.save.saveInfo.playerData.rupees -= 100; + if (gSaveContext.save.saveInfo.playerData.rupees < 0) { + gSaveContext.save.saveInfo.playerData.rupees = 0; } } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { - gSaveContext.save.playerData.rupees += 100; - if (gSaveContext.save.playerData.rupees >= 9999) { - gSaveContext.save.playerData.rupees = 9999; + gSaveContext.save.saveInfo.playerData.rupees += 100; + if (gSaveContext.save.saveInfo.playerData.rupees >= 9999) { + gSaveContext.save.saveInfo.playerData.rupees = 9999; } } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { - gSaveContext.save.playerData.rupees--; - if (gSaveContext.save.playerData.rupees < 0) { - gSaveContext.save.playerData.rupees = 0; + gSaveContext.save.saveInfo.playerData.rupees--; + if (gSaveContext.save.saveInfo.playerData.rupees < 0) { + gSaveContext.save.saveInfo.playerData.rupees = 0; } } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { - gSaveContext.save.playerData.rupees++; - if (gSaveContext.save.playerData.rupees >= 9999) { - gSaveContext.save.playerData.rupees = 9999; + gSaveContext.save.saveInfo.playerData.rupees++; + if (gSaveContext.save.saveInfo.playerData.rupees >= 9999) { + gSaveContext.save.saveInfo.playerData.rupees = 9999; } } break; @@ -734,15 +734,15 @@ void KaleidoScope_UpdateInventoryEditor(PlayState* play) { case INV_EDITOR_SECTION_HEALTH_CAPACITY: // Health Capacity if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { - gSaveContext.save.playerData.healthCapacity -= 0x10; - if (gSaveContext.save.playerData.healthCapacity < 0x30) { - gSaveContext.save.playerData.healthCapacity = 0x30; + gSaveContext.save.saveInfo.playerData.healthCapacity -= 0x10; + if (gSaveContext.save.saveInfo.playerData.healthCapacity < 0x30) { + gSaveContext.save.saveInfo.playerData.healthCapacity = 0x30; } } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { - gSaveContext.save.playerData.healthCapacity += 0x10; - if (gSaveContext.save.playerData.healthCapacity >= 0x140) { - gSaveContext.save.playerData.healthCapacity = 0x140; + gSaveContext.save.saveInfo.playerData.healthCapacity += 0x10; + if (gSaveContext.save.saveInfo.playerData.healthCapacity >= 0x140) { + gSaveContext.save.saveInfo.playerData.healthCapacity = 0x140; } } break; @@ -806,48 +806,48 @@ void KaleidoScope_UpdateInventoryEditor(PlayState* play) { } else if (slot == SLOT_TRADE_DEED) { if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { if (INV_CONTENT(ITEM_MOON_TEAR) == ITEM_NONE) { - gSaveContext.save.inventory.items[slot] = ITEM_MOON_TEAR; + gSaveContext.save.saveInfo.inventory.items[slot] = ITEM_MOON_TEAR; } else if ((INV_CONTENT(ITEM_MOON_TEAR) >= ITEM_MOON_TEAR) && (INV_CONTENT(ITEM_MOON_TEAR) <= ITEM_DEED_MOUNTAIN)) { - gSaveContext.save.inventory.items[slot] = INV_CONTENT(ITEM_MOON_TEAR) + 1; + gSaveContext.save.saveInfo.inventory.items[slot] = INV_CONTENT(ITEM_MOON_TEAR) + 1; } } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { if (INV_CONTENT(ITEM_MOON_TEAR) == ITEM_NONE) { - gSaveContext.save.inventory.items[slot] = ITEM_DEED_OCEAN; + gSaveContext.save.saveInfo.inventory.items[slot] = ITEM_DEED_OCEAN; } else if ((INV_CONTENT(ITEM_MOON_TEAR) >= ITEM_DEED_LAND) && (INV_CONTENT(ITEM_MOON_TEAR) <= ITEM_DEED_OCEAN)) { - gSaveContext.save.inventory.items[slot] = INV_CONTENT(ITEM_MOON_TEAR) - 1; + gSaveContext.save.saveInfo.inventory.items[slot] = INV_CONTENT(ITEM_MOON_TEAR) - 1; } } } else if (slot == SLOT_TRADE_KEY_MAMA) { if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { if (INV_CONTENT(ITEM_ROOM_KEY) == ITEM_NONE) { - gSaveContext.save.inventory.items[slot] = ITEM_ROOM_KEY; + gSaveContext.save.saveInfo.inventory.items[slot] = ITEM_ROOM_KEY; } else if ((INV_CONTENT(ITEM_ROOM_KEY) >= ITEM_ROOM_KEY) && (INV_CONTENT(ITEM_ROOM_KEY) <= ITEM_ROOM_KEY)) { - gSaveContext.save.inventory.items[slot] = INV_CONTENT(ITEM_ROOM_KEY) + 1; + gSaveContext.save.saveInfo.inventory.items[slot] = INV_CONTENT(ITEM_ROOM_KEY) + 1; } } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { if (INV_CONTENT(ITEM_ROOM_KEY) == ITEM_NONE) { - gSaveContext.save.inventory.items[slot] = ITEM_LETTER_MAMA; + gSaveContext.save.saveInfo.inventory.items[slot] = ITEM_LETTER_MAMA; } else if ((INV_CONTENT(ITEM_ROOM_KEY) >= ITEM_LETTER_MAMA) && (INV_CONTENT(ITEM_ROOM_KEY) <= ITEM_LETTER_MAMA)) { - gSaveContext.save.inventory.items[slot] = INV_CONTENT(ITEM_ROOM_KEY) - 1; + gSaveContext.save.saveInfo.inventory.items[slot] = INV_CONTENT(ITEM_ROOM_KEY) - 1; } } } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { if (INV_CONTENT(ITEM_LETTER_TO_KAFEI) == ITEM_NONE) { - gSaveContext.save.inventory.items[slot] = ITEM_LETTER_TO_KAFEI; + gSaveContext.save.saveInfo.inventory.items[slot] = ITEM_LETTER_TO_KAFEI; } else if ((INV_CONTENT(ITEM_LETTER_TO_KAFEI) >= ITEM_LETTER_TO_KAFEI) && (INV_CONTENT(ITEM_LETTER_TO_KAFEI) <= ITEM_LETTER_TO_KAFEI)) { - gSaveContext.save.inventory.items[slot] = INV_CONTENT(ITEM_LETTER_TO_KAFEI) + 1; + gSaveContext.save.saveInfo.inventory.items[slot] = INV_CONTENT(ITEM_LETTER_TO_KAFEI) + 1; } } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { if (INV_CONTENT(ITEM_LETTER_TO_KAFEI) == ITEM_NONE) { - gSaveContext.save.inventory.items[slot] = ITEM_PENDANT_OF_MEMORIES; + gSaveContext.save.saveInfo.inventory.items[slot] = ITEM_PENDANT_OF_MEMORIES; } else if ((INV_CONTENT(ITEM_LETTER_TO_KAFEI) >= ITEM_PENDANT_OF_MEMORIES) && (INV_CONTENT(ITEM_LETTER_TO_KAFEI) <= ITEM_PENDANT_OF_MEMORIES)) { - gSaveContext.save.inventory.items[slot] = INV_CONTENT(ITEM_LETTER_TO_KAFEI) - 1; + gSaveContext.save.saveInfo.inventory.items[slot] = INV_CONTENT(ITEM_LETTER_TO_KAFEI) - 1; } } } else if ((slot >= SLOT_BOTTLE_1) && (slot <= SLOT_BOTTLE_6)) { @@ -855,18 +855,20 @@ void KaleidoScope_UpdateInventoryEditor(PlayState* play) { value = ITEM_BOTTLE + slot - SLOT_BOTTLE_1; Inventory_DeleteItem(value, SLOT(ITEM_BOTTLE) + slot - SLOT_BOTTLE_1); } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { - if (gSaveContext.save.inventory.items[slot] == ITEM_NONE) { - gSaveContext.save.inventory.items[slot] = ITEM_BOTTLE; - } else if ((gSaveContext.save.inventory.items[slot] >= ITEM_BOTTLE) && - (gSaveContext.save.inventory.items[slot] <= ITEM_HYLIAN_LOACH)) { - gSaveContext.save.inventory.items[slot] = gSaveContext.save.inventory.items[slot] + 1; + if (gSaveContext.save.saveInfo.inventory.items[slot] == ITEM_NONE) { + gSaveContext.save.saveInfo.inventory.items[slot] = ITEM_BOTTLE; + } else if ((gSaveContext.save.saveInfo.inventory.items[slot] >= ITEM_BOTTLE) && + (gSaveContext.save.saveInfo.inventory.items[slot] <= ITEM_HYLIAN_LOACH)) { + gSaveContext.save.saveInfo.inventory.items[slot] = + gSaveContext.save.saveInfo.inventory.items[slot] + 1; } } else if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { - if (gSaveContext.save.inventory.items[slot] == ITEM_NONE) { - gSaveContext.save.inventory.items[slot] = ITEM_OBABA_DRINK; - } else if ((gSaveContext.save.inventory.items[slot] >= ITEM_POTION_RED) && - (gSaveContext.save.inventory.items[slot] <= ITEM_OBABA_DRINK)) { - gSaveContext.save.inventory.items[slot] = gSaveContext.save.inventory.items[slot] - 1; + if (gSaveContext.save.saveInfo.inventory.items[slot] == ITEM_NONE) { + gSaveContext.save.saveInfo.inventory.items[slot] = ITEM_OBABA_DRINK; + } else if ((gSaveContext.save.saveInfo.inventory.items[slot] >= ITEM_POTION_RED) && + (gSaveContext.save.saveInfo.inventory.items[slot] <= ITEM_OBABA_DRINK)) { + gSaveContext.save.saveInfo.inventory.items[slot] = + gSaveContext.save.saveInfo.inventory.items[slot] - 1; } } } else { @@ -874,7 +876,7 @@ void KaleidoScope_UpdateInventoryEditor(PlayState* play) { CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { value = sSlotItems[slot]; - if (gSaveContext.save.inventory.items[slot] == ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[slot] == ITEM_NONE) { INV_CONTENT(value) = value; } else { Inventory_DeleteItem(value, slot); @@ -895,7 +897,7 @@ void KaleidoScope_UpdateInventoryEditor(PlayState* play) { if (value != 0) { CUR_FORM_EQUIP(EQUIP_SLOT_B) = value + (ITEM_SWORD_KOKIRI - 1); - gSaveContext.save.playerData.swordHealth = 100; + gSaveContext.save.saveInfo.playerData.swordHealth = 100; } else { CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_NONE; } @@ -910,7 +912,7 @@ void KaleidoScope_UpdateInventoryEditor(PlayState* play) { SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, value); CUR_FORM_EQUIP(EQUIP_SLOT_B) = value + (ITEM_SWORD_KOKIRI - 1); - gSaveContext.save.playerData.swordHealth = 100; + gSaveContext.save.saveInfo.playerData.swordHealth = 100; } Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); @@ -974,41 +976,43 @@ void KaleidoScope_UpdateInventoryEditor(PlayState* play) { } else if (sCurSection == INV_EDITOR_SECTION_SWAMP_GOLD_SKULLS) { // Gold Skulls (Swamp Spider House) if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { - if (((gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10) != 0) { - gSaveContext.save.skullTokenCount = - ((u16)(((gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10) - 1) << 0x10) | - (gSaveContext.save.skullTokenCount & 0xFFFF); + if (((gSaveContext.save.saveInfo.skullTokenCount & 0xFFFF0000) >> 0x10) != 0) { + gSaveContext.save.saveInfo.skullTokenCount = + ((u16)(((gSaveContext.save.saveInfo.skullTokenCount & 0xFFFF0000) >> 0x10) - 1) << 0x10) | + (gSaveContext.save.saveInfo.skullTokenCount & 0xFFFF); } } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { - gSaveContext.save.skullTokenCount = - ((u16)(((gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10) + 1) << 0x10) | - (gSaveContext.save.skullTokenCount & 0xFFFF); + gSaveContext.save.saveInfo.skullTokenCount = + ((u16)(((gSaveContext.save.saveInfo.skullTokenCount & 0xFFFF0000) >> 0x10) + 1) << 0x10) | + (gSaveContext.save.saveInfo.skullTokenCount & 0xFFFF); } } else if (sCurSection == INV_EDITOR_SECTION_OCEAN_GOLD_SKULLS) { // Gold Skulls (Oceans Spider House) if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { - if (((u16)gSaveContext.save.skullTokenCount) != 0) { - gSaveContext.save.skullTokenCount = (((u16)gSaveContext.save.skullTokenCount - 1) & 0xFFFF) | - (gSaveContext.save.skullTokenCount & 0xFFFF0000); + if (((u16)gSaveContext.save.saveInfo.skullTokenCount) != 0) { + gSaveContext.save.saveInfo.skullTokenCount = + (((u16)gSaveContext.save.saveInfo.skullTokenCount - 1) & 0xFFFF) | + (gSaveContext.save.saveInfo.skullTokenCount & 0xFFFF0000); } } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { - gSaveContext.save.skullTokenCount = (((u16)gSaveContext.save.skullTokenCount + 1) & 0xFFFF) | - (gSaveContext.save.skullTokenCount & 0xFFFF0000); + gSaveContext.save.saveInfo.skullTokenCount = + (((u16)gSaveContext.save.saveInfo.skullTokenCount + 1) & 0xFFFF) | + (gSaveContext.save.saveInfo.skullTokenCount & 0xFFFF0000); } } else if (sCurSection == INV_EDITOR_SECTION_NOTEBOOK) { // Bombers Notebook if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { - gSaveContext.save.inventory.questItems ^= gBitFlags[QUEST_BOMBERS_NOTEBOOK]; + gSaveContext.save.saveInfo.inventory.questItems ^= gBitFlags[QUEST_BOMBERS_NOTEBOOK]; } } else if (sCurSection == INV_EDITOR_SECTION_LULLABY_INTRO) { // Goron Lullaby Intro if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { - gSaveContext.save.inventory.questItems ^= gBitFlags[QUEST_SONG_LULLABY_INTRO]; + gSaveContext.save.saveInfo.inventory.questItems ^= gBitFlags[QUEST_SONG_LULLABY_INTRO]; } } else if (sCurSection < INV_EDITOR_SECTION_LULLABY_INTRO) { @@ -1017,7 +1021,7 @@ void KaleidoScope_UpdateInventoryEditor(PlayState* play) { //! have also been taken slot = sCurSection - INV_EDITOR_SECTION_BOSS; if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { - gSaveContext.save.inventory.questItems ^= gBitFlags[slot]; + gSaveContext.save.saveInfo.inventory.questItems ^= gBitFlags[slot]; } } else if (sCurSection < INV_EDITOR_SECTION_DUNGEON_ITEMS) { @@ -1045,30 +1049,30 @@ void KaleidoScope_UpdateInventoryEditor(PlayState* play) { slot = sCurSection - INV_EDITOR_SECTION_DUNGEON_ITEMS; if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { // Map - gSaveContext.save.inventory.dungeonItems[slot] ^= 4; + gSaveContext.save.saveInfo.inventory.dungeonItems[slot] ^= 4; } if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { // Compass - gSaveContext.save.inventory.dungeonItems[slot] ^= 2; + gSaveContext.save.saveInfo.inventory.dungeonItems[slot] ^= 2; } if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { // Boss Key - gSaveContext.save.inventory.dungeonItems[slot] ^= 1; + gSaveContext.save.saveInfo.inventory.dungeonItems[slot] ^= 1; } } else if (sCurSection < INV_EDITOR_SECTION_DOUBLE_DEFENSE) { // Stray Fairies slot = sCurSection - INV_EDITOR_SECTION_STRAY_FAIRIES; if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { - gSaveContext.save.inventory.strayFairies[slot]--; - if (gSaveContext.save.inventory.strayFairies[slot] < 0) { - gSaveContext.save.inventory.strayFairies[slot] = 0; + gSaveContext.save.saveInfo.inventory.strayFairies[slot]--; + if (gSaveContext.save.saveInfo.inventory.strayFairies[slot] < 0) { + gSaveContext.save.saveInfo.inventory.strayFairies[slot] = 0; } } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { - gSaveContext.save.inventory.strayFairies[slot]++; - if (gSaveContext.save.inventory.strayFairies[slot] >= 99) { - gSaveContext.save.inventory.strayFairies[slot] = 99; + gSaveContext.save.saveInfo.inventory.strayFairies[slot]++; + if (gSaveContext.save.saveInfo.inventory.strayFairies[slot] >= 99) { + gSaveContext.save.saveInfo.inventory.strayFairies[slot] = 99; } } @@ -1076,11 +1080,11 @@ void KaleidoScope_UpdateInventoryEditor(PlayState* play) { // Double Defence if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT) || CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { - gSaveContext.save.playerData.doubleDefense ^= 1; - if (!gSaveContext.save.playerData.doubleDefense) { - gSaveContext.save.inventory.defenseHearts = 0; + gSaveContext.save.saveInfo.playerData.doubleDefense ^= 1; + if (!gSaveContext.save.saveInfo.playerData.doubleDefense) { + gSaveContext.save.saveInfo.inventory.defenseHearts = 0; } else { - gSaveContext.save.inventory.defenseHearts = 20; + gSaveContext.save.saveInfo.inventory.defenseHearts = 20; } } } diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c index d1a358e75..cfcaf20ea 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c @@ -15,7 +15,7 @@ s16 sEquipMagicArrowSlotHoldTimer = 0; // Number of frames to move icon from slot to target position when equipping. s16 sEquipAnimTimer = 10; -u8 gPlayerFormSlotRestrictions[PLAYER_FORM_MAX][NUM_ITEM_SLOTS] = { +u8 gPlayerFormSlotRestrictions[PLAYER_FORM_MAX][ITEM_NUM_SLOTS] = { // Fierce Deity { false, // SLOT_OCARINA @@ -236,14 +236,14 @@ void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, CLOSE_DISPS(gfxCtx); } -void KaleidoScope_SetCursorVtx(PauseContext* pauseCtx, u16 index, Vtx* vtx) { - pauseCtx->cursorVtx[0].v.ob[0] = vtx[index].v.ob[0]; - pauseCtx->cursorVtx[0].v.ob[1] = vtx[index].v.ob[1]; +void KaleidoScope_SetCursorVtxPos(PauseContext* pauseCtx, u16 vtxIndex, Vtx* vtx) { + pauseCtx->cursorVtx[0].v.ob[0] = vtx[vtxIndex].v.ob[0]; + pauseCtx->cursorVtx[0].v.ob[1] = vtx[vtxIndex].v.ob[1]; } -s16 sMagicArrowEffectsR[] = { 255, 100, 255 }; -s16 sMagicArrowEffectsG[] = { 0, 100, 255 }; -s16 sMagicArrowEffectsB[] = { 0, 255, 100 }; +static s16 sMagicArrowEffectsR[] = { 255, 100, 255 }; +static s16 sMagicArrowEffectsG[] = { 0, 100, 255 }; +static s16 sMagicArrowEffectsB[] = { 0, 255, 100 }; void KaleidoScope_DrawItemSelect(PlayState* play) { PauseContext* pauseCtx = &play->pauseCtx; @@ -258,9 +258,9 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { // Loop over c-buttons (i) and vtx offset (j) gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); - for (i = 0, j = NUM_ITEM_SLOTS * 4; i < 3; i++, j += 4) { + for (i = 0, j = ITEM_NUM_SLOTS * 4; i < 3; i++, j += 4) { if (GET_CUR_FORM_BTN_ITEM(i + 1) != ITEM_NONE) { - if (GET_CUR_FORM_BTN_SLOT(i + 1) < NUM_ITEM_SLOTS) { + if (GET_CUR_FORM_BTN_SLOT(i + 1) < ITEM_NUM_SLOTS) { gSPVertex(POLY_OPA_DISP++, &pauseCtx->itemVtx[j], 4, 0); POLY_OPA_DISP = Gfx_DrawTexQuadIA8(POLY_OPA_DISP, gEquippedItemOutlineTex, 32, 32, 0); } @@ -272,10 +272,10 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { // Draw the item icons // Loop over slots (i) and vtx offset (j) gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - for (j = 0, i = 0; i < NUM_ITEM_SLOTS; i++, j += 4) { + for (j = 0, i = 0; i < ITEM_NUM_SLOTS; i++, j += 4) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); - if (((void)0, gSaveContext.save.inventory.items[i]) != ITEM_NONE) { + if (((void)0, gSaveContext.save.saveInfo.inventory.items[i]) != ITEM_NONE) { if ((pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && (pauseCtx->pageIndex == PAUSE_ITEM) && (pauseCtx->cursorSpecialPos == 0) && gPlayerFormSlotRestrictions[(void)0, gSaveContext.save.playerForm][i]) { @@ -309,8 +309,8 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { } gSPVertex(POLY_OPA_DISP++, &pauseCtx->itemVtx[j + 0], 4, 0); - KaleidoScope_DrawTexQuadRGBA32(play->state.gfxCtx, - gItemIcons[((void)0, gSaveContext.save.inventory.items[i])], 32, 32, 0); + KaleidoScope_DrawTexQuadRGBA32( + play->state.gfxCtx, gItemIcons[((void)0, gSaveContext.save.saveInfo.inventory.items[i])], 32, 32, 0); } } @@ -323,11 +323,11 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); // Loop over slots (i) and ammoIndex (j) - for (j = 0, i = 0; i < NUM_ITEM_SLOTS; i++) { + for (j = 0, i = 0; i < ITEM_NUM_SLOTS; i++) { if (gAmmoItems[i] != ITEM_NONE) { - if (((void)0, gSaveContext.save.inventory.items[i]) != ITEM_NONE) { + if (((void)0, gSaveContext.save.saveInfo.inventory.items[i]) != ITEM_NONE) { KaleidoScope_DrawAmmoCount(pauseCtx, play->state.gfxCtx, - ((void)0, gSaveContext.save.inventory.items[i]), j); + ((void)0, gSaveContext.save.saveInfo.inventory.items[i]), j); } j++; } @@ -398,7 +398,7 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorXIndex[PAUSE_ITEM] + (pauseCtx->cursorYIndex[PAUSE_ITEM] * 6); - if (pauseCtx->cursorPoint[PAUSE_ITEM] >= NUM_ITEM_SLOTS) { + if (pauseCtx->cursorPoint[PAUSE_ITEM] >= ITEM_NUM_SLOTS) { pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorXIndex[PAUSE_ITEM]; } @@ -429,7 +429,7 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorXIndex[PAUSE_ITEM] + (pauseCtx->cursorYIndex[PAUSE_ITEM] * 6); - if (pauseCtx->cursorPoint[PAUSE_ITEM] >= NUM_ITEM_SLOTS) { + if (pauseCtx->cursorPoint[PAUSE_ITEM] >= ITEM_NUM_SLOTS) { pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorXIndex[PAUSE_ITEM]; } @@ -446,7 +446,7 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { } if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { - cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; + cursorItem = gSaveContext.save.saveInfo.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; } } } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { @@ -459,7 +459,7 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { // Search for slot to move to while (true) { // Check if current cursor has an item in its slot - if (gSaveContext.save.inventory.items[cursorPoint] != ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[cursorPoint] != ITEM_NONE) { pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; pauseCtx->cursorYIndex[PAUSE_ITEM] = cursorYIndex; @@ -497,7 +497,7 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { // Search for slot to move to while (true) { // Check if current cursor has an item in its slot - if (gSaveContext.save.inventory.items[cursorPoint] != ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[cursorPoint] != ITEM_NONE) { pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; pauseCtx->cursorYIndex[PAUSE_ITEM] = cursorYIndex; @@ -568,9 +568,9 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { - cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; + cursorItem = gSaveContext.save.saveInfo.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; } else if (moveCursorResult != PAUSE_CURSOR_RESULT_SPECIAL_POS) { - cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; + cursorItem = gSaveContext.save.saveInfo.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; } if (cursorItem == ITEM_NONE) { @@ -737,7 +737,7 @@ void KaleidoScope_UpdateItemEquip(PlayState* play) { } if (sEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { - bowItemVtx = &pauseCtx->itemVtx[4]; + bowItemVtx = &pauseCtx->itemVtx[SLOT_BOW * 4]; offsetX = ABS_ALT(pauseCtx->equipAnimX - bowItemVtx->v.ob[0] * 10) / sEquipAnimTimer; offsetY = ABS_ALT(pauseCtx->equipAnimY - bowItemVtx->v.ob[1] * 10) / sEquipAnimTimer; } else { @@ -761,13 +761,13 @@ void KaleidoScope_UpdateItemEquip(PlayState* play) { // Update coordinates of item icon while being equipped if (sEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { // target is the bow slot - if (pauseCtx->equipAnimX >= (pauseCtx->itemVtx[4].v.ob[0] * 10)) { + if (pauseCtx->equipAnimX >= (pauseCtx->itemVtx[SLOT_BOW * 4].v.ob[0] * 10)) { pauseCtx->equipAnimX -= offsetX; } else { pauseCtx->equipAnimX += offsetX; } - if (pauseCtx->equipAnimY >= (pauseCtx->itemVtx[4].v.ob[1] * 10)) { + if (pauseCtx->equipAnimY >= (pauseCtx->itemVtx[SLOT_BOW * 4].v.ob[1] * 10)) { pauseCtx->equipAnimY -= offsetY; } else { pauseCtx->equipAnimY += offsetY; diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c index 87acfaa6c..af12f2d5d 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c @@ -10,14 +10,8 @@ #include "interface/icon_item_dungeon_static/icon_item_dungeon_static.h" #include "interface/icon_item_jpn_static/icon_item_jpn_static.h" -extern s16 D_8082B7F0[]; -extern s16 D_8082B838[]; - extern TexturePtr D_09007500; // gPlayerFaceIcon -#define WORLD_MAP_IMAGE_TEX_WIDTH 216 -#define WORLD_MAP_IMAGE_TEX_HEIGHT 128 - void KaleidoScope_DrawDungeonStrayFairyCount(PlayState* play) { s16 counterDigits[2]; s16 rectLeft; @@ -59,7 +53,7 @@ void KaleidoScope_DrawDungeonStrayFairyCount(PlayState* play) { 1 << 10); // Get digits for current number of stray fairies collected - counterDigits[1] = gSaveContext.save.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex]; + counterDigits[1] = gSaveContext.save.saveInfo.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex]; counterDigits[0] = counterDigits[1] / 10; counterDigits[1] -= (s16)(counterDigits[0] * 10); @@ -142,8 +136,8 @@ void KaleidoScope_DrawDungeonMap(PlayState* play) { OPEN_DISPS(play->state.gfxCtx); - j = 72 + (pauseCtx->cursorSlot[PAUSE_MAP] * 4); - KaleidoScope_SetCursorVtx(pauseCtx, j, pauseCtx->mapPageVtx); + j = (QUAD_MAP_PAGE_DUNGEON_MAP + pauseCtx->cursorSlot[PAUSE_MAP]) * 4; + KaleidoScope_SetCursorVtxPos(pauseCtx, j, pauseCtx->mapPageVtx); pauseCtx->cursorItem[PAUSE_MAP] = PAUSE_ITEM_NONE; if (pauseCtx->cursorSpecialPos == 0) { @@ -153,11 +147,19 @@ void KaleidoScope_DrawDungeonMap(PlayState* play) { pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_MAP]; } + // Set vertices for: + // QUAD_MAP_PAGE_DUNGEON_TITLE, + // QUAD_MAP_PAGE_DUNGEON_BOSS_KEY, + // QUAD_MAP_PAGE_DUNGEON_COMPASS, + // QUAD_MAP_PAGE_DUNGEON_MAP gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[60], 16, 0); + + // Dungeon Title gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA); + // QUAD_MAP_PAGE_DUNGEON_TITLE POLY_OPA_DISP = Gfx_DrawTexQuadIA8(POLY_OPA_DISP, sDungeonTitleTextures[((void)0, gSaveContext.dungeonIndex)], 128, 16, 0); @@ -211,6 +213,7 @@ void KaleidoScope_DrawDungeonMap(PlayState* play) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + // QUAD_MAP_PAGE_DUNGEON_STRAY_FAIRY_GLOWING_CIRCLE pauseCtx->mapPageVtx[76].v.ob[0] = pauseCtx->mapPageVtx[78].v.ob[0] = -16; pauseCtx->mapPageVtx[77].v.ob[0] = pauseCtx->mapPageVtx[79].v.ob[0] = @@ -221,7 +224,8 @@ void KaleidoScope_DrawDungeonMap(PlayState* play) { pauseCtx->mapPageVtx[78].v.ob[1] = pauseCtx->mapPageVtx[79].v.ob[1] = pauseCtx->mapPageVtx[76].v.ob[1] - 24; - gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[76], 4, 0); + gSPVertex(POLY_OPA_DISP++, + &pauseCtx->mapPageVtx[QUAD_MAP_PAGE_DUNGEON_STRAY_FAIRY_GLOWING_CIRCLE * 4], 4, 0); POLY_OPA_DISP = Gfx_DrawTexQuad4b(POLY_OPA_DISP, gStrayFairyGlowingCircleIconTex, G_IM_FMT_I, 32, 24, 0); @@ -258,6 +262,9 @@ void KaleidoScope_DrawDungeonMap(PlayState* play) { G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + // QUAD_MAP_PAGE_DUNGEON_BOSS_KEY + // QUAD_MAP_PAGE_DUNGEON_COMPASS + // QUAD_MAP_PAGE_DUNGEON_MAP gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); } } @@ -379,7 +386,7 @@ void KaleidoScope_UpdateDungeonCursor(PlayState* play) { } else if ((pauseCtx->cursorSpecialPos == 0) && (pauseCtx->stickAdjY > 30)) { if (pauseCtx->cursorPoint[PAUSE_MAP] >= DUNGEON_FLOOR_INDEX_4) { for (i = pauseCtx->cursorPoint[PAUSE_MAP] - (DUNGEON_FLOOR_INDEX_4 + 1); i >= 0; i--) { - if ((gSaveContext.save.permanentSceneFlags[(void)0, gSaveContext.dungeonIndex].unk_14 & + if ((gSaveContext.save.saveInfo.permanentSceneFlags[(void)0, gSaveContext.dungeonIndex].unk_14 & gBitFlags[i]) || func_801090B0(FLOOR_INDEX_MAX - i)) { pauseCtx->cursorPoint[PAUSE_MAP] = i + DUNGEON_FLOOR_INDEX_4; @@ -400,7 +407,7 @@ void KaleidoScope_UpdateDungeonCursor(PlayState* play) { (pauseCtx->cursorPoint[PAUSE_MAP] <= DUNGEON_FLOOR_INDEX_1)) { for (i = pauseCtx->cursorPoint[PAUSE_MAP] - (DUNGEON_FLOOR_INDEX_4 - 1); i <= DUNGEON_FLOOR_INDEX_0; i++) { - if ((gSaveContext.save.permanentSceneFlags[(void)0, gSaveContext.dungeonIndex].unk_14 & + if ((gSaveContext.save.saveInfo.permanentSceneFlags[(void)0, gSaveContext.dungeonIndex].unk_14 & gBitFlags[i]) || func_801090B0(FLOOR_INDEX_MAX - i)) { pauseCtx->cursorPoint[PAUSE_MAP] = i + DUNGEON_FLOOR_INDEX_4; @@ -486,6 +493,7 @@ s16 sWorldMapDotPrimColors[][3] = { { 0, 0, 255 }, { 255, 255, 0 }, }; + s16 sWorldMapDotEnvColors[][3] = { { 255, 255, 0 }, { 0, 0, 255 }, @@ -537,7 +545,7 @@ void KaleidoScope_DrawWorldMap(PlayState* play) { OPEN_DISPS(play->state.gfxCtx); - KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_MAP] * 4, pauseCtx->mapPageVtx); + KaleidoScope_SetCursorVtxPos(pauseCtx, pauseCtx->cursorSlot[PAUSE_MAP] * 4, pauseCtx->mapPageVtx); // Draw the world map image if ((pauseCtx->pageIndex == PAUSE_MAP) && (pauseCtx->state == PAUSE_STATE_MAIN) && @@ -561,12 +569,12 @@ void KaleidoScope_DrawWorldMap(PlayState* play) { // Process the 128 rows of pixels for gWorldMapImageTex, 8 rows at a time over 16 iterations // Loop over yPos (t), textureIndex (j) for (t = 62, j = 0; j < 16; j++, t += 8) { - gDPLoadTextureBlock(POLY_OPA_DISP++, (u8*)gWorldMapImageTex + j * (WORLD_MAP_IMAGE_TEX_WIDTH * 8), - G_IM_FMT_CI, G_IM_SIZ_8b, WORLD_MAP_IMAGE_TEX_WIDTH, 8, 0, G_TX_NOMIRROR | G_TX_WRAP, + gDPLoadTextureBlock(POLY_OPA_DISP++, (u8*)gWorldMapImageTex + j * (WORLD_MAP_IMAGE_WIDTH * 8), G_IM_FMT_CI, + G_IM_SIZ_8b, WORLD_MAP_IMAGE_WIDTH, 8, 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); rectLeft = 51 << 2; - rectRight = rectLeft + (WORLD_MAP_IMAGE_TEX_WIDTH << 2); + rectRight = rectLeft + (WORLD_MAP_IMAGE_WIDTH << 2); gSPTextureRectangle(POLY_OPA_DISP++, rectLeft, t << 2, rectRight, (t << 2) + (8 << 2), G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); } @@ -593,36 +601,39 @@ void KaleidoScope_DrawWorldMap(PlayState* play) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); // Set the vertices for the first 8 quads attached to the world map texture. - gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[204], 8 * 4, 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[QUAD_MAP_PAGE_WORLD_IMAGE_FIRST * 4], 8 * 4, 0); // Process the first 72 rows of pixels for gWorldMapImageTex, 9 rows at a time over 8 iterations // Loop over quadIndex of this loop (i), quadIndex of the entire texture (k), vtxIndex (j) for (i = 0, k = 0, j = 0; i < 8; i++, k++, j += 4) { - gDPLoadTextureBlock(POLY_OPA_DISP++, (u8*)gWorldMapImageTex + k * (WORLD_MAP_IMAGE_TEX_WIDTH * 9), - G_IM_FMT_CI, G_IM_SIZ_8b, WORLD_MAP_IMAGE_TEX_WIDTH, 9, 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); + gDPLoadTextureBlock( + POLY_OPA_DISP++, (u8*)gWorldMapImageTex + k * (WORLD_MAP_IMAGE_WIDTH * WORLD_MAP_IMAGE_FRAG_HEIGHT), + G_IM_FMT_CI, G_IM_SIZ_8b, WORLD_MAP_IMAGE_WIDTH, WORLD_MAP_IMAGE_FRAG_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); gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); } // Set the vertices for the last 7 quads attached to the world map texture: // 6 quads with a height of 9, 1 quad with a height of 2 - gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[236], (6 + 1) * 4, 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[(QUAD_MAP_PAGE_WORLD_IMAGE_FIRST + 8) * 4], (6 + 1) * 4, 0); // Process the next 54 rows of pixels for gWorldMapImageTex, 9 rows at a time over 6 iterations // Loop over quadIndex of this loop (i), quadIndex of the entire texture (k), vtxIndex (j) for (i = 0, j = 0; i < 6; i++, k++, j += 4) { - gDPLoadTextureBlock(POLY_OPA_DISP++, (u8*)gWorldMapImageTex + k * (WORLD_MAP_IMAGE_TEX_WIDTH * 9), - G_IM_FMT_CI, G_IM_SIZ_8b, WORLD_MAP_IMAGE_TEX_WIDTH, 9, 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); + gDPLoadTextureBlock( + POLY_OPA_DISP++, (u8*)gWorldMapImageTex + k * (WORLD_MAP_IMAGE_WIDTH * WORLD_MAP_IMAGE_FRAG_HEIGHT), + G_IM_FMT_CI, G_IM_SIZ_8b, WORLD_MAP_IMAGE_WIDTH, WORLD_MAP_IMAGE_FRAG_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); gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); } // Process the last 2 rows of pixels for gWorldMapImageTex - gDPLoadTextureBlock(POLY_OPA_DISP++, (u8*)gWorldMapImageTex + k * (WORLD_MAP_IMAGE_TEX_WIDTH * 9), G_IM_FMT_CI, - G_IM_SIZ_8b, WORLD_MAP_IMAGE_TEX_WIDTH, 2, 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); + gDPLoadTextureBlock( + POLY_OPA_DISP++, (u8*)gWorldMapImageTex + k * (WORLD_MAP_IMAGE_WIDTH * WORLD_MAP_IMAGE_FRAG_HEIGHT), + G_IM_FMT_CI, G_IM_SIZ_8b, WORLD_MAP_IMAGE_WIDTH, WORLD_MAP_IMAGE_HEIGHT % WORLD_MAP_IMAGE_FRAG_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); gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); } @@ -641,12 +652,13 @@ void KaleidoScope_DrawWorldMap(PlayState* play) { // Draw clouds over the world map // Iterate over cloud bits (n) - for (n = 0; n < 15; n++) { - if (!(((void)0, gSaveContext.save.worldMapCloudVisibility) & gBitFlags[n])) { + for (n = 0; n < WORLD_MAP_NUM_CLOUDS; n++) { + if (!(((void)0, gSaveContext.save.saveInfo.worldMapCloudVisibility) & gBitFlags[n])) { - gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[60 + n * 4], 4, 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[(QUAD_MAP_PAGE_WORLD_CLOUDS_FIRST + n) * 4], 4, 0); - POLY_OPA_DISP = Gfx_DrawTexQuadIA8(POLY_OPA_DISP, sCloudTextures[n], D_8082B7F0[n], D_8082B838[n], 0); + POLY_OPA_DISP = Gfx_DrawTexQuadIA8(POLY_OPA_DISP, sCloudTextures[n], gVtxPageMapWorldQuadsWidth[n], + gVtxPageMapWorldQuadsHeight[n], 0); } } @@ -674,8 +686,9 @@ void KaleidoScope_DrawWorldMap(PlayState* play) { sWorldMapDotEnvColors[0][2], 0); if (R_PAUSE_DBG_MAP_CLOUD_ON) { - gSaveContext.save.worldMapCloudVisibility |= (u16)~0x8000; + gSaveContext.save.saveInfo.worldMapCloudVisibility |= (u16)~0x8000; + // QUAD_MAP_PAGE_WORLD_REGION_FIRST pauseCtx->mapPageVtx[120].v.ob[0] = pauseCtx->mapPageVtx[122].v.ob[0] = R_PAUSE_DBG_MAP_CLOUD_X; pauseCtx->mapPageVtx[121].v.ob[0] = pauseCtx->mapPageVtx[123].v.ob[0] = @@ -690,7 +703,7 @@ void KaleidoScope_DrawWorldMap(PlayState* play) { // Loop over RegionId (i), unused vtxIndex (j), unused (k) for (i = 0, j = 0; i < REGION_MAX; i++, k++, j += 4) { if (pauseCtx->worldMapPoints[i]) { - gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[120 + i * 4], 4, 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[(QUAD_MAP_PAGE_WORLD_REGION_FIRST + i) * 4], 4, 0); gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); } } @@ -706,8 +719,9 @@ void KaleidoScope_DrawWorldMap(PlayState* play) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); if (R_PAUSE_DBG_MAP_CLOUD_ON) { - gSaveContext.save.worldMapCloudVisibility |= (u16)~0x8000; + gSaveContext.save.saveInfo.worldMapCloudVisibility |= (u16)~0x8000; + // QUAD_MAP_PAGE_WORLD_WARP_FIRST pauseCtx->mapPageVtx[164].v.ob[0] = pauseCtx->mapPageVtx[166].v.ob[0] = R_PAUSE_DBG_MAP_CLOUD_X; pauseCtx->mapPageVtx[165].v.ob[0] = pauseCtx->mapPageVtx[167].v.ob[0] = @@ -722,7 +736,7 @@ void KaleidoScope_DrawWorldMap(PlayState* play) { // Loop over OwlWarpId (i), unused vtxIndex (j), unused (k) for (i = 0, j = 0; i < OWL_WARP_ENTRANCE; i++, k++, j += 4) { if (pauseCtx->worldMapPoints[i]) { - gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[164 + i * 4], 4, 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[(QUAD_MAP_PAGE_WORLD_WARP_FIRST + i) * 4], 4, 0); gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); } } diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c index 219ecd7a9..950e10788 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c @@ -15,7 +15,7 @@ s16 sMaskEquipMagicArrowSlotHoldTimer = 0; // Number of frames to move icon from slot to target position when equipping. s16 sMaskEquipAnimTimer = 10; -u8 gMaskPlayerFormSlotRestrictions[PLAYER_FORM_MAX][NUM_MASK_SLOTS] = { +u8 gMaskPlayerFormSlotRestrictions[PLAYER_FORM_MAX][MASK_NUM_SLOTS] = { // Fierce Deity { false, // SLOT_MASK_POSTMAN @@ -196,7 +196,7 @@ void KaleidoScope_DrawMaskSelect(PlayState* play) { OPEN_DISPS(play->state.gfxCtx); - KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_MASK] * 4, pauseCtx->maskVtx); + KaleidoScope_SetCursorVtxPos(pauseCtx, pauseCtx->cursorSlot[PAUSE_MASK] * 4, pauseCtx->maskVtx); func_8012C8AC(play->state.gfxCtx); @@ -204,9 +204,9 @@ void KaleidoScope_DrawMaskSelect(PlayState* play) { // Loop over c-buttons (i) and vtx offset (j) gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); - for (i = 0, j = NUM_MASK_SLOTS * 4; i < 3; i++, j += 4) { + for (i = 0, j = MASK_NUM_SLOTS * 4; i < 3; i++, j += 4) { if (GET_CUR_FORM_BTN_ITEM(i + 1) != ITEM_NONE) { - if (GET_CUR_FORM_BTN_SLOT(i + 1) >= NUM_ITEM_SLOTS) { + if (GET_CUR_FORM_BTN_SLOT(i + 1) >= ITEM_NUM_SLOTS) { gSPVertex(POLY_OPA_DISP++, &pauseCtx->maskVtx[j], 4, 0); POLY_OPA_DISP = Gfx_DrawTexQuadIA8(POLY_OPA_DISP, gEquippedItemOutlineTex, 32, 32, 0); } @@ -218,10 +218,10 @@ void KaleidoScope_DrawMaskSelect(PlayState* play) { // Draw the item icons // Loop over slots (i) and vtx offset (j) gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - for (j = 0, i = 0; i < NUM_MASK_SLOTS; i++, j += 4) { + for (j = 0, i = 0; i < MASK_NUM_SLOTS; i++, j += 4) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); - if (((void)0, gSaveContext.save.inventory.items[i + NUM_ITEM_SLOTS]) != ITEM_NONE) { + if (((void)0, gSaveContext.save.saveInfo.inventory.items[i + ITEM_NUM_SLOTS]) != ITEM_NONE) { if (!CHECK_GIVEN_MASK_ON_MOON(i)) { if ((pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && (pauseCtx->pageIndex == PAUSE_MASK) && (pauseCtx->cursorSpecialPos == 0) && @@ -258,8 +258,8 @@ void KaleidoScope_DrawMaskSelect(PlayState* play) { gSPVertex(POLY_OPA_DISP++, &pauseCtx->maskVtx[j + 0], 4, 0); KaleidoScope_DrawTexQuadRGBA32( - play->state.gfxCtx, gItemIcons[((void)0, gSaveContext.save.inventory.items[i + NUM_ITEM_SLOTS])], - 32, 32, 0); + play->state.gfxCtx, + gItemIcons[((void)0, gSaveContext.save.saveInfo.inventory.items[i + ITEM_NUM_SLOTS])], 32, 32, 0); } } } @@ -324,7 +324,7 @@ void KaleidoScope_UpdateMaskCursor(PlayState* play) { pauseCtx->cursorPoint[PAUSE_MASK] = pauseCtx->cursorXIndex[PAUSE_MASK] + (pauseCtx->cursorYIndex[PAUSE_MASK] * 6); - if (pauseCtx->cursorPoint[PAUSE_MASK] >= NUM_MASK_SLOTS) { + if (pauseCtx->cursorPoint[PAUSE_MASK] >= MASK_NUM_SLOTS) { pauseCtx->cursorPoint[PAUSE_MASK] = pauseCtx->cursorXIndex[PAUSE_MASK]; } @@ -354,7 +354,7 @@ void KaleidoScope_UpdateMaskCursor(PlayState* play) { pauseCtx->cursorPoint[PAUSE_MASK] = pauseCtx->cursorXIndex[PAUSE_MASK] + (pauseCtx->cursorYIndex[PAUSE_MASK] * 6); - if (pauseCtx->cursorPoint[PAUSE_MASK] >= NUM_MASK_SLOTS) { + if (pauseCtx->cursorPoint[PAUSE_MASK] >= MASK_NUM_SLOTS) { pauseCtx->cursorPoint[PAUSE_MASK] = pauseCtx->cursorXIndex[PAUSE_MASK]; } @@ -371,7 +371,8 @@ void KaleidoScope_UpdateMaskCursor(PlayState* play) { } if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { - cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + NUM_ITEM_SLOTS]; + cursorItem = + gSaveContext.save.saveInfo.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + ITEM_NUM_SLOTS]; if (CHECK_GIVEN_MASK_ON_MOON(pauseCtx->cursorPoint[PAUSE_MASK])) { cursorItem = ITEM_NONE; } @@ -387,7 +388,7 @@ void KaleidoScope_UpdateMaskCursor(PlayState* play) { // Search for slot to move to while (true) { // Check if current cursor has an item in its slot - if ((gSaveContext.save.inventory.items[cursorPoint + NUM_ITEM_SLOTS] != ITEM_NONE) && + if ((gSaveContext.save.saveInfo.inventory.items[cursorPoint + ITEM_NUM_SLOTS] != ITEM_NONE) && !CHECK_GIVEN_MASK_ON_MOON(cursorPoint)) { pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; pauseCtx->cursorXIndex[PAUSE_MASK] = cursorXIndex; @@ -428,7 +429,7 @@ void KaleidoScope_UpdateMaskCursor(PlayState* play) { // Search for slot to move to while (true) { // Check if current cursor has an item in its slot - if ((gSaveContext.save.inventory.items[cursorPoint + NUM_ITEM_SLOTS] != ITEM_NONE) && + if ((gSaveContext.save.saveInfo.inventory.items[cursorPoint + ITEM_NUM_SLOTS] != ITEM_NONE) && !CHECK_GIVEN_MASK_ON_MOON(cursorPoint)) { pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; pauseCtx->cursorXIndex[PAUSE_MASK] = cursorXIndex; @@ -500,12 +501,14 @@ void KaleidoScope_UpdateMaskCursor(PlayState* play) { pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { - cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + NUM_ITEM_SLOTS]; + cursorItem = + gSaveContext.save.saveInfo.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + ITEM_NUM_SLOTS]; if (CHECK_GIVEN_MASK_ON_MOON(pauseCtx->cursorPoint[PAUSE_MASK])) { cursorItem = ITEM_NONE; } } else if (moveCursorResult != PAUSE_CURSOR_RESULT_SPECIAL_POS) { - cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + NUM_ITEM_SLOTS]; + cursorItem = + gSaveContext.save.saveInfo.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + ITEM_NUM_SLOTS]; if (CHECK_GIVEN_MASK_ON_MOON(pauseCtx->cursorPoint[PAUSE_MASK])) { cursorItem = ITEM_NONE; } @@ -568,8 +571,8 @@ void KaleidoScope_UpdateMaskCursor(PlayState* play) { if ((Player_GetEnvironmentalHazard(play) >= PLAYER_ENV_HAZARD_UNDERWATER_FLOOR) && (Player_GetEnvironmentalHazard(play) <= PLAYER_ENV_HAZARD_UNDERWATER_FREE) && - ((cursorSlot == (SLOT_MASK_DEKU - NUM_ITEM_SLOTS)) || - (cursorSlot == (SLOT_MASK_GORON - NUM_ITEM_SLOTS)))) { + ((cursorSlot == (SLOT_MASK_DEKU - ITEM_NUM_SLOTS)) || + (cursorSlot == (SLOT_MASK_GORON - ITEM_NUM_SLOTS)))) { play_sound(NA_SE_SY_ERROR); return; } @@ -584,7 +587,7 @@ void KaleidoScope_UpdateMaskCursor(PlayState* play) { // Equip item to the C buttons pauseCtx->equipTargetItem = cursorItem; - pauseCtx->equipTargetSlot = cursorSlot + NUM_ITEM_SLOTS; + pauseCtx->equipTargetSlot = cursorSlot + ITEM_NUM_SLOTS; pauseCtx->mainState = PAUSE_MAIN_STATE_EQUIP_MASK; vtxIndex = cursorSlot * 4; pauseCtx->equipAnimX = pauseCtx->maskVtx[vtxIndex].v.ob[0] * 10; @@ -656,7 +659,10 @@ void KaleidoScope_UpdateMaskEquip(PlayState* play) { } if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { - bowItemVtx = &pauseCtx->itemVtx[12]; + //! Note: Copied from OoT when `SLOT_BOW` was still valued at 3. + // Due to a shift, `SLOT_ARROW_ICE` now occupies slot 3 but this value was not updated + // Block is never reached as you can not equip magic arrows from the mask page + bowItemVtx = &pauseCtx->itemVtx[SLOT_ARROW_ICE * 4]; offsetX = ABS_ALT(pauseCtx->equipAnimX - bowItemVtx->v.ob[0] * 10) / sMaskEquipAnimTimer; offsetY = ABS_ALT(pauseCtx->equipAnimY - bowItemVtx->v.ob[1] * 10) / sMaskEquipAnimTimer; } else { diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_prompt.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_prompt.c index 13e233b58..9bf89cdd2 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_prompt.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_prompt.c @@ -14,7 +14,7 @@ void KaleidoScope_UpdatePrompt(PlayState* play) { static s16 sPromptAlphaTimer = 10; PauseContext* pauseCtx = &play->pauseCtx; Input* input = CONTROLLER1(&play->state); - s8 relStickX = input->rel.stick_x; + s8 stickAdjX = input->rel.stick_x; s16 alphaStep; if (((pauseCtx->state == PAUSE_STATE_SAVEPROMPT) && (pauseCtx->savePromptState == PAUSE_SAVEPROMPT_STATE_1)) || @@ -22,11 +22,11 @@ void KaleidoScope_UpdatePrompt(PlayState* play) { (pauseCtx->state == PAUSE_STATE_GAMEOVER_CONTINUE_PROMPT)) { // Move the prompt - if ((pauseCtx->promptChoice == PAUSE_PROMPT_YES) && (relStickX >= 30)) { + if ((pauseCtx->promptChoice == PAUSE_PROMPT_YES) && (stickAdjX >= 30)) { // Move right to the no prompt play_sound(NA_SE_SY_CURSOR); pauseCtx->promptChoice = PAUSE_PROMPT_NO; - } else if ((pauseCtx->promptChoice != PAUSE_PROMPT_YES) && (relStickX <= -30)) { + } else if ((pauseCtx->promptChoice != PAUSE_PROMPT_YES) && (stickAdjX <= -30)) { // Move left to the yes prompt play_sound(NA_SE_SY_CURSOR); pauseCtx->promptChoice = PAUSE_PROMPT_YES; diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h index 7349db241..a9aeed70f 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h @@ -92,7 +92,7 @@ typedef enum { #define IS_PAUSE_STATE_OWLWARP \ ((pauseCtx->state >= PAUSE_STATE_OWLWARP_2) && (pauseCtx->state <= PAUSE_STATE_OWLWARP_6)) -#define IS_PAUSE_MAIN_STATE_SAVE_PROMPT \ +#define IS_PAUSE_MAIN_STATE_SONG_PROMPT \ ((pauseCtx->mainState >= PAUSE_MAIN_STATE_SONG_PROMPT_INIT) && \ (pauseCtx->mainState <= PAUSE_MAIN_STATE_SONG_PROMPT_DONE)) @@ -120,11 +120,189 @@ typedef enum { /* 0 */ PAUSE_BG_PRERENDER_OFF, /* 1 */ PAUSE_BG_PRERENDER_SETUP, // The current frame is only drawn for the purpose of serving as the pause background. /* 2 */ PAUSE_BG_PRERENDER_PROCESS, // The previous frame was PAUSE_BG_PRERENDER_DRAW, now apply prerender filters. - /* 3 */ PAUSE_BG_PRERENDER_DONE, // The pause background is ready to be used. + /* 3 */ PAUSE_BG_PRERENDER_READY, // The pause background is ready to be used. /* 4 */ PAUSE_BG_PRERENDER_UNK4, /* 5 */ PAUSE_BG_PRERENDER_MAX } PauseBgPreRenderState; +typedef enum { + /* 0 */ VTX_PAGE_MASK, + /* 1 */ VTX_PAGE_ITEM, + /* 2 */ VTX_PAGE_MAP_DUNGEON, + /* 3 */ VTX_PAGE_QUEST, + /* 4 */ VTX_PAGE_MAP_WORLD, + /* 5 */ VTX_PAGE_PROMPT, + /* 6 */ VTX_PAGE_MAX +} VtxPage; + +#define VTX_PAGE_MASK_QUADS 0 // VTX_PAGE_MASK +#define VTX_PAGE_ITEM_QUADS 0 // VTX_PAGE_ITEM +#define VTX_PAGE_MAP_DUNGEON_QUADS 6 // VTX_PAGE_MAP_DUNGEON +#define VTX_PAGE_QUEST_QUADS 0 // VTX_PAGE_QUEST +#define VTX_PAGE_MAP_WORLD_QUADS 36 // VTX_PAGE_MAP_WORLD +#define VTX_PAGE_SAVE_QUADS 5 // VTX_PAGE_PROMPT + +#define PAGE_BG_COLS 3 +#define PAGE_BG_ROWS 5 +#define PAGE_BG_QUADS (PAGE_BG_COLS * PAGE_BG_ROWS) +#define PAGE_BG_QUAD_WIDTH 80 +#define PAGE_BG_QUAD_HEIGHT 32 +#define PAGE_BG_QUAD_TEX_WIDTH 80 +#define PAGE_BG_QUAD_TEX_HEIGHT 32 + +// === ITEM === // + +#define ITEM_GRID_ROWS 4 +#define ITEM_GRID_COLS 6 +#define ITEM_GRID_CELL_WIDTH 32 +#define ITEM_GRID_CELL_HEIGHT 32 +#define ITEM_GRID_QUAD_MARGIN 2 +#define ITEM_GRID_QUAD_WIDTH (ITEM_GRID_CELL_WIDTH - (2 * ITEM_GRID_QUAD_MARGIN)) +#define ITEM_GRID_QUAD_HEIGHT (ITEM_GRID_CELL_HEIGHT - (2 * ITEM_GRID_QUAD_MARGIN)) +#define ITEM_GRID_QUAD_TEX_SIZE 32 // both width and height +#define ITEM_GRID_QUAD_ENLARGE_OFFSET 2 + +#define ITEM_GRID_SELECTED_QUAD_MARGIN (-2) +#define ITEM_GRID_SELECTED_QUAD_WIDTH (ITEM_GRID_QUAD_WIDTH - (2 * ITEM_GRID_SELECTED_QUAD_MARGIN)) +#define ITEM_GRID_SELECTED_QUAD_HEIGHT (ITEM_GRID_QUAD_HEIGHT - (2 * ITEM_GRID_SELECTED_QUAD_MARGIN)) +#define ITEM_GRID_SELECTED_QUAD_TEX_SIZE 32 // both width and height + +#define ITEM_NUM_SLOTS (ITEM_GRID_ROWS * ITEM_GRID_COLS) + +typedef enum { + // 0..59 are the 15 background textures + /* 0 */ QUAD_ITEM_PAGE_BG_FIRST, + /* 14 */ QUAD_ITEM_PAGE_BG_LAST = PAGE_BG_QUADS - 1, + // VTX_PAGE_ITEM_QUADS is 0 + /* 15 */ QUAD_ITEM_PAGE_MAX +} ItemPageQuad; + +typedef enum { + // 0..23 are the ITEM_GRID_ROWS*ITEM_GRID_COLS item grid + // The values follow the `InventorySlot` enum + /* 0 */ QUAD_ITEM_GRID_FIRST, + /* 23 */ QUAD_ITEM_GRID_LAST = ITEM_GRID_ROWS * ITEM_GRID_COLS - 1, + // White-box Markers indicating the currently equipped items + /* 24 */ QUAD_ITEM_GRID_SELECTED_C_LEFT, + /* 25 */ QUAD_ITEM_GRID_SELECTED_C_DOWN, + /* 26 */ QUAD_ITEM_GRID_SELECTED_C_RIGHT, + /* 27 */ QUAD_ITEM_MAX +} ItemQuad; + +// === MASK === // + +#define MASK_GRID_ROWS 4 +#define MASK_GRID_COLS 6 +#define MASK_GRID_CELL_WIDTH 32 +#define MASK_GRID_CELL_HEIGHT 32 +#define MASK_GRID_QUAD_MARGIN 2 +#define MASK_GRID_QUAD_WIDTH (MASK_GRID_CELL_WIDTH - (2 * MASK_GRID_QUAD_MARGIN)) +#define MASK_GRID_QUAD_HEIGHT (MASK_GRID_CELL_HEIGHT - (2 * MASK_GRID_QUAD_MARGIN)) +#define MASK_GRID_QUAD_TEX_SIZE 32 // both width and height +#define MASK_GRID_QUAD_ENLARGE_OFFSET 2 + +#define MASK_GRID_SELECTED_QUAD_MARGIN (-2) +#define MASK_GRID_SELECTED_QUAD_WIDTH (MASK_GRID_QUAD_WIDTH - (2 * MASK_GRID_SELECTED_QUAD_MARGIN)) +#define MASK_GRID_SELECTED_QUAD_HEIGHT (MASK_GRID_QUAD_HEIGHT - (2 * MASK_GRID_SELECTED_QUAD_MARGIN)) +#define MASK_GRID_SELECTED_QUAD_TEX_SIZE 32 // both width and height + +#define MASK_NUM_SLOTS (MASK_GRID_ROWS * MASK_GRID_COLS) + +typedef enum { + // 0..59 are the 15 background textures + /* 0 */ QUAD_MASK_PAGE_BG_FIRST, + /* 14 */ QUAD_MASK_PAGE_BG_LAST = PAGE_BG_QUADS - 1, + // VTX_PAGE_MASK_QUADS is 0 + /* 15 */ QUAD_MASK_PAGE_MAX +} MaskPageQuad; + +typedef enum { + // 0..23 are the MASK_GRID_ROWS*MASK_GRID_COLS item grid + // The values follow the `InventorySlot` enum offset by ITEM_NUM_SLOTS + /* 0 */ QUAD_MASK_GRID_FIRST, + /* 23 */ QUAD_MASK_GRID_LAST = MASK_GRID_ROWS * MASK_GRID_COLS - 1, + // Markers indicating the currently equipped items + /* 24 */ QUAD_MASK_GRID_SELECTED_C_LEFT, + /* 25 */ QUAD_MASK_GRID_SELECTED_C_DOWN, + /* 26 */ QUAD_MASK_GRID_SELECTED_C_RIGHT, + /* 27 */ QUAD_MASK_MAX +} MaskQuad; + +// === QUEST === // + +typedef enum { + // 0..59 are the 15 background textures + /* 0 */ QUAD_QUEST_PAGE_BG_FIRST, + /* 14 */ QUAD_QUEST_PAGE_BG_LAST = PAGE_BG_QUADS - 1, + // VTX_PAGE_QUEST_QUADS is 0 + /* 15 */ QUAD_QUEST_PAGE_MAX +} QuestPageQuad; + +typedef enum { + // 0 to 24 matches the `QuestItem` enum + // Notes showing the correct song + /* 25 */ QUAD_QUEST_SONG_NOTE_A1 = QUEST_HEART_PIECE + 1, + /* 26 */ QUAD_QUEST_SONG_NOTE_A2, + /* 27 */ QUAD_QUEST_SONG_NOTE_A3, + /* 28 */ QUAD_QUEST_SONG_NOTE_A4, + /* 29 */ QUAD_QUEST_SONG_NOTE_A5, + /* 30 */ QUAD_QUEST_SONG_NOTE_A6, + /* 31 */ QUAD_QUEST_SONG_NOTE_A7, + /* 32 */ QUAD_QUEST_SONG_NOTE_A8, + // Notes appearing when playing + /* 33 */ QUAD_QUEST_SONG_NOTE_B1, + /* 34 */ QUAD_QUEST_SONG_NOTE_B2, + /* 35 */ QUAD_QUEST_SONG_NOTE_B3, + /* 36 */ QUAD_QUEST_SONG_NOTE_B4, + /* 37 */ QUAD_QUEST_SONG_NOTE_B5, + /* 38 */ QUAD_QUEST_SONG_NOTE_B6, + /* 39 */ QUAD_QUEST_SONG_NOTE_B7, + /* 40 */ QUAD_QUEST_SONG_NOTE_B8, + /* 41 */ QUAD_QUEST_MAX +} QuestQuad; + +// === DUNGEON MAP === // + +typedef enum { + // 0..59 are the 15 background textures + /* 0 */ QUAD_MAP_PAGE_DUNGEON_BG_FIRST, + /* 14 */ QUAD_MAP_PAGE_DUNGEON_BG_LAST = PAGE_BG_QUADS - 1, + /* 15 */ QUAD_MAP_PAGE_DUNGEON_TITLE, + /* 16 */ QUAD_MAP_PAGE_DUNGEON_BOSS_KEY, + /* 17 */ QUAD_MAP_PAGE_DUNGEON_COMPASS, + /* 18 */ QUAD_MAP_PAGE_DUNGEON_MAP, + /* 19 */ QUAD_MAP_PAGE_DUNGEON_STRAY_FAIRY_GLOWING_CIRCLE, + /* 20 */ QUAD_MAP_PAGE_DUNGEON_UNUSED, + /* 21 */ QUAD_MAP_PAGE_DUNGEON_MAX +} DungeonMapPageQuad; + +// === WORLD MAP === // + +#define WORLD_MAP_IMAGE_WIDTH 216 +#define WORLD_MAP_IMAGE_HEIGHT 128 +#define WORLD_MAP_IMAGE_FRAG_HEIGHT ((TMEM_SIZE / 2) / (WORLD_MAP_IMAGE_WIDTH * G_IM_SIZ_8b_BYTES)) +#define WORLD_MAP_IMAGE_FRAG_NUM (((WORLD_MAP_IMAGE_HEIGHT - 1) / WORLD_MAP_IMAGE_FRAG_HEIGHT) + 1) +#define WORLD_MAP_NUM_CLOUDS 15 + +typedef enum { + // 0..59 are the 15 background textures + /* 0 */ QUAD_MAP_PAGE_WORLD_BG_FIRST, + /* 14 */ QUAD_MAP_PAGE_WORLD_BG_LAST = PAGE_BG_QUADS - 1, + // Clouds covering the world map + /* 15 */ QUAD_MAP_PAGE_WORLD_CLOUDS_FIRST, + /* 29 */ QUAD_MAP_PAGE_WORLD_CLOUDS_LAST = QUAD_MAP_PAGE_WORLD_CLOUDS_FIRST + WORLD_MAP_NUM_CLOUDS - 1, + // Markers for regions + /* 30 */ QUAD_MAP_PAGE_WORLD_REGION_FIRST, + /* 40 */ QUAD_MAP_PAGE_WORLD_REGION_LAST = QUAD_MAP_PAGE_WORLD_REGION_FIRST + REGION_MAX - 1, + // Markers for owl warps + /* 41 */ QUAD_MAP_PAGE_WORLD_WARP_FIRST, + /* 50 */ QUAD_MAP_PAGE_WORLD_WARP_LAST = QUAD_MAP_PAGE_WORLD_WARP_FIRST + OWL_WARP_ENTRANCE - 1, + // Fragments of the world map + /* 51 */ QUAD_MAP_PAGE_WORLD_IMAGE_FIRST, + /* 65 */ QUAD_MAP_PAGE_WORLD_IMAGE_LAST = QUAD_MAP_PAGE_WORLD_IMAGE_FIRST + WORLD_MAP_IMAGE_FRAG_NUM - 1, + /* 66 */ QUAD_MAP_PAGE_WORLD_MAX +} WorldMapPageQuad; + #define PAUSE_NAME_COLOR_SET_WHITE 0 #define PAUSE_NAME_COLOR_SET_GREY 1 @@ -139,12 +317,27 @@ typedef enum { /* 2 */ PAUSE_CURSOR_RESULT_SPECIAL_POS } PauseMoveCursorResult; -#define NUM_ITEM_SLOTS 24 -#define NUM_MASK_SLOTS 24 +typedef enum { + /* 0 */ PAUSE_QUAD_CURSOR_0, + /* 1 */ PAUSE_QUAD_CURSOR_1, + /* 2 */ PAUSE_QUAD_CURSOR_2, + /* 3 */ PAUSE_QUAD_CURSOR_3, + /* 4 */ PAUSE_QUAD_CURSOR_4, + /* 5 */ PAUSE_QUAD_CURSOR_MAX +} PauseCursorQuad; #define PAUSE_PROMPT_YES 0 #define PAUSE_PROMPT_NO 4 +typedef enum { + /* 0 */ QUAD_PROMPT_MESSAGE, + /* 1 */ QUAD_PROMPT_CURSOR_LEFT, + /* 2 */ QUAD_PROMPT_CURSOR_RIGHT, + /* 3 */ QUAD_PROMPT_CHOICE_YES, + /* 4 */ QUAD_PROMPT_CHOICE_NO, + /* 5 */ QUAD_PROMPT_MAX +} PromptQuad; + // NES void KaleidoScope_MoveCursorToSpecialPos(PlayState* play, s16 cursorSpecialPos); void KaleidoScope_DrawTexQuadRGBA32(GraphicsContext* gfxCtx, TexturePtr texture, u16 width, u16 height, u16 point); @@ -162,7 +355,7 @@ void KaleidoScope_DrawQuestStatus(PlayState* play); void KaleidoScope_UpdateQuestCursor(PlayState* play); // Item -void KaleidoScope_SetCursorVtx(PauseContext* pauseCtx, u16 index, Vtx* vtx); +void KaleidoScope_SetCursorVtxPos(PauseContext* pauseCtx, u16 vtxIndex, Vtx* vtx); void KaleidoScope_DrawItemSelect(PlayState* play); void KaleidoScope_UpdateItemCursor(PlayState* play); void KaleidoScope_UpdateItemEquip(PlayState* play); @@ -179,4 +372,7 @@ void KaleidoScope_UpdatePrompt(PlayState* play); void KaleidoScope_DrawInventoryEditor(PlayState* play); void KaleidoScope_UpdateInventoryEditor(PlayState* play); +extern s16 gVtxPageMapWorldQuadsWidth[]; +extern s16 gVtxPageMapWorldQuadsHeight[]; + #endif diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c index 53e993321..57fc6b32f 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c @@ -6,6 +6,8 @@ #include "z_kaleido_scope.h" #include "overlays/gamestates/ovl_opening/z_opening.h" +#include "interface/icon_item_gameover_static/icon_item_gameover_static.h" +#include "interface/icon_item_jpn_static/icon_item_jpn_static.h" #include "z64view.h" extern UNK_TYPE D_02001360; @@ -20,32 +22,165 @@ extern UNK_TYPE D_0C006C00; extern u8 sUnpausedButtonStatus[5]; -void* D_8082B700[] = { - 0x08064440, 0x0806E440, 0x08077A40, 0x08081040, 0x0808A640, 0x0D003A00, 0x0806EE40, 0x08078440, - 0x08081A40, 0x0808B040, 0x08065840, 0x0806F840, 0x08078E40, 0x08082440, 0x0808BA40, +// Page Textures (Background of Page): +// Broken up into multiple textures. +// Numbered by column/row. +TexturePtr sMaskPageBgTextures[] = { + // Column 0 + 0x08064440, // gPauseMasks00Tex + 0x0806E440, // gPauseMasks01Tex + 0x08077A40, // gPauseMasks02Tex + 0x08081040, // gPauseMasks03Tex + 0x0808A640, // gPauseMasks04Tex + // Column 1 + gPauseMasks10ENGTex, + 0x0806EE40, // gPauseMasks11Tex + 0x08078440, // gPauseMasks12Tex + 0x08081A40, // gPauseMasks13Tex + 0x0808B040, // gPauseMasks14Tex + // Column 2 + 0x08065840, // gPauseMasks20Tex + 0x0806F840, // gPauseMasks21Tex + 0x08078E40, // gPauseMasks22Tex + 0x08082440, // gPauseMasks23Tex + 0x0808BA40, // gPauseMasks24Tex }; -void* D_8082B73C[] = { - 0x0D004400, 0x08070240, 0x08079840, 0x08082E40, 0x0808C440, 0x0D004E00, 0x08070C40, 0x0807A240, - 0x08083840, 0x0808CE40, 0x0D005800, 0x08071640, 0x0807AC40, 0x08084240, 0x0808D840, +TexturePtr sItemPageBgTextures[] = { + // Column 0 + gPauseSelectItem00ENGTex, + 0x08070240, // gPauseSelectItem01Tex + 0x08079840, // gPauseSelectItem02Tex + 0x08082E40, // gPauseSelectItem03Tex + 0x0808C440, // gPauseSelectItem04Tex + // Column 1 + gPauseSelectItem10ENGTex, + 0x08070C40, // gPauseSelectItem11Tex + 0x0807A240, // gPauseSelectItem12Tex + 0x08083840, // gPauseSelectItem13Tex + 0x0808CE40, // gPauseSelectItem14Tex + // Column 2 + gPauseSelectItem20ENGTex, + 0x08071640, // gPauseSelectItem21Tex + 0x0807AC40, // gPauseSelectItem22Tex + 0x08084240, // gPauseSelectItem23Tex + 0x0808D840, // gPauseSelectItem24Tex }; -void* D_8082B778[] = { - 0x08068040, 0x08072040, 0x0807B640, 0x08084C40, 0x0808E240, 0x0D006200, 0x08072A40, 0x0807C040, - 0x08085640, 0x0808EC40, 0x08069440, 0x08073440, 0x0807CA40, 0x08086040, 0x0808F640, +TexturePtr sMapPageBgTextures[] = { + // Column 0 + 0x08068040, // gPauseMap00Tex + 0x08072040, // gPauseMap01Tex + 0x0807B640, // gPauseMap02Tex + 0x08084C40, // gPauseMap03Tex + 0x0808E240, // gPauseMap04Tex + // Column 1 + gPauseMap10ENGTex, + 0x08072A40, // gPauseMap11Tex + 0x0807C040, // gPauseMap12Tex + 0x08085640, // gPauseMap13Tex + 0x0808EC40, // gPauseMap14Tex + // Column 2 + 0x08069440, // gPauseMap20Tex + 0x08073440, // gPauseMap21Tex + 0x0807CA40, // gPauseMap22Tex + 0x08086040, // gPauseMap23Tex + 0x0808F640, // gPauseMap24Tex }; -void* D_8082B7B4[] = { - 0x0D006C00, 0x08073E40, 0x0807D440, 0x08086A40, 0x08090040, 0x0D007600, 0x08074840, 0x0807DE40, - 0x08087440, 0x08090A40, 0x0D008000, 0x08075240, 0x0807E840, 0x08087E40, 0x08091440, +TexturePtr sQuestPageBgTextures[] = { + // Column 0 + gPauseQuestStatus00ENGTex, + 0x08073E40, // gPauseQuestStatus01Tex + 0x0807D440, // gPauseQuestStatus02Tex + 0x08086A40, // gPauseQuestStatus03Tex + 0x08090040, // gPauseQuestStatus04Tex + // Column 1 + gPauseQuestStatus10ENGTex, + 0x08074840, // gPauseQuestStatus11Tex + 0x0807DE40, // gPauseQuestStatus12Tex + 0x08087440, // gPauseQuestStatus13Tex + 0x08090A40, // gPauseQuestStatus14Tex + // Column 2 + gPauseQuestStatus20ENGTex, + 0x08075240, // gPauseQuestStatus21Tex + 0x0807E840, // gPauseQuestStatus22Tex + 0x08087E40, // gPauseQuestStatus23Tex + 0x08091440, // gPauseQuestStatus24Tex }; -s16 D_8082B7F0[] = { - 0x0050, 0x0040, 0x0040, 0x0040, 0x0010, 0x0040, 0x0070, 0x0070, 0x0030, 0x0040, 0x0040, 0x0040, - 0x0040, 0x0030, 0x0040, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, - 0x0008, 0x0008, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, +s16 gVtxPageMapWorldQuadsWidth[VTX_PAGE_MAP_WORLD_QUADS] = { + 80, // mapPageVtx[60] clouds Clock Town 1 + 64, // mapPageVtx[64] clouds Clock Town 2 + 64, // mapPageVtx[68] clouds Woodfall 1 + 64, // mapPageVtx[72] clouds Woodfall 2 + 16, // mapPageVtx[76] clouds Woodfall 3 + 64, // mapPageVtx[80] clouds Snowhead 1 + 112, // mapPageVtx[84] clouds Snowhead 2 + 112, // mapPageVtx[88] clouds Snowhead 3 + 48, // mapPageVtx[92] clouds Romani Ranch + 64, // mapPageVtx[96] clouds Great Bay 1 + 64, // mapPageVtx[100] clouds Great Bay 2 + 64, // mapPageVtx[104] clouds Great Bay 3 + 64, // mapPageVtx[108] clouds Great Bay 4 + 48, // mapPageVtx[112] clouds Stone Tower 1 + 64, // mapPageVtx[116] clouds Stone Tower 2 + 8, // mapPageVtx[120] region Great Bay + 8, // mapPageVtx[124] region Zora Hall + 8, // mapPageVtx[128] region Romani Ranch + 8, // mapPageVtx[132] region Deku Palace + 8, // mapPageVtx[136] region Woodfall + 8, // mapPageVtx[140] region Clock Town + 8, // mapPageVtx[144] region Snowhead + 8, // mapPageVtx[148] region Ikana Graveyard + 8, // mapPageVtx[152] region Ikana Canyon + 8, // mapPageVtx[156] region Goron Village + 8, // mapPageVtx[160] region Stone Tower + 24, // mapPageVtx[164] owl warp Great Bay Coast + 24, // mapPageVtx[168] owl warp Zora Cape + 24, // mapPageVtx[172] owl warp Snowhead + 24, // mapPageVtx[176] owl warp Mountain Village + 24, // mapPageVtx[180] owl warp Clock Town + 24, // mapPageVtx[184] owl warp Milk Road + 24, // mapPageVtx[188] owl warp Woodfall + 24, // mapPageVtx[192] owl warp Southern Swamp + 24, // mapPageVtx[196] owl warp Ikana Canyon + 24, // mapPageVtx[200] owl warp Stone Tower }; -s16 D_8082B838[] = { - 0x0028, 0x001F, 0x0035, 0x0035, 0x0035, 0x0034, 0x0023, 0x0023, 0x0020, 0x0040, 0x0040, 0x0040, - 0x0040, 0x0052, 0x003D, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, - 0x0008, 0x0008, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, +s16 gVtxPageMapWorldQuadsHeight[VTX_PAGE_MAP_WORLD_QUADS] = { + 40, // mapPageVtx[60] clouds Clock Town 1 + 31, // mapPageVtx[64] clouds Clock Town 2 + 53, // mapPageVtx[68] clouds Woodfall 1 + 53, // mapPageVtx[72] clouds Woodfall 2 + 53, // mapPageVtx[76] clouds Woodfall 3 + 52, // mapPageVtx[80] clouds Snowhead 1 + 35, // mapPageVtx[84] clouds Snowhead 2 + 35, // mapPageVtx[88] clouds Snowhead 3 + 32, // mapPageVtx[92] clouds Romani Ranch + 64, // mapPageVtx[96] clouds Great Bay 1 + 64, // mapPageVtx[100] clouds Great Bay 2 + 64, // mapPageVtx[104] clouds Great Bay 3 + 64, // mapPageVtx[108] clouds Great Bay 4 + 82, // mapPageVtx[112] clouds Stone Tower 1 + 61, // mapPageVtx[116] clouds Stone Tower 2 + 8, // mapPageVtx[120] region Great Bay + 8, // mapPageVtx[124] region Zora Hall + 8, // mapPageVtx[128] region Romani Ranch + 8, // mapPageVtx[132] region Deku Palace + 8, // mapPageVtx[136] region Woodfall + 8, // mapPageVtx[140] region Clock Town + 8, // mapPageVtx[144] region Snowhead + 8, // mapPageVtx[148] region Ikana Graveyard + 8, // mapPageVtx[152] region Ikana Canyon + 8, // mapPageVtx[156] region Goron Village + 8, // mapPageVtx[160] region Stone Tower + 12, // mapPageVtx[164] owl warp Great Bay Coast + 12, // mapPageVtx[168] owl warp Zora Cape + 12, // mapPageVtx[172] owl warp Snowhead + 12, // mapPageVtx[176] owl warp Mountain Village + 12, // mapPageVtx[180] owl warp Clock Town + 12, // mapPageVtx[184] owl warp Milk Road + 12, // mapPageVtx[188] owl warp Woodfall + 12, // mapPageVtx[192] owl warp Southern Swamp + 12, // mapPageVtx[196] owl warp Ikana Canyon + 12, // mapPageVtx[200] owl warp Stone Tower }; s16 sGameOverPrimR = 0; @@ -115,136 +250,768 @@ u8 D_8082B924[] = { // TODO: Also applies to owl warps s16 sGameOverRectPosY = 66; -s16 D_8082B948[][3] = { - { 0x00FF, 0x00FF, 0x00FF }, { 0x00FF, 0x00FF, 0x00FF }, { 0x00FF, 0x00FF, 0x0000 }, - { 0x00FF, 0x00FF, 0x0000 }, { 0x0064, 0x0096, 0x00FF }, { 0x0064, 0x00FF, 0x00FF }, +void func_80821900(void* segment, u32 texIndex) { + CmpDma_LoadFile(SEGMENT_ROM_START(map_name_static), texIndex, segment, 0x400); +} + +void func_8082192C(void* segment, u32 texIndex) { + CmpDma_LoadFile(SEGMENT_ROM_START(map_name_static), texIndex, segment, 0xA00); +} + +void func_80821958(void* segment, u32 texIndex) { + CmpDma_LoadFile(SEGMENT_ROM_START(item_name_static), texIndex, segment, 0x400); +} + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_MoveCursorToSpecialPos.s") + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821A04.s") + +void KaleidoScope_DrawTexQuadRGBA32(GraphicsContext* gfxCtx, TexturePtr texture, u16 width, u16 height, u16 point) { + OPEN_DISPS(gfxCtx); + + gDPLoadTextureBlock(POLY_OPA_DISP++, texture, G_IM_FMT_RGBA, G_IM_SIZ_32b, 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); + gSP1Quadrangle(POLY_OPA_DISP++, point, point + 2, point + 3, point + 1, 0); + + CLOSE_DISPS(gfxCtx); +} + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821CC4.s") + +void KaleidoScope_HandlePageToggles(PlayState* play, Input* input); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_HandlePageToggles.s") + +// Draw 15 (PAGE_BG_QUADS) quads with IA8 80x32 textures +Gfx* KaleidoScope_DrawPageSections(Gfx* gfx, Vtx* vertices, TexturePtr* textures) { + s32 i; + s32 j; + + gSPVertex(gfx++, vertices, 8 * 4, 0); + + i = 0; + j = 0; + // Draw first 8/15 background textures + while (j < 32) { + gDPPipeSync(gfx++); + gDPLoadTextureBlock(gfx++, textures[i], G_IM_FMT_IA, G_IM_SIZ_8b, 80, 32, 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); + gSP1Quadrangle(gfx++, j, j + 2, j + 3, j + 1, 0); + + j += 4; + i++; + } + + gSPVertex(gfx++, vertices + (8 * 4), 7 * 4, 0); + + j = 0; + // Draw last 7/15 background textures + while (j < 28) { + gDPPipeSync(gfx++); + gDPLoadTextureBlock(gfx++, textures[i], G_IM_FMT_IA, G_IM_SIZ_8b, 80, 32, 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); + gSP1Quadrangle(gfx++, j, j + 2, j + 3, j + 1, 0); + + j += 4; + i++; + } + + return gfx; +} + +s16 sCursorPrimColorTarget[][3] = { + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 0 }, { 255, 255, 0 }, { 100, 150, 255 }, { 100, 255, 255 }, }; -s16 D_8082B96C[][3] = { - { 0x0000, 0x0000, 0x0000 }, { 0x00AA, 0x00AA, 0x00AA }, { 0x0000, 0x0000, 0x0000 }, - { 0x00FF, 0x00A0, 0x0000 }, { 0x0000, 0x0000, 0x0064 }, { 0x0000, 0x0096, 0x00FF }, +s16 sCursorEnvColorTarget[][3] = { + { 0, 0, 0 }, { 170, 170, 170 }, { 0, 0, 0 }, { 255, 160, 0 }, { 0, 0, 100 }, { 0, 150, 255 }, }; -s16 D_8082B990 = 10; -s16 D_8082B994 = 0; +void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { + static s16 sCursorColorTimer = 10; + static s16 sCursorColorTargetIndex = 0; + PauseContext* pauseCtx = &play->pauseCtx; + s16 stepR; + s16 stepG; + s16 stepB; -s32 D_8082B998[] = { - 0x0D003300, - 0x0D002700, - 0x0D002B00, - 0x0D002F00, + OPEN_DISPS(gfxCtx); + + if (!IS_PAUSE_STATE_GAMEOVER) { + if (pauseCtx->state != PAUSE_STATE_SAVEPROMPT) { + + stepR = + ABS_ALT(sCursorPrimR - sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]) / + sCursorColorTimer; + stepG = + ABS_ALT(sCursorPrimG - sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]) / + sCursorColorTimer; + stepB = + ABS_ALT(sCursorPrimB - sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]) / + sCursorColorTimer; + + if (sCursorPrimR >= sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]) { + sCursorPrimR -= stepR; + } else { + sCursorPrimR += stepR; + } + + if (sCursorPrimG >= sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]) { + sCursorPrimG -= stepG; + } else { + sCursorPrimG += stepG; + } + + if (sCursorPrimB >= sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]) { + sCursorPrimB -= stepB; + } else { + sCursorPrimB += stepB; + } + + stepR = + ABS_ALT(sCursorEnvR - sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]) / + sCursorColorTimer; + stepG = + ABS_ALT(sCursorEnvG - sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]) / + sCursorColorTimer; + stepB = + ABS_ALT(sCursorEnvB - sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]) / + sCursorColorTimer; + + if (sCursorEnvR >= sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]) { + sCursorEnvR -= stepR; + } else { + sCursorEnvR += stepR; + } + + if (sCursorEnvG >= sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]) { + sCursorEnvG -= stepG; + } else { + sCursorEnvG += stepG; + } + + if (sCursorEnvB >= sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]) { + sCursorEnvB -= stepB; + } else { + sCursorEnvB += stepB; + } + + sCursorColorTimer--; + if (sCursorColorTimer == 0) { + sCursorPrimR = sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]; + sCursorPrimG = sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]; + sCursorPrimB = sCursorPrimColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]; + sCursorEnvR = sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][0]; + sCursorEnvG = sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][1]; + sCursorEnvB = sCursorEnvColorTarget[pauseCtx->cursorColorSet + sCursorColorTargetIndex][2]; + sCursorColorTargetIndex ^= 1; + sCursorColorTimer = 10; + } + } + + if ((pauseCtx->pageIndex != PAUSE_ITEM) && (pauseCtx->pageIndex != PAUSE_QUEST)) { + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, SHADE, 0, TEXEL0, 0, PRIMITIVE, 0, + TEXEL0, 0, SHADE, 0); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); + + Matrix_RotateYF(0.0f, MTXMODE_NEW); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateXFApply(-pauseCtx->itemPageRoll / 100.0f); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->itemPageVtx, sItemPageBgTextures); + + KaleidoScope_DrawItemSelect(play); + } + + if ((pauseCtx->pageIndex != PAUSE_MAP) && (pauseCtx->pageIndex != PAUSE_MASK)) { + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, SHADE, 0, TEXEL0, 0, PRIMITIVE, 0, + TEXEL0, 0, SHADE, 0); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); + + Matrix_RotateYF(-1.57f, MTXMODE_NEW); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateXFApply(-pauseCtx->mapPageRoll / 100.0f); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->mapPageVtx, sMapPageBgTextures); + + if (sInDungeonScene) { + KaleidoScope_DrawDungeonMap(play); + func_8012C8AC(gfxCtx); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + func_801091F0(play); + } else { + KaleidoScope_DrawWorldMap(play); + } + } + + if ((pauseCtx->pageIndex != PAUSE_QUEST) && (pauseCtx->pageIndex != PAUSE_ITEM)) { + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP); + + gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, SHADE, 0, TEXEL0, 0, PRIMITIVE, 0, + TEXEL0, 0, SHADE, 0); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); + + Matrix_RotateYF(-3.14f, MTXMODE_NEW); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateXFApply(-pauseCtx->questPageRoll / 100.0f); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->questPageVtx, sQuestPageBgTextures); + + KaleidoScope_DrawQuestStatus(play); + } + + if ((pauseCtx->pageIndex != PAUSE_MASK) && (pauseCtx->pageIndex != PAUSE_MAP)) { + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP); + + gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, SHADE, 0, TEXEL0, 0, PRIMITIVE, 0, + TEXEL0, 0, SHADE, 0); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); + + Matrix_RotateYF(1.57f, MTXMODE_NEW); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateXFApply(-pauseCtx->maskPageRoll / 100.0f); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->maskPageVtx, sMaskPageBgTextures); + + KaleidoScope_DrawMaskSelect(play); + } + + switch (pauseCtx->pageIndex) { + case PAUSE_ITEM: + if (pauseCtx->mainState <= PAUSE_MAIN_STATE_EQUIP_MASK) { + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, SHADE, 0, TEXEL0, 0, + PRIMITIVE, 0, TEXEL0, 0, SHADE, 0); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); + + Matrix_RotateYF(0.0f, MTXMODE_NEW); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateXFApply(-pauseCtx->itemPageRoll / 100.0f); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = + KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->itemPageVtx, sItemPageBgTextures); + + KaleidoScope_DrawItemSelect(play); + } + break; + + case PAUSE_MAP: + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, SHADE, 0, TEXEL0, 0, PRIMITIVE, + 0, TEXEL0, 0, SHADE, 0); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); + + Matrix_RotateYF(-1.57f, MTXMODE_NEW); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateXFApply(-pauseCtx->mapPageRoll / 100.0f); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->mapPageVtx, sMapPageBgTextures); + + if (sInDungeonScene) { + KaleidoScope_DrawDungeonMap(play); + func_8012C8AC(gfxCtx); + + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + func_801091F0(play); + } else { + Matrix_RotateYF(R_PAUSE_WORLD_MAP_YAW / 1000.0f, MTXMODE_NEW); + + if ((pauseCtx->state == PAUSE_STATE_OPENING_3) || (pauseCtx->state == PAUSE_STATE_OWLWARP_3) || + (pauseCtx->state >= PAUSE_STATE_OWLWARP_6) || + ((pauseCtx->state == PAUSE_STATE_SAVEPROMPT) && + ((pauseCtx->savePromptState == PAUSE_SAVEPROMPT_STATE_3) || + (pauseCtx->savePromptState == PAUSE_SAVEPROMPT_STATE_7)))) { + Matrix_Translate(0.0f, (R_PAUSE_WORLD_MAP_Y_OFFSET - 8000) / 100.0f, + R_PAUSE_WORLD_MAP_DEPTH / 100.0f, MTXMODE_APPLY); + } else { + Matrix_Translate(0.0f, R_PAUSE_WORLD_MAP_Y_OFFSET / 100.0f, R_PAUSE_WORLD_MAP_DEPTH / 100.0f, + MTXMODE_APPLY); + } + + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateXFApply(-pauseCtx->mapPageRoll / 100.0f); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + KaleidoScope_DrawWorldMap(play); + } + break; + + case PAUSE_QUEST: + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, SHADE, 0, TEXEL0, 0, PRIMITIVE, + 0, TEXEL0, 0, SHADE, 0); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); + + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP); + + Matrix_RotateYF(-3.14f, MTXMODE_NEW); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateXFApply(-pauseCtx->questPageRoll / 100.0f); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = + KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->questPageVtx, sQuestPageBgTextures); + + KaleidoScope_DrawQuestStatus(play); + break; + + case PAUSE_MASK: + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, SHADE, 0, TEXEL0, 0, PRIMITIVE, + 0, TEXEL0, 0, SHADE, 0); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); + + Matrix_RotateYF(1.57f, MTXMODE_NEW); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateXFApply(-pauseCtx->maskPageRoll / 100.0f); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = + KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->maskPageVtx, sMaskPageBgTextures); + + KaleidoScope_DrawMaskSelect(play); + break; + } + } + + CLOSE_DISPS(gfxCtx); +} + +TexturePtr D_8082B998[] = { + gPauseToMasksENGTex, + gPauseToSelectItemENGTex, + gPauseToMapENGTex, + gPauseToQuestStatusENGTex, +}; +TexturePtr D_8082B9A8[] = { + gPauseToMapENGTex, + gPauseToQuestStatusENGTex, + gPauseToMasksENGTex, + gPauseToSelectItemENGTex, }; -s32 D_8082B9A8[] = { - 0x0D002B00, - 0x0D002F00, - 0x0D003300, - 0x0D002700, -}; - -s16 D_8082B9B8[] = { - 0x00B4, 0x00D2, 0x00FF, 0x00DC, 0x0064, 0x0064, 0x0096, 0x00DC, +s16 D_8082B9B8[][4] = { + { 180, 210, 255, 220 }, + { 100, 100, 150, 220 }, }; s16 D_8082B9C8 = 20; +s16 D_8082B9CC = 0; -s32 D_8082B9CC = 0; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80823350.s") -s16 D_8082B9D0[] = { - 0x00B4, 0x00D2, 0x00FF, 0x00DC, 0x0064, 0x0064, 0x0096, 0x00DC, +void KaleidoScope_UpdateNamePanel(PlayState* play); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_UpdateNamePanel.s") + +void KaleidoScope_DrawOwlWarpMapPage(PlayState* play) { + PauseContext* pauseCtx = &play->pauseCtx; + + OPEN_DISPS(play->state.gfxCtx); + + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, SHADE, 0, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, + SHADE, 0); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); + + Matrix_RotateYF(-1.57f, MTXMODE_NEW); + Matrix_Translate(0.0f, sPauseMenuVerticalOffset / 100.0f, -93.0f, MTXMODE_APPLY); + Matrix_Scale(0.78f, 0.78f, 0.78f, MTXMODE_APPLY); + Matrix_RotateXFApply(-pauseCtx->mapPageRoll / 100.0f); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + POLY_OPA_DISP = KaleidoScope_DrawPageSections(POLY_OPA_DISP, pauseCtx->mapPageVtx, sMapPageBgTextures); + + Matrix_RotateYF(R_PAUSE_WORLD_MAP_YAW / 1000.0f, MTXMODE_NEW); + + if ((pauseCtx->state == PAUSE_STATE_OPENING_3) || (pauseCtx->state == PAUSE_STATE_OWLWARP_3) || + (pauseCtx->state >= PAUSE_STATE_OWLWARP_6) || + ((pauseCtx->state == PAUSE_STATE_SAVEPROMPT) && ((pauseCtx->savePromptState == PAUSE_SAVEPROMPT_STATE_3) || + (pauseCtx->savePromptState == PAUSE_SAVEPROMPT_STATE_7)))) { + Matrix_Translate(0.0f, (R_PAUSE_WORLD_MAP_Y_OFFSET - 8000) / 100.0f, R_PAUSE_WORLD_MAP_DEPTH / 100.0f, + MTXMODE_APPLY); + } else { + Matrix_Translate(0.0f, R_PAUSE_WORLD_MAP_Y_OFFSET / 100.0f, R_PAUSE_WORLD_MAP_DEPTH / 100.0f, MTXMODE_APPLY); + } + + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateXFApply(-pauseCtx->mapPageRoll / 100.0f); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + KaleidoScope_DrawWorldMap(play); + + CLOSE_DISPS(play->state.gfxCtx); +} + +s16 D_8082B9D0[][4] = { + { 180, 210, 255, 220 }, + { 100, 100, 150, 220 }, }; s16 D_8082B9E0 = 20; +s16 D_8082B9E4 = 0; -s32 D_8082B9E4 = 0; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80824B90.s") -s32 D_8082B9E8 = 0; +void KaleidoScope_UpdateOwlWarpNamePanel(PlayState* play); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_UpdateOwlWarpNamePanel.s") -s32 D_8082B9EC = 0; +void KaleidoScope_UpdateSwitchPage(PlayState* play, Input* input); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_UpdateSwitchPage.s") -s16 D_8082B9F0[] = { - 0xFFEB, 0xFF98, 0xFFB4, 0xFFD0, 0xFF98, 0xFFD8, +void KaleidoScope_SetView(PauseContext* pauseCtx, f32 eyeX, f32 eyeY, f32 eyeZ) { + Vec3f eye; + Vec3f at; + Vec3f up; + + eye.x = eyeX; + eye.y = eyeY; + eye.z = eyeZ; + at.x = at.y = at.z = 0.0f; + up.x = up.z = 0.0f; + up.y = 1.0f; + + View_LookAt(&pauseCtx->view, &eye, &at, &up); + View_Apply(&pauseCtx->view, + VIEW_ALL | VIEW_FORCE_VIEWING | VIEW_FORCE_VIEWPORT | VIEW_FORCE_PROJECTION_PERSPECTIVE); +} + +// CLAMP_MIN(*, 1) because C arrays can't have 0 length +s16 sVtxPageMaskQuadsX[CLAMP_MIN(VTX_PAGE_MASK_QUADS, 1)] = { 0 }; +s16 sVtxPageItemQuadsX[CLAMP_MIN(VTX_PAGE_ITEM_QUADS, 1)] = { 0 }; +s16 sVtxPageMapDungeonQuadsX[VTX_PAGE_MAP_DUNGEON_QUADS] = { + -21, // mapPageVtx[60] QUAD_MAP_DUNGEON_TITLE + -104, // mapPageVtx[64] QUAD_MAP_DUNGEON_BOSS_KEY + -76, // mapPageVtx[68] QUAD_MAP_DUNGEON_COMPASS + -48, // mapPageVtx[72] QUAD_MAP_DUNGEON_MAP + -104, // mapPageVtx[76] QUAD_MAP_DUNGEON_STRAY_FAIRY_GLOWING_CIRCLE + -40 // mapPageVtx[80] QUAD_MAP_DUNGEON_UNUSED +}; +s16 sVtxPageQuestQuadsX[CLAMP_MIN(VTX_PAGE_QUEST_QUADS, 1)] = { 0 }; +s16 sVtxPageMapWorldQuadsX[VTX_PAGE_MAP_WORLD_QUADS] = { + -41, // mapPageVtx[60] world map clouds Clock Town 1 + 9, // mapPageVtx[64] world map clouds Clock Town 2 + 43, // mapPageVtx[68] world map clouds Woodfall 1 + -21, // mapPageVtx[72] world map clouds Woodfall 2 + -37, // mapPageVtx[76] world map clouds Woodfall 3 + 43, // mapPageVtx[80] world map clouds Snowhead 1 + -69, // mapPageVtx[84] world map clouds Snowhead 2 + -69, // mapPageVtx[88] world map clouds Snowhead 3 + -32, // mapPageVtx[92] world map clouds Romani Ranch + -109, // mapPageVtx[96] world map clouds Great Bay 1 + -45, // mapPageVtx[100] world map clouds Great Bay 2 + -109, // mapPageVtx[104] world map clouds Great Bay 3 + -45, // mapPageVtx[108] world map clouds Great Bay 4 + 59, // mapPageVtx[112] world map clouds Stone Tower 1 + -5, // mapPageVtx[116] world map clouds Stone Tower 2 + -70, // mapPageVtx[120] world map region Great Bay + -52, // mapPageVtx[124] world map region Zora Hall + -11, // mapPageVtx[128] world map region Romani Ranch + -2, // mapPageVtx[132] world map region Deku Palace + 8, // mapPageVtx[136] world map region Woodfall + 2, // mapPageVtx[140] world map region Clock Town + 1, // mapPageVtx[144] world map region Snowhead + 43, // mapPageVtx[148] world map region Ikana Graveyard + 52, // mapPageVtx[152] world map region Ikana Canyon + 54, // mapPageVtx[156] world map region Goron Village + 62, // mapPageVtx[160] world map region Stone Tower + -80, // mapPageVtx[164] world map owl warp Great Bay Coast + -64, // mapPageVtx[168] world map owl warp Zora Cape + -9, // mapPageVtx[172] world map owl warp Snowhead + -3, // mapPageVtx[176] world map owl warp Mountain Village + -7, // mapPageVtx[180] world map owl warp Clock Town + -16, // mapPageVtx[184] world map owl warp Milk Road + -1, // mapPageVtx[188] world map owl warp Woodfall + 23, // mapPageVtx[192] world map owl warp Southern Swamp + 44, // mapPageVtx[196] world map owl warp Ikana Canyon + 54, // mapPageVtx[200] world map owl warp Stone Tower +}; +s16 sVtxPageSaveQuadsX[VTX_PAGE_SAVE_QUADS] = { + -76, // promptPageVtx[60] QUAD_PROMPT_MESSAGE + -58, // promptPageVtx[64] QUAD_PROMPT_CURSOR_LEFT + 10, // promptPageVtx[68] QUAD_PROMPT_CURSOR_RIGHT + -58, // promptPageVtx[72] QUAD_PROMPT_CHOICE_YES + 10, // promptPageVtx[76] QUAD_PROMPT_CHOICE_NO }; -s32 D_8082B9FC = 0; - -s16 D_8082BA00[] = { - 0xFFD7, 0x0009, 0x002B, 0xFFEB, 0xFFDB, 0x002B, 0xFFBB, 0xFFBB, 0xFFE0, 0xFF93, 0xFFD3, 0xFF93, - 0xFFD3, 0x003B, 0xFFFB, 0xFFBA, 0xFFCC, 0xFFF5, 0xFFFE, 0x0008, 0x0002, 0x0001, 0x002B, 0x0034, - 0x0036, 0x003E, 0xFFB0, 0xFFC0, 0xFFF7, 0xFFFD, 0xFFF9, 0xFFF0, 0xFFFF, 0x0017, 0x002C, 0x0036, +// CLAMP_MIN(*, 1) because C arrays can't have 0 length +s16 sVtxPageMaskQuadsWidth[CLAMP_MIN(VTX_PAGE_MASK_QUADS, 1)] = { 0 }; +s16 sVtxPageItemQuadsWidth[CLAMP_MIN(VTX_PAGE_ITEM_QUADS, 1)] = { 0 }; +s16 sVtxPageMapDungeonQuadsWidth[VTX_PAGE_MAP_DUNGEON_QUADS] = { + 128, // mapPageVtx[60] QUAD_MAP_DUNGEON_TITLE + 24, // mapPageVtx[64] QUAD_MAP_DUNGEON_BOSS_KEY + 24, // mapPageVtx[68] QUAD_MAP_DUNGEON_COMPASS + 24, // mapPageVtx[72] QUAD_MAP_DUNGEON_MAP + 32, // mapPageVtx[76] QUAD_MAP_DUNGEON_STRAY_FAIRY_GLOWING_CIRCLE + 24, // mapPageVtx[80] QUAD_MAP_DUNGEON_UNUSED +}; +s16 sVtxPageQuestQuadsWidth[CLAMP_MIN(VTX_PAGE_QUEST_QUADS, 1)] = { 0 }; +s16 sVtxPageSaveQuadsWidth[VTX_PAGE_SAVE_QUADS] = { + 152, // promptPageVtx[60] QUAD_PROMPT_MESSAGE + 48, // promptPageVtx[64] QUAD_PROMPT_CURSOR_LEFT + 48, // promptPageVtx[68] QUAD_PROMPT_CURSOR_RIGHT + 48, // promptPageVtx[72] QUAD_PROMPT_CHOICE_YES + 48, // promptPageVtx[76] QUAD_PROMPT_CHOICE_NO }; -s16 D_8082BA48[] = { - 0xFFB4, 0xFFC6, 0x000A, 0xFFC6, 0x000A, 0x0000, +// CLAMP_MIN(*, 1) because C arrays can't have 0 length +s16 sVtxPageMaskQuadsY[CLAMP_MIN(VTX_PAGE_MASK_QUADS, 1)] = { 0 }; +s16 sVtxPageItemQuadsY[CLAMP_MIN(VTX_PAGE_ITEM_QUADS, 1)] = { 0 }; + +s16 sVtxPageMapDungeonQuadsY[VTX_PAGE_MAP_DUNGEON_QUADS] = { + 54, // mapPageVtx[60] QUAD_MAP_DUNGEON_TITLE + -42, // mapPageVtx[64] QUAD_MAP_DUNGEON_BOSS_KEY + -42, // mapPageVtx[68] QUAD_MAP_DUNGEON_COMPASS + -42, // mapPageVtx[72] QUAD_MAP_DUNGEON_MAP + -24, // mapPageVtx[76] QUAD_MAP_DUNGEON_STRAY_FAIRY_GLOWING_CIRCLE + 50, // mapPageVtx[80] QUAD_MAP_DUNGEON_UNUSED +}; +s16 sVtxPageQuestQuadsY[CLAMP_MIN(VTX_PAGE_QUEST_QUADS, 1)] = { 0 }; +s16 sVtxPageMapWorldQuadsY[VTX_PAGE_MAP_WORLD_QUADS] = { + 11, // mapPageVtx[60] world map clouds Clock Town 1 + 22, // mapPageVtx[64] world map clouds Clock Town 2 + -16, // mapPageVtx[68] world map clouds Woodfall 1 + -16, // mapPageVtx[72] world map clouds Woodfall 2 + -16, // mapPageVtx[76] world map clouds Woodfall 3 + 59, // mapPageVtx[80] world map clouds Snowhead 1 + 24, // mapPageVtx[84] world map clouds Snowhead 2 + 59, // mapPageVtx[88] world map clouds Snowhead 3 + -11, // mapPageVtx[92] world map clouds Romani Ranch + -5, // mapPageVtx[96] world map clouds Great Bay 1 + -5, // mapPageVtx[100] world map clouds Great Bay 2 + 59, // mapPageVtx[104] world map clouds Great Bay 3 + 59, // mapPageVtx[108] world map clouds Great Bay 4 + 39, // mapPageVtx[112] world map clouds Stone Tower 1 + 31, // mapPageVtx[116] world map clouds Stone Tower 2 + -10, // mapPageVtx[120] world map region Great Bay + -36, // mapPageVtx[124] world map region Zora Hall + -19, // mapPageVtx[128] world map region Romani Ranch + -53, // mapPageVtx[132] world map region Deku Palace + -27, // mapPageVtx[136] world map region Woodfall + -2, // mapPageVtx[140] world map region Clock Town + 41, // mapPageVtx[144] world map region Snowhead + 11, // mapPageVtx[148] world map region Ikana Graveyard + -3, // mapPageVtx[152] world map region Ikana Canyon + 45, // mapPageVtx[156] world map region Goron Village + 18, // mapPageVtx[160] world map region Stone Tower + -8, // mapPageVtx[164] world map owl warp Great Bay Coast + -38, // mapPageVtx[168] world map owl warp Zora Cape + 39, // mapPageVtx[172] world map owl warp Snowhead + 26, // mapPageVtx[176] world map owl warp Mountain Village + 1, // mapPageVtx[180] world map owl warp Clock Town + -7, // mapPageVtx[184] world map owl warp Milk Road + -28, // mapPageVtx[188] world map owl warp Woodfall + -27, // mapPageVtx[192] world map owl warp Southern Swamp + -1, // mapPageVtx[196] world map owl warp Ikana Canyon + 24, // mapPageVtx[200] world map owl warp Stone Tower +}; +s16 sVtxPageSaveQuadsY[VTX_PAGE_SAVE_QUADS] = { + 36, // promptPageVtx[60] QUAD_PROMPT_MESSAGE + 10, // promptPageVtx[64] QUAD_PROMPT_CURSOR_LEFT + 10, // promptPageVtx[68] QUAD_PROMPT_CURSOR_RIGHT + -6, // promptPageVtx[72] QUAD_PROMPT_CHOICE_YES + -6, // promptPageVtx[76] QUAD_PROMPT_CHOICE_NO }; -s32 D_8082BA54 = 0; - -s32 D_8082BA58 = 0; - -s16 D_8082BA5C[] = { - 0x0080, 0x0018, 0x0018, 0x0018, 0x0020, 0x0018, +// CLAMP_MIN(*, 1) because C arrays can't have 0 length +s16 sVtxPageMaskQuadsHeight[CLAMP_MIN(VTX_PAGE_MASK_QUADS, 1)] = { 0 }; +s16 sVtxPageItemQuadsHeight[CLAMP_MIN(VTX_PAGE_ITEM_QUADS, 1)] = { 0 }; +s16 sVtxPageMapDungeonQuadsHeight[] = { + 16, // mapPageVtx[60] QUAD_MAP_DUNGEON_TITLE + 24, // mapPageVtx[64] QUAD_MAP_DUNGEON_BOSS_KEY + 24, // mapPageVtx[68] QUAD_MAP_DUNGEON_COMPASS + 24, // mapPageVtx[72] QUAD_MAP_DUNGEON_MAP + 24, // mapPageVtx[76] QUAD_MAP_DUNGEON_STRAY_FAIRY_GLOWING_CIRCLE + 24, // mapPageVtx[80] QUAD_MAP_DUNGEON_UNUSED +}; +s16 sVtxPageQuestQuadsHeight[CLAMP_MIN(VTX_PAGE_QUEST_QUADS, 1)] = { 0 }; +s16 sVtxPageSaveQuadsHeight[VTX_PAGE_SAVE_QUADS] = { + 16, // promptPageVtx[60] QUAD_PROMPT_MESSAGE + 48, // promptPageVtx[64] QUAD_PROMPT_CURSOR_LEFT + 48, // promptPageVtx[68] QUAD_PROMPT_CURSOR_RIGHT + 16, // promptPageVtx[72] QUAD_PROMPT_CHOICE_YES + 16, // promptPageVtx[76] QUAD_PROMPT_CHOICE_NO }; -s32 D_8082BA68 = 0; - -s16 D_8082BA6C[] = { - 0x0098, 0x0030, 0x0030, 0x0030, 0x0030, 0x0000, +s16* sVtxPageQuadsX[VTX_PAGE_MAX] = { + sVtxPageMaskQuadsX, // VTX_PAGE_MASK + sVtxPageItemQuadsX, // VTX_PAGE_ITEM + sVtxPageMapDungeonQuadsX, // VTX_PAGE_MAP_DUNGEON + sVtxPageQuestQuadsX, // VTX_PAGE_QUEST + sVtxPageMapWorldQuadsX, // VTX_PAGE_MAP_WORLD + sVtxPageSaveQuadsX, // VTX_PAGE_PROMPT }; -s32 D_8082BA78 = 0; - -s32 D_8082BA7C = 0; - -s16 D_8082BA80[] = { - 0x0036, 0xFFD6, 0xFFD6, 0xFFD6, 0xFFE8, 0x0032, +s16* sVtxPageQuadsWidth[VTX_PAGE_MAX] = { + sVtxPageMaskQuadsWidth, // VTX_PAGE_MASK + sVtxPageItemQuadsWidth, // VTX_PAGE_ITEM + sVtxPageMapDungeonQuadsWidth, // VTX_PAGE_MAP_DUNGEON + sVtxPageQuestQuadsWidth, // VTX_PAGE_QUEST + gVtxPageMapWorldQuadsWidth, // VTX_PAGE_MAP_WORLD + sVtxPageSaveQuadsWidth, // VTX_PAGE_PROMPT }; -s32 D_8082BA8C = 0; - -s16 D_8082BA90[] = { - 0x000B, 0x0016, 0xFFF0, 0xFFF0, 0xFFF0, 0x003B, 0x0018, 0x003B, 0xFFF5, 0xFFFB, 0xFFFB, 0x003B, - 0x003B, 0x0027, 0x001F, 0xFFF6, 0xFFDC, 0xFFED, 0xFFCB, 0xFFE5, 0xFFFE, 0x0029, 0x000B, 0xFFFD, - 0x002D, 0x0012, 0xFFF8, 0xFFDA, 0x0027, 0x001A, 0x0001, 0xFFF9, 0xFFE4, 0xFFE5, 0xFFFF, 0x0018, +s16* sVtxPageQuadsY[VTX_PAGE_MAX] = { + sVtxPageMaskQuadsY, // VTX_PAGE_MASK + sVtxPageItemQuadsY, // VTX_PAGE_ITEM + sVtxPageMapDungeonQuadsY, // VTX_PAGE_MAP_DUNGEON + sVtxPageQuestQuadsY, // VTX_PAGE_QUEST + sVtxPageMapWorldQuadsY, // VTX_PAGE_MAP_WORLD + sVtxPageSaveQuadsY, // VTX_PAGE_PROMPT }; -s16 D_8082BAD8[] = { - 0x0024, 0x000A, 0x000A, 0xFFFA, 0xFFFA, 0x0000, +s16* sVtxPageQuadsHeight[VTX_PAGE_MAX] = { + sVtxPageMaskQuadsHeight, // VTX_PAGE_MASK + sVtxPageItemQuadsHeight, // VTX_PAGE_ITEM + sVtxPageMapDungeonQuadsHeight, // VTX_PAGE_MAP_DUNGEON + sVtxPageQuestQuadsHeight, // VTX_PAGE_QUEST + gVtxPageMapWorldQuadsHeight, // VTX_PAGE_MAP_WORLD + sVtxPageSaveQuadsHeight, // VTX_PAGE_PROMPT }; -s32 D_8082BAE4 = 0; - -s32 D_8082BAE8 = 0; - -s16 D_8082BAEC[] = { - 0x0010, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, +s16 sVtxPageGameOverSaveQuadsY[VTX_PAGE_SAVE_QUADS] = { + 14, // promptPageVtx[60] QUAD_PROMPT_MESSAGE + -2, // promptPageVtx[64] QUAD_PROMPT_CURSOR_LEFT + -2, // promptPageVtx[68] QUAD_PROMPT_CURSOR_RIGHT + -18, // promptPageVtx[72] QUAD_PROMPT_CHOICE_YES + -18, // promptPageVtx[76] QUAD_PROMPT_CHOICE_NO }; -s32 D_8082BAF8 = 0; +s16 KaleidoScope_SetPageVertices(PlayState* play, Vtx* vtx, s16 vtxPage, s16 numQuads) { + PauseContext* pauseCtx = &play->pauseCtx; + GameOverContext* gameOverCtx = &play->gameOverCtx; + s16* quadsX; + s16* quadsWidth; + s16* quadsY; + s16* quadsHeight; + s16 pageBgQuadX; + s16 pageBgQuadY; + s16 i; + s16 j; + s16 k; -s16 D_8082BAFC[] = { - 0x0010, 0x0030, 0x0030, 0x0010, 0x0010, 0x0000, -}; + // Vertices for KaleidoScope_DrawPageSections -void* D_8082BB08[] = { - &D_8082B9E8, &D_8082B9EC, &D_8082B9F0, &D_8082B9FC, &D_8082BA00, &D_8082BA48, -}; + pageBgQuadX = 0 - (PAGE_BG_COLS * PAGE_BG_QUAD_WIDTH) / 2 - PAGE_BG_QUAD_WIDTH; -void* D_8082BB20[] = { - &D_8082BA54, &D_8082BA58, &D_8082BA5C, &D_8082BA68, &D_8082B7F0, &D_8082BA6C, -}; + // For each column + for (k = 0, i = 0; i < 3; i++) { + pageBgQuadX += PAGE_BG_QUAD_WIDTH; -void* D_8082BB38[] = { - &D_8082BA78, &D_8082BA7C, &D_8082BA80, &D_8082BA8C, &D_8082BA90, &D_8082BAD8, -}; + // For each row + for (pageBgQuadY = (PAGE_BG_ROWS * PAGE_BG_QUAD_HEIGHT) / 2, j = 0; j < 5; j++, k += 4, pageBgQuadY -= 32) { + vtx[k + 0].v.ob[0] = vtx[k + 2].v.ob[0] = pageBgQuadX; + vtx[k + 1].v.ob[0] = vtx[k + 3].v.ob[0] = vtx[k + 0].v.ob[0] + PAGE_BG_QUAD_WIDTH; -void* D_8082BB50[] = { - &D_8082BAE4, &D_8082BAE8, &D_8082BAEC, &D_8082BAF8, &D_8082B838, &D_8082BAFC, -}; + vtx[k + 0].v.ob[1] = vtx[k + 1].v.ob[1] = pageBgQuadY + pauseCtx->offsetY; + vtx[k + 2].v.ob[1] = vtx[k + 3].v.ob[1] = vtx[k + 0].v.ob[1] - PAGE_BG_QUAD_HEIGHT; -s16 D_8082BB68[] = { - 0x000E, 0xFFFE, 0xFFFE, 0xFFEE, 0xFFEE, 0x0000, -}; + vtx[k + 0].v.ob[2] = vtx[k + 1].v.ob[2] = vtx[k + 2].v.ob[2] = vtx[k + 3].v.ob[2] = 0; + + vtx[k + 0].v.flag = vtx[k + 1].v.flag = vtx[k + 2].v.flag = vtx[k + 3].v.flag = 0; + + vtx[k + 0].v.tc[0] = vtx[k + 0].v.tc[1] = 0; + vtx[k + 1].v.tc[1] = vtx[k + 2].v.tc[0] = 0; + vtx[k + 1].v.tc[0] = vtx[k + 3].v.tc[0] = PAGE_BG_QUAD_TEX_WIDTH * (1 << 5); + vtx[k + 2].v.tc[1] = vtx[k + 3].v.tc[1] = PAGE_BG_QUAD_TEX_HEIGHT * (1 << 5); + + vtx[k + 0].v.cn[0] = vtx[k + 2].v.cn[0] = vtx[k + 0].v.cn[1] = vtx[k + 2].v.cn[1] = vtx[k + 0].v.cn[2] = + vtx[k + 2].v.cn[2] = 0; + + vtx[k + 1].v.cn[0] = vtx[k + 3].v.cn[0] = vtx[k + 1].v.cn[1] = vtx[k + 3].v.cn[1] = vtx[k + 1].v.cn[2] = + vtx[k + 3].v.cn[2] = 0; + + vtx[k + 0].v.cn[3] = vtx[k + 2].v.cn[3] = vtx[k + 1].v.cn[3] = vtx[k + 3].v.cn[3] = pauseCtx->alpha; + } + } + + if (numQuads != 0) { + quadsX = sVtxPageQuadsX[vtxPage]; + quadsWidth = sVtxPageQuadsWidth[vtxPage]; + quadsY = sVtxPageQuadsY[vtxPage]; + quadsHeight = sVtxPageQuadsHeight[vtxPage]; + + for (i = 0; i < numQuads; i++, k += 4) { + vtx[k + 2].v.ob[0] = vtx[k + 0].v.ob[0] = quadsX[i]; + + vtx[k + 1].v.ob[0] = vtx[k + 3].v.ob[0] = vtx[k + 0].v.ob[0] + quadsWidth[i]; + + if (!IS_PAUSE_STATE_GAMEOVER) { + vtx[k + 0].v.ob[1] = vtx[k + 1].v.ob[1] = quadsY[i] + pauseCtx->offsetY; + } else if (gameOverCtx->state == GAMEOVER_INACTIVE) { + vtx[k + 0].v.ob[1] = vtx[k + 1].v.ob[1] = quadsY[i] + pauseCtx->offsetY; + } else { + vtx[k + 0].v.ob[1] = vtx[k + 1].v.ob[1] = sVtxPageGameOverSaveQuadsY[i] + pauseCtx->offsetY; + } + + vtx[k + 2].v.ob[1] = vtx[k + 3].v.ob[1] = vtx[k + 0].v.ob[1] - quadsHeight[i]; + + vtx[k + 0].v.ob[2] = vtx[k + 1].v.ob[2] = vtx[k + 2].v.ob[2] = vtx[k + 3].v.ob[2] = 0; + + vtx[k + 0].v.flag = vtx[k + 1].v.flag = vtx[k + 2].v.flag = vtx[k + 3].v.flag = 0; + + vtx[k + 0].v.tc[0] = vtx[k + 0].v.tc[1] = vtx[k + 1].v.tc[1] = vtx[k + 2].v.tc[0] = 0; + vtx[k + 1].v.tc[0] = vtx[k + 3].v.tc[0] = quadsWidth[i] << 5; + vtx[k + 2].v.tc[1] = vtx[k + 3].v.tc[1] = quadsHeight[i] << 5; + + vtx[k + 0].v.cn[0] = vtx[k + 2].v.cn[0] = vtx[k + 0].v.cn[1] = vtx[k + 2].v.cn[1] = vtx[k + 0].v.cn[2] = + vtx[k + 2].v.cn[2] = 255; + + vtx[k + 1].v.cn[0] = vtx[k + 3].v.cn[0] = vtx[k + 1].v.cn[1] = vtx[k + 3].v.cn[1] = vtx[k + 1].v.cn[2] = + vtx[k + 3].v.cn[2] = 255; + + vtx[k + 0].v.cn[3] = vtx[k + 2].v.cn[3] = vtx[k + 1].v.cn[3] = vtx[k + 3].v.cn[3] = pauseCtx->alpha; + } + } + return k; +} s16 sQuestVtxRectLeft[] = { 45, // QUEST_REMAINS_ODOLWA @@ -413,6 +1180,373 @@ s16 sQuestVtxHeights[] = { 16, // ocarina input button index 6 16, // ocarina input button index 7 }; + +void KaleidoScope_SetVertices(PlayState* play, GraphicsContext* gfxCtx) { + PauseContext* pauseCtx = &play->pauseCtx; + s16 i; + s16 j; + s16 k; + s16 vtx_x; + s16 vtx_y; + + pauseCtx->offsetY = 0; + + if ((pauseCtx->state == PAUSE_STATE_OPENING_3) || (pauseCtx->state == PAUSE_STATE_OWLWARP_3) || + (pauseCtx->state >= PAUSE_STATE_OWLWARP_6) || + ((pauseCtx->state == PAUSE_STATE_SAVEPROMPT) && ((pauseCtx->savePromptState == PAUSE_SAVEPROMPT_STATE_3) || + (pauseCtx->savePromptState == PAUSE_SAVEPROMPT_STATE_7)))) { + pauseCtx->offsetY = 80; + } + + if (pauseCtx->pageIndex != PAUSE_QUEST) { + pauseCtx->itemPageVtx = GRAPH_ALLOC(gfxCtx, ((PAGE_BG_QUADS + VTX_PAGE_ITEM_QUADS) * 4) * sizeof(Vtx)); + KaleidoScope_SetPageVertices(play, pauseCtx->itemPageVtx, VTX_PAGE_ITEM, VTX_PAGE_ITEM_QUADS); + + pauseCtx->itemVtx = GRAPH_ALLOC(gfxCtx, (QUAD_ITEM_MAX * 4) * sizeof(Vtx)); + + // QUAD_ITEM_GRID_FIRST..QUAD_ITEM_GRID_LAST + + // Loop over grid rows + for (k = 0, i = 0, vtx_y = (ITEM_GRID_ROWS * ITEM_GRID_CELL_HEIGHT) / 2 - 6; k < ITEM_GRID_ROWS; + k++, vtx_y -= ITEM_GRID_CELL_HEIGHT) { + // Loop over grid columns + for (vtx_x = 0 - (ITEM_GRID_COLS * ITEM_GRID_CELL_WIDTH) / 2, j = 0; j < ITEM_GRID_COLS; + j++, i += 4, vtx_x += ITEM_GRID_CELL_WIDTH) { + pauseCtx->itemVtx[i + 0].v.ob[0] = pauseCtx->itemVtx[i + 2].v.ob[0] = vtx_x + ITEM_GRID_QUAD_MARGIN; + pauseCtx->itemVtx[i + 1].v.ob[0] = pauseCtx->itemVtx[i + 3].v.ob[0] = + pauseCtx->itemVtx[i + 0].v.ob[0] + ITEM_GRID_QUAD_WIDTH; + + pauseCtx->itemVtx[i + 0].v.ob[1] = pauseCtx->itemVtx[i + 1].v.ob[1] = + vtx_y + pauseCtx->offsetY - ITEM_GRID_QUAD_MARGIN; + pauseCtx->itemVtx[i + 2].v.ob[1] = pauseCtx->itemVtx[i + 3].v.ob[1] = + pauseCtx->itemVtx[i + 0].v.ob[1] - ITEM_GRID_QUAD_WIDTH; + + pauseCtx->itemVtx[i + 0].v.ob[2] = pauseCtx->itemVtx[i + 1].v.ob[2] = pauseCtx->itemVtx[i + 2].v.ob[2] = + pauseCtx->itemVtx[i + 3].v.ob[2] = 0; + + pauseCtx->itemVtx[i + 0].v.flag = pauseCtx->itemVtx[i + 1].v.flag = pauseCtx->itemVtx[i + 2].v.flag = + pauseCtx->itemVtx[i + 3].v.flag = 0; + + pauseCtx->itemVtx[i + 0].v.tc[0] = pauseCtx->itemVtx[i + 0].v.tc[1] = pauseCtx->itemVtx[i + 1].v.tc[1] = + pauseCtx->itemVtx[i + 2].v.tc[0] = 0; + + pauseCtx->itemVtx[i + 1].v.tc[0] = pauseCtx->itemVtx[i + 2].v.tc[1] = pauseCtx->itemVtx[i + 3].v.tc[0] = + pauseCtx->itemVtx[i + 3].v.tc[1] = ITEM_GRID_QUAD_TEX_SIZE * (1 << 5); + + pauseCtx->itemVtx[i + 0].v.cn[0] = pauseCtx->itemVtx[i + 1].v.cn[0] = pauseCtx->itemVtx[i + 2].v.cn[0] = + pauseCtx->itemVtx[i + 3].v.cn[0] = pauseCtx->itemVtx[i + 0].v.cn[1] = + pauseCtx->itemVtx[i + 1].v.cn[1] = pauseCtx->itemVtx[i + 2].v.cn[1] = + pauseCtx->itemVtx[i + 3].v.cn[1] = pauseCtx->itemVtx[i + 0].v.cn[2] = + pauseCtx->itemVtx[i + 1].v.cn[2] = pauseCtx->itemVtx[i + 2].v.cn[2] = + pauseCtx->itemVtx[i + 3].v.cn[2] = 255; + + pauseCtx->itemVtx[i + 0].v.cn[3] = pauseCtx->itemVtx[i + 1].v.cn[3] = pauseCtx->itemVtx[i + 2].v.cn[3] = + pauseCtx->itemVtx[i + 3].v.cn[3] = 255; + } + } + + // QUAD_ITEM_GRID_SELECTED_C_LEFT, QUAD_ITEM_GRID_SELECTED_C_DOWN, QUAD_ITEM_GRID_SELECTED_C_RIGHT + + for (j = EQUIP_SLOT_C_LEFT; j <= EQUIP_SLOT_C_RIGHT; j++, i += 4) { + if (GET_CUR_FORM_BTN_SLOT(j) != ITEM_NONE) { + k = GET_CUR_FORM_BTN_SLOT(j) * 4; + + pauseCtx->itemVtx[i + 0].v.ob[0] = pauseCtx->itemVtx[i + 2].v.ob[0] = + pauseCtx->itemVtx[k].v.ob[0] + ITEM_GRID_SELECTED_QUAD_MARGIN; + + pauseCtx->itemVtx[i + 1].v.ob[0] = pauseCtx->itemVtx[i + 3].v.ob[0] = + pauseCtx->itemVtx[i + 0].v.ob[0] + ITEM_GRID_SELECTED_QUAD_WIDTH; + + pauseCtx->itemVtx[i + 0].v.ob[1] = pauseCtx->itemVtx[i + 1].v.ob[1] = + pauseCtx->itemVtx[k].v.ob[1] - ITEM_GRID_SELECTED_QUAD_MARGIN; + + pauseCtx->itemVtx[i + 2].v.ob[1] = pauseCtx->itemVtx[i + 3].v.ob[1] = + pauseCtx->itemVtx[i + 0].v.ob[1] - ITEM_GRID_SELECTED_QUAD_WIDTH; + + pauseCtx->itemVtx[i + 0].v.ob[2] = pauseCtx->itemVtx[i + 1].v.ob[2] = pauseCtx->itemVtx[i + 2].v.ob[2] = + pauseCtx->itemVtx[i + 3].v.ob[2] = 0; + + pauseCtx->itemVtx[i + 0].v.flag = pauseCtx->itemVtx[i + 1].v.flag = pauseCtx->itemVtx[i + 2].v.flag = + pauseCtx->itemVtx[i + 3].v.flag = 0; + + pauseCtx->itemVtx[i + 0].v.tc[0] = pauseCtx->itemVtx[i + 0].v.tc[1] = pauseCtx->itemVtx[i + 1].v.tc[1] = + pauseCtx->itemVtx[i + 2].v.tc[0] = 0; + + pauseCtx->itemVtx[i + 1].v.tc[0] = pauseCtx->itemVtx[i + 2].v.tc[1] = pauseCtx->itemVtx[i + 3].v.tc[0] = + pauseCtx->itemVtx[i + 3].v.tc[1] = ITEM_GRID_SELECTED_QUAD_TEX_SIZE * (1 << 5); + + pauseCtx->itemVtx[i + 0].v.cn[0] = pauseCtx->itemVtx[i + 1].v.cn[0] = pauseCtx->itemVtx[i + 2].v.cn[0] = + pauseCtx->itemVtx[i + 3].v.cn[0] = pauseCtx->itemVtx[i + 0].v.cn[1] = + pauseCtx->itemVtx[i + 1].v.cn[1] = pauseCtx->itemVtx[i + 2].v.cn[1] = + pauseCtx->itemVtx[i + 3].v.cn[1] = pauseCtx->itemVtx[i + 0].v.cn[2] = + pauseCtx->itemVtx[i + 1].v.cn[2] = pauseCtx->itemVtx[i + 2].v.cn[2] = + pauseCtx->itemVtx[i + 3].v.cn[2] = 255; + + pauseCtx->itemVtx[i + 0].v.cn[3] = pauseCtx->itemVtx[i + 1].v.cn[3] = pauseCtx->itemVtx[i + 2].v.cn[3] = + pauseCtx->itemVtx[i + 3].v.cn[3] = pauseCtx->alpha; + } else { + // No item equipped on the C button, put the quad out of view + + pauseCtx->itemVtx[i + 2].v.ob[0] = -300; + pauseCtx->itemVtx[i + 0].v.ob[0] = pauseCtx->itemVtx[i + 2].v.ob[0]; + + pauseCtx->itemVtx[i + 1].v.ob[0] = pauseCtx->itemVtx[i + 3].v.ob[0] = + pauseCtx->itemVtx[i + 0].v.ob[0] + ITEM_GRID_SELECTED_QUAD_WIDTH; + + pauseCtx->itemVtx[i + 0].v.ob[1] = pauseCtx->itemVtx[i + 1].v.ob[1] = 300; + pauseCtx->itemVtx[i + 2].v.ob[1] = pauseCtx->itemVtx[i + 3].v.ob[1] = + pauseCtx->itemVtx[i + 0].v.ob[1] - ITEM_GRID_SELECTED_QUAD_HEIGHT; + } + } + } + + if (pauseCtx->pageIndex != PAUSE_MASK) { + if (!sInDungeonScene) { + pauseCtx->mapPageVtx = GRAPH_ALLOC( + gfxCtx, ((PAGE_BG_QUADS + VTX_PAGE_MAP_WORLD_QUADS + WORLD_MAP_IMAGE_FRAG_NUM) * 4) * sizeof(Vtx)); + j = KaleidoScope_SetPageVertices(play, pauseCtx->mapPageVtx, VTX_PAGE_MAP_WORLD, VTX_PAGE_MAP_WORLD_QUADS); + + for (i = 0, vtx_y = 59; i < WORLD_MAP_IMAGE_FRAG_NUM; i++, j += 4, vtx_y -= WORLD_MAP_IMAGE_FRAG_HEIGHT) { + pauseCtx->mapPageVtx[j + 2].v.ob[0] = 0 - (WORLD_MAP_IMAGE_WIDTH / 2) - 1; + pauseCtx->mapPageVtx[j + 0].v.ob[0] = pauseCtx->mapPageVtx[j + 2].v.ob[0]; + + pauseCtx->mapPageVtx[j + 1].v.ob[0] = pauseCtx->mapPageVtx[j + 3].v.ob[0] = + pauseCtx->mapPageVtx[j + 0].v.ob[0] + WORLD_MAP_IMAGE_WIDTH; + + pauseCtx->mapPageVtx[j + 0].v.ob[1] = pauseCtx->mapPageVtx[j + 1].v.ob[1] = vtx_y + pauseCtx->offsetY; + + pauseCtx->mapPageVtx[j + 2].v.ob[1] = pauseCtx->mapPageVtx[j + 3].v.ob[1] = + pauseCtx->mapPageVtx[j + 0].v.ob[1] - WORLD_MAP_IMAGE_FRAG_HEIGHT; + + pauseCtx->mapPageVtx[j + 0].v.ob[2] = pauseCtx->mapPageVtx[j + 1].v.ob[2] = + pauseCtx->mapPageVtx[j + 2].v.ob[2] = pauseCtx->mapPageVtx[j + 3].v.ob[2] = 0; + + pauseCtx->mapPageVtx[j + 0].v.flag = pauseCtx->mapPageVtx[j + 1].v.flag = + pauseCtx->mapPageVtx[j + 2].v.flag = pauseCtx->mapPageVtx[j + 3].v.flag = 0; + + pauseCtx->mapPageVtx[j + 0].v.tc[0] = pauseCtx->mapPageVtx[j + 0].v.tc[1] = + pauseCtx->mapPageVtx[j + 1].v.tc[1] = pauseCtx->mapPageVtx[j + 2].v.tc[0] = 0; + + pauseCtx->mapPageVtx[j + 1].v.tc[0] = pauseCtx->mapPageVtx[j + 3].v.tc[0] = + WORLD_MAP_IMAGE_WIDTH * (1 << 5); + pauseCtx->mapPageVtx[j + 2].v.tc[1] = pauseCtx->mapPageVtx[j + 3].v.tc[1] = + WORLD_MAP_IMAGE_FRAG_HEIGHT * (1 << 5); + + pauseCtx->mapPageVtx[j + 0].v.cn[0] = pauseCtx->mapPageVtx[j + 2].v.cn[0] = + pauseCtx->mapPageVtx[j + 0].v.cn[1] = pauseCtx->mapPageVtx[j + 2].v.cn[1] = + pauseCtx->mapPageVtx[j + 0].v.cn[2] = pauseCtx->mapPageVtx[j + 2].v.cn[2] = + pauseCtx->mapPageVtx[j + 1].v.cn[0] = pauseCtx->mapPageVtx[j + 3].v.cn[0] = + pauseCtx->mapPageVtx[j + 1].v.cn[1] = pauseCtx->mapPageVtx[j + 3].v.cn[1] = + pauseCtx->mapPageVtx[j + 1].v.cn[2] = pauseCtx->mapPageVtx[j + 3].v.cn[2] = + pauseCtx->mapPageVtx[j + 0].v.cn[3] = pauseCtx->mapPageVtx[j + 2].v.cn[3] = + pauseCtx->mapPageVtx[j + 1].v.cn[3] = pauseCtx->mapPageVtx[j + 3].v.cn[3] = + pauseCtx->alpha; + } + + pauseCtx->mapPageVtx[j - 2].v.ob[1] = pauseCtx->mapPageVtx[j - 1].v.ob[1] = + pauseCtx->mapPageVtx[j - 4].v.ob[1] - (WORLD_MAP_IMAGE_HEIGHT % WORLD_MAP_IMAGE_FRAG_HEIGHT); + + pauseCtx->mapPageVtx[j - 2].v.tc[1] = pauseCtx->mapPageVtx[j - 1].v.tc[1] = + (WORLD_MAP_IMAGE_HEIGHT % WORLD_MAP_IMAGE_FRAG_HEIGHT) * (1 << 5); + + } else { + pauseCtx->mapPageVtx = + GRAPH_ALLOC(gfxCtx, ((PAGE_BG_QUADS + VTX_PAGE_MAP_DUNGEON_QUADS) * 4) * sizeof(Vtx)); + KaleidoScope_SetPageVertices(play, pauseCtx->mapPageVtx, VTX_PAGE_MAP_DUNGEON, VTX_PAGE_MAP_DUNGEON_QUADS); + } + } + + if (pauseCtx->pageIndex != PAUSE_ITEM) { + pauseCtx->questPageVtx = GRAPH_ALLOC(gfxCtx, ((PAGE_BG_QUADS + VTX_PAGE_QUEST_QUADS) * 4) * sizeof(Vtx)); + KaleidoScope_SetPageVertices(play, pauseCtx->questPageVtx, VTX_PAGE_QUEST, VTX_PAGE_QUEST_QUADS); + + pauseCtx->questVtx = GRAPH_ALLOC(gfxCtx, (39 * 4) * sizeof(Vtx)); + + for (k = 0, j = 0; j < 39; j++, k += 4) { + if (j <= QUEST_SWORD) { + pauseCtx->questVtx[k + 0].v.ob[0] = pauseCtx->questVtx[k + 2].v.ob[0] = sQuestVtxRectLeft[j]; + + pauseCtx->questVtx[k + 1].v.ob[0] = pauseCtx->questVtx[k + 3].v.ob[0] = + pauseCtx->questVtx[k + 0].v.ob[0] + sQuestVtxWidths[j]; + + pauseCtx->questVtx[k + 0].v.ob[1] = pauseCtx->questVtx[k + 1].v.ob[1] = + sQuestVtxRectTop[j] + pauseCtx->offsetY; + + pauseCtx->questVtx[k + 2].v.ob[1] = pauseCtx->questVtx[k + 3].v.ob[1] = + pauseCtx->questVtx[k + 0].v.ob[1] - sQuestVtxHeights[j]; + } else { + pauseCtx->questVtx[k + 0].v.ob[0] = pauseCtx->questVtx[k + 2].v.ob[0] = sQuestVtxRectLeft[j] + 2; + + pauseCtx->questVtx[k + 1].v.ob[0] = pauseCtx->questVtx[k + 3].v.ob[0] = + pauseCtx->questVtx[k + 0].v.ob[0] + sQuestVtxWidths[j] - 4; + + pauseCtx->questVtx[k + 0].v.ob[1] = pauseCtx->questVtx[k + 1].v.ob[1] = + sQuestVtxRectTop[j] + pauseCtx->offsetY - 2; + + pauseCtx->questVtx[k + 2].v.ob[1] = pauseCtx->questVtx[k + 3].v.ob[1] = + pauseCtx->questVtx[k + 0].v.ob[1] - sQuestVtxHeights[j] + 4; + } + + pauseCtx->questVtx[k + 0].v.ob[2] = pauseCtx->questVtx[k + 1].v.ob[2] = pauseCtx->questVtx[k + 2].v.ob[2] = + pauseCtx->questVtx[k + 3].v.ob[2] = 0; + + pauseCtx->questVtx[k + 0].v.flag = pauseCtx->questVtx[k + 1].v.flag = pauseCtx->questVtx[k + 2].v.flag = + pauseCtx->questVtx[k + 3].v.flag = 0; + + pauseCtx->questVtx[k + 0].v.tc[0] = pauseCtx->questVtx[k + 0].v.tc[1] = pauseCtx->questVtx[k + 1].v.tc[1] = + pauseCtx->questVtx[k + 2].v.tc[0] = 0; + + pauseCtx->questVtx[k + 1].v.tc[0] = pauseCtx->questVtx[k + 3].v.tc[0] = sQuestVtxWidths[j] << 5; + pauseCtx->questVtx[k + 2].v.tc[1] = pauseCtx->questVtx[k + 3].v.tc[1] = sQuestVtxHeights[j] << 5; + + pauseCtx->questVtx[k + 0].v.cn[0] = pauseCtx->questVtx[k + 1].v.cn[0] = pauseCtx->questVtx[k + 2].v.cn[0] = + pauseCtx->questVtx[k + 3].v.cn[0] = pauseCtx->questVtx[k + 0].v.cn[1] = + pauseCtx->questVtx[k + 1].v.cn[1] = pauseCtx->questVtx[k + 2].v.cn[1] = + pauseCtx->questVtx[k + 3].v.cn[1] = pauseCtx->questVtx[k + 0].v.cn[2] = + pauseCtx->questVtx[k + 1].v.cn[2] = pauseCtx->questVtx[k + 2].v.cn[2] = + pauseCtx->questVtx[k + 3].v.cn[2] = 255; + + pauseCtx->questVtx[k + 0].v.cn[3] = pauseCtx->questVtx[k + 1].v.cn[3] = pauseCtx->questVtx[k + 2].v.cn[3] = + pauseCtx->questVtx[k + 3].v.cn[3] = pauseCtx->alpha; + } + } + + if (pauseCtx->pageIndex != PAUSE_MAP) { + pauseCtx->maskPageVtx = GRAPH_ALLOC(gfxCtx, ((PAGE_BG_QUADS + VTX_PAGE_MASK_QUADS) * 4) * sizeof(Vtx)); + KaleidoScope_SetPageVertices(play, pauseCtx->maskPageVtx, VTX_PAGE_MASK, VTX_PAGE_MASK_QUADS); + + pauseCtx->maskVtx = GRAPH_ALLOC(gfxCtx, (QUAD_MASK_MAX * 4) * sizeof(Vtx)); + + // Loop over grid rows + for (k = 0, i = 0, vtx_y = (MASK_GRID_ROWS * MASK_GRID_CELL_HEIGHT) / 2 - 6; k < MASK_GRID_ROWS; + k++, vtx_y -= MASK_GRID_CELL_HEIGHT) { + // Loop over grid columns + for (vtx_x = 0 - (MASK_GRID_COLS * MASK_GRID_CELL_WIDTH) / 2, j = 0; j < MASK_GRID_COLS; + j++, i += 4, vtx_x += MASK_GRID_CELL_WIDTH) { + pauseCtx->maskVtx[i + 0].v.ob[0] = pauseCtx->maskVtx[i + 2].v.ob[0] = vtx_x + MASK_GRID_QUAD_MARGIN; + pauseCtx->maskVtx[i + 1].v.ob[0] = pauseCtx->maskVtx[i + 3].v.ob[0] = + pauseCtx->maskVtx[i + 0].v.ob[0] + MASK_GRID_QUAD_WIDTH; + + pauseCtx->maskVtx[i + 0].v.ob[1] = pauseCtx->maskVtx[i + 1].v.ob[1] = + vtx_y + pauseCtx->offsetY - MASK_GRID_QUAD_MARGIN; + pauseCtx->maskVtx[i + 2].v.ob[1] = pauseCtx->maskVtx[i + 3].v.ob[1] = + pauseCtx->maskVtx[i + 0].v.ob[1] - MASK_GRID_QUAD_HEIGHT; + + pauseCtx->maskVtx[i + 0].v.ob[2] = pauseCtx->maskVtx[i + 1].v.ob[2] = pauseCtx->maskVtx[i + 2].v.ob[2] = + pauseCtx->maskVtx[i + 3].v.ob[2] = 0; + + pauseCtx->maskVtx[i + 0].v.flag = pauseCtx->maskVtx[i + 1].v.flag = pauseCtx->maskVtx[i + 2].v.flag = + pauseCtx->maskVtx[i + 3].v.flag = 0; + + pauseCtx->maskVtx[i + 0].v.tc[0] = pauseCtx->maskVtx[i + 0].v.tc[1] = pauseCtx->maskVtx[i + 1].v.tc[1] = + pauseCtx->maskVtx[i + 2].v.tc[0] = 0; + + pauseCtx->maskVtx[i + 1].v.tc[0] = pauseCtx->maskVtx[i + 2].v.tc[1] = pauseCtx->maskVtx[i + 3].v.tc[0] = + pauseCtx->maskVtx[i + 3].v.tc[1] = MASK_GRID_QUAD_TEX_SIZE * (1 << 5); + + pauseCtx->maskVtx[i + 0].v.cn[0] = pauseCtx->maskVtx[i + 1].v.cn[0] = pauseCtx->maskVtx[i + 2].v.cn[0] = + pauseCtx->maskVtx[i + 3].v.cn[0] = pauseCtx->maskVtx[i + 0].v.cn[1] = + pauseCtx->maskVtx[i + 1].v.cn[1] = pauseCtx->maskVtx[i + 2].v.cn[1] = + pauseCtx->maskVtx[i + 3].v.cn[1] = pauseCtx->maskVtx[i + 0].v.cn[2] = + pauseCtx->maskVtx[i + 1].v.cn[2] = pauseCtx->maskVtx[i + 2].v.cn[2] = + pauseCtx->maskVtx[i + 3].v.cn[2] = 255; + + pauseCtx->maskVtx[i + 0].v.cn[3] = pauseCtx->maskVtx[i + 1].v.cn[3] = pauseCtx->maskVtx[i + 2].v.cn[3] = + pauseCtx->maskVtx[i + 3].v.cn[3] = 255; + } + } + + // QUAD_MASK_GRID_SELECTED_C_LEFT, QUAD_MASK_GRID_SELECTED_C_DOWN, QUAD_MASK_GRID_SELECTED_C_RIGHT + + for (j = EQUIP_SLOT_C_LEFT; j <= EQUIP_SLOT_C_RIGHT; j++, i += 4) { + if (GET_CUR_FORM_BTN_SLOT(j) != ITEM_NONE) { + k = (GET_CUR_FORM_BTN_SLOT(j) - ITEM_NUM_SLOTS) * 4; + + pauseCtx->maskVtx[i + 0].v.ob[0] = pauseCtx->maskVtx[i + 2].v.ob[0] = + pauseCtx->maskVtx[k].v.ob[0] + MASK_GRID_SELECTED_QUAD_MARGIN; + + pauseCtx->maskVtx[i + 1].v.ob[0] = pauseCtx->maskVtx[i + 3].v.ob[0] = + pauseCtx->maskVtx[i + 0].v.ob[0] + MASK_GRID_SELECTED_QUAD_WIDTH; + + pauseCtx->maskVtx[i + 0].v.ob[1] = pauseCtx->maskVtx[i + 1].v.ob[1] = + pauseCtx->maskVtx[k].v.ob[1] - MASK_GRID_SELECTED_QUAD_MARGIN; + + pauseCtx->maskVtx[i + 2].v.ob[1] = pauseCtx->maskVtx[i + 3].v.ob[1] = + pauseCtx->maskVtx[i + 0].v.ob[1] - MASK_GRID_SELECTED_QUAD_HEIGHT; + + pauseCtx->maskVtx[i + 0].v.ob[2] = pauseCtx->maskVtx[i + 1].v.ob[2] = pauseCtx->maskVtx[i + 2].v.ob[2] = + pauseCtx->maskVtx[i + 3].v.ob[2] = 0; + + pauseCtx->maskVtx[i + 0].v.flag = pauseCtx->maskVtx[i + 1].v.flag = pauseCtx->maskVtx[i + 2].v.flag = + pauseCtx->maskVtx[i + 3].v.flag = 0; + + pauseCtx->maskVtx[i + 0].v.tc[0] = pauseCtx->maskVtx[i + 0].v.tc[1] = pauseCtx->maskVtx[i + 1].v.tc[1] = + pauseCtx->maskVtx[i + 2].v.tc[0] = 0; + + pauseCtx->maskVtx[i + 1].v.tc[0] = pauseCtx->maskVtx[i + 2].v.tc[1] = pauseCtx->maskVtx[i + 3].v.tc[0] = + pauseCtx->maskVtx[i + 3].v.tc[1] = MASK_GRID_SELECTED_QUAD_TEX_SIZE * (1 << 5); + + pauseCtx->maskVtx[i + 0].v.cn[0] = pauseCtx->maskVtx[i + 1].v.cn[0] = pauseCtx->maskVtx[i + 2].v.cn[0] = + pauseCtx->maskVtx[i + 3].v.cn[0] = pauseCtx->maskVtx[i + 0].v.cn[1] = + pauseCtx->maskVtx[i + 1].v.cn[1] = pauseCtx->maskVtx[i + 2].v.cn[1] = + pauseCtx->maskVtx[i + 3].v.cn[1] = pauseCtx->maskVtx[i + 0].v.cn[2] = + pauseCtx->maskVtx[i + 1].v.cn[2] = pauseCtx->maskVtx[i + 2].v.cn[2] = + pauseCtx->maskVtx[i + 3].v.cn[2] = 255; + + pauseCtx->maskVtx[i + 0].v.cn[3] = pauseCtx->maskVtx[i + 1].v.cn[3] = pauseCtx->maskVtx[i + 2].v.cn[3] = + pauseCtx->maskVtx[i + 3].v.cn[3] = pauseCtx->alpha; + } else { + pauseCtx->maskVtx[i + 2].v.ob[0] = -300; + pauseCtx->maskVtx[i + 0].v.ob[0] = pauseCtx->maskVtx[i + 2].v.ob[0]; + + pauseCtx->maskVtx[i + 1].v.ob[0] = pauseCtx->maskVtx[i + 3].v.ob[0] = + pauseCtx->maskVtx[i + 0].v.ob[0] + MASK_GRID_SELECTED_QUAD_WIDTH; + + pauseCtx->maskVtx[i + 0].v.ob[1] = pauseCtx->maskVtx[i + 1].v.ob[1] = 300; + pauseCtx->maskVtx[i + 2].v.ob[1] = pauseCtx->maskVtx[i + 3].v.ob[1] = + pauseCtx->maskVtx[i + 0].v.ob[1] - MASK_GRID_SELECTED_QUAD_HEIGHT; + } + } + } + + pauseCtx->cursorVtx = GRAPH_ALLOC(play->state.gfxCtx, (PAUSE_QUAD_CURSOR_MAX * 4) * sizeof(Vtx)); + + for (i = 0; i < (PAUSE_QUAD_CURSOR_MAX * 4); i++) { + pauseCtx->cursorVtx[i].v.ob[0] = pauseCtx->cursorVtx[i].v.ob[1] = pauseCtx->cursorVtx[i].v.ob[2] = 0; + + pauseCtx->cursorVtx[i].v.flag = 0; + + pauseCtx->cursorVtx[i].v.tc[0] = pauseCtx->cursorVtx[i].v.tc[1] = 0; + + pauseCtx->cursorVtx[i].v.cn[0] = pauseCtx->cursorVtx[i].v.cn[1] = pauseCtx->cursorVtx[i].v.cn[2] = + pauseCtx->cursorVtx[i].v.cn[3] = 255; + } + + // PAUSE_QUAD_CURSOR_0 + pauseCtx->cursorVtx[1].v.tc[0] = pauseCtx->cursorVtx[2].v.tc[1] = pauseCtx->cursorVtx[3].v.tc[0] = + pauseCtx->cursorVtx[3].v.tc[1] + // PAUSE_QUAD_CURSOR_1 + = pauseCtx->cursorVtx[5].v.tc[0] = pauseCtx->cursorVtx[6].v.tc[1] = pauseCtx->cursorVtx[7].v.tc[0] = + pauseCtx->cursorVtx[7].v.tc[1] + // PAUSE_QUAD_CURSOR_2 + = pauseCtx->cursorVtx[9].v.tc[0] = pauseCtx->cursorVtx[10].v.tc[1] = pauseCtx->cursorVtx[11].v.tc[0] = + pauseCtx->cursorVtx[11].v.tc[1] + // PAUSE_QUAD_CURSOR_3 + = pauseCtx->cursorVtx[13].v.tc[0] = pauseCtx->cursorVtx[14].v.tc[1] = pauseCtx->cursorVtx[15].v.tc[0] = + pauseCtx->cursorVtx[15].v.tc[1] = 16 * (1 << 5); + + // PAUSE_QUAD_CURSOR_4 + pauseCtx->cursorVtx[17].v.tc[0] = pauseCtx->cursorVtx[18].v.tc[1] = pauseCtx->cursorVtx[19].v.tc[0] = + pauseCtx->cursorVtx[19].v.tc[1] = 32 * (1 << 5); + + pauseCtx->infoPanelVtx = GRAPH_ALLOC(gfxCtx, 28 * sizeof(Vtx)); + + if ((pauseCtx->state == PAUSE_STATE_SAVEPROMPT) || IS_PAUSE_STATE_GAMEOVER) { + pauseCtx->promptPageVtx = GRAPH_ALLOC(gfxCtx, ((PAGE_BG_QUADS + VTX_PAGE_SAVE_QUADS) * 4) * sizeof(Vtx)); + KaleidoScope_SetPageVertices(play, pauseCtx->promptPageVtx, VTX_PAGE_PROMPT, VTX_PAGE_SAVE_QUADS); + } +} + f32 D_8082BCB4[] = { -62.0f, -36.0f, -10.0f, 16.0f, 42.0f, 68.0f, }; @@ -458,66 +1592,42 @@ f32 D_8082BE28[] = { -11.0f, -11.0f, -11.0f, -11.0f, -11.0f, -11.0f, 27.0f, -53.0f, -53.0f, 14.0f, 26.0f, }; -s16 D_8082BE84 = 0; - -void func_80821900(void* segment, u32 texIndex) { - func_80178E3C(SEGMENT_ROM_START(map_name_static), texIndex, segment, 0x400); -} - -void func_8082192C(void* segment, u32 texIndex) { - func_80178E3C(SEGMENT_ROM_START(map_name_static), texIndex, segment, 0xA00); -} - -void func_80821958(void* segment, u32 texIndex) { - func_80178E3C(SEGMENT_ROM_START(item_name_static), texIndex, segment, 0x400); -} - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_MoveCursorToSpecialPos.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821A04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_DrawTexQuadRGBA32.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821CC4.s") - -void KaleidoScope_HandlePageToggles(PlayState* play, Input* input); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_HandlePageToggles.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821F30.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808221DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80823350.s") - -void KaleidoScope_UpdateNamePanel(PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_UpdateNamePanel.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808248D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80824B90.s") - -void KaleidoScope_UpdateOwlWarpNamePanel(PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_UpdateOwlWarpNamePanel.s") - -void KaleidoScope_UpdateSwitchPage(PlayState* play, Input* input); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_UpdateSwitchPage.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_SetView.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80825A50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80825E28.s") - #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808274DC.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80827A8C.s") +s16 D_8082BE84 = 0; + #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80827E08.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_Draw.s") -void KaleidoScope_GrayOutTextureRGBA32(u32* texture, u16 pixelCount); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_GrayOutTextureRGBA32.s") +void KaleidoScope_GrayOutTextureRGBA32(u32* texture, u16 pixelCount) { + u32 rgb; + u32 gray; + u16 i; + s32 j; + + //! FAKE + if (texture == NULL) {} + + for (i = 0; i < pixelCount; i++) { + //! FAKE + j = i; + if ((texture[j] & 0xFFFFFF00) != 0) { + rgb = texture[j] >> 8; + gray = ((((rgb & 0xFF0000) >> 16) + ((rgb & 0xFF00) >> 7) + (rgb & 0xFF)) / 7) & 0xFF; + + rgb = gray; + rgb <<= 8; + rgb |= gray; + rgb <<= 8; + rgb |= gray; + + texture[j] = (rgb << 8) | (texture[j] & 0xFF); + } + } +} void KaleidoScope_UpdateOpening(PlayState* play) { PauseContext* pauseCtx = &play->pauseCtx; @@ -528,7 +1638,7 @@ void KaleidoScope_UpdateOpening(PlayState* play) { if (pauseCtx->switchPageTimer == 64) { // Finished opening - func_80112C0C(play, 1); + Interface_UpdateButtonsAlt(play, 1); if (pauseCtx->cursorSpecialPos == 0) { gSaveContext.buttonStatus[EQUIP_SLOT_B] = D_801C6A98[pauseCtx->pageIndex][0]; @@ -611,7 +1721,7 @@ void KaleidoScope_Update(PlayState* play) { pauseCtx->iconItemSegment = (void*)ALIGN16((uintptr_t)play->objectCtx.spaceStart); size0 = SEGMENT_ROM_SIZE(icon_item_static_old); - func_80178E7C((uintptr_t)SEGMENT_ROM_START(icon_item_static_test), pauseCtx->iconItemSegment, size0); + CmpDma_LoadAllFiles((uintptr_t)SEGMENT_ROM_START(icon_item_static_test), pauseCtx->iconItemSegment, size0); gSegments[0x08] = PHYSICAL_TO_VIRTUAL(pauseCtx->iconItemSegment); @@ -623,7 +1733,8 @@ void KaleidoScope_Update(PlayState* play) { pauseCtx->iconItem24Segment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemSegment + size0); size1 = SEGMENT_ROM_SIZE(icon_item_24_static_old); - func_80178E7C((uintptr_t)SEGMENT_ROM_START(icon_item_24_static_test), pauseCtx->iconItem24Segment, size1); + CmpDma_LoadAllFiles((uintptr_t)SEGMENT_ROM_START(icon_item_24_static_test), pauseCtx->iconItem24Segment, + size1); pauseCtx->iconItemAltSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItem24Segment + size1); if (func_8010A0A4(play)) { @@ -810,7 +1921,7 @@ void KaleidoScope_Update(PlayState* play) { } else { play_sound(NA_SE_SY_PIECE_OF_HEART); Play_SaveCycleSceneFlags(&play->state); - gSaveContext.save.playerData.savedSceneId = play->sceneId; + gSaveContext.save.saveInfo.playerData.savedSceneId = play->sceneId; func_8014546C(sramCtx); if (gSaveContext.unk_3F3F == 0) { pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_5; @@ -932,11 +2043,11 @@ void KaleidoScope_Update(PlayState* play) { pauseCtx->iconItemSegment = (void*)(((uintptr_t)play->objectCtx.spaceStart + 0x30) & ~0x3F); // Messed up ALIGN64 size0 = SEGMENT_ROM_SIZE(icon_item_static_old); - func_80178E7C(SEGMENT_ROM_START(icon_item_static_test), pauseCtx->iconItemSegment, size0); + CmpDma_LoadAllFiles(SEGMENT_ROM_START(icon_item_static_test), pauseCtx->iconItemSegment, size0); pauseCtx->iconItem24Segment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemSegment + size0); size1 = SEGMENT_ROM_SIZE(icon_item_24_static_old); - func_80178E7C(SEGMENT_ROM_START(icon_item_24_static_test), pauseCtx->iconItem24Segment, size1); + CmpDma_LoadAllFiles(SEGMENT_ROM_START(icon_item_24_static_test), pauseCtx->iconItem24Segment, size1); pauseCtx->iconItemAltSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItem24Segment + size1); size2 = SEGMENT_ROM_SIZE(icon_item_gameover_static); @@ -961,7 +2072,7 @@ void KaleidoScope_Update(PlayState* play) { pauseCtx->promptChoice = PAUSE_PROMPT_YES; pauseCtx->state++; if (gameOverCtx->state == GAMEOVER_INACTIVE) { - pauseCtx->state++; + pauseCtx->state++; // GAMEOVER_DEATH_START } break; @@ -1071,8 +2182,8 @@ void KaleidoScope_Update(PlayState* play) { play_sound(NA_SE_SY_PIECE_OF_HEART); pauseCtx->promptChoice = PAUSE_PROMPT_YES; Play_SaveCycleSceneFlags(&play->state); - gSaveContext.save.playerData.savedSceneId = play->sceneId; - gSaveContext.save.playerData.health = 0x30; + gSaveContext.save.saveInfo.playerData.savedSceneId = play->sceneId; + gSaveContext.save.saveInfo.playerData.health = 0x30; func_8014546C(sramCtx); if (gSaveContext.unk_3F3F == 0) { pauseCtx->state = PAUSE_STATE_GAMEOVER_8; @@ -1143,16 +2254,16 @@ void KaleidoScope_Update(PlayState* play) { if (pauseCtx->promptChoice == PAUSE_PROMPT_YES) { func_80169FDC(&play->state); gSaveContext.respawnFlag = -2; - gSaveContext.nextTransitionType = TRANS_TYPE_02; - gSaveContext.save.playerData.health = 0x30; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; + gSaveContext.save.saveInfo.playerData.health = 0x30; Audio_SetSpec(0xA); gSaveContext.healthAccumulator = 0; gSaveContext.magicState = MAGIC_STATE_IDLE; gSaveContext.magicFlag = 0; gSaveContext.magicCapacity = 0; - gSaveContext.magicFillTarget = gSaveContext.save.playerData.magic; - gSaveContext.save.playerData.magicLevel = 0; - gSaveContext.save.playerData.magic = 0; + gSaveContext.magicFillTarget = gSaveContext.save.saveInfo.playerData.magic; + gSaveContext.save.saveInfo.playerData.magicLevel = 0; + gSaveContext.save.saveInfo.playerData.magic = 0; } else { // PAUSE_PROMPT_NO STOP_GAMESTATE(&play->state); SET_NEXT_GAMESTATE(&play->state, TitleSetup_Init, sizeof(TitleSetupState)); @@ -1179,7 +2290,7 @@ void KaleidoScope_Update(PlayState* play) { pauseCtx->iconItemSegment = (void*)ALIGN16((uintptr_t)play->objectCtx.spaceStart); size0 = SEGMENT_ROM_SIZE(icon_item_static_old); - func_80178E7C(SEGMENT_ROM_START(icon_item_static_test), pauseCtx->iconItemSegment, size0); + CmpDma_LoadAllFiles(SEGMENT_ROM_START(icon_item_static_test), pauseCtx->iconItemSegment, size0); pauseCtx->iconItemAltSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemSegment + size0); sInDungeonScene = false; @@ -1339,7 +2450,7 @@ void KaleidoScope_Update(PlayState* play) { gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = sUnpausedButtonStatus[EQUIP_SLOT_C_RIGHT]; gSaveContext.buttonStatus[EQUIP_SLOT_A] = sUnpausedButtonStatus[EQUIP_SLOT_A]; - func_80110038(play); + Interface_UpdateButtonsPart2(play); gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; Interface_SetHudVisibility(HUD_VISIBILITY_ALL); MsgEvent_SendNullTask(); @@ -1431,7 +2542,7 @@ void KaleidoScope_Update(PlayState* play) { } // Process the Cursor input - if ((R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_DONE) && (pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && + if ((R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_READY) && (pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && !IS_PAUSE_STATE_OWLWARP && (((pauseCtx->state >= PAUSE_STATE_OPENING_3) && (pauseCtx->state <= PAUSE_STATE_SAVEPROMPT)) || ((pauseCtx->state >= PAUSE_STATE_GAMEOVER_2) && (pauseCtx->state <= PAUSE_STATE_UNPAUSE_SETUP)))) { diff --git a/tools/ZAPD/.gitrepo b/tools/ZAPD/.gitrepo index 3144cab20..131ccdc88 100644 --- a/tools/ZAPD/.gitrepo +++ b/tools/ZAPD/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/zeldaret/ZAPD.git branch = master - commit = 5786abbdd2d0fd14907e03575a0bd972c1fe9b28 - parent = e451a103ba5d14af3dd14acfa54a6b4999fd951f + commit = 23929ec9373d28cb298daad4ad7cb468e09c0a46 + parent = 2e487b5008c129031ab311a3a7bfd42adeb4916b method = merge - cmdver = 0.4.5 + cmdver = 0.4.3 diff --git a/tools/ZAPD/ZAPD/ZTextureAnimation.cpp b/tools/ZAPD/ZAPD/ZTextureAnimation.cpp index 698054fa8..0c55b2609 100644 --- a/tools/ZAPD/ZAPD/ZTextureAnimation.cpp +++ b/tools/ZAPD/ZAPD/ZTextureAnimation.cpp @@ -569,6 +569,7 @@ void ZTextureAnimation::DeclareReferences(const std::string& prefix) count = 2; } params = new TextureScrollingParams(parent); + params->type = entry.type; params->ExtractFromBinary(paramsOffset, count); break; @@ -582,6 +583,7 @@ void ZTextureAnimation::DeclareReferences(const std::string& prefix) case TextureAnimationParamsType::TextureCycle: params = new TextureCyclingParams(parent); + params->type = entry.type; params->ExtractFromBinary(paramsOffset); break; diff --git a/tools/asm-differ/.gitignore b/tools/asm-differ/.gitignore index eb176dc56..a2b216fea 100644 --- a/tools/asm-differ/.gitignore +++ b/tools/asm-differ/.gitignore @@ -1,2 +1,4 @@ .mypy_cache/ __pycache__/ +.vscode/ +poetry.lock diff --git a/tools/asm-differ/.gitrepo b/tools/asm-differ/.gitrepo index 8d0a6445d..a23a9c1e4 100644 --- a/tools/asm-differ/.gitrepo +++ b/tools/asm-differ/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/simonlindholm/asm-differ branch = main - commit = 1236288d1520335c2bfb672078fec65084d7cb5c - parent = 2c5690701a350c7e7c3d6252dff925ad65d59910 + commit = ae408664a89ea4dc70d005d0afc69ac26c938cbb + parent = c833969ea79ba31c3103e25e94ef88098c0287de method = merge cmdver = 0.4.3 diff --git a/tools/asm-differ/.pre-commit-config.yaml b/tools/asm-differ/.pre-commit-config.yaml index ccc4afc0e..67ba03d12 100644 --- a/tools/asm-differ/.pre-commit-config.yaml +++ b/tools/asm-differ/.pre-commit-config.yaml @@ -1,5 +1,5 @@ repos: - repo: https://github.com/psf/black - rev: 22.1.0 + rev: 22.3.0 hooks: - id: black diff --git a/tools/asm-differ/README.md b/tools/asm-differ/README.md index 205310d39..1d0932c9b 100644 --- a/tools/asm-differ/README.md +++ b/tools/asm-differ/README.md @@ -7,7 +7,7 @@ Nice differ for assembly code. Currently supports MIPS, PPC, AArch64, and ARM32; ## Dependencies - Python >= 3.6 -- `python3 -m pip install --user colorama watchdog python-Levenshtein` (also `dataclasses` if on 3.6) +- `python3 -m pip install --user colorama watchdog levenshtein cxxfilt` (also `dataclasses` if on 3.6) ## Usage diff --git a/tools/asm-differ/diff.py b/tools/asm-differ/diff.py index 4b5bc892e..230dbaed7 100755 --- a/tools/asm-differ/diff.py +++ b/tools/asm-differ/diff.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # PYTHON_ARGCOMPLETE_OK import argparse +import enum import sys from typing import ( Any, @@ -28,6 +29,14 @@ def static_assert_unreachable(x: NoReturn) -> NoReturn: raise Exception("Unreachable! " + repr(x)) +class DiffMode(enum.Enum): + SINGLE = "single" + SINGLE_BASE = "single_base" + NORMAL = "normal" + THREEWAY_PREV = "3prev" + THREEWAY_BASE = "3base" + + # ==== COMMAND-LINE ==== if __name__ == "__main__": @@ -201,11 +210,11 @@ if __name__ == "__main__": ) parser.add_argument( "-s", - "--stop-jr-ra", - dest="stop_jrra", + "--stop-at-ret", + dest="stop_at_ret", action="store_true", - help="""Stop disassembling at the first 'jr ra'. Some functions have - multiple return points, so use with care!""", + help="""Stop disassembling at the first return instruction. + Some functions have multiple return points, so use with care!""", ) parser.add_argument( "-i", @@ -228,6 +237,13 @@ if __name__ == "__main__": action="store_false", help="Don't visualize branches/branch targets.", ) + parser.add_argument( + "-R", + "--no-show-rodata-refs", + dest="show_rodata_refs", + action="store_false", + help="Don't show .rodata -> .text references (typically from jump tables).", + ) parser.add_argument( "-S", "--base-shift", @@ -248,21 +264,37 @@ if __name__ == "__main__": help="""Automatically update when source/object files change. Recommended in combination with -m.""", ) + parser.add_argument( + "-0", + "--diff_mode=single_base", + dest="diff_mode", + action="store_const", + const=DiffMode.SINGLE_BASE, + help="""View the base asm only (not a diff).""", + ) + parser.add_argument( + "-1", + "--diff_mode=single", + dest="diff_mode", + action="store_const", + const=DiffMode.SINGLE, + help="""View the current asm only (not a diff).""", + ) parser.add_argument( "-3", "--threeway=prev", - dest="threeway", + dest="diff_mode", action="store_const", - const="prev", + const=DiffMode.THREEWAY_PREV, help="""Show a three-way diff between target asm, current asm, and asm prior to -w rebuild. Requires -w.""", ) parser.add_argument( "-b", "--threeway=base", - dest="threeway", + dest="diff_mode", action="store_const", - const="base", + const=DiffMode.THREEWAY_BASE, help="""Show a three-way diff between target asm, current asm, and asm when diff.py was started. Requires -w.""", ) @@ -336,11 +368,9 @@ if __name__ == "__main__": # (We do imports late to optimize auto-complete performance.) import abc -import ast from collections import Counter, defaultdict from dataclasses import asdict, dataclass, field, replace import difflib -import enum import html import itertools import json @@ -357,7 +387,7 @@ import traceback MISSING_PREREQUISITES = ( "Missing prerequisite python module {}. " - "Run `python3 -m pip install --user colorama watchdog python-Levenshtein cxxfilt` to install prerequisites (cxxfilt only needed with --source)." + "Run `python3 -m pip install --user colorama watchdog levenshtein cxxfilt` to install prerequisites (cxxfilt only needed with --source)." ) try: @@ -376,7 +406,8 @@ class ProjectSettings: objdump_flags: List[str] build_command: List[str] map_format: str - mw_build_dir: str + build_dir: str + ms_map_address_offset: int baseimg: Optional[str] myimg: Optional[str] mapfile: Optional[str] @@ -384,6 +415,8 @@ class ProjectSettings: source_extensions: List[str] show_line_numbers_default: bool disassemble_all: bool + reg_categories: Dict[str, int] + expected_dir: str @dataclass @@ -408,17 +441,19 @@ class Config: # Display options formatter: "Formatter" - threeway: Optional[str] + diff_mode: DiffMode base_shift: int skip_lines: int compress: Optional[Compress] + show_rodata_refs: bool show_branches: bool show_line_numbers: bool show_source: bool - stop_jrra: bool + stop_at_ret: bool ignore_large_imms: bool ignore_addr_diffs: bool algorithm: str + reg_categories: Dict[str, int] # Score options score_stack_differences = True @@ -444,10 +479,13 @@ def create_project_settings(settings: Dict[str, Any]) -> ProjectSettings: ), objdump_executable=get_objdump_executable(settings.get("objdump_executable")), objdump_flags=settings.get("objdump_flags", []), + expected_dir=settings.get("expected_dir", "expected/"), map_format=settings.get("map_format", "gnu"), - mw_build_dir=settings.get("mw_build_dir", "build/"), + ms_map_address_offset=settings.get("ms_map_address_offset", 0), + build_dir=settings.get("build_dir", settings.get("mw_build_dir", "build/")), show_line_numbers_default=settings.get("show_line_numbers_default", True), disassemble_all=settings.get("disassemble_all", False), + reg_categories=settings.get("reg_categories", {}), ) @@ -493,19 +531,21 @@ def create_config(args: argparse.Namespace, project: ProjectSettings) -> Config: max_function_size_bytes=args.max_lines * 4, # Display options formatter=formatter, - threeway=args.threeway, + diff_mode=args.diff_mode or DiffMode.NORMAL, base_shift=eval_int( args.base_shift, "Failed to parse --base-shift (-S) argument as an integer." ), skip_lines=args.skip_lines, compress=compress, + show_rodata_refs=args.show_rodata_refs, show_branches=args.show_branches, show_line_numbers=show_line_numbers, show_source=args.show_source or args.source_old_binutils, - stop_jrra=args.stop_jrra, + stop_at_ret=args.stop_at_ret, ignore_large_imms=args.ignore_large_imms, ignore_addr_diffs=args.ignore_addr_diffs, algorithm=args.algorithm, + reg_categories=project.reg_categories, ) @@ -563,6 +603,7 @@ class BasicFormat(enum.Enum): IMMEDIATE = enum.auto() STACK = enum.auto() REGISTER = enum.auto() + REGISTER_CATEGORY = enum.auto() DELAY_SLOT = enum.auto() DIFF_CHANGE = enum.auto() DIFF_ADD = enum.auto() @@ -662,11 +703,19 @@ class Text: @dataclass -class TableMetadata: +class TableLine: + key: Optional[str] + is_data_ref: bool + cells: Tuple[Tuple[Text, Optional["Line"]], ...] + + +@dataclass +class TableData: headers: Tuple[Text, ...] current_score: int max_score: int previous_score: Optional[int] + lines: List[TableLine] class Formatter(abc.ABC): @@ -676,7 +725,7 @@ class Formatter(abc.ABC): ... @abc.abstractmethod - def table(self, meta: TableMetadata, lines: List[Tuple["OutputLine", ...]]) -> str: + def table(self, data: TableData) -> str: """Format a multi-column table with metadata""" ... @@ -684,8 +733,8 @@ class Formatter(abc.ABC): return "".join(self.apply_format(chunk, f) for chunk, f in text.segments) @staticmethod - def outputline_texts(lines: Tuple["OutputLine", ...]) -> Tuple[Text, ...]: - return tuple([lines[0].base or Text()] + [line.fmt2 for line in lines[1:]]) + def outputline_texts(line: TableLine) -> Tuple[Text, ...]: + return tuple(cell[0] for cell in line.cells) @dataclass @@ -695,8 +744,8 @@ class PlainFormatter(Formatter): def apply_format(self, chunk: str, f: Format) -> str: return chunk - def table(self, meta: TableMetadata, lines: List[Tuple["OutputLine", ...]]) -> str: - rows = [meta.headers] + [self.outputline_texts(ls) for ls in lines] + def table(self, data: TableData) -> str: + rows = [data.headers] + [self.outputline_texts(line) for line in data.lines] return "\n".join( "".join(self.apply(x.ljust(self.column_width)) for x in row) for row in rows ) @@ -709,12 +758,14 @@ class AnsiFormatter(Formatter): STYLE_UNDERLINE = "\x1b[4m" STYLE_NO_UNDERLINE = "\x1b[24m" STYLE_INVERT = "\x1b[7m" + STYLE_RESET = "\x1b[0m" BASIC_ANSI_CODES = { BasicFormat.NONE: "", BasicFormat.IMMEDIATE: Fore.LIGHTBLUE_EX, BasicFormat.STACK: Fore.YELLOW, BasicFormat.REGISTER: Fore.YELLOW, + BasicFormat.REGISTER_CATEGORY: Fore.LIGHTYELLOW_EX, BasicFormat.DELAY_SLOT: Fore.LIGHTBLACK_EX, BasicFormat.DIFF_CHANGE: Fore.LIGHTBLUE_EX, BasicFormat.DIFF_ADD: Fore.GREEN, @@ -761,14 +812,19 @@ class AnsiFormatter(Formatter): static_assert_unreachable(f) return f"{ansi_code}{chunk}{undo_ansi_code}" - def table(self, meta: TableMetadata, lines: List[Tuple["OutputLine", ...]]) -> str: - rows = [(meta.headers, False)] + [ - (self.outputline_texts(line), line[1].is_data_ref) for line in lines + def table(self, data: TableData) -> str: + rows = [(data.headers, False)] + [ + ( + self.outputline_texts(line), + line.is_data_ref, + ) + for line in data.lines ] return "\n".join( "".join( (self.STYLE_INVERT if is_data_ref else "") + self.apply(x.ljust(self.column_width)) + + (self.STYLE_RESET if is_data_ref else "") for x in row ) for (row, is_data_ref) in rows @@ -794,7 +850,7 @@ class HtmlFormatter(Formatter): static_assert_unreachable(f) return f"{chunk}" - def table(self, meta: TableMetadata, lines: List[Tuple["OutputLine", ...]]) -> str: + def table(self, data: TableData) -> str: def table_row(line: Tuple[Text, ...], is_data_ref: bool, cell_el: str) -> str: tr_attrs = " class='data-ref'" if is_data_ref else "" output_row = f" " @@ -806,12 +862,12 @@ class HtmlFormatter(Formatter): output = "\n" output += " \n" - output += table_row(meta.headers, False, "th") + output += table_row(data.headers, False, "th") output += " \n" output += " \n" output += "".join( - table_row(self.outputline_texts(line), line[1].is_data_ref, "td") - for line in lines + table_row(self.outputline_texts(line), line.is_data_ref, "td") + for line in data.lines ) output += " \n" output += "
\n" @@ -826,7 +882,7 @@ class JsonFormatter(Formatter): # This method is unused by this formatter return NotImplemented - def table(self, meta: TableMetadata, rows: List[Tuple["OutputLine", ...]]) -> str: + def table(self, data: TableData) -> str: def serialize_format(s: str, f: Format) -> Dict[str, Any]: if f == BasicFormat.NONE: return {"text": s} @@ -844,29 +900,25 @@ class JsonFormatter(Formatter): return [] return [serialize_format(s, f) for s, f in text.segments] - is_threeway = len(meta.headers) == 3 - output: Dict[str, Any] = {} output["arch_str"] = self.arch_str output["header"] = { name: serialize(h) - for h, name in zip(meta.headers, ("base", "current", "previous")) + for h, name in zip(data.headers, ("base", "current", "previous")) } - output["current_score"] = meta.current_score - output["max_score"] = meta.max_score - if meta.previous_score is not None: - output["previous_score"] = meta.previous_score + output["current_score"] = data.current_score + output["max_score"] = data.max_score + if data.previous_score is not None: + output["previous_score"] = data.previous_score output_rows: List[Dict[str, Any]] = [] - for row in rows: + for row in data.lines: output_row: Dict[str, Any] = {} - output_row["key"] = row[0].key2 - output_row["is_data_ref"] = row[1].is_data_ref - iters = [ - ("base", row[0].base, row[0].line1), - ("current", row[1].fmt2, row[1].line2), + output_row["key"] = row.key + output_row["is_data_ref"] = row.is_data_ref + iters: List[Tuple[str, Text, Optional[Line]]] = [ + (label, *cell) + for label, cell in zip(("base", "current", "previous"), row.cells) ] - if is_threeway: - iters.append(("previous", row[2].fmt2, row[2].line2)) if all(line is None for _, _, line in iters): # Skip rows that were only for displaying source code continue @@ -935,10 +987,41 @@ def symbol_formatter(group: str, base_index: int) -> FormatFunction: ObjdumpCommand = Tuple[List[str], str, Optional[str]] +# eval_expr adapted from https://stackoverflow.com/a/9558001 + +import ast +import operator as op + +# supported operators +operators: Dict[Type[Union[ast.operator, ast.unaryop]], Any] = { + ast.Add: op.add, + ast.Sub: op.sub, + ast.Mult: op.mul, + ast.Div: op.truediv, + ast.Pow: op.pow, + ast.BitXor: op.xor, + ast.USub: op.neg, +} + + +def eval_expr(expr: str) -> Any: + return eval_(ast.parse(expr, mode="eval").body) + + +def eval_(node: ast.AST) -> Any: + if isinstance(node, ast.Num): # + return node.n + elif isinstance(node, ast.BinOp): # + return operators[type(node.op)](eval_(node.left), eval_(node.right)) + elif isinstance(node, ast.UnaryOp): # e.g., -1 + return operators[type(node.op)](eval_(node.operand)) + else: + raise TypeError(node) + def maybe_eval_int(expr: str) -> Optional[int]: try: - ret = ast.literal_eval(expr) + ret = eval_expr(expr) if not isinstance(ret, int): raise Exception("not an integer") return ret @@ -1056,7 +1139,7 @@ def preprocess_objdump_out( out = out[out.find("\n") + 1 :] out = out.rstrip("\n") - if obj_data: + if obj_data and config.show_rodata_refs: out = ( serialize_rodata_references(parse_elf_rodata_references(obj_data, config)) + out @@ -1065,8 +1148,27 @@ def preprocess_objdump_out( return out +def search_build_objects(objname: str, project: ProjectSettings) -> Optional[str]: + objfiles = [ + os.path.join(dirpath, f) + for dirpath, _, filenames in os.walk(project.build_dir) + for f in filenames + if f == objname + ] + if len(objfiles) > 1: + all_objects = "\n".join(objfiles) + fail( + f"Found multiple objects of the same name {objname} in {project.build_dir}, " + f"cannot determine which to diff against: \n{all_objects}" + ) + if len(objfiles) == 1: + return objfiles[0] + + return None + + def search_map_file( - fn_name: str, project: ProjectSettings, config: Config + fn_name: str, project: ProjectSettings, config: Config, *, for_binary: bool ) -> Tuple[Optional[str], Optional[int]]: if not project.mapfile: fail(f"No map file configured; cannot find function {fn_name}.") @@ -1078,6 +1180,12 @@ def search_map_file( fail(f"Failed to open map file {project.mapfile} for reading.") if project.map_format == "gnu": + if for_binary and "load address" not in contents: + fail( + 'Failed to find "load address" in map file. Maybe you need to add\n' + '"export LANG := C" to your Makefile to avoid localized output?' + ) + lines = contents.split("\n") try: @@ -1093,10 +1201,12 @@ def search_map_file( ram = int(tokens[1], 0) rom = int(tokens[5], 0) ram_to_rom = rom - ram - if line.endswith(" " + fn_name): + if line.endswith(" " + fn_name) or f" {fn_name} = 0x" in line: ram = int(line.split()[0], 0) - if cur_objfile is not None and ram_to_rom is not None: - cands.append((cur_objfile, ram + ram_to_rom)) + if (for_binary and ram_to_rom is not None) or ( + not for_binary and cur_objfile is not None + ): + cands.append((cur_objfile, ram + (ram_to_rom or 0))) last_line = line except Exception as e: traceback.print_exc() @@ -1108,16 +1218,14 @@ def search_map_file( return cands[0] elif project.map_format == "mw": find = re.findall( - re.compile( - # ram elf rom - r" \S+ \S+ (\S+) (\S+) . " - + re.escape(fn_name) - + r"(?: \(entry of " - + re.escape(config.diff_section) - + r"\))? \t" - # object name - + "(\S+)" - ), + # ram elf rom alignment + r" \S+ \S+ (\S+) (\S+) +\S+ " + + re.escape(fn_name) + + r"(?: \(entry of " + + re.escape(config.diff_section) + + r"\))? \t" + # object name + + "(\S+)", contents, ) if len(find) > 1: @@ -1125,27 +1233,56 @@ def search_map_file( if len(find) == 1: rom = int(find[0][1], 16) objname = find[0][2] - # The metrowerks linker map format does not contain the full object path, - # so we must complete it manually. - objfiles = [ - os.path.join(dirpath, f) - for dirpath, _, filenames in os.walk(project.mw_build_dir) - for f in filenames - if f == objname - ] - if len(objfiles) > 1: - all_objects = "\n".join(objfiles) - fail( - f"Found multiple objects of the same name {objname} in {project.mw_build_dir}, " - f"cannot determine which to diff against: \n{all_objects}" - ) - if len(objfiles) == 1: - objfile = objfiles[0] - # TODO Currently the ram-rom conversion only works for diffing ELF - # executables, but it would likely be more convenient to diff DOLs. - # At this time it is recommended to always use -o when running the diff - # script as this mode does not make use of the ram-rom conversion. + objfile = search_build_objects(objname, project) + + # TODO Currently the ram-rom conversion only works for diffing ELF + # executables, but it would likely be more convenient to diff DOLs. + # At this time it is recommended to always use -o when running the diff + # script as this mode does not make use of the ram-rom conversion. + if objfile is not None: return objfile, rom + elif project.map_format == "ms": + load_address_find = re.search( + r"Preferred load address is ([0-9a-f]+)", + contents, + ) + if not load_address_find: + fail(f"Couldn't find module load address in map file.") + load_address = int(load_address_find.group(1), 16) + + diff_segment_find = re.search( + r"([0-9a-f]+):[0-9a-f]+ [0-9a-f]+H " + re.escape(config.diff_section), + contents, + ) + if not diff_segment_find: + fail(f"Couldn't find segment for section in map file.") + diff_segment = diff_segment_find.group(1) + + find = re.findall( + r" (?:" + + re.escape(diff_segment) + + r")\S+\s+(?:" + + re.escape(fn_name) + + r")\s+\S+ ... \S+", + contents, + ) + if len(find) > 1: + fail(f"Found multiple occurrences of function {fn_name} in map file.") + if len(find) == 1: + names_find = re.search(r"(\S+) ... (\S+)", find[0]) + assert names_find is not None + fileofs = ( + int(names_find.group(1), 16) + - load_address + + project.ms_map_address_offset + ) + if for_binary: + return None, fileofs + + objname = names_find.group(2) + objfile = search_build_objects(objname, project) + if objfile is not None: + return objfile, fileofs else: fail(f"Linker map format {project.map_format} unrecognised.") return None, None @@ -1161,6 +1298,8 @@ def parse_elf_rodata_references( SHT_SYMTAB = 2 SHT_REL = 9 SHT_RELA = 4 + R_MIPS_32 = 2 + R_MIPS_GPREL32 = 12 is_32bit = e_ident[4] == 1 is_little_endian = e_ident[5] == 1 @@ -1234,7 +1373,7 @@ def parse_elf_rodata_references( # Skip section_name -> section_name references continue sec_name = sec_names[s.sh_info].decode("latin1") - if sec_name != ".rodata": + if sec_name not in (".rodata", ".late_rodata"): continue sec_base = sections[s.sh_info].sh_offset for i in range(0, s.sh_size, s.sh_entsize): @@ -1259,7 +1398,7 @@ def parse_elf_rodata_references( ) if st_shndx == text_section: if s.sh_type == SHT_REL: - if e_machine == 8 and r_type == 2: # R_MIPS_32 + if e_machine == 8 and r_type in (R_MIPS_32, R_MIPS_GPREL32): (r_addend,) = read("I", sec_base + r_offset) else: continue @@ -1325,7 +1464,7 @@ def dump_objfile( objfile = config.objfile if not objfile: - objfile, _ = search_map_file(start, project, config) + objfile, _ = search_map_file(start, project, config, for_binary=False) if not objfile: fail("Not able to find .o file for function.") @@ -1336,8 +1475,8 @@ def dump_objfile( if not os.path.isfile(objfile): fail(f"Not able to find .o file for function: {objfile} is not a file.") - refobjfile = "expected/" + objfile - if not os.path.isfile(refobjfile): + refobjfile = os.path.join(project.expected_dir, objfile) + if config.diff_mode != DiffMode.SINGLE and not os.path.isfile(refobjfile): fail(f'Please ensure an OK .o file exists at "{refobjfile}".') if project.disassemble_all: @@ -1362,7 +1501,7 @@ def dump_binary( run_make(project.myimg, project) start_addr = maybe_eval_int(start) if start_addr is None: - _, start_addr = search_map_file(start, project, config) + _, start_addr = search_map_file(start, project, config, for_binary=True) if start_addr is None: fail("Not able to find function in map file.") if end is not None: @@ -1391,8 +1530,13 @@ class AsmProcessor: def __init__(self, config: Config) -> None: self.config = config - def process_reloc(self, row: str, prev: str) -> str: - return prev + def pre_process( + self, mnemonic: str, args: str, next_row: Optional[str] + ) -> Tuple[str, str]: + return mnemonic, args + + def process_reloc(self, row: str, prev: str) -> Tuple[str, Optional[str]]: + return prev, None def normalize(self, mnemonic: str, row: str) -> str: """This should be called exactly once for each line.""" @@ -1408,28 +1552,24 @@ class AsmProcessor: def post_process(self, lines: List["Line"]) -> None: return + def is_end_of_function(self, mnemonic: str, args: str) -> bool: + return False + class AsmProcessorMIPS(AsmProcessor): - def process_reloc(self, row: str, prev: str) -> str: + def __init__(self, config: Config) -> None: + super().__init__(config) + self.seen_jr_ra = False + + def process_reloc(self, row: str, prev: str) -> Tuple[str, Optional[str]]: arch = self.config.arch if "R_MIPS_NONE" in row or "R_MIPS_JALR" in row: # GNU as emits no-op relocations immediately after real ones when # assembling with -mabi=64. Return without trying to parse 'imm' as an # integer. - return prev + return prev, None before, imm, after = parse_relocated_line(prev) - repl = row.split()[-1] - if imm != "0": - # MIPS uses relocations with addends embedded in the code as immediates. - # If there is an immediate, show it as part of the relocation. Ideally - # we'd show this addend in both %lo/%hi, but annoyingly objdump's output - # doesn't include enough information to pair up %lo's and %hi's... - # TODO: handle unambiguous cases where all addends for a symbol are the - # same, or show "+???". - mnemonic = prev.split()[0] - if mnemonic in arch.instructions_with_address_immediates: - imm = hex(int(imm, 16)) - repl += ("" if imm.startswith("-") else "+") + imm + repl = row.split()[-1] + reloc_addend_from_imm(imm, before, self.config.arch) if "R_MIPS_LO16" in row: repl = f"%lo({repl})" elif "R_MIPS_HI16" in row: @@ -1452,20 +1592,57 @@ class AsmProcessorMIPS(AsmProcessor): repl = f"%call16({repl})" else: assert False, f"unknown relocation type '{row}' for line '{prev}'" - return before + repl + after + return before + repl + after, repl + + def is_end_of_function(self, mnemonic: str, args: str) -> bool: + if self.seen_jr_ra: + return True + if mnemonic == "jr" and args == "ra": + self.seen_jr_ra = True + return False class AsmProcessorPPC(AsmProcessor): - def process_reloc(self, row: str, prev: str) -> str: + def pre_process( + self, mnemonic: str, args: str, next_row: Optional[str] + ) -> Tuple[str, str]: + + if next_row and "R_PPC_EMB_SDA21" in next_row: + # With sda21 relocs, the linker transforms `r0` into `r2`/`r13`, and + # we may encounter this in either pre-transformed or post-transformed + # versions depending on if the .o file comes from compiler output or + # from disassembly. Normalize, to make sure both forms are treated as + # equivalent. + + args = args.replace("(r2)", "(0)") + args = args.replace("(r13)", "(0)") + args = args.replace(",r2,", ",0,") + args = args.replace(",r13,", ",0,") + + # We want to convert li and lis with an sda21 reloc, + # because the r0 to r2/r13 transformation results in + # turning an li/lis into an addi/addis with r2/r13 arg + # our preprocessing normalizes all versions to addi with a 0 arg + if mnemonic in {"li", "lis"}: + mnemonic = mnemonic.replace("li", "addi") + args_parts = args.split(",") + args = args_parts[0] + ",0," + args_parts[1] + + return mnemonic, args + + def process_reloc(self, row: str, prev: str) -> Tuple[str, Optional[str]]: arch = self.config.arch assert any( - r in row for r in ["R_PPC_REL24", "R_PPC_ADDR16", "R_PPC_EMB_SDA21"] + r in row + for r in ["R_PPC_REL24", "R_PPC_ADDR16", "R_PPC_EMB_SDA21", "R_PPC_REL14"] ), f"unknown relocation type '{row}' for line '{prev}'" before, imm, after = parse_relocated_line(prev) repl = row.split()[-1] if "R_PPC_REL24" in row: # function calls pass + if "R_PPC_REL14" in row: + pass elif "R_PPC_ADDR16_HI" in row: # absolute hi of addr repl = f"{repl}@h" @@ -1483,17 +1660,30 @@ class AsmProcessorPPC(AsmProcessor): if int(repl.split("+")[1], 16) > 0x70000000: repl = repl.split("+")[0] elif "R_PPC_EMB_SDA21" in row: - # small data area - pass - return before + repl + after + # sda21 relocations; r2/r13 --> 0 swaps are performed in pre_process + repl = f"{repl}@sda21" + + return before + repl + after, repl + + def is_end_of_function(self, mnemonic: str, args: str) -> bool: + return mnemonic == "blr" class AsmProcessorARM32(AsmProcessor): - def process_reloc(self, row: str, prev: str) -> str: + def process_reloc(self, row: str, prev: str) -> Tuple[str, Optional[str]]: arch = self.config.arch + if "R_ARM_V4BX" in row: + # R_ARM_V4BX converts "bx " to "mov pc," for some targets. + # Ignore for now. + return prev, None + if "R_ARM_ABS32" in row and not prev.startswith(".word"): + # Don't crash on R_ARM_ABS32 relocations incorrectly applied to code. + # (We may want to do something more fancy here that actually shows the + # related symbol, but this serves as a stop-gap.) + return prev, None before, imm, after = parse_relocated_line(prev) - repl = row.split()[-1] - return before + repl + after + repl = row.split()[-1] + reloc_addend_from_imm(imm, before, self.config.arch) + return before + repl + after, repl def _normalize_arch_specific(self, mnemonic: str, row: str) -> str: if self.config.ignore_addr_diffs: @@ -1577,6 +1767,51 @@ class AsmProcessorAArch64(AsmProcessor): return row +class AsmProcessorI686(AsmProcessor): + def process_reloc(self, row: str, prev: str) -> Tuple[str, Optional[str]]: + repl = row.split()[-1] + mnemonic, args = prev.split(maxsplit=1) + + addr_imm = re.search(r"(? bool: + return mnemonic == "ret" + + @dataclass class ArchSettings: name: str @@ -1701,6 +1936,76 @@ PPC_BRANCH_INSTRUCTIONS = { "bgt-", } +I686_BRANCH_INSTRUCTIONS = { + "call", + "jmp", + "ljmp", + "ja", + "jae", + "jb", + "jbe", + "jc", + "jcxz", + "jecxz", + "jrcxz", + "je", + "jg", + "jge", + "jl", + "jle", + "jna", + "jnae", + "jnb", + "jnbe", + "jnc", + "jne", + "jng", + "jnge", + "jnl", + "jnle", + "jno", + "jnp", + "jns", + "jnz", + "jo", + "jp", + "jpe", + "jpo", + "js", + "jz", + "ja", + "jae", + "jb", + "jbe", + "jc", + "je", + "jz", + "jg", + "jge", + "jl", + "jle", + "jna", + "jnae", + "jnb", + "jnbe", + "jnc", + "jne", + "jng", + "jnge", + "jnl", + "jnle", + "jno", + "jnp", + "jns", + "jnz", + "jo", + "jp", + "jpe", + "jpo", + "js", + "jz", +} + MIPS_SETTINGS = ArchSettings( name="mips", re_int=re.compile(r"[0-9]+"), @@ -1713,18 +2018,26 @@ MIPS_SETTINGS = ArchSettings( re_reg=re.compile(r"\$?\b([astv][0-9]|at|f[astv]?[0-9]+f?|kt?[01]|fp|ra|zero)\b"), re_sprel=re.compile(r"(?<=,)([0-9]+|0x[0-9a-f]+)\(sp\)"), re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), - re_imm=re.compile(r"(\b|-)([0-9]+|0x[0-9a-fA-F]+)\b(?!\(sp)|%(lo|hi)\([^)]*\)"), + re_imm=re.compile( + r"(\b|-)([0-9]+|0x[0-9a-fA-F]+)\b(?!\(sp)|%(lo|hi|got|gp_rel|call16)\([^)]*\)" + ), re_reloc=re.compile(r"R_MIPS_"), arch_flags=["-m", "mips:4300"], branch_likely_instructions=MIPS_BRANCH_LIKELY_INSTRUCTIONS, branch_instructions=MIPS_BRANCH_INSTRUCTIONS, - instructions_with_address_immediates=MIPS_BRANCH_INSTRUCTIONS.union({"jal", "j"}), + instructions_with_address_immediates=MIPS_BRANCH_INSTRUCTIONS.union({"j", "jal"}), delay_slot_instructions=MIPS_BRANCH_INSTRUCTIONS.union({"j", "jal", "jr", "jalr"}), proc=AsmProcessorMIPS, ) MIPSEL_SETTINGS = replace(MIPS_SETTINGS, name="mipsel", big_endian=False) +MIPSEE_SETTINGS = replace( + MIPSEL_SETTINGS, name="mipsee", arch_flags=["-m", "mips:5900"] +) + +MIPS_ARCH_NAMES = {"mips", "mipsel", "mipsee"} + ARM32_SETTINGS = ArchSettings( name="arm32", re_int=re.compile(r"[0-9]+"), @@ -1773,23 +2086,56 @@ PPC_SETTINGS = ArchSettings( name="ppc", re_int=re.compile(r"[0-9]+"), re_comment=re.compile(r"(<.*>|//.*$)"), - re_reg=re.compile(r"\$?\b([rf][0-9]+)\b"), + # r1 not included + re_reg=re.compile(r"\$?\b([rf](?:[02-9]|[1-9][0-9]+)|f1)\b"), re_sprel=re.compile(r"(?<=,)(-?[0-9]+|-?0x[0-9a-f]+)\(r1\)"), re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), - re_imm=re.compile(r"(\b|-)([0-9]+|0x[0-9a-fA-F]+)\b(?!\(r1)|[^@]*@(ha|h|lo)"), + re_imm=re.compile( + r"(\b|-)([0-9]+|0x[0-9a-fA-F]+)\b(?!\(r1)|[^ \t,]+@(l|ha|h|sda21)" + ), re_reloc=re.compile(r"R_PPC_"), + arch_flags=["-m", "powerpc", "-M", "broadway"], branch_instructions=PPC_BRANCH_INSTRUCTIONS, instructions_with_address_immediates=PPC_BRANCH_INSTRUCTIONS.union({"bl"}), proc=AsmProcessorPPC, ) +I686_SETTINGS = ArchSettings( + name="i686", + re_int=re.compile(r"[0-9]+"), + re_comment=re.compile(r"<.*>"), + # Includes: + # - (e)a-d(x,l,h) + # - (e)s,d,b(i,p)(l) + # - cr0-7 + # - x87 st + # - MMX, SSE vector registers + # - cursed registers: eal ebl ebh edl edh... + re_reg=re.compile( + r"\%?\b(e?(([sd]i|[sb]p)l?|[abcd][xhl])|[cdesfg]s|cr[0-7]|x?mm[0-7]|st)\b" + ), + re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), + re_sprel=re.compile(r"-?(0x[0-9a-f]+|[0-9]+)(?=\((%ebp|%esi)\))"), + re_imm=re.compile(r"-?(0x[0-9a-f]+|[0-9]+)"), + re_reloc=re.compile(r"R_386_"), + # The x86 architecture has a variable instruction length. The raw bytes of + # an instruction as displayed by objdump can line wrap if it's long enough. + # This destroys the objdump output processor logic, so we avoid this. + arch_flags=["-m", "i386", "--no-show-raw-insn"], + branch_instructions=I686_BRANCH_INSTRUCTIONS, + instructions_with_address_immediates=I686_BRANCH_INSTRUCTIONS.union({"mov"}), + proc=AsmProcessorI686, +) + ARCH_SETTINGS = [ MIPS_SETTINGS, MIPSEL_SETTINGS, + MIPSEE_SETTINGS, ARM32_SETTINGS, ARMEL_SETTINGS, AARCH64_SETTINGS, PPC_SETTINGS, + I686_SETTINGS, ] @@ -1822,11 +2168,31 @@ def parse_relocated_line(line: str) -> Tuple[str, str, str]: imm, after = after, "" else: imm, after = after[:ind2], after[ind2:] - if imm == "0x0": - imm = "0" return before, imm, after +def reloc_addend_from_imm(imm: str, before: str, arch: ArchSettings) -> str: + """For architectures like MIPS where relocations have addends embedded in + the code as immediates, convert such an immediate into an addition/ + subtraction that can occur just after the symbol.""" + # TODO this is incorrect for MIPS %lo/%hi which need to be paired up + # and combined. In practice, this means we only get symbol offsets within + # %lo, while %hi just shows the symbol. Unfortunately, objdump's output + # loses relocation order, so we cannot do this without parsing ELF relocs + # ourselves... + mnemonic = before.split()[0] + if mnemonic in arch.instructions_with_address_immediates: + addend = int(imm, 16) + else: + addend = int(imm, 0) + if addend == 0: + return "" + elif addend < 0: + return hex(addend) + else: + return "+" + hex(addend) + + def pad_mnemonic(line: str) -> str: if "\t" not in line: return line @@ -1841,6 +2207,7 @@ class Line: original: str normalized_original: str scorable_line: str + symbol: Optional[str] = None line_num: Optional[int] = None branch_target: Optional[int] = None data_pool_addr: Optional[int] = None @@ -1896,10 +2263,8 @@ def process(dump: str, config: Config) -> List[Line]: if not re.match(r"^\s+[0-9a-f]+:\s+", row): # This regex is conservative, and assumes the file path does not contain "weird" - # characters like colons, tabs, or angle brackets. - if re.match( - r"^[^ \t<>:][^\t<>:]*:[0-9]+( \(discriminator [0-9]+\))?$", row - ): + # characters like tabs or angle brackets. + if re.match(r"^[^ \t<>][^\t<>]*:[0-9]+( \(discriminator [0-9]+\))?$", row): source_filename, _, tail = row.rpartition(":") source_line_num = int(tail.partition(" ")[0]) source_lines.append(row) @@ -1919,9 +2284,14 @@ def process(dump: str, config: Config) -> List[Line]: line_num_str = row.split(":")[0] row = row.rstrip() tabs = row.split("\t") - row = "\t".join(tabs[2:]) line_num = eval_line_num(line_num_str.strip()) + # TODO: use --no-show-raw-insn for all arches + if arch.name == "i686": + row = "\t".join(tabs[1:]) + else: + row = "\t".join(tabs[2:]) + if line_num in data_refs: refs = data_refs[line_num] ref_str = "; ".join( @@ -1943,7 +2313,13 @@ def process(dump: str, config: Config) -> List[Line]: else: # powerpc-eabi-objdump doesn't use tabs row_parts = [part.lstrip() for part in row.split(" ", 1)] + mnemonic = row_parts[0].strip() + args = row_parts[1].strip() if len(row_parts) >= 2 else "" + + next_line = lines[i] if i < len(lines) else None + mnemonic, args = processor.pre_process(mnemonic, args, next_line) + row = mnemonic + "\t" + args.replace("\t", " ") addr = "" if mnemonic in arch.instructions_with_address_immediates: @@ -1960,14 +2336,28 @@ def process(dump: str, config: Config) -> List[Line]: # immediates. original = row + symbol = None while i < len(lines): reloc_row = lines[i] if re.search(arch.re_reloc, reloc_row): - original = processor.process_reloc(reloc_row, original) + original, reloc_symbol = processor.process_reloc(reloc_row, original) + if reloc_symbol is not None: + symbol = reloc_symbol else: break i += 1 + is_text_relative_j = False + if ( + arch.name in MIPS_ARCH_NAMES + and mnemonic == "j" + and symbol is not None + and symbol.startswith(".text") + ): + symbol = None + original = row + is_text_relative_j = True + normalized_original = processor.normalize(mnemonic, original) scorable_line = normalized_original @@ -1993,8 +2383,16 @@ def process(dump: str, config: Config) -> List[Line]: row = normalize_imms(row, arch) branch_target = None - if mnemonic in arch.branch_instructions: - branch_target = int(row_parts[1].strip().split(",")[-1], 16) + if ( + mnemonic in arch.branch_instructions or is_text_relative_j + ) and symbol is None: + x86_longjmp = re.search(r"\*(.*)\(", args) + if x86_longjmp: + capture = x86_longjmp.group(1) + if capture != "": + branch_target = int(capture, 16) + else: + branch_target = int(args.split(",")[-1], 16) output.append( Line( @@ -2003,6 +2401,7 @@ def process(dump: str, config: Config) -> List[Line]: original=original, normalized_original=normalized_original, scorable_line=scorable_line, + symbol=symbol, line_num=line_num, branch_target=branch_target, data_pool_addr=data_pool_addr, @@ -2015,9 +2414,7 @@ def process(dump: str, config: Config) -> List[Line]: num_instr += 1 source_lines = [] - if config.stop_jrra and mnemonic == "jr" and row_parts[1].strip() == "ra": - stop_after_delay_slot = True - elif stop_after_delay_slot: + if config.stop_at_ret and processor.is_end_of_function(mnemonic, args): break processor.post_process(output) @@ -2032,9 +2429,44 @@ def normalize_stack(row: str, arch: ArchSettings) -> str: return re.sub(arch.re_sprel, "addr(sp)", row) -def imm_matches_everything(row: str, arch: ArchSettings) -> bool: - # (this should probably be arch-specific) - return "(." in row +def check_for_symbol_mismatch( + old_line: Line, new_line: Line, symbol_map: Dict[str, str] +) -> bool: + + assert old_line.symbol is not None + assert new_line.symbol is not None + + if new_line.symbol.startswith("%hi"): + return False + + if old_line.symbol not in symbol_map: + symbol_map[old_line.symbol] = new_line.symbol + return False + elif symbol_map[old_line.symbol] == new_line.symbol: + return False + + return True + + +def field_matches_any_symbol(field: str, arch: ArchSettings) -> bool: + if arch.name == "ppc": + if "..." in field: + return True + + parts = field.rsplit("@", 1) + if len(parts) == 2 and parts[1] in {"l", "h", "ha", "sda21"}: + field = parts[0] + + return re.fullmatch((r"^@\d+$"), field) is not None + + if arch.name in MIPS_ARCH_NAMES: + return "." in field + + # Example: ".text+0x34" + if arch.name == "arm32": + return "." in field + + return False def split_off_address(line: str) -> Tuple[str, str]: @@ -2058,15 +2490,10 @@ def diff_sequences_difflib( def diff_sequences( seq1: List[str], seq2: List[str], algorithm: str ) -> List[Tuple[str, int, int, int, int]]: - if ( - algorithm != "levenshtein" - or len(seq1) * len(seq2) > 4 * 10**8 - or len(seq1) + len(seq2) >= 0x110000 - ): + if algorithm != "levenshtein": return diff_sequences_difflib(seq1, seq2) # The Levenshtein library assumes that we compare strings, not lists. Convert. - # (Per the check above we know we have fewer than 0x110000 unique elements, so chr() works.) remapping: Dict[str, str] = {} def remap(seq: List[str]) -> str: @@ -2079,8 +2506,16 @@ def diff_sequences( seq[i] = val return "".join(seq) - rem1 = remap(seq1) - rem2 = remap(seq2) + try: + rem1 = remap(seq1) + rem2 = remap(seq2) + except ValueError as e: + if len(seq1) + len(seq2) < 0x110000: + raise + # If there are too many unique elements, chr() doesn't work. + # Assume this is the case and fall back to difflib. + return diff_sequences_difflib(seq1, seq2) + import Levenshtein ret: List[Tuple[str, int, int, int, int]] = Levenshtein.opcodes(rem1, rem2) @@ -2113,69 +2548,80 @@ def diff_lines( return ret +def diff_sameline( + old_line: Line, new_line: Line, config: Config, symbol_map: Dict[str, str] +) -> Tuple[int, int, bool]: + + old = old_line.scorable_line + new = new_line.scorable_line + if old == new: + return (0, 0, False) + + num_stack_penalties = 0 + num_regalloc_penalties = 0 + has_symbol_mismatch = False + + ignore_last_field = False + if config.score_stack_differences: + oldsp = re.search(config.arch.re_sprel, old) + newsp = re.search(config.arch.re_sprel, new) + if oldsp and newsp: + oldrel = int(oldsp.group(1) or "0", 0) + newrel = int(newsp.group(1) or "0", 0) + num_stack_penalties += abs(oldrel - newrel) + ignore_last_field = True + + # Probably regalloc difference, or signed vs unsigned + + # Compare each field in order + new_parts, old_parts = new.split(None, 1), old.split(None, 1) + newfields, oldfields = new_parts[1].split(","), old_parts[1].split(",") + if ignore_last_field: + newfields = newfields[:-1] + oldfields = oldfields[:-1] + else: + # If the last field has a parenthesis suffix, e.g. "0x38(r7)" + # we split that part out to make it a separate field + # however, we don't split if it has a proceeding % macro, e.g. "%lo(.data)" + re_paren = re.compile(r"(? int: # This logic is copied from `scorer.py` from the decomp permuter project # https://github.com/simonlindholm/decomp-permuter/blob/main/src/scorer.py - score = 0 + num_stack_penalties = 0 + num_regalloc_penalties = 0 + num_reordering_penalties = 0 + num_insertion_penalties = 0 + num_deletion_penalties = 0 deletions = [] insertions = [] - def lo_hi_match(old: str, new: str) -> bool: - # TODO: Make this arch-independent, like `imm_matches_everything()` - old_lo = old.find("%lo") - old_hi = old.find("%hi") - new_lo = new.find("%lo") - new_hi = new.find("%hi") - - if old_lo != -1 and new_lo != -1: - old_idx = old_lo - new_idx = new_lo - elif old_hi != -1 and new_hi != -1: - old_idx = old_hi - new_idx = new_hi - else: - return False - - if old[:old_idx] != new[:new_idx]: - return False - - old_inner = old[old_idx + 4 : -1] - new_inner = new[new_idx + 4 : -1] - return old_inner.startswith(".") or new_inner.startswith(".") - - def diff_sameline(old: str, new: str) -> None: - nonlocal score - if old == new: - return - - if lo_hi_match(old, new): - return - - ignore_last_field = False - if config.score_stack_differences: - oldsp = re.search(config.arch.re_sprel, old) - newsp = re.search(config.arch.re_sprel, new) - if oldsp and newsp: - oldrel = int(oldsp.group(1) or "0", 0) - newrel = int(newsp.group(1) or "0", 0) - score += abs(oldrel - newrel) * config.penalty_stackdiff - ignore_last_field = True - - # Probably regalloc difference, or signed vs unsigned - - # Compare each field in order - newfields, oldfields = new.split(","), old.split(",") - if ignore_last_field: - newfields = newfields[:-1] - oldfields = oldfields[:-1] - for nf, of in zip(newfields, oldfields): - if nf != of: - score += config.penalty_regalloc - # Penalize any extra fields - score += abs(len(newfields) - len(oldfields)) * config.penalty_regalloc - def diff_insert(line: str) -> None: # Reordering or totally different codegen. # Defer this until later when we can tell. @@ -2205,7 +2651,9 @@ def score_diff_lines( if max_index is not None and index > max_index: break if line1 and line2 and line1.mnemonic == line2.mnemonic: - diff_sameline(line1.scorable_line, line2.scorable_line) + sp, rp, _ = diff_sameline(line1, line2, config, symbol_map) + num_stack_penalties += sp + num_regalloc_penalties += rp else: if line1: diff_delete(line1.scorable_line) @@ -2218,13 +2666,17 @@ def score_diff_lines( ins = insertions_co[item] dels = deletions_co[item] common = min(ins, dels) - score += ( - (ins - common) * config.penalty_insertion - + (dels - common) * config.penalty_deletion - + config.penalty_reordering * common - ) + num_insertion_penalties += ins - common + num_deletion_penalties += dels - common + num_reordering_penalties += common - return score + return ( + num_stack_penalties * config.penalty_stackdiff + + num_regalloc_penalties * config.penalty_regalloc + + num_reordering_penalties * config.penalty_reordering + + num_insertion_penalties * config.penalty_insertion + + num_deletion_penalties * config.penalty_deletion + ) @dataclass(frozen=True) @@ -2262,6 +2714,7 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: arch = config.arch fmt = config.formatter output: List[OutputLine] = [] + symbol_map: Dict[str, str] = {} sc1 = symbol_formatter("base-reg", 0) sc2 = symbol_formatter("my-reg", 0) @@ -2287,7 +2740,6 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: lines2 = trim_nops(lines2, arch) diffed_lines = diff_lines(lines1, lines2, config.algorithm) - max_score = len(lines1) * config.penalty_deletion line_num_base = -1 line_num_offset = 0 @@ -2372,7 +2824,17 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: if normalize_imms(branchless1, arch) == normalize_imms( branchless2, arch ): - if imm_matches_everything(branchless2, arch): + ( + stack_penalties, + regalloc_penalties, + has_symbol_mismatch, + ) = diff_sameline(line1, line2, config, symbol_map) + + if ( + regalloc_penalties == 0 + and stack_penalties == 0 + and not has_symbol_mismatch + ): # ignore differences due to %lo(.rodata + ...) vs symbol out1 = out1.reformat(BasicFormat.NONE) out2 = out2.reformat(BasicFormat.NONE) @@ -2397,8 +2859,19 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: else: # reg differences and maybe imm as well out1, out2 = format_fields(arch.re_reg, out1, out2, sc1, sc2) - line_color1 = line_color2 = sym_color = BasicFormat.REGISTER - line_prefix = "r" + cats = config.reg_categories + if cats and any( + cats.get(of.group()) != cats.get(nf.group()) + for (of, nf) in zip( + out1.finditer(arch.re_reg), out2.finditer(arch.re_reg) + ) + ): + sym_color = BasicFormat.REGISTER_CATEGORY + line_prefix = "R" + else: + sym_color = BasicFormat.REGISTER + line_prefix = "r" + line_color1 = line_color2 = sym_color if same_target: address_imm_fmt = BasicFormat.NONE @@ -2523,8 +2996,10 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: ) ) - score = score_diff_lines(diffed_lines, config) output = output[config.skip_lines :] + + score = score_diff_lines(diffed_lines, config, symbol_map) + max_score = len(lines1) * config.penalty_deletion return Diff(lines=output, score=score, max_score=max_score) @@ -2586,24 +3061,12 @@ def compress_matching( return ret -def align_diffs( - old_diff: Diff, new_diff: Diff, config: Config -) -> Tuple[TableMetadata, List[Tuple[OutputLine, ...]]]: - meta: TableMetadata +def align_diffs(old_diff: Diff, new_diff: Diff, config: Config) -> TableData: + headers: Tuple[Text, ...] diff_lines: List[Tuple[OutputLine, ...]] padding = " " * 7 if config.show_line_numbers else " " * 2 - if config.threeway: - meta = TableMetadata( - headers=( - Text("TARGET"), - Text(f"{padding}CURRENT ({new_diff.score})"), - Text(f"{padding}PREVIOUS ({old_diff.score})"), - ), - current_score=new_diff.score, - max_score=new_diff.max_score, - previous_score=old_diff.score, - ) + if config.diff_mode in (DiffMode.THREEWAY_PREV, DiffMode.THREEWAY_BASE): old_chunks = chunk_diff_lines(old_diff.lines) new_chunks = chunk_diff_lines(new_diff.lines) diff_lines = [] @@ -2638,20 +3101,54 @@ def align_diffs( diff_lines = [ (base, new, old if old != new else empty) for base, new, old in diff_lines ] - else: - meta = TableMetadata( - headers=( - Text("TARGET"), - Text(f"{padding}CURRENT ({new_diff.score})"), - ), - current_score=new_diff.score, - max_score=new_diff.max_score, - previous_score=None, + headers = ( + Text("TARGET"), + Text(f"{padding}CURRENT ({new_diff.score})"), + Text(f"{padding}PREVIOUS ({old_diff.score})"), ) + current_score = new_diff.score + max_score = new_diff.max_score + previous_score = old_diff.score + elif config.diff_mode in (DiffMode.SINGLE, DiffMode.SINGLE_BASE): + header = Text("BASE" if config.diff_mode == DiffMode.SINGLE_BASE else "CURRENT") + diff_lines = [(line,) for line in new_diff.lines] + headers = (header,) + # Scoring is disabled for view mode + current_score = 0 + max_score = 0 + previous_score = None + else: diff_lines = [(line, line) for line in new_diff.lines] + headers = ( + Text("TARGET"), + Text(f"{padding}CURRENT ({new_diff.score})"), + ) + current_score = new_diff.score + max_score = new_diff.max_score + previous_score = None if config.compress: diff_lines = compress_matching(diff_lines, config.compress.context) - return meta, diff_lines + + def diff_line_to_table_line(line: Tuple[OutputLine, ...]) -> TableLine: + cells = [ + (line[0].base or Text(), line[0].line1) + ] + for ol in line[1:]: + cells.append((ol.fmt2, ol.line2)) + + return TableLine( + key=line[0].key2, + is_data_ref=line[0].is_data_ref, + cells=tuple(cells), + ) + + return TableData( + headers=headers, + current_score=current_score, + max_score=max_score, + previous_score=previous_score, + lines=[diff_line_to_table_line(line) for line in diff_lines], + ) def debounced_fs_watch( @@ -2754,17 +3251,26 @@ class Display: return (self.emsg, self.emsg) my_lines = process(self.mydump, self.config) - diff_output = do_diff(self.base_lines, my_lines, self.config) + + if self.config.diff_mode == DiffMode.SINGLE_BASE: + diff_output = do_diff(self.base_lines, self.base_lines, self.config) + elif self.config.diff_mode == DiffMode.SINGLE: + diff_output = do_diff(my_lines, my_lines, self.config) + else: + diff_output = do_diff(self.base_lines, my_lines, self.config) + last_diff_output = self.last_diff_output or diff_output - if self.config.threeway != "base" or not self.last_diff_output: + if self.config.diff_mode != DiffMode.THREEWAY_BASE or not self.last_diff_output: self.last_diff_output = diff_output - meta, diff_lines = align_diffs(last_diff_output, diff_output, self.config) - output = self.config.formatter.table(meta, diff_lines) + data = align_diffs(last_diff_output, diff_output, self.config) + output = self.config.formatter.table(data) + refresh_key = ( [line.key2 for line in diff_output.lines], diff_output.score, ) + return (output, refresh_key) def run_less( @@ -2882,7 +3388,10 @@ def main() -> None: except ModuleNotFoundError as e: fail(MISSING_PREREQUISITES.format(e.name)) - if config.threeway and not args.watch: + if ( + config.diff_mode in (DiffMode.THREEWAY_BASE, DiffMode.THREEWAY_PREV) + and not args.watch + ): fail("Threeway diffing requires -w.") if args.diff_elf_symbol: @@ -2910,8 +3419,10 @@ def main() -> None: if args.base_asm is not None: with open(args.base_asm) as f: basedump = f.read() - else: + elif config.diff_mode != DiffMode.SINGLE: basedump = run_objdump(basecmd, config, project) + else: + basedump = "" mydump = run_objdump(mycmd, config, project) diff --git a/tools/asm-differ/diff_settings.py b/tools/asm-differ/diff_settings.py index 183b96b75..19d67d548 100644 --- a/tools/asm-differ/diff_settings.py +++ b/tools/asm-differ/diff_settings.py @@ -5,7 +5,8 @@ def apply(config, args): config["source_directories"] = ["."] # config["show_line_numbers_default"] = True # config["arch"] = "mips" - # config["map_format"] = "gnu" # gnu or mw - # config["mw_build_dir"] = "build/" # only needed for mw map format + # config["map_format"] = "gnu" # gnu, mw, ms + # config["build_dir"] = "build/" # only needed for mw and ms map format + # config["expected_dir"] = "expected/" # needed for -o # config["makeflags"] = [] # config["objdump_executable"] = "" diff --git a/tools/asm-differ/pyproject.toml b/tools/asm-differ/pyproject.toml new file mode 100644 index 000000000..7a112aee5 --- /dev/null +++ b/tools/asm-differ/pyproject.toml @@ -0,0 +1,21 @@ +[tool.poetry] +name = "asm-differ" +version = "0.1.0" +description = "" +authors = ["Simon Lindholm "] +license = "UNLICENSE" +readme = "README.md" +packages = [{ include = "diff.py" }] + +[tool.poetry.dependencies] +python = "^3.7" +colorama = "^0.4.6" +ansiwrap = "^0.8.4" +watchdog = "^2.2.0" +levenshtein = "^0.20.9" +cxxfilt = "^0.3.0" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/tools/asm-processor/.gitignore b/tools/asm-processor/.gitignore new file mode 100644 index 000000000..cc5bba4b5 --- /dev/null +++ b/tools/asm-processor/.gitignore @@ -0,0 +1,2 @@ +*.o +*.py[cod] diff --git a/tools/asm-processor/.gitrepo b/tools/asm-processor/.gitrepo new file mode 100644 index 000000000..e9ee1dd74 --- /dev/null +++ b/tools/asm-processor/.gitrepo @@ -0,0 +1,12 @@ +; DO NOT EDIT (unless you know what you are doing) +; +; This subdirectory is a git "subrepo", and this file is maintained by the +; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme +; +[subrepo] + remote = git@github.com:simonlindholm/asm-processor.git + branch = main + commit = bbd86ea1faf84e6a7a0e101ab8068a00a3dfb2fc + parent = 8985197b6da23db874ac6e8a29ddec5636944bba + method = merge + cmdver = 0.4.3 diff --git a/tools/asm-processor/LICENSE b/tools/asm-processor/LICENSE new file mode 100644 index 000000000..cf1ab25da --- /dev/null +++ b/tools/asm-processor/LICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/tools/asm-processor/README.md b/tools/asm-processor/README.md new file mode 100644 index 000000000..009147c06 --- /dev/null +++ b/tools/asm-processor/README.md @@ -0,0 +1,112 @@ +# asm-processor + +Pre-process .c files and post-process .o files to enable embedding MIPS assembly into IDO-compiled C. + +## Usage + +Let's say you have a file compiled with `-g` on the IDO compiler, that looks like this: +```c +float func4(void) { + "func4"; + return 0.2f; +} +``` + +This script enables replacing it by: +```asm +GLOBAL_ASM( +.rdata +.word 0x66756e63 # func +.word 0x34000000 # 4\0\0\0 + +.late_rodata +glabel rv +.word 0x3e4ccccd # 0.2f + +.text +glabel func4 +lui $at, %hi(rv) +jr $ra +lwc1 $f0, %lo(rv)($at) +jr $ra +nop +jr $ra +nop +) +``` + +To compile the file, run `python3 build.py $CC -- $AS $ASFLAGS -- $CFLAGS -o out.o in.c`, where $CC points to an IDO binary (5.3/7.1 and recomp/qemu all supported), $AS is e.g. `mips-linux-gnu-as`, $ASFLAGS e.g. `-march=vr4300 -mabi=32` and $CFLAGS e.g. `-Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm -g`. build.py may be customized as needed. + +In addition to an .o file, build.py also generates a .d file with Makefile dependencies for .s files referenced by the input .c file. +This functionality may be removed if not needed. + +Reading assembly from file is also supported, by either `GLOBAL_ASM("file.s")` or `#pragma GLOBAL_ASM("file.s")`. + +### What is supported? + +`.text`, `.data`, `.bss` and `.rodata` sections, `.word`/`.incbin`, `.ascii`/`.asciz`, and `-g`, `-g3`, `-O1`, `-O2`, `-framepointer` and `-mips1`/`-mips2` flags to the IDO compiler. + +### What is not supported? + +* complicated assembly (.ifdef, macro declarations/calls other than `glabel`, pseudo-instructions that expand to several real instructions) +* non-IDO compilers +* `-O3` (due to function reordering) + +C `#ifdef`s only work outside of `GLOBAL_ASM` calls, but is otherwise able to replace `.ifdef`. + +### What's up with "late rodata"? + +The IDO compiler emits rodata in two passes: first array/string contents, then large literals/switch jump tables. + +Data declared within `.rdata`/`.section .rodata` will end up in the first half, and `.late_rodata`/`.section .late_rodata` in the second half. + +### How does it work? + +It's a bit of a hack! +The basic idea is replace `GLOBAL_ASM` blocks with dummy C functions/global vars of the same sections sizes as the assembly. +Then the C file gets compiled, and the dummy contents overwritten with the injected assembly. + +To accomplish this, asm-processor has logic for guessing the size of assembly contents +(which assumes the assembly isn't too complicated, e.g. no macros), +and for emitting C code of exact sizes for a bunch of different IDO compiler flags. + +The assembler code is padded with nops to line it up with its correct position in the C; +this allows C and asm ELF files to be merged easily without having to fix up e.g. symbol addresses. + +The most difficult part is `late_rodata`, which is hard to create programmatically. +asm-processor does that by emitting code that uses dummy float literals/double literals/jump tables, +assembles the late_rodata at another location of the .rodata section, then overwrites the dummy rodata. +This does require some movement of symbols and relocations, and quite a bit of care in what code to +emit and how to preserve .double alignment. + +It's worth noting some alternative ways in which asm-processor would have been implemented: +- One idea to get rid of the C/asm size estimations is to emit arbitrary code, and then move code, +symbols and relocations to the correct place after the sizes are known. +Given the machinery for `late_rodata` this wouldn't have been too difficult, and it would have the upside of improved portability. +There is a big downside, however: using dummy code of incorrect size throws off alignment and can introduce unintended padding. +Fixing this would require running multiple passes of asm-processor, with one compile per `ASM_GLOBAL`. +- Another idea is to run the compiler with -S to emit assembly, modify the emitted assembly, then run the assembler +(which in IDO's case may perform additional instruction reordering etc.). +This option has not been investigated in much detail, and would perhaps be superior to the current implementation. +It does have a few unknowns to it, e.g. instruction encoding differences between GNU `as` and IDO's assembler, +how to avoid reordering the injected assembly, and how .rodata/.late_rodata are implemented. + +### Testing + +There are a few tests to ensure you don't break anything when hacking on asm-processor: `./run-tests.sh` should exit without output if they pass, or else output a diff from previous to new version. + +Tests need the environment variable `MIPS_CC` set to point to the IDO 7.1 compiler, with Pascal support enabled. + +For example if asm-processor is cloned in the same directory as [ido static recomp](https://github.com/decompals/ido-static-recomp) and the working directory is asm-processor, tests can be run using: + +```sh +MIPS_CC=../ido-static-recomp/build/7.1/out/cc ./run-tests.sh +``` + +Or using [qemu-irix](https://github.com/zeldaret/oot/releases/tag/0.1q) (don't forget `chmod u+x qemu-irix`) to emulate IDO: + +```sh +MIPS_CC='./qemu-irix -silent -L ../ido-static-recomp/ido/7.1/ ../ido-static-recomp/ido/7.1/usr/bin/cc' ./run-tests.sh +``` + +To skip running Pascal tests, remove the `tests/*.p` glob from `run-tests.sh`. diff --git a/tools/asm-processor/add-test.sh b/tools/asm-processor/add-test.sh new file mode 100755 index 000000000..708548e57 --- /dev/null +++ b/tools/asm-processor/add-test.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +for A in "$@"; do + OBJDUMPFLAGS="-srt" + ./compile-test.sh "$A" && mips-linux-gnu-objdump $OBJDUMPFLAGS "${A%.*}.o" > "${A%.*}.objdump" +done diff --git a/tools/asm-processor/asm_processor.py b/tools/asm-processor/asm_processor.py index 544b1b1b7..0d62bc32a 100644 --- a/tools/asm-processor/asm_processor.py +++ b/tools/asm-processor/asm_processor.py @@ -85,6 +85,18 @@ MIPS_DEBUG_ST_STATIC = 2 MIPS_DEBUG_ST_STATIC_PROC = 14 +class ElfFormat: + def __init__(self, is_big_endian): + self.is_big_endian = is_big_endian + self.struct_char = ">" if is_big_endian else "<" + + def pack(self, fmt, *args): + return struct.pack(self.struct_char + fmt, *args) + + def unpack(self, fmt, data): + return struct.unpack(self.struct_char + fmt, data) + + class ElfHeader: """ typedef struct { @@ -107,9 +119,9 @@ class ElfHeader: def __init__(self, data): self.e_ident = data[:EI_NIDENT] - self.e_type, self.e_machine, self.e_version, self.e_entry, self.e_phoff, self.e_shoff, self.e_flags, self.e_ehsize, self.e_phentsize, self.e_phnum, self.e_shentsize, self.e_shnum, self.e_shstrndx = struct.unpack('>HHIIIIIHHHHHH', data[EI_NIDENT:]) assert self.e_ident[EI_CLASS] == 1 # 32-bit - assert self.e_ident[EI_DATA] == 2 # big-endian + self.fmt = ElfFormat(is_big_endian=(self.e_ident[EI_DATA] == 2)) + self.e_type, self.e_machine, self.e_version, self.e_entry, self.e_phoff, self.e_shoff, self.e_flags, self.e_ehsize, self.e_phentsize, self.e_phnum, self.e_shentsize, self.e_shnum, self.e_shstrndx = self.fmt.unpack('HHIIIIIHHHHHH', data[EI_NIDENT:]) assert self.e_type == 1 # relocatable assert self.e_machine == 8 # MIPS I Architecture assert self.e_phoff == 0 # no program header @@ -117,7 +129,7 @@ class ElfHeader: assert self.e_shstrndx != SHN_UNDEF def to_bin(self): - return self.e_ident + struct.pack('>HHIIIIIHHHHHH', self.e_type, + return self.e_ident + self.fmt.pack('HHIIIIIHHHHHH', self.e_type, self.e_machine, self.e_version, self.e_entry, self.e_phoff, self.e_shoff, self.e_flags, self.e_ehsize, self.e_phentsize, self.e_phnum, self.e_shentsize, self.e_shnum, self.e_shstrndx) @@ -135,8 +147,9 @@ class Symbol: } Elf32_Sym; """ - def __init__(self, data, strtab, name=None): - self.st_name, self.st_value, self.st_size, st_info, self.st_other, self.st_shndx = struct.unpack('>IIIBBH', data) + def __init__(self, fmt, data, strtab, name=None): + self.fmt = fmt + self.st_name, self.st_value, self.st_size, st_info, self.st_other, self.st_shndx = fmt.unpack('IIIBBH', data) assert self.st_shndx != SHN_XINDEX, "too many sections (SHN_XINDEX not supported)" self.bind = st_info >> 4 self.type = st_info & 15 @@ -144,31 +157,32 @@ class Symbol: self.visibility = self.st_other & 3 @staticmethod - def from_parts(st_name, st_value, st_size, st_info, st_other, st_shndx, strtab, name): - header = struct.pack('>IIIBBH', st_name, st_value, st_size, st_info, st_other, st_shndx) - return Symbol(header, strtab, name) + def from_parts(fmt, st_name, st_value, st_size, st_info, st_other, st_shndx, strtab, name): + header = fmt.pack('IIIBBH', st_name, st_value, st_size, st_info, st_other, st_shndx) + return Symbol(fmt, header, strtab, name) def to_bin(self): st_info = (self.bind << 4) | self.type - return struct.pack('>IIIBBH', self.st_name, self.st_value, self.st_size, st_info, self.st_other, self.st_shndx) + return self.fmt.pack('IIIBBH', self.st_name, self.st_value, self.st_size, st_info, self.st_other, self.st_shndx) class Relocation: - def __init__(self, data, sh_type): + def __init__(self, fmt, data, sh_type): + self.fmt = fmt self.sh_type = sh_type if sh_type == SHT_REL: - self.r_offset, self.r_info = struct.unpack('>II', data) + self.r_offset, self.r_info = fmt.unpack('II', data) else: - self.r_offset, self.r_info, self.r_addend = struct.unpack('>III', data) + self.r_offset, self.r_info, self.r_addend = fmt.unpack('III', data) self.sym_index = self.r_info >> 8 self.rel_type = self.r_info & 0xff def to_bin(self): self.r_info = (self.sym_index << 8) | self.rel_type if self.sh_type == SHT_REL: - return struct.pack('>II', self.r_offset, self.r_info) + return self.fmt.pack('II', self.r_offset, self.r_info) else: - return struct.pack('>III', self.r_offset, self.r_info, self.r_addend) + return self.fmt.pack('III', self.r_offset, self.r_info, self.r_addend) class Section: @@ -187,8 +201,9 @@ class Section: } Elf32_Shdr; """ - def __init__(self, header, data, index): - self.sh_name, self.sh_type, self.sh_flags, self.sh_addr, self.sh_offset, self.sh_size, self.sh_link, self.sh_info, self.sh_addralign, self.sh_entsize = struct.unpack('>IIIIIIIIII', header) + def __init__(self, fmt, header, data, index): + self.fmt = fmt + self.sh_name, self.sh_type, self.sh_flags, self.sh_addr, self.sh_offset, self.sh_size, self.sh_link, self.sh_info, self.sh_addralign, self.sh_entsize = fmt.unpack('IIIIIIIIII', header) assert not self.sh_flags & SHF_LINK_ORDER if self.sh_entsize != 0: assert self.sh_size % self.sh_entsize == 0 @@ -200,9 +215,9 @@ class Section: self.relocated_by = [] @staticmethod - def from_parts(sh_name, sh_type, sh_flags, sh_link, sh_info, sh_addralign, sh_entsize, data, index): - header = struct.pack('>IIIIIIIIII', sh_name, sh_type, sh_flags, 0, 0, len(data), sh_link, sh_info, sh_addralign, sh_entsize) - return Section(header, data, index) + def from_parts(fmt, sh_name, sh_type, sh_flags, sh_link, sh_info, sh_addralign, sh_entsize, data, index): + header = fmt.pack('IIIIIIIIII', sh_name, sh_type, sh_flags, 0, 0, len(data), sh_link, sh_info, sh_addralign, sh_entsize) + return Section(fmt, header, data, index) def lookup_str(self, index): assert self.sh_type == SHT_STRTAB @@ -222,7 +237,7 @@ class Section: def header_to_bin(self): if self.sh_type != SHT_NOBITS: self.sh_size = len(self.data) - return struct.pack('>IIIIIIIIII', self.sh_name, self.sh_type, self.sh_flags, self.sh_addr, self.sh_offset, self.sh_size, self.sh_link, self.sh_info, self.sh_addralign, self.sh_entsize) + return self.fmt.pack('IIIIIIIIII', self.sh_name, self.sh_type, self.sh_flags, self.sh_addr, self.sh_offset, self.sh_size, self.sh_link, self.sh_info, self.sh_addralign, self.sh_entsize) def late_init(self, sections): if self.sh_type == SHT_SYMTAB: @@ -251,14 +266,14 @@ class Section: self.strtab = sections[self.sh_link] entries = [] for i in range(0, self.sh_size, self.sh_entsize): - entries.append(Symbol(self.data[i:i+self.sh_entsize], self.strtab)) + entries.append(Symbol(self.fmt, self.data[i:i+self.sh_entsize], self.strtab)) self.symbol_entries = entries def init_relocs(self): assert self.is_rel() entries = [] for i in range(0, self.sh_size, self.sh_entsize): - entries.append(Relocation(self.data[i:i+self.sh_entsize], self.sh_type)) + entries.append(Relocation(self.fmt, self.data[i:i+self.sh_entsize], self.sh_type)) self.relocations = entries def local_symbols(self): @@ -281,9 +296,9 @@ class Section: hdrr_cbOptOffset, hdrr_iauxMax, hdrr_cbAuxOffset, hdrr_issMax, \ hdrr_cbSsOffset, hdrr_issExtMax, hdrr_cbSsExtOffset, hdrr_ifdMax, \ hdrr_cbFdOffset, hdrr_crfd, hdrr_cbRfdOffset, hdrr_iextMax, \ - hdrr_cbExtOffset = struct.unpack(">HHIIIIIIIIIIIIIIIIIIIIIII", self.data[0:0x60]) + hdrr_cbExtOffset = self.fmt.unpack("HHIIIIIIIIIIIIIIIIIIIIIII", self.data[0:0x60]) - assert hdrr_magic == 0x7009 , "Invalid magic value for .mdebug symbolic header" + assert hdrr_magic == 0x7009, "Invalid magic value for .mdebug symbolic header" hdrr_cbLineOffset += shift_by hdrr_cbDnOffset += shift_by @@ -297,7 +312,7 @@ class Section: hdrr_cbRfdOffset += shift_by hdrr_cbExtOffset += shift_by - new_data[0:0x60] = struct.pack(">HHIIIIIIIIIIIIIIIIIIIIIII", hdrr_magic, hdrr_vstamp, hdrr_ilineMax, hdrr_cbLine, \ + new_data[0:0x60] = self.fmt.pack("HHIIIIIIIIIIIIIIIIIIIIIII", hdrr_magic, hdrr_vstamp, hdrr_ilineMax, hdrr_cbLine, \ hdrr_cbLineOffset, hdrr_idnMax, hdrr_cbDnOffset, hdrr_ipdMax, \ hdrr_cbPdOffset, hdrr_isymMax, hdrr_cbSymOffset, hdrr_ioptMax, \ hdrr_cbOptOffset, hdrr_iauxMax, hdrr_cbAuxOffset, hdrr_issMax, \ @@ -313,15 +328,16 @@ class ElfFile: assert data[:4] == b'\x7fELF', "not an ELF file" self.elf_header = ElfHeader(data[0:52]) + self.fmt = self.elf_header.fmt offset, size = self.elf_header.e_shoff, self.elf_header.e_shentsize - null_section = Section(data[offset:offset + size], data, 0) + null_section = Section(self.fmt, data[offset:offset + size], data, 0) num_sections = self.elf_header.e_shnum or null_section.sh_size self.sections = [null_section] for i in range(1, num_sections): ind = offset + i * size - self.sections.append(Section(data[ind:ind + size], data, i)) + self.sections.append(Section(self.fmt, data[ind:ind + size], data, i)) symtab = None for s in self.sections: @@ -345,7 +361,7 @@ class ElfFile: def add_section(self, name, sh_type, sh_flags, sh_link, sh_info, sh_addralign, sh_entsize, data): shstr = self.sections[self.elf_header.e_shstrndx] sh_name = shstr.add_str(name) - s = Section.from_parts(sh_name=sh_name, sh_type=sh_type, + s = Section.from_parts(self.fmt, sh_name=sh_name, sh_type=sh_type, sh_flags=sh_flags, sh_link=sh_link, sh_info=sh_info, sh_addralign=sh_addralign, sh_entsize=sh_entsize, data=data, index=len(self.sections)) @@ -421,15 +437,18 @@ class Failure(Exception): class GlobalState: - def __init__(self, min_instr_count, skip_instr_count, use_jtbl_for_rodata, mips1): + def __init__(self, min_instr_count, skip_instr_count, use_jtbl_for_rodata, prelude_if_late_rodata, mips1, pascal): # A value that hopefully never appears as a 32-bit rodata constant (or we # miscompile late rodata). Increases by 1 in each step. self.late_rodata_hex = 0xE0123456 + self.valuectr = 0 self.namectr = 0 self.min_instr_count = min_instr_count self.skip_instr_count = skip_instr_count self.use_jtbl_for_rodata = use_jtbl_for_rodata + self.prelude_if_late_rodata = prelude_if_late_rodata self.mips1 = mips1 + self.pascal = pascal def next_late_rodata_hex(self): dummy_bytes = struct.pack('>I', self.late_rodata_hex) @@ -443,6 +462,36 @@ class GlobalState: self.namectr += 1 return '_asmpp_{}{}'.format(cat, self.namectr) + def func_prologue(self, name): + if self.pascal: + return " ".join([ + "procedure {}();".format(name), + "type", + " pi = ^integer;", + " pf = ^single;", + " pd = ^double;", + "var", + " vi: pi;", + " vf: pf;", + " vd: pd;", + "begin", + " vi := vi;", + " vf := vf;", + " vd := vd;", + ]) + else: + return 'void {}(void) {{'.format(name) + + def func_epilogue(self): + if self.pascal: + return "end;" + else: + return "}" + + def pascal_assignment(self, tp, val): + self.valuectr += 1 + address = (8 * self.valuectr) & 0x7FFF + return 'v{} := p{}({}); v{}^ := {};'.format(tp, tp, address, tp, val) Function = namedtuple('Function', ['text_glabels', 'asm_conts', 'late_rodata_dummy_bytes', 'jtbl_rodata_size', 'late_rodata_asm_conts', 'fn_desc', 'data']) @@ -476,6 +525,7 @@ class GlobalAsmBlock: def count_quoted_size(self, line, z, real_line, output_enc): line = line.encode(output_enc).decode('latin1') in_quote = False + has_comma = True num_parts = 0 ret = 0 i = 0 @@ -486,10 +536,15 @@ class GlobalAsmBlock: if not in_quote: if c == '"': in_quote = True + if z and not has_comma: + self.fail(".asciiz with glued strings is not supported due to GNU as version diffs") num_parts += 1 + elif c == ',': + has_comma = True else: if c == '"': in_quote = False + has_comma = False continue ret += 1 if c != '\\': @@ -554,7 +609,7 @@ class GlobalAsmBlock: self.text_glabels.append(line.split()[1]) if not line: pass # empty line - elif line.startswith('glabel ') or (' ' not in line and line.endswith(':')): + elif line.startswith('glabel ') or line.startswith('dlabel ') or line.startswith('endlabel ') or (' ' not in line and line.endswith(':')): pass # label elif line.startswith('.section') or line in ['.text', '.data', '.rdata', '.rodata', '.bss', '.late_rodata']: # section change @@ -574,7 +629,7 @@ class GlobalAsmBlock: changed_section = True elif line.startswith('.incbin'): self.add_sized(int(line.split(',')[-1].strip(), 0), real_line) - elif line.startswith('.word') or line.startswith('.float'): + elif line.startswith('.word') or line.startswith('.gpword') or line.startswith('.float'): self.align4() self.add_sized(4 * len(line.split(',')), real_line) elif line.startswith('.double'): @@ -651,7 +706,12 @@ class GlobalAsmBlock: skip_next = False needs_double = (self.late_rodata_alignment != 0) extra_mips1_nop = False - jtbl_size = 11 if state.mips1 else 9 + if state.pascal: + jtbl_size = 9 if state.mips1 else 8 + jtbl_min_rodata_size = 2 + else: + jtbl_size = 11 if state.mips1 else 9 + jtbl_min_rodata_size = 5 for i in range(size): if skip_next: skip_next = False @@ -668,9 +728,15 @@ class GlobalAsmBlock: # - we have at least 10 more instructions to go in this function (otherwise our # function size computation will be wrong since the delay slot goes unused) if (not needs_double and state.use_jtbl_for_rodata and i >= 1 and - size - i >= 5 and num_instr - len(late_rodata_fn_output) >= jtbl_size + 1): - cases = " ".join("case {}:".format(case) for case in range(size - i)) - late_rodata_fn_output.append("switch (*(volatile int*)0) { " + cases + " ; }") + size - i >= jtbl_min_rodata_size and + num_instr - len(late_rodata_fn_output) >= jtbl_size + 1): + if state.pascal: + cases = " ".join("{}: ;".format(case) for case in range(size - i)) + line = "case 0 of " + cases + " otherwise end;" + else: + cases = " ".join("case {}:".format(case) for case in range(size - i)) + line = "switch (*(volatile int*)0) { " + cases + " ; }" + late_rodata_fn_output.append(line) late_rodata_fn_output.extend([""] * (jtbl_size - 1)) jtbl_rodata_size = (size - i) * 4 extra_mips1_nop = i != 2 @@ -681,7 +747,11 @@ class GlobalAsmBlock: dummy_bytes2 = state.next_late_rodata_hex() late_rodata_dummy_bytes.append(dummy_bytes2) fval, = struct.unpack('>d', dummy_bytes + dummy_bytes2) - late_rodata_fn_output.append('*(volatile double*)0 = {};'.format(fval)) + if state.pascal: + line = state.pascal_assignment('d', fval) + else: + line = '*(volatile double*)0 = {};'.format(fval) + late_rodata_fn_output.append(line) skip_next = True needs_double = False if state.mips1: @@ -691,7 +761,11 @@ class GlobalAsmBlock: extra_mips1_nop = False else: fval, = struct.unpack('>f', dummy_bytes) - late_rodata_fn_output.append('*(volatile float*)0 = {}f;'.format(fval)) + if state.pascal: + line = state.pascal_assignment('f', fval) + else: + line = '*(volatile float*)0 = {}f;'.format(fval) + late_rodata_fn_output.append(line) extra_mips1_nop = True late_rodata_fn_output.append('') late_rodata_fn_output.append('') @@ -701,8 +775,8 @@ class GlobalAsmBlock: text_name = None if self.fn_section_sizes['.text'] > 0 or late_rodata_fn_output: text_name = state.make_name('func') - src[0] = 'void {}(void) {{'.format(text_name) - src[self.num_lines] = '}' + src[0] = state.func_prologue(text_name) + src[self.num_lines] = state.func_epilogue() instr_count = self.fn_section_sizes['.text'] // 4 if instr_count < state.min_instr_count: self.fail("too short .text block") @@ -710,6 +784,7 @@ class GlobalAsmBlock: tot_skipped = 0 fn_emitted = 0 fn_skipped = 0 + skipping = True rodata_stack = late_rodata_fn_output[::-1] for (line, count) in self.fn_ins_inds: for _ in range(count): @@ -718,16 +793,28 @@ class GlobalAsmBlock: # Don't let functions become too large. When a function reaches 284 # instructions, and -O2 -framepointer flags are passed, the IRIX # compiler decides it is a great idea to start optimizing more. + # Also, Pascal cannot handle too large functions before it runs out + # of unique statements to write. fn_emitted = 0 fn_skipped = 0 - src[line] += ' }} void {}(void) {{ '.format(state.make_name('large_func')) - if fn_skipped < state.skip_instr_count: + skipping = True + src[line] += (' ' + state.func_epilogue() + ' ' + + state.func_prologue(state.make_name('large_func')) + ' ') + if ( + skipping and + fn_skipped < state.skip_instr_count + + (state.prelude_if_late_rodata if rodata_stack else 0) + ): fn_skipped += 1 tot_skipped += 1 - elif rodata_stack: - src[line] += rodata_stack.pop() else: - src[line] += '*(volatile int*)0 = 0;' + skipping = False + if rodata_stack: + src[line] += rodata_stack.pop() + elif state.pascal: + src[line] += state.pascal_assignment('i', '0') + else: + src[line] += '*(volatile int*)0 = 0;' tot_emitted += 1 fn_emitted += 1 if rodata_stack: @@ -741,16 +828,24 @@ class GlobalAsmBlock: rodata_name = None if self.fn_section_sizes['.rodata'] > 0: + if state.pascal: + self.fail(".rodata isn't supported with Pascal for now") rodata_name = state.make_name('rodata') src[self.num_lines] += ' const char {}[{}] = {{1}};'.format(rodata_name, self.fn_section_sizes['.rodata']) data_name = None if self.fn_section_sizes['.data'] > 0: data_name = state.make_name('data') - src[self.num_lines] += ' char {}[{}] = {{1}};'.format(data_name, self.fn_section_sizes['.data']) + if state.pascal: + line = ' var {}: packed array[1..{}] of char := [otherwise: 0];'.format(data_name, self.fn_section_sizes['.data']) + else: + line = ' char {}[{}] = {{1}};'.format(data_name, self.fn_section_sizes['.data']) + src[self.num_lines] += line bss_name = None if self.fn_section_sizes['.bss'] > 0: + if state.pascal: + self.fail(".bss isn't supported with Pascal") bss_name = state.make_name('bss') src[self.num_lines] += ' char {}[{}];'.format(bss_name, self.fn_section_sizes['.bss']) @@ -775,43 +870,55 @@ float_regexpr = re.compile(r"[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?f") def repl_float_hex(m): return str(struct.unpack(">I", struct.pack(">f", float(m.group(0).strip().rstrip("f"))))[0]) -def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_dependencies, print_source=None): - if opt in ['O2', 'O1']: - if framepointer: +Opts = namedtuple('Opts', ['opt', 'framepointer', 'mips1', 'kpic', 'pascal', 'input_enc', 'output_enc']) + +def parse_source(f, opts, out_dependencies, print_source=None): + if opts.opt in ['O1', 'O2']: + if opts.framepointer: min_instr_count = 6 skip_instr_count = 5 else: min_instr_count = 2 skip_instr_count = 1 - elif opt == 'O0': - if framepointer: + elif opts.opt == 'O0': + if opts.framepointer: min_instr_count = 8 skip_instr_count = 8 else: min_instr_count = 4 skip_instr_count = 4 - elif opt == 'g': - if framepointer: + elif opts.opt == 'g': + if opts.framepointer: min_instr_count = 7 skip_instr_count = 7 else: min_instr_count = 4 skip_instr_count = 4 - else: - if opt != 'g3': - raise Failure("must pass one of -g, -O0, -O1, -O2, -O2 -g3") - if framepointer: + elif opts.opt == 'g3': + if opts.framepointer: min_instr_count = 4 skip_instr_count = 4 else: min_instr_count = 2 skip_instr_count = 2 + else: + raise Failure("must pass one of -g, -O0, -O1, -O2, -O2 -g3") + prelude_if_late_rodata = 0 + if opts.kpic: + # Without optimizations, the PIC prelude always takes up 3 instructions. + # With optimizations, the prelude is optimized out if there's no late rodata. + if opts.opt in ('g3', 'O2'): + prelude_if_late_rodata = 3 + else: + min_instr_count += 3 + skip_instr_count += 3 use_jtbl_for_rodata = False - if opt in ['O2', 'g3'] and not framepointer: + if opts.opt in ['O2', 'g3'] and not opts.framepointer and not opts.kpic: use_jtbl_for_rodata = True - state = GlobalState(min_instr_count, skip_instr_count, use_jtbl_for_rodata, mips1) + state = GlobalState(min_instr_count, skip_instr_count, use_jtbl_for_rodata, prelude_if_late_rodata, opts.mips1, opts.pascal) + output_enc = opts.output_enc global_asm = None asm_functions = [] @@ -848,7 +955,7 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende fname = line[line.index('(') + 2 : -2] out_dependencies.append(fname) global_asm = GlobalAsmBlock(fname) - with open(fname, encoding=input_enc) as f: + with open(fname, encoding=opts.input_enc) as f: for line2 in f: global_asm.process_line(line2.rstrip(), output_enc) src, fn = global_asm.finish(state) @@ -870,8 +977,8 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende fname = os.path.join(fpath, line[line.index(' ') + 2 : -1]) out_dependencies.append(fname) include_src = StringIO() - with open(fname, encoding=input_enc) as include_file: - parse_source(include_file, opt, framepointer, mips1, input_enc, output_enc, out_dependencies, include_src) + with open(fname, encoding=opts.input_enc) as include_file: + parse_source(include_file, opts, out_dependencies, include_src) include_src.write('#line ' + str(line_no + 1) + ' "' + f.name + '"') output_lines[-1] = include_src.getvalue() include_src.close() @@ -891,6 +998,7 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende for line in output_lines: print_source.write(line + '\n') else: + newline_encoded = "\n".encode(output_enc) for line in output_lines: try: line_encoded = line.encode(output_enc) @@ -899,18 +1007,18 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende print("The line:", line) print("The line, utf-8-encoded:", line.encode("utf-8")) raise - print_source.write(line_encoded + b'\n') + print_source.write(line_encoded) + print_source.write(newline_encoded) print_source.flush() - if print_source != sys.stdout.buffer: - print_source.close() return asm_functions -def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc, drop_mdebug_gptab): +def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc, drop_mdebug_gptab, convert_statics): SECTIONS = ['.data', '.text', '.rodata', '.bss'] with open(objfile_name, 'rb') as f: objfile = ElfFile(f.read()) + fmt = objfile.fmt prev_locs = { '.text': 0, @@ -949,6 +1057,11 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc, d loc = loc[1] prev_loc = prev_locs[sectype] if loc < prev_loc: + # If the dummy C generates too little asm, and we have two + # consecutive GLOBAL_ASM blocks, we detect that error here. + # On the other hand, if it generates too much, we don't have + # a good way of discovering that error: it's indistinguishable + # from a static symbol occurring after the GLOBAL_ASM block. raise Failure("Wrongly computed size for section {} (diff {}). This is an asm-processor bug!".format(sectype, prev_loc- loc)) if loc != prev_loc: asm.append('.section ' + sectype) @@ -958,7 +1071,7 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc, d else: asm.append('.space {}'.format(loc - prev_loc)) to_copy[sectype].append((loc, size, temp_name, function.fn_desc)) - if function.text_glabels: + if function.text_glabels and sectype == '.text': func_sizes[function.text_glabels[0]] = size prev_locs[sectype] = loc + size if not ifdefed: @@ -980,7 +1093,10 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc, d if any(late_rodata_asm): late_rodata_source_name_start = '_asmpp_late_rodata_start' late_rodata_source_name_end = '_asmpp_late_rodata_end' - asm.append('.rdata') + asm.append('.section .late_rodata') + # Put some padding at the start to avoid conflating symbols with + # references to the whole section. + asm.append('.word 0, 0') asm.append('glabel {}'.format(late_rodata_source_name_start)) for conts in late_rodata_asm: asm.extend(conts) @@ -1011,11 +1127,12 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc, d # Unify reginfo sections target_reginfo = objfile.find_section('.reginfo') - source_reginfo_data = list(asm_objfile.find_section('.reginfo').data) - data = list(target_reginfo.data) - for i in range(20): - data[i] |= source_reginfo_data[i] - target_reginfo.data = bytes(data) + if target_reginfo is not None: + source_reginfo_data = list(asm_objfile.find_section('.reginfo').data) + data = list(target_reginfo.data) + for i in range(20): + data[i] |= source_reginfo_data[i] + target_reginfo.data = bytes(data) # Move over section contents modified_text_positions = set() @@ -1052,7 +1169,7 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc, d # of another way of doing it. moved_late_rodata = {} if any(all_late_rodata_dummy_bytes) or any(all_jtbl_rodata_size): - source = asm_objfile.find_section('.rodata') + source = asm_objfile.find_section('.late_rodata') target = objfile.find_section('.rodata') source_pos = asm_objfile.symtab.find_symbol_in_section(late_rodata_source_name_start, source) source_end = asm_objfile.symtab.find_symbol_in_section(late_rodata_source_name_end, source) @@ -1061,6 +1178,8 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc, d new_data = list(target.data) for dummy_bytes_list, jtbl_rodata_size in zip(all_late_rodata_dummy_bytes, all_jtbl_rodata_size): for index, dummy_bytes in enumerate(dummy_bytes_list): + if not fmt.is_big_endian: + dummy_bytes = dummy_bytes[::-1] pos = target.data.index(dummy_bytes, last_rodata_pos) # This check is nice, but makes time complexity worse for large files: if SLOW_CHECKS and target.data.find(dummy_bytes, pos + 4) != -1: @@ -1096,7 +1215,7 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc, d # Find relocated symbols relocated_symbols = set() - for sectype in SECTIONS: + for sectype in SECTIONS + ['.late_rodata']: for obj in [asm_objfile, objfile]: sec = obj.find_section(sectype) if sec is None: @@ -1106,50 +1225,60 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc, d relocated_symbols.add(obj.symtab.symbol_entries[rel.sym_index]) # Move over symbols, deleting the temporary function labels. - # Sometimes this naive procedure results in duplicate symbols, or UNDEF - # symbols that are also defined the same .o file. Hopefully that's fine. - # Skip over local symbols that aren't relocated against, to avoid - # conflicts. - new_local_syms = [s for s in objfile.symtab.local_symbols() if not is_temp_name(s.name)] - new_global_syms = [s for s in objfile.symtab.global_symbols() if not is_temp_name(s.name)] + # Skip over new local symbols that aren't relocated against, to + # avoid conflicts. + empty_symbol = objfile.symtab.symbol_entries[0] + new_syms = [s for s in objfile.symtab.symbol_entries[1:] if not is_temp_name(s.name)] + for i, s in enumerate(asm_objfile.symtab.symbol_entries): is_local = (i < asm_objfile.symtab.sh_info) if is_local and s not in relocated_symbols: continue if is_temp_name(s.name): + assert s not in relocated_symbols continue if s.st_shndx not in [SHN_UNDEF, SHN_ABS]: section_name = asm_objfile.sections[s.st_shndx].name - if section_name not in SECTIONS: - raise Failure("generated assembly .o must only have symbols for .text, .data, .rodata, ABS and UNDEF, but found " + section_name) - s.st_shndx = objfile.find_section(section_name).index + target_section_name = section_name + if section_name == ".late_rodata": + target_section_name = ".rodata" + elif section_name not in SECTIONS: + raise Failure("generated assembly .o must only have symbols for .text, .data, .rodata, .late_rodata, ABS and UNDEF, but found " + section_name) + objfile_section = objfile.find_section(target_section_name) + if objfile_section is None: + raise Failure("generated assembly .o has section that real objfile lacks: " + target_section_name) + s.st_shndx = objfile_section.index # glabel's aren't marked as functions, making objdump output confusing. Fix that. if s.name in all_text_glabels: s.type = STT_FUNC if s.name in func_sizes: s.st_size = func_sizes[s.name] - if objfile.sections[s.st_shndx].name == '.rodata' and s.st_value in moved_late_rodata: + if section_name == '.late_rodata': + if s.st_value == 0: + # This must be a symbol corresponding to the whole .late_rodata + # section, being referred to from a relocation. + # Moving local symbols is tricky, because it requires fixing up + # lo16/hi16 relocation references to .late_rodata+. + # Just disallow it for now. + raise Failure("local symbols in .late_rodata are not allowed") s.st_value = moved_late_rodata[s.st_value] s.st_name += strtab_adj - if is_local: - new_local_syms.append(s) - else: - new_global_syms.append(s) + new_syms.append(s) + make_statics_global = convert_statics in ("global", "global-with-filename") # Add static symbols from .mdebug, so they can be referred to from GLOBAL_ASM - local_sym_replacements = {} - if mdebug_section: + if mdebug_section and convert_statics != "no": strtab_index = len(objfile.symtab.strtab.data) new_strtab_data = [] - ifd_max, cb_fd_offset = struct.unpack('>II', mdebug_section.data[18*4 : 20*4]) - cb_sym_offset, = struct.unpack('>I', mdebug_section.data[9*4 : 10*4]) - cb_ss_offset, = struct.unpack('>I', mdebug_section.data[15*4 : 16*4]) + ifd_max, cb_fd_offset = fmt.unpack('II', mdebug_section.data[18*4 : 20*4]) + cb_sym_offset, = fmt.unpack('I', mdebug_section.data[9*4 : 10*4]) + cb_ss_offset, = fmt.unpack('I', mdebug_section.data[15*4 : 16*4]) for i in range(ifd_max): offset = cb_fd_offset + 18*4*i - iss_base, _, isym_base, csym = struct.unpack('>IIII', objfile.data[offset + 2*4 : offset + 6*4]) + iss_base, _, isym_base, csym = fmt.unpack('IIII', objfile.data[offset + 2*4 : offset + 6*4]) for j in range(csym): offset2 = cb_sym_offset + 12 * (isym_base + j) - iss, value, st_sc_index = struct.unpack('>III', objfile.data[offset2 : offset2 + 12]) + iss, value, st_sc_index = fmt.unpack('III', objfile.data[offset2 : offset2 + 12]) st = (st_sc_index >> 26) sc = (st_sc_index >> 21) & 0x1f if st in [MIPS_DEBUG_ST_STATIC, MIPS_DEBUG_ST_STATIC_PROC]: @@ -1157,44 +1286,72 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc, d symbol_name_offset_end = objfile.data.find(b'\0', symbol_name_offset) assert symbol_name_offset_end != -1 symbol_name = objfile.data[symbol_name_offset : symbol_name_offset_end + 1] - symbol_name_str = symbol_name[:-1].decode('latin1') + emitted_symbol_name = symbol_name + if convert_statics == "global-with-filename": + # Change the emitted symbol name to include the filename, + # but don't let that affect deduplication logic. + emitted_symbol_name = objfile_name.encode("utf-8") + b":" + symbol_name section_name = {1: '.text', 2: '.data', 3: '.bss', 15: '.rodata'}[sc] section = objfile.find_section(section_name) symtype = STT_FUNC if sc == 1 else STT_OBJECT + binding = STB_GLOBAL if make_statics_global else STB_LOCAL sym = Symbol.from_parts( + fmt, st_name=strtab_index, st_value=value, st_size=0, - st_info=(STB_LOCAL << 4 | symtype), + st_info=(binding << 4 | symtype), st_other=STV_DEFAULT, st_shndx=section.index, strtab=objfile.symtab.strtab, - name=symbol_name_str) - local_sym_replacements[symbol_name_str] = len(new_local_syms) - strtab_index += len(symbol_name) - new_strtab_data.append(symbol_name) - new_local_syms.append(sym) + name=symbol_name[:-1].decode('latin1')) + strtab_index += len(emitted_symbol_name) + new_strtab_data.append(emitted_symbol_name) + new_syms.append(sym) objfile.symtab.strtab.data += b''.join(new_strtab_data) - # To get the linker to use the local symbols, we have to get rid of UNDEF - # global ones. - newer_global_syms = [] - for s in new_global_syms: - if s.st_shndx == SHN_UNDEF and s.name in local_sym_replacements: - s.new_index = local_sym_replacements[s.name] + # Get rid of duplicate symbols, favoring ones that are not UNDEF. + # Skip this for unnamed local symbols though. + new_syms.sort(key=lambda s: 0 if s.st_shndx != SHN_UNDEF else 1) + old_syms = [] + newer_syms = [] + name_to_sym = {} + for s in new_syms: + if s.name == "_gp_disp": + s.type = STT_OBJECT + if s.bind == STB_LOCAL and s.st_shndx == SHN_UNDEF: + raise Failure("local symbol \"" + s.name + "\" is undefined") + if not s.name: + if s.bind != STB_LOCAL: + raise Failure("global symbol with no name") + newer_syms.append(s) else: - newer_global_syms.append(s) - new_global_syms = newer_global_syms + existing = name_to_sym.get(s.name) + if not existing: + name_to_sym[s.name] = s + newer_syms.append(s) + elif s.st_shndx != SHN_UNDEF: + raise Failure("symbol \"" + s.name + "\" defined twice") + else: + s.replace_by = existing + old_syms.append(s) + new_syms = newer_syms + + # Put local symbols in front, with the initial dummy entry first, and + # _gp_disp at the end if it exists. + new_syms.insert(0, empty_symbol) + new_syms.sort(key=lambda s: (s.bind != STB_LOCAL, s.name == "_gp_disp")) + num_local_syms = sum(1 for s in new_syms if s.bind == STB_LOCAL) - new_syms = new_local_syms + new_global_syms for i, s in enumerate(new_syms): s.new_index = i + for s in old_syms: + s.new_index = s.replace_by.new_index objfile.symtab.data = b''.join(s.to_bin() for s in new_syms) - objfile.symtab.sh_info = len(new_local_syms) + objfile.symtab.sh_info = num_local_syms - # Move over relocations + # Fix up relocation symbol references for sectype in SECTIONS: - source = asm_objfile.find_section(sectype) target = objfile.find_section(sectype) if target is not None: @@ -1206,34 +1363,38 @@ def fixup_objfile(objfile_name, functions, asm_prelude, assembler, output_enc, d sectype == '.rodata' and rel.r_offset in jtbl_rodata_positions): # don't include relocations for late_rodata dummy code continue - # hopefully we don't have relocations for local or - # temporary symbols, so new_index exists rel.sym_index = objfile.symtab.symbol_entries[rel.sym_index].new_index nrels.append(rel) reltab.relocations = nrels reltab.data = b''.join(rel.to_bin() for rel in nrels) - if not source: + # Move over relocations + for sectype in SECTIONS + ['.late_rodata']: + source = asm_objfile.find_section(sectype) + if source is None or not source.data: continue - target_reltab = objfile.find_section('.rel' + sectype) - target_reltaba = objfile.find_section('.rela' + sectype) + target_sectype = '.rodata' if sectype == '.late_rodata' else sectype + target = objfile.find_section(target_sectype) + assert target is not None, target_sectype + target_reltab = objfile.find_section('.rel' + target_sectype) + target_reltaba = objfile.find_section('.rela' + target_sectype) for reltab in source.relocated_by: for rel in reltab.relocations: rel.sym_index = asm_objfile.symtab.symbol_entries[rel.sym_index].new_index - if sectype == '.rodata' and rel.r_offset in moved_late_rodata: + if sectype == '.late_rodata': rel.r_offset = moved_late_rodata[rel.r_offset] new_data = b''.join(rel.to_bin() for rel in reltab.relocations) if reltab.sh_type == SHT_REL: if not target_reltab: - target_reltab = objfile.add_section('.rel' + sectype, + target_reltab = objfile.add_section('.rel' + target_sectype, sh_type=SHT_REL, sh_flags=0, sh_link=objfile.symtab.index, sh_info=target.index, sh_addralign=4, sh_entsize=8, data=b'') target_reltab.data += new_data else: if not target_reltaba: - target_reltaba = objfile.add_section('.rela' + sectype, + target_reltaba = objfile.add_section('.rela' + target_sectype, sh_type=SHT_RELA, sh_flags=0, sh_link=objfile.symtab.index, sh_info=target.index, sh_addralign=4, sh_entsize=12, data=b'') @@ -1257,9 +1418,12 @@ def run_wrapped(argv, outfile, functions): parser.add_argument('--input-enc', default='latin1', help="input encoding (default: %(default)s)") parser.add_argument('--output-enc', default='latin1', help="output encoding (default: %(default)s)") parser.add_argument('--drop-mdebug-gptab', dest='drop_mdebug_gptab', action='store_true', help="drop mdebug and gptab sections") + parser.add_argument('--convert-statics', dest='convert_statics', choices=["no", "local", "global", "global-with-filename"], default="local", help="change static symbol visibility (default: %(default)s)") + parser.add_argument('--force', dest='force', action='store_true', help="force processing of files without GLOBAL_ASM blocks") parser.add_argument('-framepointer', dest='framepointer', action='store_true') parser.add_argument('-mips1', dest='mips1', action='store_true') parser.add_argument('-g3', dest='g3', action='store_true') + parser.add_argument('-KPIC', dest='kpic', action='store_true') group = parser.add_mutually_exclusive_group(required=True) group.add_argument('-O0', dest='opt', action='store_const', const='O0') group.add_argument('-O1', dest='opt', action='store_const', const='O1') @@ -1267,31 +1431,35 @@ def run_wrapped(argv, outfile, functions): group.add_argument('-g', dest='opt', action='store_const', const='g') args = parser.parse_args(argv) opt = args.opt + pascal = any(args.filename.endswith(ext) for ext in (".p", ".pas", ".pp")) if args.g3: if opt != 'O2': raise Failure("-g3 is only supported together with -O2") opt = 'g3' - if args.mips1 and (opt != 'O2' or args.framepointer): - raise Failure("-mips1 is only supported together with -O2") + if args.mips1 and (opt not in ('O1', 'O2') or args.framepointer): + raise Failure("-mips1 is only supported together with -O1 or -O2") + if pascal and opt not in ('O1', 'O2', 'g3'): + raise Failure("Pascal is only supported together with -O1, -O2 or -O2 -g3") + opts = Opts(opt, args.framepointer, args.mips1, args.kpic, pascal, args.input_enc, args.output_enc) if args.objfile is None: with open(args.filename, encoding=args.input_enc) as f: deps = [] - functions = parse_source(f, opt=opt, framepointer=args.framepointer, mips1=args.mips1, input_enc=args.input_enc, output_enc=args.output_enc, out_dependencies=deps, print_source=outfile) + functions = parse_source(f, opts, out_dependencies=deps, print_source=outfile) return functions, deps else: if args.assembler is None: raise Failure("must pass assembler command") if functions is None: with open(args.filename, encoding=args.input_enc) as f: - functions = parse_source(f, opt=opt, framepointer=args.framepointer, mips1=args.mips1, input_enc=args.input_enc, out_dependencies=[], output_enc=args.output_enc) - if not functions: + functions = parse_source(f, opts, out_dependencies=[]) + if not functions and not args.force: return asm_prelude = b'' if args.asm_prelude: with open(args.asm_prelude, 'rb') as f: asm_prelude = f.read() - fixup_objfile(args.objfile, functions, asm_prelude, args.assembler, args.output_enc, args.drop_mdebug_gptab) + fixup_objfile(args.objfile, functions, asm_prelude, args.assembler, args.output_enc, args.drop_mdebug_gptab, args.convert_statics) def run(argv, outfile=sys.stdout.buffer, functions=None): try: diff --git a/tools/asm-processor/build.py b/tools/asm-processor/build.py old mode 100755 new mode 100644 index 480dec9ed..efbaade4a --- a/tools/asm-processor/build.py +++ b/tools/asm-processor/build.py @@ -1,41 +1,50 @@ #!/usr/bin/env python3 import sys -import os +from pathlib import Path import shlex import subprocess import tempfile +import uuid import asm_processor -dir_path = os.path.dirname(os.path.realpath(__file__)) -prelude = os.path.join(dir_path, "prelude.inc") +# Boolean for debugging purposes +# Preprocessed files are temporary, set to True to keep a copy +keep_preprocessed_files = False + +dir_path = Path(__file__).resolve().parent +asm_prelude_path = dir_path / "prelude.inc" all_args = sys.argv[1:] -sep0 = [index for index, arg in enumerate(all_args) if not arg.startswith("-")][0] +sep0 = next(index for index, arg in enumerate(all_args) if not arg.startswith("-")) sep1 = all_args.index("--") sep2 = all_args.index("--", sep1 + 1) asmproc_flags = all_args[:sep0] compiler = all_args[sep0:sep1] -assembler = all_args[sep1 + 1 : sep2] -assembler_sh = " ".join(shlex.quote(x) for x in assembler) +assembler_args = all_args[sep1 + 1 : sep2] +assembler_sh = " ".join(shlex.quote(x) for x in assembler_args) + compile_args = all_args[sep2 + 1 :] -in_file = compile_args[-1] -out_ind = compile_args.index("-o") -out_file = compile_args[out_ind + 1] + +in_file = Path(compile_args[-1]) del compile_args[-1] + +out_ind = compile_args.index("-o") +out_file = Path(compile_args[out_ind + 1]) del compile_args[out_ind + 1] del compile_args[out_ind] -in_dir = os.path.split(os.path.realpath(in_file))[0] + +in_dir = in_file.resolve().parent opt_flags = [ - x for x in compile_args if x in ["-g3", "-g", "-O0", "-O1", "-O2", "-framepointer"] + x for x in compile_args if x in {"-g3", "-g", "-O0", "-O1", "-O2", "-framepointer", "-KPIC"} ] if "-mips2" not in compile_args: opt_flags.append("-mips1") -asmproc_flags += opt_flags + [in_file] +asmproc_flags += opt_flags + [str(in_file)] # Drop .mdebug and .gptab sections from resulting binaries. This makes # resulting .o files much smaller and speeds up builds, but loses line @@ -45,50 +54,61 @@ asmproc_flags += opt_flags + [in_file] # Convert encoding before compiling. # asmproc_flags += ["--input-enc", "utf-8", "--output-enc", "euc-jp"] -preprocessed_file = tempfile.NamedTemporaryFile( - prefix="preprocessed", suffix=".c", delete=False -) +with tempfile.TemporaryDirectory(prefix="asm_processor") as tmpdirname: + tmpdir_path = Path(tmpdirname) + preprocessed_filename = "preprocessed_" + uuid.uuid4().hex + in_file.suffix + preprocessed_path = tmpdir_path / preprocessed_filename + + with preprocessed_path.open("wb") as f: + functions, deps = asm_processor.run(asmproc_flags, outfile=f) + + if keep_preprocessed_files: + import shutil + + keep_output_dir = Path("./asm_processor_preprocessed") + keep_output_dir.mkdir(parents=True, exist_ok=True) + + shutil.copy( + preprocessed_path, + keep_output_dir / (in_file.stem + "_" + preprocessed_filename), + ) -try: compile_cmdline = ( - compiler + compile_args + ["-I", in_dir, "-o", out_file, preprocessed_file.name] + compiler + + compile_args + + ["-I", str(in_dir), "-o", str(out_file), str(preprocessed_path)] ) - functions, deps = asm_processor.run(asmproc_flags, outfile=preprocessed_file) try: subprocess.check_call(compile_cmdline) except subprocess.CalledProcessError as e: - print("Failed to compile file " + in_file + ". Command line:") + print("Failed to compile file " + str(in_file) + ". Command line:") print() print(" ".join(shlex.quote(x) for x in compile_cmdline)) print() sys.exit(55) - # To keep the preprocessed file: - # os._exit(1) asm_processor.run( asmproc_flags + [ "--post-process", - out_file, + str(out_file), "--assembler", assembler_sh, "--asm-prelude", - prelude, + str(asm_prelude_path), ], functions=functions, ) - deps_file = out_file[:-2] + ".asmproc.d" + deps_file = out_file.with_suffix(".asmproc.d") if deps: - with open(deps_file, "w") as f: - f.write(out_file + ": " + " \\\n ".join(deps) + "\n") + with deps_file.open("w") as f: + f.write(str(out_file) + ": " + " \\\n ".join(deps) + "\n") for dep in deps: f.write("\n" + dep + ":\n") else: try: - os.remove(deps_file) + deps_file.unlink() except OSError: pass -finally: - os.remove(preprocessed_file.name) diff --git a/tools/asm-processor/compile-test.sh b/tools/asm-processor/compile-test.sh new file mode 100755 index 000000000..65516629e --- /dev/null +++ b/tools/asm-processor/compile-test.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -o pipefail +INPUT="$1" +OUTPUT="${INPUT%.*}.o" + +rm -f "$OUTPUT" + +CC="$MIPS_CC" # ido 7.1 via recomp or qemu-irix +AS="mips-linux-gnu-as" +ASFLAGS="-march=vr4300 -mabi=32" +OPTFLAGS=$(grep 'COMPILE-FLAGS: ' $INPUT | sed 's#^.*COMPILE-FLAGS: ##' | sed 's#}$##') +ASMPFLAGS=$(grep 'ASMP-FLAGS: ' $INPUT | sed 's#^.*ASMP-FLAGS: ##' | sed 's#}$##') +ISET=$(grep 'COMPILE-ISET: ' $INPUT | sed 's#^.*COMPILE-ISET: ##' | sed 's#}$##') +if [[ -z "$OPTFLAGS" ]]; then + OPTFLAGS="-g" +fi +CFLAGS="-Wab,-r4300_mul -G 0 -Xcpluscomm -fullwarn -wlint -woff 819,820,852,821 -signed -c" +if [[ -z "$ISET" ]]; then + CFLAGS="$CFLAGS -mips2" +fi +if [[ "$OPTFLAGS" != *-KPIC* ]]; then + CFLAGS="$CFLAGS -non_shared" +fi + +set -e +python3 build.py --drop-mdebug-gptab $ASMPFLAGS $CC -- $AS $ASFLAGS -- $CFLAGS $OPTFLAGS $ISET -o "$OUTPUT" "$INPUT" diff --git a/tools/asm-processor/run-tests.sh b/tools/asm-processor/run-tests.sh new file mode 100755 index 000000000..5cae0a741 --- /dev/null +++ b/tools/asm-processor/run-tests.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +for A in tests/*.c tests/*.p; do + OBJDUMPFLAGS=-srt + echo $A + ./compile-test.sh "$A" && mips-linux-gnu-objdump $OBJDUMPFLAGS "${A%.*}.o" | diff - "${A%.*}.objdump" || echo FAIL "$A" +done diff --git a/tools/asm-processor/tests/ascii.c b/tools/asm-processor/tests/ascii.c new file mode 100644 index 000000000..bb27d2527 --- /dev/null +++ b/tools/asm-processor/tests/ascii.c @@ -0,0 +1,19 @@ +void foo(void) { "abcdef"; } + +GLOBAL_ASM( +.rdata + .ascii "AB" + .ascii "CD", "EF" + .ascii "GH\n\n\n\0\11\222\3333\44444\x1234567\n\nIJK" +) + +void bar(void) { "hello"; } + +GLOBAL_ASM( +.rdata + .asciiz "12" + .asciiz "34", "56" + .asciiz "78\n\n\n\0\11\222\3333\44444\x1234567\n\n9A" +) + +void baz(void) { "ghijkl"; } diff --git a/tools/asm-processor/tests/ascii.objdump b/tools/asm-processor/tests/ascii.objdump new file mode 100644 index 000000000..bf42638a9 --- /dev/null +++ b/tools/asm-processor/tests/ascii.objdump @@ -0,0 +1,29 @@ + +tests/ascii.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 00000030 .text +00000000 l d .rodata 00000050 .rodata +00000000 g F .text 00000010 foo +00000010 g F .text 00000010 bar +00000020 g F .text 00000010 baz + + +Contents of section .text: + 0000 03e00008 00000000 03e00008 00000000 ................ + 0010 03e00008 00000000 03e00008 00000000 ................ + 0020 03e00008 00000000 03e00008 00000000 ................ +Contents of section .rodata: + 0000 61626364 65660000 41424344 45464748 abcdef..ABCDEFGH + 0010 0a0a0a00 0992db33 24343467 0a0a494a .......3$44g..IJ + 0020 4b000000 68656c6c 6f000000 31320033 K...hello...12.3 + 0030 34003536 0037380a 0a0a0009 92db3324 4.56.78.......3$ + 0040 3434670a 0a394100 6768696a 6b6c0000 44g..9A.ghijkl.. +Contents of section .options: + 0000 01200000 00000000 80000000 00000000 . .............. + 0010 00000000 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 80000000 00000000 00000000 00000000 ................ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/comments.c b/tools/asm-processor/tests/comments.c new file mode 100644 index 000000000..4c9366991 --- /dev/null +++ b/tools/asm-processor/tests/comments.c @@ -0,0 +1,6 @@ +const char before[] = "^"; +GLOBAL_ASM( +.rdata +.asciz "aaaa /* bbbb */ # cccc", /**//**//**//**/ /*/ "xxxx" /*/ /* dddd " eeee */ "# ffff" # gggg "hhhh" /* iiii */ +) +const char after[] = "$"; diff --git a/tools/asm-processor/tests/comments.objdump b/tools/asm-processor/tests/comments.objdump new file mode 100644 index 000000000..246df2094 --- /dev/null +++ b/tools/asm-processor/tests/comments.objdump @@ -0,0 +1,21 @@ + +tests/comments.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .rodata 00000030 .rodata +00000000 g O .rodata 00000002 before +00000024 g O .rodata 00000002 after + + +Contents of section .rodata: + 0000 5e000000 61616161 202f2a20 62626262 ^...aaaa /* bbbb + 0010 202a2f20 23206363 63630023 20666666 */ # cccc.# fff + 0020 66000000 24000000 00000000 00000000 f...$........... +Contents of section .options: + 0000 01200000 00000000 00000000 00000000 . .............. + 0010 00000000 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 00000000 00000000 00000000 00000000 ................ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/force.c b/tools/asm-processor/tests/force.c new file mode 100644 index 000000000..03b630c13 --- /dev/null +++ b/tools/asm-processor/tests/force.c @@ -0,0 +1,17 @@ +// COMPILE-FLAGS: -O2 +// ASMP-FLAGS: --convert-statics=global-with-filename --force +static int xtext(int a, int b, int c); +const int rodata1[] = {1}; +static const int rodata2[] = {2}; +int data1[] = {3}; +static int data2[] = {4}; +int bss1; +static int bss2; + +static int xtext(int a, int b, int c) { + return 1; +} + +void baz(void) { + xtext(bss2, rodata2[0], data2[0]); +} diff --git a/tools/asm-processor/tests/force.objdump b/tools/asm-processor/tests/force.objdump new file mode 100644 index 000000000..7ef70247b --- /dev/null +++ b/tools/asm-processor/tests/force.objdump @@ -0,0 +1,47 @@ + +tests/force.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 00000050 .text +00000000 l d .rodata 00000010 .rodata +00000000 l d .data 00000010 .data +00000000 l d .bss 00000010 .bss +00000000 g O .rodata 00000004 rodata1 +00000000 g O .data 00000004 data1 +00000000 g O .bss 00000004 bss1 +00000014 g F .text 00000034 baz +00000004 g O .rodata 00000000 tests/force.o:rodata2 +00000004 g O .data 00000000 tests/force.o:data2 +00000004 g O .bss 00000000 tests/force.o:bss2 +00000000 g F .text 00000000 tests/force.o:xtext + + +RELOCATION RECORDS FOR [.text]: +OFFSET TYPE VALUE +0000001c R_MIPS_HI16 .bss +00000034 R_MIPS_LO16 .bss +00000020 R_MIPS_HI16 .rodata +0000002c R_MIPS_LO16 .rodata +00000024 R_MIPS_HI16 .data +00000028 R_MIPS_LO16 .data +00000030 R_MIPS_26 .text + + +Contents of section .text: + 0000 afa40000 afa50004 afa60008 03e00008 ................ + 0010 24020001 27bdffe8 afbf0014 3c040000 $...'.......<... + 0020 3c050000 3c060000 8cc60004 8ca50004 <...<........... + 0030 0c000000 8c840004 8fbf0014 27bd0018 ............'... + 0040 03e00008 00000000 00000000 00000000 ................ +Contents of section .rodata: + 0000 00000001 00000002 00000000 00000000 ................ +Contents of section .data: + 0000 00000003 00000004 00000000 00000000 ................ +Contents of section .options: + 0000 01200000 00000000 a0000074 00000000 . .........t.... + 0010 00000000 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 a0000074 00000000 00000000 00000000 ...t............ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/kpic-o1.c b/tools/asm-processor/tests/kpic-o1.c new file mode 100644 index 000000000..4d3346d2f --- /dev/null +++ b/tools/asm-processor/tests/kpic-o1.c @@ -0,0 +1,93 @@ +// COMPILE-FLAGS: -O1 -KPIC +GLOBAL_ASM( +glabel foo +addiu $a0, $a0, 1 +addiu $a0, $a0, 2 +addiu $a0, $a0, 3 +addiu $a0, $a0, 4 +addiu $a0, $a0, 5 +addiu $a0, $a0, 6 +addiu $a0, $a0, 7 +addiu $a0, $a0, 8 +addiu $a0, $a0, 9 +addiu $a0, $a0, 10 +addiu $a0, $a0, 11 +addiu $a0, $a0, 12 +) +GLOBAL_ASM( +.late_rodata +.float 1 +.text +glabel float_fn +addiu $a0, $a0, 13 +addiu $a0, $a0, 14 +addiu $a0, $a0, 15 +addiu $a0, $a0, 16 +addiu $a0, $a0, 17 +addiu $a0, $a0, 18 +addiu $a0, $a0, 19 +addiu $a0, $a0, 20 +addiu $a0, $a0, 21 +addiu $a0, $a0, 22 +addiu $a0, $a0, 23 +addiu $a0, $a0, 24 +addiu $a0, $a0, 25 +addiu $a0, $a0, 26 +addiu $a0, $a0, 27 +addiu $a0, $a0, 28 +addiu $a0, $a0, 29 +addiu $a0, $a0, 30 +) +GLOBAL_ASM( +.late_rodata +.late_rodata_alignment 4 +.float 2 +.double 1 +.double 2 +.double 3 +.double 4 +.double 5 +.double 6 +.double 7 +.double 8 +.text +glabel doubles +addiu $a0, $a0, 31 +addiu $a0, $a0, 32 +addiu $a0, $a0, 33 +addiu $a0, $a0, 34 +addiu $a0, $a0, 35 +addiu $a0, $a0, 36 +addiu $a0, $a0, 37 +addiu $a0, $a0, 38 +addiu $a0, $a0, 39 +addiu $a0, $a0, 40 +addiu $a0, $a0, 41 +addiu $a0, $a0, 42 +addiu $a0, $a0, 43 +addiu $a0, $a0, 44 +addiu $a0, $a0, 45 +addiu $a0, $a0, 46 +addiu $a0, $a0, 47 +addiu $a0, $a0, 48 +addiu $a0, $a0, 49 +addiu $a0, $a0, 50 +addiu $a0, $a0, 51 +addiu $a0, $a0, 52 +addiu $a0, $a0, 53 +addiu $a0, $a0, 54 +addiu $a0, $a0, 55 +addiu $a0, $a0, 56 +addiu $a0, $a0, 57 +addiu $a0, $a0, 58 +addiu $a0, $a0, 59 +addiu $a0, $a0, 60 +addiu $a0, $a0, 61 +addiu $a0, $a0, 62 +addiu $a0, $a0, 63 +addiu $a0, $a0, 64 +addiu $a0, $a0, 65 +addiu $a0, $a0, 66 +addiu $a0, $a0, 67 +addiu $a0, $a0, 68 +) diff --git a/tools/asm-processor/tests/kpic-o1.objdump b/tools/asm-processor/tests/kpic-o1.objdump new file mode 100644 index 000000000..6e336753a --- /dev/null +++ b/tools/asm-processor/tests/kpic-o1.objdump @@ -0,0 +1,46 @@ + +tests/kpic-o1.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 00000110 .text +00000000 l d .rodata 00000050 .rodata +00000000 g F .text 00000030 foo +00000030 g F .text 00000048 float_fn +00000078 g F .text 00000098 doubles +00000000 O *UND* 00000000 _gp_disp + + +RELOCATION RECORDS FOR [.text]: (none) + +Contents of section .text: + 0000 24840001 24840002 24840003 24840004 $...$...$...$... + 0010 24840005 24840006 24840007 24840008 $...$...$...$... + 0020 24840009 2484000a 2484000b 2484000c $...$...$...$... + 0030 2484000d 2484000e 2484000f 24840010 $...$...$...$... + 0040 24840011 24840012 24840013 24840014 $...$...$...$... + 0050 24840015 24840016 24840017 24840018 $...$...$...$... + 0060 24840019 2484001a 2484001b 2484001c $...$...$...$... + 0070 2484001d 2484001e 2484001f 24840020 $...$...$...$.. + 0080 24840021 24840022 24840023 24840024 $..!$.."$..#$..$ + 0090 24840025 24840026 24840027 24840028 $..%$..&$..'$..( + 00a0 24840029 2484002a 2484002b 2484002c $..)$..*$..+$.., + 00b0 2484002d 2484002e 2484002f 24840030 $..-$...$../$..0 + 00c0 24840031 24840032 24840033 24840034 $..1$..2$..3$..4 + 00d0 24840035 24840036 24840037 24840038 $..5$..6$..7$..8 + 00e0 24840039 2484003a 2484003b 2484003c $..9$..:$..;$..< + 00f0 2484003d 2484003e 2484003f 24840040 $..=$..>$..?$..@ + 0100 24840041 24840042 24840043 24840044 $..A$..B$..C$..D +Contents of section .rodata: + 0000 3f800000 40000000 3ff00000 00000000 ?...@...?....... + 0010 40000000 00000000 40080000 00000000 @.......@....... + 0020 40100000 00000000 40140000 00000000 @.......@....... + 0030 40180000 00000000 401c0000 00000000 @.......@....... + 0040 40200000 00000000 00000000 00000000 @ .............. +Contents of section .options: + 0000 01200000 00000000 92000002 00000000 . .............. + 0010 000f0ff0 00000000 00000000 00000000 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 92000012 00000000 000f0ff0 00000000 ................ + 0010 00000000 00000000 ........ diff --git a/tools/asm-processor/tests/kpic-o2.c b/tools/asm-processor/tests/kpic-o2.c new file mode 100644 index 000000000..f037341cc --- /dev/null +++ b/tools/asm-processor/tests/kpic-o2.c @@ -0,0 +1,92 @@ +// COMPILE-FLAGS: -O2 -KPIC +GLOBAL_ASM( +glabel foo +addiu $a0, $a0, 1 +addiu $a0, $a0, 2 +addiu $a0, $a0, 3 +addiu $a0, $a0, 4 +addiu $a0, $a0, 5 +addiu $a0, $a0, 6 +addiu $a0, $a0, 7 +addiu $a0, $a0, 8 +addiu $a0, $a0, 9 +addiu $a0, $a0, 10 +addiu $a0, $a0, 11 +addiu $a0, $a0, 12 +) +GLOBAL_ASM( +.late_rodata +.float 1 +.text +glabel float_fn +addiu $a0, $a0, 13 +addiu $a0, $a0, 14 +addiu $a0, $a0, 15 +addiu $a0, $a0, 16 +addiu $a0, $a0, 17 +addiu $a0, $a0, 18 +addiu $a0, $a0, 19 +addiu $a0, $a0, 20 +addiu $a0, $a0, 21 +addiu $a0, $a0, 22 +addiu $a0, $a0, 23 +addiu $a0, $a0, 24 +addiu $a0, $a0, 25 +addiu $a0, $a0, 26 +addiu $a0, $a0, 27 +addiu $a0, $a0, 28 +addiu $a0, $a0, 29 +addiu $a0, $a0, 30 +) +GLOBAL_ASM( +.late_rodata +.float 2 +.double 1 +.double 2 +.double 3 +.double 4 +.double 5 +.double 6 +.double 7 +.double 8 +.text +glabel doubles +addiu $a0, $a0, 31 +addiu $a0, $a0, 32 +addiu $a0, $a0, 33 +addiu $a0, $a0, 34 +addiu $a0, $a0, 35 +addiu $a0, $a0, 36 +addiu $a0, $a0, 37 +addiu $a0, $a0, 38 +addiu $a0, $a0, 39 +addiu $a0, $a0, 40 +addiu $a0, $a0, 41 +addiu $a0, $a0, 42 +addiu $a0, $a0, 43 +addiu $a0, $a0, 44 +addiu $a0, $a0, 45 +addiu $a0, $a0, 46 +addiu $a0, $a0, 47 +addiu $a0, $a0, 48 +addiu $a0, $a0, 49 +addiu $a0, $a0, 50 +addiu $a0, $a0, 51 +addiu $a0, $a0, 52 +addiu $a0, $a0, 53 +addiu $a0, $a0, 54 +addiu $a0, $a0, 55 +addiu $a0, $a0, 56 +addiu $a0, $a0, 57 +addiu $a0, $a0, 58 +addiu $a0, $a0, 59 +addiu $a0, $a0, 60 +addiu $a0, $a0, 61 +addiu $a0, $a0, 62 +addiu $a0, $a0, 63 +addiu $a0, $a0, 64 +addiu $a0, $a0, 65 +addiu $a0, $a0, 66 +addiu $a0, $a0, 67 +addiu $a0, $a0, 68 +) diff --git a/tools/asm-processor/tests/kpic-o2.objdump b/tools/asm-processor/tests/kpic-o2.objdump new file mode 100644 index 000000000..abf87aeb4 --- /dev/null +++ b/tools/asm-processor/tests/kpic-o2.objdump @@ -0,0 +1,46 @@ + +tests/kpic-o2.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 00000110 .text +00000000 l d .rodata 00000050 .rodata +00000000 g F .text 00000030 foo +00000030 g F .text 00000048 float_fn +00000078 g F .text 00000098 doubles +00000000 O *UND* 00000000 _gp_disp + + +RELOCATION RECORDS FOR [.text]: (none) + +Contents of section .text: + 0000 24840001 24840002 24840003 24840004 $...$...$...$... + 0010 24840005 24840006 24840007 24840008 $...$...$...$... + 0020 24840009 2484000a 2484000b 2484000c $...$...$...$... + 0030 2484000d 2484000e 2484000f 24840010 $...$...$...$... + 0040 24840011 24840012 24840013 24840014 $...$...$...$... + 0050 24840015 24840016 24840017 24840018 $...$...$...$... + 0060 24840019 2484001a 2484001b 2484001c $...$...$...$... + 0070 2484001d 2484001e 2484001f 24840020 $...$...$...$.. + 0080 24840021 24840022 24840023 24840024 $..!$.."$..#$..$ + 0090 24840025 24840026 24840027 24840028 $..%$..&$..'$..( + 00a0 24840029 2484002a 2484002b 2484002c $..)$..*$..+$.., + 00b0 2484002d 2484002e 2484002f 24840030 $..-$...$../$..0 + 00c0 24840031 24840032 24840033 24840034 $..1$..2$..3$..4 + 00d0 24840035 24840036 24840037 24840038 $..5$..6$..7$..8 + 00e0 24840039 2484003a 2484003b 2484003c $..9$..:$..;$..< + 00f0 2484003d 2484003e 2484003f 24840040 $..=$..>$..?$..@ + 0100 24840041 24840042 24840043 24840044 $..A$..B$..C$..D +Contents of section .rodata: + 0000 3f800000 40000000 3ff00000 00000000 ?...@...?....... + 0010 40000000 00000000 40080000 00000000 @.......@....... + 0020 40100000 00000000 40140000 00000000 @.......@....... + 0030 40180000 00000000 401c0000 00000000 @.......@....... + 0040 40200000 00000000 00000000 00000000 @ .............. +Contents of section .options: + 0000 01200000 00000000 92000002 00000000 . .............. + 0010 000f0ff0 00000000 00000000 00000000 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 92000012 00000000 000f0ff0 00000000 ................ + 0010 00000000 00000000 ........ diff --git a/tools/asm-processor/tests/label-sameline.c b/tools/asm-processor/tests/label-sameline.c new file mode 100644 index 000000000..a35b43d85 --- /dev/null +++ b/tools/asm-processor/tests/label-sameline.c @@ -0,0 +1,7 @@ +GLOBAL_ASM( +.rdata +.word 0x12345678 +glabel blah +.word blah2 + /*a*/ blah2: /*b*/ .word blah /*c*/ +) diff --git a/tools/asm-processor/tests/label-sameline.objdump b/tools/asm-processor/tests/label-sameline.objdump new file mode 100644 index 000000000..1f1aacff4 --- /dev/null +++ b/tools/asm-processor/tests/label-sameline.objdump @@ -0,0 +1,25 @@ + +tests/label-sameline.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .rodata 00000010 .rodata +00000000 l d .rodata 00000000 +00000004 g .rodata 00000000 blah + + +RELOCATION RECORDS FOR [.rodata]: +OFFSET TYPE VALUE +00000004 R_MIPS_32 +00000008 R_MIPS_32 blah + + +Contents of section .rodata: + 0000 12345678 00000008 00000000 00000000 .4Vx............ +Contents of section .options: + 0000 01200000 00000000 00000000 00000000 . .............. + 0010 00000000 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 00000000 00000000 00000000 00000000 ................ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/large.c b/tools/asm-processor/tests/large.c new file mode 100644 index 000000000..4ffb4ac12 --- /dev/null +++ b/tools/asm-processor/tests/large.c @@ -0,0 +1,164 @@ + +GLOBAL_ASM( +glabel test + +addiu $sp, $sp, -24 + sw $zero, 4($sp) +lw $t6, 4($sp) +addu $t7, $a0, $t6 +sb $zero, ($t7) +lw $t8, 4($sp) +addiu $t9, $t8, 1 +slt $at, $t9, $a1 + sw $t9, 4($sp) + nop +jr $ra + addiu $sp, $sp, 24 +addiu $sp, $sp, -24 + sw $zero, 4($sp) +lw $t6, 4($sp) +addu $t7, $a0, $t6 +sb $zero, ($t7) +lw $t8, 4($sp) +addiu $t9, $t8, 1 +slt $at, $t9, $a1 + sw $t9, 4($sp) + nop +jr $ra + addiu $sp, $sp, 24 +addiu $sp, $sp, -24 + sw $zero, 4($sp) +lw $t6, 4($sp) +addu $t7, $a0, $t6 +sb $zero, ($t7) +lw $t8, 4($sp) +addiu $t9, $t8, 1 +slt $at, $t9, $a1 + sw $t9, 4($sp) + nop +jr $ra + addiu $sp, $sp, 24 +addiu $sp, $sp, -24 + sw $zero, 4($sp) +lw $t6, 4($sp) +addu $t7, $a0, $t6 +sb $zero, ($t7) +lw $t8, 4($sp) +addiu $t9, $t8, 1 +slt $at, $t9, $a1 + sw $t9, 4($sp) + nop +jr $ra + addiu $sp, $sp, 24 +addiu $sp, $sp, -24 + sw $zero, 4($sp) +lw $t6, 4($sp) +addu $t7, $a0, $t6 +sb $zero, ($t7) +lw $t8, 4($sp) +addiu $t9, $t8, 1 +slt $at, $t9, $a1 + sw $t9, 4($sp) + nop +jr $ra + addiu $sp, $sp, 24 +addiu $sp, $sp, -24 + sw $zero, 4($sp) +lw $t6, 4($sp) +addu $t7, $a0, $t6 +sb $zero, ($t7) +lw $t8, 4($sp) +addiu $t9, $t8, 1 +slt $at, $t9, $a1 + sw $t9, 4($sp) + nop +jr $ra + addiu $sp, $sp, 24 +addiu $sp, $sp, -24 + sw $zero, 4($sp) +lw $t6, 4($sp) +addu $t7, $a0, $t6 +sb $zero, ($t7) +lw $t8, 4($sp) +addiu $t9, $t8, 1 +slt $at, $t9, $a1 + sw $t9, 4($sp) + nop +jr $ra + addiu $sp, $sp, 24 +addiu $sp, $sp, -24 + sw $zero, 4($sp) +lw $t6, 4($sp) +addu $t7, $a0, $t6 +sb $zero, ($t7) +lw $t8, 4($sp) +addiu $t9, $t8, 1 +slt $at, $t9, $a1 + sw $t9, 4($sp) + nop +jr $ra + addiu $sp, $sp, 24 +addiu $sp, $sp, -24 + sw $zero, 4($sp) +lw $t6, 4($sp) +addu $t7, $a0, $t6 +sb $zero, ($t7) +lw $t8, 4($sp) +addiu $t9, $t8, 1 +slt $at, $t9, $a1 + sw $t9, 4($sp) + nop +jr $ra + addiu $sp, $sp, 24 +addiu $sp, $sp, -24 + sw $zero, 4($sp) +lw $t6, 4($sp) +addu $t7, $a0, $t6 +sb $zero, ($t7) +lw $t8, 4($sp) +addiu $t9, $t8, 1 +slt $at, $t9, $a1 + sw $t9, 4($sp) + nop +jr $ra + addiu $sp, $sp, 24 +addiu $sp, $sp, -24 + sw $zero, 4($sp) +lw $t6, 4($sp) +addu $t7, $a0, $t6 +sb $zero, ($t7) +lw $t8, 4($sp) +addiu $t9, $t8, 1 +slt $at, $t9, $a1 + sw $t9, 4($sp) + nop +jr $ra + addiu $sp, $sp, 24 +addiu $sp, $sp, -24 + sw $zero, 4($sp) +lw $t6, 4($sp) +addu $t7, $a0, $t6 +sb $zero, ($t7) +lw $t8, 4($sp) +addiu $t9, $t8, 1 +slt $at, $t9, $a1 + sw $t9, 4($sp) + nop +jr $ra + addiu $sp, $sp, 24 +addiu $sp, $sp, -24 + sw $zero, 4($sp) +lw $t6, 4($sp) +addu $t7, $a0, $t6 +sb $zero, ($t7) +lw $t8, 4($sp) +addiu $t9, $t8, 1 +slt $at, $t9, $a1 + sw $t9, 4($sp) + nop +jr $ra + addiu $sp, $sp, 24 + +) + +void foo(void) {} diff --git a/tools/asm-processor/tests/large.objdump b/tools/asm-processor/tests/large.objdump new file mode 100644 index 000000000..17409a7af --- /dev/null +++ b/tools/asm-processor/tests/large.objdump @@ -0,0 +1,58 @@ + +tests/large.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 00000280 .text +00000270 g F .text 00000010 foo +00000000 g F .text 00000270 test + + +Contents of section .text: + 0000 27bdffe8 afa00004 8fae0004 008e7821 '.............x! + 0010 a1e00000 8fb80004 27190001 0325082a ........'....%.* + 0020 afb90004 00000000 03e00008 27bd0018 ............'... + 0030 27bdffe8 afa00004 8fae0004 008e7821 '.............x! + 0040 a1e00000 8fb80004 27190001 0325082a ........'....%.* + 0050 afb90004 00000000 03e00008 27bd0018 ............'... + 0060 27bdffe8 afa00004 8fae0004 008e7821 '.............x! + 0070 a1e00000 8fb80004 27190001 0325082a ........'....%.* + 0080 afb90004 00000000 03e00008 27bd0018 ............'... + 0090 27bdffe8 afa00004 8fae0004 008e7821 '.............x! + 00a0 a1e00000 8fb80004 27190001 0325082a ........'....%.* + 00b0 afb90004 00000000 03e00008 27bd0018 ............'... + 00c0 27bdffe8 afa00004 8fae0004 008e7821 '.............x! + 00d0 a1e00000 8fb80004 27190001 0325082a ........'....%.* + 00e0 afb90004 00000000 03e00008 27bd0018 ............'... + 00f0 27bdffe8 afa00004 8fae0004 008e7821 '.............x! + 0100 a1e00000 8fb80004 27190001 0325082a ........'....%.* + 0110 afb90004 00000000 03e00008 27bd0018 ............'... + 0120 27bdffe8 afa00004 8fae0004 008e7821 '.............x! + 0130 a1e00000 8fb80004 27190001 0325082a ........'....%.* + 0140 afb90004 00000000 03e00008 27bd0018 ............'... + 0150 27bdffe8 afa00004 8fae0004 008e7821 '.............x! + 0160 a1e00000 8fb80004 27190001 0325082a ........'....%.* + 0170 afb90004 00000000 03e00008 27bd0018 ............'... + 0180 27bdffe8 afa00004 8fae0004 008e7821 '.............x! + 0190 a1e00000 8fb80004 27190001 0325082a ........'....%.* + 01a0 afb90004 00000000 03e00008 27bd0018 ............'... + 01b0 27bdffe8 afa00004 8fae0004 008e7821 '.............x! + 01c0 a1e00000 8fb80004 27190001 0325082a ........'....%.* + 01d0 afb90004 00000000 03e00008 27bd0018 ............'... + 01e0 27bdffe8 afa00004 8fae0004 008e7821 '.............x! + 01f0 a1e00000 8fb80004 27190001 0325082a ........'....%.* + 0200 afb90004 00000000 03e00008 27bd0018 ............'... + 0210 27bdffe8 afa00004 8fae0004 008e7821 '.............x! + 0220 a1e00000 8fb80004 27190001 0325082a ........'....%.* + 0230 afb90004 00000000 03e00008 27bd0018 ............'... + 0240 27bdffe8 afa00004 8fae0004 008e7821 '.............x! + 0250 a1e00000 8fb80004 27190001 0325082a ........'....%.* + 0260 afb90004 00000000 03e00008 27bd0018 ............'... + 0270 03e00008 00000000 03e00008 00000000 ................ +Contents of section .options: + 0000 01200000 00000000 80000000 00000000 . .............. + 0010 00000000 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 a300c032 00000000 00000000 00000000 ...2............ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/late_rodata_align.c b/tools/asm-processor/tests/late_rodata_align.c new file mode 100644 index 000000000..7367c792b --- /dev/null +++ b/tools/asm-processor/tests/late_rodata_align.c @@ -0,0 +1,80 @@ +GLOBAL_ASM( +.late_rodata + .float 4.1 + .float 4.2 + .float 4.3 + .float 4.4 +.text +glabel a + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop +) + +float foo(void) { "foo"; return 1.1f; } + +GLOBAL_ASM( +.late_rodata +.late_rodata_alignment 4 + .float 5.1 + .float 5.2 + .float 5.3 + .float 5.4 +.text +glabel b + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop +) + +float bar(void) { "bar"; return 1.2f; } + +GLOBAL_ASM( +.late_rodata +.late_rodata_alignment 8 + .float 6.1 + .float 6.2 + .float 6.3 + .float 6.4 + .float 6.5 +.text +glabel c + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop +) + diff --git a/tools/asm-processor/tests/late_rodata_align.objdump b/tools/asm-processor/tests/late_rodata_align.objdump new file mode 100644 index 000000000..87c05e866 --- /dev/null +++ b/tools/asm-processor/tests/late_rodata_align.objdump @@ -0,0 +1,51 @@ + +tests/late_rodata_align.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 000000f0 .text +00000000 l d .rodata 00000050 .rodata +00000040 g F .text 0000001c foo +00000090 g F .text 0000001c bar +00000000 g F .text 00000040 a +0000005c g F .text 00000034 b +000000ac g F .text 00000038 c + + +RELOCATION RECORDS FOR [.text]: +OFFSET TYPE VALUE +00000040 R_MIPS_HI16 .rodata +00000048 R_MIPS_LO16 .rodata +00000090 R_MIPS_HI16 .rodata +00000098 R_MIPS_LO16 .rodata + + +Contents of section .text: + 0000 00000000 00000000 00000000 00000000 ................ + 0010 00000000 00000000 00000000 00000000 ................ + 0020 00000000 00000000 00000000 00000000 ................ + 0030 00000000 00000000 00000000 00000000 ................ + 0040 3c010000 03e00008 c4200018 03e00008 <........ ...... + 0050 00000000 03e00008 00000000 00000000 ................ + 0060 00000000 00000000 00000000 00000000 ................ + 0070 00000000 00000000 00000000 00000000 ................ + 0080 00000000 00000000 00000000 00000000 ................ + 0090 3c010000 03e00008 c420002c 03e00008 <........ .,.... + 00a0 00000000 03e00008 00000000 00000000 ................ + 00b0 00000000 00000000 00000000 00000000 ................ + 00c0 00000000 00000000 00000000 00000000 ................ + 00d0 00000000 00000000 00000000 00000000 ................ + 00e0 00000000 00000000 00000000 00000000 ................ +Contents of section .rodata: + 0000 666f6f00 62617200 40833333 40866666 foo.bar.@.33@.ff + 0010 4089999a 408ccccd 3f8ccccd 40a33333 @...@...?...@.33 + 0020 40a66666 40a9999a 40accccd 3f99999a @.ff@...@...?... + 0030 40c33333 40c66666 40c9999a 40cccccd @.33@.ff@...@... + 0040 40d00000 00000000 00000000 00000000 @............... +Contents of section .options: + 0000 01200000 00000000 80000002 00000000 . .............. + 0010 000005f1 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 80000002 00000000 000005f1 00000000 ................ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/late_rodata_doubles.c b/tools/asm-processor/tests/late_rodata_doubles.c new file mode 100644 index 000000000..0a27b4148 --- /dev/null +++ b/tools/asm-processor/tests/late_rodata_doubles.c @@ -0,0 +1,83 @@ +GLOBAL_ASM( +.late_rodata + .float 4.1 +.text +glabel a + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop +) + +float foo(void) { + return 4.15f; +} + +GLOBAL_ASM( +.late_rodata + .float 4.2 + .word 0 + .double 4.3 +.text +glabel b + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop +) + +float bar(void) { + return 4.4f; +} + +GLOBAL_ASM( +.late_rodata + .float 4.55 + .double 4.6 +.text +glabel c + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop +) + +float baz(void) { + return 4.6f; +} diff --git a/tools/asm-processor/tests/late_rodata_doubles.objdump b/tools/asm-processor/tests/late_rodata_doubles.objdump new file mode 100644 index 000000000..84d7e67f4 --- /dev/null +++ b/tools/asm-processor/tests/late_rodata_doubles.objdump @@ -0,0 +1,55 @@ + +tests/late_rodata_doubles.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 00000120 .text +00000000 l d .rodata 00000030 .rodata +00000040 g F .text 0000001c foo +0000009c g F .text 0000001c bar +000000f8 g F .text 0000001c baz +00000000 g F .text 00000040 a +0000005c g F .text 00000040 b +000000b8 g F .text 00000040 c + + +RELOCATION RECORDS FOR [.text]: +OFFSET TYPE VALUE +00000040 R_MIPS_HI16 .rodata +00000048 R_MIPS_LO16 .rodata +0000009c R_MIPS_HI16 .rodata +000000a4 R_MIPS_LO16 .rodata +000000f8 R_MIPS_HI16 .rodata +00000100 R_MIPS_LO16 .rodata + + +Contents of section .text: + 0000 00000000 00000000 00000000 00000000 ................ + 0010 00000000 00000000 00000000 00000000 ................ + 0020 00000000 00000000 00000000 00000000 ................ + 0030 00000000 00000000 00000000 00000000 ................ + 0040 3c010000 03e00008 c4200004 03e00008 <........ ...... + 0050 00000000 03e00008 00000000 00000000 ................ + 0060 00000000 00000000 00000000 00000000 ................ + 0070 00000000 00000000 00000000 00000000 ................ + 0080 00000000 00000000 00000000 00000000 ................ + 0090 00000000 00000000 00000000 3c010000 ............<... + 00a0 03e00008 c4200018 03e00008 00000000 ..... .......... + 00b0 03e00008 00000000 00000000 00000000 ................ + 00c0 00000000 00000000 00000000 00000000 ................ + 00d0 00000000 00000000 00000000 00000000 ................ + 00e0 00000000 00000000 00000000 00000000 ................ + 00f0 00000000 00000000 3c010000 03e00008 ........<....... + 0100 c4200028 03e00008 00000000 03e00008 . .(............ + 0110 00000000 00000000 00000000 00000000 ................ +Contents of section .rodata: + 0000 40833333 4084cccd 40866666 00000000 @.33@...@.ff.... + 0010 40113333 33333333 408ccccd 4091999a @.333333@...@... + 0020 40126666 66666666 40933333 00000000 @.ffffff@.33.... +Contents of section .options: + 0000 01200000 00000000 80000002 00000000 . .............. + 0010 000000f1 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 80000002 00000000 000000f1 00000000 ................ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/late_rodata_doubles_mips1.c b/tools/asm-processor/tests/late_rodata_doubles_mips1.c new file mode 100644 index 000000000..b97261f68 --- /dev/null +++ b/tools/asm-processor/tests/late_rodata_doubles_mips1.c @@ -0,0 +1,86 @@ +// COMPILE-FLAGS: -O2 +// COMPILE-ISET: -mips1 +// exact copy of late_rodata_doubles.c except for the -mips1 -O2 additions +GLOBAL_ASM( +.late_rodata + .float 4.1 +.text +glabel a + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop +) + +float foo(void) { + return 4.15f; +} + +GLOBAL_ASM( +.late_rodata + .float 4.2 + .word 0 + .double 4.3 +.text +glabel b + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop +) + +float bar(void) { + return 4.4f; +} + +GLOBAL_ASM( +.late_rodata + .float 4.55 + .double 4.6 +.text +glabel c + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop +) + +float baz(void) { + return 4.6f; +} diff --git a/tools/asm-processor/tests/late_rodata_doubles_mips1.objdump b/tools/asm-processor/tests/late_rodata_doubles_mips1.objdump new file mode 100644 index 000000000..8fac85f46 --- /dev/null +++ b/tools/asm-processor/tests/late_rodata_doubles_mips1.objdump @@ -0,0 +1,52 @@ + +tests/late_rodata_doubles_mips1.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 000000f0 .text +00000000 l d .rodata 00000030 .rodata +00000040 g F .text 00000010 foo +00000090 g F .text 00000010 bar +000000e0 g F .text 00000010 baz +00000000 g F .text 00000040 a +00000050 g F .text 00000040 b +000000a0 g F .text 00000040 c + + +RELOCATION RECORDS FOR [.text]: +OFFSET TYPE VALUE +00000040 R_MIPS_HI16 .rodata +00000044 R_MIPS_LO16 .rodata +00000090 R_MIPS_HI16 .rodata +00000094 R_MIPS_LO16 .rodata +000000e0 R_MIPS_HI16 .rodata +000000e4 R_MIPS_LO16 .rodata + + +Contents of section .text: + 0000 00000000 00000000 00000000 00000000 ................ + 0010 00000000 00000000 00000000 00000000 ................ + 0020 00000000 00000000 00000000 00000000 ................ + 0030 00000000 00000000 00000000 00000000 ................ + 0040 3c010000 c4200004 03e00008 00000000 <.... .......... + 0050 00000000 00000000 00000000 00000000 ................ + 0060 00000000 00000000 00000000 00000000 ................ + 0070 00000000 00000000 00000000 00000000 ................ + 0080 00000000 00000000 00000000 00000000 ................ + 0090 3c010000 c4200018 03e00008 00000000 <.... .......... + 00a0 00000000 00000000 00000000 00000000 ................ + 00b0 00000000 00000000 00000000 00000000 ................ + 00c0 00000000 00000000 00000000 00000000 ................ + 00d0 00000000 00000000 00000000 00000000 ................ + 00e0 3c010000 c4200028 03e00008 00000000 <.... .(........ +Contents of section .rodata: + 0000 40833333 4084cccd 40866666 00000000 @.33@...@.ff.... + 0010 40113333 33333333 408ccccd 4091999a @.333333@...@... + 0020 40126666 66666666 40933333 00000000 @.ffffff@.33.... +Contents of section .options: + 0000 01200000 00000000 80000002 00000000 . .............. + 0010 000c0011 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 80000002 00000000 000c0011 00000000 ................ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/late_rodata_jtbl.c b/tools/asm-processor/tests/late_rodata_jtbl.c new file mode 100644 index 000000000..3c2a5bba2 --- /dev/null +++ b/tools/asm-processor/tests/late_rodata_jtbl.c @@ -0,0 +1,153 @@ +// COMPILE-FLAGS: -O2 +GLOBAL_ASM( +.late_rodata +.double 1 +.double 2 +.double 3 +.double 4 +.double 5 +.double 6 +.double 7 +.double 8 +.text +glabel doubles1 +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +) + +float a(void) { return 1.1f; } + +GLOBAL_ASM( +.late_rodata +.float 1 +.double 2 +.double 3 +.double 4 +.double 5 +.double 6 +.double 7 +.double 8 +.double 9 +.float 10 +.text +glabel doubles2 +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +) + +GLOBAL_ASM( +glabel a2 +move $a0, $a0 +nop +nop +nop +jr $ra +move $a0, $a0 +) + +GLOBAL_ASM( +.late_rodata + +glabel jtbl +.word case0, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10 +.word case11, case12, case13, case14, case15, case16, case17, case18, case19, case20 +.word case21, case22, case23, case24, case25, case26 + +.text +glabel foo +sltiu $at, $a0, 0xa +beqz $at, .L756E659B + sll $t7, $a0, 2 +lui $at, %hi(jtbl) +addu $at, $at, $t7 +lw $t7, %lo(jtbl)($at) +jr $t7 + nop +case0: addiu $a0, $a0, 1 +case1: addiu $a0, $a0, 1 +case2: addiu $a0, $a0, 1 +case3: addiu $a0, $a0, 1 +case4: addiu $a0, $a0, 1 +case5: addiu $a0, $a0, 1 +case6: addiu $a0, $a0, 1 +case7: addiu $a0, $a0, 1 +case8: addiu $a0, $a0, 1 +case9: addiu $a0, $a0, 1 +case10: addiu $a0, $a0, 1 +case11: addiu $a0, $a0, 1 +case12: addiu $a0, $a0, 1 +case13: addiu $a0, $a0, 1 +case14: addiu $a0, $a0, 1 +case15: addiu $a0, $a0, 1 +case16: addiu $a0, $a0, 1 +case17: addiu $a0, $a0, 1 +case18: addiu $a0, $a0, 1 +case19: addiu $a0, $a0, 1 +case20: addiu $a0, $a0, 1 +case21: addiu $a0, $a0, 1 +case22: addiu $a0, $a0, 1 +case23: addiu $a0, $a0, 1 +case24: addiu $a0, $a0, 1 +case25: addiu $a0, $a0, 1 +case26: +jr $ra + addiu $v0, $a0, 1 + +.L756E659B: +addiu $v0, $zero, 2 +jr $ra + nop +) + +GLOBAL_ASM( +glabel b2 +move $a0, $a0 +nop +nop +jr $ra +move $a0, $a0 +) + +float b(void) { return 1.2f; } diff --git a/tools/asm-processor/tests/late_rodata_jtbl.objdump b/tools/asm-processor/tests/late_rodata_jtbl.objdump new file mode 100644 index 000000000..44bb6e847 --- /dev/null +++ b/tools/asm-processor/tests/late_rodata_jtbl.objdump @@ -0,0 +1,110 @@ + +tests/late_rodata_jtbl.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 000001a0 .text +00000000 l d .rodata 00000100 .rodata +00000000 l d .text 00000000 +0000005c g F .text 0000000c a +0000018c g F .text 0000000c b +00000000 g F .text 0000005c doubles1 +00000068 g F .text 0000005c doubles2 +000000c4 g F .text 00000018 a2 +000000dc g F .text 0000009c foo +0000008c g .rodata 00000000 jtbl +00000178 g F .text 00000014 b2 + + +RELOCATION RECORDS FOR [.text]: +OFFSET TYPE VALUE +0000005c R_MIPS_HI16 .rodata +00000064 R_MIPS_LO16 .rodata +0000018c R_MIPS_HI16 .rodata +00000194 R_MIPS_LO16 .rodata +000000e8 R_MIPS_HI16 jtbl +000000f0 R_MIPS_LO16 jtbl + + +RELOCATION RECORDS FOR [.rodata]: +OFFSET TYPE VALUE +0000008c R_MIPS_32 +00000090 R_MIPS_32 +00000094 R_MIPS_32 +00000098 R_MIPS_32 +0000009c R_MIPS_32 +000000a0 R_MIPS_32 +000000a4 R_MIPS_32 +000000a8 R_MIPS_32 +000000ac R_MIPS_32 +000000b0 R_MIPS_32 +000000b4 R_MIPS_32 +000000b8 R_MIPS_32 +000000bc R_MIPS_32 +000000c0 R_MIPS_32 +000000c4 R_MIPS_32 +000000c8 R_MIPS_32 +000000cc R_MIPS_32 +000000d0 R_MIPS_32 +000000d4 R_MIPS_32 +000000d8 R_MIPS_32 +000000dc R_MIPS_32 +000000e0 R_MIPS_32 +000000e4 R_MIPS_32 +000000e8 R_MIPS_32 +000000ec R_MIPS_32 +000000f0 R_MIPS_32 +000000f4 R_MIPS_32 + + +Contents of section .text: + 0000 00000000 00000000 00000000 00000000 ................ + 0010 00000000 00000000 00000000 00000000 ................ + 0020 00000000 00000000 00000000 00000000 ................ + 0030 00000000 00000000 00000000 00000000 ................ + 0040 00000000 00000000 00000000 00000000 ................ + 0050 00000000 00000000 00000000 3c010000 ............<... + 0060 03e00008 c4200040 00000000 00000000 ..... .@........ + 0070 00000000 00000000 00000000 00000000 ................ + 0080 00000000 00000000 00000000 00000000 ................ + 0090 00000000 00000000 00000000 00000000 ................ + 00a0 00000000 00000000 00000000 00000000 ................ + 00b0 00000000 00000000 00000000 00000000 ................ + 00c0 00000000 00802025 00000000 00000000 ...... %........ + 00d0 00000000 03e00008 00802025 2c81000a .......... %,... + 00e0 10200022 00047880 3c010000 002f0821 . ."..x.<..../.! + 00f0 8c2f0000 01e00008 00000000 24840001 ./..........$... + 0100 24840001 24840001 24840001 24840001 $...$...$...$... + 0110 24840001 24840001 24840001 24840001 $...$...$...$... + 0120 24840001 24840001 24840001 24840001 $...$...$...$... + 0130 24840001 24840001 24840001 24840001 $...$...$...$... + 0140 24840001 24840001 24840001 24840001 $...$...$...$... + 0150 24840001 24840001 24840001 24840001 $...$...$...$... + 0160 24840001 03e00008 24820001 24020002 $.......$...$... + 0170 03e00008 00000000 00802025 00000000 .......... %.... + 0180 00000000 03e00008 00802025 3c010000 .......... %<... + 0190 03e00008 c42000f8 00000000 00000000 ..... .......... +Contents of section .rodata: + 0000 3ff00000 00000000 40000000 00000000 ?.......@....... + 0010 40080000 00000000 40100000 00000000 @.......@....... + 0020 40140000 00000000 40180000 00000000 @.......@....... + 0030 401c0000 00000000 40200000 00000000 @.......@ ...... + 0040 3f8ccccd 3f800000 40000000 00000000 ?...?...@....... + 0050 40080000 00000000 40100000 00000000 @.......@....... + 0060 40140000 00000000 40180000 00000000 @.......@....... + 0070 401c0000 00000000 40200000 00000000 @.......@ ...... + 0080 40220000 00000000 41200000 000000fc @"......A ...... + 0090 00000100 00000104 00000108 0000010c ................ + 00a0 00000110 00000114 00000118 0000011c ................ + 00b0 00000120 00000124 00000128 0000012c ... ...$...(..., + 00c0 00000130 00000134 00000138 0000013c ...0...4...8...< + 00d0 00000140 00000144 00000148 0000014c ...@...D...H...L + 00e0 00000150 00000154 00000158 0000015c ...P...T...X...\ + 00f0 00000160 00000164 3f99999a 00000000 ...`...d?....... +Contents of section .options: + 0000 01200000 00000000 80004002 00000000 . ........@..... + 0010 000000f1 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 8000c016 00000000 000000f1 00000000 ................ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/late_rodata_jtbl_mips1.c b/tools/asm-processor/tests/late_rodata_jtbl_mips1.c new file mode 100644 index 000000000..505f4c1d5 --- /dev/null +++ b/tools/asm-processor/tests/late_rodata_jtbl_mips1.c @@ -0,0 +1,155 @@ +// COMPILE-FLAGS: -O2 +// COMPILE-ISET: -mips1 +// exact copy of late_rodata_jtbl.c except for the -mips1 addition +GLOBAL_ASM( +.late_rodata +.double 1 +.double 2 +.double 3 +.double 4 +.double 5 +.double 6 +.double 7 +.double 8 +.text +glabel doubles1 +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +) + +float a(void) { return 1.1f; } + +GLOBAL_ASM( +.late_rodata +.float 1 +.double 2 +.double 3 +.double 4 +.double 5 +.double 6 +.double 7 +.double 8 +.double 9 +.float 10 +.text +glabel doubles2 +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +) + +GLOBAL_ASM( +glabel a2 +move $a0, $a0 +nop +nop +nop +jr $ra +move $a0, $a0 +) + +GLOBAL_ASM( +.late_rodata + +glabel jtbl +.word case0, case1, case2, case3, case4, case5, case6, case7, case8, case9, case10 +.word case11, case12, case13, case14, case15, case16, case17, case18, case19, case20 +.word case21, case22, case23, case24, case25, case26 + +.text +glabel foo +sltiu $at, $a0, 0xa +beqz $at, .L756E659B + sll $t7, $a0, 2 +lui $at, %hi(jtbl) +addu $at, $at, $t7 +lw $t7, %lo(jtbl)($at) +jr $t7 + nop +case0: addiu $a0, $a0, 1 +case1: addiu $a0, $a0, 1 +case2: addiu $a0, $a0, 1 +case3: addiu $a0, $a0, 1 +case4: addiu $a0, $a0, 1 +case5: addiu $a0, $a0, 1 +case6: addiu $a0, $a0, 1 +case7: addiu $a0, $a0, 1 +case8: addiu $a0, $a0, 1 +case9: addiu $a0, $a0, 1 +case10: addiu $a0, $a0, 1 +case11: addiu $a0, $a0, 1 +case12: addiu $a0, $a0, 1 +case13: addiu $a0, $a0, 1 +case14: addiu $a0, $a0, 1 +case15: addiu $a0, $a0, 1 +case16: addiu $a0, $a0, 1 +case17: addiu $a0, $a0, 1 +case18: addiu $a0, $a0, 1 +case19: addiu $a0, $a0, 1 +case20: addiu $a0, $a0, 1 +case21: addiu $a0, $a0, 1 +case22: addiu $a0, $a0, 1 +case23: addiu $a0, $a0, 1 +case24: addiu $a0, $a0, 1 +case25: addiu $a0, $a0, 1 +case26: +jr $ra + addiu $v0, $a0, 1 + +.L756E659B: +addiu $v0, $zero, 2 +jr $ra + nop +) + +GLOBAL_ASM( +glabel b2 +move $a0, $a0 +nop +nop +jr $ra +move $a0, $a0 +) + +float b(void) { return 1.2f; } diff --git a/tools/asm-processor/tests/late_rodata_jtbl_mips1.objdump b/tools/asm-processor/tests/late_rodata_jtbl_mips1.objdump new file mode 100644 index 000000000..d37c8bb9e --- /dev/null +++ b/tools/asm-processor/tests/late_rodata_jtbl_mips1.objdump @@ -0,0 +1,110 @@ + +tests/late_rodata_jtbl_mips1.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 000001a0 .text +00000000 l d .rodata 00000100 .rodata +00000000 l d .text 00000000 +0000005c g F .text 00000010 a +00000190 g F .text 00000010 b +00000000 g F .text 0000005c doubles1 +0000006c g F .text 0000005c doubles2 +000000c8 g F .text 00000018 a2 +000000e0 g F .text 0000009c foo +0000008c g .rodata 00000000 jtbl +0000017c g F .text 00000014 b2 + + +RELOCATION RECORDS FOR [.text]: +OFFSET TYPE VALUE +0000005c R_MIPS_HI16 .rodata +00000060 R_MIPS_LO16 .rodata +00000190 R_MIPS_HI16 .rodata +00000194 R_MIPS_LO16 .rodata +000000ec R_MIPS_HI16 jtbl +000000f4 R_MIPS_LO16 jtbl + + +RELOCATION RECORDS FOR [.rodata]: +OFFSET TYPE VALUE +0000008c R_MIPS_32 +00000090 R_MIPS_32 +00000094 R_MIPS_32 +00000098 R_MIPS_32 +0000009c R_MIPS_32 +000000a0 R_MIPS_32 +000000a4 R_MIPS_32 +000000a8 R_MIPS_32 +000000ac R_MIPS_32 +000000b0 R_MIPS_32 +000000b4 R_MIPS_32 +000000b8 R_MIPS_32 +000000bc R_MIPS_32 +000000c0 R_MIPS_32 +000000c4 R_MIPS_32 +000000c8 R_MIPS_32 +000000cc R_MIPS_32 +000000d0 R_MIPS_32 +000000d4 R_MIPS_32 +000000d8 R_MIPS_32 +000000dc R_MIPS_32 +000000e0 R_MIPS_32 +000000e4 R_MIPS_32 +000000e8 R_MIPS_32 +000000ec R_MIPS_32 +000000f0 R_MIPS_32 +000000f4 R_MIPS_32 + + +Contents of section .text: + 0000 00000000 00000000 00000000 00000000 ................ + 0010 00000000 00000000 00000000 00000000 ................ + 0020 00000000 00000000 00000000 00000000 ................ + 0030 00000000 00000000 00000000 00000000 ................ + 0040 00000000 00000000 00000000 00000000 ................ + 0050 00000000 00000000 00000000 3c010000 ............<... + 0060 c4200040 03e00008 00000000 00000000 . .@............ + 0070 00000000 00000000 00000000 00000000 ................ + 0080 00000000 00000000 00000000 00000000 ................ + 0090 00000000 00000000 00000000 00000000 ................ + 00a0 00000000 00000000 00000000 00000000 ................ + 00b0 00000000 00000000 00000000 00000000 ................ + 00c0 00000000 00000000 00802025 00000000 .......... %.... + 00d0 00000000 00000000 03e00008 00802025 .............. % + 00e0 2c81000a 10200022 00047880 3c010000 ,.... ."..x.<... + 00f0 002f0821 8c2f0000 01e00008 00000000 ./.!./.......... + 0100 24840001 24840001 24840001 24840001 $...$...$...$... + 0110 24840001 24840001 24840001 24840001 $...$...$...$... + 0120 24840001 24840001 24840001 24840001 $...$...$...$... + 0130 24840001 24840001 24840001 24840001 $...$...$...$... + 0140 24840001 24840001 24840001 24840001 $...$...$...$... + 0150 24840001 24840001 24840001 24840001 $...$...$...$... + 0160 24840001 24840001 03e00008 24820001 $...$.......$... + 0170 24020002 03e00008 00000000 00802025 $............. % + 0180 00000000 00000000 03e00008 00802025 .............. % + 0190 3c010000 c42000f8 03e00008 00000000 <.... .......... +Contents of section .rodata: + 0000 3ff00000 00000000 40000000 00000000 ?.......@....... + 0010 40080000 00000000 40100000 00000000 @.......@....... + 0020 40140000 00000000 40180000 00000000 @.......@....... + 0030 401c0000 00000000 40200000 00000000 @.......@ ...... + 0040 3f8ccccd 3f800000 40000000 00000000 ?...?...@....... + 0050 40080000 00000000 40100000 00000000 @.......@....... + 0060 40140000 00000000 40180000 00000000 @.......@....... + 0070 401c0000 00000000 40200000 00000000 @.......@ ...... + 0080 40220000 00000000 41200000 00000100 @"......A ...... + 0090 00000104 00000108 0000010c 00000110 ................ + 00a0 00000114 00000118 0000011c 00000120 ............... + 00b0 00000124 00000128 0000012c 00000130 ...$...(...,...0 + 00c0 00000134 00000138 0000013c 00000140 ...4...8...<...@ + 00d0 00000144 00000148 0000014c 00000150 ...D...H...L...P + 00e0 00000154 00000158 0000015c 00000160 ...T...X...\...` + 00f0 00000164 00000168 3f99999a 00000000 ...d...h?....... +Contents of section .options: + 0000 01200000 00000000 80004002 00000000 . ........@..... + 0010 000000f1 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 8000c016 00000000 000000f1 00000000 ................ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/late_rodata_misaligned_doubles.c b/tools/asm-processor/tests/late_rodata_misaligned_doubles.c new file mode 100644 index 000000000..a453dbdd4 --- /dev/null +++ b/tools/asm-processor/tests/late_rodata_misaligned_doubles.c @@ -0,0 +1,77 @@ +GLOBAL_ASM( +.late_rodata + .float 4.01 + .word 0 + .double 4.02 +.text +glabel a + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop +) + +double foo(void) { return 4.03; } + +GLOBAL_ASM( +.late_rodata + .float 4.04 + .double 4.05 +.text +glabel b + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop +) + +double bar(void) { return 4.06; } +float baz(void) { return 4.07f; } + +GLOBAL_ASM( +.late_rodata + .double 4.08 +.text +glabel c + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop +) + diff --git a/tools/asm-processor/tests/late_rodata_misaligned_doubles.objdump b/tools/asm-processor/tests/late_rodata_misaligned_doubles.objdump new file mode 100644 index 000000000..cdba84de4 --- /dev/null +++ b/tools/asm-processor/tests/late_rodata_misaligned_doubles.objdump @@ -0,0 +1,56 @@ + +tests/late_rodata_misaligned_doubles.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 00000120 .text +00000000 l d .rodata 00000040 .rodata +00000040 g F .text 0000001c foo +0000009c g F .text 0000001c bar +000000b8 g F .text 0000001c baz +00000000 g F .text 00000040 a +0000005c g F .text 00000040 b +000000d4 g F .text 00000040 c + + +RELOCATION RECORDS FOR [.text]: +OFFSET TYPE VALUE +00000040 R_MIPS_HI16 .rodata +00000048 R_MIPS_LO16 .rodata +0000009c R_MIPS_HI16 .rodata +000000a4 R_MIPS_LO16 .rodata +000000b8 R_MIPS_HI16 .rodata +000000c0 R_MIPS_LO16 .rodata + + +Contents of section .text: + 0000 00000000 00000000 00000000 00000000 ................ + 0010 00000000 00000000 00000000 00000000 ................ + 0020 00000000 00000000 00000000 00000000 ................ + 0030 00000000 00000000 00000000 00000000 ................ + 0040 3c010000 03e00008 d4200010 03e00008 <........ ...... + 0050 00000000 03e00008 00000000 00000000 ................ + 0060 00000000 00000000 00000000 00000000 ................ + 0070 00000000 00000000 00000000 00000000 ................ + 0080 00000000 00000000 00000000 00000000 ................ + 0090 00000000 00000000 00000000 3c010000 ............<... + 00a0 03e00008 d4200028 03e00008 00000000 ..... .(........ + 00b0 03e00008 00000000 3c010000 03e00008 ........<....... + 00c0 c4200030 03e00008 00000000 03e00008 . .0............ + 00d0 00000000 00000000 00000000 00000000 ................ + 00e0 00000000 00000000 00000000 00000000 ................ + 00f0 00000000 00000000 00000000 00000000 ................ + 0100 00000000 00000000 00000000 00000000 ................ + 0110 00000000 00000000 00000000 00000000 ................ +Contents of section .rodata: + 0000 408051ec 00000000 4010147a e147ae14 @.Q.....@..z.G.. + 0010 40101eb8 51eb851f 00000000 408147ae @...Q.......@.G. + 0020 40103333 33333333 40103d70 a3d70a3d @.333333@.=p...= + 0030 40823d71 00000000 401051eb 851eb852 @.=q....@.Q....R +Contents of section .options: + 0000 01200000 00000000 80000002 00000000 . .............. + 0010 000000f3 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 80000002 00000000 000000f3 00000000 ................ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/line-continuation-separate-file.s b/tools/asm-processor/tests/line-continuation-separate-file.s new file mode 100644 index 000000000..e1301804a --- /dev/null +++ b/tools/asm-processor/tests/line-continuation-separate-file.s @@ -0,0 +1,4 @@ +.rdata + label: .asciiz "1\n\ +2", \ + "34", "56" diff --git a/tools/asm-processor/tests/line-continuation.asmproc.d b/tools/asm-processor/tests/line-continuation.asmproc.d new file mode 100644 index 000000000..687dd1aee --- /dev/null +++ b/tools/asm-processor/tests/line-continuation.asmproc.d @@ -0,0 +1,3 @@ +tests/line-continuation.o: tests/line-continuation-separate-file.s + +tests/line-continuation-separate-file.s: diff --git a/tools/asm-processor/tests/line-continuation.c b/tools/asm-processor/tests/line-continuation.c new file mode 100644 index 000000000..d5ab09372 --- /dev/null +++ b/tools/asm-processor/tests/line-continuation.c @@ -0,0 +1,22 @@ +void foo(void) { "abcdef"; } + +GLOBAL_ASM( +.rdata + .ascii "AB" \ + "CD", "EF" + .ascii "GH\n\n\n\0\11\222\3333\44444\x1234567\n\nIJK" +) + +void bar(void) { "hello"; } + +GLOBAL_ASM( +.rdata + .asciiz "1\ +2" + .asciiz "34", "56" + .asciiz "78\n\n\n\0\11\222\3333\44444\x1234567\n\n9A" +) + +void baz(void) { "ghijkl"; } + +GLOBAL_ASM("tests/line-continuation-separate-file.s") diff --git a/tools/asm-processor/tests/line-continuation.objdump b/tools/asm-processor/tests/line-continuation.objdump new file mode 100644 index 000000000..038766fdb --- /dev/null +++ b/tools/asm-processor/tests/line-continuation.objdump @@ -0,0 +1,30 @@ + +tests/line-continuation.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 00000030 .text +00000000 l d .rodata 00000060 .rodata +00000000 g F .text 00000010 foo +00000010 g F .text 00000010 bar +00000020 g F .text 00000010 baz + + +Contents of section .text: + 0000 03e00008 00000000 03e00008 00000000 ................ + 0010 03e00008 00000000 03e00008 00000000 ................ + 0020 03e00008 00000000 03e00008 00000000 ................ +Contents of section .rodata: + 0000 61626364 65660000 41424344 45464748 abcdef..ABCDEFGH + 0010 0a0a0a00 0992db33 24343467 0a0a494a .......3$44g..IJ + 0020 4b000000 68656c6c 6f000000 31320033 K...hello...12.3 + 0030 34003536 0037380a 0a0a0009 92db3324 4.56.78.......3$ + 0040 3434670a 0a394100 6768696a 6b6c0000 44g..9A.ghijkl.. + 0050 310a3200 33340035 36000000 00000000 1.2.34.56....... +Contents of section .options: + 0000 01200000 00000000 80000000 00000000 . .............. + 0010 00000000 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 80000000 00000000 00000000 00000000 ................ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/o0.c b/tools/asm-processor/tests/o0.c new file mode 100644 index 000000000..6f8e5e419 --- /dev/null +++ b/tools/asm-processor/tests/o0.c @@ -0,0 +1,28 @@ +// COMPILE-FLAGS: -O0 + +int a(void) { return 1; } +GLOBAL_ASM( +glabel foo +addiu $a0, $a0, 1 +addiu $a0, $a0, 2 +addiu $a0, $a0, 3 +jr $ra +addiu $a0, $a0, 4 +) +float b(void) { return 1.2f; } +GLOBAL_ASM( +.late_rodata +glabel float1 +.float 12.34 + +.text +glabel bar +addiu $a0, $a0, 5 +addiu $a0, $a0, 6 +addiu $a0, $a0, 7 +addiu $a0, $a0, 8 +lui $v0, %hi(float1 + 1) +jr $ra +addiu $v0, $v0, %lo(float1 + 1) +) +float c(void) { return 1.3f; } diff --git a/tools/asm-processor/tests/o0.objdump b/tools/asm-processor/tests/o0.objdump new file mode 100644 index 000000000..f94ec7a05 --- /dev/null +++ b/tools/asm-processor/tests/o0.objdump @@ -0,0 +1,44 @@ + +tests/o0.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 00000090 .text +00000000 l d .rodata 00000010 .rodata +00000000 g F .text 0000001c a +00000030 g F .text 00000020 b +0000006c g F .text 00000020 c +0000001c g F .text 00000014 foo +00000050 g F .text 0000001c bar +00000004 g .rodata 00000000 float1 + + +RELOCATION RECORDS FOR [.text]: +OFFSET TYPE VALUE +00000030 R_MIPS_HI16 .rodata +00000034 R_MIPS_LO16 .rodata +0000006c R_MIPS_HI16 .rodata +00000070 R_MIPS_LO16 .rodata +00000060 R_MIPS_HI16 float1 +00000068 R_MIPS_LO16 float1 + + +Contents of section .text: + 0000 24020001 03e00008 00000000 03e00008 $............... + 0010 00000000 03e00008 00000000 24840001 ............$... + 0020 24840002 24840003 03e00008 24840004 $...$.......$... + 0030 3c010000 c4200000 03e00008 00000000 <.... .......... + 0040 03e00008 00000000 03e00008 00000000 ................ + 0050 24840005 24840006 24840007 24840008 $...$...$...$... + 0060 3c020000 03e00008 24420001 3c010000 <.......$B..<... + 0070 c4200008 03e00008 00000000 03e00008 . .............. + 0080 00000000 03e00008 00000000 00000000 ................ +Contents of section .rodata: + 0000 3f99999a 414570a4 3fa66666 00000000 ?...AEp.?.ff.... +Contents of section .options: + 0000 01200000 00000000 80000006 00000000 . .............. + 0010 00000011 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 80000016 00000000 00000011 00000000 ................ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/o2.c b/tools/asm-processor/tests/o2.c new file mode 100644 index 000000000..144a604e0 --- /dev/null +++ b/tools/asm-processor/tests/o2.c @@ -0,0 +1,26 @@ +// COMPILE-FLAGS: -O2 + +int a(void) { return 1; } +GLOBAL_ASM( +glabel foo +addiu $a0, $a0, 1 +addiu $a0, $a0, 2 +addiu $a0, $a0, 3 +jr $ra +addiu $a0, $a0, 4 +) +float b(void) { return 1.2f; } +GLOBAL_ASM( +.late_rodata +glabel float1 +.float 12.34 + +.text +glabel bar +addiu $a0, $a0, 5 +addiu $a0, $a0, 6 +lui $v0, %hi(float1 + 1) +jr $ra +addiu $v0, $v0, %lo(float1 + 1) +) +float c(void) { return 1.3f; } diff --git a/tools/asm-processor/tests/o2.objdump b/tools/asm-processor/tests/o2.objdump new file mode 100644 index 000000000..61e3fb0e5 --- /dev/null +++ b/tools/asm-processor/tests/o2.objdump @@ -0,0 +1,40 @@ + +tests/o2.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 00000050 .text +00000000 l d .rodata 00000010 .rodata +00000000 g F .text 00000008 a +0000001c g F .text 0000000c b +0000003c g F .text 0000000c c +00000008 g F .text 00000014 foo +00000028 g F .text 00000014 bar +00000004 g .rodata 00000000 float1 + + +RELOCATION RECORDS FOR [.text]: +OFFSET TYPE VALUE +0000001c R_MIPS_HI16 .rodata +00000024 R_MIPS_LO16 .rodata +0000003c R_MIPS_HI16 .rodata +00000044 R_MIPS_LO16 .rodata +00000030 R_MIPS_HI16 float1 +00000038 R_MIPS_LO16 float1 + + +Contents of section .text: + 0000 03e00008 24020001 24840001 24840002 ....$...$...$... + 0010 24840003 03e00008 24840004 3c010000 $.......$...<... + 0020 03e00008 c4200000 24840005 24840006 ..... ..$...$... + 0030 3c020000 03e00008 24420001 3c010000 <.......$B..<... + 0040 03e00008 c4200008 00000000 00000000 ..... .......... +Contents of section .rodata: + 0000 3f99999a 414570a4 3fa66666 00000000 ?...AEp.?.ff.... +Contents of section .options: + 0000 01200000 00000000 80000006 00000000 . .............. + 0010 00000011 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 80000016 00000000 00000011 00000000 ................ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/pascal.objdump b/tools/asm-processor/tests/pascal.objdump new file mode 100644 index 000000000..cb3740f0a --- /dev/null +++ b/tools/asm-processor/tests/pascal.objdump @@ -0,0 +1,137 @@ + +tests/pascal.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 000000e0 .text +00000000 l d .rodata 00000030 .rodata +00000000 l d .data 00000010 .data +00000000 l d .bss 00000010 .bss +00000000 l O .bss 00000000 $dat +00000000 g F .text 0000000c foo +000000d0 g F .text 0000000c bar +0000000c g F .text 00000004 test +00000048 g F .text 00000004 test2 +0000008c g F .text 00000044 test3 +00000000 *UND* 00000000 get +00000000 *UND* 00000000 put +00000000 *UND* 00000000 pascal_close +00000000 *UND* 00000000 fflush +00000000 *UND* 00000000 filesize +00000000 *UND* 00000000 curpos +00000000 *UND* 00000000 seek +00000000 *UND* 00000000 eof +00000000 *UND* 00000000 eoln +00000000 *UND* 00000000 page +00000000 *UND* 00000000 reset +00000000 *UND* 00000000 rewrite +00000000 *UND* 00000000 cos +00000000 *UND* 00000000 exp +00000000 *UND* 00000000 sqrt +00000000 *UND* 00000000 log +00000000 *UND* 00000000 atan +00000000 *UND* 00000000 sin +00000000 *UND* 00000000 __random_float +00000000 *UND* 00000000 clock +00000000 *UND* 00000000 exit +00000000 *UND* 00000000 __date +00000000 *UND* 00000000 __time +00000000 *UND* 00000000 get_arg +00000000 *UND* 00000000 new +00000000 *UND* 00000000 dispose +00000000 *UND* 00000000 initfile +00000000 *UND* 00000000 peek_char +00000000 *UND* 00000000 next_char +00000000 *UND* 00000000 readln +00000000 *UND* 00000000 read_int64 +00000000 *UND* 00000000 read_card64 +00000000 *UND* 00000000 read_integer +00000000 *UND* 00000000 read_cardinal +00000000 *UND* 00000000 read_integer_range +00000000 *UND* 00000000 read_real +00000000 *UND* 00000000 read_double +00000000 *UND* 00000000 read_extended +00000000 *UND* 00000000 read_string +00000000 *UND* 00000000 read_enum +00000000 *UND* 00000000 read_char +00000000 *UND* 00000000 read_char_range +00000000 *UND* 00000000 read_boolean +00000000 *UND* 00000000 read_set +00000000 *UND* 00000000 writeln +00000000 *UND* 00000000 write_int64 +00000000 *UND* 00000000 write_card64 +00000000 *UND* 00000000 write_integer +00000000 *UND* 00000000 write_cardinal +00000000 *UND* 00000000 write_boolean +00000000 *UND* 00000000 write_char +00000000 *UND* 00000000 write_real +00000000 *UND* 00000000 write_double +00000000 *UND* 00000000 write_extended +00000000 *UND* 00000000 write_string +00000000 *UND* 00000000 write_enum +00000000 *UND* 00000000 write_set +00000000 *UND* 00000000 caseerror +00000000 *UND* 00000000 __pc_nloc_goto +00000000 *UND* 00000000 memcpy +00000000 *UND* 00000000 __in_range +00000000 *UND* 00000000 __ll_mul +00000000 *UND* 00000000 __ll_div +00000000 *UND* 00000000 __ull_div +00000000 *UND* 00000000 __ll_mod +00000000 *UND* 00000000 __ll_rem +00000000 *UND* 00000000 __ull_rem +00000000 *UND* 00000000 __ll_lshift +00000000 *UND* 00000000 __ll_rshift +00000000 *UND* 00000000 __ll_to_f +00000000 *UND* 00000000 __ull_to_f +00000000 *UND* 00000000 __ll_to_d +00000000 *UND* 00000000 __ull_to_d +00000000 *UND* 00000000 __f_ll_ll +00000000 *UND* 00000000 __f_to_ull +00000000 *UND* 00000000 __d_to_ll +00000000 *UND* 00000000 __d_to_ull +00000000 *UND* 00000000 round64 +00000000 *UND* 00000000 trunc64 +00000000 *UND* 00000000 max64 +00000000 *UND* 00000000 min64 +00000000 *UND* 00000000 abs64 +00000000 *UND* 00000000 odd64 +00000000 *UND* 00000000 trapNaN +00000000 *UND* 00000008 input +00000000 *UND* 00000008 output +00000000 *UND* 00000008 err +00000000 *UND* 00000008 __Argc + + +RELOCATION RECORDS FOR [.text]: (none) + +RELOCATION RECORDS FOR [.rodata]: (none) + +Contents of section .text: + 0000 00041080 03e00008 00441023 27bdffe8 .........D.#'... + 0010 18a00009 afa00004 8fae0004 008e7821 ..............x! + 0020 a1e00000 8fb80004 27190001 0325082a ........'....%.* + 0030 1420fff9 afb90004 10000001 00000000 . .............. + 0040 03e00008 27bd0018 00000000 00000000 ....'........... + 0050 00000000 00000000 00000000 00000000 ................ + 0060 00000000 00000000 00000000 00000000 ................ + 0070 00000000 00000000 00000000 00000000 ................ + 0080 00000000 00000000 00000000 00000000 ................ + 0090 00000000 00000000 00000000 00000000 ................ + 00a0 00000000 00000000 00000000 00000000 ................ + 00b0 00000000 00000000 00000000 00000000 ................ + 00c0 00000000 00000000 00000000 00000000 ................ + 00d0 00041080 03e00008 00441023 00000000 .........D.#.... +Contents of section .rodata: + 0000 00123123 00456456 00789789 00000001 ..1#.EdV.x...... + 0010 3ff19999 9999999a 00000002 00000003 ?............... + 0020 4000cccc cccccccd 00000000 00000000 @............... +Contents of section .data: + 0000 00002323 00003434 00000000 00000000 ..##..44........ +Contents of section .options: + 0000 01200000 00000000 80004016 00000000 . ........@..... + 0010 000000f0 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 a300c036 00000000 000000f0 00000000 ...6............ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/pascal.p b/tools/asm-processor/tests/pascal.p new file mode 100644 index 000000000..0886126ab --- /dev/null +++ b/tools/asm-processor/tests/pascal.p @@ -0,0 +1,95 @@ +{ COMPILE-FLAGS: -O2 } + +function foo(x: integer): integer; +begin + foo := x * 3 +end; + +GLOBAL_ASM( +.section .data +.word 0x2323 + +.late_rodata +.word 0x123123 +.word 0x456456 +.word 0x789789 +.text +glabel test +/* 000090 00400090 27BDFFF8 */ addiu $sp, $sp, -24 +/* 000094 00400094 18A00009 */ blez $a1, .L004000BC +/* 000098 00400098 AFA00004 */ sw $zero, 4($sp) +.L0040009C: +/* 00009C 0040009C 8FAE0004 */ lw $t6, 4($sp) +/* 0000A0 004000A0 008E7821 */ addu $t7, $a0, $t6 +/* 0000A4 004000A4 A1E00000 */ sb $zero, ($t7) +/* 0000A8 004000A8 8FB80004 */ lw $t8, 4($sp) +/* 0000AC 004000AC 27190001 */ addiu $t9, $t8, 1 +/* 0000B0 004000B0 0325082A */ slt $at, $t9, $a1 +/* 0000B4 004000B4 1420FFF9 */ bnez $at, .L0040009C +/* 0000B8 004000B8 AFB90004 */ sw $t9, 4($sp) +.L004000BC: +/* 0000BC 004000BC 10000001 */ b .L004000C4 +/* 0000C0 004000C0 00000000 */ nop +.L004000C4: +/* 0000C4 004000C4 03E00008 */ jr $ra +/* 0000C8 004000C8 27BD0008 */ addiu $sp, $sp, 24 +) + +GLOBAL_ASM( +.section .data +.word 0x3434 + +.late_rodata +.word 0x1 +.double 1.1 +.word 0x2, 0x3 +.text +glabel test2 +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +) + +GLOBAL_ASM( +.late_rodata +.double 2.1 +.text +glabel test3 +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +nop +) + +function bar(x: integer): integer; +begin + return x * 3 +end; + diff --git a/tools/asm-processor/tests/static-global.c b/tools/asm-processor/tests/static-global.c new file mode 100644 index 000000000..a7f616907 --- /dev/null +++ b/tools/asm-processor/tests/static-global.c @@ -0,0 +1,33 @@ +// COMPILE-FLAGS: -O2 +// ASMP-FLAGS: --convert-statics=global +static int xtext(int a, int b, int c); +const int rodata1[] = {1}; +static const int rodata2[] = {2}; +int data1[] = {3}; +static int data2[] = {4}; +int bss1; +static int bss2; + +GLOBAL_ASM( +glabel bar +lui $a0, %hi(rodata2) +lw $a0, %lo(rodata2)($a0) +lui $a1, %hi(data2) +lw $a1, %lo(data2)($a0) +lui $a2, %hi(bss2) +lw $a2, %lo(bss2)($a0) +jal xtext +nop +jr $ra +nop +nop +nop +) + +static int xtext(int a, int b, int c) { + return 1; +} + +void baz(void) { + xtext(bss2, rodata2[0], data2[0]); +} diff --git a/tools/asm-processor/tests/static-global.objdump b/tools/asm-processor/tests/static-global.objdump new file mode 100644 index 000000000..a519e4f48 --- /dev/null +++ b/tools/asm-processor/tests/static-global.objdump @@ -0,0 +1,58 @@ + +tests/static-global.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 00000080 .text +00000000 l d .rodata 00000010 .rodata +00000000 l d .data 00000010 .data +00000000 l d .bss 00000010 .bss +00000000 g O .rodata 00000004 rodata1 +00000000 g O .data 00000004 data1 +00000000 g O .bss 00000004 bss1 +00000044 g F .text 00000034 baz +00000000 g F .text 00000030 bar +00000004 g O .rodata 00000000 rodata2 +00000004 g O .data 00000000 data2 +00000004 g O .bss 00000000 bss2 +00000030 g F .text 00000000 xtext + + +RELOCATION RECORDS FOR [.text]: +OFFSET TYPE VALUE +0000004c R_MIPS_HI16 .bss +00000064 R_MIPS_LO16 .bss +00000050 R_MIPS_HI16 .rodata +0000005c R_MIPS_LO16 .rodata +00000054 R_MIPS_HI16 .data +00000058 R_MIPS_LO16 .data +00000060 R_MIPS_26 .text +00000000 R_MIPS_HI16 rodata2 +00000004 R_MIPS_LO16 rodata2 +00000008 R_MIPS_HI16 data2 +0000000c R_MIPS_LO16 data2 +00000010 R_MIPS_HI16 bss2 +00000014 R_MIPS_LO16 bss2 +00000018 R_MIPS_26 xtext + + +Contents of section .text: + 0000 3c040000 8c840000 3c050000 8c850000 <.......<....... + 0010 3c060000 8c860000 0c000000 00000000 <............... + 0020 03e00008 00000000 00000000 00000000 ................ + 0030 afa40000 afa50004 afa60008 03e00008 ................ + 0040 24020001 27bdffe8 afbf0014 3c040000 $...'.......<... + 0050 3c050000 3c060000 8cc60004 8ca50004 <...<........... + 0060 0c00000c 8c840004 8fbf0014 27bd0018 ............'... + 0070 03e00008 00000000 00000000 00000000 ................ +Contents of section .rodata: + 0000 00000001 00000002 00000000 00000000 ................ +Contents of section .data: + 0000 00000003 00000004 00000000 00000000 ................ +Contents of section .options: + 0000 01200000 00000000 a0000074 00000000 . .........t.... + 0010 00000000 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 a0000074 00000000 00000000 00000000 ...t............ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/static.c b/tools/asm-processor/tests/static.c new file mode 100644 index 000000000..c265021e5 --- /dev/null +++ b/tools/asm-processor/tests/static.c @@ -0,0 +1,32 @@ +// COMPILE-FLAGS: -O2 +static int xtext(int a, int b, int c); +const int rodata1[] = {1}; +static const int rodata2[] = {2}; +int data1[] = {3}; +static int data2[] = {4}; +int bss1; +static int bss2; + +GLOBAL_ASM( +glabel bar +lui $a0, %hi(rodata2) +lw $a0, %lo(rodata2)($a0) +lui $a1, %hi(data2) +lw $a1, %lo(data2)($a0) +lui $a2, %hi(bss2) +lw $a2, %lo(bss2)($a0) +jal xtext +nop +jr $ra +nop +nop +nop +) + +static int xtext(int a, int b, int c) { + return 1; +} + +void baz(void) { + xtext(bss2, rodata2[0], data2[0]); +} diff --git a/tools/asm-processor/tests/static.objdump b/tools/asm-processor/tests/static.objdump new file mode 100644 index 000000000..dd62c94c1 --- /dev/null +++ b/tools/asm-processor/tests/static.objdump @@ -0,0 +1,58 @@ + +tests/static.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 00000080 .text +00000000 l d .rodata 00000010 .rodata +00000000 l d .data 00000010 .data +00000000 l d .bss 00000010 .bss +00000004 l O .rodata 00000000 rodata2 +00000004 l O .data 00000000 data2 +00000004 l O .bss 00000000 bss2 +00000030 l F .text 00000000 xtext +00000000 g O .rodata 00000004 rodata1 +00000000 g O .data 00000004 data1 +00000000 g O .bss 00000004 bss1 +00000044 g F .text 00000034 baz +00000000 g F .text 00000030 bar + + +RELOCATION RECORDS FOR [.text]: +OFFSET TYPE VALUE +0000004c R_MIPS_HI16 .bss +00000064 R_MIPS_LO16 .bss +00000050 R_MIPS_HI16 .rodata +0000005c R_MIPS_LO16 .rodata +00000054 R_MIPS_HI16 .data +00000058 R_MIPS_LO16 .data +00000060 R_MIPS_26 .text +00000000 R_MIPS_HI16 rodata2 +00000004 R_MIPS_LO16 rodata2 +00000008 R_MIPS_HI16 data2 +0000000c R_MIPS_LO16 data2 +00000010 R_MIPS_HI16 bss2 +00000014 R_MIPS_LO16 bss2 +00000018 R_MIPS_26 xtext + + +Contents of section .text: + 0000 3c040000 8c840000 3c050000 8c850000 <.......<....... + 0010 3c060000 8c860000 0c000000 00000000 <............... + 0020 03e00008 00000000 00000000 00000000 ................ + 0030 afa40000 afa50004 afa60008 03e00008 ................ + 0040 24020001 27bdffe8 afbf0014 3c040000 $...'.......<... + 0050 3c050000 3c060000 8cc60004 8ca50004 <...<........... + 0060 0c00000c 8c840004 8fbf0014 27bd0018 ............'... + 0070 03e00008 00000000 00000000 00000000 ................ +Contents of section .rodata: + 0000 00000001 00000002 00000000 00000000 ................ +Contents of section .data: + 0000 00000003 00000004 00000000 00000000 ................ +Contents of section .options: + 0000 01200000 00000000 a0000074 00000000 . .........t.... + 0010 00000000 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 a0000074 00000000 00000000 00000000 ...t............ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/test1.c b/tools/asm-processor/tests/test1.c new file mode 100644 index 000000000..475555a75 --- /dev/null +++ b/tools/asm-processor/tests/test1.c @@ -0,0 +1,71 @@ + +GLOBAL_ASM( +.rdata +.word 0x1212 +) + +GLOBAL_ASM( +.late_rodata +.word 0x123123 +.text +glabel test +/* 000090 00400090 27BDFFF8 */ addiu $sp, $sp, -24 +/* 000094 00400094 18A00009 */ blez $a1, .L004000BC +/* 000098 00400098 AFA00004 */ sw $zero, 4($sp) +.L0040009C: +/* 00009C 0040009C 8FAE0004 */ lw $t6, 4($sp) +/* 0000A0 004000A0 008E7821 */ addu $t7, $a0, $t6 +/* 0000A4 004000A4 A1E00000 */ sb $zero, ($t7) +/* 0000A8 004000A8 8FB80004 */ lw $t8, 4($sp) +/* 0000AC 004000AC 27190001 */ addiu $t9, $t8, 1 +/* 0000B0 004000B0 0325082A */ slt $at, $t9, $a1 +/* 0000B4 004000B4 1420FFF9 */ bnez $at, .L0040009C +/* 0000B8 004000B8 AFB90004 */ sw $t9, 4($sp) +.L004000BC: +/* 0000BC 004000BC 10000001 */ b .L004000C4 +/* 0000C0 004000C0 00000000 */ nop +.L004000C4: +/* 0000C4 004000C4 03E00008 */ jr $ra +/* 0000C8 004000C8 27BD0008 */ addiu $sp, $sp, 24 +) + +char bss1[3]; +GLOBAL_ASM( +.bss +bss2: +.space 3 +) +char bss3[3]; +char bss4[3]; +const int rodata1[2] = {1}; +extern int some_rodata; + +unsigned g(float, int); +unsigned f(void) { + return g(1.1f, some_rodata); +} + +GLOBAL_ASM( +.rdata +glabel some_rodata +.word 0x1313 +.text +.late_rodata +.word 0x321321 +.text +glabel g +/* 0000C0 004000C0 27BDFFE8 */ addiu $sp, $sp, -0x18 +/* 0000C4 004000C4 AFBF0014 */ sw $ra, 0x14($sp) +/* 0000C8 004000C8 240E0004 */ addiu $t6, $zero, 4 +/* 0000CC 004000CC 3C010041 */ lui $at, %hi(D_410100) +/* 0000D0 004000D0 AC2E0100 */ sw $t6, %lo(D_410100)($at) +/* 0000D4 004000D4 0C10002C */ jal func_004000B0 +/* 0000D8 004000D8 00000000 */ nop +/* 0000DC 004000DC 10000001 */ b .L004000E4 +/* 0000E0 004000E0 00000000 */ nop +.L004000E4: +/* 0000E4 004000E4 8FBF0014 */ lw $ra, 0x14($sp) +/* 0000E8 004000E8 27BD0018 */ addiu $sp, $sp, 0x18 +/* 0000EC 004000EC 03E00008 */ jr $ra +/* 0000F0 004000F0 00000000 */ nop +) diff --git a/tools/asm-processor/tests/test1.objdump b/tools/asm-processor/tests/test1.objdump new file mode 100644 index 000000000..b97ae46e1 --- /dev/null +++ b/tools/asm-processor/tests/test1.objdump @@ -0,0 +1,54 @@ + +tests/test1.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 000000b0 .text +00000000 l d .rodata 00000020 .rodata +00000000 l d .bss 00000010 .bss +00000000 g O .bss 00000003 bss1 +00000008 g O .bss 00000003 bss3 +0000000c g O .bss 00000003 bss4 +00000004 g O .rodata 00000008 rodata1 +0000003c g F .text 0000003c f +00000000 g F .text 0000003c test +0000000c g .rodata 00000000 some_rodata +00000078 g F .text 00000004 g +00000000 *UND* 00000000 D_410100 +00000000 *UND* 00000000 func_004000B0 + + +RELOCATION RECORDS FOR [.text]: +OFFSET TYPE VALUE +00000044 R_MIPS_HI16 .rodata +00000054 R_MIPS_LO16 .rodata +00000048 R_MIPS_HI16 some_rodata +0000004c R_MIPS_LO16 some_rodata +00000050 R_MIPS_26 g +00000084 R_MIPS_HI16 D_410100 +00000088 R_MIPS_LO16 D_410100 +0000008c R_MIPS_26 func_004000B0 + + +Contents of section .text: + 0000 27bdffe8 18a00009 afa00004 8fae0004 '............... + 0010 008e7821 a1e00000 8fb80004 27190001 ..x!........'... + 0020 0325082a 1420fff9 afb90004 10000001 .%.*. .......... + 0030 00000000 03e00008 27bd0018 27bdffe8 ........'...'... + 0040 afbf0014 3c010000 3c050000 8ca50000 ....<...<....... + 0050 0c000000 c42c0014 10000003 00000000 .....,.......... + 0060 10000001 00000000 8fbf0014 27bd0018 ............'... + 0070 03e00008 00000000 27bdffe8 afbf0014 ........'....... + 0080 240e0004 3c010000 ac2e0000 0c000000 $...<........... + 0090 00000000 10000001 00000000 8fbf0014 ................ + 00a0 27bd0018 03e00008 00000000 00000000 '............... +Contents of section .rodata: + 0000 00001212 00000001 00000000 00001313 ................ + 0010 00123123 3f8ccccd 00321321 00000000 ..1#?....2.!.... +Contents of section .options: + 0000 01200000 00000000 a0000022 00000000 . .........".... + 0010 00001010 00000000 00000000 00007ff0 ................ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 a300c032 00000000 00001010 00000000 ...2............ + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/test2.c b/tools/asm-processor/tests/test2.c new file mode 100644 index 000000000..15969feb6 --- /dev/null +++ b/tools/asm-processor/tests/test2.c @@ -0,0 +1,69 @@ +const char buf1[1] = {1}; +float func1(void) { + "func1"; + return 0.1f; +} +const char buf2[1] = {2}; +void func2(void) { + *(volatile float*)0 = -3.5792360305786133f; + *(volatile float*)0 = -3.5792362689971924f; + // "func2"; + // return 0.2f; +} +const char buf3[1] = {3}; +int func3(int x) { + switch(x) { + case 0: + return 1; + case 1: + return 2; + case 2: + return 3; + case 3: + return 4; + case 4: + return 5; + case 5: + return 4; + case 6: + return 4; + case 7: + return 4; + default: + return 3; + } +} + +#if 1 +GLOBAL_ASM( +.rdata +.word 0x66756e63 # func +.word 0x34000000 # 4\0\0\0 +.word jumptarget + 4 + +.late_rodata +glabel rv +.word 0x3e4ccccd # 0.2f +.word jumptarget + 8 + +.text +glabel func4 +lui $at, %hi(rv) +glabel jumptarget +jr $ra +lwc1 $f0, %lo(rv)($at) +jr $ra +nop +jr $ra +nop +jr $ra +nop +jr $ra +nop +) +#else +float func4(void) { + "func4"; + return 0.2f; +} +#endif diff --git a/tools/asm-processor/tests/test2.objdump b/tools/asm-processor/tests/test2.objdump new file mode 100644 index 000000000..276ed9f1f --- /dev/null +++ b/tools/asm-processor/tests/test2.objdump @@ -0,0 +1,76 @@ + +tests/test2.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 000000f0 .text +00000000 l d .rodata 00000060 .rodata +00000000 g O .rodata 00000001 buf1 +00000000 g F .text 0000001c func1 +0000000c g O .rodata 00000001 buf2 +0000001c g F .text 00000028 func2 +00000010 g O .rodata 00000001 buf3 +00000044 g F .text 0000007c func3 +000000c4 g F .text 00000000 jumptarget +000000c0 g F .text 0000000c func4 +0000004c g .rodata 00000000 rv + + +RELOCATION RECORDS FOR [.text]: +OFFSET TYPE VALUE +00000000 R_MIPS_HI16 .rodata +00000008 R_MIPS_LO16 .rodata +0000001c R_MIPS_HI16 .rodata +00000020 R_MIPS_LO16 .rodata +00000028 R_MIPS_HI16 .rodata +0000002c R_MIPS_LO16 .rodata +00000054 R_MIPS_HI16 .rodata +0000005c R_MIPS_LO16 .rodata +000000c0 R_MIPS_HI16 rv +000000c8 R_MIPS_LO16 rv + + +RELOCATION RECORDS FOR [.rodata]: +OFFSET TYPE VALUE +0000002c R_MIPS_32 .text +00000030 R_MIPS_32 .text +00000034 R_MIPS_32 .text +00000038 R_MIPS_32 .text +0000003c R_MIPS_32 .text +00000040 R_MIPS_32 .text +00000044 R_MIPS_32 .text +00000048 R_MIPS_32 .text +0000001c R_MIPS_32 jumptarget +00000050 R_MIPS_32 jumptarget + + +Contents of section .text: + 0000 3c010000 03e00008 c4200020 03e00008 <........ . .... + 0010 00000000 03e00008 00000000 3c010000 ............<... + 0020 c4240024 e4040000 3c010000 c4260028 .$.$....<....&.( + 0030 e4060000 03e00008 00000000 03e00008 ................ + 0040 00000000 2c810008 10200017 00000000 ....,.... ...... + 0050 00047080 3c010000 002e0821 8c2e002c ..p.<......!..., + 0060 01c00008 00000000 03e00008 24020001 ............$... + 0070 03e00008 24020002 03e00008 24020003 ....$.......$... + 0080 03e00008 24020004 03e00008 24020005 ....$.......$... + 0090 03e00008 24020004 03e00008 24020004 ....$.......$... + 00a0 03e00008 24020004 03e00008 24020003 ....$.......$... + 00b0 03e00008 00000000 03e00008 00000000 ................ + 00c0 3c010000 03e00008 c4200000 03e00008 <........ ...... + 00d0 00000000 03e00008 00000000 03e00008 ................ + 00e0 00000000 03e00008 00000000 00000000 ................ +Contents of section .rodata: + 0000 01000000 66756e63 31000000 02000000 ....func1....... + 0010 03000000 66756e63 34000000 00000004 ....func4....... + 0020 3dcccccd c0651234 c0651235 00000068 =....e.4.e.5...h + 0030 00000070 00000078 00000080 00000088 ...p...x........ + 0040 00000090 00000098 000000a0 3e4ccccd ............>L.. + 0050 00000008 00000000 00000000 00000000 ................ +Contents of section .options: + 0000 01200000 00000000 80004016 00000000 . ........@..... + 0010 00000051 00000000 00000000 00007ff0 ...Q............ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 80004016 00000000 00000051 00000000 ..@........Q.... + 0010 00000000 00007ff0 ........ diff --git a/tools/asm-processor/tests/test3.c b/tools/asm-processor/tests/test3.c new file mode 100644 index 000000000..d74bb4cbd --- /dev/null +++ b/tools/asm-processor/tests/test3.c @@ -0,0 +1,70 @@ + +GLOBAL_ASM( +.rdata +.word 321321 +.text +glabel test +/* 000090 00400090 27BDFFF8 */ addiu $sp, $sp, -24 +/* 000094 00400094 18A00009 */ blez $a1, .L004000BC +/* 000098 00400098 AFA00004 */ sw $zero, 4($sp) +.L0040009C: +/* 00009C 0040009C 8FAE0004 */ lw $t6, 4($sp) +/* 0000A0 004000A0 008E7821 */ addu $t7, $a0, $t6 +/* 0000A4 004000A4 A1E00000 */ sb $zero, ($t7) +/* 0000A8 004000A8 8FB80004 */ lw $t8, 4($sp) +/* 0000AC 004000AC 27190001 */ addiu $t9, $t8, 1 +/* 0000B0 004000B0 0325082A */ slt $at, $t9, $a1 +/* 0000B4 004000B4 1420FFF9 */ bnez $at, .L0040009C +/* 0000B8 004000B8 AFB90004 */ sw $t9, 4($sp) +.L004000BC: +/* 0000BC 004000BC 10000001 */ b .L004000C4 +/* 0000C0 004000C0 00000000 */ nop +.L004000C4: +/* 0000C4 004000C4 03E00008 */ jr $ra +/* 0000C8 004000C8 27BD0008 */ addiu $sp, $sp, 24 +) + +// static -> no symbols +// bss +char globalBuf[4]; +const char constBuf[4]; + +// data +char globalBufInit[4] = {1}; + +// rodata +const char constBufInit[4] = {1}; +const char constBufInit2[1] = {2}; +const char constBufInit3[1] = {3}; + +unsigned g(void); +unsigned f(void) { + // aligns to 4 or 8 byte boundary (char -> 4, double -> 8) + double x = 5.1; + float y = 5.2f; + float z = 5.3f; + "Hello "; + "World"; + return g(); +} + +GLOBAL_ASM( +.rdata +.word 123123 +.text +glabel g +/* 0000C0 004000C0 27BDFFE8 */ addiu $sp, $sp, -0x18 +/* 0000C4 004000C4 AFBF0014 */ sw $ra, 0x14($sp) +/* 0000C8 004000C8 240E0004 */ addiu $t6, $zero, 4 +/* 0000CC 004000CC 3C010041 */ lui $at, %hi(D_410100) +/* 0000D0 004000D0 AC2E0100 */ sw $t6, %lo(D_410100)($at) +/* 0000D4 004000D4 0C10002C */ jal func_004000B0 +/* 0000D8 004000D8 00000000 */ nop +/* 0000DC 004000DC 10000001 */ b .L004000E4 +/* 0000E0 004000E0 00000000 */ nop +.L004000E4: +/* 0000E4 004000E4 8FBF0014 */ lw $ra, 0x14($sp) +/* 0000E8 004000E8 27BD0018 */ addiu $sp, $sp, 0x18 +/* 0000EC 004000EC 03E00008 */ jr $ra +/* 0000F0 004000F0 00000000 */ nop +) diff --git a/tools/asm-processor/tests/test3.objdump b/tools/asm-processor/tests/test3.objdump new file mode 100644 index 000000000..bfa7f6e37 --- /dev/null +++ b/tools/asm-processor/tests/test3.objdump @@ -0,0 +1,64 @@ + +tests/test3.o: file format elf32-tradbigmips + +SYMBOL TABLE: +00000000 l d .text 000000d0 .text +00000000 l d .rodata 00000040 .rodata +00000000 l d .data 00000010 .data +00000000 l d .bss 00000010 .bss +00000000 g O .bss 00000004 globalBuf +00000004 g O .bss 00000004 constBuf +00000000 g O .data 00000004 globalBufInit +00000004 g O .rodata 00000004 constBufInit +00000008 g O .rodata 00000001 constBufInit2 +0000000c g O .rodata 00000001 constBufInit3 +0000003c g F .text 00000054 f +00000000 g F .text 00000004 test +00000090 g F .text 00000004 g +00000000 *UND* 00000000 D_410100 +00000000 *UND* 00000000 func_004000B0 + + +RELOCATION RECORDS FOR [.text]: +OFFSET TYPE VALUE +00000044 R_MIPS_HI16 .rodata +00000048 R_MIPS_LO16 .rodata +00000050 R_MIPS_HI16 .rodata +00000054 R_MIPS_LO16 .rodata +0000005c R_MIPS_HI16 .rodata +00000060 R_MIPS_LO16 .rodata +00000068 R_MIPS_26 g +0000009c R_MIPS_HI16 D_410100 +000000a0 R_MIPS_LO16 D_410100 +000000a4 R_MIPS_26 func_004000B0 + + +Contents of section .text: + 0000 27bdffe8 18a00009 afa00004 8fae0004 '............... + 0010 008e7821 a1e00000 8fb80004 27190001 ..x!........'... + 0020 0325082a 1420fff9 afb90004 10000001 .%.*. .......... + 0030 00000000 03e00008 27bd0018 27bdffd8 ........'...'... + 0040 afbf0014 3c010000 d4240028 f7a40020 ....<....$.(... + 0050 3c010000 c4260030 e7a6001c 3c010000 <....&.0....<... + 0060 c4280034 e7a80018 0c000000 00000000 .(.4............ + 0070 10000003 00000000 10000001 00000000 ................ + 0080 8fbf0014 27bd0028 03e00008 00000000 ....'..(........ + 0090 27bdffe8 afbf0014 240e0004 3c010000 '.......$...<... + 00a0 ac2e0000 0c000000 00000000 10000001 ................ + 00b0 00000000 8fbf0014 27bd0018 03e00008 ........'....... + 00c0 00000000 00000000 00000000 00000000 ................ +Contents of section .rodata: + 0000 0004e729 01000000 02000000 03000000 ...)............ + 0010 48656c6c 6f202000 576f726c 64000000 Hello .World... + 0020 0001e0f3 00000000 40146666 66666666 ........@.ffffff + 0030 40a66666 40a9999a 00000000 00000000 @.ff@........... +Contents of section .data: + 0000 01000000 00000000 00000000 00000000 ................ +Contents of section .options: + 0000 01200000 00000000 a0000002 00000000 . .............. + 0010 00000170 00000000 00000000 00007ff0 ...p............ + 0020 07100000 00000000 00000000 00000000 ................ + 0030 08100000 00000000 00000000 00000000 ................ +Contents of section .reginfo: + 0000 a300c032 00000000 00000170 00000000 ...2.......p.... + 0010 00000000 00007ff0 ........ diff --git a/tools/disasm/disasm.py b/tools/disasm/disasm.py index 0f5e16464..e7b0f4d81 100755 --- a/tools/disasm/disasm.py +++ b/tools/disasm/disasm.py @@ -177,6 +177,10 @@ def proper_name(symbol, in_data=False, is_symbol=True): return variables_ast[0x809C46DC][0] + " + 0x14" elif symbol == 0x801EF66D: # z_message_nes constant-folding stray fairy array return variables_ast[0x801EF670][0] + f" - 0x{0x801EF670 - 0x801EF66D:X}" + elif symbol == 0x801EF51D: # z_message constant-folding stray fairy array + return variables_ast[0x801EF670][0] + f" - 0x{0x801EF670 - 0x801EF51D:X}" + elif symbol == 0x801D0D7A: # play_hireso constant-folding D_801D0D80 array + return variables_ast[0x801D0D80][0] + f" - 0x{0x801D0D80 - 0x801D0D7A:X}" elif symbol == 0x80A09740: # boss_07 symbol with large addend folded into %lo return variables_ast[0x80A09A60][0] + f" - 0x{0x80A09A60 - 0x80A09740:X}" # bg_ikana_mirror symbol with large addend folded into %lo diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index 7ed8ced9d..de9a0e39b 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -431,7 +431,7 @@ 0x80140CE0 : "code_80140CE0", 0x80140E80 : "code_80140E80", 0x801418B0 : "z_vismono", - 0x801420C0 : "code_801420C0", + 0x801420C0 : "z_viszbuf", 0x80142440 : "z_vr_box", 0x801435A0 : "z_vr_box_draw", 0x80143A10 : "z_sram_NES", @@ -440,7 +440,7 @@ 0x8015E750 : "z_message_staff", 0x80160A90 : "z_player_call", 0x80160C00 : "z_shrink_window", - 0x80161180 : "db_camera", + 0x80161180 : "cutscene_camera", 0x80163700 : "z_kaleido_manager", 0x801639A0 : "z_kaleido_scope_call", 0x80163C90 : "z_fbdemo_dlftbls", @@ -453,8 +453,8 @@ 0x8016FCF0 : "PreRender", 0x801727F0 : "TwoHeadGfxArena", 0x80172A00 : "TwoHeadArena", - 0x80172BC0 : "code_80172BC0", - 0x80172C30 : "audioMgr", + 0x80172BC0 : "audio_stop_all_sfx", + 0x80172C30 : "audio_thread_manager", 0x80173130 : "title_setup", 0x80173360 : "game", 0x80173BF0 : "gamealloc", @@ -466,7 +466,8 @@ 0x80176280 : "sched", 0x80177390 : "speed_meter", 0x801780F0 : "su_mtx", - 0x80178750 : "sys_cmpdma", + 0x80178750 : "sys_cfb", + 0x80178AC0 : "sys_cmpdma", 0x80178F30 : "sys_initial_check", 0x80179300 : "sys_math", 0x801795F0 : "sys_math3d", @@ -494,11 +495,11 @@ 0x8019AEB0 : "[PADDING]", 0x8019AEC0 : "code_8019AEC0", 0x8019AF00 : "code_8019AF00", - 0x801A4EB0 : "code_801A4EB0", - 0x801A51F0 : "code_801A51F0", + 0x801A4EB0 : "voice_external", + 0x801A51F0 : "voice_internal", 0x801A5BC0 : "[PADDING]", 0x801A5BD0 : "code_801A5BD0", - 0x801A7B10 : "code_801A7B10", + 0x801A7B10 : "sequence", 0x801A9B10 : "jpegutils", 0x801AA020 : "jpegdecoder", 0x801AA610 : "z_game_over", @@ -554,7 +555,7 @@ 0x801C1D30 : "code_8012EC80", 0x801C2410 : "code_801C2410", 0x801C2650 : "z_scene", - 0x801C2730 : "", + 0x801C2730 : "object_table", 0x801C3B60 : "z_scene_proc", 0x801C3CA0 : "z_scene_table", 0x801C5C50 : "z_schedule", @@ -570,10 +571,11 @@ 0x801D0B70 : "z_kaleido_manager", 0x801D0BB0 : "", 0x801D0C80 : "z_fbdemo", + 0x801D0CB0 : "z_fbdemo_fade", 0x801D0D00 : "z_fbdemo_circle", 0x801D0D50 : "z_play", 0x801D0D80 : "z_play_hireso", - 0x801D14F0 : "audioMgr", + 0x801D14F0 : "audio_thread_manager", 0x801D1500 : "game", 0x801D1510 : "graph", 0x801D1520 : "main", @@ -595,12 +597,12 @@ 0x801D61A0 : "audio_seqplayer", 0x801D6200 : "audio_dramStack", 0x801D6600 : "code_8019AF00", - 0x801D8BE0 : "code_801A4EB0", - 0x801D8E50 : "code_801A51F0", + 0x801D8BE0 : "voice_external", + 0x801D8E50 : "voice_internal", 0x801D9090 : "audio_sound_params", 0x801DB470 : "code_801A5BD0", - 0x801DB4C0 : "code_801A7B10", - 0x801DB4E0 : "audio_init_params", + 0x801DB4C0 : "sequence", + 0x801DB4E0 : "session_config", # .rodata section 0x801DBDF0 : "z_en_item00", @@ -651,14 +653,14 @@ 0x801DF150 : "z_message", 0x801DF730 : "z_message_nes", 0x801DF860 : "z_message_staff", - 0x801DF900 : "db_camera", + 0x801DF900 : "cutscene_camera", 0x801DF9C0 : "z_kaleido_manager", 0x801DF9E0 : "z_fbdemo_circle", 0x801DFA00 : "z_play", 0x801DFC50 : "z_play_hireso", 0x801DFC60 : "PreRender", - 0x801DFC70 : "code_80172BC0", - 0x801DFC80 : "audioMgr", + 0x801DFC70 : "audio_stop_all_sfx", + 0x801DFC80 : "audio_thread_manager", 0x801DFCC0 : "game", 0x801DFCE0 : "graph", 0x801DFD70 : "main", @@ -678,10 +680,10 @@ 0x801E0510 : "audio_effects", 0x801E0540 : "audio_seqplayer", 0x801E0BD0 : "code_8019AF00", - 0x801E0EC0 : "code_801A51F0", + 0x801E0EC0 : "voice_internal", 0x801E1050 : "code_801A5BD0", - 0x801E1070 : "code_801A7B10", - 0x801E1100 : "audio_init_params", + 0x801E1070 : "sequence", + 0x801E1100 : "session_config", 0x801E1110 : "z_game_over", 0x801E1180 : "audio_tables", 0x801E1E80 : "aspMain", @@ -722,7 +724,7 @@ 0x801F6B00 : "z_message", 0x801F6B30 : "z_player_call", 0x801F6B40 : "z_shrink_window", - 0x801F6B50 : "db_camera", + 0x801F6B50 : "cutscene_camera", 0x801F6BF0 : "z_kaleido_manager", 0x801F6C00 : "z_kaleido_scope_call", 0x801F6C10 : "z_play", @@ -741,9 +743,9 @@ 0x801FD120 : "audio_heap", 0x801FD140 : "audio_load", 0x801FD1F0 : "code_8019AF00", - 0x801FD5A0 : "code_801A51F0", + 0x801FD5A0 : "voice_internal", 0x801FD710 : "code_801A5BD0", - 0x801FFD00 : "code_801A7B10", + 0x801FFD00 : "sequence", 0x80208E90 : "jpegdecoder", 0x80208EA0 : "gfxbuffers", 0x8024A4C0 : "buffers", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 3c1a5d177..12c14705c 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -696,10 +696,10 @@ 0x800B5E68:("TitleCard_Update",), 0x800B5F24:("TitleCard_Draw",), 0x800B6434:("func_800B6434",), - 0x800B6468:("func_800B6468",), - 0x800B6474:("func_800B6474",), - 0x800B648C:("func_800B648C",), - 0x800B64FC:("func_800B64FC",), + 0x800B6468:("Actor_InitPlayerImpact",), + 0x800B6474:("Actor_UpdatePlayerImpact",), + 0x800B648C:("Actor_SetPlayerImpact",), + 0x800B64FC:("Actor_GetPlayerImpact",), 0x800B6584:("func_800B6584",), 0x800B6608:("func_800B6608",), 0x800B6680:("func_800B6680",), @@ -722,16 +722,16 @@ 0x800B6BD8:("Actor_MoveWithoutGravityReverse",), 0x800B6C04:("Actor_SetSpeeds",), 0x800B6C58:("Actor_UpdatePosFromSkelAnime",), - 0x800B6CD4:("Actor_YawBetweenActors",), - 0x800B6D00:("Actor_YawBetweenActorsTop",), - 0x800B6D2C:("Actor_YawToPoint",), - 0x800B6D50:("Actor_PitchBetweenActors",), - 0x800B6D7C:("Actor_PitchBetweenActorsTop",), - 0x800B6DA8:("Actor_PitchToPoint",), - 0x800B6DCC:("Actor_DistanceBetweenActors",), - 0x800B6DF8:("Actor_DistanceToPoint",), - 0x800B6E1C:("Actor_XZDistanceBetweenActors",), - 0x800B6E48:("Actor_XZDistanceToPoint",), + 0x800B6CD4:("Actor_WorldYawTowardActor",), + 0x800B6D00:("Actor_FocusYawTowardActor",), + 0x800B6D2C:("Actor_WorldYawTowardPoint",), + 0x800B6D50:("Actor_WorldPitchTowardActor",), + 0x800B6D7C:("Actor_FocusPitchTowardActor",), + 0x800B6DA8:("Actor_WorldPitchTowardPoint",), + 0x800B6DCC:("Actor_WorldDistXYZToActor",), + 0x800B6DF8:("Actor_WorldDistXYZToPoint",), + 0x800B6E1C:("Actor_WorldDistXZToActor",), + 0x800B6E48:("Actor_WorldDistXZToPoint",), 0x800B6E6C:("Actor_OffsetOfPointInActorCoords",), 0x800B6F0C:("Actor_HeightDiff",), 0x800B6F20:("func_800B6F20",), @@ -785,13 +785,13 @@ 0x800B8898:("Actor_GetScreenPos",), 0x800B8934:("Actor_OnScreen",), 0x800B89F8:("Actor_HasParent",), - 0x800B8A1C:("Actor_PickUp",), - 0x800B8B84:("Actor_PickUpNearby",), - 0x800B8BB0:("Actor_LiftActor",), - 0x800B8BD0:("Actor_PickUpFar",), + 0x800B8A1C:("Actor_OfferGetItem",), + 0x800B8B84:("Actor_OfferGetItemNearby",), + 0x800B8BB0:("Actor_OfferCarry",), + 0x800B8BD0:("Actor_OfferGetItemFar",), 0x800B8BFC:("Actor_HasNoParent",), 0x800B8C20:("func_800B8C20",), - 0x800B8C50:("func_800B8C50",), + 0x800B8C50:("Actor_SetClosestSecretDistance",), 0x800B8C78:("Actor_HasRider",), 0x800B8C9C:("Actor_SetRideActor",), 0x800B8CEC:("Actor_HasNoRider",), @@ -800,8 +800,8 @@ 0x800B8D98:("func_800B8D98",), 0x800B8DD4:("func_800B8DD4",), 0x800B8E1C:("func_800B8E1C",), - 0x800B8E58:("func_800B8E58",), - 0x800B8EC8:("Actor_PlaySfxAtPos",), + 0x800B8E58:("Player_PlaySfx",), + 0x800B8EC8:("Actor_PlaySfx",), 0x800B8EF4:("func_800B8EF4",), 0x800B8F98:("func_800B8F98",), 0x800B8FC0:("func_800B8FC0",), @@ -812,23 +812,23 @@ 0x800B9098:("func_800B9098",), 0x800B90AC:("func_800B90AC",), 0x800B90F4:("Actor_DeactivateLens",), - 0x800B9120:("func_800B9120",), + 0x800B9120:("Actor_InitHalfDaysBit",), 0x800B9170:("Actor_InitContext",), 0x800B9334:("Actor_SpawnSetupActors",), 0x800B948C:("Actor_UpdateActor",), 0x800B9780:("Actor_UpdateAll",), 0x800B9A04:("Actor_Draw",), 0x800B9D1C:("func_800B9D1C",), - 0x800B9E3C:("Actor_DrawAllSetup",), - 0x800B9E4C:("Actor_RecordUndrawnActor",), + 0x800B9E3C:("Actor_ResetLensActors",), + 0x800B9E4C:("Actor_AddToLensActors",), 0x800B9E84:("Actor_DrawLensOverlay",), 0x800B9EF4:("Actor_DrawLensActors",), 0x800BA2D8:("func_800BA2D8",), 0x800BA2FC:("func_800BA2FC",), 0x800BA42C:("Actor_DrawAll",), - 0x800BA6FC:("func_800BA6FC",), + 0x800BA6FC:("Actor_KillAllWithMissingObject",), 0x800BA798:("func_800BA798",), - 0x800BA8B8:("func_800BA8B8",), + 0x800BA8B8:("Actor_KillAllOnHalfDayChange",), 0x800BA9B4:("Actor_CleanupContext",), 0x800BAAB4:("Actor_AddToCategory",), 0x800BAB24:("Actor_RemoveFromCategory",), @@ -851,7 +851,7 @@ 0x800BBDAC:("Actor_SpawnFloorDustRing",), 0x800BBFB0:("func_800BBFB0",), 0x800BC154:("func_800BC154",), - 0x800BC188:("func_800BC188",), + 0x800BC188:("Actor_GetArrowDmgFlags",), 0x800BC1B4:("func_800BC1B4",), 0x800BC270:("func_800BC270",), 0x800BC444:("func_800BC444",), @@ -859,20 +859,20 @@ 0x800BC5B8:("Actor_IsTargeted",), 0x800BC5EC:("Actor_OtherIsTargeted",), 0x800BC620:("func_800BC620",), - 0x800BC770:("Actor_AddQuake",), - 0x800BC7D8:("Actor_AddQuakeWithSpeed",), - 0x800BC848:("func_800BC848",), + 0x800BC770:("Actor_RequestQuake",), + 0x800BC7D8:("Actor_RequestQuakeWithSpeed",), + 0x800BC848:("Actor_RequestQuakeAndRumble",), 0x800BC8B8:("Actor_DrawDoorLock",), 0x800BCB50:("Actor_SpawnShieldParticlesMetal",), 0x800BCB70:("Actor_SetColorFilter",), 0x800BCBF4:("func_800BCBF4",), 0x800BCC68:("func_800BCC68",), 0x800BCCDC:("Actor_GetClosestPosOnPath",), - 0x800BD2B4:("func_800BD2B4",), - 0x800BD384:("func_800BD384",), - 0x800BD6B8:("func_800BD6B8",), - 0x800BD6E4:("func_800BD6E4",), - 0x800BD888:("func_800BD888",), + 0x800BD2B4:("Npc_UpdateTalking",), + 0x800BD384:("Npc_TrackPointWithLimits",), + 0x800BD6B8:("Npc_GetTrackingPresetMaxPlayerYaw",), + 0x800BD6E4:("Npc_UpdateAutoTurn",), + 0x800BD888:("Npc_TrackPoint",), 0x800BD9A0:("func_800BD9A0",), 0x800BD9E0:("func_800BD9E0",), 0x800BDAA0:("func_800BDAA0",), @@ -895,7 +895,7 @@ 0x800BE63C:("Actor_IsSmallChest",), 0x800BE680:("Actor_DrawDamageEffects",), 0x800BF7CC:("Actor_SpawnIceEffects",), - 0x800BF9A0:("ActorOverlayTable_FaultPrint",), + 0x800BF9A0:("ActorOverlayTable_FaultClient",), 0x800BFA78:("ActorOverlayTable_FaultAddrConv",), 0x800BFAE8:("ActorOverlayTable_Init",), 0x800BFB40:("ActorOverlayTable_Cleanup",), @@ -1016,18 +1016,18 @@ 0x800C6098:("DynaPoly_Alloc",), 0x800C6188:("DynaPoly_SetBgActor",), 0x800C6248:("DynaPoly_GetActor",), - 0x800C62BC:("func_800C62BC",), - 0x800C6314:("func_800C6314",), - 0x800C636C:("func_800C636C",), - 0x800C63C4:("func_800C63C4",), - 0x800C641C:("func_800C641C",), - 0x800C6474:("func_800C6474",), + 0x800C62BC:("DynaPoly_DisableCollision",), + 0x800C6314:("DynaPoly_EnableCollision",), + 0x800C636C:("DynaPoly_DisableCeilingCollision",), + 0x800C63C4:("DynaPoly_EnableCeilingCollision",), + 0x800C641C:("DynaPoly_DisableFloorCollision",), + 0x800C6474:("DynaPoly_EnableFloorCollision",), 0x800C64CC:("DynaPoly_DeleteBgActor",), - 0x800C6554:("func_800C6554",), + 0x800C6554:("DynaPoly_InvalidateLookup",), 0x800C656C:("BgCheck_CalcWaterboxDimensions",), - 0x800C6838:("DynaPoly_ExpandSRT",), - 0x800C734C:("BgCheck_ResetFlagsIfLoadedActor",), - 0x800C73E4:("DynaPoly_Setup",), + 0x800C6838:("DynaPoly_AddBgActorToLookup",), + 0x800C734C:("DynaPoly_UnsetAllInteractFlags",), + 0x800C73E4:("DynaPoly_UpdateContext",), 0x800C756C:("func_800C756C",), 0x800C765C:("DynaPoly_UpdateBgActorTransforms",), 0x800C76EC:("BgCheck_RaycastFloorDynaList",), @@ -1055,21 +1055,21 @@ 0x800C98CC:("BgCheck_GetBgCamFuncDataImpl",), 0x800C9924:("BgCheck_GetBgCamFuncData",), 0x800C99AC:("SurfaceType_GetSceneExitIndex",), - 0x800C99D4:("func_800C99D4",), + 0x800C99D4:("SurfaceType_GetFloorType",), 0x800C99FC:("func_800C99FC",), - 0x800C9A24:("func_800C9A24",), - 0x800C9A4C:("func_800C9A4C",), - 0x800C9A7C:("func_800C9A7C",), - 0x800C9AB0:("func_800C9AB0",), - 0x800C9AE4:("func_800C9AE4",), - 0x800C9B18:("func_800C9B18",), - 0x800C9B40:("func_800C9B40",), - 0x800C9B68:("func_800C9B68",), + 0x800C9A24:("SurfaceType_GetWallType",), + 0x800C9A4C:("SurfaceType_GetWallFlags",), + 0x800C9A7C:("SurfaceType_CheckWallFlag0",), + 0x800C9AB0:("SurfaceType_CheckWallFlag1",), + 0x800C9AE4:("SurfaceType_CheckWallFlag2",), + 0x800C9B18:("SurfaceType_GetFloorProperty2",), + 0x800C9B40:("SurfaceType_GetFloorProperty",), + 0x800C9B68:("SurfaceType_IsSoft",), 0x800C9B90:("SurfaceType_IsHorseBlocked",), - 0x800C9BB8:("func_800C9BB8",), - 0x800C9BDC:("SurfaceType_GetSfx",), - 0x800C9C24:("func_800C9C24",), - 0x800C9C74:("SurfaceType_GetSlope",), + 0x800C9BB8:("SurfaceType_GetMaterial",), + 0x800C9BDC:("SurfaceType_GetSfxOffset",), + 0x800C9C24:("SurfaceType_HasMaterialProperty",), + 0x800C9C74:("SurfaceType_GetFloorEffect",), 0x800C9C9C:("SurfaceType_GetLightSettingIndex",), 0x800C9CC4:("SurfaceType_GetEcho",), 0x800C9CEC:("SurfaceType_IsHookshotSurface",), @@ -1092,39 +1092,39 @@ 0x800CA6F0:("func_800CA6F0",), 0x800CA9D0:("func_800CA9D0",), 0x800CAA14:("func_800CAA14",), - 0x800CAAD0:("BgCheck2_UpdateActorPosition",), - 0x800CAC0C:("BgCheck2_UpdateActorYRotation",), - 0x800CACA0:("BgCheck2_AttachToMesh",), - 0x800CAD2C:("BgCheck2_UpdateActorAttachedToMesh",), + 0x800CAAD0:("DynaPolyActor_UpdateCarriedActorPos",), + 0x800CAC0C:("DynaPolyActor_UpdateCarriedActorRotY",), + 0x800CACA0:("DynaPolyActor_AttachCarriedActor",), + 0x800CAD2C:("DynaPolyActor_TransformCarriedActor",), 0x800CAE10:("DynaPolyActor_Init",), 0x800CAE34:("DynaPolyActor_LoadMesh",), - 0x800CAE7C:("DynaPolyActor_ResetState",), - 0x800CAE88:("DynaPolyActor_SetRidingFallingState",), - 0x800CAE9C:("DynaPolyActor_SetRidingMovingState",), - 0x800CAEB0:("DynaPolyActor_SetRidingMovingStateByIndex",), - 0x800CAEE0:("DynaPolyActor_SetRidingRotatingState",), - 0x800CAEF4:("DynaPolyActor_SetRidingRotatingStateByIndex",), - 0x800CAF24:("DynaPolyActor_SetSwitchPressedState",), - 0x800CAF38:("DynaPolyActor_SetHeavySwitchPressedState",), - 0x800CAF4C:("DynaPolyActor_IsInRidingFallingState",), - 0x800CAF70:("DynaPolyActor_IsInRidingMovingState",), - 0x800CAF94:("DynaPolyActor_IsInRidingRotatingState",), - 0x800CAFB8:("DynaPolyActor_IsInSwitchPressedState",), - 0x800CAFDC:("DynaPolyActor_IsInHeavySwitchPressedState",), + 0x800CAE7C:("DynaPolyActor_UnsetAllInteractFlags",), + 0x800CAE88:("DynaPolyActor_SetActorOnTop",), + 0x800CAE9C:("DynaPolyActor_SetPlayerOnTop",), + 0x800CAEB0:("DynaPoly_SetPlayerOnTop",), + 0x800CAEE0:("DynaPolyActor_SetPlayerAbove",), + 0x800CAEF4:("DynaPoly_SetPlayerAbove",), + 0x800CAF24:("DynaPolyActor_SetActorOnSwitch",), + 0x800CAF38:("DynaPolyActor_SetActorOnHeavySwitch",), + 0x800CAF4C:("DynaPolyActor_IsActorOnTop",), + 0x800CAF70:("DynaPolyActor_IsPlayerOnTop",), + 0x800CAF94:("DynaPolyActor_IsPlayerAbove",), + 0x800CAFB8:("DynaPolyActor_IsSwitchPressed",), + 0x800CAFDC:("DynaPolyActor_IsHeavySwitchPressed",), 0x800CB000:("DynaPolyActor_ValidateMove",), 0x800CB210:("Camera_fabsf",), 0x800CB240:("Camera_Vec3fMagnitude",), 0x800CB270:("Camera_QuadraticAttenuation",), - 0x800CB330:("Camera_LerpCeilF",), - 0x800CB398:("Camera_LerpCeilS",), - 0x800CB42C:("Camera_LerpFloorS",), - 0x800CB4C0:("Camera_LerpCeilVec3f",), + 0x800CB330:("Camera_ScaledStepToCeilF",), + 0x800CB398:("Camera_ScaledStepToCeilS",), + 0x800CB42C:("Camera_ScaledStepToFloorS",), + 0x800CB4C0:("Camera_ScaledStepToCeilVec3f",), 0x800CB544:("Camera_SetUpdateRatesFastPitch",), 0x800CB584:("Camera_SetUpdateRatesFastYaw",), 0x800CB5DC:("Camera_SetUpdateRatesSlow",), 0x800CB60C:("Camera_Vec3sToVec3f",), 0x800CB674:("Camera_AngleDiffAndScale",), - 0x800CB6C8:("Camera_UpdateAtActorOffset",), + 0x800CB6C8:("Camera_SetFocalActorAtOffset",), 0x800CB700:("Camera_GetFocalActorHeight",), 0x800CB780:("Camera_GetRunSpeedLimit",), 0x800CB7CC:("func_800CB7CC",), @@ -1147,41 +1147,41 @@ 0x800CBC30:("func_800CBC30",), 0x800CBC84:("func_800CBC84",), 0x800CBFA4:("func_800CBFA4",), - 0x800CC000:("func_800CC000",), - 0x800CC128:("func_800CC128",), - 0x800CC1C4:("func_800CC1C4",), + 0x800CC000:("Camera_BgCheckInfo",), + 0x800CC128:("Camera_BgCheck",), + 0x800CC1C4:("Camera_CheckOOB",), 0x800CC260:("func_800CC260",), - 0x800CC488:("func_800CC488",), - 0x800CC56C:("func_800CC56C",), - 0x800CC5C8:("func_800CC5C8",), + 0x800CC488:("Camera_GetFloorYNorm",), + 0x800CC56C:("Camera_GetFloorY",), + 0x800CC5C8:("Camera_GetFloorYLayer",), 0x800CC740:("Camera_GetBgCamOrActorCsCamSetting",), 0x800CC7A8:("Camera_GetBgCamOrActorCsCamFuncData",), 0x800CC804:("Camera_GetBgCamIndex",), 0x800CC874:("Camera_GetWaterBoxBgCamSetting",), 0x800CC938:("func_800CC938",), - 0x800CC958:("func_800CC958",), - 0x800CC9C0:("func_800CC9C0",), + 0x800CC958:("Camera_CalcXZAngle",), + 0x800CC9C0:("Camera_GetPitchAdjFromFloorHeightDiffs",), 0x800CCCEC:("func_800CCCEC",), - 0x800CD04C:("func_800CD04C",), - 0x800CD288:("func_800CD288",), - 0x800CD2E0:("func_800CD2E0",), - 0x800CD2F0:("func_800CD2F0",), - 0x800CD3E4:("func_800CD3E4",), + 0x800CD04C:("Camera_CalcUpVec",), + 0x800CD288:("Camera_ClampLerpScale",), + 0x800CD2E0:("Camera_ResetActionFuncState",), + 0x800CD2F0:("Camera_UpdateInterface",), + 0x800CD3E4:("Camera_BgCheckCorner",), 0x800CD44C:("func_800CD44C",), - 0x800CD634:("func_800CD634",), + 0x800CD634:("Camera_CalcSlopeYAdj",), 0x800CD6CC:("func_800CD6CC",), - 0x800CD6F8:("func_800CD6F8",), - 0x800CD834:("func_800CD834",), - 0x800CDA14:("func_800CDA14",), - 0x800CDB6C:("func_800CDB6C",), - 0x800CDE6C:("func_800CDE6C",), - 0x800CE2B8:("func_800CE2B8",), - 0x800CE5E0:("func_800CE5E0",), - 0x800CE79C:("func_800CE79C",), - 0x800CE930:("func_800CE930",), - 0x800CEAD8:("func_800CEAD8",), - 0x800CEC38:("func_800CEC38",), - 0x800CED90:("func_800CED90",), + 0x800CD6F8:("Camera_CalcAtDefault",), + 0x800CD834:("Camera_CalcAtForScreen",), + 0x800CDA14:("Camera_CalcAtForNormal1",), + 0x800CDB6C:("Camera_CalcAtForParallel",), + 0x800CDE6C:("Camera_CalcAtForFriendlyLockOn",), + 0x800CE2B8:("Camera_CalcAtForEnemyLockOn",), + 0x800CE5E0:("Camera_CalcAtForHorse",), + 0x800CE79C:("Camera_ClampDist1",), + 0x800CE930:("Camera_ClampDist2",), + 0x800CEAD8:("Camera_CalcDefaultPitch",), + 0x800CEC38:("Camera_CalcDefaultYaw",), + 0x800CED90:("Camera_CalcDefaultSwing",), 0x800CF3A4:("Camera_Noop",), 0x800CF3B4:("Camera_Normal1",), 0x800D0874:("Camera_Normal2",), @@ -1253,48 +1253,48 @@ 0x800DD11C:("Camera_Special7",), 0x800DD13C:("Camera_Special8",), 0x800DD5B8:("Camera_Special9",), - 0x800DDD58:("Camera_Alloc",), - 0x800DDDA8:("Camera_Free",), + 0x800DDD58:("Camera_Create",), + 0x800DDDA8:("Camera_Destroy",), 0x800DDDD0:("Camera_Init",), 0x800DDFE0:("func_800DDFE0",), - 0x800DE0E0:("func_800DE0E0",), - 0x800DE0EC:("Camera_InitPlayerSettings",), + 0x800DE0E0:("Camera_Stub800DE0E0",), + 0x800DE0EC:("Camera_InitFocalActorSettings",), 0x800DE308:("Camera_ChangeStatus",), - 0x800DE324:("func_800DE324",), - 0x800DE62C:("func_800DE62C",), - 0x800DE840:("func_800DE840",), - 0x800DE890:("func_800DE890",), - 0x800DE954:("func_800DE954",), + 0x800DE324:("Camera_UpdateWater",), + 0x800DE62C:("Camera_EarthquakeDay3",), + 0x800DE840:("Camera_UpdateHotRoom",), + 0x800DE890:("Camera_SetSwordDistortion",), + 0x800DE954:("Camera_RequestGiantsMaskSetting",), 0x800DE9B0:("Camera_Update",), 0x800DF498:("func_800DF498",), - 0x800DF4D0:("Camera_SetMode",), + 0x800DF4D0:("Camera_ChangeModeFlags",), 0x800DF840:("Camera_ChangeMode",), - 0x800DF86C:("func_800DF86C",), - 0x800DF8EC:("func_800DF8EC",), + 0x800DF86C:("Camera_CheckValidMode",), + 0x800DF8EC:("Camera_ChangeSettingFlags",), 0x800DFAC8:("Camera_ChangeSetting",), - 0x800DFB14:("Camera_ChangeDataIdx",), - 0x800DFC1C:("func_800DFC1C",), - 0x800DFC40:("func_800DFC40",), + 0x800DFB14:("Camera_ChangeActorCsCamIndex",), + 0x800DFC1C:("Camera_GetInputDir",), + 0x800DFC40:("Camera_GetInputDirPitch",), 0x800DFC68:("Camera_GetInputDirYaw",), 0x800DFC90:("Camera_GetCamDir",), 0x800DFCB4:("Camera_GetCamDirPitch",), 0x800DFCDC:("Camera_GetCamDirYaw",), 0x800DFD04:("Camera_AddQuake",), 0x800DFD78:("Camera_SetViewParam",), - 0x800DFEF0:("func_800DFEF0",), - 0x800DFF18:("func_800DFF18",), - 0x800DFF34:("func_800DFF34",), - 0x800DFF44:("func_800DFF44",), - 0x800DFF60:("Camera_SetFlags",), - 0x800DFF84:("Camera_ClearFlags",), + 0x800DFEF0:("Camera_UnsetViewFlag",), + 0x800DFF18:("Camera_OverwriteStateFlags",), + 0x800DFF34:("Camera_ResetActionFuncStateUnused",), + 0x800DFF44:("Camera_SetCsParams",), + 0x800DFF60:("Camera_SetStateFlag",), + 0x800DFF84:("Camera_UnsetStateFlag",), 0x800DFFAC:("Camera_ChangeDoorCam",), 0x800E007C:("Camera_Copy",), - 0x800E01AC:("func_800E01AC",), + 0x800E01AC:("Camera_IsDbgCamEnabled",), 0x800E01B8:("Camera_GetQuakeOffset",), - 0x800E01DC:("func_800E01DC",), - 0x800E0228:("func_800E0228",), + 0x800E01DC:("Camera_SetCameraData",), + 0x800E0228:("Camera_GetNegOne",), 0x800E0238:("func_800E0238",), - 0x800E02AC:("Camera_SetToTrackActor",), + 0x800E02AC:("Camera_SetFocalActor",), 0x800E0308:("Camera_SetTargetActor",), 0x800E031C:("Camera_GetWaterYPos",), 0x800E0348:("func_800E0348",), @@ -1519,7 +1519,7 @@ 0x800E9138:("Actor_TrackPlayerSetFocusHeight",), 0x800E9250:("Actor_TrackPlayer",), 0x800E9360:("SaveContext_Init",), - 0x800E93E0:("GameInfo_Init",), + 0x800E93E0:("Regs_Init",), 0x800E9470:("DebugDisplay_Init",), 0x800E9488:("DebugDisplay_AddObject",), 0x800E9564:("DebugDisplay_DrawObjects",), @@ -1527,60 +1527,60 @@ 0x800E97D8:("DebugDisplay_DrawPolygon",), 0x800E992C:("DebugDisplay_DrawPath",), 0x800E99B0:("DebugDisplay_PathDisplayList",), - 0x800E9C90:("func_800E9C90",), - 0x800E9CA0:("func_800E9CA0",), - 0x800E9CFC:("func_800E9CFC",), - 0x800E9DBC:("func_800E9DBC",), - 0x800E9E94:("func_800E9E94",), - 0x800E9F78:("func_800E9F78",), - 0x800EA060:("Cutscene_Init",), - 0x800EA0D4:("Cutscene_Start",), - 0x800EA0EC:("Cutscene_End",), - 0x800EA110:("Cutscene_Update1",), - 0x800EA15C:("Cutscene_Update2",), - 0x800EA210:("Cutscene_DoNothing",), - 0x800EA220:("func_800EA220",), - 0x800EA258:("func_800EA258",), - 0x800EA2B8:("func_800EA2B8",), - 0x800EA324:("Cutscene_Command_Misc",), - 0x800EABAC:("Cutscene_Command_SetLighting",), - 0x800EAC08:("Cutscene_Command_PlaySequence",), - 0x800EAC44:("Cutscene_Command_StopSequence",), - 0x800EAC94:("Cutscene_Command_FadeSequence",), - 0x800EAD14:("Cutscene_Command_PlayAmbienceSequence",), - 0x800EAD48:("func_800EAD48",), - 0x800EAD7C:("func_800EAD7C",), - 0x800EADB0:("func_800EADB0",), - 0x800EAECC:("Cutscene_Command_FadeAmbienceSequence",), - 0x800EAF20:("Cutscene_Command_Rumble",), - 0x800EAFE0:("Cutscene_Command_FadeColorScreen",), - 0x800EB1DC:("Cutscene_Command_SetTime",), - 0x800EB364:("Cutscene_TerminatorImpl",), - 0x800EB4B4:("Cutscene_Command_Terminator",), - 0x800EB6F8:("Cutscene_Command_ChooseCreditsScenes",), - 0x800EBB68:("Cutscene_Command_MotionBlur",), - 0x800EBCD0:("Cutscene_Command_GiveTatlToPlayer",), - 0x800EBD60:("Cutscene_Command_TransitionFX",), - 0x800EC678:("Cutscene_Command_Camera",), + 0x800E9C90:("Debug_ClearTextDrawFlags",), + 0x800E9CA0:("Debug_ScreenText",), + 0x800E9CFC:("Debug_DrawScreenText",), + 0x800E9DBC:("DebugCamera_ScreenText",), + 0x800E9E94:("DebugCamera_DrawScreenText",), + 0x800E9F78:("Debug_DrawText",), + 0x800EA060:("Cutscene_InitContext",), + 0x800EA0D4:("Cutscene_StartManual",), + 0x800EA0EC:("Cutscene_StopManual",), + 0x800EA110:("Cutscene_UpdateManual",), + 0x800EA15C:("Cutscene_UpdateScripted",), + 0x800EA210:("CutsceneHandler_DoNothing",), + 0x800EA220:("Cutscene_StepTimer",), + 0x800EA258:("CutsceneHandler_StartManual",), + 0x800EA2B8:("CutsceneHandler_StartScript",), + 0x800EA324:("CutsceneCmd_Misc",), + 0x800EABAC:("CutsceneCmd_SetLightSetting",), + 0x800EAC08:("CutsceneCmd_StartSequence",), + 0x800EAC44:("CutsceneCmd_StopSequence",), + 0x800EAC94:("CutsceneCmd_FadeOutSequence",), + 0x800EAD14:("CutsceneCmd_StartAmbience",), + 0x800EAD48:("Cutscene_SetSfxReverbIndexTo2",), + 0x800EAD7C:("Cutscene_SetSfxReverbIndexTo1",), + 0x800EADB0:("CutsceneCmd_ModifySequence",), + 0x800EAECC:("CutsceneCmd_FadeOutAmbience",), + 0x800EAF20:("CutsceneCmd_RumbleController",), + 0x800EAFE0:("CutsceneCmd_TransitionGeneral",), + 0x800EB1DC:("CutsceneCmd_SetTime",), + 0x800EB364:("CutsceneCmd_DestinationDefault",), + 0x800EB4B4:("CutsceneCmd_Destination",), + 0x800EB6F8:("CutsceneCmd_ChooseCreditsScenes",), + 0x800EBB68:("CutsceneCmd_MotionBlur",), + 0x800EBCD0:("CutsceneCmd_GiveTatlToPlayer",), + 0x800EBD60:("CutsceneCmd_Transition",), + 0x800EC678:("CutsceneCmd_UpdateCamSpline",), 0x800EC6D4:("Cutscene_CountNormalMasks",), - 0x800EC924:("Cutscene_Command_Textbox",), - 0x800ECD7C:("func_800ECD7C",), - 0x800ECE40:("Cutscene_ProcessCommands",), - 0x800ED980:("func_800ED980",), - 0x800ED9C4:("func_800ED9C4",), - 0x800EDA04:("func_800EDA04",), - 0x800EDA84:("func_800EDA84",), - 0x800EDBE0:("func_800EDBE0",), + 0x800EC924:("CutsceneCmd_Text",), + 0x800ECD7C:("Cutscene_SetActorCue",), + 0x800ECE40:("Cutscene_ProcessScript",), + 0x800ED980:("CutsceneHandler_RunScript",), + 0x800ED9C4:("CutsceneHandler_StopManual",), + 0x800EDA04:("CutsceneHandler_StopScript",), + 0x800EDA84:("Cutscene_SetupScripted",), + 0x800EDBE0:("Cutscene_HandleEntranceTriggers",), 0x800EDDB0:("func_800EDDB0",), 0x800EDDBC:("func_800EDDBC",), - 0x800EDDCC:("Cutscene_LoadCutsceneData",), + 0x800EDDCC:("Cutscene_StartScripted",), 0x800EDE34:("Cutscene_ActorTranslate",), 0x800EDF24:("Cutscene_ActorTranslateAndYaw",), 0x800EDF78:("Cutscene_ActorTranslateAndYawSmooth",), 0x800EE0CC:("Cutscene_ActorTranslateXZAndYawSmooth",), 0x800EE1D8:("Cutscene_GetSceneLayer",), - 0x800EE200:("Cutscene_GetActorActionIndex",), - 0x800EE29C:("Cutscene_CheckActorAction",), + 0x800EE200:("Cutscene_GetCueChannel",), + 0x800EE29C:("Cutscene_IsCueInChannel",), 0x800EE2F4:("Cutscene_IsPlaying",), 0x800EE320:("GetItem_Draw",), 0x800EE364:("GetItem_DrawBombchu",), @@ -1632,35 +1632,35 @@ 0x800F10AC:("EnHy_UpdateCollider",), 0x800F112C:("EnHy_PlayWalkingSound",), 0x800F1250:("Text_GetFaceReaction",), - 0x800F12D0:("EnvFlags_UnsetAll",), - 0x800F1304:("EnvFlags_Set",), - 0x800F1374:("EnvFlags_Unset",), - 0x800F13E8:("EnvFlags_Get",), - 0x800F1460:("func_800F1460",), - 0x800F14F8:("ActorCutscene_GetCutsceneImpl",), - 0x800F1544:("ActorCutscene_Init",), - 0x800F15D8:("func_800F15D8",), - 0x800F1648:("ActorCutscene_ClearWaiting",), - 0x800F1678:("ActorCutscene_ClearNextCutscenes",), - 0x800F16A8:("ActorCutscene_MarkNextCutscenes",), - 0x800F17FC:("ActorCutscene_End",), - 0x800F1A7C:("ActorCutscene_Update",), - 0x800F1BA4:("ActorCutscene_SetIntentToPlay",), - 0x800F1BE4:("ActorCutscene_GetCanPlayNext",), - 0x800F1C68:("ActorCutscene_StartAndSetUnkLinkFields",), - 0x800F1CE0:("ActorCutscene_StartAndSetFlag",), - 0x800F1D84:("ActorCutscene_Start",), - 0x800F1FBC:("ActorCutscene_Stop",), - 0x800F207C:("ActorCutscene_GetCurrentIndex",), - 0x800F208C:("ActorCutscene_GetCutscene",), - 0x800F20B8:("ActorCutscene_GetAdditionalCutscene",), - 0x800F20F8:("ActorCutscene_GetLength",), - 0x800F2138:("func_800F2138",), - 0x800F2178:("func_800F2178",), - 0x800F21B8:("ActorCutscene_GetCurrentSubCamId",), - 0x800F21CC:("func_800F21CC",), + 0x800F12D0:("CutsceneFlags_UnsetAll",), + 0x800F1304:("CutsceneFlags_Set",), + 0x800F1374:("CutsceneFlags_Unset",), + 0x800F13E8:("CutsceneFlags_Get",), + 0x800F1460:("CutsceneManager_SetHudVisibility",), + 0x800F14F8:("CutsceneManager_GetCutsceneEntryImpl",), + 0x800F1544:("CutsceneManager_Init",), + 0x800F15D8:("CutsceneManager_StoreCamera",), + 0x800F1648:("CutsceneManager_ClearWaiting",), + 0x800F1678:("CutsceneManager_ClearNextCutscenes",), + 0x800F16A8:("CutsceneManager_MarkNextCutscenes",), + 0x800F17FC:("CutsceneManager_End",), + 0x800F1A7C:("CutsceneManager_Update",), + 0x800F1BA4:("CutsceneManager_Queue",), + 0x800F1BE4:("CutsceneManager_IsNext",), + 0x800F1C68:("CutsceneManager_StartWithPlayerCs",), + 0x800F1CE0:("CutsceneManager_StartWithPlayerCsAndSetFlag",), + 0x800F1D84:("CutsceneManager_Start",), + 0x800F1FBC:("CutsceneManager_Stop",), + 0x800F207C:("CutsceneManager_GetCurrentCsId",), + 0x800F208C:("CutsceneManager_GetCutsceneEntry",), + 0x800F20B8:("CutsceneManager_GetAdditionalCsId",), + 0x800F20F8:("CutsceneManager_GetLength",), + 0x800F2138:("CutsceneManager_GetCutsceneScriptIndex",), + 0x800F2178:("CutsceneManager_GetCutsceneCustomValue",), + 0x800F21B8:("CutsceneManager_GetCurrentSubCamId",), + 0x800F21CC:("CutsceneManager_FindEntranceCsId",), 0x800F22C4:("func_800F22C4",), - 0x800F23C4:("ActorCutscene_SetReturnCamera",), + 0x800F23C4:("CutsceneManager_SetReturnCamera",), 0x800F23E0:("Curve_CubicHermiteSpline",), 0x800F2478:("Curve_Interpolate",), 0x800F2620:("SkelCurve_Clear",), @@ -1708,11 +1708,11 @@ 0x800F5004:("Font_LoadOrderedFont",), 0x800F5090:("func_800F5090",), 0x800F50D4:("func_800F50D4",), - 0x800F510C:("Kankyo_Init",), + 0x800F510C:("Environment_Init",), 0x800F5954:("func_800F5954",), 0x800F5A8C:("Environment_LerpWeight",), 0x800F5B10:("func_800F5B10",), - 0x800F5CD0:("func_800F5CD0",), + 0x800F5CD0:("Environment_UpdateSkybox",), 0x800F6834:("func_800F6834",), 0x800F694C:("func_800F694C",), 0x800F6A04:("func_800F6A04",), @@ -1727,13 +1727,13 @@ 0x800F88C4:("func_800F88C4",), 0x800F8970:("func_800F8970",), 0x800F8A9C:("func_800F8A9C",), - 0x800F8CD4:("func_800F8CD4",), + 0x800F8CD4:("Environment_Update",), 0x800F8D84:("func_800F8D84",), - 0x800F9728:("func_800F9728",), + 0x800F9728:("Environment_DrawSunLensFlare",), 0x800F9824:("func_800F9824",), 0x800FA39C:("func_800FA39C",), 0x800FA3C4:("func_800FA3C4",), - 0x800FA9FC:("func_800FA9FC",), + 0x800FA9FC:("Environment_DrawRain",), 0x800FAAB4:("func_800FAAB4",), 0x800FAC20:("func_800FAC20",), 0x800FAF74:("func_800FAF74",), @@ -1742,13 +1742,13 @@ 0x800FB388:("func_800FB388",), 0x800FB758:("func_800FB758",), 0x800FB9B4:("func_800FB9B4",), - 0x800FBCBC:("func_800FBCBC",), + 0x800FBCBC:("Environment_DrawCustomLensFlare",), 0x800FBDEC:("Kankyo_InitGameOverLights",), 0x800FBF3C:("Kankyo_FadeInGameOverLights",), 0x800FC158:("Kankyo_FadeOutGameOverLights",), 0x800FC3DC:("func_800FC3DC",), - 0x800FC444:("func_800FC444",), - 0x800FC64C:("func_800FC64C",), + 0x800FC444:("Environment_FillScreen",), + 0x800FC64C:("Environment_DrawSandstorm",), 0x800FD2B4:("func_800FD2B4",), 0x800FD538:("func_800FD538",), 0x800FD59C:("func_800FD59C",), @@ -1881,7 +1881,7 @@ 0x80102464:("Lights_FreeNode",), 0x801024AC:("LightContext_Init",), 0x80102518:("LightContext_SetAmbientColor",), - 0x80102544:("func_80102544",), + 0x80102544:("LightContext_SetFog",), 0x80102580:("LightContext_NewLights",), 0x801025B8:("LightContext_InitList",), 0x801025C8:("LightContext_DestroyList",), @@ -2072,17 +2072,17 @@ 0x8010C36C:("OLib_ClampMaxDist",), 0x8010C3D4:("OLib_Vec3fDistNormalize",), 0x8010C484:("OLib_VecSphToVec3f",), - 0x8010C530:("OLib_VecSphGeoToVec3f",), + 0x8010C530:("OLib_VecGeoToVec3f",), 0x8010C574:("OLib_Vec3fToVecSph",), - 0x8010C6C8:("OLib_Vec3fToVecSphGeo",), + 0x8010C6C8:("OLib_Vec3fToVecGeo",), 0x8010C710:("OLib_Vec3fDiffToVecSph",), - 0x8010C764:("OLib_Vec3fDiffToVecSphGeo",), - 0x8010C7B8:("OLib_VecSphAddToVec3f",), + 0x8010C764:("OLib_Vec3fDiffToVecGeo",), + 0x8010C7B8:("OLib_AddVecGeoToVec3f",), 0x8010C838:("OLib_Vec3fDiffRad",), 0x8010C8C8:("OLib_Vec3fDiffDegF",), 0x8010C930:("OLib_Vec3fDiffBinAng",), - 0x8010C9C8:("OLib_DbCameraVec3fDiff",), - 0x8010CAA0:("OLib_DbCameraVec3fSum",), + 0x8010C9C8:("OLib_Vec3fDiff",), + 0x8010CAA0:("OLib_Vec3fAdd",), 0x8010CB80:("Gfx_DrawTexRectRGBA16",), 0x8010CD98:("Gfx_DrawTexRectIA8",), 0x8010CFBC:("Gfx_DrawTexRectIA8_DropShadow",), @@ -2104,14 +2104,14 @@ 0x8010EF9C:("Interface_UpdateButtonAlphasByStatus",), 0x8010F0D4:("Interface_UpdateButtonAlphas",), 0x8010F1A8:("Interface_UpdateHudAlphas",), - 0x80110038:("func_80110038",), - 0x80111CB4:("func_80111CB4",), + 0x80110038:("Interface_UpdateButtonsPart2",), + 0x80111CB4:("Interface_UpdateButtonsPart1",), 0x801129E4:("Interface_SetSceneRestrictions",), 0x80112AF4:("Interface_Noop",), 0x80112AFC:("Interface_InitMinigame",), 0x80112B40:("Interface_LoadItemIconImpl",), 0x80112BE4:("Interface_LoadItemIcon",), - 0x80112C0C:("func_80112C0C",), + 0x80112C0C:("Interface_UpdateButtonsAlt",), 0x80112E80:("Item_Give",), 0x801143CC:("Item_CheckObtainabilityImpl",), 0x80114978:("Item_CheckObtainability",), @@ -2141,15 +2141,15 @@ 0x80116114:("Magic_FlashMeterBorder",), 0x80116348:("Magic_Update",), 0x80116918:("Magic_DrawMeter",), - 0x80116FD8:("func_80116FD8",), - 0x801170B8:("func_801170B8",), - 0x80117100:("func_80117100",), - 0x80117A20:("func_80117A20",), - 0x80117BD0:("func_80117BD0",), - 0x80118084:("func_80118084",), - 0x80118890:("func_80118890",), - 0x80118BA4:("func_80118BA4",), - 0x80119030:("func_80119030",), + 0x80116FD8:("Interface_SetPerspectiveView",), + 0x801170B8:("Interface_SetOrthoView",), + 0x80117100:("Interface_DrawItemButtons",), + 0x80117A20:("Interface_DrawItemIconTexture",), + 0x80117BD0:("Interface_DrawAmmoCount",), + 0x80118084:("Interface_DrawBButtonIcons",), + 0x80118890:("Interface_DrawCButtonIcons",), + 0x80118BA4:("Interface_DrawAButton",), + 0x80119030:("Interface_DrawPauseMenuEquippingIcons",), 0x80119610:("Interface_DrawClock",), 0x8011B4E0:("Interface_SetPerfectLetters",), 0x8011B5C0:("Interface_UpdatePerfectLettersType1",), @@ -2221,23 +2221,23 @@ 0x80124088:("Player_IsHoldingMirrorShield",), 0x801240C8:("Player_IsHoldingHookshot",), 0x801240DC:("func_801240DC",), - 0x80124110:("func_80124110",), - 0x80124148:("func_80124148",), - 0x80124168:("Player_ActionToMeleeWeapon",), + 0x80124110:("Player_BButtonSwordFromIA",), + 0x80124148:("Player_GetHeldBButtonSword",), + 0x80124168:("Player_MeleeWeaponFromIA",), 0x80124190:("Player_GetMeleeWeaponHeld",), 0x801241B4:("Player_IsHoldingTwoHandedWeapon",), - 0x801241E0:("Player_ActionToBottle",), + 0x801241E0:("Player_BottleFromIA",), 0x8012420C:("Player_GetBottleHeld",), - 0x8012422C:("Player_ActionToExplosive",), + 0x8012422C:("Player_ExplosiveFromIA",), 0x80124258:("Player_GetExplosiveHeld",), - 0x80124278:("Player_ActionToSword",), + 0x80124278:("Player_SwordFromIA",), 0x801242B4:("func_801242B4",), 0x801242DC:("Player_GetEnvironmentalHazard",), - 0x80124420:("func_80124420",), + 0x80124420:("Player_UpdateBunnyEars",), 0x80124618:("func_80124618",), 0x801246F4:("Player_DrawImpl",), - 0x80124870:("func_80124870",), - 0x80124CC4:("func_80124CC4",), + 0x80124870:("Player_AdjustSingleLeg",), + 0x80124CC4:("Player_DrawHookshotReticle",), 0x80124F18:("func_80124F18",), 0x80124FF0:("func_80124FF0",), 0x801251C4:("func_801251C4",), @@ -2246,13 +2246,13 @@ 0x8012536C:("func_8012536C",), 0x801253A4:("Player_DrawZoraShield",), 0x80125500:("func_80125500",), - 0x80125580:("func_80125580",), + 0x80125580:("Player_OverrideLimbDrawGameplayCommon",), 0x80125CE0:("func_80125CE0",), - 0x80125D4C:("func_80125D4C",), - 0x801262C8:("func_801262C8",), - 0x801263FC:("func_801263FC",), + 0x80125D4C:("Player_OverrideLimbDrawGameplayDefault",), + 0x801262C8:("Player_OverrideLimbDrawGameplayFirstPerson",), + 0x801263FC:("Player_OverrideLimbDrawGameplayCrawling",), 0x80126440:("func_80126440",), - 0x801265C8:("func_801265C8",), + 0x801265C8:("Player_UpdateShieldCollider",), 0x8012669C:("func_8012669C",), 0x80126808:("Player_DrawGetItemImpl",), 0x8012697C:("Player_DrawGetItem",), @@ -2267,13 +2267,13 @@ 0x801278F8:("Player_DrawBlastMask",), 0x80127A60:("Player_DrawBunnyHood",), 0x80127B64:("func_80127B64",), - 0x80127BE8:("func_80127BE8",), + 0x80127BE8:("Player_DrawStrayFairyParticles",), 0x80127DA4:("func_80127DA4",), 0x80128388:("func_80128388",), 0x801284A0:("Player_DrawGreatFairysMask",), 0x80128640:("func_80128640",), - 0x80128B74:("func_80128B74",), - 0x80128BD0:("func_80128BD0",), + 0x80128B74:("Player_SetFeetPos",), + 0x80128BD0:("Player_PostLimbDrawGameplay",), 0x80129EF0:("PreNMI_Stop",), 0x80129F04:("PreNMI_Update",), 0x80129F4C:("PreNMI_Draw",), @@ -2289,28 +2289,28 @@ 0x8012A4D0:("Quake_CallbackType2",), 0x8012A540:("Quake_CallbackType4",), 0x8012A5D8:("Quake_GetFreeIndex",), - 0x8012A638:("Quake_AddImpl",), - 0x8012A6F0:("Quake_RemoveRequest",), + 0x8012A638:("Quake_RequestImpl",), + 0x8012A6F0:("Quake_Remove",), 0x8012A718:("Quake_GetRequest",), 0x8012A774:("Quake_SetValue",), 0x8012A8A8:("Quake_SetSpeed",), - 0x8012A8F0:("Quake_SetCountdown",), - 0x8012A940:("Quake_GetCountdown",), - 0x8012A978:("Quake_SetQuakeValues",), - 0x8012A9E0:("Quake_SetQuakeValues2",), + 0x8012A8F0:("Quake_SetDuration",), + 0x8012A940:("Quake_GetTimeLeft",), + 0x8012A978:("Quake_SetPerturbations",), + 0x8012A9E0:("Quake_SetOrientation",), 0x8012AA48:("Quake_Init",), - 0x8012AA9C:("Quake_Add",), - 0x8012AAC0:("Quake_Remove",), - 0x8012AB08:("Quake_Calc",), + 0x8012AA9C:("Quake_Request",), + 0x8012AAC0:("Quake_RemoveRequest",), + 0x8012AB08:("Quake_Update",), 0x8012AE68:("Distortion_Init",), - 0x8012AEAC:("Distortion_SetCountdown",), - 0x8012AED4:("Distortion_GetCountdown",), + 0x8012AEAC:("Distortion_SetDuration",), + 0x8012AED4:("Distortion_GetTimeLeft",), 0x8012AEE4:("Distortion_GetType",), - 0x8012AEF4:("Distortion_SetType",), - 0x8012AF18:("Distortion_ClearType",), + 0x8012AEF4:("Distortion_Request",), + 0x8012AF18:("Distortion_RemoveRequest",), 0x8012AF38:("Distortion_GetUnderwaterCurrentSpeed",), 0x8012AF9C:("Distortion_Update",), - 0x8012BBE8:("Quake_NumActiveQuakes",), + 0x8012BBE8:("Quake_GetNumActiveQuakes",), 0x8012BC50:("Gfx_SetFog",), 0x8012BD8C:("Gfx_SetFogWithSync",), 0x8012BF08:("Gfx_SetFog2",), @@ -2391,14 +2391,14 @@ 0x8012CF0C:("func_8012CF0C",), 0x8012D374:("func_8012D374",), 0x8012D40C:("func_8012D40C",), - 0x8012D510:("Room_nop8012D510",), - 0x8012D528:("Room_DrawType3Mesh",), - 0x8012D53C:("Room_DrawType0Mesh",), - 0x8012D750:("Room_DrawType2Mesh",), - 0x8012DEE8:("func_8012DEE8",), - 0x8012E254:("func_8012E254",), - 0x8012E32C:("func_8012E32C",), - 0x8012E6A8:("Room_DrawType1Mesh",), + 0x8012D510:("Room_Noop",), + 0x8012D528:("Room_DrawNone",), + 0x8012D53C:("Room_DrawNormal",), + 0x8012D750:("Room_DrawCullable",), + 0x8012DEE8:("Room_DrawImageSingle",), + 0x8012E254:("Room_GetImageMultiBgEntry",), + 0x8012E32C:("Room_DrawImageMulti",), + 0x8012E6A8:("Room_DrawImage",), 0x8012E710:("Room_Init",), 0x8012E750:("Room_AllocateAndLoad",), 0x8012E96C:("Room_StartRoomTransition",), @@ -2422,43 +2422,43 @@ 0x8012F668:("Object_IsLoaded",), 0x8012F698:("Object_LoadAll",), 0x8012F73C:("func_8012F73C",), - 0x8012F79C:("Scene_HeaderCmdSpawnList",), - 0x8012F90C:("Scene_HeaderCmdActorList",), - 0x8012F954:("Scene_HeaderCmdActorCutsceneCamList",), - 0x8012F984:("Scene_HeaderCmdColHeader",), - 0x8012FA24:("Scene_HeaderCmdRoomList",), - 0x8012FA68:("Scene_HeaderCmdEntranceList",), - 0x8012FA98:("Scene_HeaderCmdSpecialFiles",), - 0x8012FB60:("Scene_HeaderCmdRoomBehavior",), - 0x8012FBE8:("Scene_HeaderCmdMesh",), - 0x8012FC18:("Scene_HeaderCmdObjectList",), - 0x8012FDA4:("Scene_HeaderCmdLightList",), - 0x8012FE2C:("Scene_HeaderCmdPathList",), - 0x8012FE5C:("Scene_HeaderCmdTransiActorList",), + 0x8012F79C:("Scene_CommandSpawnList",), + 0x8012F90C:("Scene_CommandActorList",), + 0x8012F954:("Scene_CommandActorCutsceneCamList",), + 0x8012F984:("Scene_CommandCollisionHeader",), + 0x8012FA24:("Scene_CommandRoomList",), + 0x8012FA68:("Scene_CommandEntranceList",), + 0x8012FA98:("Scene_CommandSpecialFiles",), + 0x8012FB60:("Scene_CommandRoomBehavior",), + 0x8012FBE8:("Scene_CommandMesh",), + 0x8012FC18:("Scene_CommandObjectList",), + 0x8012FDA4:("Scene_CommandLightList",), + 0x8012FE2C:("Scene_CommandPathList",), + 0x8012FE5C:("Scene_CommandTransiActorList",), 0x8012FEBC:("Scene_ResetTransiActorList",), - 0x8012FECC:("Scene_HeaderCmdEnvLightSettings",), + 0x8012FECC:("Scene_CommandEnvLightSettings",), 0x8012FF10:("Scene_LoadAreaTextures",), - 0x8012FF8C:("Scene_HeaderCmdSkyboxSettings",), - 0x8012FFF0:("Scene_HeaderCmdSkyboxDisables",), - 0x80130018:("Scene_HeaderCmdTimeSettings",), - 0x8013033C:("Scene_HeaderCmdWindSettings",), - 0x801303A0:("Scene_HeaderCmdExitList",), - 0x801303D0:("Scene_HeaderCmd09",), - 0x801303E0:("Scene_HeaderCmdSoundSettings",), - 0x8013043C:("Scene_HeaderCmdEchoSetting",), - 0x80130454:("Scene_HeaderCmdAltHeaderList",), - 0x801304CC:("Scene_HeaderCmdCutsceneList",), - 0x80130500:("Scene_HeaderCmdActorCutsceneList",), - 0x80130540:("Scene_HeaderCmdMiniMap",), - 0x80130578:("Scene_HeaderCmd1D",), - 0x80130588:("Scene_HeaderCmdMiniMapCompassInfo",), - 0x801305B0:("Scene_HeaderCmdSetRegionVisitedFlag",), - 0x80130674:("Scene_HeaderCmdAnimatedMaterials",), + 0x8012FF8C:("Scene_CommandSkyboxSettings",), + 0x8012FFF0:("Scene_CommandSkyboxDisables",), + 0x80130018:("Scene_CommandTimeSettings",), + 0x8013033C:("Scene_CommandWindSettings",), + 0x801303A0:("Scene_CommandExitList",), + 0x801303D0:("Scene_Command09",), + 0x801303E0:("Scene_CommandSoundSettings",), + 0x8013043C:("Scene_CommandEchoSetting",), + 0x80130454:("Scene_CommandAltHeaderList",), + 0x801304CC:("Scene_CommandCutsceneScriptList",), + 0x80130500:("Scene_CommandCutsceneList",), + 0x80130540:("Scene_CommandMiniMap",), + 0x80130578:("Scene_Command1D",), + 0x80130588:("Scene_CommandMiniMapCompassInfo",), + 0x801305B0:("Scene_CommandSetRegionVisitedFlag",), + 0x80130674:("Scene_CommandAnimatedMaterials",), 0x801306A4:("Scene_SetExitFade",), - 0x801306E8:("Scene_ProcessHeader",), + 0x801306E8:("Scene_ExecuteCommands",), 0x80130768:("Entrance_Create",), 0x80130784:("Entrance_CreateFromSpawn",), - 0x801307C0:("Scene_ExecuteDrawConfig",), + 0x801307C0:("Scene_Draw",), 0x801307F4:("Scene_DrawConfigDefault",), 0x80130834:("AnimatedMat_TexScroll",), 0x801308A0:("AnimatedMat_DrawTexScroll",), @@ -2537,9 +2537,9 @@ 0x80134B54:("SkelAnime_DrawFlexLimb",), 0x80134DBC:("SkelAnime_DrawFlex",), 0x80134FFC:("SkelAnime_GetFrameDataLegacy",), - 0x801353D4:("Animation_GetLimbCount2",), - 0x801353F8:("Animation_GetLength2",), - 0x8013541C:("Animation_GetLastFrame2",), + 0x801353D4:("Animation_GetLimbCountLegacy",), + 0x801353F8:("Animation_GetLengthLegacy",), + 0x8013541C:("Animation_GetLastFrameLegacy",), 0x80135448:("SkelAnime_InterpFrameTable",), 0x801358C8:("AnimationContext_Reset",), 0x801358D4:("AnimationContext_SetNextQueue",), @@ -2558,29 +2558,29 @@ 0x80135DB8:("AnimationContext_CopyFalse",), 0x80135E3C:("AnimationContext_MoveActor",), 0x80135EE8:("AnimationContext_Update",), - 0x80135F88:("SkelAnime_InitLink",), - 0x801360A8:("LinkAnimation_SetUpdateFunction",), - 0x801360E0:("LinkAnimation_Update",), - 0x80136104:("LinkAnimation_Morph",), - 0x801361BC:("LinkAnimation_AnimateFrame",), - 0x80136288:("LinkAnimation_Loop",), - 0x8013631C:("LinkAnimation_Once",), + 0x80135F88:("SkelAnime_InitPlayer",), + 0x801360A8:("PlayerAnimation_SetUpdateFunction",), + 0x801360E0:("PlayerAnimation_Update",), + 0x80136104:("PlayerAnimation_Morph",), + 0x801361BC:("PlayerAnimation_AnimateFrame",), + 0x80136288:("PlayerAnimation_Loop",), + 0x8013631C:("PlayerAnimation_Once",), 0x801363F0:("Animation_SetMorph",), - 0x80136414:("LinkAnimation_Change",), - 0x8013658C:("LinkAnimation_PlayOnce",), - 0x801365EC:("LinkAnimation_PlayOnceSetSpeed",), - 0x80136650:("LinkAnimation_PlayLoop",), - 0x801366AC:("LinkAnimation_PlayLoopSetSpeed",), - 0x8013670C:("LinkAnimation_CopyJointToMorph",), - 0x8013673C:("LinkAnimation_CopyMorphToJoint",), - 0x8013676C:("LinkAnimation_LoadToMorph",), - 0x801367B0:("LinkAnimation_LoadToJoint",), - 0x801367F4:("LinkAnimation_InterpJointMorph",), - 0x8013682C:("LinkAnimation_BlendToJoint",), - 0x801368CC:("LinkAnimation_BlendToMorph",), - 0x8013696C:("LinkAnimation_EndLoop",), + 0x80136414:("PlayerAnimation_Change",), + 0x8013658C:("PlayerAnimation_PlayOnce",), + 0x801365EC:("PlayerAnimation_PlayOnceSetSpeed",), + 0x80136650:("PlayerAnimation_PlayLoop",), + 0x801366AC:("PlayerAnimation_PlayLoopSetSpeed",), + 0x8013670C:("PlayerAnimation_CopyJointToMorph",), + 0x8013673C:("PlayerAnimation_CopyMorphToJoint",), + 0x8013676C:("PlayerAnimation_LoadToMorph",), + 0x801367B0:("PlayerAnimation_LoadToJoint",), + 0x801367F4:("PlayerAnimation_InterpJointMorph",), + 0x8013682C:("PlayerAnimation_BlendToJoint",), + 0x801368CC:("PlayerAnimation_BlendToMorph",), + 0x8013696C:("PlayerAnimation_EndLoop",), 0x80136990:("Animation_OnFrameImpl",), - 0x80136A48:("LinkAnimation_OnFrame",), + 0x80136A48:("PlayerAnimation_OnFrame",), 0x80136A7C:("SkelAnime_Init",), 0x80136B30:("SkelAnime_InitFlex",), 0x80136BEC:("SkelAnime_InitSkin",), @@ -2701,7 +2701,7 @@ 0x8013E07C:("SubS_ActorPathing_MoveWithoutGravityReverse",), 0x8013E0A4:("SubS_ActorPathing_SetNextPoint",), 0x8013E1C8:("SubS_ChangeAnimationBySpeedInfo",), - 0x8013E2D4:("SubS_StartActorCutscene",), + 0x8013E2D4:("SubS_StartCutscene",), 0x8013E3B8:("SubS_FillCutscenesList",), 0x8013E4B0:("SubS_ConstructPlane",), 0x8013E5CC:("SubS_LineSegVsPlane",), @@ -2775,18 +2775,18 @@ 0x80141C34:("VisMono_DesaturateDList",), 0x80141E60:("VisMono_Draw",), 0x8014204C:("VisMono_DrawOld",), - 0x801420C0:("func_801420C0",), - 0x801420F4:("func_801420F4",), - 0x80142100:("func_80142100",), + 0x801420C0:("VisZbuf_Init",), + 0x801420F4:("VisZbuf_Destroy",), + 0x80142100:("VisZbuf_Draw",), 0x80142440:("func_80142440",), 0x80143148:("func_80143148",), 0x801431E8:("Skybox_Setup",), 0x80143324:("func_80143324",), 0x801434E4:("Skybox_Init",), - 0x801435A0:("SkyboxDraw_UpdateMatrix",), - 0x80143624:("SkyboxDraw_SetColors",), - 0x80143668:("SkyboxDraw_Draw",), - 0x80143A04:("SkyboxDraw_Noop",), + 0x801435A0:("Skybox_UpdateMatrix",), + 0x80143624:("Skybox_SetColors",), + 0x80143668:("Skybox_Draw",), + 0x80143A04:("Skybox_Update",), 0x80143A10:("Sram_ActivateOwl",), 0x80143A54:("Sram_ClearHighscores",), 0x80143AC4:("Sram_ClearFlagsAtDawnOfTheFirstDay",), @@ -2797,7 +2797,7 @@ 0x80144684:("Sram_GenerateRandomSaveFields",), 0x80144890:("Sram_InitNewSave",), 0x80144968:("Sram_InitDebugSave",), - 0x80144A94:("func_80144A94",), + 0x80144A94:("Sram_ResetSaveFromMoonCrash",), 0x80144E78:("Sram_OpenSave",), 0x8014546C:("func_8014546C",), 0x80145698:("func_80145698",), @@ -2824,7 +2824,7 @@ 0x80147564:("func_80147564",), 0x80147624:("Message_ShouldAdvance",), 0x80147734:("Message_ShouldAdvanceSilent",), - 0x801477B4:("func_801477B4",), + 0x801477B4:("Message_CloseTextbox",), 0x80147818:("func_80147818",), 0x80147F18:("func_80147F18",), 0x80148558:("func_80148558",), @@ -2853,7 +2853,7 @@ 0x80150D08:("func_80150D08",), 0x801514B0:("func_801514B0",), 0x801518B0:("Message_StartTextbox",), - 0x80151938:("func_80151938",), + 0x80151938:("Message_ContinueTextbox",), 0x80151A68:("func_80151A68",), 0x80151BB4:("func_80151BB4",), 0x80151C9C:("func_80151C9C",), @@ -2870,8 +2870,8 @@ 0x80153E7C:("func_80153E7C",), 0x80153EF0:("func_80153EF0",), 0x801541D4:("func_801541D4",), - 0x80156758:("func_80156758",), - 0x8015680C:("func_8015680C",), + 0x80156758:("Message_Draw",), + 0x8015680C:("Message_Update",), 0x801586A4:("func_801586A4",), 0x801586D4:("Message_Init",), 0x801588D0:("Message_FindMessageNES",), @@ -2905,13 +2905,13 @@ 0x80160CE4:("ShrinkWindow_Update",), 0x80160D98:("ShrinkWindow_Draw",), 0x80161180:("func_80161180",), - 0x8016119C:("func_8016119C",), - 0x8016122C:("func_8016122C",), - 0x801612B8:("func_801612B8",), - 0x80161998:("func_80161998",), + 0x8016119C:("CutsceneCamera_Init",), + 0x8016122C:("CutsceneCamera_Interpolate",), + 0x801612B8:("CutsceneCamera_ProcessSpline",), + 0x80161998:("CutsceneCamera_UpdateSplines",), 0x80161BAC:("func_80161BAC",), - 0x80161BE0:("func_80161BE0",), - 0x80161C0C:("func_80161C0C",), + 0x80161BE0:("CutsceneCamera_SetState",), + 0x80161C0C:("CutsceneCamera_Reset",), 0x80161C20:("func_80161C20",), 0x80161E4C:("func_80161E4C",), 0x801620CC:("func_801620CC",), @@ -2925,7 +2925,7 @@ 0x801631DC:("func_801631DC",), 0x80163334:("func_80163334",), 0x80163660:("func_80163660",), - 0x80163700:("KaleidoManager_FaultAddrConvFunc",), + 0x80163700:("KaleidoManager_FaultAddrConv",), 0x80163758:("KaleidoManager_LoadOvl",), 0x801637B4:("KaleidoManager_ClearOvl",), 0x80163804:("KaleidoManager_Init",), @@ -2938,14 +2938,14 @@ 0x80163C0C:("KaleidoScopeCall_Draw",), 0x80163C90:("Transition_Init",), 0x80163D80:("Transition_Destroy",), - 0x80163DC0:("func_80163DC0",), - 0x8016418C:("func_8016418C",), - 0x8016424C:("func_8016424C",), - 0x801642D8:("func_801642D8",), - 0x80164438:("func_80164438",), - 0x8016454C:("func_8016454C",), - 0x80164678:("func_80164678",), - 0x801647AC:("func_801647AC",), + 0x80163DC0:("TransitionTile_InitGraphics",), + 0x8016418C:("TransitionTile_InitVtxData",), + 0x8016424C:("TransitionTile_Destroy",), + 0x801642D8:("TransitionTile_Init",), + 0x80164438:("TransitionTile_SetVtx",), + 0x8016454C:("TransitionTile_Draw",), + 0x80164678:("TransitionTile_Suck",), + 0x801647AC:("TransitionTile_Update",), 0x801647B8:("func_801647B8",), 0x801647D0:("TransitionFade_Start",), 0x8016482C:("TransitionFade_Init",), @@ -2970,41 +2970,41 @@ 0x8016537C:("TransitionOverlay_Free",), 0x80165438:("TransitionOverlay_ClearLoadInfo",), 0x80165444:("TransitionOverlay_SetSegment",), - 0x80165460:("func_80165460",), - 0x80165608:("func_80165608",), - 0x80165630:("func_80165630",), - 0x80165658:("func_80165658",), - 0x8016566C:("func_8016566C",), - 0x80165690:("func_80165690",), - 0x801656A4:("func_801656A4",), - 0x80165DB8:("func_80165DB8",), - 0x80165DCC:("func_80165DCC",), - 0x80165DF0:("func_80165DF0",), - 0x80165E04:("func_80165E04",), - 0x80165E1C:("func_80165E1C",), - 0x80165E7C:("func_80165E7C",), - 0x80165EC0:("func_80165EC0",), - 0x80166060:("func_80166060",), - 0x801660B8:("func_801660B8",), + 0x80165460:("Play_DrawMotionBlur",), + 0x80165608:("Play_InitMotionBlur",), + 0x80165630:("Play_DestroyMotionBlur",), + 0x80165658:("Play_SetMotionBlurAlpha",), + 0x8016566C:("Play_EnableMotionBlur",), + 0x80165690:("Play_DisableMotionBlur",), + 0x801656A4:("Play_ConvertRgba16ToIntensityImage",), + 0x80165DB8:("Play_SetMotionBlurPriorityAlpha",), + 0x80165DCC:("Play_EnableMotionBlurPriority",), + 0x80165DF0:("Play_DisableMotionBlurPriority",), + 0x80165E04:("Play_StartPictographPhoto",), + 0x80165E1C:("Play_TakePictoPhoto",), + 0x80165E7C:("Play_ChooseDynamicTransition",), + 0x80165EC0:("Play_SetupTransition",), + 0x80166060:("Play_ClearTransition",), + 0x801660B8:("Play_SetFog",), 0x8016613C:("Play_Destroy",), 0x801663C4:("Play_CompressI8ToI5",), 0x80166644:("Play_DecompressI5ToI8",), - 0x801668B4:("func_801668B4",), - 0x80166968:("func_80166968",), - 0x80166B30:("func_80166B30",), - 0x80167814:("Play_Update",), - 0x80167DE4:("func_80167DE4",), - 0x80167F0C:("func_80167F0C",), - 0x80168090:("Play_Draw",), - 0x80168DAC:("func_80168DAC",), + 0x801668B4:("Play_GetWaterSurface",), + 0x80166968:("Play_UpdateWaterCamera",), + 0x80166B30:("Play_UpdateTransition",), + 0x80167814:("Play_UpdateMain",), + 0x80167DE4:("Play_Update",), + 0x80167F0C:("Play_PostWorldDraw",), + 0x80168090:("Play_DrawMain",), + 0x80168DAC:("Play_Draw",), 0x80168F64:("Play_Main",), 0x801690CC:("Play_InCsMode",), - 0x80169100:("func_80169100",), - 0x801691F0:("func_801691F0",), - 0x80169220:("Play_LoadScene",), - 0x8016927C:("func_8016927C",), - 0x801692C4:("func_801692C4",), - 0x801693D4:("Play_SceneInit",), + 0x80169100:("Play_GetFloorSurfaceImpl",), + 0x801691F0:("Play_GetFloorSurface",), + 0x80169220:("Play_LoadFile",), + 0x8016927C:("Play_InitEnvironment",), + 0x801692C4:("Play_InitScene",), + 0x801693D4:("Play_SpawnScene",), 0x80169474:("Play_GetScreenPos",), 0x801694DC:("Play_CreateSubCamera",), 0x80169584:("Play_GetActiveCamId",), @@ -3032,12 +3032,12 @@ 0x80169EFC:("func_80169EFC",), 0x80169F78:("func_80169F78",), 0x80169FDC:("func_80169FDC",), - 0x80169FFC:("func_80169FFC",), + 0x80169FFC:("Play_CamIsNotFixed",), 0x8016A01C:("FrameAdvance_IsEnabled",), 0x8016A02C:("func_8016A02C",), 0x8016A0AC:("Play_IsUnderwater",), 0x8016A168:("Play_IsDebugCamEnabled",), - 0x8016A178:("Play_AssignPlayerActorCsIdsFromScene",), + 0x8016A178:("Play_AssignPlayerCsIdsFromScene",), 0x8016A268:("Play_FillScreen",), 0x8016A2C8:("Play_Init",), 0x8016AC10:("func_8016AC10",), @@ -3048,11 +3048,11 @@ 0x8016CD4C:("func_8016CD4C",), 0x8016E40C:("func_8016E40C",), 0x8016EA90:("func_8016EA90",), - 0x8016F1A8:("func_8016F1A8",), + 0x8016F1A8:("BombersNotebook_Draw",), 0x8016F4EC:("func_8016F4EC",), - 0x8016F5A8:("func_8016F5A8",), - 0x8016FC78:("func_8016FC78",), - 0x8016FC98:("func_8016FC98",), + 0x8016F5A8:("BombersNotebook_Update",), + 0x8016FC78:("BombersNotebook_Init",), + 0x8016FC98:("BombersNotebook_Destroy",), 0x8016FCF0:("PreRender_SetValuesSave",), 0x8016FD2C:("PreRender_Init",), 0x8016FD60:("PreRender_SetValues",), @@ -3079,36 +3079,36 @@ 0x80172078:("PreRender_ApplyFiltersSlowlyDestroy",), 0x801720C4:("func_801720C4",), 0x801720FC:("func_801720FC",), - 0x80172758:("func_80172758",), - 0x801727F0:("THGA_Ct",), - 0x80172810:("THGA_Dt",), + 0x80172758:("Prerender_DrawBackground2D",), + 0x801727F0:("THGA_Init",), + 0x80172810:("THGA_Destroy",), 0x80172830:("THGA_IsCrash",), 0x80172850:("THGA_Init",), - 0x80172870:("THGA_GetSize",), + 0x80172870:("THGA_GetRemaining",), 0x80172890:("THGA_GetHead",), 0x801728B0:("THGA_SetHead",), 0x801728D0:("THGA_GetTail",), - 0x801728F0:("THGA_AllocStartArray8",), - 0x80172914:("THGA_AllocStart8",), - 0x80172934:("THGA_AllocStart8Wrapper",), - 0x80172954:("THGA_AllocEnd",), - 0x80172974:("THGA_AllocEndArray64",), - 0x80172998:("THGA_AllocEnd64",), - 0x801729B8:("THGA_AllocEndArray16",), - 0x801729DC:("THGA_AllocEnd16",), + 0x801728F0:("THGA_AllocDisplayList",), + 0x80172914:("THGA_AllocGfx",), + 0x80172934:("THGA_AllocGfx2",), + 0x80172954:("THGA_AllocTail",), + 0x80172974:("THGA_AllocMtxArray",), + 0x80172998:("THGA_AllocMtx",), + 0x801729B8:("THGA_AllocVtxArray",), + 0x801729DC:("THGA_AllocVtx",), 0x80172A00:("THA_GetHead",), 0x80172A0C:("THA_SetHead",), 0x80172A18:("THA_GetTail",), - 0x80172A24:("THA_AllocStart",), - 0x80172A38:("THA_AllocStart1",), - 0x80172A58:("THA_AllocEnd",), - 0x80172AC8:("THA_AllocEndAlign16",), - 0x80172AE8:("THA_AllocEndAlign",), - 0x80172B04:("THA_GetSize",), + 0x80172A24:("THA_AllocHead",), + 0x80172A38:("THA_AllocHeadByte",), + 0x80172A58:("THA_AllocTail",), + 0x80172AC8:("THA_AllocTailAlign16",), + 0x80172AE8:("THA_AllocTailAlign",), + 0x80172B04:("THA_GetRemaining",), 0x80172B18:("THA_IsCrash",), - 0x80172B3C:("THA_Init",), - 0x80172B58:("THA_Ct",), - 0x80172B9C:("THA_Dt",), + 0x80172B3C:("THA_Reset",), + 0x80172B58:("THA_Init",), + 0x80172B9C:("THA_Destroy",), 0x80172BC0:("AudioMgr_StopAllSfxExceptSystem",), 0x80172C30:("func_80172C30",), 0x80172C68:("AudioMgr_HandleRetrace",), @@ -3148,7 +3148,7 @@ 0x80173DAC:("Graph_InitTHGA",), 0x80173DCC:("Graph_SetNextGfxPool",), 0x80173F98:("Graph_GetNextGameState",), - 0x80174060:("Graph_FaultAddrConvFunc",), + 0x80174060:("Graph_FaultAddrConv",), 0x801740D0:("Graph_Init",), 0x80174174:("Graph_Destroy",), 0x801741A8:("Graph_TaskSet00",), @@ -3164,33 +3164,33 @@ 0x80174B20:("ListAlloc_Free",), 0x80174BA0:("ListAlloc_FreeAll",), 0x80174BF0:("Main",), - 0x80174F10:("Padmgr_GetControllerBitmask",), - 0x80174F24:("func_80174F24",), - 0x80174F44:("func_80174F44",), - 0x80174F7C:("func_80174F7C",), - 0x80174F9C:("func_80174F9C",), - 0x80174FD4:("Padmgr_GetEventCallback",), - 0x80175008:("func_80175008",), - 0x8017503C:("Padmgr_SetEventCallback",), - 0x8017506C:("func_8017506C",), - 0x8017509C:("Padmgr_Lock",), - 0x801750CC:("Padmgr_Unlock",), - 0x801750FC:("func_801750FC",), - 0x80175364:("func_80175364",), - 0x80175434:("func_80175434",), - 0x8017544C:("func_8017544C",), + 0x80174F10:("PadMgr_GetValidControllersMask",), + 0x80174F24:("PadMgr_SetRumbleRetraceCallback",), + 0x80174F44:("PadMgr_UnsetRumbleRetraceCallback",), + 0x80174F7C:("PadMgr_SetInputRetraceCallback",), + 0x80174F9C:("PadMgr_UnsetInputRetraceCallback",), + 0x80174FD4:("PadMgr_AcquireSerialEventQueue",), + 0x80175008:("PadMgr_VoiceAcquireSerialEventQueue",), + 0x8017503C:("PadMgr_ReleaseSerialEventQueue",), + 0x8017506C:("PadMgr_VoiceReleaseSerialEventQueue",), + 0x8017509C:("PadMgr_LockPadData",), + 0x801750CC:("PadMgr_UnlockPadData",), + 0x801750FC:("PadMgr_UpdateRumble",), + 0x80175364:("PadMgr_RumbleStop",), + 0x80175434:("PadMgr_RumblePause",), + 0x8017544C:("PadMgr_RumbleSetSingle",), 0x80175474:("PadMgr_RumbleSet",), 0x801754C0:("PadMgr_ControllerHasRumblePak",), - 0x801754E0:("Padmgr_CalcStickEdges",), - 0x801757A4:("Padmgr_ParseState",), - 0x801759BC:("func_801759BC",), - 0x80175AE0:("func_80175AE0",), - 0x80175C80:("Padmgr_Update",), - 0x80175E3C:("Padmgr_Stop",), - 0x80175E68:("func_80175E68",), - 0x80175F98:("Padmgr_GetInput",), - 0x80175FD4:("Padmgr_GetInput2",), - 0x80176010:("Padmgr_ThreadEntry",), + 0x801754E0:("PadMgr_AdjustInput",), + 0x801757A4:("PadMgr_UpdateInputs",), + 0x801759BC:("PadMgr_InitVoice",), + 0x80175AE0:("PadMgr_UpdateConnections",), + 0x80175C80:("PadMgr_HandleRetrace",), + 0x80175E3C:("PadMgr_HandlePreNMI",), + 0x80175E68:("PadMgr_GetInputNoLock",), + 0x80175F98:("PadMgr_GetInput",), + 0x80175FD4:("PadMgr_GetInput2",), + 0x80176010:("PadMgr_ThreadEntry",), 0x80176194:("PadMgr_Init",), 0x80176280:("Sched_SwapFramebuffer",), 0x80176314:("Sched_RetraceUpdateFramebuffer",), @@ -3235,11 +3235,11 @@ 0x80178A34:("func_80178A34",), 0x80178A94:("func_80178A94",), 0x80178AC0:("func_80178AC0",), - 0x80178C80:("func_80178C80",), - 0x80178D7C:("func_80178D7C",), - 0x80178DAC:("func_80178DAC",), - 0x80178E3C:("func_80178E3C",), - 0x80178E7C:("func_80178E7C",), + 0x80178C80:("CmpDma_GetFileInfo",), + 0x80178D7C:("CmpDma_Decompress",), + 0x80178DAC:("CmpDma_LoadFileImpl",), + 0x80178E3C:("CmpDma_LoadFile",), + 0x80178E7C:("CmpDma_LoadAllFiles",), 0x80178F30:("Check_WriteRGBA16Pixel",), 0x80178F60:("Check_WriteI4Pixel",), 0x80178FA0:("Check_DrawI4Texture",), @@ -3445,8 +3445,8 @@ 0x80185460:("func_80185460",), 0x80185660:("Slowly_Main",), 0x801856FC:("Slowly_ThreadEntry",), - 0x8018571C:("Slowly_Start",), - 0x801857A0:("Slowly_Stop",), + 0x8018571C:("Slowly_Init",), + 0x801857A0:("Slowly_Destroy",), 0x801857C0:("func_801857C0",), 0x801857D0:("func_801857D0",), 0x80185864:("func_80185864",), @@ -3767,42 +3767,42 @@ 0x80197138:("AudioEffects_NotePortamentoInit",), 0x80197164:("AudioEffects_AdsrInit",), 0x80197188:("AudioEffects_AdsrUpdate",), - 0x801974D0:("AudioSeq_GetScriptControlFlowArgument",), - 0x80197538:("AudioSeq_HandleScriptFlowControl",), - 0x80197714:("AudioSeq_InitSequenceChannel",), - 0x80197880:("AudioSeq_SeqChannelSetLayer",), - 0x801979D8:("AudioSeq_SeqLayerDisable",), - 0x80197A54:("AudioSeq_SeqLayerFree",), - 0x80197AA4:("AudioSeq_SequenceChannelDisable",), - 0x80197B14:("AudioSeq_SequencePlayerSetupChannels",), - 0x80197C0C:("AudioSeq_SequencePlayerDisableChannels",), - 0x80197C8C:("AudioSeq_SequenceChannelEnable",), - 0x80197D24:("AudioSeq_SequencePlayerDisableAsFinished",), - 0x80197D4C:("AudioSeq_SequencePlayerDisable",), - 0x80197E08:("AudioSeq_AudioListPushBack",), - 0x80197E48:("AudioSeq_AudioListPopBack",), - 0x80197E88:("AudioSeq_InitLayerFreelist",), - 0x80197F28:("AudioSeq_ScriptReadU8",), - 0x80197F3C:("AudioSeq_ScriptReadS16",), - 0x80197F74:("AudioSeq_ScriptReadCompressedU16",), - 0x80197FB4:("AudioSeq_SeqLayerProcessScript",), - 0x801980D0:("AudioSeq_SeqLayerProcessScriptStep1",), - 0x8019815C:("AudioSeq_SeqLayerProcessScriptStep5",), - 0x8019825C:("AudioSeq_SeqLayerProcessScriptStep2",), - 0x80198640:("AudioSeq_SeqLayerProcessScriptStep4",), - 0x80198CE0:("AudioSeq_SeqLayerProcessScriptStep3",), - 0x801990F4:("AudioSeq_SetChannelPriorities",), - 0x80199124:("AudioSeq_GetInstrument",), - 0x80199198:("AudioSeq_SetInstrument",), - 0x80199244:("AudioSeq_SequenceChannelSetVolume",), - 0x80199268:("AudioSeq_SequenceChannelProcessScript",), - 0x8019A0BC:("AudioSeq_SequencePlayerProcessSequence",), - 0x8019AA3C:("AudioSeq_ProcessSequences",), - 0x8019AAF0:("AudioSeq_SkipForwardSequence",), - 0x8019AB40:("AudioSeq_ResetSequencePlayer",), - 0x8019AC10:("AudioSeq_InitSequencePlayerChannels",), - 0x8019ACEC:("AudioSeq_InitSequencePlayer",), - 0x8019ADBC:("AudioSeq_InitSequencePlayers",), + 0x801974D0:("AudioScript_GetScriptControlFlowArgument",), + 0x80197538:("AudioScript_HandleScriptFlowControl",), + 0x80197714:("AudioScript_InitSequenceChannel",), + 0x80197880:("AudioScript_SeqChannelSetLayer",), + 0x801979D8:("AudioScript_SeqLayerDisable",), + 0x80197A54:("AudioScript_SeqLayerFree",), + 0x80197AA4:("AudioScript_SequenceChannelDisable",), + 0x80197B14:("AudioScript_SequencePlayerSetupChannels",), + 0x80197C0C:("AudioScript_SequencePlayerDisableChannels",), + 0x80197C8C:("AudioScript_SequenceChannelEnable",), + 0x80197D24:("AudioScript_SequencePlayerDisableAsFinished",), + 0x80197D4C:("AudioScript_SequencePlayerDisable",), + 0x80197E08:("AudioScript_AudioListPushBack",), + 0x80197E48:("AudioScript_AudioListPopBack",), + 0x80197E88:("AudioScript_InitLayerFreelist",), + 0x80197F28:("AudioScript_ScriptReadU8",), + 0x80197F3C:("AudioScript_ScriptReadS16",), + 0x80197F74:("AudioScript_ScriptReadCompressedU16",), + 0x80197FB4:("AudioScript_SeqLayerProcessScript",), + 0x801980D0:("AudioScript_SeqLayerProcessScriptStep1",), + 0x8019815C:("AudioScript_SeqLayerProcessScriptStep5",), + 0x8019825C:("AudioScript_SeqLayerProcessScriptStep2",), + 0x80198640:("AudioScript_SeqLayerProcessScriptStep4",), + 0x80198CE0:("AudioScript_SeqLayerProcessScriptStep3",), + 0x801990F4:("AudioScript_SetChannelPriorities",), + 0x80199124:("AudioScript_GetInstrument",), + 0x80199198:("AudioScript_SetInstrument",), + 0x80199244:("AudioScript_SequenceChannelSetVolume",), + 0x80199268:("AudioScript_SequenceChannelProcessScript",), + 0x8019A0BC:("AudioScript_SequencePlayerProcessSequence",), + 0x8019AA3C:("AudioScript_ProcessSequences",), + 0x8019AAF0:("AudioScript_SkipForwardSequence",), + 0x8019AB40:("AudioScript_ResetSequencePlayer",), + 0x8019AC10:("AudioScript_InitSequencePlayerChannels",), + 0x8019ACEC:("AudioScript_InitSequencePlayer",), + 0x8019ADBC:("AudioScript_InitSequencePlayers",), 0x8019AE40:("func_8019AE40",), 0x8019AEC0:("func_8019AEC0",), 0x8019AF00:("AudioOcarina_ReadControllerInput",), @@ -3845,7 +3845,7 @@ 0x8019D488:("AudioOcarina_MemoryGameInit",), 0x8019D4F8:("AudioOcarina_MemoryGameNextNote",), 0x8019D600:("AudioOcarina_Update",), - 0x8019D758:("AudioOcarina_PlayLongScarecrowAfterCredits",), + 0x8019D758:("AudioOcarina_PlayLongScarecrowSong",), 0x8019D864:("AudioOcarina_SetCustomSequence",), 0x8019D8B4:("AudioOcarina_PlayCustomSequence",), 0x8019D8E4:("AudioOcarina_CreateCustomSequence",), @@ -3857,7 +3857,7 @@ 0x8019E014:("Audio_Update",), 0x8019E0FC:("Audio_Noop4",), 0x8019E104:("Audio_Noop5",), - 0x8019E110:("func_8019E110",), + 0x8019E110:("Audio_PlayMainBgm",), 0x8019E14C:("AudioSfx_ComputeVolume",), 0x8019E324:("AudioSfx_ComputeReverb",), 0x8019E4B0:("AudioSfx_ComputePanSigned",), @@ -3901,10 +3901,10 @@ 0x801A0048:("Audio_PlaySfxForWaterfall",), 0x801A00EC:("Audio_StepFreqLerp",), 0x801A0124:("func_801A0124",), - 0x801A0184:("func_801A0184",), - 0x801A01C4:("func_801A01C4",), + 0x801A0184:("Audio_SetBgmVolumeOff",), + 0x801A01C4:("Audio_SetBgmVolumeOn",), 0x801A0204:("func_801A0204",), - 0x801A0238:("func_801A0238",), + 0x801A0238:("Audio_SetMainBgmVolume",), 0x801A026C:("Audio_SetGanonsTowerBgmVolumeLevel",), 0x801A0318:("Audio_SetGanonsTowerBgmVolume",), 0x801A0450:("Audio_LowerMainBgmVolume",), @@ -3943,12 +3943,12 @@ 0x801A25E4:("Audio_PlaySceneSequence",), 0x801A2670:("Audio_StartSceneSequence",), 0x801A2778:("Audio_UpdateSceneSequenceResumePoint",), - 0x801A27E8:("func_801A27E8",), - 0x801A281C:("func_801A281C",), - 0x801A29D4:("func_801A29D4",), - 0x801A2BB8:("func_801A2BB8",), - 0x801A2C20:("func_801A2C20",), - 0x801A2C44:("func_801A2C44",), + 0x801A27E8:("Audio_PlayBgmForSongOfStorms",), + 0x801A281C:("Audio_ScaleTempoAndFreqForMainBgm",), + 0x801A29D4:("Audio_SetSeqTempoAndFreq",), + 0x801A2BB8:("Audio_PlaySubBgm",), + 0x801A2C20:("Audio_StopSubBgm",), + 0x801A2C44:("Audio_IncreaseTempoForTimedMinigame",), 0x801A2C88:("Audio_PlaySequenceInCutscene",), 0x801A2D54:("Audio_StopSequenceInCutscene",), 0x801A2DE0:("Audio_IsSequencePlaying",), @@ -3994,7 +3994,7 @@ 0x801A4428:("func_801A4428",), 0x801A44A4:("Audio_PreNMI",), 0x801A44C4:("Audio_ResetRequestedSceneSeqId",), - 0x801A44D4:("func_801A44D4",), + 0x801A44D4:("Audio_ResetData",), 0x801A46F8:("func_801A46F8",), 0x801A4748:("func_801A4748",), 0x801A479C:("func_801A479C",), @@ -4004,11 +4004,11 @@ 0x801A4B80:("Audio_SetAmbienceRandomBend",), 0x801A4C30:("Audio_Init",), 0x801A4C54:("AudioSfx_Init",), - 0x801A4D00:("func_801A4D00",), - 0x801A4D50:("func_801A4D50",), - 0x801A4DA4:("func_801A4DA4",), - 0x801A4DF4:("func_801A4DF4",), - 0x801A4E64:("func_801A4E64",), + 0x801A4D00:("Audio_InitSound",), + 0x801A4D50:("Audio_ResetForAudioHeapStep3",), + 0x801A4DA4:("Audio_ResetForAudioHeapStep2",), + 0x801A4DF4:("Audio_ResetForAudioHeapStep1",), + 0x801A4E64:("Audio_UnusedReset",), 0x801A4EB0:("func_801A4EB0",), 0x801A4EB8:("func_801A4EB8",), 0x801A4FD8:("func_801A4FD8",), @@ -4028,7 +4028,7 @@ 0x801A54D0:("func_801A54D0",), 0x801A5680:("func_801A5680",), 0x801A5808:("func_801A5808",), - 0x801A5A10:("func_801A5A10",), + 0x801A5A10:("AudioVoice_ResetData",), 0x801A5A1C:("func_801A5A1C",), 0x801A5BD0:("AudioSfx_MuteBanks",), 0x801A5C28:("AudioSfx_LowerBgmVolume",), @@ -4052,21 +4052,21 @@ 0x801A787C:("AudioSfx_ProcessActiveSfx",), 0x801A78E4:("AudioSfx_IsPlaying",), 0x801A794C:("AudioSfx_Reset",), - 0x801A7B10:("Audio_StartSequence",), - 0x801A7D04:("Audio_StopSequence",), - 0x801A7D84:("func_801A7D84",), - 0x801A89A8:("Audio_QueueSeqCmd",), - 0x801A89D0:("func_801A89D0",), - 0x801A8A50:("Audio_GetActiveSequence",), - 0x801A8ABC:("func_801A8ABC",), - 0x801A8B14:("func_801A8B14",), - 0x801A8B2C:("func_801A8B2C",), - 0x801A8BD0:("Audio_SetVolumeScale",), - 0x801A8D5C:("func_801A8D5C",), - 0x801A9768:("func_801A9768",), - 0x801A982C:("func_801A982C",), - 0x801A99B8:("func_801A99B8",), - 0x801A9A74:("func_801A9A74",), + 0x801A7B10:("AudioSeq_StartSequence",), + 0x801A7D04:("AudioSeq_StopSequence",), + 0x801A7D84:("AudioSeq_ProcessSeqCmd",), + 0x801A89A8:("AudioSeq_QueueSeqCmd",), + 0x801A89D0:("AudioSeq_ProcessSeqCmds",), + 0x801A8A50:("AudioSeq_GetActiveSeqId",), + 0x801A8ABC:("AudioSeq_IsSeqCmdNotQueued",), + 0x801A8B14:("AudioSeq_ResetSequenceRequests",), + 0x801A8B2C:("AudioSeq_ReplaceSeqCmdSetupOpVolRestore",), + 0x801A8BD0:("AudioSeq_SetVolumeScale",), + 0x801A8D5C:("AudioSeq_UpdateActiveSequences",), + 0x801A9768:("AudioSeq_UpdateAudioHeapReset",), + 0x801A982C:("AudioSeq_ResetReverb",), + 0x801A99B8:("AudioSeq_ResetActiveSequences",), + 0x801A9A74:("AudioSeq_ResetActiveSequencesAndVolume",), 0x801A9B10:("JpegUtils_ProcessQuantizationTable",), 0x801A9B78:("JpegUtils_ParseHuffmanCodesLengths",), 0x801A9BFC:("JpegUtils_GetHuffmanCodes",), @@ -4082,7 +4082,7 @@ 0x801AA610:("GameOver_Init",), 0x801AA624:("GameOver_FadeLights",), 0x801AA68C:("GameOver_Update",), - 0x801AAAA0:("func_801AAAA0",), + 0x801AAAA0:("Regs_InitData",), 0x80800000:("ConsoleLogo_UpdateCounters",), 0x8080009C:("ConsoleLogo_RenderView",), 0x80800134:("ConsoleLogo_Draw",), @@ -4205,7 +4205,7 @@ 0x80819238:("KaleidoScope_DrawInventoryEditor",), 0x80819F04:("KaleidoScope_UpdateInventoryEditor",), 0x8081B240:("KaleidoScope_DrawAmmoCount",), - 0x8081B6BC:("KaleidoScope_SetCursorVtx",), + 0x8081B6BC:("KaleidoScope_SetCursorVtxPos",), 0x8081B6EC:("KaleidoScope_DrawItemSelect",), 0x8081BCA8:("KaleidoScope_UpdateItemCursor",), 0x8081C684:("KaleidoScope_UpdateItemEquip",), @@ -4226,17 +4226,17 @@ 0x80821AD4:("KaleidoScope_DrawTexQuadRGBA32",), 0x80821CC4:("func_80821CC4",), 0x80821D84:("KaleidoScope_HandlePageToggles",), - 0x80821F30:("func_80821F30",), - 0x808221DC:("func_808221DC",), + 0x80821F30:("KaleidoScope_DrawPageSections",), + 0x808221DC:("KaleidoScope_DrawPages",), 0x80823350:("func_80823350",), 0x80824738:("KaleidoScope_UpdateNamePanel",), - 0x808248D0:("func_808248D0",), + 0x808248D0:("KaleidoScope_DrawOwlWarpMapPage",), 0x80824B90:("func_80824B90",), 0x808256E4:("KaleidoScope_UpdateOwlWarpNamePanel",), 0x8082585C:("KaleidoScope_UpdateSwitchPage",), 0x808259D4:("KaleidoScope_SetView",), - 0x80825A50:("func_80825A50",), - 0x80825E28:("func_80825E28",), + 0x80825A50:("KaleidoScope_SetPageVertices",), + 0x80825E28:("KaleidoScope_SetVertices",), 0x808274DC:("func_808274DC",), 0x80827A8C:("func_80827A8C",), 0x80827E08:("func_80827E08",), @@ -5098,14 +5098,14 @@ 0x808706E0:("EnOkuta_Draw",), 0x80870DB0:("EnBom_Init",), 0x80870FF8:("EnBom_Destroy",), - 0x80871058:("func_80871058",), - 0x808714D4:("func_808714D4",), - 0x808715B8:("func_808715B8",), + 0x80871058:("EnBom_Move",), + 0x808714D4:("EnBom_WaitForRelease",), + 0x808715B8:("EnBom_Explode",), 0x808719A8:("EnBom_Update",), 0x808722F4:("EnBom_Draw",), 0x80872648:("func_80872648",), 0x808726DC:("func_808726DC",), - 0x80872BC0:("func_80872BC0",), + 0x80872BC0:("EnBom_DrawKeg",), 0x80874810:("EnWallmas_Init",), 0x80874A28:("EnWallmas_Destroy",), 0x80874A88:("EnWallmas_Freeze",), @@ -5901,48 +5901,48 @@ 0x808B0F98:("EnAm_Draw",), 0x808B1330:("EnDekubaba_Init",), 0x808B1504:("EnDekubaba_Destroy",), - 0x808B1530:("func_808B1530",), - 0x808B15B8:("func_808B15B8",), - 0x808B16BC:("func_808B16BC",), - 0x808B1798:("func_808B1798",), - 0x808B1814:("func_808B1814",), - 0x808B18A8:("func_808B18A8",), - 0x808B1B14:("func_808B1B14",), - 0x808B1BC0:("func_808B1BC0",), - 0x808B1CF0:("func_808B1CF0",), - 0x808B2158:("func_808B2158",), - 0x808B2240:("func_808B2240",), - 0x808B2608:("func_808B2608",), - 0x808B2660:("func_808B2660",), - 0x808B2890:("func_808B2890",), - 0x808B28B4:("func_808B28B4",), - 0x808B2980:("func_808B2980",), - 0x808B29C4:("func_808B29C4",), - 0x808B2C40:("func_808B2C40",), - 0x808B2CB8:("func_808B2CB8",), - 0x808B3044:("func_808B3044",), - 0x808B3078:("func_808B3078",), - 0x808B3170:("func_808B3170",), - 0x808B3280:("func_808B3280",), - 0x808B3390:("func_808B3390",), - 0x808B3404:("func_808B3404",), - 0x808B3768:("func_808B3768",), - 0x808B37E8:("func_808B37E8",), - 0x808B39AC:("func_808B39AC",), - 0x808B3B48:("func_808B3B48",), - 0x808B3BE4:("func_808B3BE4",), - 0x808B3C50:("func_808B3C50",), - 0x808B3D74:("func_808B3D74",), - 0x808B3DA8:("func_808B3DA8",), - 0x808B3E40:("func_808B3E40",), - 0x808B3EE8:("func_808B3EE8",), - 0x808B3F50:("func_808B3F50",), + 0x808B1530:("EnDekubaba_DisableHitboxes",), + 0x808B15B8:("EnDekubaba_UpdateHeadPosition",), + 0x808B16BC:("EnDekubaba_SetFireLightEffects",), + 0x808B1798:("EnDekubaba_SetFrozenEffects",), + 0x808B1814:("EnDekubaba_SpawnIceEffects",), + 0x808B18A8:("EnDekubaba_SetupWait",), + 0x808B1B14:("EnDekubaba_Wait",), + 0x808B1BC0:("EnDekubaba_SetupGrow",), + 0x808B1CF0:("EnDekubaba_Grow",), + 0x808B2158:("EnDekubaba_SetupRetract",), + 0x808B2240:("EnDekubaba_Retract",), + 0x808B2608:("EnDekubaba_SetupDecideLunge",), + 0x808B2660:("EnDekubaba_DecideLunge",), + 0x808B2890:("EnDekubaba_SetupPrepareLunge",), + 0x808B28B4:("EnDekubaba_PrepareLunge",), + 0x808B2980:("EnDekubaba_SetupLunge",), + 0x808B29C4:("EnDekubaba_Lunge",), + 0x808B2C40:("EnDekubaba_SetupPullBack",), + 0x808B2CB8:("EnDekubaba_PullBack",), + 0x808B3044:("EnDekubaba_SetupRecover",), + 0x808B3078:("EnDekubaba_Recover",), + 0x808B3170:("EnDekubaba_SetupHit",), + 0x808B3280:("EnDekubaba_Hit",), + 0x808B3390:("EnDekubaba_SetupPrunedSomersaultDie",), + 0x808B3404:("EnDekubaba_PrunedSomersaultDie",), + 0x808B3768:("EnDekubaba_SetupShrinkDie",), + 0x808B37E8:("EnDekubaba_ShrinkDie",), + 0x808B39AC:("EnDekubaba_SetupStunnedVertical",), + 0x808B3B48:("EnDekubaba_StunnedVertical",), + 0x808B3BE4:("EnDekubaba_SetupSway",), + 0x808B3C50:("EnDekubaba_Sway",), + 0x808B3D74:("EnDekubaba_SetupFrozen",), + 0x808B3DA8:("EnDekubaba_Frozen",), + 0x808B3E40:("EnDekubaba_SetupDeadStickDrop",), + 0x808B3EE8:("EnDekubaba_DeadStickDrop",), + 0x808B3F50:("EnDekubaba_UpdateDamage",), 0x808B42FC:("EnDekubaba_Update",), - 0x808B4548:("func_808B4548",), - 0x808B465C:("func_808B465C",), - 0x808B48FC:("func_808B48FC",), - 0x808B49C8:("func_808B49C8",), - 0x808B4ABC:("func_808B4ABC",), + 0x808B4548:("EnDekubaba_DrawStemRetracted",), + 0x808B465C:("EnDekubaba_DrawStemExtended",), + 0x808B48FC:("EnDekubaba_DrawStemBasePruned",), + 0x808B49C8:("EnDekubaba_DrawShadow",), + 0x808B4ABC:("EnDekubaba_PostLimbDraw",), 0x808B4AF8:("EnDekubaba_Draw",), 0x808B5230:("EnMFire1_Init",), 0x808B5294:("EnMFire1_Destroy",), @@ -6504,7 +6504,7 @@ 0x808E06B0:("DoorAna_Update",), 0x808E0704:("DoorAna_Draw",), 0x808E0830:("EnEncount1_Init",), - 0x808E0954:("func_808E0954",), + 0x808E0954:("EnEncount1_SpawnActor",), 0x808E0DA8:("EnEncount1_Update",), 0x808E0E40:("DemoTreLgt_Init",), 0x808E0EBC:("DemoTreLgt_Destroy",), @@ -6675,33 +6675,33 @@ 0x808ED3F4:("func_808ED3F4",), 0x808F1200:("EnKarebaba_Init",), 0x808F1334:("EnKarebaba_Destroy",), - 0x808F1374:("func_808F1374",), - 0x808F13FC:("func_808F13FC",), - 0x808F152C:("func_808F152C",), - 0x808F155C:("func_808F155C",), - 0x808F15B0:("func_808F15B0",), - 0x808F1648:("func_808F1648",), - 0x808F169C:("func_808F169C",), - 0x808F16FC:("func_808F16FC",), - 0x808F1778:("func_808F1778",), - 0x808F1878:("func_808F1878",), - 0x808F190C:("func_808F190C",), - 0x808F1A3C:("func_808F1A3C",), - 0x808F1A58:("func_808F1A58",), - 0x808F1BF8:("func_808F1BF8",), - 0x808F1C84:("func_808F1C84",), - 0x808F1FAC:("func_808F1FAC",), - 0x808F200C:("func_808F200C",), - 0x808F20FC:("func_808F20FC",), - 0x808F21A4:("func_808F21A4",), - 0x808F220C:("func_808F220C",), - 0x808F228C:("func_808F228C",), - 0x808F238C:("func_808F238C",), - 0x808F241C:("func_808F241C",), - 0x808F24F8:("func_808F24F8",), - 0x808F254C:("func_808F254C",), + 0x808F1374:("EnKarebaba_SpawnIceEffects",), + 0x808F13FC:("EnKarebaba_SetDamageEffects",), + 0x808F152C:("EnKarebaba_ResetColliders",), + 0x808F155C:("EnKarebaba_SetupGrow",), + 0x808F15B0:("EnKarebaba_Grow",), + 0x808F1648:("EnKarebaba_SetupIdle",), + 0x808F169C:("EnKarebaba_Idle",), + 0x808F16FC:("EnKarebaba_SetupAwaken",), + 0x808F1778:("EnKarebaba_Awaken",), + 0x808F1878:("EnKarebaba_SetupUpright",), + 0x808F190C:("EnKarebaba_Upright",), + 0x808F1A3C:("EnKarebaba_SetupSpin",), + 0x808F1A58:("EnKarebaba_Spin",), + 0x808F1BF8:("EnKarebaba_SetupDying",), + 0x808F1C84:("EnKarebaba_Dying",), + 0x808F1FAC:("EnKarebaba_SetupShrinkDie",), + 0x808F200C:("EnKarebaba_ShrinkDie",), + 0x808F20FC:("EnKarebaba_SetupDeadItemDrop",), + 0x808F21A4:("EnKarebaba_DeadItemDrop",), + 0x808F220C:("EnKarebaba_SetupRetract",), + 0x808F228C:("EnKarebaba_Retract",), + 0x808F238C:("EnKarebaba_SetupDead",), + 0x808F241C:("EnKarebaba_Regrow",), + 0x808F24F8:("EnKarebaba_SetupRegrow",), + 0x808F254C:("EnKarebaba_Dead",), 0x808F25A4:("EnKarebaba_Update",), - 0x808F280C:("func_808F280C",), + 0x808F280C:("EnKarebaba_DrawShadow",), 0x808F28F8:("EnKarebaba_Draw",), 0x808F30B0:("EnIn_ChangeAnim",), 0x808F3178:("func_808F3178",), @@ -7124,7 +7124,7 @@ 0x8092C86C:("func_8092C86C",), 0x8092C934:("func_8092C934",), 0x8092C9BC:("func_8092C9BC",), - 0x8092CA74:("func_8092CA74",), + 0x8092CA74:("EnDns_GetCueType",), 0x8092CAD0:("func_8092CAD0",), 0x8092CB98:("func_8092CB98",), 0x8092CC68:("func_8092CC68",), @@ -8354,10 +8354,10 @@ 0x8098BFB8:("EnDg_OverrideLimbDraw",), 0x8098BFD4:("EnDg_PostLimbDraw",), 0x8098C06C:("EnDg_Draw",), - 0x8098CA20:("func_8098CA20",), - 0x8098CAD0:("func_8098CAD0",), - 0x8098CB70:("func_8098CB70",), - 0x8098CBDC:("func_8098CBDC",), + 0x8098CA20:("EnSi_UpdateCollision",), + 0x8098CAD0:("EnSi_GiveToken",), + 0x8098CB70:("EnSi_Wait",), + 0x8098CBDC:("EnSi_DraggedByHookshot",), 0x8098CC18:("EnSi_Init",), 0x8098CC98:("EnSi_Destroy",), 0x8098CCC4:("EnSi_Update",), @@ -8682,7 +8682,7 @@ 0x809A20FC:("EnMm2_WaitForRead",), 0x809A2194:("EnMm2_Update",), 0x809A21B8:("EnMm2_Draw",), - 0x809A2B60:("DoorSpiral_SetupAction",), + 0x809A2B60:("func_809A2B60",), 0x809A2B70:("func_809A2B70",), 0x809A2BF8:("func_809A2BF8",), 0x809A2C78:("DoorSpiral_Init",), @@ -8997,37 +8997,37 @@ 0x809C0E30:("EnWarpTag_GrottoReturn",), 0x809C0F18:("EnWarptag_Update",), 0x809C0F3C:("EnWarpTag_Draw",), - 0x809C10B0:("func_809C10B0",), - 0x809C1124:("func_809C1124",), - 0x809C1158:("func_809C1158",), - 0x809C11EC:("func_809C11EC",), - 0x809C1304:("func_809C1304",), - 0x809C1424:("func_809C1424",), - 0x809C14D0:("func_809C14D0",), - 0x809C15BC:("func_809C15BC",), - 0x809C165C:("func_809C165C",), - 0x809C16DC:("func_809C16DC",), - 0x809C1C9C:("func_809C1C9C",), - 0x809C1D64:("func_809C1D64",), - 0x809C1EC8:("func_809C1EC8",), - 0x809C2060:("func_809C2060",), - 0x809C21E0:("func_809C21E0",), - 0x809C2504:("func_809C2504",), - 0x809C2594:("func_809C2594",), - 0x809C25E4:("func_809C25E4",), - 0x809C2680:("func_809C2680",), - 0x809C26E4:("func_809C26E4",), - 0x809C2730:("func_809C2730",), - 0x809C2788:("func_809C2788",), - 0x809C2824:("func_809C2824",), - 0x809C28B8:("func_809C28B8",), - 0x809C2A64:("func_809C2A64",), - 0x809C2BE4:("func_809C2BE4",), - 0x809C2C9C:("func_809C2C9C",), - 0x809C2D0C:("func_809C2D0C",), - 0x809C2EC4:("func_809C2EC4",), - 0x809C2F34:("func_809C2F34",), - 0x809C2FA0:("func_809C2FA0",), + 0x809C10B0:("EnAob01_Blink",), + 0x809C1124:("EnAob01_AdvanceTime",), + 0x809C1158:("EnAob01_InitializeDogPaths",), + 0x809C11EC:("EnAob01_SpawnDogs",), + 0x809C1304:("EnAob01_SpawnRacedogs",), + 0x809C1424:("EnAob01_ProcessLaughAnim",), + 0x809C14D0:("EnAob01_ProcessSurpriseAnim",), + 0x809C15BC:("EnAob01_ProcessIdleAnim",), + 0x809C165C:("EnAob01_UpdateCollision",), + 0x809C16DC:("EnAob01_BeforeRace_HandleConversation",), + 0x809C1C9C:("EnAob01_BeforeRace_StartRace",), + 0x809C1D64:("EnAob01_BeforeRace_RespondToPlayAgainQuestion",), + 0x809C1EC8:("EnAob01_UpdateCommon",), + 0x809C2060:("EnAob01_BeforeRace_Idle",), + 0x809C21E0:("EnAob01_BeforeRace_Talk",), + 0x809C2504:("EnAob01_Race_DogHasReachedNextCutsceneTrigger",), + 0x809C2594:("EnAob01_Race_FollowSelectedDog",), + 0x809C25E4:("EnAob01_Race_IsRaceOver",), + 0x809C2680:("EnAob01_Race_CurrentCutsceneHasEnded",), + 0x809C26E4:("EnAob01_Race_SkipNonRaceCutscene",), + 0x809C2730:("EnAob01_Race_HandleRaceCutscene",), + 0x809C2788:("EnAob01_Race_HandleRaceEndCutscene",), + 0x809C2824:("EnAob01_Race_StartCutscene",), + 0x809C28B8:("EnAob01_AfterRace_GiveRaceResult",), + 0x809C2A64:("EnAob01_AfterRace_GiveReward",), + 0x809C2BE4:("EnAob01_AfterRace_AfterGivingReward",), + 0x809C2C9C:("EnAob01_AfterRace_AskToPlayAgain",), + 0x809C2D0C:("EnAob01_AfterRace_Talk",), + 0x809C2EC4:("EnAob01_PlayerIsHoldingDog",), + 0x809C2F34:("EnAob01_Race_HidePlayer",), + 0x809C2FA0:("EnAob01_InitializeDogTextOffsets",), 0x809C3190:("EnAob01_Init",), 0x809C3350:("EnAob01_Destroy",), 0x809C339C:("EnAob01_Update",), @@ -9125,8 +9125,8 @@ 0x809CA27C:("BgIcicle_Draw",), 0x809CA3F0:("EnSyatekiCrow_Init",), 0x809CA5A8:("EnSyatekiCrow_Destroy",), - 0x809CA5D4:("EnSyatekiCrow_SetupWaitForSpawn",), - 0x809CA67C:("EnSyatekiCrow_WaitForSpawn",), + 0x809CA5D4:("EnSyatekiCrow_SetupWaitForSignal",), + 0x809CA67C:("EnSyatekiCrow_WaitForSignal",), 0x809CA71C:("EnSyatekiCrow_SetupWaitToMove",), 0x809CA840:("EnSyatekiCrow_WaitToMove",), 0x809CA8E4:("EnSyatekiCrow_Fly",), @@ -9710,7 +9710,7 @@ 0x80A134B0:("func_80A134B0",), 0x80A134F4:("func_80A134F4",), 0x80A13564:("func_80A13564",), - 0x80A136B8:("func_80A136B8",), + 0x80A136B8:("EnGo_RequestQuake",), 0x80A13728:("func_80A13728",), 0x80A137C0:("func_80A137C0",), 0x80A139E4:("func_80A139E4",), @@ -9876,21 +9876,21 @@ 0x80A1FC50:("DmHina_Draw",), 0x80A1FE50:("EnSyatekiWf_Init",), 0x80A200A0:("EnSyatekiWf_Destroy",), - 0x80A200E0:("func_80A200E0",), - 0x80A201CC:("func_80A201CC",), - 0x80A20284:("func_80A20284",), - 0x80A2030C:("func_80A2030C",), - 0x80A20320:("func_80A20320",), - 0x80A20378:("func_80A20378",), - 0x80A203DC:("func_80A203DC",), - 0x80A20670:("func_80A20670",), - 0x80A206DC:("func_80A206DC",), - 0x80A20710:("func_80A20710",), - 0x80A2075C:("func_80A2075C",), - 0x80A2079C:("func_80A2079C",), - 0x80A20800:("func_80A20800",), - 0x80A20858:("func_80A20858",), - 0x80A208F8:("func_80A208F8",), + 0x80A200E0:("EnSyatekiWf_InitPathStart",), + 0x80A201CC:("EnSyatekiWf_SetupWaitForSignal",), + 0x80A20284:("EnSyatekiWf_WaitForSignal",), + 0x80A2030C:("EnSyatekiWf_SetupWaitToMove",), + 0x80A20320:("EnSyatekiWf_WaitToMove",), + 0x80A20378:("EnSyatekiWf_SetupRun",), + 0x80A203DC:("EnSyatekiWf_Run",), + 0x80A20670:("EnSyatekiWf_SetupJump",), + 0x80A206DC:("EnSyatekiWf_Jump",), + 0x80A20710:("EnSyatekiWf_SetupLand",), + 0x80A2075C:("EnSyatekiWf_Land",), + 0x80A2079C:("EnSyatekiWf_SetupHowl",), + 0x80A20800:("EnSyatekiWf_Howl",), + 0x80A20858:("EnSyatekiWf_SetupDead",), + 0x80A208F8:("EnSyatekiWf_Dead",), 0x80A20A50:("EnSyatekiWf_Update",), 0x80A20CF4:("EnSyatekiWf_OverrideLimbDraw",), 0x80A20D10:("EnSyatekiWf_PostLimbDraw",), @@ -10063,10 +10063,10 @@ 0x80A2B390:("BgDblueMovebg_Draw",), 0x80A2BC00:("EnSyatekiDekunuts_Init",), 0x80A2BE28:("EnSyatekiDekunuts_Destroy",), - 0x80A2BE54:("EnSyatekiDekunuts_SetupWaitForSpawn",), - 0x80A2BF18:("EnSyatekiDekunuts_WaitForSpawn",), - 0x80A2BFC4:("EnSyatekiDekunuts_SetupSpawn",), - 0x80A2C0F8:("EnSyatekiDekunuts_Spawn",), + 0x80A2BE54:("EnSyatekiDekunuts_SetupWaitForSignal",), + 0x80A2BF18:("EnSyatekiDekunuts_WaitForSignal",), + 0x80A2BFC4:("EnSyatekiDekunuts_SetupWaitToStart",), + 0x80A2C0F8:("EnSyatekiDekunuts_WaitToStart",), 0x80A2C150:("EnSyatekiDekunuts_SetupWaitToEmerge",), 0x80A2C168:("EnSyatekiDekunuts_WaitToEmerge",), 0x80A2C1AC:("EnSyatekiDekunuts_SetupEmerge",), @@ -10126,43 +10126,43 @@ 0x80A2EBE8:("DmSa_Draw",), 0x80A2EDA0:("EnSlime_Init",), 0x80A2EF80:("EnSlime_Destroy",), - 0x80A2EFAC:("func_80A2EFAC",), - 0x80A2F028:("func_80A2F028",), - 0x80A2F0A8:("func_80A2F0A8",), - 0x80A2F110:("func_80A2F110",), - 0x80A2F140:("func_80A2F140",), - 0x80A2F180:("func_80A2F180",), - 0x80A2F1A4:("func_80A2F1A4",), - 0x80A2F354:("func_80A2F354",), - 0x80A2F418:("func_80A2F418",), - 0x80A2F684:("func_80A2F684",), - 0x80A2F6CC:("func_80A2F6CC",), - 0x80A2F8B4:("func_80A2F8B4",), - 0x80A2F8E0:("func_80A2F8E0",), - 0x80A2F9A0:("func_80A2F9A0",), - 0x80A2FA88:("func_80A2FA88",), - 0x80A2FB60:("func_80A2FB60",), - 0x80A2FBA0:("func_80A2FBA0",), - 0x80A2FD94:("func_80A2FD94",), - 0x80A2FE38:("func_80A2FE38",), - 0x80A30018:("func_80A30018",), - 0x80A30344:("func_80A30344",), - 0x80A30454:("func_80A30454",), - 0x80A304B8:("func_80A304B8",), - 0x80A3072C:("func_80A3072C",), - 0x80A30778:("func_80A30778",), - 0x80A30820:("func_80A30820",), - 0x80A30924:("func_80A30924",), - 0x80A30944:("func_80A30944",), - 0x80A309C8:("func_80A309C8",), - 0x80A30A20:("func_80A30A20",), - 0x80A30A90:("func_80A30A90",), - 0x80A30AE4:("func_80A30AE4",), - 0x80A30BE0:("func_80A30BE0",), - 0x80A30C2C:("func_80A30C2C",), - 0x80A30C68:("func_80A30C68",), - 0x80A30CEC:("func_80A30CEC",), - 0x80A30F98:("func_80A30F98",), + 0x80A2EFAC:("EnSlime_Freeze",), + 0x80A2F028:("EnSlime_Thaw",), + 0x80A2F0A8:("EnSlime_Blink",), + 0x80A2F110:("EnSlime_SetupInitializeIdle",), + 0x80A2F140:("EnSlime_InitializeIdle",), + 0x80A2F180:("EnSlime_SetupIdle",), + 0x80A2F1A4:("EnSlime_Idle",), + 0x80A2F354:("EnSlime_SetupMoveInDirection",), + 0x80A2F418:("EnSlime_MoveInDirection",), + 0x80A2F684:("EnSlime_SetupMoveToHome",), + 0x80A2F6CC:("EnSlime_MoveToHome",), + 0x80A2F8B4:("EnSlime_SetupTurnToPlayer",), + 0x80A2F8E0:("EnSlime_TurnToPlayer",), + 0x80A2F9A0:("EnSlime_SetupJump",), + 0x80A2FA88:("EnSlime_Jump",), + 0x80A2FB60:("EnSlime_SetupLand",), + 0x80A2FBA0:("EnSlime_Land",), + 0x80A2FD94:("EnSlime_SetupReactToBluntHit",), + 0x80A2FE38:("EnSlime_ReactToBluntHit",), + 0x80A30018:("EnSlime_SetupDamaged",), + 0x80A30344:("EnSlime_Damaged",), + 0x80A30454:("EnSlime_SetupDead",), + 0x80A304B8:("EnSlime_Dead",), + 0x80A3072C:("EnSlime_SnapIceBlockPosition",), + 0x80A30778:("EnSlime_SetupSpawnIceBlock",), + 0x80A30820:("EnSlime_SpawnIceBlock",), + 0x80A30924:("EnSlime_SetupIceBlock",), + 0x80A30944:("EnSlime_IceBlock",), + 0x80A309C8:("EnSlime_SetupStun",), + 0x80A30A20:("EnSlime_Stun",), + 0x80A30A90:("EnSlime_SetupIceBlockThaw",), + 0x80A30AE4:("EnSlime_IceBlockThaw",), + 0x80A30BE0:("EnSlime_SetupWaitForRevive",), + 0x80A30C2C:("EnSlime_WaitForRevive",), + 0x80A30C68:("EnSlime_SetupRevive",), + 0x80A30CEC:("EnSlime_Revive",), + 0x80A30F98:("EnSlime_UpdateDamage",), 0x80A311E8:("EnSlime_Update",), 0x80A3148C:("EnSlime_Draw",), 0x80A32210:("EnPr_Init",), @@ -10620,7 +10620,7 @@ 0x80A53E60:("func_80A53E60",), 0x80A541F4:("func_80A541F4",), 0x80A54600:("func_80A54600",), - 0x80A54980:("ObjHugebombiwa_AddQuake",), + 0x80A54980:("ObjHugebombiwa_RequestQuakeAndRumble",), 0x80A54A0C:("func_80A54A0C",), 0x80A54AC0:("ObjHugebombiwa_Init",), 0x80A54BC4:("ObjHugebombiwa_Destroy",), @@ -11339,8 +11339,8 @@ 0x80A90478:("EnTest5_HandleBottleAction",), 0x80A905A4:("EnTest5_Update",), 0x80A90730:("func_80A90730",), - 0x80A90C08:("func_80A90C08",), - 0x80A90C34:("func_80A90C34",), + 0x80A90C08:("EnTest6_EnableMotionBlur",), + 0x80A90C34:("EnTest6_DisableMotionBlur",), 0x80A90C54:("func_80A90C54",), 0x80A90D20:("func_80A90D20",), 0x80A90D34:("func_80A90D34",), @@ -11433,7 +11433,7 @@ 0x80A9BC0C:("func_80A9BC0C",), 0x80A9BD24:("func_80A9BD24",), 0x80A9C058:("func_80A9C058",), - 0x80A9C18C:("func_80A9C18C",), + 0x80A9C18C:("BgHakuginPost_RequestQuakeAndRumble",), 0x80A9C228:("func_80A9C228",), 0x80A9C634:("func_80A9C634",), 0x80A9C854:("func_80A9C854",), @@ -12021,21 +12021,21 @@ 0x80AC9D10:("ObjOcarinalift_Draw",), 0x80AC9EA0:("EnTimeTag_Init",), 0x80AC9FC4:("EnTimeTag_Destroy",), - 0x80AC9FD4:("func_80AC9FD4",), - 0x80AC9FE4:("func_80AC9FE4",), - 0x80ACA0A8:("func_80ACA0A8",), - 0x80ACA12C:("func_80ACA12C",), - 0x80ACA184:("func_80ACA184",), - 0x80ACA208:("func_80ACA208",), - 0x80ACA268:("func_80ACA268",), - 0x80ACA348:("func_80ACA348",), - 0x80ACA3C0:("func_80ACA3C0",), - 0x80ACA418:("func_80ACA418",), - 0x80ACA5F8:("func_80ACA5F8",), - 0x80ACA714:("func_80ACA714",), - 0x80ACA724:("func_80ACA724",), - 0x80ACA7C4:("func_80ACA7C4",), - 0x80ACA840:("func_80ACA840",), + 0x80AC9FD4:("EnTimeTag_RooftopOath_DoNothing",), + 0x80AC9FE4:("EnTimeTag_RooftopOath_Cutscene",), + 0x80ACA0A8:("EnTimeTag_RooftopOath_Wait",), + 0x80ACA12C:("EnTimeTag_SoaringEngraving_GetSong",), + 0x80ACA184:("EnTimeTag_SoaringEngraving_StartCutscene",), + 0x80ACA208:("EnTimeTag_SoaringEngraving_SubsequentInteraction",), + 0x80ACA268:("EnTimeTag_SoaringEngraving_Wait",), + 0x80ACA348:("EnTimeTag_Diary_AfterOcarina",), + 0x80ACA3C0:("EnTimeTag_Diary_TeachEvanSongSnippets",), + 0x80ACA418:("EnTimeTag_Diary_Cutscene",), + 0x80ACA5F8:("EnTimeTag_Diary_Wait",), + 0x80ACA714:("EnTimeTag_KickOut_DoNothing",), + 0x80ACA724:("EnTimeTag_KickOut_Transition",), + 0x80ACA7C4:("EnTimeTag_KickOut_WaitForTrigger",), + 0x80ACA840:("EnTimeTag_KickOut_WaitForTime",), 0x80ACA9AC:("EnTimeTag_Update",), 0x80ACAB10:("func_80ACAB10",), 0x80ACABA8:("func_80ACABA8",), @@ -12211,7 +12211,7 @@ 0x80AD566C:("EnTrt2_TransformLimbDraw",), 0x80AD56E8:("func_80AD56E8",), 0x80AD5BB0:("ObjTokeiStep_SetSysMatrix",), - 0x80AD5BE8:("ObjTokeiStep_AddQuake",), + 0x80AD5BE8:("ObjTokeiStep_RequestQuakeAndRumble",), 0x80AD5C70:("ObjTokeiStep_SpawnDust",), 0x80AD5DFC:("ObjTokeiStep_InitSteps",), 0x80AD5EB8:("ObjTokeiStep_InitStepsOpen",), @@ -12481,8 +12481,8 @@ 0x80AE6E8C:("EnShn_Draw",), 0x80AE73A0:("EnStopheishi_Init",), 0x80AE74E0:("EnStopheishi_Destroy",), - 0x80AE750C:("func_80AE750C",), - 0x80AE75C8:("func_80AE75C8",), + 0x80AE750C:("EnStopHeishi_ChangeAnim",), + 0x80AE75C8:("EnStopheishi_UpdateHeadNormal",), 0x80AE7718:("func_80AE7718",), 0x80AE77D4:("func_80AE77D4",), 0x80AE795C:("func_80AE795C",), @@ -12491,8 +12491,8 @@ 0x80AE854C:("func_80AE854C",), 0x80AE85C4:("func_80AE85C4",), 0x80AE8680:("EnStopheishi_Update",), - 0x80AE87A4:("func_80AE87A4",), - 0x80AE87EC:("func_80AE87EC",), + 0x80AE87A4:("EnStopheishi_OverrideLimbDraw",), + 0x80AE87EC:("EnStopheishi_PostLimbDraw",), 0x80AE882C:("EnStopheishi_Draw",), 0x80AE8B70:("ObjBigicicle_Init",), 0x80AE8DA4:("ObjBigicicle_Destroy",), @@ -12870,7 +12870,7 @@ 0x80B01B30:("EnGiant_Init",), 0x80B01E74:("EnGiant_Destroy",), 0x80B01E84:("EnGiant_ChangeToStartOrLoopAnimation",), - 0x80B01EE8:("EnGiant_ChangeAnimBasedOnCsAction",), + 0x80B01EE8:("EnGiant_ChangeAnimBasedOnCueId",), 0x80B020A0:("EnGiant_UpdateAlpha",), 0x80B0211C:("EnGiant_PlayAndUpdateAnimation",), 0x80B02234:("EnGiant_PlaySound",), @@ -13735,9 +13735,9 @@ 0x80B43DD4:("func_80B43DD4",), 0x80B43E6C:("func_80B43E6C",), 0x80B43F0C:("func_80B43F0C",), - 0x80B43F70:("EnInvadepoh_GetTotalPathDistance",), + 0x80B43F70:("func_80B43F70",), 0x80B44024:("func_80B44024",), - 0x80B4407C:("EnInvadepoh_SetPathPointToWorldPos",), + 0x80B4407C:("func_80B4407C",), 0x80B440B8:("func_80B440B8",), 0x80B44234:("func_80B44234",), 0x80B442E4:("func_80B442E4",), @@ -13771,9 +13771,9 @@ 0x80B453F4:("func_80B453F4",), 0x80B45460:("func_80B45460",), 0x80B454BC:("func_80B454BC",), - 0x80B45518:("EnInvadepoh_SetSysMatrix",), + 0x80B45518:("func_80B45518",), 0x80B45550:("func_80B45550",), - 0x80B4560C:("EnInvadepoh_SetTextID",), + 0x80B4560C:("func_80B4560C",), 0x80B45648:("func_80B45648",), 0x80B456A8:("func_80B456A8",), 0x80B457A0:("func_80B457A0",), @@ -13791,13 +13791,13 @@ 0x80B46184:("func_80B46184",), 0x80B461DC:("func_80B461DC",), 0x80B4627C:("func_80B4627C",), - 0x80B46414:("EnInvadepoh_InitAlien",), - 0x80B46520:("EnInvadepoh_InitParentCow",), - 0x80B465CC:("EnInvadepoh_InitChildCow",), - 0x80B46644:("EnInvadepoh_InitRomani",), + 0x80B46414:("func_80B46414",), + 0x80B46520:("func_80B46520",), + 0x80B465CC:("func_80B465CC",), + 0x80B46644:("func_80B46644",), 0x80B468B4:("func_80B468B4",), - 0x80B469C4:("EnInvadepoh_InitDog",), - 0x80B46A80:("EnInvadepoh_InitCremia",), + 0x80B469C4:("func_80B469C4",), + 0x80B46A80:("func_80B46A80",), 0x80B46B74:("EnInvadepoh_Init",), 0x80B46BB0:("func_80B46BB0",), 0x80B46BC0:("func_80B46BC0",), @@ -14252,30 +14252,30 @@ 0x80B66BDC:("ObjHariko_Draw",), 0x80B66D30:("EnSth_Init",), 0x80B67010:("EnSth_Destroy",), - 0x80B6703C:("func_80B6703C",), - 0x80B670A4:("func_80B670A4",), - 0x80B67148:("func_80B67148",), - 0x80B671A0:("func_80B671A0",), - 0x80B67208:("func_80B67208",), - 0x80B672A4:("func_80B672A4",), - 0x80B67348:("func_80B67348",), - 0x80B67458:("func_80B67458",), - 0x80B67540:("func_80B67540",), - 0x80B677BC:("func_80B677BC",), - 0x80B67838:("func_80B67838",), - 0x80B678A8:("func_80B678A8",), - 0x80B67958:("func_80B67958",), - 0x80B67984:("func_80B67984",), - 0x80B67AB4:("func_80B67AB4",), - 0x80B67B50:("func_80B67B50",), - 0x80B67C1C:("func_80B67C1C",), - 0x80B67DA0:("func_80B67DA0",), - 0x80B67E20:("func_80B67E20",), - 0x80B67E78:("EnSth_Update",), - 0x80B680A8:("func_80B680A8",), - 0x80B681E8:("func_80B681E8",), - 0x80B68310:("func_80B68310",), - 0x80B6849C:("func_80B6849C",), + 0x80B6703C:("EnSth_CanSpeakToPlayer",), + 0x80B670A4:("EnSth_ChangeAnim",), + 0x80B67148:("EnSth_GetInitialPanicText",), + 0x80B671A0:("EnSth_HandlePanicConversation",), + 0x80B67208:("EnSth_PanicIdle",), + 0x80B672A4:("EnSth_GetInitialOceansideSpiderHouseText",), + 0x80B67348:("EnSth_PostOceanspiderhouseReward",), + 0x80B67458:("EnSth_GiveOceansideSpiderHouseReward",), + 0x80B67540:("EnSth_HandleOceansideSpiderHouseConversation",), + 0x80B677BC:("EnSth_OceansideSpiderHouseIdle",), + 0x80B67838:("EnSth_HandleMoonLookingConversation",), + 0x80B678A8:("EnSth_MoonLookingIdle",), + 0x80B67958:("EnSth_DefaultIdle",), + 0x80B67984:("EnSth_GetInitialSwampSpiderHouseText",), + 0x80B67AB4:("EnSth_TalkAfterSwampSpiderHouseGiveMask",), + 0x80B67B50:("EnSth_SwampSpiderHouseGiveMask",), + 0x80B67C1C:("EnSth_HandleSwampSpiderHouseConversation",), + 0x80B67DA0:("EnSth_SwampSpiderHouseIdle",), + 0x80B67E20:("EnSth_UpdateOceansideSpiderHouseWaitForTokens",), + 0x80B67E78:("EnSth_UpdateWaitForObject",), + 0x80B680A8:("EnSth_Update",), + 0x80B681E8:("EnSth_OverrideLimbDraw",), + 0x80B68310:("EnSth_PostLimbDraw",), + 0x80B6849C:("EnSth_Draw",), 0x80B6D660:("BgSinkaiKabe_Init",), 0x80B6D9EC:("BgSinkaiKabe_Destroy",), 0x80B6DA20:("BgSinkaiKabe_WaitForPlayer",), @@ -14411,7 +14411,7 @@ 0x80B73AE4:("EnJg_UpdateCollision",), 0x80B73B98:("EnJg_GetWalkingYRotation",), 0x80B73C58:("EnJg_ReachedPoint",), - 0x80B73DF4:("EnJg_GetCutsceneForTeachingLullabyIntro",), + 0x80B73DF4:("EnJg_GetCsIdForTeachingLullabyIntro",), 0x80B73E3C:("EnJg_SetupGoronShrineCheer",), 0x80B73F1C:("EnJg_SetupTalk",), 0x80B7406C:("EnJg_Idle",), @@ -14704,33 +14704,33 @@ 0x80B8A718:("EnKaizoku_Draw",), 0x80B8B2D0:("EnGe2_Init",), 0x80B8B504:("EnGe2_Destroy",), - 0x80B8B514:("func_80B8B514",), - 0x80B8B5AC:("func_80B8B5AC",), - 0x80B8B6B4:("func_80B8B6B4",), - 0x80B8B7A8:("func_80B8B7A8",), - 0x80B8B848:("func_80B8B848",), - 0x80B8B90C:("func_80B8B90C",), - 0x80B8BA40:("func_80B8BA40",), - 0x80B8BB3C:("func_80B8BB3C",), - 0x80B8BC1C:("func_80B8BC1C",), - 0x80B8BC78:("func_80B8BC78",), - 0x80B8BCEC:("func_80B8BCEC",), - 0x80B8BD38:("func_80B8BD38",), - 0x80B8BD90:("func_80B8BD90",), - 0x80B8BE08:("func_80B8BE08",), - 0x80B8BF04:("func_80B8BF04",), - 0x80B8BFC8:("func_80B8BFC8",), - 0x80B8C048:("func_80B8C048",), - 0x80B8C0B0:("func_80B8C0B0",), - 0x80B8C13C:("func_80B8C13C",), - 0x80B8C45C:("func_80B8C45C",), - 0x80B8C59C:("func_80B8C59C",), - 0x80B8C644:("func_80B8C644",), - 0x80B8C9B8:("func_80B8C9B8",), + 0x80B8B514:("EnGe2_DetectPlayer",), + 0x80B8B5AC:("EnGe2_LookForPlayer",), + 0x80B8B6B4:("EnGe2_SetupPath",), + 0x80B8B7A8:("EnGe2_GetNextPath",), + 0x80B8B848:("EnGe2_SetupBlownAwayPath",), + 0x80B8B90C:("EnGe2_FollowPath",), + 0x80B8BA40:("EnGe2_FollowPathWithoutGravity",), + 0x80B8BB3C:("EnGe2_SpawnEffects",), + 0x80B8BC1C:("EnGe2_Scream",), + 0x80B8BC78:("EnGe2_ThrowPlayerOut",), + 0x80B8BCEC:("EnGe2_TurnToPlayerFast",), + 0x80B8BD38:("EnGe2_CapturePlayer",), + 0x80B8BD90:("EnGe2_SetupCapturePlayer",), + 0x80B8BE08:("EnGe2_Charge",), + 0x80B8BF04:("EnGe2_SetupCharge",), + 0x80B8BFC8:("EnGe2_SetupLookAround",), + 0x80B8C048:("EnGe2_Stunned",), + 0x80B8C0B0:("EnGe2_KnockedOut",), + 0x80B8C13C:("EnGe2_PatrolDuties",), + 0x80B8C45C:("EnGe2_LookAround",), + 0x80B8C59C:("EnGe2_Walk",), + 0x80B8C644:("EnGe2_PerformCutsceneActions",), + 0x80B8C9B8:("EnGe2_GuardStationary",), 0x80B8CAA8:("EnGe2_Update",), - 0x80B8CC0C:("func_80B8CC0C",), - 0x80B8CCB4:("func_80B8CCB4",), - 0x80B8CCFC:("func_80B8CCFC",), + 0x80B8CC0C:("EnGe2_ValidatePictograph",), + 0x80B8CCB4:("EnGe2_OverrideLimbDraw",), + 0x80B8CCFC:("EnGe2_PostLimbDraw",), 0x80B8CD3C:("EnGe2_Draw",), 0x80B8D030:("EnMaYts_UpdateEyes",), 0x80B8D0BC:("EnMaYts_ChangeAnim",), @@ -14960,9 +14960,9 @@ 0x80B9AF50:("func_80B9AF50",), 0x80B9AFE0:("ObjBoat_Init",), 0x80B9B0F0:("ObjBoat_Destroy",), - 0x80B9B124:("func_80B9B124",), + 0x80B9B124:("ObjBoat_SetRotations",), 0x80B9B1B8:("ObjBoat_Update",), - 0x80B9B428:("func_80B9B428",), + 0x80B9B428:("ObjBoat_UpdateCutscene",), 0x80B9B628:("ObjBoat_Draw",), 0x80B9B6E0:("func_80B9B6E0",), 0x80B9B74C:("func_80B9B74C",), @@ -15161,7 +15161,7 @@ 0x80BA78F8:("EnRailgibud_PostLimbDraw",), 0x80BA79D4:("EnRailgibud_Draw",), 0x80BA7B6C:("EnRailgibud_InitCutsceneGibdo",), - 0x80BA7C78:("EnRailgibud_InitActorActionCommand",), + 0x80BA7C78:("EnRailgibud_InitCueType",), 0x80BA7CF0:("EnRailgibud_SetupDoNothing",), 0x80BA7D04:("EnRailgibud_DoNothing",), 0x80BA7D14:("EnRailgibud_SetupSinkIntoGround",), @@ -15199,7 +15199,7 @@ 0x80BAA6D0:("EnSuttari_UpdateCollider",), 0x80BAA848:("EnSuttari_GetActorById",), 0x80BAA88C:("EnSuttari_TriggerTransition",), - 0x80BAA8D0:("EnSuttari_UpdateTime",), + 0x80BAA8D0:("EnSuttari_AdvanceTime",), 0x80BAA904:("func_80BAA904",), 0x80BAA9B4:("func_80BAA9B4",), 0x80BAAA94:("func_80BAAA94",), @@ -16662,7 +16662,7 @@ 0x80C0A740:("func_80C0A740",), 0x80C0A804:("func_80C0A804",), 0x80C0A838:("func_80C0A838",), - 0x80C0A86C:("func_80C0A86C",), + 0x80C0A86C:("BgIkninSusceil_RequestQuakeAndRumble",), 0x80C0A95C:("func_80C0A95C",), 0x80C0AA70:("BgIkninSusceil_Init",), 0x80C0AAE0:("BgIkninSusceil_Destroy",), @@ -16868,13 +16868,13 @@ 0x80C18928:("BgLastBwall_DoNothing",), 0x80C18938:("BgLastBwall_Update",), 0x80C1895C:("BgLastBwall_Draw",), - 0x80C18B90:("func_80C18B90",), - 0x80C18BD8:("func_80C18BD8",), - 0x80C18C50:("func_80C18C50",), + 0x80C18B90:("EnAnd_ChangeAnimation",), + 0x80C18BD8:("EnAnd_Blink",), + 0x80C18C50:("EnAnd_HandleCsAction",), 0x80C18DC8:("EnAnd_Init",), 0x80C18E84:("EnAnd_Destroy",), 0x80C18E94:("EnAnd_Update",), - 0x80C18ED0:("func_80C18ED0",), + 0x80C18ED0:("EnAnd_TransformLimbDraw",), 0x80C19084:("EnAnd_Draw",), 0x80C192A0:("func_80C192A0",), 0x80C192B0:("func_80C192B0",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 285cb4992..68c0933d3 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -285,15 +285,15 @@ 0x800994D0:("D_800994D0","char","[]",0xc), 0x800994DC:("D_800994DC","char","[]",0x12), 0x800994F0:("D_800994F0","char","[]",0x1), - 0x80099500:("sBootThreadInfo","StackEntry","",0x1c), + 0x80099500:("sBootStackInfo","StackEntry","",0x1c), 0x80099520:("sIdleThread","OSThread","",0x1b0), 0x800996D0:("sIdleThreadStack","u8","[1024]",0x400), - 0x80099AD0:("sIdleThreadInfo","StackEntry","",0x1c), - 0x80099AF0:("sBootThreadStack","u8","[1024]",0x400), + 0x80099AD0:("sIdleStackInfo","StackEntry","",0x1c), + 0x80099AF0:("sBootStack","u8","[1024]",0x400), 0x80099EF0:("gIrqMgr","IrqMgr","",0x280), 0x8009A170:("sIrqMgrStack","u8","[1280]",0x500), 0x8009A670:("sIrqMgrStackInfo","StackEntry","",0x1c), - 0x8009A690:("gMainThread","OSThread","",0x1b0), + 0x8009A690:("sMainThread","OSThread","",0x1b0), 0x8009A840:("sMainStack","u8","[2304]",0x900), 0x8009B140:("sMainStackInfo","StackEntry","",0x1c), 0x8009B160:("sPiMgrCmdBuff","OSMesg","[50]",0xc8), @@ -311,7 +311,7 @@ 0x8009BE14:("sYaz0CurRomStart","u32","",0x4), 0x8009BE18:("sYaz0CurSize","u32","",0x4), 0x8009BE1C:("sYaz0MaxPtr","u8*","",0x4), - 0x8009BE20:("D_8009BE20","u8*","",0x4), + 0x8009BE20:("gYaz0DecompressDstEnd","void*","",0x4), 0x8009BE30:("D_8009BE30","UNK_TYPE4","",0x4), 0x8009BE34:("D_8009BE34","UNK_TYPE4","",0x4), 0x8009BE38:("romInfoFaultClient","FaultClient","",0x10), @@ -320,7 +320,7 @@ 0x8009BE58:("faultCustomOptions","u32","",0x4), 0x8009BE5C:("faultCopyToLog","u32","",0x4), 0x8009BE60:("sFaultStack","u8","[1536]",0x600), - 0x8009C460:("sFaultThreadInfo","StackEntry","",0x1c), + 0x8009C460:("sFaultStackInfo","StackEntry","",0x1c), 0x8009C480:("gFaultStruct","FaultThreadStruct","",0x848), 0x8009CCD0:("sFaultDrawerStruct","FaultDrawer","",0x3c), 0x8009CD10:("D_8009CD10","UNK_TYPE4","",0x4), @@ -328,7 +328,7 @@ 0x8009CD50:("sRandFloat","f32","",0x4), 0x8009CD60:("sArenaLockMsg","OSMesg","[1]",0x4), 0x8009CD70:("tmp_task","OSTask","",0x40), - 0x8009CDB0:("osPifBuffers","OSPifRam","[4]",0x100), + 0x8009CDB0:("__MotorDataBuf","OSPifRam","[4]",0x100), 0x8009CEB0:("siAccessBuf","OSMesg","[1]",0x4), 0x8009CEB8:("__osSiAccessQueue","OSMesgQueue","",0x18), 0x8009CED0:("__osContPifRam","OSPifRam","",0x40), @@ -343,8 +343,8 @@ 0x8009CF80:("__osThreadSave","OSThread","",0x1b0), 0x8009D130:("D_8009D130","OSPiHandle","",0x74), 0x8009D1A8:("D_8009D1A8","OSPiHandle","",0x74), - 0x8009D220:("D_8009D220","OSThread","",0x1b0), - 0x8009D3D0:("piManagerStack","u8","[4096]",0x1000), + 0x8009D220:("sPiMgrThread","OSThread","",0x1b0), + 0x8009D3D0:("sPiMgrStack","u8","[4096]",0x1000), 0x8009E3D0:("D_8009E3D0","OSMesgQueue","",0x18), 0x8009E3E8:("D_8009E3E8","OSMesg","[1]",0x4), 0x8009E3F0:("D_8009E3F0","OSMesg","[1]",0x4), @@ -359,7 +359,7 @@ 0x8009E5D0:("__osPfsPifRam","OSPifRam","",0x40), 0x8009E610:("CartRomHandle","OSPiHandle","",0x74), 0x8009E690:("viThread","OSThread","",0x1b0), - 0x8009E840:("viThreadStack","u8","[4096]",0x1000), + 0x8009E840:("sViStack","u8","[4096]",0x1000), 0x8009F840:("viEventQueue","OSMesgQueue","",0x18), 0x8009F858:("viEventBuf","OSMesg","[5]",0x14), 0x8009F870:("viRetraceMsg","OSIoMesg","",0x18), @@ -398,7 +398,7 @@ 0x801AE2BC:("D_801AE2BC","UNK_TYPE4","",0x4), 0x801AE2CC:("D_801AE2CC","UNK_TYPE4","",0x4), 0x801AE2DC:("D_801AE2DC","UNK_TYPE4","",0x4), - 0x801AE2F0:("sEffectShieldParticleVertices","F3DVertex","[4]",0x40), + 0x801AE2F0:("sEffShieldParticleVtx","Vtx","[4]",0x40), 0x801AE330:("sEffectInfoTable","EffectInfo","[5]",0x64), 0x801AE3A0:("sEffectSsInfo","EffectSsInfo","",0xc), 0x801AE3B0:("D_801AE3B0","Color_RGBA8","",0x4), @@ -430,19 +430,19 @@ 0x801AEC78:("sTimer","s32","",0x4), 0x801AEC80:("D_801AEC80","Color_RGBA8","",0x4), 0x801AEC84:("sTatlColorList","TatlColor","[13]",0x68), - 0x801AECEC:("actorMovementScale","f32","",0x4), + 0x801AECEC:("sActorMovementScale","f32","",0x4), 0x801AECF0:("gTargetRanges","f32","[]",0x58), 0x801AED48:("D_801AED48","s16","[8]",0x10), - 0x801AED58:("D_801AED58","UNK_TYPE4","",0x4), + 0x801AED58:("sCategoryFreezeMasks","UNK_TYPE4","",0x4), 0x801AED88:("actorDefaultHitColor","Color_RGBA8","",0x4), 0x801AED8C:("D_801AED8C","UNK_TYPE1","",0x1), 0x801AED98:("D_801AED98","Vec3f","",0xC), 0x801AEDA4:("D_801AEDA4","UNK_TYPE4","",0x4), - 0x801AEDB0:("D_801AEDB0","UNK_TYPE1","",0x1), - 0x801AEDD4:("D_801AEDD4","UNK_TYPE4","",0x4), + 0x801AEDB0:("sArrowDmgFlags","UNK_TYPE1","",0x1), + 0x801AEDD4:("sDoorLocksInfo","UNK_TYPE4","",0x4), 0x801AEE28:("D_801AEE28","UNK_TYPE4","",0x4), 0x801AEE30:("D_801AEE30","UNK_TYPE4","",0x4), - 0x801AEE38:("D_801AEE38","struct_801AEE38","[14]",0x150), + 0x801AEE38:("sNpcTrackingPresets","NpcTrackingParams","[14]",0x150), 0x801AEF88:("D_801AEF88","UNK_TYPE1","",0x1), 0x801AEFA0:("D_801AEFA0","UNK_TYPE1","",0x1), 0x801AEFA8:("sElectricSparkTextures","UNK_TYPE1","",0x1), @@ -451,6 +451,11 @@ 0x801AEFC0:("D_801AEFC0","UNK_TYPE1","",0x1), 0x801AEFD0:("gActorOverlayTable","ActorOverlay","[ACTOR_ID_MAX]",0x5640), 0x801B4610:("gMaxActorId","s32","",0x4), + 0x801B4620:("sWallFlags","u32","",0x80), + 0x801B46A0:("sSurfaceSfxOffsets","u16","",0x1E), + 0x801B46C0:("sSurfaceMaterialProperties","u8","",0xF), + 0x801B46D0:("sSmallMemSceneIds","s16","",0x2), + 0x801B46D4:("sSceneMemList","BgCheckSceneMemEntry","",0x8), 0x801B46DC:("sSceneSubdivisionList","BgCheckSceneSubdivisionEntry","[3]",0x24), 0x801B4700:("sCustomDynapolyMem","BgSpecialSceneMaxObjects","[1]",0x8), 0x801B4708:("D_801B4708","UNK_TYPE1","",0x1), @@ -467,19 +472,6 @@ 0x801B48B0:("sSetNormal0ModeBoomerangData","UNK_TYPE1","",0x1), 0x801B48D4:("sSetNormal0ModeSlingshotData","UNK_TYPE1","",0x1), 0x801B48F8:("sSetNormal0ModeClimbZData","UNK_TYPE1","",0x1), - 0x801B4710:("sSetNormal0ModeNormalData","UNK_TYPE1","",0x1), - 0x801B4738:("sSetNormal0ModeTargetData","UNK_TYPE1","",0x1), - 0x801B4768:("sSetNormal0ModeFollowTargetData","UNK_TYPE1","",0x1), - 0x801B4798:("sSetNormal0ModeBattleData","UNK_TYPE1","",0x1), - 0x801B47CC:("sSetNormal0ModeFirstPersonData","UNK_TYPE1","",0x1), - 0x801B47F0:("sSetNormal0ModeTalkData","UNK_TYPE1","",0x1), - 0x801B4824:("sSetNormal0ModeClimbData","UNK_TYPE1","",0x1), - 0x801B4848:("sSetNormal0ModeBowArrowData","UNK_TYPE1","",0x1), - 0x801B486C:("sSetNormal0ModeBowArrowZData","UNK_TYPE1","",0x1), - 0x801B4890:("sSetNormal0ModeHookshotData","UNK_TYPE1","",0x1), - 0x801B48B0:("sSetNormal0ModeBoomerangData","UNK_TYPE1","",0x1), - 0x801B48D4:("sSetNormal0ModeSlingshotData","UNK_TYPE1","",0x1), - 0x801B48F8:("sSetNormal0ModeClimbZData","UNK_TYPE1","",0x1), 0x801B491C:("sSetNormal0ModeJumpData","UNK_TYPE1","",0x1), 0x801B4944:("sSetNormal0ModeHangData","UNK_TYPE1","",0x1), 0x801B4974:("sSetNormal0ModeHangZData","UNK_TYPE1","",0x1), @@ -918,33 +910,25 @@ 0x801BB0DC:("D_801BB0DC","UNK_TYPE1","",0x1), 0x801BB0FC:("D_801BB0FC","UNK_TYPE2","",0x2), 0x801BB100:("D_801BB100","UNK_TYPE1","",0x1), - 0x801BB124:("D_801BB124","UNK_TYPE2","",0x2), - 0x801BB128:("D_801BB128","UNK_TYPE2","",0x2), - 0x801BB12C:("D_801BB12C","UNK_TYPE1","",0x1), + 0x801BB124:("sCurTextId","UNK_TYPE2","",0x2), + 0x801BB128:("sCurOcarinaAction","UNK_TYPE2","",0x2), + 0x801BB12C:("gOpeningEntranceIndex","UNK_TYPE1","",0x1), 0x801BB130:("sCutsceneStoredPlayerForm","UNK_TYPE1","",0x1), - 0x801BB134:("sCsStateHandlers1","cutscene_update_func","[5]",0x14), - 0x801BB148:("sCsStateHandlers2","cutscene_update_func","[5]",0x14), + 0x801BB134:("sManualCutsceneHandlers","cutscene_update_func","[5]",0x14), + 0x801BB148:("sScriptedCutsceneHandlers","cutscene_update_func","[5]",0x14), 0x801BB15C:("D_801BB15C","UNK_TYPE2","",0x2), - 0x801BB160:("D_801BB160","UNK_TYPE4","",0x4), + 0x801BB160:("sCutsceneTextboxType","UNK_TYPE4","",0x4), 0x801BB170:("sDrawItemTable","DrawItemTableEntry","[118]",0x1098), - 0x801BC210:("D_801BC210","UNK_TYPE1","",0x1), - 0x801BC240:("D_801BC240","Gfx","[9]",0x48), - 0x801BC288:("D_801BC288","Gfx","[3]",0x18), + 0x801BC210:("gEffFootprintVtx","UNK_TYPE1","",0x1), + 0x801BC240:("gEffFootprintMaterialDL","Gfx","[9]",0x48), + 0x801BC288:("gEffFootprintModelDL","Gfx","[3]",0x18), 0x801BC2A0:("D_801BC2A0","UNK_TYPE1","",0x1), 0x801BC3F0:("gEnHyBodyParts","UNK_TYPE1","",0x1), 0x801BC400:("gEnHyParentBodyParts","UNK_TYPE1","",0x1), 0x801BC410:("gEnHyShadowSizes","s32",[],0x10), 0x801BC420:("sReactionTextIds","u16","[]",0x140A), - 0x801BD830:("actorCutscenesGlobalCutscenes","ActorCutscene","[8]",0x80), - 0x801BD8B0:("actorCutsceneCurrent","s16","",0x2), - 0x801BD8B2:("actorCutsceneCurrentLength","s16","",0x2), - 0x801BD8B4:("actorCutsceneEnding","s16","",0x2), - 0x801BD8B6:("actorCutsceneCurrentCamera","s16","",0x2), - 0x801BD8B8:("actorCutsceneCurrentCutsceneActor","Actor*","",0x4), - 0x801BD8BC:("actorCutsceneStartMethod","UNK_TYPE4","",0x4), - 0x801BD8C0:("actorCutscenesPlayState","PlayState*","",0x4), - 0x801BD8C4:("actorCutsceneReturnCamera","s16","",0x2), - 0x801BD8C6:("D_801BD8C6","s16","",0x2), + 0x801BD830:("sGlobalCutsceneList","ActorCutscene","[8]",0x80), + 0x801BD8B0:("sCutsceneMgr","ActorCutsceneManager","",0x18), 0x801BD8D0:("sFireObjCollisionInit","ColliderCylinderInit","",0x2c), 0x801BD8FC:("sFireObjColors","FireObjColors","[1]",0x08), 0x801BD904:("sFireObjLightParams","FireObjLightParams","[1]",0x08), @@ -1121,9 +1105,9 @@ 0x801BFAFC:("D_801BFAFC","UNK_TYPE4","",0x4), 0x801BFB04:("D_801BFB04","UNK_TYPE1","",0x1), 0x801BFB0C:("D_801BFB0C","UNK_TYPE1","",0x1), - 0x801BFB14:("D_801BFB14","UNK_TYPE1","",0x1), - 0x801BFB1C:("D_801BFB1C","UNK_TYPE1","",0x1), - 0x801BFB24:("D_801BFB24","UNK_TYPE1","",0x1), + 0x801BFB14:("sMagicArrowEffectsR","UNK_TYPE1","",0x1), + 0x801BFB1C:("sMagicArrowEffectsG","UNK_TYPE1","",0x1), + 0x801BFB24:("sMagicArrowEffectsB","UNK_TYPE1","",0x1), 0x801BFB2C:("sThreeDayClockAlpha","UNK_TYPE2","",0x2), 0x801BFB30:("D_801BFB30","UNK_TYPE2","",0x2), 0x801BFB34:("D_801BFB34","UNK_TYPE2","",0x2), @@ -1190,9 +1174,9 @@ 0x801C0034:("gPlayerSheath12DLs","UNK_TYPE1","",0x1), 0x801C005C:("gPlayerSheath13DLs","UNK_TYPE1","",0x1), 0x801C0084:("gPlayerSheath14DLs","UNK_TYPE1","",0x1), - 0x801C00AC:("gPlayerShields","UNK_TYPE1","",0x1), - 0x801C00BC:("gPlayerSheathedSwords","UNK_TYPE1","",0x1), - 0x801C00D4:("gPlayerSwordSheaths","UNK_TYPE1","",0x1), + 0x801C00AC:("gPlayerShields","Gfx*","",0x10), + 0x801C00BC:("gPlayerSheathedSwords","Gfx*","",0x18), + 0x801C00D4:("gPlayerSwordSheaths","Gfx*","",0x18), 0x801C00EC:("gPlayerLeftHandTwoHandSwordDLs","UNK_TYPE1","",0x1), 0x801C0114:("gPlayerLeftHandOpenDLs","UNK_TYPE1","",0x1), 0x801C013C:("gPlayerLeftHandClosedDLs","UNK_TYPE1","",0x1), @@ -1204,11 +1188,11 @@ 0x801C021C:("gPlayerRightHandInstrumentDLs","UNK_TYPE1","",0x1), 0x801C0244:("gPlayerRightHandHookshotDLs","UNK_TYPE1","",0x1), 0x801C026C:("gPlayerLeftHandBottleDLs","UNK_TYPE1","",0x1), - 0x801C0294:("D_801C0294","UNK_TYPE1","",0x1), - 0x801C02A8:("D_801C02A8","UNK_TYPE1","",0x1), - 0x801C02BC:("D_801C02BC","UNK_TYPE1","",0x1), - 0x801C02D0:("D_801C02D0","UNK_TYPE1","",0x1), - 0x801C02E4:("D_801C02E4","UNK_TYPE1","",0x1), + 0x801C0294:("sPlayerFirstPersonLeftForearmDLs","UNK_TYPE1","",0x1), + 0x801C02A8:("sPlayerFirstPersonLeftHandDLs","UNK_TYPE1","",0x1), + 0x801C02BC:("sPlayerFirstPersonRightShoulderDLs","UNK_TYPE1","",0x1), + 0x801C02D0:("sPlayerFirstPersonRightHandDLs","UNK_TYPE1","",0x1), + 0x801C02E4:("sPlayerFirstPersonRightHandHookshotDLs","UNK_TYPE1","",0x1), 0x801C02F8:("sPlayerDListGroups","UNK_PTR","",0x4), 0x801C0340:("D_801C0340","UNK_TYPE1","",0x1), 0x801C0368:("D_801C0368","UNK_TYPE1","",0x1), @@ -1259,7 +1243,7 @@ 0x801C0958:("D_801C0958","UNK_TYPE4","",0x4), 0x801C095C:("D_801C095C","UNK_PTR","",0x4), 0x801C0964:("D_801C0964","UNK_TYPE1","",0x1), - 0x801C096C:("D_801C096C","UNK_TYPE1","",0x1), + 0x801C096C:("sPlayerShieldCollisionTypes","UNK_TYPE1","",0x1), 0x801C0970:("D_801C0970","UNK_TYPE1","",0x1), 0x801C0994:("D_801C0994","UNK_TYPE4","",0x4), 0x801C09B8:("D_801C09B8","UNK_TYPE1","",0x1), @@ -1293,29 +1277,28 @@ 0x801C0C0C:("D_801C0C0C","UNK_TYPE4","",0x4), 0x801C0C30:("D_801C0C30","UNK_TYPE1","",0x1), 0x801C0C54:("D_801C0C54","struct_80128388_arg1","",0x54), - 0x801C0CA8:("D_801C0CA8","UNK_TYPE1","",0x1), + 0x801C0CA8:("sPlayerBottleColors","UNK_TYPE1","",0x1), 0x801C0CE8:("D_801C0CE8","UNK_TYPE4","",0x4), - 0x801C0D24:("D_801C0D24","UNK_TYPE1","",0x1), + 0x801C0D24:("sPlayerFootPos","UNK_TYPE1","",0x1), 0x801C0D60:("D_801C0D60","UNK_TYPE1","",0x1), 0x801C0D6C:("D_801C0D6C","UNK_TYPE1","",0x1), - 0x801C0D78:("D_801C0D78","UNK_TYPE1","",0x1), + 0x801C0D78:("sMeleeWeaponLengths","f32","[7]",0x1C), 0x801C0D94:("D_801C0D94","UNK_TYPE4","",0x4), - 0x801C0D98:("D_801C0D98","UNK_TYPE4","",0x4), - 0x801C0D9C:("D_801C0D9C","UNK_TYPE4","",0x4), - 0x801C0DA0:("D_801C0DA0","UNK_TYPE4","",0x4), - 0x801C0DA8:("D_801C0DA8","UNK_TYPE1","",0x1), + 0x801C0D98:("D_801C0D98","Vec3f","",0xC), + 0x801C0DA4:("D_801C0DA4","UNK_TYPE4","",0x4), + 0x801C0DA8:("sRightHandLimbModelShieldQuadVertices","Vec3f","[4]",0x30), 0x801C0DD8:("D_801C0DD8","UNK_TYPE1","",0x1), 0x801C0DE4:("D_801C0DE4","UNK_TYPE1","",0x1), 0x801C0DF0:("D_801C0DF0","UNK_TYPE4","",0x4), 0x801C0E04:("D_801C0E04","UNK_TYPE1","",0x1), 0x801C0E2C:("D_801C0E2C","UNK_TYPE4","",0x4), 0x801C0E40:("D_801C0E40","UNK_TYPE4","",0x4), - 0x801C0E7C:("D_801C0E7C","UNK_TYPE1","",0x1), + 0x801C0E7C:("sPlayerFocusHeadLimbModelPos","Vec3f","",0xC), 0x801C0E94:("D_801C0E94","UNK_TYPE1","",0x1), 0x801C0EA0:("D_801C0EA0","UNK_TYPE1","",0x1), - 0x801C0EAC:("D_801C0EAC","UNK_TYPE1","",0x1), - 0x801C0EB8:("D_801C0EB8","UNK_TYPE1","",0x1), - 0x801C0EC0:("sIsQuakeInitialized","UNK_TYPE2","",0x2), + 0x801C0EAC:("sSheathLimbModelShieldOnBackPos","Vec3f","",0xC), + 0x801C0EB8:("sSheathLimbModelShieldOnBackZyxRot","Vec3s","",0x6), + 0x801C0EC0:("sQuakeUnused","UNK_TYPE2","",0x2), 0x801C0EC4:("sQuakeRequestCount","s16","",0x2), 0x801C0EC8:("sQuakeCallbacks","quake_callback_func","[7]",0x1c), 0x801C0EE4:("D_801C0EE4","s16","",0x2), @@ -1324,8 +1307,8 @@ 0x801C0EF0:("sSetupDL","Gfx","[438]",0xdb0), 0x801C1CA0:("sFillSetupDL","Gfx","[12]",0x60), 0x801C1D00:("gEmptyDL","Gfx","[1]",0x8), - 0x801C1D10:("D_801C1D10","Vec3f","",0xc), - 0x801C1D1C:("roomDrawFuncs","room_draw_func","[4]",0x10), + 0x801C1D10:("sZeroVec","Vec3f","",0xc), + 0x801C1D1C:("sRoomDrawHandlers","RoomDrawHandler","[4]",0x10), 0x801C1D30:("gBitFlags","u32","[32]",0x80), 0x801C1DB0:("gEquipMasks","u16","[4]",0x8), 0x801C1DB8:("gEquipNegMasks","u16","[4]",0x8), @@ -1345,7 +1328,8 @@ 0x801C2650:("tatlMessageFiles","RomFile","[2]",0x10), 0x801C2660:("sceneTextureFiles","RomFile","[9]",0x48), 0x801C26A8:("sceneHeaderFuncTable","scene_header_func","[31]",0x7c), - 0x801C2730:("gPlayerFormObjectIndices","s16","[8]",0x10), + 0x801C2730:("gPlayerFormObjectIndices","s16","[5]",0xA), + 0x801C273C:("gObjectTableSize","ObjectId","",0x4), 0x801C2740:("gObjectTable","RomFile","[643]",0x1418), 0x801C3B60:("sSceneDrawDefaultDl","Gfx","[11]",0x58), 0x801C3BB8:("gSceneProcSceneDrawFuncs","SceneDrawConfigFunc","[8]",0x20), @@ -2114,7 +2098,7 @@ 0x801D0B70:("gKaleidoMgrOverlayTable","KaleidoMgrOverlay","",0x38), 0x801D0BA8:("sKaleidoAreaPtr","void*","",0x4), 0x801D0BAC:("gKaleidoMgrCurOvl","KaleidoMgrOverlay*","",0x4), - 0x801D0BB0:("D_801D0BB0","UNK_TYPE4","",0x4), + 0x801D0BB0:("gTransitionOverlayTable","UNK_TYPE4","",0x4), 0x801D0C80:("D_801D0C80","UNK_TYPE1","",0x1), 0x801D0CB0:("D_801D0CB0","UNK_TYPE1","",0x1), 0x801D0CD8:("TransitionFade_InitVars","UNK_PTR","",0x4), @@ -2122,11 +2106,10 @@ 0x801D0D28:("TransitionCircle_InitVars","UNK_PTR","",0x4), 0x801D0D50:("gDbgCamEnabled","UNK_TYPE4","",0x4), 0x801D0D54:("D_801D0D54","UNK_TYPE1","",0x1), - 0x801D0D58:("D_801D0D58","UNK_TYPE2","",0x2), - 0x801D0D5C:("D_801D0D5C","UNK_TYPE2","",0x2), + 0x801D0D58:("sQuakeIndex","UNK_TYPE2","",0x2), + 0x801D0D5C:("sIsCameraUnderwater","UNK_TYPE2","",0x2), 0x801D0D60:("D_801D0D60","Input*","",0x4), - 0x801D0D64:("D_801D0D64","s16","[10]",0x14), - 0x801D0D7A:("D_801D0D7A","UNK_TYPE1","",0x1), + 0x801D0D64:("sPlayerCsIdToCsCamId","s16","[10]",0x14), 0x801D0D80:("D_801D0D80","UNK_TYPE1","",0x1), 0x801D11F4:("D_801D11F4","UNK_TYPE1","",0x1), 0x801D1230:("D_801D1230","UNK_TYPE1","",0x1), @@ -2182,9 +2165,9 @@ 0x801D1520:("gScreenWidth","s32","",0x4), 0x801D1524:("gScreenHeight","s32","",0x4), 0x801D1528:("startHeapSize","UNK_TYPE4","",0x4), - 0x801D1530:("padmgrContext","PadMgr*","",0x4), - 0x801D1534:("controllerInputsCaptured","UNK_TYPE4","",0x4), - 0x801D1538:("D_801D1538","UNK_TYPE4","",0x4), + 0x801D1530:("sPadMgrInstance","PadMgr*","",0x4), + 0x801D1534:("sPadMgrRetraceCount","UNK_TYPE4","",0x4), + 0x801D1538:("sVoiceInitStatus","UNK_TYPE4","",0x4), 0x801D1540:("D_801D1540","UNK_PTR","",0x4), 0x801D1570:("D_801D1570","f32","[13]",0x34), 0x801D15B0:("gZeroVec3f","Vec3f","",0xC), @@ -2385,14 +2368,14 @@ 0x801DB4A4:("gSfxDefaultPos","UNK_TYPE4","",0x4), 0x801DB4B0:("gSfxDefaultFreqAndVolScale","UNK_TYPE1","",0x1), 0x801DB4B8:("gSfxDefaultReverb","UNK_TYPE1","",0x1), - 0x801DB4C0:("D_801DB4C0","UNK_TYPE1","",0x1), - 0x801DB4C4:("D_801DB4C4","UNK_TYPE1","",0x1), - 0x801DB4C8:("D_801DB4C8","UNK_TYPE1","",0x1), - 0x801DB4CC:("D_801DB4CC","UNK_TYPE1","",0x1), + 0x801DB4C0:("sSeqCmdWritePos","UNK_TYPE1","",0x1), + 0x801DB4C4:("sSeqCmdReadPos","UNK_TYPE1","",0x1), + 0x801DB4C8:("sStartSeqDisabled","UNK_TYPE1","",0x1), + 0x801DB4CC:("sSoundModeList","UNK_TYPE1","",0x1), 0x801DB4D4:("gAudioSpecId","UNK_TYPE1","",0x1), - 0x801DB4D8:("D_801DB4D8","UNK_TYPE1","",0x1), - 0x801DB4DC:("D_801DB4DC","UNK_TYPE4","",0x4), - 0x801DB4E0:("D_801DB4E0","UNK_TYPE1","",0x1), + 0x801DB4D8:("gAudioHeapResetState","UNK_TYPE1","",0x1), + 0x801DB4DC:("sResetAudioHeapSeqCmd","UNK_TYPE4","",0x4), + 0x801DB4E0:("gReverbSettings","UNK_TYPE1","",0x1), 0x801DB528:("D_801DB528","UNK_TYPE1","",0x1), 0x801DB570:("D_801DB570","UNK_TYPE1","",0x1), 0x801DB5B8:("D_801DB5B8","UNK_TYPE1","",0x1), @@ -3839,14 +3822,14 @@ 0x801ED8D8:("D_801ED8D8","UNK_TYPE1","",0x1), 0x801ED8DC:("D_801ED8DC","UNK_TYPE1","",0x1), 0x801ED8E0:("D_801ED8E0","Mtx","",0x40), - 0x801ED920:("D_801ED920","UNK_TYPE1","",0x1), + 0x801ED920:("D_801ED920","Actor*","",0x1), 0x801ED930:("D_801ED930","FaultClient","",0x10), - 0x801ED940:("D_801ED940","FaultAddrConvClient","",0xc), + 0x801ED940:("sActorOverlayTableFaultAddrConvClient","FaultAddrConvClient","",0xC), 0x801ED950:("D_801ED950","char","[80]",0x50), 0x801ED9A0:("D_801ED9A0","char","[80]",0x50), 0x801ED9F0:("D_801ED9F0","Vec3f","[3]",0x24), 0x801EDA18:("D_801EDA18","Vec3f","[3]",0x24), - 0x801EDA40:("D_801EDA40","MtxF","",0x40), + 0x801EDA40:("sModelToWorldMtxF","MtxF","",0x40), 0x801EDA80:("D_801EDA80","Vec3f","[3]",0x24), 0x801EDAA8:("D_801EDAA8","char","[80]",0x50), 0x801EDAF8:("D_801EDAF8","char","[80]",0x50), @@ -3856,9 +3839,9 @@ 0x801EDBA8:("D_801EDBA8","Sphere16","",0x8), 0x801EDBB0:("D_801EDBB0","TriNorm","",0x34), 0x801EDBF0:("D_801EDBF0","s16","",0x2), - 0x801EDBF4:("D_801EDBF4","f32","",0x4), - 0x801EDBF8:("D_801EDBF8","f32","",0x4), - 0x801EDC00:("D_801EDC00","CameraCollision","",0x28), + 0x801EDBF4:("sFloorYNear","f32","",0x4), + 0x801EDBF8:("sFloorYFar","f32","",0x4), + 0x801EDC00:("sFarColChk","CameraCollision","",0x28), 0x801EDC28:("sCamPlayState","PlayState*","",0x4), 0x801EDC30:("D_801EDC30","SwingAnimation","[4]",0x1A0), 0x801EDDD0:("D_801EDDD0","Vec3f","",0xc), @@ -3908,23 +3891,21 @@ 0x801EF670:("gSaveContext","SaveContext","",0x48e8), 0x801F3F58:("D_801F3F58","UNK_TYPE1","",0x1), 0x801F3F5A:("D_801F3F5A","UNK_TYPE1","",0x1), - 0x801F3F60:("gGameInfo","GameInfo*","",0x4), + 0x801F3F60:("gRegEditor","RegEditor*","",0x4), 0x801F3F70:("sDebugObjectListHead","UNK_TYPE1","",0x1), - 0x801F3F80:("D_801F3F80","UNK_TYPE1","",0x1), - 0x801F3F83:("D_801F3F83","UNK_TYPE1","",0x1), - 0x801F48C8:("D_801F48C8","UNK_TYPE1","",0x1), - 0x801F4D40:("seqId","u16","",0x2), + 0x801F3F80:("D_801F3F80","UNK_TYPE1","",0xDC0), + 0x801F4D40:("sSeqId","u16","",0x2), 0x801F4D42:("sCutsceneQuakeIndex","UNK_TYPE2","",0x2), 0x801F4D48:("sCutsceneCameraInfo","UNK_TYPE","",0x80), - 0x801F4DC8:("D_801F4DC8","u16","[10]",0x14), + 0x801F4DC8:("sCueTypeList","u16","[10]",0x14), 0x801F4DDC:("D_801F4DDC","UNK_TYPE1","",0x1), - 0x801F4DE0:("D_801F4DE0","UNK_TYPE1","",0x1), - 0x801F4DE2:("D_801F4DE2","UNK_TYPE2","",0x2), - 0x801F4DF0:("actorCutscenes","ActorCutscene*","",0x4), - 0x801F4DF4:("actorCutsceneCount","s16","",0x2), - 0x801F4DF8:("actorCutsceneWaiting","u8","[16]",0x10), + 0x801F4DE0:("gDisablePlayerCsModeStartPos","UNK_TYPE1","",0x1), + 0x801F4DE2:("gDungeonBossWarpSceneId","UNK_TYPE2","",0x2), + 0x801F4DF0:("sSceneCutsceneList","ActorCutscene*","",0x4), + 0x801F4DF4:("sSceneCutsceneCount","s16","",0x2), + 0x801F4DF8:("sWaitingCutsceneList","u8","[16]",0x10), 0x801F4E08:("D_801F4E08","UNK_TYPE1","",0x1), - 0x801F4E10:("actorCutsceneNextCutscenes","u8","[16]",0x10), + 0x801F4E10:("sNextCutsceneList","u8","[16]",0x10), 0x801F4E20:("D_801F4E20","UNK_TYPE1","",0x1), 0x801F4E30:("D_801F4E30","UNK_TYPE1","",0x1), 0x801F4E31:("D_801F4E31","UNK_TYPE1","",0x1), @@ -3986,14 +3967,14 @@ 0x801F59AC:("D_801F59AC","UNK_TYPE1","",0x1), 0x801F59B0:("D_801F59B0","Vec3f","[2]",0x18), 0x801F59C8:("D_801F59C8","s32","[2]",0x8), - 0x801F59D0:("D_801F59D0","struct_801F59D0","",0x0A), - 0x801F59DC:("D_801F59DC","Vec3f*","",0x4), + 0x801F59D0:("sBunnyEarKinematics","struct_801F59D0","",0x0A), + 0x801F59DC:("sPlayerCurBodyPartPos","Vec3f*","",0x4), 0x801F59E0:("D_801F59E0","s32","",0x4), - 0x801F59E4:("D_801F59E4","s32","",0x4), - 0x801F59E8:("D_801F59E8","Vec3f","",0xC), - 0x801F59F4:("D_801F59F4","s32","",0x4), - 0x801F59F8:("D_801F59F8","s32","",0x4), - 0x801F5A00:("sQuakeRequest","QuakeRequest","[4]",0x90), + 0x801F59E4:("sPlayerLod","s32","",0x4), + 0x801F59E8:("sPlayerGetItemRefPos","Vec3f","",0xC), + 0x801F59F4:("sPlayerLeftHandType","s32","",0x4), + 0x801F59F8:("sPlayerRightHandType","s32","",0x4), + 0x801F5A00:("sQuakeRequests","QuakeRequest","[4]",0x90), 0x801F5A90:("sDistortionRequest","DistortionRequest","",0xc), 0x801F5AA0:("sMatAnimStep","s32","",0x4), 0x801F5AA4:("sMatAnimFlags","u32","",0x4), @@ -4027,31 +4008,29 @@ 0x801F6B3C:("sPlayerCallDrawFunc","UNK_TYPE1","",0x1), 0x801F6B40:("sShrinkWindow","ShrinkWindow","",0x4), 0x801F6B44:("sShrinkWindowPtr","ShrinkWindow*","",0x4), - 0x801F6B50:("D_801F6B50","UNK_TYPE4","",0x4), + 0x801F6B50:("sCurCsCamera","UNK_TYPE4","",0x4), 0x801F6B58:("D_801F6B58","UNK_TYPE1","",0x1), - 0x801F6BF0:("sKaleidoAreaFaultClient","FaultAddrConvClient","",0xC), + 0x801F6BF0:("sKaleidoMgrFaultAddrConvClient","FaultAddrConvClient","",0xC), 0x801F6C00:("sKaleidoScopeUpdateFunc","void*","",0x4), 0x801F6C04:("sKaleidoScopeDrawFunc","void*","",0x4), - 0x801F6C10:("D_801F6C10","UNK_TYPE1","",0x1), + 0x801F6C10:("sTransitionFillTimer","UNK_TYPE1","",0x1), 0x801F6C18:("D_801F6C18","Input","",0x18), - 0x801F6C30:("D_801F6C30","UNK_TYPE1","",0x1), - 0x801F6D0C:("D_801F6D0C","UNK_TYPE1","",0x1), - 0x801F6D10:("D_801F6D10","UNK_TYPE4","",0x4), - 0x801F6D18:("D_801F6D18","UNK_TYPE1","",0x1), - 0x801F6D30:("D_801F6D30","Color_RGBA8","",0x4), + 0x801F6C30:("sTransitionTile","TransitionTile","",0xE0), + 0x801F6D10:("gTransitionTileState","UNK_TYPE4","",0x4), + 0x801F6D18:("sVisMono","UNK_TYPE1","",0x1), + 0x801F6D30:("gVisMonoColor","Color_RGBA8","",0x4), 0x801F6D38:("D_801F6D38","UNK_TYPE1","",0x1), 0x801F6D4C:("D_801F6D4C","UNK_TYPE4","",0x4), - 0x801F6D50:("D_801F6D50","UNK_TYPE1","",0x1), - 0x801F6DFC:("D_801F6DFC","u8","",0x1), - 0x801F6DFD:("D_801F6DFD","UNK_TYPE1","",0x1), - 0x801F6E00:("D_801F6E00","SlowlyTask","",0x1c0), + 0x801F6D50:("sBombersNotebook","UNK_TYPE1","",0x1), + 0x801F6DFC:("sBombersNotebookOpen","u8","",0x1), + 0x801F6DFD:("sMotionBlurStatus","UNK_TYPE1","",0x1), + 0x801F6E00:("sSlowlyMgr","SlowlyMgr","",0x1c0), 0x801F6FC0:("D_801F6FC0","UNK_TYPE1","",0x1), - 0x801F6FC8:("slowlyStackEntry","StackEntry","",0x1c), - 0x801F6FE8:("slowlyStack","u8","[4096]",0x1000), - 0x801F7FE8:("D_801F7FE8","UNK_TYPE1","",0x1), + 0x801F6FC8:("sSlowlyStackInfo","StackEntry","",0x1c), + 0x801F6FE8:("sSlowlyStack","u8","[4096]",0x1000), 0x801F7FF0:("D_801F7FF0","UNK_TYPE1","",0x1), 0x801F8010:("D_801F8010","struct_801F8010","",0x10), - 0x801F8020:("D_801F8020","struct_801F8020","",0x10), + 0x801F8020:("sVisZbuf","VisZbuf","",0x10), 0x801F8030:("sMonoColors","VisMono","",0x18), 0x801F8048:("D_801F8048","UNK_TYPE1","",0x1), 0x801F80D0:("sGraphFaultAddrConvClient","FaultAddrConvClient","",0xc), @@ -4066,17 +4045,17 @@ 0x801F84F8:("irqClient","IrqMgrClient","",0x8), 0x801F8500:("irqMgrMsgQ","OSMesgQueue","",0x18), 0x801F8518:("irqMgrMsgBuf","OSMesg","[60]",0xf0), - 0x801F8608:("sGraphThread","OSThread","",0x1b0), + 0x801F8608:("gGraphThread","OSThread","",0x1b0), 0x801F87B8:("sGraphStack","u8","[6144]",0x1800), - 0x801F9FB8:("schedStack","u8","[1536]",0x600), - 0x801FA5B8:("audioStack","u8","[2048]",0x800), - 0x801FADB8:("padmgrStack","u8","[1280]",0x500), + 0x801F9FB8:("sSchedStack","u8","[1536]",0x600), + 0x801FA5B8:("sAudioStack","u8","[2048]",0x800), + 0x801FADB8:("sPadMgrStack","u8","[1280]",0x500), 0x801FB2B8:("sGraphStackInfo","StackEntry","",0x1c), - 0x801FB2D8:("schedStackEntry","StackEntry","",0x1c), - 0x801FB2F8:("audioStackEntry","StackEntry","",0x1c), - 0x801FB318:("padmgrStackEntry","StackEntry","",0x1c), - 0x801FB338:("audioContext","AudioMgr","",0x2e0), - 0x801FB620:("D_801FB620","PadMgr","",0x480), + 0x801FB2D8:("sSchedStackInfo","StackEntry","",0x1c), + 0x801FB2F8:("sAudioStackInfo","StackEntry","",0x1c), + 0x801FB318:("sPadMgrStackInfo","StackEntry","",0x1c), + 0x801FB338:("sAudioMgr","AudioMgr","",0x2e0), + 0x801FB620:("gPadMgr","PadMgr","",0x480), 0x801FBAA0:("sSchedFaultClient","UNK_TYPE1","",0x1), 0x801FBAB0:("sRSPGFXStartTime","OSTime","",0x8), 0x801FBAB8:("sRSPAudioStartTime","OSTime","",0x8), @@ -4120,7 +4099,7 @@ 0x801FBBD0:("D_801FBBD0","UNK_TYPE1","",0x1), 0x801FBBD2:("D_801FBBD2","UNK_TYPE1","",0x1), 0x801FBBD4:("D_801FBBD4","UNK_TYPE1","",0x1), - 0x801FBBE0:("D_801FBBE0","UNK_TYPE1","",0x1), + 0x801FBBE0:("sDmaBuffer","u32","[2]",0x8), 0x801FBBF0:("D_801FBBF0","Vec3f","",0xc), 0x801FBC00:("Math3D_ColSphereTri_line","LineSegment","",0x18), 0x801FBC18:("Math3D_ColSphereTri_point","Vec3f","",0xc), @@ -4199,9 +4178,9 @@ 0x801FBE28:("D_801FBE28","UNK_TYPE1","",0x1), 0x801FBE2C:("D_801FBE2C","UNK_TYPE1","",0x1), 0x801FBE30:("D_801FBE30","UNK_TYPE4","",0x4), - 0x801FBE38:("sys_flashromStack","u8","[4096]",0x1000), - 0x801FCE38:("sys_flashromStackEntry","StackEntry","",0x1c), - 0x801FCE58:("sys_flashromOSThread","OSThread","",0x1b0), + 0x801FBE38:("sSysFlashromStack","u8","[4096]",0x1000), + 0x801FCE38:("sSysFlashromStackInfo","StackEntry","",0x1c), + 0x801FCE58:("sSysFlashromThread","OSThread","",0x1b0), 0x801FD008:("D_801FD008","s80185D40","",0x2c), 0x801FD034:("D_801FD034","OSMesg","",0x4), 0x801FD040:("D_801FD040","s32","",0x10), @@ -4294,7 +4273,7 @@ 0x801FD598:("sCustomSequencePc","UNK_TYPE1","",0x1), 0x801FD5A0:("D_801FD5A0","UNK_TYPE1","",0x1), 0x801FD5A4:("D_801FD5A4","UNK_TYPE1","",0x1), - 0x801FD5B8:("D_801FD5B8","UNK_TYPE1","",0x1), + 0x801FD5B8:("gVoiceHandle","UNK_TYPE1","",0x1), 0x801FD5C4:("D_801FD5C4","UNK_TYPE1","",0x1), 0x801FD5C8:("D_801FD5C8","UNK_TYPE1","",0x1), 0x801FD5E8:("D_801FD5E8","UNK_TYPE1","",0x1), @@ -4315,9 +4294,9 @@ 0x801FFC80:("sCurSfxPlayerChannelIndex","UNK_TYPE1","",0x1), 0x801FFC84:("gSfxBankMuted","UNK_TYPE1","",0x1), 0x801FFC90:("sUnusedBankLerp","UNK_TYPE1","",0x1), - 0x801FFD00:("D_801FFD00","UNK_TYPE1","",0x1), - 0x801FFD34:("D_801FFD34","UNK_TYPE1","",0x1), - 0x801FFD40:("D_801FFD40","UNK_TYPE1","",0x1), + 0x801FFD00:("sSeqRequests","UNK_TYPE1","",0x1), + 0x801FFD34:("sNumSeqRequests","UNK_TYPE1","",0x1), + 0x801FFD40:("sAudioSeqCmds","UNK_TYPE1","",0x1), 0x80200000:("D_80200000","UNK_TYPE1","",0x1), 0x80200002:("D_80200002","UNK_TYPE1","",0x1), 0x80200004:("D_80200004","UNK_TYPE1","",0x1), @@ -4329,9 +4308,9 @@ 0x8020034A:("D_8020034A","UNK_TYPE1","",0x1), 0x80200B88:("D_80200B88","UNK_TYPE1","",0x1), 0x80200BBA:("D_80200BBA","UNK_TYPE1","",0x1), - 0x80200BCC:("D_80200BCC","UNK_TYPE1","",0x1), - 0x80200BCE:("D_80200BCE","UNK_TYPE1","",0x1), - 0x80200BD0:("D_80200BD0","UNK_TYPE1","",0x1), + 0x80200BCC:("sResetAudioHeapTimer","UNK_TYPE1","",0x1), + 0x80200BCE:("sResetAudioHeapFadeReverbVolume","UNK_TYPE1","",0x1), + 0x80200BD0:("sResetAudioHeapFadeReverbVolumeStep","UNK_TYPE1","",0x1), 0x80200C70:("gAudioCtx","AudioContext","",0x81F8), 0x80208E68:("gAudioCustomUpdateFunction","UNK_TYPE4","",0x4), 0x80208E6C:("gAudioCustomSeqFunction","UNK_TYPE4","",0x4), @@ -4716,12 +4695,12 @@ 0x8082B6F0:("sPromptAlphaTargets","UNK_TYPE1","",0x1), 0x8082B6F4:("sPromptAlphaTargetIndex","UNK_TYPE2","",0x2), 0x8082B6F8:("sPromptAlphaTimer","UNK_TYPE2","",0x2), - 0x8082B700:("D_8082B700","UNK_TYPE1","",0x1), - 0x8082B73C:("D_8082B73C","UNK_TYPE1","",0x1), - 0x8082B778:("D_8082B778","UNK_TYPE1","",0x1), - 0x8082B7B4:("D_8082B7B4","UNK_TYPE1","",0x1), - 0x8082B7F0:("D_8082B7F0","UNK_TYPE2","",0x2), - 0x8082B838:("D_8082B838","UNK_TYPE2","",0x2), + 0x8082B700:("sMaskPageBgTextures","UNK_TYPE1","",0x1), + 0x8082B73C:("sItemPageBgTextures","UNK_TYPE1","",0x1), + 0x8082B778:("sMapPageBgTextures","UNK_TYPE1","",0x1), + 0x8082B7B4:("sQuestPageBgTextures","UNK_TYPE1","",0x1), + 0x8082B7F0:("gVtxPageMapWorldQuadsWidth","UNK_TYPE2","",0x2), + 0x8082B838:("gVtxPageMapWorldQuadsHeight","UNK_TYPE2","",0x2), 0x8082B880:("sGameOverPrimR","UNK_TYPE2","",0x2), 0x8082B884:("sGameOverPrimG","UNK_TYPE2","",0x2), 0x8082B888:("sGameOverPrimB","UNK_TYPE2","",0x2), @@ -4748,10 +4727,10 @@ 0x8082B920:("D_8082B920","UNK_TYPE2","",0x2), 0x8082B924:("D_8082B924","UNK_TYPE2","",0x2), 0x8082B944:("sGameOverRectPosY","UNK_TYPE2","",0x2), - 0x8082B948:("D_8082B948","UNK_TYPE2","",0x2), - 0x8082B96C:("D_8082B96C","UNK_TYPE2","",0x2), - 0x8082B990:("D_8082B990","UNK_TYPE2","",0x2), - 0x8082B994:("D_8082B994","UNK_TYPE2","",0x2), + 0x8082B948:("sCursorPrimColorTarget","UNK_TYPE2","",0x2), + 0x8082B96C:("sCursorEnvColorTarget","UNK_TYPE2","",0x2), + 0x8082B990:("sCursorColorTimer","UNK_TYPE2","",0x2), + 0x8082B994:("sCursorColorTargetIndex","UNK_TYPE2","",0x2), 0x8082B998:("D_8082B998","UNK_TYPE1","",0x1), 0x8082B9A8:("D_8082B9A8","UNK_TYPE1","",0x1), 0x8082B9B8:("D_8082B9B8","UNK_TYPE1","",0x1), @@ -4760,33 +4739,33 @@ 0x8082B9D0:("D_8082B9D0","UNK_TYPE1","",0x1), 0x8082B9E0:("D_8082B9E0","UNK_TYPE2","",0x2), 0x8082B9E4:("D_8082B9E4","UNK_TYPE2","",0x2), - 0x8082B9E8:("D_8082B9E8","UNK_TYPE1","",0x1), - 0x8082B9EC:("D_8082B9EC","UNK_TYPE1","",0x1), - 0x8082B9F0:("D_8082B9F0","UNK_TYPE1","",0x1), - 0x8082B9FC:("D_8082B9FC","UNK_TYPE1","",0x1), - 0x8082BA00:("D_8082BA00","UNK_TYPE1","",0x1), - 0x8082BA48:("D_8082BA48","UNK_TYPE1","",0x1), - 0x8082BA54:("D_8082BA54","UNK_TYPE1","",0x1), - 0x8082BA58:("D_8082BA58","UNK_TYPE1","",0x1), - 0x8082BA5C:("D_8082BA5C","UNK_TYPE1","",0x1), - 0x8082BA68:("D_8082BA68","UNK_TYPE1","",0x1), - 0x8082BA6C:("D_8082BA6C","UNK_TYPE1","",0x1), - 0x8082BA78:("D_8082BA78","UNK_TYPE1","",0x1), - 0x8082BA7C:("D_8082BA7C","UNK_TYPE1","",0x1), - 0x8082BA80:("D_8082BA80","UNK_TYPE1","",0x1), - 0x8082BA8C:("D_8082BA8C","UNK_TYPE1","",0x1), - 0x8082BA90:("D_8082BA90","UNK_TYPE1","",0x1), - 0x8082BAD8:("D_8082BAD8","UNK_TYPE1","",0x1), - 0x8082BAE4:("D_8082BAE4","UNK_TYPE1","",0x1), - 0x8082BAE8:("D_8082BAE8","UNK_TYPE1","",0x1), - 0x8082BAEC:("D_8082BAEC","UNK_TYPE1","",0x1), - 0x8082BAF8:("D_8082BAF8","UNK_TYPE1","",0x1), - 0x8082BAFC:("D_8082BAFC","UNK_TYPE1","",0x1), - 0x8082BB08:("D_8082BB08","UNK_PTR","",0x4), - 0x8082BB20:("D_8082BB20","UNK_PTR","",0x4), - 0x8082BB38:("D_8082BB38","UNK_PTR","",0x4), - 0x8082BB50:("D_8082BB50","UNK_PTR","",0x4), - 0x8082BB68:("D_8082BB68","UNK_TYPE2","",0x2), + 0x8082B9E8:("sVtxPageMaskQuadsX","UNK_TYPE1","",0x1), + 0x8082B9EC:("sVtxPageItemQuadsX","UNK_TYPE1","",0x1), + 0x8082B9F0:("sVtxPageMapDungeonQuadsX","UNK_TYPE1","",0x1), + 0x8082B9FC:("sVtxPageQuestQuadsX","UNK_TYPE1","",0x1), + 0x8082BA00:("sVtxPageMapWorldQuadsX","UNK_TYPE1","",0x1), + 0x8082BA48:("sVtxPagePromptQuadsX","UNK_TYPE1","",0x1), + 0x8082BA54:("sVtxPageMaskQuadsWidth","UNK_TYPE1","",0x1), + 0x8082BA58:("sVtxPageItemQuadsWidth","UNK_TYPE1","",0x1), + 0x8082BA5C:("sVtxPageMapDungeonQuadsWidth","UNK_TYPE1","",0x1), + 0x8082BA68:("sVtxPageQuestQuadsWidth","UNK_TYPE1","",0x1), + 0x8082BA6C:("sVtxPagePromptQuadsWidth","UNK_TYPE1","",0x1), + 0x8082BA78:("sVtxPageMaskQuadsY","UNK_TYPE1","",0x1), + 0x8082BA7C:("sVtxPageItemQuadsY","UNK_TYPE1","",0x1), + 0x8082BA80:("sVtxPageMapDungeonQuadsY","UNK_TYPE1","",0x1), + 0x8082BA8C:("sVtxPageQuestQuadsY","UNK_TYPE1","",0x1), + 0x8082BA90:("sVtxPageMapWorldQuadsY","UNK_TYPE1","",0x1), + 0x8082BAD8:("sVtxPagePromptQuadsY","UNK_TYPE1","",0x1), + 0x8082BAE4:("sVtxPageMaskQuadsHeight","UNK_TYPE1","",0x1), + 0x8082BAE8:("sVtxPageItemQuadsHeight","UNK_TYPE1","",0x1), + 0x8082BAEC:("sVtxPageMapDungeonQuadsHeight","UNK_TYPE1","",0x1), + 0x8082BAF8:("sVtxPageQuestQuadsHeight","UNK_TYPE1","",0x1), + 0x8082BAFC:("sVtxPagePromptQuadsHeight","UNK_TYPE1","",0x1), + 0x8082BB08:("sVtxPageQuadsX","UNK_PTR","",0x4), + 0x8082BB20:("sVtxPageQuadsWidth","UNK_PTR","",0x4), + 0x8082BB38:("sVtxPageQuadsY","UNK_PTR","",0x4), + 0x8082BB50:("sVtxPageQuadsHeight","UNK_PTR","",0x4), + 0x8082BB68:("sVtxPageGameOverSaveQuadsY","UNK_TYPE2","",0x2), 0x8082BB74:("sQuestVtxRectLeft","UNK_TYPE2","",0x2), 0x8082BBC4:("sQuestVtxRectTop","UNK_TYPE2","",0x2), 0x8082BC14:("sQuestVtxWidths","UNK_TYPE2","",0x2), @@ -5668,8 +5647,8 @@ 0x80872E8C:("D_80872E8C","UNK_TYPE1","",0x1), 0x80872E90:("D_80872E90","UNK_TYPE4","",0x4), 0x80872E94:("D_80872E94","UNK_TYPE4","",0x4), - 0x80872E98:("D_80872E98","UNK_TYPE1","",0x1), - 0x80872E9C:("D_80872E9C","UNK_TYPE1","",0x1), + 0x80872E98:("sQuakeY","UNK_TYPE1","",0x1), + 0x80872E9C:("sQuakeDurations","UNK_TYPE1","",0x1), 0x80872EA0:("D_80872EA0","UNK_TYPE4","",0x4), 0x80872EAC:("D_80872EAC","UNK_TYPE4","",0x4), 0x80872EB8:("D_80872EB8","UNK_TYPE4","",0x4), @@ -6174,7 +6153,7 @@ 0x8089E314:("D_8089E314","UNK_TYPE1","",0x1), 0x8089E334:("D_8089E334","UNK_TYPE1","",0x1), 0x8089E33C:("D_8089E33C","UNK_TYPE4","",0x4), - 0x8089E34C:("D_8089E34C","UNK_TYPE2","",0x2), + 0x8089E34C:("sCsId","UNK_TYPE2","",0x2), 0x8089E350:("D_8089E350","UNK_TYPE4","",0x4), 0x8089E354:("D_8089E354","UNK_TYPE1","",0x1), 0x8089E364:("D_8089E364","UNK_TYPE4","",0x4), @@ -6412,15 +6391,15 @@ 0x808B11B0:("D_808B11B0","f32","",0x4), 0x808B11B4:("D_808B11B4","f32","",0x4), 0x808B11B8:("D_808B11B8","f32","",0x4), - 0x808B4D40:("En_Dekubaba_InitVars","UNK_TYPE1","",0x1), - 0x808B4D60:("D_808B4D60","UNK_TYPE1","",0x1), - 0x808B4E5C:("D_808B4E5C","UNK_TYPE1","",0x1), - 0x808B4E6C:("D_808B4E6C","UNK_TYPE1","",0x1), - 0x808B4E74:("D_808B4E74","UNK_TYPE1","",0x1), - 0x808B4E94:("D_808B4E94","UNK_TYPE1","",0x1), - 0x808B4E98:("D_808B4E98","UNK_TYPE1","",0x1), - 0x808B4E9C:("D_808B4E9C","UNK_TYPE1","",0x1), - 0x808B4EA0:("D_808B4EA0","UNK_PTR","",0x4), + 0x808B4D40:("En_Dekubaba_InitVars","ActorInit","",0x20), + 0x808B4D60:("sJntSphElementsInit","ColliderJntSphElementInit","[7]",0xFC), + 0x808B4E5C:("sJntSphInit","ColliderJntSphInit","",0x10), + 0x808B4E6C:("sColChkInfoInit","CollisionCheckInfoInit","",0x4), + 0x808B4E74:("sDamageTable","DamageTable","",0x20), + 0x808B4E94:("sInitChain","InitChainEntry","[1]",0x4), + 0x808B4E98:("sDustPrimColor","Color_RGBA8","",0x4), + 0x808B4E9C:("sDustEnvColor","Color_RGBA8","",0x4), + 0x808B4EA0:("sStemDLists","Gfx*","[3]",0xC), 0x808B4EB0:("D_808B4EB0","f32","",0x4), 0x808B4EB4:("D_808B4EB4","f32","",0x4), 0x808B4EB8:("D_808B4EB8","f32","",0x4), @@ -6632,8 +6611,8 @@ 0x808C3BC0:("D_808C3BC0","UNK_TYPE1","",0x1), 0x808C4CE0:("En_Wood02_InitVars","UNK_TYPE1","",0x1), 0x808C4D00:("D_808C4D00","UNK_TYPE1","",0x1), - 0x808C4D2C:("D_808C4D2C","UNK_TYPE1","",0x1), - 0x808C4D44:("D_808C4D44","UNK_TYPE1","",0x1), + 0x808C4D2C:("sWood02SpawnDistance","f32","",0x1), + 0x808C4D44:("sWood02SpawnAngle","UNK_TYPE1","",0x1), 0x808C4D4E:("D_808C4D4E","UNK_TYPE2","",0x2), 0x808C4D50:("D_808C4D50","UNK_TYPE1","",0x1), 0x808C4D54:("D_808C4D54","UNK_TYPE1","",0x1), @@ -6643,8 +6622,8 @@ 0x808C4E10:("D_808C4E10","f32","",0x4), 0x808C4E14:("D_808C4E14","f32","",0x4), 0x808C4E18:("D_808C4E18","UNK_TYPE1","",0x1), - 0x808C4F70:("D_808C4F70","f32","",0x4), - 0x808C4F74:("D_808C4F74","UNK_TYPE1","",0x1), + 0x808C4F70:("sWood02SpawnCos","f32","",0x4), + 0x808C4F74:("sWood02SpawnSin","UNK_TYPE1","",0x4), 0x808C98C0:("En_Death_InitVars","UNK_TYPE1","",0x1), 0x808C98E0:("D_808C98E0","UNK_TYPE1","",0x1), 0x808C990C:("D_808C990C","UNK_TYPE1","",0x1), @@ -7178,8 +7157,8 @@ 0x808F2DF8:("D_808F2DF8","UNK_TYPE1","",0x1), 0x808F2E00:("D_808F2E00","UNK_TYPE1","",0x1), 0x808F2E20:("D_808F2E20","UNK_TYPE1","",0x1), - 0x808F2E28:("D_808F2E28","UNK_TYPE1","",0x1), - 0x808F2E2C:("D_808F2E2C","UNK_PTR","",0x4), + 0x808F2E28:("sFogColor","Color_RGBA8","",0x4), + 0x808F2E2C:("sStemDLists","Gfx*","[3]",0xC), 0x808F2E40:("D_808F2E40","f32","",0x4), 0x808F2E44:("D_808F2E44","f32","",0x4), 0x808F2E48:("D_808F2E48","f32","",0x4), @@ -7656,11 +7635,11 @@ 0x80911E30:("sSinkingLurePos","Vec3f","[20]",0xF0), 0x80911F20:("D_80911F20","UNK_TYPE1","",0x1), 0x80911F24:("sProjectedW","f32","",0x4), - 0x80911F28:("sCameraEye","Vec3f","",0xC), - 0x80911F38:("sCameraAt","Vec3f","",0xC), - 0x80911F44:("sCameraId","s32","",0x4), + 0x80911F28:("sSubCamEye","Vec3f","",0xC), + 0x80911F38:("sSubCamAt","Vec3f","",0xC), + 0x80911F44:("sSubCamId","s32","",0x4), 0x80911F48:("D_80911F48","f32","",0x4), - 0x80911F4C:("D_80911F4C","f32","",0x4), + 0x80911F4C:("sSubCamVelFactor","f32","",0x4), 0x80911F50:("D_80911F50","UNK_TYPE1","",0x1), 0x80911F58:("sSinkingLureBasePos","Vec3f","",0xC), 0x80911F64:("D_80911F64","f32","",0x4), @@ -7892,7 +7871,7 @@ 0x80920290:("jtbl_80920290","UNK_PTR","",0x4), 0x80920DF0:("gFireArrowTex","u8","[2048]",0x800), 0x809215F0:("gFireArrowMaskTex","u8","[2048]",0x800), - 0x80921DF0:("gFireArrowVtx","F3DVertex","[43]",0x2b0), + 0x80921DF0:("gFireArrowVtx","Vtx","[43]",0x2b0), 0x809220A0:("gIceArrowMaterialDL","Gfx","[22]",0xb0), 0x80922150:("gIceArrowModelDL","Gfx","[24]",0xc0), 0x80922210:("Arrow_Fire_InitVars","ActorInit","",0x20), @@ -9170,9 +9149,9 @@ 0x8098C498:("D_8098C498","f32","",0x4), 0x8098C49C:("jtbl_8098C49C","UNK_PTR","",0x4), 0x8098CD60:("En_Si_InitVars","UNK_TYPE1","",0x1), - 0x8098CD80:("D_8098CD80","UNK_TYPE1","",0x1), - 0x8098CDAC:("D_8098CDAC","UNK_PTR","",0x4), - 0x8098CDB8:("D_8098CDB8","UNK_TYPE1","",0x1), + 0x8098CD80:("sSphereInit","UNK_TYPE1","",0x1), + 0x8098CDAC:("sColChkInfoInit","UNK_PTR","",0x4), + 0x8098CDB8:("sDamageTable","UNK_TYPE1","",0x1), 0x8098E420:("Obj_Comb_InitVars","UNK_TYPE1","",0x1), 0x8098E440:("D_8098E440","UNK_TYPE1","",0x1), 0x8098E464:("D_8098E464","UNK_TYPE1","",0x1), @@ -9495,7 +9474,7 @@ 0x809A6150:("Obj_Boyo_InitVars","UNK_TYPE1","",0x1), 0x809A6170:("D_809A6170","UNK_TYPE1","",0x1), 0x809A619C:("D_809A619C","UNK_TYPE1","",0x1), - 0x809A61B0:("sBumperCollideInfo","UNK_TYPE1","",0x1), + 0x809A61B0:("D_809A61B0","UNK_TYPE1","",0x1), 0x809A61B4:("D_809A61B4","UNK_TYPE2","",0x2), 0x809A61D0:("D_809A61D0","f32","",0x4), 0x809A61D4:("D_809A61D4","f32","",0x4), @@ -9849,11 +9828,11 @@ 0x809C3770:("En_Aob_01_InitVars","UNK_TYPE1","",0x1), 0x809C3790:("sAnimationInfo","UNK_TYPE4","",0x4), 0x809C3820:("D_809C3820","UNK_TYPE1","",0x1), - 0x809C384C:("D_809C384C","UNK_TYPE4","",0x4), + 0x809C384C:("sDogInfo","UNK_TYPE4","",0x4), 0x809C392C:("D_809C392C","UNK_TYPE1","",0x1), 0x809C394C:("D_809C394C","UNK_TYPE4","",0x4), 0x809C395C:("D_809C395C","UNK_PTR","",0x4), - 0x809C3968:("D_809C3968","UNK_TYPE1","",0x1), + 0x809C3968:("sFocusOffset","UNK_TYPE1","",0x1), 0x809C3980:("D_809C3980","f32","",0x4), 0x809C3984:("D_809C3984","f32","",0x4), 0x809C3988:("D_809C3988","f32","",0x4), @@ -10935,13 +10914,13 @@ 0x80A20EA0:("D_80A20EA0","UNK_TYPE1","",0x1), 0x80A20EAC:("D_80A20EAC","UNK_PTR","",0x4), 0x80A20EB0:("D_80A20EB0","UNK_TYPE1","",0x1), - 0x80A20EDC:("D_80A20EDC","UNK_TYPE1","",0x1), - 0x80A20EE8:("D_80A20EE8","UNK_TYPE1","",0x1), + 0x80A20EDC:("sVelocity","UNK_TYPE1","",0x1), + 0x80A20EE8:("sAccel","UNK_TYPE1","",0x1), 0x80A20EF4:("En_Syateki_Wf_InitVars","UNK_TYPE1","",0x1), 0x80A20F14:("D_80A20F14","UNK_PTR","",0x4), 0x80A20FBC:("D_80A20FBC","UNK_TYPE1","",0x1), - 0x80A20FC4:("D_80A20FC4","UNK_TYPE4","",0x4), - 0x80A20FD0:("D_80A20FD0","UNK_TYPE1","",0x1), + 0x80A20FC4:("sFireVelocityAndAccel","UNK_TYPE4","",0x4), + 0x80A20FD0:("sTailColliderOffset","UNK_TYPE1","",0x1), 0x80A20FDC:("D_80A20FDC","UNK_TYPE1","",0x1), 0x80A20FF0:("D_80A20FF0","f32","",0x4), 0x80A229F0:("Obj_Skateblock_InitVars","UNK_TYPE1","",0x1), @@ -11074,7 +11053,7 @@ 0x80A2B90C:("sColHeaders","UNK_TYPE1","",0x1), 0x80A2B93C:("sTexAnims","UNK_TYPE1","",0x1), 0x80A2B96C:("D_80A2B96C","UNK_TYPE1","",0x1), - 0x80A2B974:("D_80A2B974","UNK_TYPE2","",0x2), + 0x80A2B974:("sCsIdList","UNK_TYPE2","",0x2), 0x80A2B978:("D_80A2B978","UNK_TYPE1","",0x1), 0x80A2B988:("D_80A2B988","UNK_TYPE1","",0x1), 0x80A2B9A0:("jtbl_80A2B9A0","UNK_PTR","",0x4), @@ -11136,19 +11115,19 @@ 0x80A2ECE0:("Dm_Sa_InitVars","UNK_TYPE1","",0x1), 0x80A2ED00:("sAnimationInfo","UNK_TYPE1","",0x1), 0x80A2ED20:("D_80A2ED20","f32","",0x4), - 0x80A31AD0:("En_Slime_InitVars","UNK_TYPE1","",0x1), - 0x80A31AF0:("D_80A31AF0","UNK_TYPE1","",0x1), - 0x80A31B1C:("D_80A31B1C","UNK_TYPE1","",0x1), - 0x80A31B3C:("D_80A31B3C","UNK_TYPE1","",0x1), - 0x80A31B44:("D_80A31B44","UNK_TYPE4","",0x4), - 0x80A31B54:("D_80A31B54","UNK_TYPE1","",0x1), - 0x80A31B5C:("D_80A31B5C","UNK_TYPE4","",0x4), - 0x80A31B60:("D_80A31B60","UNK_TYPE1","",0x1), - 0x80A31B64:("D_80A31B64","UNK_TYPE1","",0x1), - 0x80A31B68:("D_80A31B68","UNK_TYPE1","",0x1), - 0x80A31B74:("D_80A31B74","UNK_TYPE1","",0x1), - 0x80A31B84:("D_80A31B84","UNK_TYPE1","",0x1), - 0x80A31B94:("D_80A31B94","UNK_TYPE1","",0x1), + 0x80A31AD0:("En_Slime_InitVars","ActorInit","",0x1), + 0x80A31AF0:("sCylinderInit","ColliderCylinderInit","",0x1), + 0x80A31B1C:("sDamageTable","DamageTable","",0x1), + 0x80A31B3C:("sColChkInfoInit","CollisionCheckInfoInit","",0x1), + 0x80A31B44:("sEyeTextures","TexturePtr","",0x4), + 0x80A31B54:("sInitChain","InitChainEntry","",0x1), + 0x80A31B5C:("sTexturesDesegmented","s32","",0x1), + 0x80A31B60:("sBubblePrimColor","Color_RGBA8","",0x1), + 0x80A31B64:("sBubbleEnvColor","Color_RGBA8","",0x1), + 0x80A31B68:("sBubbleAccel","Vec3f","",0x1), + 0x80A31B74:("sPrimColors","Color_RGBA8","",0x4), + 0x80A31B84:("sEnvColors","Color_RGBA8","",0x4), + 0x80A31B94:("sLimbPosOffsets","Vec3f","",0x5), 0x80A31BD0:("D_80A31BD0","f32","",0x4), 0x80A31BD4:("D_80A31BD4","f32","",0x4), 0x80A31BD8:("D_80A31BD8","f32","",0x4), @@ -11233,7 +11212,7 @@ 0x80A31D14:("D_80A31D14","f32","",0x4), 0x80A31D18:("D_80A31D18","f32","",0x4), 0x80A31D1C:("D_80A31D1C","f32","",0x4), - 0x80A32200:("D_80A32200","UNK_TYPE1","",0x1), + 0x80A32200:("sSlimeTexAnim","AnimatedMaterial*","",0x1), 0x80A338A0:("D_80A338A0","UNK_TYPE1","",0x1), 0x80A338C0:("D_80A338C0","UNK_TYPE1","",0x1), 0x80A338D4:("En_Pr_InitVars","UNK_TYPE1","",0x1), @@ -11463,8 +11442,8 @@ 0x80A43352:("sNightMessages2","s16","[3]",0x6), 0x80A4335A:("sDayMessages2","s16","[3]",0x6), 0x80A43364:("D_80A43364","u16","[2]",0x4), - 0x80A434D0:("sCutscenes","s16","[2]",0x4), - 0x80A434D4:("sCurrentCs","s16","",0x2), + 0x80A434D0:("sCsIdList","s16","[2]",0x4), + 0x80A434D4:("sCurCsId","s16","",0x2), 0x80A449E0:("En_Bat_InitVars","ActorInit","",0x1), 0x80A44A00:("sSphereInit","ColliderSphereInit","",0x1), 0x80A44A2C:("sDamageTable","DamageTable","4",0x1), @@ -12811,7 +12790,7 @@ 0x80AC0254:("D_80AC0254","UNK_TYPE2","",0x2), 0x80AC0258:("D_80AC0258","UNK_TYPE2","",0x2), 0x80AC025C:("D_80AC025C","UNK_TYPE4","",0x4), - 0x80AC0260:("D_80AC0260","UNK_TYPE2","",0x2), + 0x80AC0260:("sCueId","UNK_TYPE2","",0x2), 0x80AC0264:("D_80AC0264","UNK_TYPE4","",0x4), 0x80AC0270:("D_80AC0270","f32","",0x4), 0x80AC0274:("D_80AC0274","f32","",0x4), @@ -12905,8 +12884,8 @@ 0x80AC4F60:("D_80AC4F60","f32","",0x4), 0x80AC4F64:("D_80AC4F64","f32","",0x4), 0x80AC5060:("D_80AC5060","UNK_TYPE1","",0x1), - 0x80AC5630:("sTriforceWipeDL","UNK_TYPE1","",0x1), - 0x80AC5660:("sTriforceWipeVtx","UNK_TYPE1","",0x1), + 0x80AC5630:("sTransTriforceDL","UNK_TYPE1","",0x1), + 0x80AC5660:("sTransTriforceVtx","UNK_TYPE1","",0x1), 0x80AC5700:("TransitionTriforce_InitVars","UNK_PTR","",0x4), 0x80AC5730:("D_80AC5730","f32","",0x4), 0x80AC5734:("D_80AC5734","f32","",0x4), @@ -13241,10 +13220,10 @@ 0x80AE7270:("D_80AE7270","UNK_TYPE1","",0x1), 0x80AE7280:("jtbl_80AE7280","UNK_PTR","",0x4), 0x80AE8890:("En_Stop_heishi_InitVars","UNK_TYPE1","",0x1), - 0x80AE88B0:("D_80AE88B0","UNK_TYPE1","",0x1), + 0x80AE88B0:("sCylinderInit","UNK_TYPE1","",0x1), 0x80AE88DC:("D_80AE88DC","UNK_TYPE1","",0x1), 0x80AE897C:("D_80AE897C","UNK_TYPE1","",0x1), - 0x80AE8A1C:("D_80AE8A1C","UNK_TYPE1","",0x1), + 0x80AE8A1C:("sAnimations","UNK_TYPE1","",0x1), 0x80AE8A24:("D_80AE8A24","UNK_TYPE1","",0x1), 0x80AE8A2C:("D_80AE8A2C","UNK_TYPE1","",0x1), 0x80AE8A30:("D_80AE8A30","UNK_TYPE1","",0x1), @@ -14312,11 +14291,11 @@ 0x80B4E934:("D_80B4E934","UNK_TYPE4","",0x4), 0x80B4E938:("D_80B4E938","f32","",0x4), 0x80B4E940:("D_80B4E940","UNK_TYPE4","",0x4), - 0x80B4E944:("sRomaniEyeTextures","UNK_TYPE4","",0x4), - 0x80B4E958:("sRomaniMouthTextures","UNK_TYPE4","",0x4), + 0x80B4E944:("D_80B4E944","UNK_TYPE4","",0x4), + 0x80B4E958:("D_80B4E958","UNK_TYPE4","",0x4), 0x80B4E968:("D_80B4E968","UNK_TYPE1","",0x1), - 0x80B4E96C:("sCremiaEyeTextures","UNK_TYPE4","",0x4), - 0x80B4E984:("sCremiaMouthTextures","UNK_TYPE4","",0x4), + 0x80B4E96C:("D_80B4E96C","UNK_TYPE4","",0x4), + 0x80B4E984:("D_80B4E984","UNK_TYPE4","",0x4), 0x80B4E994:("D_80B4E994","UNK_TYPE1","",0x1), 0x80B4E998:("D_80B4E998","UNK_TYPE1","",0x1), 0x80B4E99C:("D_80B4E99C","UNK_TYPE1","",0x1), @@ -14402,6 +14381,21 @@ 0x80B4EE0C:("D_80B4EE0C","UNK_TYPE1","",0x1), 0x80B4EE24:("D_80B4EE24","UNK_TYPE1","",0x1), 0x80B4EE30:("D_80B4EE30","UNK_TYPE1","",0x1), + 0x80B4EE40:("D_80B4EE40","f32","",0x4), + 0x80B4EE44:("D_80B4EE44","f32","",0x4), + 0x80B4EE48:("D_80B4EE48","f32","",0x4), + 0x80B4EE4C:("D_80B4EE4C","f32","",0x4), + 0x80B4EE50:("D_80B4EE50","f32","",0x4), + 0x80B4EE54:("D_80B4EE54","f32","",0x4), + 0x80B4EE58:("D_80B4EE58","f32","",0x4), + 0x80B4EE5C:("D_80B4EE5C","f32","",0x4), + 0x80B4EE60:("D_80B4EE60","f32","",0x4), + 0x80B4EE64:("D_80B4EE64","f32","",0x4), + 0x80B4EE68:("D_80B4EE68","f32","",0x4), + 0x80B4EE6C:("D_80B4EE6C","f32","",0x4), + 0x80B4EE70:("D_80B4EE70","f32","",0x4), + 0x80B4EE74:("D_80B4EE74","f32","",0x4), + 0x80B4EE78:("D_80B4EE78","f32","",0x4), 0x80B4EE7C:("D_80B4EE7C","f32","",0x4), 0x80B4EE80:("D_80B4EE80","f32","",0x4), 0x80B4EE84:("D_80B4EE84","f32","",0x4), @@ -14542,8 +14536,8 @@ 0x80B503F0:("D_80B503F0","UNK_TYPE4","",0x4), 0x80B503F4:("D_80B503F4","UNK_TYPE4","",0x4), 0x80B503F8:("D_80B503F8","UNK_TYPE4","",0x4), - 0x80B503FC:("sAlienEyeBeamTexAnim","UNK_TYPE4","",0x4), - 0x80B50400:("sAlienEmptyTexAnim","UNK_TYPE4","",0x4), + 0x80B503FC:("D_80B503FC","UNK_TYPE4","",0x4), + 0x80B50400:("D_80B50400","UNK_TYPE4","",0x4), 0x80B50404:("D_80B50404","UNK_TYPE2","",0x2), 0x80B50406:("D_80B50406","UNK_TYPE2","",0x2), 0x80B5040A:("D_80B5040A","UNK_TYPE1","",0x1), @@ -15163,27 +15157,27 @@ 0x80B8ADB0:("D_80B8ADB0","f32","",0x4), 0x80B8ADB4:("D_80B8ADB4","f32","",0x4), 0x80B8CE20:("En_Ge2_InitVars","UNK_TYPE1","",0x1), - 0x80B8CE40:("D_80B8CE40","UNK_TYPE1","",0x1), - 0x80B8CE6C:("D_80B8CE6C","UNK_TYPE1","",0x1), - 0x80B8CE78:("D_80B8CE78","UNK_TYPE1","",0x1), - 0x80B8CE84:("D_80B8CE84","UNK_TYPE1","",0x1), - 0x80B8CE88:("D_80B8CE88","UNK_TYPE1","",0x1), - 0x80B8CE8C:("D_80B8CE8C","UNK_TYPE1","",0x1), - 0x80B8CE98:("D_80B8CE98","UNK_TYPE1","",0x1), + 0x80B8CE40:("sCylinderInit","ColliderCylinderInit","",0x2C), + 0x80B8CE6C:("effectVelocity","Vec3f","",0xC), + 0x80B8CE78:("effectAccel","Vec3f","",0xC), + 0x80B8CE84:("effectPrimColor","Color_RGBA8","",0x4), + 0x80B8CE88:("effectEnvColor","Color_RGBA8","",0x4), + 0x80B8CE8C:("sFocusOffset","Vec3f","",0x1), + 0x80B8CE98:("sEyeTextures","TexturePtr","[3]",0xC), 0x80B8CEB0:("jtbl_80B8CEB0","UNK_PTR","",0x4), 0x80B8E150:("En_Ma_Yts_InitVars","UNK_TYPE1","",0x1), 0x80B8E170:("D_80B8E170","ColliderCylinderInit","",0x2C), 0x80B8E19C:("D_80B8E19C","CollisionCheckInfoInit2","",0xC), 0x80B8E308:("D_80B8E308","void*","",0x4), 0x80B8E318:("D_80B8E318","UNK_TYPE1","",0x1), - 0x80B8E32C:("D_80B8E32C","UNK_TYPE2","",0x2), + 0x80B8E32C:("sCueId","UNK_TYPE2","",0x2), 0x80B8E330:("jtbl_80B8E330","UNK_PTR","",0x4), 0x80B8E34C:("jtbl_80B8E34C","UNK_PTR","",0x4), 0x80B913F0:("En_Ma_Yto_InitVars","UNK_TYPE1","",0x1), 0x80B91410:("D_80B91410","UNK_TYPE1","",0x1), 0x80B9143C:("D_80B9143C","UNK_TYPE1","",0x1), 0x80B91448:("D_80B91448","UNK_TYPE1","",0x1), - 0x80B915F0:("D_80B915F0","UNK_TYPE2","",0x2), + 0x80B915F0:("sCueId","UNK_TYPE2","",0x2), 0x80B91600:("jtbl_80B91600","UNK_PTR","",0x4), 0x80B91614:("jtbl_80B91614","UNK_PTR","",0x4), 0x80B91628:("jtbl_80B91628","UNK_PTR","",0x4), @@ -16571,7 +16565,7 @@ 0x80C1E984:("D_80C1E984","UNK_TYPE1","",0x1), 0x80C1F150:("Dm_Bal_InitVars","UNK_TYPE1","",0x1), 0x80C1F170:("sAnimationInfo","UNK_PTR","",0x4), - 0x80C1F2C0:("D_80C1F2C0","UNK_TYPE2","",0x2), + 0x80C1F2C0:("sCueId","UNK_TYPE2","",0x2), 0x80C1F2C4:("D_80C1F2C4","UNK_TYPE4","",0x4), 0x80C1F2D0:("D_80C1F2D0","UNK_TYPE1","",0x1), 0x80C1F2E0:("D_80C1F2E0","f32","",0x4), diff --git a/tools/fado/.gitrepo b/tools/fado/.gitrepo index cedec4930..042b904f1 100644 --- a/tools/fado/.gitrepo +++ b/tools/fado/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = git@github.com:EllipticEllipsis/fado.git branch = master - commit = f7efb10a9a65f27e9ccad7ce270234f20d386ac9 - parent = 90cfafec47fe4b73ad9009e9501e147e86025aa6 + commit = 8d896ee97d565508755584803c409fc33bb0c953 + parent = b51c9f4d22d6e7db63700c163418654431a2a61a method = merge cmdver = 0.4.3 diff --git a/tools/fado/lib/vc_vector/vc_vector.c b/tools/fado/lib/vc_vector/vc_vector.c index 3f677c242..426f1b0cb 100644 --- a/tools/fado/lib/vc_vector/vc_vector.c +++ b/tools/fado/lib/vc_vector/vc_vector.c @@ -112,15 +112,15 @@ bool vc_vector_is_equals(vc_vector* vector1, vc_vector* vector2) { return memcmp(vector1->data, vector2->data, size_vector1) == 0; } -float vc_vector_get_growth_factor() { +float vc_vector_get_growth_factor(void) { return GROWTH_FACTOR; } -size_t vc_vector_get_default_count_of_elements() { +size_t vc_vector_get_default_count_of_elements(void) { return DEFAULT_COUNT_OF_ELEMENTS; } -size_t vc_vector_struct_size() { +size_t vc_vector_struct_size(void) { return sizeof(vc_vector); } diff --git a/tools/fado/lib/vc_vector/vc_vector.h b/tools/fado/lib/vc_vector/vc_vector.h index 2b1422c1a..e57f83254 100644 --- a/tools/fado/lib/vc_vector/vc_vector.h +++ b/tools/fado/lib/vc_vector/vc_vector.h @@ -24,13 +24,13 @@ void vc_vector_release(vc_vector* vector); bool vc_vector_is_equals(vc_vector* vector1, vc_vector* vector2); // Returns constant value of the vector growth factor. -float vc_vector_get_growth_factor(); +float vc_vector_get_growth_factor(void); // Returns constant value of the vector default count of elements. -size_t vc_vector_get_default_count_of_elements(); +size_t vc_vector_get_default_count_of_elements(void); // Returns constant value of the vector struct size. -size_t vc_vector_struct_size(); +size_t vc_vector_struct_size(void); // ---------------------------------------------------------------------------- // Element access diff --git a/tools/fado/src/main.c b/tools/fado/src/main.c index c6af79025..e6b7926d6 100644 --- a/tools/fado/src/main.c +++ b/tools/fado/src/main.c @@ -15,7 +15,7 @@ #include "version.inc" -void PrintVersion() { +void PrintVersion(void) { printf("Fado (Fairy-Assisted relocations for Decompiled Overlays), version %s\n", versionNumber); printf("Copyright (C) 2021 Elliptic Ellipsis\n"); printf("%s\n", credits); @@ -88,7 +88,7 @@ static size_t posArgCount = ARRAY_COUNT(posArgInfo); static size_t optCount = ARRAY_COUNT(optInfo); static struct option longOptions[ARRAY_COUNT(optInfo)]; -void ConstructLongOpts() { +void ConstructLongOpts(void) { size_t i; for (i = 0; i < optCount; i++) { diff --git a/tools/fixbaserom.py b/tools/fixbaserom.py index 2c3942160..3966c3533 100755 --- a/tools/fixbaserom.py +++ b/tools/fixbaserom.py @@ -122,6 +122,7 @@ def decompress_rom(dmadata_addr, dmadata): # re-calculate crc return update_crc(decompressed) +correct_compressed_str_hash = "2a0a8acb61538235bc1094d297fb6556" correct_str_hash = "f46493eaa0628827dbd6ad3ecd8d65d6" def get_str_hash(byte_array): @@ -179,6 +180,13 @@ elif fileContent[0] == 0x37: print("Byte swapping done.") +# Check to see if the ROM is a compressed "vanilla" ROM +compressed_str_hash = get_str_hash(bytearray(fileContent)) +if compressed_str_hash != correct_compressed_str_hash: + print("Error: Expected a hash of " + correct_compressed_str_hash + " but got " + compressed_str_hash + ". " + + "The baserom has probably been tampered, find a new one") + sys.exit(1) + # Decompress FILE_TABLE_OFFSET = 0x1A500 # 0x1C110 for JP1.0, 0x1C050 for JP1.1, 0x24F60 for debug if any([b != 0 for b in fileContent[FILE_TABLE_OFFSET + 0x9C:FILE_TABLE_OFFSET + 0x9C + 0x4]]): diff --git a/tools/graphovl/.gitrepo b/tools/graphovl/.gitrepo index 064b8ee58..ca544b885 100644 --- a/tools/graphovl/.gitrepo +++ b/tools/graphovl/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/AngheloAlf/graphovl.git branch = master - commit = f5fe93d75bb75ea4bea65f62c43f41f6a1e70679 - parent = 6c5a50ef95f351acc7c4c0455a347a94443adbe1 + commit = dab4addae0c5db6274ab5daf7780c62c346120a1 + parent = 5da1ae553569ddb0016d302cfac8c45d9cb22e73 method = merge cmdver = 0.4.3 diff --git a/tools/graphovl/graphovl.py b/tools/graphovl/graphovl.py index 28f0a361c..7cb7af2c5 100755 --- a/tools/graphovl/graphovl.py +++ b/tools/graphovl/graphovl.py @@ -18,7 +18,7 @@ except ModuleNotFoundError: script_dir = os.path.dirname(os.path.realpath(__file__)) config = ConfigParser() -func_names = None +func_names = list() func_definitions = list() line_numbers_of_functions = list() @@ -72,6 +72,19 @@ def capture_setupaction_call_arg(content): transitionList.append(func) return transitionList +setaction_regexpr = re.compile(r"_SetAction+\([^\)]*\)(\.[^\)]*\))?;") + +def capture_setaction_calls(content): + return [x.group() for x in re.finditer(setaction_regexpr, content)] + +def capture_setaction_call_arg(content): + transitionList = [] + for x in re.finditer(setaction_regexpr, content): + func = x.group().split(",")[2].strip().split(");")[0].strip() + if func not in transitionList: + transitionList.append(func) + return transitionList + # Search for the function definition by supplied function name def definition_by_name(content, name): for definition in capture_definitions(content): @@ -206,7 +219,11 @@ def addFunctionTransitionToGraph(dot, index: int, func_name: str, action_transit fontColor = config.get("colors", "fontcolor") bubbleColor = config.get("colors", "bubbleColor") indexStr = str(index) - funcIndex = str(index_of_func(action_transition)) + try: + funcIndex = str(index_of_func(action_transition)) + except ValueError: + print(f"Warning: function '{action_transition}' called by '{func_name}' was not found. Skiping...", file=sys.stderr) + return dot.node(indexStr, func_name, fontcolor=fontColor, color=bubbleColor) dot.node(funcIndex, action_transition, fontcolor=fontColor, color=bubbleColor) @@ -230,7 +247,7 @@ def addCallNamesToGraph(dot, func_names: list, index: int, code_body: str, remov if call in removeList: continue - if setupAction and "_SetupAction" in call: + if setupAction and ("_SetupAction" in call or "_SetAction" in call): continue seen.add(call) @@ -342,10 +359,11 @@ def main(): actionIdentifier = "this->actionFunc" setupAction = func_prefix + "_SetupAction" in func_names + setAction = func_prefix + "_SetAction" in func_names arrayActorFunc = match_obj is not None rawActorFunc = actionIdentifier in contents - if not setupAction and not arrayActorFunc and not rawActorFunc: + if not setupAction and not setAction and not arrayActorFunc and not rawActorFunc: print("No actor action-based structure found") os._exit(1) @@ -383,6 +401,8 @@ def main(): Create all edges for SetupAction-based actors """ transitionList = capture_setupaction_call_arg(code_body) + elif setAction: + transitionList = capture_setaction_call_arg(code_body) elif arrayActorFunc: """ Create all edges for ActorFunc array-based actors diff --git a/tools/ido_recomp/linux/5.3/as0 b/tools/ido_recomp/linux/5.3/as0 index 15c169107..cdac712e5 100755 Binary files a/tools/ido_recomp/linux/5.3/as0 and b/tools/ido_recomp/linux/5.3/as0 differ diff --git a/tools/ido_recomp/linux/5.3/as1 b/tools/ido_recomp/linux/5.3/as1 index 1a24f18b2..f89911f80 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 65f0d1b2d..be5bed557 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 cbb4f9d44..c257f65a6 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 119d2817b..d356300bf 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 index 4091986a8..5a3162799 100755 Binary files a/tools/ido_recomp/linux/5.3/ujoin 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 index 653ff37df..a65a2239b 100755 Binary files a/tools/ido_recomp/linux/5.3/uld 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 index 4b00ffa36..36fa5ac6e 100755 Binary files a/tools/ido_recomp/linux/5.3/umerge 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 d5ba32fbd..f44642087 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 index 17d9d3d5d..5aa4151ed 100755 Binary files a/tools/ido_recomp/linux/5.3/usplit and b/tools/ido_recomp/linux/5.3/usplit differ diff --git a/tools/ido_recomp/linux/7.1/as0 b/tools/ido_recomp/linux/7.1/as0 index e9ef71c63..1a69a14a5 100755 Binary files a/tools/ido_recomp/linux/7.1/as0 and b/tools/ido_recomp/linux/7.1/as0 differ diff --git a/tools/ido_recomp/linux/7.1/as1 b/tools/ido_recomp/linux/7.1/as1 index 475079063..047cfdd7f 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 6c68698f3..61c43ede1 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 2b52669de..75235c112 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 340a282c9..32d8d0be6 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/ujoin b/tools/ido_recomp/linux/7.1/ujoin index 3752698d8..49b35ba6a 100755 Binary files a/tools/ido_recomp/linux/7.1/ujoin and b/tools/ido_recomp/linux/7.1/ujoin differ diff --git a/tools/ido_recomp/linux/7.1/uld b/tools/ido_recomp/linux/7.1/uld index 2b76d0c18..756d30cd4 100755 Binary files a/tools/ido_recomp/linux/7.1/uld and b/tools/ido_recomp/linux/7.1/uld differ diff --git a/tools/ido_recomp/linux/7.1/umerge b/tools/ido_recomp/linux/7.1/umerge index 03d68a8f2..569e56e76 100755 Binary files a/tools/ido_recomp/linux/7.1/umerge 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 feef7f749..349d1d6ff 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/linux/7.1/usplit b/tools/ido_recomp/linux/7.1/usplit index 090200ab5..563c5f8a2 100755 Binary files a/tools/ido_recomp/linux/7.1/usplit and b/tools/ido_recomp/linux/7.1/usplit differ diff --git a/tools/ido_recomp/macos/5.3/as0 b/tools/ido_recomp/macos/5.3/as0 index 46e69e09b..1d2b7a725 100755 Binary files a/tools/ido_recomp/macos/5.3/as0 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 f723cc5c1..44fada1c5 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 d583c6b5b..9e3c8f8c9 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 92f76465a..86d98c79d 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/ugen b/tools/ido_recomp/macos/5.3/ugen index 7be477312..add44a34d 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 index e69611f41..5e7ed4789 100755 Binary files a/tools/ido_recomp/macos/5.3/ujoin 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 index 2bcce1cd6..64fc3899c 100755 Binary files a/tools/ido_recomp/macos/5.3/uld 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 index 7fdf06e8d..c66ef9f2f 100755 Binary files a/tools/ido_recomp/macos/5.3/umerge 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 e9b8cbe62..0872f9c17 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 index cb28e320c..2a7c35188 100755 Binary files a/tools/ido_recomp/macos/5.3/usplit and b/tools/ido_recomp/macos/5.3/usplit differ diff --git a/tools/ido_recomp/macos/7.1/as0 b/tools/ido_recomp/macos/7.1/as0 index cdb4f9121..9a2fd2f0a 100755 Binary files a/tools/ido_recomp/macos/7.1/as0 and b/tools/ido_recomp/macos/7.1/as0 differ diff --git a/tools/ido_recomp/macos/7.1/as1 b/tools/ido_recomp/macos/7.1/as1 index 93370b495..e91f7d1a2 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 96d45690b..b487956f2 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 a9f0b56fc..f86fc3743 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/ugen b/tools/ido_recomp/macos/7.1/ugen index 801337b48..1e9839b4e 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/ujoin b/tools/ido_recomp/macos/7.1/ujoin index 620e624f0..d2512e934 100755 Binary files a/tools/ido_recomp/macos/7.1/ujoin and b/tools/ido_recomp/macos/7.1/ujoin differ diff --git a/tools/ido_recomp/macos/7.1/uld b/tools/ido_recomp/macos/7.1/uld index a7826480f..a746a8236 100755 Binary files a/tools/ido_recomp/macos/7.1/uld and b/tools/ido_recomp/macos/7.1/uld differ diff --git a/tools/ido_recomp/macos/7.1/umerge b/tools/ido_recomp/macos/7.1/umerge index 0f1978051..a561c0801 100755 Binary files a/tools/ido_recomp/macos/7.1/umerge 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 528151499..30817f201 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/ido_recomp/macos/7.1/usplit b/tools/ido_recomp/macos/7.1/usplit index cc539bdb1..247279453 100755 Binary files a/tools/ido_recomp/macos/7.1/usplit and b/tools/ido_recomp/macos/7.1/usplit differ diff --git a/tools/ido_recomp/windows/5.3/as0.exe b/tools/ido_recomp/windows/5.3/as0.exe index 10c16ca69..0c4926085 100755 Binary files a/tools/ido_recomp/windows/5.3/as0.exe and b/tools/ido_recomp/windows/5.3/as0.exe differ diff --git a/tools/ido_recomp/windows/5.3/as1.exe b/tools/ido_recomp/windows/5.3/as1.exe index 0ddac02bb..2d79cc536 100755 Binary files a/tools/ido_recomp/windows/5.3/as1.exe and b/tools/ido_recomp/windows/5.3/as1.exe differ diff --git a/tools/ido_recomp/windows/5.3/cc.exe b/tools/ido_recomp/windows/5.3/cc.exe index fdbaea21d..7c08eac81 100755 Binary files a/tools/ido_recomp/windows/5.3/cc.exe and b/tools/ido_recomp/windows/5.3/cc.exe differ diff --git a/tools/ido_recomp/windows/5.3/cfe.exe b/tools/ido_recomp/windows/5.3/cfe.exe index abe1063c6..2f5de5f18 100755 Binary files a/tools/ido_recomp/windows/5.3/cfe.exe and b/tools/ido_recomp/windows/5.3/cfe.exe differ diff --git a/tools/ido_recomp/windows/5.3/ugen.exe b/tools/ido_recomp/windows/5.3/ugen.exe index be08a43c9..0f919c234 100755 Binary files a/tools/ido_recomp/windows/5.3/ugen.exe and b/tools/ido_recomp/windows/5.3/ugen.exe differ diff --git a/tools/ido_recomp/windows/5.3/ujoin.exe b/tools/ido_recomp/windows/5.3/ujoin.exe index b01b5c335..f1397ee0c 100755 Binary files a/tools/ido_recomp/windows/5.3/ujoin.exe and b/tools/ido_recomp/windows/5.3/ujoin.exe differ diff --git a/tools/ido_recomp/windows/5.3/uld.exe b/tools/ido_recomp/windows/5.3/uld.exe index 34cad1400..d415d9ba0 100755 Binary files a/tools/ido_recomp/windows/5.3/uld.exe and b/tools/ido_recomp/windows/5.3/uld.exe differ diff --git a/tools/ido_recomp/windows/5.3/umerge.exe b/tools/ido_recomp/windows/5.3/umerge.exe index 3ce31e0cb..23bf7b251 100755 Binary files a/tools/ido_recomp/windows/5.3/umerge.exe and b/tools/ido_recomp/windows/5.3/umerge.exe differ diff --git a/tools/ido_recomp/windows/5.3/uopt.exe b/tools/ido_recomp/windows/5.3/uopt.exe index c1fb98c0d..248beabc7 100755 Binary files a/tools/ido_recomp/windows/5.3/uopt.exe and b/tools/ido_recomp/windows/5.3/uopt.exe differ diff --git a/tools/ido_recomp/windows/5.3/usplit.exe b/tools/ido_recomp/windows/5.3/usplit.exe index d179f1e13..6ac2a6382 100755 Binary files a/tools/ido_recomp/windows/5.3/usplit.exe and b/tools/ido_recomp/windows/5.3/usplit.exe differ diff --git a/tools/ido_recomp/windows/7.1/as0.exe b/tools/ido_recomp/windows/7.1/as0.exe index 1a375d73e..346827a49 100755 Binary files a/tools/ido_recomp/windows/7.1/as0.exe and b/tools/ido_recomp/windows/7.1/as0.exe differ diff --git a/tools/ido_recomp/windows/7.1/as1.exe b/tools/ido_recomp/windows/7.1/as1.exe index 4778d2db6..7076875b9 100755 Binary files a/tools/ido_recomp/windows/7.1/as1.exe and b/tools/ido_recomp/windows/7.1/as1.exe differ diff --git a/tools/ido_recomp/windows/7.1/cc.exe b/tools/ido_recomp/windows/7.1/cc.exe index 887b7cc49..53bf83433 100755 Binary files a/tools/ido_recomp/windows/7.1/cc.exe and b/tools/ido_recomp/windows/7.1/cc.exe differ diff --git a/tools/ido_recomp/windows/7.1/cfe.exe b/tools/ido_recomp/windows/7.1/cfe.exe index 6f5fd9e8d..0286c3fa5 100755 Binary files a/tools/ido_recomp/windows/7.1/cfe.exe and b/tools/ido_recomp/windows/7.1/cfe.exe differ diff --git a/tools/ido_recomp/windows/7.1/ugen.exe b/tools/ido_recomp/windows/7.1/ugen.exe index fcc03538c..30577e396 100755 Binary files a/tools/ido_recomp/windows/7.1/ugen.exe and b/tools/ido_recomp/windows/7.1/ugen.exe differ diff --git a/tools/ido_recomp/windows/7.1/ujoin.exe b/tools/ido_recomp/windows/7.1/ujoin.exe index 9fb3a3f4f..18fc825bc 100755 Binary files a/tools/ido_recomp/windows/7.1/ujoin.exe and b/tools/ido_recomp/windows/7.1/ujoin.exe differ diff --git a/tools/ido_recomp/windows/7.1/uld.exe b/tools/ido_recomp/windows/7.1/uld.exe index 4a0cc8fe2..a0bb88593 100755 Binary files a/tools/ido_recomp/windows/7.1/uld.exe and b/tools/ido_recomp/windows/7.1/uld.exe differ diff --git a/tools/ido_recomp/windows/7.1/umerge.exe b/tools/ido_recomp/windows/7.1/umerge.exe index 7cc0b1be6..3e6698ada 100755 Binary files a/tools/ido_recomp/windows/7.1/umerge.exe and b/tools/ido_recomp/windows/7.1/umerge.exe differ diff --git a/tools/ido_recomp/windows/7.1/uopt.exe b/tools/ido_recomp/windows/7.1/uopt.exe index 4fbd1ab57..ae714d528 100755 Binary files a/tools/ido_recomp/windows/7.1/uopt.exe and b/tools/ido_recomp/windows/7.1/uopt.exe differ diff --git a/tools/ido_recomp/windows/7.1/usplit.exe b/tools/ido_recomp/windows/7.1/usplit.exe index 5c0da6fe6..f61837d0f 100755 Binary files a/tools/ido_recomp/windows/7.1/usplit.exe and b/tools/ido_recomp/windows/7.1/usplit.exe differ diff --git a/tools/m2ctx.py b/tools/m2ctx.py index 0824899f1..23875eef0 100755 --- a/tools/m2ctx.py +++ b/tools/m2ctx.py @@ -1,14 +1,39 @@ #!/usr/bin/env python3 -import argparse, os, subprocess, sys +import argparse +import os +import sys +import subprocess +import tempfile from pathlib import Path -script_dir = os.path.dirname(os.path.realpath(__file__)) -root_dir = script_dir + "/../" -src_dir = root_dir + "src/" +script_dir = Path(os.path.dirname(os.path.realpath(__file__))) +root_dir = script_dir / ".." +src_dir = root_dir / "src" + +# Project-specific +CPP_FLAGS = [ + "-Iinclude", + "-Isrc", + "-Iassets", + "-Ibuild", + "-I.", + + "-D__sgi", + "-D_LANGUAGE_C", + "-DNON_MATCHING", + "-D_Static_assert(x, y)=", + "-D__attribute__(x)=" + "-D_MIPS_SZLONG=32", + "-ffreestanding", + "-DM2CTX", + + "-std=gnu89", +] # Read through the processes context and replace whatever def custom_replacements(output): + actorList = [] output = output.splitlines() i = 0 @@ -36,7 +61,6 @@ def custom_replacements(output): "door", "chest", ] - actorList = [] for x in range(12): actorList.append(actorListText.replace("first;", f"{actorCats[x]};") + "\n") if x == 2: @@ -48,63 +72,55 @@ def custom_replacements(output): i += 1 return "\n".join(output) -def get_c_dir(dirname): - for root, dirs, files in os.walk(src_dir): - for directory in dirs: - if directory == dirname: - return os.path.join(root, directory) - - -def get_c_file(directory): - for root, dirs, files in os.walk(directory): - for file in files: - if file.endswith(".c") and "data" not in file: - return file - - -def import_c_file(in_file): +def import_c_file(in_file) -> str: in_file = os.path.relpath(in_file, root_dir) - cpp_command = ["gcc", "-E", "-P", "-Iinclude", "-Iassets", "-Isrc", "-undef", "-D__sgi", "-D_LANGUAGE_C", - "-DNON_MATCHING", "-D_Static_assert(x, y)=", "-D__attribute__(x)=", in_file] + + cpp_command = ["gcc", "-E", "-P", "-undef", "-dM", *CPP_FLAGS, in_file] + cpp_command2 = ["gcc", "-E", "-P", "-undef", *CPP_FLAGS, in_file] + + with tempfile.NamedTemporaryFile(suffix=".c") as tmp: + stock_macros = subprocess.check_output(["gcc", "-E", "-P", "-undef", "-dM", tmp.name], cwd=root_dir, encoding="utf-8") + + out_text = "" try: - return subprocess.check_output(cpp_command, cwd=root_dir, encoding="utf-8") + out_text += subprocess.check_output(cpp_command, cwd=root_dir, encoding="utf-8") + out_text += subprocess.check_output(cpp_command2, cwd=root_dir, encoding="utf-8") except subprocess.CalledProcessError: print( "Failed to preprocess input file, when running command:\n" - + cpp_command, + + " ".join(cpp_command), file=sys.stderr, - ) + ) sys.exit(1) + if not out_text: + print("Output is empty - aborting") + sys.exit(1) + + for line in stock_macros.strip().splitlines(): + out_text = out_text.replace(line + "\n", "") + return out_text + def main(): parser = argparse.ArgumentParser(usage="./m2ctx.py path/to/file.c or ./m2ctx.py (from an actor or gamestate's asm dir)", - description="Creates a ctx.c file for mips2c. " - "Output will be saved as oot/ctx.c") + description="Creates a ctx.c file for m2c or decomp.me. " + "Output will be saved as ctx.c") parser.add_argument('filepath', help="path of c file to be processed") - parser.add_argument("--custom", "-c", dest="custom", action="store_true", default=False, - help="Apply custom replacements to the output to help aid m2c output") + parser.add_argument("--custom", "-c", dest="custom", action="store_true", default=False, + help="Apply custom replacements to the output to help aid m2c output") args = parser.parse_args() - if args.filepath: - c_file_path = args.filepath - print("Using file: {}".format(c_file_path)) - else: - this_dir = Path.cwd() - c_dir_path = get_c_dir(this_dir.name) - if c_dir_path is None: - sys.exit( - "Cannot find appropriate c file dir. In argumentless mode, run this script from the c file's corresponding asm dir.") - c_file = get_c_file(c_dir_path) - c_file_path = os.path.join(c_dir_path, c_file) - print("Using file: {}".format(c_file_path)) + c_file_path = args.filepath + print("Using file: {}".format(c_file_path)) output = import_c_file(c_file_path) if args.custom: output = custom_replacements(output) - with open(os.path.join(root_dir, "ctx.c"), "w", encoding="UTF-8") as f: + ctxPath = root_dir / "ctx.c" + with ctxPath.open("w", encoding="UTF-8") as f: f.write(output) diff --git a/tools/namefixer.py b/tools/namefixer.py index 198116315..a03cc06cf 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -18,7 +18,7 @@ simpleReplace = { wordReplace = { # Functions "Actor_GetSwitchFlag": "Flags_GetSwitch", - "Math_FAtan2F(": "Math_Atan2S_XY(", + # "Math_FAtan2F": "Math_Atan2S_XY", // All old Math_FAtan2F should be renamed, so func_80086B30 can be renamed to Math_FAtan2F "Math_Acot2F": "Math_Atan2F_XY", "atan_flip": "Math_Atan2F_XY", "atans": "Math_Atan2S", @@ -117,6 +117,23 @@ wordReplace = { "Actor_MarkForDeath": "Actor_Kill", "func_800B84D0": "Actor_ProcessTalkRequest", "func_8017D668": "Math3D_PointDistToLine2D", + + "THGA_GetSize": "THGA_GetRemaining", + "THGA_AllocStartArray8": "THGA_AllocDisplayList", + "THGA_AllocStart8": "THGA_AllocGfx", + "THGA_AllocStart8Wrapper": "THGA_AllocGfx2", + "THGA_AllocEnd": "THGA_AllocTail", + "THGA_AllocEndArray64": "THGA_AllocMtxArray", + "THGA_AllocEnd64": "THGA_AllocMtx", + "THGA_AllocEndArray16": "THGA_AllocVtxArray", + "THGA_AllocEnd16": "THGA_AllocVtx", + "THA_AllocStart": "THA_AllocHead", + "THA_AllocStart1": "THA_AllocHeadByte", + "THA_AllocEnd": "THA_AllocTail", + "THA_AllocEndAlign16": "THA_AllocTailAlign16", + "THA_AllocEndAlign": "THA_AllocTailAlign", + "THA_GetSize": "THA_GetRemaining", + "func_800BDFC0": "Gfx_DrawDListOpa", "func_800BE03C": "Gfx_DrawDListXlu", "func_800B6FC8": "Player_GetHeight", @@ -137,6 +154,20 @@ wordReplace = { "func_800B8214": "Actor_GetWorld", "func_800B8248": "Actor_GetWorldPosShapeRot", "func_800BE22C": "Actor_ApplyDamage", + "Actor_YawBetweenActors": "Actor_WorldYawTowardActor", + "Actor_YawBetweenActorsTop": "Actor_FocusYawTowardActor", + "Actor_YawToPoint": "Actor_WorldYawTowardPoint", + "Actor_PitchBetweenActors": "Actor_WorldPitchTowardActor", + "Actor_PitchBetweenActorsTop": "Actor_FocusPitchTowardActor", + "Actor_PitchToPoint": "Actor_WorldPitchTowardPoint", + "Actor_DistanceBetweenActors": "Actor_WorldDistXYZToActor", + "Actor_DistanceToPoint": "Actor_WorldDistXYZToPoint", + "Actor_XZDistanceBetweenActors": "Actor_WorldDistXZToActor", + "Actor_XZDistanceToPoint": "Actor_WorldDistXZToPoint", + "func_800B6468": "Actor_InitPlayerImpact", + "func_800B6474": "Actor_UpdatePlayerImpact", + "func_800B648C": "Actor_SetPlayerImpact", + "func_800B64FC": "Actor_GetPlayerImpact", "Audio_PlaySoundAtPosition": "SoundSource_PlaySfxAtFixedWorldPos", "func_800F0590": "SoundSource_PlaySfxEachFrameAtFixedWorldPos", "func_8016970C": "Play_SetCameraAtEye", @@ -144,14 +175,19 @@ wordReplace = { "func_800BBA88": "Enemy_StartFinishingBlow", "ShrinkWindow_Step": "ShrinkWindow_Update", "ShrinkWindow_Fini": "ShrinkWindow_Destroy", - "func_801A89A8": "Audio_QueueSeqCmd", + "func_801A89A8": "AudioSeq_QueueSeqCmd", + "Audio_QueueSeqCmd": "AudioSeq_QueueSeqCmd", + "func_801A0238": "Audio_SetMainBgmVolume", + "func_801A2C20": "Audio_StopSubBgm", + "func_801A2BB8": "Audio_PlaySubBgm", "func_8019F1C0": "Audio_PlaySfxAtPos", "func_801A5BD0": "AudioSfx_MuteBanks", "func_801A72CC": "AudioSfx_StopByPos", "Audio_StopSfxByPos": "AudioSfx_StopByPos", "Audio_StopSfxById": "AudioSfx_StopById", "func_801A3098": "Audio_PlayFanfare", - "func_801A8A50": "Audio_GetActiveSequence", + "func_801A8A50": "AudioSeq_GetActiveSeqId", + "Audio_GetActiveSequence": "AudioSeq_GetActiveSeqId", "func_801A2E54": "Audio_PlayBgm_StorePrevBgm", "func_801A2ED8": "Audio_RestorePrevBgm", "func_801A2544": "Audio_PlayMorningSceneSequence", @@ -163,72 +199,50 @@ wordReplace = { "func_801A4A28": "Audio_PlayAmbience", "func_801A7328": "AudioSfx_StopByPosAndId", "func_801A75E8": "AudioSfx_StopById", - "SkelAnime_LodDrawLimb": "SkelAnime_DrawLimbLod", "SkelAnime_LodDraw": "SkelAnime_DrawLod", - "SkelAnime_LodDrawLimbSV": "SkelAnime_DrawFlexLimbLod", "SkelAnime_LodDrawSV": "SkelAnime_DrawFlexLod", - # "SkelAnime_DrawLimb": "SkelAnime_DrawLimbOpa", # A different function is called this now # "SkelAnime_Draw": "SkelAnime_DrawOpa", # A different function is called this now "SkelAnime_DrawLimbSV": "SkelAnime_DrawFlexLimbOpa", "SkelAnime_DrawSV": "SkelAnime_DrawFlexOpa", # "SkelAnime_AnimateFrame": "SkelAnime_GetFrameData", # A different function is called this now - "SkelAnime_GetTotalFrames": "Animation_GetLength", "SkelAnime_GetFrameCount": "Animation_GetLastFrame", - "SkelAnime_Draw2Limb": "SkelAnime_DrawLimb", "SkelAnime_Draw2": "SkelAnime_Draw", - "SkelAnime_DrawLimbSV2": "SkelAnime_DrawFlexLimb", "SkelAnime_DrawSV2": "SkelAnime_DrawFlex", - "func_80134FFC": "SkelAnime_GetFrameData2", - "func_801353D4": "Animation_GetLimbCount2", - "SkelAnime_GetTotalFrames2": "Animation_GetLength2", - "SkelAnime_GetFrameCount2": "Animation_GetLastFrame2", - "SkelAnime_InterpolateVec3s": "SkelAnime_InterpFrameTable", "SkelAnime_AnimationCtxReset": "AnimationContext_Reset", "func_801358D4": "AnimationContext_SetNextQueue", "func_801358F4": "AnimationContext_DisableQueue", - "SkelAnime_NextEntry": "AnimationContext_AddEntry", "SkelAnime_LoadLinkAnimetion": "AnimationContext_SetLoadFrame", - "SkelAnime_LoadAnimationType1": "AnimationContext_SetCopyAll", - "SkelAnime_LoadAnimationType2": "AnimationContext_SetInterp", - "SkelAnime_LoadAnimationType3": "AnimationContext_SetCopyTrue", - "SkelAnime_LoadAnimationType4": "AnimationContext_SetCopyFalse", - "SkelAnime_LoadAnimationType5": "AnimationContext_SetMoveActor", - "SkelAnime_LinkAnimetionLoaded": "AnimationContext_LoadFrame", + "SkelAnime_AnimationType1Loaded": "AnimationContext_CopyAll", "SkelAnime_AnimationType2Loaded": "AnimationContext_CopyInterp", "SkelAnime_AnimationType3Loaded": "AnimationContext_CopyTrue", "SkelAnime_AnimationType4Loaded": "AnimationContext_CopyFalse", "SkelAnime_AnimationType5Loaded": "AnimationContext_MoveActor", "func_80135EE8": "AnimationContext_Update", - "SkelAnime_InitLinkAnimetion": "SkelAnime_InitLink", - "func_801360A8": "LinkAnimation_SetUpdateFunction", - "func_801360E0": "LinkAnimation_Update", - "func_80136104": "LinkAnimation_Morph", - "func_801361BC": "LinkAnimation_AnimateFrame", - "func_80136288": "LinkAnimation_Loop", - "func_8013631C": "LinkAnimation_Once", + "SkelAnime_InitLink": "SkelAnime_InitPlayer", + "LinkAnimation_SetUpdateFunction": "PlayerAnimation_SetUpdateFunction", + "LinkAnimation_Update": "PlayerAnimation_Update", "SkelAnime_SetTransition": "Animation_SetMorph", - "SkelAnime_ChangeLinkAnim": "LinkAnimation_Change", - "SkelAnime_ChangeLinkAnimDefaultStop": "LinkAnimation_PlayOnce", - "SkelAnime_ChangeLinkAnimPlaybackStop": "LinkAnimation_PlayOnceSetSpeed", - "SkelAnime_ChangeLinkAnimDefaultRepeat": "LinkAnimation_PlayLoop", - "SkelAnime_ChangeLinkAnimPlaybackRepeat": "LinkAnimation_PlayLoopSetSpeed", - "func_8013670C": "LinkAnimation_CopyJointToMorph", - "func_8013673C": "LinkAnimation_CopyMorphToJoint", - "func_8013676C": "LinkAnimation_LoadToMorph", - "func_801367B0": "LinkAnimation_LoadToJoint", - "func_801367F4": "LinkAnimation_InterpJointMorph", - "func_8013682C": "LinkAnimation_BlendToJoint", - "func_801368CC": "LinkAnimation_BlendToMorph", - "SkelAnime_SetModeStop": "LinkAnimation_EndLoop", - "func_80136990": "Animation_OnFrameImpl", - "func_80136A48": "LinkAnimation_OnFrame", + "LinkAnimation_Change": "PlayerAnimation_Change", + "LinkAnimation_PlayOnce": "PlayerAnimation_PlayOnce", + "LinkAnimation_PlayOnceSetSpeed": "PlayerAnimation_PlayOnceSetSpeed", + "LinkAnimation_PlayLoop": "PlayerAnimation_PlayLoop", + "LinkAnimation_PlayLoopSetSpeed": "PlayerAnimation_PlayLoopSetSpeed", + "LinkAnimation_CopyJointToMorph": "PlayerAnimation_CopyJointToMorph", + "LinkAnimation_CopyMorphToJoint": "PlayerAnimation_CopyMorphToJoint", + "LinkAnimation_LoadToMorph": "PlayerAnimation_LoadToMorph", + "LinkAnimation_LoadToJoint": "PlayerAnimation_LoadToJoint", + "LinkAnimation_InterpJointMorph": "PlayerAnimation_InterpJointMorph", + "LinkAnimation_BlendToJoint": "PlayerAnimation_BlendToJoint", + "LinkAnimation_BlendToMorph": "PlayerAnimation_BlendToMorph", + "LinkAnimation_EndLoop": "PlayerAnimation_EndLoop", + "LinkAnimation_OnFrame": "PlayerAnimation_OnFrame", + "SkelAnime_InitSV": "SkelAnime_InitFlex", - "func_80136C84": "SkelAnime_SetUpdate", "SkelAnime_FrameUpdateMatrix": "SkelAnime_Update", "func_80136CF4": "SkelAnime_Morph", "func_80136D98": "SkelAnime_MorphTaper", - "func_80136F04": "SkelAnime_AnimateFrame", + "func_8013702C": "SkelAnime_LoopFull", "func_801370B0": "SkelAnime_LoopPartial", "func_8013713C": "SkelAnime_Once", @@ -246,7 +260,7 @@ wordReplace = { "func_801376DC": "SkelAnime_CopyFrameTableFalse", "func_80137748": "SkelAnime_UpdateTranslation", "func_801378B8": "Animation_OnFrame", - "SkelAnime_CopyVec3s": "SkelAnime_CopyFrameTable", + "Actor_SetObjectSegment": "Actor_SetObjectDependency", "func_800B3FC0": "ActorShadow_DrawCircle", "func_800B4024": "ActorShadow_DrawSquare", @@ -269,12 +283,17 @@ wordReplace = { "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_800B8A1C": "Actor_OfferGetItem", + "Actor_PickUp": "Actor_OfferGetItem", + "func_800B8B84": "Actor_OfferGetItemNearby", + "Actor_PickUpNearby": "Actor_OfferGetItemNearby", + "func_800B8BB0": "Actor_OfferCarry", + "Actor_LiftActor": "Actor_OfferCarry", + "func_800B8BD0": "Actor_OfferGetItemFar", + "Actor_PickUpFar": "Actor_OfferGetItemFar", "func_801A5CFC": "AudioSfx_PlaySfx", "Audio_PlaySfxGeneral": "AudioSfx_PlaySfx", + "func_800B8C50": "Actor_SetClosestSecretDistance", "func_800BBDAC": "Actor_SpawnFloorDustRing", "func_800B8708": "Player_GetExchangeItemId", "func_801233E4": "Player_InCsMode", @@ -289,16 +308,25 @@ wordReplace = { "func_800B867C": "Actor_TextboxIsClosing", "func_800BDC5C": "Actor_ChangeAnimationByInfo", "Actor_ChangeAnimation": "Actor_ChangeAnimationByInfo", + "func_801477B4": "Message_CloseTextbox", + "func_80151938": "Message_ContinueTextbox", "func_80152498": "Message_GetState", "func_800B8898": "Actor_GetScreenPos", - "Audio_PlayActorSound2": "Actor_PlaySfxAtPos", + "Audio_PlayActorSound2": "Actor_PlaySfx", + "Actor_PlaySfxAtPos": "Actor_PlaySfx", + "func_800B8E58": "Player_PlaySfx", "func_800BF7CC": "Actor_SpawnIceEffects", "Actor_IsFacingPlayerAndWithinRange": "Actor_IsFacingAndNearPlayer", "func_800BC8B8": "Actor_DrawDoorLock", "func_800B86C8": "Actor_ChangeFocus", - "func_800B90F4": "Actor_DeactivateLens", - "func_800BC770": "Actor_AddQuake", "func_800DF840": "Camera_ChangeMode", + "func_800B90F4": "Actor_DeactivateLens", + "Actor_AddQuake": "Actor_RequestQuake", + "func_800BC770": "Actor_RequestQuake", + "Actor_AddQuakeWithSpeed": "Actor_RequestQuakeWithSpeed", + "func_800BC848": "Actor_RequestQuakeAndRumble", + "func_800DF840": "Camera_ChangeMode", + "Camera_SetToTrackActor": "Camera_SetFocalActor", "zelda_malloc": "ZeldaArena_Malloc", "zelda_mallocR": "ZeldaArena_MallocR", "zelda_realloc": "ZeldaArena_Realloc", @@ -408,20 +436,49 @@ wordReplace = { "BgCheck_AddActorMesh": "DynaPoly_SetBgActor", "BgCheck_GetActorOfMesh": "DynaPoly_GetActor", "BgCheck_RemoveActorMesh": "DynaPoly_DeleteBgActor", - "BgCheck_AddActorMeshToLists": "DynaPoly_ExpandSRT", - "BgCheck_Update": "DynaPoly_Setup", + "BgCheck_AddActorMeshToLists": "DynaPoly_AddBgActorToLookup", + "BgCheck_Update": "DynaPoly_UpdateContext", "BgCheck_UpdateAllActorMeshes": "DynaPoly_UpdateBgActorTransforms", "BgCheck_RelocateMeshHeaderPointers": "CollisionHeader_SegmentedToVirtual", "BgCheck_RelocateMeshHeader": "CollisionHeader_GetVirtual", "BgCheck_RelocateAllMeshHeaders": "BgCheck_InitCollisionHeaders", "BgCheck_GetPolygonAttributes": "SurfaceType_GetData", + "DynaPolyActor_ResetState": "DynaPolyActor_UnsetAllInteractFlags", + "DynaPolyActor_SetRidingFallingState": "DynaPolyActor_SetActorOnTop", + "DynaPolyActor_SetRidingMovingState": "DynaPolyActor_SetPlayerOnTop", + "DynaPolyActor_SetRidingMovingStateByIndex": "DynaPoly_SetPlayerOnTop", + "DynaPolyActor_SetRidingRotatingState": "DynaPolyActor_SetPlayerAbove", + "DynaPolyActor_SetRidingRotatingStateByIndex": "DynaPoly_SetPlayerAbove", + "DynaPolyActor_SetSwitchPressedState": "DynaPolyActor_SetActorOnSwitch", + "DynaPolyActor_SetHeavySwitchPressedState": "DynaPolyActor_SetActorOnHeavySwitch", + "DynaPolyActor_IsInRidingFallingState": "DynaPolyActor_IsActorOnTop", + "DynaPolyActor_IsInRidingMovingState": "DynaPolyActor_IsPlayerOnTop", + "DynaPolyActor_IsInRidingRotatingState": "DynaPolyActor_IsPlayerAbove", + "DynaPolyActor_IsInSwitchPressedState": "DynaPolyActor_IsSwitchPressed", + "DynaPolyActor_IsInHeavySwitchPressedState": "DynaPolyActor_IsHeavySwitchPressed", + "func_800C62BC": "DynaPoly_DisableCollision", + "func_800C6314": "DynaPoly_EnableCollision", + "func_800C636C": "DynaPoly_DisableCeilingCollision", + "func_800C63C4": "DynaPoly_EnableCeilingCollision", + "func_800C641C": "DynaPoly_DisableFloorCollision", + "func_800C6474": "DynaPoly_EnableFloorCollision", "SurfaceType_GetConveyorType": "SurfaceType_IsFloorConveyor", "func_800C9704": "SurfaceType_GetBgCamIndex", "func_800C9924": "BgCheck_GetBgCamFuncData", "func_800C99AC": "SurfaceType_GetSceneExitIndex", + "func_800C99D4": "SurfaceType_GetFloorType", + "func_800C9A24": "SurfaceType_GetWallType", + "func_800C9A4C": "SurfaceType_GetWallFlags", + "func_800C9A7C": "SurfaceType_CheckWallFlag0", + "func_800C9AB0": "SurfaceType_CheckWallFlag1", + "func_800C9AE4": "SurfaceType_CheckWallFlag2", + "func_800C9B18": "SurfaceType_GetFloorProperty2", + "func_800C9B40": "SurfaceType_GetFloorProperty", + "func_800C9BB8": "SurfaceType_GetMaterial", "func_800C9B90": "SurfaceType_IsHorseBlocked", - "func_800C9BDC": "SurfaceType_GetSfx", - "func_800C9C74": "SurfaceType_GetSlope", + "func_800C9BDC": "SurfaceType_GetSfxOffset", + "SurfaceType_GetSfx": "SurfaceType_GetSfxOffset", + "func_800C9C74": "SurfaceType_GetFloorEffect", "func_800C9C9C": "SurfaceType_GetLightSettingIndex", "func_800C9CC4": "SurfaceType_GetEcho", "func_800C9CEC": "SurfaceType_IsHookshotSurface", @@ -461,17 +518,18 @@ wordReplace = { "func_8017F9C0": "Math3D_XZInSphere", "func_8017FA34": "Math3D_XYInSphere", "func_8017FAA8": "Math3D_YZInSphere", - "func_800DFB14": "Camera_ChangeDataIdx", + "func_800DFB14": "Camera_ChangeActorCsCamIndex", "func_800DFC68": "Camera_GetInputDirYaw", "func_800DFCB4": "Camera_GetCamDirPitch", "func_800DFCDC": "Camera_GetCamDirYaw", "func_800E0308": "Camera_SetTargetActor", "func_800E031C": "Camera_GetWaterYPos", - "func_800E02AC": "Camera_SetToTrackActor", + "func_800E02AC": "Camera_SetFocalActor", "func_800DFAC8": "Camera_ChangeSetting", "func_800DFC90": "Camera_GetCamDir", "func_800DFD04": "Camera_AddQuake", "func_800DFFAC": "Camera_ChangeDoorCam", + "func_80169FFC": "Play_CamIsNotFixed", "func_801694DC": "Play_CreateSubCamera", "Play_GetActiveCameraIndex": "Play_GetActiveCamId", "func_80169590": "Play_ChangeCameraStatus", @@ -499,6 +557,11 @@ wordReplace = { "func_80169E6C": "Play_SetupRespawnPoint", "func_8016A0AC": "Play_IsUnderwater", "func_801690CC": "Play_InCsMode", + "func_80165658": "Play_SetMotionBlurAlpha", + "func_8016566C": "Play_EnableMotionBlur", + "func_80165690": "Play_DisableMotionBlur", + "func_801660B8": "Play_SetFog", + "func_801129E4": "Interface_SetSceneRestrictions", "func_8011B4E0": "Interface_SetPerfectLetters", "func_80112AFC": "Interface_InitMinigame", @@ -519,7 +582,7 @@ wordReplace = { "func_80115130": "Inventory_ConsumeFairy", "func_801152B8": "Inventory_UpdateItem", "func_80115908": "Health_ChangeBy", - "func_801159c0": "Health_GiveHearts", + "func_801159C0": "Health_GiveHearts", "func_801159EC": "Rupees_ChangeBy", "func_80115A14": "Inventory_ChangeAmmo", "Parameter_AddMagic": "Magic_Add", @@ -535,29 +598,63 @@ wordReplace = { "func_800FE498": "Environment_StartTime", "func_800FE4A8": "Environment_IsTimeStopped", "func_800F5A8C": "Environment_LerpWeight", + "func_801A3F54": "Audio_SetCutsceneFlag", - "func_800EA0D4": "Cutscene_Start", - "func_800EA0EC": "Cutscene_End", + "func_800EA0D4": "Cutscene_StartManual", + "Cutscene_Start": "Cutscene_StartManual", + "func_800EA0EC": "Cutscene_StopManual", + "Cutscene_End": "Cutscene_StopManual", "func_800EDE34": "Cutscene_ActorTranslate", "func_800EDF24": "Cutscene_ActorTranslateAndYaw", "func_800EDF78": "Cutscene_ActorTranslateAndYawSmooth", "func_800EE0CC": "Cutscene_ActorTranslateXZAndYawSmooth", "func_800EE1D8": "Cutscene_GetSceneLayer", - "func_800EE200": "Cutscene_GetActorActionIndex", - "func_800EE29C": "Cutscene_CheckActorAction", + "func_800EE200": "Cutscene_GetCueChannel", + "Cutscene_GetActorActionIndex": "Cutscene_GetCueChannel", + "func_800EE29C": "Cutscene_IsCueInChannel", + "Cutscene_CheckActorAction": "Cutscene_IsCueInChannel", "func_800EE2F4": "Cutscene_IsPlaying", "Cutscene_GetSceneSetupIndex": "Cutscene_GetSceneLayer", + + "func_800F15D8": "CutsceneManager_StoreCamera", + "ActorCutscene_SetIntentToPlay": "CutsceneManager_Queue", + "ActorCutscene_GetCanPlayNext": "CutsceneManager_IsNext", + "ActorCutscene_StartAndSetUnkLinkFields": "CutsceneManager_StartWithPlayerCs", + "ActorCutscene_StartAndSetFlag": "CutsceneManager_StartWithPlayerCsAndSetFlag", + "ActorCutscene_Start": "CutsceneManager_Start", + "ActorCutscene_Stop": "CutsceneManager_Stop", + "ActorCutscene_GetCurrentIndex": "CutsceneManager_GetCurrentCsId", + "ActorCutscene_GetCutscene": "CutsceneManager_GetCutsceneEntry", + "ActorCutscene_GetAdditionalCutscene": "CutsceneManager_GetAdditionalCsId", + "ActorCutscene_GetLength": "CutsceneManager_GetLength", + "ActorCutscene_GetCurrentSubCamId": "CutsceneManager_GetCurrentSubCamId", + "ActorCutscene_GetCurrentCamera": "CutsceneManager_GetCurrentSubCamId", + + "EnvFlags_UnsetAll": "CutsceneFlags_UnsetAll", + "EnvFlags_Set": "CutsceneFlags_Set", + "EnvFlags_Unset": "CutsceneFlags_Unset", + "EnvFlags_Get": "CutsceneFlags_Get", + "func_801343C0": "SkelAnime_DrawTransformFlexOpa", - "func_80134148": "SkelAnime_DrawTransformFlexLimbOpa", "func_80114E90": "Inventory_HasEmptyBottle", "func_80114F2C": "Inventory_HasItemInBottle", "func_80123C90": "Player_SetEquipmentData", - "Quake2_ClearType": "Distortion_ClearType", - "Quake2_SetType": "Distortion_SetType", - "Quake2_SetCountdown": "Distortion_SetCountdown", + "Quake2_SetType": "Distortion_Request", + "Distortion_SetType": "Distortion_Request", + "Quake2_SetCountdown": "Distortion_SetDuration", + "Distortion_SetCountdown": "Distortion_SetDuration", + "Distortion_GetCountdown": "Distortion_GetTimeLeft", + "Quake2_ClearType": "Distortion_RemoveRequest", + "Distortion_ClearType": "Distortion_RemoveRequest", "func_800BE680": "Actor_DrawDamageEffects", "func_8012F22C": "Inventory_GetSkullTokenCount", - "Quake_RemoveFromIdx": "Quake_Remove", + "Quake_Add": "Quake_Request", + "Quake_SetQuakeValues": "Quake_SetPerturbations", + "Quake_SetCountdown": "Quake_SetDuration", + "Quake_GetCountdown": "Quake_GetTimeLeft", + "Quake_NumActiveQuakes": "Quake_GetNumActiveQuakes", + "Quake_RemoveFromIdx": "Quake_RemoveRequest", + "OLib_DbCameraVec3fSum":"OLib_Vec3fAdd", "func_8013AB00": "SubS_DrawTransformFlex", "func_8013A860": "SubS_DrawTransformFlexLimb", @@ -568,7 +665,8 @@ wordReplace = { "func_8013E640": "SubS_FindActorCustom", "func_ActorCategoryIterateById": "SubS_FindActor", "func_8013BB7C": "SubS_FindNearestActor", - "func_8013E2D4": "SubS_StartActorCutscene", + "func_8013E2D4": "SubS_StartCutscene", + "SubS_StartActorCutscene": "SubS_StartCutscene", "func_8013E3B8": "SubS_FillCutscenesList", "func_8013AED4": "SubS_UpdateFlags", "func_8013D8DC": "SubS_IsObjectLoaded", @@ -639,11 +737,33 @@ wordReplace = { "func_8010A54C": "Minimap_Draw", "func_8010A580": "Map_Update", - "ActorCutscene_GetCurrentCamera": "ActorCutscene_GetCurrentSubCamId", - "Entrance_CreateIndex": "Entrance_Create", "Entrance_CreateIndexFromSpawn": "Entrance_CreateFromSpawn", + "func_80102544": "LightContext_SetFog", + + "Padmgr_GetControllerBitmask": "PadMgr_GetValidControllersMask", + "func_80174F24": "PadMgr_SetRumbleRetraceCallback", + "func_80174F44": "PadMgr_UnsetRumbleRetraceCallback", + "func_80174F7C": "PadMgr_SetInputRetraceCallback", + "func_80174F9C": "PadMgr_UnsetInputRetraceCallback", + "Padmgr_GetEventCallback": "PadMgr_AcquireSerialEventQueue", + "func_80175008": "PadMgr_VoiceAcquireSerialEventQueue", + "Padmgr_SetEventCallback": "PadMgr_ReleaseSerialEventQueue", + "func_8017506C": "PadMgr_VoiceReleaseSerialEventQueue", + "Padmgr_Lock": "PadMgr_LockPadData", + "Padmgr_Unlock": "PadMgr_UnlockPadData", + "func_801750FC": "PadMgr_UpdateRumble", + "func_80175364": "PadMgr_RumbleStop", + "func_80175434": "PadMgr_RumblePause", + "func_8017544C": "PadMgr_RumbleSetSingle", + "Padmgr_ParseState": "PadMgr_UpdateInputs", + "func_801759BC": "PadMgr_InitVoice", + "func_80175AE0": "PadMgr_UpdateConnections", + "Padmgr_Update": "PadMgr_HandleRetrace", + "Padmgr_Stop": "PadMgr_HandlePreNMI", + "func_80175E68": "PadMgr_GetInputNoLock", + # Structs "ActorAnimationEntry": "AnimationInfo", "ActorAnimationEntryS": "AnimationInfoS", @@ -652,6 +772,7 @@ wordReplace = { "globalCtx": "play", "globalCtx2": "play2", "ScheduleResult": "ScheduleOutput", + "LinkAnimationHeader": "PlayerAnimationHeader", # Struct members "skelAnime.unk03": "skelAnime.taper", @@ -670,50 +791,55 @@ wordReplace = { "skelAnime.prevFrameRot": "skelAnime.prevRot", "skelAnime.prevFramePos": "skelAnime.prevTransl", "skelAnime.unk3E": "skelAnime.baseTransl", + "actor.unk20": "actor.halfDaysBits", "actor.minVelocityY": "actor.terminalVelocity", "actor.yDistToWater": "actor.depthInWater", "actor.yDistToPlayer": "actor.playerHeightRel", + "actor.cutscene": "actor.csId", + "actor.speedXZ": "actor.speed", + "thisx->speedXZ": "thisx->speed", "gSaveContext.unk_3F1E": "gSaveContext.hudVisibilityForceButtonAlphasByStatus", "gSaveContext.unk_3F20": "gSaveContext.nextHudVisibility", "gSaveContext.unk_3F22": "gSaveContext.hudVisibility", "gSaveContext.unk_3F24": "gSaveContext.hudVisibilityTimer", "gSaveContext.unk_3F26": "gSaveContext.prevHudVisibility", - "gSaveContext.weekEventReg": "gSaveContext.save.weekEventReg", + "gSaveContext.weekEventReg": "gSaveContext.save.saveInfo.weekEventReg", "gSaveContext.playerForm": "gSaveContext.save.playerForm", "gSaveContext.day": "gSaveContext.save.day", "gSaveContext.isNight": "gSaveContext.save.isNight", "gSaveContext.environmentTime": "gSaveContext.skyboxTime", - "gSaveContext.naviTimer": "gSaveContext.save.playerData.tatlTimer", - "gSaveContext.tatlTimer": "gSaveContext.save.playerData.tatlTimer", - "gSaveContext.rupees": "gSaveContext.save.playerData.rupees", - "gSaveContext.magicAcquired": "gSaveContext.save.playerData.isMagicAcquired", - "gSaveContext.doubleMagic": "gSaveContext.save.playerData.isDoubleMagicAcquired", - "gSaveContext.doubleDefense": "gSaveContext.save.playerData.doubleDefense", - "gSaveContext.playerName": "gSaveContext.save.playerData.playerName", - "gSaveContext.inventory": "gSaveContext.save.inventory", + "gSaveContext.naviTimer": "gSaveContext.save.saveInfo.playerData.tatlTimer", + "gSaveContext.tatlTimer": "gSaveContext.save.saveInfo.playerData.tatlTimer", + "gSaveContext.rupees": "gSaveContext.save.saveInfo.playerData.rupees", + "gSaveContext.magicAcquired": "gSaveContext.save.saveInfo.playerData.isMagicAcquired", + "gSaveContext.doubleMagic": "gSaveContext.save.saveInfo.playerData.isDoubleMagicAcquired", + "gSaveContext.doubleDefense": "gSaveContext.save.saveInfo.playerData.doubleDefense", + "gSaveContext.playerName": "gSaveContext.save.saveInfo.playerData.playerName", + "gSaveContext.inventory": "gSaveContext.save.saveInfo.inventory", "gSaveContext.equippedMask": "gSaveContext.save.equippedMask", "gSaveContext.entranceIndex": "gSaveContext.save.entrance", "gSaveContext.time": "gSaveContext.save.time", "gSaveContext.save.daySpeed": "gSaveContext.save.timeSpeedOffset", "gSaveContext.unk_14": "gSaveContext.save.timeSpeedOffset", - "gSaveContext.unk_FE6": "gSaveContext.save.bombersCaughtNum", - "gSaveContext.unk_FE7": "gSaveContext.save.bombersCaughtOrder", + "gSaveContext.unk_FE6": "gSaveContext.save.saveInfo.bombersCaughtNum", + "gSaveContext.unk_FE7": "gSaveContext.save.saveInfo.bombersCaughtOrder", "gSaveContext.linkAge": "gSaveContext.save.linkAge", - "gSaveContext.dekuPlaygroundHighScores": "gSaveContext.save.dekuPlaygroundHighScores", - "gSaveContext.lotteryCodeGuess": "gSaveContext.save.lotteryCodeGuess", - "gSaveContext.permanentSceneFlags": "gSaveContext.save.permanentSceneFlags", - "gSaveContext.bomberCode": "gSaveContext.save.bomberCode", - "gSaveContext.skullTokenCount": "gSaveContext.save.skullTokenCount", - "gSaveContext.cutscene": "gSaveContext.save.cutscene", - "gSaveContext.health": "gSaveContext.save.playerData.health", - "gSaveContext.equips": "gSaveContext.save.equips", + "gSaveContext.dekuPlaygroundHighScores": "gSaveContext.save.saveInfo.dekuPlaygroundHighScores", + "gSaveContext.lotteryCodeGuess": "gSaveContext.save.saveInfo.lotteryCodeGuess", + "gSaveContext.permanentSceneFlags": "gSaveContext.save.saveInfo.permanentSceneFlags", + "gSaveContext.bomberCode": "gSaveContext.save.saveInfo.bomberCode", + "gSaveContext.skullTokenCount": "gSaveContext.save.saveInfo.skullTokenCount", + "gSaveContext.cutscene": "gSaveContext.save.cutsceneIndex", + "gSaveContext.save.cutscene": "gSaveContext.save.cutsceneIndex", + "gSaveContext.health": "gSaveContext.save.saveInfo.playerData.health", + "gSaveContext.equips": "gSaveContext.save.saveInfo.equips", "gSaveContext.unk_1016": "gSaveContext.jinxTimer", "gSaveContext.unk_3F58": "gSaveContext.sunsSongState", "gSaveContext.equips.buttonItems": "gSaveContext.save.equips.buttonItems", "gSaveContext.unk_48C8": "gSaveContext.dungeonIndex", - "gSaveContext.save.playerData.magicAcquired": "gSaveContext.save.playerData.isMagicAcquired", - "gSaveContext.save.playerDatadoubleMagic": "gSaveContext.save.playerData.isDoubleMagicAcquired", + "gSaveContext.save.saveInfo.playerData.magicAcquired": "gSaveContext.save.saveInfo.playerData.isMagicAcquired", + "gSaveContext.save.playerData.doubleMagic": "gSaveContext.save.saveInfo.playerData.isDoubleMagicAcquired", "gSaveContext.unk_3F28": "gSaveContext.magicState", "gSaveContext.unk_3F30": "gSaveContext.magicFillTarget", "gSaveContext.unk_3F2C": "gSaveContext.magicFlag", @@ -723,6 +849,44 @@ wordReplace = { "gSaveContext.nightSeqIndex": "gSaveContext.ambienceId", "gSaveContext.minigameState": "gSaveContext.minigameStatus", "gSaveContext.unk_3F3C": "gSaveContext.minigameHiddenScore", + "gSaveContext.save.playerData": "gSaveContext.save.saveInfo.playerData", + "gSaveContext.save.equips": "gSaveContext.save.saveInfo.equips", + "gSaveContext.save.inventory": "gSaveContext.save.saveInfo.inventory", + "gSaveContext.save.permanentSceneFlags": "gSaveContext.save.saveInfo.permanentSceneFlags", + + "gSaveContext.save.unk_E18": "gSaveContext.save.saveInfo.unk_E5C", + "gSaveContext.save.dekuPlaygroundHighScores": "gSaveContext.save.saveInfo.dekuPlaygroundHighScores", + "gSaveContext.save.pictoFlags0": "gSaveContext.save.saveInfo.pictoFlags0", + "gSaveContext.save.pictoFlags1": "gSaveContext.save.saveInfo.pictoFlags1", + "gSaveContext.save.unk_E84": "gSaveContext.save.saveInfo.unk_E60", + "gSaveContext.save.unk_E88": "gSaveContext.save.saveInfo.unk_E64", + "gSaveContext.save.scenesVisible": "gSaveContext.save.saveInfo.scenesVisible", + "gSaveContext.save.skullTokenCount": "gSaveContext.save.saveInfo.skullTokenCount", + "gSaveContext.save.unk_EC4": "gSaveContext.save.saveInfo.unk_EA0", + "gSaveContext.save.unk_EC8": "gSaveContext.save.saveInfo.unk_EA4", + "gSaveContext.save.unk_ECC": "gSaveContext.save.saveInfo.unk_EA8", + "gSaveContext.save.stolenItems": "gSaveContext.save.saveInfo.stolenItems", + "gSaveContext.save.unk_DD8": "gSaveContext.save.saveInfo.unk_EB4", + "gSaveContext.save.bankRupees": "gSaveContext.save.saveInfo.bankRupees", + "gSaveContext.save.unk_EE0": "gSaveContext.save.saveInfo.unk_EBC", + "gSaveContext.save.unk_EE4": "gSaveContext.save.saveInfo.unk_EC0", + "gSaveContext.save.unk_EE8": "gSaveContext.save.saveInfo.unk_EC4", + "gSaveContext.save.horseBackBalloonHighScore": "gSaveContext.save.saveInfo.horseBackBalloonHighScore", + "gSaveContext.save.lotteryCodeGuess": "gSaveContext.save.saveInfo.lotteryCodeGuess", + "gSaveContext.save.shootingGalleryHighScores": "gSaveContext.save.saveInfo.shootingGalleryHighScores", + "gSaveContext.save.weekEventReg": "gSaveContext.save.saveInfo.weekEventReg", + "gSaveContext.save.regionsVisited": "gSaveContext.save.saveInfo.regionsVisited", + "gSaveContext.save.worldMapCloudVisibility": "gSaveContext.save.saveInfo.worldMapCloudVisibility", + "gSaveContext.save.unk_F64": "gSaveContext.save.saveInfo.unk_F40", + "gSaveContext.save.unk_F65": "gSaveContext.save.saveInfo.unk_F41", + "gSaveContext.save.scarecrowSpawnSong": "gSaveContext.save.saveInfo.scarecrowSpawnSong", + "gSaveContext.save.bombersCaughtNum": "gSaveContext.save.saveInfo.bombersCaughtNum", + "gSaveContext.save.bombersCaughtOrder": "gSaveContext.save.saveInfo.bombersCaughtOrder", + "gSaveContext.save.lotteryCodes": "gSaveContext.save.saveInfo.lotteryCodes", + "gSaveContext.save.spiderHouseMaskOrder": "gSaveContext.save.saveInfo.spiderHouseMaskOrder", + "gSaveContext.save.bomberCode": "gSaveContext.save.saveInfo.bomberCode", + "gSaveContext.save.horseData": "gSaveContext.save.saveInfo.horseData", + "gSaveContext.save.checksum": "gSaveContext.save.saveInfo.checksum", "player->unk_A87": "player->exchangeItemId", "player->leftHandActor": "player->heldActor", @@ -741,17 +905,33 @@ wordReplace = { "player->heldItemActionParam": "player->itemAction", "player->unk_A9C": "player->secretRumbleCharge", "player->unk_AA0": "player->closestSecretDistSq", + "player->unk_AAC": "player->headLimbRot", + "player->unk_AB2": "player->upperLimbRot", + "player->unk_B2A": "player->getItemDrawIdPlusOne", + "player->getItemDrawId": "player->getItemDrawIdPlusOne", "player->unk_B68": "player->fallStartHeight", "player->unk_B6A": "player->fallDistance", "player->targetActor": "player->talkActor", "player->targetActorDistance": "player->talkActorDistance", "player->unk_730": "player->targetedActor", - "player->ageProperties->unk_92": "player->ageProperties->voiceSfxIdOffset", - "player->ageProperties->unk_94": "player->ageProperties->surfaceSfxIdOffset", - "csCtx.npcActions": "csCtx.actorActions", - "csCtx->npcActions": "csCtx->actorActions", - "csCtx.unk_12": "csCtx.currentCsIndex", + "ageProperties->unk_04": "ageProperties->shadowScale", + "ageProperties->unk_92": "ageProperties->voiceSfxOffset", + "ageProperties->unk_94": "ageProperties->surfaceSfxOffset", + "player->unk_A86": "player->csId", + + "csCtx.npcActions": "csCtx.actorCues", + "csCtx->npcActions": "csCtx->actorCues", + "csCtx.actorActions": "csCtx.actorCues", + "csCtx->actorActions": "csCtx->actorCues", + "csCtx.playerAction": "csCtx.playerCue", + "csCtx->playerAction": "csCtx->playerCue", + "csCtx.unk_12": "csCtx.scriptIndex", + "csCtx.currentCsIndex": "csCtx.scriptIndex", + "csCtx->currentCsIndex": "csCtx->scriptIndex", + "csCtx.frames": "csCtx.curFrame", + "csCtx->frames": "csCtx->curFrame", + "globalCtx->mf_187FC": "play->billboardMtxF", "globalCtx->projectionMatrix": "play->viewProjectionMtxF", "globalCtx->actorCtx.actorList[": "play->actorCtx.actorLists[", @@ -783,6 +963,21 @@ wordReplace = { "play->nextEntranceIndex": "play->nextEntrance", "play->sceneNum": "play->sceneId", "play->pauseCtx.unk_1F0": "play->pauseCtx.bombersNotebookOpen", + "play->playerActorCsIds": "play->playerCsIds", + "play->envFlags": "play->cutsceneFlags", + "play->roomCtx.curRoom.unk3": "play->roomCtx.curRoom.behaviorType1", + "play->roomCtx.curRoom.unk2": "play->roomCtx.curRoom.behaviorType2", + "play->roomCtx.unk31": "play->roomCtx.status", + + "actorCtx.unkC": "actorCtx.halfDaysBit", + "actorCtx.unk1F4": "actorCtx.playerImpact.type", + "actorCtx.unk1F5": "actorCtx.playerImpact.timer", + "actorCtx.unk1F8": "actorCtx.playerImpact.dist", + "actorCtx.unk1FC": "actorCtx.playerImpact.pos", + "actorCtx.unk_1F4.unk_00": "actorCtx.playerImpact.type", + "actorCtx.unk_1F4.timer": "actorCtx.playerImpact.timer", + "actorCtx.unk_1F4.unk_04": "actorCtx.playerImpact.dist", + "actorCtx.unk_1F4.unk_08": "actorCtx.playerImpact.pos", "gSaveContext.unk_3DC8": "gSaveContext.timerOsTime", "gSaveContext.unk_3DD0": "gSaveContext.timerStates", @@ -812,8 +1007,15 @@ wordReplace = { "ICHAIN_F32_DIV1000(minVelocityY,": "ICHAIN_F32_DIV1000(terminalVelocity,", "ICHAIN_F32(minVelocityY,": "ICHAIN_F32(terminalVelocity,", + "RADF_TO_BINANG": "RAD_TO_BINANG", + "RADF_TO_DEGF": "RAD_TO_DEG", + "DEGF_TO_RADF": "DEG_TO_RAD", + "ACTORCTX_FLAG_2": "ACTORCTX_FLAG_PICTO_BOX_ON", + "ACTOR_FLAG_100": "ACTOR_FLAG_TALK_REQUESTED", + "ACTOR_FLAG_8000000": "ACTOR_FLAG_CANT_LOCK_ON", + "EXCH_ITEM_MINUS1": "PLAYER_IA_MINUS1", "EXCH_ITEM_NONE": "PLAYER_IA_NONE", "EXCH_ITEM_PICTO_BOX": "PLAYER_IA_PICTO_BOX", @@ -829,6 +1031,46 @@ wordReplace = { "EXCH_ITEM_LETTER_MAMA": "PLAYER_IA_LETTER_MAMA", "ITEM_FISHING_POLE": "ITEM_FISHING_ROD", "PLAYER_AP_FISHING_POLE": "PLAYER_IA_FISHING_ROD", + "PLAYER_IA_BOTTLE": "PLAYER_IA_BOTTLE_EMPTY", + + "WEEKEVENTREG_20_02": "WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE", + "WEEKEVENTREG_33_80": "WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE", + "WEEKEVENTREG_52_20": "WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE", + "WEEKEVENTREG_55_80": "WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE", + + # Enums + "TRANS_TYPE_00": "TRANS_TYPE_WIPE", + "TRANS_TYPE_01": "TRANS_TYPE_TRIFORCE", + "TRANS_TYPE_02": "TRANS_TYPE_FADE_BLACK", + "TRANS_TYPE_03": "TRANS_TYPE_FADE_WHITE", + "TRANS_TYPE_04": "TRANS_TYPE_FADE_BLACK_FAST", + "TRANS_TYPE_05": "TRANS_TYPE_FADE_WHITE_FAST", + "TRANS_TYPE_06": "TRANS_TYPE_FADE_BLACK_SLOW", + "TRANS_TYPE_07": "TRANS_TYPE_FADE_WHITE_SLOW", + "TRANS_TYPE_08": "TRANS_TYPE_WIPE_FAST", + "TRANS_TYPE_09": "TRANS_TYPE_FILL_WHITE_FAST", + "TRANS_TYPE_10": "TRANS_TYPE_FILL_WHITE", + "TRANS_TYPE_11": "TRANS_TYPE_INSTANT", + "TRANS_TYPE_12": "TRANS_TYPE_FILL_BROWN", + "TRANS_TYPE_13": "TRANS_TYPE_FADE_WHITE_CS_DELAYED", + "TRANS_TYPE_14": "TRANS_TYPE_SANDSTORM_PERSIST", + "TRANS_TYPE_15": "TRANS_TYPE_SANDSTORM_END", + "TRANS_TYPE_16": "TRANS_TYPE_CS_BLACK_FILL", + "TRANS_TYPE_17": "TRANS_TYPE_FADE_WHITE_INSTANT", + "TRANS_TYPE_18": "TRANS_TYPE_FADE_GREEN", + "TRANS_TYPE_19": "TRANS_TYPE_FADE_BLUE", + "TRANS_TYPE_20": "TRANS_TYPE_FADE_DYNAMIC", + "TRANS_TYPE_21": "TRANS_TYPE_CIRCLE", + "TRANS_TYPE_22": "TRANS_TYPE_WIPE5", + "PLAYER_CSMODE_6": "PLAYER_CSMODE_END", + "PLAYER_CSMODE_7": "PLAYER_CSMODE_WAIT", + "SUBS_CUTSCENE_SET_UNK_LINK_FIELDS": "SUBS_CUTSCENE_WITH_PLAYER", + "SUBS_CUTSCENE_SET_FLAG": "SUBS_CUTSCENE_WITH_PLAYER_SET_FLAG", + + "COLPOLY_SURFACE_GROUND": "SURFACE_MATERIAL_DIRT", + "COLPOLY_SURFACE_SAND": "SURFACE_MATERIAL_SAND", + "COLPOLY_SURFACE_SNOW": "SURFACE_MATERIAL_SNOW", + "CS_STATE_0": "CS_STATE_IDLE", # Example of custom behaviour: # "PLAYER": ("GET_PLAYER(play)", {"ignore": (-1, '"PLAYER"')}), # ignore "PLAYER" in sSoundBankNames diff --git a/tools/permuter_settings.toml b/tools/permuter_settings.toml index 691913cdc..5f42d30d6 100644 --- a/tools/permuter_settings.toml +++ b/tools/permuter_settings.toml @@ -20,6 +20,7 @@ CLOCK_TIME = "int" CURRENT_DAY = "int" CHECK_NEWF = "int" NULL = "int" +"SCREEN_.*" = "int" GET_PLAYER = "int" CHECK_WEEKEVENTREG = "int" SET_WEEKEVENTREG = "int" diff --git a/tools/progress.py b/tools/progress.py index dccd743d7..5a2958cd8 100755 --- a/tools/progress.py +++ b/tools/progress.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -import argparse, csv, git, json, os, re, sys +import argparse, csv, os, re, sys parser = argparse.ArgumentParser() @@ -170,6 +170,7 @@ srcCategories = [ "libultra", "code", "overlays", + "audio", ] srcCategoriesFixer = { @@ -256,6 +257,12 @@ asmTracker["boot"]["totalSize"] += asmTracker["libultra"]["totalSize"] del srcTracker["libultra"] del asmTracker["libultra"] +# Add audio to code. +srcTracker["code"]["totalSize"] += srcTracker["audio"]["totalSize"] +asmTracker["code"]["totalSize"] += asmTracker["audio"]["totalSize"] +del srcTracker["audio"] +del asmTracker["audio"] + # Calculate Non-Matching non_matching_functions_ovl = list(map(lambda x: x.split("/")[-1].split(".")[0], filter(lambda x: "/overlays/" in x, non_matching_functions))) non_matching_functions_code = list(map(lambda x: x.split("/")[-1].split(".")[0], filter(lambda x: "/code/" in x, non_matching_functions))) @@ -337,6 +344,8 @@ masks = int(src / bytes_per_mask) rupees = int((src % bytes_per_mask) / bytes_per_rupee) if args.format == 'csv': + import git + version = 2 git_object = git.Repo().head.object timestamp = str(git_object.committed_date) @@ -358,6 +367,8 @@ if args.format == 'csv': print(",".join(map(str, csv_list))) elif args.format == 'shield-json': + import json + # https://shields.io/endpoint print(json.dumps({ "schemaVersion": 1, diff --git a/tools/regconvert.py b/tools/regconvert.py index f4b9b0db1..892e3f885 100755 --- a/tools/regconvert.py +++ b/tools/regconvert.py @@ -28,7 +28,7 @@ def read_file(filename): file_contents = src_file.read() src_file.close() - pattern = re.compile("gGameInfo->data\[((0[xX])?[0-9a-fA-F]+)\]") + pattern = re.compile("gRegEditor->data\[((0[xX])?[0-9a-fA-F]+)\]") match = pattern.search(file_contents) while match: @@ -56,19 +56,19 @@ def check_valid_offset(offset): return 0x14 <= offset <= 0x15D2 def main(): - parser = argparse.ArgumentParser(description="Converts a gGameInfo->data index to a REG macro.") + parser = argparse.ArgumentParser(description="Converts a gRegEditor->data index to a REG macro.") # TODO: Add a description and a better title # index_group = parser.add_argument_group(title="index", description="") index_group = parser.add_argument_group() - index_group.add_argument("index", help="index of gGameInfo->data in decimal (or hexadecimal if starts with 0x)") - index_group.add_argument("--offset", help="treat index argument as an offset to gGameInfo instead", action="store_true") + index_group.add_argument("index", help="index of gRegEditor->data in decimal (or hexadecimal if starts with 0x)") + index_group.add_argument("--offset", help="treat index argument as an offset to gRegEditor instead", action="store_true") index_group.add_argument("--hex", help="treat index argument as hexadecimal, even without the 0x", action="store_true") # TODO: Add a description and a better title # file_group = parser.add_argument_group(title="file", description="") file_group = parser.add_argument_group() - file_group.add_argument("--file", help="use the parameter as a filepath, then replace every occurrence of `gGameInfo->data[number]` in that file a REG macro", action="store_true") + file_group.add_argument("--file", help="use the parameter as a filepath, then replace every occurrence of `gRegEditor->data[number]` in that file a REG macro", action="store_true") file_group.add_argument("--stdout", help="print the processed file to stdout instead of overwriting the original", action="store_true") args = parser.parse_args() diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index afb03d3b7..ba751f02a 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -210,10 +210,10 @@ asm/non_matchings/code/z_actor/TitleCard_InitPlaceName.s,TitleCard_InitPlaceName 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 -asm/non_matchings/code/z_actor/func_800B648C.s,func_800B648C,0x800B648C,0x1C -asm/non_matchings/code/z_actor/func_800B64FC.s,func_800B64FC,0x800B64FC,0x22 +asm/non_matchings/code/z_actor/Actor_InitPlayerImpact.s,Actor_InitPlayerImpact,0x800B6468,0x3 +asm/non_matchings/code/z_actor/Actor_UpdatePlayerImpact.s,Actor_UpdatePlayerImpact,0x800B6474,0x6 +asm/non_matchings/code/z_actor/Actor_SetPlayerImpact.s,Actor_SetPlayerImpact,0x800B648C,0x1C +asm/non_matchings/code/z_actor/Actor_GetPlayerImpact.s,Actor_GetPlayerImpact,0x800B64FC,0x22 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 @@ -236,16 +236,16 @@ asm/non_matchings/code/z_actor/Actor_UpdateVelocityWithoutGravityReverse.s,Actor 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 -asm/non_matchings/code/z_actor/Actor_PitchBetweenActors.s,Actor_PitchBetweenActors,0x800B6D50,0xB -asm/non_matchings/code/z_actor/Actor_PitchBetweenActorsTop.s,Actor_PitchBetweenActorsTop,0x800B6D7C,0xB -asm/non_matchings/code/z_actor/Actor_PitchToPoint.s,Actor_PitchToPoint,0x800B6DA8,0x9 -asm/non_matchings/code/z_actor/Actor_DistanceBetweenActors.s,Actor_DistanceBetweenActors,0x800B6DCC,0xB -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_WorldYawTowardActor.s,Actor_WorldYawTowardActor,0x800B6CD4,0xB +asm/non_matchings/code/z_actor/Actor_FocusYawTowardActor.s,Actor_FocusYawTowardActor,0x800B6D00,0xB +asm/non_matchings/code/z_actor/Actor_WorldYawTowardPoint.s,Actor_WorldYawTowardPoint,0x800B6D2C,0x9 +asm/non_matchings/code/z_actor/Actor_WorldPitchTowardActor.s,Actor_WorldPitchTowardActor,0x800B6D50,0xB +asm/non_matchings/code/z_actor/Actor_FocusPitchTowardActor.s,Actor_FocusPitchTowardActor,0x800B6D7C,0xB +asm/non_matchings/code/z_actor/Actor_WorldPitchTowardPoint.s,Actor_WorldPitchTowardPoint,0x800B6DA8,0x9 +asm/non_matchings/code/z_actor/Actor_WorldDistXYZToActor.s,Actor_WorldDistXYZToActor,0x800B6DCC,0xB +asm/non_matchings/code/z_actor/Actor_WorldDistXYZToPoint.s,Actor_WorldDistXYZToPoint,0x800B6DF8,0x9 +asm/non_matchings/code/z_actor/Actor_WorldDistXZToActor.s,Actor_WorldDistXZToActor,0x800B6E1C,0xB +asm/non_matchings/code/z_actor/Actor_WorldDistXZToPoint.s,Actor_WorldDistXZToPoint,0x800B6E48,0x9 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 @@ -299,13 +299,13 @@ asm/non_matchings/code/z_actor/func_800B886C.s,func_800B886C,0x800B886C,0xB asm/non_matchings/code/z_actor/Actor_GetScreenPos.s,Actor_GetScreenPos,0x800B8898,0x27 asm/non_matchings/code/z_actor/Actor_OnScreen.s,Actor_OnScreen,0x800B8934,0x31 asm/non_matchings/code/z_actor/Actor_HasParent.s,Actor_HasParent,0x800B89F8,0x9 -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_OfferGetItem.s,Actor_OfferGetItem,0x800B8A1C,0x5A +asm/non_matchings/code/z_actor/Actor_OfferGetItemNearby.s,Actor_OfferGetItemNearby,0x800B8B84,0xB +asm/non_matchings/code/z_actor/Actor_OfferCarry.s,Actor_OfferCarry,0x800B8BB0,0x8 +asm/non_matchings/code/z_actor/Actor_OfferGetItemFar.s,Actor_OfferGetItemFar,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/Actor_SetClosestSecretDistance.s,Actor_SetClosestSecretDistance,0x800B8C50,0xA 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 @@ -314,8 +314,8 @@ 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/Actor_PlaySfxAtPos.s,Actor_PlaySfxAtPos,0x800B8EC8,0xB +asm/non_matchings/code/z_actor/Player_PlaySfx.s,Player_PlaySfx,0x800B8E58,0x1C +asm/non_matchings/code/z_actor/Actor_PlaySfx.s,Actor_PlaySfx,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 @@ -326,23 +326,23 @@ asm/non_matchings/code/z_actor/func_800B9084.s,func_800B9084,0x800B9084,0x5 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/Actor_DeactivateLens.s,Actor_DeactivateLens,0x800B90F4,0xB -asm/non_matchings/code/z_actor/func_800B9120.s,func_800B9120,0x800B9120,0x14 +asm/non_matchings/code/z_actor/Actor_InitHalfDaysBit.s,Actor_InitHalfDaysBit,0x800B9120,0x14 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_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 +asm/non_matchings/code/z_actor/Actor_ResetLensActors.s,Actor_ResetLensActors,0x800B9E3C,0x4 +asm/non_matchings/code/z_actor/Actor_AddToLensActors.s,Actor_AddToLensActors,0x800B9E4C,0xE asm/non_matchings/code/z_actor/Actor_DrawLensOverlay.s,Actor_DrawLensOverlay,0x800B9E84,0x1C asm/non_matchings/code/z_actor/Actor_DrawLensActors.s,Actor_DrawLensActors,0x800B9EF4,0xF9 asm/non_matchings/code/z_actor/func_800BA2D8.s,func_800BA2D8,0x800BA2D8,0x9 asm/non_matchings/code/z_actor/func_800BA2FC.s,func_800BA2FC,0x800BA2FC,0x4C 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/Actor_KillAllWithMissingObject.s,Actor_KillAllWithMissingObject,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/Actor_KillAllOnHalfDayChange.s,Actor_KillAllOnHalfDayChange,0x800BA8B8,0x3F 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 @@ -365,7 +365,7 @@ asm/non_matchings/code/z_actor/Actor_SpawnBodyParts.s,Actor_SpawnBodyParts,0x800 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/Actor_GetArrowDmgFlags.s,Actor_GetArrowDmgFlags,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 @@ -373,20 +373,20 @@ asm/non_matchings/code/z_actor/Actor_TestFloorInDirection.s,Actor_TestFloorInDir 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/Actor_AddQuake.s,Actor_AddQuake,0x800BC770,0x1A -asm/non_matchings/code/z_actor/Actor_AddQuakeWithSpeed.s,Actor_AddQuakeWithSpeed,0x800BC7D8,0x1C -asm/non_matchings/code/z_actor/func_800BC848.s,func_800BC848,0x800BC848,0x1C +asm/non_matchings/code/z_actor/Actor_RequestQuake.s,Actor_RequestQuake,0x800BC770,0x1A +asm/non_matchings/code/z_actor/Actor_RequestQuakeWithSpeed.s,Actor_RequestQuakeWithSpeed,0x800BC7D8,0x1C +asm/non_matchings/code/z_actor/Actor_RequestQuakeAndRumble.s,Actor_RequestQuakeAndRumble,0x800BC848,0x1C 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/Actor_GetClosestPosOnPath.s,Actor_GetClosestPosOnPath,0x800BCCDC,0x176 -asm/non_matchings/code/z_actor/func_800BD2B4.s,func_800BD2B4,0x800BD2B4,0x34 -asm/non_matchings/code/z_actor/func_800BD384.s,func_800BD384,0x800BD384,0xCD -asm/non_matchings/code/z_actor/func_800BD6B8.s,func_800BD6B8,0x800BD6B8,0xB -asm/non_matchings/code/z_actor/func_800BD6E4.s,func_800BD6E4,0x800BD6E4,0x69 -asm/non_matchings/code/z_actor/func_800BD888.s,func_800BD888,0x800BD888,0x46 +asm/non_matchings/code/z_actor/Npc_UpdateTalking.s,Npc_UpdateTalking,0x800BD2B4,0x34 +asm/non_matchings/code/z_actor/Npc_TrackPointWithLimits.s,Npc_TrackPointWithLimits,0x800BD384,0xCD +asm/non_matchings/code/z_actor/Npc_GetTrackingPresetMaxPlayerYaw.s,Npc_GetTrackingPresetMaxPlayerYaw,0x800BD6B8,0xB +asm/non_matchings/code/z_actor/Npc_UpdateAutoTurn.s,Npc_UpdateAutoTurn,0x800BD6E4,0x69 +asm/non_matchings/code/z_actor/Npc_TrackPoint.s,Npc_TrackPoint,0x800BD888,0x46 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 @@ -409,7 +409,7 @@ 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/Actor_DrawDamageEffects.s,Actor_DrawDamageEffects,0x800BE680,0x453 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_FaultClient.s,ActorOverlayTable_FaultClient,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 asm/non_matchings/code/z_actor_dlftbls/ActorOverlayTable_Cleanup.s,ActorOverlayTable_Cleanup,0x800BFB40,0x10 @@ -530,18 +530,18 @@ asm/non_matchings/code/z_bgcheck/DynaPoly_Init.s,DynaPoly_Init,0x800C6044,0x15 asm/non_matchings/code/z_bgcheck/DynaPoly_Alloc.s,DynaPoly_Alloc,0x800C6098,0x3C asm/non_matchings/code/z_bgcheck/DynaPoly_SetBgActor.s,DynaPoly_SetBgActor,0x800C6188,0x30 asm/non_matchings/code/z_bgcheck/DynaPoly_GetActor.s,DynaPoly_GetActor,0x800C6248,0x1D -asm/non_matchings/code/z_bgcheck/func_800C62BC.s,func_800C62BC,0x800C62BC,0x16 -asm/non_matchings/code/z_bgcheck/func_800C6314.s,func_800C6314,0x800C6314,0x16 -asm/non_matchings/code/z_bgcheck/func_800C636C.s,func_800C636C,0x800C636C,0x16 -asm/non_matchings/code/z_bgcheck/func_800C63C4.s,func_800C63C4,0x800C63C4,0x16 -asm/non_matchings/code/z_bgcheck/func_800C641C.s,func_800C641C,0x800C641C,0x16 -asm/non_matchings/code/z_bgcheck/func_800C6474.s,func_800C6474,0x800C6474,0x16 +asm/non_matchings/code/z_bgcheck/DynaPoly_DisableCollision.s,DynaPoly_DisableCollision,0x800C62BC,0x16 +asm/non_matchings/code/z_bgcheck/DynaPoly_EnableCollision.s,DynaPoly_EnableCollision,0x800C6314,0x16 +asm/non_matchings/code/z_bgcheck/DynaPoly_DisableCeilingCollision.s,DynaPoly_DisableCeilingCollision,0x800C636C,0x16 +asm/non_matchings/code/z_bgcheck/DynaPoly_EnableCeilingCollision.s,DynaPoly_EnableCeilingCollision,0x800C63C4,0x16 +asm/non_matchings/code/z_bgcheck/DynaPoly_DisableFloorCollision.s,DynaPoly_DisableFloorCollision,0x800C641C,0x16 +asm/non_matchings/code/z_bgcheck/DynaPoly_EnableFloorCollision.s,DynaPoly_EnableFloorCollision,0x800C6474,0x16 asm/non_matchings/code/z_bgcheck/DynaPoly_DeleteBgActor.s,DynaPoly_DeleteBgActor,0x800C64CC,0x22 -asm/non_matchings/code/z_bgcheck/func_800C6554.s,func_800C6554,0x800C6554,0x6 +asm/non_matchings/code/z_bgcheck/DynaPoly_InvalidateLookup.s,DynaPoly_InvalidateLookup,0x800C6554,0x6 asm/non_matchings/code/z_bgcheck/BgCheck_CalcWaterboxDimensions.s,BgCheck_CalcWaterboxDimensions,0x800C656C,0xB3 asm/non_matchings/code/z_bgcheck/DynaPoly_SetBgActorToLists.s,DynaPoly_SetBgActorToLists,0x800C6838,0x2C5 -asm/non_matchings/code/z_bgcheck/BgCheck_ResetFlagsIfLoadedActor.s,BgCheck_ResetFlagsIfLoadedActor,0x800C734C,0x26 -asm/non_matchings/code/z_bgcheck/DynaPoly_Setup.s,DynaPoly_Setup,0x800C73E4,0x62 +asm/non_matchings/code/z_bgcheck/DynaPoly_UnsetAllInteractFlags.s,DynaPoly_UnsetAllInteractFlags,0x800C734C,0x26 +asm/non_matchings/code/z_bgcheck/DynaPoly_UpdateContext.s,DynaPoly_UpdateContext,0x800C73E4,0x62 asm/non_matchings/code/z_bgcheck/func_800C756C.s,func_800C756C,0x800C756C,0x3C asm/non_matchings/code/z_bgcheck/DynaPoly_SetupAllActorMeshes.s,DynaPoly_SetupAllActorMeshes,0x800C765C,0x24 asm/non_matchings/code/z_bgcheck/func_800C76EC.s,func_800C76EC,0x800C76EC,0xA2 @@ -569,21 +569,21 @@ asm/non_matchings/code/z_bgcheck/BgCheck_GetBgCamCount.s,BgCheck_GetBgCamCount,0 asm/non_matchings/code/z_bgcheck/BgCheck_GetBgCamFuncDataImpl.s,BgCheck_GetBgCamFuncDataImpl,0x800C98CC,0x16 asm/non_matchings/code/z_bgcheck/BgCheck_GetBgCamFuncData.s,BgCheck_GetBgCamFuncData,0x800C9924,0x22 asm/non_matchings/code/z_bgcheck/SurfaceType_GetSceneExitIndex.s,SurfaceType_GetSceneExitIndex,0x800C99AC,0xA -asm/non_matchings/code/z_bgcheck/func_800C99D4.s,func_800C99D4,0x800C99D4,0xA +asm/non_matchings/code/z_bgcheck/SurfaceType_GetFloorType.s,SurfaceType_GetFloorType,0x800C99D4,0xA asm/non_matchings/code/z_bgcheck/func_800C99FC.s,func_800C99FC,0x800C99FC,0xA -asm/non_matchings/code/z_bgcheck/func_800C9A24.s,func_800C9A24,0x800C9A24,0xA -asm/non_matchings/code/z_bgcheck/func_800C9A4C.s,func_800C9A4C,0x800C9A4C,0xC -asm/non_matchings/code/z_bgcheck/func_800C9A7C.s,func_800C9A7C,0x800C9A7C,0xD -asm/non_matchings/code/z_bgcheck/func_800C9AB0.s,func_800C9AB0,0x800C9AB0,0xD -asm/non_matchings/code/z_bgcheck/func_800C9AE4.s,func_800C9AE4,0x800C9AE4,0xD -asm/non_matchings/code/z_bgcheck/func_800C9B18.s,func_800C9B18,0x800C9B18,0xA -asm/non_matchings/code/z_bgcheck/func_800C9B40.s,func_800C9B40,0x800C9B40,0xA -asm/non_matchings/code/z_bgcheck/func_800C9B68.s,func_800C9B68,0x800C9B68,0xA +asm/non_matchings/code/z_bgcheck/SurfaceType_GetWallType.s,SurfaceType_GetWallType,0x800C9A24,0xA +asm/non_matchings/code/z_bgcheck/SurfaceType_GetWallFlags.s,SurfaceType_GetWallFlags,0x800C9A4C,0xC +asm/non_matchings/code/z_bgcheck/SurfaceType_CheckWallFlag0.s,SurfaceType_CheckWallFlag0,0x800C9A7C,0xD +asm/non_matchings/code/z_bgcheck/SurfaceType_CheckWallFlag1.s,SurfaceType_CheckWallFlag1,0x800C9AB0,0xD +asm/non_matchings/code/z_bgcheck/SurfaceType_CheckWallFlag2.s,SurfaceType_CheckWallFlag2,0x800C9AE4,0xD +asm/non_matchings/code/z_bgcheck/SurfaceType_GetFloorProperty2.s,SurfaceType_GetFloorProperty2,0x800C9B18,0xA +asm/non_matchings/code/z_bgcheck/SurfaceType_GetFloorProperty.s,SurfaceType_GetFloorProperty,0x800C9B40,0xA +asm/non_matchings/code/z_bgcheck/SurfaceType_IsSoft.s,SurfaceType_IsSoft,0x800C9B68,0xA asm/non_matchings/code/z_bgcheck/SurfaceType_IsHorseBlocked.s,SurfaceType_IsHorseBlocked,0x800C9B90,0xA -asm/non_matchings/code/z_bgcheck/func_800C9BB8.s,func_800C9BB8,0x800C9BB8,0x9 -asm/non_matchings/code/z_bgcheck/SurfaceType_GetSfx.s,SurfaceType_GetSfx,0x800C9BDC,0x12 -asm/non_matchings/code/z_bgcheck/func_800C9C24.s,func_800C9C24,0x800C9C24,0x14 -asm/non_matchings/code/z_bgcheck/SurfaceType_GetSlope.s,SurfaceType_GetSlope,0x800C9C74,0xA +asm/non_matchings/code/z_bgcheck/SurfaceType_GetMaterial.s,SurfaceType_GetMaterial,0x800C9BB8,0x9 +asm/non_matchings/code/z_bgcheck/SurfaceType_GetSfxOffset.s,SurfaceType_GetSfxOffset,0x800C9BDC,0x12 +asm/non_matchings/code/z_bgcheck/SurfaceType_HasMaterialProperty.s,SurfaceType_HasMaterialProperty,0x800C9C24,0x14 +asm/non_matchings/code/z_bgcheck/SurfaceType_GetFloorEffect.s,SurfaceType_GetFloorEffect,0x800C9C74,0xA asm/non_matchings/code/z_bgcheck/SurfaceType_GetLightSettingIndex.s,SurfaceType_GetLightSettingIndex,0x800C9C9C,0xA asm/non_matchings/code/z_bgcheck/SurfaceType_GetEcho.s,SurfaceType_GetEcho,0x800C9CC4,0xA asm/non_matchings/code/z_bgcheck/SurfaceType_IsHookshotSurface.s,SurfaceType_IsHookshotSurface,0x800C9CEC,0xA @@ -606,10 +606,10 @@ asm/non_matchings/code/z_bgcheck/WaterBox_GetLightSettingIndex.s,WaterBox_GetLig asm/non_matchings/code/z_bgcheck/func_800CA6F0.s,func_800CA6F0,0x800CA6F0,0xB8 asm/non_matchings/code/z_bgcheck/func_800CA9D0.s,func_800CA9D0,0x800CA9D0,0x11 asm/non_matchings/code/z_bgcheck/func_800CAA14.s,func_800CAA14,0x800CAA14,0x2F -asm/non_matchings/code/z_bg_collect/BgCheck2_UpdateActorPosition.s,BgCheck2_UpdateActorPosition,0x800CAAD0,0x4F -asm/non_matchings/code/z_bg_collect/BgCheck2_UpdateActorYRotation.s,BgCheck2_UpdateActorYRotation,0x800CAC0C,0x25 -asm/non_matchings/code/z_bg_collect/BgCheck2_AttachToMesh.s,BgCheck2_AttachToMesh,0x800CACA0,0x23 -asm/non_matchings/code/z_bg_collect/BgCheck2_UpdateActorAttachedToMesh.s,BgCheck2_UpdateActorAttachedToMesh,0x800CAD2C,0x39 +asm/non_matchings/code/z_bg_collect/DynaPolyActor_UpdateCarriedActorPos.s,DynaPolyActor_UpdateCarriedActorPos,0x800CAAD0,0x4F +asm/non_matchings/code/z_bg_collect/DynaPolyActor_UpdateCarriedActorRotY.s,DynaPolyActor_UpdateCarriedActorRotY,0x800CAC0C,0x25 +asm/non_matchings/code/z_bg_collect/DynaPolyActor_AttachCarriedActor.s,DynaPolyActor_AttachCarriedActor,0x800CACA0,0x23 +asm/non_matchings/code/z_bg_collect/DynaPolyActor_TransformCarriedActor.s,DynaPolyActor_TransformCarriedActor,0x800CAD2C,0x39 asm/non_matchings/code/z_bg_item/DynaPoly_Init.s,DynaPoly_Init,0x800CAE10,0x9 asm/non_matchings/code/z_bg_item/DynaPoly_LoadMesh.s,DynaPoly_LoadMesh,0x800CAE34,0x12 asm/non_matchings/code/z_bg_item/DynaPoly_ResetState.s,DynaPoly_ResetState,0x800CAE7C,0x3 @@ -629,16 +629,16 @@ asm/non_matchings/code/z_bg_item/DynaPoly_ValidateMove.s,DynaPoly_ValidateMove,0 asm/non_matchings/code/z_camera/Camera_fabsf.s,Camera_fabsf,0x800CB210,0xC asm/non_matchings/code/z_camera/Camera_Vec3fMagnitude.s,Camera_Vec3fMagnitude,0x800CB240,0xC asm/non_matchings/code/z_camera/Camera_QuadraticAttenuation.s,Camera_QuadraticAttenuation,0x800CB270,0x30 -asm/non_matchings/code/z_camera/Camera_LerpCeilF.s,Camera_LerpCeilF,0x800CB330,0x1A -asm/non_matchings/code/z_camera/Camera_LerpCeilS.s,Camera_LerpCeilS,0x800CB398,0x25 -asm/non_matchings/code/z_camera/Camera_LerpFloorS.s,Camera_LerpFloorS,0x800CB42C,0x25 -asm/non_matchings/code/z_camera/Camera_LerpCeilVec3f.s,Camera_LerpCeilVec3f,0x800CB4C0,0x21 +asm/non_matchings/code/z_camera/Camera_ScaledStepToCeilF.s,Camera_ScaledStepToCeilF,0x800CB330,0x1A +asm/non_matchings/code/z_camera/Camera_ScaledStepToCeilS.s,Camera_ScaledStepToCeilS,0x800CB398,0x25 +asm/non_matchings/code/z_camera/Camera_ScaledStepToFloorS.s,Camera_ScaledStepToFloorS,0x800CB42C,0x25 +asm/non_matchings/code/z_camera/Camera_ScaledStepToCeilVec3f.s,Camera_ScaledStepToCeilVec3f,0x800CB4C0,0x21 asm/non_matchings/code/z_camera/Camera_SetUpdateRatesFastPitch.s,Camera_SetUpdateRatesFastPitch,0x800CB544,0x10 asm/non_matchings/code/z_camera/Camera_SetUpdateRatesFastYaw.s,Camera_SetUpdateRatesFastYaw,0x800CB584,0x16 asm/non_matchings/code/z_camera/Camera_SetUpdateRatesSlow.s,Camera_SetUpdateRatesSlow,0x800CB5DC,0xC asm/non_matchings/code/z_camera/Camera_Vec3sToVec3f.s,Camera_Vec3sToVec3f,0x800CB60C,0x1A asm/non_matchings/code/z_camera/Camera_AngleDiffAndScale.s,Camera_AngleDiffAndScale,0x800CB674,0x15 -asm/non_matchings/code/z_camera/Camera_UpdateAtActorOffset.s,Camera_UpdateAtActorOffset,0x800CB6C8,0xE +asm/non_matchings/code/z_camera/Camera_SetFocalActorAtOffset.s,Camera_SetFocalActorAtOffset,0x800CB6C8,0xE asm/non_matchings/code/z_camera/Camera_GetFocalActorHeight.s,Camera_GetFocalActorHeight,0x800CB700,0x20 asm/non_matchings/code/z_camera/Camera_GetRunSpeedLimit.s,Camera_GetRunSpeedLimit,0x800CB780,0x13 asm/non_matchings/code/z_camera/func_800CB7CC.s,func_800CB7CC,0x800CB7CC,0xB @@ -661,41 +661,41 @@ asm/non_matchings/code/z_camera/Camera_IsUsingZoraFins.s,Camera_IsUsingZoraFins, asm/non_matchings/code/z_camera/func_800CBC30.s,func_800CBC30,0x800CBC30,0x15 asm/non_matchings/code/z_camera/func_800CBC84.s,func_800CBC84,0x800CBC84,0xC8 asm/non_matchings/code/z_camera/func_800CBFA4.s,func_800CBFA4,0x800CBFA4,0x17 -asm/non_matchings/code/z_camera/func_800CC000.s,func_800CC000,0x800CC000,0x4A -asm/non_matchings/code/z_camera/func_800CC128.s,func_800CC128,0x800CC128,0x27 -asm/non_matchings/code/z_camera/func_800CC1C4.s,func_800CC1C4,0x800CC1C4,0x27 +asm/non_matchings/code/z_camera/Camera_BgCheckInfo.s,Camera_BgCheckInfo,0x800CC000,0x4A +asm/non_matchings/code/z_camera/Camera_BgCheck.s,Camera_BgCheck,0x800CC128,0x27 +asm/non_matchings/code/z_camera/Camera_CheckOOB.s,Camera_CheckOOB,0x800CC1C4,0x27 asm/non_matchings/code/z_camera/func_800CC260.s,func_800CC260,0x800CC260,0x8A -asm/non_matchings/code/z_camera/func_800CC488.s,func_800CC488,0x800CC488,0x39 -asm/non_matchings/code/z_camera/func_800CC56C.s,func_800CC56C,0x800CC56C,0x17 -asm/non_matchings/code/z_camera/func_800CC5C8.s,func_800CC5C8,0x800CC5C8,0x5E +asm/non_matchings/code/z_camera/Camera_GetFloorYNorm.s,Camera_GetFloorYNorm,0x800CC488,0x39 +asm/non_matchings/code/z_camera/Camera_GetFloorY.s,Camera_GetFloorY,0x800CC56C,0x17 +asm/non_matchings/code/z_camera/Camera_GetFloorYLayer.s,Camera_GetFloorYLayer,0x800CC5C8,0x5E asm/non_matchings/code/z_camera/Camera_GetBgCamOrActorCsCamSetting.s,Camera_GetBgCamOrActorCsCamSetting,0x800CC740,0x1A asm/non_matchings/code/z_camera/Camera_GetBgCamOrActorCsCamFuncData.s,Camera_GetBgCamOrActorCsCamFuncData,0x800CC7A8,0x17 asm/non_matchings/code/z_camera/Camera_GetBgCamIndex.s,Camera_GetBgCamIndex,0x800CC804,0x1C asm/non_matchings/code/z_camera/Camera_GetWaterBoxBgCamSetting.s,Camera_GetWaterBoxBgCamSetting,0x800CC874,0x31 asm/non_matchings/code/z_camera/func_800CC938.s,func_800CC938,0x800CC938,0x8 -asm/non_matchings/code/z_camera/func_800CC958.s,func_800CC958,0x800CC958,0x1A -asm/non_matchings/code/z_camera/func_800CC9C0.s,func_800CC9C0,0x800CC9C0,0xCB +asm/non_matchings/code/z_camera/Camera_CalcXZAngle.s,Camera_CalcXZAngle,0x800CC958,0x1A +asm/non_matchings/code/z_camera/Camera_GetPitchAdjFromFloorHeightDiffs.s,Camera_GetPitchAdjFromFloorHeightDiffs,0x800CC9C0,0xCB asm/non_matchings/code/z_camera/func_800CCCEC.s,func_800CCCEC,0x800CCCEC,0xD8 -asm/non_matchings/code/z_camera/func_800CD04C.s,func_800CD04C,0x800CD04C,0x8F -asm/non_matchings/code/z_camera/func_800CD288.s,func_800CD288,0x800CD288,0x16 -asm/non_matchings/code/z_camera/func_800CD2E0.s,func_800CD2E0,0x800CD2E0,0x4 -asm/non_matchings/code/z_camera/func_800CD2F0.s,func_800CD2F0,0x800CD2F0,0x3D -asm/non_matchings/code/z_camera/func_800CD3E4.s,func_800CD3E4,0x800CD3E4,0x1A +asm/non_matchings/code/z_camera/Camera_CalcUpVec.s,Camera_CalcUpVec,0x800CD04C,0x8F +asm/non_matchings/code/z_camera/Camera_ClampLerpScale.s,Camera_ClampLerpScale,0x800CD288,0x16 +asm/non_matchings/code/z_camera/Camera_ResetActionFuncState.s,Camera_ResetActionFuncState,0x800CD2E0,0x4 +asm/non_matchings/code/z_camera/Camera_UpdateInterface.s,Camera_UpdateInterface,0x800CD2F0,0x3D +asm/non_matchings/code/z_camera/Camera_BgCheckCorner.s,Camera_BgCheckCorner,0x800CD3E4,0x1A asm/non_matchings/code/z_camera/func_800CD44C.s,func_800CD44C,0x800CD44C,0x7A -asm/non_matchings/code/z_camera/func_800CD634.s,func_800CD634,0x800CD634,0x26 +asm/non_matchings/code/z_camera/Camera_CalcSlopeYAdj.s,Camera_CalcSlopeYAdj,0x800CD634,0x26 asm/non_matchings/code/z_camera/func_800CD6CC.s,func_800CD6CC,0x800CD6CC,0xB -asm/non_matchings/code/z_camera/func_800CD6F8.s,func_800CD6F8,0x800CD6F8,0x4F -asm/non_matchings/code/z_camera/func_800CD834.s,func_800CD834,0x800CD834,0x78 -asm/non_matchings/code/z_camera/func_800CDA14.s,func_800CDA14,0x800CDA14,0x56 -asm/non_matchings/code/z_camera/func_800CDB6C.s,func_800CDB6C,0x800CDB6C,0xC0 -asm/non_matchings/code/z_camera/func_800CDE6C.s,func_800CDE6C,0x800CDE6C,0x113 -asm/non_matchings/code/z_camera/func_800CE2B8.s,func_800CE2B8,0x800CE2B8,0xCA -asm/non_matchings/code/z_camera/func_800CE5E0.s,func_800CE5E0,0x800CE5E0,0x6F -asm/non_matchings/code/z_camera/func_800CE79C.s,func_800CE79C,0x800CE79C,0x65 -asm/non_matchings/code/z_camera/func_800CE930.s,func_800CE930,0x800CE930,0x6A -asm/non_matchings/code/z_camera/func_800CEAD8.s,func_800CEAD8,0x800CEAD8,0x58 -asm/non_matchings/code/z_camera/func_800CEC38.s,func_800CEC38,0x800CEC38,0x56 -asm/non_matchings/code/z_camera/func_800CED90.s,func_800CED90,0x800CED90,0x185 +asm/non_matchings/code/z_camera/Camera_CalcAtDefault.s,Camera_CalcAtDefault,0x800CD6F8,0x4F +asm/non_matchings/code/z_camera/Camera_CalcAtForScreen.s,Camera_CalcAtForScreen,0x800CD834,0x78 +asm/non_matchings/code/z_camera/Camera_CalcAtForNormal1.s,Camera_CalcAtForNormal1,0x800CDA14,0x56 +asm/non_matchings/code/z_camera/Camera_CalcAtForParallel.s,Camera_CalcAtForParallel,0x800CDB6C,0xC0 +asm/non_matchings/code/z_camera/Camera_CalcAtForFriendlyLockOn.s,Camera_CalcAtForFriendlyLockOn,0x800CDE6C,0x113 +asm/non_matchings/code/z_camera/Camera_CalcAtForEnemyLockOn.s,Camera_CalcAtForEnemyLockOn,0x800CE2B8,0xCA +asm/non_matchings/code/z_camera/Camera_CalcAtForHorse.s,Camera_CalcAtForHorse,0x800CE5E0,0x6F +asm/non_matchings/code/z_camera/Camera_ClampDist1.s,Camera_ClampDist1,0x800CE79C,0x65 +asm/non_matchings/code/z_camera/Camera_ClampDist2.s,Camera_ClampDist2,0x800CE930,0x6A +asm/non_matchings/code/z_camera/Camera_CalcDefaultPitch.s,Camera_CalcDefaultPitch,0x800CEAD8,0x58 +asm/non_matchings/code/z_camera/Camera_CalcDefaultYaw.s,Camera_CalcDefaultYaw,0x800CEC38,0x56 +asm/non_matchings/code/z_camera/Camera_CalcDefaultSwing.s,Camera_CalcDefaultSwing,0x800CED90,0x185 asm/non_matchings/code/z_camera/Camera_Noop.s,Camera_Noop,0x800CF3A4,0x4 asm/non_matchings/code/z_camera/Camera_Normal1.s,Camera_Normal1,0x800CF3B4,0x530 asm/non_matchings/code/z_camera/Camera_Normal2.s,Camera_Normal2,0x800D0874,0x8 @@ -767,48 +767,48 @@ asm/non_matchings/code/z_camera/Camera_Special6.s,Camera_Special6,0x800DD0FC,0x8 asm/non_matchings/code/z_camera/Camera_Special7.s,Camera_Special7,0x800DD11C,0x8 asm/non_matchings/code/z_camera/Camera_Special8.s,Camera_Special8,0x800DD13C,0x11F asm/non_matchings/code/z_camera/Camera_Special9.s,Camera_Special9,0x800DD5B8,0x1E8 -asm/non_matchings/code/z_camera/Camera_Alloc.s,Camera_Alloc,0x800DDD58,0x14 -asm/non_matchings/code/z_camera/Camera_Free.s,Camera_Free,0x800DDDA8,0xA +asm/non_matchings/code/z_camera/Camera_Create.s,Camera_Create,0x800DDD58,0x14 +asm/non_matchings/code/z_camera/Camera_Destroy.s,Camera_Destroy,0x800DDDA8,0xA asm/non_matchings/code/z_camera/Camera_Init.s,Camera_Init,0x800DDDD0,0x84 asm/non_matchings/code/z_camera/func_800DDFE0.s,func_800DDFE0,0x800DDFE0,0x40 -asm/non_matchings/code/z_camera/func_800DE0E0.s,func_800DE0E0,0x800DE0E0,0x3 -asm/non_matchings/code/z_camera/Camera_InitPlayerSettings.s,Camera_InitPlayerSettings,0x800DE0EC,0x87 +asm/non_matchings/code/z_camera/Camera_Stub800DE0E0.s,Camera_Stub800DE0E0,0x800DE0E0,0x3 +asm/non_matchings/code/z_camera/Camera_InitFocalActorSettings.s,Camera_InitFocalActorSettings,0x800DE0EC,0x87 asm/non_matchings/code/z_camera/Camera_ChangeStatus.s,Camera_ChangeStatus,0x800DE308,0x7 -asm/non_matchings/code/z_camera/func_800DE324.s,func_800DE324,0x800DE324,0xC2 -asm/non_matchings/code/z_camera/func_800DE62C.s,func_800DE62C,0x800DE62C,0x85 -asm/non_matchings/code/z_camera/func_800DE840.s,func_800DE840,0x800DE840,0x14 -asm/non_matchings/code/z_camera/func_800DE890.s,func_800DE890,0x800DE890,0x31 -asm/non_matchings/code/z_camera/func_800DE954.s,func_800DE954,0x800DE954,0x17 +asm/non_matchings/code/z_camera/Camera_UpdateWater.s,Camera_UpdateWater,0x800DE324,0xC2 +asm/non_matchings/code/z_camera/Camera_EarthquakeDay3.s,Camera_EarthquakeDay3,0x800DE62C,0x85 +asm/non_matchings/code/z_camera/Camera_UpdateHotRoom.s,Camera_UpdateHotRoom,0x800DE840,0x14 +asm/non_matchings/code/z_camera/Camera_SetSwordDistortion.s,Camera_SetSwordDistortion,0x800DE890,0x31 +asm/non_matchings/code/z_camera/Camera_RequestGiantsMaskSetting.s,Camera_RequestGiantsMaskSetting,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/Camera_ChangeModeFlags.s,Camera_ChangeModeFlags,0x800DF4D0,0xDC 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/Camera_CheckValidMode.s,Camera_CheckValidMode,0x800DF86C,0x20 +asm/non_matchings/code/z_camera/Camera_ChangeSettingFlags.s,Camera_ChangeSettingFlags,0x800DF8EC,0x77 asm/non_matchings/code/z_camera/Camera_ChangeSetting.s,Camera_ChangeSetting,0x800DFAC8,0x13 -asm/non_matchings/code/z_camera/Camera_ChangeDataIdx.s,Camera_ChangeDataIdx,0x800DFB14,0x42 -asm/non_matchings/code/z_camera/func_800DFC1C.s,func_800DFC1C,0x800DFC1C,0x9 -asm/non_matchings/code/z_camera/func_800DFC40.s,func_800DFC40,0x800DFC40,0xA +asm/non_matchings/code/z_camera/Camera_ChangeActorCsCamIndex.s,Camera_ChangeActorCsCamIndex,0x800DFB14,0x42 +asm/non_matchings/code/z_camera/Camera_GetInputDir.s,Camera_GetInputDir,0x800DFC1C,0x9 +asm/non_matchings/code/z_camera/Camera_GetInputDirPitch.s,Camera_GetInputDirPitch,0x800DFC40,0xA asm/non_matchings/code/z_camera/Camera_GetInputDirYaw.s,Camera_GetInputDirYaw,0x800DFC68,0xA asm/non_matchings/code/z_camera/Camera_GetCamDir.s,Camera_GetCamDir,0x800DFC90,0x9 asm/non_matchings/code/z_camera/Camera_GetCamDirPitch.s,Camera_GetCamDirPitch,0x800DFCB4,0xA asm/non_matchings/code/z_camera/Camera_GetCamDirYaw.s,Camera_GetCamDirYaw,0x800DFCDC,0xA asm/non_matchings/code/z_camera/Camera_AddQuake.s,Camera_AddQuake,0x800DFD04,0x1D asm/non_matchings/code/z_camera/Camera_SetViewParam.s,Camera_SetViewParam,0x800DFD78,0x5E -asm/non_matchings/code/z_camera/func_800DFEF0.s,func_800DFEF0,0x800DFEF0,0xA -asm/non_matchings/code/z_camera/func_800DFF18.s,func_800DFF18,0x800DFF18,0x7 -asm/non_matchings/code/z_camera/func_800DFF34.s,func_800DFF34,0x800DFF34,0x4 -asm/non_matchings/code/z_camera/func_800DFF44.s,func_800DFF44,0x800DFF44,0x7 -asm/non_matchings/code/z_camera/Camera_SetFlags.s,Camera_SetFlags,0x800DFF60,0x9 -asm/non_matchings/code/z_camera/Camera_ClearFlags.s,Camera_ClearFlags,0x800DFF84,0xA +asm/non_matchings/code/z_camera/Camera_UnsetViewFlag.s,Camera_UnsetViewFlag,0x800DFEF0,0xA +asm/non_matchings/code/z_camera/Camera_OverwriteStateFlags.s,Camera_OverwriteStateFlags,0x800DFF18,0x7 +asm/non_matchings/code/z_camera/Camera_ResetActionFuncStateUnused.s,Camera_ResetActionFuncStateUnused,0x800DFF34,0x4 +asm/non_matchings/code/z_camera/Camera_SetCsParams.s,Camera_SetCsParams,0x800DFF44,0x7 +asm/non_matchings/code/z_camera/Camera_SetStateFlag.s,Camera_SetStateFlag,0x800DFF60,0x9 +asm/non_matchings/code/z_camera/Camera_UnsetStateFlag.s,Camera_UnsetStateFlag,0x800DFF84,0xA asm/non_matchings/code/z_camera/Camera_ChangeDoorCam.s,Camera_ChangeDoorCam,0x800DFFAC,0x34 asm/non_matchings/code/z_camera/Camera_Copy.s,Camera_Copy,0x800E007C,0x4C -asm/non_matchings/code/z_camera/func_800E01AC.s,func_800E01AC,0x800E01AC,0x3 +asm/non_matchings/code/z_camera/Camera_IsDbgCamEnabled.s,Camera_IsDbgCamEnabled,0x800E01AC,0x3 asm/non_matchings/code/z_camera/Camera_GetQuakeOffset.s,Camera_GetQuakeOffset,0x800E01B8,0x9 -asm/non_matchings/code/z_camera/func_800E01DC.s,func_800E01DC,0x800E01DC,0x13 -asm/non_matchings/code/z_camera/func_800E0228.s,func_800E0228,0x800E0228,0x4 +asm/non_matchings/code/z_camera/Camera_SetCameraData.s,Camera_SetCameraData,0x800E01DC,0x13 +asm/non_matchings/code/z_camera/Camera_GetNegOne.s,Camera_GetNegOne,0x800E0228,0x4 asm/non_matchings/code/z_camera/func_800E0238.s,func_800E0238,0x800E0238,0x1D -asm/non_matchings/code/z_camera/Camera_SetToTrackActor.s,Camera_SetToTrackActor,0x800E02AC,0x17 +asm/non_matchings/code/z_camera/Camera_SetFocalActor.s,Camera_SetFocalActor,0x800E02AC,0x17 asm/non_matchings/code/z_camera/Camera_SetTargetActor.s,Camera_SetTargetActor,0x800E0308,0x5 asm/non_matchings/code/z_camera/Camera_GetWaterYPos.s,Camera_GetWaterYPos,0x800E031C,0xB asm/non_matchings/code/z_camera/func_800E0348.s,func_800E0348,0x800E0348,0x16 @@ -1033,7 +1033,7 @@ asm/non_matchings/code/code_800E8EA0/Actor_TrackPoint.s,Actor_TrackPoint,0x800E8 asm/non_matchings/code/code_800E8EA0/Actor_TrackPlayerSetFocusHeight.s,Actor_TrackPlayerSetFocusHeight,0x800E9138,0x46 asm/non_matchings/code/code_800E8EA0/Actor_TrackPlayer.s,Actor_TrackPlayer,0x800E9250,0x44 asm/non_matchings/code/z_common_data/func_800E9360.s,func_800E9360,0x800E9360,0x20 -asm/non_matchings/code/z_debug/GameInfo_Init.s,GameInfo_Init,0x800E93E0,0x24 +asm/non_matchings/code/z_debug/Regs_Init.s,Regs_Init,0x800E93E0,0x24 asm/non_matchings/code/z_debug_display/DebugDisplay_Init.s,DebugDisplay_Init,0x800E9470,0x6 asm/non_matchings/code/z_debug_display/DebugDisplay_AddObject.s,DebugDisplay_AddObject,0x800E9488,0x37 asm/non_matchings/code/z_debug_display/DebugDisplay_DrawObjects.s,DebugDisplay_DrawObjects,0x800E9564,0x24 @@ -1041,60 +1041,60 @@ asm/non_matchings/code/z_debug_display/func_800E95F4.s,func_800E95F4,0x800E95F4, asm/non_matchings/code/z_debug_display/func_800E97D8.s,func_800E97D8,0x800E97D8,0x55 asm/non_matchings/code/z_debug_display/func_800E992C.s,func_800E992C,0x800E992C,0x21 asm/non_matchings/code/z_debug_display/func_800E99B0.s,func_800E99B0,0x800E99B0,0xB8 -asm/non_matchings/code/z_debug_mode/func_800E9C90.s,func_800E9C90,0x800E9C90,0x4 -asm/non_matchings/code/z_debug_mode/func_800E9CA0.s,func_800E9CA0,0x800E9CA0,0x17 -asm/non_matchings/code/z_debug_mode/func_800E9CFC.s,func_800E9CFC,0x800E9CFC,0x30 -asm/non_matchings/code/z_debug_mode/func_800E9DBC.s,func_800E9DBC,0x800E9DBC,0x36 -asm/non_matchings/code/z_debug_mode/func_800E9E94.s,func_800E9E94,0x800E9E94,0x39 -asm/non_matchings/code/z_debug_mode/func_800E9F78.s,func_800E9F78,0x800E9F78,0x3A -asm/non_matchings/code/z_demo/Cutscene_Init.s,Cutscene_Init,0x800EA060,0x1D -asm/non_matchings/code/z_demo/Cutscene_Start.s,Cutscene_Start,0x800EA0D4,0x6 -asm/non_matchings/code/z_demo/Cutscene_End.s,Cutscene_End,0x800EA0EC,0x9 -asm/non_matchings/code/z_demo/Cutscene_Update1.s,Cutscene_Update1,0x800EA110,0x13 -asm/non_matchings/code/z_demo/Cutscene_Update2.s,Cutscene_Update2,0x800EA15C,0x2D -asm/non_matchings/code/z_demo/Cutscene_DoNothing.s,Cutscene_DoNothing,0x800EA210,0x4 -asm/non_matchings/code/z_demo/func_800EA220.s,func_800EA220,0x800EA220,0xE -asm/non_matchings/code/z_demo/func_800EA258.s,func_800EA258,0x800EA258,0x18 -asm/non_matchings/code/z_demo/func_800EA2B8.s,func_800EA2B8,0x800EA2B8,0x1B -asm/non_matchings/code/z_demo/Cutscene_Command_Misc.s,Cutscene_Command_Misc,0x800EA324,0x222 -asm/non_matchings/code/z_demo/Cutscene_Command_SetLighting.s,Cutscene_Command_SetLighting,0x800EABAC,0x17 -asm/non_matchings/code/z_demo/Cutscene_Command_PlaySequence.s,Cutscene_Command_PlaySequence,0x800EAC08,0xF -asm/non_matchings/code/z_demo/Cutscene_Command_StopSequence.s,Cutscene_Command_StopSequence,0x800EAC44,0x14 -asm/non_matchings/code/z_demo/Cutscene_Command_FadeSequence.s,Cutscene_Command_FadeSequence,0x800EAC94,0x20 -asm/non_matchings/code/z_demo/Cutscene_Command_PlayAmbienceSequence.s,Cutscene_Command_PlayAmbienceSequence,0x800EAD14,0xD -asm/non_matchings/code/z_demo/func_800EAD48.s,func_800EAD48,0x800EAD48,0xD -asm/non_matchings/code/z_demo/func_800EAD7C.s,func_800EAD7C,0x800EAD7C,0xD -asm/non_matchings/code/z_demo/func_800EADB0.s,func_800EADB0,0x800EADB0,0x47 -asm/non_matchings/code/z_demo/Cutscene_Command_FadeAmbienceSequence.s,Cutscene_Command_FadeAmbienceSequence,0x800EAECC,0x15 -asm/non_matchings/code/z_demo/Cutscene_Command_Rumble.s,Cutscene_Command_Rumble,0x800EAF20,0x30 -asm/non_matchings/code/z_demo/Cutscene_Command_FadeColorScreen.s,Cutscene_Command_FadeColorScreen,0x800EAFE0,0x7F -asm/non_matchings/code/z_demo/Cutscene_Command_SetTime.s,Cutscene_Command_SetTime,0x800EB1DC,0x62 -asm/non_matchings/code/z_demo/Cutscene_TerminatorImpl.s,Cutscene_TerminatorImpl,0x800EB364,0x54 -asm/non_matchings/code/z_demo/Cutscene_Command_Terminator.s,Cutscene_Command_Terminator,0x800EB4B4,0x91 -asm/non_matchings/code/z_demo/Cutscene_Command_ChooseCreditsScenes.s,Cutscene_Command_ChooseCreditsScenes,0x800EB6F8,0x11C -asm/non_matchings/code/z_demo/Cutscene_Command_MotionBlur.s,Cutscene_Command_MotionBlur,0x800EBB68,0x5A -asm/non_matchings/code/z_demo/Cutscene_Command_GiveTatlToPlayer.s,Cutscene_Command_GiveTatlToPlayer,0x800EBCD0,0x24 -asm/non_matchings/code/z_demo/Cutscene_Command_TransitionFX.s,Cutscene_Command_TransitionFX,0x800EBD60,0x246 -asm/non_matchings/code/z_demo/Cutscene_Command_Camera.s,Cutscene_Command_Camera,0x800EC678,0x17 +asm/non_matchings/code/z_debug_mode/Debug_ClearTextDrawFlags.s,Debug_ClearTextDrawFlags,0x800E9C90,0x4 +asm/non_matchings/code/z_debug_mode/Debug_ScreenText.s,Debug_ScreenText,0x800E9CA0,0x17 +asm/non_matchings/code/z_debug_mode/Debug_DrawScreenText.s,Debug_DrawScreenText,0x800E9CFC,0x30 +asm/non_matchings/code/z_debug_mode/DebugCamera_ScreenText.s,DebugCamera_ScreenText,0x800E9DBC,0x36 +asm/non_matchings/code/z_debug_mode/DebugCamera_DrawScreenText.s,DebugCamera_DrawScreenText,0x800E9E94,0x39 +asm/non_matchings/code/z_debug_mode/Debug_DrawText.s,Debug_DrawText,0x800E9F78,0x3A +asm/non_matchings/code/z_demo/Cutscene_InitContext.s,Cutscene_InitContext,0x800EA060,0x1D +asm/non_matchings/code/z_demo/Cutscene_StartManual.s,Cutscene_StartManual,0x800EA0D4,0x6 +asm/non_matchings/code/z_demo/Cutscene_StopManual.s,Cutscene_StopManual,0x800EA0EC,0x9 +asm/non_matchings/code/z_demo/Cutscene_UpdateManual.s,Cutscene_UpdateManual,0x800EA110,0x13 +asm/non_matchings/code/z_demo/Cutscene_UpdateScripted.s,Cutscene_UpdateScripted,0x800EA15C,0x2D +asm/non_matchings/code/z_demo/CutsceneHandler_DoNothing.s,CutsceneHandler_DoNothing,0x800EA210,0x4 +asm/non_matchings/code/z_demo/Cutscene_StepTimer.s,Cutscene_StepTimer,0x800EA220,0xE +asm/non_matchings/code/z_demo/CutsceneHandler_StartManual.s,CutsceneHandler_StartManual,0x800EA258,0x18 +asm/non_matchings/code/z_demo/CutsceneHandler_StartScript.s,CutsceneHandler_StartScript,0x800EA2B8,0x1B +asm/non_matchings/code/z_demo/CutsceneCmd_Misc.s,CutsceneCmd_Misc,0x800EA324,0x222 +asm/non_matchings/code/z_demo/CutsceneCmd_SetLightSetting.s,CutsceneCmd_SetLightSetting,0x800EABAC,0x17 +asm/non_matchings/code/z_demo/CutsceneCmd_StartSequence.s,CutsceneCmd_StartSequence,0x800EAC08,0xF +asm/non_matchings/code/z_demo/CutsceneCmd_StopSequence.s,CutsceneCmd_StopSequence,0x800EAC44,0x14 +asm/non_matchings/code/z_demo/CutsceneCmd_FadeOutSequence.s,CutsceneCmd_FadeOutSequence,0x800EAC94,0x20 +asm/non_matchings/code/z_demo/CutsceneCmd_StartAmbience.s,CutsceneCmd_StartAmbience,0x800EAD14,0xD +asm/non_matchings/code/z_demo/Cutscene_SetSfxReverbIndexTo2.s,Cutscene_SetSfxReverbIndexTo2,0x800EAD48,0xD +asm/non_matchings/code/z_demo/Cutscene_SetSfxReverbIndexTo1.s,Cutscene_SetSfxReverbIndexTo1,0x800EAD7C,0xD +asm/non_matchings/code/z_demo/CutsceneCmd_ModifySequence.s,CutsceneCmd_ModifySequence,0x800EADB0,0x47 +asm/non_matchings/code/z_demo/CutsceneCmd_FadeOutAmbience.s,CutsceneCmd_FadeOutAmbience,0x800EAECC,0x15 +asm/non_matchings/code/z_demo/CutsceneCmd_RumbleController.s,CutsceneCmd_RumbleController,0x800EAF20,0x30 +asm/non_matchings/code/z_demo/CutsceneCmd_TransitionGeneral.s,CutsceneCmd_TransitionGeneral,0x800EAFE0,0x7F +asm/non_matchings/code/z_demo/CutsceneCmd_SetTime.s,CutsceneCmd_SetTime,0x800EB1DC,0x62 +asm/non_matchings/code/z_demo/CutsceneCmd_DestinationDefault.s,CutsceneCmd_DestinationDefault,0x800EB364,0x54 +asm/non_matchings/code/z_demo/CutsceneCmd_Destination.s,CutsceneCmd_Destination,0x800EB4B4,0x91 +asm/non_matchings/code/z_demo/CutsceneCmd_ChooseCreditsScenes.s,CutsceneCmd_ChooseCreditsScenes,0x800EB6F8,0x11C +asm/non_matchings/code/z_demo/CutsceneCmd_MotionBlur.s,CutsceneCmd_MotionBlur,0x800EBB68,0x5A +asm/non_matchings/code/z_demo/CutsceneCmd_GiveTatlToPlayer.s,CutsceneCmd_GiveTatlToPlayer,0x800EBCD0,0x24 +asm/non_matchings/code/z_demo/CutsceneCmd_Transition.s,CutsceneCmd_Transition,0x800EBD60,0x246 +asm/non_matchings/code/z_demo/CutsceneCmd_UpdateCamSpline.s,CutsceneCmd_UpdateCamSpline,0x800EC678,0x17 asm/non_matchings/code/z_demo/Cutscene_CountNormalMasks.s,Cutscene_CountNormalMasks,0x800EC6D4,0x94 -asm/non_matchings/code/z_demo/Cutscene_Command_Textbox.s,Cutscene_Command_Textbox,0x800EC924,0x116 -asm/non_matchings/code/z_demo/func_800ECD7C.s,func_800ECD7C,0x800ECD7C,0x31 -asm/non_matchings/code/z_demo/Cutscene_ProcessCommands.s,Cutscene_ProcessCommands,0x800ECE40,0x2D0 -asm/non_matchings/code/z_demo/func_800ED980.s,func_800ED980,0x800ED980,0x11 -asm/non_matchings/code/z_demo/func_800ED9C4.s,func_800ED9C4,0x800ED9C4,0x10 -asm/non_matchings/code/z_demo/func_800EDA04.s,func_800EDA04,0x800EDA04,0x20 -asm/non_matchings/code/z_demo/func_800EDA84.s,func_800EDA84,0x800EDA84,0x57 -asm/non_matchings/code/z_demo/func_800EDBE0.s,func_800EDBE0,0x800EDBE0,0x74 +asm/non_matchings/code/z_demo/CutsceneCmd_Text.s,CutsceneCmd_Text,0x800EC924,0x116 +asm/non_matchings/code/z_demo/Cutscene_SetActorCue.s,Cutscene_SetActorCue,0x800ECD7C,0x31 +asm/non_matchings/code/z_demo/Cutscene_ProcessScript.s,Cutscene_ProcessScript,0x800ECE40,0x2D0 +asm/non_matchings/code/z_demo/CutsceneHandler_RunScript.s,CutsceneHandler_RunScript,0x800ED980,0x11 +asm/non_matchings/code/z_demo/CutsceneHandler_StopManual.s,CutsceneHandler_StopManual,0x800ED9C4,0x10 +asm/non_matchings/code/z_demo/CutsceneHandler_StopScript.s,CutsceneHandler_StopScript,0x800EDA04,0x20 +asm/non_matchings/code/z_demo/Cutscene_SetupScripted.s,Cutscene_SetupScripted,0x800EDA84,0x57 +asm/non_matchings/code/z_demo/Cutscene_HandleEntranceTriggers.s,Cutscene_HandleEntranceTriggers,0x800EDBE0,0x74 asm/non_matchings/code/z_demo/func_800EDDB0.s,func_800EDDB0,0x800EDDB0,0x3 asm/non_matchings/code/z_demo/func_800EDDBC.s,func_800EDDBC,0x800EDDBC,0x4 -asm/non_matchings/code/z_demo/Cutscene_LoadCutsceneData.s,Cutscene_LoadCutsceneData,0x800EDDCC,0x1A +asm/non_matchings/code/z_demo/Cutscene_StartScripted.s,Cutscene_StartScripted,0x800EDDCC,0x1A asm/non_matchings/code/z_demo/Cutscene_ActorTranslate.s,Cutscene_ActorTranslate,0x800EDE34,0x3C asm/non_matchings/code/z_demo/Cutscene_ActorTranslateAndYaw.s,Cutscene_ActorTranslateAndYaw,0x800EDF24,0x15 asm/non_matchings/code/z_demo/Cutscene_ActorTranslateAndYawSmooth.s,Cutscene_ActorTranslateAndYawSmooth,0x800EDF78,0x55 asm/non_matchings/code/z_demo/Cutscene_ActorTranslateXZAndYawSmooth.s,Cutscene_ActorTranslateXZAndYawSmooth,0x800EE0CC,0x43 asm/non_matchings/code/z_demo/Cutscene_GetSceneLayer.s,Cutscene_GetSceneLayer,0x800EE1D8,0xA -asm/non_matchings/code/z_demo/Cutscene_GetActorActionIndex.s,Cutscene_GetActorActionIndex,0x800EE200,0x27 -asm/non_matchings/code/z_demo/Cutscene_CheckActorAction.s,Cutscene_CheckActorAction,0x800EE29C,0x16 +asm/non_matchings/code/z_demo/Cutscene_GetCueChannel.s,Cutscene_GetCueChannel,0x800EE200,0x27 +asm/non_matchings/code/z_demo/Cutscene_IsCueInChannel.s,Cutscene_IsCueInChannel,0x800EE29C,0x16 asm/non_matchings/code/z_demo/Cutscene_IsPlaying.s,Cutscene_IsPlaying,0x800EE2F4,0xB asm/non_matchings/code/z_draw/GetItem_Draw.s,GetItem_Draw,0x800EE320,0x11 asm/non_matchings/code/z_draw/GetItem_DrawBombchu.s,GetItem_DrawBombchu,0x800EE364,0x27 @@ -1150,31 +1150,31 @@ asm/non_matchings/code/code_800F12D0/func_800F12D0.s,func_800F12D0,0x800F12D0,0x asm/non_matchings/code/code_800F12D0/func_800F1304.s,func_800F1304,0x800F1304,0x1C asm/non_matchings/code/code_800F12D0/func_800F1374.s,func_800F1374,0x800F1374,0x1D asm/non_matchings/code/code_800F12D0/func_800F13E8.s,func_800F13E8,0x800F13E8,0x1E -asm/non_matchings/code/z_eventmgr/func_800F1460.s,func_800F1460,0x800F1460,0x26 -asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCutsceneImpl.s,ActorCutscene_GetCutsceneImpl,0x800F14F8,0x13 -asm/non_matchings/code/z_eventmgr/ActorCutscene_Init.s,ActorCutscene_Init,0x800F1544,0x25 -asm/non_matchings/code/z_eventmgr/func_800F15D8.s,func_800F15D8,0x800F15D8,0x1C -asm/non_matchings/code/z_eventmgr/ActorCutscene_ClearWaiting.s,ActorCutscene_ClearWaiting,0x800F1648,0xC -asm/non_matchings/code/z_eventmgr/ActorCutscene_ClearNextCutscenes.s,ActorCutscene_ClearNextCutscenes,0x800F1678,0xC -asm/non_matchings/code/z_eventmgr/ActorCutscene_MarkNextCutscenes.s,ActorCutscene_MarkNextCutscenes,0x800F16A8,0x55 -asm/non_matchings/code/z_eventmgr/ActorCutscene_End.s,ActorCutscene_End,0x800F17FC,0xA0 -asm/non_matchings/code/z_eventmgr/ActorCutscene_Update.s,ActorCutscene_Update,0x800F1A7C,0x4A -asm/non_matchings/code/z_eventmgr/ActorCutscene_SetIntentToPlay.s,ActorCutscene_SetIntentToPlay,0x800F1BA4,0x10 -asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCanPlayNext.s,ActorCutscene_GetCanPlayNext,0x800F1BE4,0x21 -asm/non_matchings/code/z_eventmgr/ActorCutscene_StartAndSetUnkLinkFields.s,ActorCutscene_StartAndSetUnkLinkFields,0x800F1C68,0x1E -asm/non_matchings/code/z_eventmgr/ActorCutscene_StartAndSetFlag.s,ActorCutscene_StartAndSetFlag,0x800F1CE0,0x29 -asm/non_matchings/code/z_eventmgr/ActorCutscene_Start.s,ActorCutscene_Start,0x800F1D84,0x8E -asm/non_matchings/code/z_eventmgr/ActorCutscene_Stop.s,ActorCutscene_Stop,0x800F1FBC,0x30 -asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCurrentIndex.s,ActorCutscene_GetCurrentIndex,0x800F207C,0x4 -asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCutscene.s,ActorCutscene_GetCutscene,0x800F208C,0xB -asm/non_matchings/code/z_eventmgr/ActorCutscene_GetAdditionalCutscene.s,ActorCutscene_GetAdditionalCutscene,0x800F20B8,0x10 -asm/non_matchings/code/z_eventmgr/ActorCutscene_GetLength.s,ActorCutscene_GetLength,0x800F20F8,0x10 -asm/non_matchings/code/z_eventmgr/func_800F2138.s,func_800F2138,0x800F2138,0x10 -asm/non_matchings/code/z_eventmgr/func_800F2178.s,func_800F2178,0x800F2178,0x10 -asm/non_matchings/code/z_eventmgr/ActorCutscene_GetCurrentSubCamId.s,ActorCutscene_GetCurrentSubCamId,0x800F21B8,0x5 -asm/non_matchings/code/z_eventmgr/func_800F21CC.s,func_800F21CC,0x800F21CC,0x3E +asm/non_matchings/code/z_eventmgr/CutsceneManager_SetHudVisibility.s,CutsceneManager_SetHudVisibility,0x800F1460,0x26 +asm/non_matchings/code/z_eventmgr/CutsceneManager_GetCutsceneEntryImpl.s,CutsceneManager_GetCutsceneEntryImpl,0x800F14F8,0x13 +asm/non_matchings/code/z_eventmgr/CutsceneManager_Init.s,CutsceneManager_Init,0x800F1544,0x25 +asm/non_matchings/code/z_eventmgr/CutsceneManager_StoreCamera.s,CutsceneManager_StoreCamera,0x800F15D8,0x1C +asm/non_matchings/code/z_eventmgr/CutsceneManager_ClearWaiting.s,CutsceneManager_ClearWaiting,0x800F1648,0xC +asm/non_matchings/code/z_eventmgr/CutsceneManager_ClearNextCutscenes.s,CutsceneManager_ClearNextCutscenes,0x800F1678,0xC +asm/non_matchings/code/z_eventmgr/CutsceneManager_MarkNextCutscenes.s,CutsceneManager_MarkNextCutscenes,0x800F16A8,0x55 +asm/non_matchings/code/z_eventmgr/CutsceneManager_End.s,CutsceneManager_End,0x800F17FC,0xA0 +asm/non_matchings/code/z_eventmgr/CutsceneManager_Update.s,CutsceneManager_Update,0x800F1A7C,0x4A +asm/non_matchings/code/z_eventmgr/CutsceneManager_Queue.s,CutsceneManager_Queue,0x800F1BA4,0x10 +asm/non_matchings/code/z_eventmgr/CutsceneManager_IsNext.s,CutsceneManager_IsNext,0x800F1BE4,0x21 +asm/non_matchings/code/z_eventmgr/CutsceneManager_StartWithPlayerCs.s,CutsceneManager_StartWithPlayerCs,0x800F1C68,0x1E +asm/non_matchings/code/z_eventmgr/CutsceneManager_StartWithPlayerCsAndSetFlag.s,CutsceneManager_StartWithPlayerCsAndSetFlag,0x800F1CE0,0x29 +asm/non_matchings/code/z_eventmgr/CutsceneManager_Start.s,CutsceneManager_Start,0x800F1D84,0x8E +asm/non_matchings/code/z_eventmgr/CutsceneManager_Stop.s,CutsceneManager_Stop,0x800F1FBC,0x30 +asm/non_matchings/code/z_eventmgr/CutsceneManager_GetCurrentCsId.s,CutsceneManager_GetCurrentCsId,0x800F207C,0x4 +asm/non_matchings/code/z_eventmgr/CutsceneManager_GetCutsceneEntry.s,CutsceneManager_GetCutsceneEntry,0x800F208C,0xB +asm/non_matchings/code/z_eventmgr/CutsceneManager_GetAdditionalCsId.s,CutsceneManager_GetAdditionalCsId,0x800F20B8,0x10 +asm/non_matchings/code/z_eventmgr/CutsceneManager_GetLength.s,CutsceneManager_GetLength,0x800F20F8,0x10 +asm/non_matchings/code/z_eventmgr/CutsceneManager_GetCutsceneScriptIndex.s,CutsceneManager_GetCutsceneScriptIndex,0x800F2138,0x10 +asm/non_matchings/code/z_eventmgr/CutsceneManager_GetCutsceneCustomValue.s,CutsceneManager_GetCutsceneCustomValue,0x800F2178,0x10 +asm/non_matchings/code/z_eventmgr/CutsceneManager_GetCurrentSubCamId.s,CutsceneManager_GetCurrentSubCamId,0x800F21B8,0x5 +asm/non_matchings/code/z_eventmgr/CutsceneManager_FindEntranceCsId.s,CutsceneManager_FindEntranceCsId,0x800F21CC,0x3E asm/non_matchings/code/z_eventmgr/func_800F22C4.s,func_800F22C4,0x800F22C4,0x40 -asm/non_matchings/code/z_eventmgr/ActorCutscene_SetReturnCamera.s,ActorCutscene_SetReturnCamera,0x800F23C4,0x7 +asm/non_matchings/code/z_eventmgr/CutsceneManager_SetReturnCamera.s,CutsceneManager_SetReturnCamera,0x800F23C4,0x7 asm/non_matchings/code/z_fcurve_data/func_800F23E0.s,func_800F23E0,0x800F23E0,0x26 asm/non_matchings/code/z_fcurve_data/func_800F2478.s,func_800F2478,0x800F2478,0x6A asm/non_matchings/code/z_fcurve_data_skelanime/func_800F2620.s,func_800F2620,0x800F2620,0xC @@ -1222,11 +1222,11 @@ asm/non_matchings/code/z_kanfont/Font_LoadMessageBoxEndIcon.s,Font_LoadMessageBo asm/non_matchings/code/z_kanfont/Font_LoadOrderedFont.s,Font_LoadOrderedFont,0x800F5004,0x23 asm/non_matchings/code/z_kankyo/func_800F5090.s,func_800F5090,0x800F5090,0x11 asm/non_matchings/code/z_kankyo/func_800F50D4.s,func_800F50D4,0x800F50D4,0xE -asm/non_matchings/code/z_kankyo/Kankyo_Init.s,Kankyo_Init,0x800F510C,0x212 +asm/non_matchings/code/z_kankyo/Environment_Init.s,Environment_Init,0x800F510C,0x212 asm/non_matchings/code/z_kankyo/func_800F5954.s,func_800F5954,0x800F5954,0x4E asm/non_matchings/code/z_kankyo/Environment_LerpWeight.s,Environment_LerpWeight,0x800F5A8C,0x21 asm/non_matchings/code/z_kankyo/func_800F5B10.s,func_800F5B10,0x800F5B10,0x70 -asm/non_matchings/code/z_kankyo/func_800F5CD0.s,func_800F5CD0,0x800F5CD0,0x2D9 +asm/non_matchings/code/z_kankyo/Environment_UpdateSkybox.s,Environment_UpdateSkybox,0x800F5CD0,0x2D9 asm/non_matchings/code/z_kankyo/func_800F6834.s,func_800F6834,0x800F6834,0x46 asm/non_matchings/code/z_kankyo/func_800F694C.s,func_800F694C,0x800F694C,0x2E asm/non_matchings/code/z_kankyo/func_800F6A04.s,func_800F6A04,0x800F6A04,0xF @@ -1241,13 +1241,13 @@ asm/non_matchings/code/z_kankyo/func_800F8554.s,func_800F8554,0x800F8554,0xDC asm/non_matchings/code/z_kankyo/func_800F88C4.s,func_800F88C4,0x800F88C4,0x2B asm/non_matchings/code/z_kankyo/func_800F8970.s,func_800F8970,0x800F8970,0x4B asm/non_matchings/code/z_kankyo/func_800F8A9C.s,func_800F8A9C,0x800F8A9C,0x8E -asm/non_matchings/code/z_kankyo/func_800F8CD4.s,func_800F8CD4,0x800F8CD4,0x2C +asm/non_matchings/code/z_kankyo/Environment_Update.s,Environment_Update,0x800F8CD4,0x2C asm/non_matchings/code/z_kankyo/func_800F8D84.s,func_800F8D84,0x800F8D84,0x269 -asm/non_matchings/code/z_kankyo/func_800F9728.s,func_800F9728,0x800F9728,0x3F +asm/non_matchings/code/z_kankyo/Environment_DrawSunLensFlare.s,Environment_DrawSunLensFlare,0x800F9728,0x3F asm/non_matchings/code/z_kankyo/func_800F9824.s,func_800F9824,0x800F9824,0x2DE asm/non_matchings/code/z_kankyo/func_800FA39C.s,func_800FA39C,0x800FA39C,0xA asm/non_matchings/code/z_kankyo/func_800FA3C4.s,func_800FA3C4,0x800FA3C4,0x18E -asm/non_matchings/code/z_kankyo/func_800FA9FC.s,func_800FA9FC,0x800FA9FC,0x2E +asm/non_matchings/code/z_kankyo/Environment_DrawRain.s,Environment_DrawRain,0x800FA9FC,0x2E asm/non_matchings/code/z_kankyo/func_800FAAB4.s,func_800FAAB4,0x800FAAB4,0x5B asm/non_matchings/code/z_kankyo/func_800FAC20.s,func_800FAC20,0x800FAC20,0xD5 asm/non_matchings/code/z_kankyo/func_800FAF74.s,func_800FAF74,0x800FAF74,0x27 @@ -1256,13 +1256,13 @@ asm/non_matchings/code/z_kankyo/Environment_AddLightningBolts.s,Environment_AddL asm/non_matchings/code/z_kankyo/func_800FB388.s,func_800FB388,0x800FB388,0xF4 asm/non_matchings/code/z_kankyo/func_800FB758.s,func_800FB758,0x800FB758,0x97 asm/non_matchings/code/z_kankyo/func_800FB9B4.s,func_800FB9B4,0x800FB9B4,0xC2 -asm/non_matchings/code/z_kankyo/func_800FBCBC.s,func_800FBCBC,0x800FBCBC,0x4C +asm/non_matchings/code/z_kankyo/Environment_DrawCustomLensFlare.s,Environment_DrawCustomLensFlare,0x800FBCBC,0x4C asm/non_matchings/code/z_kankyo/Kankyo_InitGameOverLights.s,Kankyo_InitGameOverLights,0x800FBDEC,0x54 asm/non_matchings/code/z_kankyo/Kankyo_FadeInGameOverLights.s,Kankyo_FadeInGameOverLights,0x800FBF3C,0x87 asm/non_matchings/code/z_kankyo/Kankyo_FadeOutGameOverLights.s,Kankyo_FadeOutGameOverLights,0x800FC158,0xA1 asm/non_matchings/code/z_kankyo/func_800FC3DC.s,func_800FC3DC,0x800FC3DC,0x1A -asm/non_matchings/code/z_kankyo/func_800FC444.s,func_800FC444,0x800FC444,0x82 -asm/non_matchings/code/z_kankyo/func_800FC64C.s,func_800FC64C,0x800FC64C,0x31A +asm/non_matchings/code/z_kankyo/Environment_FillScreen.s,Environment_FillScreen,0x800FC444,0x82 +asm/non_matchings/code/z_kankyo/Environment_DrawSandstorm.s,Environment_DrawSandstorm,0x800FC64C,0x31A asm/non_matchings/code/z_kankyo/func_800FD2B4.s,func_800FD2B4,0x800FD2B4,0xA1 asm/non_matchings/code/z_kankyo/func_800FD538.s,func_800FD538,0x800FD538,0x19 asm/non_matchings/code/z_kankyo/func_800FD59C.s,func_800FD59C,0x800FD59C,0x11 @@ -1395,7 +1395,7 @@ asm/non_matchings/code/z_lights/Lights_FindBufSlot.s,Lights_FindBufSlot,0x801023 asm/non_matchings/code/z_lights/Lights_FreeNode.s,Lights_FreeNode,0x80102464,0x12 asm/non_matchings/code/z_lights/LightContext_Init.s,LightContext_Init,0x801024AC,0x1B asm/non_matchings/code/z_lights/LightContext_SetAmbientColor.s,LightContext_SetAmbientColor,0x80102518,0xB -asm/non_matchings/code/z_lights/func_80102544.s,func_80102544,0x80102544,0xF +asm/non_matchings/code/z_lights/LightContext_SetFog.s,LightContext_SetFog,0x80102544,0xF asm/non_matchings/code/z_lights/LightContext_NewLights.s,LightContext_NewLights,0x80102580,0xE asm/non_matchings/code/z_lights/LightContext_InitList.s,LightContext_InitList,0x801025B8,0x4 asm/non_matchings/code/z_lights/LightContext_DestroyList.s,LightContext_DestroyList,0x801025C8,0x17 @@ -1586,17 +1586,17 @@ asm/non_matchings/code/z_olib/OLib_ClampMinDist.s,OLib_ClampMinDist,0x8010C304,0 asm/non_matchings/code/z_olib/OLib_ClampMaxDist.s,OLib_ClampMaxDist,0x8010C36C,0x1A asm/non_matchings/code/z_olib/OLib_Vec3fDistNormalize.s,OLib_Vec3fDistNormalize,0x8010C3D4,0x2C asm/non_matchings/code/z_olib/OLib_VecSphToVec3f.s,OLib_VecSphToVec3f,0x8010C484,0x2B -asm/non_matchings/code/z_olib/OLib_VecSphGeoToVec3f.s,OLib_VecSphGeoToVec3f,0x8010C530,0x11 +asm/non_matchings/code/z_olib/OLib_VecGeoToVec3f.s,OLib_VecGeoToVec3f,0x8010C530,0x11 asm/non_matchings/code/z_olib/OLib_Vec3fToVecSph.s,OLib_Vec3fToVecSph,0x8010C574,0x55 -asm/non_matchings/code/z_olib/OLib_Vec3fToVecSphGeo.s,OLib_Vec3fToVecSphGeo,0x8010C6C8,0x12 +asm/non_matchings/code/z_olib/OLib_Vec3fToVecGeo.s,OLib_Vec3fToVecGeo,0x8010C6C8,0x12 asm/non_matchings/code/z_olib/OLib_Vec3fDiffToVecSph.s,OLib_Vec3fDiffToVecSph,0x8010C710,0x15 -asm/non_matchings/code/z_olib/OLib_Vec3fDiffToVecSphGeo.s,OLib_Vec3fDiffToVecSphGeo,0x8010C764,0x15 -asm/non_matchings/code/z_olib/OLib_VecSphAddToVec3f.s,OLib_VecSphAddToVec3f,0x8010C7B8,0x20 +asm/non_matchings/code/z_olib/OLib_Vec3fDiffToVecGeo.s,OLib_Vec3fDiffToVecGeo,0x8010C764,0x15 +asm/non_matchings/code/z_olib/OLib_AddVecGeoToVec3f.s,OLib_AddVecGeoToVec3f,0x8010C7B8,0x20 asm/non_matchings/code/z_olib/OLib_Vec3fDiffRad.s,OLib_Vec3fDiffRad,0x8010C838,0x24 asm/non_matchings/code/z_olib/OLib_Vec3fDiffDegF.s,OLib_Vec3fDiffDegF,0x8010C8C8,0x1A asm/non_matchings/code/z_olib/OLib_Vec3fDiffBinAng.s,OLib_Vec3fDiffBinAng,0x8010C930,0x26 -asm/non_matchings/code/z_olib/OLib_DbCameraVec3fDiff.s,OLib_DbCameraVec3fDiff,0x8010C9C8,0x36 -asm/non_matchings/code/z_olib/OLib_DbCameraVec3fSum.s,OLib_DbCameraVec3fSum,0x8010CAA0,0x34 +asm/non_matchings/code/z_olib/OLib_Vec3fDiff.s,OLib_Vec3fDiff,0x8010C9C8,0x36 +asm/non_matchings/code/z_olib/OLib_Vec3fAdd.s,OLib_Vec3fAdd,0x8010CAA0,0x34 asm/non_matchings/code/z_parameter/Gfx_DrawTexRectRGBA16.s,Gfx_DrawTexRectRGBA16,0x8010CB80,0x86 asm/non_matchings/code/z_parameter/Gfx_DrawTexRectIA8.s,Gfx_DrawTexRectIA8,0x8010CD98,0x89 asm/non_matchings/code/z_parameter/Gfx_DrawTexRectIA8_DropShadow.s,Gfx_DrawTexRectIA8_DropShadow,0x8010CFBC,0xC6 @@ -1618,14 +1618,14 @@ asm/non_matchings/code/z_parameter/Interface_SetHudVisibility.s,Interface_SetHud asm/non_matchings/code/z_parameter/Interface_UpdateButtonAlphasByStatus.s,Interface_UpdateButtonAlphasByStatus,0x8010EF9C,0x4E asm/non_matchings/code/z_parameter/Interface_UpdateButtonAlphas.s,Interface_UpdateButtonAlphas,0x8010F0D4,0x35 asm/non_matchings/code/z_parameter/Interface_UpdateHudAlphas.s,Interface_UpdateHudAlphas,0x8010F1A8,0x3A4 -asm/non_matchings/code/z_parameter/func_80110038.s,func_80110038,0x80110038,0x71F -asm/non_matchings/code/z_parameter/func_80111CB4.s,func_80111CB4,0x80111CB4,0x34C +asm/non_matchings/code/z_parameter/Interface_UpdateButtonsPart2.s,Interface_UpdateButtonsPart2,0x80110038,0x71F +asm/non_matchings/code/z_parameter/Interface_UpdateButtonsPart1.s,Interface_UpdateButtonsPart1,0x80111CB4,0x34C asm/non_matchings/code/z_parameter/Interface_SetSceneRestrictions.s,Interface_SetSceneRestrictions,0x801129E4,0x44 asm/non_matchings/code/z_parameter/Interface_Noop.s,Interface_Noop,0x80112AF4,0x2 asm/non_matchings/code/z_parameter/Interface_InitMinigame.s,Interface_InitMinigame,0x80112AFC,0x11 asm/non_matchings/code/z_parameter/Interface_LoadItemIconImpl.s,Interface_LoadItemIconImpl,0x80112B40,0x29 asm/non_matchings/code/z_parameter/Interface_LoadItemIcon.s,Interface_LoadItemIcon,0x80112BE4,0xA -asm/non_matchings/code/z_parameter/func_80112C0C.s,func_80112C0C,0x80112C0C,0x9D +asm/non_matchings/code/z_parameter/Interface_UpdateButtonsAlt.s,Interface_UpdateButtonsAlt,0x80112C0C,0x9D asm/non_matchings/code/z_parameter/Item_Give.s,Item_Give,0x80112E80,0x553 asm/non_matchings/code/z_parameter/Item_CheckObtainabilityImpl.s,Item_CheckObtainabilityImpl,0x801143CC,0x16B asm/non_matchings/code/z_parameter/Item_CheckObtainability.s,Item_CheckObtainability,0x80114978,0xA @@ -1655,15 +1655,15 @@ asm/non_matchings/code/z_parameter/Magic_UpdateAddRequest.s,Magic_UpdateAddReque asm/non_matchings/code/z_parameter/Magic_FlashMeterBorder.s,Magic_FlashMeterBorder,0x80116114,0x8D asm/non_matchings/code/z_parameter/Magic_Update.s,Magic_Update,0x80116348,0x174 asm/non_matchings/code/z_parameter/Magic_DrawMeter.s,Magic_DrawMeter,0x80116918,0x1B0 -asm/non_matchings/code/z_parameter/func_80116FD8.s,func_80116FD8,0x80116FD8,0x38 -asm/non_matchings/code/z_parameter/func_801170B8.s,func_801170B8,0x801170B8,0x12 -asm/non_matchings/code/z_parameter/func_80117100.s,func_80117100,0x80117100,0x248 -asm/non_matchings/code/z_parameter/func_80117A20.s,func_80117A20,0x80117A20,0x6C -asm/non_matchings/code/z_parameter/func_80117BD0.s,func_80117BD0,0x80117BD0,0x12D -asm/non_matchings/code/z_parameter/func_80118084.s,func_80118084,0x80118084,0x203 -asm/non_matchings/code/z_parameter/func_80118890.s,func_80118890,0x80118890,0xC5 -asm/non_matchings/code/z_parameter/func_80118BA4.s,func_80118BA4,0x80118BA4,0x123 -asm/non_matchings/code/z_parameter/func_80119030.s,func_80119030,0x80119030,0x178 +asm/non_matchings/code/z_parameter/Interface_SetPerspectiveView.s,Interface_SetPerspectiveView,0x80116FD8,0x38 +asm/non_matchings/code/z_parameter/Interface_SetOrthoView.s,Interface_SetOrthoView,0x801170B8,0x12 +asm/non_matchings/code/z_parameter/Interface_DrawItemButtons.s,Interface_DrawItemButtons,0x80117100,0x248 +asm/non_matchings/code/z_parameter/Interface_DrawItemIconTexture.s,Interface_DrawItemIconTexture,0x80117A20,0x6C +asm/non_matchings/code/z_parameter/Interface_DrawAmmoCount.s,Interface_DrawAmmoCount,0x80117BD0,0x12D +asm/non_matchings/code/z_parameter/Interface_DrawBButtonIcons.s,Interface_DrawBButtonIcons,0x80118084,0x203 +asm/non_matchings/code/z_parameter/Interface_DrawCButtonIcons.s,Interface_DrawCButtonIcons,0x80118890,0xC5 +asm/non_matchings/code/z_parameter/Interface_DrawAButton.s,Interface_DrawAButton,0x80118BA4,0x123 +asm/non_matchings/code/z_parameter/Interface_DrawPauseMenuEquippingIcons.s,Interface_DrawPauseMenuEquippingIcons,0x80119030,0x178 asm/non_matchings/code/z_parameter/Interface_DrawClock.s,Interface_DrawClock,0x80119610,0x7B4 asm/non_matchings/code/z_parameter/Interface_SetPerfectLetters.s,Interface_SetPerfectLetters,0x8011B4E0,0x38 asm/non_matchings/code/z_parameter/Interface_UpdatePerfectLettersType1.s,Interface_UpdatePerfectLettersType1,0x8011B5C0,0x108 @@ -1735,23 +1735,23 @@ asm/non_matchings/code/z_player_lib/Player_HasMirrorShieldEquipped.s,Player_HasM asm/non_matchings/code/z_player_lib/Player_IsHoldingMirrorShield.s,Player_IsHoldingMirrorShield,0x80124088,0x10 asm/non_matchings/code/z_player_lib/Player_IsHoldingHookshot.s,Player_IsHoldingHookshot,0x801240C8,0x5 asm/non_matchings/code/z_player_lib/func_801240DC.s,func_801240DC,0x801240DC,0xD -asm/non_matchings/code/z_player_lib/func_80124110.s,func_80124110,0x80124110,0xE -asm/non_matchings/code/z_player_lib/func_80124148.s,func_80124148,0x80124148,0x8 -asm/non_matchings/code/z_player_lib/Player_ActionToMeleeWeapon.s,Player_ActionToMeleeWeapon,0x80124168,0xA +asm/non_matchings/code/z_player_lib/Player_BButtonSwordFromIA.s,Player_BButtonSwordFromIA,0x80124110,0xE +asm/non_matchings/code/z_player_lib/Player_GetHeldBButtonSword.s,Player_GetHeldBButtonSword,0x80124148,0x8 +asm/non_matchings/code/z_player_lib/Player_MeleeWeaponFromIA.s,Player_MeleeWeaponFromIA,0x80124168,0xA asm/non_matchings/code/z_player_lib/Player_GetMeleeWeaponHeld.s,Player_GetMeleeWeaponHeld,0x80124190,0x9 asm/non_matchings/code/z_player_lib/Player_IsHoldingTwoHandedWeapon.s,Player_IsHoldingTwoHandedWeapon,0x801241B4,0xB -asm/non_matchings/code/z_player_lib/Player_ActionToBottle.s,Player_ActionToBottle,0x801241E0,0xB +asm/non_matchings/code/z_player_lib/Player_BottleFromIA.s,Player_BottleFromIA,0x801241E0,0xB asm/non_matchings/code/z_player_lib/Player_GetBottleHeld.s,Player_GetBottleHeld,0x8012420C,0x8 -asm/non_matchings/code/z_player_lib/Player_ActionToExplosive.s,Player_ActionToExplosive,0x8012422C,0xB +asm/non_matchings/code/z_player_lib/Player_ExplosiveFromIA.s,Player_ExplosiveFromIA,0x8012422C,0xB asm/non_matchings/code/z_player_lib/Player_GetExplosiveHeld.s,Player_GetExplosiveHeld,0x80124258,0x8 -asm/non_matchings/code/z_player_lib/Player_ActionToSword.s,Player_ActionToSword,0x80124278,0xF +asm/non_matchings/code/z_player_lib/Player_SwordFromIA.s,Player_SwordFromIA,0x80124278,0xF asm/non_matchings/code/z_player_lib/func_801242B4.s,func_801242B4,0x801242B4,0xA asm/non_matchings/code/z_player_lib/Player_GetEnvironmentalHazard.s,Player_GetEnvironmentalHazard,0x801242DC,0x51 -asm/non_matchings/code/z_player_lib/func_80124420.s,func_80124420,0x80124420,0x7E +asm/non_matchings/code/z_player_lib/Player_UpdateBunnyEars.s,Player_UpdateBunnyEars,0x80124420,0x7E asm/non_matchings/code/z_player_lib/func_80124618.s,func_80124618,0x80124618,0x37 asm/non_matchings/code/z_player_lib/Player_DrawImpl.s,Player_DrawImpl,0x801246F4,0x5F -asm/non_matchings/code/z_player_lib/func_80124870.s,func_80124870,0x80124870,0x115 -asm/non_matchings/code/z_player_lib/func_80124CC4.s,func_80124CC4,0x80124CC4,0x95 +asm/non_matchings/code/z_player_lib/Player_AdjustSingleLeg.s,Player_AdjustSingleLeg,0x80124870,0x115 +asm/non_matchings/code/z_player_lib/Player_DrawHookshotReticle.s,Player_DrawHookshotReticle,0x80124CC4,0x95 asm/non_matchings/code/z_player_lib/func_80124F18.s,func_80124F18,0x80124F18,0x36 asm/non_matchings/code/z_player_lib/func_80124FF0.s,func_80124FF0,0x80124FF0,0x75 asm/non_matchings/code/z_player_lib/func_801251C4.s,func_801251C4,0x801251C4,0x55 @@ -1760,13 +1760,13 @@ asm/non_matchings/code/z_player_lib/func_80125340.s,func_80125340,0x80125340,0xB asm/non_matchings/code/z_player_lib/func_8012536C.s,func_8012536C,0x8012536C,0xE asm/non_matchings/code/z_player_lib/Player_DrawZoraShield.s,Player_DrawZoraShield,0x801253A4,0x57 asm/non_matchings/code/z_player_lib/func_80125500.s,func_80125500,0x80125500,0x20 -asm/non_matchings/code/z_player_lib/func_80125580.s,func_80125580,0x80125580,0x1D8 +asm/non_matchings/code/z_player_lib/Player_OverrideLimbDrawGameplayCommon.s,Player_OverrideLimbDrawGameplayCommon,0x80125580,0x1D8 asm/non_matchings/code/z_player_lib/func_80125CE0.s,func_80125CE0,0x80125CE0,0x1B -asm/non_matchings/code/z_player_lib/func_80125D4C.s,func_80125D4C,0x80125D4C,0x15F -asm/non_matchings/code/z_player_lib/func_801262C8.s,func_801262C8,0x801262C8,0x4D -asm/non_matchings/code/z_player_lib/func_801263FC.s,func_801263FC,0x801263FC,0x11 +asm/non_matchings/code/z_player_lib/Player_OverrideLimbDrawGameplayDefault.s,Player_OverrideLimbDrawGameplayDefault,0x80125D4C,0x15F +asm/non_matchings/code/z_player_lib/Player_OverrideLimbDrawGameplayFirstPerson.s,Player_OverrideLimbDrawGameplayFirstPerson,0x801262C8,0x4D +asm/non_matchings/code/z_player_lib/Player_OverrideLimbDrawGameplayCrawling.s,Player_OverrideLimbDrawGameplayCrawling,0x801263FC,0x11 asm/non_matchings/code/z_player_lib/func_80126440.s,func_80126440,0x80126440,0x62 -asm/non_matchings/code/z_player_lib/func_801265C8.s,func_801265C8,0x801265C8,0x35 +asm/non_matchings/code/z_player_lib/Player_UpdateShieldCollider.s,Player_UpdateShieldCollider,0x801265C8,0x35 asm/non_matchings/code/z_player_lib/func_8012669C.s,func_8012669C,0x8012669C,0x5B asm/non_matchings/code/z_player_lib/Player_DrawGetItemImpl.s,Player_DrawGetItemImpl,0x80126808,0x5D asm/non_matchings/code/z_player_lib/Player_DrawGetItem.s,Player_DrawGetItem,0x8012697C,0x4E @@ -1781,13 +1781,13 @@ asm/non_matchings/code/z_player_lib/Player_DrawCircusLeadersMask.s,Player_DrawCi asm/non_matchings/code/z_player_lib/Player_DrawBlastMask.s,Player_DrawBlastMask,0x801278F8,0x5A asm/non_matchings/code/z_player_lib/Player_DrawBunnyHood.s,Player_DrawBunnyHood,0x80127A60,0x41 asm/non_matchings/code/z_player_lib/func_80127B64.s,func_80127B64,0x80127B64,0x21 -asm/non_matchings/code/z_player_lib/func_80127BE8.s,func_80127BE8,0x80127BE8,0x6F +asm/non_matchings/code/z_player_lib/Player_DrawStrayFairyParticles.s,Player_DrawStrayFairyParticles,0x80127BE8,0x6F asm/non_matchings/code/z_player_lib/func_80127DA4.s,func_80127DA4,0x80127DA4,0x179 asm/non_matchings/code/z_player_lib/func_80128388.s,func_80128388,0x80128388,0x46 asm/non_matchings/code/z_player_lib/Player_DrawGreatFairysMask.s,Player_DrawGreatFairysMask,0x801284A0,0x68 asm/non_matchings/code/z_player_lib/func_80128640.s,func_80128640,0x80128640,0x14D -asm/non_matchings/code/z_player_lib/func_80128B74.s,func_80128B74,0x80128B74,0x17 -asm/non_matchings/code/z_player_lib/func_80128BD0.s,func_80128BD0,0x80128BD0,0x4C8 +asm/non_matchings/code/z_player_lib/Player_SetFeetPos.s,Player_SetFeetPos,0x80128B74,0x17 +asm/non_matchings/code/z_player_lib/Player_PostLimbDrawGameplay.s,Player_PostLimbDrawGameplay,0x80128BD0,0x4C8 asm/non_matchings/code/z_prenmi/PreNMI_Stop.s,PreNMI_Stop,0x80129EF0,0x5 asm/non_matchings/code/z_prenmi/PreNMI_Update.s,PreNMI_Update,0x80129F04,0x12 asm/non_matchings/code/z_prenmi/PreNMI_Draw.s,PreNMI_Draw,0x80129F4C,0x2B @@ -1803,28 +1803,28 @@ asm/non_matchings/code/z_quake/Quake_CallbackType3.s,Quake_CallbackType3,0x8012A asm/non_matchings/code/z_quake/Quake_CallbackType2.s,Quake_CallbackType2,0x8012A4D0,0x1C asm/non_matchings/code/z_quake/Quake_CallbackType4.s,Quake_CallbackType4,0x8012A540,0x26 asm/non_matchings/code/z_quake/Quake_GetFreeIndex.s,Quake_GetFreeIndex,0x8012A5D8,0x18 -asm/non_matchings/code/z_quake/Quake_AddImpl.s,Quake_AddImpl,0x8012A638,0x2E -asm/non_matchings/code/z_quake/Quake_RemoveRequest.s,Quake_RemoveRequest,0x8012A6F0,0xA +asm/non_matchings/code/z_quake/Quake_RequestImpl.s,Quake_RequestImpl,0x8012A638,0x2E +asm/non_matchings/code/z_quake/Quake_Remove.s,Quake_Remove,0x8012A6F0,0xA asm/non_matchings/code/z_quake/Quake_GetRequest.s,Quake_GetRequest,0x8012A718,0x17 asm/non_matchings/code/z_quake/Quake_SetValue.s,Quake_SetValue,0x8012A774,0x4D asm/non_matchings/code/z_quake/Quake_SetSpeed.s,Quake_SetSpeed,0x8012A8A8,0x12 -asm/non_matchings/code/z_quake/Quake_SetCountdown.s,Quake_SetCountdown,0x8012A8F0,0x14 -asm/non_matchings/code/z_quake/Quake_GetCountdown.s,Quake_GetCountdown,0x8012A940,0xE -asm/non_matchings/code/z_quake/Quake_SetQuakeValues.s,Quake_SetQuakeValues,0x8012A978,0x1A -asm/non_matchings/code/z_quake/Quake_SetQuakeValues2.s,Quake_SetQuakeValues2,0x8012A9E0,0x1A +asm/non_matchings/code/z_quake/Quake_SetDuration.s,Quake_SetDuration,0x8012A8F0,0x14 +asm/non_matchings/code/z_quake/Quake_GetTimeLeft.s,Quake_GetTimeLeft,0x8012A940,0xE +asm/non_matchings/code/z_quake/Quake_SetPerturbations.s,Quake_SetPerturbations,0x8012A978,0x1A +asm/non_matchings/code/z_quake/Quake_SetOrientation.s,Quake_SetOrientation,0x8012A9E0,0x1A asm/non_matchings/code/z_quake/Quake_Init.s,Quake_Init,0x8012AA48,0x15 -asm/non_matchings/code/z_quake/Quake_Add.s,Quake_Add,0x8012AA9C,0x9 -asm/non_matchings/code/z_quake/Quake_Remove.s,Quake_Remove,0x8012AAC0,0x12 -asm/non_matchings/code/z_quake/Quake_Calc.s,Quake_Calc,0x8012AB08,0xD8 +asm/non_matchings/code/z_quake/Quake_Request.s,Quake_Request,0x8012AA9C,0x9 +asm/non_matchings/code/z_quake/Quake_RemoveRequest.s,Quake_RemoveRequest,0x8012AAC0,0x12 +asm/non_matchings/code/z_quake/Quake_Update.s,Quake_Update,0x8012AB08,0xD8 asm/non_matchings/code/z_quake/Distortion_Init.s,Distortion_Init,0x8012AE68,0x11 -asm/non_matchings/code/z_quake/Distortion_SetCountdown.s,Distortion_SetCountdown,0x8012AEAC,0xA -asm/non_matchings/code/z_quake/Distortion_GetCountdown.s,Distortion_GetCountdown,0x8012AED4,0x4 +asm/non_matchings/code/z_quake/Distortion_SetDuration.s,Distortion_SetDuration,0x8012AEAC,0xA +asm/non_matchings/code/z_quake/Distortion_GetTimeLeft.s,Distortion_GetTimeLeft,0x8012AED4,0x4 asm/non_matchings/code/z_quake/Distortion_GetType.s,Distortion_GetType,0x8012AEE4,0x4 -asm/non_matchings/code/z_quake/Distortion_SetType.s,Distortion_SetType,0x8012AEF4,0x9 -asm/non_matchings/code/z_quake/Distortion_ClearType.s,Distortion_ClearType,0x8012AF18,0x8 +asm/non_matchings/code/z_quake/Distortion_Request.s,Distortion_Request,0x8012AEF4,0x9 +asm/non_matchings/code/z_quake/Distortion_RemoveRequest.s,Distortion_RemoveRequest,0x8012AF18,0x8 asm/non_matchings/code/z_quake/Distortion_GetUnderwaterCurrentSpeed.s,Distortion_GetUnderwaterCurrentSpeed,0x8012AF38,0x19 asm/non_matchings/code/z_quake/Distortion_Update.s,Distortion_Update,0x8012AF9C,0x313 -asm/non_matchings/code/z_quake/Quake_NumActiveQuakes.s,Quake_NumActiveQuakes,0x8012BBE8,0x1A +asm/non_matchings/code/z_quake/Quake_GetNumActiveQuakes.s,Quake_GetNumActiveQuakes,0x8012BBE8,0x1A asm/non_matchings/code/z_rcp/Gfx_SetFog.s,Gfx_SetFog,0x8012BC50,0x4F asm/non_matchings/code/z_rcp/Gfx_SetFogWithSync.s,Gfx_SetFogWithSync,0x8012BD8C,0x5F asm/non_matchings/code/z_rcp/Gfx_SetFog2.s,Gfx_SetFog2,0x8012BF08,0xD @@ -1905,14 +1905,14 @@ asm/non_matchings/code/z_rcp/Gfx_PrimColor.s,Gfx_PrimColor,0x8012CEA8,0x19 asm/non_matchings/code/z_rcp/func_8012CF0C.s,func_8012CF0C,0x8012CF0C,0x11A asm/non_matchings/code/z_rcp/func_8012D374.s,func_8012D374,0x8012D374,0x26 asm/non_matchings/code/z_rcp/func_8012D40C.s,func_8012D40C,0x8012D40C,0x3D -asm/non_matchings/code/z_room/Room_nop8012D510.s,Room_nop8012D510,0x8012D510,0x6 -asm/non_matchings/code/z_room/Room_DrawType3Mesh.s,Room_DrawType3Mesh,0x8012D528,0x5 -asm/non_matchings/code/z_room/Room_DrawType0Mesh.s,Room_DrawType0Mesh,0x8012D53C,0x85 -asm/non_matchings/code/z_room/Room_DrawType2Mesh.s,Room_DrawType2Mesh,0x8012D750,0x1E6 -asm/non_matchings/code/z_room/func_8012DEE8.s,func_8012DEE8,0x8012DEE8,0xDB -asm/non_matchings/code/z_room/func_8012E254.s,func_8012E254,0x8012E254,0x36 -asm/non_matchings/code/z_room/func_8012E32C.s,func_8012E32C,0x8012E32C,0xDF -asm/non_matchings/code/z_room/Room_DrawType1Mesh.s,Room_DrawType1Mesh,0x8012E6A8,0x1A +asm/non_matchings/code/z_room/Room_Noop.s,Room_Noop,0x8012D510,0x6 +asm/non_matchings/code/z_room/Room_DrawNone.s,Room_DrawNone,0x8012D528,0x5 +asm/non_matchings/code/z_room/Room_DrawNormal.s,Room_DrawNormal,0x8012D53C,0x85 +asm/non_matchings/code/z_room/Room_DrawCullable.s,Room_DrawCullable,0x8012D750,0x1E6 +asm/non_matchings/code/z_room/Room_DrawImageSingle.s,Room_DrawImageSingle,0x8012DEE8,0xDB +asm/non_matchings/code/z_room/Room_GetImageMultiBgEntry.s,Room_GetImageMultiBgEntry,0x8012E254,0x36 +asm/non_matchings/code/z_room/Room_DrawImageMulti.s,Room_DrawImageMulti,0x8012E32C,0xDF +asm/non_matchings/code/z_room/Room_DrawImage.s,Room_DrawImage,0x8012E6A8,0x1A asm/non_matchings/code/z_room/Room_Init.s,Room_Init,0x8012E710,0x10 asm/non_matchings/code/z_room/Room_AllocateAndLoad.s,Room_AllocateAndLoad,0x8012E750,0x87 asm/non_matchings/code/z_room/Room_StartRoomTransition.s,Room_StartRoomTransition,0x8012E96C,0x4F @@ -1936,43 +1936,43 @@ asm/non_matchings/code/z_scene/Object_GetIndex.s,Object_GetIndex,0x8012F608,0x18 asm/non_matchings/code/z_scene/Object_IsLoaded.s,Object_IsLoaded,0x8012F668,0xC asm/non_matchings/code/z_scene/Object_LoadAll.s,Object_LoadAll,0x8012F698,0x29 asm/non_matchings/code/z_scene/func_8012F73C.s,func_8012F73C,0x8012F73C,0x18 -asm/non_matchings/code/z_scene/Scene_HeaderCmdSpawnList.s,Scene_HeaderCmdSpawnList,0x8012F79C,0x5C -asm/non_matchings/code/z_scene/Scene_HeaderCmdActorList.s,Scene_HeaderCmdActorList,0x8012F90C,0x12 -asm/non_matchings/code/z_scene/Scene_HeaderCmdActorCutsceneCamList.s,Scene_HeaderCmdActorCutsceneCamList,0x8012F954,0xC -asm/non_matchings/code/z_scene/Scene_HeaderCmdColHeader.s,Scene_HeaderCmdColHeader,0x8012F984,0x28 -asm/non_matchings/code/z_scene/Scene_HeaderCmdRoomList.s,Scene_HeaderCmdRoomList,0x8012FA24,0x11 -asm/non_matchings/code/z_scene/Scene_HeaderCmdEntranceList.s,Scene_HeaderCmdEntranceList,0x8012FA68,0xC -asm/non_matchings/code/z_scene/Scene_HeaderCmdSpecialFiles.s,Scene_HeaderCmdSpecialFiles,0x8012FA98,0x32 -asm/non_matchings/code/z_scene/Scene_HeaderCmdRoomBehavior.s,Scene_HeaderCmdRoomBehavior,0x8012FB60,0x22 -asm/non_matchings/code/z_scene/Scene_HeaderCmdMesh.s,Scene_HeaderCmdMesh,0x8012FBE8,0xC -asm/non_matchings/code/z_scene/Scene_HeaderCmdObjectList.s,Scene_HeaderCmdObjectList,0x8012FC18,0x63 -asm/non_matchings/code/z_scene/Scene_HeaderCmdLightList.s,Scene_HeaderCmdLightList,0x8012FDA4,0x22 -asm/non_matchings/code/z_scene/Scene_HeaderCmdPathList.s,Scene_HeaderCmdPathList,0x8012FE2C,0xC -asm/non_matchings/code/z_scene/Scene_HeaderCmdTransiActorList.s,Scene_HeaderCmdTransiActorList,0x8012FE5C,0x18 +asm/non_matchings/code/z_scene/Scene_CommandSpawnList.s,Scene_CommandSpawnList,0x8012F79C,0x5C +asm/non_matchings/code/z_scene/Scene_CommandActorList.s,Scene_CommandActorList,0x8012F90C,0x12 +asm/non_matchings/code/z_scene/Scene_CommandActorCutsceneCamList.s,Scene_CommandActorCutsceneCamList,0x8012F954,0xC +asm/non_matchings/code/z_scene/Scene_CommandCollisionHeader.s,Scene_CommandCollisionHeader,0x8012F984,0x28 +asm/non_matchings/code/z_scene/Scene_CommandRoomList.s,Scene_CommandRoomList,0x8012FA24,0x11 +asm/non_matchings/code/z_scene/Scene_CommandEntranceList.s,Scene_CommandEntranceList,0x8012FA68,0xC +asm/non_matchings/code/z_scene/Scene_CommandSpecialFiles.s,Scene_CommandSpecialFiles,0x8012FA98,0x32 +asm/non_matchings/code/z_scene/Scene_CommandRoomBehavior.s,Scene_CommandRoomBehavior,0x8012FB60,0x22 +asm/non_matchings/code/z_scene/Scene_CommandMesh.s,Scene_CommandMesh,0x8012FBE8,0xC +asm/non_matchings/code/z_scene/Scene_CommandObjectList.s,Scene_CommandObjectList,0x8012FC18,0x63 +asm/non_matchings/code/z_scene/Scene_CommandLightList.s,Scene_CommandLightList,0x8012FDA4,0x22 +asm/non_matchings/code/z_scene/Scene_CommandPathList.s,Scene_CommandPathList,0x8012FE2C,0xC +asm/non_matchings/code/z_scene/Scene_CommandTransiActorList.s,Scene_CommandTransiActorList,0x8012FE5C,0x18 asm/non_matchings/code/z_scene/Door_InitContext.s,Door_InitContext,0x8012FEBC,0x4 -asm/non_matchings/code/z_scene/Scene_HeaderCmdEnvLightSettings.s,Scene_HeaderCmdEnvLightSettings,0x8012FECC,0x11 +asm/non_matchings/code/z_scene/Scene_CommandEnvLightSettings.s,Scene_CommandEnvLightSettings,0x8012FECC,0x11 asm/non_matchings/code/z_scene/Scene_LoadAreaTextures.s,Scene_LoadAreaTextures,0x8012FF10,0x1F -asm/non_matchings/code/z_scene/Scene_HeaderCmdSkyboxSettings.s,Scene_HeaderCmdSkyboxSettings,0x8012FF8C,0x19 -asm/non_matchings/code/z_scene/Scene_HeaderCmdSkyboxDisables.s,Scene_HeaderCmdSkyboxDisables,0x8012FFF0,0xA -asm/non_matchings/code/z_scene/Scene_HeaderCmdTimeSettings.s,Scene_HeaderCmdTimeSettings,0x80130018,0xC9 -asm/non_matchings/code/z_scene/Scene_HeaderCmdWindSettings.s,Scene_HeaderCmdWindSettings,0x8013033C,0x19 -asm/non_matchings/code/z_scene/Scene_HeaderCmdExitList.s,Scene_HeaderCmdExitList,0x801303A0,0xC -asm/non_matchings/code/z_scene/Scene_HeaderCmd09.s,Scene_HeaderCmd09,0x801303D0,0x4 -asm/non_matchings/code/z_scene/Scene_HeaderCmdSoundSettings.s,Scene_HeaderCmdSoundSettings,0x801303E0,0x17 -asm/non_matchings/code/z_scene/Scene_HeaderCmdEchoSetting.s,Scene_HeaderCmdEchoSetting,0x8013043C,0x6 -asm/non_matchings/code/z_scene/Scene_HeaderCmdAltHeaderList.s,Scene_HeaderCmdAltHeaderList,0x80130454,0x1E -asm/non_matchings/code/z_scene/Scene_HeaderCmdCutsceneList.s,Scene_HeaderCmdCutsceneList,0x801304CC,0xD -asm/non_matchings/code/z_scene/Scene_HeaderCmdActorCutsceneList.s,Scene_HeaderCmdActorCutsceneList,0x80130500,0x10 -asm/non_matchings/code/z_scene/Scene_HeaderCmdMiniMap.s,Scene_HeaderCmdMiniMap,0x80130540,0xE -asm/non_matchings/code/z_scene/Scene_HeaderCmd1D.s,Scene_HeaderCmd1D,0x80130578,0x4 -asm/non_matchings/code/z_scene/Scene_HeaderCmdMiniMapCompassInfo.s,Scene_HeaderCmdMiniMapCompassInfo,0x80130588,0xA -asm/non_matchings/code/z_scene/Scene_HeaderCmdSetRegionVisitedFlag.s,Scene_HeaderCmdSetRegionVisitedFlag,0x801305B0,0x31 -asm/non_matchings/code/z_scene/Scene_HeaderCmdAnimatedMaterials.s,Scene_HeaderCmdAnimatedMaterials,0x80130674,0xC +asm/non_matchings/code/z_scene/Scene_CommandSkyboxSettings.s,Scene_CommandSkyboxSettings,0x8012FF8C,0x19 +asm/non_matchings/code/z_scene/Scene_CommandSkyboxDisables.s,Scene_CommandSkyboxDisables,0x8012FFF0,0xA +asm/non_matchings/code/z_scene/Scene_CommandTimeSettings.s,Scene_CommandTimeSettings,0x80130018,0xC9 +asm/non_matchings/code/z_scene/Scene_CommandWindSettings.s,Scene_CommandWindSettings,0x8013033C,0x19 +asm/non_matchings/code/z_scene/Scene_CommandExitList.s,Scene_CommandExitList,0x801303A0,0xC +asm/non_matchings/code/z_scene/Scene_Command09.s,Scene_Command09,0x801303D0,0x4 +asm/non_matchings/code/z_scene/Scene_CommandSoundSettings.s,Scene_CommandSoundSettings,0x801303E0,0x17 +asm/non_matchings/code/z_scene/Scene_CommandEchoSetting.s,Scene_CommandEchoSetting,0x8013043C,0x6 +asm/non_matchings/code/z_scene/Scene_CommandAltHeaderList.s,Scene_CommandAltHeaderList,0x80130454,0x1E +asm/non_matchings/code/z_scene/Scene_CommandCutsceneScriptList.s,Scene_CommandCutsceneScriptList,0x801304CC,0xD +asm/non_matchings/code/z_scene/Scene_CommandCutsceneList.s,Scene_CommandCutsceneList,0x80130500,0x10 +asm/non_matchings/code/z_scene/Scene_CommandMiniMap.s,Scene_CommandMiniMap,0x80130540,0xE +asm/non_matchings/code/z_scene/Scene_Command1D.s,Scene_Command1D,0x80130578,0x4 +asm/non_matchings/code/z_scene/Scene_CommandMiniMapCompassInfo.s,Scene_CommandMiniMapCompassInfo,0x80130588,0xA +asm/non_matchings/code/z_scene/Scene_CommandSetRegionVisitedFlag.s,Scene_CommandSetRegionVisitedFlag,0x801305B0,0x31 +asm/non_matchings/code/z_scene/Scene_CommandAnimatedMaterials.s,Scene_CommandAnimatedMaterials,0x80130674,0xC asm/non_matchings/code/z_scene/Scene_SetExitFade.s,Scene_SetExitFade,0x801306A4,0x11 -asm/non_matchings/code/z_scene/Scene_ProcessHeader.s,Scene_ProcessHeader,0x801306E8,0x20 +asm/non_matchings/code/z_scene/Scene_ExecuteCommands.s,Scene_ExecuteCommands,0x801306E8,0x20 asm/non_matchings/code/z_scene/Entrance_Create.s,Entrance_Create,0x80130768,0x7 asm/non_matchings/code/z_scene/Entrance_CreateFromSpawn.s,Entrance_CreateFromSpawn,0x80130784,0xF -asm/non_matchings/code/z_scene_proc/Scene_ExecuteDrawConfig.s,Scene_ExecuteDrawConfig,0x801307C0,0xD +asm/non_matchings/code/z_scene_proc/Scene_Draw.s,Scene_Draw,0x801307C0,0xD asm/non_matchings/code/z_scene_proc/Scene_DrawConfigDefault.s,Scene_DrawConfigDefault,0x801307F4,0x10 asm/non_matchings/code/z_scene_proc/AnimatedMat_TexScroll.s,AnimatedMat_TexScroll,0x80130834,0x1B asm/non_matchings/code/z_scene_proc/AnimatedMat_DrawTexScroll.s,AnimatedMat_DrawTexScroll,0x801308A0,0x28 @@ -2051,7 +2051,7 @@ asm/non_matchings/code/z_skelanime/SkelAnime_Draw.s,SkelAnime_Draw,0x80134990,0x asm/non_matchings/code/z_skelanime/SkelAnime_DrawLimbSV2.s,SkelAnime_DrawLimbSV2,0x80134B54,0x9A asm/non_matchings/code/z_skelanime/SkelAnime_DrawFlex.s,SkelAnime_DrawFlex,0x80134DBC,0x90 asm/non_matchings/code/z_skelanime/SkelAnime_GetFrameData2.s,SkelAnime_GetFrameData2,0x80134FFC,0xF6 -asm/non_matchings/code/z_skelanime/Animation_GetLimbCount2.s,Animation_GetLimbCount2,0x801353D4,0x9 +asm/non_matchings/code/z_skelanime/Animation_GetLimbCountLegacy.s,Animation_GetLimbCountLegacy,0x801353D4,0x9 asm/non_matchings/code/z_skelanime/SkelAnime_GetTotalFrames2.s,SkelAnime_GetTotalFrames2,0x801353F8,0x9 asm/non_matchings/code/z_skelanime/SkelAnime_GetFrameCount2.s,SkelAnime_GetFrameCount2,0x8013541C,0xB asm/non_matchings/code/z_skelanime/SkelAnime_InterpFrameTable.s,SkelAnime_InterpFrameTable,0x80135448,0x120 @@ -2072,29 +2072,29 @@ asm/non_matchings/code/z_skelanime/AnimationContext_CopyTrue.s,AnimationContext_ asm/non_matchings/code/z_skelanime/AnimationContext_CopyFalse.s,AnimationContext_CopyFalse,0x80135DB8,0x21 asm/non_matchings/code/z_skelanime/AnimationContext_MoveActor.s,AnimationContext_MoveActor,0x80135E3C,0x2B asm/non_matchings/code/z_skelanime/AnimationContext_Update.s,AnimationContext_Update,0x80135EE8,0x28 -asm/non_matchings/code/z_skelanime/SkelAnime_InitLinkAnimetion.s,SkelAnime_InitLinkAnimetion,0x80135F88,0x48 -asm/non_matchings/code/z_skelanime/LinkAnimation_SetUpdateFunction.s,LinkAnimation_SetUpdateFunction,0x801360A8,0xE -asm/non_matchings/code/z_skelanime/LinkAnimation_Update.s,LinkAnimation_Update,0x801360E0,0x9 -asm/non_matchings/code/z_skelanime/LinkAnimation_Morph.s,LinkAnimation_Morph,0x80136104,0x2E -asm/non_matchings/code/z_skelanime/LinkAnimation_AnimateFrame.s,LinkAnimation_AnimateFrame,0x801361BC,0x33 -asm/non_matchings/code/z_skelanime/LinkAnimation_Loop.s,LinkAnimation_Loop,0x80136288,0x25 -asm/non_matchings/code/z_skelanime/LinkAnimation_Once.s,LinkAnimation_Once,0x8013631C,0x35 +asm/non_matchings/code/z_skelanime/SkelAnime_InitPlayerAnimetion.s,SkelAnime_InitPlayerAnimetion,0x80135F88,0x48 +asm/non_matchings/code/z_skelanime/PlayerAnimation_SetUpdateFunction.s,PlayerAnimation_SetUpdateFunction,0x801360A8,0xE +asm/non_matchings/code/z_skelanime/PlayerAnimation_Update.s,PlayerAnimation_Update,0x801360E0,0x9 +asm/non_matchings/code/z_skelanime/PlayerAnimation_Morph.s,PlayerAnimation_Morph,0x80136104,0x2E +asm/non_matchings/code/z_skelanime/PlayerAnimation_AnimateFrame.s,PlayerAnimation_AnimateFrame,0x801361BC,0x33 +asm/non_matchings/code/z_skelanime/PlayerAnimation_Loop.s,PlayerAnimation_Loop,0x80136288,0x25 +asm/non_matchings/code/z_skelanime/PlayerAnimation_Once.s,PlayerAnimation_Once,0x8013631C,0x35 asm/non_matchings/code/z_skelanime/Animation_SetMorph.s,Animation_SetMorph,0x801363F0,0x9 -asm/non_matchings/code/z_skelanime/LinkAnimation_Change.s,LinkAnimation_Change,0x80136414,0x5E -asm/non_matchings/code/z_skelanime/LinkAnimation_ChangeDefaultStop.s,LinkAnimation_ChangeDefaultStop,0x8013658C,0x18 -asm/non_matchings/code/z_skelanime/LinkAnimation_ChangePlaybackStop.s,LinkAnimation_ChangePlaybackStop,0x801365EC,0x19 -asm/non_matchings/code/z_skelanime/LinkAnimation_ChangeDefaultRepeat.s,LinkAnimation_ChangeDefaultRepeat,0x80136650,0x17 -asm/non_matchings/code/z_skelanime/LinkAnimation_ChangePlaybackRepeat.s,LinkAnimation_ChangePlaybackRepeat,0x801366AC,0x18 -asm/non_matchings/code/z_skelanime/LinkAnimation_CopyJointToMorph.s,LinkAnimation_CopyJointToMorph,0x8013670C,0xC -asm/non_matchings/code/z_skelanime/LinkAnimation_CopyMorphToJoint.s,LinkAnimation_CopyMorphToJoint,0x8013673C,0xC -asm/non_matchings/code/z_skelanime/LinkAnimation_LoadToMorph.s,LinkAnimation_LoadToMorph,0x8013676C,0x11 -asm/non_matchings/code/z_skelanime/LinkAnimation_LoadToJoint.s,LinkAnimation_LoadToJoint,0x801367B0,0x11 -asm/non_matchings/code/z_skelanime/LinkAnimation_InterpJointMorph.s,LinkAnimation_InterpJointMorph,0x801367F4,0xE -asm/non_matchings/code/z_skelanime/LinkAnimation_BlendToJoint.s,LinkAnimation_BlendToJoint,0x8013682C,0x28 -asm/non_matchings/code/z_skelanime/LinkAnimation_BlendToMorph.s,LinkAnimation_BlendToMorph,0x801368CC,0x28 -asm/non_matchings/code/z_skelanime/LinkAnimation_EndLoop.s,LinkAnimation_EndLoop,0x8013696C,0x9 +asm/non_matchings/code/z_skelanime/PlayerAnimation_Change.s,PlayerAnimation_Change,0x80136414,0x5E +asm/non_matchings/code/z_skelanime/PlayerAnimation_ChangeDefaultStop.s,PlayerAnimation_ChangeDefaultStop,0x8013658C,0x18 +asm/non_matchings/code/z_skelanime/PlayerAnimation_ChangePlaybackStop.s,PlayerAnimation_ChangePlaybackStop,0x801365EC,0x19 +asm/non_matchings/code/z_skelanime/PlayerAnimation_ChangeDefaultRepeat.s,PlayerAnimation_ChangeDefaultRepeat,0x80136650,0x17 +asm/non_matchings/code/z_skelanime/PlayerAnimation_ChangePlaybackRepeat.s,PlayerAnimation_ChangePlaybackRepeat,0x801366AC,0x18 +asm/non_matchings/code/z_skelanime/PlayerAnimation_CopyJointToMorph.s,PlayerAnimation_CopyJointToMorph,0x8013670C,0xC +asm/non_matchings/code/z_skelanime/PlayerAnimation_CopyMorphToJoint.s,PlayerAnimation_CopyMorphToJoint,0x8013673C,0xC +asm/non_matchings/code/z_skelanime/PlayerAnimation_LoadToMorph.s,PlayerAnimation_LoadToMorph,0x8013676C,0x11 +asm/non_matchings/code/z_skelanime/PlayerAnimation_LoadToJoint.s,PlayerAnimation_LoadToJoint,0x801367B0,0x11 +asm/non_matchings/code/z_skelanime/PlayerAnimation_InterpJointMorph.s,PlayerAnimation_InterpJointMorph,0x801367F4,0xE +asm/non_matchings/code/z_skelanime/PlayerAnimation_BlendToJoint.s,PlayerAnimation_BlendToJoint,0x8013682C,0x28 +asm/non_matchings/code/z_skelanime/PlayerAnimation_BlendToMorph.s,PlayerAnimation_BlendToMorph,0x801368CC,0x28 +asm/non_matchings/code/z_skelanime/PlayerAnimation_EndLoop.s,PlayerAnimation_EndLoop,0x8013696C,0x9 asm/non_matchings/code/z_skelanime/Animation_OnFrameImpl.s,Animation_OnFrameImpl,0x80136990,0x2E -asm/non_matchings/code/z_skelanime/LinkAnimation_OnFrame.s,LinkAnimation_OnFrame,0x80136A48,0xD +asm/non_matchings/code/z_skelanime/PlayerAnimation_OnFrame.s,PlayerAnimation_OnFrame,0x80136A48,0xD asm/non_matchings/code/z_skelanime/SkelAnime_Init.s,SkelAnime_Init,0x80136A7C,0x2D asm/non_matchings/code/z_skelanime/SkelAnime_InitFlex.s,SkelAnime_InitFlex,0x80136B30,0x2F asm/non_matchings/code/z_skelanime/SkelAnime_InitSkin.s,SkelAnime_InitSkin,0x80136BEC,0x26 @@ -2215,7 +2215,7 @@ asm/non_matchings/code/z_sub_s/SubS_ActorPathing_MoveWithGravity.s,SubS_ActorPat asm/non_matchings/code/z_sub_s/SubS_ActorPathing_MoveWithoutGravityReverse.s,SubS_ActorPathing_MoveWithoutGravityReverse,0x8013E07C,0xA asm/non_matchings/code/z_sub_s/SubS_ActorPathing_SetNextPoint.s,SubS_ActorPathing_SetNextPoint,0x8013E0A4,0x49 asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationBySpeedInfo.s,SubS_ChangeAnimationBySpeedInfo,0x8013E1C8,0x43 -asm/non_matchings/code/z_sub_s/SubS_StartActorCutscene.s,SubS_StartActorCutscene,0x8013E2D4,0x39 +asm/non_matchings/code/z_sub_s/SubS_StartCutscene.s,SubS_StartCutscene,0x8013E2D4,0x39 asm/non_matchings/code/z_sub_s/SubS_FillCutscenesList.s,SubS_FillCutscenesList,0x8013E3B8,0x3E asm/non_matchings/code/z_sub_s/SubS_ConstructPlane.s,SubS_ConstructPlane,0x8013E4B0,0x47 asm/non_matchings/code/z_sub_s/SubS_LineSegVsPlane.s,SubS_LineSegVsPlane,0x8013E5CC,0x1D @@ -2289,9 +2289,9 @@ asm/non_matchings/code/z_vismono/VisMono_DesaturateTLUT.s,VisMono_DesaturateTLUT asm/non_matchings/code/z_vismono/VisMono_DesaturateDList.s,VisMono_DesaturateDList,0x80141C34,0x8B asm/non_matchings/code/z_vismono/VisMono_Draw.s,VisMono_Draw,0x80141E60,0x7B asm/non_matchings/code/z_vismono/VisMono_DrawOld.s,VisMono_DrawOld,0x8014204C,0x1D -asm/non_matchings/code/code_801420C0/func_801420C0.s,func_801420C0,0x801420C0,0xD -asm/non_matchings/code/code_801420C0/func_801420F4.s,func_801420F4,0x801420F4,0x3 -asm/non_matchings/code/code_801420C0/func_80142100.s,func_80142100,0x80142100,0xD0 +asm/non_matchings/code/z_viszbuf/VisZbuf_Init.s,VisZbuf_Init,0x801420C0,0xD +asm/non_matchings/code/z_viszbuf/VisZbuf_Destroy.s,VisZbuf_Destroy,0x801420F4,0x3 +asm/non_matchings/code/z_viszbuf/VisZbuf_Draw.s,VisZbuf_Draw,0x80142100,0xD0 asm/non_matchings/code/z_vr_box/func_80142440.s,func_80142440,0x80142440,0x342 asm/non_matchings/code/z_vr_box/func_80143148.s,func_80143148,0x80143148,0x28 asm/non_matchings/code/z_vr_box/Skybox_Setup.s,Skybox_Setup,0x801431E8,0x4F @@ -2311,7 +2311,7 @@ asm/non_matchings/code/z_sram_NES/Sram_ResetSave.s,Sram_ResetSave,0x80144628,0x1 asm/non_matchings/code/z_sram_NES/Sram_GenerateRandomSaveFields.s,Sram_GenerateRandomSaveFields,0x80144684,0x83 asm/non_matchings/code/z_sram_NES/func_80144890.s,func_80144890,0x80144890,0x36 asm/non_matchings/code/z_sram_NES/Sram_InitDebugSave.s,Sram_InitDebugSave,0x80144968,0x4B -asm/non_matchings/code/z_sram_NES/func_80144A94.s,func_80144A94,0x80144A94,0xF9 +asm/non_matchings/code/z_sram_NES/Sram_ResetSaveFromMoonCrash.s,Sram_ResetSaveFromMoonCrash,0x80144A94,0xF9 asm/non_matchings/code/z_sram_NES/Sram_OpenSave.s,Sram_OpenSave,0x80144E78,0x17D asm/non_matchings/code/z_sram_NES/func_8014546C.s,func_8014546C,0x8014546C,0x8B asm/non_matchings/code/z_sram_NES/func_80145698.s,func_80145698,0x80145698,0x4D @@ -2338,7 +2338,7 @@ asm/non_matchings/code/z_message/func_80147520.s,func_80147520,0x80147520,0x11 asm/non_matchings/code/z_message/func_80147564.s,func_80147564,0x80147564,0x30 asm/non_matchings/code/z_message/Message_ShouldAdvance.s,Message_ShouldAdvance,0x80147624,0x44 asm/non_matchings/code/z_message/Message_ShouldAdvanceSilent.s,Message_ShouldAdvanceSilent,0x80147734,0x20 -asm/non_matchings/code/z_message/func_801477B4.s,func_801477B4,0x801477B4,0x19 +asm/non_matchings/code/z_message/Message_CloseTextbox.s,Message_CloseTextbox,0x801477B4,0x19 asm/non_matchings/code/z_message/func_80147818.s,func_80147818,0x80147818,0x1C0 asm/non_matchings/code/z_message/func_80147F18.s,func_80147F18,0x80147F18,0x190 asm/non_matchings/code/z_message/func_80148558.s,func_80148558,0x80148558,0x190 @@ -2367,7 +2367,7 @@ asm/non_matchings/code/z_message/func_80150A84.s,func_80150A84,0x80150A84,0xA1 asm/non_matchings/code/z_message/func_80150D08.s,func_80150D08,0x80150D08,0x1EA asm/non_matchings/code/z_message/func_801514B0.s,func_801514B0,0x801514B0,0x100 asm/non_matchings/code/z_message/Message_StartTextbox.s,Message_StartTextbox,0x801518B0,0x22 -asm/non_matchings/code/z_message/func_80151938.s,func_80151938,0x80151938,0x4C +asm/non_matchings/code/z_message/Message_ContinueTextbox.s,Message_ContinueTextbox,0x80151938,0x4C asm/non_matchings/code/z_message/func_80151A68.s,func_80151A68,0x80151A68,0x53 asm/non_matchings/code/z_message/func_80151BB4.s,func_80151BB4,0x80151BB4,0x3A asm/non_matchings/code/z_message/func_80151C9C.s,func_80151C9C,0x80151C9C,0x42 @@ -2384,8 +2384,8 @@ asm/non_matchings/code/z_message/func_80153750.s,func_80153750,0x80153750,0x1CB asm/non_matchings/code/z_message/func_80153E7C.s,func_80153E7C,0x80153E7C,0x1D asm/non_matchings/code/z_message/func_80153EF0.s,func_80153EF0,0x80153EF0,0xB9 asm/non_matchings/code/z_message/func_801541D4.s,func_801541D4,0x801541D4,0x961 -asm/non_matchings/code/z_message/func_80156758.s,func_80156758,0x80156758,0x2D -asm/non_matchings/code/z_message/func_8015680C.s,func_8015680C,0x8015680C,0x7A6 +asm/non_matchings/code/z_message/Message_Draw.s,Message_Draw,0x80156758,0x2D +asm/non_matchings/code/z_message/Message_Update.s,Message_Update,0x8015680C,0x7A6 asm/non_matchings/code/z_message/func_801586A4.s,func_801586A4,0x801586A4,0xC asm/non_matchings/code/z_message/Message_Init.s,Message_Init,0x801586D4,0x7F asm/non_matchings/code/z_message_nes/Message_FindMessageNES.s,Message_FindMessageNES,0x801588D0,0x2E @@ -2418,27 +2418,27 @@ asm/non_matchings/code/z_shrink_window/ShrinkWindow_Init.s,ShrinkWindow_Init,0x8 asm/non_matchings/code/z_shrink_window/ShrinkWindow_Destroy.s,ShrinkWindow_Destroy,0x80160CD4,0x4 asm/non_matchings/code/z_shrink_window/ShrinkWindow_Update.s,ShrinkWindow_Update,0x80160CE4,0x2D asm/non_matchings/code/z_shrink_window/ShrinkWindow_Draw.s,ShrinkWindow_Draw,0x80160D98,0xFA -asm/non_matchings/code/db_camera/func_80161180.s,func_80161180,0x80161180,0x7 -asm/non_matchings/code/db_camera/func_8016119C.s,func_8016119C,0x8016119C,0x24 -asm/non_matchings/code/db_camera/func_8016122C.s,func_8016122C,0x8016122C,0x23 -asm/non_matchings/code/db_camera/func_801612B8.s,func_801612B8,0x801612B8,0x1B8 -asm/non_matchings/code/db_camera/func_80161998.s,func_80161998,0x80161998,0x85 -asm/non_matchings/code/db_camera/func_80161BAC.s,func_80161BAC,0x80161BAC,0xD -asm/non_matchings/code/db_camera/func_80161BE0.s,func_80161BE0,0x80161BE0,0xB -asm/non_matchings/code/db_camera/func_80161C0C.s,func_80161C0C,0x80161C0C,0x5 -asm/non_matchings/code/db_camera/func_80161C20.s,func_80161C20,0x80161C20,0x8B -asm/non_matchings/code/db_camera/func_80161E4C.s,func_80161E4C,0x80161E4C,0xA0 -asm/non_matchings/code/db_camera/func_801620CC.s,func_801620CC,0x801620CC,0xAC -asm/non_matchings/code/db_camera/func_8016237C.s,func_8016237C,0x8016237C,0x1A -asm/non_matchings/code/db_camera/func_801623E4.s,func_801623E4,0x801623E4,0x42 -asm/non_matchings/code/db_camera/func_801624EC.s,func_801624EC,0x801624EC,0x14 -asm/non_matchings/code/db_camera/func_8016253C.s,func_8016253C,0x8016253C,0x120 -asm/non_matchings/code/db_camera/func_801629BC.s,func_801629BC,0x801629BC,0x25 -asm/non_matchings/code/db_camera/func_80162A50.s,func_80162A50,0x80162A50,0x16A -asm/non_matchings/code/db_camera/func_80162FF8.s,func_80162FF8,0x80162FF8,0x79 -asm/non_matchings/code/db_camera/func_801631DC.s,func_801631DC,0x801631DC,0x56 -asm/non_matchings/code/db_camera/func_80163334.s,func_80163334,0x80163334,0xCB -asm/non_matchings/code/db_camera/func_80163660.s,func_80163660,0x80163660,0x28 +asm/non_matchings/code/cutscene_camera/func_80161180.s,func_80161180,0x80161180,0x7 +asm/non_matchings/code/cutscene_camera/CutsceneCamera_Init.s,CutsceneCamera_Init,0x8016119C,0x24 +asm/non_matchings/code/cutscene_camera/CutsceneCamera_Interpolate.s,CutsceneCamera_Interpolate,0x8016122C,0x23 +asm/non_matchings/code/cutscene_camera/CutsceneCamera_ProcessSpline.s,CutsceneCamera_ProcessSpline,0x801612B8,0x1B8 +asm/non_matchings/code/cutscene_camera/CutsceneCamera_UpdateSplines.s,CutsceneCamera_UpdateSplines,0x80161998,0x85 +asm/non_matchings/code/cutscene_camera/func_80161BAC.s,func_80161BAC,0x80161BAC,0xD +asm/non_matchings/code/cutscene_camera/CutsceneCamera_SetState.s,CutsceneCamera_SetState,0x80161BE0,0xB +asm/non_matchings/code/cutscene_camera/CutsceneCamera_Reset.s,CutsceneCamera_Reset,0x80161C0C,0x5 +asm/non_matchings/code/cutscene_camera/func_80161C20.s,func_80161C20,0x80161C20,0x8B +asm/non_matchings/code/cutscene_camera/func_80161E4C.s,func_80161E4C,0x80161E4C,0xA0 +asm/non_matchings/code/cutscene_camera/func_801620CC.s,func_801620CC,0x801620CC,0xAC +asm/non_matchings/code/cutscene_camera/func_8016237C.s,func_8016237C,0x8016237C,0x1A +asm/non_matchings/code/cutscene_camera/func_801623E4.s,func_801623E4,0x801623E4,0x42 +asm/non_matchings/code/cutscene_camera/func_801624EC.s,func_801624EC,0x801624EC,0x14 +asm/non_matchings/code/cutscene_camera/func_8016253C.s,func_8016253C,0x8016253C,0x120 +asm/non_matchings/code/cutscene_camera/func_801629BC.s,func_801629BC,0x801629BC,0x25 +asm/non_matchings/code/cutscene_camera/func_80162A50.s,func_80162A50,0x80162A50,0x16A +asm/non_matchings/code/cutscene_camera/func_80162FF8.s,func_80162FF8,0x80162FF8,0x79 +asm/non_matchings/code/cutscene_camera/func_801631DC.s,func_801631DC,0x801631DC,0x56 +asm/non_matchings/code/cutscene_camera/func_80163334.s,func_80163334,0x80163334,0xCB +asm/non_matchings/code/cutscene_camera/func_80163660.s,func_80163660,0x80163660,0x28 asm/non_matchings/code/z_kaleido_manager/func_80163700.s,func_80163700,0x80163700,0x16 asm/non_matchings/code/z_kaleido_manager/func_80163758.s,func_80163758,0x80163758,0x17 asm/non_matchings/code/z_kaleido_manager/func_801637B4.s,func_801637B4,0x801637B4,0x14 @@ -2452,14 +2452,14 @@ asm/non_matchings/code/z_kaleido_scope_call/func_80163A58.s,func_80163A58,0x8016 asm/non_matchings/code/z_kaleido_scope_call/func_80163C0C.s,func_80163C0C,0x80163C0C,0x21 asm/non_matchings/code/z_fbdemo_dlftbls/Transition_Init.s,Transition_Init,0x80163C90,0x3C asm/non_matchings/code/z_fbdemo_dlftbls/Transition_Destroy.s,Transition_Destroy,0x80163D80,0x10 -asm/non_matchings/code/z_fbdemo/func_80163DC0.s,func_80163DC0,0x80163DC0,0xF3 -asm/non_matchings/code/z_fbdemo/func_8016418C.s,func_8016418C,0x8016418C,0x30 -asm/non_matchings/code/z_fbdemo/func_8016424C.s,func_8016424C,0x8016424C,0x23 -asm/non_matchings/code/z_fbdemo/func_801642D8.s,func_801642D8,0x801642D8,0x58 -asm/non_matchings/code/z_fbdemo/func_80164438.s,func_80164438,0x80164438,0x45 -asm/non_matchings/code/z_fbdemo/func_8016454C.s,func_8016454C,0x8016454C,0x4B -asm/non_matchings/code/z_fbdemo/func_80164678.s,func_80164678,0x80164678,0x4D -asm/non_matchings/code/z_fbdemo/func_801647AC.s,func_801647AC,0x801647AC,0x3 +asm/non_matchings/code/z_fbdemo/TransitionTile_InitGraphics.s,TransitionTile_InitGraphics,0x80163DC0,0xF3 +asm/non_matchings/code/z_fbdemo/TransitionTile_InitVtxData.s,TransitionTile_InitVtxData,0x8016418C,0x30 +asm/non_matchings/code/z_fbdemo/TransitionTile_Destroy.s,TransitionTile_Destroy,0x8016424C,0x23 +asm/non_matchings/code/z_fbdemo/TransitionTile_Init.s,TransitionTile_Init,0x801642D8,0x58 +asm/non_matchings/code/z_fbdemo/TransitionTile_SetVtx.s,TransitionTile_SetVtx,0x80164438,0x45 +asm/non_matchings/code/z_fbdemo/TransitionTile_Draw.s,TransitionTile_Draw,0x8016454C,0x4B +asm/non_matchings/code/z_fbdemo/TransitionTile_Suck.s,TransitionTile_Suck,0x80164678,0x4D +asm/non_matchings/code/z_fbdemo/TransitionTile_Update.s,TransitionTile_Update,0x801647AC,0x3 asm/non_matchings/code/z_fbdemo/func_801647B8.s,func_801647B8,0x801647B8,0x6 asm/non_matchings/code/z_fbdemo_fade/TransitionFade_Start.s,TransitionFade_Start,0x801647D0,0x17 asm/non_matchings/code/z_fbdemo_fade/TransitionFade_Init.s,TransitionFade_Init,0x8016482C,0xB @@ -2484,41 +2484,41 @@ asm/non_matchings/code/z_overlay/TransitionOverlay_Load.s,TransitionOverlay_Load asm/non_matchings/code/z_overlay/TransitionOverlay_Free.s,TransitionOverlay_Free,0x8016537C,0x2F asm/non_matchings/code/z_overlay/TransitionOverlay_ClearLoadInfo.s,TransitionOverlay_ClearLoadInfo,0x80165438,0x3 asm/non_matchings/code/z_overlay/TransitionOverlay_SetSegment.s,TransitionOverlay_SetSegment,0x80165444,0x7 -asm/non_matchings/code/z_play/func_80165460.s,func_80165460,0x80165460,0x6A -asm/non_matchings/code/z_play/func_80165608.s,func_80165608,0x80165608,0xA -asm/non_matchings/code/z_play/func_80165630.s,func_80165630,0x80165630,0xA -asm/non_matchings/code/z_play/func_80165658.s,func_80165658,0x80165658,0x5 -asm/non_matchings/code/z_play/func_8016566C.s,func_8016566C,0x8016566C,0x9 -asm/non_matchings/code/z_play/func_80165690.s,func_80165690,0x80165690,0x5 -asm/non_matchings/code/z_play/func_801656A4.s,func_801656A4,0x801656A4,0x1C5 -asm/non_matchings/code/z_play/func_80165DB8.s,func_80165DB8,0x80165DB8,0x5 -asm/non_matchings/code/z_play/func_80165DCC.s,func_80165DCC,0x80165DCC,0x9 -asm/non_matchings/code/z_play/func_80165DF0.s,func_80165DF0,0x80165DF0,0x5 -asm/non_matchings/code/z_play/func_80165E04.s,func_80165E04,0x80165E04,0x6 -asm/non_matchings/code/z_play/func_80165E1C.s,func_80165E1C,0x80165E1C,0x18 -asm/non_matchings/code/z_play/func_80165E7C.s,func_80165E7C,0x80165E7C,0x11 -asm/non_matchings/code/z_play/func_80165EC0.s,func_80165EC0,0x80165EC0,0x68 -asm/non_matchings/code/z_play/func_80166060.s,func_80166060,0x80166060,0x16 -asm/non_matchings/code/z_play/func_801660B8.s,func_801660B8,0x801660B8,0x21 +asm/non_matchings/code/z_play/Play_DrawMotionBlur.s,Play_DrawMotionBlur,0x80165460,0x6A +asm/non_matchings/code/z_play/Play_InitMotionBlur.s,Play_InitMotionBlur,0x80165608,0xA +asm/non_matchings/code/z_play/Play_DestroyMotionBlur.s,Play_DestroyMotionBlur,0x80165630,0xA +asm/non_matchings/code/z_play/Play_SetMotionBlurAlpha.s,Play_SetMotionBlurAlpha,0x80165658,0x5 +asm/non_matchings/code/z_play/Play_EnableMotionBlur.s,Play_EnableMotionBlur,0x8016566C,0x9 +asm/non_matchings/code/z_play/Play_DisableMotionBlur.s,Play_DisableMotionBlur,0x80165690,0x5 +asm/non_matchings/code/z_play/Play_ConvertRgba16ToIntensityImage.s,Play_ConvertRgba16ToIntensityImage,0x801656A4,0x1C5 +asm/non_matchings/code/z_play/Play_SetMotionBlurPriorityAlpha.s,Play_SetMotionBlurPriorityAlpha,0x80165DB8,0x5 +asm/non_matchings/code/z_play/Play_EnableMotionBlurPriority.s,Play_EnableMotionBlurPriority,0x80165DCC,0x9 +asm/non_matchings/code/z_play/Play_DisableMotionBlurPriority.s,Play_DisableMotionBlurPriority,0x80165DF0,0x5 +asm/non_matchings/code/z_play/Play_TriggerPictoPhoto.s,Play_TriggerPictoPhoto,0x80165E04,0x6 +asm/non_matchings/code/z_play/Play_TakePictoPhoto.s,Play_TakePictoPhoto,0x80165E1C,0x18 +asm/non_matchings/code/z_play/Play_ChooseDynamicTransition.s,Play_ChooseDynamicTransition,0x80165E7C,0x11 +asm/non_matchings/code/z_play/Play_SetupTransition.s,Play_SetupTransition,0x80165EC0,0x68 +asm/non_matchings/code/z_play/Play_ClearTransition.s,Play_ClearTransition,0x80166060,0x16 +asm/non_matchings/code/z_play/Play_SetFog.s,Play_SetFog,0x801660B8,0x21 asm/non_matchings/code/z_play/Play_Destroy.s,Play_Destroy,0x8016613C,0xA2 asm/non_matchings/code/z_play/Play_CompressI8ToI5.s,Play_CompressI8ToI5,0x801663C4,0xA0 asm/non_matchings/code/z_play/Play_DecompressI5ToI8.s,Play_DecompressI5ToI8,0x80166644,0x9C -asm/non_matchings/code/z_play/func_801668B4.s,func_801668B4,0x801668B4,0x2D -asm/non_matchings/code/z_play/func_80166968.s,func_80166968,0x80166968,0x72 -asm/non_matchings/code/z_play/func_80166B30.s,func_80166B30,0x80166B30,0x339 -asm/non_matchings/code/z_play/Play_Update.s,Play_Update,0x80167814,0x174 -asm/non_matchings/code/z_play/func_80167DE4.s,func_80167DE4,0x80167DE4,0x4A -asm/non_matchings/code/z_play/func_80167F0C.s,func_80167F0C,0x80167F0C,0x61 -asm/non_matchings/code/z_play/Play_Draw.s,Play_Draw,0x80168090,0x347 -asm/non_matchings/code/z_play/func_80168DAC.s,func_80168DAC,0x80168DAC,0x6E +asm/non_matchings/code/z_play/Play_GetWaterSurface.s,Play_GetWaterSurface,0x801668B4,0x2D +asm/non_matchings/code/z_play/Play_UpdateWaterCamera.s,Play_UpdateWaterCamera,0x80166968,0x72 +asm/non_matchings/code/z_play/Play_UpdateTransition.s,Play_UpdateTransition,0x80166B30,0x339 +asm/non_matchings/code/z_play/Play_UpdateMain.s,Play_UpdateMain,0x80167814,0x174 +asm/non_matchings/code/z_play/Play_Update.s,Play_Update,0x80167DE4,0x4A +asm/non_matchings/code/z_play/Play_PostWorldDraw.s,Play_PostWorldDraw,0x80167F0C,0x61 +asm/non_matchings/code/z_play/Play_DrawMain.s,Play_DrawMain,0x80168090,0x347 +asm/non_matchings/code/z_play/Play_Draw.s,Play_Draw,0x80168DAC,0x6E asm/non_matchings/code/z_play/Play_Main.s,Play_Main,0x80168F64,0x5A asm/non_matchings/code/z_play/Play_InCsMode.s,Play_InCsMode,0x801690CC,0xD -asm/non_matchings/code/z_play/func_80169100.s,func_80169100,0x80169100,0x3C -asm/non_matchings/code/z_play/func_801691F0.s,func_801691F0,0x801691F0,0xC -asm/non_matchings/code/z_play/Play_LoadScene.s,Play_LoadScene,0x80169220,0x17 -asm/non_matchings/code/z_play/func_8016927C.s,func_8016927C,0x8016927C,0x12 -asm/non_matchings/code/z_play/func_801692C4.s,func_801692C4,0x801692C4,0x44 -asm/non_matchings/code/z_play/Play_SceneInit.s,Play_SceneInit,0x801693D4,0x28 +asm/non_matchings/code/z_play/Play_GetFloorSurfaceImpl.s,Play_GetFloorSurfaceImpl,0x80169100,0x3C +asm/non_matchings/code/z_play/Play_GetFloorSurface.s,Play_GetFloorSurface,0x801691F0,0xC +asm/non_matchings/code/z_play/Play_LoadFile.s,Play_LoadFile,0x80169220,0x17 +asm/non_matchings/code/z_play/Play_InitEnvironment.s,Play_InitEnvironment,0x8016927C,0x12 +asm/non_matchings/code/z_play/Play_InitScene.s,Play_InitScene,0x801692C4,0x44 +asm/non_matchings/code/z_play/Play_SpawnScene.s,Play_SpawnScene,0x801693D4,0x28 asm/non_matchings/code/z_play/Play_GetScreenPos.s,Play_GetScreenPos,0x80169474,0x1A asm/non_matchings/code/z_play/Play_CreateSubCamera.s,Play_CreateSubCamera,0x801694DC,0x2A asm/non_matchings/code/z_play/Play_GetActiveCamId.s,Play_GetActiveCamId,0x80169584,0x3 @@ -2546,7 +2546,7 @@ asm/non_matchings/code/z_play/func_80169ECC.s,func_80169ECC,0x80169ECC,0xC asm/non_matchings/code/z_play/func_80169EFC.s,func_80169EFC,0x80169EFC,0x1F asm/non_matchings/code/z_play/func_80169F78.s,func_80169F78,0x80169F78,0x19 asm/non_matchings/code/z_play/func_80169FDC.s,func_80169FDC,0x80169FDC,0x8 -asm/non_matchings/code/z_play/func_80169FFC.s,func_80169FFC,0x80169FFC,0x8 +asm/non_matchings/code/z_play/Play_CamIsNotFixed.s,Play_CamIsNotFixed,0x80169FFC,0x8 asm/non_matchings/code/z_play/FrameAdvance_IsEnabled.s,FrameAdvance_IsEnabled,0x8016A01C,0x4 asm/non_matchings/code/z_play/func_8016A02C.s,func_8016A02C,0x8016A02C,0x20 asm/non_matchings/code/z_play/Play_IsUnderwater.s,Play_IsUnderwater,0x8016A0AC,0x2F @@ -2562,11 +2562,11 @@ asm/non_matchings/code/z_play_hireso/func_8016C344.s,func_8016C344,0x8016C344,0x asm/non_matchings/code/z_play_hireso/func_8016CD4C.s,func_8016CD4C,0x8016CD4C,0x5B0 asm/non_matchings/code/z_play_hireso/func_8016E40C.s,func_8016E40C,0x8016E40C,0x1A1 asm/non_matchings/code/z_play_hireso/func_8016EA90.s,func_8016EA90,0x8016EA90,0x1C6 -asm/non_matchings/code/z_play_hireso/func_8016F1A8.s,func_8016F1A8,0x8016F1A8,0xD1 +asm/non_matchings/code/z_play_hireso/BombersNotebook_Draw.s,BombersNotebook_Draw,0x8016F1A8,0xD1 asm/non_matchings/code/z_play_hireso/func_8016F4EC.s,func_8016F4EC,0x8016F4EC,0x2F -asm/non_matchings/code/z_play_hireso/func_8016F5A8.s,func_8016F5A8,0x8016F5A8,0x1B4 -asm/non_matchings/code/z_play_hireso/func_8016FC78.s,func_8016FC78,0x8016FC78,0x8 -asm/non_matchings/code/z_play_hireso/func_8016FC98.s,func_8016FC98,0x8016FC98,0x16 +asm/non_matchings/code/z_play_hireso/BombersNotebook_Update.s,BombersNotebook_Update,0x8016F5A8,0x1B4 +asm/non_matchings/code/z_play_hireso/BombersNotebook_Init.s,BombersNotebook_Init,0x8016FC78,0x8 +asm/non_matchings/code/z_play_hireso/BombersNotebook_Destroy.s,BombersNotebook_Destroy,0x8016FC98,0x16 asm/non_matchings/code/PreRender/PreRender_SetValuesSave.s,PreRender_SetValuesSave,0x8016FCF0,0xF asm/non_matchings/code/PreRender/PreRender_Init.s,PreRender_Init,0x8016FD2C,0xD asm/non_matchings/code/PreRender/PreRender_SetValues.s,PreRender_SetValues,0x8016FD60,0xD @@ -2593,43 +2593,43 @@ asm/non_matchings/code/PreRender/PreRender_ApplyFiltersSlowlyInit.s,PreRender_Ap asm/non_matchings/code/PreRender/PreRender_ApplyFiltersSlowlyDestroy.s,PreRender_ApplyFiltersSlowlyDestroy,0x80172078,0x13 asm/non_matchings/code/PreRender/func_801720C4.s,func_801720C4,0x801720C4,0xE asm/non_matchings/code/PreRender/func_801720FC.s,func_801720FC,0x801720FC,0x197 -asm/non_matchings/code/PreRender/func_80172758.s,func_80172758,0x80172758,0x26 -asm/non_matchings/code/TwoHeadGfxArena/THGA_Ct.s,THGA_Ct,0x801727F0,0x8 -asm/non_matchings/code/TwoHeadGfxArena/THGA_Dt.s,THGA_Dt,0x80172810,0x8 +asm/non_matchings/code/PreRender/Prerender_DrawBackground2D.s,Prerender_DrawBackground2D,0x80172758,0x26 +asm/non_matchings/code/TwoHeadGfxArena/THGA_Init.s,THGA_Init,0x801727F0,0x8 +asm/non_matchings/code/TwoHeadGfxArena/THGA_Destroy.s,THGA_Destroy,0x80172810,0x8 asm/non_matchings/code/TwoHeadGfxArena/THGA_IsCrash.s,THGA_IsCrash,0x80172830,0x8 asm/non_matchings/code/TwoHeadGfxArena/THGA_Init.s,THGA_Init,0x80172850,0x8 -asm/non_matchings/code/TwoHeadGfxArena/THGA_GetSize.s,THGA_GetSize,0x80172870,0x8 +asm/non_matchings/code/TwoHeadGfxArena/THGA_GetRemaining.s,THGA_GetRemaining,0x80172870,0x8 asm/non_matchings/code/TwoHeadGfxArena/THGA_GetHead.s,THGA_GetHead,0x80172890,0x8 asm/non_matchings/code/TwoHeadGfxArena/THGA_SetHead.s,THGA_SetHead,0x801728B0,0x8 asm/non_matchings/code/TwoHeadGfxArena/THGA_GetTail.s,THGA_GetTail,0x801728D0,0x8 -asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocStartArray8.s,THGA_AllocStartArray8,0x801728F0,0x9 -asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocStart8.s,THGA_AllocStart8,0x80172914,0x8 -asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocStart8Wrapper.s,THGA_AllocStart8Wrapper,0x80172934,0x8 -asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocEnd.s,THGA_AllocEnd,0x80172954,0x8 -asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocEndArray64.s,THGA_AllocEndArray64,0x80172974,0x9 -asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocEnd64.s,THGA_AllocEnd64,0x80172998,0x8 -asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocEndArray16.s,THGA_AllocEndArray16,0x801729B8,0x9 -asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocEnd16.s,THGA_AllocEnd16,0x801729DC,0x9 +asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocDisplayList.s,THGA_AllocDisplayList,0x801728F0,0x9 +asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocGfx.s,THGA_AllocGfx,0x80172914,0x8 +asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocGfx2.s,THGA_AllocGfx2,0x80172934,0x8 +asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocTail.s,THGA_AllocTail,0x80172954,0x8 +asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocMtxArray.s,THGA_AllocMtxArray,0x80172974,0x9 +asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocMtx.s,THGA_AllocMtx,0x80172998,0x8 +asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocVtxArray.s,THGA_AllocVtxArray,0x801729B8,0x9 +asm/non_matchings/code/TwoHeadGfxArena/THGA_AllocVtx.s,THGA_AllocVtx,0x801729DC,0x9 asm/non_matchings/code/TwoHeadArena/THA_GetHead.s,THA_GetHead,0x80172A00,0x3 asm/non_matchings/code/TwoHeadArena/THA_SetHead.s,THA_SetHead,0x80172A0C,0x3 asm/non_matchings/code/TwoHeadArena/THA_GetTail.s,THA_GetTail,0x80172A18,0x3 -asm/non_matchings/code/TwoHeadArena/THA_AllocStart.s,THA_AllocStart,0x80172A24,0x5 -asm/non_matchings/code/TwoHeadArena/THA_AllocStart1.s,THA_AllocStart1,0x80172A38,0x8 -asm/non_matchings/code/TwoHeadArena/THA_AllocEnd.s,THA_AllocEnd,0x80172A58,0x1C -asm/non_matchings/code/TwoHeadArena/THA_AllocEndAlign16.s,THA_AllocEndAlign16,0x80172AC8,0x8 -asm/non_matchings/code/TwoHeadArena/THA_AllocEndAlign.s,THA_AllocEndAlign,0x80172AE8,0x7 -asm/non_matchings/code/TwoHeadArena/THA_GetSize.s,THA_GetSize,0x80172B04,0x5 +asm/non_matchings/code/TwoHeadArena/THA_AllocHead.s,THA_AllocHead,0x80172A24,0x5 +asm/non_matchings/code/TwoHeadArena/THA_AllocHeadByte.s,THA_AllocHeadByte,0x80172A38,0x8 +asm/non_matchings/code/TwoHeadArena/THA_AllocTail.s,THA_AllocTail,0x80172A58,0x1C +asm/non_matchings/code/TwoHeadArena/THA_AllocTailAlign16.s,THA_AllocTailAlign16,0x80172AC8,0x8 +asm/non_matchings/code/TwoHeadArena/THA_AllocTailAlign.s,THA_AllocTailAlign,0x80172AE8,0x7 +asm/non_matchings/code/TwoHeadArena/THA_GetRemaining.s,THA_GetRemaining,0x80172B04,0x5 asm/non_matchings/code/TwoHeadArena/THA_IsCrash.s,THA_IsCrash,0x80172B18,0x9 -asm/non_matchings/code/TwoHeadArena/THA_Init.s,THA_Init,0x80172B3C,0x7 -asm/non_matchings/code/TwoHeadArena/THA_Ct.s,THA_Ct,0x80172B58,0x11 -asm/non_matchings/code/TwoHeadArena/THA_Dt.s,THA_Dt,0x80172B9C,0x9 -asm/non_matchings/code/code_80172BC0/AudioMgr_StopAllSfxExceptSystem.s,AudioMgr_StopAllSfxExceptSystem,0x80172BC0,0x1C -asm/non_matchings/code/audioMgr/func_80172C30.s,func_80172C30,0x80172C30,0xE -asm/non_matchings/code/audioMgr/AudioMgr_HandleRetrace.s,AudioMgr_HandleRetrace,0x80172C68,0x91 -asm/non_matchings/code/audioMgr/AudioMgr_HandlePRENMI.s,AudioMgr_HandlePRENMI,0x80172EAC,0x9 -asm/non_matchings/code/audioMgr/AudioMgr_ThreadEntry.s,AudioMgr_ThreadEntry,0x80172ED0,0x5E -asm/non_matchings/code/audioMgr/AudioMgr_Unlock.s,AudioMgr_Unlock,0x80173048,0xB -asm/non_matchings/code/audioMgr/AudioMgr_Init.s,AudioMgr_Init,0x80173074,0x2F +asm/non_matchings/code/TwoHeadArena/THA_Reset.s,THA_Reset,0x80172B3C,0x7 +asm/non_matchings/code/TwoHeadArena/THA_Init.s,THA_Init,0x80172B58,0x11 +asm/non_matchings/code/TwoHeadArena/THA_Destroy.s,THA_Destroy,0x80172B9C,0x9 +asm/non_matchings/code/audio_stop_all_sfx/AudioMgr_StopAllSfxExceptSystem.s,AudioMgr_StopAllSfxExceptSystem,0x80172BC0,0x1C +asm/non_matchings/code/audio_thread_manager/func_80172C30.s,func_80172C30,0x80172C30,0xE +asm/non_matchings/code/audio_thread_manager/AudioMgr_HandleRetrace.s,AudioMgr_HandleRetrace,0x80172C68,0x91 +asm/non_matchings/code/audio_thread_manager/AudioMgr_HandlePRENMI.s,AudioMgr_HandlePRENMI,0x80172EAC,0x9 +asm/non_matchings/code/audio_thread_manager/AudioMgr_ThreadEntry.s,AudioMgr_ThreadEntry,0x80172ED0,0x5E +asm/non_matchings/code/audio_thread_manager/AudioMgr_Unlock.s,AudioMgr_Unlock,0x80173048,0xB +asm/non_matchings/code/audio_thread_manager/AudioMgr_Init.s,AudioMgr_Init,0x80173074,0x2F asm/non_matchings/code/title_setup/Setup_SetRegs.s,Setup_SetRegs,0x80173130,0x6B asm/non_matchings/code/title_setup/Setup_InitImpl.s,Setup_InitImpl,0x801732DC,0x14 asm/non_matchings/code/title_setup/Setup_Destroy.s,Setup_Destroy,0x8017332C,0x3 @@ -2662,7 +2662,7 @@ asm/non_matchings/code/graph/Graph_FaultClient.s,Graph_FaultClient,0x80173D30,0x asm/non_matchings/code/graph/Graph_InitTHGA.s,Graph_InitTHGA,0x80173DAC,0x8 asm/non_matchings/code/graph/Graph_SetNextGfxPool.s,Graph_SetNextGfxPool,0x80173DCC,0x73 asm/non_matchings/code/graph/Graph_GetNextGameState.s,Graph_GetNextGameState,0x80173F98,0x32 -asm/non_matchings/code/graph/Graph_FaultAddrConvFunc.s,Graph_FaultAddrConvFunc,0x80174060,0x1C +asm/non_matchings/code/graph/Graph_FaultAddrConv.s,Graph_FaultAddrConv,0x80174060,0x1C asm/non_matchings/code/graph/Graph_Init.s,Graph_Init,0x801740D0,0x29 asm/non_matchings/code/graph/Graph_Destroy.s,Graph_Destroy,0x80174174,0xD asm/non_matchings/code/graph/Graph_TaskSet00.s,Graph_TaskSet00,0x801741A8,0xC1 @@ -2678,33 +2678,33 @@ asm/non_matchings/code/listalloc/func_80174AB4.s,func_80174AB4,0x80174AB4,0x1B asm/non_matchings/code/listalloc/func_80174B20.s,func_80174B20,0x80174B20,0x20 asm/non_matchings/code/listalloc/func_80174BA0.s,func_80174BA0,0x80174BA0,0x14 asm/non_matchings/code/main/main.s,main,0x80174BF0,0xC8 -asm/non_matchings/code/padmgr/Padmgr_GetControllerBitmask.s,Padmgr_GetControllerBitmask,0x80174F10,0x5 -asm/non_matchings/code/padmgr/func_80174F24.s,func_80174F24,0x80174F24,0x8 -asm/non_matchings/code/padmgr/func_80174F44.s,func_80174F44,0x80174F44,0xE -asm/non_matchings/code/padmgr/func_80174F7C.s,func_80174F7C,0x80174F7C,0x8 -asm/non_matchings/code/padmgr/func_80174F9C.s,func_80174F9C,0x80174F9C,0xE -asm/non_matchings/code/padmgr/Padmgr_GetEventCallback.s,Padmgr_GetEventCallback,0x80174FD4,0xD -asm/non_matchings/code/padmgr/func_80175008.s,func_80175008,0x80175008,0xD -asm/non_matchings/code/padmgr/Padmgr_SetEventCallback.s,Padmgr_SetEventCallback,0x8017503C,0xC -asm/non_matchings/code/padmgr/func_8017506C.s,func_8017506C,0x8017506C,0xC -asm/non_matchings/code/padmgr/Padmgr_Lock.s,Padmgr_Lock,0x8017509C,0xC -asm/non_matchings/code/padmgr/Padmgr_Unlock.s,Padmgr_Unlock,0x801750CC,0xC -asm/non_matchings/code/padmgr/func_801750FC.s,func_801750FC,0x801750FC,0x9A -asm/non_matchings/code/padmgr/func_80175364.s,func_80175364,0x80175364,0x34 -asm/non_matchings/code/padmgr/func_80175434.s,func_80175434,0x80175434,0x6 -asm/non_matchings/code/padmgr/func_8017544C.s,func_8017544C,0x8017544C,0xA +asm/non_matchings/code/padmgr/PadMgr_GetValidControllersMask.s,PadMgr_GetValidControllersMask,0x80174F10,0x5 +asm/non_matchings/code/padmgr/PadMgr_SetRumbleRetraceCallback.s,PadMgr_SetRumbleRetraceCallback,0x80174F24,0x8 +asm/non_matchings/code/padmgr/PadMgr_UnsetRumbleRetraceCallback.s,PadMgr_UnsetRumbleRetraceCallback,0x80174F44,0xE +asm/non_matchings/code/padmgr/PadMgr_SetInputRetraceCallback.s,PadMgr_SetInputRetraceCallback,0x80174F7C,0x8 +asm/non_matchings/code/padmgr/PadMgr_UnsetInputRetraceCallback.s,PadMgr_UnsetInputRetraceCallback,0x80174F9C,0xE +asm/non_matchings/code/padmgr/PadMgr_AcquireSerialEventQueue.s,PadMgr_AcquireSerialEventQueue,0x80174FD4,0xD +asm/non_matchings/code/padmgr/PadMgr_VoiceAcquireSerialEventQueue.s,PadMgr_VoiceAcquireSerialEventQueue,0x80175008,0xD +asm/non_matchings/code/padmgr/PadMgr_ReleaseSerialEventQueue.s,PadMgr_ReleaseSerialEventQueue,0x8017503C,0xC +asm/non_matchings/code/padmgr/PadMgr_VoiceReleaseSerialEventQueue.s,PadMgr_VoiceReleaseSerialEventQueue,0x8017506C,0xC +asm/non_matchings/code/padmgr/PadMgr_LockPadData.s,PadMgr_LockPadData,0x8017509C,0xC +asm/non_matchings/code/padmgr/PadMgr_UnlockPadData.s,PadMgr_UnlockPadData,0x801750CC,0xC +asm/non_matchings/code/padmgr/PadMgr_UpdateRumble.s,PadMgr_UpdateRumble,0x801750FC,0x9A +asm/non_matchings/code/padmgr/PadMgr_RumbleStop.s,PadMgr_RumbleStop,0x80175364,0x34 +asm/non_matchings/code/padmgr/PadMgr_RumblePause.s,PadMgr_RumblePause,0x80175434,0x6 +asm/non_matchings/code/padmgr/PadMgr_RumbleSetSingle.s,PadMgr_RumbleSetSingle,0x8017544C,0xA asm/non_matchings/code/padmgr/PadMgr_RumbleSet.s,PadMgr_RumbleSet,0x80175474,0x13 asm/non_matchings/code/padmgr/PadMgr_ControllerHasRumblePak.s,PadMgr_ControllerHasRumblePak,0x801754C0,0x8 -asm/non_matchings/code/padmgr/Padmgr_CalcStickEdges.s,Padmgr_CalcStickEdges,0x801754E0,0xB1 -asm/non_matchings/code/padmgr/Padmgr_ParseState.s,Padmgr_ParseState,0x801757A4,0x86 -asm/non_matchings/code/padmgr/func_801759BC.s,func_801759BC,0x801759BC,0x49 -asm/non_matchings/code/padmgr/func_80175AE0.s,func_80175AE0,0x80175AE0,0x68 -asm/non_matchings/code/padmgr/Padmgr_Update.s,Padmgr_Update,0x80175C80,0x6F -asm/non_matchings/code/padmgr/Padmgr_Stop.s,Padmgr_Stop,0x80175E3C,0xB -asm/non_matchings/code/padmgr/func_80175E68.s,func_80175E68,0x80175E68,0x4C -asm/non_matchings/code/padmgr/Padmgr_GetInput.s,Padmgr_GetInput,0x80175F98,0xF -asm/non_matchings/code/padmgr/Padmgr_GetInput2.s,Padmgr_GetInput2,0x80175FD4,0xF -asm/non_matchings/code/padmgr/Padmgr_ThreadEntry.s,Padmgr_ThreadEntry,0x80176010,0x61 +asm/non_matchings/code/padmgr/PadMgr_AdjustInput.s,PadMgr_AdjustInput,0x801754E0,0xB1 +asm/non_matchings/code/padmgr/PadMgr_UpdateInputs.s,PadMgr_UpdateInputs,0x801757A4,0x86 +asm/non_matchings/code/padmgr/PadMgr_InitVoice.s,PadMgr_InitVoice,0x801759BC,0x49 +asm/non_matchings/code/padmgr/PadMgr_UpdateConnections.s,PadMgr_UpdateConnections,0x80175AE0,0x68 +asm/non_matchings/code/padmgr/PadMgr_HandleRetrace.s,PadMgr_HandleRetrace,0x80175C80,0x6F +asm/non_matchings/code/padmgr/PadMgr_HandlePreNMI.s,PadMgr_HandlePreNMI,0x80175E3C,0xB +asm/non_matchings/code/padmgr/PadMgr_GetInputNoLock.s,PadMgr_GetInputNoLock,0x80175E68,0x4C +asm/non_matchings/code/padmgr/PadMgr_GetInput.s,PadMgr_GetInput,0x80175F98,0xF +asm/non_matchings/code/padmgr/PadMgr_GetInput2.s,PadMgr_GetInput2,0x80175FD4,0xF +asm/non_matchings/code/padmgr/PadMgr_ThreadEntry.s,PadMgr_ThreadEntry,0x80176010,0x61 asm/non_matchings/code/padmgr/PadMgr_Init.s,PadMgr_Init,0x80176194,0x3B asm/non_matchings/code/sched/Sched_SwapFramebuffer.s,Sched_SwapFramebuffer,0x80176280,0x25 asm/non_matchings/code/sched/Sched_RetraceUpdateFramebuffer.s,Sched_RetraceUpdateFramebuffer,0x80176314,0x14 @@ -2749,11 +2749,11 @@ asm/non_matchings/code/sys_cmpdma/func_80178A24.s,func_80178A24,0x80178A24,0x4 asm/non_matchings/code/sys_cmpdma/func_80178A34.s,func_80178A34,0x80178A34,0x18 asm/non_matchings/code/sys_cmpdma/func_80178A94.s,func_80178A94,0x80178A94,0xB asm/non_matchings/code/sys_cmpdma/func_80178AC0.s,func_80178AC0,0x80178AC0,0x70 -asm/non_matchings/code/sys_cmpdma/func_80178C80.s,func_80178C80,0x80178C80,0x3F -asm/non_matchings/code/sys_cmpdma/func_80178D7C.s,func_80178D7C,0x80178D7C,0xC -asm/non_matchings/code/sys_cmpdma/func_80178DAC.s,func_80178DAC,0x80178DAC,0x24 -asm/non_matchings/code/sys_cmpdma/func_80178E3C.s,func_80178E3C,0x80178E3C,0x10 -asm/non_matchings/code/sys_cmpdma/func_80178E7C.s,func_80178E7C,0x80178E7C,0x2D +asm/non_matchings/code/sys_cmpdma/CmpDma_GetFileInfo.s,CmpDma_GetFileInfo,0x80178C80,0x3F +asm/non_matchings/code/sys_cmpdma/CmpDma_Decompress.s,CmpDma_Decompress,0x80178D7C,0xC +asm/non_matchings/code/sys_cmpdma/CmpDma_LoadFileImpl.s,CmpDma_LoadFileImpl,0x80178DAC,0x24 +asm/non_matchings/code/sys_cmpdma/CmpDma_LoadFile.s,CmpDma_LoadFile,0x80178E3C,0x10 +asm/non_matchings/code/sys_cmpdma/CmpDma_LoadAllFiles.s,CmpDma_LoadAllFiles,0x80178E7C,0x2D asm/non_matchings/code/sys_initial_check/Check_WriteRGBA16Pixel.s,Check_WriteRGBA16Pixel,0x80178F30,0xC asm/non_matchings/code/sys_initial_check/Check_WriteI4Pixel.s,Check_WriteI4Pixel,0x80178F60,0x10 asm/non_matchings/code/sys_initial_check/Check_DrawI4Texture.s,Check_DrawI4Texture,0x80178FA0,0x3C @@ -2959,8 +2959,8 @@ asm/non_matchings/code/c_keyframe/func_801853C8.s,func_801853C8,0x801853C8,0x26 asm/non_matchings/code/c_keyframe/func_80185460.s,func_80185460,0x80185460,0x80 asm/non_matchings/code/sys_slowly/Slowly_Main.s,Slowly_Main,0x80185660,0x27 asm/non_matchings/code/sys_slowly/Slowly_ThreadEntry.s,Slowly_ThreadEntry,0x801856FC,0x8 -asm/non_matchings/code/sys_slowly/Slowly_Start.s,Slowly_Start,0x8018571C,0x21 -asm/non_matchings/code/sys_slowly/Slowly_Stop.s,Slowly_Stop,0x801857A0,0x8 +asm/non_matchings/code/sys_slowly/Slowly_Init.s,Slowly_Init,0x8018571C,0x21 +asm/non_matchings/code/sys_slowly/Slowly_Destroy.s,Slowly_Destroy,0x801857A0,0x8 asm/non_matchings/code/sys_flashrom/func_801857C0.s,func_801857C0,0x801857C0,0x4 asm/non_matchings/code/sys_flashrom/func_801857D0.s,func_801857D0,0x801857D0,0x25 asm/non_matchings/code/sys_flashrom/func_80185864.s,func_80185864,0x80185864,0x29 @@ -3283,42 +3283,42 @@ asm/non_matchings/code/audio_effects/AudioEffects_NoteVibratoInit.s,AudioEffects asm/non_matchings/code/audio_effects/AudioEffects_NotePortamentoInit.s,AudioEffects_NotePortamentoInit,0x80197138,0xB asm/non_matchings/code/audio_effects/AudioEffects_AdsrInit.s,AudioEffects_AdsrInit,0x80197164,0x9 asm/non_matchings/code/audio_effects/AudioEffects_AdsrUpdate.s,AudioEffects_AdsrUpdate,0x80197188,0xD2 -asm/non_matchings/code/audio_seqplayer/AudioSeq_GetScriptControlFlowArgument.s,AudioSeq_GetScriptControlFlowArgument,0x801974D0,0x1A -asm/non_matchings/code/audio_seqplayer/AudioSeq_HandleScriptFlowControl.s,AudioSeq_HandleScriptFlowControl,0x80197538,0x77 -asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequenceChannel.s,AudioSeq_InitSequenceChannel,0x80197714,0x5B -asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqChannelSetLayer.s,AudioSeq_SeqChannelSetLayer,0x80197880,0x56 -asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerDisable.s,AudioSeq_SeqLayerDisable,0x801979D8,0x1F -asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerFree.s,AudioSeq_SeqLayerFree,0x80197A54,0x14 -asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelDisable.s,AudioSeq_SequenceChannelDisable,0x80197AA4,0x1C -asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerSetupChannels.s,AudioSeq_SequencePlayerSetupChannels,0x80197B14,0x3E -asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisableChannels.s,AudioSeq_SequencePlayerDisableChannels,0x80197C0C,0x20 -asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelEnable.s,AudioSeq_SequenceChannelEnable,0x80197C8C,0x26 -asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisableAsFinished.s,AudioSeq_SequencePlayerDisableAsFinished,0x80197D24,0xA -asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisable.s,AudioSeq_SequencePlayerDisable,0x80197D4C,0x2F -asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPushBack.s,AudioSeq_AudioListPushBack,0x80197E08,0x10 -asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPopBack.s,AudioSeq_AudioListPopBack,0x80197E48,0x10 -asm/non_matchings/code/audio_seqplayer/AudioSeq_InitLayerFreelist.s,AudioSeq_InitLayerFreelist,0x80197E88,0x28 -asm/non_matchings/code/audio_seqplayer/AudioSeq_ScriptReadU8.s,AudioSeq_ScriptReadU8,0x80197F28,0x5 -asm/non_matchings/code/audio_seqplayer/AudioSeq_ScriptReadS16.s,AudioSeq_ScriptReadS16,0x80197F3C,0xE -asm/non_matchings/code/audio_seqplayer/AudioSeq_ScriptReadCompressedU16.s,AudioSeq_ScriptReadCompressedU16,0x80197F74,0x10 -asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScript.s,AudioSeq_SeqLayerProcessScript,0x80197FB4,0x47 -asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScriptStep1.s,AudioSeq_SeqLayerProcessScriptStep1,0x801980D0,0x23 -asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScriptStep5.s,AudioSeq_SeqLayerProcessScriptStep5,0x8019815C,0x40 -asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScriptStep2.s,AudioSeq_SeqLayerProcessScriptStep2,0x8019825C,0xF9 -asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScriptStep4.s,AudioSeq_SeqLayerProcessScriptStep4,0x80198640,0x1A8 -asm/non_matchings/code/audio_seqplayer/AudioSeq_SeqLayerProcessScriptStep3.s,AudioSeq_SeqLayerProcessScriptStep3,0x80198CE0,0x105 -asm/non_matchings/code/audio_seqplayer/AudioSeq_SetChannelPriorities.s,AudioSeq_SetChannelPriorities,0x801990F4,0xC -asm/non_matchings/code/audio_seqplayer/AudioSeq_GetInstrument.s,AudioSeq_GetInstrument,0x80199124,0x1D -asm/non_matchings/code/audio_seqplayer/AudioSeq_SetInstrument.s,AudioSeq_SetInstrument,0x80199198,0x2B -asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelSetVolume.s,AudioSeq_SequenceChannelSetVolume,0x80199244,0x9 -asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelProcessScript.s,AudioSeq_SequenceChannelProcessScript,0x80199268,0x395 -asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerProcessSequence.s,AudioSeq_SequencePlayerProcessSequence,0x8019A0BC,0x260 -asm/non_matchings/code/audio_seqplayer/AudioSeq_ProcessSequences.s,AudioSeq_ProcessSequences,0x8019AA3C,0x2D -asm/non_matchings/code/audio_seqplayer/AudioSeq_SkipForwardSequence.s,AudioSeq_SkipForwardSequence,0x8019AAF0,0x14 -asm/non_matchings/code/audio_seqplayer/AudioSeq_ResetSequencePlayer.s,AudioSeq_ResetSequencePlayer,0x8019AB40,0x34 -asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayerChannels.s,AudioSeq_InitSequencePlayerChannels,0x8019AC10,0x37 -asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayer.s,AudioSeq_InitSequencePlayer,0x8019ACEC,0x34 -asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayers.s,AudioSeq_InitSequencePlayers,0x8019ADBC,0x21 +asm/non_matchings/code/audio_seqplayer/AudioScript_GetScriptControlFlowArgument.s,AudioScript_GetScriptControlFlowArgument,0x801974D0,0x1A +asm/non_matchings/code/audio_seqplayer/AudioScript_HandleScriptFlowControl.s,AudioScript_HandleScriptFlowControl,0x80197538,0x77 +asm/non_matchings/code/audio_seqplayer/AudioScript_InitSequenceChannel.s,AudioScript_InitSequenceChannel,0x80197714,0x5B +asm/non_matchings/code/audio_seqplayer/AudioScript_SeqChannelSetLayer.s,AudioScript_SeqChannelSetLayer,0x80197880,0x56 +asm/non_matchings/code/audio_seqplayer/AudioScript_SeqLayerDisable.s,AudioScript_SeqLayerDisable,0x801979D8,0x1F +asm/non_matchings/code/audio_seqplayer/AudioScript_SeqLayerFree.s,AudioScript_SeqLayerFree,0x80197A54,0x14 +asm/non_matchings/code/audio_seqplayer/AudioScript_SequenceChannelDisable.s,AudioScript_SequenceChannelDisable,0x80197AA4,0x1C +asm/non_matchings/code/audio_seqplayer/AudioScript_SequencePlayerSetupChannels.s,AudioScript_SequencePlayerSetupChannels,0x80197B14,0x3E +asm/non_matchings/code/audio_seqplayer/AudioScript_SequencePlayerDisableChannels.s,AudioScript_SequencePlayerDisableChannels,0x80197C0C,0x20 +asm/non_matchings/code/audio_seqplayer/AudioScript_SequenceChannelEnable.s,AudioScript_SequenceChannelEnable,0x80197C8C,0x26 +asm/non_matchings/code/audio_seqplayer/AudioScript_SequencePlayerDisableAsFinished.s,AudioScript_SequencePlayerDisableAsFinished,0x80197D24,0xA +asm/non_matchings/code/audio_seqplayer/AudioScript_SequencePlayerDisable.s,AudioScript_SequencePlayerDisable,0x80197D4C,0x2F +asm/non_matchings/code/audio_seqplayer/AudioScript_AudioListPushBack.s,AudioScript_AudioListPushBack,0x80197E08,0x10 +asm/non_matchings/code/audio_seqplayer/AudioScript_AudioListPopBack.s,AudioScript_AudioListPopBack,0x80197E48,0x10 +asm/non_matchings/code/audio_seqplayer/AudioScript_InitLayerFreelist.s,AudioScript_InitLayerFreelist,0x80197E88,0x28 +asm/non_matchings/code/audio_seqplayer/AudioScript_ScriptReadU8.s,AudioScript_ScriptReadU8,0x80197F28,0x5 +asm/non_matchings/code/audio_seqplayer/AudioScript_ScriptReadS16.s,AudioScript_ScriptReadS16,0x80197F3C,0xE +asm/non_matchings/code/audio_seqplayer/AudioScript_ScriptReadCompressedU16.s,AudioScript_ScriptReadCompressedU16,0x80197F74,0x10 +asm/non_matchings/code/audio_seqplayer/AudioScript_SeqLayerProcessScript.s,AudioScript_SeqLayerProcessScript,0x80197FB4,0x47 +asm/non_matchings/code/audio_seqplayer/AudioScript_SeqLayerProcessScriptStep1.s,AudioScript_SeqLayerProcessScriptStep1,0x801980D0,0x23 +asm/non_matchings/code/audio_seqplayer/AudioScript_SeqLayerProcessScriptStep5.s,AudioScript_SeqLayerProcessScriptStep5,0x8019815C,0x40 +asm/non_matchings/code/audio_seqplayer/AudioScript_SeqLayerProcessScriptStep2.s,AudioScript_SeqLayerProcessScriptStep2,0x8019825C,0xF9 +asm/non_matchings/code/audio_seqplayer/AudioScript_SeqLayerProcessScriptStep4.s,AudioScript_SeqLayerProcessScriptStep4,0x80198640,0x1A8 +asm/non_matchings/code/audio_seqplayer/AudioScript_SeqLayerProcessScriptStep3.s,AudioScript_SeqLayerProcessScriptStep3,0x80198CE0,0x105 +asm/non_matchings/code/audio_seqplayer/AudioScript_SetChannelPriorities.s,AudioScript_SetChannelPriorities,0x801990F4,0xC +asm/non_matchings/code/audio_seqplayer/AudioScript_GetInstrument.s,AudioScript_GetInstrument,0x80199124,0x1D +asm/non_matchings/code/audio_seqplayer/AudioScript_SetInstrument.s,AudioScript_SetInstrument,0x80199198,0x2B +asm/non_matchings/code/audio_seqplayer/AudioScript_SequenceChannelSetVolume.s,AudioScript_SequenceChannelSetVolume,0x80199244,0x9 +asm/non_matchings/code/audio_seqplayer/AudioScript_SequenceChannelProcessScript.s,AudioScript_SequenceChannelProcessScript,0x80199268,0x395 +asm/non_matchings/code/audio_seqplayer/AudioScript_SequencePlayerProcessSequence.s,AudioScript_SequencePlayerProcessSequence,0x8019A0BC,0x260 +asm/non_matchings/code/audio_seqplayer/AudioScript_ProcessSequences.s,AudioScript_ProcessSequences,0x8019AA3C,0x2D +asm/non_matchings/code/audio_seqplayer/AudioScript_SkipForwardSequence.s,AudioScript_SkipForwardSequence,0x8019AAF0,0x14 +asm/non_matchings/code/audio_seqplayer/AudioScript_ResetSequencePlayer.s,AudioScript_ResetSequencePlayer,0x8019AB40,0x34 +asm/non_matchings/code/audio_seqplayer/AudioScript_InitSequencePlayerChannels.s,AudioScript_InitSequencePlayerChannels,0x8019AC10,0x37 +asm/non_matchings/code/audio_seqplayer/AudioScript_InitSequencePlayer.s,AudioScript_InitSequencePlayer,0x8019ACEC,0x34 +asm/non_matchings/code/audio_seqplayer/AudioScript_InitSequencePlayers.s,AudioScript_InitSequencePlayers,0x8019ADBC,0x21 asm/non_matchings/code/code_8019AE40/func_8019AE40.s,func_8019AE40,0x8019AE40,0x1C asm/non_matchings/code/code_8019AEC0/func_8019AEC0.s,func_8019AEC0,0x8019AEC0,0x10 asm/non_matchings/code/code_8019AF00/AudioOcarina_ReadControllerInput.s,AudioOcarina_ReadControllerInput,0x8019AF00,0x16 @@ -3361,7 +3361,7 @@ asm/non_matchings/code/code_8019AF00/AudioOcarina_TerminaWallGenerateNotes.s,Aud asm/non_matchings/code/code_8019AF00/AudioOcarina_MemoryGameInit.s,AudioOcarina_MemoryGameInit,0x8019D488,0x1C asm/non_matchings/code/code_8019AF00/AudioOcarina_MemoryGameNextNote.s,AudioOcarina_MemoryGameNextNote,0x8019D4F8,0x42 asm/non_matchings/code/code_8019AF00/AudioOcarina_Update.s,AudioOcarina_Update,0x8019D600,0x56 -asm/non_matchings/code/code_8019AF00/AudioOcarina_PlayLongScarecrowAfterCredits.s,AudioOcarina_PlayLongScarecrowAfterCredits,0x8019D758,0x43 +asm/non_matchings/code/code_8019AF00/AudioOcarina_PlayLongScarecrowSong.s,AudioOcarina_PlayLongScarecrowSong,0x8019D758,0x43 asm/non_matchings/code/code_8019AF00/AudioOcarina_SetCustomSequence.s,AudioOcarina_SetCustomSequence,0x8019D864,0x14 asm/non_matchings/code/code_8019AF00/AudioOcarina_PlayCustomSequence.s,AudioOcarina_PlayCustomSequence,0x8019D8B4,0xC asm/non_matchings/code/code_8019AF00/AudioOcarina_CreateCustomSequence.s,AudioOcarina_CreateCustomSequence,0x8019D8E4,0x191 @@ -3373,7 +3373,7 @@ asm/non_matchings/code/code_8019AF00/Audio_Noop3.s,Audio_Noop3,0x8019E00C,0x2 asm/non_matchings/code/code_8019AF00/Audio_Update.s,Audio_Update,0x8019E014,0x3A asm/non_matchings/code/code_8019AF00/Audio_Noop4.s,Audio_Noop4,0x8019E0FC,0x2 asm/non_matchings/code/code_8019AF00/Audio_Noop5.s,Audio_Noop5,0x8019E104,0x3 -asm/non_matchings/code/code_8019AF00/func_8019E110.s,func_8019E110,0x8019E110,0xF +asm/non_matchings/code/code_8019AF00/Audio_PlayMainBgm.s,Audio_PlayMainBgm,0x8019E110,0xF asm/non_matchings/code/code_8019AF00/AudioSfx_ComputeVolume.s,AudioSfx_ComputeVolume,0x8019E14C,0x76 asm/non_matchings/code/code_8019AF00/AudioSfx_ComputeReverb.s,AudioSfx_ComputeReverb,0x8019E324,0x63 asm/non_matchings/code/code_8019AF00/AudioSfx_ComputePanSigned.s,AudioSfx_ComputePanSigned,0x8019E4B0,0x61 @@ -3417,10 +3417,10 @@ asm/non_matchings/code/code_8019AF00/Audio_PlaySfxForRiver.s,Audio_PlaySfxForRiv asm/non_matchings/code/code_8019AF00/Audio_PlaySfxForWaterfall.s,Audio_PlaySfxForWaterfall,0x801A0048,0x29 asm/non_matchings/code/code_8019AF00/Audio_StepFreqLerp.s,Audio_StepFreqLerp,0x801A00EC,0xE asm/non_matchings/code/code_8019AF00/func_801A0124.s,func_801A0124,0x801A0124,0x18 -asm/non_matchings/code/code_8019AF00/func_801A0184.s,func_801A0184,0x801A0184,0x10 -asm/non_matchings/code/code_8019AF00/func_801A01C4.s,func_801A01C4,0x801A01C4,0x10 +asm/non_matchings/code/code_8019AF00/Audio_SetBgmVolumeOff.s,Audio_SetBgmVolumeOff,0x801A0184,0x10 +asm/non_matchings/code/code_8019AF00/Audio_SetBgmVolumeOn.s,Audio_SetBgmVolumeOn,0x801A01C4,0x10 asm/non_matchings/code/code_8019AF00/func_801A0204.s,func_801A0204,0x801A0204,0xD -asm/non_matchings/code/code_8019AF00/func_801A0238.s,func_801A0238,0x801A0238,0xD +asm/non_matchings/code/code_8019AF00/Audio_SetMainBgmVolume.s,Audio_SetMainBgmVolume,0x801A0238,0xD asm/non_matchings/code/code_8019AF00/Audio_SetGanonsTowerBgmVolumeLevel.s,Audio_SetGanonsTowerBgmVolumeLevel,0x801A026C,0x2B asm/non_matchings/code/code_8019AF00/Audio_SetGanonsTowerBgmVolume.s,Audio_SetGanonsTowerBgmVolume,0x801A0318,0x4E asm/non_matchings/code/code_8019AF00/Audio_LowerMainBgmVolume.s,Audio_LowerMainBgmVolume,0x801A0450,0x7 @@ -3459,12 +3459,12 @@ asm/non_matchings/code/code_8019AF00/Audio_StartMorningSceneSequence.s,Audio_Sta asm/non_matchings/code/code_8019AF00/Audio_PlaySceneSequence.s,Audio_PlaySceneSequence,0x801A25E4,0x23 asm/non_matchings/code/code_8019AF00/Audio_StartSceneSequence.s,Audio_StartSceneSequence,0x801A2670,0x42 asm/non_matchings/code/code_8019AF00/Audio_UpdateSceneSequenceResumePoint.s,Audio_UpdateSceneSequenceResumePoint,0x801A2778,0x1C -asm/non_matchings/code/code_8019AF00/func_801A27E8.s,func_801A27E8,0x801A27E8,0xD -asm/non_matchings/code/code_8019AF00/func_801A281C.s,func_801A281C,0x801A281C,0x6E -asm/non_matchings/code/code_8019AF00/func_801A29D4.s,func_801A29D4,0x801A29D4,0x79 -asm/non_matchings/code/code_8019AF00/func_801A2BB8.s,func_801A2BB8,0x801A2BB8,0x1A -asm/non_matchings/code/code_8019AF00/func_801A2C20.s,func_801A2C20,0x801A2C20,0x9 -asm/non_matchings/code/code_8019AF00/func_801A2C44.s,func_801A2C44,0x801A2C44,0x11 +asm/non_matchings/code/code_8019AF00/Audio_PlayBgmForSongOfStorms.s,Audio_PlayBgmForSongOfStorms,0x801A27E8,0xD +asm/non_matchings/code/code_8019AF00/Audio_ScaleTempoAndFreqForMainBgm.s,Audio_ScaleTempoAndFreqForMainBgm,0x801A281C,0x6E +asm/non_matchings/code/code_8019AF00/Audio_SetSeqTempoAndFreq.s,Audio_SetSeqTempoAndFreq,0x801A29D4,0x79 +asm/non_matchings/code/code_8019AF00/Audio_PlaySubBgm.s,Audio_PlaySubBgm,0x801A2BB8,0x1A +asm/non_matchings/code/code_8019AF00/Audio_StopSubBgm.s,Audio_StopSubBgm,0x801A2C20,0x9 +asm/non_matchings/code/code_8019AF00/Audio_IncreaseTempoForTimedMinigame.s,Audio_IncreaseTempoForTimedMinigame,0x801A2C44,0x11 asm/non_matchings/code/code_8019AF00/Audio_PlaySequenceInCutscene.s,Audio_PlaySequenceInCutscene,0x801A2C88,0x33 asm/non_matchings/code/code_8019AF00/Audio_StopSequenceInCutscene.s,Audio_StopSequenceInCutscene,0x801A2D54,0x23 asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s,Audio_IsSequencePlaying,0x801A2DE0,0x1D @@ -3510,7 +3510,7 @@ asm/non_matchings/code/code_8019AF00/Audio_SetSfxVolumeExceptSystemAndOcarinaBan asm/non_matchings/code/code_8019AF00/func_801A4428.s,func_801A4428,0x801A4428,0x1F asm/non_matchings/code/code_8019AF00/Audio_PreNMI.s,Audio_PreNMI,0x801A44A4,0x8 asm/non_matchings/code/code_8019AF00/Audio_ResetRequestedSceneSeqId.s,Audio_ResetRequestedSceneSeqId,0x801A44C4,0x4 -asm/non_matchings/code/code_8019AF00/func_801A44D4.s,func_801A44D4,0x801A44D4,0x89 +asm/non_matchings/code/code_8019AF00/Audio_ResetData.s,Audio_ResetData,0x801A44D4,0x89 asm/non_matchings/code/code_8019AF00/func_801A46F8.s,func_801A46F8,0x801A46F8,0x14 asm/non_matchings/code/code_8019AF00/func_801A4748.s,func_801A4748,0x801A4748,0x15 asm/non_matchings/code/code_8019AF00/func_801A479C.s,func_801A479C,0x801A479C,0x10 @@ -3520,32 +3520,32 @@ asm/non_matchings/code/code_8019AF00/Audio_PlayAmbience.s,Audio_PlayAmbience,0x8 asm/non_matchings/code/code_8019AF00/Audio_SetAmbienceRandomBend.s,Audio_SetAmbienceRandomBend,0x801A4B80,0x2C asm/non_matchings/code/code_8019AF00/Audio_Init.s,Audio_Init,0x801A4C30,0x9 asm/non_matchings/code/code_8019AF00/AudioSfx_Init.s,AudioSfx_Init,0x801A4C54,0x2B -asm/non_matchings/code/code_8019AF00/func_801A4D00.s,func_801A4D00,0x801A4D00,0x14 -asm/non_matchings/code/code_8019AF00/func_801A4D50.s,func_801A4D50,0x801A4D50,0x15 -asm/non_matchings/code/code_8019AF00/func_801A4DA4.s,func_801A4DA4,0x801A4DA4,0x14 -asm/non_matchings/code/code_8019AF00/func_801A4DF4.s,func_801A4DF4,0x801A4DF4,0x1C -asm/non_matchings/code/code_8019AF00/func_801A4E64.s,func_801A4E64,0x801A4E64,0x13 -asm/non_matchings/code/code_8019AF00/func_801A4EB0.s,func_801A4EB0,0x801A4EB0,0x2 -asm/non_matchings/code/code_8019AF00/func_801A4EB8.s,func_801A4EB8,0x801A4EB8,0x48 -asm/non_matchings/code/code_8019AF00/func_801A4FD8.s,func_801A4FD8,0x801A4FD8,0x2A -asm/non_matchings/code/code_8019AF00/func_801A5080.s,func_801A5080,0x801A5080,0x10 -asm/non_matchings/code/code_8019AF00/func_801A50C0.s,func_801A50C0,0x801A50C0,0x10 -asm/non_matchings/code/code_8019AF00/func_801A5100.s,func_801A5100,0x801A5100,0x3 -asm/non_matchings/code/code_8019AF00/func_801A510C.s,func_801A510C,0x801A510C,0x3 -asm/non_matchings/code/code_8019AF00/func_801A5118.s,func_801A5118,0x801A5118,0x36 -asm/non_matchings/code/code_801A51F0/func_801A51F0.s,func_801A51F0,0x801A51F0,0xE -asm/non_matchings/code/code_801A51F0/func_801A5228.s,func_801A5228,0x801A5228,0x5A -asm/non_matchings/code/code_801A51F0/func_801A5390.s,func_801A5390,0x801A5390,0x13 -asm/non_matchings/code/code_801A51F0/func_801A53DC.s,func_801A53DC,0x801A53DC,0x3 -asm/non_matchings/code/code_801A51F0/func_801A53E8.s,func_801A53E8,0x801A53E8,0xD -asm/non_matchings/code/code_801A51F0/func_801A541C.s,func_801A541C,0x801A541C,0x1B -asm/non_matchings/code/code_801A51F0/func_801A5488.s,func_801A5488,0x801A5488,0xF -asm/non_matchings/code/code_801A51F0/func_801A54C4.s,func_801A54C4,0x801A54C4,0x3 -asm/non_matchings/code/code_801A51F0/func_801A54D0.s,func_801A54D0,0x801A54D0,0x6C -asm/non_matchings/code/code_801A51F0/func_801A5680.s,func_801A5680,0x801A5680,0x62 -asm/non_matchings/code/code_801A51F0/func_801A5808.s,func_801A5808,0x801A5808,0x82 -asm/non_matchings/code/code_801A51F0/func_801A5A10.s,func_801A5A10,0x801A5A10,0x3 -asm/non_matchings/code/code_801A51F0/func_801A5A1C.s,func_801A5A1C,0x801A5A1C,0x69 +asm/non_matchings/code/code_8019AF00/Audio_InitSound.s,Audio_InitSound,0x801A4D00,0x14 +asm/non_matchings/code/code_8019AF00/Audio_ResetForAudioHeapStep3.s,Audio_ResetForAudioHeapStep3,0x801A4D50,0x15 +asm/non_matchings/code/code_8019AF00/Audio_ResetForAudioHeapStep2.s,Audio_ResetForAudioHeapStep2,0x801A4DA4,0x14 +asm/non_matchings/code/code_8019AF00/Audio_ResetForAudioHeapStep1.s,Audio_ResetForAudioHeapStep1,0x801A4DF4,0x1C +asm/non_matchings/code/code_8019AF00/Audio_UnusedReset.s,Audio_UnusedReset,0x801A4E64,0x13 +asm/non_matchings/code/voice_external/func_801A4EB0.s,func_801A4EB0,0x801A4EB0,0x2 +asm/non_matchings/code/voice_external/func_801A4EB8.s,func_801A4EB8,0x801A4EB8,0x48 +asm/non_matchings/code/voice_external/func_801A4FD8.s,func_801A4FD8,0x801A4FD8,0x2A +asm/non_matchings/code/voice_external/func_801A5080.s,func_801A5080,0x801A5080,0x10 +asm/non_matchings/code/voice_external/func_801A50C0.s,func_801A50C0,0x801A50C0,0x10 +asm/non_matchings/code/voice_external/func_801A5100.s,func_801A5100,0x801A5100,0x3 +asm/non_matchings/code/voice_external/func_801A510C.s,func_801A510C,0x801A510C,0x3 +asm/non_matchings/code/voice_external/func_801A5118.s,func_801A5118,0x801A5118,0x36 +asm/non_matchings/code/voice_internal/func_801A51F0.s,func_801A51F0,0x801A51F0,0xE +asm/non_matchings/code/voice_internal/func_801A5228.s,func_801A5228,0x801A5228,0x5A +asm/non_matchings/code/voice_internal/func_801A5390.s,func_801A5390,0x801A5390,0x13 +asm/non_matchings/code/voice_internal/func_801A53DC.s,func_801A53DC,0x801A53DC,0x3 +asm/non_matchings/code/voice_internal/func_801A53E8.s,func_801A53E8,0x801A53E8,0xD +asm/non_matchings/code/voice_internal/func_801A541C.s,func_801A541C,0x801A541C,0x1B +asm/non_matchings/code/voice_internal/func_801A5488.s,func_801A5488,0x801A5488,0xF +asm/non_matchings/code/voice_internal/func_801A54C4.s,func_801A54C4,0x801A54C4,0x3 +asm/non_matchings/code/voice_internal/func_801A54D0.s,func_801A54D0,0x801A54D0,0x6C +asm/non_matchings/code/voice_internal/func_801A5680.s,func_801A5680,0x801A5680,0x62 +asm/non_matchings/code/voice_internal/func_801A5808.s,func_801A5808,0x801A5808,0x82 +asm/non_matchings/code/voice_internal/AudioVoice_ResetData.s,AudioVoice_ResetData,0x801A5A10,0x3 +asm/non_matchings/code/voice_internal/func_801A5A1C.s,func_801A5A1C,0x801A5A1C,0x69 asm/non_matchings/code/code_801A5BD0/AudioSfx_MuteBanks.s,AudioSfx_MuteBanks,0x801A5BD0,0x16 asm/non_matchings/code/code_801A5BD0/AudioSfx_LowerBgmVolume.s,AudioSfx_LowerBgmVolume,0x801A5C28,0x19 asm/non_matchings/code/code_801A5BD0/AudioSfx_RestoreBgmVolume.s,AudioSfx_RestoreBgmVolume,0x801A5C8C,0x1C @@ -3568,21 +3568,21 @@ asm/non_matchings/code/code_801A5BD0/AudioSfx_StepBankLerp.s,AudioSfx_StepBankLe asm/non_matchings/code/code_801A5BD0/AudioSfx_ProcessActiveSfx.s,AudioSfx_ProcessActiveSfx,0x801A787C,0x1A asm/non_matchings/code/code_801A5BD0/AudioSfx_IsPlaying.s,AudioSfx_IsPlaying,0x801A78E4,0x1A asm/non_matchings/code/code_801A5BD0/AudioSfx_Reset.s,AudioSfx_Reset,0x801A794C,0x71 -asm/non_matchings/code/code_801A7B10/Audio_StartSequence.s,Audio_StartSequence,0x801A7B10,0x7D -asm/non_matchings/code/code_801A7B10/Audio_StopSequence.s,Audio_StopSequence,0x801A7D04,0x20 -asm/non_matchings/code/code_801A7B10/func_801A7D84.s,func_801A7D84,0x801A7D84,0x309 -asm/non_matchings/code/code_801A7B10/Audio_QueueSeqCmd.s,Audio_QueueSeqCmd,0x801A89A8,0xA -asm/non_matchings/code/code_801A7B10/func_801A89D0.s,func_801A89D0,0x801A89D0,0x20 -asm/non_matchings/code/code_801A7B10/Audio_GetActiveSequence.s,Audio_GetActiveSequence,0x801A8A50,0x1B -asm/non_matchings/code/code_801A7B10/func_801A8ABC.s,func_801A8ABC,0x801A8ABC,0x16 -asm/non_matchings/code/code_801A7B10/func_801A8B14.s,func_801A8B14,0x801A8B14,0x6 -asm/non_matchings/code/code_801A7B10/func_801A8B2C.s,func_801A8B2C,0x801A8B2C,0x29 -asm/non_matchings/code/code_801A7B10/Audio_SetVolumeScale.s,Audio_SetVolumeScale,0x801A8BD0,0x63 -asm/non_matchings/code/code_801A7B10/func_801A8D5C.s,func_801A8D5C,0x801A8D5C,0x283 -asm/non_matchings/code/code_801A7B10/func_801A9768.s,func_801A9768,0x801A9768,0x31 -asm/non_matchings/code/code_801A7B10/func_801A982C.s,func_801A982C,0x801A982C,0x63 -asm/non_matchings/code/code_801A7B10/func_801A99B8.s,func_801A99B8,0x801A99B8,0x2F -asm/non_matchings/code/code_801A7B10/func_801A9A74.s,func_801A9A74,0x801A9A74,0x27 +asm/non_matchings/code/sequence/AudioSeq_StartSequence.s,AudioSeq_StartSequence,0x801A7B10,0x7D +asm/non_matchings/code/sequence/AudioSeq_StopSequence.s,AudioSeq_StopSequence,0x801A7D04,0x20 +asm/non_matchings/code/sequence/AudioSeq_ProcessSeqCmd.s,AudioSeq_ProcessSeqCmd,0x801A7D84,0x309 +asm/non_matchings/code/sequence/AudioSeq_QueueSeqCmd.s,AudioSeq_QueueSeqCmd,0x801A89A8,0xA +asm/non_matchings/code/sequence/AudioSeq_ProcessSeqCmds.s,AudioSeq_ProcessSeqCmds,0x801A89D0,0x20 +asm/non_matchings/code/sequence/AudioSeq_GetActiveSeqId.s,AudioSeq_GetActiveSeqId,0x801A8A50,0x1B +asm/non_matchings/code/sequence/AudioSeq_IsSeqCmdNotQueued.s,AudioSeq_IsSeqCmdNotQueued,0x801A8ABC,0x16 +asm/non_matchings/code/sequence/AudioSeq_ResetSequenceRequests.s,AudioSeq_ResetSequenceRequests,0x801A8B14,0x6 +asm/non_matchings/code/sequence/AudioSeq_ReplaceSeqCmdSetupOpVolRestore.s,AudioSeq_ReplaceSeqCmdSetupOpVolRestore,0x801A8B2C,0x29 +asm/non_matchings/code/sequence/AudioSeq_SetVolumeScale.s,AudioSeq_SetVolumeScale,0x801A8BD0,0x63 +asm/non_matchings/code/sequence/AudioSeq_UpdateActiveSequences.s,AudioSeq_UpdateActiveSequences,0x801A8D5C,0x283 +asm/non_matchings/code/sequence/AudioSeq_UpdateAudioHeapReset.s,AudioSeq_UpdateAudioHeapReset,0x801A9768,0x31 +asm/non_matchings/code/sequence/AudioSeq_ResetReverb.s,AudioSeq_ResetReverb,0x801A982C,0x63 +asm/non_matchings/code/sequence/AudioSeq_ResetActiveSequences.s,AudioSeq_ResetActiveSequences,0x801A99B8,0x2F +asm/non_matchings/code/sequence/AudioSeq_ResetActiveSequencesAndVolume.s,AudioSeq_ResetActiveSequencesAndVolume,0x801A9A74,0x27 asm/non_matchings/code/jpegutils/JpegUtils_ProcessQuantizationTable.s,JpegUtils_ProcessQuantizationTable,0x801A9B10,0x1A asm/non_matchings/code/jpegutils/JpegUtils_ParseHuffmanCodesLengths.s,JpegUtils_ParseHuffmanCodesLengths,0x801A9B78,0x21 asm/non_matchings/code/jpegutils/JpegUtils_GetHuffmanCodes.s,JpegUtils_GetHuffmanCodes,0x801A9BFC,0x1B @@ -3598,4 +3598,4 @@ asm/non_matchings/code/jpegdecoder/JpegDecoder_ReadBits.s,JpegDecoder_ReadBits,0 asm/non_matchings/code/z_game_over/GameOver_Init.s,GameOver_Init,0x801AA610,0x5 asm/non_matchings/code/z_game_over/GameOver_FadeLights.s,GameOver_FadeLights,0x801AA624,0x1A asm/non_matchings/code/z_game_over/GameOver_Update.s,GameOver_Update,0x801AA68C,0x105 -asm/non_matchings/code/z_construct/func_801AAAA0.s,func_801AAAA0,0x801AAAA0,0x4 +asm/non_matchings/code/z_construct/Regs_InitData.s,Regs_InitData,0x801AAAA0,0x4 diff --git a/tools/weekeventregconvert.py b/tools/weekeventregconvert.py index e2092e595..b96696b46 100755 --- a/tools/weekeventregconvert.py +++ b/tools/weekeventregconvert.py @@ -5,36 +5,36 @@ import re weekEventReg = { ( 0 << 8) | 0x01: "WEEKEVENTREG_00_01", - ( 0 << 8) | 0x02: "WEEKEVENTREG_00_02", - ( 0 << 8) | 0x04: "WEEKEVENTREG_00_04", - ( 0 << 8) | 0x08: "WEEKEVENTREG_00_08", - ( 0 << 8) | 0x10: "WEEKEVENTREG_00_10", - ( 0 << 8) | 0x20: "WEEKEVENTREG_00_20", - ( 0 << 8) | 0x40: "WEEKEVENTREG_00_40", - ( 0 << 8) | 0x80: "WEEKEVENTREG_00_80", - ( 1 << 8) | 0x01: "WEEKEVENTREG_01_01", - ( 1 << 8) | 0x02: "WEEKEVENTREG_01_02", - ( 1 << 8) | 0x04: "WEEKEVENTREG_01_04", - ( 1 << 8) | 0x08: "WEEKEVENTREG_01_08", - ( 1 << 8) | 0x10: "WEEKEVENTREG_01_10", - ( 1 << 8) | 0x20: "WEEKEVENTREG_01_20", - ( 1 << 8) | 0x40: "WEEKEVENTREG_01_40", - ( 1 << 8) | 0x80: "WEEKEVENTREG_01_80", - ( 2 << 8) | 0x01: "WEEKEVENTREG_02_01", - ( 2 << 8) | 0x02: "WEEKEVENTREG_02_02", - ( 2 << 8) | 0x04: "WEEKEVENTREG_02_04", - ( 2 << 8) | 0x08: "WEEKEVENTREG_02_08", - ( 2 << 8) | 0x10: "WEEKEVENTREG_02_10", - ( 2 << 8) | 0x20: "WEEKEVENTREG_02_20", - ( 2 << 8) | 0x40: "WEEKEVENTREG_02_40", - ( 2 << 8) | 0x80: "WEEKEVENTREG_02_80", - ( 3 << 8) | 0x01: "WEEKEVENTREG_03_01", - ( 3 << 8) | 0x02: "WEEKEVENTREG_03_02", - ( 3 << 8) | 0x04: "WEEKEVENTREG_03_04", - ( 3 << 8) | 0x08: "WEEKEVENTREG_03_08", - ( 3 << 8) | 0x10: "WEEKEVENTREG_03_10", - ( 3 << 8) | 0x20: "WEEKEVENTREG_03_20", - ( 3 << 8) | 0x40: "WEEKEVENTREG_03_40", + ( 0 << 8) | 0x02: "WEEKEVENTREG_ENTERED_TERMINA_FIELD", + ( 0 << 8) | 0x04: "WEEKEVENTREG_ENTERED_IKANA_GRAVEYARD", + ( 0 << 8) | 0x08: "WEEKEVENTREG_ENTERED_ROMANI_RANCH", + ( 0 << 8) | 0x10: "WEEKEVENTREG_ENTERED_GORMAN_TRACK", + ( 0 << 8) | 0x20: "WEEKEVENTREG_ENTERED_MOUNTAIN_VILLAGE_WINTER", + ( 0 << 8) | 0x40: "WEEKEVENTREG_ENTERED_GORON_SHRINE", + ( 0 << 8) | 0x80: "WEEKEVENTREG_ENTERED_SNOWHEAD", + ( 1 << 8) | 0x01: "WEEKEVENTREG_ENTERED_SOUTHERN_SWAMP_POISONED", + ( 1 << 8) | 0x02: "WEEKEVENTREG_ENTERED_WOODFALL", + ( 1 << 8) | 0x04: "WEEKEVENTREG_ENTERED_DEKU_PALACE", + ( 1 << 8) | 0x08: "WEEKEVENTREG_ENTERED_GREAT_BAY_COAST", + ( 1 << 8) | 0x10: "WEEKEVENTREG_ENTERED_PIRATES_FORTRESS", + ( 1 << 8) | 0x20: "WEEKEVENTREG_ENTERED_ZORA_HALL", + ( 1 << 8) | 0x40: "WEEKEVENTREG_ENTERED_WATERFALL_RAPIDS", + ( 1 << 8) | 0x80: "WEEKEVENTREG_ENTERED_IKANA_CANYON", + ( 2 << 8) | 0x01: "WEEKEVENTREG_ENTERED_IKANA_CASTLE", + ( 2 << 8) | 0x02: "WEEKEVENTREG_ENTERED_STONE_TOWER", + ( 2 << 8) | 0x04: "WEEKEVENTREG_ENTERED_STONE_TOWER_INVERTED", + ( 2 << 8) | 0x08: "WEEKEVENTREG_ENTERED_EAST_CLOCK_TOWN", + ( 2 << 8) | 0x10: "WEEKEVENTREG_ENTERED_WEST_CLOCK_TOWN", + ( 2 << 8) | 0x20: "WEEKEVENTREG_ENTERED_NORTH_CLOCK_TOWN", + ( 2 << 8) | 0x40: "WEEKEVENTREG_ENTERED_WOODFALL_TEMPLE", + ( 2 << 8) | 0x80: "WEEKEVENTREG_ENTERED_SNOWHEAD_TEMPLE", + ( 3 << 8) | 0x01: "WEEKEVENTREG_ENTERED_PIRATES_FORTRESS_EXTERIOR", + ( 3 << 8) | 0x02: "WEEKEVENTREG_ENTERED_STONE_TOWER_TEMPLE", + ( 3 << 8) | 0x04: "WEEKEVENTREG_ENTERED_STONE_TOWER_TEMPLE_INVERTED", + ( 3 << 8) | 0x08: "WEEKEVENTREG_ENTERED_THE_MOON", + ( 3 << 8) | 0x10: "WEEKEVENTREG_ENTERED_MOON_DEKU_TRIAL", + ( 3 << 8) | 0x20: "WEEKEVENTREG_ENTERED_MOON_GORON_TRIAL", + ( 3 << 8) | 0x40: "WEEKEVENTREG_ENTERED_MOON_ZORA_TRIAL", ( 3 << 8) | 0x80: "WEEKEVENTREG_03_80", ( 4 << 8) | 0x01: "WEEKEVENTREG_04_01", ( 4 << 8) | 0x02: "WEEKEVENTREG_04_02", @@ -67,13 +67,13 @@ weekEventReg = { ( 7 << 8) | 0x10: "WEEKEVENTREG_07_10", ( 7 << 8) | 0x20: "WEEKEVENTREG_07_20", ( 7 << 8) | 0x40: "WEEKEVENTREG_07_40", - ( 7 << 8) | 0x80: "WEEKEVENTREG_07_80", + ( 7 << 8) | 0x80: "WEEKEVENTREG_ENTERED_WOODFALL_TEMPLE_PRISON", ( 8 << 8) | 0x01: "WEEKEVENTREG_08_01", ( 8 << 8) | 0x02: "WEEKEVENTREG_08_02", ( 8 << 8) | 0x04: "WEEKEVENTREG_08_04", ( 8 << 8) | 0x08: "WEEKEVENTREG_08_08", ( 8 << 8) | 0x10: "WEEKEVENTREG_08_10", - ( 8 << 8) | 0x20: "WEEKEVENTREG_08_20", + ( 8 << 8) | 0x20: "WEEKEVENTREG_RECEIVED_DOGGY_RACETRACK_HEART_PIECE", ( 8 << 8) | 0x40: "WEEKEVENTREG_08_40", ( 8 << 8) | 0x80: "WEEKEVENTREG_08_80", ( 9 << 8) | 0x01: "WEEKEVENTREG_09_01", @@ -113,9 +113,9 @@ weekEventReg = { (13 << 8) | 0x04: "WEEKEVENTREG_13_04", (13 << 8) | 0x08: "WEEKEVENTREG_13_08", (13 << 8) | 0x10: "WEEKEVENTREG_13_10", - (13 << 8) | 0x20: "WEEKEVENTREG_13_20", - (13 << 8) | 0x40: "WEEKEVENTREG_13_40", - (13 << 8) | 0x80: "WEEKEVENTREG_13_80", + (13 << 8) | 0x20: "WEEKEVENTREG_OCEANSIDE_SPIDER_HOUSE_BUYER_MOVED_IN", + (13 << 8) | 0x40: "WEEKEVENTREG_RECEIVED_OCEANSIDE_WALLET_UPGRADE", + (13 << 8) | 0x80: "WEEKEVENTREG_OCEANSIDE_SPIDER_HOUSE_COLLECTED_REWARD", (14 << 8) | 0x01: "WEEKEVENTREG_14_01", (14 << 8) | 0x02: "WEEKEVENTREG_14_02", (14 << 8) | 0x04: "WEEKEVENTREG_14_04", @@ -165,7 +165,7 @@ weekEventReg = { (19 << 8) | 0x40: "WEEKEVENTREG_19_40", (19 << 8) | 0x80: "WEEKEVENTREG_19_80", (20 << 8) | 0x01: "WEEKEVENTREG_20_01", - (20 << 8) | 0x02: "WEEKEVENTREG_20_02", + (20 << 8) | 0x02: "WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE", (20 << 8) | 0x04: "WEEKEVENTREG_20_04", (20 << 8) | 0x08: "WEEKEVENTREG_20_08", (20 << 8) | 0x10: "WEEKEVENTREG_20_10", @@ -275,14 +275,14 @@ weekEventReg = { (33 << 8) | 0x10: "WEEKEVENTREG_33_10", (33 << 8) | 0x20: "WEEKEVENTREG_33_20", (33 << 8) | 0x40: "WEEKEVENTREG_33_40", - (33 << 8) | 0x80: "WEEKEVENTREG_33_80", + (33 << 8) | 0x80: "WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE", (34 << 8) | 0x01: "WEEKEVENTREG_34_01", (34 << 8) | 0x02: "WEEKEVENTREG_34_02", (34 << 8) | 0x04: "WEEKEVENTREG_34_04", - (34 << 8) | 0x08: "WEEKEVENTREG_34_08", + (34 << 8) | 0x08: "WEEKEVENTREG_TALKED_SWAMP_SPIDER_HOUSE_MAN", (34 << 8) | 0x10: "WEEKEVENTREG_34_10", (34 << 8) | 0x20: "WEEKEVENTREG_34_20", - (34 << 8) | 0x40: "WEEKEVENTREG_34_40", + (34 << 8) | 0x40: "WEEKEVENTREG_RECEIVED_MASK_OF_TRUTH", (34 << 8) | 0x80: "WEEKEVENTREG_34_80", (35 << 8) | 0x01: "WEEKEVENTREG_35_01", (35 << 8) | 0x02: "WEEKEVENTREG_35_02", @@ -425,7 +425,7 @@ weekEventReg = { (52 << 8) | 0x04: "WEEKEVENTREG_52_04", (52 << 8) | 0x08: "WEEKEVENTREG_52_08", (52 << 8) | 0x10: "WEEKEVENTREG_52_10", - (52 << 8) | 0x20: "WEEKEVENTREG_52_20", + (52 << 8) | 0x20: "WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE", (52 << 8) | 0x40: "WEEKEVENTREG_52_40", (52 << 8) | 0x80: "WEEKEVENTREG_52_80", (53 << 8) | 0x01: "WEEKEVENTREG_53_01", @@ -451,7 +451,7 @@ weekEventReg = { (55 << 8) | 0x10: "WEEKEVENTREG_55_10", (55 << 8) | 0x20: "WEEKEVENTREG_55_20", (55 << 8) | 0x40: "WEEKEVENTREG_55_40", - (55 << 8) | 0x80: "WEEKEVENTREG_55_80", + (55 << 8) | 0x80: "WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE", (56 << 8) | 0x01: "WEEKEVENTREG_56_01", (56 << 8) | 0x02: "WEEKEVENTREG_56_02", (56 << 8) | 0x04: "WEEKEVENTREG_56_04", @@ -508,8 +508,8 @@ weekEventReg = { (62 << 8) | 0x20: "WEEKEVENTREG_62_20", (62 << 8) | 0x40: "WEEKEVENTREG_62_40", (62 << 8) | 0x80: "WEEKEVENTREG_62_80", - (63 << 8) | 0x01: "WEEKEVENTREG_63_01", - (63 << 8) | 0x02: "WEEKEVENTREG_63_02", + (63 << 8) | 0x01: "WEEKEVENTREG_KICKOUT_WAIT", + (63 << 8) | 0x02: "WEEKEVENTREG_KICKOUT_TIME_PASSED", (63 << 8) | 0x04: "WEEKEVENTREG_63_04", (63 << 8) | 0x08: "WEEKEVENTREG_63_08", (63 << 8) | 0x10: "WEEKEVENTREG_63_10", @@ -523,12 +523,12 @@ weekEventReg = { (64 << 8) | 0x10: "WEEKEVENTREG_64_10", (64 << 8) | 0x20: "WEEKEVENTREG_64_20", (64 << 8) | 0x40: "WEEKEVENTREG_64_40", - (64 << 8) | 0x80: "WEEKEVENTREG_64_80", - (65 << 8) | 0x01: "WEEKEVENTREG_65_01", - (65 << 8) | 0x02: "WEEKEVENTREG_65_02", - (65 << 8) | 0x04: "WEEKEVENTREG_65_04", - (65 << 8) | 0x08: "WEEKEVENTREG_65_08", - (65 << 8) | 0x10: "WEEKEVENTREG_65_10", + (64 << 8) | 0x80: "WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_DAY_1", + (65 << 8) | 0x01: "WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_NIGHT_1", + (65 << 8) | 0x02: "WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_DAY_2", + (65 << 8) | 0x04: "WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_NIGHT_2", + (65 << 8) | 0x08: "WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_DAY_3", + (65 << 8) | 0x10: "WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_NIGHT_3", (65 << 8) | 0x20: "WEEKEVENTREG_65_20", (65 << 8) | 0x40: "WEEKEVENTREG_65_40", (65 << 8) | 0x80: "WEEKEVENTREG_65_80", @@ -843,20 +843,20 @@ def applyChange(fileContents: str, compiledRegex: re.Pattern, callback) -> str: def updateCheck(fileContents: str) -> str: - # gSaveContext.save.weekEventReg[86] & 2 - checkRegex = re.compile(rf"gSaveContext.save.weekEventReg\[(?P{NUMBER_PATTERN})\]\s*\&\s*(?P{NUMBER_PATTERN})") + # gSaveContext.save.saveInfo.weekEventReg[86] & 2 + checkRegex = re.compile(rf"gSaveContext.save.saveInfo.weekEventReg\[(?P{NUMBER_PATTERN})\]\s*\&\s*(?P{NUMBER_PATTERN})") return applyChange(fileContents, checkRegex, getCheckMacro) def updateSet(fileContents: str) -> str: - # gSaveContext.save.weekEventReg[51] |= 0x10 - setRegex = re.compile(rf"gSaveContext.save.weekEventReg\[(?P{NUMBER_PATTERN})\]\s*\|=\s*(?P{NUMBER_PATTERN})") + # gSaveContext.save.saveInfo.weekEventReg[51] |= 0x10 + setRegex = re.compile(rf"gSaveContext.save.saveInfo.weekEventReg\[(?P{NUMBER_PATTERN})\]\s*\|=\s*(?P{NUMBER_PATTERN})") return applyChange(fileContents, setRegex, getSetMacro) def updateClear(fileContents: str) -> str: - # gSaveContext.save.weekEventReg[85] &= (u8)~0x80 - clearRegex = re.compile(rf"gSaveContext.save.weekEventReg\[(?P{NUMBER_PATTERN})\]\s*\&=\s*(\(u8\))?~(?P{NUMBER_PATTERN})") + # gSaveContext.save.saveInfo.weekEventReg[85] &= (u8)~0x80 + clearRegex = re.compile(rf"gSaveContext.save.saveInfo.weekEventReg\[(?P{NUMBER_PATTERN})\]\s*\&=\s*(\(u8\))?~(?P{NUMBER_PATTERN})") return applyChange(fileContents, clearRegex, getClearMacro) diff --git a/undefined_syms.txt b/undefined_syms.txt index 649b781ce..1e09ceaab 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -574,6 +574,22 @@ D_06001680 = 0x06001680; D_06000288 = 0x06000288; +// ovl_Bg_Keikoku_Spr + +D_06000100 = 0x06000100; +D_060001F8 = 0x060001F8; +D_060003F8 = 0x060003F8; +D_06000500 = 0x06000500; +D_060005F8 = 0x060005F8; + +/* ovl_Bg_Lotus */ +D_06000A20 = 0x06000A20; +D_06000040 = 0x06000040; + +/* ovl_Bg_Tobira01 */ +D_060011C0 = 0x060011C0; +D_06000088 = 0x06000088; + // ovl_Boss_01 D_06000C44 = 0x06000C44; @@ -724,6 +740,21 @@ D_060129F0 = 0x060129F0; D_06002D30 = 0x06002D30; D_06011458 = 0x06011458; +// ovl_Door_Spiral + +D_06000590 = 0x06000590; +D_060007A8 = 0x060007A8; +D_06000EA0 = 0x06000EA0; +D_060012C0 = 0x060012C0; +D_060014C8 = 0x060014C8; +D_06002110 = 0x06002110; +D_06004448 = 0x06004448; +D_060051B8 = 0x060051B8; +D_06006128 = 0x06006128; +D_06009278 = 0x06009278; +D_06012B70 = 0x06012B70; +D_06013EA8 = 0x06013EA8; + // ovl_Eff_Stk D_06008920 = 0x06008920; @@ -739,10 +770,6 @@ D_060111E8 = 0x060111E8; D_06012478 = 0x06012478; D_06012618 = 0x06012618; -// ovl_En_And - -D_0600B380 = 0x0600B380; - // ovl_En_Bal D_060005FC = 0x060005FC; @@ -780,16 +807,6 @@ D_0600CB2C = 0x0600CB2C; D_0600CB84 = 0x0600CB84; D_0600CBC0 = 0x0600CBC0; -// ovl_En_Dekubaba - -D_06000208 = 0x06000208; -D_060002B8 = 0x060002B8; -D_060010F0 = 0x060010F0; -D_06001330 = 0x06001330; -D_06001828 = 0x06001828; -D_06002A40 = 0x06002A40; -D_06003070 = 0x06003070; - // ovl_En_Dnh D_06002950 = 0x06002950; @@ -840,6 +857,55 @@ D_0600A344 = 0x0600A344; D_06001EFC = 0x06001EFC; D_0600A808 = 0x0600A808; +// ovl_En_Invadepoh + +D_06000080 = 0x06000080; +D_060003B0 = 0x060003B0; +D_06000550 = 0x06000550; +D_06000560 = 0x06000560; +D_06000608 = 0x06000608; +D_060006C8 = 0x060006C8; +D_06000720 = 0x06000720; +D_06000998 = 0x06000998; +D_06001560 = 0x06001560; +D_06001674 = 0x06001674; +D_06001BD8 = 0x06001BD8; +D_06001D80 = 0x06001D80; +D_060021C8 = 0x060021C8; +D_06002A8C = 0x06002A8C; +D_06004010 = 0x06004010; +D_06004264 = 0x06004264; +D_06004C30 = 0x06004C30; +D_06004E50 = 0x06004E50; +D_06004E98 = 0x06004E98; +D_06007328 = 0x06007328; +D_060080F0 = 0x060080F0; +D_06009E58 = 0x06009E58; +D_0600A174 = 0x0600A174; +D_0600FFC8 = 0x0600FFC8; +D_060107C8 = 0x060107C8; +D_06010FC8 = 0x06010FC8; +D_060117C8 = 0x060117C8; +D_06011AD8 = 0x06011AD8; +D_06011FC8 = 0x06011FC8; +D_060122D8 = 0x060122D8; +D_060127C8 = 0x060127C8; +D_06012AD8 = 0x06012AD8; +D_06012BC8 = 0x06012BC8; +D_06012FC8 = 0x06012FC8; +D_060132D8 = 0x060132D8; +D_060133C8 = 0x060133C8; +D_06013928 = 0x06013928; +D_06013AD8 = 0x06013AD8; +D_06014088 = 0x06014088; +D_060142D8 = 0x060142D8; +D_06014AD8 = 0x06014AD8; +D_06014ED8 = 0x06014ED8; +D_060152D8 = 0x060152D8; +D_06015C28 = 0x06015C28; +D_060156D8 = 0x060156D8; +D_06016720 = 0x06016720; + // ovl_En_Invadepoh_Demo D_06000080 = 0x06000080; @@ -980,11 +1046,6 @@ D_06001AA0 = 0x06001AA0; D_06000304 = 0x06000304; -// ovl_En_Stop_heishi - -D_06006C18 = 0x06006C18; -D_0600D640 = 0x0600D640; - // ovl_En_Takaraya D_06000968 = 0x06000968; @@ -1025,6 +1086,16 @@ D_06000D94 = 0x06000D94; D_06007650 = 0x06007650; D_0600D658 = 0x0600D658; +// ovl_Item_B_Heart + +D_06001290 = 0x06001290; +D_06001470 = 0x06001470; + +// ovl_Obj_Boyo + +D_06000300 = 0x06000300; +D_06000E88 = 0x06000E88; + // ovl_Obj_Mine D_06000030 = 0x06000030;